@coralai/sps-cli 0.63.5 → 0.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README-CN.md +2 -0
- package/README.md +2 -0
- package/dist/commands/agentCommand.d.ts.map +1 -1
- package/dist/commands/agentCommand.js +4 -3
- package/dist/commands/agentCommand.js.map +1 -1
- package/dist/commands/agentRenderer.js +3 -3
- package/dist/commands/agentRenderer.js.map +1 -1
- package/dist/commands/cardDashboard.d.ts.map +1 -1
- package/dist/commands/cardDashboard.js +2 -2
- package/dist/commands/cardDashboard.js.map +1 -1
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +0 -3
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/logs.d.ts.map +1 -1
- package/dist/commands/logs.js +15 -15
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/openaiAgent.d.ts +3 -0
- package/dist/commands/openaiAgent.d.ts.map +1 -0
- package/dist/commands/openaiAgent.js +81 -0
- package/dist/commands/openaiAgent.js.map +1 -0
- package/dist/commands/pipelineRunner.js.map +1 -1
- package/dist/commands/pipelineTick.js +1 -1
- package/dist/commands/pipelineTick.js.map +1 -1
- package/dist/commands/projectInit.d.ts +11 -1
- package/dist/commands/projectInit.d.ts.map +1 -1
- package/dist/commands/projectInit.js +38 -7
- package/dist/commands/projectInit.js.map +1 -1
- package/dist/commands/prune.d.ts +6 -0
- package/dist/commands/prune.d.ts.map +1 -0
- package/dist/commands/prune.js +87 -0
- package/dist/commands/prune.js.map +1 -0
- package/dist/commands/qaTick.js +1 -1
- package/dist/commands/qaTick.js.map +1 -1
- package/dist/commands/reset.d.ts.map +1 -1
- package/dist/commands/reset.js +3 -2
- package/dist/commands/reset.js.map +1 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +8 -1
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/skillCommand.d.ts.map +1 -1
- package/dist/commands/skillCommand.js +2 -3
- package/dist/commands/skillCommand.js.map +1 -1
- package/dist/commands/status.js +2 -2
- package/dist/commands/status.js.map +1 -1
- package/dist/commands/stop.js +3 -3
- package/dist/commands/stop.js.map +1 -1
- package/dist/commands/tick.d.ts.map +1 -1
- package/dist/commands/tick.js +5 -2
- package/dist/commands/tick.js.map +1 -1
- package/dist/commands/workerDashboard.d.ts.map +1 -1
- package/dist/commands/workerDashboard.js +27 -26
- package/dist/commands/workerDashboard.js.map +1 -1
- package/dist/commands/workerLaunch.js +1 -1
- package/dist/commands/workerLaunch.js.map +1 -1
- package/dist/console/routes/chat.d.ts +18 -1
- package/dist/console/routes/chat.d.ts.map +1 -1
- package/dist/console/routes/chat.js +529 -40
- package/dist/console/routes/chat.js.map +1 -1
- package/dist/console/routes/fs.d.ts.map +1 -1
- package/dist/console/routes/fs.js +2 -1
- package/dist/console/routes/fs.js.map +1 -1
- package/dist/console/routes/logs.d.ts.map +1 -1
- package/dist/console/routes/logs.js +17 -5
- package/dist/console/routes/logs.js.map +1 -1
- package/dist/console/routes/projects.d.ts.map +1 -1
- package/dist/console/routes/projects.js +11 -2
- package/dist/console/routes/projects.js.map +1 -1
- package/dist/console/routes/workers.js +3 -3
- package/dist/console/routes/workers.js.map +1 -1
- package/dist/console-assets/assets/{ShowcasePage-BWHyDQhw.js → ShowcasePage-DFRO5bAO.js} +1 -1
- package/dist/console-assets/assets/{index-rQ_2k-G9.css → index-DZ28qAcd.css} +1 -1
- package/dist/console-assets/assets/{index-DH_TQHY4.js → index-De5GjRjY.js} +220 -215
- package/dist/console-assets/index.html +2 -2
- package/dist/core/agents/AgentBackend.d.ts +2 -2
- package/dist/core/agents/AgentBackend.d.ts.map +1 -1
- package/dist/core/agents/AgentBackend.js.map +1 -1
- package/dist/core/agents/DaemonBackend.d.ts +12 -2
- package/dist/core/agents/DaemonBackend.d.ts.map +1 -1
- package/dist/core/agents/DaemonBackend.js +68 -20
- package/dist/core/agents/DaemonBackend.js.map +1 -1
- package/dist/core/agents/resolveBackend.d.ts +4 -1
- package/dist/core/agents/resolveBackend.d.ts.map +1 -1
- package/dist/core/agents/resolveBackend.js +31 -1
- package/dist/core/agents/resolveBackend.js.map +1 -1
- package/dist/core/config.d.ts +5 -8
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +3 -9
- package/dist/core/config.js.map +1 -1
- package/dist/core/intel/agentsConfig.d.ts +9 -0
- package/dist/core/intel/agentsConfig.d.ts.map +1 -1
- package/dist/core/intel/agentsConfig.js +42 -0
- package/dist/core/intel/agentsConfig.js.map +1 -1
- package/dist/core/intel/types.d.ts +1 -0
- package/dist/core/intel/types.d.ts.map +1 -1
- package/dist/core/markerFile.d.ts.map +1 -1
- package/dist/core/markerFile.js +2 -2
- package/dist/core/markerFile.js.map +1 -1
- package/dist/core/openaiWorkerLog.d.ts +7 -0
- package/dist/core/openaiWorkerLog.d.ts.map +1 -0
- package/dist/core/openaiWorkerLog.js +98 -0
- package/dist/core/openaiWorkerLog.js.map +1 -0
- package/dist/core/paths.d.ts +1 -1
- package/dist/core/paths.d.ts.map +1 -1
- package/dist/core/paths.js +9 -7
- package/dist/core/paths.js.map +1 -1
- package/dist/core/pipelineConfig.js +7 -7
- package/dist/core/pipelineConfig.js.map +1 -1
- package/dist/core/pipelineSession.d.ts +3 -1
- package/dist/core/pipelineSession.d.ts.map +1 -1
- package/dist/core/pipelineSession.js +8 -2
- package/dist/core/pipelineSession.js.map +1 -1
- package/dist/core/processInspect.d.ts +5 -0
- package/dist/core/processInspect.d.ts.map +1 -1
- package/dist/core/processInspect.js +41 -11
- package/dist/core/processInspect.js.map +1 -1
- package/dist/core/projectPipelineAdapter.d.ts.map +1 -1
- package/dist/core/projectPipelineAdapter.js +4 -4
- package/dist/core/projectPipelineAdapter.js.map +1 -1
- package/dist/core/runtimeSnapshot.d.ts +2 -2
- package/dist/core/runtimeSnapshot.d.ts.map +1 -1
- package/dist/core/runtimeSnapshot.js +2 -2
- package/dist/core/runtimeSnapshot.js.map +1 -1
- package/dist/core/runtimeStore.d.ts +12 -12
- package/dist/core/runtimeStore.d.ts.map +1 -1
- package/dist/core/runtimeStore.js +16 -16
- package/dist/core/runtimeStore.js.map +1 -1
- package/dist/core/runtimeTypes.d.ts +109 -24
- package/dist/core/runtimeTypes.d.ts.map +1 -1
- package/dist/core/runtimeTypes.js +1 -1
- package/dist/core/sessionCleanup.d.ts +1 -1
- package/dist/core/sessionCleanup.d.ts.map +1 -1
- package/dist/core/sessionCleanup.js +2 -2
- package/dist/core/sessionCleanup.js.map +1 -1
- package/dist/core/sessionContext.d.ts +2 -2
- package/dist/core/sessionContext.d.ts.map +1 -1
- package/dist/core/sessionContext.js +1 -1
- package/dist/core/sessionContext.js.map +1 -1
- package/dist/core/sessionLiveness.d.ts +7 -6
- package/dist/core/sessionLiveness.d.ts.map +1 -1
- package/dist/core/sessionLiveness.js +3 -4
- package/dist/core/sessionLiveness.js.map +1 -1
- package/dist/core/state.d.ts +13 -12
- package/dist/core/state.d.ts.map +1 -1
- package/dist/core/state.js +9 -1
- package/dist/core/state.js.map +1 -1
- package/dist/core/workerRuntimeSummary.js +2 -2
- package/dist/core/workerRuntimeSummary.js.map +1 -1
- package/dist/core/workspacePaths.d.ts +22 -0
- package/dist/core/workspacePaths.d.ts.map +1 -0
- package/dist/core/workspacePaths.js +73 -0
- package/dist/core/workspacePaths.js.map +1 -0
- package/dist/daemon/daemonClient.d.ts +19 -22
- package/dist/daemon/daemonClient.d.ts.map +1 -1
- package/dist/daemon/daemonClient.js +82 -2
- package/dist/daemon/daemonClient.js.map +1 -1
- package/dist/daemon/sessionDaemon.d.ts +52 -7
- package/dist/daemon/sessionDaemon.d.ts.map +1 -1
- package/dist/daemon/sessionDaemon.js +40 -24
- package/dist/daemon/sessionDaemon.js.map +1 -1
- package/dist/engines/EventHandler.js +1 -1
- package/dist/engines/EventHandler.js.map +1 -1
- package/dist/engines/MonitorEngine.d.ts +2 -2
- package/dist/engines/MonitorEngine.d.ts.map +1 -1
- package/dist/engines/MonitorEngine.js +15 -17
- package/dist/engines/MonitorEngine.js.map +1 -1
- package/dist/engines/StageEngine.d.ts +5 -3
- package/dist/engines/StageEngine.d.ts.map +1 -1
- package/dist/engines/StageEngine.js +33 -18
- package/dist/engines/StageEngine.js.map +1 -1
- package/dist/main.js +21 -1
- package/dist/main.js.map +1 -1
- package/dist/manager/makeBackendFactory.d.ts +11 -4
- package/dist/manager/makeBackendFactory.d.ts.map +1 -1
- package/dist/manager/makeBackendFactory.js +28 -15
- package/dist/manager/makeBackendFactory.js.map +1 -1
- package/dist/manager/runtime-coordinator.js.map +1 -1
- package/dist/manager/supervisor.d.ts +7 -7
- package/dist/manager/supervisor.d.ts.map +1 -1
- package/dist/manager/supervisor.js +7 -7
- package/dist/manager/supervisor.js.map +1 -1
- package/dist/manager/worker-manager-impl.d.ts +4 -4
- package/dist/manager/worker-manager-impl.d.ts.map +1 -1
- package/dist/manager/worker-manager-impl.js +56 -24
- package/dist/manager/worker-manager-impl.js.map +1 -1
- package/dist/manager/worker-manager.d.ts +6 -6
- package/dist/manager/worker-manager.d.ts.map +1 -1
- package/dist/openai-agent/agentFactory.d.ts +10 -0
- package/dist/openai-agent/agentFactory.d.ts.map +1 -0
- package/dist/openai-agent/agentFactory.js +26 -0
- package/dist/openai-agent/agentFactory.js.map +1 -0
- package/dist/openai-agent/eventMap.d.ts +11 -0
- package/dist/openai-agent/eventMap.d.ts.map +1 -0
- package/dist/openai-agent/eventMap.js +191 -0
- package/dist/openai-agent/eventMap.js.map +1 -0
- package/dist/openai-agent/hooks.d.ts +13 -0
- package/dist/openai-agent/hooks.d.ts.map +1 -0
- package/dist/openai-agent/hooks.js +63 -0
- package/dist/openai-agent/hooks.js.map +1 -0
- package/dist/openai-agent/instructions.d.ts +3 -0
- package/dist/openai-agent/instructions.d.ts.map +1 -0
- package/dist/openai-agent/instructions.js +63 -0
- package/dist/openai-agent/instructions.js.map +1 -0
- package/dist/openai-agent/interactions/broker.d.ts +23 -0
- package/dist/openai-agent/interactions/broker.d.ts.map +1 -0
- package/dist/openai-agent/interactions/broker.js +316 -0
- package/dist/openai-agent/interactions/broker.js.map +1 -0
- package/dist/openai-agent/mcp/managedMcp.d.ts +31 -0
- package/dist/openai-agent/mcp/managedMcp.d.ts.map +1 -0
- package/dist/openai-agent/mcp/managedMcp.js +95 -0
- package/dist/openai-agent/mcp/managedMcp.js.map +1 -0
- package/dist/openai-agent/protocolWriter.d.ts +29 -0
- package/dist/openai-agent/protocolWriter.d.ts.map +1 -0
- package/dist/openai-agent/protocolWriter.js +74 -0
- package/dist/openai-agent/protocolWriter.js.map +1 -0
- package/dist/openai-agent/providerCapabilities.d.ts +31 -0
- package/dist/openai-agent/providerCapabilities.d.ts.map +1 -0
- package/dist/openai-agent/providerCapabilities.js +49 -0
- package/dist/openai-agent/providerCapabilities.js.map +1 -0
- package/dist/openai-agent/providerFactory.d.ts +18 -0
- package/dist/openai-agent/providerFactory.d.ts.map +1 -0
- package/dist/openai-agent/providerFactory.js +38 -0
- package/dist/openai-agent/providerFactory.js.map +1 -0
- package/dist/openai-agent/request.d.ts +22 -0
- package/dist/openai-agent/request.d.ts.map +1 -0
- package/dist/openai-agent/request.js +89 -0
- package/dist/openai-agent/request.js.map +1 -0
- package/dist/openai-agent/runWorker.d.ts +25 -0
- package/dist/openai-agent/runWorker.d.ts.map +1 -0
- package/dist/openai-agent/runWorker.js +635 -0
- package/dist/openai-agent/runWorker.js.map +1 -0
- package/dist/openai-agent/sandbox/execution.d.ts +36 -0
- package/dist/openai-agent/sandbox/execution.d.ts.map +1 -0
- package/dist/openai-agent/sandbox/execution.js +239 -0
- package/dist/openai-agent/sandbox/execution.js.map +1 -0
- package/dist/openai-agent/sandbox/productionDocker.d.ts +17 -0
- package/dist/openai-agent/sandbox/productionDocker.d.ts.map +1 -0
- package/dist/openai-agent/sandbox/productionDocker.js +76 -0
- package/dist/openai-agent/sandbox/productionDocker.js.map +1 -0
- package/dist/openai-agent/sdkContract.d.ts +18 -0
- package/dist/openai-agent/sdkContract.d.ts.map +1 -0
- package/dist/openai-agent/sdkContract.js +2 -0
- package/dist/openai-agent/sdkContract.js.map +1 -0
- package/dist/openai-agent/storage/atomic.d.ts +10 -0
- package/dist/openai-agent/storage/atomic.d.ts.map +1 -0
- package/dist/openai-agent/storage/atomic.js +112 -0
- package/dist/openai-agent/storage/atomic.js.map +1 -0
- package/dist/openai-agent/storage/checkpoint.d.ts +38 -0
- package/dist/openai-agent/storage/checkpoint.d.ts.map +1 -0
- package/dist/openai-agent/storage/checkpoint.js +141 -0
- package/dist/openai-agent/storage/checkpoint.js.map +1 -0
- package/dist/openai-agent/storage/errors.d.ts +8 -0
- package/dist/openai-agent/storage/errors.d.ts.map +1 -0
- package/dist/openai-agent/storage/errors.js +11 -0
- package/dist/openai-agent/storage/errors.js.map +1 -0
- package/dist/openai-agent/storage/index.d.ts +12 -0
- package/dist/openai-agent/storage/index.d.ts.map +1 -0
- package/dist/openai-agent/storage/index.js +12 -0
- package/dist/openai-agent/storage/index.js.map +1 -0
- package/dist/openai-agent/storage/interaction.d.ts +45 -0
- package/dist/openai-agent/storage/interaction.d.ts.map +1 -0
- package/dist/openai-agent/storage/interaction.js +372 -0
- package/dist/openai-agent/storage/interaction.js.map +1 -0
- package/dist/openai-agent/storage/lock.d.ts +13 -0
- package/dist/openai-agent/storage/lock.d.ts.map +1 -0
- package/dist/openai-agent/storage/lock.js +95 -0
- package/dist/openai-agent/storage/lock.js.map +1 -0
- package/dist/openai-agent/storage/metrics.d.ts +34 -0
- package/dist/openai-agent/storage/metrics.d.ts.map +1 -0
- package/dist/openai-agent/storage/metrics.js +74 -0
- package/dist/openai-agent/storage/metrics.js.map +1 -0
- package/dist/openai-agent/storage/output.d.ts +22 -0
- package/dist/openai-agent/storage/output.d.ts.map +1 -0
- package/dist/openai-agent/storage/output.js +175 -0
- package/dist/openai-agent/storage/output.js.map +1 -0
- package/dist/openai-agent/storage/session.d.ts +38 -0
- package/dist/openai-agent/storage/session.d.ts.map +1 -0
- package/dist/openai-agent/storage/session.js +216 -0
- package/dist/openai-agent/storage/session.js.map +1 -0
- package/dist/openai-agent/storage/toolLedger.d.ts +64 -0
- package/dist/openai-agent/storage/toolLedger.d.ts.map +1 -0
- package/dist/openai-agent/storage/toolLedger.js +281 -0
- package/dist/openai-agent/storage/toolLedger.js.map +1 -0
- package/dist/openai-agent/storage/workerStorage.d.ts +21 -0
- package/dist/openai-agent/storage/workerStorage.d.ts.map +1 -0
- package/dist/openai-agent/storage/workerStorage.js +38 -0
- package/dist/openai-agent/storage/workerStorage.js.map +1 -0
- package/dist/openai-agent/storage/workspace.d.ts +17 -0
- package/dist/openai-agent/storage/workspace.d.ts.map +1 -0
- package/dist/openai-agent/storage/workspace.js +67 -0
- package/dist/openai-agent/storage/workspace.js.map +1 -0
- package/dist/openai-agent/testHelpers.d.ts +9 -0
- package/dist/openai-agent/testHelpers.d.ts.map +1 -0
- package/dist/openai-agent/testHelpers.js +35 -0
- package/dist/openai-agent/testHelpers.js.map +1 -0
- package/dist/openai-agent/tools/ledgerTools.d.ts +12 -0
- package/dist/openai-agent/tools/ledgerTools.d.ts.map +1 -0
- package/dist/openai-agent/tools/ledgerTools.js +151 -0
- package/dist/openai-agent/tools/ledgerTools.js.map +1 -0
- package/dist/providers/MarkdownTaskBackend.d.ts.map +1 -1
- package/dist/providers/MarkdownTaskBackend.js +2 -2
- package/dist/providers/MarkdownTaskBackend.js.map +1 -1
- package/dist/providers/RuntimeSessionRuntime.d.ts +35 -15
- package/dist/providers/RuntimeSessionRuntime.d.ts.map +1 -1
- package/dist/providers/RuntimeSessionRuntime.js +239 -22
- package/dist/providers/RuntimeSessionRuntime.js.map +1 -1
- package/dist/providers/llm/chatTools.d.ts.map +1 -1
- package/dist/providers/llm/chatTools.js +3 -3
- package/dist/providers/llm/chatTools.js.map +1 -1
- package/dist/providers/llm/codexAuth.d.ts +6 -1
- package/dist/providers/llm/codexAuth.d.ts.map +1 -1
- package/dist/providers/llm/codexAuth.js +45 -9
- package/dist/providers/llm/codexAuth.js.map +1 -1
- package/dist/providers/llm/codexModel.d.ts +4 -1
- package/dist/providers/llm/codexModel.d.ts.map +1 -1
- package/dist/providers/llm/codexModel.js +13 -3
- package/dist/providers/llm/codexModel.js.map +1 -1
- package/dist/providers/llm/localSubscription.d.ts +1 -1
- package/dist/providers/llm/localSubscription.d.ts.map +1 -1
- package/dist/providers/llm/localSubscription.js +2 -2
- package/dist/providers/llm/localSubscription.js.map +1 -1
- package/dist/providers/runtimeEventMap.d.ts +54 -5
- package/dist/providers/runtimeEventMap.d.ts.map +1 -1
- package/dist/providers/runtimeEventMap.js +110 -11
- package/dist/providers/runtimeEventMap.js.map +1 -1
- package/dist/runtime/agentd/client.d.ts +29 -0
- package/dist/runtime/agentd/client.d.ts.map +1 -0
- package/dist/runtime/agentd/client.js +131 -0
- package/dist/runtime/agentd/client.js.map +1 -0
- package/dist/runtime/agentd/main.d.ts +10 -0
- package/dist/runtime/agentd/main.d.ts.map +1 -0
- package/dist/runtime/agentd/main.js +49 -0
- package/dist/runtime/agentd/main.js.map +1 -0
- package/dist/runtime/agentd/protocol.d.ts +74 -0
- package/dist/runtime/agentd/protocol.d.ts.map +1 -0
- package/dist/runtime/agentd/protocol.js +21 -0
- package/dist/runtime/agentd/protocol.js.map +1 -0
- package/dist/runtime/agentd/server.d.ts +15 -0
- package/dist/runtime/agentd/server.d.ts.map +1 -0
- package/dist/runtime/agentd/server.js +116 -0
- package/dist/runtime/agentd/server.js.map +1 -0
- package/dist/runtime/backends/claude/ClaudeBackend.d.ts +155 -0
- package/dist/runtime/backends/claude/ClaudeBackend.d.ts.map +1 -0
- package/dist/runtime/backends/claude/ClaudeBackend.js +398 -0
- package/dist/runtime/backends/claude/ClaudeBackend.js.map +1 -0
- package/dist/runtime/backends/claude/ClaudeSessions.d.ts +23 -0
- package/dist/runtime/backends/claude/ClaudeSessions.d.ts.map +1 -0
- package/dist/runtime/backends/claude/ClaudeSessions.js +45 -0
- package/dist/runtime/backends/claude/ClaudeSessions.js.map +1 -0
- package/dist/runtime/backends/claude/inprocTools.d.ts +17 -0
- package/dist/runtime/backends/claude/inprocTools.d.ts.map +1 -0
- package/dist/runtime/backends/claude/inprocTools.js +14 -0
- package/dist/runtime/backends/claude/inprocTools.js.map +1 -0
- package/dist/runtime/backends/process/ExternalProcessBackend.d.ts +83 -0
- package/dist/runtime/backends/process/ExternalProcessBackend.d.ts.map +1 -0
- package/dist/runtime/backends/process/ExternalProcessBackend.js +642 -0
- package/dist/runtime/backends/process/ExternalProcessBackend.js.map +1 -0
- package/dist/runtime/contract/AgentBackend.d.ts +199 -0
- package/dist/runtime/contract/AgentBackend.d.ts.map +1 -0
- package/dist/runtime/contract/AgentBackend.js +2 -0
- package/dist/runtime/contract/AgentBackend.js.map +1 -0
- package/dist/runtime/contract/events.d.ts +96 -0
- package/dist/runtime/contract/events.d.ts.map +1 -0
- package/dist/runtime/contract/events.js +2 -0
- package/dist/runtime/contract/events.js.map +1 -0
- package/dist/runtime/contract/index.d.ts +13 -0
- package/dist/runtime/contract/index.d.ts.map +1 -0
- package/dist/runtime/contract/index.js +2 -0
- package/dist/runtime/contract/index.js.map +1 -0
- package/dist/runtime/contract/lifecycle.d.ts +26 -0
- package/dist/runtime/contract/lifecycle.d.ts.map +1 -0
- package/dist/runtime/contract/lifecycle.js +6 -0
- package/dist/runtime/contract/lifecycle.js.map +1 -0
- package/dist/runtime/contract/processProtocol.d.ts +263 -0
- package/dist/runtime/contract/processProtocol.d.ts.map +1 -0
- package/dist/runtime/contract/processProtocol.js +779 -0
- package/dist/runtime/contract/processProtocol.js.map +1 -0
- package/dist/runtime/contract/service.d.ts +85 -0
- package/dist/runtime/contract/service.d.ts.map +1 -0
- package/dist/runtime/contract/service.js +2 -0
- package/dist/runtime/contract/service.js.map +1 -0
- package/dist/runtime/contract/versioning.d.ts +44 -0
- package/dist/runtime/contract/versioning.d.ts.map +1 -0
- package/dist/runtime/contract/versioning.js +10 -0
- package/dist/runtime/contract/versioning.js.map +1 -0
- package/dist/runtime/index.d.ts +21 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +26 -0
- package/dist/runtime/index.js.map +1 -0
- package/dist/runtime/runtime.d.ts +21 -0
- package/dist/runtime/runtime.d.ts.map +1 -0
- package/dist/runtime/runtime.js +34 -0
- package/dist/runtime/runtime.js.map +1 -0
- package/dist/runtime/service/AgentRuntime.d.ts +60 -0
- package/dist/runtime/service/AgentRuntime.d.ts.map +1 -0
- package/dist/runtime/service/AgentRuntime.js +396 -0
- package/dist/runtime/service/AgentRuntime.js.map +1 -0
- package/dist/runtime/service/FileRecordStore.d.ts +12 -0
- package/dist/runtime/service/FileRecordStore.d.ts.map +1 -0
- package/dist/runtime/service/FileRecordStore.js +48 -0
- package/dist/runtime/service/FileRecordStore.js.map +1 -0
- package/dist/runtime/service/backendFactory.d.ts +8 -0
- package/dist/runtime/service/backendFactory.d.ts.map +1 -0
- package/dist/runtime/service/backendFactory.js +20 -0
- package/dist/runtime/service/backendFactory.js.map +1 -0
- package/dist/runtime/stub/NoopBackend.d.ts +29 -0
- package/dist/runtime/stub/NoopBackend.d.ts.map +1 -0
- package/dist/runtime/stub/NoopBackend.js +56 -0
- package/dist/runtime/stub/NoopBackend.js.map +1 -0
- package/dist/runtime/stub/NoopService.d.ts +23 -0
- package/dist/runtime/stub/NoopService.d.ts.map +1 -0
- package/dist/runtime/stub/NoopService.js +136 -0
- package/dist/runtime/stub/NoopService.js.map +1 -0
- package/dist/runtime/stub/index.d.ts +8 -0
- package/dist/runtime/stub/index.d.ts.map +1 -0
- package/dist/runtime/stub/index.js +8 -0
- package/dist/runtime/stub/index.js.map +1 -0
- package/dist/runtime/versioning/VersionManager.d.ts +31 -0
- package/dist/runtime/versioning/VersionManager.d.ts.map +1 -0
- package/dist/runtime/versioning/VersionManager.js +142 -0
- package/dist/runtime/versioning/VersionManager.js.map +1 -0
- package/dist/services/ChatService.d.ts +11 -0
- package/dist/services/ChatService.d.ts.map +1 -1
- package/dist/services/ChatService.js +35 -5
- package/dist/services/ChatService.js.map +1 -1
- package/dist/services/LogService.d.ts +10 -4
- package/dist/services/LogService.d.ts.map +1 -1
- package/dist/services/LogService.js +26 -5
- package/dist/services/LogService.js.map +1 -1
- package/dist/services/ProjectService.d.ts +27 -0
- package/dist/services/ProjectService.d.ts.map +1 -1
- package/dist/services/ProjectService.js +74 -14
- package/dist/services/ProjectService.js.map +1 -1
- package/dist/services/WorkerService.d.ts +1 -0
- package/dist/services/WorkerService.d.ts.map +1 -1
- package/dist/services/WorkerService.js +72 -0
- package/dist/services/WorkerService.js.map +1 -1
- package/dist/services/executors.d.ts +1 -0
- package/dist/services/executors.d.ts.map +1 -1
- package/dist/services/executors.js +9 -1
- package/dist/services/executors.js.map +1 -1
- package/dist/services/promptPreview.d.ts.map +1 -1
- package/dist/services/promptPreview.js +4 -3
- package/dist/services/promptPreview.js.map +1 -1
- package/dist/shared/runtimePaths.d.ts +4 -0
- package/dist/shared/runtimePaths.d.ts.map +1 -1
- package/dist/shared/runtimePaths.js +8 -0
- package/dist/shared/runtimePaths.js.map +1 -1
- package/dist/shared/runtimeSchemas.d.ts +6 -2
- package/dist/shared/runtimeSchemas.d.ts.map +1 -1
- package/dist/shared/runtimeSchemas.js +3 -2
- package/dist/shared/runtimeSchemas.js.map +1 -1
- package/docs/openai-daemon-agent.md +144 -0
- package/package.json +15 -9
- package/project-template/.claude/hooks/openai/on-start.sh +6 -0
- package/project-template/.claude/hooks/openai/on-stop.sh +6 -0
|
@@ -0,0 +1,779 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Versioned NDJSON contract between an agent supervisor and a short-lived
|
|
3
|
+
* external agent worker. This protocol is independent from the agentd socket
|
|
4
|
+
* protocol: stdin carries commands, stdout carries events, and stderr is
|
|
5
|
+
* reserved for diagnostics.
|
|
6
|
+
*/
|
|
7
|
+
export const AGENT_PROCESS_PROTOCOL_VERSION = 1;
|
|
8
|
+
export class AgentProcessProtocolError extends Error {
|
|
9
|
+
code;
|
|
10
|
+
line;
|
|
11
|
+
constructor(code, message, line) {
|
|
12
|
+
super(message);
|
|
13
|
+
this.code = code;
|
|
14
|
+
this.line = line;
|
|
15
|
+
this.name = 'AgentProcessProtocolError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const EVENT_TYPES = new Set([
|
|
19
|
+
'session.started',
|
|
20
|
+
'capabilities',
|
|
21
|
+
'assistant.delta',
|
|
22
|
+
'assistant.message',
|
|
23
|
+
'tool.call',
|
|
24
|
+
'tool.progress',
|
|
25
|
+
'tool.result',
|
|
26
|
+
'agent.changed',
|
|
27
|
+
'interaction.required',
|
|
28
|
+
'context.compacted',
|
|
29
|
+
'usage.updated',
|
|
30
|
+
'system.warning',
|
|
31
|
+
'run.waiting_for_input',
|
|
32
|
+
'run.completed',
|
|
33
|
+
'run.failed',
|
|
34
|
+
'run.cancelled',
|
|
35
|
+
]);
|
|
36
|
+
const TERMINAL_EVENT_TYPES = new Set([
|
|
37
|
+
'run.waiting_for_input',
|
|
38
|
+
'run.completed',
|
|
39
|
+
'run.failed',
|
|
40
|
+
'run.cancelled',
|
|
41
|
+
]);
|
|
42
|
+
const ERROR_CODES = new Set([
|
|
43
|
+
'not_found',
|
|
44
|
+
'corrupt',
|
|
45
|
+
'unsupported_version',
|
|
46
|
+
'incompatible_agent_graph',
|
|
47
|
+
'missing_tool',
|
|
48
|
+
'workspace_unavailable',
|
|
49
|
+
'provider_state_unavailable',
|
|
50
|
+
'operator_reconciliation',
|
|
51
|
+
'provider_error',
|
|
52
|
+
'tool_error',
|
|
53
|
+
'guardrail_error',
|
|
54
|
+
'protocol_error',
|
|
55
|
+
'persistence_error',
|
|
56
|
+
'internal_error',
|
|
57
|
+
]);
|
|
58
|
+
export function isTerminalAgentProcessEventType(type) {
|
|
59
|
+
return TERMINAL_EVENT_TYPES.has(type);
|
|
60
|
+
}
|
|
61
|
+
export function parseAgentProcessCommandV1(value) {
|
|
62
|
+
const command = requireRecord(value, 'command');
|
|
63
|
+
requireProtocolVersion(command);
|
|
64
|
+
const kind = requireString(command, 'command');
|
|
65
|
+
if (kind === 'start') {
|
|
66
|
+
return parseStartCommand(command);
|
|
67
|
+
}
|
|
68
|
+
if (kind === 'cancel') {
|
|
69
|
+
return parseCancelCommand(command);
|
|
70
|
+
}
|
|
71
|
+
throw protocolError('unexpected_command', `Unsupported worker command: ${kind}`);
|
|
72
|
+
}
|
|
73
|
+
export function parseAgentProcessEventV1(value) {
|
|
74
|
+
const event = requireRecord(value, 'event');
|
|
75
|
+
assertAllowedKeys(event, 'event', [
|
|
76
|
+
'protocolVersion',
|
|
77
|
+
'eventId',
|
|
78
|
+
'sessionId',
|
|
79
|
+
'runId',
|
|
80
|
+
'turnId',
|
|
81
|
+
'sequence',
|
|
82
|
+
'timestamp',
|
|
83
|
+
'type',
|
|
84
|
+
'payload',
|
|
85
|
+
'backend',
|
|
86
|
+
]);
|
|
87
|
+
requireProtocolVersion(event);
|
|
88
|
+
const type = requireString(event, 'type');
|
|
89
|
+
if (!EVENT_TYPES.has(type)) {
|
|
90
|
+
throw protocolError('invalid_shape', `Unknown worker event type: ${type}`);
|
|
91
|
+
}
|
|
92
|
+
const parsedType = type;
|
|
93
|
+
const sequence = requireInteger(event, 'sequence', 1);
|
|
94
|
+
const timestamp = requireString(event, 'timestamp');
|
|
95
|
+
if (!Number.isFinite(Date.parse(timestamp))) {
|
|
96
|
+
throw protocolError('invalid_shape', 'event.timestamp must be an ISO-compatible date');
|
|
97
|
+
}
|
|
98
|
+
const backend = parseBackendMetadata(event.backend);
|
|
99
|
+
const payload = parseEventPayload(parsedType, event.payload);
|
|
100
|
+
return {
|
|
101
|
+
protocolVersion: AGENT_PROCESS_PROTOCOL_VERSION,
|
|
102
|
+
eventId: requireNonEmptyString(event, 'eventId'),
|
|
103
|
+
sessionId: requireNonEmptyString(event, 'sessionId'),
|
|
104
|
+
runId: requireNonEmptyString(event, 'runId'),
|
|
105
|
+
turnId: requireNonEmptyString(event, 'turnId'),
|
|
106
|
+
sequence,
|
|
107
|
+
timestamp,
|
|
108
|
+
type: parsedType,
|
|
109
|
+
payload,
|
|
110
|
+
backend,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Stateful validation for a single run. It rejects identity changes,
|
|
115
|
+
* duplicate IDs, non-contiguous sequence numbers, and output after terminal.
|
|
116
|
+
*/
|
|
117
|
+
export class AgentProcessEventStreamValidator {
|
|
118
|
+
expected;
|
|
119
|
+
options;
|
|
120
|
+
eventIds = new Set();
|
|
121
|
+
nextSequence;
|
|
122
|
+
terminal = false;
|
|
123
|
+
constructor(expected, options = {}) {
|
|
124
|
+
this.expected = expected;
|
|
125
|
+
this.options = options;
|
|
126
|
+
this.nextSequence = (options.initialSequence ?? 0) + 1;
|
|
127
|
+
}
|
|
128
|
+
accept(value) {
|
|
129
|
+
const event = parseAgentProcessEventV1(value);
|
|
130
|
+
if (this.terminal) {
|
|
131
|
+
throw protocolError('after_terminal', `Event ${event.eventId} arrived after terminal`);
|
|
132
|
+
}
|
|
133
|
+
if ((this.expected?.sessionId !== undefined && event.sessionId !== this.expected.sessionId) ||
|
|
134
|
+
(this.expected?.runId !== undefined && event.runId !== this.expected.runId) ||
|
|
135
|
+
(this.expected?.turnId !== undefined && event.turnId !== this.expected.turnId)) {
|
|
136
|
+
throw protocolError('identity_mismatch', 'Event identity does not match the active run');
|
|
137
|
+
}
|
|
138
|
+
if (this.eventIds.has(event.eventId)) {
|
|
139
|
+
throw protocolError('duplicate_event_id', `Duplicate eventId: ${event.eventId}`);
|
|
140
|
+
}
|
|
141
|
+
if (event.sequence !== this.nextSequence) {
|
|
142
|
+
throw protocolError('out_of_order', `Expected sequence ${this.nextSequence}, received ${event.sequence}`);
|
|
143
|
+
}
|
|
144
|
+
this.eventIds.add(event.eventId);
|
|
145
|
+
this.nextSequence += 1;
|
|
146
|
+
this.terminal =
|
|
147
|
+
isTerminalAgentProcessEventType(event.type) &&
|
|
148
|
+
!(event.type === 'run.waiting_for_input' &&
|
|
149
|
+
this.options.allowResumeAfterWaiting);
|
|
150
|
+
return event;
|
|
151
|
+
}
|
|
152
|
+
get lastSequence() {
|
|
153
|
+
return this.nextSequence - 1;
|
|
154
|
+
}
|
|
155
|
+
get hasTerminal() {
|
|
156
|
+
return this.terminal;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Stateful validation for worker stdin. Exactly one start command must be the
|
|
161
|
+
* first frame; subsequent frames may only cancel that same run.
|
|
162
|
+
*/
|
|
163
|
+
export class AgentProcessCommandStreamValidator {
|
|
164
|
+
activeStart = null;
|
|
165
|
+
accept(value) {
|
|
166
|
+
const command = parseAgentProcessCommandV1(value);
|
|
167
|
+
if (this.activeStart === null) {
|
|
168
|
+
if (command.command !== 'start') {
|
|
169
|
+
throw protocolError('unexpected_command', 'The first worker command must be start');
|
|
170
|
+
}
|
|
171
|
+
this.activeStart = command;
|
|
172
|
+
return command;
|
|
173
|
+
}
|
|
174
|
+
if (command.command === 'start') {
|
|
175
|
+
throw protocolError('unexpected_command', 'A worker process accepts only one start command');
|
|
176
|
+
}
|
|
177
|
+
if (command.sessionId !== this.activeStart.sessionId ||
|
|
178
|
+
command.runId !== this.activeStart.runId) {
|
|
179
|
+
throw protocolError('identity_mismatch', 'Cancel command does not match the active run');
|
|
180
|
+
}
|
|
181
|
+
return command;
|
|
182
|
+
}
|
|
183
|
+
get startCommand() {
|
|
184
|
+
return this.activeStart;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Incremental UTF-8 NDJSON decoder. It is safe for arbitrarily split or
|
|
189
|
+
* coalesced chunks and validates every non-empty stdout line.
|
|
190
|
+
*/
|
|
191
|
+
export class AgentProcessEventDecoder {
|
|
192
|
+
validator;
|
|
193
|
+
decoder = new TextDecoder();
|
|
194
|
+
buffer = '';
|
|
195
|
+
constructor(validator = new AgentProcessEventStreamValidator()) {
|
|
196
|
+
this.validator = validator;
|
|
197
|
+
}
|
|
198
|
+
push(chunk) {
|
|
199
|
+
this.buffer += typeof chunk === 'string' ? chunk : this.decoder.decode(chunk, { stream: true });
|
|
200
|
+
return this.drain(false);
|
|
201
|
+
}
|
|
202
|
+
finish() {
|
|
203
|
+
this.buffer += this.decoder.decode();
|
|
204
|
+
return this.drain(true);
|
|
205
|
+
}
|
|
206
|
+
drain(final) {
|
|
207
|
+
const events = [];
|
|
208
|
+
let newline = this.buffer.indexOf('\n');
|
|
209
|
+
while (newline >= 0) {
|
|
210
|
+
const line = this.buffer.slice(0, newline).replace(/\r$/, '');
|
|
211
|
+
this.buffer = this.buffer.slice(newline + 1);
|
|
212
|
+
if (line.trim() !== '')
|
|
213
|
+
events.push(this.parseLine(line));
|
|
214
|
+
newline = this.buffer.indexOf('\n');
|
|
215
|
+
}
|
|
216
|
+
if (final && this.buffer.trim() !== '') {
|
|
217
|
+
const line = this.buffer.replace(/\r$/, '');
|
|
218
|
+
this.buffer = '';
|
|
219
|
+
throw new AgentProcessProtocolError('incomplete_frame', 'Worker stdout ended without a newline-delimited frame', line);
|
|
220
|
+
}
|
|
221
|
+
if (final)
|
|
222
|
+
this.buffer = '';
|
|
223
|
+
return events;
|
|
224
|
+
}
|
|
225
|
+
parseLine(line) {
|
|
226
|
+
let parsed;
|
|
227
|
+
try {
|
|
228
|
+
parsed = JSON.parse(line);
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
const code = looksLikeJson(line) ? 'invalid_json' : 'stdout_pollution';
|
|
232
|
+
throw new AgentProcessProtocolError(code, 'Worker stdout contained an invalid frame', line);
|
|
233
|
+
}
|
|
234
|
+
try {
|
|
235
|
+
return this.validator.accept(parsed);
|
|
236
|
+
}
|
|
237
|
+
catch (error) {
|
|
238
|
+
if (error instanceof AgentProcessProtocolError && error.line === undefined) {
|
|
239
|
+
throw new AgentProcessProtocolError(error.code, error.message, line);
|
|
240
|
+
}
|
|
241
|
+
throw error;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/** Incremental NDJSON decoder for worker stdin commands. */
|
|
246
|
+
export class AgentProcessCommandDecoder {
|
|
247
|
+
decoder = new TextDecoder();
|
|
248
|
+
validator = new AgentProcessCommandStreamValidator();
|
|
249
|
+
buffer = '';
|
|
250
|
+
push(chunk) {
|
|
251
|
+
this.buffer += typeof chunk === 'string' ? chunk : this.decoder.decode(chunk, { stream: true });
|
|
252
|
+
return this.drain(false);
|
|
253
|
+
}
|
|
254
|
+
finish() {
|
|
255
|
+
this.buffer += this.decoder.decode();
|
|
256
|
+
return this.drain(true);
|
|
257
|
+
}
|
|
258
|
+
drain(final) {
|
|
259
|
+
const commands = [];
|
|
260
|
+
let newline = this.buffer.indexOf('\n');
|
|
261
|
+
while (newline >= 0) {
|
|
262
|
+
const line = this.buffer.slice(0, newline).replace(/\r$/, '');
|
|
263
|
+
this.buffer = this.buffer.slice(newline + 1);
|
|
264
|
+
if (line.trim() !== '')
|
|
265
|
+
commands.push(this.parseLine(line));
|
|
266
|
+
newline = this.buffer.indexOf('\n');
|
|
267
|
+
}
|
|
268
|
+
if (final && this.buffer.trim() !== '') {
|
|
269
|
+
const line = this.buffer.replace(/\r$/, '');
|
|
270
|
+
this.buffer = '';
|
|
271
|
+
throw new AgentProcessProtocolError('incomplete_frame', 'Worker stdin ended without a newline-delimited frame', line);
|
|
272
|
+
}
|
|
273
|
+
if (final)
|
|
274
|
+
this.buffer = '';
|
|
275
|
+
return commands;
|
|
276
|
+
}
|
|
277
|
+
parseLine(line) {
|
|
278
|
+
let parsed;
|
|
279
|
+
try {
|
|
280
|
+
parsed = JSON.parse(line);
|
|
281
|
+
}
|
|
282
|
+
catch {
|
|
283
|
+
throw new AgentProcessProtocolError('invalid_json', 'Worker stdin contained invalid JSON', line);
|
|
284
|
+
}
|
|
285
|
+
try {
|
|
286
|
+
return this.validator.accept(parsed);
|
|
287
|
+
}
|
|
288
|
+
catch (error) {
|
|
289
|
+
if (error instanceof AgentProcessProtocolError && error.line === undefined) {
|
|
290
|
+
throw new AgentProcessProtocolError(error.code, error.message, line);
|
|
291
|
+
}
|
|
292
|
+
throw error;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
function parseStartCommand(value) {
|
|
297
|
+
assertAllowedKeys(value, 'start command', [
|
|
298
|
+
'command',
|
|
299
|
+
'protocolVersion',
|
|
300
|
+
'sessionId',
|
|
301
|
+
'runId',
|
|
302
|
+
'turnId',
|
|
303
|
+
'prompt',
|
|
304
|
+
'cwd',
|
|
305
|
+
'provider',
|
|
306
|
+
'conversationOwner',
|
|
307
|
+
'sessionRoot',
|
|
308
|
+
'agentBundleVersion',
|
|
309
|
+
'sandbox',
|
|
310
|
+
'mcp',
|
|
311
|
+
'options',
|
|
312
|
+
]);
|
|
313
|
+
const provider = requireRecord(value.provider, 'command.provider');
|
|
314
|
+
assertAllowedKeys(provider, 'command.provider', [
|
|
315
|
+
'providerId',
|
|
316
|
+
'model',
|
|
317
|
+
'transport',
|
|
318
|
+
'baseUrl',
|
|
319
|
+
]);
|
|
320
|
+
const transport = requireEnum(provider, 'transport', ['responses', 'chat_completions', 'codex']);
|
|
321
|
+
const conversationOwner = parseConversationOwner(value.conversationOwner);
|
|
322
|
+
const sandbox = parseSandboxPolicy(value.sandbox);
|
|
323
|
+
const mcp = requireRecord(value.mcp, 'command.mcp');
|
|
324
|
+
assertAllowedKeys(mcp, 'command.mcp', ['servers']);
|
|
325
|
+
const servers = requireArray(mcp.servers, 'mcp.servers').map((entry, index) => parseMcpServer(entry, index));
|
|
326
|
+
const options = parseStartOptions(value.options);
|
|
327
|
+
return {
|
|
328
|
+
command: 'start',
|
|
329
|
+
protocolVersion: AGENT_PROCESS_PROTOCOL_VERSION,
|
|
330
|
+
sessionId: requireNonEmptyString(value, 'sessionId'),
|
|
331
|
+
runId: requireNonEmptyString(value, 'runId'),
|
|
332
|
+
turnId: requireNonEmptyString(value, 'turnId'),
|
|
333
|
+
prompt: requireString(value, 'prompt'),
|
|
334
|
+
cwd: requireAbsolutePath(value, 'cwd'),
|
|
335
|
+
provider: {
|
|
336
|
+
providerId: requireNonEmptyString(provider, 'providerId'),
|
|
337
|
+
model: requireNonEmptyString(provider, 'model'),
|
|
338
|
+
transport,
|
|
339
|
+
...optionalStringProperty(provider, 'baseUrl'),
|
|
340
|
+
},
|
|
341
|
+
conversationOwner,
|
|
342
|
+
sessionRoot: requireAbsolutePath(value, 'sessionRoot'),
|
|
343
|
+
agentBundleVersion: requireNonEmptyString(value, 'agentBundleVersion'),
|
|
344
|
+
sandbox,
|
|
345
|
+
mcp: { servers },
|
|
346
|
+
options,
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
function parseCancelCommand(value) {
|
|
350
|
+
assertAllowedKeys(value, 'cancel command', [
|
|
351
|
+
'command',
|
|
352
|
+
'protocolVersion',
|
|
353
|
+
'sessionId',
|
|
354
|
+
'runId',
|
|
355
|
+
'reason',
|
|
356
|
+
]);
|
|
357
|
+
return {
|
|
358
|
+
command: 'cancel',
|
|
359
|
+
protocolVersion: AGENT_PROCESS_PROTOCOL_VERSION,
|
|
360
|
+
sessionId: requireNonEmptyString(value, 'sessionId'),
|
|
361
|
+
runId: requireNonEmptyString(value, 'runId'),
|
|
362
|
+
...optionalStringProperty(value, 'reason'),
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
function parseConversationOwner(value) {
|
|
366
|
+
const owner = requireRecord(value, 'conversationOwner');
|
|
367
|
+
const kind = requireEnum(owner, 'kind', ['local_session', 'openai_conversation', 'previous_response']);
|
|
368
|
+
if (kind === 'openai_conversation') {
|
|
369
|
+
assertAllowedKeys(owner, 'conversationOwner', ['kind', 'conversationId']);
|
|
370
|
+
return { kind, ...optionalStringProperty(owner, 'conversationId') };
|
|
371
|
+
}
|
|
372
|
+
if (kind === 'previous_response') {
|
|
373
|
+
assertAllowedKeys(owner, 'conversationOwner', ['kind', 'previousResponseId']);
|
|
374
|
+
return { kind, ...optionalStringProperty(owner, 'previousResponseId') };
|
|
375
|
+
}
|
|
376
|
+
assertAllowedKeys(owner, 'conversationOwner', ['kind']);
|
|
377
|
+
return { kind };
|
|
378
|
+
}
|
|
379
|
+
function parseSandboxPolicy(value) {
|
|
380
|
+
const sandbox = requireRecord(value, 'sandbox');
|
|
381
|
+
assertAllowedKeys(sandbox, 'sandbox', ['profile', 'provider', 'workspaceId']);
|
|
382
|
+
return {
|
|
383
|
+
profile: requireNonEmptyString(sandbox, 'profile'),
|
|
384
|
+
provider: requireEnum(sandbox, 'provider', ['none', 'unix_local', 'docker', 'hosted']),
|
|
385
|
+
...optionalStringProperty(sandbox, 'workspaceId'),
|
|
386
|
+
};
|
|
387
|
+
}
|
|
388
|
+
function parseMcpServer(value, index) {
|
|
389
|
+
const server = requireRecord(value, `mcp.servers[${index}]`);
|
|
390
|
+
assertAllowedKeys(server, `mcp.servers[${index}]`, [
|
|
391
|
+
'name',
|
|
392
|
+
'transport',
|
|
393
|
+
'commandRef',
|
|
394
|
+
'url',
|
|
395
|
+
'authRef',
|
|
396
|
+
'allowedTools',
|
|
397
|
+
]);
|
|
398
|
+
const allowedToolsValue = server.allowedTools;
|
|
399
|
+
const allowedTools = allowedToolsValue === undefined
|
|
400
|
+
? undefined
|
|
401
|
+
: requireStringArray(allowedToolsValue, `mcp.servers[${index}].allowedTools`);
|
|
402
|
+
return {
|
|
403
|
+
name: requireNonEmptyString(server, 'name'),
|
|
404
|
+
transport: requireEnum(server, 'transport', ['stdio', 'sse', 'streamable_http']),
|
|
405
|
+
...optionalStringProperty(server, 'commandRef'),
|
|
406
|
+
...optionalStringProperty(server, 'url'),
|
|
407
|
+
...optionalStringProperty(server, 'authRef'),
|
|
408
|
+
...(allowedTools === undefined ? {} : { allowedTools }),
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
function parseStartOptions(value) {
|
|
412
|
+
const options = requireRecord(value, 'options');
|
|
413
|
+
assertAllowedKeys(options, 'options', [
|
|
414
|
+
'maxTurns',
|
|
415
|
+
'trace',
|
|
416
|
+
'outputTypeRef',
|
|
417
|
+
'interactionAnswers',
|
|
418
|
+
'resumeFromCheckpoint',
|
|
419
|
+
'replayAfterSequence',
|
|
420
|
+
]);
|
|
421
|
+
const maxTurns = options.maxTurns === undefined ? undefined : requireInteger(options, 'maxTurns', 1);
|
|
422
|
+
const trace = options.trace === undefined ? undefined : requireBoolean(options, 'trace');
|
|
423
|
+
const outputTypeRef = options.outputTypeRef === undefined
|
|
424
|
+
? undefined
|
|
425
|
+
: requireNonEmptyString(options, 'outputTypeRef');
|
|
426
|
+
const resumeFromCheckpoint = options.resumeFromCheckpoint === undefined
|
|
427
|
+
? undefined
|
|
428
|
+
: requireBoolean(options, 'resumeFromCheckpoint');
|
|
429
|
+
const replayAfterSequence = options.replayAfterSequence === undefined
|
|
430
|
+
? undefined
|
|
431
|
+
: requireInteger(options, 'replayAfterSequence', 0);
|
|
432
|
+
let interactionAnswers;
|
|
433
|
+
if (options.interactionAnswers !== undefined) {
|
|
434
|
+
const answers = requireRecord(options.interactionAnswers, 'options.interactionAnswers');
|
|
435
|
+
assertJsonValue(answers, 'options.interactionAnswers');
|
|
436
|
+
interactionAnswers = answers;
|
|
437
|
+
}
|
|
438
|
+
return {
|
|
439
|
+
...(maxTurns === undefined ? {} : { maxTurns }),
|
|
440
|
+
...(trace === undefined ? {} : { trace }),
|
|
441
|
+
...(outputTypeRef === undefined ? {} : { outputTypeRef }),
|
|
442
|
+
...(interactionAnswers === undefined ? {} : { interactionAnswers }),
|
|
443
|
+
...(resumeFromCheckpoint === undefined
|
|
444
|
+
? {}
|
|
445
|
+
: { resumeFromCheckpoint }),
|
|
446
|
+
...(replayAfterSequence === undefined
|
|
447
|
+
? {}
|
|
448
|
+
: { replayAfterSequence }),
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
function parseBackendMetadata(value) {
|
|
452
|
+
const backend = requireRecord(value, 'event.backend');
|
|
453
|
+
assertAllowedKeys(backend, 'event.backend', [
|
|
454
|
+
'name',
|
|
455
|
+
'provider',
|
|
456
|
+
'model',
|
|
457
|
+
'requestId',
|
|
458
|
+
'responseId',
|
|
459
|
+
'rawType',
|
|
460
|
+
'metadata',
|
|
461
|
+
]);
|
|
462
|
+
const name = requireEnum(backend, 'name', ['openai', 'claude']);
|
|
463
|
+
const metadata = backend.metadata === undefined
|
|
464
|
+
? undefined
|
|
465
|
+
: requireRecord(backend.metadata, 'event.backend.metadata');
|
|
466
|
+
if (metadata !== undefined)
|
|
467
|
+
assertJsonValue(metadata, 'event.backend.metadata');
|
|
468
|
+
return {
|
|
469
|
+
name,
|
|
470
|
+
provider: requireNonEmptyString(backend, 'provider'),
|
|
471
|
+
...optionalStringProperty(backend, 'model'),
|
|
472
|
+
...optionalStringProperty(backend, 'requestId'),
|
|
473
|
+
...optionalStringProperty(backend, 'responseId'),
|
|
474
|
+
...optionalStringProperty(backend, 'rawType'),
|
|
475
|
+
...(metadata === undefined ? {} : { metadata }),
|
|
476
|
+
};
|
|
477
|
+
}
|
|
478
|
+
function parseEventPayload(type, value) {
|
|
479
|
+
const payload = requireRecord(value, `event.payload(${type})`);
|
|
480
|
+
switch (type) {
|
|
481
|
+
case 'session.started':
|
|
482
|
+
assertAllowedKeys(payload, type, ['resumed', 'conversationOwner']);
|
|
483
|
+
return {
|
|
484
|
+
resumed: requireBoolean(payload, 'resumed'),
|
|
485
|
+
conversationOwner: parseConversationOwner(payload.conversationOwner),
|
|
486
|
+
};
|
|
487
|
+
case 'capabilities':
|
|
488
|
+
assertAllowedKeys(payload, type, [
|
|
489
|
+
'tools',
|
|
490
|
+
'mcpServers',
|
|
491
|
+
'features',
|
|
492
|
+
'sandboxProvider',
|
|
493
|
+
]);
|
|
494
|
+
return {
|
|
495
|
+
tools: requireStringArray(payload.tools, 'capabilities.tools'),
|
|
496
|
+
mcpServers: requireStringArray(payload.mcpServers, 'capabilities.mcpServers'),
|
|
497
|
+
features: requireStringArray(payload.features, 'capabilities.features'),
|
|
498
|
+
sandboxProvider: requireEnum(payload, 'sandboxProvider', ['none', 'unix_local', 'docker', 'hosted']),
|
|
499
|
+
};
|
|
500
|
+
case 'assistant.delta':
|
|
501
|
+
assertAllowedKeys(payload, type, ['delta']);
|
|
502
|
+
return { delta: requireString(payload, 'delta') };
|
|
503
|
+
case 'assistant.message':
|
|
504
|
+
assertAllowedKeys(payload, type, ['text', 'itemId']);
|
|
505
|
+
return {
|
|
506
|
+
text: requireString(payload, 'text'),
|
|
507
|
+
...optionalStringProperty(payload, 'itemId'),
|
|
508
|
+
};
|
|
509
|
+
case 'tool.call': {
|
|
510
|
+
assertAllowedKeys(payload, type, [
|
|
511
|
+
'toolCallId',
|
|
512
|
+
'toolName',
|
|
513
|
+
'input',
|
|
514
|
+
'providerCallId',
|
|
515
|
+
'itemId',
|
|
516
|
+
]);
|
|
517
|
+
assertJsonValue(payload.input, 'tool.call.input');
|
|
518
|
+
return {
|
|
519
|
+
toolCallId: requireNonEmptyString(payload, 'toolCallId'),
|
|
520
|
+
toolName: requireNonEmptyString(payload, 'toolName'),
|
|
521
|
+
input: payload.input,
|
|
522
|
+
...optionalStringProperty(payload, 'providerCallId'),
|
|
523
|
+
...optionalStringProperty(payload, 'itemId'),
|
|
524
|
+
};
|
|
525
|
+
}
|
|
526
|
+
case 'tool.progress':
|
|
527
|
+
assertAllowedKeys(payload, type, ['toolCallId', 'status', 'detail']);
|
|
528
|
+
return {
|
|
529
|
+
toolCallId: requireNonEmptyString(payload, 'toolCallId'),
|
|
530
|
+
status: requireEnum(payload, 'status', ['running', 'completed', 'failed']),
|
|
531
|
+
...optionalStringProperty(payload, 'detail'),
|
|
532
|
+
};
|
|
533
|
+
case 'tool.result': {
|
|
534
|
+
assertAllowedKeys(payload, type, ['toolCallId', 'status', 'output', 'error']);
|
|
535
|
+
assertJsonValue(payload.output, 'tool.result.output');
|
|
536
|
+
return {
|
|
537
|
+
toolCallId: requireNonEmptyString(payload, 'toolCallId'),
|
|
538
|
+
status: requireEnum(payload, 'status', ['completed', 'failed']),
|
|
539
|
+
output: payload.output,
|
|
540
|
+
...(payload.error === undefined ? {} : { error: parseProcessError(payload.error) }),
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
case 'agent.changed':
|
|
544
|
+
assertAllowedKeys(payload, type, ['agentName', 'previousAgentName']);
|
|
545
|
+
return {
|
|
546
|
+
agentName: requireNonEmptyString(payload, 'agentName'),
|
|
547
|
+
...optionalStringProperty(payload, 'previousAgentName'),
|
|
548
|
+
};
|
|
549
|
+
case 'interaction.required': {
|
|
550
|
+
assertAllowedKeys(payload, type, [
|
|
551
|
+
'interactionId',
|
|
552
|
+
'kind',
|
|
553
|
+
'title',
|
|
554
|
+
'schema',
|
|
555
|
+
'toolCallId',
|
|
556
|
+
'revision',
|
|
557
|
+
]);
|
|
558
|
+
assertJsonValue(payload.schema, 'interaction.required.schema');
|
|
559
|
+
return {
|
|
560
|
+
interactionId: requireNonEmptyString(payload, 'interactionId'),
|
|
561
|
+
kind: requireEnum(payload, 'kind', [
|
|
562
|
+
'approval',
|
|
563
|
+
'choices',
|
|
564
|
+
'form',
|
|
565
|
+
'operator_reconciliation',
|
|
566
|
+
]),
|
|
567
|
+
title: requireNonEmptyString(payload, 'title'),
|
|
568
|
+
schema: payload.schema,
|
|
569
|
+
...optionalStringProperty(payload, 'toolCallId'),
|
|
570
|
+
...optionalIntegerProperty(payload, 'revision', 1),
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
case 'context.compacted':
|
|
574
|
+
assertAllowedKeys(payload, type, ['strategy', 'beforeItems', 'afterItems']);
|
|
575
|
+
return {
|
|
576
|
+
strategy: requireNonEmptyString(payload, 'strategy'),
|
|
577
|
+
...optionalIntegerProperty(payload, 'beforeItems', 0),
|
|
578
|
+
...optionalIntegerProperty(payload, 'afterItems', 0),
|
|
579
|
+
};
|
|
580
|
+
case 'usage.updated':
|
|
581
|
+
assertAllowedKeys(payload, type, ['usage', 'final']);
|
|
582
|
+
return {
|
|
583
|
+
usage: parseUsage(payload.usage),
|
|
584
|
+
final: requireBoolean(payload, 'final'),
|
|
585
|
+
};
|
|
586
|
+
case 'system.warning':
|
|
587
|
+
assertAllowedKeys(payload, type, ['code', 'message', 'recoverable']);
|
|
588
|
+
return {
|
|
589
|
+
code: requireNonEmptyString(payload, 'code'),
|
|
590
|
+
message: requireString(payload, 'message'),
|
|
591
|
+
recoverable: requireBoolean(payload, 'recoverable'),
|
|
592
|
+
};
|
|
593
|
+
case 'run.waiting_for_input':
|
|
594
|
+
assertAllowedKeys(payload, type, ['interactionId', 'checkpointRevision']);
|
|
595
|
+
return {
|
|
596
|
+
interactionId: requireNonEmptyString(payload, 'interactionId'),
|
|
597
|
+
checkpointRevision: requireInteger(payload, 'checkpointRevision', 0),
|
|
598
|
+
};
|
|
599
|
+
case 'run.completed':
|
|
600
|
+
assertAllowedKeys(payload, type, ['output', 'usage']);
|
|
601
|
+
if (payload.output !== undefined)
|
|
602
|
+
assertJsonValue(payload.output, 'run.completed.output');
|
|
603
|
+
return {
|
|
604
|
+
...(payload.output === undefined ? {} : { output: payload.output }),
|
|
605
|
+
...(payload.usage === undefined ? {} : { usage: parseUsage(payload.usage) }),
|
|
606
|
+
};
|
|
607
|
+
case 'run.failed':
|
|
608
|
+
assertAllowedKeys(payload, type, ['error', 'usage']);
|
|
609
|
+
return {
|
|
610
|
+
error: parseProcessError(payload.error),
|
|
611
|
+
...(payload.usage === undefined ? {} : { usage: parseUsage(payload.usage) }),
|
|
612
|
+
};
|
|
613
|
+
case 'run.cancelled':
|
|
614
|
+
assertAllowedKeys(payload, type, ['reason', 'checkpointRevision', 'usage']);
|
|
615
|
+
return {
|
|
616
|
+
reason: requireString(payload, 'reason'),
|
|
617
|
+
...optionalIntegerProperty(payload, 'checkpointRevision', 0),
|
|
618
|
+
...(payload.usage === undefined ? {} : { usage: parseUsage(payload.usage) }),
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
function parseUsage(value) {
|
|
623
|
+
const usage = requireRecord(value, 'usage');
|
|
624
|
+
assertAllowedKeys(usage, 'usage', [
|
|
625
|
+
'inputTokens',
|
|
626
|
+
'outputTokens',
|
|
627
|
+
'reasoningTokens',
|
|
628
|
+
'cachedInputTokens',
|
|
629
|
+
'totalTokens',
|
|
630
|
+
'costUsd',
|
|
631
|
+
]);
|
|
632
|
+
return {
|
|
633
|
+
...optionalIntegerProperty(usage, 'inputTokens', 0),
|
|
634
|
+
...optionalIntegerProperty(usage, 'outputTokens', 0),
|
|
635
|
+
...optionalIntegerProperty(usage, 'reasoningTokens', 0),
|
|
636
|
+
...optionalIntegerProperty(usage, 'cachedInputTokens', 0),
|
|
637
|
+
...optionalIntegerProperty(usage, 'totalTokens', 0),
|
|
638
|
+
...optionalNumberProperty(usage, 'costUsd', 0),
|
|
639
|
+
};
|
|
640
|
+
}
|
|
641
|
+
function parseProcessError(value) {
|
|
642
|
+
const error = requireRecord(value, 'error');
|
|
643
|
+
assertAllowedKeys(error, 'error', ['code', 'message', 'recoverable', 'details']);
|
|
644
|
+
const code = requireString(error, 'code');
|
|
645
|
+
if (!ERROR_CODES.has(code)) {
|
|
646
|
+
throw protocolError('invalid_shape', `Unknown agent process error code: ${code}`);
|
|
647
|
+
}
|
|
648
|
+
const details = error.details === undefined ? undefined : requireRecord(error.details, 'error.details');
|
|
649
|
+
if (details !== undefined)
|
|
650
|
+
assertJsonValue(details, 'error.details');
|
|
651
|
+
return {
|
|
652
|
+
code: code,
|
|
653
|
+
message: requireString(error, 'message'),
|
|
654
|
+
recoverable: requireBoolean(error, 'recoverable'),
|
|
655
|
+
...(details === undefined ? {} : { details }),
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
function requireProtocolVersion(value) {
|
|
659
|
+
if (value.protocolVersion !== AGENT_PROCESS_PROTOCOL_VERSION) {
|
|
660
|
+
throw protocolError('unsupported_version', `Unsupported agent process protocol version: ${String(value.protocolVersion)}`);
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
function requireRecord(value, path) {
|
|
664
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
|
|
665
|
+
throw protocolError('invalid_shape', `${path} must be an object`);
|
|
666
|
+
}
|
|
667
|
+
return value;
|
|
668
|
+
}
|
|
669
|
+
function requireArray(value, path) {
|
|
670
|
+
if (!Array.isArray(value)) {
|
|
671
|
+
throw protocolError('invalid_shape', `${path} must be an array`);
|
|
672
|
+
}
|
|
673
|
+
return value;
|
|
674
|
+
}
|
|
675
|
+
function requireString(value, key) {
|
|
676
|
+
const current = value[key];
|
|
677
|
+
if (typeof current !== 'string') {
|
|
678
|
+
throw protocolError('invalid_shape', `${key} must be a string`);
|
|
679
|
+
}
|
|
680
|
+
return current;
|
|
681
|
+
}
|
|
682
|
+
function requireNonEmptyString(value, key) {
|
|
683
|
+
const current = requireString(value, key);
|
|
684
|
+
if (current.trim() === '') {
|
|
685
|
+
throw protocolError('invalid_shape', `${key} must not be empty`);
|
|
686
|
+
}
|
|
687
|
+
return current;
|
|
688
|
+
}
|
|
689
|
+
function requireBoolean(value, key) {
|
|
690
|
+
const current = value[key];
|
|
691
|
+
if (typeof current !== 'boolean') {
|
|
692
|
+
throw protocolError('invalid_shape', `${key} must be a boolean`);
|
|
693
|
+
}
|
|
694
|
+
return current;
|
|
695
|
+
}
|
|
696
|
+
function requireInteger(value, key, minimum) {
|
|
697
|
+
const current = value[key];
|
|
698
|
+
if (!Number.isInteger(current) || current < minimum) {
|
|
699
|
+
throw protocolError('invalid_shape', `${key} must be an integer >= ${minimum}`);
|
|
700
|
+
}
|
|
701
|
+
return current;
|
|
702
|
+
}
|
|
703
|
+
function requireEnum(value, key, allowed) {
|
|
704
|
+
const current = requireString(value, key);
|
|
705
|
+
if (!allowed.includes(current)) {
|
|
706
|
+
throw protocolError('invalid_shape', `${key} must be one of: ${allowed.join(', ')}`);
|
|
707
|
+
}
|
|
708
|
+
return current;
|
|
709
|
+
}
|
|
710
|
+
function requireAbsolutePath(value, key) {
|
|
711
|
+
const current = requireNonEmptyString(value, key);
|
|
712
|
+
if (!current.startsWith('/')) {
|
|
713
|
+
throw protocolError('invalid_shape', `${key} must be an absolute path`);
|
|
714
|
+
}
|
|
715
|
+
return current;
|
|
716
|
+
}
|
|
717
|
+
function requireStringArray(value, path) {
|
|
718
|
+
if (!Array.isArray(value) || !value.every((entry) => typeof entry === 'string')) {
|
|
719
|
+
throw protocolError('invalid_shape', `${path} must be a string array`);
|
|
720
|
+
}
|
|
721
|
+
return value;
|
|
722
|
+
}
|
|
723
|
+
function optionalStringProperty(value, key) {
|
|
724
|
+
const current = value[key];
|
|
725
|
+
if (current === undefined)
|
|
726
|
+
return {};
|
|
727
|
+
if (typeof current !== 'string') {
|
|
728
|
+
throw protocolError('invalid_shape', `${key} must be a string when provided`);
|
|
729
|
+
}
|
|
730
|
+
return { [key]: current };
|
|
731
|
+
}
|
|
732
|
+
function optionalIntegerProperty(value, key, minimum) {
|
|
733
|
+
if (value[key] === undefined)
|
|
734
|
+
return {};
|
|
735
|
+
return { [key]: requireInteger(value, key, minimum) };
|
|
736
|
+
}
|
|
737
|
+
function optionalNumberProperty(value, key, minimum) {
|
|
738
|
+
const current = value[key];
|
|
739
|
+
if (current === undefined)
|
|
740
|
+
return {};
|
|
741
|
+
if (typeof current !== 'number' || !Number.isFinite(current) || current < minimum) {
|
|
742
|
+
throw protocolError('invalid_shape', `${key} must be a number >= ${minimum}`);
|
|
743
|
+
}
|
|
744
|
+
return { [key]: current };
|
|
745
|
+
}
|
|
746
|
+
function assertJsonValue(value, path) {
|
|
747
|
+
if (value === null ||
|
|
748
|
+
typeof value === 'string' ||
|
|
749
|
+
typeof value === 'boolean' ||
|
|
750
|
+
(typeof value === 'number' && Number.isFinite(value))) {
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
if (Array.isArray(value)) {
|
|
754
|
+
value.forEach((entry, index) => assertJsonValue(entry, `${path}[${index}]`));
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
if (typeof value === 'object') {
|
|
758
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
759
|
+
assertJsonValue(entry, `${path}.${key}`);
|
|
760
|
+
}
|
|
761
|
+
return;
|
|
762
|
+
}
|
|
763
|
+
throw protocolError('invalid_shape', `${path} must be JSON-serializable`);
|
|
764
|
+
}
|
|
765
|
+
function assertAllowedKeys(value, path, allowed) {
|
|
766
|
+
const allowedSet = new Set(allowed);
|
|
767
|
+
const unexpected = Object.keys(value).filter((key) => !allowedSet.has(key));
|
|
768
|
+
if (unexpected.length > 0) {
|
|
769
|
+
throw protocolError('invalid_shape', `${path} contains unsupported fields: ${unexpected.join(', ')}`);
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
function looksLikeJson(line) {
|
|
773
|
+
const trimmed = line.trimStart();
|
|
774
|
+
return trimmed.startsWith('{') || trimmed.startsWith('[');
|
|
775
|
+
}
|
|
776
|
+
function protocolError(code, message) {
|
|
777
|
+
return new AgentProcessProtocolError(code, message);
|
|
778
|
+
}
|
|
779
|
+
//# sourceMappingURL=processProtocol.js.map
|