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
feat(ts/e2e): add CLI runtime support and `composio version` e2e test
jkomyno5519752ba4b6
diff --git a/.github/workflows/ts.test-e2e.yml b/.github/workflows/ts.test-e2e.ymlindex 9dc06ae2a..196ace674 100644--- a/.github/workflows/ts.test-e2e.yml+++ b/.github/workflows/ts.test-e2e.yml@@ -92,6 +92,44 @@ jobs:- name: Run Deno E2E Testsrun: pnpm run test:e2e:deno+ # CLI E2E tests, running in scratch Docker to isolate environment+ test-e2e-cli-docker:+ name: E2E Test CLI (scratch)+ runs-on: ubuntu-24.04+ permissions: read-all+ env:+ CI: 1+ COMPOSIO_API_KEY: ${{ secrets.COMPOSIO_API_KEY }}+ OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}++ steps:+ - name: Checkout Code+ uses: actions/checkout@v6++ - name: Setup Node.js, pnpm, Bun+ uses: ./.github/actions/setup-node-pnpm-bun++ - name: Install Dependencies+ run: pnpm install --frozen-lockfile++ - name: Build+ run: pnpm run build:packages++ - name: Pre-build Docker image for CLI e2e tests+ run: |+ CLI_VERSION=$(node -p "require('./ts/packages/cli/package.json').version")+ echo "COMPOSIO_E2E_CLI_VERSION=${CLI_VERSION}" >> "$GITHUB_ENV"+ docker build -f ts/e2e-tests/_utils/Dockerfile.cli \+ --build-arg CLI_VERSION="${CLI_VERSION}" \+ --label composio.e2e=true \+ --label composio.runtime=cli \+ --label "composio.cli_version=${CLI_VERSION}" \+ -t "composio-e2e-cli:${CLI_VERSION}" \+ .++ - name: Run CLI E2E Tests+ run: pnpm run test:e2e:cli+# Cloudflare Workerd E2E teststest-e2e-cloudflare:name: E2E Test Cloudflare Workerddiff --git a/package.json b/package.jsonindex dd7c2fbfc..385b99397 100644--- a/package.json+++ b/package.json@@ -16,6 +16,7 @@"test:e2e": "turbo test:e2e --filter='@e2e-tests/*'","test:e2e:node": "turbo test:e2e:node --filter='@e2e-tests/node-*'","test:e2e:deno": "turbo test:e2e:deno --filter='@e2e-tests/deno-*'",+ "test:e2e:cli": "turbo test:e2e:cli --filter='@e2e-tests/cli-*'","test:e2e:cloudflare": "turbo test:e2e:cloudflare --filter='@e2e-tests/cf-*'","test:ui": "vitest --ui","typecheck": "turbo typecheck --filter=./ts/packages/**",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 3393c2c91..667a09a63 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -173,6 +173,12 @@ importers:specifier: 'catalog:'version: 5.9.3+ ts/e2e-tests/cli/version:+ devDependencies:+ '@e2e-tests/utils':+ specifier: workspace:*+ version: link:../../_utils+ts/e2e-tests/runtimes/cloudflare/cf-workers-basic:dependencies:'@composio/core':diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yamlindex 3b4748938..7c507964e 100644--- a/pnpm-workspace.yaml+++ b/pnpm-workspace.yaml@@ -1,5 +1,6 @@packages:- ts/e2e-tests/_utils+ - ts/e2e-tests/cli/*- ts/e2e-tests/runtimes/node/*- ts/e2e-tests/runtimes/deno/*- ts/e2e-tests/runtimes/cloudflare/*diff --git a/ts/e2e-tests/README.md b/ts/e2e-tests/README.mdindex 643a6b9a0..2c837a6f6 100644--- a/ts/e2e-tests/README.md+++ b/ts/e2e-tests/README.md@@ -1,6 +1,6 @@# E2E Tests-End-to-end tests for `@composio/core` across different JavaScript runtimes.+End-to-end tests for `@composio/core` and the CLI across different runtimes.## Directory Structure@@ -9,8 +9,9 @@ ts/e2e-tests/├── _utils/ # Shared test infrastructure│ ├── Dockerfile.node # Docker image for Node.js tests│ ├── Dockerfile.deno # Docker image for Deno tests+│ ├── Dockerfile.cli # Docker image for CLI tests (scratch)│ ├── scripts/ # Docker build and cleanup scripts-│ │ ├── docker-build.ts # Pre-build images for all Node/Deno versions+│ │ ├── docker-build.ts # Pre-build images for all Node/Deno/CLI versions│ │ └── docker-clean.ts # Remove all e2e Docker images│ ├── src/ # TypeScript runner utilities│ │ ├── config.ts # Configuration utilities@@ -23,7 +24,7 @@ ts/e2e-tests/│ │ ├── types.ts # TypeScript type definitions│ │ └── volume.ts # Docker volume management│ └── README.md # Utils documentation-└── runtimes/+├── runtimes/├── node/ # Node.js runtime tests│ ├── cjs-basic/ # CommonJS compatibility tests│ ├── esm-basic/ # ESM compatibility tests@@ -39,6 +40,8 @@ ts/e2e-tests/├── cf-workers-basic/ # Basic Cloudflare Workers tests├── cf-workers-files/ # Cloudflare Workers file handling tests└── cf-workers-tool-router-ai/ # Cloudflare Workers AI SDK tool router tests+└── cli/ # CLI runtime tests (scratch)+ └── version/ # composio version command tests```## Running Tests@@ -83,6 +86,18 @@ COMPOSIO_E2E_DENO_VERSION=2.6.7 pnpm test:e2e:denopnpm test:e2e:cloudflare```+### CLI Tests Only++```bash+pnpm test:e2e:cli+```++To run with a specific CLI version:++```bash+COMPOSIO_E2E_CLI_VERSION=0.1.24 pnpm test:e2e:cli+```+## Adding New Tests### Node.js Runtime Tests@@ -208,6 +223,42 @@ e2e(import.meta.url, {3. Add `test:e2e` and `test:e2e:cloudflare` scripts4. Configure vitest with `@cloudflare/vitest-pool-workers`+### CLI Runtime Tests++1. Create a new directory under `cli/` (e.g., `cli/my-test`)+2. Add a `package.json` with name `@e2e-tests/cli-my-test`+3. Add `test:e2e` and `test:e2e:cli` scripts+4. Create an `e2e.test.ts` file with inline configuration:++```typescript+import { e2e, sanitizeOutput, type E2ETestResult } from '@e2e-tests/utils';+import { TIMEOUTS } from '@e2e-tests/utils/const';+import { describe, it, expect, beforeAll } from 'bun:test';++e2e(import.meta.url, {+ versions: {+ cli: ['current'],+ },+ defineTests: ({ runCmd }) => {+ let result: E2ETestResult;++ beforeAll(async () => {+ result = await runCmd('composio version');+ }, TIMEOUTS.FIXTURE);++ describe('output', () => {+ it('exits successfully', () => {+ expect(result.exitCode).toBe(0);+ });++ it('stdout matches snapshot', () => {+ expect(sanitizeOutput(result.stdout)).toMatchSnapshot();+ });+ });+ },+});+```+## DebuggingEach test suite generates an ephemereal `DEBUG.log` file in its directory with structured output:diff --git a/ts/e2e-tests/_utils/Dockerfile.cli b/ts/e2e-tests/_utils/Dockerfile.clinew file mode 100644index 000000000..0f238c72e--- /dev/null+++ b/ts/e2e-tests/_utils/Dockerfile.cli@@ -0,0 +1,79 @@+# syntax=docker/dockerfile:1+# Reusable Dockerfile for CLI e2e tests (debian runtime)+# Usage: docker build -f Dockerfile.cli --build-arg CLI_VERSION=0.1.24 -t test-name .++ARG NODE_VERSION=20.19.0+ARG BUN_VERSION=1.3.8+ARG CLI_VERSION=0.0.0++FROM oven/bun:${BUN_VERSION} AS bun++FROM node:${NODE_VERSION}-slim AS builder++ENV PNPM_HOME="/pnpm"+ENV PATH="$PNPM_HOME:/usr/local/bin:$PATH"++WORKDIR /app++# Bring in bun binary from the official image (no curl)+COPY --from=bun /usr/local/bin/bun /usr/local/bin/bun++# Install corepack (pnpm) without curl/git+RUN corepack enable++# Copy lockfile first for optimal layer caching+COPY pnpm-lock.yaml ./++# Copy workspace configuration files+COPY package.json \+ pnpm-workspace.yaml \+ .pnpmfile.cjs \+ tsconfig.base.json \+ tsdown.config.base.ts \+ .bun-version \+ ./++# Copy pre-install scripts (rarely change)+COPY ts/scripts/pre-install.sh ./ts/scripts/pre-install.sh+COPY ts/scripts/pre-install/ ./ts/scripts/pre-install/++# Copy all ts/packages (pre-built)+COPY ts/packages/ ./ts/packages/++# Install dependencies using pnpm+# Note: We intentionally don't use --mount=type=cache for the pnpm store here+# because it causes native binding issues across builds+RUN pnpm install --frozen-lockfile++# Build composio CLI binary+WORKDIR /app/ts/packages/cli+RUN bun build ./src/bin.ts \+ --env DEBUG_OVERRIDE_* \+ --compile \+ --production \+ --outfile /out/composio++# Copy CLI e2e tests last (changes frequently)+WORKDIR /app+COPY ts/e2e-tests/cli/ /app/ts/e2e-tests/cli/++# Pre-create Composio CLI cache directory to work around Bun issue #7967+RUN mkdir -p /tmp/.composio++FROM debian:bookworm-slim++ENV PATH="/usr/local/bin:/bin"+ENV HOME="/tmp"++WORKDIR /app++# CLI binary+COPY --from=builder /out/composio /usr/local/bin/composio++# CLI e2e tests+COPY --from=builder /app/ts/e2e-tests/cli/ /app/ts/e2e-tests/cli/++# CLI cache directory+COPY --from=builder /tmp/.composio /tmp/.composio++CMD ["/bin/sh"]diff --git a/ts/e2e-tests/_utils/README.md b/ts/e2e-tests/_utils/README.mdindex d97873861..22cf0e424 100644--- a/ts/e2e-tests/_utils/README.md+++ b/ts/e2e-tests/_utils/README.md@@ -1,6 +1,6 @@# E2E Test Utilities-Shared infrastructure for running `@composio/core` end-to-end tests in isolated Docker environments.+Shared infrastructure for running `@composio/core` and CLI end-to-end tests in isolated Docker environments.## What's Here@@ -10,6 +10,7 @@ Shared infrastructure for running `@composio/core` end-to-end tests in isolated| `scripts/` | Docker build and cleanup scripts || `Dockerfile.node` | Multi-stage Dockerfile for Node.js test environments || `Dockerfile.deno` | Dockerfile for Deno test environments |+| `Dockerfile.cli` | Scratch Dockerfile for CLI test environments |## API@@ -26,6 +27,7 @@ e2e(import.meta.url, {versions: {node: ['20.18.0', '20.19.0', '22.12.0'], // optional, defaults to .nvmrcdeno: ['2.6.7'], // optional, defaults to .dvmrc+ cli: ['current'], // optional, defaults to CLI package.json version},env: { MY_VAR: 'value' }, // optional env varsdefineTests: ({ runtime, runCmd, runFixture }) => {@@ -61,6 +63,7 @@ Configuration object passed to `e2e()`:| -------- | -------------------------------- | ------------------------------------------------ || `node` | `readonly NodeVersionFromUser[]` | Node.js versions. Defaults to `.nvmrc` || `deno` | `readonly DenoVersionFromUser[]` | Deno versions. Defaults to `.dvmrc` |+| `cli` | `readonly CliVersionFromUser[]` | CLI versions. Defaults to CLI package.json |### `DefineTestsContext`@@ -68,7 +71,7 @@ The context passed to the `defineTests` callback:| Property | Type/Signature | Description || ------------ | ---------------------------------------------------------------- | ---------------------------------------------- |-| `runtime` | `'node' \| 'deno'` | Current runtime being tested |+| `runtime` | `'node' \| 'deno' \| 'cli'` | Current runtime being tested || `runCmd` | `(command: string) => Promise<E2ETestResult>` | Run arbitrary command in Docker container || `runFixture` | `(options: RunFixtureOptions) => Promise<E2ETestResult \| E2ETestResultWithSetup>` | Run fixture with optional setup phase |@@ -111,6 +114,21 @@ interface E2ETestResult {}```+### `runCmd` with File Capture++When you need to assert on files created inside the container, pass a `files` array:++```typescript+const result = await runCmd({+ command: 'composio version > out.txt',+ files: ['out.txt'],+});++expect(result.files['out.txt']).toBe('0.1.24');+```++The files are copied out of the container after execution and returned as a map in the result.+### `E2ETestResultWithSetup`Extended result when `runFixture` is called with a `setup` option:@@ -190,6 +208,18 @@ The following versions are pre-defined in `const.ts`:- `2.6.7`- `current` (resolves to `.dvmrc` version)+### CLI Version Resolution++CLI versions to test are resolved in this order:++1. **`COMPOSIO_E2E_CLI_VERSION` env var** (highest priority): Use `[env_value]`+2. **`config.versions.cli`**: Use the provided array+3. **Default**: Use version from `ts/packages/cli/package.json`++### Well-Known CLI Versions++- `current` (resolves to CLI package.json version)+## Environment Variable ValidationEnvironment variables passed to `E2EConfig.env` are validated at test startup. If any variable has an `undefined` value, the test fails fast with a clear error message:@@ -231,10 +261,10 @@ e2e(import.meta.url, {## Scripts```bash-# Pre-build Docker images for all well-known Node and Deno versions+# Pre-build Docker images for all well-known Node, Deno, and CLI versionspnpm docker:build-# Remove all e2e Docker images (both Node.js and Deno)+# Remove all e2e Docker images (Node.js, Deno, and CLI)pnpm docker:clean```diff --git a/ts/e2e-tests/_utils/scripts/docker-build.ts b/ts/e2e-tests/_utils/scripts/docker-build.tsindex aae07abac..4816f7a1c 100644--- a/ts/e2e-tests/_utils/scripts/docker-build.ts+++ b/ts/e2e-tests/_utils/scripts/docker-build.ts@@ -1,9 +1,9 @@#!/usr/bin/env bun/**- * Builds Docker images for Node.js and Deno e2e tests.+ * Builds Docker images for Node.js, Deno, and CLI e2e tests.*- * In CI mode (COMPOSIO_E2E_NODE_VERSION or COMPOSIO_E2E_DENO_VERSION set):- * Only builds the image for the specified version.+ * In CI mode (COMPOSIO_E2E_NODE_VERSION or COMPOSIO_E2E_DENO_VERSION or COMPOSIO_E2E_CLI_VERSION set):+ * Only builds the image for the specified version(s).** In local mode:* Builds images for all versions in WELL_KNOWN_NODE_VERSIONS and WELL_KNOWN_DENO_VERSIONS.@@ -38,6 +38,15 @@ function getDvmrcVersion(repoRoot: string): string {}}+function getCliPackageVersion(repoRoot: string): string {+ const pkg = readFileSync(resolve(repoRoot, 'ts/packages/cli/package.json'), 'utf-8');+ const parsed = JSON.parse(pkg) as { version?: string };+ if (!parsed.version) {+ throw new Error('Missing version in ts/packages/cli/package.json');+ }+ return String(parsed.version).trim();+}+// ============================================================================// Node.js image building// ============================================================================@@ -118,6 +127,46 @@ async function buildDenoImage(denoVersion: string, repoRoot: string): Promise<boreturn true;}+// ============================================================================+// CLI image building+// ============================================================================++function imageTagForCliVersion(cliVersion: string): string {+ return `composio-e2e-cli:${cliVersion}`;+}++function defaultCliLabels(cliVersion: string): Record<string, string> {+ return {+ 'composio.e2e': 'true',+ 'composio.runtime': 'cli',+ 'composio.cli_version': cliVersion,+ };+}++async function buildCliImage(cliVersion: string, repoRoot: string): Promise<boolean> {+ const dockerfilePath = resolve(repoRoot, 'ts/e2e-tests/_utils/Dockerfile.cli');+ const imageTag = imageTagForCliVersion(cliVersion);+ const labels = defaultCliLabels(cliVersion);+ const labelArgs = Object.entries(labels)+ .map(([k, v]) => `--label=${k}=${v}`)+ .join(' ');++ console.log(`\nBuilding image for CLI ${cliVersion}...`);++ const result = await $`docker build -f ${dockerfilePath} --build-arg CLI_VERSION=${cliVersion} ${{ raw: labelArgs }} -t ${imageTag} ${repoRoot}`+ .cwd(repoRoot)+ .nothrow();++ if (result.exitCode !== 0) {+ console.error(` Failed to build ${imageTag}:`);+ console.error(result.stderr.toString() || result.stdout.toString());+ return false;+ }++ console.log(` Built ${imageTag}`);+ return true;+}+// ============================================================================// Main// ============================================================================@@ -126,17 +175,20 @@ async function main() {const repoRoot = getRepoRoot();const currentNodeVersion = getNvmrcVersion(repoRoot);const currentDenoVersion = getDvmrcVersion(repoRoot);+ const currentCliVersion = getCliPackageVersion(repoRoot);const envNodeVersion = Bun.env.COMPOSIO_E2E_NODE_VERSION;const envDenoVersion = Bun.env.COMPOSIO_E2E_DENO_VERSION;+ const envCliVersion = Bun.env.COMPOSIO_E2E_CLI_VERSION;const nodeVersions = new Set<string>();const denoVersions = new Set<string>();+ const cliVersions = new Set<string>();// Determine which Node.js versions to buildif (envNodeVersion) {nodeVersions.add(envNodeVersion);console.log(`Building Docker image for CI matrix Node.js version: ${envNodeVersion}`);- } else if (!envDenoVersion) {+ } else if (!envDenoVersion && !envCliVersion) {// Build all Node.js versions only if no specific runtime was requestedfor (const version of WELL_KNOWN_NODE_VERSIONS) {if (version === 'current') {@@ -158,7 +210,7 @@ async function main() {if (envDenoVersion) {denoVersions.add(envDenoVersion);console.log(`Building Docker image for CI matrix Deno version: ${envDenoVersion}`);- } else if (!envNodeVersion) {+ } else if (!envNodeVersion && !envCliVersion) {// Build all Deno versions only if no specific runtime was requestedfor (const version of WELL_KNOWN_DENO_VERSIONS) {if (version === 'current') {@@ -176,6 +228,15 @@ async function main() {}}+ // Determine which CLI versions to build+ if (envCliVersion) {+ cliVersions.add(envCliVersion);+ console.log(`Building Docker image for CI matrix CLI version: ${envCliVersion}`);+ } else if (!envNodeVersion && !envDenoVersion) {+ cliVersions.add(currentCliVersion);+ console.log(`Building Docker image for CLI version: ${currentCliVersion}`);+ }+let failed = 0;let total = 0;@@ -197,6 +258,15 @@ async function main() {}}+ // Build CLI images+ for (const version of cliVersions) {+ total++;+ const success = await buildCliImage(version, repoRoot);+ if (!success) {+ failed++;+ }+ }+console.log('\n---');console.log(`Built ${total - failed}/${total} images.`);diff --git a/ts/e2e-tests/_utils/scripts/docker-clean.ts b/ts/e2e-tests/_utils/scripts/docker-clean.tsindex 6554c726e..f9f73c9e6 100644--- a/ts/e2e-tests/_utils/scripts/docker-clean.ts+++ b/ts/e2e-tests/_utils/scripts/docker-clean.ts@@ -1,13 +1,14 @@#!/usr/bin/env bun/**- * Removes all Docker images used by Node.js and Deno e2e tests.+ * Removes all Docker images used by Node.js, Deno, and CLI e2e tests.* Images are identified by the label `composio.e2e=true`.*/import { $ } from 'bun';-async function cleanImages(runtime: 'node' | 'deno'): Promise<number> {- console.log(`Finding e2e ${runtime === 'node' ? 'Node.js' : 'Deno'} Docker images...`);+async function cleanImages(runtime: 'node' | 'deno' | 'cli'): Promise<number> {+ const runtimeLabel = runtime === 'node' ? 'Node.js' : runtime === 'deno' ? 'Deno' : 'CLI';+ console.log(`Finding e2e ${runtimeLabel} Docker images...`);// Find all images with the e2e labelsconst result = await $`docker images --filter label=composio.e2e=true --filter label=composio.runtime=${runtime} --format {{.Repository}}:{{.Tag}}`@@ -26,7 +27,7 @@ async function cleanImages(runtime: 'node' | 'deno'): Promise<number> {.filter((img) => img.length > 0 && !img.includes('<none>'));if (images.length === 0) {- console.log(`No e2e ${runtime === 'node' ? 'Node.js' : 'Deno'} Docker images found.`);+ console.log(`No e2e ${runtimeLabel} Docker images found.`);return 0;}@@ -59,6 +60,9 @@ async function main() {// Clean Deno imagestotalFailures += await cleanImages('deno');+ // Clean CLI images+ totalFailures += await cleanImages('cli');+if (totalFailures > 0) {console.error(`\nFailed to remove ${totalFailures} image(s).`);process.exit(1);diff --git a/ts/e2e-tests/_utils/src/config.ts b/ts/e2e-tests/_utils/src/config.tsindex 54cbab736..6a0f605ae 100644--- a/ts/e2e-tests/_utils/src/config.ts+++ b/ts/e2e-tests/_utils/src/config.ts@@ -2,13 +2,23 @@ import { dirname, resolve } from 'node:path';import { fileURLToPath } from 'node:url';import { readFileSync } from 'node:fs';import process from 'node:process';-import type { NodeVersionMeta, NodeVersionFromUser, DenoVersionMeta, DenoVersionFromUser, SkipInCI, NonEmptyArray } from './types';+import type {+ NodeVersionMeta,+ NodeVersionFromUser,+ DenoVersionMeta,+ DenoVersionFromUser,+ CliVersionMeta,+ CliVersionFromUser,+ SkipInCI,+ NonEmptyArray,+} from './types';declare module 'bun' {interface Env {CI?: string;COMPOSIO_E2E_NODE_VERSION?: string;COMPOSIO_E2E_DENO_VERSION?: string;+ COMPOSIO_E2E_CLI_VERSION?: string;}}@@ -123,6 +133,23 @@ export function getDvmrcVersion(): string {}}+/**+ * Read the CLI version from ts/packages/cli/package.json.+ * Used to determine the version for 'current' tests.+ */+export function getCliPackageVersion(): string {+ try {+ const pkg = readFileSync(resolve(getRepoRoot(), 'ts/packages/cli/package.json'), 'utf-8');+ const parsed = JSON.parse(pkg) as { version?: string };+ if (!parsed.version) {+ throw new Error('Missing version field');+ }+ return String(parsed.version).trim();+ } catch (err) {+ throw new Error(`Failed to read CLI version from ts/packages/cli/package.json: ${(err as Error).message}`);+ }+}+/*** Compute skip state for a Deno version in CI mode.*/@@ -144,6 +171,27 @@ function computeSkipForDenoVersion(return { value: false };}+/**+ * Compute skip state for a CLI version in CI mode.+ */+function computeSkipForCliVersion(+ envVersion: string | undefined,+ versionValue: string+): SkipInCI {+ if (!isCI() || !envVersion) {+ return { value: false };+ }++ if (versionValue !== envVersion) {+ return {+ value: true,+ reason: `CLI ${versionValue} not selected (running ${envVersion})`,+ };+ }++ return { value: false };+}+/*** Resolve the Deno versions to test against, with CI skip state.*@@ -185,3 +233,40 @@ export function resolveDenoVersionMetaList(return resolvedVersions as NonEmptyArray<DenoVersionMeta>;}+/**+ * Resolve the CLI versions to test against, with CI skip state.+ *+ * The `'current'` version always resolves to the value in ts/packages/cli/package.json.+ *+ * In CI mode (CI env var set + COMPOSIO_E2E_CLI_VERSION set):+ * - Versions not matching COMPOSIO_E2E_CLI_VERSION are marked to skip+ *+ * In local mode:+ * - COMPOSIO_E2E_CLI_VERSION overrides everything (single version, no skip)+ * - Otherwise returns all configured versions (no skip)+ */+export function resolveCliVersionMetaList(+ configCliVersions?: readonly CliVersionFromUser[]+): NonEmptyArray<CliVersionMeta> {+ const envVersion = Bun.env.COMPOSIO_E2E_CLI_VERSION;+ const currentVersion = getCliPackageVersion();++ // Local mode with env override: single version, no skip+ if (!isCI() && envVersion) {+ return [{ kind: 'overridden', value: envVersion, skip: { value: false } }];+ }++ // No config provided: use package.json version+ if (configCliVersions === undefined || configCliVersions.length === 0) {+ return [{ kind: 'current', value: currentVersion, skip: { value: false } }];+ }++ const resolvedVersions = configCliVersions.map((v): CliVersionMeta => {+ if (v === 'current') {+ return { kind: 'current', value: currentVersion, skip: computeSkipForCliVersion(envVersion, currentVersion) };+ }+ return { kind: 'static', value: v, skip: computeSkipForCliVersion(envVersion, v) };+ });++ return resolvedVersions as NonEmptyArray<CliVersionMeta>;+}diff --git a/ts/e2e-tests/_utils/src/const.ts b/ts/e2e-tests/_utils/src/const.tsindex 7efdc41a5..09eda9971 100644--- a/ts/e2e-tests/_utils/src/const.ts+++ b/ts/e2e-tests/_utils/src/const.ts@@ -15,6 +15,12 @@ export const WELL_KNOWN_NODE_VERSIONS = ['20.18.0', '20.19.0', '22.12.0', 'curre*/export const WELL_KNOWN_DENO_VERSIONS = ['2.6.7', 'current'] as const;+/**+ * CLI versions that are well-known to the CI strategy.+ * `current` refers to the version in ts/packages/cli/package.json.+ */+export const WELL_KNOWN_CLI_VERSIONS = ['current'] as const;+export const TIMEOUTS = {DEFAULT: 5_000,FIXTURE: 120_000,diff --git a/ts/e2e-tests/_utils/src/image-lifecycle.ts b/ts/e2e-tests/_utils/src/image-lifecycle.tsindex 906dd5907..e479a2d9e 100644--- a/ts/e2e-tests/_utils/src/image-lifecycle.ts+++ b/ts/e2e-tests/_utils/src/image-lifecycle.ts@@ -53,6 +53,8 @@ export interface RunNodeContainerOptions {env?: Record<string, string | undefined>;labels?: Record<string, string>;name?: string;+ /** Whether to auto-remove the container after exit (default: true) */+ remove?: boolean;}/**@@ -106,6 +108,20 @@ function defaultDenoLabels(denoVersion?: string): Record<string, string> {return labels;}+/**+ * Creates default Docker labels for CLI e2e images.+ */+function defaultCliLabels(cliVersion?: string): Record<string, string> {+ const labels: Record<string, string> = {+ 'composio.e2e': 'true',+ 'composio.runtime': 'cli',+ };+ if (cliVersion) {+ labels['composio.cli_version'] = cliVersion;+ }+ return labels;+}+/*** Converts labels object to Docker CLI arguments array.*/@@ -224,7 +240,7 @@ export async function ensureNodeImage(* Runs a command in a Node Docker container.*/export async function runNodeContainer(options: RunNodeContainerOptions): Promise<ExecResult> {- const { imageTag, cmd, cwd, mounts, volumes, env, labels, name } = options;+ const { imageTag, cmd, cwd, mounts, volumes, env, labels, name, remove } = options;// Validate imageTag is provided, as it determines which Docker image to run.if (!imageTag || typeof imageTag !== 'string') {@@ -233,7 +249,10 @@ export async function runNodeContainer(options: RunNodeContainerOptions): Promisconst nodeVersion = parseNodeVersionFromImageTag(imageTag);- const dockerArgs = ['run', '--rm'];+ const dockerArgs = ['run'];+ if (remove !== false) {+ dockerArgs.push('--rm');+ }dockerArgs.push(...labelsToArgs({ ...defaultNodeLabels(nodeVersion), ...(labels ?? {}) }));@@ -317,6 +336,8 @@ export interface RunDenoContainerOptions {env?: Record<string, string | undefined>;labels?: Record<string, string>;name?: string;+ /** Whether to auto-remove the container after exit (default: true) */+ remove?: boolean;}/**@@ -398,7 +419,7 @@ export async function ensureDenoImage(* Runs a command in a Deno Docker container.*/export async function runDenoContainer(options: RunDenoContainerOptions): Promise<ExecResult> {- const { imageTag, cmd, cwd, mounts, volumes, env, labels, name } = options;+ const { imageTag, cmd, cwd, mounts, volumes, env, labels, name, remove } = options;// Validate imageTag is provided, as it determines which Docker image to run.if (!imageTag || typeof imageTag !== 'string') {@@ -407,7 +428,10 @@ export async function runDenoContainer(options: RunDenoContainerOptions): Promisconst denoVersion = parseDenoVersionFromImageTag(imageTag);- const dockerArgs = ['run', '--rm'];+ const dockerArgs = ['run'];+ if (remove !== false) {+ dockerArgs.push('--rm');+ }dockerArgs.push(...labelsToArgs({ ...defaultDenoLabels(denoVersion), ...(labels ?? {}) }));@@ -474,3 +498,168 @@ export async function runDenoContainer(options: RunDenoContainerOptions): Promisreturn exec('docker', dockerArgs);}++// ============================================================================+// CLI Docker utilities+// ============================================================================++/**+ * Options for running a CLI container.+ */+export interface RunCliContainerOptions {+ imageTag: string;+ cmd: string | string[];+ cwd?: string;+ mounts?: DockerMount[];+ /** Named volume mounts (volumes must be created beforehand with `docker volume create`) */+ volumes?: DockerVolumeMount[];+ env?: Record<string, string | undefined>;+ labels?: Record<string, string>;+ name?: string;+ /** Whether to auto-remove the container after exit (default: true) */+ remove?: boolean;+}++/**+ * Options for ensureCliImage.+ */+export interface EnsureCliImageOptions {+ repoRoot?: string;+ dockerfilePath?: string;+}++/**+ * Creates image tag for a given CLI version.+ */+function imageTagForCliVersion(cliVersion: string): string {+ return `composio-e2e-cli:${cliVersion}`;+}++/**+ * Parses CLI version from an image tag.+ */+function parseCliVersionFromImageTag(imageTag: string): string | undefined {+ const match = /^composio-e2e-cli:(.+)$/.exec(imageTag);+ return match?.[1];+}++/**+ * Ensures a Docker image exists for the given CLI version, building it if necessary.+ */+export async function ensureCliImage(+ cliVersion: string,+ options: EnsureCliImageOptions = {}+): Promise<string> {+ if (!cliVersion || typeof cliVersion !== 'string') {+ throw new Error(`ensureCliImage(${cliVersion}): cliVersion must be a non-empty string`);+ }++ const repoRoot = options.repoRoot ?? getRepoRoot();+ const dockerfilePath = options.dockerfilePath ?? resolve(repoRoot, 'ts/e2e-tests/_utils/Dockerfile.cli');+ const imageTag = imageTagForCliVersion(cliVersion);++ const inspect = await exec('docker', ['image', 'inspect', imageTag], { cwd: repoRoot });+ if (inspect.exitCode === 0) {+ return imageTag;+ }++ const buildArgs = [+ 'build',+ '-f',+ dockerfilePath,+ '--build-arg',+ `CLI_VERSION=${cliVersion}`,+ ...labelsToArgs(defaultCliLabels(cliVersion)),+ '-t',+ imageTag,+ repoRoot,+ ];++ const built = await exec('docker', buildArgs, { cwd: repoRoot });+ if (built.exitCode !== 0) {+ const output = built.stderr || built.stdout;+ if (output.includes('already exists')) {+ const recheck = await exec('docker', ['image', 'inspect', imageTag], { cwd: repoRoot });+ if (recheck.exitCode === 0) {+ return imageTag;+ }+ }++ const err = new Error(`Failed to build Docker image ${imageTag}`);+ (err as Error & { cause: Error }).cause = new Error(output);+ throw err;+ }++ return imageTag;+}++/**+ * Runs a command in a CLI Docker container.+ */+export async function runCliContainer(options: RunCliContainerOptions): Promise<ExecResult> {+ const { imageTag, cmd, cwd, mounts, volumes, env, labels, name, remove } = options;++ if (!imageTag || typeof imageTag !== 'string') {+ throw new Error('runCliContainer({ imageTag, ... }): imageTag must be a non-empty string');+ }++ const cliVersion = parseCliVersionFromImageTag(imageTag);++ const dockerArgs = ['run'];+ if (remove !== false) {+ dockerArgs.push('--rm');+ }++ dockerArgs.push(...labelsToArgs({ ...defaultCliLabels(cliVersion), ...(labels ?? {}) }));++ if (name) {+ dockerArgs.push('--name', name);+ }++ if (cwd) {+ const containerCwd = cwd.startsWith('/') ? cwd : `/app/${cwd}`;+ dockerArgs.push('--workdir', containerCwd);+ }++ if (env) {+ for (const [k, v] of Object.entries(env)) {+ if (v === undefined) continue;+ dockerArgs.push('-e', `${k}=${v}`);+ }+ }++ if (mounts) {+ for (const m of mounts) {+ if (!m?.source || !m?.target) {+ throw new Error('runCliContainer(...): each mount must have { source, target }');+ }+ const parts = [`type=bind`, `src=${m.source}`, `dst=${m.target}`];+ if (m.readonly) parts.push('readonly');+ dockerArgs.push('--mount', parts.join(','));+ }+ }++ if (volumes) {+ for (const v of volumes) {+ if (!v?.volume || !v?.target) {+ throw new Error('runCliContainer(...): each volume must have { volume, target }');+ }+ const parts = [`type=volume`, `src=${v.volume}`, `dst=${v.target}`];+ if (v.readonly) parts.push('readonly');+ dockerArgs.push('--mount', parts.join(','));+ }+ }++ dockerArgs.push(imageTag);++ if (Array.isArray(cmd)) {+ dockerArgs.push(...cmd.map(String));+ } else if (typeof cmd === 'string' && cmd.length > 0) {+ // Use -c (not -lc) for busybox sh compatibility in scratch images+ dockerArgs.push('sh', '-c', cmd);+ } else {+ throw new Error('runCliContainer({ cmd, ... }): cmd must be a non-empty string or string[]');+ }++ return exec('docker', dockerArgs);+}diff --git a/ts/e2e-tests/_utils/src/index.ts b/ts/e2e-tests/_utils/src/index.tsindex 61a26e38c..bfe3197c1 100644--- a/ts/e2e-tests/_utils/src/index.ts+++ b/ts/e2e-tests/_utils/src/index.ts@@ -2,10 +2,12 @@ export type {E2EConfig,E2ETestResult,E2ETestResultWithSetup,+ E2ETestResultWithFiles,RunFixtureOptions,DefineTestsContext,NodeVersionMeta as NodeVersion,DenoVersionMeta as DenoVersion,+ CliVersionMeta as CliVersion,RuntimeVersions,RuntimeKind,SkipInCI,diff --git a/ts/e2e-tests/_utils/src/runner.ts b/ts/e2e-tests/_utils/src/runner.tsindex 42e4b34ba..e93f9af58 100644--- a/ts/e2e-tests/_utils/src/runner.ts+++ b/ts/e2e-tests/_utils/src/runner.ts@@ -1,20 +1,37 @@import { describe, beforeAll, afterAll, it } from 'bun:test';-import { appendFile, writeFile } from 'node:fs/promises';-import { resolve } from 'node:path';+import { $ } from 'bun';+import { appendFile, writeFile, mkdtemp, readFile, rm } from 'node:fs/promises';+import { resolve, join } from 'node:path';+import { tmpdir } from 'node:os';import type {DefineTestsContext,E2EConfig,E2ETestResult,E2ETestResultWithSetup,+ E2ETestResultWithFiles,NodeVersionMeta,DenoVersionMeta,+ CliVersionMeta,NonEmptyString,RunFixtureOptions,+ RunCmdOptions,RuntimeVersions,RuntimeKind,} from './types';-import { getRepoRoot, resolveNodeVersionMetaList, resolveDenoVersionMetaList } from './config';-import { ensureNodeImage, runNodeContainer, ensureDenoImage, runDenoContainer } from './image-lifecycle';+import {+ getRepoRoot,+ resolveNodeVersionMetaList,+ resolveDenoVersionMetaList,+ resolveCliVersionMetaList,+} from './config';+import {+ ensureNodeImage,+ runNodeContainer,+ ensureDenoImage,+ runDenoContainer,+ ensureCliImage,+ runCliContainer,+} from './image-lifecycle';import { WELL_KNOWN_ENV_VARS } from './const';import { createVolume, generateVolumeName, initializeVolumeOwnership, removeVolume } from './volume';@@ -123,7 +140,8 @@ class DebugLogManager {private formatVersionSection(result: VersionResult): string {const dividerHeavy = '#'.repeat(80);- const runtimeLabel = result.runtime === 'node' ? 'Node.js' : 'Deno';+ const runtimeLabel =+ result.runtime === 'node' ? 'Node.js' : result.runtime === 'deno' ? 'Deno' : 'CLI';const lines: string[] = ['',dividerHeavy,@@ -181,7 +199,8 @@ class DebugLogManager {];for (const result of this.versionResults) {- const runtimeLabel = result.runtime === 'node' ? 'Node.js' : 'Deno';+ const runtimeLabel =+ result.runtime === 'node' ? 'Node.js' : result.runtime === 'deno' ? 'Deno' : 'CLI';if (result.status === 'skipped') {lines.push(`${runtimeLabel} ${result.version}: SKIPPED`);} else {@@ -258,6 +277,59 @@ function validateRequiredEnvVars(}}+// ============================================================================+// Command execution helpers+// ============================================================================++type RunCmdInput = string | RunCmdOptions;++function normalizeRunCmdInput(input: RunCmdInput): { command: string; files?: string[] } {+ if (typeof input === 'string') {+ return { command: input };+ }+ return { command: input.command, files: input.files };+}++function toContainerCwd(cwd: string): string {+ return cwd.startsWith('/') ? cwd : `/app/${cwd}`;+}++async function dockerCp(source: string, destination: string): Promise<void> {+ const result = await $`docker cp ${source} ${destination}`.nothrow();+ if (result.exitCode !== 0) {+ const details = (result.stderr || result.stdout).toString().trim();+ throw new Error(`docker cp failed: ${details || 'unknown error'}`);+ }+}++async function dockerRm(containerName: string): Promise<void> {+ await $`docker rm ${containerName}`.nothrow();+}++async function captureFilesFromContainer(options: {+ containerName: string;+ containerCwd: string;+ files: string[];+}): Promise<Record<string, string>> {+ const { containerName, containerCwd, files } = options;+ const tempDir = await mkdtemp(join(tmpdir(), 'composio-e2e-files-'));+ const outputs: Record<string, string> = {};++ try {+ for (const file of files) {+ const containerPath = file.startsWith('/') ? file : `${containerCwd}/${file}`;+ const safeName = file.replace(/^\/+/, '').replace(/[\\/]/g, '__');+ const hostPath = join(tempDir, safeName);+ await dockerCp(`${containerName}:${containerPath}`, hostPath);+ outputs[file] = await readFile(hostPath, 'utf-8');+ }+ } finally {+ await rm(tempDir, { recursive: true, force: true });+ }++ return outputs;+}+/*** Internal configuration for runE2E.*/@@ -299,7 +371,9 @@ function createNodeDockerExecutors(imageTag,};- const runCmd = async (command: string): Promise<E2ETestResult> => {+ const runCmd = async (input: RunCmdInput): Promise<E2ETestResult | E2ETestResultWithFiles> => {+ const { command, files } = normalizeRunCmdInput(input);+ const shouldCapture = Array.isArray(files) && files.length > 0;const containerName = `e2e-${suiteName}-node-${nodeVersion.replace(/\./g, '-')}-${Date.now()}`;const startTime = Date.now();@@ -309,6 +383,7 @@ function createNodeDockerExecutors(cwd: effectiveCwd,env: containerEnv,name: containerName,+ remove: !shouldCapture,});const durationMs = Date.now() - startTime;@@ -325,6 +400,20 @@ function createNodeDockerExecutors(stderr: result.stderr,});+ if (shouldCapture) {+ const containerCwd = toContainerCwd(effectiveCwd);+ try {+ const captured = await captureFilesFromContainer({+ containerName,+ containerCwd,+ files: files as string[],+ });+ return { ...result, files: captured };+ } finally {+ await dockerRm(containerName);+ }+ }+return result;};@@ -448,7 +537,9 @@ function createDenoDockerExecutors(imageTag,};- const runCmd = async (command: string): Promise<E2ETestResult> => {+ const runCmd = async (input: RunCmdInput): Promise<E2ETestResult | E2ETestResultWithFiles> => {+ const { command, files } = normalizeRunCmdInput(input);+ const shouldCapture = Array.isArray(files) && files.length > 0;const containerName = `e2e-${suiteName}-deno-${denoVersion.replace(/\./g, '-')}-${Date.now()}`;const startTime = Date.now();@@ -458,6 +549,7 @@ function createDenoDockerExecutors(cwd: effectiveCwd,env: containerEnv,name: containerName,+ remove: !shouldCapture,});const durationMs = Date.now() - startTime;@@ -474,6 +566,20 @@ function createDenoDockerExecutors(stderr: result.stderr,});+ if (shouldCapture) {+ const containerCwd = toContainerCwd(effectiveCwd);+ try {+ const captured = await captureFilesFromContainer({+ containerName,+ containerCwd,+ files: files as string[],+ });+ return { ...result, files: captured };+ } finally {+ await dockerRm(containerName);+ }+ }+return result;};@@ -571,6 +677,98 @@ function createDenoDockerExecutors(return { runCmd, runFixture, finalizeVersionLog, context };}+// ============================================================================+// CLI Docker Executors+// ============================================================================++/**+ * Creates Docker execution utilities for a specific CLI version.+ */+function createCliDockerExecutors(+ config: RunE2EInternalConfig,+ cliVersion: string,+ imageTag: string,+ repoRoot: string,+ logManager: DebugLogManager+) {+ const { cwd, suiteName, env, usesFixtures } = config;+ const containerEnv = buildContainerEnv(env);+ const effectiveCwd = usesFixtures ? `${cwd}/fixtures` : cwd;++ const context: VersionExecutionContext = {+ phases: [],+ versionStartTime: Date.now(),+ imageTag,+ };++ const runCmd = async (input: RunCmdInput): Promise<E2ETestResult | E2ETestResultWithFiles> => {+ const { command, files } = normalizeRunCmdInput(input);+ const shouldCapture = Array.isArray(files) && files.length > 0;+ const containerName = `e2e-${suiteName}-cli-${cliVersion.replace(/\./g, '-')}-${Date.now()}`;+ const startTime = Date.now();++ const result = await runCliContainer({+ imageTag,+ cmd: command,+ cwd: effectiveCwd,+ env: containerEnv,+ name: containerName,+ remove: !shouldCapture,+ });++ const durationMs = Date.now() - startTime;++ context.phases.push({+ phase: 'fixture',+ phaseIndex: context.phases.length + 1,+ totalPhases: context.phases.length + 1,+ command,+ containerName,+ durationMs,+ exitCode: result.exitCode,+ stdout: result.stdout,+ stderr: result.stderr,+ });++ if (shouldCapture) {+ const containerCwd = toContainerCwd(effectiveCwd);+ try {+ const captured = await captureFilesFromContainer({+ containerName,+ containerCwd,+ files: files as string[],+ });+ return { ...result, files: captured };+ } finally {+ await dockerRm(containerName);+ }+ }++ return result;+ };++ const runFixture = ((_: RunFixtureOptions) => {+ throw new Error('runFixture is not supported for CLI runtime tests');+ }) as DefineTestsContext['runFixture'];++ const finalizeVersionLog = async (): Promise<void> => {+ const totalDurationMs = Date.now() - context.versionStartTime;+ const allPassed = context.phases.every(p => p.exitCode === 0);+ const status: 'pass' | 'fail' = allPassed ? 'pass' : 'fail';++ await logManager.writeVersionSection({+ runtime: 'cli',+ version: cliVersion,+ status,+ imageTag: context.imageTag,+ phases: context.phases,+ totalDurationMs,+ });+ };++ return { runCmd, runFixture, finalizeVersionLog, context };+}+// ============================================================================// Version normalization and resolution// ============================================================================@@ -582,7 +780,7 @@ function normalizeVersionConfig(config: E2EConfig): RuntimeVersions {if (config.versions) {return config.versions;}- // Default: use current version for Node.js and Deno+ // Default: use current version for Node.js and Deno (CLI is opt-in)return { node: ['current'], deno: ['current'] };}@@ -614,6 +812,20 @@ function renderDenoVersionMeta({ kind, value }: DenoVersionMeta): string {}}+/**+ * Render a CLI version meta for display in test names.+ */+function renderCliVersionMeta({ kind, value }: CliVersionMeta): string {+ switch (kind) {+ case 'current':+ return `CLI ${value} [current]`;+ case 'overridden':+ return `CLI ${value} [overridden]`;+ case 'static':+ return `CLI ${value}`;+ }+}+// ============================================================================// Main test runner// ============================================================================@@ -622,7 +834,7 @@ function renderDenoVersionMeta({ kind, value }: DenoVersionMeta): string {* Runs e2e tests using bun:test.* Creates a describe block per runtime version and passes test utilities to defineTests.*- * Supports both Node.js and Deno runtimes.+ * Supports Node.js, Deno, and CLI runtimes.* In CI mode, versions not matching their respective env vars are skipped.*/export function runE2E(config: RunE2EInternalConfig): void {@@ -637,11 +849,13 @@ export function runE2E(config: RunE2EInternalConfig): void {// Resolve versions for each runtimeconst nodeVersionMetaList = versions.node ? resolveNodeVersionMetaList(versions.node) : [];const denoVersionMetaList = versions.deno ? resolveDenoVersionMetaList(versions.deno) : [];+ const cliVersionMetaList = versions.cli ? resolveCliVersionMetaList(versions.cli) : [];// Build runtime version labels for loggingconst allRuntimeVersions = [...nodeVersionMetaList.map(v => `Node.js ${v.value}`),...denoVersionMetaList.map(v => `Deno ${v.value}`),+ ...cliVersionMetaList.map(v => `CLI ${v.value}`),];// Create the debug log manager for structured output@@ -748,6 +962,50 @@ export function runE2E(config: RunE2EInternalConfig): void {});}+ // =========== CLI Tests ===========+ for (const cliVersionMeta of cliVersionMetaList) {+ const testName = renderCliVersionMeta(cliVersionMeta);++ // Skip this version in CI if not selected+ if (cliVersionMeta.skip.value) {+ describe(`${testName} - skipped: ${cliVersionMeta.skip.reason}`, () => {+ beforeAll(async () => {+ await logManager.writeVersionSection({+ runtime: 'cli',+ version: cliVersionMeta.value,+ status: 'skipped',+ reason: cliVersionMeta.skip.reason || 'Skipped in CI',+ phases: [],+ });+ });++ it('this version should not run in this CI job', () => {});+ });+ continue;+ }++ describe(testName, () => {+ let executors: ReturnType<typeof createCliDockerExecutors>;++ beforeAll(async () => {+ const imageTag = await ensureCliImage(cliVersionMeta.value, { repoRoot });+ executors = createCliDockerExecutors(config, cliVersionMeta.value, imageTag, repoRoot, logManager);+ }, 600_000);++ defineTests({+ runtime: 'cli',+ runCmd: (cmd) => executors.runCmd(cmd),+ runFixture: ((opts: RunFixtureOptions) => executors.runFixture(opts)) as DefineTestsContext['runFixture'],+ });++ afterAll(async () => {+ if (executors) {+ await executors.finalizeVersionLog();+ }+ });+ });+ }+// Write summary after all versions completeafterAll(async () => {await logManager.writeSummary();diff --git a/ts/e2e-tests/_utils/src/sanitize.ts b/ts/e2e-tests/_utils/src/sanitize.tsindex 0c7e6328f..952649899 100644--- a/ts/e2e-tests/_utils/src/sanitize.ts+++ b/ts/e2e-tests/_utils/src/sanitize.ts@@ -3,8 +3,9 @@*//**- * Sanitize command output for stable snapshot comparisons.- * Removes ANSI escape codes, normalizes line endings, and trims whitespace.+ * Sanitize command output for stable comparisons.+ * Removes ANSI escape codes, normalizes line endings, and trims leading/trailing+ * whitespace around the first/last meaningful output.** @param output - Raw command output (stdout or stderr)* @returns Sanitized output suitable for assertions and snapshots@@ -16,10 +17,6 @@ export function sanitizeOutput(output: string): string {.replace(/\x1b\[[0-9;]*m/g, '')// Normalize line endings (Windows → Unix).replace(/\r\n/g, '\n')- // Trim trailing whitespace from each line- .split('\n')- .map((line) => line.trimEnd())- .join('\n')// Trim leading/trailing whitespace from entire output.trim());diff --git a/ts/e2e-tests/_utils/src/types.ts b/ts/e2e-tests/_utils/src/types.tsindex fa6a1f3b7..16d04fd89 100644--- a/ts/e2e-tests/_utils/src/types.ts+++ b/ts/e2e-tests/_utils/src/types.ts@@ -1,4 +1,4 @@-import { WELL_KNOWN_NODE_VERSIONS, WELL_KNOWN_DENO_VERSIONS } from './const';+import { WELL_KNOWN_NODE_VERSIONS, WELL_KNOWN_DENO_VERSIONS, WELL_KNOWN_CLI_VERSIONS } from './const';export type NonEmptyArray<T> = [T, ...T[]];@@ -15,6 +15,7 @@ export type NonEmptyString<T extends string> = T extends '' ? never : T;export type NodeVersionFromUser = typeof WELL_KNOWN_NODE_VERSIONS[number];export type DenoVersionFromUser = typeof WELL_KNOWN_DENO_VERSIONS[number];+export type CliVersionFromUser = typeof WELL_KNOWN_CLI_VERSIONS[number];/*** Result of CI skip check for a specific Node version.@@ -42,15 +43,26 @@ export type DenoVersionMeta =| { kind: 'overridden'; value: string; skip: SkipInCI }| { kind: 'current'; value: string; skip: SkipInCI };+/**+ * Metadata for a resolved CLI version to test against.+ * Includes skip state for CI mode.+ */+export type CliVersionMeta =+ | { kind: 'static'; value: string; skip: SkipInCI }+ | { kind: 'overridden'; value: string; skip: SkipInCI }+ | { kind: 'current'; value: string; skip: SkipInCI };+/*** Runtime versions to test against.- * Supports both Node.js and Deno runtimes.+ * Supports Node.js, Deno, and CLI runtimes.*/export interface RuntimeVersions {/** Node.js versions to test */node?: readonly NodeVersionFromUser[];/** Deno versions to test */deno?: readonly DenoVersionFromUser[];+ /** CLI versions to test */+ cli?: readonly CliVersionFromUser[];}/**@@ -65,6 +77,14 @@ export interface E2ETestResult {stderr: string;}+/**+ * Result of executing a command with requested file captures.+ */+export interface E2ETestResultWithFiles extends E2ETestResult {+ /** Captured file contents keyed by requested file path */+ files: Record<string, string>;+}+/*** Result of runFixture when a setup command is provided.* Top-level fields (exitCode, stdout, stderr) reflect the fixture result.@@ -87,7 +107,17 @@ export interface RunFixtureOptions {/*** Supported runtime environments for e2e tests.*/-export type RuntimeKind = 'node' | 'deno';+export type RuntimeKind = 'node' | 'deno' | 'cli';++/**+ * Options for runCmd.+ */+export interface RunCmdOptions {+ /** Command to execute */+ command: string;+ /** Files to copy out of the container after execution */+ files?: string[];+}/*** Context passed to defineTests callback.@@ -96,7 +126,10 @@ export interface DefineTestsContext {/** The runtime environment for this test execution */runtime: RuntimeKind;/** Run an arbitrary command in the Docker container */- runCmd: (command: string) => Promise<E2ETestResult>;+ runCmd: {+ <const C extends string>(command: NonEmptyString<C>): Promise<E2ETestResult>;+ <const C extends string>(options: { command: NonEmptyString<C>; files: NonEmptyArray<string> }): Promise<E2ETestResultWithFiles>;+ };/*** Run a fixture file with Node.js.*@@ -135,7 +168,7 @@ export interface DefineTestsContext {export interface E2EConfig {/*** Runtime versions to test against.- * Supports Node.js and Deno runtimes.+ * Supports Node.js, Deno, and CLI runtimes.** @example* ```typescriptdiff --git a/ts/e2e-tests/cli/version/e2e.test.ts b/ts/e2e-tests/cli/version/e2e.test.tsnew file mode 100644index 000000000..caf84598a--- /dev/null+++ b/ts/e2e-tests/cli/version/e2e.test.ts@@ -0,0 +1,61 @@+/**+ * CLI version command e2e test+ *+ * Verifies that the compiled composio CLI behaves correctly in a scratch container.+ */++import { e2e, sanitizeOutput, type E2ETestResult, type E2ETestResultWithFiles } from '@e2e-tests/utils';+import { TIMEOUTS } from '@e2e-tests/utils/const';+import { describe, it, expect, beforeAll } from 'bun:test';+import cliPkg from '../../../packages/cli/package.json' with { type: 'json' };++e2e(import.meta.url, {+ versions: {+ cli: ['current'],+ },+ defineTests: ({ runCmd }) => {+ const expectedVersion = String(cliPkg.version ?? '').trim();+ let versionResult: E2ETestResult;+ let redirectedResult: E2ETestResultWithFiles;++ beforeAll(async () => {+ versionResult = await runCmd('composio version');+ redirectedResult = await runCmd({+ command: 'composio version > out.txt',+ files: ['out.txt'],+ });+ }, TIMEOUTS.FIXTURE);++ describe('composio version', () => {+ it('exits successfully', () => {+ expect(versionResult.exitCode).toBe(0);+ });++ it('stdout matches snapshot', () => {+ expect(sanitizeOutput(versionResult.stdout)).toBe(expectedVersion);+ });++ it('stderr matches snapshot', () => {+ expect(sanitizeOutput(versionResult.stderr)).toBe('');+ });+ });++ describe('stdout redirection to out.txt', () => {+ it('exits successfully', () => {+ expect(redirectedResult.exitCode).toBe(0);+ });++ it('stdout is empty', () => {+ expect(sanitizeOutput(redirectedResult.stdout)).toBe('');+ });++ it('stderr is empty', () => {+ expect(sanitizeOutput(redirectedResult.stderr)).toBe('');+ });++ it('out.txt matches snapshot', () => {+ expect(sanitizeOutput(redirectedResult.files['out.txt'] ?? '')).toBe(expectedVersion);+ });+ });+ },+});diff --git a/ts/e2e-tests/cli/version/package.json b/ts/e2e-tests/cli/version/package.jsonnew file mode 100644index 000000000..72cc570d2--- /dev/null+++ b/ts/e2e-tests/cli/version/package.json@@ -0,0 +1,14 @@+{+ "name": "@e2e-tests/cli-version",+ "version": "0.0.0",+ "private": true,+ "type": "module",+ "scripts": {+ "typecheck": "tsc --noEmit",+ "test:e2e": "bun test e2e.test.ts",+ "test:e2e:cli": "bun test e2e.test.ts"+ },+ "devDependencies": {+ "@e2e-tests/utils": "workspace:*"+ }+}diff --git a/turbo.jsonc b/turbo.jsoncindex eff0da018..4fdc0c53d 100644--- a/turbo.jsonc+++ b/turbo.jsonc@@ -32,6 +32,11 @@"env": ["COMPOSIO_API_KEY", "COMPOSIO_E2E_DENO_VERSION", "OPENAI_API_KEY"],"cache": false},+ "test:e2e:cli": {+ "dependsOn": ["^build"],+ "env": ["COMPOSIO_API_KEY", "COMPOSIO_E2E_CLI_VERSION", "OPENAI_API_KEY"],+ "cache": false+ },"test:e2e:cloudflare": {"dependsOn": ["^build"],"env": ["COMPOSIO_API_KEY", "OPENAI_API_KEY"],