{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../src/core/shared-inference/cli.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAmBH,iBAAe,sBAAsB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAwDtE;AAED,iBAAe,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAsBnE;AAED,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,CAAC","sourcesContent":["/**\n * Shared inference + logical agent CLI (3.0.0 foundation).\n *\n * Operator diagnostics:\n *   jensen inference status\n *   jensen inference queue\n *   jensen inference resources\n *   jensen agents list\n *\n * JSON output is canonical. Never prints API keys or prompt content.\n */\n\nimport chalk from \"chalk\";\nimport { sharedInferenceResources } from \"./config.js\";\nimport { createFileInferenceQueueStore } from \"./file-inference-queue-store.js\";\nimport { createFileLogicalAgentStore } from \"./file-logical-agent-store.js\";\nimport { LocalSubagentRuntime } from \"./runtime.js\";\nimport { SharedInferenceScheduler } from \"./scheduler.js\";\n\nfunction printJson(payload: unknown): void {\n\tconsole.log(JSON.stringify(payload, null, 2));\n}\n\nfunction buildScheduler(): SharedInferenceScheduler {\n\tconst scheduler = new SharedInferenceScheduler({ store: createFileInferenceQueueStore() });\n\tvoid Promise.all(sharedInferenceResources().map((r) => scheduler.registerResource(r))).catch(() => {});\n\treturn scheduler;\n}\n\nasync function handleInferenceCommand(args: string[]): Promise<boolean> {\n\tif (args[0] !== \"inference\") return false;\n\tconst sub = args[1] ?? \"status\";\n\tconst json = args.includes(\"--json\");\n\n\tconst scheduler = buildScheduler();\n\tconst runtime = new LocalSubagentRuntime({ store: createFileLogicalAgentStore() });\n\tconst status = await scheduler.status();\n\tstatus.agents = await runtime.activityCounts();\n\n\tif (sub === \"status\") {\n\t\tif (json) {\n\t\t\tprintJson(status);\n\t\t} else {\n\t\t\tfor (const resource of status.resources) {\n\t\t\t\tconsole.log(chalk.bold(`Resource: ${resource.resourceId}`));\n\t\t\t\tconsole.log(`  Slots: ${resource.busySlots} / ${resource.capacity} busy`);\n\t\t\t\tconsole.log(`  Queue: ${resource.queueDepth}`);\n\t\t\t}\n\t\t\tconsole.log(\n\t\t\t\t`Agents: runningInference ${status.agents.runningInference}, waitingInference ${status.agents.waitingInference}, tooling ${status.agents.tooling}, parked ${status.agents.parked}, runnable ${status.agents.runnable}, total ${status.agents.total}`,\n\t\t\t);\n\t\t}\n\t\tprocess.exit(0);\n\t}\n\n\tif (sub === \"queue\") {\n\t\tconst queue = status.queue.filter((r) => r.state === \"QUEUED\");\n\t\tif (json) {\n\t\t\tprintJson(queue);\n\t\t} else {\n\t\t\tfor (const request of queue) {\n\t\t\t\tconsole.log(\n\t\t\t\t\t`  ${request.inferenceRequestId} agent=${request.logicalAgentId} pos=${request.position} priority=${request.effectivePriority}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tprocess.exit(0);\n\t}\n\n\tif (sub === \"resources\") {\n\t\tconst resources = scheduler.listResources();\n\t\tif (json) {\n\t\t\tprintJson(resources);\n\t\t} else {\n\t\t\tfor (const resource of resources) {\n\t\t\t\tconsole.log(\n\t\t\t\t\t`  ${resource.resourceId}: ${resource.backend}/${resource.model} @ ${resource.location} slots=${resource.capacity}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tprocess.exit(0);\n\t}\n\n\tconsole.error(chalk.red(`Unknown inference subcommand \"${sub}\". Supported: status, queue, resources.`));\n\tprocess.exit(1);\n}\n\nasync function handleAgentsCommand(args: string[]): Promise<boolean> {\n\tif (args[0] !== \"agents\") return false;\n\tconst sub = args[1] ?? \"list\";\n\tconst json = args.includes(\"--json\");\n\n\tconst runtime = new LocalSubagentRuntime({ store: createFileLogicalAgentStore() });\n\tif (sub === \"list\") {\n\t\tconst records = await runtime.list();\n\t\tif (json) {\n\t\t\tprintJson(records);\n\t\t} else {\n\t\t\tfor (const record of records) {\n\t\t\t\tconsole.log(\n\t\t\t\t\t`  ${record.logicalAgentId} ${record.activity}${record.waitingReason ? ` (${record.waitingReason})` : \"\"} mission=${record.missionId ?? \"-\"}`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tprocess.exit(0);\n\t}\n\n\tconsole.error(chalk.red(`Unknown agents subcommand \"${sub}\". Supported: list.`));\n\tprocess.exit(1);\n}\n\nexport { handleAgentsCommand, handleInferenceCommand };\n"]}