@devries-cameron20 / composio-1 / commits / c8851a54f
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.

chore(ci): automate published client dependency updates (#5199)

This PR: - pairs with https://github.com/ComposioHQ/composio-client/pull/130; merge this receiving workflow first. - opens one reviewed client dependency PR against `next` after `composio-client-published` dispatches, with hourly and manual reconciliation as a fallback. - verifies the newest common stable npm/PyPI release, rejects downgrades and stale payloads, and updates the shared SDK/CLI catalog plus both Python pins through the owning package managers. - includes a core patch changeset and CLI patch note in generated PRs; the latter also triggers the existing CLI beta build when the catalog changes. Notes are confined to Unreleased and preserve published history. - keeps SDKRelease credentials in a separate publication job and refuses artifacts prepared against an older `next`; reuses `RELEASE_BOT_CLIENT_ID` and `RELEASE_BOT_APP_PRIVATE_KEY` without new App permissions. - exempts every `@composio/*` package from pnpm's `minimumReleaseAge`, so a just-published client resolves immediately and the updater only bumps the catalog pin. - uses Effect for typed I/O failures, file system access, schema validation, orchestration and scoped cleanup, with BunRuntime handling process interruption. - validates the updater with 13 offline tests, script typechecking, lint, actionlint, the existing release-workflow/guidance checks and changeset validation. Actual preparation against published `2.0.1` also passed frozen pnpm and uv lock checks in an isolated worktree. The first hourly/manual run can propose the already-published `2.0.1` upgrade. Generated dependency PRs retain normal review and SDK/CLI CI; this implementation does not publish an SDK or CLI release itself.

Alberto Schiabel committed Nov 3, 2026 at 17:52 UTC c8851a54faa2a132517a9645a0d39554e20b9782
6 files changed +1069 -1
.github/workflows/agent-substrate.yml
+3
@@ -70,3 +70,6 @@ jobs:
70
71 - name: Verify issue triage security boundary
72 run: pnpm test:issue-triage
73 +
74 + - name: Verify API client dependency reconciliation
75 + run: bun test test/composio-client-update.test.ts
.github/workflows/client.update.yml new
+126
@@ -0,0 +1,126 @@
1 +name: Update published API client
2 +
3 +on:
4 + repository_dispatch:
5 + types: [composio-client-published]
6 + schedule:
7 + - cron: '23 * * * *'
8 + workflow_dispatch:
9 +
10 +permissions:
11 + contents: read
12 +
13 +concurrency:
14 + group: update-composio-client
15 + cancel-in-progress: false
16 +
17 +jobs:
18 + prepare:
19 + if: >-
20 + github.repository == 'ComposioHQ/composio' &&
21 + github.ref == 'refs/heads/next' &&
22 + (github.event_name != 'repository_dispatch' || github.actor == 'sdkrelease[bot]')
23 + runs-on: ubuntu-latest
24 + outputs:
25 + changed: ${{ steps.update.outputs.changed }}
26 + version: ${{ steps.update.outputs.version }}
27 + steps:
28 + - name: Checkout trusted release branch
29 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
30 + with:
31 + ref: next
32 + fetch-depth: 0
33 + persist-credentials: false
34 +
35 + - name: Setup Node.js, pnpm, Bun
36 + uses: ./.github/actions/setup-node-pnpm-bun
37 +
38 + - name: Setup Python and uv
39 + uses: ./.github/actions/setup-python-uv
40 +
41 + - name: Install trusted tooling without lifecycle scripts
42 + run: pnpm install --frozen-lockfile --ignore-scripts
43 +
44 + - name: Verify registries and prepare dependency update
45 + id: update
46 + run: bun scripts/update-composio-client.ts prepare
47 +
48 + - name: Validate SDK changeset
49 + if: steps.update.outputs.changed == 'true'
50 + run: pnpm validate:changesets
51 +
52 + - name: Transfer only the prepared update
53 + if: steps.update.outputs.changed == 'true'
54 + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
55 + with:
56 + name: client-update
57 + path: .artifacts/client-update/update.json
58 + include-hidden-files: true
59 + if-no-files-found: error
60 + retention-days: 1
61 +
62 + publish:
63 + needs: prepare
64 + if: needs.prepare.result == 'success' && needs.prepare.outputs.changed == 'true'
65 + runs-on: ubuntu-latest
66 + steps:
67 + - name: Checkout trusted release branch
68 + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
69 + with:
70 + ref: next
71 + persist-credentials: false
72 +
73 + - name: Setup Node.js, pnpm, Bun
74 + uses: ./.github/actions/setup-node-pnpm-bun
75 +
76 + - name: Install trusted tooling without lifecycle scripts
77 + run: pnpm install --frozen-lockfile --ignore-scripts
78 +
79 + - name: Download prepared update
80 + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
81 + with:
82 + name: client-update
83 + path: .artifacts/client-update
84 +
85 + - name: Apply allowlisted files after checking the base revision
86 + run: bun scripts/update-composio-client.ts apply
87 +
88 + # The App key is available only after registry access and lock generation.
89 + # App-created PRs trigger the SDK and CLI checks under normal branch protection.
90 + - name: Generate scoped SDKRelease token
91 + id: app-token
92 + uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
93 + with:
94 + client-id: ${{ vars.RELEASE_BOT_CLIENT_ID }}
95 + private-key: ${{ secrets.RELEASE_BOT_APP_PRIVATE_KEY }}
96 + owner: ComposioHQ
97 + repositories: composio
98 + permission-contents: write
99 + permission-pull-requests: write
100 +
101 + - name: Create or update dependency PR
102 + uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
103 + with:
104 + token: ${{ steps.app-token.outputs.token }}
105 + branch: chore/update-composio-client
106 + base: next
107 + commit-message: 'chore(sdk): update composio-client to ${{ needs.prepare.outputs.version }}'
108 + title: 'chore(sdk): update composio-client to ${{ needs.prepare.outputs.version }}'
109 + body: |
110 + Update the shared TypeScript SDK/CLI catalog and Python SDK pins to
111 + composio-client ${{ needs.prepare.outputs.version }}, with regenerated pnpm/uv locks.
112 +
113 + The updater verified the exact stable version on both
114 + [npm](https://www.npmjs.com/package/@composio/client/v/${{ needs.prepare.outputs.version }}) and
115 + [PyPI](https://pypi.org/project/composio-client/${{ needs.prepare.outputs.version }}/).
116 + Includes the SDK patch changeset and CLI release note.
117 +
118 + [Preparation run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
119 + add-paths: |
120 + pnpm-workspace.yaml
121 + pnpm-lock.yaml
122 + python/pyproject.toml
123 + python/setup.py
124 + uv.lock
125 + .changeset/composio-client-update.md
126 + ts/packages/cli/CHANGELOG.md
pnpm-workspace.yaml
+3 -1
@@ -88,7 +88,9 @@ minimumReleaseAgeExclude:
88 - '@effect/platform-node-shared@4.0.3'
89 - '@effect/vitest@4.0.3'
90 - '@mastra/core'
91 - - '@composio/client'
91 + # First-party packages: the automated client update must resolve a release
92 + # the hour it is published, so the release-age wait never applies to them.
93 + - '@composio/*'
94 - chrome-devtools-mcp
95 # temporary: 0.6.0 (2026-09-15) is the first release with the API that
96 # @composio/typesafe targets. Publisher, provenance, and the absence of install
scripts/update-composio-client.ts new
+525
@@ -0,0 +1,525 @@
1 +import { dirname, resolve } from 'node:path';
2 +import * as BunFileSystem from '@effect/platform-bun/BunFileSystem';
3 +import * as BunRuntime from '@effect/platform-bun/BunRuntime';
4 +import { Data, Effect, FileSystem, Schema } from 'effect';
5 +import { compare, valid } from 'semver';
6 +
7 +export const branch = 'chore/update-composio-client';
8 +export const paths = [
9 + 'pnpm-workspace.yaml',
10 + 'pnpm-lock.yaml',
11 + 'python/pyproject.toml',
12 + 'python/setup.py',
13 + 'uv.lock',
14 + '.changeset/composio-client-update.md',
15 + 'ts/packages/cli/CHANGELOG.md',
16 +] as const;
17 +
18 +// The pattern admits only X.Y.Z; semver round-trips it, so whitespace and
19 +// out-of-range components are rejected too.
20 +export const stableVersion = Schema.String.check(
21 + Schema.makeFilter(
22 + value => /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/.test(value) && valid(value) === value,
23 + { message: 'Expected a canonical stable semver version' }
24 + )
25 +);
26 +const sha = Schema.String.check(Schema.isPattern(/^[a-f0-9]{40}$/));
27 +const dispatch = Schema.Struct({
28 + version: stableVersion,
29 + source_sha: sha,
30 + source_repository: Schema.Literal('ComposioHQ/composio-client'),
31 +});
32 +const dispatchEvent = Schema.Struct({ client_payload: Schema.Unknown });
33 +const pypiFile = Schema.Struct({ yanked: Schema.Boolean, filename: Schema.String });
34 +const npmIndex = Schema.Struct({ versions: Schema.Record(Schema.String, Schema.Unknown) });
35 +const pypiIndex = Schema.Struct({
36 + releases: Schema.Record(Schema.String, Schema.Array(pypiFile)),
37 +});
38 +const npmRelease = Schema.Struct({
39 + name: Schema.Literal('@composio/client'),
40 + version: stableVersion,
41 + dist: Schema.Struct({
42 + integrity: Schema.NonEmptyString,
43 + tarball: Schema.String.check(Schema.isPattern(/^https:\/\/registry\.npmjs\.org\/\S+$/)),
44 + }),
45 +});
46 +const pypiRelease = Schema.Struct({
47 + info: Schema.Struct({ name: Schema.Literal('composio-client'), version: stableVersion }),
48 + urls: Schema.Array(pypiFile),
49 +});
50 +const artifactSchema = Schema.Struct({
51 + version: stableVersion,
52 + base_sha: sha,
53 + files: Schema.Array(
54 + Schema.Struct({ path: Schema.Literals(paths), content: Schema.String })
55 + ).check(Schema.isMinLength(1), Schema.isMaxLength(paths.length)),
56 +});
57 +
58 +const decode = <S extends Schema.Codec<unknown, unknown>>(schema: S) =>
59 + Schema.decodeUnknownSync(schema);
60 +// Inputs crossing a trust boundary must not carry fields the updater ignores.
61 +const decodeExact = <S extends Schema.Codec<unknown, unknown>>(schema: S) =>
62 + Schema.decodeUnknownSync(schema, { onExcessProperty: 'error' });
63 +
64 +export const isStableVersion = Schema.is(stableVersion);
65 +
66 +export function validateEvent(name: string, payload: unknown) {
67 + if (name === 'repository_dispatch') {
68 + return decodeExact(dispatch)(decode(dispatchEvent)(payload).client_payload);
69 + }
70 + if (name !== 'schedule' && name !== 'workflow_dispatch')
71 + throw new Error(`Unsupported event: ${name}`);
72 + return undefined;
73 +}
74 +
75 +export function commonStableVersion(npmData: unknown, pypiData: unknown): string {
76 + const npm = decode(npmIndex)(npmData);
77 + const pypi = decode(pypiIndex)(pypiData);
78 + const versions = Object.keys(npm.versions).filter(
79 + version => isStableVersion(version) && pypi.releases[version]?.some(file => !file.yanked)
80 + );
81 + versions.sort(compare);
82 + const latest = versions.at(-1);
83 + if (!latest) throw new Error('npm and PyPI have no common stable composio-client release');
84 + return latest;
85 +}
86 +
87 +export function verifyReleases(version: string, npmData: unknown, pypiData: unknown) {
88 + const npm = decode(npmRelease)(npmData);
89 + const pypi = decode(pypiRelease)(pypiData);
90 + if (
91 + npm.version !== version ||
92 + pypi.info.version !== version ||
93 + !pypi.urls.some(file => !file.yanked && file.filename.endsWith('.whl'))
94 + ) {
95 + throw new Error(`Both registries must expose usable composio-client ${version} distributions`);
96 + }
97 +}
98 +
99 +export const decodeArtifact = decodeExact(artifactSchema);
100 +
101 +const catalogPattern = /^(\s*'@composio\/client':\s*)([^\s#]+)(\s*)$/gm;
102 +const pythonPattern = /("composio-client==)([^"\s]+)(")/g;
103 +
104 +function onePin(content: string, pattern: RegExp, label: string): string {
105 + const matches = [...content.matchAll(pattern)];
106 + if (matches.length !== 1) throw new Error(`Expected exactly one ${label} pin`);
107 + return decode(stableVersion)(matches[0]?.[2]);
108 +}
109 +
110 +function required(files: Record<string, string>, path: string): string {
111 + const content = files[path];
112 + if (content === undefined) throw new Error(`Missing ${path}`);
113 + return content;
114 +}
115 +
116 +export function catalogVersion(content: string) {
117 + return onePin(content, catalogPattern, 'catalog');
118 +}
119 +
120 +export function planUpdates(
121 + files: Record<string, string>,
122 + targetInput: string,
123 + existingCandidate?: string
124 +) {
125 + const target = decode(stableVersion)(targetInput);
126 + const current = [
127 + catalogVersion(required(files, 'pnpm-workspace.yaml')),
128 + onePin(required(files, 'python/pyproject.toml'), pythonPattern, 'Python pyproject'),
129 + onePin(required(files, 'python/setup.py'), pythonPattern, 'Python setup'),
130 + ];
131 + if (current[1] !== current[2])
132 + throw new Error('Python client pins disagree; reconcile metadata first');
133 + if (
134 + [...current, ...(existingCandidate ? [decode(stableVersion)(existingCandidate)] : [])].some(
135 + version => compare(version, target) > 0
136 + )
137 + ) {
138 + throw new Error(`Refusing to downgrade a current or pending client pin to ${target}`);
139 + }
140 + const changed: Record<string, string> = {};
141 + if (current[0] !== target) {
142 + changed['pnpm-workspace.yaml'] = required(files, 'pnpm-workspace.yaml').replace(
143 + catalogPattern,
144 + `$1${target}$3`
145 + );
146 + changed['.changeset/composio-client-update.md'] =
147 + `---\n'@composio/core': patch\n---\n\nUpdate @composio/client to ${target} to include the latest API changes.\n`;
148 + const changelog = required(files, 'ts/packages/cli/CHANGELOG.md');
149 + const header = '# @composio/cli\n\n## Unreleased\n';
150 + const marker = '### Patch Changes\n';
151 + if (!changelog.startsWith(header)) {
152 + throw new Error('CLI changelog is missing its Unreleased section');
153 + }
154 + const nextRelease = changelog.indexOf('\n## ', header.length);
155 + const end = nextRelease === -1 ? changelog.length : nextRelease;
156 + const unreleased = changelog.slice(header.length, end);
157 + const note = `- Update @composio/client to ${target} to include the latest API changes.\n`;
158 + const updated = unreleased.includes(marker)
159 + ? unreleased.replace(marker, `${marker}\n${note}`)
160 + : `\n${marker}\n${note}${unreleased}`;
161 + changed['ts/packages/cli/CHANGELOG.md'] = `${header}${updated}${changelog.slice(end)}`;
162 + }
163 + if (current[1] !== target) {
164 + for (const path of ['python/pyproject.toml', 'python/setup.py']) {
165 + changed[path] = required(files, path).replace(pythonPattern, `$1${target}$3`);
166 + }
167 + }
168 + return { changed, typescript: current[0] !== target, python: current[1] !== target };
169 +}
170 +
171 +export class ClientUpdateIoError extends Data.TaggedError('ClientUpdateIoError')<{
172 + readonly operation: string;
173 + readonly path: string;
174 + readonly message: string;
175 + readonly cause: unknown;
176 +}> {}
177 +export class ClientUpdateRegistryError extends Data.TaggedError('ClientUpdateRegistryError')<{
178 + readonly url: string;
179 + readonly message: string;
180 + readonly cause?: unknown;
181 +}> {}
182 +export class ClientUpdateCommandError extends Data.TaggedError('ClientUpdateCommandError')<{
183 + readonly command: readonly string[];
184 + readonly message: string;
185 + readonly cause?: unknown;
186 +}> {}
187 +export class ClientUpdateValidationError extends Data.TaggedError('ClientUpdateValidationError')<{
188 + readonly message: string;
189 + readonly cause?: unknown;
190 +}> {}
191 +type ClientUpdateError =
192 + | ClientUpdateIoError
193 + | ClientUpdateRegistryError
194 + | ClientUpdateCommandError
195 + | ClientUpdateValidationError;
196 +
197 +const checked = <A>(operation: () => A) =>
198 + Effect.try({
199 + try: operation,
200 + catch: cause =>
201 + new ClientUpdateValidationError({
202 + message: cause instanceof Error ? cause.message : 'Client update validation failed',
203 + cause,
204 + }),
205 + });
206 +const file = <A, E>(
207 + operation: string,
208 + path: string,
209 + action: (fs: FileSystem.FileSystem) => Effect.Effect<A, E>
210 +) =>
211 + Effect.gen(function* () {
212 + return yield* action(yield* FileSystem.FileSystem);
213 + }).pipe(
214 + Effect.mapError(
215 + cause =>
216 + new ClientUpdateIoError({ operation, path, message: `Cannot ${operation}: ${path}`, cause })
217 + )
218 + );
219 +const read = (path: string) => file('read file', path, fs => fs.readFileString(path));
220 +const write = (path: string, content: string) =>
221 + file('write file', path, fs => fs.writeFileString(path, content));
222 +const directory = (path: string) =>
223 + file('create directory', path, fs => fs.makeDirectory(path, { recursive: true }));
224 +
225 +const registryJson = (url: string) =>
226 + Effect.gen(function* () {
227 + const response = yield* Effect.tryPromise({
228 + try: signal =>
229 + fetch(url, {
230 + signal: AbortSignal.any([signal, AbortSignal.timeout(60_000)]),
231 + headers: { accept: 'application/json' },
232 + redirect: 'error',
233 + }),
234 + catch: cause =>
235 + new ClientUpdateRegistryError({ url, message: `Registry request failed: ${url}`, cause }),
236 + });
237 + if (!response.ok)
238 + return yield* Effect.fail(
239 + new ClientUpdateRegistryError({
240 + url,
241 + message: `Registry request failed: ${url} (${response.status})`,
242 + })
243 + );
244 + return yield* Effect.tryPromise({
245 + try: () => response.json(),
246 + catch: cause =>
247 + new ClientUpdateRegistryError({ url, message: `Invalid registry JSON: ${url}`, cause }),
248 + });
249 + });
250 +
251 +const processResult = (args: string[], cwd: string, capture = false) =>
252 + Effect.acquireUseRelease(
253 + Effect.try({
254 + try: () =>
255 + Bun.spawn(args, {
256 + cwd,
257 + stdout: capture ? 'pipe' : 'inherit',
258 + stderr: capture ? 'ignore' : 'inherit',
259 + }),
260 + catch: cause =>
261 + new ClientUpdateCommandError({
262 + command: args,
263 + message: `Cannot start command: ${args.join(' ')}`,
264 + cause,
265 + }),
266 + }),
267 + child =>
268 + Effect.gen(function* () {
269 + const [stdout, exitCode] = yield* Effect.all(
270 + [
271 + capture
272 + ? Effect.tryPromise({
273 + try: () => new Response(child.stdout).text(),
274 + catch: cause =>
275 + new ClientUpdateCommandError({
276 + command: args,
277 + message: `Cannot read command output: ${args.join(' ')}`,
278 + cause,
279 + }),
280 + })
281 + : Effect.succeed(''),
282 + Effect.tryPromise({
283 + try: () => child.exited,
284 + catch: cause =>
285 + new ClientUpdateCommandError({
286 + command: args,
287 + message: `Cannot await command: ${args.join(' ')}`,
288 + cause,
289 + }),
290 + }),
291 + ],
292 + { concurrency: 'unbounded' }
293 + );
294 + return { stdout, exitCode };
295 + }),
296 + child =>
297 + Effect.try({
298 + try: () => {
299 + if (child.exitCode === null) child.kill();
300 + },
301 + catch: cause =>
302 + new ClientUpdateCommandError({
303 + command: args,
304 + message: 'Cannot stop interrupted command',
305 + cause,
306 + }),
307 + }).pipe(Effect.ignore)
308 + );
309 +const command = (args: string[], cwd: string) =>
310 + Effect.gen(function* () {
311 + const result = yield* processResult(args, cwd);
312 + if (result.exitCode !== 0)
313 + return yield* Effect.fail(
314 + new ClientUpdateCommandError({
315 + command: args,
316 + message: `Command failed: ${args.join(' ')}`,
317 + })
318 + );
319 + });
320 +const git = (args: string[], root: string, allowFailure = false) =>
321 + Effect.gen(function* () {
322 + const result = yield* processResult(['git', ...args], root, true);
323 + if (!allowFailure && result.exitCode !== 0)
324 + return yield* Effect.fail(
325 + new ClientUpdateCommandError({
326 + command: ['git', ...args],
327 + message: `Git command failed: ${args[0]}`,
328 + })
329 + );
330 + return result;
331 + });
332 +const output = (name: string, value: string) =>
333 + Effect.gen(function* () {
334 + const path = process.env.GITHUB_OUTPUT;
335 + if (path)
336 + yield* file('append workflow output', path, fs =>
337 + fs.writeFileString(path, `${name}=${value}\n`, { flag: 'a' })
338 + );
339 + });
340 +
341 +export const prepare = (
342 + root: string,
343 + options: {
344 + eventName: string;
345 + event: unknown;
346 + registry?: (url: string) => Effect.Effect<unknown, ClientUpdateError>;
347 + runCommand?: (
348 + args: string[],
349 + cwd: string
350 + ) => Effect.Effect<void, ClientUpdateError, FileSystem.FileSystem>;
351 + setOutput?: (
352 + name: string,
353 + value: string
354 + ) => Effect.Effect<void, ClientUpdateError, FileSystem.FileSystem>;
355 + }
356 +) =>
357 + Effect.gen(function* () {
358 + const readRegistry = options.registry ?? registryJson;
359 + const runCommand = options.runCommand ?? command;
360 + const setOutput = options.setOutput ?? output;
361 + const source = yield* checked(() => validateEvent(options.eventName, options.event));
362 + const artifactPath = resolve(root, '.artifacts/client-update/update.json');
363 + yield* file('remove stale artifact', artifactPath, fs =>
364 + fs.remove(artifactPath, { force: true })
365 + );
366 + const [npm, pypi] = yield* Effect.all(
367 + [
368 + readRegistry('https://registry.npmjs.org/@composio%2fclient'),
369 + readRegistry('https://pypi.org/pypi/composio-client/json'),
370 + ],
371 + { concurrency: 'unbounded' }
372 + );
373 + const version = yield* checked(() => commonStableVersion(npm, pypi));
374 + // A dispatch may race the registry CDN. Retry next hour rather than silently acknowledging an older release.
375 + if (source && compare(version, source.version) < 0)
376 + return yield* Effect.fail(
377 + new ClientUpdateValidationError({
378 + message: `Dispatched ${source.version} is not yet available on both registries`,
379 + })
380 + );
381 + const [npmExact, pypiExact] = yield* Effect.all(
382 + [
383 + readRegistry(`https://registry.npmjs.org/@composio%2fclient/${version}`),
384 + readRegistry(`https://pypi.org/pypi/composio-client/${version}/json`),
385 + ],
386 + { concurrency: 'unbounded' }
387 + );
388 + yield* checked(() => verifyReleases(version, npmExact, pypiExact));
389 + const files = Object.fromEntries(
390 + yield* Effect.all(
391 + [
392 + 'pnpm-workspace.yaml',
393 + 'python/pyproject.toml',
394 + 'python/setup.py',
395 + 'ts/packages/cli/CHANGELOG.md',
396 + ].map(path =>
397 + Effect.gen(function* () {
398 + return [path, yield* read(resolve(root, path))];
399 + })
400 + ),
401 + { concurrency: 'unbounded' }
402 + )
403 + );
404 + const candidate = yield* git(
405 + ['show', `refs/remotes/origin/${branch}:pnpm-workspace.yaml`],
406 + root,
407 + true
408 + );
409 + const existing =
410 + candidate.exitCode === 0 ? yield* checked(() => catalogVersion(candidate.stdout)) : undefined;
411 + const plan = yield* checked(() => planUpdates(files, version, existing));
412 + const changed = Object.keys(plan.changed).length > 0;
413 + yield* setOutput('changed', String(changed));
414 + yield* setOutput('version', version);
415 + if (!changed) {
416 + yield* Effect.sync(() => console.log(`All client pins already use ${version}`));
417 + return;
418 + }
419 + for (const [path, content] of Object.entries(plan.changed)) {
420 + yield* directory(dirname(resolve(root, path)));
421 + yield* write(resolve(root, path), content);
422 + }
423 + if (plan.typescript) {
424 + yield* runCommand(
425 + ['pnpm', 'install', '--lockfile-only', '--ignore-scripts', '--no-frozen-lockfile'],
426 + root
427 + );
428 + }
429 + if (plan.python) {
430 + const python = yield* checked(() => decode(Schema.NonEmptyString)(Bun.which('python')));
431 + yield* runCommand(
432 + ['uv', 'lock', '--python', python, '--upgrade-package', 'composio-client'],
433 + root
434 + );
435 + }
436 + const diff = yield* git(['diff', '--name-only'], root);
437 + const diffPaths = diff.stdout.trim().split('\n').filter(Boolean);
438 + if (diffPaths.some(path => !paths.some(allowed => allowed === path))) {
439 + return yield* Effect.fail(
440 + new ClientUpdateValidationError({
441 + message: 'Lock generation changed files outside the client update allowlist',
442 + })
443 + );
444 + }
445 + const base = yield* git(['rev-parse', 'HEAD'], root);
446 + const baseSha = yield* checked(() => decode(sha)(base.stdout.trim()));
447 + const artifactFiles = yield* Effect.all(
448 + [...new Set([...diffPaths, ...Object.keys(plan.changed)])].map(path =>
449 + Effect.gen(function* () {
450 + return { path, content: yield* read(resolve(root, path)) };
451 + })
452 + ),
453 + { concurrency: 'unbounded' }
454 + );
455 + const artifact = yield* checked(() =>
456 + decodeArtifact({
457 + version,
458 + base_sha: baseSha,
459 + files: artifactFiles,
460 + })
461 + );
462 + yield* directory(resolve(root, '.artifacts/client-update'));
463 + yield* write(artifactPath, JSON.stringify(artifact));
464 + yield* Effect.sync(() =>
465 + console.log(`Prepared client ${version}; npm and PyPI exact distributions verified`)
466 + );
467 + });
468 +
469 +export const applyArtifact = (root: string, data: unknown, baseSha: string) =>
470 + Effect.gen(function* () {
471 + const artifact = yield* checked(() => decodeArtifact(data));
472 + if (artifact.base_sha !== baseSha)
473 + return yield* Effect.fail(
474 + new ClientUpdateValidationError({
475 + message: 'next advanced after preparation; retry against its current revision',
476 + })
477 + );
478 + if (new Set(artifact.files.map(file => file.path)).size !== artifact.files.length)
479 + return yield* Effect.fail(
480 + new ClientUpdateValidationError({ message: 'Duplicate artifact path' })
481 + );
482 + for (const file of artifact.files) {
483 + yield* directory(dirname(resolve(root, file.path)));
484 + yield* write(resolve(root, file.path), file.content);
485 + }
486 + return artifact.version;
487 + });
488 +
489 +if (import.meta.main) {
490 + const main = Effect.gen(function* () {
491 + const root = process.cwd();
492 + if (process.argv[2] === 'prepare') {
493 + const eventText = process.env.GITHUB_EVENT_PATH
494 + ? yield* read(process.env.GITHUB_EVENT_PATH)
495 + : '{}';
496 + yield* prepare(root, {
497 + eventName: process.env.GITHUB_EVENT_NAME ?? 'workflow_dispatch',
498 + event: yield* checked(() => JSON.parse(eventText)),
499 + });
500 + } else if (process.argv[2] === 'apply') {
501 + const head = yield* git(['rev-parse', 'HEAD'], root);
502 + const artifactText = yield* read(resolve(root, '.artifacts/client-update/update.json'));
503 + const version = yield* applyArtifact(
504 + root,
505 + yield* checked(() => JSON.parse(artifactText)),
506 + head.stdout.trim()
507 + );
508 + yield* output('version', version);
509 + } else
510 + return yield* Effect.fail(
511 + new ClientUpdateValidationError({
512 + message: 'Usage: bun scripts/update-composio-client.ts prepare|apply',
513 + })
514 + );
515 + });
516 + BunRuntime.runMain(
517 + main.pipe(
518 + Effect.tapError(error => Effect.sync(() => console.error(error.message))),
519 + Effect.provide(BunFileSystem.layer)
520 + ),
521 + {
522 + disableErrorReporting: true,
523 + }
524 + );
525 +}
test/composio-client-update.test.ts new
+410
@@ -0,0 +1,410 @@
1 +import { expect, test } from 'bun:test';
2 +import { dirname, join } from 'node:path';
3 +import * as BunFileSystem from '@effect/platform-bun/BunFileSystem';
4 +import { Effect, FileSystem, Schema } from 'effect';
5 +import {
6 + ClientUpdateCommandError,
7 + ClientUpdateIoError,
8 + ClientUpdateRegistryError,
9 + applyArtifact,
10 + catalogVersion,
11 + commonStableVersion,
12 + isStableVersion,
13 + planUpdates,
14 + prepare,
15 + validateEvent,
16 + verifyReleases,
17 +} from '../scripts/update-composio-client';
18 +
19 +const wheel = { filename: 'composio_client-2.0.1-py3-none-any.whl', yanked: false };
20 +const sourceSha = 'a'.repeat(40);
21 +const run = <A, E>(effect: Effect.Effect<A, E, FileSystem.FileSystem>) =>
22 + Effect.runPromise(effect.pipe(Effect.provide(BunFileSystem.layer)));
23 +const withFs = <A, E>(action: (fs: FileSystem.FileSystem) => Effect.Effect<A, E>) =>
24 + Effect.gen(function* () {
25 + return yield* action(yield* FileSystem.FileSystem);
26 + });
27 +const fixtureIo = <A, E>(action: (fs: FileSystem.FileSystem) => Effect.Effect<A, E>) =>
28 + withFs(action).pipe(
29 + Effect.mapError(
30 + cause =>
31 + new ClientUpdateIoError({
32 + operation: 'fixture I/O',
33 + path: 'fixture',
34 + message: 'Fixture I/O failed',
35 + cause,
36 + })
37 + )
38 + );
39 +const tempDirectory = (prefix: string) => run(withFs(fs => fs.makeTempDirectory({ prefix })));
40 +const removeDirectory = (path: string) =>
41 + run(withFs(fs => fs.remove(path, { recursive: true, force: true })));
42 +const readText = (path: string) => run(withFs(fs => fs.readFileString(path)));
43 +const files = {
44 + 'pnpm-workspace.yaml':
45 + "catalog:\n '@composio/client': 2.0.0\n effect: ^4.1.0\nminimumReleaseAgeExclude:\n - '@composio/*'\n - effect@4.0.3\n",
46 + 'python/pyproject.toml': 'dependencies = [\n "composio-client==2.0.0",\n]\n',
47 + 'python/setup.py': 'install_requires=["composio-client==2.0.0"],\n',
48 + 'ts/packages/cli/CHANGELOG.md':
49 + '# @composio/cli\n\n## Unreleased\n\n### Patch Changes\n\n- Existing note.\n',
50 +};
51 +
52 +test('only canonical stable versions cross the registry/event boundary', () => {
53 + for (const version of [
54 + 'v2.0.1',
55 + '2.0.1-rc.1',
56 + '2.0.1+meta',
57 + '02.0.1',
58 + '2.0.1\n',
59 + ' 2.0.1',
60 + '2.0.1 ',
61 + '9007199254740993.0.0',
62 + '$(id)',
63 + '2.0',
64 + ]) {
65 + expect(isStableVersion(version)).toBe(false);
66 + }
67 + const payload = {
68 + version: '2.0.1',
69 + source_sha: sourceSha,
70 + source_repository: 'ComposioHQ/composio-client',
71 + };
72 + expect(validateEvent('repository_dispatch', { client_payload: payload })?.version).toBe('2.0.1');
73 + expect(() =>
74 + validateEvent('repository_dispatch', { client_payload: { ...payload, ref: 'attacker' } })
75 + ).toThrow();
76 + expect(() =>
77 + validateEvent('repository_dispatch', {
78 + client_payload: { ...payload, source_repository: 'other/repo' },
79 + })
80 + ).toThrow();
81 + expect(() =>
82 + validateEvent('repository_dispatch', { client_payload: { ...payload, source_sha: 'next' } })
83 + ).toThrow();
84 + expect(validateEvent('schedule', {})).toBeUndefined();
85 +});
86 +
87 +test('reconciliation selects the latest common stable non-yanked release', () => {
88 + expect(
89 + commonStableVersion(
90 + { versions: { '2.0.0': {}, '2.0.1': {}, '2.1.0': {}, '3.0.0-rc.1': {}, '2.0.2': {} } },
91 + {
92 + releases: {
93 + '2.0.0': [wheel],
94 + '2.0.1': [wheel],
95 + '2.0.2': [{ ...wheel, yanked: true }],
96 + '3.0.0-rc.1': [wheel],
97 + },
98 + }
99 + )
100 + ).toBe('2.0.1');
101 + expect(() => commonStableVersion({ versions: { '2.0.1': {} } }, { releases: {} })).toThrow(
102 + 'no common stable'
103 + );
104 + expect(() => commonStableVersion({ error: 'rate limited' }, { releases: {} })).toThrow();
105 +});
106 +
107 +test('exact registry metadata must confirm usable distributions from both packages', () => {
108 + const npm = {
109 + name: '@composio/client',
110 + version: '2.0.1',
111 + dist: {
112 + integrity: 'sha512-value',
113 + tarball: 'https://registry.npmjs.org/@composio/client/-/client-2.0.1.tgz',
114 + },
115 + };
116 + const pypi = { info: { name: 'composio-client', version: '2.0.1' }, urls: [wheel] };
117 + verifyReleases('2.0.1', npm, pypi);
118 + expect(() => verifyReleases('2.0.2', npm, pypi)).toThrow('Both registries');
119 + expect(() =>
120 + verifyReleases('2.0.1', npm, { ...pypi, urls: [{ ...wheel, yanked: true }] })
121 + ).toThrow();
122 + expect(() => verifyReleases('2.0.1', { ...npm, dist: {} }, pypi)).toThrow();
123 +});
124 +
125 +test('planning updates owned pins, SDK changeset and CLI release note once', () => {
126 + const plan = planUpdates(files, '2.0.1');
127 + expect(plan.typescript).toBe(true);
128 + expect(plan.python).toBe(true);
129 + expect(catalogVersion(plan.changed['pnpm-workspace.yaml']!)).toBe('2.0.1');
130 + expect(plan.changed['pnpm-workspace.yaml']).toBe(
131 + files['pnpm-workspace.yaml'].replace("'@composio/client': 2.0.0", "'@composio/client': 2.0.1")
132 + );
133 + expect(plan.changed['python/setup.py']).toContain('composio-client==2.0.1');
134 + expect(plan.changed['python/pyproject.toml']).toContain('composio-client==2.0.1');
135 + expect(plan.changed['.changeset/composio-client-update.md']).toContain("'@composio/core': patch");
136 + expect(plan.changed['.changeset/composio-client-update.md']).not.toContain("'@composio/cli':");
137 + expect(plan.changed['ts/packages/cli/CHANGELOG.md']).toContain('- Existing note.');
138 + expect(planUpdates({ ...files, ...plan.changed }, '2.0.1').changed).toEqual({});
139 + expect(planUpdates(files, '2.0.1').changed).toEqual(plan.changed);
140 +});
141 +
142 +test('the workspace exempts every first-party package from the release-age wait', async () => {
143 + const workspace = Schema.decodeUnknownSync(
144 + Schema.Struct({
145 + minimumReleaseAge: Schema.Number,
146 + minimumReleaseAgeExclude: Schema.Array(Schema.String),
147 + })
148 + )(Bun.YAML.parse(await readText(new URL('../pnpm-workspace.yaml', import.meta.url).pathname)));
149 + expect(workspace.minimumReleaseAgeExclude).toContain('@composio/*');
150 +});
151 +
152 +test('CLI notes create an Unreleased patch section without changing released history', () => {
153 + const history = '\n## 0.3.0\n\n### Patch Changes\n\n- A published fix.\n';
154 + for (const unreleased of ['\n', '\n### Minor Changes\n\n- An upcoming feature.\n']) {
155 + const header = '# @composio/cli\n\n## Unreleased\n';
156 + const updated = planUpdates(
157 + {
158 + ...files,
159 + 'ts/packages/cli/CHANGELOG.md': `${header}${unreleased}${history}`,
160 + },
161 + '2.0.1'
162 + ).changed['ts/packages/cli/CHANGELOG.md']!;
163 + const boundary = updated.indexOf('\n## 0.3.0');
164 + expect(updated.slice(boundary)).toBe(history);
165 + expect(updated.slice(0, boundary)).toContain(
166 + '### Patch Changes\n\n- Update @composio/client to 2.0.1'
167 + );
168 + expect(updated.slice(0, boundary)).toContain(unreleased);
169 + }
170 +});
171 +
172 +test('never lowers current or pending versions, and rejects inconsistent Python metadata', () => {
173 + expect(() => planUpdates(files, '1.9.9')).toThrow('downgrade');
174 + expect(() => planUpdates(files, '2.0.1', '2.0.2')).toThrow('downgrade');
175 + expect(() =>
176 + planUpdates({ ...files, 'python/setup.py': '"composio-client==2.0.2"' }, '2.0.3')
177 + ).toThrow('disagree');
178 + expect(() =>
179 + planUpdates(
180 + { ...files, 'pnpm-workspace.yaml': files['pnpm-workspace.yaml'].repeat(2) },
181 + '2.0.1'
182 + )
183 + ).toThrow('exactly one');
184 +});
185 +
186 +test('Python-only catchup does not create a TypeScript release', () => {
187 + const plan = planUpdates(
188 + { ...files, 'pnpm-workspace.yaml': files['pnpm-workspace.yaml'].replace('2.0.0', '2.0.1') },
189 + '2.0.1'
190 + );
191 + expect(plan.typescript).toBe(false);
192 + expect(plan.python).toBe(true);
193 + expect(Object.keys(plan.changed).sort()).toEqual(['python/pyproject.toml', 'python/setup.py']);
194 +});
195 +
196 +test('artifact transfer rejects unexpected paths, duplicates and advancing next before writes', async () => {
197 + const root = await tempDirectory('client-update-');
198 + const artifact = {
199 + version: '2.0.1',
200 + base_sha: sourceSha,
201 + files: [{ path: 'python/setup.py', content: 'updated' }],
202 + };
203 + try {
204 + await expect(run(applyArtifact(root, artifact, 'b'.repeat(40)))).rejects.toThrow(
205 + 'next advanced'
206 + );
207 + await expect(
208 + run(
209 + applyArtifact(
210 + root,
211 + { ...artifact, files: [{ path: '../escape', content: 'bad' }] },
212 + sourceSha
213 + )
214 + )
215 + ).rejects.toThrow();
216 + await expect(
217 + run(
218 + applyArtifact(
219 + root,
220 + { ...artifact, files: [...artifact.files, ...artifact.files] },
221 + sourceSha
222 + )
223 + )
224 + ).rejects.toThrow('Duplicate');
225 + expect(await run(applyArtifact(root, artifact, sourceSha))).toBe('2.0.1');
226 + expect(await readText(join(root, 'python/setup.py'))).toBe('updated');
227 + } finally {
228 + await removeDirectory(root);
229 + }
230 +});
231 +
232 +test('offline preparation runs scoped lock commands and publishes no artifact on failure', async () => {
233 + for (const failLock of [false, true]) {
234 + const root = await tempDirectory('client-update-prepare-');
235 + const commands: string[][] = [];
236 + try {
237 + for (const [path, content] of Object.entries(files)) {
238 + await run(
239 + withFs(fs =>
240 + Effect.andThen(fs.makeDirectory(dirname(join(root, path)), { recursive: true }), () =>
241 + fs.writeFileString(join(root, path), content)
242 + )
243 + )
244 + );
245 + }
246 + for (const args of [
247 + ['init', '--quiet'],
248 + ['add', '.'],
249 + [
250 + '-c',
251 + 'user.name=Fixture',
252 + '-c',
253 + 'user.email=fixture@example.com',
254 + 'commit',
255 + '--quiet',
256 + '-m',
257 + 'fixture',
258 + ],
259 + ]) {
260 + expect(Bun.spawnSync(['git', ...args], { cwd: root }).exitCode).toBe(0);
261 + }
262 + const registry = (url: string) =>
263 + Effect.sync(() => {
264 + if (url.endsWith('/2.0.1'))
265 + return {
266 + name: '@composio/client',
267 + version: '2.0.1',
268 + dist: { integrity: 'sha512-value', tarball: 'https://registry.npmjs.org/client.tgz' },
269 + };
270 + if (url.endsWith('/2.0.1/json'))
271 + return { info: { name: 'composio-client', version: '2.0.1' }, urls: [wheel] };
272 + if (new URL(url).hostname === 'pypi.org') return { releases: { '2.0.1': [wheel] } };
273 + return { versions: { '2.0.1': {} } };
274 + });
275 + const result = run(
276 + prepare(root, {
277 + eventName: 'schedule',
278 + event: {},
279 + registry,
280 + runCommand: args =>
281 + Effect.gen(function* () {
282 + yield* Effect.sync(() => commands.push(args));
283 + if (failLock)
284 + return yield* Effect.fail(
285 + new ClientUpdateCommandError({ command: args, message: 'lock resolution failed' })
286 + );
287 + yield* fixtureIo(fs =>
288 + fs.writeFileString(
289 + join(root, args[0] === 'pnpm' ? 'pnpm-lock.yaml' : 'uv.lock'),
290 + 'fixture lock'
291 + )
292 + );
293 + }),
294 + setOutput: () => Effect.succeed(undefined),
295 + })
296 + );
297 + const artifactPath = join(root, '.artifacts/client-update/update.json');
298 + if (failLock) {
299 + await expect(result).rejects.toThrow('lock resolution failed');
300 + await expect(result).rejects.toBeInstanceOf(ClientUpdateCommandError);
301 + await expect(readText(artifactPath)).rejects.toThrow();
302 + } else {
303 + await result;
304 + expect(commands).toEqual([
305 + ['pnpm', 'install', '--lockfile-only', '--ignore-scripts', '--no-frozen-lockfile'],
306 + [
307 + 'uv',
308 + 'lock',
309 + '--python',
310 + Bun.which('python') ?? '',
311 + '--upgrade-package',
312 + 'composio-client',
313 + ],
314 + ]);
315 + expect(JSON.parse(await readText(artifactPath)).version).toBe('2.0.1');
316 + }
317 + expect(catalogVersion(await readText(join(root, 'pnpm-workspace.yaml')))).toBe('2.0.1');
318 + } finally {
319 + await removeDirectory(root);
320 + }
321 + }
322 +});
323 +
324 +test('registry outages and dispatch/CDN races fail before mutation', async () => {
325 + const root = await tempDirectory('client-update-registry-');
326 + try {
327 + await expect(
328 + run(
329 + prepare(root, {
330 + eventName: 'schedule',
331 + event: {},
332 + registry: () =>
333 + Effect.fail(
334 + new ClientUpdateRegistryError({
335 + url: 'https://pypi.org',
336 + message: 'Registry request failed (503)',
337 + })
338 + ),
339 + })
340 + )
341 + ).rejects.toThrow('Registry request failed');
342 + await expect(
343 + run(
344 + prepare(root, {
345 + eventName: 'repository_dispatch',
346 + event: {
347 + client_payload: {
348 + version: '2.0.2',
349 + source_sha: sourceSha,
350 + source_repository: 'ComposioHQ/composio-client',
351 + },
352 + },
353 + registry: url =>
354 + Effect.succeed(
355 + new URL(url).hostname === 'pypi.org'
356 + ? { releases: { '2.0.1': [wheel] } }
357 + : { versions: { '2.0.1': {} } }
358 + ),
359 + })
360 + )
361 + ).rejects.toThrow('not yet available on both registries');
362 + await expect(readText(join(root, '.artifacts/client-update/update.json'))).rejects.toThrow();
363 + } finally {
364 + await removeDirectory(root);
365 + }
366 +});
367 +
368 +test('workflow keeps dispatched data out of code and scopes App credentials to publishing', async () => {
369 + const workflow = Bun.YAML.parse(
370 + await readText(new URL('../.github/workflows/client.update.yml', import.meta.url).pathname)
371 + );
372 + const steps = Schema.Array(Schema.Record(Schema.String, Schema.Unknown));
373 + const parsed = Schema.decodeUnknownSync(
374 + Schema.Struct({
375 + on: Schema.Struct({
376 + repository_dispatch: Schema.Struct({ types: Schema.Array(Schema.String) }),
377 + schedule: Schema.Array(Schema.Struct({ cron: Schema.String })),
378 + }),
379 + concurrency: Schema.Struct({ 'cancel-in-progress': Schema.Literal(false) }),
380 + jobs: Schema.Struct({
381 + prepare: Schema.Struct({ if: Schema.String, steps }),
382 + publish: Schema.Struct({ steps }),
383 + }),
384 + })
385 + )(workflow);
386 + expect(parsed.on.repository_dispatch.types).toContain('composio-client-published');
387 + expect(parsed.jobs.prepare.if).toContain("github.actor == 'sdkrelease[bot]'");
388 + expect(JSON.stringify(parsed.jobs.prepare)).not.toContain('RELEASE_BOT_APP_PRIVATE_KEY');
389 + const text = JSON.stringify(parsed.jobs.publish.steps);
390 + expect(text).toContain('permission-pull-requests');
391 + expect(text).not.toContain('auto-merge');
392 + expect(text.indexOf('update-composio-client.ts apply')).toBeLessThan(
393 + text.indexOf('RELEASE_BOT_APP_PRIVATE_KEY')
394 + );
395 +});
396 +
397 +test('CLI reports a failed command once without dumping structured causes', () => {
398 + const result = Bun.spawnSync(
399 + [
400 + process.execPath,
401 + new URL('../scripts/update-composio-client.ts', import.meta.url).pathname,
402 + 'invalid-command',
403 + ],
404 + { stdout: 'pipe', stderr: 'pipe' }
405 + );
406 + expect(result.exitCode).toBe(1);
407 + expect(result.stderr.toString().trim()).toBe(
408 + 'Usage: bun scripts/update-composio-client.ts prepare|apply'
409 + );
410 +});
tsconfig.agent-workflow.json
+2
@@ -10,6 +10,8 @@
10 "esModuleInterop": true
11 },
12 "include": [
13 + "scripts/update-composio-client.ts",
14 + "test/composio-client-update.test.ts",
15 "scripts/agent-task.ts",
16 "ts/scripts/check-cli-skills.ts",
17 "test/cli-skills.test.ts",