@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,271 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Status: NOT INTEGRATED YET
|
|
4
|
+
* Moved from @a5c-ai/babysitter-sdk.
|
|
5
|
+
* GAP-REMOTE-003: WebSocket server transport for MCP.
|
|
6
|
+
*
|
|
7
|
+
* Creates a WebSocket server where each connection gets its own MCP Transport,
|
|
8
|
+
* enabling per-connection McpServer instances for session multiplexing.
|
|
9
|
+
*/
|
|
10
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
13
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
14
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}) : (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
o[k2] = m[k];
|
|
20
|
+
}));
|
|
21
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
22
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
23
|
+
}) : function(o, v) {
|
|
24
|
+
o["default"] = v;
|
|
25
|
+
});
|
|
26
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
27
|
+
var ownKeys = function(o) {
|
|
28
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
29
|
+
var ar = [];
|
|
30
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
31
|
+
return ar;
|
|
32
|
+
};
|
|
33
|
+
return ownKeys(o);
|
|
34
|
+
};
|
|
35
|
+
return function (mod) {
|
|
36
|
+
if (mod && mod.__esModule) return mod;
|
|
37
|
+
var result = {};
|
|
38
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
39
|
+
__setModuleDefault(result, mod);
|
|
40
|
+
return result;
|
|
41
|
+
};
|
|
42
|
+
})();
|
|
43
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
+
exports.WebSocketConnectionTransport = void 0;
|
|
45
|
+
exports.authenticateUpgrade = authenticateUpgrade;
|
|
46
|
+
exports.createWebSocketTransport = createWebSocketTransport;
|
|
47
|
+
const ws_1 = require("ws");
|
|
48
|
+
const http = __importStar(require("node:http"));
|
|
49
|
+
const crypto = __importStar(require("node:crypto"));
|
|
50
|
+
const session_1 = require("./session");
|
|
51
|
+
const DEFAULT_PING_INTERVAL_MS = 30_000;
|
|
52
|
+
const DEFAULT_MAX_MESSAGES_PER_SECOND = 100;
|
|
53
|
+
const SESSION_GRACE_PERIOD_MS = 60_000;
|
|
54
|
+
function authenticateUpgrade(request, expectedToken) {
|
|
55
|
+
if (!expectedToken)
|
|
56
|
+
return true;
|
|
57
|
+
const authHeader = request.headers.authorization;
|
|
58
|
+
if (!authHeader)
|
|
59
|
+
return false;
|
|
60
|
+
const expected = `Bearer ${expectedToken}`;
|
|
61
|
+
if (authHeader.length !== expected.length)
|
|
62
|
+
return false;
|
|
63
|
+
try {
|
|
64
|
+
return crypto.timingSafeEqual(Buffer.from(authHeader), Buffer.from(expected));
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* A Transport implementation backed by a single WebSocket connection.
|
|
72
|
+
* Bridges WS messages to/from the MCP server.
|
|
73
|
+
*/
|
|
74
|
+
class WebSocketConnectionTransport {
|
|
75
|
+
onclose;
|
|
76
|
+
onerror;
|
|
77
|
+
onmessage;
|
|
78
|
+
sessionId;
|
|
79
|
+
_ws;
|
|
80
|
+
_rateLimiter;
|
|
81
|
+
_maxMps;
|
|
82
|
+
constructor(ws, sessionId, maxMessagesPerSecond) {
|
|
83
|
+
this._ws = ws;
|
|
84
|
+
this.sessionId = sessionId;
|
|
85
|
+
this._maxMps = maxMessagesPerSecond;
|
|
86
|
+
this._rateLimiter = { count: 0, resetAt: Date.now() + 1000 };
|
|
87
|
+
}
|
|
88
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- Transport interface requires Promise
|
|
89
|
+
async start() {
|
|
90
|
+
this._ws.on("message", (data) => {
|
|
91
|
+
// Rate limit check
|
|
92
|
+
const now = Date.now();
|
|
93
|
+
if (now >= this._rateLimiter.resetAt) {
|
|
94
|
+
this._rateLimiter.count = 0;
|
|
95
|
+
this._rateLimiter.resetAt = now + 1000;
|
|
96
|
+
}
|
|
97
|
+
this._rateLimiter.count++;
|
|
98
|
+
if (this._rateLimiter.count > this._maxMps) {
|
|
99
|
+
const errorResponse = JSON.stringify({
|
|
100
|
+
jsonrpc: "2.0",
|
|
101
|
+
error: { code: -32000, message: "Rate limit exceeded" },
|
|
102
|
+
id: null,
|
|
103
|
+
});
|
|
104
|
+
this._ws.send(errorResponse);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
try {
|
|
108
|
+
const message = JSON.parse(data.toString());
|
|
109
|
+
if (this.onmessage) {
|
|
110
|
+
this.onmessage(message);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
if (this.onerror) {
|
|
115
|
+
this.onerror(err instanceof Error ? err : new Error(String(err)));
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
this._ws.on("close", () => {
|
|
120
|
+
if (this.onclose)
|
|
121
|
+
this.onclose();
|
|
122
|
+
});
|
|
123
|
+
this._ws.on("error", (err) => {
|
|
124
|
+
if (this.onerror)
|
|
125
|
+
this.onerror(err);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- Transport interface requires Promise
|
|
129
|
+
async send(message, _options) {
|
|
130
|
+
if (this._ws.readyState === ws_1.WebSocket.OPEN) {
|
|
131
|
+
this._ws.send(JSON.stringify(message));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/require-await -- Transport interface requires Promise
|
|
135
|
+
async close() {
|
|
136
|
+
this._ws.close(1001, "Server shutting down");
|
|
137
|
+
}
|
|
138
|
+
setProtocolVersion;
|
|
139
|
+
}
|
|
140
|
+
exports.WebSocketConnectionTransport = WebSocketConnectionTransport;
|
|
141
|
+
async function createWebSocketTransport(options) {
|
|
142
|
+
const { port, host = "127.0.0.1", authToken, pingIntervalMs = DEFAULT_PING_INTERVAL_MS, maxMessagesPerSecond = DEFAULT_MAX_MESSAGES_PER_SECOND, sessionGracePeriodMs = SESSION_GRACE_PERIOD_MS, } = options;
|
|
143
|
+
const sessionManager = new session_1.WebSocketSessionManager();
|
|
144
|
+
const server = http.createServer();
|
|
145
|
+
const wss = new ws_1.WebSocketServer({ noServer: true });
|
|
146
|
+
const connections = new Set();
|
|
147
|
+
const pingTimers = new Map();
|
|
148
|
+
const sessionGraceTimers = new Map();
|
|
149
|
+
let onconnection;
|
|
150
|
+
server.on("upgrade", (request, socket, head) => {
|
|
151
|
+
if (!authenticateUpgrade(request, authToken)) {
|
|
152
|
+
socket.write("HTTP/1.1 401 Unauthorized\r\n\r\n");
|
|
153
|
+
socket.destroy();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
wss.handleUpgrade(request, socket, head, (ws) => {
|
|
157
|
+
// Check for session restore
|
|
158
|
+
const restoreId = request.headers["x-session-id"];
|
|
159
|
+
let session;
|
|
160
|
+
if (restoreId) {
|
|
161
|
+
session = sessionManager.restoreSession(restoreId);
|
|
162
|
+
if (session) {
|
|
163
|
+
// Cancel any pending grace period cleanup
|
|
164
|
+
const graceTimer = sessionGraceTimers.get(restoreId);
|
|
165
|
+
if (graceTimer) {
|
|
166
|
+
clearTimeout(graceTimer);
|
|
167
|
+
sessionGraceTimers.delete(restoreId);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (!session) {
|
|
172
|
+
session = sessionManager.createSession();
|
|
173
|
+
}
|
|
174
|
+
connections.add(ws);
|
|
175
|
+
// Set up ping/pong keepalive
|
|
176
|
+
let alive = true;
|
|
177
|
+
const pingTimer = setInterval(() => {
|
|
178
|
+
if (!alive) {
|
|
179
|
+
ws.terminate();
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
alive = false;
|
|
183
|
+
ws.ping();
|
|
184
|
+
}, pingIntervalMs);
|
|
185
|
+
ws.on("pong", () => {
|
|
186
|
+
alive = true;
|
|
187
|
+
});
|
|
188
|
+
// Create per-connection MCP transport
|
|
189
|
+
const transport = new WebSocketConnectionTransport(ws, session.sessionId, maxMessagesPerSecond);
|
|
190
|
+
ws.on("close", () => {
|
|
191
|
+
connections.delete(ws);
|
|
192
|
+
clearInterval(pingTimer);
|
|
193
|
+
pingTimers.delete(ws);
|
|
194
|
+
// Grace period: don't delete session immediately — allow reconnection
|
|
195
|
+
const sid = transport.sessionId;
|
|
196
|
+
if (sid) {
|
|
197
|
+
const graceTimer = setTimeout(() => {
|
|
198
|
+
sessionManager.removeSession(sid);
|
|
199
|
+
sessionGraceTimers.delete(sid);
|
|
200
|
+
}, sessionGracePeriodMs);
|
|
201
|
+
sessionGraceTimers.set(sid, graceTimer);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
pingTimers.set(ws, pingTimer);
|
|
205
|
+
// Notify consumer so they can connect a McpServer to this transport
|
|
206
|
+
if (onconnection) {
|
|
207
|
+
onconnection(transport);
|
|
208
|
+
}
|
|
209
|
+
// Send session info
|
|
210
|
+
ws.send(JSON.stringify({
|
|
211
|
+
jsonrpc: "2.0",
|
|
212
|
+
method: "session/initialized",
|
|
213
|
+
params: { sessionId: session.sessionId },
|
|
214
|
+
}));
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
return new Promise((resolve, reject) => {
|
|
218
|
+
server.on("error", reject);
|
|
219
|
+
server.listen(port, host, () => {
|
|
220
|
+
const addr = server.address();
|
|
221
|
+
const actualPort = typeof addr === "object" && addr ? addr.port : port;
|
|
222
|
+
const result = {
|
|
223
|
+
port: actualPort,
|
|
224
|
+
sessionManager,
|
|
225
|
+
get onconnection() {
|
|
226
|
+
return onconnection;
|
|
227
|
+
},
|
|
228
|
+
set onconnection(handler) {
|
|
229
|
+
onconnection = handler;
|
|
230
|
+
},
|
|
231
|
+
async close() {
|
|
232
|
+
// Clear all grace timers
|
|
233
|
+
for (const timer of sessionGraceTimers.values()) {
|
|
234
|
+
clearTimeout(timer);
|
|
235
|
+
}
|
|
236
|
+
sessionGraceTimers.clear();
|
|
237
|
+
// Send close frame to all connections
|
|
238
|
+
for (const ws of connections) {
|
|
239
|
+
ws.close(1001, "Server shutting down");
|
|
240
|
+
}
|
|
241
|
+
// Clear all ping timers
|
|
242
|
+
for (const timer of pingTimers.values()) {
|
|
243
|
+
clearInterval(timer);
|
|
244
|
+
}
|
|
245
|
+
pingTimers.clear();
|
|
246
|
+
// Wait for connections to close (max 5s)
|
|
247
|
+
await Promise.race([
|
|
248
|
+
new Promise((res) => {
|
|
249
|
+
if (connections.size === 0) {
|
|
250
|
+
res();
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const check = setInterval(() => {
|
|
254
|
+
if (connections.size === 0) {
|
|
255
|
+
clearInterval(check);
|
|
256
|
+
res();
|
|
257
|
+
}
|
|
258
|
+
}, 100);
|
|
259
|
+
}),
|
|
260
|
+
new Promise((res) => setTimeout(res, 5000)),
|
|
261
|
+
]);
|
|
262
|
+
wss.close();
|
|
263
|
+
await new Promise((res, rej) => {
|
|
264
|
+
server.close((err) => (err ? rej(err) : res()));
|
|
265
|
+
});
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
resolve(result);
|
|
269
|
+
});
|
|
270
|
+
});
|
|
271
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run Health Model (GAP-STATE-008).
|
|
3
|
+
*
|
|
4
|
+
* Computes a point-in-time health snapshot from journal events.
|
|
5
|
+
* Pure function — no file I/O, takes events as input.
|
|
6
|
+
*/
|
|
7
|
+
import type { JournalEvent } from "@a5c-ai/babysitter-sdk";
|
|
8
|
+
import type { RunHealthSnapshot, HealthConfig } from "./types";
|
|
9
|
+
interface HealthOptions {
|
|
10
|
+
config?: Partial<HealthConfig>;
|
|
11
|
+
/** Override "now" for testing. */
|
|
12
|
+
now?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Compute a health snapshot from an array of journal events.
|
|
16
|
+
*/
|
|
17
|
+
export declare function computeRunHealthFromEvents(events: JournalEvent[], options?: HealthOptions): RunHealthSnapshot;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=health.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/observability/health.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EACV,iBAAiB,EAGjB,YAAY,EACb,MAAM,SAAS,CAAC;AAiBjB,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAC/B,kCAAkC;IAClC,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,YAAY,EAAE,EACtB,OAAO,CAAC,EAAE,aAAa,GACtB,iBAAiB,CAiInB"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Run Health Model (GAP-STATE-008).
|
|
4
|
+
*
|
|
5
|
+
* Computes a point-in-time health snapshot from journal events.
|
|
6
|
+
* Pure function — no file I/O, takes events as input.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.computeRunHealthFromEvents = computeRunHealthFromEvents;
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Defaults
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
const DEFAULT_CONFIG = {
|
|
14
|
+
stuckThresholdMs: 300_000, // 5 minutes
|
|
15
|
+
degradedErrorRate: 0.3,
|
|
16
|
+
failedErrorRate: 0.7,
|
|
17
|
+
maxPendingAge: 600_000, // 10 minutes
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Compute a health snapshot from an array of journal events.
|
|
21
|
+
*/
|
|
22
|
+
function computeRunHealthFromEvents(events, options) {
|
|
23
|
+
const config = { ...DEFAULT_CONFIG, ...options?.config };
|
|
24
|
+
const now = options?.now ?? Date.now();
|
|
25
|
+
// Track effects
|
|
26
|
+
const requestedAt = new Map(); // effectId → timestamp ms
|
|
27
|
+
const resolvedEffects = new Set();
|
|
28
|
+
let failedEffects = 0;
|
|
29
|
+
let totalLatency = 0;
|
|
30
|
+
let latencyCount = 0;
|
|
31
|
+
let lastActivityAt = null;
|
|
32
|
+
let hasRunFailed = false;
|
|
33
|
+
const iterations = new Set();
|
|
34
|
+
for (const event of events) {
|
|
35
|
+
lastActivityAt = event.recordedAt;
|
|
36
|
+
const ts = new Date(event.recordedAt).getTime();
|
|
37
|
+
if (event.type === "RUN_FAILED") {
|
|
38
|
+
hasRunFailed = true;
|
|
39
|
+
}
|
|
40
|
+
if (event.type === "EFFECT_REQUESTED") {
|
|
41
|
+
const effectId = typeof event.data.effectId === "string" ? event.data.effectId : undefined;
|
|
42
|
+
if (effectId) {
|
|
43
|
+
requestedAt.set(effectId, ts);
|
|
44
|
+
}
|
|
45
|
+
const iteration = typeof event.data.iteration === "number" ? event.data.iteration : undefined;
|
|
46
|
+
if (iteration != null) {
|
|
47
|
+
iterations.add(iteration);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (event.type === "EFFECT_RESOLVED") {
|
|
51
|
+
const effectId = typeof event.data.effectId === "string" ? event.data.effectId : undefined;
|
|
52
|
+
if (effectId) {
|
|
53
|
+
resolvedEffects.add(effectId);
|
|
54
|
+
const reqTs = requestedAt.get(effectId);
|
|
55
|
+
if (reqTs != null) {
|
|
56
|
+
totalLatency += ts - reqTs;
|
|
57
|
+
latencyCount++;
|
|
58
|
+
}
|
|
59
|
+
const status = typeof event.data.status === "string" ? event.data.status : undefined;
|
|
60
|
+
if (status === "error") {
|
|
61
|
+
failedEffects++;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
// Compute metrics
|
|
67
|
+
const totalEffects = requestedAt.size;
|
|
68
|
+
const resolvedCount = resolvedEffects.size;
|
|
69
|
+
const pendingCount = totalEffects - resolvedCount;
|
|
70
|
+
const errorRate = resolvedCount > 0 ? failedEffects / resolvedCount : 0;
|
|
71
|
+
const avgEffectLatencyMs = latencyCount > 0 ? Math.round(totalLatency / latencyCount) : 0;
|
|
72
|
+
// Oldest pending effect age
|
|
73
|
+
let oldestPendingAgeMs = 0;
|
|
74
|
+
for (const [effectId, reqTs] of requestedAt) {
|
|
75
|
+
if (!resolvedEffects.has(effectId)) {
|
|
76
|
+
const age = now - reqTs;
|
|
77
|
+
if (age > oldestPendingAgeMs) {
|
|
78
|
+
oldestPendingAgeMs = age;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const metrics = {
|
|
83
|
+
errorRate,
|
|
84
|
+
avgEffectLatencyMs,
|
|
85
|
+
pendingCount,
|
|
86
|
+
oldestPendingAgeMs,
|
|
87
|
+
iterationCount: iterations.size,
|
|
88
|
+
lastActivityAt,
|
|
89
|
+
totalEffects,
|
|
90
|
+
resolvedEffects: resolvedCount,
|
|
91
|
+
failedEffects,
|
|
92
|
+
};
|
|
93
|
+
// Determine status and issues
|
|
94
|
+
const issues = [];
|
|
95
|
+
let status = "healthy";
|
|
96
|
+
if (hasRunFailed) {
|
|
97
|
+
status = "failed";
|
|
98
|
+
issues.push("Run failed: RUN_FAILED event detected");
|
|
99
|
+
}
|
|
100
|
+
else if (errorRate >= config.failedErrorRate && resolvedCount > 0) {
|
|
101
|
+
status = "failed";
|
|
102
|
+
issues.push(`High error rate: ${(errorRate * 100).toFixed(1)}% exceeds failed threshold (${(config.failedErrorRate * 100).toFixed(1)}%)`);
|
|
103
|
+
}
|
|
104
|
+
else if (lastActivityAt != null &&
|
|
105
|
+
now - new Date(lastActivityAt).getTime() > config.stuckThresholdMs &&
|
|
106
|
+
pendingCount > 0) {
|
|
107
|
+
status = "stuck";
|
|
108
|
+
const idleMs = now - new Date(lastActivityAt).getTime();
|
|
109
|
+
issues.push(`Run stuck: no activity for ${Math.round(idleMs / 1000)}s (threshold: ${Math.round(config.stuckThresholdMs / 1000)}s)`);
|
|
110
|
+
}
|
|
111
|
+
else if (errorRate >= config.degradedErrorRate && resolvedCount > 0) {
|
|
112
|
+
status = "degraded";
|
|
113
|
+
issues.push(`Elevated error rate: ${(errorRate * 100).toFixed(1)}% exceeds degraded threshold (${(config.degradedErrorRate * 100).toFixed(1)}%)`);
|
|
114
|
+
}
|
|
115
|
+
// Additional issues (additive, don't change status)
|
|
116
|
+
if (oldestPendingAgeMs > config.maxPendingAge &&
|
|
117
|
+
status !== "failed") {
|
|
118
|
+
issues.push(`Oldest pending effect age: ${Math.round(oldestPendingAgeMs / 1000)}s exceeds max pending age (${Math.round(config.maxPendingAge / 1000)}s)`);
|
|
119
|
+
if (status === "healthy") {
|
|
120
|
+
status = "degraded";
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return {
|
|
124
|
+
status,
|
|
125
|
+
metrics,
|
|
126
|
+
issues,
|
|
127
|
+
computedAt: new Date(now).toISOString(),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-export shim — canonical implementation lives in @a5c-ai/agent-runtime.
|
|
3
|
+
* Internal agent-platform consumers continue to import via relative paths
|
|
4
|
+
* through this barrel file.
|
|
5
|
+
*/
|
|
6
|
+
export { buildPhaseTimeline, buildPhaseTimelineFromEvents, computeRunHealthFromEvents, getRunHealthSnapshot, getOrchestrationStatus, getPendingWorkItems, type OrchestrationStatus, type OrchestrationPhase, type PendingWorkItem, type PhaseTimeline, type PhaseEntry, type PhaseName, type Milestone, type IterationTimeline, type RunHealthSnapshot, type RunHealthStatus, type RunHealthMetrics, type HealthConfig, registerWebhook, unregisterWebhook, listWebhooks, buildWebhookEvent, evaluateAlertLevel, filterRegistrations, type AlertLevel, type WebhookEventType, type WebhookRegistration, type WebhookEvent, type WebhookDeliveryResult, type WebhookRegistry, type WebhookRegistrationInput, WEBHOOK_SCHEMA_VERSION, } from "@a5c-ai/agent-runtime/observability";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/observability/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC5B,0BAA0B,EAC1B,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,UAAU,EACf,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC7B,sBAAsB,GACvB,MAAM,qCAAqC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WEBHOOK_SCHEMA_VERSION = exports.filterRegistrations = exports.evaluateAlertLevel = exports.buildWebhookEvent = exports.listWebhooks = exports.unregisterWebhook = exports.registerWebhook = exports.getPendingWorkItems = exports.getOrchestrationStatus = exports.getRunHealthSnapshot = exports.computeRunHealthFromEvents = exports.buildPhaseTimelineFromEvents = exports.buildPhaseTimeline = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Re-export shim — canonical implementation lives in @a5c-ai/agent-runtime.
|
|
6
|
+
* Internal agent-platform consumers continue to import via relative paths
|
|
7
|
+
* through this barrel file.
|
|
8
|
+
*/
|
|
9
|
+
var observability_1 = require("@a5c-ai/agent-runtime/observability");
|
|
10
|
+
Object.defineProperty(exports, "buildPhaseTimeline", { enumerable: true, get: function () { return observability_1.buildPhaseTimeline; } });
|
|
11
|
+
Object.defineProperty(exports, "buildPhaseTimelineFromEvents", { enumerable: true, get: function () { return observability_1.buildPhaseTimelineFromEvents; } });
|
|
12
|
+
Object.defineProperty(exports, "computeRunHealthFromEvents", { enumerable: true, get: function () { return observability_1.computeRunHealthFromEvents; } });
|
|
13
|
+
Object.defineProperty(exports, "getRunHealthSnapshot", { enumerable: true, get: function () { return observability_1.getRunHealthSnapshot; } });
|
|
14
|
+
Object.defineProperty(exports, "getOrchestrationStatus", { enumerable: true, get: function () { return observability_1.getOrchestrationStatus; } });
|
|
15
|
+
Object.defineProperty(exports, "getPendingWorkItems", { enumerable: true, get: function () { return observability_1.getPendingWorkItems; } });
|
|
16
|
+
Object.defineProperty(exports, "registerWebhook", { enumerable: true, get: function () { return observability_1.registerWebhook; } });
|
|
17
|
+
Object.defineProperty(exports, "unregisterWebhook", { enumerable: true, get: function () { return observability_1.unregisterWebhook; } });
|
|
18
|
+
Object.defineProperty(exports, "listWebhooks", { enumerable: true, get: function () { return observability_1.listWebhooks; } });
|
|
19
|
+
Object.defineProperty(exports, "buildWebhookEvent", { enumerable: true, get: function () { return observability_1.buildWebhookEvent; } });
|
|
20
|
+
Object.defineProperty(exports, "evaluateAlertLevel", { enumerable: true, get: function () { return observability_1.evaluateAlertLevel; } });
|
|
21
|
+
Object.defineProperty(exports, "filterRegistrations", { enumerable: true, get: function () { return observability_1.filterRegistrations; } });
|
|
22
|
+
Object.defineProperty(exports, "WEBHOOK_SCHEMA_VERSION", { enumerable: true, get: function () { return observability_1.WEBHOOK_SCHEMA_VERSION; } });
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run status and inspection APIs (GAP-OBS-001, GAP-UX-005, GAP-UX-006).
|
|
3
|
+
*
|
|
4
|
+
* - getRunHealthSnapshot: wraps computeRunHealthFromEvents with journal loading
|
|
5
|
+
* - getOrchestrationStatus: structured status view combining metadata, health, effects
|
|
6
|
+
* - getPendingWorkItems: detailed inspection of pending effects
|
|
7
|
+
*/
|
|
8
|
+
import type { RunHealthSnapshot } from "./types";
|
|
9
|
+
/**
|
|
10
|
+
* Compute a health snapshot for a run by loading its journal.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getRunHealthSnapshot(runDir: string): Promise<RunHealthSnapshot>;
|
|
13
|
+
export type OrchestrationPhase = "created" | "running" | "waiting" | "completed" | "failed";
|
|
14
|
+
export interface OrchestrationStatus {
|
|
15
|
+
runId: string;
|
|
16
|
+
processId: string;
|
|
17
|
+
phase: OrchestrationPhase;
|
|
18
|
+
iterationCount: number;
|
|
19
|
+
totalEffects: number;
|
|
20
|
+
pendingEffects: number;
|
|
21
|
+
resolvedEffects: number;
|
|
22
|
+
failedEffects: number;
|
|
23
|
+
health: RunHealthSnapshot;
|
|
24
|
+
createdAt: string;
|
|
25
|
+
lastActivityAt: string | null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get structured orchestration status for a run.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getOrchestrationStatus(runDir: string): Promise<OrchestrationStatus>;
|
|
31
|
+
export interface PendingWorkItem {
|
|
32
|
+
effectId: string;
|
|
33
|
+
taskId?: string;
|
|
34
|
+
kind?: string;
|
|
35
|
+
title?: string;
|
|
36
|
+
requestedAt: string;
|
|
37
|
+
ageMs: number;
|
|
38
|
+
labels?: string[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* List pending (unresolved) effects with rich detail.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getPendingWorkItems(runDir: string): Promise<PendingWorkItem[]>;
|
|
44
|
+
//# sourceMappingURL=runStatus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runStatus.d.ts","sourceRoot":"","sources":["../../src/observability/runStatus.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAMjD;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,CAAC,CAG5B;AAMD,MAAM,MAAM,kBAAkB,GAC1B,SAAS,GACT,SAAS,GACT,SAAS,GACT,WAAW,GACX,QAAQ,CAAC;AAEb,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,kBAAkB,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,mBAAmB,CAAC,CAqC9B;AAMD,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,eAAe,EAAE,CAAC,CA4E5B"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Run status and inspection APIs (GAP-OBS-001, GAP-UX-005, GAP-UX-006).
|
|
4
|
+
*
|
|
5
|
+
* - getRunHealthSnapshot: wraps computeRunHealthFromEvents with journal loading
|
|
6
|
+
* - getOrchestrationStatus: structured status view combining metadata, health, effects
|
|
7
|
+
* - getPendingWorkItems: detailed inspection of pending effects
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.getRunHealthSnapshot = getRunHealthSnapshot;
|
|
44
|
+
exports.getOrchestrationStatus = getOrchestrationStatus;
|
|
45
|
+
exports.getPendingWorkItems = getPendingWorkItems;
|
|
46
|
+
const node_fs_1 = require("node:fs");
|
|
47
|
+
const path = __importStar(require("node:path"));
|
|
48
|
+
const babysitter_sdk_1 = require("@a5c-ai/babysitter-sdk");
|
|
49
|
+
const health_1 = require("./health");
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
// GAP-OBS-001: Run Health Snapshot
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
/**
|
|
54
|
+
* Compute a health snapshot for a run by loading its journal.
|
|
55
|
+
*/
|
|
56
|
+
async function getRunHealthSnapshot(runDir) {
|
|
57
|
+
const events = await (0, babysitter_sdk_1.loadJournal)(runDir);
|
|
58
|
+
return (0, health_1.computeRunHealthFromEvents)(events);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get structured orchestration status for a run.
|
|
62
|
+
*/
|
|
63
|
+
async function getOrchestrationStatus(runDir) {
|
|
64
|
+
const [metadata, events] = await Promise.all([
|
|
65
|
+
(0, babysitter_sdk_1.readRunMetadata)(runDir),
|
|
66
|
+
(0, babysitter_sdk_1.loadJournal)(runDir),
|
|
67
|
+
]);
|
|
68
|
+
const health = (0, health_1.computeRunHealthFromEvents)(events);
|
|
69
|
+
// Determine phase from events
|
|
70
|
+
let phase = "created";
|
|
71
|
+
const hasCompleted = events.some((e) => e.type === "RUN_COMPLETED");
|
|
72
|
+
const hasFailed = events.some((e) => e.type === "RUN_FAILED");
|
|
73
|
+
const hasPending = health.metrics.pendingCount > 0;
|
|
74
|
+
if (hasFailed) {
|
|
75
|
+
phase = "failed";
|
|
76
|
+
}
|
|
77
|
+
else if (hasCompleted) {
|
|
78
|
+
phase = "completed";
|
|
79
|
+
}
|
|
80
|
+
else if (hasPending) {
|
|
81
|
+
phase = "waiting";
|
|
82
|
+
}
|
|
83
|
+
else if (events.length > 1) {
|
|
84
|
+
phase = "running";
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
runId: metadata.runId,
|
|
88
|
+
processId: metadata.processId,
|
|
89
|
+
phase,
|
|
90
|
+
iterationCount: health.metrics.iterationCount,
|
|
91
|
+
totalEffects: health.metrics.totalEffects,
|
|
92
|
+
pendingEffects: health.metrics.pendingCount,
|
|
93
|
+
resolvedEffects: health.metrics.resolvedEffects,
|
|
94
|
+
failedEffects: health.metrics.failedEffects,
|
|
95
|
+
health,
|
|
96
|
+
createdAt: metadata.createdAt,
|
|
97
|
+
lastActivityAt: health.metrics.lastActivityAt,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* List pending (unresolved) effects with rich detail.
|
|
102
|
+
*/
|
|
103
|
+
async function getPendingWorkItems(runDir) {
|
|
104
|
+
const events = await (0, babysitter_sdk_1.loadJournal)(runDir);
|
|
105
|
+
const now = Date.now();
|
|
106
|
+
// Track requested and resolved effect IDs
|
|
107
|
+
const requested = new Map();
|
|
108
|
+
const resolved = new Set();
|
|
109
|
+
for (const event of events) {
|
|
110
|
+
if (event.type === "EFFECT_REQUESTED") {
|
|
111
|
+
const effectId = typeof event.data.effectId === "string"
|
|
112
|
+
? event.data.effectId
|
|
113
|
+
: undefined;
|
|
114
|
+
if (effectId) {
|
|
115
|
+
requested.set(effectId, {
|
|
116
|
+
effectId,
|
|
117
|
+
requestedAt: event.recordedAt,
|
|
118
|
+
data: event.data,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (event.type === "EFFECT_RESOLVED") {
|
|
123
|
+
const effectId = typeof event.data.effectId === "string"
|
|
124
|
+
? event.data.effectId
|
|
125
|
+
: undefined;
|
|
126
|
+
if (effectId) {
|
|
127
|
+
resolved.add(effectId);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
// Build pending items
|
|
132
|
+
const items = [];
|
|
133
|
+
for (const [effectId, req] of requested) {
|
|
134
|
+
if (resolved.has(effectId))
|
|
135
|
+
continue;
|
|
136
|
+
const reqTs = new Date(req.requestedAt).getTime();
|
|
137
|
+
// Try to read task definition for richer details
|
|
138
|
+
let title;
|
|
139
|
+
let kind;
|
|
140
|
+
let taskId;
|
|
141
|
+
let labels;
|
|
142
|
+
try {
|
|
143
|
+
const taskPath = path.join(runDir, "tasks", effectId, "task.json");
|
|
144
|
+
const raw = await node_fs_1.promises.readFile(taskPath, "utf-8");
|
|
145
|
+
const taskDef = JSON.parse(raw);
|
|
146
|
+
title = typeof taskDef.title === "string" ? taskDef.title : undefined;
|
|
147
|
+
kind = typeof taskDef.kind === "string" ? taskDef.kind : undefined;
|
|
148
|
+
taskId = typeof taskDef.taskId === "string" ? taskDef.taskId : undefined;
|
|
149
|
+
labels = Array.isArray(taskDef.labels) ? taskDef.labels : undefined;
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// Task def may not exist for all effect types
|
|
153
|
+
kind = typeof req.data.kind === "string" ? req.data.kind : undefined;
|
|
154
|
+
taskId = typeof req.data.taskId === "string" ? req.data.taskId : undefined;
|
|
155
|
+
}
|
|
156
|
+
items.push({
|
|
157
|
+
effectId,
|
|
158
|
+
taskId,
|
|
159
|
+
kind,
|
|
160
|
+
title,
|
|
161
|
+
requestedAt: req.requestedAt,
|
|
162
|
+
ageMs: now - reqTs,
|
|
163
|
+
labels,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
// Sort by age descending (oldest first)
|
|
167
|
+
items.sort((a, b) => b.ageMs - a.ageMs);
|
|
168
|
+
return items;
|
|
169
|
+
}
|