Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

next
sh 131 lines 5.24 KB
Raw
1 #!/usr/bin/env bash
2 #
3 # Loud failure gate: assert one release archive carries the companion layout the CLI
4 # actually ships — the legacy paths present but empty, the live bundles present with
5 # real bytes, and a release-manifest.json that lists exactly what upgrades must install.
6 #
7 # Each check guards a different failure:
8 #
9 # - A missing legacy path breaks `composio upgrade` for every stable CLI from 0.2.12
10 # to 0.4.2. Those clients verify a downloaded package against their own path list,
11 # by existence only, and refuse one that lacks any of them.
12 # - A legacy path with content means sub-agent or adapter code is shipping again. The
13 # helper it served was removed; the path is only a placeholder.
14 # - An empty live bundle passes every existence check and still breaks `composio run`
15 # and `composio generate`. The root files of the same name are one-line re-export
16 # wrappers, so the bundles under services/ are what carries the code.
17 # - Manifest-aware clients install what release-manifest.json lists and nothing else,
18 # and refuse a manifest they cannot decode. A manifest that omits a live bundle
19 # ships an install that cannot run; one that lists a placeholder or a missing entry
20 # fails every upgrade to this release.
21 #
22 # The unit tests cover the packaging rules on synthetic inputs; only this gate looks at a
23 # real archive, so a change to the packaging pipeline cannot quietly reintroduce any of
24 # these states.
25 #
26 # Inputs (env): ARCHIVE (path to the .zip), ARTIFACT (its top-level directory)
27 set -euo pipefail
28
29 : "${ARCHIVE:?ARCHIVE is required}"
30 : "${ARTIFACT:?ARTIFACT is required}"
31
32 # Keep in lock-step with RUN_COMPANION_LEGACY_PLACEHOLDER_RELATIVE_PATHS in
33 # ts/packages/cli/src/services/run-companion-modules.ts. The list is frozen: it is what
34 # already-released clients ask for.
35 legacy_placeholders=(
36 run-subagent-shared.mjs
37 run-subagent-acp.mjs
38 run-subagent-legacy.mjs
39 run-subagent-output-mcp.mjs
40 acp-adapters/claude-code-acp.mjs
41 acp-adapters/cli.js
42 acp-adapters/codex/darwin-arm64/codex-acp
43 acp-adapters/codex/darwin-x64/codex-acp
44 acp-adapters/codex/linux-arm64/codex-acp
45 acp-adapters/codex/linux-x64/codex-acp
46 )
47
48 live_bundles=(
49 services/run-helpers-runtime.mjs
50 services/generation-runtime.mjs
51 )
52
53 fail() {
54 echo "::error::$1"
55 exit 1
56 }
57
58 test -f "$ARCHIVE" || fail "archive not found: $ARCHIVE"
59 entries="$(unzip -Z1 "$ARCHIVE")"
60
61 # Byte count of an entry as stored, read without extracting to disk.
62 entry_size() {
63 unzip -p "$ARCHIVE" "$1" | wc -c | tr -d '[:space:]'
64 }
65
66 for relative_path in "${legacy_placeholders[@]}"; do
67 entry="${ARTIFACT}/${relative_path}"
68
69 grep -Fxq "$entry" <<<"$entries" ||
70 fail "missing legacy entry '$entry'; CLIs from 0.2.12 to 0.4.2 refuse an archive without it"
71
72 size="$(entry_size "$entry")"
73 [ "$size" -eq 0 ] ||
74 fail "'$entry' is a legacy placeholder but carries $size bytes; it must be empty"
75 echo "ok: $relative_path is an empty placeholder"
76 done
77
78 for relative_path in "${live_bundles[@]}"; do
79 entry="${ARTIFACT}/${relative_path}"
80
81 grep -Fxq "$entry" <<<"$entries" ||
82 fail "missing companion bundle '$entry'; the CLI cannot run without it"
83
84 size="$(entry_size "$entry")"
85 [ "$size" -gt 0 ] ||
86 fail "'$entry' is empty; the CLI cannot run without it"
87 echo "ok: $relative_path carries $size bytes"
88 done
89
90 manifest_entry="${ARTIFACT}/release-manifest.json"
91 grep -Fxq "$manifest_entry" <<<"$entries" ||
92 fail "missing '$manifest_entry'; manifest-aware clients check upgrades against it"
93 manifest="$(unzip -p "$ARCHIVE" "$manifest_entry")"
94
95 jq -e '.schemaVersion == 1' <<<"$manifest" >/dev/null ||
96 fail "'$manifest_entry' must have schemaVersion 1"
97 jq -e '.minimumUpgradeFrom | type == "string" and test("^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z.-]+)?$")' \
98 <<<"$manifest" >/dev/null ||
99 fail "'$manifest_entry' must have a semver minimumUpgradeFrom"
100 jq -e '.companions | type == "array" and length > 0 and all(type == "string")' \
101 <<<"$manifest" >/dev/null ||
102 fail "'$manifest_entry' must list its companions"
103 jq -e '.companions == (.companions | unique)' <<<"$manifest" >/dev/null ||
104 fail "'$manifest_entry' must list its companions sorted and without duplicates; the CLI refuses any other order"
105 # jq on Windows writes CRLF line endings in text mode.
106 manifest_companions="$(jq -r '.companions[]' <<<"$manifest" | tr -d '\r')"
107
108 for relative_path in "${live_bundles[@]}"; do
109 grep -Fxq "$relative_path" <<<"$manifest_companions" ||
110 fail "'$manifest_entry' does not list '$relative_path'; upgrades would not install it"
111 done
112
113 for relative_path in "${legacy_placeholders[@]}"; do
114 if grep -Fxq "$relative_path" <<<"$manifest_companions"; then
115 fail "'$manifest_entry' lists the legacy placeholder '$relative_path'; it must list live companions only"
116 fi
117 done
118
119 listed=0
120 while IFS= read -r relative_path; do
121 entry="${ARTIFACT}/${relative_path}"
122 grep -Fxq "$entry" <<<"$entries" ||
123 fail "'$manifest_entry' lists '$relative_path', which the archive does not contain"
124 size="$(entry_size "$entry")"
125 [ "$size" -gt 0 ] ||
126 fail "'$manifest_entry' lists '$relative_path', which is empty"
127 listed=$((listed + 1))
128 done <<<"$manifest_companions"
129 echo "ok: release-manifest.json lists $listed live companions"
130
131 echo "Archive companion layout verified for $ARTIFACT."