@devries-cameron20 / composio Mirror · read-only / commits / a0c3bcc2c
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.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 14:45 UTC

fix(cli): make upgrade downloads visible and half the size (#4187)

## Problem `composio upgrade` from `0.3.4-beta.351` to `0.4.0-beta.359` looked hung for several minutes: ``` ◐ New version available: @composio/cli@0.4.0-beta.359 (current: @composio/cli@0.3.4-beta.351). Downloading. ``` Two independent defects behind that. **No feedback.** `upgrade-binary.ts` printed that message once and then said nothing until the download finished. The only byte-level signal was a `logDebug`, invisible in a normal run, because the body was read with a single buffered `response.arrayBuffer`. **Mostly wasted payload.** The archive is 338 MB, and ~651 MB of what it unpacks is `codex-acp` binaries for the three platforms the host cannot execute. Measured on a darwin-arm64 install: ``` ~/.composio 967 MB total codex/darwin-arm64 180 MB ← the only one this Mac can run codex/darwin-x64 190 MB ┐ codex/linux-arm64 208 MB ├─ 620 MB of dead weight codex/linux-x64 222 MB ┘ ``` ## Changes **Progress reporting.** The response is streamed and reported on a 250 ms interval: `Downloading... 42% (142.0 MB / 338.0 MB)`. The total comes from the release asset's `size` (newly decoded — the field was being dropped), falling back to `content-length`, and falling back again to a plain byte count so an unknown size degrades instead of failing. **Half the payload.** Each archive now carries real bytes only for the `codex-acp` binary its own platform can execute. The other three paths cannot simply be dropped — that is exactly the break #4186 just repaired. A CLI released before 2026-08-18 verifies a downloaded package against all four codex-acp paths and refuses one missing any of them. So they ship as **empty placeholders**: the existence check passes at zero bytes, and since no host ever executes a foreign codex-acp, the placeholder is never read. Once no supported client performs that check, placeholders become plain omissions — `archiveCompanionEntries` is where that switch lives. As a guard, codex adapter resolution now requires a non-empty file, so a zero-byte binary resolves as absent and falls through to the existing bundled → PATH → npx chain rather than trying to exec it. Expected effect: download 338 MB → ~165 MB, install footprint 967 MB → ~347 MB. ## Verification - Full CLI suite: **122 files, 1262 passed, 1 skipped** - `pnpm --filter @composio/cli typecheck` — clean - The existing `upgrade-binary` download tests run against a real HTTP server and pass unchanged, covering the buffered → streamed rewrite - New tests: progress formatting (known total, unknown total, zero total, overshoot) and `archiveCompanionEntries` (all four paths named, exactly one copied, three placeholdered, portable assets copied) - `pnpm validate:changesets` — passes; note lands in `ts/packages/cli/CHANGELOG.md` Not verifiable locally: actual archive sizes and a real upgrade against a pre-2026-08-18 client. Both need a beta build — worth confirming on the beta cut from this branch before it goes near a stable promotion. Independent of the `0.4.0` release in flight; `0.4.0-beta.359` is unaffected. https://claude.ai/code/session_01JkwtxPHfobZxzvAqe53x62

Alberto Schiabel committed Aug 23, 2026 at 13:07 UTC a0c3bcc2c80ffd84f9f9585baf832df3ca7ac05e
12 files changed +391 -86
.github/scripts/cli-release/verify-archive-companions.sh new
+63
@@ -0,0 +1,63 @@
1 +#!/usr/bin/env bash
2 +#
3 +# Loud failure gate: assert one release archive carries the codex-acp layout the CLI
4 +# actually ships — every platform's path present, but real bytes only for the platform
5 +# this archive runs on.
6 +#
7 +# Both halves matter, and each guards a shipped regression:
8 +#
9 +# - A missing path breaks `composio upgrade` for every CLI released before 2026-08-18.
10 +# Those clients verify a downloaded package against all four codex-acp paths and
11 +# refuse one that lacks any of them.
12 +# - A populated foreign binary is ~200MB nobody unpacking this archive can execute,
13 +# which is what made the upgrade download several minutes of mostly dead weight.
14 +#
15 +# The unit tests cover the packaging rules on synthetic inputs; only this gate looks at a
16 +# real archive, so a change to the packaging pipeline cannot quietly reintroduce either
17 +# state.
18 +#
19 +# Inputs (env): ARCHIVE (path to the .zip), ARTIFACT (its top-level directory),
20 +# HOST_CODEX_TARGET (the one target that must carry real bytes)
21 +set -euo pipefail
22 +
23 +: "${ARCHIVE:?ARCHIVE is required}"
24 +: "${ARTIFACT:?ARTIFACT is required}"
25 +: "${HOST_CODEX_TARGET:?HOST_CODEX_TARGET is required}"
26 +
27 +# Keep in lock-step with RUN_CODEX_ACP_BINARY_TARGETS in
28 +# ts/packages/cli/src/services/run-companion-modules.ts. Adding a codex target there must
29 +# extend this list, or the gate stops covering it.
30 +codex_targets=(darwin-arm64 darwin-x64 linux-arm64 linux-x64)
31 +
32 +fail() {
33 + echo "::error::$1"
34 + exit 1
35 +}
36 +
37 +printf '%s\n' "${codex_targets[@]}" | grep -Fxq "$HOST_CODEX_TARGET" ||
38 + fail "HOST_CODEX_TARGET '$HOST_CODEX_TARGET' is not a known codex target (${codex_targets[*]})"
39 +
40 +test -f "$ARCHIVE" || fail "archive not found: $ARCHIVE"
41 +entries="$(unzip -Z1 "$ARCHIVE")"
42 +
43 +for target in "${codex_targets[@]}"; do
44 + entry="${ARTIFACT}/acp-adapters/codex/${target}/codex-acp"
45 +
46 + grep -Fxq "$entry" <<<"$entries" ||
47 + fail "missing codex-acp entry '$entry'; pre-2026-08-18 clients refuse an archive without it"
48 +
49 + # Byte count of the entry as stored, read without extracting to disk.
50 + size="$(unzip -p "$ARCHIVE" "$entry" | wc -c | tr -d '[:space:]')"
51 +
52 + if [ "$target" = "$HOST_CODEX_TARGET" ]; then
53 + [ "$size" -gt 0 ] ||
54 + fail "'$entry' is this archive's own platform but is empty; the CLI cannot run an ACP sub-agent"
55 + echo "ok: $target carries $size bytes (this archive's platform)"
56 + else
57 + [ "$size" -eq 0 ] ||
58 + fail "'$entry' is a foreign platform but carries $size bytes; it can never execute here"
59 + echo "ok: $target is an empty placeholder"
60 + fi
61 +done
62 +
63 +echo "Archive companion layout verified for $ARTIFACT (host target: $HOST_CODEX_TARGET)."
.github/workflows/build-cli-binaries.yml
+12
@@ -103,18 +103,22 @@ jobs:
103 artifact: composio-linux-x64
104 runner: ubuntu-latest
105 local_tools_target: ''
106 + codex_target: linux-x64
107 - target: bun-linux-arm64
108 artifact: composio-linux-aarch64
109 runner: ubuntu-latest
110 local_tools_target: ''
111 + codex_target: linux-arm64
112 - target: bun-darwin-x64
113 artifact: composio-darwin-x64
114 runner: macos-15-intel
115 local_tools_target: ''
116 + codex_target: darwin-x64
117 - target: bun-darwin-arm64
118 artifact: composio-darwin-aarch64
119 runner: macos-15
120 local_tools_target: darwin-arm64
121 + codex_target: darwin-arm64
122
123 steps:
124 - name: Checkout
@@ -191,6 +195,14 @@ jobs:
195 working-directory: ts/packages/cli
196 run: unzip -p dist/binaries/${{ matrix.artifact }}.zip ${{ matrix.artifact }}/release-tag.txt | grep -Fx '${{ needs.prepare.outputs.release_tag }}'
197
198 + - name: Verify companion adapters in archive
199 + working-directory: ts/packages/cli
200 + env:
201 + ARCHIVE: dist/binaries/${{ matrix.artifact }}.zip
202 + ARTIFACT: ${{ matrix.artifact }}
203 + HOST_CODEX_TARGET: ${{ matrix.codex_target }}
204 + run: bash "${{ github.workspace }}/.github/scripts/cli-release/verify-archive-companions.sh"
205 +
206 - name: Verify local-tool sidecars in archive
207 if: matrix.local_tools_target != ''
208 working-directory: ts/packages/cli
ts/packages/cli/CHANGELOG.md
+15 -6
@@ -4,18 +4,27 @@
4
5 ### Patch Changes
6
7 +- `composio upgrade` shows download progress. The archive is a few hundred
8 + megabytes, and the command previously printed `Downloading...` once and then
9 + said nothing for minutes, which was indistinguishable from a hang. It now
10 + reports percent and transferred size as the download runs.
11 +- `composio upgrade` downloads roughly half as much. Release archives carried
12 + all four platforms' `codex-acp` binaries, about 651 MB that the machine
13 + unpacking them can never execute. Only the binary for the archive's own
14 + platform is shipped now; the other three remain as empty placeholders so that
15 + a CLI installed before this change still passes its upgrade verification.
16 +- `composio upgrade` works again from any previously released CLI. Release
17 + archives had been narrowed to drop the `codex-acp` binaries a machine cannot
18 + execute, but a CLI installed before that change verifies a downloaded package
19 + against all four platforms' binaries and rejects one that is missing any of
20 + them, failing with `Downloaded binary package is incomplete`. Every archive
21 + names all four paths again.
22 - Archives are no longer extracted with symbolic links in them. `extract-zip`
23 creates a symlink entry without validating its target (CVE-2026-56876), which
24 has no fixed release, and anything that later reads the extracted tree can be
25 walked out of it. No archive this CLI extracts legitimately contains a
26 symlink, so such an entry is now refused before it is written.
27 - `composio search` now uses schemas returned by Tool Router for dashboard-registered custom MCP tools instead of querying the legacy managed-tool endpoint, which returned 404 for `CUSTOM_*` tool slugs.
13 -- `composio upgrade` works again from any previously released CLI. Release
14 - archives had been narrowed to carry only the `codex-acp` binary their own
15 - platform can run, but a CLI installed before that change verifies a downloaded
16 - package against all four platforms' binaries and rejects one that is missing
17 - any of them, failing with `Downloaded binary package is incomplete`. Archives
18 - ship the full set again.
28 - `COMPOSIO_ENVIRONMENT=staging` now opens the staging dashboard at
29 `https://staging-dashboard.composio.dev/`.
30 - `composio dev auth-configs create` now sends custom OAuth credentials and scopes
ts/packages/cli/scripts/_release-artifacts.ts
+30 -17
@@ -60,34 +60,47 @@ export const releaseArtifactTargetFor = (
60 () => new UnknownReleaseArtifactError({ artifactName })
61 );
62
63 +export type ArchiveCompanionEntryKind = 'copy' | 'placeholder';
64 +
65 +export type ArchiveCompanionEntry = {
66 + readonly relativePath: string;
67 + readonly kind: ArchiveCompanionEntryKind;
68 +};
69 +
70 /**
64 - * Narrow the full multi-platform companion asset list down to the assets one
65 - * archive should ship: the portable ones plus the single codex-acp binary that
66 - * archive's platform can execute.
71 + * Decide how each companion asset enters one archive.
72 + *
73 + * An archive already carries a platform-specific `composio` binary, so only one
74 + * of the four codex-acp binaries inside it can ever execute. The other three are
75 + * ~651 MB that every machine unpacking this archive downloads, stores, and can
76 + * never run.
77 *
68 - * An archive already carries a platform-specific `composio` binary, so a
69 - * darwin-arm64 archive is unusable on linux-x64 no matter which codex-acp
70 - * binaries travel with it. Shipping foreign ones only inflates the download.
78 + * They cannot simply be dropped. A CLI released before 2026-08-18 verifies a
79 + * downloaded upgrade package against all four codex-acp paths and refuses to
80 + * install one that is missing any of them, so omitting them breaks
81 + * `composio upgrade` for every client already in the field. An empty placeholder
82 + * satisfies that existence check at zero bytes, and no host ever executes a
83 + * foreign codex-acp binary, so the placeholder is never read.
84 *
72 - * Packaging deliberately does not call this yet. A CLI released before
73 - * 2026-08-18 verifies a downloaded upgrade package against all four codex-acp
74 - * paths, so an archive narrowed this way breaks `composio upgrade` for every
75 - * client already in the field. Wire it back into `package-binaries.ts` once no
76 - * supported client still performs that check.
85 + * Once no supported client performs that check, placeholders can become plain
86 + * omissions.
87 */
78 -export const archiveCompanionRelativePaths = ({
88 +export const archiveCompanionEntries = ({
89 allRelativePaths,
90 target,
91 }: {
92 readonly allRelativePaths: ReadonlyArray<string>;
93 readonly target: ReleaseArtifactTarget;
84 -}): ReadonlyArray<string> => {
85 - const included = new Set(runCompanionStaticAssetRelativePathsFor(target));
86 - const excluded = new Set(
94 +}): ReadonlyArray<ArchiveCompanionEntry> => {
95 + const executableHere = new Set(runCompanionStaticAssetRelativePathsFor(target));
96 + const foreignCodexPaths = new Set(
97 RUN_COMPANION_ALL_STATIC_ASSET_RELATIVE_PATHS.filter(
88 - relativePath => !included.has(relativePath)
98 + relativePath => !executableHere.has(relativePath)
99 )
100 );
101
92 - return allRelativePaths.filter(relativePath => !excluded.has(relativePath));
102 + return allRelativePaths.map(relativePath => ({
103 + relativePath,
104 + kind: foreignCodexPaths.has(relativePath) ? ('placeholder' as const) : ('copy' as const),
105 + }));
106 };
ts/packages/cli/scripts/package-binaries.ts
+21 -15
@@ -25,7 +25,11 @@ import {
25 collectExpectedRunCompanionAssetRelativePaths,
26 RUN_COMPANION_ALL_STATIC_ASSET_RELATIVE_PATHS,
27 } from '../src/services/run-companion-modules';
28 -import { ARTIFACT_NAMES } from './_release-artifacts';
28 +import {
29 + archiveCompanionEntries,
30 + ARTIFACT_NAMES,
31 + releaseArtifactTargetFor,
32 +} from './_release-artifacts';
33
34 const BINARIES_DIR = './dist/binaries';
35 const COMPANIONS_DIR = path.join(BINARIES_DIR, 'companions');
@@ -65,16 +69,14 @@ export function packageBinaries() {
69 yield* Console.log(`Packaging ${binaries.length} binaries...`);
70
71 for (const binary of binaries) {
68 - // Every archive ships every platform's codex-acp, even though its own
69 - // `composio` binary can only ever execute one of them.
70 - //
71 - // A CLI released before 2026-08-18 verifies a downloaded upgrade package
72 - // against all four codex-acp paths and refuses to install one that is
73 - // missing any of them, so an archive carrying only its own binary breaks
74 - // `composio upgrade` for every client already in the field. Narrowing the
75 - // set is worth roughly 651 MB per archive, but it can only ship once no
76 - // supported client still performs that check.
77 - const companionRelativePaths = allCompanionRelativePaths;
72 + // Every archive names all four codex-acp paths, but carries real bytes
73 + // only for the one its own `composio` binary can execute. See
74 + // `archiveCompanionEntries` for why the other three are present but empty.
75 + const target = yield* releaseArtifactTargetFor(binary);
76 + const companionEntries = archiveCompanionEntries({
77 + allRelativePaths: allCompanionRelativePaths,
78 + target,
79 + });
80
81 const binaryPath = path.join(BINARIES_DIR, binary);
82 const zipPath = path.join(BINARIES_DIR, `${binary}.zip`);
@@ -87,10 +89,14 @@ export function packageBinaries() {
89 yield* Effect.tryPromise(async () => {
90 await $`mkdir -p ${nestedDir}`.quiet();
91 await $`cp ${binaryPath} ${nestedDir}/composio`.quiet();
90 - for (const relativePath of companionRelativePaths) {
91 - const targetDirectory = path.dirname(path.join(nestedDir, relativePath));
92 - await $`mkdir -p ${targetDirectory}`.quiet();
93 - await $`cp ${path.join(COMPANIONS_DIR, relativePath)} ${path.join(nestedDir, relativePath)}`.quiet();
92 + for (const { relativePath, kind } of companionEntries) {
93 + const destinationPath = path.join(nestedDir, relativePath);
94 + await $`mkdir -p ${path.dirname(destinationPath)}`.quiet();
95 + if (kind === 'placeholder') {
96 + await writeFile(destinationPath, '');
97 + continue;
98 + }
99 + await $`cp ${path.join(COMPANIONS_DIR, relativePath)} ${destinationPath}`.quiet();
100 }
101 const hasLocalToolsBinaryAssets = await stat(LOCAL_TOOLS_BINARY_ASSETS_DIR)
102 .then(stats => stats.isDirectory())
ts/packages/cli/src/effects/resolve-cli-release.ts
+3
@@ -6,6 +6,9 @@ import type { CliReleaseChannel } from 'src/constants';
6 export const GitHubReleaseAsset = Schema.Struct({
7 name: Schema.NonEmptyString,
8 browser_download_url: Schema.NonEmptyString,
9 + // Present on every real GitHub asset; optional so a release payload that omits
10 + // it still decodes and the download simply reports progress without a total.
11 + size: Schema.optional(Schema.Number),
12 });
13 export type GitHubReleaseAsset = typeof GitHubReleaseAsset.Type;
14 export const GitHubReleaseAssets = Schema.Array(GitHubReleaseAsset);
ts/packages/cli/src/services/run-companion-modules.ts
+16 -1
@@ -238,14 +238,28 @@ export const collectRunCompanionAssetRelativePaths = (
238 return [...collected].sort();
239 });
240
241 +/**
242 + * A release archive names every codex-acp path but fills only the one its own
243 + * platform can execute; the rest are empty placeholders that keep older clients'
244 + * upgrade verification passing. `requireNonEmpty` makes a placeholder resolve as
245 + * absent so the caller falls through to its next adapter source.
246 + */
247 +const fileHasContent = (fs: FileSystem.FileSystem, filePath: string) =>
248 + fs.stat(filePath).pipe(
249 + Effect.map(info => Number(info.size) > 0),
250 + Effect.orElseSucceed(() => false)
251 + );
252 +
253 export const resolveRunCompanionAssetPath = ({
254 callerImportMetaUrl,
255 execPath,
256 relativePathFromRoot,
257 + requireNonEmpty = false,
258 }: {
259 callerImportMetaUrl: string;
260 execPath: string;
261 relativePathFromRoot: string;
262 + requireNonEmpty?: boolean;
263 }): Effect.Effect<string | null, never, FileSystem.FileSystem | Path.Path> =>
264 Effect.gen(function* () {
265 const fs = yield* FileSystem.FileSystem;
@@ -260,7 +274,8 @@ export const resolveRunCompanionAssetPath = ({
274 path.resolve(executableDirectory, relativePathFromRoot),
275 ];
276
263 - const found = yield* Effect.findFirst(candidates, candidate => fileExists(fs, candidate));
277 + const isUsable = requireNonEmpty ? fileHasContent : fileExists;
278 + const found = yield* Effect.findFirst(candidates, candidate => isUsable(fs, candidate));
279 return Option.getOrNull(found);
280 });
281
ts/packages/cli/src/services/run-subagent-acp.ts
+3
@@ -168,10 +168,13 @@ const resolveShippedAdapterAsset = ({
168 }
169
170 return {
171 + // Reject a zero-byte placeholder: a foreign-platform slot in the archive
172 + // can never execute, so treat it as absent and fall through.
173 resolvedPath: yield* resolveRunCompanionAssetPath({
174 callerImportMetaUrl: import.meta.url,
175 execPath,
176 relativePathFromRoot: binaryTarget.relativePath,
177 + requireNonEmpty: true,
178 }),
179 expectedRelativePaths: [binaryTarget.relativePath],
180 };
ts/packages/cli/src/services/upgrade-binary.ts
+77 -6
@@ -7,6 +7,7 @@ import {
7 Predicate,
8 Record as EffectRecord,
9 Scope,
10 + Stream,
11 } from 'effect';
12 import { HttpClient, HttpClientResponse, FileSystem, Path } from '@effect/platform';
13 import { APP_VERSION } from '../constants';
@@ -201,13 +202,54 @@ const isUpdateAvailable = (
202 return isVersionOutdated(comparison);
203 });
204
205 +type DownloadProgress = {
206 + readonly receivedBytes: number;
207 + readonly totalBytes: number | undefined;
208 +};
209 +
210 +type DownloadProgressReporter = (progress: DownloadProgress) => Effect.Effect<void>;
211 +
212 +// Fast enough to look live, slow enough not to thrash the spinner.
213 +const DOWNLOAD_PROGRESS_INTERVAL_MILLIS = 250;
214 +
215 +const MEGABYTE = 1_000_000;
216 +
217 +export const formatMegabytes = (bytes: number): string => `${(bytes / MEGABYTE).toFixed(1)} MB`;
218 +
219 +/**
220 + * Human-readable transfer state. Falls back to a plain byte count when the
221 + * server never told us how large the asset is.
222 + */
223 +export const formatDownloadProgress = ({ receivedBytes, totalBytes }: DownloadProgress): string => {
224 + if (totalBytes === undefined || totalBytes <= 0) {
225 + return `Downloading... ${formatMegabytes(receivedBytes)}`;
226 + }
227 +
228 + const percent = Math.min(100, Math.floor((receivedBytes / totalBytes) * 100));
229 + return `Downloading... ${percent}% (${formatMegabytes(receivedBytes)} / ${formatMegabytes(totalBytes)})`;
230 +};
231 +
232 +const resolveDownloadTotalBytes = (
233 + asset: { readonly size?: number },
234 + response: HttpClientResponse.HttpClientResponse
235 +): number | undefined => {
236 + if (typeof asset.size === 'number' && asset.size > 0) {
237 + return asset.size;
238 + }
239 +
240 + const header = response.headers['content-length'];
241 + const parsed = header === undefined ? Number.NaN : Number.parseInt(header, 10);
242 + return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
243 +};
244 +
245 /**
246 * Download binary for current platform
247 */
248 const downloadBinary = (
249 { httpClient }: UpgradeBinaryContext,
250 release: GitHubRelease,
210 - platformArch: PlatformArch
251 + platformArch: PlatformArch,
252 + onProgress: DownloadProgressReporter = () => Effect.void
253 ): Effect.Effect<{ name: string; data: Uint8Array }, UpgradeBinaryError, never> =>
254 Effect.gen(function* () {
255 yield* Effect.logDebug(`Looking up binary for ${platformArch.platform}-${platformArch.arch}`);
@@ -247,9 +289,27 @@ const downloadBinary = (
289 return resp;
290 });
291
250 - const arrayBuffer = yield* Effect.gen(function* () {
251 - return yield* response.arrayBuffer;
252 - }).pipe(
292 + // Streamed rather than buffered so the transfer can be reported as it runs:
293 + // these archives are hundreds of megabytes, and a silent multi-minute wait
294 + // is indistinguishable from a hung command.
295 + const totalBytes = resolveDownloadTotalBytes(asset, response);
296 +
297 + const parts: Array<Uint8Array> = [];
298 + let receivedBytes = 0;
299 + let lastReportedAt = 0;
300 +
301 + yield* response.stream.pipe(
302 + Stream.runForEach(chunk => {
303 + parts.push(chunk);
304 + receivedBytes += chunk.length;
305 +
306 + const now = Date.now();
307 + if (now - lastReportedAt < DOWNLOAD_PROGRESS_INTERVAL_MILLIS) {
308 + return Effect.void;
309 + }
310 + lastReportedAt = now;
311 + return onProgress({ receivedBytes, totalBytes });
312 + }),
313 Effect.mapError(
314 cause =>
315 new UpgradeBinaryError({
@@ -259,9 +319,18 @@ const downloadBinary = (
319 )
320 );
321
322 + yield* onProgress({ receivedBytes, totalBytes: totalBytes ?? receivedBytes });
323 +
324 + const data = new Uint8Array(receivedBytes);
325 + let offset = 0;
326 + for (const part of parts) {
327 + data.set(part, offset);
328 + offset += part.length;
329 + }
330 +
331 return {
332 name: binaryName,
264 - data: new Uint8Array(arrayBuffer),
333 + data,
334 };
335 });
336
@@ -607,7 +676,9 @@ const upgrade = (
676 : `New version available: ${release.tag_name} (current: ${currentReleaseIdentifier}). Downloading...`
677 );
678
610 - const { name, data } = yield* downloadBinary(ctx, release, platformArch);
679 + const { name, data } = yield* downloadBinary(ctx, release, platformArch, progress =>
680 + spinner.message(formatDownloadProgress(progress))
681 + );
682
683 yield* spinner.message('Verifying checksum...');
684
ts/packages/cli/test/src/scripts/release-artifacts.test.ts
+40 -40
@@ -8,7 +8,7 @@ import {
8 RUN_COMPANION_SHARED_STATIC_ASSET_RELATIVE_PATHS,
9 } from '../../../src/services/run-companion-modules';
10 import {
11 - archiveCompanionRelativePaths,
11 + archiveCompanionEntries,
12 ARTIFACT_NAMES,
13 RELEASE_ARTIFACT_TARGETS,
14 releaseArtifactTargetFor,
@@ -74,80 +74,80 @@ describe('releaseArtifactTargetFor', () => {
74 );
75 });
76
77 -describe('archiveCompanionRelativePaths', () => {
77 +describe('archiveCompanionEntries', () => {
78 + const pathsOfKind = (
79 + entries: ReadonlyArray<{ relativePath: string; kind: string }>,
80 + kind: string
81 + ): ReadonlyArray<string> =>
82 + entries.filter(entry => entry.kind === kind).map(entry => entry.relativePath);
83 +
84 it.each(RELEASE_ARTIFACT_TARGETS)(
79 - 'ships only $platform-$arch codex-acp in $artifactName',
85 + 'names every codex-acp path in $artifactName so older clients still verify',
86 target => {
81 - const selected = archiveCompanionRelativePaths({
87 + const entries = archiveCompanionEntries({
88 allRelativePaths: ALL_COMPANION_RELATIVE_PATHS,
89 target,
90 });
91
86 - expect(codexAcpRelativePathsIn(selected)).toEqual([
87 - `acp-adapters/codex/${target.platform}-${target.arch}/codex-acp`,
88 - ]);
92 + expect(entries.map(entry => entry.relativePath)).toEqual(ALL_COMPANION_RELATIVE_PATHS);
93 }
94 );
95
92 - it.each(RELEASE_ARTIFACT_TARGETS)('keeps portable assets in $artifactName', target => {
93 - const selected = archiveCompanionRelativePaths({
94 - allRelativePaths: ALL_COMPANION_RELATIVE_PATHS,
95 - target,
96 - });
96 + it.each(RELEASE_ARTIFACT_TARGETS)(
97 + 'carries real bytes only for the $platform-$arch codex-acp binary',
98 + target => {
99 + const entries = archiveCompanionEntries({
100 + allRelativePaths: ALL_COMPANION_RELATIVE_PATHS,
101 + target,
102 + });
103
98 - expect(selected).toEqual(
99 - expect.arrayContaining([
100 - ...RUN_COMPANION_SHARED_STATIC_ASSET_RELATIVE_PATHS,
101 - ...RUN_COMPANION_MODULE_FILENAMES,
102 - ...RUN_COMPANION_MODULE_FILENAMES.map(fileName => `services/${fileName}`),
103 - ])
104 - );
105 - });
104 + expect(codexAcpRelativePathsIn(pathsOfKind(entries, 'copy'))).toEqual([
105 + `acp-adapters/codex/${target.platform}-${target.arch}/codex-acp`,
106 + ]);
107 + }
108 + );
109
110 it.each(RELEASE_ARTIFACT_TARGETS)(
108 - 'drops exactly the foreign codex-acp binaries from $artifactName',
111 + 'placeholders exactly the foreign codex-acp binaries in $artifactName',
112 target => {
110 - const selected = archiveCompanionRelativePaths({
113 + const entries = archiveCompanionEntries({
114 allRelativePaths: ALL_COMPANION_RELATIVE_PATHS,
115 target,
116 });
117
115 - const dropped = ALL_COMPANION_RELATIVE_PATHS.filter(
116 - relativePath => !selected.includes(relativePath)
117 - );
118 -
119 - expect(dropped).toEqual(
118 + expect(pathsOfKind(entries, 'placeholder')).toEqual(
119 RUN_CODEX_ACP_BINARY_TARGETS.filter(
120 codexTarget =>
121 codexTarget.platform !== target.platform || codexTarget.arch !== target.arch
123 - )
124 - .map(codexTarget => codexTarget.relativePath)
125 - .sort()
122 + ).map(codexTarget => codexTarget.relativePath)
123 );
127 - expect(dropped).toHaveLength(RUN_CODEX_ACP_BINARY_TARGETS.length - 1);
124 }
125 );
126
131 - it('leaves an already-narrowed list untouched', () => {
132 - const target = RELEASE_ARTIFACT_TARGETS[0]!;
133 - const selected = archiveCompanionRelativePaths({
127 + it.each(RELEASE_ARTIFACT_TARGETS)('copies the portable assets into $artifactName', target => {
128 + const entries = archiveCompanionEntries({
129 allRelativePaths: ALL_COMPANION_RELATIVE_PATHS,
130 target,
131 });
132
138 - expect(archiveCompanionRelativePaths({ allRelativePaths: selected, target })).toEqual(selected);
133 + expect(pathsOfKind(entries, 'copy')).toEqual(
134 + expect.arrayContaining([
135 + ...RUN_COMPANION_SHARED_STATIC_ASSET_RELATIVE_PATHS,
136 + ...RUN_COMPANION_MODULE_FILENAMES,
137 + ...RUN_COMPANION_MODULE_FILENAMES.map(fileName => `services/${fileName}`),
138 + ])
139 + );
140 });
141 });
142
143 /**
143 - * Packaging ships {@link RUN_COMPANION_ALL_STATIC_ASSET_RELATIVE_PATHS} into every
144 - * archive rather than the narrowed slice, because a CLI released before
145 - * 2026-08-18 verifies an upgrade package against all four codex-acp paths and
146 - * refuses one that is missing any of them.
144 + * Packaging names {@link RUN_COMPANION_ALL_STATIC_ASSET_RELATIVE_PATHS} in every
145 + * archive, because a CLI released before 2026-08-18 verifies an upgrade package
146 + * against all four codex-acp paths and refuses one that is missing any of them.
147 */
148 describe('published archive companion coverage', () => {
149 it.each(RUN_CODEX_ACP_BINARY_TARGETS)(
150 - 'ships the $platform-$arch codex-acp binary in every archive',
150 + 'names the $platform-$arch codex-acp binary in every archive',
151 codexTarget => {
152 expect(RUN_COMPANION_ALL_STATIC_ASSET_RELATIVE_PATHS).toContain(codexTarget.relativePath);
153 }
ts/packages/cli/test/src/services/run-companion-modules.test.ts
+74
@@ -9,6 +9,7 @@ import {
9 hostRunCompanionStaticAssetRelativePaths,
10 listMissingInstalledRunCompanionModules,
11 repairMissingInstalledRunCompanionModules,
12 + resolveRunCompanionAssetPath,
13 RUN_CODEX_ACP_BINARY_TARGETS,
14 RUN_COMPANION_ALL_STATIC_ASSET_RELATIVE_PATHS,
15 RUN_COMPANION_MODULE_FILENAMES,
@@ -373,3 +374,76 @@ describe('run-companion-modules', () => {
374 );
375 });
376 });
377 +
378 +/**
379 + * Release archives fill only the codex-acp binary their own platform can execute
380 + * and leave the other three as empty placeholders, so that a CLI installed
381 + * before 2026-08-18 still passes its upgrade verification. A placeholder must
382 + * never be handed back as a runnable adapter.
383 + */
384 +describe('resolveRunCompanionAssetPath', () => {
385 + layer(BunContext.layer)(it => {
386 + const withInstallDirectory = <A, E, R>(
387 + contents: number,
388 + use: (execPath: string) => Effect.Effect<A, E, R>
389 + ) =>
390 + Effect.gen(function* () {
391 + const installDirectory = fs.mkdtempSync(path.join(os.tmpdir(), 'companion-asset-'));
392 + const execPath = path.join(installDirectory, 'composio');
393 + const assetPath = path.join(installDirectory, 'acp-adapters', 'codex', 'darwin-arm64');
394 + fs.mkdirSync(assetPath, { recursive: true });
395 + fs.writeFileSync(path.join(assetPath, 'codex-acp'), Buffer.alloc(contents));
396 + return yield* use(execPath).pipe(
397 + Effect.ensuring(
398 + Effect.sync(() => fs.rmSync(installDirectory, { recursive: true, force: true }))
399 + )
400 + );
401 + });
402 +
403 + const relativePathFromRoot = 'acp-adapters/codex/darwin-arm64/codex-acp';
404 +
405 + it.effect('resolves a populated binary', () =>
406 + withInstallDirectory(64, execPath =>
407 + Effect.gen(function* () {
408 + const resolved = yield* resolveRunCompanionAssetPath({
409 + callerImportMetaUrl: import.meta.url,
410 + execPath,
411 + relativePathFromRoot,
412 + requireNonEmpty: true,
413 + });
414 +
415 + expect(resolved).toBe(path.join(path.dirname(execPath), relativePathFromRoot));
416 + })
417 + )
418 + );
419 +
420 + it.effect('reports an empty placeholder as absent under requireNonEmpty', () =>
421 + withInstallDirectory(0, execPath =>
422 + Effect.gen(function* () {
423 + const resolved = yield* resolveRunCompanionAssetPath({
424 + callerImportMetaUrl: import.meta.url,
425 + execPath,
426 + relativePathFromRoot,
427 + requireNonEmpty: true,
428 + });
429 +
430 + expect(resolved).toBeNull();
431 + })
432 + )
433 + );
434 +
435 + it.effect('still resolves an empty file when only existence is required', () =>
436 + withInstallDirectory(0, execPath =>
437 + Effect.gen(function* () {
438 + const resolved = yield* resolveRunCompanionAssetPath({
439 + callerImportMetaUrl: import.meta.url,
440 + execPath,
441 + relativePathFromRoot,
442 + });
443 +
444 + expect(resolved).toBe(path.join(path.dirname(execPath), relativePathFromRoot));
445 + })
446 + )
447 + );
448 + });
449 +});
ts/packages/cli/test/src/services/upgrade-binary.test.ts
+37 -1
@@ -5,7 +5,12 @@ import * as PlatformError from '@effect/platform/Error';
5 import { BunFileSystem, BunPath } from '@effect/platform-bun';
6 import { withHttpServer } from 'test/__utils__/http-server';
7 import { getTerminalCapabilities, TerminalUI } from 'src/services/terminal-ui';
8 -import { UpgradeBinary, UpgradeBinaryError } from 'src/services/upgrade-binary';
8 +import {
9 + formatDownloadProgress,
10 + formatMegabytes,
11 + UpgradeBinary,
12 + UpgradeBinaryError,
13 +} from 'src/services/upgrade-binary';
14 import { NodeOs } from 'src/services/node-os';
15 import {
16 collectExpectedRunCompanionAssetRelativePaths,
@@ -718,3 +723,34 @@ describe('UpgradeBinary', () => {
723 }).pipe(Effect.provide(TestPlatform), Effect.ensuring(restoreStubsAndMocks));
724 });
725 });
726 +
727 +describe('formatDownloadProgress', () => {
728 + it('reports percent and both sizes when the total is known', () => {
729 + expect(formatDownloadProgress({ receivedBytes: 142_000_000, totalBytes: 338_000_000 })).toBe(
730 + 'Downloading... 42% (142.0 MB / 338.0 MB)'
731 + );
732 + });
733 +
734 + it('reports bytes alone when the server never sent a size', () => {
735 + expect(formatDownloadProgress({ receivedBytes: 12_500_000, totalBytes: undefined })).toBe(
736 + 'Downloading... 12.5 MB'
737 + );
738 + });
739 +
740 + it('treats a zero total as unknown rather than dividing by it', () => {
741 + expect(formatDownloadProgress({ receivedBytes: 1_000_000, totalBytes: 0 })).toBe(
742 + 'Downloading... 1.0 MB'
743 + );
744 + });
745 +
746 + it('never exceeds 100% when more bytes arrive than announced', () => {
747 + expect(formatDownloadProgress({ receivedBytes: 400_000_000, totalBytes: 338_000_000 })).toBe(
748 + 'Downloading... 100% (400.0 MB / 338.0 MB)'
749 + );
750 + });
751 +
752 + it('formats megabytes to one decimal place', () => {
753 + expect(formatMegabytes(0)).toBe('0.0 MB');
754 + expect(formatMegabytes(338_027_339)).toBe('338.0 MB');
755 + });
756 +});