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
test(cli): add hermetic installer e2e coverage
jkomynodadd2f447179
diff --git a/package.json b/package.jsonindex 2d6e492f0..755170122 100644--- a/package.json+++ b/package.json@@ -34,6 +34,7 @@"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:install": "turbo test:e2e:install --filter='@e2e-tests/cli-install'","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 a53a16195..8975e6765 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -211,6 +211,15 @@ importers:specifier: workspace:*version: link:../../_utils+ ts/e2e-tests/cli/install:+ devDependencies:+ '@e2e-tests/utils':+ specifier: workspace:*+ version: link:../../_utils+ '@types/bun':+ specifier: 'catalog:'+ version: 1.3.14+ts/e2e-tests/cli/setup-plugins:devDependencies:'@e2e-tests/utils':diff --git a/ts/e2e-tests/_utils/Dockerfile.install b/ts/e2e-tests/_utils/Dockerfile.installnew file mode 100644index 000000000..ecba8b153--- /dev/null+++ b/ts/e2e-tests/_utils/Dockerfile.install@@ -0,0 +1,18 @@+FROM debian:bookworm-slim++ARG INSTALL_SHELL=bash++RUN case "$INSTALL_SHELL" in bash|zsh) ;; *) exit 2 ;; esac && \+ apt-get update && \+ apt-get install -y --no-install-recommends bash ca-certificates curl passwd unzip $([ "$INSTALL_SHELL" = zsh ] && printf zsh) && \+ rm -rf /var/lib/apt/lists/* && \+ useradd -m -s "/bin/$INSTALL_SHELL" composio++ENV HOME=/home/composio+ENV SHELL=/bin/$INSTALL_SHELL+ENV PATH=/usr/local/bin:/usr/bin:/bin++USER composio+WORKDIR /home/composio++CMD ["/bin/sh"]diff --git a/ts/e2e-tests/_utils/src/config.ts b/ts/e2e-tests/_utils/src/config.tsindex 2d7b48ca9..52b11f2ba 100644--- a/ts/e2e-tests/_utils/src/config.ts+++ b/ts/e2e-tests/_utils/src/config.ts@@ -1,4 +1,4 @@-import { dirname, resolve } from 'node:path';+import { dirname, isAbsolute, resolve } from 'node:path';import { fileURLToPath } from 'node:url';import { readFileSync } from 'node:fs';import { execFileSync } from 'node:child_process';@@ -12,6 +12,17 @@ import type {SkipInCI,NonEmptyArray,} from './types';+import { INSTALL_E2E_MODES, INSTALL_E2E_SHELLS } from './const';++export type InstallE2EMode = (typeof INSTALL_E2E_MODES)[number];+export type InstallE2EShell = (typeof INSTALL_E2E_SHELLS)[number];++export interface InstallE2EConfig {+ mode: InstallE2EMode;+ shell: InstallE2EShell;+ version: string;+ releaseDir?: string;+}declare module 'bun' {interface Env {@@ -19,7 +30,69 @@ declare module 'bun' {COMPOSIO_E2E_NODE_VERSION?: string;COMPOSIO_E2E_DENO_VERSION?: string;COMPOSIO_E2E_CLI_VERSION?: string;+ COMPOSIO_INSTALL_E2E_MODE?: string;+ COMPOSIO_INSTALL_E2E_SHELL?: string;+ COMPOSIO_INSTALL_E2E_VERSION?: string;+ COMPOSIO_INSTALL_E2E_RELEASE_DIR?: string;+ }+}++function resolveEnumValue<T extends string>(+ name: string,+ value: string | undefined,+ allowed: readonly T[],+ fallback: T+): T {+ const resolved = value || fallback;+ if (!allowed.includes(resolved as T)) {+ throw new Error(`${name} must be one of: ${allowed.join(', ')} (got ${resolved})`);+ }+ return resolved as T;+}++export function resolveInstallE2EConfig(): InstallE2EConfig {+ const mode = resolveEnumValue(+ 'COMPOSIO_INSTALL_E2E_MODE',+ Bun.env.COMPOSIO_INSTALL_E2E_MODE,+ INSTALL_E2E_MODES,+ 'local'+ );+ const shell = resolveEnumValue(+ 'COMPOSIO_INSTALL_E2E_SHELL',+ Bun.env.COMPOSIO_INSTALL_E2E_SHELL,+ INSTALL_E2E_SHELLS,+ 'bash'+ );+ const version = Bun.env.COMPOSIO_INSTALL_E2E_VERSION || 'latest';+ const releaseDir = Bun.env.COMPOSIO_INSTALL_E2E_RELEASE_DIR;++ if (+ version !== 'latest' &&+ !/^@composio\/cli@[0-9]+\.[0-9]+\.[0-9]+(?:-beta\.[0-9]+)?$/.test(version)+ ) {+ throw new Error(+ 'COMPOSIO_INSTALL_E2E_VERSION must be latest or a full @composio/cli release tag'+ );}++ if (mode === 'local') {+ if (!releaseDir) {+ throw new Error('COMPOSIO_INSTALL_E2E_RELEASE_DIR is required in local mode');+ }+ if (!isAbsolute(releaseDir)) {+ throw new Error('COMPOSIO_INSTALL_E2E_RELEASE_DIR must be an absolute path');+ }+ if (version !== 'latest') {+ throw new Error('COMPOSIO_INSTALL_E2E_VERSION is only supported in prod mode');+ }+ }++ return {+ mode,+ shell,+ version,+ releaseDir,+ };}/**diff --git a/ts/e2e-tests/_utils/src/const.ts b/ts/e2e-tests/_utils/src/const.tsindex a15a45640..cdebadf9a 100644--- a/ts/e2e-tests/_utils/src/const.ts+++ b/ts/e2e-tests/_utils/src/const.ts@@ -28,6 +28,12 @@ export const WELL_KNOWN_DENO_VERSIONS = [...toolchainVersions.deno, 'current'] a*/export const WELL_KNOWN_CLI_VERSIONS = ['current'] as const;+export const INSTALL_E2E_SHELLS = ['bash', 'zsh'] as const;++export const INSTALL_E2E_MODES = ['local', 'prod'] as const;++export const INSTALL_E2E_LOCAL_RELEASE_TAG = '@composio/[email protected]';+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 e17382818..4cb0239e6 100644--- a/ts/e2e-tests/_utils/src/image-lifecycle.ts+++ b/ts/e2e-tests/_utils/src/image-lifecycle.ts@@ -714,3 +714,131 @@ export async function runCliContainer(options: RunCliContainerOptions): Promise<return exec('docker', dockerArgs);}++// ============================================================================+// CLI installer Docker utilities+// ============================================================================++export type InstallShell = 'bash' | 'zsh';+export type InstallPlatform = 'linux/amd64' | 'linux/arm64';++export interface EnsureInstallImageOptions {+ repoRoot?: string;+ dockerfilePath?: string;+ platform?: InstallPlatform;+}++export interface RunInstallContainerOptions {+ imageTag: string;+ cmd: string[];+ env?: Record<string, string | undefined>;+ labels?: Record<string, string>;+}++function imageTagForInstallShell(shell: InstallShell): string {+ return `composio-e2e-install:${shell}`;+}++function defaultInstallLabels(shell: InstallShell): Record<string, string> {+ return {+ 'composio.e2e': 'true',+ 'composio.runtime': 'cli-install',+ 'composio.install_shell': shell,+ };+}++export async function ensureInstallImage(+ shell: InstallShell,+ options: EnsureInstallImageOptions = {}+): Promise<string> {+ if (shell !== 'bash' && shell !== 'zsh') {+ throw new Error(`ensureInstallImage(${shell}): shell must be bash or zsh`);+ }++ const repoRoot = options.repoRoot ?? getRepoRoot();+ const dockerfilePath =+ options.dockerfilePath ?? resolve(repoRoot, 'ts/e2e-tests/_utils/Dockerfile.install');+ const platform = options.platform ?? (process.arch === 'arm64' ? 'linux/arm64' : 'linux/amd64');+ const architecture = platform === 'linux/arm64' ? 'arm64' : 'amd64';+ const imageTag = imageTagForInstallShell(shell);+ const inspect = await exec(+ 'docker',+ ['image', 'inspect', '--format', '{{.Architecture}}', imageTag],+ { cwd: repoRoot }+ );+ if (inspect.exitCode === 0 && inspect.stdout.trim() === architecture) {+ return imageTag;+ }++ const built = await exec(+ 'docker',+ [+ 'build',+ '--platform',+ platform,+ '-f',+ dockerfilePath,+ '--build-arg',+ `INSTALL_SHELL=${shell}`,+ ...labelsToArgs(defaultInstallLabels(shell)),+ '-t',+ imageTag,+ repoRoot,+ ],+ { cwd: repoRoot }+ );+ if (built.exitCode !== 0) {+ const err = new Error(`Failed to build Docker image ${imageTag}`);+ (err as Error & { cause: Error }).cause = new Error(built.stderr || built.stdout);+ throw err;+ }++ return imageTag;+}++export async function runInstallContainer(+ options: RunInstallContainerOptions+): Promise<ExecResult> {+ const { imageTag, cmd, env, labels } = options;+ const shellMatch = /^composio-e2e-install:(bash|zsh)$/.exec(imageTag);+ if (!shellMatch) {+ throw new Error(+ 'runInstallContainer({ imageTag, ... }): expected composio-e2e-install:<bash|zsh>'+ );+ }+ if (!Array.isArray(cmd) || cmd.length === 0) {+ throw new Error('runInstallContainer({ cmd, ... }): cmd must be a non-empty array');+ }++ const shell = shellMatch[1] as InstallShell;+ const inspect = await exec('docker', [+ 'image',+ 'inspect',+ '--format',+ '{{.Architecture}}',+ imageTag,+ ]);+ if (inspect.exitCode !== 0) {+ throw new Error(`Failed to inspect Docker image ${imageTag}: ${inspect.stderr}`);+ }+ const platform = inspect.stdout.trim() === 'arm64' ? 'linux/arm64' : 'linux/amd64';+ const dockerArgs = [+ 'run',+ '--rm',+ '--platform',+ platform,+ ...labelsToArgs({ ...defaultInstallLabels(shell), ...(labels ?? {}) }),+ '--add-host',+ 'host.docker.internal:host-gateway',+ ];++ for (const [key, value] of Object.entries(env ?? {})) {+ if (value !== undefined) {+ dockerArgs.push('-e', `${key}=${value}`);+ }+ }++ // Installer tests intentionally do not mount the host's ~/.composio directory.+ dockerArgs.push(imageTag, ...cmd.map(String));+ return exec('docker', dockerArgs);+}diff --git a/ts/e2e-tests/_utils/src/index.ts b/ts/e2e-tests/_utils/src/index.tsindex 151b20535..782da117b 100644--- a/ts/e2e-tests/_utils/src/index.ts+++ b/ts/e2e-tests/_utils/src/index.ts@@ -14,3 +14,10 @@ export type {} from './types';export { e2e } from './e2e';export { sanitizeOutput, parseJsonStdout } from './sanitize';+export { resolveInstallE2EConfig, type InstallE2EConfig } from './config';+export {+ checkDocker,+ ensureInstallImage,+ runInstallContainer,+ type ExecResult,+} from './image-lifecycle';diff --git a/ts/e2e-tests/cli/install/README.md b/ts/e2e-tests/cli/install/README.mdnew file mode 100644index 000000000..be47dd95a--- /dev/null+++ b/ts/e2e-tests/cli/install/README.md@@ -0,0 +1,29 @@+# CLI installer E2E tests++This suite installs the published-style CLI bundle in a clean Debian container. The image has no preinstalled CLI, no `~/.local/bin`, and no host `~/.composio` mount.++## Local mode++Build a `@composio/[email protected]` Linux fixture for the host architecture, then point the suite at the absolute directory containing `composio-linux-x64.zip` or `composio-linux-aarch64.zip` and `checksums.txt`:++```bash+COMPOSIO_INSTALL_E2E_MODE=local \+COMPOSIO_INSTALL_E2E_SHELL=bash \+COMPOSIO_INSTALL_E2E_RELEASE_DIR="$PWD/fixture" \+pnpm test:e2e:install+```++Run the same command with `COMPOSIO_INSTALL_E2E_SHELL=zsh` for the shell-variant and bundle-layout assertions. The host server serves the checked-out installer scripts and the local release fixture without publishing it.++## Production mode++Run the latest stable installer against the live routes:++```bash+COMPOSIO_INSTALL_E2E_MODE=prod \+COMPOSIO_INSTALL_E2E_SHELL=zsh \+COMPOSIO_INSTALL_E2E_VERSION=latest \+pnpm test:e2e:install+```++Set `COMPOSIO_INSTALL_E2E_VERSION=@composio/[email protected]` to cover the shell-configuration fallback for a CLI release that predates `composio install --shell`.diff --git a/ts/e2e-tests/cli/install/e2e.test.ts b/ts/e2e-tests/cli/install/e2e.test.tsnew file mode 100644index 000000000..9b3a8b730--- /dev/null+++ b/ts/e2e-tests/cli/install/e2e.test.ts@@ -0,0 +1,217 @@+import { resolve } from 'node:path';+import { afterAll, beforeAll, describe, expect, it } from 'bun:test';+import {+ checkDocker,+ ensureInstallImage,+ resolveInstallE2EConfig,+ runInstallContainer,+ type ExecResult,+} from '@e2e-tests/utils';+import { INSTALL_E2E_LOCAL_RELEASE_TAG } from '@e2e-tests/utils/const';+import { startInstallReleaseServer, type InstallReleaseServer } from './release-server';++const config = resolveInstallE2EConfig();+const repoRoot = resolve(import.meta.dir, '../../../..');+const timeout = 600_000;++let imageTag = '';+let releaseServer: InstallReleaseServer | undefined;++function assertSuccess(result: ExecResult): void {+ if (result.exitCode !== 0) {+ throw new Error(+ `Install container exited ${result.exitCode}\n\nstdout:\n${result.stdout}\n\nstderr:\n${result.stderr}`+ );+ }+ expect(result.exitCode).toBe(0);+}++function installerEnvironment(): Record<string, string> {+ if (config.mode === 'prod') {+ return {+ INSTALL_BASE_URL: 'https://composio.dev',+ E2E_VERSION: config.version,+ };+ }++ if (!releaseServer) {+ throw new Error('Local release server is not running');+ }++ return {+ INSTALL_BASE_URL: releaseServer.baseUrl,+ E2E_RELEASE_TAG: INSTALL_E2E_LOCAL_RELEASE_TAG,+ COMPOSIO_GITHUB_URL: releaseServer.baseUrl,+ COMPOSIO_GITHUB_API_BASE_URL: releaseServer.baseUrl,+ COMPOSIO_INSTALL_SCRIPT_URL: `${releaseServer.baseUrl}/install`,+ COMPOSIO_INSTALL_ALLOW_HTTP_HOST: 'host.docker.internal',+ };+}++async function run(script: string): Promise<ExecResult> {+ return runInstallContainer({+ imageTag,+ cmd: [config.shell, '-lc', script],+ env: installerEnvironment(),+ });+}++beforeAll(async () => {+ const docker = await checkDocker({ repoRoot });+ if (docker.exitCode !== 0) {+ throw new Error(`Docker is required for install e2e tests: ${docker.stderr || docker.stdout}`);+ }++ if (config.mode === 'local') {+ releaseServer = startInstallReleaseServer({+ repoRoot,+ releaseDir: config.releaseDir!,+ });+ }+ imageTag = await ensureInstallImage(config.shell, {+ repoRoot,+ platform: releaseServer?.platform,+ });+}, timeout);++afterAll(() => {+ releaseServer?.stop();+});++if (config.mode === 'local' && config.shell === 'bash') {+ describe('local bash installation', () => {+ it(+ 'installs into a virgin home and is available in a fresh login shell',+ async () => {+ const result = await run(`+set -eu+test ! -d "$HOME/.local/bin"+curl -fsSL "$INSTALL_BASE_URL/install" | sh+test -x "$HOME/.composio/composio"+test -L "$HOME/.local/bin/composio"+test "$(readlink -f "$HOME/.local/bin/composio")" = "$HOME/.composio/composio"+test "$(bash -ilc 'command -v composio')" = "$HOME/.local/bin/composio"+test "$(bash -ilc 'composio --version')" = 98.0.0+`);+ assertSuccess(result);+ },+ timeout+ );++ it(+ 'configures an existing bash login profile only through the bash variant',+ async () => {+ const result = await run(`+set -eu+printf '%s\n' 'export PROFILE_TRAP=1' > "$HOME/.bash_profile"+output=$(curl -fsSL "$INSTALL_BASE_URL/install" | sh)+printf '%s\n' "$output" | grep -F 'Required next step for bash:'+if bash -ilc 'command -v composio' >/dev/null 2>&1; then+ echo 'default installer unexpectedly configured the login shell' >&2+ exit 1+fi+curl -fsSL "$INSTALL_BASE_URL/install/bash" | sh+test "$(bash -ilc 'command -v composio')" = "$HOME/.local/bin/composio"+test "$(bash -ilc 'composio --version')" = 98.0.0+test "$(grep -Fc '# Composio CLI' "$HOME/.bash_profile")" = 1+test "$(grep -Fc '# Composio CLI' "$HOME/.bashrc")" = 1+`);+ assertSuccess(result);+ },+ timeout+ );+ });+}++if (config.mode === 'local' && config.shell === 'zsh') {+ describe('local zsh installation', () => {+ it(+ 'keeps the bundle beside its support files and configures zsh idempotently',+ async () => {+ const result = await run(`+set -eu+test ! -d "$HOME/.local/bin"+curl -fsSL "$INSTALL_BASE_URL/install/zsh" | sh+curl -fsSL "$INSTALL_BASE_URL/install/zsh" | sh+test -x "$HOME/.composio/composio"+test -L "$HOME/.local/bin/composio"+test "$(readlink -f "$HOME/.local/bin/composio")" = "$HOME/.composio/composio"+test "$(cat "$HOME/.composio/release-tag.txt")" = "$E2E_RELEASE_TAG"+test -f "$HOME/.composio/run-helpers-runtime.mjs"+test -d "$HOME/.composio/local-tools-binaries"+test "$(grep -Fc '# Composio CLI' "$HOME/.zshrc")" = 1+test "$(zsh -ilc 'command -v composio')" = "$HOME/.local/bin/composio"+test "$(zsh -ilc 'composio --version')" = 98.0.0+`);+ assertSuccess(result);+ },+ timeout+ );+ });+}++if (config.mode === 'local') {+ describe('local failure handling', () => {+ it(+ 'rejects a corrupted release archive before creating the entry point',+ async () => {+ const result = await run(`+set -eu+if curl -fsSL "$INSTALL_BASE_URL/install" | COMPOSIO_GITHUB_URL="$INSTALL_BASE_URL/corrupt" sh -s -- "$E2E_RELEASE_TAG"; then+ echo 'corrupted archive unexpectedly installed' >&2+ exit 1+fi+test ! -e "$HOME/.local/bin/composio"+`);+ assertSuccess(result);+ },+ timeout+ );+ });+}++if (config.mode === 'prod' && config.version === 'latest') {+ describe(`production latest installation on ${config.shell}`, () => {+ it(+ 'makes composio available in a fresh login shell',+ async () => {+ const route = config.shell === 'bash' ? 'install' : 'install/zsh';+ const result = await run(`+set -eu+test ! -d "$HOME/.local/bin"+curl -fsSL "$INSTALL_BASE_URL/${route}" | sh+test -x "$HOME/.composio/composio"+test -L "$HOME/.local/bin/composio"+test "$(${config.shell} -ilc 'command -v composio')" = "$HOME/.local/bin/composio"+${config.shell} -ilc 'composio --version'+`);+ assertSuccess(result);+ },+ timeout+ );+ });+}++if (config.mode === 'prod' && config.version !== 'latest') {+ describe(`production ${config.version} compatibility installation`, () => {+ it(+ 'uses inline shell setup when the pinned CLI lacks install --shell',+ async () => {+ const result = await run(`+set -eu+curl -fsSL "$INSTALL_BASE_URL/install" | sh -s -- "$E2E_VERSION"+if "$HOME/.composio/composio" install --help | grep -q -- '--shell'; then+ echo 'expected the pinned CLI to predate install --shell' >&2+ exit 1+fi+curl -fsSL "$INSTALL_BASE_URL/install/${config.shell}" | sh -s -- "$E2E_VERSION"+test "$(grep -Fc '# Composio CLI' "$HOME/.zshrc")" = 1+test "$(zsh -ilc 'command -v composio')" = "$HOME/.local/bin/composio"+zsh -ilc 'composio --version'+`);+ assertSuccess(result);+ },+ timeout+ );+ });+}diff --git a/ts/e2e-tests/cli/install/package.json b/ts/e2e-tests/cli/install/package.jsonnew file mode 100644index 000000000..4df5acd86--- /dev/null+++ b/ts/e2e-tests/cli/install/package.json@@ -0,0 +1,14 @@+{+ "name": "@e2e-tests/cli-install",+ "version": "0.0.0",+ "private": true,+ "type": "module",+ "scripts": {+ "typecheck": "tsc --noEmit",+ "test:e2e:install": "bun test e2e.test.ts"+ },+ "devDependencies": {+ "@e2e-tests/utils": "workspace:*",+ "@types/bun": "catalog:"+ }+}diff --git a/ts/e2e-tests/cli/install/release-server.ts b/ts/e2e-tests/cli/install/release-server.tsnew file mode 100644index 000000000..cd97d4784--- /dev/null+++ b/ts/e2e-tests/cli/install/release-server.ts@@ -0,0 +1,93 @@+import { existsSync, readFileSync } from 'node:fs';+import { join } from 'node:path';+import { INSTALL_E2E_LOCAL_RELEASE_TAG } from '@e2e-tests/utils/const';++const ARCHIVE_BY_ARCH = {+ arm64: 'composio-linux-aarch64.zip',+ x64: 'composio-linux-x64.zip',+} as const;++export interface InstallReleaseServer {+ baseUrl: string;+ platform: 'linux/amd64' | 'linux/arm64';+ stop: () => void;+}++export function startInstallReleaseServer(options: {+ repoRoot: string;+ releaseDir: string;+}): InstallReleaseServer {+ const preferredArch = process.arch === 'arm64' ? 'arm64' : 'x64';+ const archiveName = ARCHIVE_BY_ARCH[preferredArch];+ const archivePath = join(options.releaseDir, archiveName);+ const checksumsPath = join(options.releaseDir, 'checksums.txt');+ if (!existsSync(archivePath) || !existsSync(checksumsPath)) {+ throw new Error(+ `Local install fixture must contain ${archiveName} and checksums.txt: ${options.releaseDir}`+ );+ }++ const scripts = new Map([+ ['/install', join(options.repoRoot, 'install.sh')],+ ['/install/bash', join(options.repoRoot, 'install/bash.sh')],+ ['/install/zsh', join(options.repoRoot, 'install/zsh.sh')],+ ['/install/fish', join(options.repoRoot, 'install/fish.sh')],+ ]);++ let dockerBaseUrl = '';+ const server = Bun.serve({+ hostname: '0.0.0.0',+ port: 0,+ fetch(request) {+ const url = new URL(request.url);+ const scriptPath = scripts.get(url.pathname);+ if (scriptPath) {+ return new Response(Bun.file(scriptPath), {+ headers: { 'content-type': 'text/x-shellscript; charset=utf-8' },+ });+ }++ if (/^\/repos\/[^/]+\/[^/]+\/releases$/.test(url.pathname)) {+ return Response.json([+ {+ tag_name: INSTALL_E2E_LOCAL_RELEASE_TAG,+ draft: false,+ prerelease: false,+ assets: [+ {+ name: archiveName,+ browser_download_url: `${dockerBaseUrl}/ComposioHQ/composio/releases/download/${encodeURIComponent(INSTALL_E2E_LOCAL_RELEASE_TAG)}/${archiveName}`,+ },+ ],+ },+ ]);+ }++ if (url.pathname.includes('/releases/download/') && url.pathname.endsWith(archiveName)) {+ if (url.pathname.startsWith('/corrupt/')) {+ return new Response('not a zip archive\n', {+ headers: { 'content-type': 'application/zip' },+ });+ }+ return new Response(Bun.file(archivePath), {+ headers: { 'content-type': 'application/zip' },+ });+ }++ if (url.pathname.includes('/releases/download/') && url.pathname.endsWith('checksums.txt')) {+ return new Response(readFileSync(checksumsPath), {+ headers: { 'content-type': 'text/plain; charset=utf-8' },+ });+ }++ return new Response('not found\n', { status: 404 });+ },+ });++ dockerBaseUrl = `http://host.docker.internal:${server.port}`;+ return {+ baseUrl: dockerBaseUrl,+ platform: preferredArch === 'arm64' ? 'linux/arm64' : 'linux/amd64',+ stop: () => server.stop(true),+ };+}diff --git a/ts/e2e-tests/cli/install/tsconfig.json b/ts/e2e-tests/cli/install/tsconfig.jsonnew file mode 100644index 000000000..6e2b89cab--- /dev/null+++ b/ts/e2e-tests/cli/install/tsconfig.json@@ -0,0 +1,13 @@+{+ "$schema": "https://json.schemastore.org/tsconfig",+ "compilerOptions": {+ "target": "es2022",+ "module": "esnext",+ "moduleResolution": "bundler",+ "strict": true,+ "skipLibCheck": true,+ "noEmit": true,+ "types": ["bun"]+ },+ "include": ["*.ts"]+}diff --git a/ts/packages/cli/test/src/services/upgrade-binary.test.ts b/ts/packages/cli/test/src/services/upgrade-binary.test.tsindex 2428de219..09b920535 100644--- a/ts/packages/cli/test/src/services/upgrade-binary.test.ts+++ b/ts/packages/cli/test/src/services/upgrade-binary.test.ts@@ -461,6 +461,50 @@ describe('UpgradeBinary', () => {}).pipe(Effect.provide(TestPlatform), Effect.ensuring(restoreStubsAndMocks));});+ it.scoped('replaces the bundle target without replacing its entry-point symlink', () => {+ vi.stubGlobal('Bun', { which: vi.fn(() => null) });++ return Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;+ const path = yield* Path.Path;+ const installDir = yield* fs.makeTempDirectoryScoped({+ prefix: 'composio-symlink-upgrade-target-',+ });+ const binDir = yield* fs.makeTempDirectoryScoped({+ prefix: 'composio-symlink-upgrade-entry-',+ });+ const sourceDir = yield* fs.makeTempDirectoryScoped({+ prefix: 'composio-symlink-upgrade-source-',+ });+ const installedBinaryPath = path.join(installDir, 'composio');+ const entryPointPath = path.join(binDir, 'composio');+ const sourceBinaryPath = path.join(sourceDir, 'composio');++ yield* fs.writeFileString(installedBinaryPath, 'old-binary');+ yield* fs.writeFileString(sourceBinaryPath, 'new-binary');+ yield* fs.symlink(installedBinaryPath, entryPointPath);+ const originalLinkTarget = yield* fs.readLink(entryPointPath);+ vi.spyOn(process, 'execPath', 'get').mockReturnValue(installedBinaryPath);++ const companionRelativePaths =+ yield* collectExpectedRunCompanionAssetRelativePaths(sourceDir);+ for (const relativePath of companionRelativePaths) {+ const companionPath = path.join(sourceDir, relativePath);+ yield* fs.makeDirectory(path.dirname(companionPath), { recursive: true });+ yield* fs.writeFileString(companionPath, 'support-file');+ }++ const result = yield* runUpgradeSuccess([+ ['DEBUG_OVERRIDE_UPGRADE_TARGET', sourceBinaryPath],+ ]);++ expect(result).toBeUndefined();+ expect(yield* fs.readFileString(installedBinaryPath)).toBe('new-binary');+ expect(yield* fs.readLink(entryPointPath)).toBe(originalLinkTarget);+ expect(yield* fs.exists(entryPointPath)).toBe(true);+ }).pipe(Effect.provide(TestPlatform), Effect.ensuring(restoreStubsAndMocks));+ });+it.scoped('uses the installed beta release tag when comparing beta updates', () => {vi.stubGlobal('Bun', { which: vi.fn(() => null) });diff --git a/turbo.jsonc b/turbo.jsoncindex b407fdb0c..71374f060 100644--- a/turbo.jsonc+++ b/turbo.jsonc@@ -46,6 +46,10 @@"env": ["COMPOSIO_API_KEY", "COMPOSIO_BASE_URL", "COMPOSIO_USER_API_KEY", "COMPOSIO_E2E_CLI_VERSION", "OPENAI_API_KEY"],"cache": false},+ "test:e2e:install": {+ "env": ["COMPOSIO_INSTALL_E2E_MODE", "COMPOSIO_INSTALL_E2E_SHELL", "COMPOSIO_INSTALL_E2E_VERSION", "COMPOSIO_INSTALL_E2E_RELEASE_DIR"],+ "cache": false+ },"test:e2e:cloudflare": {"dependsOn": ["^build"],"env": ["COMPOSIO_API_KEY", "COMPOSIO_BASE_URL", "COMPOSIO_USER_API_KEY", "OPENAI_API_KEY"],