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.

Skip CLI releases without platform binaries (#3045)

Rahul Tarak4589cd440616
diff --git a/ts/packages/cli/src/commands/upgrade.cmd.ts b/ts/packages/cli/src/commands/upgrade.cmd.ts
index 0ea5282fa..809682f03 100644
--- a/ts/packages/cli/src/commands/upgrade.cmd.ts
+++ b/ts/packages/cli/src/commands/upgrade.cmd.ts
@@ -1,5 +1,6 @@
import { Command } from '@effect/cli';
import { Effect } from 'effect';
+import { APP_VERSION } from 'src/constants';
import { UpgradeBinary } from 'src/services/upgrade-binary';
import { installSkillSafe } from 'src/effects/install-skill';
@@ -15,8 +16,6 @@ export const upgradeCmd = Command.make('upgrade', {}, () =>
Effect.gen(function* () {
const upgradeBinary = yield* UpgradeBinary;
const newReleaseTag = yield* upgradeBinary.upgrade();
- if (newReleaseTag) {
- yield* installSkillSafe({ releaseTag: newReleaseTag });
- }
+ yield* installSkillSafe({ releaseTag: newReleaseTag ?? `@composio/cli@${APP_VERSION}` });
})
).pipe(Command.withDescription('Upgrade your Composio CLI to the latest available version.'));
diff --git a/ts/packages/cli/src/services/upgrade-binary.ts b/ts/packages/cli/src/services/upgrade-binary.ts
index a7a80ed86..4c9071050 100644
--- a/ts/packages/cli/src/services/upgrade-binary.ts
+++ b/ts/packages/cli/src/services/upgrade-binary.ts
@@ -36,6 +36,12 @@ type GitHubRelease = {
const CLI_RELEASE_TAG_PATTERN = /^@composio\/cli@\d+\.\d+\.\d+.*$/;
+const getBinaryAssetName = (platformArch: PlatformArch): string =>
+ `${CLI_BINARY_NAME}-${platformArch.platform}-${platformArch.arch}.zip`;
+
+const hasBinaryAsset = (release: GitHubRelease, platformArch: PlatformArch): boolean =>
+ release.assets.some(asset => asset.name === getBinaryAssetName(platformArch));
+
// Service to manage CLI binary upgrades
export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/UpgradeBinary', {
accessors: true,
@@ -98,7 +104,9 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
)) as T;
});
- const fetchLatestRelease = (): Effect.Effect<GitHubRelease, UpgradeBinaryError, never> =>
+ const fetchLatestRelease = (
+ platformArch: PlatformArch
+ ): Effect.Effect<Option.Option<GitHubRelease>, UpgradeBinaryError, never> =>
Effect.gen(function* () {
const release = yield* githubConfig.TAG.pipe(
Option.match({
@@ -143,8 +151,19 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
);
}
- let latest = cliReleases[0];
- for (const release of cliReleases.slice(1)) {
+ const releasesWithBinary = cliReleases.filter(release =>
+ hasBinaryAsset(release, platformArch)
+ );
+
+ if (releasesWithBinary.length === 0) {
+ yield* Effect.logDebug(
+ `No published CLI releases currently contain ${getBinaryAssetName(platformArch)}`
+ );
+ return Option.none();
+ }
+
+ let latest = releasesWithBinary[0];
+ for (const release of releasesWithBinary.slice(1)) {
const comparison = yield* semverComparator(latest.tag_name, release.tag_name).pipe(
Effect.mapError(
error =>
@@ -161,7 +180,7 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
}
yield* Effect.logDebug(`Resolved latest CLI release tag: ${latest.tag_name}`);
- return latest;
+ return Option.some(latest);
}),
onSome: Effect.fn(function* (tag) {
yield* Effect.logDebug(`Using tag: ${tag}`);
@@ -173,7 +192,14 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
parseErrorMessage: 'Failed to parse GitHub release JSON response',
});
- return release as GitHubRelease;
+ if (!hasBinaryAsset(release, platformArch)) {
+ yield* Effect.logDebug(
+ `Release ${tag} does not yet contain ${getBinaryAssetName(platformArch)}`
+ );
+ return Option.none();
+ }
+
+ return Option.some(release as GitHubRelease);
}),
})
);
@@ -205,7 +231,7 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
`Looking up binary for ${platformArch.platform}-${platformArch.arch}`
);
- const binaryName = `${CLI_BINARY_NAME}-${platformArch.platform}-${platformArch.arch}.zip`;
+ const binaryName = getBinaryAssetName(platformArch);
const asset = release.assets.find(asset => asset.name === binaryName);
if (!asset) {
@@ -540,7 +566,14 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
const didUpgrade = yield* ui.useMakeSpinner('Checking for updates...', spinner =>
Effect.gen(function* () {
- const release = yield* fetchLatestRelease();
+ const platformArch = yield* detectPlatform;
+ const releaseOption = yield* fetchLatestRelease(platformArch);
+ if (Option.isNone(releaseOption)) {
+ yield* spinner.stop('You are already running the latest version!');
+ return false;
+ }
+
+ const release = releaseOption.value;
const updateAvailable = yield* isUpdateAvailable(release);
if (!updateAvailable) {
yield* spinner.stop('You are already running the latest version!');
@@ -551,7 +584,6 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
`New version available: ${release.tag_name} (current: ${APP_VERSION}). Downloading...`
);
- const platformArch = yield* detectPlatform;
const { name, data } = yield* downloadBinary(release, platformArch);
yield* spinner.message('Verifying checksum...');
diff --git a/ts/packages/cli/test/src/services/upgrade-binary.test.ts b/ts/packages/cli/test/src/services/upgrade-binary.test.ts
index 4480a1913..7ff85138e 100644
--- a/ts/packages/cli/test/src/services/upgrade-binary.test.ts
+++ b/ts/packages/cli/test/src/services/upgrade-binary.test.ts
@@ -58,6 +58,21 @@ const runUpgrade = (configEntries: ReadonlyArray<[string, string]>) =>
Effect.runPromise
);
+const runUpgradeSuccess = (configEntries: ReadonlyArray<[string, string]>) =>
+ Effect.gen(function* () {
+ const service = yield* UpgradeBinary;
+ return yield* service.upgrade();
+ }).pipe(
+ Effect.provide(UpgradeBinary.Default),
+ Effect.provide(FetchHttpClient.layer),
+ Effect.provide(BunFileSystem.layer),
+ Effect.provide(TerminalUINoop),
+ Effect.provide(NodeOsTest),
+ Effect.withConfigProvider(ConfigProvider.fromMap(new Map(configEntries))),
+ Effect.scoped,
+ Effect.runPromise
+ );
+
describe('UpgradeBinary', () => {
it('wraps non-2xx releases fetch failures with fetch context (no tag branch)', async () => {
vi.stubGlobal('Bun', { which: vi.fn(() => null) });
@@ -153,4 +168,92 @@ describe('UpgradeBinary', () => {
vi.restoreAllMocks();
}
});
+
+ it('skips newer releases that do not yet contain a binary for the current platform', async () => {
+ vi.stubGlobal('Bun', { which: vi.fn(() => null) });
+
+ try {
+ await withHttpServer(
+ (req, res) => {
+ if (req.url === '/repos/test-owner/test-repo/releases?per_page=100') {
+ res.writeHead(200, { 'content-type': 'application/json' });
+ res.end(
+ JSON.stringify([
+ {
+ tag_name: '@composio/[email protected]',
+ prerelease: false,
+ draft: false,
+ assets: [],
+ },
+ {
+ tag_name: '@composio/[email protected]',
+ prerelease: false,
+ draft: false,
+ assets: [],
+ },
+ ])
+ );
+ return;
+ }
+
+ res.writeHead(404, { 'content-type': 'application/json' });
+ res.end(JSON.stringify({ message: 'not found' }));
+ },
+ async apiBaseUrl => {
+ const result = await runUpgradeSuccess([
+ ['GITHUB_API_BASE_URL', apiBaseUrl],
+ ['GITHUB_OWNER', 'test-owner'],
+ ['GITHUB_REPO', 'test-repo'],
+ ]);
+
+ expect(result).toBeUndefined();
+ }
+ );
+ } finally {
+ vi.unstubAllGlobals();
+ vi.restoreAllMocks();
+ }
+ });
+
+ it('treats an explicitly requested release without binaries as no upgrade', async () => {
+ vi.stubGlobal('Bun', { which: vi.fn(() => null) });
+
+ try {
+ await withHttpServer(
+ (req, res) => {
+ if (
+ req.url ===
+ `/repos/test-owner/test-repo/releases/tags/${encodeURIComponent('@composio/[email protected]')}`
+ ) {
+ res.writeHead(200, { 'content-type': 'application/json' });
+ res.end(
+ JSON.stringify({
+ tag_name: '@composio/[email protected]',
+ prerelease: false,
+ draft: false,
+ assets: [],
+ })
+ );
+ return;
+ }
+
+ res.writeHead(404, { 'content-type': 'application/json' });
+ res.end(JSON.stringify({ message: 'not found' }));
+ },
+ async apiBaseUrl => {
+ const result = await runUpgradeSuccess([
+ ['GITHUB_API_BASE_URL', apiBaseUrl],
+ ['GITHUB_OWNER', 'test-owner'],
+ ['GITHUB_REPO', 'test-repo'],
+ ['GITHUB_TAG', '@composio/[email protected]'],
+ ]);
+
+ expect(result).toBeUndefined();
+ }
+ );
+ } finally {
+ vi.unstubAllGlobals();
+ vi.restoreAllMocks();
+ }
+ });
});