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 651 lines 22.3 KB
Raw
1 #!/usr/bin/env node
2 import { spawnSync } from 'node:child_process';
3 import { access, mkdir, mkdtemp, readFile, readdir, rm, writeFile } from 'node:fs/promises';
4 import { tmpdir } from 'node:os';
5 import path from 'node:path';
6 import { fileURLToPath, pathToFileURL } from 'node:url';
7 import semver from 'semver';
8 import { z } from 'zod';
9
10 const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
11 const providersDir = path.join(repoRoot, 'ts/packages/providers');
12 const coreDir = path.join(repoRoot, 'ts/packages/core');
13 const jsonSchemaToZodDir = path.join(repoRoot, 'ts/packages/json-schema-to-zod');
14 const npmBin = process.platform === 'win32' ? 'npm.cmd' : 'npm';
15 const pnpmBin = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm';
16
17 // Published 0.x floors remain unchanged until the planned breaking release. These verified
18 // floors keep the artifact gate green only for combinations the current providers can load.
19 const PROVIDER_CONTRACTS: Record<
20 string,
21 { agentic: boolean; exportName: string; verifiedMinimumCore: string }
22 > = {
23 '@composio/anthropic': {
24 agentic: false,
25 exportName: 'AnthropicProvider',
26 verifiedMinimumCore: '0.14.0',
27 },
28 '@composio/claude-agent-sdk': {
29 agentic: true,
30 exportName: 'ClaudeAgentSDKProvider',
31 verifiedMinimumCore: '0.11.0',
32 },
33 '@composio/cloudflare': {
34 agentic: false,
35 exportName: 'CloudflareProvider',
36 verifiedMinimumCore: '0.14.0',
37 },
38 '@composio/google': {
39 agentic: false,
40 exportName: 'GoogleProvider',
41 verifiedMinimumCore: '0.16.0',
42 },
43 '@composio/langchain': {
44 agentic: true,
45 exportName: 'LangchainProvider',
46 verifiedMinimumCore: '0.11.0',
47 },
48 '@composio/llamaindex': {
49 agentic: true,
50 exportName: 'LlamaindexProvider',
51 verifiedMinimumCore: '0.14.0',
52 },
53 '@composio/mastra': {
54 agentic: true,
55 exportName: 'MastraProvider',
56 verifiedMinimumCore: '0.18.0',
57 },
58 '@composio/openai': {
59 agentic: false,
60 exportName: 'OpenAIProvider',
61 verifiedMinimumCore: '0.18.0',
62 },
63 '@composio/openai-agents': {
64 agentic: true,
65 exportName: 'OpenAIAgentsProvider',
66 verifiedMinimumCore: '0.18.0',
67 },
68 '@composio/typesafe': {
69 agentic: false,
70 exportName: 'TypesafeProvider',
71 verifiedMinimumCore: '0.18.1',
72 },
73 '@composio/vercel': {
74 agentic: true,
75 exportName: 'VercelProvider',
76 verifiedMinimumCore: '0.18.0',
77 },
78 };
79
80 const StringRecordSchema = z.record(z.string(), z.string());
81 const PackageManifestSchema = z
82 .object({
83 name: z.string().min(1),
84 version: z.string().min(1),
85 peerDependencies: StringRecordSchema.default({}),
86 dependencies: StringRecordSchema.default({}),
87 })
88 .passthrough();
89 const JSON_SCHEMA_TO_ZOD = '@composio/json-schema-to-zod';
90 const InstalledPackageManifestSchema = z.object({ version: z.string().min(1) }).passthrough();
91
92 export type ProviderCompatibilityCase = {
93 directory: string;
94 name: string;
95 version: string;
96 advertisedMinimumCoreVersion: string;
97 verifiedMinimumCoreVersion: string;
98 agentic: boolean;
99 providerExportName: string;
100 externalPeers: Record<string, string>;
101 };
102
103 export type CompatibilityLane = {
104 id: string;
105 core:
106 | { kind: 'workspace' }
107 | { kind: 'workspace-prerelease'; version: string }
108 | { kind: 'registry'; specifier: string };
109 providerNames: string[];
110 // The release-blocking workspace lane installs exactly as a consumer does so install-time
111 // lifecycle failures cannot pass the gate; the other lanes skip that cost.
112 lifecycleScripts: 'run' | 'skip';
113 };
114
115 export type CliOptions = {
116 lanes: Set<'current' | 'minimum' | 'beta'>;
117 planOnly: boolean;
118 };
119
120 async function readJsonFile<T>(filePath: string, schema: z.ZodType<T>): Promise<T> {
121 const raw: unknown = JSON.parse(await readFile(filePath, 'utf8'));
122 const result = schema.safeParse(raw);
123 if (!result.success) {
124 throw new Error(
125 `Invalid JSON in ${path.relative(repoRoot, filePath)}: ${result.error.message}`
126 );
127 }
128 return result.data;
129 }
130
131 function installedPeerManifestPath(providerDirectory: string, peerName: string): string {
132 return path.join(providerDirectory, 'node_modules', ...peerName.split('/'), 'package.json');
133 }
134
135 async function readInstalledPeerVersion(
136 providerDirectory: string,
137 peerName: string
138 ): Promise<string> {
139 const manifestPath = installedPeerManifestPath(providerDirectory, peerName);
140 try {
141 const manifest = await readJsonFile(manifestPath, InstalledPackageManifestSchema);
142 return manifest.version;
143 } catch (error) {
144 throw new Error(
145 `Could not resolve installed peer ${peerName} for ${path.relative(repoRoot, providerDirectory)}. Run pnpm install first.`,
146 { cause: error }
147 );
148 }
149 }
150
151 export async function discoverProviderCases(): Promise<ProviderCompatibilityCase[]> {
152 const entries = await readdir(providersDir, { withFileTypes: true });
153 const providers: ProviderCompatibilityCase[] = [];
154
155 for (const entry of entries) {
156 if (!entry.isDirectory()) continue;
157
158 const directory = path.join(providersDir, entry.name);
159 const manifestPath = path.join(directory, 'package.json');
160 try {
161 await access(manifestPath);
162 } catch {
163 continue;
164 }
165
166 const manifest = await readJsonFile(manifestPath, PackageManifestSchema);
167 const coreRange = manifest.peerDependencies['@composio/core'];
168 if (!coreRange) {
169 throw new Error(`${manifest.name} must declare @composio/core as a peer dependency`);
170 }
171
172 const minimumCore = semver.minVersion(coreRange);
173 if (!minimumCore) {
174 throw new Error(`${manifest.name} has an invalid @composio/core peer range: ${coreRange}`);
175 }
176 const contract = PROVIDER_CONTRACTS[manifest.name];
177 if (!contract) {
178 throw new Error(`${manifest.name} must define a packed consumer contract`);
179 }
180
181 const externalPeers: Record<string, string> = {};
182 for (const peerName of Object.keys(manifest.peerDependencies).sort()) {
183 if (peerName === '@composio/core') continue;
184 externalPeers[peerName] = await readInstalledPeerVersion(directory, peerName);
185 }
186
187 providers.push({
188 directory,
189 name: manifest.name,
190 version: manifest.version,
191 advertisedMinimumCoreVersion: minimumCore.version,
192 verifiedMinimumCoreVersion: contract.verifiedMinimumCore,
193 agentic: contract.agentic,
194 providerExportName: contract.exportName,
195 externalPeers,
196 });
197 }
198
199 if (providers.length === 0) {
200 throw new Error('No provider packages were found');
201 }
202
203 return providers.sort((left, right) => left.name.localeCompare(right.name));
204 }
205
206 export function buildCompatibilityPlan(
207 providers: ProviderCompatibilityCase[],
208 prereleaseVersion = process.env.COMPOSIO_CORE_PRERELEASE_VERSION || '1.0.0-beta.0'
209 ): CompatibilityLane[] {
210 const providerNames = providers.map(provider => provider.name);
211 const lanes: CompatibilityLane[] = [
212 {
213 id: 'workspace-current',
214 core: { kind: 'workspace' },
215 providerNames,
216 lifecycleScripts: 'run',
217 },
218 ];
219
220 for (const provider of providers) {
221 lanes.push({
222 id: `verified-minimum-core-${provider.verifiedMinimumCoreVersion}-${provider.name.replace('@', '').replace('/', '-')}`,
223 core: { kind: 'registry', specifier: provider.verifiedMinimumCoreVersion },
224 providerNames: [provider.name],
225 lifecycleScripts: 'skip',
226 });
227 }
228
229 lanes.push({
230 id: 'workspace-major-prerelease',
231 core: { kind: 'workspace-prerelease', version: prereleaseVersion },
232 providerNames,
233 lifecycleScripts: 'skip',
234 });
235
236 return lanes;
237 }
238
239 export function parseCliOptions(args: string[]): CliOptions {
240 const lanes = new Set<'current' | 'minimum' | 'beta'>();
241 let planOnly = false;
242
243 for (let index = 0; index < args.length; index += 1) {
244 const argument = args[index];
245 if (argument === '--') {
246 continue;
247 }
248 if (argument === '--plan') {
249 planOnly = true;
250 continue;
251 }
252 if (argument === '--lane') {
253 const lane = args[index + 1];
254 if (lane !== 'current' && lane !== 'minimum' && lane !== 'beta') {
255 throw new Error('--lane must be current, minimum, or beta');
256 }
257 lanes.add(lane);
258 index += 1;
259 continue;
260 }
261 throw new Error(`Unknown argument: ${argument}`);
262 }
263
264 if (lanes.size === 0) {
265 lanes.add('current');
266 lanes.add('minimum');
267 lanes.add('beta');
268 }
269
270 return { lanes, planOnly };
271 }
272
273 function laneCategory(lane: CompatibilityLane): 'current' | 'minimum' | 'beta' {
274 if (lane.id === 'workspace-current') return 'current';
275 if (lane.id === 'workspace-major-prerelease') return 'beta';
276 return 'minimum';
277 }
278
279 function run(command: string, args: string[], cwd = repoRoot): string {
280 const result = spawnSync(command, args, {
281 cwd,
282 encoding: 'utf8',
283 env: {
284 ...process.env,
285 FORCE_COLOR: '0',
286 NO_COLOR: '1',
287 npm_config_update_notifier: 'false',
288 },
289 });
290
291 if (result.status !== 0) {
292 const output = [result.stdout, result.stderr].filter(Boolean).join('\n').trim();
293 const lines = output.split('\n');
294 const relevantOutput =
295 lines.length > 120
296 ? [
297 ...lines.slice(0, 40),
298 `... ${lines.length - 120} lines omitted ...`,
299 ...lines.slice(-80),
300 ].join('\n')
301 : output;
302 throw new Error(
303 [`Command failed: ${command} ${args.join(' ')}`, relevantOutput].filter(Boolean).join('\n')
304 );
305 }
306
307 return result.stdout.trim();
308 }
309
310 function packageTarballName(packageName: string, version: string): string {
311 return `${packageName.replace(/^@/, '').replaceAll('/', '-')}-${version}.tgz`;
312 }
313
314 async function packPackage(
315 packageDirectory: string,
316 packageName: string,
317 version: string,
318 artifactDirectory: string
319 ): Promise<string> {
320 run(pnpmBin, [
321 '--dir',
322 packageDirectory,
323 'pack',
324 '--pack-destination',
325 artifactDirectory,
326 '--silent',
327 ]);
328 const tarballPath = path.join(artifactDirectory, packageTarballName(packageName, version));
329 await access(tarballPath);
330
331 const contents = run('tar', ['-tzf', tarballPath]);
332 for (const requiredPath of [
333 'package/package.json',
334 'package/dist/index.mjs',
335 'package/dist/index.d.mts',
336 ]) {
337 if (!contents.split('\n').includes(requiredPath)) {
338 throw new Error(`${packageName} tarball is missing ${requiredPath}`);
339 }
340 }
341
342 return tarballPath;
343 }
344
345 async function packWorkspaceArtifacts(
346 providers: ProviderCompatibilityCase[],
347 artifactDirectory: string,
348 prereleaseVersion: string
349 ): Promise<Map<string, string>> {
350 const coreManifest = await readJsonFile(
351 path.join(coreDir, 'package.json'),
352 PackageManifestSchema
353 );
354 const jsonSchemaManifest = await readJsonFile(
355 path.join(jsonSchemaToZodDir, 'package.json'),
356 PackageManifestSchema
357 );
358 const tarballs = new Map<string, string>();
359
360 const jsonSchemaTarball = await packPackage(
361 jsonSchemaToZodDir,
362 jsonSchemaManifest.name,
363 jsonSchemaManifest.version,
364 artifactDirectory
365 );
366 const packedCore = await packPackage(
367 coreDir,
368 coreManifest.name,
369 coreManifest.version,
370 artifactDirectory
371 );
372 tarballs.set(
373 coreManifest.name,
374 await repackCoreTarball(packedCore, coreManifest.name, {
375 version: coreManifest.version,
376 jsonSchemaTarball,
377 artifactDirectory: path.join(artifactDirectory, 'core-workspace'),
378 })
379 );
380 tarballs.set(
381 `${coreManifest.name}@prerelease`,
382 await repackCoreTarball(packedCore, coreManifest.name, {
383 version: prereleaseVersion,
384 jsonSchemaTarball,
385 artifactDirectory: path.join(artifactDirectory, 'core-prerelease'),
386 })
387 );
388
389 for (const provider of providers) {
390 const packedProvider = await packPackage(
391 provider.directory,
392 provider.name,
393 provider.version,
394 artifactDirectory
395 );
396 const providerManifest = await readJsonFile(
397 path.join(provider.directory, 'package.json'),
398 PackageManifestSchema
399 );
400 // A provider that imports the helper directly needs the workspace build too: the
401 // registry copy of the same version may predate the entry point it imports.
402 tarballs.set(
403 provider.name,
404 providerManifest.dependencies[JSON_SCHEMA_TO_ZOD]
405 ? await repackCoreTarball(packedProvider, provider.name, {
406 version: provider.version,
407 jsonSchemaTarball,
408 artifactDirectory: path.join(
409 artifactDirectory,
410 `provider-${path.basename(provider.directory)}`
411 ),
412 })
413 : packedProvider
414 );
415 }
416
417 return tarballs;
418 }
419
420 export async function repackCoreTarball(
421 tarballPath: string,
422 packageName: string,
423 options: { version: string; jsonSchemaTarball: string; artifactDirectory: string }
424 ): Promise<string> {
425 // Consumers install core and providers only, so the unpublished workspace helper must reach
426 // them through core's own dependency declaration. A release gate also cannot depend on a
427 // prerelease that has not been published yet, so the same repack re-versions the exact
428 // workspace tarball for the prerelease peer lane.
429 const stagingDirectory = path.join(options.artifactDirectory, 'staging');
430 await mkdir(stagingDirectory, { recursive: true });
431 run('tar', ['-xzf', tarballPath, '-C', stagingDirectory]);
432
433 const manifestPath = path.join(stagingDirectory, 'package/package.json');
434 const manifest = await readJsonFile(manifestPath, PackageManifestSchema);
435 if (!manifest.dependencies[JSON_SCHEMA_TO_ZOD]) {
436 throw new Error(
437 `${packageName} packed manifest must declare ${JSON_SCHEMA_TO_ZOD} as a dependency`
438 );
439 }
440 manifest.version = options.version;
441 manifest.dependencies[JSON_SCHEMA_TO_ZOD] = `file:${options.jsonSchemaTarball}`;
442 await writeFile(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
443
444 const repackedTarball = path.join(
445 options.artifactDirectory,
446 packageTarballName(packageName, options.version)
447 );
448 run('tar', ['-czf', repackedTarball, '-C', stagingDirectory, 'package']);
449 return repackedTarball;
450 }
451
452 function mergeExternalPeers(providers: ProviderCompatibilityCase[]): Record<string, string> {
453 const peers: Record<string, string> = {};
454 for (const provider of providers) {
455 for (const [peerName, version] of Object.entries(provider.externalPeers)) {
456 const existingVersion = peers[peerName];
457 if (existingVersion && existingVersion !== version) {
458 throw new Error(
459 `${peerName} resolves to both ${existingVersion} and ${version} across provider fixtures`
460 );
461 }
462 peers[peerName] = version;
463 }
464 }
465 return peers;
466 }
467
468 async function writeConsumerFixture(
469 fixtureDirectory: string,
470 lane: CompatibilityLane,
471 providers: ProviderCompatibilityCase[],
472 tarballs: Map<string, string>
473 ): Promise<void> {
474 const dependencies: Record<string, string> = {
475 ...mergeExternalPeers(providers),
476 typescript: (
477 await readJsonFile(
478 path.join(repoRoot, 'node_modules/typescript/package.json'),
479 InstalledPackageManifestSchema
480 )
481 ).version,
482 };
483
484 for (const provider of providers) {
485 const tarball = tarballs.get(provider.name);
486 if (!tarball) throw new Error(`Missing packed artifact for ${provider.name}`);
487 dependencies[provider.name] = `file:${tarball}`;
488 }
489
490 if (lane.core.kind !== 'registry') {
491 const coreTarball = tarballs.get(
492 lane.core.kind === 'workspace' ? '@composio/core' : '@composio/core@prerelease'
493 );
494 if (!coreTarball) {
495 throw new Error('Missing packed core workspace artifact');
496 }
497 dependencies['@composio/core'] = `file:${coreTarball}`;
498 } else {
499 dependencies['@composio/core'] = lane.core.specifier;
500 }
501
502 const imports = providers.map((provider, index) => ({
503 identifier: `provider${index}`,
504 name: provider.name,
505 exportName: provider.providerExportName,
506 agentic: provider.agentic,
507 }));
508
509 await writeFile(
510 path.join(fixtureDirectory, 'package.json'),
511 `${JSON.stringify({ private: true, type: 'module', dependencies }, null, 2)}\n`
512 );
513 await writeFile(
514 path.join(fixtureDirectory, 'index.ts'),
515 `import type { ExecuteToolFn, Tool } from '@composio/core';\n${imports
516 .map(item => `import { ${item.exportName} as ${item.identifier} } from '${item.name}';`)
517 .join(
518 '\n'
519 )}\nconst tool: Tool = { slug: 'COMPATIBILITY_CHECK', name: 'Compatibility check', description: 'Checks packed provider conversion', inputParameters: { type: 'object', properties: { value: { type: 'string' } }, required: ['value'] }, toolkit: { slug: 'compatibility', name: 'Compatibility' }, tags: [] };\nconst executeTool: ExecuteToolFn = async () => ({ data: {}, error: null, successful: true });\n${imports
520 .map(
521 item =>
522 `const ${item.identifier}Instance = new ${item.identifier}();\nconst ${item.identifier}Tool = ${item.identifier}Instance.wrapTool(tool${item.agentic ? ', executeTool' : ''});\nvoid ${item.identifier}Tool;`
523 )
524 .join('\n')}\n`
525 );
526 await writeFile(
527 path.join(fixtureDirectory, 'index.mjs'),
528 `const providerContracts = ${JSON.stringify(imports.map(item => [item.name, item.exportName, item.agentic]))};\nconst tool = { slug: 'COMPATIBILITY_CHECK', name: 'Compatibility check', description: 'Checks packed provider conversion', inputParameters: { type: 'object', properties: { value: { type: 'string' } }, required: ['value'] }, toolkit: { slug: 'compatibility', name: 'Compatibility' }, tags: [] };\nconst executeTool = async () => ({ data: {}, error: null, successful: true });\nfor (const [packageName, exportName, agentic] of providerContracts) {\n const packageExports = await import(packageName);\n const Provider = packageExports[exportName];\n if (typeof Provider !== 'function') throw new Error(\`\${packageName} does not export \${exportName}\`);\n const provider = new Provider();\n const wrappedTool = provider.wrapTool(tool, ...(agentic ? [executeTool] : []));\n if ((typeof wrappedTool !== 'object' || wrappedTool === null) && typeof wrappedTool !== 'function') throw new Error(\`\${packageName} did not wrap a minimal tool\`);\n}\nconst core = JSON.parse(await (await import('node:fs/promises')).readFile(new URL('./node_modules/@composio/core/package.json', import.meta.url), 'utf8'));\nconsole.log(\`${lane.id}: wrapped a tool with \${providerContracts.length} providers and @composio/core@\${core.version}\`);\n`
529 );
530 await writeFile(
531 path.join(fixtureDirectory, 'tsconfig.json'),
532 `${JSON.stringify(
533 {
534 compilerOptions: {
535 strict: true,
536 noEmit: true,
537 // This aggregate fixture owns Composio's package boundary. Provider-specific
538 // strict fixtures own upstream declaration compatibility so unrelated framework
539 // internals cannot make every provider's packaging result unreadable.
540 skipLibCheck: true,
541 target: 'ES2022',
542 module: 'NodeNext',
543 moduleResolution: 'NodeNext',
544 },
545 include: ['index.ts'],
546 },
547 null,
548 2
549 )}\n`
550 );
551 }
552
553 async function runLane(
554 lane: CompatibilityLane,
555 allProviders: ProviderCompatibilityCase[],
556 tarballs: Map<string, string>,
557 runDirectory: string
558 ): Promise<void> {
559 const providers = lane.providerNames.map(name => {
560 const provider = allProviders.find(candidate => candidate.name === name);
561 if (!provider) throw new Error(`Unknown provider in compatibility plan: ${name}`);
562 return provider;
563 });
564 const fixtureDirectory = path.join(runDirectory, lane.id);
565 await mkdir(fixtureDirectory, { recursive: true });
566 await writeConsumerFixture(fixtureDirectory, lane, providers, tarballs);
567
568 const installArgs = [
569 'install',
570 ...(lane.lifecycleScripts === 'skip' ? ['--ignore-scripts'] : []),
571 '--package-lock=false',
572 '--no-audit',
573 '--no-fund',
574 ];
575 console.log(
576 `${lane.id}: installing ${providers.length} packed provider package(s), lifecycle scripts: ${lane.lifecycleScripts}`
577 );
578 run(npmBin, installArgs, fixtureDirectory);
579 run(path.join(fixtureDirectory, 'node_modules/.bin/tsc'), ['--noEmit'], fixtureDirectory);
580 const result = run(process.execPath, ['index.mjs'], fixtureDirectory);
581 console.log(result);
582 }
583
584 async function main(): Promise<void> {
585 const options = parseCliOptions(process.argv.slice(2));
586 const providers = await discoverProviderCases();
587 const plan = buildCompatibilityPlan(providers).filter(lane =>
588 options.lanes.has(laneCategory(lane))
589 );
590 const prereleaseLane = plan.find(lane => lane.core.kind === 'workspace-prerelease');
591 const prereleaseVersion =
592 prereleaseLane?.core.kind === 'workspace-prerelease'
593 ? prereleaseLane.core.version
594 : process.env.COMPOSIO_CORE_PRERELEASE_VERSION || '1.0.0-beta.0';
595
596 if (options.planOnly) {
597 console.log(JSON.stringify({ providers, lanes: plan }, null, 2));
598 return;
599 }
600
601 const deferredFloorCorrections = providers.filter(
602 provider => provider.advertisedMinimumCoreVersion !== provider.verifiedMinimumCoreVersion
603 );
604 if (deferredFloorCorrections.length > 0) {
605 console.log(
606 `Using verified core floors without changing published 0.x ranges: ${deferredFloorCorrections
607 .map(
608 provider =>
609 `${provider.name} ${provider.advertisedMinimumCoreVersion}→${provider.verifiedMinimumCoreVersion}`
610 )
611 .join(', ')}`
612 );
613 }
614
615 const runDirectory = await mkdtemp(path.join(tmpdir(), 'composio-provider-compatibility-'));
616 try {
617 const artifactDirectory = path.join(runDirectory, 'artifacts');
618 await mkdir(artifactDirectory, { recursive: true });
619 const tarballs = await packWorkspaceArtifacts(providers, artifactDirectory, prereleaseVersion);
620
621 console.log(
622 `Checking ${providers.length} providers across ${plan.length} compatibility lanes...`
623 );
624 const failures: string[] = [];
625 for (const lane of plan) {
626 try {
627 await runLane(lane, providers, tarballs, runDirectory);
628 } catch (error) {
629 const message = error instanceof Error ? error.message : String(error);
630 console.error(`${lane.id}: failed\n${message}`);
631 failures.push(lane.id);
632 }
633 }
634 if (failures.length > 0) {
635 throw new Error(
636 `Provider compatibility failed in ${failures.length} lane(s): ${failures.join(', ')}`
637 );
638 }
639 console.log('Packed provider compatibility checks passed.');
640 } finally {
641 await rm(runDirectory, { recursive: true, force: true });
642 }
643 }
644
645 const entrypoint = process.argv[1] ? pathToFileURL(path.resolve(process.argv[1])).href : '';
646 if (import.meta.url === entrypoint) {
647 main().catch(error => {
648 console.error(error instanceof Error ? error.message : String(error));
649 process.exitCode = 1;
650 });
651 }