Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(cli): unblock release checksum generation (#3990)

Alberto Schiabel7c5e22c3ce1c
diff --git a/test/release-workflow.test.ts b/test/release-workflow.test.ts
index b023f5567..787eb3e3f 100644
--- a/test/release-workflow.test.ts
+++ b/test/release-workflow.test.ts
@@ -66,6 +66,12 @@ const verifyAssetsScript = readFileSync(
new URL('../.github/scripts/cli-release/verify-assets.sh', import.meta.url),
'utf8'
);
+const generateChecksumsScriptUrl = new URL(
+ '../ts/packages/cli/scripts/generate-checksums.ts',
+ import.meta.url
+);
+const generateChecksumsScriptPath = generateChecksumsScriptUrl.pathname;
+const generateChecksumsScript = readFileSync(generateChecksumsScriptUrl, 'utf8');
function requireMatch(text, pattern, label) {
const match = text.match(pattern);
@@ -527,6 +533,46 @@ if (!(packageSkillsIdx < generateChecksumsIdx)) {
);
}
+if (
+ !generateChecksumsScript.includes("from './_teardown'") ||
+ generateChecksumsScript.includes("from './_shared'")
+) {
+ throw new Error(
+ 'CLI checksum generation must use the dependency-light teardown without loading CLI runtime helpers'
+ );
+}
+
+// The release job runs checksum generation in a fresh checkout where workspace packages have not
+// been built. Exercise the script from an unrelated working directory to prevent imports from
+// pulling in the CLI runtime and its unbuilt @composio/core dependency.
+{
+ const fixtureDir = mkdtempSync(join(tmpdir(), 'composio-cli-checksums-'));
+ try {
+ const binariesDir = join(fixtureDir, 'dist/binaries');
+ mkdirSync(binariesDir, { recursive: true });
+ writeFileSync(join(binariesDir, 'composio-linux-x64.zip'), 'release archive fixture\n');
+
+ const result = spawnSync(process.execPath, [generateChecksumsScriptPath], {
+ cwd: fixtureDir,
+ encoding: 'utf8',
+ env: process.env,
+ });
+
+ if (result.status !== 0) {
+ throw new Error(
+ `CLI checksum generation must run without built workspace packages\nstdout:\n${result.stdout}\nstderr:\n${result.stderr}`
+ );
+ }
+
+ const checksums = readFileSync(join(binariesDir, 'checksums.txt'), 'utf8');
+ if (!/^[a-f0-9]{64} composio-linux-x64\.zip\n$/.test(checksums)) {
+ throw new Error(`CLI checksum generation wrote an invalid manifest:\n${checksums}`);
+ }
+ } finally {
+ rmSync(fixtureDir, { recursive: true, force: true });
+ }
+}
+
// Per-tag concurrency prevents two runs clobbering the same release without serializing betas.
if (!buildCliWorkflow.includes('group: cli-release-${{ needs.prepare.outputs.release_tag }}')) {
throw new Error(
diff --git a/ts/packages/cli/scripts/_shared.ts b/ts/packages/cli/scripts/_shared.ts
index 99f743598..4be1fcb15 100644
--- a/ts/packages/cli/scripts/_shared.ts
+++ b/ts/packages/cli/scripts/_shared.ts
@@ -2,11 +2,12 @@ import { builtinModules } from 'node:module';
import { chmod, copyFile, mkdir, readdir, rm, stat, writeFile } from 'node:fs/promises';
import * as path from 'node:path';
import process from 'node:process';
-import { Cause, Effect, Exit } from 'effect';
-import type { Teardown } from '@effect/platform/Runtime';
+import { Effect } from 'effect';
import { RUN_COMPANION_MODULE_BASENAMES } from '../src/services/run-companion-modules';
import { materializeAcpAdaptersCache } from './_acp-adapters';
+export { teardown } from './_teardown';
+
const RUN_COMPANION_SERVICE_ENTRY_MAP = Object.fromEntries(
RUN_COMPANION_MODULE_BASENAMES.map(name => [`services/${name}`, `src/services/${name}.ts`])
) satisfies Record<string, string>;
@@ -295,18 +296,6 @@ const buildCompanionServiceBundles = async (outputDir: string): Promise<void> =>
}
};
-/**
- * Shared teardown for all CLI scripts.
- *
- * Exits with a non-zero code when the Effect program fails
- * (unless the failure is an interrupt-only cause).
- */
-export const teardown: Teardown = <E, A>(exit: Exit.Exit<E, A>, onExit: (code: number) => void) => {
- const shouldFail = Exit.isFailure(exit) && !Cause.isInterruptedOnly(exit.cause);
- const errorCode = Number(process.exitCode ?? 1);
- onExit(shouldFail ? errorCode : 0);
-};
-
export const buildCompanionModules = (outputDir: string) =>
Effect.gen(function* () {
yield* Effect.tryPromise(() => mkdir(outputDir, { recursive: true }));
diff --git a/ts/packages/cli/scripts/_teardown.ts b/ts/packages/cli/scripts/_teardown.ts
new file mode 100644
index 000000000..528256bb3
--- /dev/null
+++ b/ts/packages/cli/scripts/_teardown.ts
@@ -0,0 +1,15 @@
+import process from 'node:process';
+import { Cause, Exit } from 'effect';
+import type { Teardown } from '@effect/platform/Runtime';
+
+/**
+ * Shared teardown for CLI scripts.
+ *
+ * Keep this module dependency-light so release-only scripts can use it without
+ * loading the CLI runtime or requiring built workspace packages.
+ */
+export const teardown: Teardown = <E, A>(exit: Exit.Exit<E, A>, onExit: (code: number) => void) => {
+ const shouldFail = Exit.isFailure(exit) && !Cause.isInterruptedOnly(exit.cause);
+ const errorCode = Number(process.exitCode ?? 1);
+ onExit(shouldFail ? errorCode : 0);
+};
diff --git a/ts/packages/cli/scripts/generate-checksums.ts b/ts/packages/cli/scripts/generate-checksums.ts
index a779c8788..65c5a8591 100644
--- a/ts/packages/cli/scripts/generate-checksums.ts
+++ b/ts/packages/cli/scripts/generate-checksums.ts
@@ -17,7 +17,7 @@
import process from 'node:process';
import { Config, ConfigProvider, Console, Effect, Logger, Layer, LogLevel } from 'effect';
import { BunContext, BunRuntime } from '@effect/platform-bun';
-import { teardown } from './_shared';
+import { teardown } from './_teardown';
import { readdir, readFile, writeFile } from 'node:fs/promises';
import path from 'node:path';