@a5c-ai/agent-platform 5.0.1-staging.b436b3b3e611
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/README.md +53 -0
- package/dist/anycli/cache.d.ts +45 -0
- package/dist/anycli/cache.d.ts.map +1 -0
- package/dist/anycli/cache.js +118 -0
- package/dist/anycli/index.d.ts +10 -0
- package/dist/anycli/index.d.ts.map +1 -0
- package/dist/anycli/index.js +25 -0
- package/dist/anycli/types.d.ts +32 -0
- package/dist/anycli/types.d.ts.map +1 -0
- package/dist/anycli/types.js +9 -0
- package/dist/api/breakpoints.d.ts +93 -0
- package/dist/api/breakpoints.d.ts.map +1 -0
- package/dist/api/breakpoints.js +334 -0
- package/dist/api/effects.d.ts +14 -0
- package/dist/api/effects.d.ts.map +1 -0
- package/dist/api/effects.js +306 -0
- package/dist/api/effectsTypes.d.ts +79 -0
- package/dist/api/effectsTypes.d.ts.map +1 -0
- package/dist/api/effectsTypes.js +6 -0
- package/dist/api/eventStream.d.ts +34 -0
- package/dist/api/eventStream.d.ts.map +1 -0
- package/dist/api/eventStream.js +126 -0
- package/dist/api/index.d.ts +10 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +27 -0
- package/dist/api/runs.d.ts +85 -0
- package/dist/api/runs.d.ts.map +1 -0
- package/dist/api/runs.js +247 -0
- package/dist/api/utils.d.ts +28 -0
- package/dist/api/utils.d.ts.map +1 -0
- package/dist/api/utils.js +74 -0
- package/dist/breakpoints/approvalChains.d.ts +68 -0
- package/dist/breakpoints/approvalChains.d.ts.map +1 -0
- package/dist/breakpoints/approvalChains.js +111 -0
- package/dist/breakpoints/delegation.d.ts +42 -0
- package/dist/breakpoints/delegation.d.ts.map +1 -0
- package/dist/breakpoints/delegation.js +199 -0
- package/dist/breakpoints/delegationTypes.d.ts +46 -0
- package/dist/breakpoints/delegationTypes.d.ts.map +1 -0
- package/dist/breakpoints/delegationTypes.js +10 -0
- package/dist/breakpoints/postures.d.ts +28 -0
- package/dist/breakpoints/postures.d.ts.map +1 -0
- package/dist/breakpoints/postures.js +100 -0
- package/dist/cli/amuxEventsFormatter.d.ts +26 -0
- package/dist/cli/amuxEventsFormatter.d.ts.map +1 -0
- package/dist/cli/amuxEventsFormatter.js +86 -0
- package/dist/cli/args/argFlags.d.ts +6 -0
- package/dist/cli/args/argFlags.d.ts.map +1 -0
- package/dist/cli/args/argFlags.js +72 -0
- package/dist/cli/args/argPositionals.d.ts +3 -0
- package/dist/cli/args/argPositionals.d.ts.map +1 -0
- package/dist/cli/args/argPositionals.js +18 -0
- package/dist/cli/args/index.d.ts +4 -0
- package/dist/cli/args/index.d.ts.map +1 -0
- package/dist/cli/args/index.js +75 -0
- package/dist/cli/args/types.d.ts +13 -0
- package/dist/cli/args/types.d.ts.map +1 -0
- package/dist/cli/args/types.js +2 -0
- package/dist/cli/commands/daemon.d.ts +31 -0
- package/dist/cli/commands/daemon.d.ts.map +1 -0
- package/dist/cli/commands/daemon.js +156 -0
- package/dist/cli/commands/harness/createRun.d.ts +3 -0
- package/dist/cli/commands/harness/createRun.d.ts.map +1 -0
- package/dist/cli/commands/harness/createRun.js +8 -0
- package/dist/cli/commands/harness/resumeRun.d.ts +20 -0
- package/dist/cli/commands/harness/resumeRun.d.ts.map +1 -0
- package/dist/cli/commands/harness/resumeRun.js +341 -0
- package/dist/cli/commands/jsonlInteractive.d.ts +35 -0
- package/dist/cli/commands/jsonlInteractive.d.ts.map +1 -0
- package/dist/cli/commands/jsonlInteractive.js +302 -0
- package/dist/cli/commands/mcpServe.d.ts +18 -0
- package/dist/cli/commands/mcpServe.d.ts.map +1 -0
- package/dist/cli/commands/mcpServe.js +59 -0
- package/dist/cli/commands/session/history.d.ts +14 -0
- package/dist/cli/commands/session/history.d.ts.map +1 -0
- package/dist/cli/commands/session/history.js +100 -0
- package/dist/cli/commands/tui.d.ts +23 -0
- package/dist/cli/commands/tui.d.ts.map +1 -0
- package/dist/cli/commands/tui.js +183 -0
- package/dist/cli/dispatch.d.ts +4 -0
- package/dist/cli/dispatch.d.ts.map +1 -0
- package/dist/cli/dispatch.js +332 -0
- package/dist/cli/main.d.ts +7 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +41 -0
- package/dist/cli/program.d.ts +7 -0
- package/dist/cli/program.d.ts.map +1 -0
- package/dist/cli/program.js +8 -0
- package/dist/cli/ui.d.ts +9 -0
- package/dist/cli/ui.d.ts.map +1 -0
- package/dist/cli/ui.js +125 -0
- package/dist/compression/compaction.d.ts +82 -0
- package/dist/compression/compaction.d.ts.map +1 -0
- package/dist/compression/compaction.js +310 -0
- package/dist/cost/claudeCodeParser.d.ts +81 -0
- package/dist/cost/claudeCodeParser.d.ts.map +1 -0
- package/dist/cost/claudeCodeParser.js +232 -0
- package/dist/cost/collector.d.ts +42 -0
- package/dist/cost/collector.d.ts.map +1 -0
- package/dist/cost/collector.js +105 -0
- package/dist/cost/effectCost.d.ts +23 -0
- package/dist/cost/effectCost.d.ts.map +1 -0
- package/dist/cost/effectCost.js +26 -0
- package/dist/cost/index.d.ts +7 -0
- package/dist/cost/index.d.ts.map +1 -0
- package/dist/cost/index.js +28 -0
- package/dist/cost/journal.d.ts +40 -0
- package/dist/cost/journal.d.ts.map +1 -0
- package/dist/cost/journal.js +137 -0
- package/dist/cost/types.d.ts +164 -0
- package/dist/cost/types.d.ts.map +1 -0
- package/dist/cost/types.js +228 -0
- package/dist/daemon/automationExecutor.d.ts +16 -0
- package/dist/daemon/automationExecutor.d.ts.map +1 -0
- package/dist/daemon/automationExecutor.js +222 -0
- package/dist/daemon/config.d.ts +8 -0
- package/dist/daemon/config.d.ts.map +1 -0
- package/dist/daemon/config.js +209 -0
- package/dist/daemon/daemonLog.d.ts +13 -0
- package/dist/daemon/daemonLog.d.ts.map +1 -0
- package/dist/daemon/daemonLog.js +64 -0
- package/dist/daemon/fileWatcher.d.ts +9 -0
- package/dist/daemon/fileWatcher.d.ts.map +1 -0
- package/dist/daemon/fileWatcher.js +141 -0
- package/dist/daemon/index.d.ts +7 -0
- package/dist/daemon/index.d.ts.map +1 -0
- package/dist/daemon/index.js +21 -0
- package/dist/daemon/lifecycle.d.ts +12 -0
- package/dist/daemon/lifecycle.d.ts.map +1 -0
- package/dist/daemon/lifecycle.js +257 -0
- package/dist/daemon/loop.d.ts +21 -0
- package/dist/daemon/loop.d.ts.map +1 -0
- package/dist/daemon/loop.js +196 -0
- package/dist/daemon/timerScheduler.d.ts +13 -0
- package/dist/daemon/timerScheduler.d.ts.map +1 -0
- package/dist/daemon/timerScheduler.js +122 -0
- package/dist/daemon/types.d.ts +93 -0
- package/dist/daemon/types.d.ts.map +1 -0
- package/dist/daemon/types.js +25 -0
- package/dist/daemon/webhookListener.d.ts +6 -0
- package/dist/daemon/webhookListener.d.ts.map +1 -0
- package/dist/daemon/webhookListener.js +110 -0
- package/dist/governance/authority.d.ts +68 -0
- package/dist/governance/authority.d.ts.map +1 -0
- package/dist/governance/authority.js +136 -0
- package/dist/governance/bridge.d.ts +17 -0
- package/dist/governance/bridge.d.ts.map +1 -0
- package/dist/governance/bridge.js +46 -0
- package/dist/governance/builtins.d.ts +25 -0
- package/dist/governance/builtins.d.ts.map +1 -0
- package/dist/governance/builtins.js +67 -0
- package/dist/governance/categories.d.ts +58 -0
- package/dist/governance/categories.d.ts.map +1 -0
- package/dist/governance/categories.js +120 -0
- package/dist/governance/decisionTrail.d.ts +60 -0
- package/dist/governance/decisionTrail.d.ts.map +1 -0
- package/dist/governance/decisionTrail.js +68 -0
- package/dist/governance/engine.d.ts +20 -0
- package/dist/governance/engine.d.ts.map +1 -0
- package/dist/governance/engine.js +124 -0
- package/dist/governance/index.d.ts +20 -0
- package/dist/governance/index.d.ts.map +1 -0
- package/dist/governance/index.js +75 -0
- package/dist/governance/logging.d.ts +18 -0
- package/dist/governance/logging.d.ts.map +1 -0
- package/dist/governance/logging.js +83 -0
- package/dist/governance/mandate.d.ts +83 -0
- package/dist/governance/mandate.d.ts.map +1 -0
- package/dist/governance/mandate.js +180 -0
- package/dist/governance/permissionEvents.d.ts +51 -0
- package/dist/governance/permissionEvents.d.ts.map +1 -0
- package/dist/governance/permissionEvents.js +52 -0
- package/dist/governance/permissionPropagation.d.ts +18 -0
- package/dist/governance/permissionPropagation.d.ts.map +1 -0
- package/dist/governance/permissionPropagation.js +58 -0
- package/dist/governance/postureBridge.d.ts +17 -0
- package/dist/governance/postureBridge.d.ts.map +1 -0
- package/dist/governance/postureBridge.js +117 -0
- package/dist/governance/sandboxBridge.d.ts +49 -0
- package/dist/governance/sandboxBridge.d.ts.map +1 -0
- package/dist/governance/sandboxBridge.js +77 -0
- package/dist/governance/sandboxPolicy.d.ts +51 -0
- package/dist/governance/sandboxPolicy.d.ts.map +1 -0
- package/dist/governance/sandboxPolicy.js +177 -0
- package/dist/governance/types.d.ts +3 -0
- package/dist/governance/types.d.ts.map +1 -0
- package/dist/governance/types.js +5 -0
- package/dist/harness/amux/amuxBridge.d.ts +71 -0
- package/dist/harness/amux/amuxBridge.d.ts.map +1 -0
- package/dist/harness/amux/amuxBridge.js +117 -0
- package/dist/harness/amux/amuxClientFactory.d.ts +29 -0
- package/dist/harness/amux/amuxClientFactory.d.ts.map +1 -0
- package/dist/harness/amux/amuxClientFactory.js +90 -0
- package/dist/harness/amux/amuxEventEmitter.d.ts +51 -0
- package/dist/harness/amux/amuxEventEmitter.d.ts.map +1 -0
- package/dist/harness/amux/amuxEventEmitter.js +143 -0
- package/dist/harness/amux/amuxEventMapper.d.ts +58 -0
- package/dist/harness/amux/amuxEventMapper.d.ts.map +1 -0
- package/dist/harness/amux/amuxEventMapper.js +92 -0
- package/dist/harness/amux/amuxHarnessMap.d.ts +25 -0
- package/dist/harness/amux/amuxHarnessMap.d.ts.map +1 -0
- package/dist/harness/amux/amuxHarnessMap.js +55 -0
- package/dist/harness/amux/amuxStdinReader.d.ts +45 -0
- package/dist/harness/amux/amuxStdinReader.d.ts.map +1 -0
- package/dist/harness/amux/amuxStdinReader.js +106 -0
- package/dist/harness/amux/amuxTypes.d.ts +122 -0
- package/dist/harness/amux/amuxTypes.d.ts.map +1 -0
- package/dist/harness/amux/amuxTypes.js +11 -0
- package/dist/harness/amux/index.d.ts +17 -0
- package/dist/harness/amux/index.d.ts.map +1 -0
- package/dist/harness/amux/index.js +34 -0
- package/dist/harness/backgroundTracker.d.ts +64 -0
- package/dist/harness/backgroundTracker.d.ts.map +1 -0
- package/dist/harness/backgroundTracker.js +107 -0
- package/dist/harness/builtInHarness.d.ts +3 -0
- package/dist/harness/builtInHarness.d.ts.map +1 -0
- package/dist/harness/builtInHarness.js +18 -0
- package/dist/harness/capabilityRouter.d.ts +76 -0
- package/dist/harness/capabilityRouter.d.ts.map +1 -0
- package/dist/harness/capabilityRouter.js +176 -0
- package/dist/harness/fallbackChains.d.ts +42 -0
- package/dist/harness/fallbackChains.d.ts.map +1 -0
- package/dist/harness/fallbackChains.js +69 -0
- package/dist/harness/hostContract.d.ts +63 -0
- package/dist/harness/hostContract.d.ts.map +1 -0
- package/dist/harness/hostContract.js +136 -0
- package/dist/harness/index.d.ts +10 -0
- package/dist/harness/index.d.ts.map +1 -0
- package/dist/harness/index.js +66 -0
- package/dist/harness/internal/createRun/askUserQuestion.d.ts +11 -0
- package/dist/harness/internal/createRun/askUserQuestion.d.ts.map +1 -0
- package/dist/harness/internal/createRun/askUserQuestion.js +162 -0
- package/dist/harness/internal/createRun/index.d.ts +25 -0
- package/dist/harness/internal/createRun/index.d.ts.map +1 -0
- package/dist/harness/internal/createRun/index.js +137 -0
- package/dist/harness/internal/createRun/orchestration/constants.d.ts +7 -0
- package/dist/harness/internal/createRun/orchestration/constants.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/constants.js +13 -0
- package/dist/harness/internal/createRun/orchestration/effects.d.ts +43 -0
- package/dist/harness/internal/createRun/orchestration/effects.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/effects.js +490 -0
- package/dist/harness/internal/createRun/orchestration/effectsHelpers.d.ts +20 -0
- package/dist/harness/internal/createRun/orchestration/effectsHelpers.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/effectsHelpers.js +79 -0
- package/dist/harness/internal/createRun/orchestration/externalPhase.d.ts +3 -0
- package/dist/harness/internal/createRun/orchestration/externalPhase.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/externalPhase.js +319 -0
- package/dist/harness/internal/createRun/orchestration/externalPhaseHelpers.d.ts +16 -0
- package/dist/harness/internal/createRun/orchestration/externalPhaseHelpers.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/externalPhaseHelpers.js +104 -0
- package/dist/harness/internal/createRun/orchestration/index.d.ts +14 -0
- package/dist/harness/internal/createRun/orchestration/index.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/index.js +36 -0
- package/dist/harness/internal/createRun/orchestration/internalPhase.d.ts +3 -0
- package/dist/harness/internal/createRun/orchestration/internalPhase.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/internalPhase.js +464 -0
- package/dist/harness/internal/createRun/orchestration/internalTools.d.ts +26 -0
- package/dist/harness/internal/createRun/orchestration/internalTools.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/internalTools.js +262 -0
- package/dist/harness/internal/createRun/orchestration/internalToolsHelpers.d.ts +17 -0
- package/dist/harness/internal/createRun/orchestration/internalToolsHelpers.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/internalToolsHelpers.js +23 -0
- package/dist/harness/internal/createRun/orchestration/taskResult.d.ts +10 -0
- package/dist/harness/internal/createRun/orchestration/taskResult.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/taskResult.js +67 -0
- package/dist/harness/internal/createRun/orchestration/types.d.ts +46 -0
- package/dist/harness/internal/createRun/orchestration/types.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/types.js +2 -0
- package/dist/harness/internal/createRun/orchestration/verbose.d.ts +7 -0
- package/dist/harness/internal/createRun/orchestration/verbose.d.ts.map +1 -0
- package/dist/harness/internal/createRun/orchestration/verbose.js +240 -0
- package/dist/harness/internal/createRun/output.d.ts +38 -0
- package/dist/harness/internal/createRun/output.d.ts.map +1 -0
- package/dist/harness/internal/createRun/output.js +415 -0
- package/dist/harness/internal/createRun/pi.d.ts +34 -0
- package/dist/harness/internal/createRun/pi.d.ts.map +1 -0
- package/dist/harness/internal/createRun/pi.js +216 -0
- package/dist/harness/internal/createRun/planProcess/agentOutput.d.ts +5 -0
- package/dist/harness/internal/createRun/planProcess/agentOutput.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/agentOutput.js +113 -0
- package/dist/harness/internal/createRun/planProcess/delegation.d.ts +23 -0
- package/dist/harness/internal/createRun/planProcess/delegation.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/delegation.js +176 -0
- package/dist/harness/internal/createRun/planProcess/external.d.ts +14 -0
- package/dist/harness/internal/createRun/planProcess/external.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/external.js +139 -0
- package/dist/harness/internal/createRun/planProcess/index.d.ts +12 -0
- package/dist/harness/internal/createRun/planProcess/index.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/index.js +24 -0
- package/dist/harness/internal/createRun/planProcess/paths.d.ts +7 -0
- package/dist/harness/internal/createRun/planProcess/paths.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/paths.js +98 -0
- package/dist/harness/internal/createRun/planProcess/phase.d.ts +6 -0
- package/dist/harness/internal/createRun/planProcess/phase.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/phase.js +361 -0
- package/dist/harness/internal/createRun/planProcess/phaseHelpers.d.ts +37 -0
- package/dist/harness/internal/createRun/planProcess/phaseHelpers.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/phaseHelpers.js +159 -0
- package/dist/harness/internal/createRun/planProcess/phaseTypes.d.ts +25 -0
- package/dist/harness/internal/createRun/planProcess/phaseTypes.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/phaseTypes.js +6 -0
- package/dist/harness/internal/createRun/planProcess/prompts.d.ts +20 -0
- package/dist/harness/internal/createRun/planProcess/prompts.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/prompts.js +208 -0
- package/dist/harness/internal/createRun/planProcess/recovery.d.ts +18 -0
- package/dist/harness/internal/createRun/planProcess/recovery.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/recovery.js +188 -0
- package/dist/harness/internal/createRun/planProcess/recovery.test.d.ts +2 -0
- package/dist/harness/internal/createRun/planProcess/recovery.test.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/recovery.test.js +68 -0
- package/dist/harness/internal/createRun/planProcess/runState.d.ts +40 -0
- package/dist/harness/internal/createRun/planProcess/runState.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/runState.js +179 -0
- package/dist/harness/internal/createRun/planProcess/understandIntent.d.ts +22 -0
- package/dist/harness/internal/createRun/planProcess/understandIntent.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/understandIntent.js +65 -0
- package/dist/harness/internal/createRun/planProcess/validation.d.ts +2 -0
- package/dist/harness/internal/createRun/planProcess/validation.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/validation.js +212 -0
- package/dist/harness/internal/createRun/planProcess/validationSource.d.ts +11 -0
- package/dist/harness/internal/createRun/planProcess/validationSource.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/validationSource.js +328 -0
- package/dist/harness/internal/createRun/planProcess/validationText.d.ts +3 -0
- package/dist/harness/internal/createRun/planProcess/validationText.d.ts.map +1 -0
- package/dist/harness/internal/createRun/planProcess/validationText.js +145 -0
- package/dist/harness/internal/createRun/prompts.d.ts +49 -0
- package/dist/harness/internal/createRun/prompts.d.ts.map +1 -0
- package/dist/harness/internal/createRun/prompts.js +307 -0
- package/dist/harness/internal/createRun/resumeState.d.ts +28 -0
- package/dist/harness/internal/createRun/resumeState.d.ts.map +1 -0
- package/dist/harness/internal/createRun/resumeState.js +133 -0
- package/dist/harness/internal/createRun/utils.d.ts +182 -0
- package/dist/harness/internal/createRun/utils.d.ts.map +1 -0
- package/dist/harness/internal/createRun/utils.js +133 -0
- package/dist/harness/internal.d.ts +13 -0
- package/dist/harness/internal.d.ts.map +1 -0
- package/dist/harness/internal.js +149 -0
- package/dist/harness/invoker/launch.d.ts +20 -0
- package/dist/harness/invoker/launch.d.ts.map +1 -0
- package/dist/harness/invoker/launch.js +23 -0
- package/dist/harness/invoker/processControl.d.ts +11 -0
- package/dist/harness/invoker/processControl.d.ts.map +1 -0
- package/dist/harness/invoker/processControl.js +50 -0
- package/dist/harness/invoker.d.ts +43 -0
- package/dist/harness/invoker.d.ts.map +1 -0
- package/dist/harness/invoker.js +210 -0
- package/dist/harness/modeSelector.d.ts +50 -0
- package/dist/harness/modeSelector.d.ts.map +1 -0
- package/dist/harness/modeSelector.js +124 -0
- package/dist/harness/modelSelection.d.ts +37 -0
- package/dist/harness/modelSelection.d.ts.map +1 -0
- package/dist/harness/modelSelection.js +81 -0
- package/dist/harness/operatorCommands.d.ts +38 -0
- package/dist/harness/operatorCommands.d.ts.map +1 -0
- package/dist/harness/operatorCommands.js +118 -0
- package/dist/harness/piSecureSandbox.d.ts +8 -0
- package/dist/harness/piSecureSandbox.d.ts.map +1 -0
- package/dist/harness/piSecureSandbox.js +366 -0
- package/dist/harness/piSecureSandboxTypes.d.ts +51 -0
- package/dist/harness/piSecureSandboxTypes.d.ts.map +1 -0
- package/dist/harness/piSecureSandboxTypes.js +6 -0
- package/dist/harness/piWrapper/compaction.d.ts +13 -0
- package/dist/harness/piWrapper/compaction.d.ts.map +1 -0
- package/dist/harness/piWrapper/compaction.js +38 -0
- package/dist/harness/piWrapper/instructionPrompts.d.ts +2 -0
- package/dist/harness/piWrapper/instructionPrompts.d.ts.map +1 -0
- package/dist/harness/piWrapper/instructionPrompts.js +97 -0
- package/dist/harness/piWrapper/moduleSupport.d.ts +77 -0
- package/dist/harness/piWrapper/moduleSupport.d.ts.map +1 -0
- package/dist/harness/piWrapper/moduleSupport.js +204 -0
- package/dist/harness/piWrapper.d.ts +80 -0
- package/dist/harness/piWrapper.d.ts.map +1 -0
- package/dist/harness/piWrapper.js +389 -0
- package/dist/harness/piWrapper.test.d.ts +2 -0
- package/dist/harness/piWrapper.test.d.ts.map +1 -0
- package/dist/harness/piWrapper.test.js +193 -0
- package/dist/harness/planMode.d.ts +68 -0
- package/dist/harness/planMode.d.ts.map +1 -0
- package/dist/harness/planMode.js +145 -0
- package/dist/harness/selectionPolicies.d.ts +29 -0
- package/dist/harness/selectionPolicies.d.ts.map +1 -0
- package/dist/harness/selectionPolicies.js +165 -0
- package/dist/harness/types.d.ts +266 -0
- package/dist/harness/types.d.ts.map +1 -0
- package/dist/harness/types.js +34 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +52 -0
- package/dist/interaction/askUserQuestion/core.d.ts +8 -0
- package/dist/interaction/askUserQuestion/core.d.ts.map +1 -0
- package/dist/interaction/askUserQuestion/core.js +112 -0
- package/dist/interaction/askUserQuestion/terminal.d.ts +15 -0
- package/dist/interaction/askUserQuestion/terminal.d.ts.map +1 -0
- package/dist/interaction/askUserQuestion/terminal.js +128 -0
- package/dist/interaction/askUserQuestion.d.ts +10 -0
- package/dist/interaction/askUserQuestion.d.ts.map +1 -0
- package/dist/interaction/askUserQuestion.js +295 -0
- package/dist/interaction/askUserQuestionTypes.d.ts +31 -0
- package/dist/interaction/askUserQuestionTypes.d.ts.map +1 -0
- package/dist/interaction/askUserQuestionTypes.js +6 -0
- package/dist/interaction/index.d.ts +4 -0
- package/dist/interaction/index.d.ts.map +1 -0
- package/dist/interaction/index.js +20 -0
- package/dist/interaction/interactionRouter.d.ts +25 -0
- package/dist/interaction/interactionRouter.d.ts.map +1 -0
- package/dist/interaction/interactionRouter.js +55 -0
- package/dist/mcp/channels/allowlist.d.ts +19 -0
- package/dist/mcp/channels/allowlist.d.ts.map +1 -0
- package/dist/mcp/channels/allowlist.js +140 -0
- package/dist/mcp/channels/channelManager.d.ts +64 -0
- package/dist/mcp/channels/channelManager.d.ts.map +1 -0
- package/dist/mcp/channels/channelManager.js +137 -0
- package/dist/mcp/channels/inboundQueue.d.ts +47 -0
- package/dist/mcp/channels/inboundQueue.d.ts.map +1 -0
- package/dist/mcp/channels/inboundQueue.js +96 -0
- package/dist/mcp/channels/index.d.ts +17 -0
- package/dist/mcp/channels/index.d.ts.map +1 -0
- package/dist/mcp/channels/index.js +39 -0
- package/dist/mcp/channels/outbound.d.ts +33 -0
- package/dist/mcp/channels/outbound.d.ts.map +1 -0
- package/dist/mcp/channels/outbound.js +94 -0
- package/dist/mcp/channels/permissionRelay.d.ts +62 -0
- package/dist/mcp/channels/permissionRelay.d.ts.map +1 -0
- package/dist/mcp/channels/permissionRelay.js +159 -0
- package/dist/mcp/channels/types.d.ts +135 -0
- package/dist/mcp/channels/types.d.ts.map +1 -0
- package/dist/mcp/channels/types.js +16 -0
- package/dist/mcp/client/config.d.ts +28 -0
- package/dist/mcp/client/config.d.ts.map +1 -0
- package/dist/mcp/client/config.js +142 -0
- package/dist/mcp/client/executor.d.ts +30 -0
- package/dist/mcp/client/executor.d.ts.map +1 -0
- package/dist/mcp/client/executor.js +60 -0
- package/dist/mcp/client/index.d.ts +12 -0
- package/dist/mcp/client/index.d.ts.map +1 -0
- package/dist/mcp/client/index.js +27 -0
- package/dist/mcp/client/manager.d.ts +74 -0
- package/dist/mcp/client/manager.d.ts.map +1 -0
- package/dist/mcp/client/manager.js +214 -0
- package/dist/mcp/client/toolRegistry.d.ts +50 -0
- package/dist/mcp/client/toolRegistry.d.ts.map +1 -0
- package/dist/mcp/client/toolRegistry.js +118 -0
- package/dist/mcp/client/types.d.ts +96 -0
- package/dist/mcp/client/types.d.ts.map +1 -0
- package/dist/mcp/client/types.js +15 -0
- package/dist/mcp/transport/index.d.ts +9 -0
- package/dist/mcp/transport/index.d.ts.map +1 -0
- package/dist/mcp/transport/index.js +13 -0
- package/dist/mcp/transport/session.d.ts +18 -0
- package/dist/mcp/transport/session.d.ts.map +1 -0
- package/dist/mcp/transport/session.js +78 -0
- package/dist/mcp/transport/types.d.ts +19 -0
- package/dist/mcp/transport/types.d.ts.map +1 -0
- package/dist/mcp/transport/types.js +7 -0
- package/dist/mcp/transport/websocket.d.ts +41 -0
- package/dist/mcp/transport/websocket.d.ts.map +1 -0
- package/dist/mcp/transport/websocket.js +271 -0
- package/dist/observability/health.d.ts +19 -0
- package/dist/observability/health.d.ts.map +1 -0
- package/dist/observability/health.js +129 -0
- package/dist/observability/index.d.ts +7 -0
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +22 -0
- package/dist/observability/runStatus.d.ts +44 -0
- package/dist/observability/runStatus.d.ts.map +1 -0
- package/dist/observability/runStatus.js +169 -0
- package/dist/observability/timeline.d.ts +11 -0
- package/dist/observability/timeline.d.ts.map +1 -0
- package/dist/observability/timeline.js +176 -0
- package/dist/observability/types.d.ts +62 -0
- package/dist/observability/types.d.ts.map +1 -0
- package/dist/observability/types.js +8 -0
- package/dist/observability/webhooks.d.ts +68 -0
- package/dist/observability/webhooks.d.ts.map +1 -0
- package/dist/observability/webhooks.js +132 -0
- package/dist/prompts/commandTemplates.d.ts +3 -0
- package/dist/prompts/commandTemplates.d.ts.map +1 -0
- package/dist/prompts/commandTemplates.js +238 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +28 -0
- package/dist/seams/contract.d.ts +55 -0
- package/dist/seams/contract.d.ts.map +1 -0
- package/dist/seams/contract.js +120 -0
- package/dist/seams/contract.test.d.ts +2 -0
- package/dist/seams/contract.test.d.ts.map +1 -0
- package/dist/seams/contract.test.js +96 -0
- package/dist/seams/index.d.ts +3 -0
- package/dist/seams/index.d.ts.map +1 -0
- package/dist/seams/index.js +8 -0
- package/dist/session/context.d.ts +22 -0
- package/dist/session/context.d.ts.map +1 -0
- package/dist/session/context.js +113 -0
- package/dist/session/continuityState.d.ts +39 -0
- package/dist/session/continuityState.d.ts.map +1 -0
- package/dist/session/continuityState.js +164 -0
- package/dist/session/cost.d.ts +63 -0
- package/dist/session/cost.d.ts.map +1 -0
- package/dist/session/cost.js +194 -0
- package/dist/session/discovery.d.ts +22 -0
- package/dist/session/discovery.d.ts.map +1 -0
- package/dist/session/discovery.js +35 -0
- package/dist/session/history.d.ts +30 -0
- package/dist/session/history.d.ts.map +1 -0
- package/dist/session/history.js +143 -0
- package/dist/session/index.d.ts +7 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +70 -0
- package/dist/session/memoryExtraction.d.ts +65 -0
- package/dist/session/memoryExtraction.d.ts.map +1 -0
- package/dist/session/memoryExtraction.js +201 -0
- package/dist/session/parse.d.ts +45 -0
- package/dist/session/parse.d.ts.map +1 -0
- package/dist/session/parse.js +170 -0
- package/dist/session/persistence.d.ts +46 -0
- package/dist/session/persistence.d.ts.map +1 -0
- package/dist/session/persistence.js +180 -0
- package/dist/session/types.d.ts +267 -0
- package/dist/session/types.d.ts.map +1 -0
- package/dist/session/types.js +45 -0
- package/dist/session/write.d.ts +61 -0
- package/dist/session/write.d.ts.map +1 -0
- package/dist/session/write.js +213 -0
- package/dist/storage/atomic.d.ts +2 -0
- package/dist/storage/atomic.d.ts.map +1 -0
- package/dist/storage/atomic.js +54 -0
- package/dist/storage/clock.d.ts +2 -0
- package/dist/storage/clock.d.ts.map +1 -0
- package/dist/storage/clock.js +6 -0
- package/dist/storage/index.d.ts +7 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +9 -0
- package/dist/storage/journalWatcher.d.ts +24 -0
- package/dist/storage/journalWatcher.d.ts.map +1 -0
- package/dist/storage/journalWatcher.js +172 -0
- package/dist/storage/paths.d.ts +5 -0
- package/dist/storage/paths.d.ts.map +1 -0
- package/dist/storage/paths.js +26 -0
- package/dist/storage/snapshotState.d.ts +10 -0
- package/dist/storage/snapshotState.d.ts.map +1 -0
- package/dist/storage/snapshotState.js +15 -0
- package/dist/storage/storeTaskArtifacts.d.ts +6 -0
- package/dist/storage/storeTaskArtifacts.d.ts.map +1 -0
- package/dist/storage/storeTaskArtifacts.js +55 -0
- package/dist/storage/types.d.ts +21 -0
- package/dist/storage/types.d.ts.map +1 -0
- package/dist/storage/types.js +2 -0
- package/dist/tasks/crud.d.ts +33 -0
- package/dist/tasks/crud.d.ts.map +1 -0
- package/dist/tasks/crud.js +150 -0
- package/dist/tasks/index.d.ts +2 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/index.js +9 -0
- package/package.json +141 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* resume-run command handler.
|
|
4
|
+
* Uses an agentic Pi session to discover existing runs, present them to the
|
|
5
|
+
* user, assess state, and resume orchestration via handleHarnessCreateRun.
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
+
}) : function(o, v) {
|
|
21
|
+
o["default"] = v;
|
|
22
|
+
});
|
|
23
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
+
var ownKeys = function(o) {
|
|
25
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
+
var ar = [];
|
|
27
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
+
return ar;
|
|
29
|
+
};
|
|
30
|
+
return ownKeys(o);
|
|
31
|
+
};
|
|
32
|
+
return function (mod) {
|
|
33
|
+
if (mod && mod.__esModule) return mod;
|
|
34
|
+
var result = {};
|
|
35
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
+
__setModuleDefault(result, mod);
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
})();
|
|
40
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
+
exports.handleHarnessResumeRun = handleHarnessResumeRun;
|
|
42
|
+
const path = __importStar(require("node:path"));
|
|
43
|
+
const typebox_1 = require("@sinclair/typebox");
|
|
44
|
+
const agent_core_1 = require("@a5c-ai/agent-core");
|
|
45
|
+
const agent_core_2 = require("@a5c-ai/agent-core");
|
|
46
|
+
const babysitter_sdk_1 = require("@a5c-ai/babysitter-sdk");
|
|
47
|
+
const createRun_1 = require("./createRun");
|
|
48
|
+
const utils_1 = require("../../../harness/internal/createRun/utils");
|
|
49
|
+
const resumeState_1 = require("../../../harness/internal/createRun/resumeState");
|
|
50
|
+
function errorResult(message) {
|
|
51
|
+
return {
|
|
52
|
+
content: [{ type: "text", text: `Error: ${message}` }],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
// System prompt
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
function buildResumeSystemPrompt(runsDir, runIdHint) {
|
|
59
|
+
const parts = [
|
|
60
|
+
"You are an assistant that helps users find and resume babysitter orchestration runs.",
|
|
61
|
+
"",
|
|
62
|
+
"## Your workflow",
|
|
63
|
+
"",
|
|
64
|
+
"1. **Discover runs** -- call `babysitter_list_runs` to list recent runs.",
|
|
65
|
+
runIdHint
|
|
66
|
+
? `2. The user has requested run ID "${runIdHint}". Call \`babysitter_assess_run\` with that run ID to inspect it.`
|
|
67
|
+
: "2. Present the runs to the user. If there are multiple, use `AskUserQuestion` to let them pick one.",
|
|
68
|
+
"3. **Assess** the selected run by calling `babysitter_assess_run` with the run ID.",
|
|
69
|
+
"4. Show the user the run's state (status, pending effects, journal summary).",
|
|
70
|
+
"5. If the run is resumable (not completed), call `babysitter_resume_run` to resume it.",
|
|
71
|
+
"6. If the run is already completed, tell the user and stop.",
|
|
72
|
+
"",
|
|
73
|
+
"## Important rules",
|
|
74
|
+
"",
|
|
75
|
+
"- Always call `babysitter_list_runs` first to see what's available.",
|
|
76
|
+
"- Use `AskUserQuestion` for interactive selection when there are multiple runs.",
|
|
77
|
+
"- You may also use read, grep, bash and other tools to inspect run files in " + runsDir + " if more detail is needed.",
|
|
78
|
+
"- Call `babysitter_resume_run` exactly once when ready to resume.",
|
|
79
|
+
"- Do NOT attempt to modify run files yourself -- only use the provided resume tool.",
|
|
80
|
+
];
|
|
81
|
+
return parts.join("\n");
|
|
82
|
+
}
|
|
83
|
+
function buildResumeUserPrompt(runIdHint) {
|
|
84
|
+
if (runIdHint) {
|
|
85
|
+
return `Resume the run with ID "${runIdHint}". Assess it and proceed.`;
|
|
86
|
+
}
|
|
87
|
+
return "Help me find and resume a babysitter run. Start by listing the available runs.";
|
|
88
|
+
}
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// Main handler
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
async function handleHarnessResumeRun(args) {
|
|
93
|
+
const { json, verbose, interactive = true, } = args;
|
|
94
|
+
const runsDir = args.runsDir ?? (0, babysitter_sdk_1.resolveRunsDir)({ cwd: args.workspace ?? process.cwd() });
|
|
95
|
+
const outputMode = args.outputMode;
|
|
96
|
+
const writeVerbose = (message) => {
|
|
97
|
+
(0, utils_1.writeVerboseLine)(verbose, json, message, outputMode);
|
|
98
|
+
};
|
|
99
|
+
const writeVerboseData = (label, value, maxChars) => {
|
|
100
|
+
(0, utils_1.writeVerboseBlock)(verbose, json, label, value, maxChars, outputMode);
|
|
101
|
+
};
|
|
102
|
+
// Track whether the agent has triggered a resume (set by the resume tool).
|
|
103
|
+
let resumeTriggered = false;
|
|
104
|
+
let resumeExitCode = 0;
|
|
105
|
+
// -----------------------------------------------------------------
|
|
106
|
+
// Define domain-specific tools
|
|
107
|
+
// -----------------------------------------------------------------
|
|
108
|
+
const customTools = [
|
|
109
|
+
{
|
|
110
|
+
name: "babysitter_list_runs",
|
|
111
|
+
label: "List Runs",
|
|
112
|
+
description: "List recent runs in the runs directory with status and metadata. " +
|
|
113
|
+
"Returns up to 20 runs sorted by most recent first.",
|
|
114
|
+
parameters: typebox_1.Type.Object({
|
|
115
|
+
statusFilter: typebox_1.Type.Optional(typebox_1.Type.String({ description: "Optional status filter: created, in-progress, waiting, failed, completed" })),
|
|
116
|
+
}),
|
|
117
|
+
execute: async (_toolCallId, params) => {
|
|
118
|
+
writeVerboseData("resume tool babysitter_list_runs", params);
|
|
119
|
+
try {
|
|
120
|
+
let runs = await (0, resumeState_1.discoverRuns)(runsDir);
|
|
121
|
+
if (params.statusFilter) {
|
|
122
|
+
runs = runs.filter((r) => r.status === params.statusFilter);
|
|
123
|
+
}
|
|
124
|
+
if (runs.length === 0) {
|
|
125
|
+
return (0, utils_1.formatToolResult)({ runs: [], runsDir }, "No runs found.");
|
|
126
|
+
}
|
|
127
|
+
const summary = runs.map((r) => ({
|
|
128
|
+
runId: r.runId,
|
|
129
|
+
processId: r.processId,
|
|
130
|
+
status: r.status,
|
|
131
|
+
createdAt: r.createdAt,
|
|
132
|
+
prompt: r.prompt
|
|
133
|
+
? r.prompt.length > 80 ? r.prompt.slice(0, 77) + "..." : r.prompt
|
|
134
|
+
: undefined,
|
|
135
|
+
effects: `${r.resolvedEffects}/${r.totalEffects} resolved`,
|
|
136
|
+
pendingEffects: r.pendingEffects,
|
|
137
|
+
}));
|
|
138
|
+
return (0, utils_1.formatToolResult)({ count: runs.length, runs: summary }, `Found ${runs.length} run(s).`);
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
142
|
+
return errorResult(`Failed to list runs: ${msg}`);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "babysitter_assess_run",
|
|
148
|
+
label: "Assess Run",
|
|
149
|
+
description: "Get detailed state assessment for a specific run by ID. " +
|
|
150
|
+
"Returns status, effects, journal summary, and entrypoint info.",
|
|
151
|
+
parameters: typebox_1.Type.Object({
|
|
152
|
+
runId: typebox_1.Type.String({ description: "The run ID (or prefix) to assess" }),
|
|
153
|
+
}),
|
|
154
|
+
execute: async (_toolCallId, params) => {
|
|
155
|
+
writeVerboseData("resume tool babysitter_assess_run", params);
|
|
156
|
+
const runDir = (0, babysitter_sdk_1.resolveExistingRunDir)(params.runId, {
|
|
157
|
+
cwd: args.workspace ?? process.cwd(),
|
|
158
|
+
override: runsDir,
|
|
159
|
+
});
|
|
160
|
+
try {
|
|
161
|
+
const assessment = await (0, resumeState_1.assessRun)(runDir);
|
|
162
|
+
return (0, utils_1.formatToolResult)({
|
|
163
|
+
runId: assessment.run.runId,
|
|
164
|
+
processId: assessment.run.processId,
|
|
165
|
+
status: assessment.run.status,
|
|
166
|
+
createdAt: assessment.run.createdAt,
|
|
167
|
+
prompt: assessment.run.prompt,
|
|
168
|
+
totalEffects: assessment.run.totalEffects,
|
|
169
|
+
resolvedEffects: assessment.run.resolvedEffects,
|
|
170
|
+
pendingEffects: assessment.run.pendingEffects,
|
|
171
|
+
journalEvents: assessment.journalLength,
|
|
172
|
+
lastEvent: assessment.lastEvent,
|
|
173
|
+
entrypoint: assessment.run.entrypoint,
|
|
174
|
+
runDir: assessment.run.runDir,
|
|
175
|
+
resumable: assessment.run.status !== "completed",
|
|
176
|
+
}, `Run ${assessment.run.runId} assessed.`);
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
180
|
+
return errorResult(`Failed to assess run "${params.runId}": ${msg}`);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
name: "babysitter_resume_run",
|
|
186
|
+
label: "Resume Run",
|
|
187
|
+
description: "Resume orchestration for a specific run. Call this exactly once " +
|
|
188
|
+
"after assessing the run and confirming it should be resumed.",
|
|
189
|
+
parameters: typebox_1.Type.Object({
|
|
190
|
+
runId: typebox_1.Type.String({ description: "The run ID to resume" }),
|
|
191
|
+
}),
|
|
192
|
+
execute: async (_toolCallId, params) => {
|
|
193
|
+
writeVerboseData("resume tool babysitter_resume_run", params);
|
|
194
|
+
if (resumeTriggered) {
|
|
195
|
+
return errorResult("Resume has already been triggered for this session.");
|
|
196
|
+
}
|
|
197
|
+
const runDir = (0, babysitter_sdk_1.resolveExistingRunDir)(params.runId, {
|
|
198
|
+
cwd: args.workspace ?? process.cwd(),
|
|
199
|
+
override: runsDir,
|
|
200
|
+
});
|
|
201
|
+
try {
|
|
202
|
+
const assessment = await (0, resumeState_1.assessRun)(runDir);
|
|
203
|
+
const selectedRun = assessment.run;
|
|
204
|
+
if (selectedRun.status === "completed") {
|
|
205
|
+
return (0, utils_1.formatToolResult)({ runId: selectedRun.runId, status: "completed" }, "Run is already completed. Nothing to resume.");
|
|
206
|
+
}
|
|
207
|
+
resumeTriggered = true;
|
|
208
|
+
if (!json && outputMode !== "tui") {
|
|
209
|
+
process.stderr.write(`${utils_1.MAGENTA}Resuming run ${utils_1.BOLD}${selectedRun.runId}${utils_1.RESET}${utils_1.MAGENTA}...${utils_1.RESET}\n\n`);
|
|
210
|
+
}
|
|
211
|
+
// Resolve the process entry path
|
|
212
|
+
const entryImportPath = selectedRun.entrypoint.importPath;
|
|
213
|
+
const processPath = path.isAbsolute(entryImportPath)
|
|
214
|
+
? entryImportPath
|
|
215
|
+
: path.resolve(entryImportPath);
|
|
216
|
+
resumeExitCode = await (0, createRun_1.handleHarnessCreateRun)({
|
|
217
|
+
processPath,
|
|
218
|
+
prompt: selectedRun.prompt,
|
|
219
|
+
harness: args.harness,
|
|
220
|
+
workspace: args.workspace,
|
|
221
|
+
model: args.model,
|
|
222
|
+
maxIterations: args.maxIterations,
|
|
223
|
+
runsDir: args.runsDir,
|
|
224
|
+
json: args.json,
|
|
225
|
+
verbose: args.verbose,
|
|
226
|
+
interactive: args.interactive,
|
|
227
|
+
existingRunId: selectedRun.runId,
|
|
228
|
+
existingRunDir: selectedRun.runDir,
|
|
229
|
+
outputMode,
|
|
230
|
+
});
|
|
231
|
+
return (0, utils_1.formatToolResult)({ runId: selectedRun.runId, exitCode: resumeExitCode }, resumeExitCode === 0
|
|
232
|
+
? "Run resumed successfully."
|
|
233
|
+
: `Run resume completed with exit code ${resumeExitCode}.`);
|
|
234
|
+
}
|
|
235
|
+
catch (err) {
|
|
236
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
237
|
+
return errorResult(`Failed to resume run "${params.runId}": ${msg}`);
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
];
|
|
242
|
+
// -----------------------------------------------------------------
|
|
243
|
+
// Build agentic tools (read/write/edit/grep/bash/etc.)
|
|
244
|
+
// -----------------------------------------------------------------
|
|
245
|
+
const agenticTools = (0, agent_core_2.createAgentCoreToolDefinitions)({
|
|
246
|
+
workspace: args.workspace ?? process.cwd(),
|
|
247
|
+
interactive: interactive,
|
|
248
|
+
askUserQuestionHandler: interactive
|
|
249
|
+
? undefined // Let the default AskUserQuestion handler work
|
|
250
|
+
: undefined,
|
|
251
|
+
});
|
|
252
|
+
const mergedCustomTools = [...customTools, ...agenticTools];
|
|
253
|
+
writeVerbose(`[resume setup] runsDir=${runsDir} workspace=${path.resolve(args.workspace ?? process.cwd())} model=${args.model ?? "(default)"}`);
|
|
254
|
+
writeVerboseData("resume tools", mergedCustomTools.map((tool) => ({
|
|
255
|
+
name: tool.name,
|
|
256
|
+
label: tool.label,
|
|
257
|
+
})));
|
|
258
|
+
// -----------------------------------------------------------------
|
|
259
|
+
// Create Pi session
|
|
260
|
+
// -----------------------------------------------------------------
|
|
261
|
+
const systemPrompt = buildResumeSystemPrompt(runsDir, args.runId);
|
|
262
|
+
const userPrompt = buildResumeUserPrompt(args.runId);
|
|
263
|
+
writeVerboseData("resume system prompt", systemPrompt);
|
|
264
|
+
writeVerboseData("resume user prompt", userPrompt);
|
|
265
|
+
let session = null;
|
|
266
|
+
try {
|
|
267
|
+
session = (0, agent_core_1.createAgentCoreSession)({
|
|
268
|
+
workspace: args.workspace,
|
|
269
|
+
model: args.model,
|
|
270
|
+
thinkingLevel: "low",
|
|
271
|
+
toolsMode: "coding",
|
|
272
|
+
customTools: mergedCustomTools,
|
|
273
|
+
systemPrompt,
|
|
274
|
+
isolated: true,
|
|
275
|
+
ephemeral: true,
|
|
276
|
+
});
|
|
277
|
+
await session.initialize();
|
|
278
|
+
// Subscribe to stream text output to stderr in non-JSON mode
|
|
279
|
+
let unsubscribe = null;
|
|
280
|
+
if (!json && outputMode !== "tui") {
|
|
281
|
+
process.stderr.write(`\n${utils_1.BOLD}${utils_1.MAGENTA}Run Discovery${utils_1.RESET} ${utils_1.DIM}Agent is searching for runs...${utils_1.RESET}\n\n`);
|
|
282
|
+
unsubscribe = session.subscribe((event) => {
|
|
283
|
+
if (event.type === "text_delta") {
|
|
284
|
+
const text = event.text;
|
|
285
|
+
if (text)
|
|
286
|
+
process.stderr.write(text);
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
// Prompt the agent
|
|
291
|
+
const result = await session.prompt(userPrompt, 300_000);
|
|
292
|
+
if (unsubscribe)
|
|
293
|
+
unsubscribe();
|
|
294
|
+
if (!json && outputMode !== "tui")
|
|
295
|
+
process.stderr.write("\n");
|
|
296
|
+
writeVerboseData("resume agent result", {
|
|
297
|
+
success: result.success,
|
|
298
|
+
outputPreview: result.output.length > 500
|
|
299
|
+
? result.output.slice(0, 497) + "..."
|
|
300
|
+
: result.output,
|
|
301
|
+
resumeTriggered,
|
|
302
|
+
});
|
|
303
|
+
if (!result.success && !resumeTriggered) {
|
|
304
|
+
if (json) {
|
|
305
|
+
process.stdout.write(JSON.stringify({ ok: false, error: "Resume agent failed", details: result.output }) + "\n");
|
|
306
|
+
}
|
|
307
|
+
else if (outputMode !== "tui") {
|
|
308
|
+
process.stderr.write(`${utils_1.RED}Resume agent failed:${utils_1.RESET} ${result.output}\n`);
|
|
309
|
+
}
|
|
310
|
+
return 1;
|
|
311
|
+
}
|
|
312
|
+
// If the agent never triggered resume, it decided not to (e.g., no runs or user quit)
|
|
313
|
+
if (!resumeTriggered) {
|
|
314
|
+
if (json) {
|
|
315
|
+
process.stdout.write(JSON.stringify({ ok: true, resumed: false, message: "No run was resumed" }) + "\n");
|
|
316
|
+
}
|
|
317
|
+
return 0;
|
|
318
|
+
}
|
|
319
|
+
return resumeExitCode;
|
|
320
|
+
}
|
|
321
|
+
catch (err) {
|
|
322
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
323
|
+
if (json) {
|
|
324
|
+
process.stdout.write(JSON.stringify({ ok: false, error: "Resume session failed", details: message }) + "\n");
|
|
325
|
+
}
|
|
326
|
+
else if (outputMode !== "tui") {
|
|
327
|
+
process.stderr.write(`${utils_1.RED}Error:${utils_1.RESET} ${message}\n`);
|
|
328
|
+
}
|
|
329
|
+
return 1;
|
|
330
|
+
}
|
|
331
|
+
finally {
|
|
332
|
+
if (session) {
|
|
333
|
+
try {
|
|
334
|
+
session.dispose();
|
|
335
|
+
}
|
|
336
|
+
catch {
|
|
337
|
+
// Ignore cleanup errors
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GAP-JSON-004: Streaming JSONL CLI Mode (stdin/stdout).
|
|
3
|
+
*
|
|
4
|
+
* Reads JSONL requests from stdin, dispatches to API functions, writes
|
|
5
|
+
* JSONL responses to stdout. Enables programmatic control from any
|
|
6
|
+
* language via process pipes — no HTTP, no WebSocket.
|
|
7
|
+
*/
|
|
8
|
+
import type { ApiResult } from "../../api/runs";
|
|
9
|
+
interface ParsedRequest {
|
|
10
|
+
id: string;
|
|
11
|
+
method: string;
|
|
12
|
+
params: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
interface ParseError {
|
|
15
|
+
id: null;
|
|
16
|
+
error: {
|
|
17
|
+
code: string;
|
|
18
|
+
message: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
interface StreamOptions {
|
|
22
|
+
stdin: NodeJS.ReadableStream;
|
|
23
|
+
stdout: NodeJS.WritableStream;
|
|
24
|
+
}
|
|
25
|
+
export declare const SUPPORTED_METHODS: readonly ["run.create", "run.iterate", "run.status", "run.events", "effect.commit", "effect.list", "effect.show", "effect.cancel", "effect.batchCommit", "breakpoint.list", "breakpoint.show", "breakpoint.respond", "breakpoint.listRules", "breakpoint.addRule", "breakpoint.removeRule", "breakpoint.evaluateAutoApproval", "event.subscribe", "event.unsubscribe", "shutdown"];
|
|
26
|
+
export declare function parseJsonlRequest(line: string): ParsedRequest | ParseError;
|
|
27
|
+
export declare function formatJsonlResponse(id: string | null, result: ApiResult<unknown>): string;
|
|
28
|
+
export declare function dispatchJsonlMethod(method: string, params: Record<string, unknown>, defaults: {
|
|
29
|
+
runsDir: string;
|
|
30
|
+
}): Promise<ApiResult<unknown>>;
|
|
31
|
+
export declare function handleJsonlInteractive(args: {
|
|
32
|
+
runsDir: string;
|
|
33
|
+
}, streamOpts?: StreamOptions): Promise<number>;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=jsonlInteractive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsonlInteractive.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/jsonlInteractive.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA8BH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAIhD,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,UAAU,UAAU;IAClB,EAAE,EAAE,IAAI,CAAC;IACT,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAC1C;AAED,UAAU,aAAa;IACrB,KAAK,EAAE,MAAM,CAAC,cAAc,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;CAC/B;AAID,eAAO,MAAM,iBAAiB,oXAoBpB,CAAC;AAIX,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,UAAU,CAyC1E;AAED,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,MAAM,CAWzF;AAID,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,QAAQ,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAC5B,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAoJ7B;AAMD,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,EACzB,UAAU,CAAC,EAAE,aAAa,GACzB,OAAO,CAAC,MAAM,CAAC,CAqFjB"}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* GAP-JSON-004: Streaming JSONL CLI Mode (stdin/stdout).
|
|
4
|
+
*
|
|
5
|
+
* Reads JSONL requests from stdin, dispatches to API functions, writes
|
|
6
|
+
* JSONL responses to stdout. Enables programmatic control from any
|
|
7
|
+
* language via process pipes — no HTTP, no WebSocket.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.SUPPORTED_METHODS = void 0;
|
|
11
|
+
exports.parseJsonlRequest = parseJsonlRequest;
|
|
12
|
+
exports.formatJsonlResponse = formatJsonlResponse;
|
|
13
|
+
exports.dispatchJsonlMethod = dispatchJsonlMethod;
|
|
14
|
+
exports.handleJsonlInteractive = handleJsonlInteractive;
|
|
15
|
+
const node_readline_1 = require("node:readline");
|
|
16
|
+
const runs_1 = require("../../api/runs");
|
|
17
|
+
const effects_1 = require("../../api/effects");
|
|
18
|
+
const breakpoints_1 = require("../../api/breakpoints");
|
|
19
|
+
const eventStream_1 = require("../../api/eventStream");
|
|
20
|
+
// ── Supported methods ──────────────────────────────────────────────────────
|
|
21
|
+
exports.SUPPORTED_METHODS = [
|
|
22
|
+
"run.create",
|
|
23
|
+
"run.iterate",
|
|
24
|
+
"run.status",
|
|
25
|
+
"run.events",
|
|
26
|
+
"effect.commit",
|
|
27
|
+
"effect.list",
|
|
28
|
+
"effect.show",
|
|
29
|
+
"effect.cancel",
|
|
30
|
+
"effect.batchCommit",
|
|
31
|
+
"breakpoint.list",
|
|
32
|
+
"breakpoint.show",
|
|
33
|
+
"breakpoint.respond",
|
|
34
|
+
"breakpoint.listRules",
|
|
35
|
+
"breakpoint.addRule",
|
|
36
|
+
"breakpoint.removeRule",
|
|
37
|
+
"breakpoint.evaluateAutoApproval",
|
|
38
|
+
"event.subscribe",
|
|
39
|
+
"event.unsubscribe",
|
|
40
|
+
"shutdown",
|
|
41
|
+
];
|
|
42
|
+
// ── Pure functions ─────────────────────────────────────────────────────────
|
|
43
|
+
function parseJsonlRequest(line) {
|
|
44
|
+
let parsed;
|
|
45
|
+
try {
|
|
46
|
+
parsed = JSON.parse(line);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return {
|
|
50
|
+
id: null,
|
|
51
|
+
error: { code: "INVALID_REQUEST", message: "Malformed JSON" },
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
55
|
+
return {
|
|
56
|
+
id: null,
|
|
57
|
+
error: { code: "INVALID_REQUEST", message: "Request must be a JSON object" },
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const obj = parsed;
|
|
61
|
+
if (obj.id === undefined || obj.id === null) {
|
|
62
|
+
return {
|
|
63
|
+
id: null,
|
|
64
|
+
error: { code: "INVALID_REQUEST", message: "Missing required field: id" },
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (typeof obj.method !== "string" || !obj.method) {
|
|
68
|
+
return {
|
|
69
|
+
id: null,
|
|
70
|
+
error: { code: "INVALID_REQUEST", message: "Missing required field: method" },
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
id: String(obj.id),
|
|
75
|
+
method: obj.method,
|
|
76
|
+
params: (typeof obj.params === "object" && obj.params !== null && !Array.isArray(obj.params))
|
|
77
|
+
? obj.params
|
|
78
|
+
: {},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function formatJsonlResponse(id, result) {
|
|
82
|
+
try {
|
|
83
|
+
if (result.ok) {
|
|
84
|
+
return JSON.stringify({ id, result: result.data });
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
return JSON.stringify({ id, error: result.error });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
92
|
+
return JSON.stringify({ id, error: { code: "SERIALIZATION_ERROR", message: msg } });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// ── Dispatch table ─────────────────────────────────────────────────────────
|
|
96
|
+
async function dispatchJsonlMethod(method, params, defaults) {
|
|
97
|
+
try {
|
|
98
|
+
const p = params;
|
|
99
|
+
const runsDir = (typeof p.runsDir === "string" ? p.runsDir : defaults.runsDir);
|
|
100
|
+
switch (method) {
|
|
101
|
+
// ── Run lifecycle ──
|
|
102
|
+
case "run.create":
|
|
103
|
+
return (0, runs_1.apiCreateRun)({
|
|
104
|
+
processId: p.processId,
|
|
105
|
+
entrypoint: p.entrypoint,
|
|
106
|
+
runsDir,
|
|
107
|
+
inputs: p.inputs,
|
|
108
|
+
prompt: p.prompt,
|
|
109
|
+
});
|
|
110
|
+
case "run.iterate":
|
|
111
|
+
return (0, runs_1.apiIterate)({ runDir: p.runDir });
|
|
112
|
+
case "run.status":
|
|
113
|
+
return (0, runs_1.apiRunStatus)({ runId: p.runId, runsDir });
|
|
114
|
+
case "run.events":
|
|
115
|
+
return (0, runs_1.apiRunEvents)({
|
|
116
|
+
runId: p.runId,
|
|
117
|
+
runsDir,
|
|
118
|
+
limit: typeof p.limit === "number" ? p.limit : undefined,
|
|
119
|
+
filterType: typeof p.filterType === "string" ? p.filterType : undefined,
|
|
120
|
+
});
|
|
121
|
+
// ── Effect dispatch ──
|
|
122
|
+
case "effect.commit":
|
|
123
|
+
return (0, runs_1.apiCommitEffect)({
|
|
124
|
+
runDir: p.runDir,
|
|
125
|
+
effectId: p.effectId,
|
|
126
|
+
result: p.result,
|
|
127
|
+
});
|
|
128
|
+
case "effect.list":
|
|
129
|
+
return (0, effects_1.apiListEffects)({
|
|
130
|
+
runDir: p.runDir,
|
|
131
|
+
filter: p.filter,
|
|
132
|
+
});
|
|
133
|
+
case "effect.show":
|
|
134
|
+
return (0, effects_1.apiShowEffect)({
|
|
135
|
+
runDir: p.runDir,
|
|
136
|
+
effectId: p.effectId,
|
|
137
|
+
});
|
|
138
|
+
case "effect.cancel":
|
|
139
|
+
return (0, effects_1.apiCancelEffect)({
|
|
140
|
+
runDir: p.runDir,
|
|
141
|
+
effectId: p.effectId,
|
|
142
|
+
reason: p.reason,
|
|
143
|
+
});
|
|
144
|
+
case "effect.batchCommit":
|
|
145
|
+
return (0, effects_1.apiBatchCommitEffects)({
|
|
146
|
+
runDir: p.runDir,
|
|
147
|
+
effects: p.effects,
|
|
148
|
+
});
|
|
149
|
+
// ── Breakpoint interaction ──
|
|
150
|
+
case "breakpoint.list":
|
|
151
|
+
return (0, breakpoints_1.apiListBreakpoints)({ runDir: p.runDir });
|
|
152
|
+
case "breakpoint.show":
|
|
153
|
+
return (0, breakpoints_1.apiShowBreakpoint)({
|
|
154
|
+
runDir: p.runDir,
|
|
155
|
+
effectId: p.effectId,
|
|
156
|
+
});
|
|
157
|
+
case "breakpoint.respond":
|
|
158
|
+
return (0, breakpoints_1.apiRespondToBreakpoint)({
|
|
159
|
+
runDir: p.runDir,
|
|
160
|
+
effectId: p.effectId,
|
|
161
|
+
approved: p.approved,
|
|
162
|
+
response: p.response,
|
|
163
|
+
feedback: p.feedback,
|
|
164
|
+
option: p.option,
|
|
165
|
+
respondedBy: p.respondedBy,
|
|
166
|
+
});
|
|
167
|
+
case "breakpoint.listRules":
|
|
168
|
+
return (0, breakpoints_1.apiListAutoApprovalRules)({ rulesPath: p.rulesPath });
|
|
169
|
+
case "breakpoint.addRule":
|
|
170
|
+
return (0, breakpoints_1.apiAddAutoApprovalRule)({
|
|
171
|
+
pattern: p.pattern,
|
|
172
|
+
action: p.action,
|
|
173
|
+
createdBy: p.createdBy,
|
|
174
|
+
id: p.id,
|
|
175
|
+
source: p.source,
|
|
176
|
+
note: p.note,
|
|
177
|
+
rulesPath: p.rulesPath,
|
|
178
|
+
});
|
|
179
|
+
case "breakpoint.removeRule":
|
|
180
|
+
return (0, breakpoints_1.apiRemoveAutoApprovalRule)({
|
|
181
|
+
ruleId: p.ruleId,
|
|
182
|
+
rulesPath: p.rulesPath,
|
|
183
|
+
});
|
|
184
|
+
case "breakpoint.evaluateAutoApproval":
|
|
185
|
+
return (0, breakpoints_1.apiEvaluateAutoApproval)({
|
|
186
|
+
breakpointId: p.breakpointId,
|
|
187
|
+
tags: p.tags,
|
|
188
|
+
expert: p.expert,
|
|
189
|
+
rulesPath: p.rulesPath,
|
|
190
|
+
autoApproveAfterN: p.autoApproveAfterN,
|
|
191
|
+
consecutiveApprovals: p.consecutiveApprovals,
|
|
192
|
+
});
|
|
193
|
+
// ── Event streaming ──
|
|
194
|
+
case "event.subscribe": {
|
|
195
|
+
const subResult = await (0, eventStream_1.apiSubscribeRunEvents)({
|
|
196
|
+
runId: p.runId,
|
|
197
|
+
runsDir,
|
|
198
|
+
afterSeq: typeof p.afterSeq === "number" ? p.afterSeq : undefined,
|
|
199
|
+
pollIntervalMs: typeof p.pollIntervalMs === "number" ? p.pollIntervalMs : undefined,
|
|
200
|
+
onEvent: () => {
|
|
201
|
+
// Events are consumed via polling; JSONL doesn't push events
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
return subResult;
|
|
205
|
+
}
|
|
206
|
+
case "event.unsubscribe":
|
|
207
|
+
return (0, eventStream_1.apiUnsubscribeRunEvents)({
|
|
208
|
+
subscriptionId: p.subscriptionId,
|
|
209
|
+
});
|
|
210
|
+
// ── Control ──
|
|
211
|
+
case "shutdown":
|
|
212
|
+
(0, eventStream_1.closeAllSubscriptions)();
|
|
213
|
+
return { ok: true, data: { ok: true } };
|
|
214
|
+
default:
|
|
215
|
+
return {
|
|
216
|
+
ok: false,
|
|
217
|
+
error: { code: "UNKNOWN_METHOD", message: `Unknown method: ${method}` },
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
223
|
+
return { ok: false, error: { code: "INTERNAL_ERROR", message: msg } };
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
// ── Main handler ───────────────────────────────────────────────────────────
|
|
227
|
+
const MAX_PENDING_QUEUE = 100;
|
|
228
|
+
async function handleJsonlInteractive(args, streamOpts) {
|
|
229
|
+
const stdin = streamOpts?.stdin ?? process.stdin;
|
|
230
|
+
const stdout = streamOpts?.stdout ?? process.stdout;
|
|
231
|
+
const writeLine = (line) => {
|
|
232
|
+
return stdout.write(line + "\n");
|
|
233
|
+
};
|
|
234
|
+
// Emit ready notification
|
|
235
|
+
writeLine(JSON.stringify({
|
|
236
|
+
jsonl: "ready",
|
|
237
|
+
version: 1,
|
|
238
|
+
methods: [...exports.SUPPORTED_METHODS],
|
|
239
|
+
}));
|
|
240
|
+
const rl = (0, node_readline_1.createInterface)({
|
|
241
|
+
input: stdin,
|
|
242
|
+
crlfDelay: Infinity,
|
|
243
|
+
});
|
|
244
|
+
let shutdownRequested = false;
|
|
245
|
+
let activeCount = 0;
|
|
246
|
+
const pending = new Set();
|
|
247
|
+
const processLine = async (line) => {
|
|
248
|
+
const trimmed = line.trim();
|
|
249
|
+
if (!trimmed)
|
|
250
|
+
return;
|
|
251
|
+
const parsed = parseJsonlRequest(trimmed);
|
|
252
|
+
if ("error" in parsed) {
|
|
253
|
+
writeLine(formatJsonlResponse(parsed.id, {
|
|
254
|
+
ok: false,
|
|
255
|
+
error: parsed.error,
|
|
256
|
+
}));
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
const result = await dispatchJsonlMethod(parsed.method, parsed.params, {
|
|
261
|
+
runsDir: args.runsDir,
|
|
262
|
+
});
|
|
263
|
+
writeLine(formatJsonlResponse(parsed.id, result));
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
267
|
+
writeLine(formatJsonlResponse(parsed.id, {
|
|
268
|
+
ok: false,
|
|
269
|
+
error: { code: "INTERNAL_ERROR", message: msg },
|
|
270
|
+
}));
|
|
271
|
+
}
|
|
272
|
+
if (parsed.method === "shutdown") {
|
|
273
|
+
shutdownRequested = true;
|
|
274
|
+
rl.close();
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
return new Promise((resolve) => {
|
|
278
|
+
rl.on("line", (line) => {
|
|
279
|
+
if (shutdownRequested)
|
|
280
|
+
return;
|
|
281
|
+
activeCount++;
|
|
282
|
+
const promise = processLine(line).finally(() => {
|
|
283
|
+
activeCount--;
|
|
284
|
+
pending.delete(promise);
|
|
285
|
+
if (activeCount < MAX_PENDING_QUEUE) {
|
|
286
|
+
rl.resume();
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
pending.add(promise);
|
|
290
|
+
// Backpressure: pause stdin when too many pending
|
|
291
|
+
if (activeCount >= MAX_PENDING_QUEUE) {
|
|
292
|
+
rl.pause();
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
rl.on("close", () => {
|
|
296
|
+
// Wait for all pending requests to complete
|
|
297
|
+
void Promise.allSettled([...pending]).then(() => {
|
|
298
|
+
resolve(0);
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
}
|