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 | #!/usr/bin/env bun |
| 2 | |
| 3 | /** |
| 4 | * Generate `checksums.txt` from all `.zip` files in `dist/binaries/`. |
| 5 | * |
| 6 | * Usage: `bun scripts/generate-checksums.ts` |
| 7 | * |
| 8 | * Output format (sha256sum-compatible): |
| 9 | * <sha256hex> composio-darwin-aarch64.zip |
| 10 | * <sha256hex> composio-darwin-x64.zip |
| 11 | * <sha256hex> composio-linux-x64.zip |
| 12 | * <sha256hex> composio-linux-aarch64.zip |
| 13 | * |
| 14 | * Output: `dist/binaries/checksums.txt` |
| 15 | */ |
| 16 | |
| 17 | import process from 'node:process'; |
| 18 | import { Config, ConfigProvider, Console, Effect, Logger, Layer, References } from 'effect'; |
| 19 | import * as BunServices from '@effect/platform-bun/BunServices'; |
| 20 | import * as BunRuntime from '@effect/platform-bun/BunRuntime'; |
| 21 | import { teardown } from './_teardown'; |
| 22 | import { readdir, readFile, writeFile } from 'node:fs/promises'; |
| 23 | import path from 'node:path'; |
| 24 | |
| 25 | const BINARIES_DIR = './dist/binaries'; |
| 26 | |
| 27 | export function generateChecksums() { |
| 28 | return Effect.gen(function* () { |
| 29 | const entries = yield* Effect.tryPromise(() => readdir(BINARIES_DIR)); |
| 30 | const zipFiles = entries.filter(entry => entry.endsWith('.zip')).sort(); |
| 31 | |
| 32 | if (zipFiles.length === 0) { |
| 33 | yield* Console.error( |
| 34 | 'No .zip files found in dist/binaries/. Run build:binary:package first.' |
| 35 | ); |
| 36 | process.exitCode = 1; |
| 37 | return; |
| 38 | } |
| 39 | |
| 40 | yield* Console.log(`Generating checksums for ${zipFiles.length} archives...`); |
| 41 | |
| 42 | const lines: string[] = []; |
| 43 | |
| 44 | for (const zipFile of zipFiles) { |
| 45 | const filePath = path.join(BINARIES_DIR, zipFile); |
| 46 | const data = yield* Effect.tryPromise(() => readFile(filePath)); |
| 47 | const hashBuffer = yield* Effect.tryPromise(() => crypto.subtle.digest('SHA-256', data)); |
| 48 | const hash = Array.from(new Uint8Array(hashBuffer)) |
| 49 | .map(b => b.toString(16).padStart(2, '0')) |
| 50 | .join(''); |
| 51 | lines.push(`${hash} ${zipFile}`); |
| 52 | yield* Console.log(` ${hash} ${zipFile}`); |
| 53 | } |
| 54 | |
| 55 | const checksumsPath = path.join(BINARIES_DIR, 'checksums.txt'); |
| 56 | yield* Effect.tryPromise(() => writeFile(checksumsPath, lines.join('\n') + '\n')); |
| 57 | |
| 58 | yield* Console.log(`\nWritten: ${checksumsPath}`); |
| 59 | }); |
| 60 | } |
| 61 | |
| 62 | const ConfigLive = Effect.gen(function* () { |
| 63 | const logLevel = yield* Config.LogLevel('COMPOSIO_LOG_LEVEL').pipe(Config.withDefault('Info')); |
| 64 | |
| 65 | return Layer.succeed(References.MinimumLogLevel, logLevel); |
| 66 | }).pipe(Layer.unwrap, Layer.merge(ConfigProvider.layer(ConfigProvider.fromEnv()))); |
| 67 | |
| 68 | if (require.main === module) { |
| 69 | generateChecksums().pipe( |
| 70 | Effect.provide(ConfigLive), |
| 71 | Effect.provide(Logger.layer([Logger.consolePretty()])), |
| 72 | Effect.provide(BunServices.layer), |
| 73 | Effect.scoped, |
| 74 | Effect.map(() => ({ message: 'Process completed successfully.' })), |
| 75 | BunRuntime.runMain({ |
| 76 | teardown, |
| 77 | }) |
| 78 | ); |
| 79 | } |