Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
| 1 | import { describe, expect, it } from 'bun:test'; |
| 2 | import { spawnSync } from 'node:child_process'; |
| 3 | import { mkdir, mkdtemp, rm, writeFile } from 'node:fs/promises'; |
| 4 | import { tmpdir } from 'node:os'; |
| 5 | import path from 'node:path'; |
| 6 | import { |
| 7 | buildCompatibilityPlan, |
| 8 | discoverProviderCases, |
| 9 | parseCliOptions, |
| 10 | repackCoreTarball, |
| 11 | } from '../ts/scripts/check-provider-compatibility'; |
| 12 | |
| 13 | describe('provider compatibility plan', () => { |
| 14 | it('covers every provider at the workspace, verified minimum, and beta boundaries', async () => { |
| 15 | const providers = await discoverProviderCases(); |
| 16 | const plan = buildCompatibilityPlan(providers, '1.0.0-beta.0'); |
| 17 | const providerNames = providers.map(provider => provider.name); |
| 18 | const current = plan.find(lane => lane.id === 'workspace-current'); |
| 19 | const beta = plan.find(lane => lane.id === 'workspace-major-prerelease'); |
| 20 | const minimum = plan.filter(lane => lane.id.startsWith('verified-minimum-core-')); |
| 21 | |
| 22 | expect(providerNames).toHaveLength(11); |
| 23 | expect(current?.providerNames).toEqual(providerNames); |
| 24 | expect(beta?.providerNames).toEqual(providerNames); |
| 25 | expect(beta?.core).toEqual({ kind: 'workspace-prerelease', version: '1.0.0-beta.0' }); |
| 26 | expect(minimum.flatMap(lane => lane.providerNames).sort()).toEqual([...providerNames].sort()); |
| 27 | expect(minimum).toHaveLength(11); |
| 28 | expect( |
| 29 | Object.fromEntries( |
| 30 | minimum.map(lane => [ |
| 31 | lane.providerNames[0], |
| 32 | lane.core.kind === 'registry' && lane.core.specifier, |
| 33 | ]) |
| 34 | ) |
| 35 | ).toEqual({ |
| 36 | '@composio/anthropic': '0.14.0', |
| 37 | '@composio/claude-agent-sdk': '0.11.0', |
| 38 | '@composio/cloudflare': '0.14.0', |
| 39 | '@composio/google': '0.16.0', |
| 40 | '@composio/langchain': '0.11.0', |
| 41 | '@composio/llamaindex': '0.14.0', |
| 42 | '@composio/mastra': '0.18.0', |
| 43 | '@composio/openai': '0.18.0', |
| 44 | '@composio/openai-agents': '0.18.0', |
| 45 | '@composio/typesafe': '0.18.1', |
| 46 | '@composio/vercel': '0.18.0', |
| 47 | }); |
| 48 | expect(minimum.every(lane => lane.providerNames.length === 1)).toBe(true); |
| 49 | expect(current?.lifecycleScripts).toBe('run'); |
| 50 | expect(beta?.lifecycleScripts).toBe('skip'); |
| 51 | expect(minimum.every(lane => lane.lifecycleScripts === 'skip')).toBe(true); |
| 52 | expect( |
| 53 | Object.fromEntries( |
| 54 | providers.map(provider => [provider.name, provider.advertisedMinimumCoreVersion]) |
| 55 | ) |
| 56 | ).toEqual({ |
| 57 | '@composio/anthropic': '0.10.0', |
| 58 | '@composio/claude-agent-sdk': '0.10.0', |
| 59 | '@composio/cloudflare': '0.10.0', |
| 60 | '@composio/google': '0.16.0', |
| 61 | '@composio/langchain': '0.10.0', |
| 62 | '@composio/llamaindex': '0.10.0', |
| 63 | '@composio/mastra': '0.10.0', |
| 64 | '@composio/openai': '0.10.0', |
| 65 | '@composio/openai-agents': '0.10.0', |
| 66 | '@composio/typesafe': '0.18.1', |
| 67 | '@composio/vercel': '0.10.0', |
| 68 | }); |
| 69 | }); |
| 70 | |
| 71 | it('selects all lanes by default and accepts focused runs', () => { |
| 72 | expect([...parseCliOptions([]).lanes]).toEqual(['current', 'minimum', 'beta']); |
| 73 | expect([...parseCliOptions(['--', '--lane', 'current', '--plan']).lanes]).toEqual(['current']); |
| 74 | expect(parseCliOptions(['--', '--lane', 'current', '--plan']).planOnly).toBe(true); |
| 75 | expect(() => parseCliOptions(['--lane', 'future'])).toThrow( |
| 76 | '--lane must be current, minimum, or beta' |
| 77 | ); |
| 78 | expect(() => parseCliOptions(['--unknown'])).toThrow('Unknown argument: --unknown'); |
| 79 | }); |
| 80 | }); |
| 81 | |
| 82 | describe('repackCoreTarball', () => { |
| 83 | async function withPackedManifest<T>( |
| 84 | manifest: unknown, |
| 85 | callback: (tarball: string, artifactDirectory: string) => Promise<T> |
| 86 | ): Promise<T> { |
| 87 | const root = await mkdtemp(path.join(tmpdir(), 'composio-repack-test-')); |
| 88 | try { |
| 89 | await mkdir(path.join(root, 'source/package'), { recursive: true }); |
| 90 | await writeFile(path.join(root, 'source/package/package.json'), JSON.stringify(manifest)); |
| 91 | const tarball = path.join(root, 'core.tgz'); |
| 92 | const packed = spawnSync('tar', [ |
| 93 | '-czf', |
| 94 | tarball, |
| 95 | '-C', |
| 96 | path.join(root, 'source'), |
| 97 | 'package', |
| 98 | ]); |
| 99 | if (packed.status !== 0) throw new Error(String(packed.stderr)); |
| 100 | return await callback(tarball, path.join(root, 'artifacts')); |
| 101 | } finally { |
| 102 | await rm(root, { recursive: true, force: true }); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | const options = (artifactDirectory: string) => ({ |
| 107 | version: '1.0.0-beta.0', |
| 108 | jsonSchemaTarball: '/artifacts/composio-json-schema-to-zod-0.1.0.tgz', |
| 109 | artifactDirectory, |
| 110 | }); |
| 111 | |
| 112 | it('re-versions core and routes its helper dependency through the packed tarball', async () => { |
| 113 | await withPackedManifest( |
| 114 | { |
| 115 | name: '@composio/core', |
| 116 | version: '0.18.0', |
| 117 | dependencies: { '@composio/json-schema-to-zod': 'workspace:*', zod: '^3.0.0' }, |
| 118 | peerDependencies: {}, |
| 119 | exports: { '.': './dist/index.mjs' }, |
| 120 | }, |
| 121 | async (tarball, artifactDirectory) => { |
| 122 | const repacked = await repackCoreTarball( |
| 123 | tarball, |
| 124 | '@composio/core', |
| 125 | options(artifactDirectory) |
| 126 | ); |
| 127 | expect(path.basename(repacked)).toBe('composio-core-1.0.0-beta.0.tgz'); |
| 128 | const extracted = spawnSync('tar', ['-xzf', repacked, '-O', 'package/package.json'], { |
| 129 | encoding: 'utf8', |
| 130 | }); |
| 131 | const manifest = JSON.parse(extracted.stdout); |
| 132 | expect(manifest.version).toBe('1.0.0-beta.0'); |
| 133 | expect(manifest.dependencies['@composio/json-schema-to-zod']).toBe( |
| 134 | 'file:/artifacts/composio-json-schema-to-zod-0.1.0.tgz' |
| 135 | ); |
| 136 | expect(manifest.dependencies.zod).toBe('^3.0.0'); |
| 137 | expect(manifest.exports).toEqual({ '.': './dist/index.mjs' }); |
| 138 | } |
| 139 | ); |
| 140 | }); |
| 141 | |
| 142 | it('rejects a packed core manifest that omits the helper dependency', async () => { |
| 143 | await withPackedManifest( |
| 144 | { name: '@composio/core', version: '0.18.0', dependencies: { zod: '^3.0.0' } }, |
| 145 | async (tarball, artifactDirectory) => { |
| 146 | await expect( |
| 147 | repackCoreTarball(tarball, '@composio/core', options(artifactDirectory)) |
| 148 | ).rejects.toThrow('must declare @composio/json-schema-to-zod as a dependency'); |
| 149 | } |
| 150 | ); |
| 151 | }); |
| 152 | |
| 153 | it('rejects a malformed packed core manifest', async () => { |
| 154 | await withPackedManifest( |
| 155 | { name: '@composio/core', dependencies: { '@composio/json-schema-to-zod': '*' } }, |
| 156 | async (tarball, artifactDirectory) => { |
| 157 | await expect( |
| 158 | repackCoreTarball(tarball, '@composio/core', options(artifactDirectory)) |
| 159 | ).rejects.toThrow('Invalid JSON in'); |
| 160 | } |
| 161 | ); |
| 162 | }); |
| 163 | }); |