@devries-cameron20 / composio-1 / commits / e40577f2b
Fork 0

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

jkomyno committed Aug 1, 2026 at 18:51 UTC e40577f2b99d5c94b53384413f79ba9459dd87ef
9 files changed +109 -14
ts/packages/cli/src/constants.ts
+3
@@ -54,6 +54,9 @@ export const CACHE_FILENAMES = {
54 TRIGGER_TYPES: 'trigger-types.json',
55 };
56
57 +/** Whether the CLI has an exact release version compiled into it. */
58 +export const IS_RELEASE_BUILD = typeof __COMPOSIO_CLI_RELEASE_VERSION__ !== 'undefined';
59 +
60 /**
61 * Version of the running Composio CLI.
62 *
ts/packages/cli/src/effects/install-skill.ts
+2 -2
@@ -4,7 +4,7 @@ import { NodeOs } from 'src/services/node-os';
4 import { TerminalUI } from 'src/services/terminal-ui';
5 import { GITHUB_CONFIG } from 'src/effects/github-config';
6 import { APP_VERSION, type CliReleaseChannel } from 'src/constants';
7 -import { readInstalledReleaseTag } from 'src/services/run-companion-modules';
7 +import { resolveRunningCliReleaseTag } from 'src/services/run-companion-modules';
8 import {
9 fetchLatestCliRelease,
10 fetchCliReleaseByTag,
@@ -150,7 +150,7 @@ export const installSkill = (options?: {
150 channel: options?.channel,
151 githubConfig,
152 httpClient,
153 - installedReleaseTag: yield* readInstalledReleaseTag(process.execPath),
153 + installedReleaseTag: yield* resolveRunningCliReleaseTag(process.execPath, APP_VERSION),
154 releaseTag: options?.releaseTag,
155 });
156
ts/packages/cli/src/effects/version.ts
+2 -2
@@ -1,12 +1,12 @@
1 import { Effect, Option } from 'effect';
2 import { DEBUG_OVERRIDE_CONFIG } from 'src/effects/debug-config';
3 import * as constants from 'src/constants';
4 -import { resolveInstalledCliVersion } from 'src/services/run-companion-modules';
4 +import { resolveRunningCliVersion } from 'src/services/run-companion-modules';
5
6 export const getVersion = Effect.flatMap(
7 DEBUG_OVERRIDE_CONFIG.VERSION,
8 Option.match({
9 - onNone: () => resolveInstalledCliVersion(process.execPath, constants.APP_VERSION),
9 + onNone: () => resolveRunningCliVersion(process.execPath, constants.APP_VERSION),
10 onSome: version => Effect.succeed(version),
11 })
12 );
ts/packages/cli/src/services/run-companion-modules.ts
+20 -1
@@ -7,6 +7,7 @@ import { FileSystem, Path } from '@effect/platform';
7 import type { PlatformError } from '@effect/platform/Error';
8 import { Config, ConfigProvider, Data, Effect, Option, Schema } from 'effect';
9 import extractZip from 'extract-zip';
10 +import { IS_RELEASE_BUILD } from 'src/constants';
11 import { GitHubRelease } from 'src/effects/resolve-cli-release';
12 import { BaseConfigProviderLive, extendConfigProvider } from 'src/services/config';
13 import { parseChecksumsText, sha256Hex } from 'src/utils/checksums';
@@ -324,6 +325,24 @@ export const resolveInstalledCliReleaseTag = (
325 normalizeCliReleaseTag(releaseTag ?? fallbackVersion)
326 );
327
328 +export const resolveRunningCliVersion = (
329 + execPath: string,
330 + appVersion: string,
331 + isReleaseBuild = IS_RELEASE_BUILD
332 +): Effect.Effect<string, never, FileSystem.FileSystem | Path.Path> =>
333 + isReleaseBuild
334 + ? Effect.succeed(normalizeCliReleaseVersion(appVersion))
335 + : resolveInstalledCliVersion(execPath, appVersion);
336 +
337 +export const resolveRunningCliReleaseTag = (
338 + execPath: string,
339 + appVersion: string,
340 + isReleaseBuild = IS_RELEASE_BUILD
341 +): Effect.Effect<string, never, FileSystem.FileSystem | Path.Path> =>
342 + isReleaseBuild
343 + ? Effect.succeed(normalizeCliReleaseTag(appVersion))
344 + : resolveInstalledCliReleaseTag(execPath, appVersion);
345 +
346 export const writeInstalledReleaseTag = (
347 installDir: string,
348 releaseTag: string
@@ -451,7 +470,7 @@ const resolveRepairReleaseTag = ({
470 return pinnedTag;
471 }
472
454 - return yield* resolveInstalledCliReleaseTag(execPath, appVersion);
473 + return yield* resolveRunningCliReleaseTag(execPath, appVersion);
474 });
475
476 const nonEmptyConfigWithFallback = (name: string, fallback: string) =>
ts/packages/cli/src/services/setup-skill-installer.ts
+2 -2
@@ -10,7 +10,7 @@ import {
10 } from 'src/effects/install-skill';
11 import { GITHUB_CONFIG } from 'src/effects/github-config';
12 import { APP_VERSION } from 'src/constants';
13 -import { readInstalledReleaseTag } from 'src/services/run-companion-modules';
13 +import { resolveRunningCliReleaseTag } from 'src/services/run-companion-modules';
14 import { NodeOs } from './node-os';
15
16 export const resolveSetupSkillReleaseTag = (
@@ -20,7 +20,7 @@ export const resolveSetupSkillReleaseTag = (
20 Effect.gen(function* () {
21 const httpClient = yield* HttpClient.HttpClient;
22 const githubConfig = yield* Config.all(GITHUB_CONFIG);
23 - const installedReleaseTag = yield* readInstalledReleaseTag(execPath);
23 + const installedReleaseTag = yield* resolveRunningCliReleaseTag(execPath, fallbackVersion);
24
25 return yield* resolveSkillReleaseTag({
26 channel: inferSkillReleaseChannel(fallbackVersion),
ts/packages/cli/src/services/update-check.ts
+3 -3
@@ -5,7 +5,7 @@ import semver from 'semver';
5 import { bold, cyanBright, dim } from 'src/ui/colors';
6 import { APP_VERSION, GITHUB_REPO } from '../constants';
7 import { NodeOs } from './node-os';
8 -import { resolveInstalledCliVersion } from './run-companion-modules';
8 +import { resolveRunningCliVersion } from './run-companion-modules';
9 import { TerminalUI } from './terminal-ui';
10
11 /**
@@ -35,7 +35,7 @@ export interface UpdateCheckState {
35
36 /** Machine-readable update status for `composio version --check`. */
37 export interface UpdateStatus {
38 - /** Installed CLI version (release-tag.txt next to the binary, or APP_VERSION). */
38 + /** Version reported by the running CLI executable. */
39 current: string;
40 /** Latest known stable release with a binary for this platform, if known. */
41 latestStable: string | null;
@@ -98,7 +98,7 @@ function getCurrentBinaryAssetName(os: Pick<NodeOs, 'platform' | 'arch'>): strin
98 const defaultConfig = (stateFile: string) =>
99 Effect.gen(function* () {
100 const os = yield* NodeOs;
101 - const currentVersion = yield* resolveInstalledCliVersion(process.execPath, APP_VERSION);
101 + const currentVersion = yield* resolveRunningCliVersion(process.execPath, APP_VERSION);
102 const accessToken = yield* Effect.orDie(
103 Config.option(Config.string('COMPOSIO_GITHUB_ACCESS_TOKEN')).pipe(
104 Config.map(Option.getOrUndefined)
ts/packages/cli/src/services/upgrade-binary.ts
+2 -2
@@ -14,7 +14,7 @@ import { renderPrettyError } from './utils/pretty-error';
14 import { TerminalUI } from './terminal-ui';
15 import {
16 collectExpectedRunCompanionAssetRelativePaths,
17 - resolveInstalledCliReleaseTag,
17 + resolveRunningCliReleaseTag,
18 writeInstalledReleaseTag,
19 } from './run-companion-modules';
20
@@ -173,7 +173,7 @@ const provideFsAndPath = <A, E>(
173 * Check if update is available
174 */
175 const resolveCurrentReleaseIdentifier = (ctx: UpgradeBinaryContext, currentPath: string) =>
176 - provideFsAndPath(ctx, resolveInstalledCliReleaseTag(currentPath, APP_VERSION));
176 + provideFsAndPath(ctx, resolveRunningCliReleaseTag(currentPath, APP_VERSION));
177
178 const isUpdateAvailable = (
179 release: GitHubRelease,
ts/packages/cli/test/src/services/running-cli-version.test.ts new
+73
@@ -0,0 +1,73 @@
1 +import { FileSystem, Path } from '@effect/platform';
2 +import { BunFileSystem, BunPath } from '@effect/platform-bun';
3 +import { describe, expect, layer } from '@effect/vitest';
4 +import { Effect, Layer } from 'effect';
5 +import {
6 + resolveRunningCliReleaseTag,
7 + resolveRunningCliVersion,
8 +} from 'src/services/run-companion-modules';
9 +
10 +const TestPlatform = Layer.mergeAll(BunFileSystem.layer, BunPath.layer);
11 +
12 +describe('running CLI version authority', () => {
13 + layer(TestPlatform)(it => {
14 + it.scoped('uses the compiled version in release builds despite installed tag metadata', () =>
15 + Effect.gen(function* () {
16 + const fs = yield* FileSystem.FileSystem;
17 + const path = yield* Path.Path;
18 + const installDirectory = yield* fs.makeTempDirectoryScoped();
19 + const execPath = path.join(installDirectory, 'composio');
20 +
21 + for (const installedTag of ['@composio/cli@9.9.9', '@composio/cli@0.2.31']) {
22 + yield* fs.writeFileString(path.join(installDirectory, 'release-tag.txt'), installedTag);
23 +
24 + expect(yield* resolveRunningCliVersion(execPath, '0.3.0', true)).toBe('0.3.0');
25 + expect(yield* resolveRunningCliReleaseTag(execPath, '0.3.0', true)).toBe(
26 + '@composio/cli@0.3.0'
27 + );
28 + }
29 + })
30 + );
31 +
32 + it.scoped('uses the compiled version in a release build without installed metadata', () =>
33 + Effect.gen(function* () {
34 + const fs = yield* FileSystem.FileSystem;
35 + const path = yield* Path.Path;
36 + const installDirectory = yield* fs.makeTempDirectoryScoped();
37 + const execPath = path.join(installDirectory, 'composio');
38 +
39 + expect(yield* resolveRunningCliVersion(execPath, '0.3.0', true)).toBe('0.3.0');
40 + expect(yield* resolveRunningCliReleaseTag(execPath, '0.3.0', true)).toBe(
41 + '@composio/cli@0.3.0'
42 + );
43 + })
44 + );
45 +
46 + it.scoped('keeps installed tag fallback behavior in development builds', () =>
47 + Effect.gen(function* () {
48 + const fs = yield* FileSystem.FileSystem;
49 + const path = yield* Path.Path;
50 + const installDirectory = yield* fs.makeTempDirectoryScoped();
51 + const execPath = path.join(installDirectory, 'composio');
52 + const releaseTagPath = path.join(installDirectory, 'release-tag.txt');
53 + yield* fs.writeFileString(releaseTagPath, '@composio/cli@0.2.31');
54 +
55 + expect(yield* resolveRunningCliVersion(execPath, '0.0.0-development', false)).toBe(
56 + '0.2.31'
57 + );
58 + expect(yield* resolveRunningCliReleaseTag(execPath, '0.0.0-development', false)).toBe(
59 + '@composio/cli@0.2.31'
60 + );
61 +
62 + yield* fs.remove(releaseTagPath);
63 +
64 + expect(yield* resolveRunningCliVersion(execPath, '0.0.0-development', false)).toBe(
65 + '0.0.0-development'
66 + );
67 + expect(yield* resolveRunningCliReleaseTag(execPath, '0.0.0-development', false)).toBe(
68 + '@composio/cli@0.0.0-development'
69 + );
70 + })
71 + );
72 + });
73 +});
ts/packages/cli/test/src/services/setup-skill-installer.test.ts
+2 -2
@@ -61,13 +61,13 @@ describe('SetupSkillInstaller', () => {
61 })
62 );
63
64 - it.effect('discovers the latest stable release outside a packaged install', () =>
64 + it.effect('uses the running package fallback outside a packaged install', () =>
65 Effect.gen(function* () {
66 const path = yield* Path.Path;
67 const installDir = tempy.temporaryDirectory();
68
69 expect(yield* resolveSetupSkillReleaseTag(path.join(installDir, 'composio'), '0.3.0')).toBe(
70 - '@composio/cli@0.2.21'
70 + '@composio/cli@0.3.0'
71 );
72 })
73 );