Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
import * as FileSystem from '@effect/platform/FileSystem';
import * as Path from '@effect/platform/Path';
import * as BunFileSystem from '@effect/platform-bun/BunFileSystem';
import * as BunPath from '@effect/platform-bun/BunPath';
import { describe, expect, layer } from '@effect/vitest';
import { Effect, Layer } from 'effect';
import {
RUN_COMPANION_RELEASE_TAG_FILENAME,
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, RUN_COMPANION_RELEASE_TAG_FILENAME),
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, RUN_COMPANION_RELEASE_TAG_FILENAME);
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]'
);
})
);
});
});