@a5c-ai/agent-platform 5.0.1-staging.016f0b0e8119
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 +48 -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/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 +9 -0
- package/dist/daemon/index.d.ts.map +1 -0
- package/dist/daemon/index.js +25 -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 +18 -0
- package/dist/harness/index.d.ts.map +1 -0
- package/dist/harness/index.js +91 -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 +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -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/plugins/index.d.ts +11 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +18 -0
- package/dist/plugins/loader.d.ts +37 -0
- package/dist/plugins/loader.d.ts.map +1 -0
- package/dist/plugins/loader.js +112 -0
- package/dist/plugins/sandbox.d.ts +38 -0
- package/dist/plugins/sandbox.d.ts.map +1 -0
- package/dist/plugins/sandbox.js +109 -0
- package/dist/plugins/types.d.ts +27 -0
- package/dist/plugins/types.d.ts.map +1 -0
- package/dist/plugins/types.js +7 -0
- package/dist/plugins/version-check.d.ts +23 -0
- package/dist/plugins/version-check.d.ts.map +1 -0
- package/dist/plugins/version-check.js +70 -0
- package/dist/processes/index.d.ts +12 -0
- package/dist/processes/index.d.ts.map +1 -0
- package/dist/processes/index.js +15 -0
- package/dist/processes/recommender.d.ts +36 -0
- package/dist/processes/recommender.d.ts.map +1 -0
- package/dist/processes/recommender.js +73 -0
- package/dist/processes/scorer.d.ts +26 -0
- package/dist/processes/scorer.d.ts.map +1 -0
- package/dist/processes/scorer.js +104 -0
- package/dist/processes/types.d.ts +48 -0
- package/dist/processes/types.d.ts.map +1 -0
- package/dist/processes/types.js +9 -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 +63 -0
- package/dist/seams/contract.d.ts.map +1 -0
- package/dist/seams/contract.js +138 -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 +99 -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/skills/chain.d.ts +31 -0
- package/dist/skills/chain.d.ts.map +1 -0
- package/dist/skills/chain.js +113 -0
- package/dist/skills/discovery.d.ts +34 -0
- package/dist/skills/discovery.d.ts.map +1 -0
- package/dist/skills/discovery.js +185 -0
- package/dist/skills/index.d.ts +12 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +18 -0
- package/dist/skills/router.d.ts +35 -0
- package/dist/skills/router.d.ts.map +1 -0
- package/dist/skills/router.js +143 -0
- package/dist/skills/types.d.ts +33 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +5 -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 +159 -0
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cost tracking type definitions and pricing constants for Babysitter SDK.
|
|
3
|
+
*
|
|
4
|
+
* Covers Anthropic Claude API token usage structures as seen in Claude Code
|
|
5
|
+
* session JSONL files, plus aggregation interfaces for run-level and
|
|
6
|
+
* cross-run cost reporting.
|
|
7
|
+
*
|
|
8
|
+
* Pricing source: https://docs.anthropic.com/en/docs/about-claude/pricing
|
|
9
|
+
* Last verified: 2026-04-05
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Token/cost data for a single API interaction (assistant message).
|
|
13
|
+
*
|
|
14
|
+
* Field names mirror the Anthropic API usage response shape, converted to
|
|
15
|
+
* camelCase for SDK consistency.
|
|
16
|
+
*/
|
|
17
|
+
export interface CostEventData {
|
|
18
|
+
/** Model identifier, e.g. "claude-opus-4-6", "claude-sonnet-4-6". */
|
|
19
|
+
model: string;
|
|
20
|
+
/** Base (non-cached) input tokens. */
|
|
21
|
+
inputTokens: number;
|
|
22
|
+
/** Output (completion) tokens. */
|
|
23
|
+
outputTokens: number;
|
|
24
|
+
/** Total cache-creation input tokens (sum of 5m + 1h buckets). */
|
|
25
|
+
cacheCreationTokens: number;
|
|
26
|
+
/** Tokens read from prompt cache (cache hits). */
|
|
27
|
+
cacheReadTokens: number;
|
|
28
|
+
/** Ephemeral 5-minute cache-creation input tokens. */
|
|
29
|
+
cacheCreation5mTokens: number;
|
|
30
|
+
/** Extended 1-hour cache-creation input tokens. */
|
|
31
|
+
cacheCreation1hTokens: number;
|
|
32
|
+
/** Service tier reported by the API (e.g. "standard"). */
|
|
33
|
+
serviceTier?: string;
|
|
34
|
+
/** Effect ID that produced this usage, when tracked inside a run. */
|
|
35
|
+
effectId?: string;
|
|
36
|
+
/** Task kind (e.g. "orchestrator_task", "node", "breakpoint"). */
|
|
37
|
+
taskKind?: string;
|
|
38
|
+
/** Wall-clock duration of the API call in milliseconds. */
|
|
39
|
+
durationMs?: number;
|
|
40
|
+
/** Computed cost in USD for this single event. */
|
|
41
|
+
costUsd?: number;
|
|
42
|
+
/** ISO-8601 timestamp of the event. */
|
|
43
|
+
timestamp?: string;
|
|
44
|
+
}
|
|
45
|
+
/** Per-model cost aggregation within a run. */
|
|
46
|
+
export interface ModelCostStats {
|
|
47
|
+
model: string;
|
|
48
|
+
eventCount: number;
|
|
49
|
+
inputTokens: number;
|
|
50
|
+
outputTokens: number;
|
|
51
|
+
cacheCreationTokens: number;
|
|
52
|
+
cacheReadTokens: number;
|
|
53
|
+
costUsd: number;
|
|
54
|
+
}
|
|
55
|
+
/** Per-task-kind cost aggregation within a run. */
|
|
56
|
+
export interface KindCostStats {
|
|
57
|
+
kind: string;
|
|
58
|
+
eventCount: number;
|
|
59
|
+
costUsd: number;
|
|
60
|
+
}
|
|
61
|
+
/** Cost summary for a single run. */
|
|
62
|
+
export interface RunCostStats {
|
|
63
|
+
runId: string;
|
|
64
|
+
date: string;
|
|
65
|
+
eventCount: number;
|
|
66
|
+
totalInputTokens: number;
|
|
67
|
+
totalOutputTokens: number;
|
|
68
|
+
totalCacheCreation: number;
|
|
69
|
+
totalCacheRead: number;
|
|
70
|
+
totalCostUsd: number;
|
|
71
|
+
byModel: Record<string, ModelCostStats>;
|
|
72
|
+
byKind: Record<string, KindCostStats>;
|
|
73
|
+
}
|
|
74
|
+
/** Aggregate cost summary across multiple runs. */
|
|
75
|
+
export interface AggregateCostStats {
|
|
76
|
+
totalRuns: number;
|
|
77
|
+
totalEvents: number;
|
|
78
|
+
totalInputTokens: number;
|
|
79
|
+
totalOutputTokens: number;
|
|
80
|
+
totalCacheCreation: number;
|
|
81
|
+
totalCacheRead: number;
|
|
82
|
+
totalCostUsd: number;
|
|
83
|
+
/** Overall cost including all token categories across all runs. */
|
|
84
|
+
overallCostUsd: number;
|
|
85
|
+
runs: RunCostStats[];
|
|
86
|
+
}
|
|
87
|
+
/** Per-million-token pricing for a single model. All values in USD. */
|
|
88
|
+
export interface ModelPricing {
|
|
89
|
+
/** Base (non-cached) input tokens, per 1M tokens. */
|
|
90
|
+
inputPer1M: number;
|
|
91
|
+
/** Output tokens, per 1M tokens. */
|
|
92
|
+
outputPer1M: number;
|
|
93
|
+
/**
|
|
94
|
+
* Cache-creation tokens, per 1M tokens.
|
|
95
|
+
*
|
|
96
|
+
* This is the blended/default rate used when the 5m vs 1h breakdown is
|
|
97
|
+
* unavailable. Defaults to the 5-minute cache write rate (1.25x input).
|
|
98
|
+
*/
|
|
99
|
+
cacheCreationPer1M: number;
|
|
100
|
+
/** Cache-read (hit) tokens, per 1M tokens (0.1x input). */
|
|
101
|
+
cacheReadPer1M: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Pricing table for known Claude models.
|
|
105
|
+
*
|
|
106
|
+
* Keys use the API model identifier format (e.g. "claude-opus-4-6").
|
|
107
|
+
* Pricing sourced from https://docs.anthropic.com/en/docs/about-claude/pricing
|
|
108
|
+
*
|
|
109
|
+
* Cache-creation rates default to the 5-minute write multiplier (1.25x input).
|
|
110
|
+
* For fine-grained 5m vs 1h cost splits, use {@link MODEL_PRICING_EXTENDED}.
|
|
111
|
+
*/
|
|
112
|
+
export declare const MODEL_PRICING: Record<string, ModelPricing>;
|
|
113
|
+
/**
|
|
114
|
+
* Extended pricing with separate 5-minute and 1-hour cache write rates.
|
|
115
|
+
*
|
|
116
|
+
* Use this when the event data provides the `cacheCreation5mTokens` /
|
|
117
|
+
* `cacheCreation1hTokens` breakdown (available via the `cache_creation`
|
|
118
|
+
* sub-object in the Anthropic API response).
|
|
119
|
+
*/
|
|
120
|
+
export interface ModelPricingExtended extends ModelPricing {
|
|
121
|
+
/** 5-minute cache write, per 1M tokens (1.25x input). */
|
|
122
|
+
cacheCreation5mPer1M: number;
|
|
123
|
+
/** 1-hour cache write, per 1M tokens (2x input). */
|
|
124
|
+
cacheCreation1hPer1M: number;
|
|
125
|
+
}
|
|
126
|
+
export declare const MODEL_PRICING_EXTENDED: Record<string, ModelPricingExtended>;
|
|
127
|
+
/**
|
|
128
|
+
* Calculate the USD cost for a single API interaction.
|
|
129
|
+
*
|
|
130
|
+
* Uses the blended cache-creation rate from {@link MODEL_PRICING}.
|
|
131
|
+
* For fine-grained 5m/1h splits, use {@link calculateCostUsdExtended}.
|
|
132
|
+
*
|
|
133
|
+
* @returns Cost in USD, or `undefined` if the model is unknown.
|
|
134
|
+
*/
|
|
135
|
+
export declare function calculateCostUsd(model: string, inputTokens: number, outputTokens: number, cacheCreationTokens: number, cacheReadTokens: number): number | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Calculate the USD cost with separate 5-minute and 1-hour cache write rates.
|
|
138
|
+
*
|
|
139
|
+
* Use when the Anthropic API response includes the `cache_creation` sub-object
|
|
140
|
+
* with `ephemeral_5m_input_tokens` and `ephemeral_1h_input_tokens`.
|
|
141
|
+
*
|
|
142
|
+
* @returns Cost in USD, or `undefined` if the model is unknown.
|
|
143
|
+
*/
|
|
144
|
+
export declare function calculateCostUsdExtended(model: string, inputTokens: number, outputTokens: number, cacheCreation5mTokens: number, cacheCreation1hTokens: number, cacheReadTokens: number): number | undefined;
|
|
145
|
+
/** Options for the cost:stats CLI command. */
|
|
146
|
+
export interface CostStatsOptions {
|
|
147
|
+
/** Show stats for a specific run. */
|
|
148
|
+
runId?: string;
|
|
149
|
+
/** Aggregate stats across all runs. */
|
|
150
|
+
all?: boolean;
|
|
151
|
+
/** Output JSON instead of a table. */
|
|
152
|
+
json?: boolean;
|
|
153
|
+
/** Custom runs directory. */
|
|
154
|
+
runsDir?: string;
|
|
155
|
+
/** Filter to a specific model. */
|
|
156
|
+
model?: string;
|
|
157
|
+
/** Filter to a specific task kind. */
|
|
158
|
+
kind?: string;
|
|
159
|
+
/** Only show runs after this ISO-8601 date. */
|
|
160
|
+
since?: string;
|
|
161
|
+
/** Only show runs before this ISO-8601 date. */
|
|
162
|
+
until?: string;
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/cost/types.ts"],"names":[],"mappings":"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"}
|
|
@@ -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"}
|