| 471 | // ── Command Registration ───────────────────────────────── |
| 472 | |
| 473 | export function registerBotCommand(program: Command) { |
| 474 | const bot = program.command('bot').description('Manage bot integrations'); |
| 475 | |
| 476 | // Register message subcommand group |
| 477 | registerBotMessageCommands(bot); |
| 478 | |
| 479 | // Register messengers subcommand group (System Bot installations + account links) |
| 480 | registerBotMessengersCommands(bot); |
| 481 | |
| 482 | // ── platforms ─────────────────────────────────────────── |
| 483 | |
| 484 | bot |
| 485 | .command('platforms') |
| 486 | .description('List supported platforms and their required credentials') |
| 487 | .option('--json', 'Output JSON') |
| 488 | .action(async (options: { json?: boolean }) => { |
| 489 | const client = await getTrpcClient(); |
| 490 | const platforms = await client.agentBotProvider.listPlatforms.query(); |
| 491 | |
| 492 | if (options.json) { |
| 493 | outputJson(platforms); |
| 494 | return; |
| 495 | } |
| 496 | |
| 497 | console.log(pc.bold('Supported platforms:\n')); |
| 498 | |
| 499 | for (const p of platforms as any[]) { |
| 500 | console.log(` ${pc.bold(pc.cyan(p.id))}`); |
| 501 | if (p.name) console.log(` Name: ${p.name}`); |
| 502 | |
| 503 | const fields = getCredentialFields(p); |
| 504 | const required = fields.filter((f: any) => f.required); |
| 505 | const optional = fields.filter((f: any) => !f.required); |
| 506 | |
| 507 | if (required.length > 0) { |
| 508 | console.log( |
| 509 | ` Required: ${required.map((f: any) => pc.yellow(camelToFlag(f.key))).join(', ')}`, |
| 510 | ); |
| 511 | } |
| 512 | if (optional.length > 0) { |
| 513 | console.log( |
| 514 | ` Optional: ${optional.map((f: any) => pc.dim(camelToFlag(f.key))).join(', ')}`, |
| 515 | ); |
| 516 | } |
| 517 | console.log(); |
| 518 | } |
| 519 | }); |
| 520 | |
| 521 | // ── list ────────────────────────────────────────────── |
| 522 | |
| 523 | bot |
| 524 | .command('list') |
| 525 | .description('List bot integrations') |
| 526 | .option('-a, --agent <agentId>', 'Filter by agent ID') |
| 527 | .option('--platform <platform>', 'Filter by platform') |
| 528 | .option('--json [fields]', 'Output JSON, optionally specify fields (comma-separated)') |
| 529 | .action(async (options: { agent?: string; json?: string | boolean; platform?: string }) => { |
| 530 | const client = await getTrpcClient(); |