#!/usr/bin/env bun import type { Command } from '../src/index.ts'; import { run } from '../src/index.ts'; function printUsage(): void { console.error(`Usage: bun scripts/run.ts [--api-base=] [args...] [--dry-run] Commands: run Config: ~/.openclaw/.env (CLIENT_KEY, API_BASE) `); } async function main(): Promise { const positionals: string[] = []; let dryRun = false; for (const arg of process.argv.slice(2)) { if (arg === '--dry-run') { dryRun = true; } else if (arg.startsWith('--api-base=')) { process.env.API_BASE = arg.slice('--api-base='.length).trim(); } else if (arg === '-h' || arg === '--help') { printUsage(); process.exit(0); } else { positionals.push(arg); } } if (positionals.length < 1) { printUsage(); process.exit(1); } const result = await run(positionals[0] as Command, positionals.slice(1), dryRun); console.log(JSON.stringify(result, null, 2)); } main().catch((err) => { console.error(JSON.stringify({ status: 'failed', error: err instanceof Error ? err.message : String(err) }, null, 2)); process.exit(1); });