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): trust the running binary version

jkomynoe40577f2b99d
diff --git a/ts/packages/cli/src/constants.ts b/ts/packages/cli/src/constants.ts
index 70538f68a..63a3d367f 100644
--- a/ts/packages/cli/src/constants.ts
+++ b/ts/packages/cli/src/constants.ts
@@ -54,6 +54,9 @@ export const CACHE_FILENAMES = {
TRIGGER_TYPES: 'trigger-types.json',
};
+/** Whether the CLI has an exact release version compiled into it. */
+export const IS_RELEASE_BUILD = typeof __COMPOSIO_CLI_RELEASE_VERSION__ !== 'undefined';
+
/**
* Version of the running Composio CLI.
*
diff --git a/ts/packages/cli/src/effects/install-skill.ts b/ts/packages/cli/src/effects/install-skill.ts
index 92792d876..4661793ff 100644
--- a/ts/packages/cli/src/effects/install-skill.ts
+++ b/ts/packages/cli/src/effects/install-skill.ts
@@ -4,7 +4,7 @@ import { NodeOs } from 'src/services/node-os';
import { TerminalUI } from 'src/services/terminal-ui';
import { GITHUB_CONFIG } from 'src/effects/github-config';
import { APP_VERSION, type CliReleaseChannel } from 'src/constants';
-import { readInstalledReleaseTag } from 'src/services/run-companion-modules';
+import { resolveRunningCliReleaseTag } from 'src/services/run-companion-modules';
import {
fetchLatestCliRelease,
fetchCliReleaseByTag,
@@ -150,7 +150,7 @@ export const installSkill = (options?: {
channel: options?.channel,
githubConfig,
httpClient,
- installedReleaseTag: yield* readInstalledReleaseTag(process.execPath),
+ installedReleaseTag: yield* resolveRunningCliReleaseTag(process.execPath, APP_VERSION),
releaseTag: options?.releaseTag,
});
diff --git a/ts/packages/cli/src/effects/version.ts b/ts/packages/cli/src/effects/version.ts
index 1111d0611..edd5d115c 100644
--- a/ts/packages/cli/src/effects/version.ts
+++ b/ts/packages/cli/src/effects/version.ts
@@ -1,12 +1,12 @@
import { Effect, Option } from 'effect';
import { DEBUG_OVERRIDE_CONFIG } from 'src/effects/debug-config';
import * as constants from 'src/constants';
-import { resolveInstalledCliVersion } from 'src/services/run-companion-modules';
+import { resolveRunningCliVersion } from 'src/services/run-companion-modules';
export const getVersion = Effect.flatMap(
DEBUG_OVERRIDE_CONFIG.VERSION,
Option.match({
- onNone: () => resolveInstalledCliVersion(process.execPath, constants.APP_VERSION),
+ onNone: () => resolveRunningCliVersion(process.execPath, constants.APP_VERSION),
onSome: version => Effect.succeed(version),
})
);
diff --git a/ts/packages/cli/src/services/run-companion-modules.ts b/ts/packages/cli/src/services/run-companion-modules.ts
index 4583b5e09..7e8edebb0 100644
--- a/ts/packages/cli/src/services/run-companion-modules.ts
+++ b/ts/packages/cli/src/services/run-companion-modules.ts
@@ -7,6 +7,7 @@ import { FileSystem, Path } from '@effect/platform';
import type { PlatformError } from '@effect/platform/Error';
import { Config, ConfigProvider, Data, Effect, Option, Schema } from 'effect';
import extractZip from 'extract-zip';
+import { IS_RELEASE_BUILD } from 'src/constants';
import { GitHubRelease } from 'src/effects/resolve-cli-release';
import { BaseConfigProviderLive, extendConfigProvider } from 'src/services/config';
import { parseChecksumsText, sha256Hex } from 'src/utils/checksums';
@@ -324,6 +325,24 @@ export const resolveInstalledCliReleaseTag = (
normalizeCliReleaseTag(releaseTag ?? fallbackVersion)
);
+export const resolveRunningCliVersion = (
+ execPath: string,
+ appVersion: string,
+ isReleaseBuild = IS_RELEASE_BUILD
+): Effect.Effect<string, never, FileSystem.FileSystem | Path.Path> =>
+ isReleaseBuild
+ ? Effect.succeed(normalizeCliReleaseVersion(appVersion))
+ : resolveInstalledCliVersion(execPath, appVersion);
+
+export const resolveRunningCliReleaseTag = (
+ execPath: string,
+ appVersion: string,
+ isReleaseBuild = IS_RELEASE_BUILD
+): Effect.Effect<string, never, FileSystem.FileSystem | Path.Path> =>
+ isReleaseBuild
+ ? Effect.succeed(normalizeCliReleaseTag(appVersion))
+ : resolveInstalledCliReleaseTag(execPath, appVersion);
+
export const writeInstalledReleaseTag = (
installDir: string,
releaseTag: string
@@ -451,7 +470,7 @@ const resolveRepairReleaseTag = ({
return pinnedTag;
}
- return yield* resolveInstalledCliReleaseTag(execPath, appVersion);
+ return yield* resolveRunningCliReleaseTag(execPath, appVersion);
});
const nonEmptyConfigWithFallback = (name: string, fallback: string) =>
diff --git a/ts/packages/cli/src/services/setup-skill-installer.ts b/ts/packages/cli/src/services/setup-skill-installer.ts
index 31b1da1a4..9536df5d1 100644
--- a/ts/packages/cli/src/services/setup-skill-installer.ts
+++ b/ts/packages/cli/src/services/setup-skill-installer.ts
@@ -10,7 +10,7 @@ import {
} from 'src/effects/install-skill';
import { GITHUB_CONFIG } from 'src/effects/github-config';
import { APP_VERSION } from 'src/constants';
-import { readInstalledReleaseTag } from 'src/services/run-companion-modules';
+import { resolveRunningCliReleaseTag } from 'src/services/run-companion-modules';
import { NodeOs } from './node-os';
export const resolveSetupSkillReleaseTag = (
@@ -20,7 +20,7 @@ export const resolveSetupSkillReleaseTag = (
Effect.gen(function* () {
const httpClient = yield* HttpClient.HttpClient;
const githubConfig = yield* Config.all(GITHUB_CONFIG);
- const installedReleaseTag = yield* readInstalledReleaseTag(execPath);
+ const installedReleaseTag = yield* resolveRunningCliReleaseTag(execPath, fallbackVersion);
return yield* resolveSkillReleaseTag({
channel: inferSkillReleaseChannel(fallbackVersion),
diff --git a/ts/packages/cli/src/services/update-check.ts b/ts/packages/cli/src/services/update-check.ts
index d9319d062..4108c22b9 100644
--- a/ts/packages/cli/src/services/update-check.ts
+++ b/ts/packages/cli/src/services/update-check.ts
@@ -5,7 +5,7 @@ import semver from 'semver';
import { bold, cyanBright, dim } from 'src/ui/colors';
import { APP_VERSION, GITHUB_REPO } from '../constants';
import { NodeOs } from './node-os';
-import { resolveInstalledCliVersion } from './run-companion-modules';
+import { resolveRunningCliVersion } from './run-companion-modules';
import { TerminalUI } from './terminal-ui';
/**
@@ -35,7 +35,7 @@ export interface UpdateCheckState {
/** Machine-readable update status for `composio version --check`. */
export interface UpdateStatus {
- /** Installed CLI version (release-tag.txt next to the binary, or APP_VERSION). */
+ /** Version reported by the running CLI executable. */
current: string;
/** Latest known stable release with a binary for this platform, if known. */
latestStable: string | null;
@@ -98,7 +98,7 @@ function getCurrentBinaryAssetName(os: Pick<NodeOs, 'platform' | 'arch'>): strin
const defaultConfig = (stateFile: string) =>
Effect.gen(function* () {
const os = yield* NodeOs;
- const currentVersion = yield* resolveInstalledCliVersion(process.execPath, APP_VERSION);
+ const currentVersion = yield* resolveRunningCliVersion(process.execPath, APP_VERSION);
const accessToken = yield* Effect.orDie(
Config.option(Config.string('COMPOSIO_GITHUB_ACCESS_TOKEN')).pipe(
Config.map(Option.getOrUndefined)
diff --git a/ts/packages/cli/src/services/upgrade-binary.ts b/ts/packages/cli/src/services/upgrade-binary.ts
index f6150fbc4..885537522 100644
--- a/ts/packages/cli/src/services/upgrade-binary.ts
+++ b/ts/packages/cli/src/services/upgrade-binary.ts
@@ -14,7 +14,7 @@ import { renderPrettyError } from './utils/pretty-error';
import { TerminalUI } from './terminal-ui';
import {
collectExpectedRunCompanionAssetRelativePaths,
- resolveInstalledCliReleaseTag,
+ resolveRunningCliReleaseTag,
writeInstalledReleaseTag,
} from './run-companion-modules';
@@ -173,7 +173,7 @@ const provideFsAndPath = <A, E>(
* Check if update is available
*/
const resolveCurrentReleaseIdentifier = (ctx: UpgradeBinaryContext, currentPath: string) =>
- provideFsAndPath(ctx, resolveInstalledCliReleaseTag(currentPath, APP_VERSION));
+ provideFsAndPath(ctx, resolveRunningCliReleaseTag(currentPath, APP_VERSION));
const isUpdateAvailable = (
release: GitHubRelease,
diff --git a/ts/packages/cli/test/src/services/running-cli-version.test.ts b/ts/packages/cli/test/src/services/running-cli-version.test.ts
new file mode 100644
index 000000000..07b83fd70
--- /dev/null
+++ b/ts/packages/cli/test/src/services/running-cli-version.test.ts
@@ -0,0 +1,73 @@
+import { FileSystem, Path } from '@effect/platform';
+import { BunFileSystem, BunPath } from '@effect/platform-bun';
+import { describe, expect, layer } from '@effect/vitest';
+import { Effect, Layer } from 'effect';
+import {
+ resolveRunningCliReleaseTag,
+ resolveRunningCliVersion,
+} from 'src/services/run-companion-modules';
+
+const TestPlatform = Layer.mergeAll(BunFileSystem.layer, BunPath.layer);
+
+describe('running CLI version authority', () => {
+ layer(TestPlatform)(it => {
+ it.scoped('uses the compiled version in release builds despite installed tag metadata', () =>
+ Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const installDirectory = yield* fs.makeTempDirectoryScoped();
+ const execPath = path.join(installDirectory, 'composio');
+
+ for (const installedTag of ['@composio/[email protected]', '@composio/[email protected]']) {
+ yield* fs.writeFileString(path.join(installDirectory, 'release-tag.txt'), installedTag);
+
+ expect(yield* resolveRunningCliVersion(execPath, '0.3.0', true)).toBe('0.3.0');
+ expect(yield* resolveRunningCliReleaseTag(execPath, '0.3.0', true)).toBe(
+ '@composio/[email protected]'
+ );
+ }
+ })
+ );
+
+ it.scoped('uses the compiled version in a release build without installed metadata', () =>
+ Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const installDirectory = yield* fs.makeTempDirectoryScoped();
+ const execPath = path.join(installDirectory, 'composio');
+
+ expect(yield* resolveRunningCliVersion(execPath, '0.3.0', true)).toBe('0.3.0');
+ expect(yield* resolveRunningCliReleaseTag(execPath, '0.3.0', true)).toBe(
+ '@composio/[email protected]'
+ );
+ })
+ );
+
+ it.scoped('keeps installed tag fallback behavior in development builds', () =>
+ Effect.gen(function* () {
+ const fs = yield* FileSystem.FileSystem;
+ const path = yield* Path.Path;
+ const installDirectory = yield* fs.makeTempDirectoryScoped();
+ const execPath = path.join(installDirectory, 'composio');
+ const releaseTagPath = path.join(installDirectory, 'release-tag.txt');
+ yield* fs.writeFileString(releaseTagPath, '@composio/[email protected]');
+
+ expect(yield* resolveRunningCliVersion(execPath, '0.0.0-development', false)).toBe(
+ '0.2.31'
+ );
+ expect(yield* resolveRunningCliReleaseTag(execPath, '0.0.0-development', false)).toBe(
+ '@composio/[email protected]'
+ );
+
+ yield* fs.remove(releaseTagPath);
+
+ expect(yield* resolveRunningCliVersion(execPath, '0.0.0-development', false)).toBe(
+ '0.0.0-development'
+ );
+ expect(yield* resolveRunningCliReleaseTag(execPath, '0.0.0-development', false)).toBe(
+ '@composio/[email protected]'
+ );
+ })
+ );
+ });
+});
diff --git a/ts/packages/cli/test/src/services/setup-skill-installer.test.ts b/ts/packages/cli/test/src/services/setup-skill-installer.test.ts
index 37be00379..89aa011a3 100644
--- a/ts/packages/cli/test/src/services/setup-skill-installer.test.ts
+++ b/ts/packages/cli/test/src/services/setup-skill-installer.test.ts
@@ -61,13 +61,13 @@ describe('SetupSkillInstaller', () => {
})
);
- it.effect('discovers the latest stable release outside a packaged install', () =>
+ it.effect('uses the running package fallback outside a packaged install', () =>
Effect.gen(function* () {
const path = yield* Path.Path;
const installDir = tempy.temporaryDirectory();
expect(yield* resolveSetupSkillReleaseTag(path.join(installDir, 'composio'), '0.3.0')).toBe(
- '@composio/[email protected]'
+ '@composio/[email protected]'
);
})
);