mirror of
https://github.com/qwibitai/nanoclaw.git
synced 2026-06-12 18:11:51 +08:00
9486d56b01
- Move all v1 files (index, router, container-runner, db, ipc, types, logger, channels/registry, and all utilities) to src/v1/ as a fully self-contained archive with no shared dependencies - Rename v2 files to remove -v2 suffix (index-v2.ts → index.ts, etc.) - Update all imports across v2 source, tests, and setup files - Migrate shared utilities (config, env, container-runtime, mount-security, timezone, group-folder) from pino logger to v2 log module - Migrate setup/ files from logger to log with argument order swap - Container agent-runner: move v1 entry to v1/, rename v2 to index.ts - Update setup skill to offer all 13 v2 channels - Install all Chat SDK adapter packages - dist/index.js now runs v2; dist/v1/index.js runs v1 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
/**
|
|
* Setup CLI entry point.
|
|
* Usage: npx tsx setup/index.ts --step <name> [args...]
|
|
*/
|
|
import { log } from '../src/log.js';
|
|
import { emitStatus } from './status.js';
|
|
|
|
const STEPS: Record<
|
|
string,
|
|
() => Promise<{ run: (args: string[]) => Promise<void> }>
|
|
> = {
|
|
timezone: () => import('./timezone.js'),
|
|
environment: () => import('./environment.js'),
|
|
container: () => import('./container.js'),
|
|
groups: () => import('./groups.js'),
|
|
register: () => import('./register.js'),
|
|
mounts: () => import('./mounts.js'),
|
|
service: () => import('./service.js'),
|
|
verify: () => import('./verify.js'),
|
|
};
|
|
|
|
async function main(): Promise<void> {
|
|
const args = process.argv.slice(2);
|
|
const stepIdx = args.indexOf('--step');
|
|
|
|
if (stepIdx === -1 || !args[stepIdx + 1]) {
|
|
console.error(
|
|
`Usage: npx tsx setup/index.ts --step <${Object.keys(STEPS).join('|')}> [args...]`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
const stepName = args[stepIdx + 1];
|
|
const stepArgs = args.filter(
|
|
(a, i) => i !== stepIdx && i !== stepIdx + 1 && a !== '--',
|
|
);
|
|
|
|
const loader = STEPS[stepName];
|
|
if (!loader) {
|
|
console.error(`Unknown step: ${stepName}`);
|
|
console.error(`Available steps: ${Object.keys(STEPS).join(', ')}`);
|
|
process.exit(1);
|
|
}
|
|
|
|
try {
|
|
const mod = await loader();
|
|
await mod.run(stepArgs);
|
|
} catch (err) {
|
|
const message = err instanceof Error ? err.message : String(err);
|
|
log.error('Setup step failed', { err, step: stepName });
|
|
emitStatus(stepName.toUpperCase(), {
|
|
STATUS: 'failed',
|
|
ERROR: message,
|
|
});
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
main();
|