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, 04:45 UTC
| 1 | /** |
| 2 | * Published artifact names and the companion paths included in every archive. |
| 3 | * |
| 4 | * Deliberately free of Bun-only imports so the packaging rules stay unit-testable |
| 5 | * under Node. |
| 6 | */ |
| 7 | |
| 8 | import { Schema } from 'effect'; |
| 9 | import { |
| 10 | RELEASE_MANIFEST_SCHEMA_VERSION, |
| 11 | ReleaseManifest, |
| 12 | RUN_COMPANION_LEGACY_PLACEHOLDER_RELATIVE_PATHS, |
| 13 | } from '../src/services/run-companion-modules'; |
| 14 | |
| 15 | /** |
| 16 | * Every published platform: the Bun cross-compilation target and the artifact it produces. |
| 17 | */ |
| 18 | export const RELEASE_TARGETS = [ |
| 19 | { bunTarget: 'bun-darwin-arm64', artifact: 'composio-darwin-aarch64' }, |
| 20 | { bunTarget: 'bun-darwin-x64', artifact: 'composio-darwin-x64' }, |
| 21 | { bunTarget: 'bun-linux-x64', artifact: 'composio-linux-x64' }, |
| 22 | { bunTarget: 'bun-linux-arm64', artifact: 'composio-linux-aarch64' }, |
| 23 | { bunTarget: 'bun-windows-x64', artifact: 'composio-windows-x64' }, |
| 24 | ] as const; |
| 25 | |
| 26 | export type ReleaseTarget = (typeof RELEASE_TARGETS)[number]; |
| 27 | |
| 28 | const isWindowsArtifact = (artifact: string): boolean => artifact.startsWith('composio-windows-'); |
| 29 | |
| 30 | /** File name of the compiled binary in `dist/binaries/`. */ |
| 31 | export const compiledBinaryFileName = (artifact: string): string => |
| 32 | isWindowsArtifact(artifact) ? `${artifact}.exe` : artifact; |
| 33 | |
| 34 | /** Name of the executable inside the published archive. */ |
| 35 | export const archiveExecutableName = (artifact: string): string => |
| 36 | isWindowsArtifact(artifact) ? 'composio.exe' : 'composio'; |
| 37 | |
| 38 | export type ArchiveCompanionEntryKind = 'copy' | 'placeholder'; |
| 39 | |
| 40 | export type ArchiveCompanionEntry = { |
| 41 | readonly relativePath: string; |
| 42 | readonly kind: ArchiveCompanionEntryKind; |
| 43 | }; |
| 44 | |
| 45 | /** |
| 46 | * Decide how each companion path enters an archive. |
| 47 | * |
| 48 | * The live companions are copied. The legacy paths are written as empty files: |
| 49 | * the sub-agent helper they served is gone, but every stable CLI from 0.2.12 to |
| 50 | * 0.4.2 verifies a downloaded upgrade package against those paths and refuses to |
| 51 | * install one that is missing any of them, so omitting them breaks |
| 52 | * `composio upgrade` for every client already in the field. That check looks at |
| 53 | * existence only, and an empty wrapper imports nothing, so a placeholder |
| 54 | * satisfies it at zero bytes and is never read. |
| 55 | * |
| 56 | * Once no supported client performs that check, placeholders can become plain |
| 57 | * omissions. |
| 58 | */ |
| 59 | export const archiveCompanionEntries = ( |
| 60 | liveRelativePaths: ReadonlyArray<string> |
| 61 | ): ReadonlyArray<ArchiveCompanionEntry> => [ |
| 62 | ...liveRelativePaths.map(relativePath => ({ relativePath, kind: 'copy' as const })), |
| 63 | ...RUN_COMPANION_LEGACY_PLACEHOLDER_RELATIVE_PATHS.map(relativePath => ({ |
| 64 | relativePath, |
| 65 | kind: 'placeholder' as const, |
| 66 | })), |
| 67 | ]; |
| 68 | |
| 69 | /** |
| 70 | * The earliest CLI version a manifest-aware client may upgrade from to an archive |
| 71 | * built today. It starts at the lowest semver version, so no build is refused, |
| 72 | * including prerelease builds such as the `0.0.0-beta.0` CI fixtures. |
| 73 | * |
| 74 | * Raise it when an archive drops a path that some client at or above it still |
| 75 | * requires. Clients that predate manifests never read it, so it does not make |
| 76 | * them accept a smaller archive: the legacy placeholders stay while it is at or |
| 77 | * below 0.4.2, the last release that requires them. |
| 78 | */ |
| 79 | export const MINIMUM_UPGRADE_FROM = '0.0.0-0'; |
| 80 | |
| 81 | /** |
| 82 | * The `release-manifest.json` every archive carries: the live companions, never |
| 83 | * the legacy placeholders, which no current client needs. Decoded on the way out |
| 84 | * so packaging cannot write a manifest the CLI would refuse. |
| 85 | */ |
| 86 | export const buildReleaseManifest = (liveRelativePaths: ReadonlyArray<string>): ReleaseManifest => |
| 87 | Schema.decodeUnknownSync(ReleaseManifest)({ |
| 88 | schemaVersion: RELEASE_MANIFEST_SCHEMA_VERSION, |
| 89 | minimumUpgradeFrom: MINIMUM_UPGRADE_FROM, |
| 90 | companions: [...liveRelativePaths].sort(), |
| 91 | }); |
| 92 | |
| 93 | export const serializeReleaseManifest = (manifest: ReleaseManifest): string => |
| 94 | `${JSON.stringify(manifest, null, 2)}\n`; |