@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,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cost tracking type definitions and pricing constants for Babysitter SDK.
|
|
4
|
+
*
|
|
5
|
+
* Covers Anthropic Claude API token usage structures as seen in Claude Code
|
|
6
|
+
* session JSONL files, plus aggregation interfaces for run-level and
|
|
7
|
+
* cross-run cost reporting.
|
|
8
|
+
*
|
|
9
|
+
* Pricing source: https://docs.anthropic.com/en/docs/about-claude/pricing
|
|
10
|
+
* Last verified: 2026-04-05
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.MODEL_PRICING_EXTENDED = exports.MODEL_PRICING = void 0;
|
|
14
|
+
exports.calculateCostUsd = calculateCostUsd;
|
|
15
|
+
exports.calculateCostUsdExtended = calculateCostUsdExtended;
|
|
16
|
+
/**
|
|
17
|
+
* Pricing table for known Claude models.
|
|
18
|
+
*
|
|
19
|
+
* Keys use the API model identifier format (e.g. "claude-opus-4-6").
|
|
20
|
+
* Pricing sourced from https://docs.anthropic.com/en/docs/about-claude/pricing
|
|
21
|
+
*
|
|
22
|
+
* Cache-creation rates default to the 5-minute write multiplier (1.25x input).
|
|
23
|
+
* For fine-grained 5m vs 1h cost splits, use {@link MODEL_PRICING_EXTENDED}.
|
|
24
|
+
*/
|
|
25
|
+
exports.MODEL_PRICING = {
|
|
26
|
+
// --- Opus family ---
|
|
27
|
+
"claude-opus-4-6": {
|
|
28
|
+
inputPer1M: 5,
|
|
29
|
+
outputPer1M: 25,
|
|
30
|
+
cacheCreationPer1M: 6.25, // 1.25x input
|
|
31
|
+
cacheReadPer1M: 0.5, // 0.1x input
|
|
32
|
+
},
|
|
33
|
+
"claude-opus-4-5": {
|
|
34
|
+
inputPer1M: 5,
|
|
35
|
+
outputPer1M: 25,
|
|
36
|
+
cacheCreationPer1M: 6.25,
|
|
37
|
+
cacheReadPer1M: 0.5,
|
|
38
|
+
},
|
|
39
|
+
"claude-opus-4-1": {
|
|
40
|
+
inputPer1M: 15,
|
|
41
|
+
outputPer1M: 75,
|
|
42
|
+
cacheCreationPer1M: 18.75,
|
|
43
|
+
cacheReadPer1M: 1.5,
|
|
44
|
+
},
|
|
45
|
+
"claude-opus-4-0": {
|
|
46
|
+
inputPer1M: 15,
|
|
47
|
+
outputPer1M: 75,
|
|
48
|
+
cacheCreationPer1M: 18.75,
|
|
49
|
+
cacheReadPer1M: 1.5,
|
|
50
|
+
},
|
|
51
|
+
// --- Sonnet family ---
|
|
52
|
+
"claude-sonnet-4-6": {
|
|
53
|
+
inputPer1M: 3,
|
|
54
|
+
outputPer1M: 15,
|
|
55
|
+
cacheCreationPer1M: 3.75,
|
|
56
|
+
cacheReadPer1M: 0.3,
|
|
57
|
+
},
|
|
58
|
+
"claude-sonnet-4-5": {
|
|
59
|
+
inputPer1M: 3,
|
|
60
|
+
outputPer1M: 15,
|
|
61
|
+
cacheCreationPer1M: 3.75,
|
|
62
|
+
cacheReadPer1M: 0.3,
|
|
63
|
+
},
|
|
64
|
+
"claude-sonnet-4-0": {
|
|
65
|
+
inputPer1M: 3,
|
|
66
|
+
outputPer1M: 15,
|
|
67
|
+
cacheCreationPer1M: 3.75,
|
|
68
|
+
cacheReadPer1M: 0.3,
|
|
69
|
+
},
|
|
70
|
+
// --- Haiku family ---
|
|
71
|
+
"claude-haiku-4-5": {
|
|
72
|
+
inputPer1M: 1,
|
|
73
|
+
outputPer1M: 5,
|
|
74
|
+
cacheCreationPer1M: 1.25,
|
|
75
|
+
cacheReadPer1M: 0.1,
|
|
76
|
+
},
|
|
77
|
+
"claude-haiku-3-5": {
|
|
78
|
+
inputPer1M: 0.8,
|
|
79
|
+
outputPer1M: 4,
|
|
80
|
+
cacheCreationPer1M: 1,
|
|
81
|
+
cacheReadPer1M: 0.08,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
exports.MODEL_PRICING_EXTENDED = {
|
|
85
|
+
"claude-opus-4-6": {
|
|
86
|
+
inputPer1M: 5,
|
|
87
|
+
outputPer1M: 25,
|
|
88
|
+
cacheCreationPer1M: 6.25,
|
|
89
|
+
cacheCreation5mPer1M: 6.25,
|
|
90
|
+
cacheCreation1hPer1M: 10,
|
|
91
|
+
cacheReadPer1M: 0.5,
|
|
92
|
+
},
|
|
93
|
+
"claude-opus-4-5": {
|
|
94
|
+
inputPer1M: 5,
|
|
95
|
+
outputPer1M: 25,
|
|
96
|
+
cacheCreationPer1M: 6.25,
|
|
97
|
+
cacheCreation5mPer1M: 6.25,
|
|
98
|
+
cacheCreation1hPer1M: 10,
|
|
99
|
+
cacheReadPer1M: 0.5,
|
|
100
|
+
},
|
|
101
|
+
"claude-opus-4-1": {
|
|
102
|
+
inputPer1M: 15,
|
|
103
|
+
outputPer1M: 75,
|
|
104
|
+
cacheCreationPer1M: 18.75,
|
|
105
|
+
cacheCreation5mPer1M: 18.75,
|
|
106
|
+
cacheCreation1hPer1M: 30,
|
|
107
|
+
cacheReadPer1M: 1.5,
|
|
108
|
+
},
|
|
109
|
+
"claude-opus-4-0": {
|
|
110
|
+
inputPer1M: 15,
|
|
111
|
+
outputPer1M: 75,
|
|
112
|
+
cacheCreationPer1M: 18.75,
|
|
113
|
+
cacheCreation5mPer1M: 18.75,
|
|
114
|
+
cacheCreation1hPer1M: 30,
|
|
115
|
+
cacheReadPer1M: 1.5,
|
|
116
|
+
},
|
|
117
|
+
"claude-sonnet-4-6": {
|
|
118
|
+
inputPer1M: 3,
|
|
119
|
+
outputPer1M: 15,
|
|
120
|
+
cacheCreationPer1M: 3.75,
|
|
121
|
+
cacheCreation5mPer1M: 3.75,
|
|
122
|
+
cacheCreation1hPer1M: 6,
|
|
123
|
+
cacheReadPer1M: 0.3,
|
|
124
|
+
},
|
|
125
|
+
"claude-sonnet-4-5": {
|
|
126
|
+
inputPer1M: 3,
|
|
127
|
+
outputPer1M: 15,
|
|
128
|
+
cacheCreationPer1M: 3.75,
|
|
129
|
+
cacheCreation5mPer1M: 3.75,
|
|
130
|
+
cacheCreation1hPer1M: 6,
|
|
131
|
+
cacheReadPer1M: 0.3,
|
|
132
|
+
},
|
|
133
|
+
"claude-sonnet-4-0": {
|
|
134
|
+
inputPer1M: 3,
|
|
135
|
+
outputPer1M: 15,
|
|
136
|
+
cacheCreationPer1M: 3.75,
|
|
137
|
+
cacheCreation5mPer1M: 3.75,
|
|
138
|
+
cacheCreation1hPer1M: 6,
|
|
139
|
+
cacheReadPer1M: 0.3,
|
|
140
|
+
},
|
|
141
|
+
"claude-haiku-4-5": {
|
|
142
|
+
inputPer1M: 1,
|
|
143
|
+
outputPer1M: 5,
|
|
144
|
+
cacheCreationPer1M: 1.25,
|
|
145
|
+
cacheCreation5mPer1M: 1.25,
|
|
146
|
+
cacheCreation1hPer1M: 2,
|
|
147
|
+
cacheReadPer1M: 0.1,
|
|
148
|
+
},
|
|
149
|
+
"claude-haiku-3-5": {
|
|
150
|
+
inputPer1M: 0.8,
|
|
151
|
+
outputPer1M: 4,
|
|
152
|
+
cacheCreationPer1M: 1,
|
|
153
|
+
cacheCreation5mPer1M: 1,
|
|
154
|
+
cacheCreation1hPer1M: 1.6,
|
|
155
|
+
cacheReadPer1M: 0.08,
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* Resolve pricing for a model identifier.
|
|
160
|
+
*
|
|
161
|
+
* Handles common variations: the API may return "claude-opus-4-6-20260301"
|
|
162
|
+
* or similar dated suffixes. We strip the date and try progressively
|
|
163
|
+
* shorter prefixes until we find a match.
|
|
164
|
+
*/
|
|
165
|
+
function resolvePricing(model) {
|
|
166
|
+
// Direct match first.
|
|
167
|
+
if (exports.MODEL_PRICING[model])
|
|
168
|
+
return exports.MODEL_PRICING[model];
|
|
169
|
+
// Strip date suffix (e.g. "claude-opus-4-6-20260301" -> "claude-opus-4-6").
|
|
170
|
+
const withoutDate = model.replace(/-\d{8}$/, "");
|
|
171
|
+
if (exports.MODEL_PRICING[withoutDate])
|
|
172
|
+
return exports.MODEL_PRICING[withoutDate];
|
|
173
|
+
// Try prefix matching (longest first).
|
|
174
|
+
const keys = Object.keys(exports.MODEL_PRICING).sort((a, b) => b.length - a.length);
|
|
175
|
+
for (const key of keys) {
|
|
176
|
+
if (withoutDate.startsWith(key))
|
|
177
|
+
return exports.MODEL_PRICING[key];
|
|
178
|
+
}
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Calculate the USD cost for a single API interaction.
|
|
183
|
+
*
|
|
184
|
+
* Uses the blended cache-creation rate from {@link MODEL_PRICING}.
|
|
185
|
+
* For fine-grained 5m/1h splits, use {@link calculateCostUsdExtended}.
|
|
186
|
+
*
|
|
187
|
+
* @returns Cost in USD, or `undefined` if the model is unknown.
|
|
188
|
+
*/
|
|
189
|
+
function calculateCostUsd(model, inputTokens, outputTokens, cacheCreationTokens, cacheReadTokens) {
|
|
190
|
+
const pricing = resolvePricing(model);
|
|
191
|
+
if (!pricing)
|
|
192
|
+
return undefined;
|
|
193
|
+
const cost = (inputTokens / 1_000_000) * pricing.inputPer1M +
|
|
194
|
+
(outputTokens / 1_000_000) * pricing.outputPer1M +
|
|
195
|
+
(cacheCreationTokens / 1_000_000) * pricing.cacheCreationPer1M +
|
|
196
|
+
(cacheReadTokens / 1_000_000) * pricing.cacheReadPer1M;
|
|
197
|
+
return Math.round(cost * 1_000_000) / 1_000_000; // 6 decimal places
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Calculate the USD cost with separate 5-minute and 1-hour cache write rates.
|
|
201
|
+
*
|
|
202
|
+
* Use when the Anthropic API response includes the `cache_creation` sub-object
|
|
203
|
+
* with `ephemeral_5m_input_tokens` and `ephemeral_1h_input_tokens`.
|
|
204
|
+
*
|
|
205
|
+
* @returns Cost in USD, or `undefined` if the model is unknown.
|
|
206
|
+
*/
|
|
207
|
+
function calculateCostUsdExtended(model, inputTokens, outputTokens, cacheCreation5mTokens, cacheCreation1hTokens, cacheReadTokens) {
|
|
208
|
+
const pricing = exports.MODEL_PRICING_EXTENDED[model] ?? (() => {
|
|
209
|
+
// Fall back to base pricing with derived 1h rate (2x input).
|
|
210
|
+
const base = resolvePricing(model);
|
|
211
|
+
if (!base)
|
|
212
|
+
return undefined;
|
|
213
|
+
return {
|
|
214
|
+
...base,
|
|
215
|
+
cacheCreation5mPer1M: base.cacheCreationPer1M,
|
|
216
|
+
cacheCreation1hPer1M: base.inputPer1M * 2,
|
|
217
|
+
};
|
|
218
|
+
})();
|
|
219
|
+
if (!pricing)
|
|
220
|
+
return undefined;
|
|
221
|
+
const ext = pricing;
|
|
222
|
+
const cost = (inputTokens / 1_000_000) * ext.inputPer1M +
|
|
223
|
+
(outputTokens / 1_000_000) * ext.outputPer1M +
|
|
224
|
+
(cacheCreation5mTokens / 1_000_000) * ext.cacheCreation5mPer1M +
|
|
225
|
+
(cacheCreation1hTokens / 1_000_000) * ext.cacheCreation1hPer1M +
|
|
226
|
+
(cacheReadTokens / 1_000_000) * ext.cacheReadPer1M;
|
|
227
|
+
return Math.round(cost * 1_000_000) / 1_000_000;
|
|
228
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared automation-rule execution path for daemon timer and webhook triggers.
|
|
3
|
+
*/
|
|
4
|
+
import type { AutomationExecutionRecord } from "@a5c-ai/agent-comm-mux";
|
|
5
|
+
import type { AutomationTriggerEvent } from "./types";
|
|
6
|
+
type StoredAutomationExecutionRecord = Omit<AutomationExecutionRecord, "status" | "reason"> & {
|
|
7
|
+
readonly status: AutomationExecutionRecord["status"] | "skipped";
|
|
8
|
+
readonly skipReason?: string;
|
|
9
|
+
};
|
|
10
|
+
export interface ExecuteAutomationTriggerOptions {
|
|
11
|
+
backlogFilePath?: string;
|
|
12
|
+
now?: () => string;
|
|
13
|
+
}
|
|
14
|
+
export declare function executeAutomationTrigger(event: AutomationTriggerEvent, options?: ExecuteAutomationTriggerOptions): Promise<StoredAutomationExecutionRecord>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=automationExecutor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"automationExecutor.d.ts","sourceRoot":"","sources":["../../src/daemon/automationExecutor.ts"],"names":[],"mappings":"AAAA;;GAEG;AAOH,OAAO,KAAK,EACV,yBAAyB,EAY1B,MAAM,wBAAwB,CAAC;AAEhC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AA8CtD,KAAK,+BAA+B,GAAG,IAAI,CAAC,yBAAyB,EAAE,QAAQ,GAAG,QAAQ,CAAC,GAAG;IAC5F,QAAQ,CAAC,MAAM,EAAE,yBAAyB,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC;IACjE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AASF,MAAM,WAAW,+BAA+B;IAC9C,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AA4LD,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,sBAAsB,EAC7B,OAAO,GAAE,+BAAoC,GAC5C,OAAO,CAAC,+BAA+B,CAAC,CA4E1C"}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared automation-rule execution path for daemon timer and webhook triggers.
|
|
4
|
+
*/
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.executeAutomationTrigger = executeAutomationTrigger;
|
|
10
|
+
const node_fs_1 = require("node:fs");
|
|
11
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
12
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
const node_crypto_1 = require("node:crypto");
|
|
14
|
+
const DEFAULT_BACKLOG_FILE_PATH = process.env.KANBAN_BACKLOG_FILE
|
|
15
|
+
?? node_path_1.default.join(node_os_1.default.homedir(), ".a5c", "kanban-backlog.json");
|
|
16
|
+
function cloneRecord(value) {
|
|
17
|
+
return value ? { ...value } : undefined;
|
|
18
|
+
}
|
|
19
|
+
async function readAutomationStorage(backlogFilePath) {
|
|
20
|
+
try {
|
|
21
|
+
const raw = await node_fs_1.promises.readFile(backlogFilePath, "utf8");
|
|
22
|
+
return JSON.parse(raw);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
const errno = error;
|
|
26
|
+
if (errno.code === "ENOENT") {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async function writeAutomationStorage(backlogFilePath, payload) {
|
|
33
|
+
await node_fs_1.promises.mkdir(node_path_1.default.dirname(backlogFilePath), { recursive: true });
|
|
34
|
+
await node_fs_1.promises.writeFile(backlogFilePath, `${JSON.stringify(payload, null, 2)}\n`, "utf8");
|
|
35
|
+
}
|
|
36
|
+
function createTriggerMetadata(rule) {
|
|
37
|
+
if (rule.trigger.type === "timer") {
|
|
38
|
+
return {
|
|
39
|
+
triggerType: "timer",
|
|
40
|
+
cron: rule.trigger.cron,
|
|
41
|
+
timezone: rule.trigger.timezone,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
triggerType: "webhook",
|
|
46
|
+
port: rule.trigger.port,
|
|
47
|
+
path: rule.trigger.path ?? "/trigger",
|
|
48
|
+
method: rule.trigger.method ?? "POST",
|
|
49
|
+
sourceEvent: rule.trigger.sourceEvent,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function nextIssueNumber(project, issues) {
|
|
53
|
+
const prefix = `${project.key}-AUTO-`;
|
|
54
|
+
return issues.reduce((max, issue) => {
|
|
55
|
+
if (!issue.key.startsWith(prefix)) {
|
|
56
|
+
return max;
|
|
57
|
+
}
|
|
58
|
+
const rawNumber = issue.key.slice(prefix.length);
|
|
59
|
+
const parsed = Number.parseInt(rawNumber, 10);
|
|
60
|
+
return Number.isFinite(parsed) ? Math.max(max, parsed) : max;
|
|
61
|
+
}, 0) + 1;
|
|
62
|
+
}
|
|
63
|
+
function resolveProjectCollections(project, template) {
|
|
64
|
+
const labelsById = new Map(project.labels.map((label) => [label.id, label]));
|
|
65
|
+
const assigneesById = new Map(project.assignees.map((assignee) => [assignee.id, assignee]));
|
|
66
|
+
return {
|
|
67
|
+
labels: (template.labelIds ?? [])
|
|
68
|
+
.map((labelId) => labelsById.get(labelId))
|
|
69
|
+
.filter((label) => Boolean(label)),
|
|
70
|
+
assignees: (template.assigneeIds ?? [])
|
|
71
|
+
.map((assigneeId) => assigneesById.get(assigneeId))
|
|
72
|
+
.filter((assignee) => Boolean(assignee)),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function resolveIssueSource(rule) {
|
|
76
|
+
if (rule.template.issueSource) {
|
|
77
|
+
return { ...rule.template.issueSource };
|
|
78
|
+
}
|
|
79
|
+
if (rule.source.kind === "config-file") {
|
|
80
|
+
return {
|
|
81
|
+
kind: "file",
|
|
82
|
+
path: rule.source.path,
|
|
83
|
+
externalId: rule.source.externalId ?? rule.id,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
kind: "run-derived",
|
|
88
|
+
externalId: rule.source.externalId ?? rule.id,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function createAcceptanceCriteria(issueId, criteria) {
|
|
92
|
+
return (criteria ?? []).map((title, index) => ({
|
|
93
|
+
id: `${issueId}-ac-${index + 1}`,
|
|
94
|
+
title,
|
|
95
|
+
satisfied: false,
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
function createDecomposition(issueId, items) {
|
|
99
|
+
return (items ?? []).map((item, index) => ({
|
|
100
|
+
id: `${issueId}-decomp-${index + 1}`,
|
|
101
|
+
title: item.title,
|
|
102
|
+
kind: item.kind,
|
|
103
|
+
status: item.status,
|
|
104
|
+
issueId: undefined,
|
|
105
|
+
}));
|
|
106
|
+
}
|
|
107
|
+
function createAutomationIssue(rule, project, issues, now) {
|
|
108
|
+
const sequence = nextIssueNumber(project, issues);
|
|
109
|
+
const issueKey = `${project.key}-AUTO-${String(sequence).padStart(3, "0")}`;
|
|
110
|
+
const issueId = issueKey;
|
|
111
|
+
const { labels, assignees } = resolveProjectCollections(project, rule.template);
|
|
112
|
+
return {
|
|
113
|
+
id: issueId,
|
|
114
|
+
key: issueKey,
|
|
115
|
+
projectId: rule.target.projectId,
|
|
116
|
+
title: rule.template.title,
|
|
117
|
+
summary: rule.template.summary,
|
|
118
|
+
description: rule.template.description,
|
|
119
|
+
status: rule.template.status ?? "backlog",
|
|
120
|
+
priority: rule.template.priority ?? "medium",
|
|
121
|
+
labels,
|
|
122
|
+
assignees,
|
|
123
|
+
dependencies: [],
|
|
124
|
+
acceptanceCriteria: createAcceptanceCriteria(issueId, rule.template.acceptanceCriteria),
|
|
125
|
+
decomposition: createDecomposition(issueId, rule.template.decomposition),
|
|
126
|
+
childIssueIds: [],
|
|
127
|
+
createdAt: now,
|
|
128
|
+
updatedAt: now,
|
|
129
|
+
source: resolveIssueSource(rule),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
function createExecutionRecord(rule, event, now, overrides) {
|
|
133
|
+
return {
|
|
134
|
+
id: `automation-exec-${(0, node_crypto_1.randomUUID)().toLowerCase()}`,
|
|
135
|
+
ruleId: rule.id,
|
|
136
|
+
ruleName: rule.name,
|
|
137
|
+
triggerType: rule.trigger.type,
|
|
138
|
+
status: overrides.status,
|
|
139
|
+
triggeredAt: now,
|
|
140
|
+
triggeredBy: `daemon-${rule.trigger.type}`,
|
|
141
|
+
source: {
|
|
142
|
+
...rule.source,
|
|
143
|
+
metadata: cloneRecord(rule.source.metadata),
|
|
144
|
+
},
|
|
145
|
+
projectId: rule.target.projectId,
|
|
146
|
+
boardProjectId: rule.target.boardProjectId,
|
|
147
|
+
issueId: overrides.issue?.id,
|
|
148
|
+
issueKey: overrides.issue?.key,
|
|
149
|
+
issueSource: overrides.issue?.source,
|
|
150
|
+
stateAtExecution: rule.state,
|
|
151
|
+
skipReason: overrides.skipReason,
|
|
152
|
+
inputs: event.inputs ? { ...event.inputs } : undefined,
|
|
153
|
+
metadata: createTriggerMetadata(rule),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
async function executeAutomationTrigger(event, options = {}) {
|
|
157
|
+
const backlogFilePath = options.backlogFilePath ?? DEFAULT_BACKLOG_FILE_PATH;
|
|
158
|
+
const now = options.now?.() ?? new Date().toISOString();
|
|
159
|
+
const storage = await readAutomationStorage(backlogFilePath);
|
|
160
|
+
const rules = [...(storage.automationRules ?? [])];
|
|
161
|
+
const rule = rules.find((candidate) => candidate.id === event.rule.id) ?? event.rule;
|
|
162
|
+
if (rule.state !== "active") {
|
|
163
|
+
const execution = createExecutionRecord(rule, event, now, {
|
|
164
|
+
status: "skipped",
|
|
165
|
+
skipReason: `Rule ${rule.id} is ${rule.state}.`,
|
|
166
|
+
});
|
|
167
|
+
await writeAutomationStorage(backlogFilePath, {
|
|
168
|
+
...storage,
|
|
169
|
+
automationExecutions: [...(storage.automationExecutions ?? []), execution],
|
|
170
|
+
});
|
|
171
|
+
return execution;
|
|
172
|
+
}
|
|
173
|
+
const projects = [...(storage.projects ?? [])];
|
|
174
|
+
const issueProject = projects.find((candidate) => candidate.id === rule.target.projectId);
|
|
175
|
+
const boardProject = projects.find((candidate) => candidate.id === rule.target.boardProjectId);
|
|
176
|
+
if (!issueProject || !boardProject) {
|
|
177
|
+
const missingTarget = !issueProject
|
|
178
|
+
? `Project ${rule.target.projectId}`
|
|
179
|
+
: `Board project ${rule.target.boardProjectId}`;
|
|
180
|
+
const execution = createExecutionRecord(rule, event, now, {
|
|
181
|
+
status: "skipped",
|
|
182
|
+
skipReason: `${missingTarget} not found.`,
|
|
183
|
+
});
|
|
184
|
+
await writeAutomationStorage(backlogFilePath, {
|
|
185
|
+
...storage,
|
|
186
|
+
automationExecutions: [...(storage.automationExecutions ?? []), execution],
|
|
187
|
+
});
|
|
188
|
+
return execution;
|
|
189
|
+
}
|
|
190
|
+
const issues = [...(storage.issues ?? [])];
|
|
191
|
+
const issue = createAutomationIssue(rule, issueProject, issues, now);
|
|
192
|
+
const execution = createExecutionRecord(rule, event, now, {
|
|
193
|
+
status: "created",
|
|
194
|
+
issue,
|
|
195
|
+
});
|
|
196
|
+
const nextRules = rules.length > 0
|
|
197
|
+
? rules.map((candidate) => (candidate.id === rule.id
|
|
198
|
+
? {
|
|
199
|
+
...candidate,
|
|
200
|
+
audit: {
|
|
201
|
+
...candidate.audit,
|
|
202
|
+
lastTriggeredAt: now,
|
|
203
|
+
lastTriggeredBy: execution.triggeredBy,
|
|
204
|
+
},
|
|
205
|
+
}
|
|
206
|
+
: candidate))
|
|
207
|
+
: storage.automationRules;
|
|
208
|
+
const nextProjects = projects.map((candidate) => (candidate.id === issueProject.id || candidate.id === boardProject.id
|
|
209
|
+
? {
|
|
210
|
+
...candidate,
|
|
211
|
+
issueIds: Array.from(new Set([...candidate.issueIds, issue.id])),
|
|
212
|
+
}
|
|
213
|
+
: candidate));
|
|
214
|
+
await writeAutomationStorage(backlogFilePath, {
|
|
215
|
+
...storage,
|
|
216
|
+
projects: nextProjects,
|
|
217
|
+
issues: [...issues, issue],
|
|
218
|
+
automationRules: nextRules,
|
|
219
|
+
automationExecutions: [...(storage.automationExecutions ?? []), execution],
|
|
220
|
+
});
|
|
221
|
+
return execution;
|
|
222
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GAP-REMOTE-001: Daemon Config — load/validate/write daemon configuration.
|
|
3
|
+
*/
|
|
4
|
+
import type { ApiResult } from "../api/runs";
|
|
5
|
+
import type { DaemonConfig } from "./types";
|
|
6
|
+
export declare function loadDaemonConfig(configPath: string): Promise<ApiResult<DaemonConfig>>;
|
|
7
|
+
export declare function writeDaemonConfig(config: DaemonConfig, configPath: string): Promise<ApiResult<void>>;
|
|
8
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/daemon/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAkJ5C,wBAAsB,gBAAgB,CACpC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CA0BlC;AAED,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAgB1B"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* GAP-REMOTE-001: Daemon Config — load/validate/write daemon configuration.
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.loadDaemonConfig = loadDaemonConfig;
|
|
40
|
+
exports.writeDaemonConfig = writeDaemonConfig;
|
|
41
|
+
const node_fs_1 = require("node:fs");
|
|
42
|
+
const path = __importStar(require("node:path"));
|
|
43
|
+
const utils_1 = require("../api/utils");
|
|
44
|
+
const VALID_TRIGGER_TYPES = new Set(["file", "webhook", "timer"]);
|
|
45
|
+
const VALID_AUTOMATION_STATES = new Set(["draft", "active", "paused", "disabled", "archived"]);
|
|
46
|
+
const DEFAULT_MAX_CONCURRENT_RUNS = 4;
|
|
47
|
+
function isRecord(value) {
|
|
48
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
49
|
+
}
|
|
50
|
+
function isUnknownArray(value) {
|
|
51
|
+
return Array.isArray(value);
|
|
52
|
+
}
|
|
53
|
+
function validateFileTrigger(raw, index) {
|
|
54
|
+
if (!isRecord(raw)) {
|
|
55
|
+
return `Trigger at index ${index} must be an object`;
|
|
56
|
+
}
|
|
57
|
+
if (raw.type !== "file") {
|
|
58
|
+
return `Invalid trigger type at index ${index}: ${String(raw.type)}. Must be one of: file, webhook, timer`;
|
|
59
|
+
}
|
|
60
|
+
if (typeof raw.processId !== "string" || !raw.processId) {
|
|
61
|
+
return `Missing processId at trigger index ${index}`;
|
|
62
|
+
}
|
|
63
|
+
if (typeof raw.entrypoint !== "string" || !raw.entrypoint) {
|
|
64
|
+
return `Missing entrypoint at trigger index ${index}`;
|
|
65
|
+
}
|
|
66
|
+
if (typeof raw.pattern !== "string" || !raw.pattern) {
|
|
67
|
+
return `Missing pattern at trigger index ${index}`;
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
function validateAutomationRule(raw, index) {
|
|
72
|
+
if (!isRecord(raw)) {
|
|
73
|
+
return `Trigger at index ${index} must be an object`;
|
|
74
|
+
}
|
|
75
|
+
if (typeof raw.id !== "string" || !raw.id) {
|
|
76
|
+
return `Missing automation rule id at trigger index ${index}`;
|
|
77
|
+
}
|
|
78
|
+
if (typeof raw.name !== "string" || !raw.name) {
|
|
79
|
+
return `Missing automation rule name at trigger index ${index}`;
|
|
80
|
+
}
|
|
81
|
+
if (typeof raw.state !== "string" || !VALID_AUTOMATION_STATES.has(raw.state)) {
|
|
82
|
+
return `Invalid automation state at trigger index ${index}: ${String(raw.state)}`;
|
|
83
|
+
}
|
|
84
|
+
const trigger = raw.trigger;
|
|
85
|
+
if (!isRecord(trigger) || typeof trigger.type !== "string" || !VALID_TRIGGER_TYPES.has(trigger.type)) {
|
|
86
|
+
return `Invalid automation trigger type at index ${index}: ${String(isRecord(trigger) ? trigger.type : trigger)}`;
|
|
87
|
+
}
|
|
88
|
+
if (trigger.type === "file") {
|
|
89
|
+
return `Automation rules do not support file triggers at index ${index}`;
|
|
90
|
+
}
|
|
91
|
+
if (trigger.type === "timer" && (typeof trigger.cron !== "string" || !trigger.cron)) {
|
|
92
|
+
return `Missing cron for timer automation at trigger index ${index}`;
|
|
93
|
+
}
|
|
94
|
+
if (trigger.type === "webhook") {
|
|
95
|
+
if (typeof trigger.port !== "number" || trigger.port <= 0) {
|
|
96
|
+
return `Missing port for webhook automation at trigger index ${index}`;
|
|
97
|
+
}
|
|
98
|
+
if (trigger.path !== undefined && (typeof trigger.path !== "string" || !trigger.path)) {
|
|
99
|
+
return `Invalid webhook path at trigger index ${index}`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const target = raw.target;
|
|
103
|
+
if (!isRecord(target) || typeof target.projectId !== "string" || !target.projectId) {
|
|
104
|
+
return `Missing target.projectId at trigger index ${index}`;
|
|
105
|
+
}
|
|
106
|
+
if (typeof target.boardProjectId !== "string" || !target.boardProjectId) {
|
|
107
|
+
return `Missing target.boardProjectId at trigger index ${index}`;
|
|
108
|
+
}
|
|
109
|
+
const template = raw.template;
|
|
110
|
+
if (!isRecord(template) || typeof template.title !== "string" || !template.title) {
|
|
111
|
+
return `Missing template.title at trigger index ${index}`;
|
|
112
|
+
}
|
|
113
|
+
const routing = raw.routing;
|
|
114
|
+
if (!isRecord(routing)) {
|
|
115
|
+
return `Missing routing block at trigger index ${index}`;
|
|
116
|
+
}
|
|
117
|
+
if (!isRecord(routing.issue) || routing.issue.action !== "canonical-issue-create") {
|
|
118
|
+
return `Invalid routing.issue action at trigger index ${index}`;
|
|
119
|
+
}
|
|
120
|
+
if (!isRecord(routing.board) || routing.board.action !== "shared-board-derive") {
|
|
121
|
+
return `Invalid routing.board action at trigger index ${index}`;
|
|
122
|
+
}
|
|
123
|
+
if (routing.mutateBoardDirectly !== false) {
|
|
124
|
+
return `Automation routing must disable direct board mutation at trigger index ${index}`;
|
|
125
|
+
}
|
|
126
|
+
const source = raw.source;
|
|
127
|
+
if (!isRecord(source) || typeof source.kind !== "string" || !source.kind) {
|
|
128
|
+
return `Missing source.kind at trigger index ${index}`;
|
|
129
|
+
}
|
|
130
|
+
const audit = raw.audit;
|
|
131
|
+
if (!isRecord(audit) || typeof audit.createdAt !== "string" || !audit.createdAt) {
|
|
132
|
+
return `Missing audit.createdAt at trigger index ${index}`;
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
function validateConfig(raw) {
|
|
137
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) {
|
|
138
|
+
return { valid: false, error: "Config must be a JSON object" };
|
|
139
|
+
}
|
|
140
|
+
const obj = raw;
|
|
141
|
+
if (typeof obj.workspace !== "string" || !obj.workspace) {
|
|
142
|
+
return { valid: false, error: "Missing required field: workspace" };
|
|
143
|
+
}
|
|
144
|
+
if (!isUnknownArray(obj.triggers)) {
|
|
145
|
+
return { valid: false, error: "Missing required field: triggers (must be an array)" };
|
|
146
|
+
}
|
|
147
|
+
for (let i = 0; i < obj.triggers.length; i++) {
|
|
148
|
+
const trigger = obj.triggers[i];
|
|
149
|
+
const error = isRecord(trigger) && trigger.type === "file"
|
|
150
|
+
? validateFileTrigger(trigger, i)
|
|
151
|
+
: validateAutomationRule(trigger, i);
|
|
152
|
+
if (error) {
|
|
153
|
+
return { valid: false, error };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const maxConcurrent = typeof obj.maxConcurrentRuns === "number"
|
|
157
|
+
? obj.maxConcurrentRuns
|
|
158
|
+
: DEFAULT_MAX_CONCURRENT_RUNS;
|
|
159
|
+
return {
|
|
160
|
+
valid: true,
|
|
161
|
+
config: {
|
|
162
|
+
workspace: obj.workspace,
|
|
163
|
+
triggers: obj.triggers,
|
|
164
|
+
maxConcurrentRuns: maxConcurrent,
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
async function loadDaemonConfig(configPath) {
|
|
169
|
+
try {
|
|
170
|
+
let raw;
|
|
171
|
+
try {
|
|
172
|
+
raw = await node_fs_1.promises.readFile(configPath, "utf-8");
|
|
173
|
+
}
|
|
174
|
+
catch {
|
|
175
|
+
return (0, utils_1.fail)("CONFIG_NOT_FOUND", `Config file not found: ${configPath}`);
|
|
176
|
+
}
|
|
177
|
+
let parsed;
|
|
178
|
+
try {
|
|
179
|
+
parsed = JSON.parse(raw);
|
|
180
|
+
}
|
|
181
|
+
catch {
|
|
182
|
+
return (0, utils_1.fail)("INVALID_CONFIG", `Failed to parse config as JSON: ${configPath}`);
|
|
183
|
+
}
|
|
184
|
+
const result = validateConfig(parsed);
|
|
185
|
+
if (!result.valid) {
|
|
186
|
+
return (0, utils_1.fail)("INVALID_CONFIG", result.error);
|
|
187
|
+
}
|
|
188
|
+
return (0, utils_1.ok)(result.config);
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
192
|
+
return (0, utils_1.fail)("INTERNAL_ERROR", msg);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
async function writeDaemonConfig(config, configPath) {
|
|
196
|
+
try {
|
|
197
|
+
const dir = path.dirname(configPath);
|
|
198
|
+
await node_fs_1.promises.mkdir(dir, { recursive: true });
|
|
199
|
+
const content = JSON.stringify(config, null, 2);
|
|
200
|
+
const tmpPath = `${configPath}.tmp-${process.pid}-${Date.now()}`;
|
|
201
|
+
await node_fs_1.promises.writeFile(tmpPath, content, "utf-8");
|
|
202
|
+
await node_fs_1.promises.rename(tmpPath, configPath);
|
|
203
|
+
return (0, utils_1.ok)(undefined);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
207
|
+
return (0, utils_1.fail)("INTERNAL_ERROR", msg);
|
|
208
|
+
}
|
|
209
|
+
}
|