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
ts 52 lines 1.54 KB
Raw
1 /**
2 * Refresh only the version field in the committed toolkit catalog.
3 *
4 * This is the narrow, reproducible repair path for version-only incidents. The
5 * full `generate-toolkits.ts` script remains the owner of complete catalog
6 * regeneration.
7 *
8 * Run from docs/: bun run generate:toolkit-versions
9 */
10
11 import { readFile, writeFile } from 'fs/promises';
12 import { join } from 'path';
13 import {
14 applyToolkitVersions,
15 fetchProductionToolkitVersions,
16 } from './toolkit-versions';
17
18 interface Toolkit {
19 slug: string;
20 version: string | null;
21 [key: string]: unknown;
22 }
23
24 const TOOLKITS_PATH = join(process.cwd(), 'public/data/toolkits.json');
25
26 export async function refreshToolkitVersions(apiKey: string): Promise<void> {
27 const raw = await readFile(TOOLKITS_PATH, 'utf-8');
28 const toolkits = JSON.parse(raw) as Toolkit[];
29
30 if (!Array.isArray(toolkits)) {
31 throw new Error('Expected public/data/toolkits.json to contain an array');
32 }
33
34 const versionMap = await fetchProductionToolkitVersions(apiKey);
35 const { matched, missing } = applyToolkitVersions(toolkits, versionMap);
36
37 await writeFile(TOOLKITS_PATH, JSON.stringify(toolkits, null, 2));
38 console.log(`Updated ${matched} toolkit versions from production; ${missing} set to null`);
39 }
40
41 if (import.meta.main) {
42 const apiKey = process.env.COMPOSIO_API_KEY;
43 if (!apiKey) {
44 console.error('Error: COMPOSIO_API_KEY environment variable is required');
45 process.exit(1);
46 }
47
48 refreshToolkitVersions(apiKey).catch((error) => {
49 console.error('Fatal error:', error);
50 process.exit(1);
51 });
52 }