@wrongstack/core 0.284.0 → 0.285.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-status-tracker.d.ts +74 -0
- package/dist/agent-status-tracker.d.ts.map +1 -0
- package/dist/autophase/auto-phase-planner.d.ts +79 -0
- package/dist/autophase/auto-phase-planner.d.ts.map +1 -0
- package/dist/autophase/auto-phase-runner.d.ts +79 -0
- package/dist/autophase/auto-phase-runner.d.ts.map +1 -0
- package/dist/autophase/checkpoint.d.ts +49 -0
- package/dist/autophase/checkpoint.d.ts.map +1 -0
- package/dist/autophase/index.d.ts +9 -0
- package/dist/autophase/index.d.ts.map +1 -0
- package/dist/autophase/phase-graph-builder.d.ts +46 -0
- package/dist/autophase/phase-graph-builder.d.ts.map +1 -0
- package/dist/autophase/phase-orchestrator.d.ts +150 -0
- package/dist/autophase/phase-orchestrator.d.ts.map +1 -0
- package/dist/autophase/phase-store.d.ts +29 -0
- package/dist/autophase/phase-store.d.ts.map +1 -0
- package/dist/autophase/types.d.ts +329 -0
- package/dist/autophase/types.d.ts.map +1 -0
- package/dist/boot.d.ts +73 -0
- package/dist/boot.d.ts.map +1 -0
- package/dist/coordination/adaptive-concurrency.d.ts +63 -0
- package/dist/coordination/adaptive-concurrency.d.ts.map +1 -0
- package/dist/coordination/agent-bridge.d.ts +24 -0
- package/dist/coordination/agent-bridge.d.ts.map +1 -0
- package/dist/coordination/agent-monitor.d.ts +100 -0
- package/dist/coordination/agent-monitor.d.ts.map +1 -0
- package/dist/coordination/agent-subagent-runner.d.ts +74 -0
- package/dist/coordination/agent-subagent-runner.d.ts.map +1 -0
- package/dist/coordination/agents/agent-prompts.d.ts +2 -0
- package/dist/coordination/agents/agent-prompts.d.ts.map +1 -0
- package/dist/coordination/agents/index.d.ts +35 -0
- package/dist/coordination/agents/index.d.ts.map +1 -0
- package/dist/coordination/agents/phase1-discovery.d.ts +4 -0
- package/dist/coordination/agents/phase1-discovery.d.ts.map +1 -0
- package/dist/coordination/agents/phase2-planning.d.ts +4 -0
- package/dist/coordination/agents/phase2-planning.d.ts.map +1 -0
- package/dist/coordination/agents/phase3-build.d.ts +4 -0
- package/dist/coordination/agents/phase3-build.d.ts.map +1 -0
- package/dist/coordination/agents/phase3-techstack.d.ts +13 -0
- package/dist/coordination/agents/phase3-techstack.d.ts.map +1 -0
- package/dist/coordination/agents/phase4-verify.d.ts +4 -0
- package/dist/coordination/agents/phase4-verify.d.ts.map +1 -0
- package/dist/coordination/agents/phase5-review.d.ts +4 -0
- package/dist/coordination/agents/phase5-review.d.ts.map +1 -0
- package/dist/coordination/agents/phase6-domain.d.ts +4 -0
- package/dist/coordination/agents/phase6-domain.d.ts.map +1 -0
- package/dist/coordination/agents/phase7-knowledge.d.ts +4 -0
- package/dist/coordination/agents/phase7-knowledge.d.ts.map +1 -0
- package/dist/coordination/agents/phase8-delivery.d.ts +4 -0
- package/dist/coordination/agents/phase8-delivery.d.ts.map +1 -0
- package/dist/coordination/agents/phase9-meta.d.ts +4 -0
- package/dist/coordination/agents/phase9-meta.d.ts.map +1 -0
- package/dist/coordination/agents/types.d.ts +79 -0
- package/dist/coordination/agents/types.d.ts.map +1 -0
- package/dist/coordination/agents.d.ts +8 -0
- package/dist/coordination/agents.d.ts.map +1 -0
- package/dist/coordination/auto-extend.d.ts +46 -0
- package/dist/coordination/auto-extend.d.ts.map +1 -0
- package/dist/coordination/autonomous-brain.d.ts +154 -0
- package/dist/coordination/autonomous-brain.d.ts.map +1 -0
- package/dist/coordination/autonomous-coordinator.d.ts +239 -0
- package/dist/coordination/autonomous-coordinator.d.ts.map +1 -0
- package/dist/coordination/brain-monitor.d.ts +74 -0
- package/dist/coordination/brain-monitor.d.ts.map +1 -0
- package/dist/coordination/brain.d.ts +104 -0
- package/dist/coordination/brain.d.ts.map +1 -0
- package/dist/coordination/change-manager.d.ts +151 -0
- package/dist/coordination/change-manager.d.ts.map +1 -0
- package/dist/coordination/checkpoint-wiring.d.ts +61 -0
- package/dist/coordination/checkpoint-wiring.d.ts.map +1 -0
- package/dist/coordination/collab-bus.d.ts +132 -0
- package/dist/coordination/collab-bus.d.ts.map +1 -0
- package/dist/coordination/collab-debug.d.ts +302 -0
- package/dist/coordination/collab-debug.d.ts.map +1 -0
- package/dist/coordination/commit-safety.d.ts +72 -0
- package/dist/coordination/commit-safety.d.ts.map +1 -0
- package/dist/coordination/consensus-protocol.d.ts +106 -0
- package/dist/coordination/consensus-protocol.d.ts.map +1 -0
- package/dist/coordination/coordinator/error-classifier.d.ts +15 -0
- package/dist/coordination/coordinator/error-classifier.d.ts.map +1 -0
- package/dist/coordination/delegate-tool.d.ts +101 -0
- package/dist/coordination/delegate-tool.d.ts.map +1 -0
- package/dist/coordination/dep-watcher-bridge.d.ts +47 -0
- package/dist/coordination/dep-watcher-bridge.d.ts.map +1 -0
- package/dist/coordination/dep-watcher.d.ts +74 -0
- package/dist/coordination/dep-watcher.d.ts.map +1 -0
- package/dist/coordination/director/director-errors.d.ts +29 -0
- package/dist/coordination/director/director-errors.d.ts.map +1 -0
- package/dist/coordination/director-construction.d.ts +90 -0
- package/dist/coordination/director-construction.d.ts.map +1 -0
- package/dist/coordination/director-prompts.d.ts +119 -0
- package/dist/coordination/director-prompts.d.ts.map +1 -0
- package/dist/coordination/director-session.d.ts +68 -0
- package/dist/coordination/director-session.d.ts.map +1 -0
- package/dist/coordination/director-tools.d.ts +65 -0
- package/dist/coordination/director-tools.d.ts.map +1 -0
- package/dist/coordination/director.d.ts +802 -0
- package/dist/coordination/director.d.ts.map +1 -0
- package/dist/coordination/dispatcher.d.ts +82 -0
- package/dist/coordination/dispatcher.d.ts.map +1 -0
- package/dist/coordination/file-author-tracker.d.ts +76 -0
- package/dist/coordination/file-author-tracker.d.ts.map +1 -0
- package/dist/coordination/fleet-bus.d.ts +122 -0
- package/dist/coordination/fleet-bus.d.ts.map +1 -0
- package/dist/coordination/fleet-event-validation.d.ts +10 -0
- package/dist/coordination/fleet-event-validation.d.ts.map +1 -0
- package/dist/coordination/fleet-manager.d.ts +234 -0
- package/dist/coordination/fleet-manager.d.ts.map +1 -0
- package/dist/coordination/fleet-spawn.d.ts +102 -0
- package/dist/coordination/fleet-spawn.d.ts.map +1 -0
- package/dist/coordination/fleet-status-tool.d.ts +36 -0
- package/dist/coordination/fleet-status-tool.d.ts.map +1 -0
- package/dist/coordination/fleet-supervisor.d.ts +157 -0
- package/dist/coordination/fleet-supervisor.d.ts.map +1 -0
- package/dist/coordination/fleet.d.ts +96 -0
- package/dist/coordination/fleet.d.ts.map +1 -0
- package/dist/coordination/global-mailbox.d.ts +234 -0
- package/dist/coordination/global-mailbox.d.ts.map +1 -0
- package/dist/coordination/icoordinator.d.ts +97 -0
- package/dist/coordination/icoordinator.d.ts.map +1 -0
- package/dist/coordination/ifleet-manager.d.ts +177 -0
- package/dist/coordination/ifleet-manager.d.ts.map +1 -0
- package/dist/coordination/in-memory-transport.d.ts +12 -0
- package/dist/coordination/in-memory-transport.d.ts.map +1 -0
- package/dist/coordination/index.d.ts +78 -2587
- package/dist/coordination/index.d.ts.map +1 -0
- package/dist/coordination/index.js +739 -254
- package/dist/coordination/index.js.map +7 -1
- package/dist/coordination/knowledge-graph.d.ts +217 -0
- package/dist/coordination/knowledge-graph.d.ts.map +1 -0
- package/dist/coordination/large-answer-store.d.ts +61 -0
- package/dist/coordination/large-answer-store.d.ts.map +1 -0
- package/dist/coordination/mail-tools.d.ts +34 -0
- package/dist/coordination/mail-tools.d.ts.map +1 -0
- package/dist/coordination/mailbox-actions.d.ts +68 -0
- package/dist/coordination/mailbox-actions.d.ts.map +1 -0
- package/dist/coordination/mailbox-health.d.ts +131 -0
- package/dist/coordination/mailbox-health.d.ts.map +1 -0
- package/dist/coordination/mailbox-hooks.d.ts +55 -0
- package/dist/coordination/mailbox-hooks.d.ts.map +1 -0
- package/dist/coordination/mailbox-tool.d.ts +75 -0
- package/dist/coordination/mailbox-tool.d.ts.map +1 -0
- package/dist/{mailbox-types-BGZWrYTJ.d.ts → coordination/mailbox-types.d.ts} +37 -22
- package/dist/coordination/mailbox-types.d.ts.map +1 -0
- package/dist/coordination/mailbox.d.ts +69 -0
- package/dist/coordination/mailbox.d.ts.map +1 -0
- package/dist/coordination/model-matrix.d.ts +98 -0
- package/dist/coordination/model-matrix.d.ts.map +1 -0
- package/dist/coordination/multi-agent-coordinator.d.ts +202 -0
- package/dist/coordination/multi-agent-coordinator.d.ts.map +1 -0
- package/dist/coordination/null-fleet-bus.d.ts +10 -0
- package/dist/coordination/null-fleet-bus.d.ts.map +1 -0
- package/dist/coordination/package-author-tracker.d.ts +87 -0
- package/dist/coordination/package-author-tracker.d.ts.map +1 -0
- package/dist/coordination/package-outdated-watcher.d.ts +83 -0
- package/dist/coordination/package-outdated-watcher.d.ts.map +1 -0
- package/dist/coordination/single-instance-mailbox.d.ts +154 -0
- package/dist/coordination/single-instance-mailbox.d.ts.map +1 -0
- package/dist/coordination/spawn-budget.d.ts +6 -0
- package/dist/coordination/spawn-budget.d.ts.map +1 -0
- package/dist/coordination/subagent-budget.d.ts +323 -0
- package/dist/coordination/subagent-budget.d.ts.map +1 -0
- package/dist/coordination/subagent-nicknames.d.ts +42 -0
- package/dist/coordination/subagent-nicknames.d.ts.map +1 -0
- package/dist/coordination/subagent-result-tool.d.ts +20 -0
- package/dist/coordination/subagent-result-tool.d.ts.map +1 -0
- package/dist/coordination/task-auctioneer.d.ts +143 -0
- package/dist/coordination/task-auctioneer.d.ts.map +1 -0
- package/dist/coordination/task-dag.d.ts +147 -0
- package/dist/coordination/task-dag.d.ts.map +1 -0
- package/dist/coordination/techstack-mailbox-consumer.d.ts +50 -0
- package/dist/coordination/techstack-mailbox-consumer.d.ts.map +1 -0
- package/dist/coordination/transport.d.ts +2 -0
- package/dist/coordination/transport.d.ts.map +1 -0
- package/dist/coordination/worktree-task-runner.d.ts +45 -0
- package/dist/coordination/worktree-task-runner.d.ts.map +1 -0
- package/dist/core/agent-internals.d.ts +41 -0
- package/dist/core/agent-internals.d.ts.map +1 -0
- package/dist/core/agent-loop.d.ts +18 -0
- package/dist/core/agent-loop.d.ts.map +1 -0
- package/dist/core/agent-response.d.ts +21 -0
- package/dist/core/agent-response.d.ts.map +1 -0
- package/dist/core/agent-tools.d.ts +21 -0
- package/dist/core/agent-tools.d.ts.map +1 -0
- package/dist/core/agent-types.d.ts +95 -0
- package/dist/core/agent-types.d.ts.map +1 -0
- package/dist/core/agent.d.ts +54 -0
- package/dist/core/agent.d.ts.map +1 -0
- package/dist/core/btw.d.ts +40 -0
- package/dist/core/btw.d.ts.map +1 -0
- package/dist/core/context.d.ts +269 -0
- package/dist/core/context.d.ts.map +1 -0
- package/dist/core/continue-intent.d.ts +92 -0
- package/dist/core/continue-intent.d.ts.map +1 -0
- package/dist/core/continue-to-next-iteration.d.ts +96 -0
- package/dist/core/continue-to-next-iteration.d.ts.map +1 -0
- package/dist/core/conversation-state.d.ts +96 -0
- package/dist/core/conversation-state.d.ts.map +1 -0
- package/dist/core/fallback-model.d.ts +94 -0
- package/dist/core/fallback-model.d.ts.map +1 -0
- package/dist/core/fleet-pulse.d.ts +42 -0
- package/dist/core/fleet-pulse.d.ts.map +1 -0
- package/dist/core/input-builder.d.ts +95 -0
- package/dist/core/input-builder.d.ts.map +1 -0
- package/dist/core/instruction-bundle.d.ts +22 -0
- package/dist/core/instruction-bundle.d.ts.map +1 -0
- package/dist/core/iteration-limit.d.ts +35 -0
- package/dist/core/iteration-limit.d.ts.map +1 -0
- package/dist/core/mailbox-loop.d.ts +63 -0
- package/dist/core/mailbox-loop.d.ts.map +1 -0
- package/dist/core/modes/brief.d.ts +2 -0
- package/dist/core/modes/brief.d.ts.map +1 -0
- package/dist/core/modes/default.d.ts +8 -0
- package/dist/core/modes/default.d.ts.map +1 -0
- package/dist/core/modes/teach.d.ts +2 -0
- package/dist/core/modes/teach.d.ts.map +1 -0
- package/dist/core/provider-runner.d.ts +24 -0
- package/dist/core/provider-runner.d.ts.map +1 -0
- package/dist/core/queued-messages.d.ts +55 -0
- package/dist/core/queued-messages.d.ts.map +1 -0
- package/dist/core/run-env.d.ts +49 -0
- package/dist/core/run-env.d.ts.map +1 -0
- package/dist/core/streaming-response-builder.d.ts +78 -0
- package/dist/core/streaming-response-builder.d.ts.map +1 -0
- package/dist/core/system-prompt-builder.d.ts +213 -0
- package/dist/core/system-prompt-builder.d.ts.map +1 -0
- package/dist/defaults/index.d.ts +68 -158
- package/dist/defaults/index.d.ts.map +1 -0
- package/dist/defaults/index.js +1257 -819
- package/dist/defaults/index.js.map +7 -1
- package/dist/execution/auto-compaction-middleware.d.ts +123 -0
- package/dist/execution/auto-compaction-middleware.d.ts.map +1 -0
- package/dist/execution/autonomous-runner.d.ts +55 -0
- package/dist/execution/autonomous-runner.d.ts.map +1 -0
- package/dist/execution/autonomy-brain.d.ts +90 -0
- package/dist/execution/autonomy-brain.d.ts.map +1 -0
- package/dist/execution/autonomy-prompt-contributor.d.ts +39 -0
- package/dist/execution/autonomy-prompt-contributor.d.ts.map +1 -0
- package/dist/execution/compaction-core.d.ts +103 -0
- package/dist/execution/compaction-core.d.ts.map +1 -0
- package/dist/execution/compactor.d.ts +56 -0
- package/dist/execution/compactor.d.ts.map +1 -0
- package/dist/execution/design-color.d.ts +31 -0
- package/dist/execution/design-color.d.ts.map +1 -0
- package/dist/execution/design-detect.d.ts +96 -0
- package/dist/execution/design-detect.d.ts.map +1 -0
- package/dist/execution/design-kit-loader.d.ts +53 -0
- package/dist/execution/design-kit-loader.d.ts.map +1 -0
- package/dist/execution/design-materialize.d.ts +32 -0
- package/dist/execution/design-materialize.d.ts.map +1 -0
- package/dist/execution/design-project-store.d.ts +57 -0
- package/dist/execution/design-project-store.d.ts.map +1 -0
- package/dist/execution/design-verify.d.ts +44 -0
- package/dist/execution/design-verify.d.ts.map +1 -0
- package/dist/execution/error-handler.d.ts +34 -0
- package/dist/execution/error-handler.d.ts.map +1 -0
- package/dist/{parallel-eternal-engine-HUrtePLd.d.ts → execution/eternal-autonomy.d.ts} +10 -225
- package/dist/execution/eternal-autonomy.d.ts.map +1 -0
- package/dist/execution/goal-preamble.d.ts +2 -0
- package/dist/execution/goal-preamble.d.ts.map +1 -0
- package/dist/execution/index.d.ts +21 -180
- package/dist/execution/index.d.ts.map +1 -0
- package/dist/execution/index.js +465 -180
- package/dist/execution/index.js.map +7 -1
- package/dist/execution/intelligent-compactor.d.ts +85 -0
- package/dist/execution/intelligent-compactor.d.ts.map +1 -0
- package/dist/execution/model-runtime.d.ts +75 -0
- package/dist/execution/model-runtime.d.ts.map +1 -0
- package/dist/execution/parallel-eternal-engine.d.ts +130 -0
- package/dist/execution/parallel-eternal-engine.d.ts.map +1 -0
- package/dist/execution/prompt-enhancer.d.ts +12 -13
- package/dist/execution/prompt-enhancer.d.ts.map +1 -0
- package/dist/execution/prompt-enhancer.js +13 -7
- package/dist/execution/prompt-enhancer.js.map +7 -1
- package/dist/execution/prompt-loader.d.ts +52 -0
- package/dist/execution/prompt-loader.d.ts.map +1 -0
- package/dist/execution/provider-runner-impl.d.ts +14 -0
- package/dist/execution/provider-runner-impl.d.ts.map +1 -0
- package/dist/execution/regex-patterns.d.ts +7 -0
- package/dist/execution/regex-patterns.d.ts.map +1 -0
- package/dist/execution/retry-policy.d.ts +35 -0
- package/dist/execution/retry-policy.d.ts.map +1 -0
- package/dist/execution/selective-compactor.d.ts +94 -0
- package/dist/execution/selective-compactor.d.ts.map +1 -0
- package/dist/execution/skill-loader.d.ts +43 -0
- package/dist/execution/skill-loader.d.ts.map +1 -0
- package/dist/execution/strategy-compactor.d.ts +43 -0
- package/dist/execution/strategy-compactor.d.ts.map +1 -0
- package/dist/execution/tool-executor.d.ts +112 -0
- package/dist/execution/tool-executor.d.ts.map +1 -0
- package/dist/extension/extension-points.d.ts +121 -0
- package/dist/extension/extension-points.d.ts.map +1 -0
- package/dist/extension/index.d.ts +3 -10
- package/dist/extension/index.d.ts.map +1 -0
- package/dist/extension/index.js +59 -5
- package/dist/extension/index.js.map +7 -1
- package/dist/extension/registry.d.ts +86 -0
- package/dist/extension/registry.d.ts.map +1 -0
- package/dist/fleet-notifier.d.ts +28 -0
- package/dist/fleet-notifier.d.ts.map +1 -0
- package/dist/hooks/http-executor.d.ts +11 -0
- package/dist/hooks/http-executor.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +10 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/registry.d.ts +71 -0
- package/dist/hooks/registry.d.ts.map +1 -0
- package/dist/hooks/runner.d.ts +65 -0
- package/dist/hooks/runner.d.ts.map +1 -0
- package/dist/hooks/shell-executor.d.ts +33 -0
- package/dist/hooks/shell-executor.d.ts.map +1 -0
- package/dist/hooks/shell-hooks-equal.d.ts +15 -0
- package/dist/hooks/shell-hooks-equal.d.ts.map +1 -0
- package/dist/hq/agent-bridge.d.ts +27 -0
- package/dist/hq/agent-bridge.d.ts.map +1 -0
- package/dist/hq/alerts.d.ts +67 -0
- package/dist/hq/alerts.d.ts.map +1 -0
- package/dist/hq/auth-store.d.ts +161 -0
- package/dist/hq/auth-store.d.ts.map +1 -0
- package/dist/hq/brain-bridge.d.ts +37 -0
- package/dist/hq/brain-bridge.d.ts.map +1 -0
- package/dist/hq/commands.d.ts +122 -0
- package/dist/hq/commands.d.ts.map +1 -0
- package/dist/hq/cost-bridge.d.ts +36 -0
- package/dist/hq/cost-bridge.d.ts.map +1 -0
- package/dist/hq/factory.d.ts +66 -0
- package/dist/hq/factory.d.ts.map +1 -0
- package/dist/hq/fleet-bridge.d.ts +39 -0
- package/dist/hq/fleet-bridge.d.ts.map +1 -0
- package/dist/hq/index.d.ts +18 -816
- package/dist/hq/index.d.ts.map +1 -0
- package/dist/hq/index.js +417 -122
- package/dist/hq/index.js.map +7 -1
- package/dist/hq/mailbox-mapper.d.ts +27 -0
- package/dist/hq/mailbox-mapper.d.ts.map +1 -0
- package/dist/hq/persistence.d.ts +121 -0
- package/dist/hq/persistence.d.ts.map +1 -0
- package/dist/hq/protocol.d.ts +560 -0
- package/dist/hq/protocol.d.ts.map +1 -0
- package/dist/hq/publisher.d.ts +177 -0
- package/dist/hq/publisher.d.ts.map +1 -0
- package/dist/hq/redaction.d.ts +30 -0
- package/dist/hq/redaction.d.ts.map +1 -0
- package/dist/hq/session-bridge.d.ts +29 -0
- package/dist/hq/session-bridge.d.ts.map +1 -0
- package/dist/hq/tool-bridge.d.ts +41 -0
- package/dist/hq/tool-bridge.d.ts.map +1 -0
- package/dist/hq/transcript-mapper.d.ts +36 -0
- package/dist/hq/transcript-mapper.d.ts.map +1 -0
- package/dist/hq/worktree-bridge.d.ts +34 -0
- package/dist/hq/worktree-bridge.d.ts.map +1 -0
- package/dist/index.d.ts +108 -2872
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2724 -1344
- package/dist/index.js.map +7 -1
- package/dist/infrastructure/context-manager.d.ts +92 -0
- package/dist/infrastructure/context-manager.d.ts.map +1 -0
- package/dist/infrastructure/index.d.ts +6 -64
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/infrastructure/index.js +39 -12
- package/dist/infrastructure/index.js.map +7 -1
- package/dist/infrastructure/logger.d.ts +99 -0
- package/dist/infrastructure/logger.d.ts.map +1 -0
- package/dist/infrastructure/mcp-servers.d.ts +83 -0
- package/dist/infrastructure/mcp-servers.d.ts.map +1 -0
- package/dist/{path-resolver-CMS5307d.d.ts → infrastructure/path-resolver.d.ts} +3 -5
- package/dist/infrastructure/path-resolver.d.ts.map +1 -0
- package/dist/infrastructure/token-counter.d.ts +57 -0
- package/dist/infrastructure/token-counter.d.ts.map +1 -0
- package/dist/kernel/container.d.ts +84 -0
- package/dist/kernel/container.d.ts.map +1 -0
- package/dist/{events-Bgnh43r9.d.ts → kernel/events.d.ts} +112 -206
- package/dist/kernel/events.d.ts.map +1 -0
- package/dist/kernel/index.d.ts +6 -107
- package/dist/kernel/index.d.ts.map +1 -0
- package/dist/kernel/index.js +56 -4
- package/dist/kernel/index.js.map +7 -1
- package/dist/kernel/pipeline.d.ts +105 -0
- package/dist/kernel/pipeline.d.ts.map +1 -0
- package/dist/kernel/run-controller.d.ts +55 -0
- package/dist/kernel/run-controller.d.ts.map +1 -0
- package/dist/kernel/tokens.d.ts +53 -0
- package/dist/kernel/tokens.d.ts.map +1 -0
- package/dist/mailbox-attach.d.ts +27 -0
- package/dist/mailbox-attach.d.ts.map +1 -0
- package/dist/middleware/collab-pause.d.ts +73 -0
- package/dist/middleware/collab-pause.d.ts.map +1 -0
- package/dist/models/codex-catalog.d.ts +41 -0
- package/dist/models/codex-catalog.d.ts.map +1 -0
- package/dist/models/index.d.ts +8 -163
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +150 -51
- package/dist/models/index.js.map +7 -1
- package/dist/models/llm-selector.d.ts +47 -0
- package/dist/models/llm-selector.d.ts.map +1 -0
- package/dist/models/mode-store.d.ts +22 -0
- package/dist/models/mode-store.d.ts.map +1 -0
- package/dist/models/model-intelligence.d.ts +56 -0
- package/dist/models/model-intelligence.d.ts.map +1 -0
- package/dist/models/model-router.d.ts +100 -0
- package/dist/models/model-router.d.ts.map +1 -0
- package/dist/models/models-registry.d.ts +106 -0
- package/dist/models/models-registry.d.ts.map +1 -0
- package/dist/models/provider-model-resolve.d.ts +69 -0
- package/dist/models/provider-model-resolve.d.ts.map +1 -0
- package/dist/observability/event-bridge.d.ts +10 -0
- package/dist/observability/event-bridge.d.ts.map +1 -0
- package/dist/observability/health.d.ts +18 -0
- package/dist/observability/health.d.ts.map +1 -0
- package/dist/observability/index.d.ts +9 -354
- package/dist/observability/index.d.ts.map +1 -0
- package/dist/observability/index.js +21 -8
- package/dist/observability/index.js.map +7 -1
- package/dist/observability/metrics.d.ts +26 -0
- package/dist/observability/metrics.d.ts.map +1 -0
- package/dist/observability/otel-tracer.d.ts +41 -0
- package/dist/observability/otel-tracer.d.ts.map +1 -0
- package/dist/observability/otlp-metrics.d.ts +111 -0
- package/dist/observability/otlp-metrics.d.ts.map +1 -0
- package/dist/observability/otlp-traces.d.ts +95 -0
- package/dist/observability/otlp-traces.d.ts.map +1 -0
- package/dist/observability/prometheus.d.ts +49 -0
- package/dist/observability/prometheus.d.ts.map +1 -0
- package/dist/observability/tracer.d.ts +9 -0
- package/dist/observability/tracer.d.ts.map +1 -0
- package/dist/plugin/api.d.ts +226 -0
- package/dist/plugin/api.d.ts.map +1 -0
- package/dist/plugin/loader.d.ts +73 -0
- package/dist/plugin/loader.d.ts.map +1 -0
- package/dist/plugins/chimera-plugin.d.ts +37 -0
- package/dist/plugins/chimera-plugin.d.ts.map +1 -0
- package/dist/plugins/git-plugin.d.ts +15 -0
- package/dist/plugins/git-plugin.d.ts.map +1 -0
- package/dist/plugins/observability-plugin.d.ts +19 -0
- package/dist/plugins/observability-plugin.d.ts.map +1 -0
- package/dist/plugins/plan-plugin.d.ts +16 -0
- package/dist/plugins/plan-plugin.d.ts.map +1 -0
- package/dist/plugins/prompts-plugin.d.ts +26 -0
- package/dist/plugins/prompts-plugin.d.ts.map +1 -0
- package/dist/plugins/security-plugin.d.ts +19 -0
- package/dist/plugins/security-plugin.d.ts.map +1 -0
- package/dist/plugins/skills-plugin.d.ts +42 -0
- package/dist/plugins/skills-plugin.d.ts.map +1 -0
- package/dist/plugins/sync-plugin.d.ts +22 -0
- package/dist/plugins/sync-plugin.d.ts.map +1 -0
- package/dist/prompts/index.d.ts +3 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/prompt-installer.d.ts +50 -0
- package/dist/prompts/prompt-installer.d.ts.map +1 -0
- package/dist/prompts/prompt-manifest-store.d.ts +18 -0
- package/dist/prompts/prompt-manifest-store.d.ts.map +1 -0
- package/dist/registry/provider-registry.d.ts +51 -0
- package/dist/registry/provider-registry.d.ts.map +1 -0
- package/dist/registry/slash-command-registry.d.ts +61 -0
- package/dist/registry/slash-command-registry.d.ts.map +1 -0
- package/dist/registry/tool-registry.d.ts +154 -0
- package/dist/registry/tool-registry.d.ts.map +1 -0
- package/dist/replay/hash.d.ts +31 -0
- package/dist/replay/hash.d.ts.map +1 -0
- package/dist/replay/replay-provider-runner.d.ts +53 -0
- package/dist/replay/replay-provider-runner.d.ts.map +1 -0
- package/dist/{index-CbyuOE5y.d.ts → security/capabilities.d.ts} +31 -34
- package/dist/security/capabilities.d.ts.map +1 -0
- package/dist/security/config-secrets.d.ts +25 -0
- package/dist/security/config-secrets.d.ts.map +1 -0
- package/dist/security/index.d.ts +6 -8
- package/dist/security/index.d.ts.map +1 -0
- package/dist/security/index.js +102 -381
- package/dist/security/index.js.map +7 -1
- package/dist/security/permission-policy.d.ts +153 -0
- package/dist/security/permission-policy.d.ts.map +1 -0
- package/dist/security/secret-scrubber.d.ts +14 -0
- package/dist/security/secret-scrubber.d.ts.map +1 -0
- package/dist/security/secret-vault.d.ts +87 -0
- package/dist/security/secret-vault.d.ts.map +1 -0
- package/dist/security/yolo-risk.d.ts +11 -0
- package/dist/security/yolo-risk.d.ts.map +1 -0
- package/dist/{session-registry-Dvg7i_IA.d.ts → session-registry.d.ts} +8 -9
- package/dist/session-registry.d.ts.map +1 -0
- package/dist/skills/foreign-sources.d.ts +59 -0
- package/dist/skills/foreign-sources.d.ts.map +1 -0
- package/dist/skills/frontmatter.d.ts +44 -0
- package/dist/skills/frontmatter.d.ts.map +1 -0
- package/dist/skills/github-fetcher.d.ts +38 -0
- package/dist/skills/github-fetcher.d.ts.map +1 -0
- package/dist/skills/index.d.ts +11 -582
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +81 -43
- package/dist/skills/index.js.map +7 -1
- package/dist/skills/limits.d.ts +92 -0
- package/dist/skills/limits.d.ts.map +1 -0
- package/dist/skills/manifest-store.d.ts +42 -0
- package/dist/skills/manifest-store.d.ts.map +1 -0
- package/dist/skills/registry/github-direct-adapter.d.ts +17 -0
- package/dist/skills/registry/github-direct-adapter.d.ts.map +1 -0
- package/dist/skills/registry/registry-adapter.d.ts +84 -0
- package/dist/skills/registry/registry-adapter.d.ts.map +1 -0
- package/dist/skills/registry/skills-sh-adapter.d.ts +13 -0
- package/dist/skills/registry/skills-sh-adapter.d.ts.map +1 -0
- package/dist/skills/skill-generator.d.ts +82 -0
- package/dist/skills/skill-generator.d.ts.map +1 -0
- package/dist/skills/skill-installer.d.ts +124 -0
- package/dist/skills/skill-installer.d.ts.map +1 -0
- package/dist/storage/annotations-store.d.ts +118 -0
- package/dist/storage/annotations-store.d.ts.map +1 -0
- package/dist/storage/attachment-store.d.ts +31 -0
- package/dist/storage/attachment-store.d.ts.map +1 -0
- package/dist/storage/cloud-sync.d.ts +44 -0
- package/dist/storage/cloud-sync.d.ts.map +1 -0
- package/dist/storage/completed-work-checkpoint.d.ts +11 -0
- package/dist/storage/completed-work-checkpoint.d.ts.map +1 -0
- package/dist/storage/config-loader.d.ts +104 -0
- package/dist/storage/config-loader.d.ts.map +1 -0
- package/dist/storage/config-migration.d.ts +87 -0
- package/dist/storage/config-migration.d.ts.map +1 -0
- package/dist/storage/config-store.d.ts +22 -0
- package/dist/storage/config-store.d.ts.map +1 -0
- package/dist/{director-state-CMS_bMs4.d.ts → storage/director-state.d.ts} +28 -8
- package/dist/storage/director-state.d.ts.map +1 -0
- package/dist/storage/file-session-writer.d.ts +169 -0
- package/dist/storage/file-session-writer.d.ts.map +1 -0
- package/dist/{goal-store-Datpp-ar.d.ts → storage/goal-store.d.ts} +26 -19
- package/dist/storage/goal-store.d.ts.map +1 -0
- package/dist/storage/index.d.ts +39 -1031
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +655 -300
- package/dist/storage/index.js.map +7 -1
- package/dist/storage/input-history-store.d.ts +56 -0
- package/dist/storage/input-history-store.d.ts.map +1 -0
- package/dist/storage/memory-backend.d.ts +66 -0
- package/dist/storage/memory-backend.d.ts.map +1 -0
- package/dist/storage/memory-consolidator.d.ts +50 -0
- package/dist/storage/memory-consolidator.d.ts.map +1 -0
- package/dist/storage/memory-graph-backend.d.ts +117 -0
- package/dist/storage/memory-graph-backend.d.ts.map +1 -0
- package/dist/storage/memory-store.d.ts +119 -0
- package/dist/storage/memory-store.d.ts.map +1 -0
- package/dist/storage/plan-store.d.ts +78 -0
- package/dist/storage/plan-store.d.ts.map +1 -0
- package/dist/storage/plan-templates.d.ts +21 -0
- package/dist/storage/plan-templates.d.ts.map +1 -0
- package/dist/storage/prompt-store.d.ts +37 -0
- package/dist/storage/prompt-store.d.ts.map +1 -0
- package/dist/storage/prompt-usage-store.d.ts +29 -0
- package/dist/storage/prompt-usage-store.d.ts.map +1 -0
- package/dist/storage/provider-config-watcher.d.ts +34 -0
- package/dist/storage/provider-config-watcher.d.ts.map +1 -0
- package/dist/storage/queue-store.d.ts +37 -0
- package/dist/storage/queue-store.d.ts.map +1 -0
- package/dist/storage/recovery-lock.d.ts +79 -0
- package/dist/storage/recovery-lock.d.ts.map +1 -0
- package/dist/storage/replay-log-store.d.ts +97 -0
- package/dist/storage/replay-log-store.d.ts.map +1 -0
- package/dist/storage/session-analyzer.d.ts +48 -0
- package/dist/storage/session-analyzer.d.ts.map +1 -0
- package/dist/storage/session-checkpoint-cas.d.ts +37 -0
- package/dist/storage/session-checkpoint-cas.d.ts.map +1 -0
- package/dist/{session-event-bridge-D_z_mBwk.d.ts → storage/session-event-bridge.d.ts} +14 -15
- package/dist/storage/session-event-bridge.d.ts.map +1 -0
- package/dist/storage/session-helpers.d.ts +9 -0
- package/dist/storage/session-helpers.d.ts.map +1 -0
- package/dist/storage/session-id.d.ts +18 -0
- package/dist/storage/session-id.d.ts.map +1 -0
- package/dist/storage/session-reader.d.ts +21 -0
- package/dist/storage/session-reader.d.ts.map +1 -0
- package/dist/storage/session-recovery.d.ts +93 -0
- package/dist/storage/session-recovery.d.ts.map +1 -0
- package/dist/storage/session-resume-validation.d.ts +6 -0
- package/dist/storage/session-resume-validation.d.ts.map +1 -0
- package/dist/storage/session-rewinder.d.ts +21 -0
- package/dist/storage/session-rewinder.d.ts.map +1 -0
- package/dist/storage/session-store.d.ts +210 -0
- package/dist/storage/session-store.d.ts.map +1 -0
- package/dist/storage/session-summary.d.ts +12 -0
- package/dist/storage/session-summary.d.ts.map +1 -0
- package/dist/storage/session-tool-call-ends.d.ts +5 -0
- package/dist/storage/session-tool-call-ends.d.ts.map +1 -0
- package/dist/storage/storage-concurrency.d.ts +2 -0
- package/dist/storage/storage-concurrency.d.ts.map +1 -0
- package/dist/storage/task-store.d.ts +33 -0
- package/dist/storage/task-store.d.ts.map +1 -0
- package/dist/storage/todos-checkpoint.d.ts +39 -0
- package/dist/storage/todos-checkpoint.d.ts.map +1 -0
- package/dist/storage/tool-audit-log.d.ts +141 -0
- package/dist/storage/tool-audit-log.d.ts.map +1 -0
- package/dist/tasking/index.d.ts +3 -124
- package/dist/tasking/index.d.ts.map +1 -0
- package/dist/tasking/index.js +57 -4
- package/dist/tasking/index.js.map +7 -1
- package/dist/tasking/task-store.d.ts +22 -0
- package/dist/tasking/task-store.d.ts.map +1 -0
- package/dist/tasking/task-tracker.d.ts +102 -0
- package/dist/tasking/task-tracker.d.ts.map +1 -0
- package/dist/tools/index.d.ts +2 -59
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +93 -14
- package/dist/tools/index.js.map +7 -1
- package/dist/tools/mcp-control.d.ts +53 -0
- package/dist/tools/mcp-control.d.ts.map +1 -0
- package/dist/tools/mcp-use.d.ts +24 -0
- package/dist/tools/mcp-use.d.ts.map +1 -0
- package/dist/types/agent-bridge.d.ts +42 -0
- package/dist/types/agent-bridge.d.ts.map +1 -0
- package/dist/types/attachment.d.ts +54 -0
- package/dist/types/attachment.d.ts.map +1 -0
- package/dist/types/autonomy.d.ts +5 -0
- package/dist/types/autonomy.d.ts.map +1 -0
- package/dist/types/blocks.d.ts +76 -0
- package/dist/types/blocks.d.ts.map +1 -0
- package/dist/{compactor-DQLL4HTo.d.ts → types/compactor.d.ts} +5 -7
- package/dist/types/compactor.d.ts.map +1 -0
- package/dist/{config-MRqn1V-u.d.ts → types/config.d.ts} +135 -354
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/context-evidence.d.ts +68 -0
- package/dist/types/context-evidence.d.ts.map +1 -0
- package/dist/types/context-window.d.ts +35 -0
- package/dist/types/context-window.d.ts.map +1 -0
- package/dist/{default-config-B79_gJYv.d.ts → types/default-config.d.ts} +10 -11
- package/dist/types/default-config.d.ts.map +1 -0
- package/dist/types/design-kit.d.ts +91 -0
- package/dist/types/design-kit.d.ts.map +1 -0
- package/dist/{retry-policy-CQ7KwXJa.d.ts → types/error-handler.d.ts} +5 -12
- package/dist/types/error-handler.d.ts.map +1 -0
- package/dist/types/errors.d.ts +277 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/hooks.d.ts +167 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/index.d.ts +40 -244
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +90 -12
- package/dist/types/index.js.map +7 -1
- package/dist/{input-reader-E-ffP2ee.d.ts → types/input-reader.d.ts} +3 -4
- package/dist/types/input-reader.d.ts.map +1 -0
- package/dist/{logger-B63L5bTg.d.ts → types/logger.d.ts} +3 -4
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/types/memory.d.ts +89 -0
- package/dist/types/memory.d.ts.map +1 -0
- package/dist/types/messages.d.ts +24 -0
- package/dist/types/messages.d.ts.map +1 -0
- package/dist/types/mode-prompts.d.ts +2 -0
- package/dist/types/mode-prompts.d.ts.map +1 -0
- package/dist/{mode-CZlO9iU1.d.ts → types/mode.d.ts} +6 -7
- package/dist/types/mode.d.ts.map +1 -0
- package/dist/types/models-registry.d.ts +105 -0
- package/dist/types/models-registry.d.ts.map +1 -0
- package/dist/types/multi-agent.d.ts +435 -0
- package/dist/types/multi-agent.d.ts.map +1 -0
- package/dist/{observability-D-HZN_mF.d.ts → types/observability.d.ts} +12 -13
- package/dist/types/observability.d.ts.map +1 -0
- package/dist/{path-resolver-CPRj4bFY.d.ts → types/path-resolver.d.ts} +2 -3
- package/dist/types/path-resolver.d.ts.map +1 -0
- package/dist/{permission-ByDKXEcG.d.ts → types/permission.d.ts} +8 -9
- package/dist/types/permission.d.ts.map +1 -0
- package/dist/types/plugin.d.ts +385 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/prompt-registry.d.ts +81 -0
- package/dist/types/prompt-registry.d.ts.map +1 -0
- package/dist/{prompt-DLd35n4Q.d.ts → types/prompt.d.ts} +14 -15
- package/dist/types/prompt.d.ts.map +1 -0
- package/dist/{provider-runner-ChL-kVg6.d.ts → types/provider-runner.d.ts} +9 -10
- package/dist/types/provider-runner.d.ts.map +1 -0
- package/dist/types/provider.d.ts +387 -0
- package/dist/types/provider.d.ts.map +1 -0
- package/dist/types/renderer.d.ts +23 -0
- package/dist/types/renderer.d.ts.map +1 -0
- package/dist/types/retry-policy.d.ts +7 -0
- package/dist/types/retry-policy.d.ts.map +1 -0
- package/dist/types/secret-scrubber.d.ts +5 -0
- package/dist/types/secret-scrubber.d.ts.map +1 -0
- package/dist/{secret-vault-BAKpgFw_.d.ts → types/secret-vault.d.ts} +13 -7
- package/dist/types/secret-vault.d.ts.map +1 -0
- package/dist/{selector-D8O6B_Rm.d.ts → types/selector.d.ts} +4 -6
- package/dist/types/selector.d.ts.map +1 -0
- package/dist/types/session-reader.d.ts +81 -0
- package/dist/types/session-reader.d.ts.map +1 -0
- package/dist/{session-rewinder-C9HnMkhP.d.ts → types/session-rewinder.d.ts} +5 -6
- package/dist/types/session-rewinder.d.ts.map +1 -0
- package/dist/types/session.d.ts +650 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/side-effect.d.ts +34 -0
- package/dist/types/side-effect.d.ts.map +1 -0
- package/dist/{skill-DHniprNl.d.ts → types/skill.d.ts} +4 -5
- package/dist/types/skill.d.ts.map +1 -0
- package/dist/types/slash-command.d.ts +59 -0
- package/dist/types/slash-command.d.ts.map +1 -0
- package/dist/types/spec.d.ts +77 -0
- package/dist/types/spec.d.ts.map +1 -0
- package/dist/types/system-prompt-contributor.d.ts +20 -0
- package/dist/types/system-prompt-contributor.d.ts.map +1 -0
- package/dist/types/system-prompt.d.ts +51 -0
- package/dist/types/system-prompt.d.ts.map +1 -0
- package/dist/{task-graph-CH3acNQ7.d.ts → types/task-graph.d.ts} +21 -22
- package/dist/types/task-graph.d.ts.map +1 -0
- package/dist/types/token-counter.d.ts +42 -0
- package/dist/types/token-counter.d.ts.map +1 -0
- package/dist/types/tool-executor.d.ts +133 -0
- package/dist/types/tool-executor.d.ts.map +1 -0
- package/dist/types/tool-markers.d.ts +23 -0
- package/dist/types/tool-markers.d.ts.map +1 -0
- package/dist/types/tool.d.ts +245 -0
- package/dist/types/tool.d.ts.map +1 -0
- package/dist/types/utility-types.d.ts +31 -0
- package/dist/types/utility-types.d.ts.map +1 -0
- package/dist/utils/assert-never.d.ts +14 -0
- package/dist/utils/assert-never.d.ts.map +1 -0
- package/dist/utils/atomic-write.d.ts +12 -0
- package/dist/utils/atomic-write.d.ts.map +1 -0
- package/dist/utils/child-env.d.ts +67 -0
- package/dist/utils/child-env.d.ts.map +1 -0
- package/dist/utils/color.d.ts +20 -0
- package/dist/utils/color.d.ts.map +1 -0
- package/dist/utils/config-json.d.ts +14 -0
- package/dist/utils/config-json.d.ts.map +1 -0
- package/dist/utils/context-evidence.d.ts +47 -0
- package/dist/utils/context-evidence.d.ts.map +1 -0
- package/dist/utils/deep-merge.d.ts +64 -0
- package/dist/utils/deep-merge.d.ts.map +1 -0
- package/dist/utils/diff.d.ts +11 -0
- package/dist/utils/diff.d.ts.map +1 -0
- package/dist/utils/error.d.ts +2 -3
- package/dist/utils/error.d.ts.map +1 -0
- package/dist/utils/error.js +3 -3
- package/dist/utils/error.js.map +7 -1
- package/dist/utils/expect-defined.d.ts +2 -3
- package/dist/utils/expect-defined.d.ts.map +1 -0
- package/dist/utils/expect-defined.js +3 -3
- package/dist/utils/expect-defined.js.map +7 -1
- package/dist/utils/glob-expand.d.ts +10 -0
- package/dist/utils/glob-expand.d.ts.map +1 -0
- package/dist/utils/glob-match.d.ts +4 -0
- package/dist/utils/glob-match.d.ts.map +1 -0
- package/dist/utils/index.d.ts +37 -920
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +242 -33
- package/dist/utils/index.js.map +7 -1
- package/dist/utils/instruction-file.d.ts +3 -0
- package/dist/utils/instruction-file.d.ts.map +1 -0
- package/dist/utils/ip-guard.d.ts +34 -0
- package/dist/utils/ip-guard.d.ts.map +1 -0
- package/dist/utils/json-repair.d.ts +23 -0
- package/dist/utils/json-repair.d.ts.map +1 -0
- package/dist/utils/json-schema-validate.d.ts +42 -0
- package/dist/utils/json-schema-validate.d.ts.map +1 -0
- package/dist/utils/lru-cache.d.ts +29 -0
- package/dist/utils/lru-cache.d.ts.map +1 -0
- package/dist/utils/merge-custom-models.d.ts +12 -0
- package/dist/utils/merge-custom-models.d.ts.map +1 -0
- package/dist/utils/merge-models-payload.d.ts +20 -0
- package/dist/utils/merge-models-payload.d.ts.map +1 -0
- package/dist/utils/message-invariants.d.ts +22 -0
- package/dist/utils/message-invariants.d.ts.map +1 -0
- package/dist/utils/newline-normalize.d.ts +5 -0
- package/dist/utils/newline-normalize.d.ts.map +1 -0
- package/dist/utils/regex-guard.d.ts +21 -0
- package/dist/utils/regex-guard.d.ts.map +1 -0
- package/dist/utils/safe-json.d.ts +31 -0
- package/dist/utils/safe-json.d.ts.map +1 -0
- package/dist/utils/session-scoped-path.d.ts +13 -0
- package/dist/utils/session-scoped-path.d.ts.map +1 -0
- package/dist/utils/sleep.d.ts +5 -0
- package/dist/utils/sleep.d.ts.map +1 -0
- package/dist/utils/slug.d.ts +13 -0
- package/dist/utils/slug.d.ts.map +1 -0
- package/dist/utils/string.d.ts +9 -0
- package/dist/utils/string.d.ts.map +1 -0
- package/dist/utils/task-format.d.ts +22 -0
- package/dist/utils/task-format.d.ts.map +1 -0
- package/dist/utils/term.d.ts +133 -0
- package/dist/utils/term.d.ts.map +1 -0
- package/dist/utils/todos-format.d.ts +30 -0
- package/dist/utils/todos-format.d.ts.map +1 -0
- package/dist/utils/token-estimate.d.ts +112 -0
- package/dist/utils/token-estimate.d.ts.map +1 -0
- package/dist/utils/tool-description-mode.d.ts +28 -0
- package/dist/utils/tool-description-mode.d.ts.map +1 -0
- package/dist/utils/tool-output-serializer.d.ts +40 -0
- package/dist/utils/tool-output-serializer.d.ts.map +1 -0
- package/dist/utils/tool-result-render-mode.d.ts +55 -0
- package/dist/utils/tool-result-render-mode.d.ts.map +1 -0
- package/dist/utils/tool-subject.d.ts +5 -0
- package/dist/utils/tool-subject.d.ts.map +1 -0
- package/dist/utils/tool-wire-compact.d.ts +28 -0
- package/dist/utils/tool-wire-compact.d.ts.map +1 -0
- package/dist/utils/ulid.d.ts +11 -0
- package/dist/utils/ulid.d.ts.map +1 -0
- package/dist/{wstack-paths-C3K40Qst.d.ts → utils/wstack-paths.d.ts} +7 -8
- package/dist/utils/wstack-paths.d.ts.map +1 -0
- package/dist/worktree/index.d.ts +2 -0
- package/dist/worktree/index.d.ts.map +1 -0
- package/dist/{worktree-manager-DzwxKE35.d.ts → worktree/worktree-manager.d.ts} +19 -13
- package/dist/worktree/worktree-manager.d.ts.map +1 -0
- package/instructions/autonomy/active-mission.md +2 -4
- package/instructions/sections/tool/delegation-full.md +1 -1
- package/package.json +4 -5
- package/skills/node-modern/SKILL.md +2 -2
- package/skills/plugin-author/SKILL.md +9 -16
- package/dist/dispatcher-types.d-BBeXBQgS.d.ts +0 -66
- package/dist/global-mailbox-sZwyI6CS.d.ts +0 -959
- package/dist/index--Gm41aBJ.d.ts +0 -671
- package/dist/mcp-servers-DEV4s6Ks.d.ts +0 -259
- package/dist/multi-agent-coordinator-4RCRZKjN.d.ts +0 -1770
- package/dist/null-fleet-bus-CFoNVQEK.d.ts +0 -2127
- package/dist/pipeline-DGDyIohT.d.ts +0 -331
- package/dist/provider-model-resolve-o2hHLs79.d.ts +0 -263
- package/dist/secret-scrubber-3MHDDAtm.d.ts +0 -6
- package/dist/secret-vault-DxohkUBc.d.ts +0 -272
- package/dist/session-reader-7Esxrkpw.d.ts +0 -155
- package/dist/task-format-GX0B1mMC.d.ts +0 -23
- package/dist/todos-checkpoint-FY7PjmMx.d.ts +0 -850
- package/dist/tool-BNlnIJvo.d.ts +0 -2190
- package/dist/tool-executor-CckSCM5E.d.ts +0 -906
package/dist/tool-BNlnIJvo.d.ts
DELETED
|
@@ -1,2190 +0,0 @@
|
|
|
1
|
-
interface TextBlock {
|
|
2
|
-
type: 'text';
|
|
3
|
-
text: string;
|
|
4
|
-
cache_control?: {
|
|
5
|
-
type: 'ephemeral' | undefined;
|
|
6
|
-
};
|
|
7
|
-
}
|
|
8
|
-
interface ToolUseBlock {
|
|
9
|
-
type: 'tool_use';
|
|
10
|
-
id: string;
|
|
11
|
-
name: string;
|
|
12
|
-
input: Record<string, unknown>;
|
|
13
|
-
/**
|
|
14
|
-
* Provider-specific opaque metadata captured from the wire response.
|
|
15
|
-
* Echoed back verbatim in the next request so providers that bind
|
|
16
|
-
* extra state to function calls keep working. Example: Gemini's
|
|
17
|
-
* `thoughtSignature` — required for tool-use turns with thinking
|
|
18
|
-
* models, otherwise the next request fails with 400 "Function call
|
|
19
|
-
* is missing a thought_signature in functionCall parts".
|
|
20
|
-
*
|
|
21
|
-
* Keys are namespaced by intent so multiple wires can coexist:
|
|
22
|
-
* - `google.thoughtSignature` — Gemini signed-thought blob
|
|
23
|
-
* Other providers can add their own keys without colliding.
|
|
24
|
-
*/
|
|
25
|
-
providerMeta?: Record<string, unknown>;
|
|
26
|
-
}
|
|
27
|
-
interface ToolResultBlock {
|
|
28
|
-
type: 'tool_result';
|
|
29
|
-
tool_use_id: string;
|
|
30
|
-
/**
|
|
31
|
-
* The original tool name. Useful for providers like Google Gemini that
|
|
32
|
-
* need the tool name in `functionResponse.name` — the tool_use_id is
|
|
33
|
-
* only a session-local identifier and is not stable across replays.
|
|
34
|
-
* Always set by ToolExecutor; may be absent on manually-constructed blocks.
|
|
35
|
-
*/
|
|
36
|
-
name?: string | undefined;
|
|
37
|
-
content: string;
|
|
38
|
-
is_error?: boolean | undefined;
|
|
39
|
-
}
|
|
40
|
-
interface ImageBlock {
|
|
41
|
-
type: 'image';
|
|
42
|
-
source: {
|
|
43
|
-
type: 'base64' | 'url';
|
|
44
|
-
media_type?: string | undefined;
|
|
45
|
-
data?: string | undefined;
|
|
46
|
-
url?: string | undefined;
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Chain-of-thought / extended-thinking content emitted by the model.
|
|
51
|
-
*
|
|
52
|
-
* Both Anthropic extended thinking (`{type:'thinking', thinking, signature}`)
|
|
53
|
-
* and DeepSeek reasoning mode (top-level `reasoning_content` on the assistant
|
|
54
|
-
* message) require this content to be echoed back verbatim on the next
|
|
55
|
-
* request, otherwise the provider returns 400:
|
|
56
|
-
* - Anthropic: "The `content[].thinking` in the thinking mode must be passed back"
|
|
57
|
-
* - DeepSeek: "The `reasoning_content` in the thinking mode must be passed back"
|
|
58
|
-
*
|
|
59
|
-
* `signature` is Anthropic-specific (an opaque integrity blob). DeepSeek
|
|
60
|
-
* doesn't issue a signature — the field is absent for that provider.
|
|
61
|
-
*
|
|
62
|
-
* Per Anthropic, thinking blocks MUST appear before any text/tool_use blocks
|
|
63
|
-
* in an assistant message. Stream builders preserve that order.
|
|
64
|
-
*/
|
|
65
|
-
interface ThinkingBlock {
|
|
66
|
-
type: 'thinking';
|
|
67
|
-
thinking: string;
|
|
68
|
-
signature?: string | undefined;
|
|
69
|
-
providerMeta?: Record<string, unknown>;
|
|
70
|
-
}
|
|
71
|
-
type ContentBlock = TextBlock | ToolUseBlock | ToolResultBlock | ImageBlock | ThinkingBlock;
|
|
72
|
-
declare function isTextBlock(b: ContentBlock): b is TextBlock;
|
|
73
|
-
declare function isToolUseBlock(b: ContentBlock): b is ToolUseBlock;
|
|
74
|
-
declare function isToolResultBlock(b: ContentBlock): b is ToolResultBlock;
|
|
75
|
-
declare function isImageBlock(b: ContentBlock): b is ImageBlock;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Side-effect risk classification for structured audit recording (P2 #5).
|
|
79
|
-
*
|
|
80
|
-
* @see {@link import('../core/context.js').Context.recordSideEffect}
|
|
81
|
-
*/
|
|
82
|
-
/**
|
|
83
|
-
* The kind of risk a tool side-effect poses. Used by /diag and session
|
|
84
|
-
* replay to filter and group side effects.
|
|
85
|
-
*/
|
|
86
|
-
type SideEffectRisk = 'fs.write' | 'shell' | 'package' | 'network' | 'config';
|
|
87
|
-
/**
|
|
88
|
-
* A structured record of a non-filesystem side effect produced by a tool.
|
|
89
|
-
* Appended to the session JSONL as a `side_effect` event for audit and
|
|
90
|
-
* observability.
|
|
91
|
-
*/
|
|
92
|
-
interface SideEffect {
|
|
93
|
-
/** Session-unique tool call ID (from the tool_use block). */
|
|
94
|
-
toolUseId: string;
|
|
95
|
-
/** Tool name: 'bash' | 'install' | 'fetch' | ... */
|
|
96
|
-
toolName: string;
|
|
97
|
-
/** ISO timestamp. */
|
|
98
|
-
ts: string;
|
|
99
|
-
/** The input the tool received (command, url, packages). */
|
|
100
|
-
input: Record<string, unknown>;
|
|
101
|
-
/**
|
|
102
|
-
* Optional outcome summary — NOT the full output (that's already in the
|
|
103
|
-
* tool_result block). A short string like "exit 0", "installed 42 packages",
|
|
104
|
-
* "HTTP 200 (12KB)", or "timed out".
|
|
105
|
-
*/
|
|
106
|
-
outcome?: string | undefined;
|
|
107
|
-
/** Risk classification for filtering in /diag. */
|
|
108
|
-
risk: SideEffectRisk;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
type MessageRole = 'user' | 'assistant' | 'system';
|
|
112
|
-
interface Message {
|
|
113
|
-
role: MessageRole;
|
|
114
|
-
content: string | ContentBlock[];
|
|
115
|
-
/**
|
|
116
|
-
* ISO-8601 timestamp from the originating SessionEvent.
|
|
117
|
-
* Populated by SessionStore.replay() during session load/resume
|
|
118
|
-
* so consumers (WebUI, TUI, exports) can reconstruct the original
|
|
119
|
-
* conversation timeline instead of seeing every message stamped
|
|
120
|
-
* with "now". Absent for in-memory messages created during a live
|
|
121
|
-
* run — those use wall-clock time from the caller.
|
|
122
|
-
*/
|
|
123
|
-
ts?: string | undefined;
|
|
124
|
-
/**
|
|
125
|
-
* Pre-computed token estimate for this message, set by
|
|
126
|
-
* ConversationState on append/replace. Used by estimateMessageTokens
|
|
127
|
-
* and estimateRequestTokens to skip the O(n·m) content-block walk
|
|
128
|
-
* on every context-pressure check. Undefined means "not yet computed"
|
|
129
|
-
* — the estimator falls back to walking content blocks.
|
|
130
|
-
*/
|
|
131
|
-
_estTokens?: number | undefined;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* WrongStack error hierarchy.
|
|
136
|
-
*
|
|
137
|
-
* Every error thrown by the framework is a `WrongStackError` with a
|
|
138
|
-
* machine-readable `code`, a `subsystem` tag, and a `severity` level.
|
|
139
|
-
* This lets consumers (CLI, TUI, plugins, tests) branch on structured
|
|
140
|
-
* data instead of parsing error messages.
|
|
141
|
-
*/
|
|
142
|
-
/**
|
|
143
|
-
* Machine-readable error codes as frozen constants.
|
|
144
|
-
*
|
|
145
|
-
* Use `ERROR_CODES.X` instead of raw string literals for:
|
|
146
|
-
* - IDE autocomplete and compile-time validation
|
|
147
|
-
* - Safe refactoring (rename updates all usages)
|
|
148
|
-
* - Plugin extensibility (extend the object to add custom codes)
|
|
149
|
-
*
|
|
150
|
-
* The `ErrorCode` type is derived from this object, so adding a new
|
|
151
|
-
* code here automatically updates the type without extra changes.
|
|
152
|
-
*/
|
|
153
|
-
declare const ERROR_CODES: {
|
|
154
|
-
readonly PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED";
|
|
155
|
-
readonly PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED";
|
|
156
|
-
readonly PROVIDER_OVERLOADED: "PROVIDER_OVERLOADED";
|
|
157
|
-
readonly PROVIDER_INVALID_REQUEST: "PROVIDER_INVALID_REQUEST";
|
|
158
|
-
readonly PROVIDER_SERVER_ERROR: "PROVIDER_SERVER_ERROR";
|
|
159
|
-
readonly PROVIDER_NETWORK_ERROR: "PROVIDER_NETWORK_ERROR";
|
|
160
|
-
readonly PROVIDER_CONTEXT_OVERFLOW: "PROVIDER_CONTEXT_OVERFLOW";
|
|
161
|
-
readonly TOOL_NOT_FOUND: "TOOL_NOT_FOUND";
|
|
162
|
-
readonly TOOL_PERMISSION_DENIED: "TOOL_PERMISSION_DENIED";
|
|
163
|
-
readonly TOOL_EXECUTION_FAILED: "TOOL_EXECUTION_FAILED";
|
|
164
|
-
readonly TOOL_TIMEOUT: "TOOL_TIMEOUT";
|
|
165
|
-
readonly TOOL_INPUT_INVALID: "TOOL_INPUT_INVALID";
|
|
166
|
-
readonly CONFIG_INVALID: "CONFIG_INVALID";
|
|
167
|
-
readonly CONFIG_NOT_FOUND: "CONFIG_NOT_FOUND";
|
|
168
|
-
readonly CONFIG_PARSE_FAILED: "CONFIG_PARSE_FAILED";
|
|
169
|
-
readonly CONFIG_MIGRATION_NEEDED: "CONFIG_MIGRATION_NEEDED";
|
|
170
|
-
readonly PLUGIN_LOAD_FAILED: "PLUGIN_LOAD_FAILED";
|
|
171
|
-
readonly PLUGIN_API_MISMATCH: "PLUGIN_API_MISMATCH";
|
|
172
|
-
readonly PLUGIN_MISSING_DEPENDENCY: "PLUGIN_MISSING_DEPENDENCY";
|
|
173
|
-
readonly AGENT_ITERATION_LIMIT: "AGENT_ITERATION_LIMIT";
|
|
174
|
-
readonly AGENT_CONTEXT_OVERFLOW: "AGENT_CONTEXT_OVERFLOW";
|
|
175
|
-
readonly AGENT_ABORTED: "AGENT_ABORTED";
|
|
176
|
-
readonly AGENT_RUN_FAILED: "AGENT_RUN_FAILED";
|
|
177
|
-
readonly SESSION_NOT_FOUND: "SESSION_NOT_FOUND";
|
|
178
|
-
readonly SESSION_CORRUPTED: "SESSION_CORRUPTED";
|
|
179
|
-
readonly SESSION_WRITE_FAILED: "SESSION_WRITE_FAILED";
|
|
180
|
-
readonly CONTAINER_TOKEN_ALREADY_BOUND: "CONTAINER_TOKEN_ALREADY_BOUND";
|
|
181
|
-
readonly CONTAINER_TOKEN_NOT_BOUND: "CONTAINER_TOKEN_NOT_BOUND";
|
|
182
|
-
readonly CONTAINER_CIRCULAR_DEPENDENCY: "CONTAINER_CIRCULAR_DEPENDENCY";
|
|
183
|
-
readonly REGISTRY_DUPLICATE: "REGISTRY_DUPLICATE";
|
|
184
|
-
readonly REGISTRY_NOT_FOUND: "REGISTRY_NOT_FOUND";
|
|
185
|
-
readonly REGISTRY_INVALID: "REGISTRY_INVALID";
|
|
186
|
-
readonly FS_READ_FAILED: "FS_READ_FAILED";
|
|
187
|
-
readonly FS_WRITE_FAILED: "FS_WRITE_FAILED";
|
|
188
|
-
readonly FS_MKDIR_FAILED: "FS_MKDIR_FAILED";
|
|
189
|
-
readonly FS_DELETE_FAILED: "FS_DELETE_FAILED";
|
|
190
|
-
readonly FS_ATOMIC_WRITE_FAILED: "FS_ATOMIC_WRITE_FAILED";
|
|
191
|
-
readonly SDD_VALIDATION_FAILED: "SDD_VALIDATION_FAILED";
|
|
192
|
-
readonly SDD_PARSE_FAILED: "SDD_PARSE_FAILED";
|
|
193
|
-
readonly SDD_INVALID_STATE: "SDD_INVALID_STATE";
|
|
194
|
-
readonly SDD_NOT_READY: "SDD_NOT_READY";
|
|
195
|
-
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
196
|
-
readonly PARSE_FAILED: "PARSE_FAILED";
|
|
197
|
-
readonly UNKNOWN: "UNKNOWN";
|
|
198
|
-
};
|
|
199
|
-
/**
|
|
200
|
-
* Union type derived from `ERROR_CODES`. Using `typeof ERROR_CODES[keyof typeof ERROR_CODES]`
|
|
201
|
-
* instead of a string literal union means TypeScript auto-updates the type whenever
|
|
202
|
-
* a new code is added to `ERROR_CODES` — no need to keep two lists in sync.
|
|
203
|
-
*/
|
|
204
|
-
type ErrorCode = (typeof ERROR_CODES)[keyof typeof ERROR_CODES];
|
|
205
|
-
type ErrorSubsystem = 'provider' | 'tool' | 'config' | 'plugin' | 'agent' | 'session' | 'sdd' | 'container' | 'fs' | 'general';
|
|
206
|
-
type ErrorSeverity = 'fatal' | 'error' | 'warning';
|
|
207
|
-
declare class WrongStackError extends Error {
|
|
208
|
-
readonly code: ErrorCode;
|
|
209
|
-
readonly subsystem: ErrorSubsystem;
|
|
210
|
-
readonly severity: ErrorSeverity;
|
|
211
|
-
readonly recoverable: boolean;
|
|
212
|
-
readonly context?: Record<string, unknown> | undefined;
|
|
213
|
-
constructor(opts: {
|
|
214
|
-
message: string;
|
|
215
|
-
code: ErrorCode;
|
|
216
|
-
subsystem: ErrorSubsystem;
|
|
217
|
-
severity?: ErrorSeverity | undefined;
|
|
218
|
-
recoverable?: boolean | undefined;
|
|
219
|
-
context?: Record<string, unknown> | undefined;
|
|
220
|
-
cause?: unknown | undefined;
|
|
221
|
-
});
|
|
222
|
-
/**
|
|
223
|
-
* Render a one-line user-facing description.
|
|
224
|
-
* Subclasses should override for domain-specific formatting.
|
|
225
|
-
*/
|
|
226
|
-
describe(): string;
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Tool execution errors — thrown by ToolExecutor and individual tools.
|
|
230
|
-
*/
|
|
231
|
-
declare class ToolError extends WrongStackError {
|
|
232
|
-
readonly toolName: string;
|
|
233
|
-
constructor(opts: {
|
|
234
|
-
message: string;
|
|
235
|
-
code: Extract<ErrorCode, 'TOOL_NOT_FOUND' | 'TOOL_PERMISSION_DENIED' | 'TOOL_EXECUTION_FAILED' | 'TOOL_TIMEOUT' | 'TOOL_INPUT_INVALID'>;
|
|
236
|
-
toolName: string;
|
|
237
|
-
recoverable?: boolean | undefined;
|
|
238
|
-
context?: Record<string, unknown> | undefined;
|
|
239
|
-
cause?: unknown | undefined;
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Config loading / validation errors.
|
|
244
|
-
*/
|
|
245
|
-
declare class ConfigError extends WrongStackError {
|
|
246
|
-
constructor(opts: {
|
|
247
|
-
message: string;
|
|
248
|
-
code: Extract<ErrorCode, 'CONFIG_INVALID' | 'CONFIG_NOT_FOUND' | 'CONFIG_PARSE_FAILED' | 'CONFIG_MIGRATION_NEEDED'>;
|
|
249
|
-
context?: Record<string, unknown> | undefined;
|
|
250
|
-
cause?: unknown | undefined;
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Plugin loading / lifecycle errors.
|
|
255
|
-
*/
|
|
256
|
-
declare class PluginError extends WrongStackError {
|
|
257
|
-
readonly pluginName: string;
|
|
258
|
-
constructor(opts: {
|
|
259
|
-
message: string;
|
|
260
|
-
code: Extract<ErrorCode, 'PLUGIN_LOAD_FAILED' | 'PLUGIN_API_MISMATCH' | 'PLUGIN_MISSING_DEPENDENCY'>;
|
|
261
|
-
pluginName: string;
|
|
262
|
-
context?: Record<string, unknown> | undefined;
|
|
263
|
-
cause?: unknown | undefined;
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Agent runtime errors — thrown by Agent.run when a non-WrongStackError
|
|
268
|
-
* escapes the inner loop, so callers always see a structured error.
|
|
269
|
-
*/
|
|
270
|
-
declare class AgentError extends WrongStackError {
|
|
271
|
-
constructor(opts: {
|
|
272
|
-
message: string;
|
|
273
|
-
code: Extract<ErrorCode, 'AGENT_ITERATION_LIMIT' | 'AGENT_CONTEXT_OVERFLOW' | 'AGENT_ABORTED' | 'AGENT_RUN_FAILED'>;
|
|
274
|
-
recoverable?: boolean | undefined;
|
|
275
|
-
context?: Record<string, unknown> | undefined;
|
|
276
|
-
cause?: unknown | undefined;
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
* Wrap an arbitrary thrown value into a `WrongStackError` so the caller
|
|
281
|
-
* always gets a structured error. Pass-throughs WrongStackError instances
|
|
282
|
-
* unchanged; raw `Error`s and primitives get an `AGENT_RUN_FAILED` wrapper
|
|
283
|
-
* with the original preserved as `cause`.
|
|
284
|
-
*/
|
|
285
|
-
declare function toWrongStackError(err: unknown, code?: Extract<ErrorCode, 'AGENT_RUN_FAILED' | 'AGENT_ABORTED' | 'UNKNOWN'>): WrongStackError;
|
|
286
|
-
/**
|
|
287
|
-
* Session storage errors.
|
|
288
|
-
*/
|
|
289
|
-
declare class SessionError extends WrongStackError {
|
|
290
|
-
readonly sessionId?: string | undefined;
|
|
291
|
-
constructor(opts: {
|
|
292
|
-
message: string;
|
|
293
|
-
code: Extract<ErrorCode, 'SESSION_NOT_FOUND' | 'SESSION_CORRUPTED' | 'SESSION_WRITE_FAILED'>;
|
|
294
|
-
sessionId?: string | undefined;
|
|
295
|
-
context?: Record<string, unknown> | undefined;
|
|
296
|
-
cause?: unknown | undefined;
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* SDD (Spec-Driven Development) errors — spec validation, parsing, and
|
|
301
|
-
* state machine violations in the AISpecBuilder, TaskFlow, and TaskTracker.
|
|
302
|
-
*/
|
|
303
|
-
declare class SddError extends WrongStackError {
|
|
304
|
-
constructor(opts: {
|
|
305
|
-
message: string;
|
|
306
|
-
code: Extract<ErrorCode, 'SDD_VALIDATION_FAILED' | 'SDD_PARSE_FAILED' | 'SDD_INVALID_STATE' | 'SDD_NOT_READY'>;
|
|
307
|
-
context?: Record<string, unknown> | undefined;
|
|
308
|
-
cause?: unknown | undefined;
|
|
309
|
-
});
|
|
310
|
-
}
|
|
311
|
-
/**
|
|
312
|
-
* File system operation errors.
|
|
313
|
-
*/
|
|
314
|
-
declare class FsError extends WrongStackError {
|
|
315
|
-
readonly path?: string | undefined;
|
|
316
|
-
constructor(opts: {
|
|
317
|
-
message: string;
|
|
318
|
-
code: Extract<ErrorCode, 'FS_READ_FAILED' | 'FS_WRITE_FAILED' | 'FS_MKDIR_FAILED' | 'FS_DELETE_FAILED' | 'FS_ATOMIC_WRITE_FAILED'>;
|
|
319
|
-
path?: string | undefined;
|
|
320
|
-
context?: Record<string, unknown> | undefined;
|
|
321
|
-
cause?: unknown | undefined;
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* HTTP fetch error — thrown when a network request returns a non-OK status.
|
|
326
|
-
* Carries the response status so {@link classifyToolError} can branch on it
|
|
327
|
-
* (429 → transient, 404 → not_found, 401 → permission) without duck-typing
|
|
328
|
-
* the error via `'response' in err`.
|
|
329
|
-
*
|
|
330
|
-
* P3 #18 (before-release.md): the previous `'response' in err` check caught
|
|
331
|
-
* any Error with a `response` property, including custom errors, proxy
|
|
332
|
-
* objects, or mocked errors in tests. `instanceof FetchError` is reliable.
|
|
333
|
-
*
|
|
334
|
-
* Tools and providers that make HTTP requests and need the executor to
|
|
335
|
-
* classify their failures should throw `new FetchError({ status, message })`
|
|
336
|
-
* instead of a bare `Error` with an ad-hoc `response` field.
|
|
337
|
-
*/
|
|
338
|
-
declare class FetchError extends WrongStackError {
|
|
339
|
-
readonly status: number;
|
|
340
|
-
constructor(opts: {
|
|
341
|
-
message: string;
|
|
342
|
-
status: number;
|
|
343
|
-
context?: Record<string, unknown> | undefined;
|
|
344
|
-
cause?: unknown | undefined;
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Tool input validation error — thrown when a tool's input fails a validation
|
|
349
|
-
* check that the JSON Schema cannot express (e.g. `old_string === new_string`
|
|
350
|
-
* in edit, or a cross-field invariant). Use this instead of a bare
|
|
351
|
-
* `throw new Error('...validation...')` so {@link classifyToolError} can
|
|
352
|
-
* match on `instanceof` rather than a locale-dependent message substring.
|
|
353
|
-
*
|
|
354
|
-
* P2 #6 (before-release.md): the previous `err.message.includes('validation')`
|
|
355
|
-
* check misclassified any error whose message happened to contain "validation"
|
|
356
|
-
* (e.g. a third-party "input validation timeout") as a VALIDATION error.
|
|
357
|
-
*
|
|
358
|
-
* Named `ToolValidationError` (not `ValidationError`) to avoid colliding with
|
|
359
|
-
* the existing `ValidationError` interface exported by json-schema-validate.ts
|
|
360
|
-
* (a validation-result shape, not an Error subclass).
|
|
361
|
-
*/
|
|
362
|
-
declare class ToolValidationError extends WrongStackError {
|
|
363
|
-
constructor(opts: {
|
|
364
|
-
message: string;
|
|
365
|
-
/** Field path or tool name that failed validation, for diagnostics. */
|
|
366
|
-
field?: string | undefined;
|
|
367
|
-
context?: Record<string, unknown> | undefined;
|
|
368
|
-
cause?: unknown | undefined;
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Response / payload parse error — thrown when an upstream HTTP response,
|
|
373
|
-
* file, or data structure is well-formed at the transport layer (HTTP 200,
|
|
374
|
-
* valid JSON) but is missing required fields or has an unexpected shape.
|
|
375
|
-
*
|
|
376
|
-
* Distinct from `ConfigError(CONFIG_PARSE_FAILED)` (which is specifically
|
|
377
|
-
* for config-file parsing) and `FetchError` (which covers HTTP non-OK
|
|
378
|
-
* responses). `ParseError` fills the gap: the request succeeded but the
|
|
379
|
-
* response body couldn't be interpreted.
|
|
380
|
-
*
|
|
381
|
-
* Common sites: OAuth token responses missing `access_token`, device-code
|
|
382
|
-
* responses missing `device_code`, registry responses with unexpected
|
|
383
|
-
* schemas.
|
|
384
|
-
*/
|
|
385
|
-
declare class ParseError extends WrongStackError {
|
|
386
|
-
readonly source?: string | undefined;
|
|
387
|
-
constructor(opts: {
|
|
388
|
-
message: string;
|
|
389
|
-
/**
|
|
390
|
-
* What was being parsed — e.g. `'oauth-token-response'`,
|
|
391
|
-
* `'device-code-response'`. Lets consumers distinguish parse failures
|
|
392
|
-
* from different upstream APIs without parsing the message.
|
|
393
|
-
*/
|
|
394
|
-
source?: string | undefined;
|
|
395
|
-
context?: Record<string, unknown> | undefined;
|
|
396
|
-
cause?: unknown | undefined;
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
declare function isWrongStackError(err: unknown): err is WrongStackError;
|
|
400
|
-
declare function isToolError(err: unknown): err is ToolError;
|
|
401
|
-
declare function isConfigError(err: unknown): err is ConfigError;
|
|
402
|
-
declare function isPluginError(err: unknown): err is PluginError;
|
|
403
|
-
declare function isSessionError(err: unknown): err is SessionError;
|
|
404
|
-
declare function isAgentError(err: unknown): err is AgentError;
|
|
405
|
-
declare function isFsError(err: unknown): err is FsError;
|
|
406
|
-
declare function isToolValidationError(err: unknown): err is ToolValidationError;
|
|
407
|
-
declare function isFetchError(err: unknown): err is FetchError;
|
|
408
|
-
declare function isParseError(err: unknown): err is ParseError;
|
|
409
|
-
declare function isSddError(err: unknown): err is SddError;
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Token usage for a single provider call, normalized across providers.
|
|
413
|
-
*
|
|
414
|
-
* Disjoint semantics: the four fields never overlap. `input` is the count
|
|
415
|
-
* of FRESH input tokens (billed at the full input rate); `cacheRead` and
|
|
416
|
-
* `cacheWrite` are separate cached subsets each priced at their own rate.
|
|
417
|
-
* The total context the model loaded for this turn is
|
|
418
|
-
* `input + (cacheRead ?? 0) + (cacheWrite ?? 0)`.
|
|
419
|
-
*
|
|
420
|
-
* Provider quirks normalized at the adapter layer:
|
|
421
|
-
* - Anthropic: returns `input_tokens` already disjoint from cache fields.
|
|
422
|
-
* - OpenAI / OpenAI-compatible: `prompt_tokens` is the TOTAL including
|
|
423
|
-
* cached portion; the adapter subtracts `cached_tokens` to stay disjoint.
|
|
424
|
-
* - Google: `promptTokenCount` likewise includes cache; adapter subtracts
|
|
425
|
-
* `cachedContentTokenCount`.
|
|
426
|
-
*
|
|
427
|
-
* Cost math and the context-fullness chip both depend on the disjoint
|
|
428
|
-
* invariant — a TOTAL `input` plus a separate `cacheRead` count would bill
|
|
429
|
-
* cached tokens twice and skew cache-hit-ratio reporting.
|
|
430
|
-
*/
|
|
431
|
-
type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
432
|
-
type CacheTtl = '5m' | '1h';
|
|
433
|
-
/**
|
|
434
|
-
* Provider-agnostic response-format directive.
|
|
435
|
-
*
|
|
436
|
-
* - `{ type: 'text' }` — free-form text (default).
|
|
437
|
-
* - `{ type: 'json_object' }` — valid JSON without a schema constraint.
|
|
438
|
-
* - `{ type: 'json_schema', jsonSchema: { name, schema, strict? } }` — JSON
|
|
439
|
-
* constrained to the supplied JSON Schema. The `strict` flag is
|
|
440
|
-
* OpenAI-specific; Gemini ignores it in favour of `responseMimeType`.
|
|
441
|
-
*
|
|
442
|
-
* Each provider adapter maps this into its own wire format:
|
|
443
|
-
* OpenAI → `response_format`
|
|
444
|
-
* Gemini → `responseMimeType` + `responseSchema`
|
|
445
|
-
* Anthropic → (not yet supported; uses tools for structured output)
|
|
446
|
-
*/
|
|
447
|
-
interface JsonSchemaSpec {
|
|
448
|
-
name: string;
|
|
449
|
-
/** OpenAI-specific: enable strict schema adherence. */
|
|
450
|
-
strict?: boolean | undefined;
|
|
451
|
-
/** The JSON Schema object describing the expected shape. */
|
|
452
|
-
schema: Record<string, unknown>;
|
|
453
|
-
/** Optional human-readable description (OpenAI). */
|
|
454
|
-
description?: string | undefined;
|
|
455
|
-
}
|
|
456
|
-
type ResponseFormat = {
|
|
457
|
-
type: 'text';
|
|
458
|
-
} | {
|
|
459
|
-
type: 'json_object';
|
|
460
|
-
} | {
|
|
461
|
-
type: 'json_schema';
|
|
462
|
-
jsonSchema: JsonSchemaSpec;
|
|
463
|
-
};
|
|
464
|
-
/**
|
|
465
|
-
* Safety category threshold pair used by Google Gemini's `safetySettings`.
|
|
466
|
-
*
|
|
467
|
-
* Categories: `HARM_CATEGORY_HARASSMENT`, `HARM_CATEGORY_HATE_SPEECH`,
|
|
468
|
-
* `HARM_CATEGORY_SEXUALLY_EXPLICIT`, `HARM_CATEGORY_DANGEROUS_CONTENT`.
|
|
469
|
-
*
|
|
470
|
-
* Thresholds: `BLOCK_NONE`, `BLOCK_ONLY_HIGH`, `BLOCK_MEDIUM_AND_ABOVE`,
|
|
471
|
-
* `BLOCK_LOW_AND_ABOVE`.
|
|
472
|
-
*/
|
|
473
|
-
interface SafetySetting {
|
|
474
|
-
category: string;
|
|
475
|
-
threshold: string;
|
|
476
|
-
}
|
|
477
|
-
interface Usage {
|
|
478
|
-
input: number;
|
|
479
|
-
output: number;
|
|
480
|
-
cacheRead?: number | undefined;
|
|
481
|
-
/** Back-compat aggregate of all cache-write tokens. Prefer TTL-specific fields when present. */
|
|
482
|
-
cacheWrite?: number | undefined;
|
|
483
|
-
cacheWrite5m?: number | undefined;
|
|
484
|
-
cacheWrite1h?: number | undefined;
|
|
485
|
-
}
|
|
486
|
-
/**
|
|
487
|
-
* Effective prompt tokens loaded by the model for one request.
|
|
488
|
-
*
|
|
489
|
-
* Provider adapters normalize `Usage` to disjoint fields: `input` is fresh
|
|
490
|
-
* full-rate tokens, `cacheRead` is cached prefix tokens, and `cacheWrite` is
|
|
491
|
-
* the cache-written prefix segment. Context-window pressure cares about the
|
|
492
|
-
* full prompt the model saw, not only the bill-at-full-rate slice.
|
|
493
|
-
*/
|
|
494
|
-
declare function effectiveInputTokens(usage: Usage): number;
|
|
495
|
-
interface ReasoningRequest {
|
|
496
|
-
enabled?: boolean | undefined;
|
|
497
|
-
effort?: ReasoningEffort | undefined;
|
|
498
|
-
preserve?: boolean | undefined;
|
|
499
|
-
display?: 'summarized' | 'omitted' | undefined;
|
|
500
|
-
}
|
|
501
|
-
interface RequestCacheControl {
|
|
502
|
-
ttl?: CacheTtl | undefined;
|
|
503
|
-
}
|
|
504
|
-
interface ReasoningConfig {
|
|
505
|
-
default: 'enabled' | 'disabled' | 'adaptive' | 'always_on';
|
|
506
|
-
disableSupported: boolean;
|
|
507
|
-
effortSupported: boolean;
|
|
508
|
-
effortLevels: ReasoningEffort[];
|
|
509
|
-
preserveThinking: 'unsupported' | 'optional' | 'always_on';
|
|
510
|
-
}
|
|
511
|
-
interface Capabilities {
|
|
512
|
-
tools: boolean;
|
|
513
|
-
parallelTools: boolean;
|
|
514
|
-
vision: boolean;
|
|
515
|
-
streaming: boolean;
|
|
516
|
-
promptCache: boolean;
|
|
517
|
-
systemPrompt: boolean;
|
|
518
|
-
jsonMode: boolean;
|
|
519
|
-
reasoning: boolean;
|
|
520
|
-
maxContext: number;
|
|
521
|
-
/**
|
|
522
|
-
* Maximum output tokens the model can produce in a single response.
|
|
523
|
-
* Used as the default for `Request.maxTokens` when the caller doesn't
|
|
524
|
-
* supply an explicit value — letting subagents run up to the model's
|
|
525
|
-
* native ceiling instead of a fixed 8192 cap. Omit (undefined) to fall
|
|
526
|
-
* back to a conservative default; populate per family in
|
|
527
|
-
* `family-capabilities.ts` once you know the spec.
|
|
528
|
-
*/
|
|
529
|
-
maxOutput?: number | undefined;
|
|
530
|
-
cacheControl: 'native' | 'auto' | 'none';
|
|
531
|
-
/** Model accepts `top_k` / `topK` sampling parameter. */
|
|
532
|
-
topK?: boolean | undefined;
|
|
533
|
-
/** Model accepts `frequency_penalty` / `frequencyPenalty` parameter. */
|
|
534
|
-
frequencyPenalty?: boolean | undefined;
|
|
535
|
-
/** Model accepts `presence_penalty` / `presencePenalty` parameter. */
|
|
536
|
-
presencePenalty?: boolean | undefined;
|
|
537
|
-
/** Model accepts `seed` parameter for deterministic generation. */
|
|
538
|
-
seed?: boolean | undefined;
|
|
539
|
-
/**
|
|
540
|
-
* Model accepts JSON Schema / structured-output constraints
|
|
541
|
-
* (OpenAI `response_format.json_schema`, Gemini `responseMimeType`+`responseSchema`).
|
|
542
|
-
* Distinct from `jsonMode` (which is just a system-prompt hint).
|
|
543
|
-
*/
|
|
544
|
-
structuredOutput?: boolean | undefined;
|
|
545
|
-
/** Model supports log-probability output (`logprobs`, `top_logprobs`). */
|
|
546
|
-
logprobs?: boolean | undefined;
|
|
547
|
-
/** Model supports audio input/output modality. */
|
|
548
|
-
audio?: boolean | undefined;
|
|
549
|
-
/** Model supports the `n` parameter for multiple completions. */
|
|
550
|
-
multipleCompletions?: boolean | undefined;
|
|
551
|
-
}
|
|
552
|
-
interface Request {
|
|
553
|
-
model: string;
|
|
554
|
-
system?: TextBlock[] | undefined;
|
|
555
|
-
messages: Message[];
|
|
556
|
-
tools?: Tool[] | undefined;
|
|
557
|
-
/**
|
|
558
|
-
* Cap on output tokens for this single response. Optional — when
|
|
559
|
-
* omitted, the provider adapter falls back to its own
|
|
560
|
-
* `capabilities.maxOutput` (which the catalog populates from
|
|
561
|
-
* `ModelsDevModel.limit.output`). If neither is available, the
|
|
562
|
-
* adapter applies a conservative 8192 safety net. Letting this stay
|
|
563
|
-
* undefined at the call site means callers like Chimera can hand the
|
|
564
|
-
* model its native output ceiling without hard-coding a number.
|
|
565
|
-
*/
|
|
566
|
-
maxTokens?: number | undefined;
|
|
567
|
-
temperature?: number | undefined;
|
|
568
|
-
topP?: number | undefined;
|
|
569
|
-
topK?: number | undefined;
|
|
570
|
-
frequencyPenalty?: number | undefined;
|
|
571
|
-
presencePenalty?: number | undefined;
|
|
572
|
-
seed?: number | undefined;
|
|
573
|
-
/**
|
|
574
|
-
* End-user identifier for abuse monitoring and per-user rate limiting.
|
|
575
|
-
* - Anthropic → `metadata.user_id`
|
|
576
|
-
* - OpenAI → `user`
|
|
577
|
-
* - Gemini → (not supported)
|
|
578
|
-
*/
|
|
579
|
-
user?: string | undefined;
|
|
580
|
-
/**
|
|
581
|
-
* Number of response candidates to generate. Google Gemini supports
|
|
582
|
-
* this via `generationConfig.candidateCount`. OpenAI does not have
|
|
583
|
-
* an equivalent (`n` is conceptually similar but distinct).
|
|
584
|
-
*/
|
|
585
|
-
candidateCount?: number | undefined;
|
|
586
|
-
/**
|
|
587
|
-
* Whether to return log probabilities for output tokens.
|
|
588
|
-
* - OpenAI → `logprobs: boolean` (+ `topLogprobs: number`)
|
|
589
|
-
* - Gemini → `generationConfig.logprobs: number` (how many top candidates)
|
|
590
|
-
* Default undefined = no logprobs requested.
|
|
591
|
-
*/
|
|
592
|
-
logprobs?: boolean | undefined;
|
|
593
|
-
/**
|
|
594
|
-
* Number of most probable tokens to return log probabilities for
|
|
595
|
-
* (OpenAI `top_logprobs`). Only meaningful when `logprobs` is true.
|
|
596
|
-
* Range: 0-20. Gemini ignores this (uses `logprobs` as the count).
|
|
597
|
-
*/
|
|
598
|
-
topLogprobs?: number | undefined;
|
|
599
|
-
stopSequences?: string[] | undefined;
|
|
600
|
-
toolChoice?: 'auto' | 'required' | 'none' | {
|
|
601
|
-
type: 'tool' | undefined;
|
|
602
|
-
name: string;
|
|
603
|
-
};
|
|
604
|
-
reasoning?: ReasoningRequest | undefined;
|
|
605
|
-
cache?: RequestCacheControl | undefined;
|
|
606
|
-
/**
|
|
607
|
-
* Structured-output / response-format directive.
|
|
608
|
-
* When set, the provider adapter maps this to its native response-format
|
|
609
|
-
* parameter (OpenAI `response_format`, Gemini `responseMimeType`, etc.).
|
|
610
|
-
* The model must advertise `capabilities.structuredOutput` for this to be
|
|
611
|
-
* honoured; unsupported models will likely 400 or ignore it.
|
|
612
|
-
*/
|
|
613
|
-
responseFormat?: ResponseFormat | undefined;
|
|
614
|
-
/**
|
|
615
|
-
* Safety category thresholds for filtering harmful content.
|
|
616
|
-
* - Gemini → top-level `safetySettings` array with `{ category, threshold }`
|
|
617
|
-
* - OpenAI → not supported (uses server-side moderation)
|
|
618
|
-
* - Anthropic → not supported
|
|
619
|
-
*/
|
|
620
|
-
safetySettings?: SafetySetting[] | undefined;
|
|
621
|
-
}
|
|
622
|
-
type StopReason = 'end_turn' | 'tool_use' | 'max_tokens' | 'stop_sequence' | 'refusal';
|
|
623
|
-
interface Response {
|
|
624
|
-
content: ContentBlock[];
|
|
625
|
-
stopReason: StopReason;
|
|
626
|
-
usage: Usage;
|
|
627
|
-
model: string;
|
|
628
|
-
}
|
|
629
|
-
type StreamEvent = {
|
|
630
|
-
type: 'message_start';
|
|
631
|
-
model: string;
|
|
632
|
-
} | {
|
|
633
|
-
type: 'content_block_start';
|
|
634
|
-
kind: 'text' | 'tool_use' | 'thinking';
|
|
635
|
-
id?: string | undefined;
|
|
636
|
-
name?: string | undefined;
|
|
637
|
-
} | {
|
|
638
|
-
type: 'content_block_stop';
|
|
639
|
-
index: number;
|
|
640
|
-
} | {
|
|
641
|
-
type: 'text_delta';
|
|
642
|
-
text: string;
|
|
643
|
-
} | {
|
|
644
|
-
type: 'tool_use_start';
|
|
645
|
-
id: string;
|
|
646
|
-
name: string;
|
|
647
|
-
} | {
|
|
648
|
-
type: 'tool_use_input_delta';
|
|
649
|
-
id: string;
|
|
650
|
-
partial: string;
|
|
651
|
-
} | {
|
|
652
|
-
type: 'tool_use_stop';
|
|
653
|
-
id: string;
|
|
654
|
-
input: unknown;
|
|
655
|
-
providerMeta?: Record<string, unknown>;
|
|
656
|
-
} | {
|
|
657
|
-
type: 'thinking_start';
|
|
658
|
-
providerMeta?: Record<string, unknown>;
|
|
659
|
-
} | {
|
|
660
|
-
type: 'thinking_delta';
|
|
661
|
-
text: string;
|
|
662
|
-
} | {
|
|
663
|
-
type: 'thinking_signature';
|
|
664
|
-
signature: string;
|
|
665
|
-
} | {
|
|
666
|
-
type: 'thinking_stop';
|
|
667
|
-
} | {
|
|
668
|
-
type: 'message_stop';
|
|
669
|
-
stopReason: StopReason;
|
|
670
|
-
usage: Usage;
|
|
671
|
-
};
|
|
672
|
-
interface Provider {
|
|
673
|
-
readonly id: string;
|
|
674
|
-
readonly capabilities: Capabilities;
|
|
675
|
-
/** Canonical streaming entry point. `complete()` defaults to a wrapper that
|
|
676
|
-
* aggregates this stream — providers may override for non-streaming wires. */
|
|
677
|
-
stream(req: Request, opts: {
|
|
678
|
-
signal: AbortSignal;
|
|
679
|
-
}): AsyncIterable<StreamEvent>;
|
|
680
|
-
complete(req: Request, opts: {
|
|
681
|
-
signal: AbortSignal;
|
|
682
|
-
}): Promise<Response>;
|
|
683
|
-
}
|
|
684
|
-
/**
|
|
685
|
-
* Structured body parsed from a provider's HTTP error response. Populated
|
|
686
|
-
* best-effort: providers return JSON shaped differently (Anthropic uses
|
|
687
|
-
* `{error: {type, message}}`, OpenAI uses `{error: {message, code}}`,
|
|
688
|
-
* Google uses `{error: {status, message}}`), so the fields here are the
|
|
689
|
-
* intersection that's usable for rendering and routing.
|
|
690
|
-
*/
|
|
691
|
-
interface ProviderErrorBody {
|
|
692
|
-
/** Provider-specific kind, e.g. "overloaded_error", "rate_limit_error", "invalid_request_error". */
|
|
693
|
-
type?: string | undefined;
|
|
694
|
-
/** Human-readable explanation from the provider. */
|
|
695
|
-
message?: string | undefined;
|
|
696
|
-
/** Provider request id, when present in the body or headers. */
|
|
697
|
-
requestId?: string | undefined;
|
|
698
|
-
/** Parsed Retry-After header (or equivalent body hint) in milliseconds. */
|
|
699
|
-
retryAfterMs?: number | undefined;
|
|
700
|
-
/** The raw response body (truncated to ~2 KB), kept for debugging. */
|
|
701
|
-
raw?: string | undefined;
|
|
702
|
-
/** True when `raw` was truncated; check `rawLength` for the original size. */
|
|
703
|
-
truncated?: boolean | undefined;
|
|
704
|
-
/** Original length of the response body in bytes, when `truncated` is true. */
|
|
705
|
-
rawLength?: number | undefined;
|
|
706
|
-
}
|
|
707
|
-
/**
|
|
708
|
-
* Canonical provider-failure taxonomy. Computed ONCE at error-construction
|
|
709
|
-
* time (`classifyProviderError`) and carried on `ProviderError.kind` so
|
|
710
|
-
* every downstream consumer — retry policy, cross-provider fallback,
|
|
711
|
-
* recovery strategies, the subagent error classifier — branches on the
|
|
712
|
-
* same classification instead of re-deriving it from status codes and
|
|
713
|
-
* message regexes. When a new provider's error format needs special
|
|
714
|
-
* handling, this module is the only place to teach it.
|
|
715
|
-
*/
|
|
716
|
-
type ProviderErrorKind = 'rate_limit' | 'overloaded' | 'server' | 'timeout' | 'network' | 'stream_hang' | 'auth' | 'context_overflow' | 'content_filter' | 'invalid_request' | 'unknown';
|
|
717
|
-
/**
|
|
718
|
-
* Classify a provider HTTP failure into the canonical taxonomy from its
|
|
719
|
-
* status code plus the parsed error body (and, for message-only errors
|
|
720
|
-
* without a structured body, the error message itself). Pure and total —
|
|
721
|
-
* always returns a kind, never throws.
|
|
722
|
-
*/
|
|
723
|
-
declare function classifyProviderError(status: number, body?: ProviderErrorBody, message?: string): ProviderErrorKind;
|
|
724
|
-
/**
|
|
725
|
-
* Whether a kind is worth retrying against the SAME provider/model.
|
|
726
|
-
* `context_overflow` is deliberately false — the request must shrink first;
|
|
727
|
-
* `auth`/`invalid_request`/`content_filter` won't improve on replay.
|
|
728
|
-
*
|
|
729
|
-
* Exhaustive by construction (`Record<ProviderErrorKind, …>`): adding a new
|
|
730
|
-
* kind refuses to compile until it is classified here. Every kind→X mapping
|
|
731
|
-
* in the codebase follows this drift-guard pattern — see also KIND_TO_CODE
|
|
732
|
-
* below, DefaultRetryPolicy.maxAttempts, fallback-model shouldFallback, and
|
|
733
|
-
* the coordinator's providerErrorToSubagentError.
|
|
734
|
-
*/
|
|
735
|
-
declare function isRetryableKind(kind: ProviderErrorKind): boolean;
|
|
736
|
-
declare class ProviderError extends WrongStackError {
|
|
737
|
-
readonly status: number;
|
|
738
|
-
readonly retryable: boolean;
|
|
739
|
-
readonly providerId: string;
|
|
740
|
-
/** Canonical failure classification — see {@link ProviderErrorKind}. */
|
|
741
|
-
readonly kind: ProviderErrorKind;
|
|
742
|
-
readonly body?: ProviderErrorBody | undefined;
|
|
743
|
-
constructor(message: string, status: number, retryable: boolean, providerId: string, opts?: {
|
|
744
|
-
body?: ProviderErrorBody | undefined;
|
|
745
|
-
cause?: unknown | undefined;
|
|
746
|
-
/** Override the computed classification (rarely needed — tests, custom wires). */
|
|
747
|
-
kind?: ProviderErrorKind | undefined;
|
|
748
|
-
});
|
|
749
|
-
/**
|
|
750
|
-
* Render a one-line, user-facing description. Designed for the CLI/TUI
|
|
751
|
-
* status line and the agent's retry warning. Avoids dumping raw JSON
|
|
752
|
-
* (which is what users see today when a 529 lands and the log message
|
|
753
|
-
* includes the full `{"type":"error",...}` body).
|
|
754
|
-
*
|
|
755
|
-
* Examples:
|
|
756
|
-
* "minimax-coding-plan overloaded (529): High traffic detected. Upgrade for highspeed model. [req 06534785201de9c0…]"
|
|
757
|
-
* "openai rate limited (429): Retry after 12s"
|
|
758
|
-
* "anthropic invalid request (400): messages.0.role must be one of 'user'|'assistant'"
|
|
759
|
-
* "groq HTTP 500 (server error)"
|
|
760
|
-
*/
|
|
761
|
-
describe(): string;
|
|
762
|
-
}
|
|
763
|
-
/**
|
|
764
|
-
* Thrown when the provider stream stops delivering data mid-response.
|
|
765
|
-
* This is distinct from a network error (TCP reset, DNS failure) — the
|
|
766
|
-
* connection is established and the response started, but chunks stopped
|
|
767
|
-
* arriving before the stream completed.
|
|
768
|
-
*
|
|
769
|
-
* Status 599 is used as a sentinel to distinguish stream hangs from
|
|
770
|
-
* regular HTTP errors while still flowing through ProviderError-based
|
|
771
|
-
* retry and fallback infrastructure.
|
|
772
|
-
*/
|
|
773
|
-
declare class StreamHangError extends ProviderError {
|
|
774
|
-
/** Name of the provider that hung, e.g. "zai", "anthropic". */
|
|
775
|
-
readonly hungProviderId: string;
|
|
776
|
-
/** Model that was being called when the hang occurred. */
|
|
777
|
-
readonly hungModel: string;
|
|
778
|
-
/** How long (ms) we waited for the next chunk before declaring a hang. */
|
|
779
|
-
readonly hangTimeoutMs: number;
|
|
780
|
-
/** How many bytes were received before the hang. */
|
|
781
|
-
readonly bytesReceived: number;
|
|
782
|
-
/** Elapsed time (ms) from the start of the stream until the hang. */
|
|
783
|
-
readonly elapsedMs: number;
|
|
784
|
-
constructor(opts: {
|
|
785
|
-
providerId: string;
|
|
786
|
-
model: string;
|
|
787
|
-
hangTimeoutMs: number;
|
|
788
|
-
bytesReceived: number;
|
|
789
|
-
elapsedMs: number;
|
|
790
|
-
cause?: unknown | undefined;
|
|
791
|
-
});
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
interface SessionMetadata {
|
|
795
|
-
id: string;
|
|
796
|
-
title?: string | undefined;
|
|
797
|
-
model?: string | undefined;
|
|
798
|
-
provider?: string | undefined;
|
|
799
|
-
startedAt: string;
|
|
800
|
-
endedAt?: string | undefined;
|
|
801
|
-
/** Set when a session is closed with open tool calls — used to restore pending state on resume. */
|
|
802
|
-
pendingToolUses?: string[] | undefined;
|
|
803
|
-
/** Parent journal metadata when this session was created by fork(). */
|
|
804
|
-
forkedFrom?: {
|
|
805
|
-
sessionId: string;
|
|
806
|
-
checkpointPromptIndex?: number | undefined;
|
|
807
|
-
checkpointHash: string;
|
|
808
|
-
workspace: 'shared-current';
|
|
809
|
-
workspaceCheckpointHash?: string | undefined;
|
|
810
|
-
} | undefined;
|
|
811
|
-
}
|
|
812
|
-
/**
|
|
813
|
-
* SessionEvent — per-session persistent JSONL audit + reconstruct log.
|
|
814
|
-
*
|
|
815
|
-
* ## Two-Tier Model (see Config.session.auditLevel)
|
|
816
|
-
*
|
|
817
|
-
* **Core Reconstruct Set** (always persisted, minimal & reliable):
|
|
818
|
-
* - `session_start`, `session_resumed`, `session_forked`, `user_input`, `llm_response`, `tool_result`
|
|
819
|
-
* - `context_snapshot`, `checkpoint`, `file_snapshot`, `file_observation`, `rewound`
|
|
820
|
-
* - `in_flight_start` / `in_flight_end`, `session_end`
|
|
821
|
-
*
|
|
822
|
-
* These events are **required** for correct resume, rewind, crash recovery
|
|
823
|
-
* and conversation replay. They are written regardless of auditLevel.
|
|
824
|
-
*
|
|
825
|
-
* **Audit Detail Set** (controlled by `session.auditLevel`):
|
|
826
|
-
* - `llm_request` (lightweight by default)
|
|
827
|
-
* - `tool_use`, `tool_call_start`/`tool_call_end`
|
|
828
|
-
* - `compaction`, `error`, `message_truncated`, provider retries, etc.
|
|
829
|
-
*
|
|
830
|
-
* When `auditLevel: "minimal"` only Core Reconstruct events are guaranteed.
|
|
831
|
-
* `"standard"` (default) adds the most valuable lightweight audit events.
|
|
832
|
-
* `"full"` enables heavier payloads (may be stored in a sidecar replay log).
|
|
833
|
-
*
|
|
834
|
-
* ## Guarantees
|
|
835
|
-
* - All appends are best-effort. A failed write logs a throttled warning but
|
|
836
|
-
* never aborts the agent loop.
|
|
837
|
-
* - Sensitive content in `user_input`, `llm_response`, and
|
|
838
|
-
* `context_snapshot` is passed through the configured SecretScrubber before
|
|
839
|
-
* being written or summarized.
|
|
840
|
-
* - The log is append-only JSONL. Individual lines may be malformed after
|
|
841
|
-
* hard crashes; `DefaultSessionStore.load()` silently skips bad lines.
|
|
842
|
-
*
|
|
843
|
-
* ## Location (source of truth: resolveWstackPaths)
|
|
844
|
-
* ~/.wrongstack/projects/<sha256(projectRoot).slice(0,12)>/sessions/<date>/sess_<ULID>.jsonl
|
|
845
|
-
*
|
|
846
|
-
* The only files that live inside the project tree are the committed
|
|
847
|
-
* `.wrongstack/AGENTS.md` and `.wrongstack/skills/`.
|
|
848
|
-
*/
|
|
849
|
-
type SessionEvent = {
|
|
850
|
-
type: 'session_start';
|
|
851
|
-
ts: string;
|
|
852
|
-
id: string;
|
|
853
|
-
model: string;
|
|
854
|
-
provider: string;
|
|
855
|
-
} | {
|
|
856
|
-
type: 'session_resumed';
|
|
857
|
-
ts: string;
|
|
858
|
-
id: string;
|
|
859
|
-
model: string;
|
|
860
|
-
provider: string;
|
|
861
|
-
} | {
|
|
862
|
-
type: 'session_forked';
|
|
863
|
-
ts: string;
|
|
864
|
-
parentSessionId: string;
|
|
865
|
-
parentCheckpointPromptIndex?: number | undefined;
|
|
866
|
-
parentCheckpointHash: string;
|
|
867
|
-
/** The child journal is isolated; filesystem state remains shared. */
|
|
868
|
-
workspace: 'shared-current';
|
|
869
|
-
workspaceCheckpointHash?: string | undefined;
|
|
870
|
-
} | {
|
|
871
|
-
type: 'user_input';
|
|
872
|
-
ts: string;
|
|
873
|
-
content: string | ContentBlock[];
|
|
874
|
-
} | {
|
|
875
|
-
type: 'llm_request';
|
|
876
|
-
ts: string;
|
|
877
|
-
model: string;
|
|
878
|
-
messageCount: number;
|
|
879
|
-
/** Estimated total input tokens for this request (messages + tools + system). */
|
|
880
|
-
estimatedInputTokens?: number | undefined;
|
|
881
|
-
/** Number of tools offered to the model in this request. */
|
|
882
|
-
toolCount?: number | undefined;
|
|
883
|
-
} | {
|
|
884
|
-
type: 'llm_response';
|
|
885
|
-
ts: string;
|
|
886
|
-
content: ContentBlock[];
|
|
887
|
-
stopReason: string;
|
|
888
|
-
usage: Usage;
|
|
889
|
-
} | {
|
|
890
|
-
type: 'tool_use';
|
|
891
|
-
ts: string;
|
|
892
|
-
name: string;
|
|
893
|
-
id: string;
|
|
894
|
-
input: unknown;
|
|
895
|
-
} | {
|
|
896
|
-
type: 'tool_result';
|
|
897
|
-
ts: string;
|
|
898
|
-
id: string;
|
|
899
|
-
content: unknown;
|
|
900
|
-
isError: boolean;
|
|
901
|
-
} | {
|
|
902
|
-
/**
|
|
903
|
-
* Exact post-rewrite conversation state. Replay replaces all messages
|
|
904
|
-
* reconstructed before this event, then continues applying later events.
|
|
905
|
-
* Currently emitted after compaction.
|
|
906
|
-
*/
|
|
907
|
-
type: 'context_snapshot';
|
|
908
|
-
ts: string;
|
|
909
|
-
reason: 'compaction';
|
|
910
|
-
messages: Message[];
|
|
911
|
-
} | {
|
|
912
|
-
type: 'compaction';
|
|
913
|
-
ts: string;
|
|
914
|
-
before: number;
|
|
915
|
-
after: number;
|
|
916
|
-
/** Pressure level that triggered the compaction. */
|
|
917
|
-
level?: 'warn' | 'soft' | 'hard' | undefined;
|
|
918
|
-
aggressive?: boolean | undefined;
|
|
919
|
-
/** Summary of token savings per phase (elision, summary, selective). */
|
|
920
|
-
reductions?: Array<{
|
|
921
|
-
phase: string;
|
|
922
|
-
saved: number;
|
|
923
|
-
}>;
|
|
924
|
-
/** Context budget snapshot used to trigger this compaction. */
|
|
925
|
-
budget?: {
|
|
926
|
-
maxContext: number;
|
|
927
|
-
inputTokens: number;
|
|
928
|
-
availableInputTokens: number;
|
|
929
|
-
remainingInputTokens: number;
|
|
930
|
-
reservedOutputTokens: number;
|
|
931
|
-
reservedSafetyTokens: number;
|
|
932
|
-
load: number;
|
|
933
|
-
overflowTokens: number;
|
|
934
|
-
} | undefined;
|
|
935
|
-
/** Adaptive trigger signals observed alongside token pressure. */
|
|
936
|
-
signals?: {
|
|
937
|
-
repeatedReadCount?: number | undefined;
|
|
938
|
-
} | undefined;
|
|
939
|
-
/**
|
|
940
|
-
* Lossless digest of the range collapsed during this compaction (text
|
|
941
|
-
* content preserved; raw tool I/O omitted). Captures *what* was collapsed
|
|
942
|
-
* for forensics. May be truncated for log size. Absent when nothing was
|
|
943
|
-
* collapsed (e.g. elision-only passes).
|
|
944
|
-
*/
|
|
945
|
-
digest?: string | undefined;
|
|
946
|
-
} | {
|
|
947
|
-
type: 'error';
|
|
948
|
-
ts: string;
|
|
949
|
-
message: string;
|
|
950
|
-
phase: string;
|
|
951
|
-
} | {
|
|
952
|
-
type: 'session_end';
|
|
953
|
-
ts: string;
|
|
954
|
-
usage: Usage;
|
|
955
|
-
pendingToolUses?: string[] | undefined;
|
|
956
|
-
} | {
|
|
957
|
-
type: 'mode_changed';
|
|
958
|
-
ts: string;
|
|
959
|
-
from: string;
|
|
960
|
-
to: string;
|
|
961
|
-
} | {
|
|
962
|
-
type: 'task_created';
|
|
963
|
-
ts: string;
|
|
964
|
-
taskId: string;
|
|
965
|
-
title: string;
|
|
966
|
-
} | {
|
|
967
|
-
type: 'task_updated';
|
|
968
|
-
ts: string;
|
|
969
|
-
taskId: string;
|
|
970
|
-
status: string;
|
|
971
|
-
} | {
|
|
972
|
-
type: 'task_completed';
|
|
973
|
-
ts: string;
|
|
974
|
-
taskId: string;
|
|
975
|
-
title: string;
|
|
976
|
-
} | {
|
|
977
|
-
type: 'task_failed';
|
|
978
|
-
ts: string;
|
|
979
|
-
taskId: string;
|
|
980
|
-
title: string;
|
|
981
|
-
error: string;
|
|
982
|
-
} | {
|
|
983
|
-
type: 'agent_spawned';
|
|
984
|
-
ts: string;
|
|
985
|
-
agentId: string;
|
|
986
|
-
role: string;
|
|
987
|
-
} | {
|
|
988
|
-
type: 'agent_stopped';
|
|
989
|
-
ts: string;
|
|
990
|
-
agentId: string;
|
|
991
|
-
} | {
|
|
992
|
-
type: 'agent_error';
|
|
993
|
-
ts: string;
|
|
994
|
-
agentId: string;
|
|
995
|
-
error: string;
|
|
996
|
-
} | {
|
|
997
|
-
type: 'spec_parsed';
|
|
998
|
-
ts: string;
|
|
999
|
-
specId: string;
|
|
1000
|
-
title: string;
|
|
1001
|
-
completeness: number;
|
|
1002
|
-
} | {
|
|
1003
|
-
type: 'spec_analyzed';
|
|
1004
|
-
ts: string;
|
|
1005
|
-
specId: string;
|
|
1006
|
-
gaps: string[];
|
|
1007
|
-
} | {
|
|
1008
|
-
type: 'skill_activated';
|
|
1009
|
-
ts: string;
|
|
1010
|
-
skillName: string;
|
|
1011
|
-
} | {
|
|
1012
|
-
type: 'skill_deactivated';
|
|
1013
|
-
ts: string;
|
|
1014
|
-
skillName: string;
|
|
1015
|
-
} | {
|
|
1016
|
-
type: 'tool_call_start';
|
|
1017
|
-
ts: string;
|
|
1018
|
-
name: string;
|
|
1019
|
-
id: string;
|
|
1020
|
-
input: unknown;
|
|
1021
|
-
} | {
|
|
1022
|
-
type: 'tool_call_end';
|
|
1023
|
-
ts: string;
|
|
1024
|
-
name: string;
|
|
1025
|
-
id: string;
|
|
1026
|
-
durationMs: number;
|
|
1027
|
-
/** Legacy field kept for backward compatibility. Prefer outputBytes. */
|
|
1028
|
-
outputSize: number;
|
|
1029
|
-
ok?: boolean | undefined;
|
|
1030
|
-
outputBytes?: number | undefined;
|
|
1031
|
-
outputTokens?: number | undefined;
|
|
1032
|
-
outputLines?: number | undefined;
|
|
1033
|
-
} | {
|
|
1034
|
-
/** Lightweight sampled progress from Tool.executeStream (only at auditLevel 'full'). */
|
|
1035
|
-
type: 'tool_progress';
|
|
1036
|
-
ts: string;
|
|
1037
|
-
name: string;
|
|
1038
|
-
id: string;
|
|
1039
|
-
event: {
|
|
1040
|
-
type: 'log' | 'warning' | 'metric' | 'file_changed' | 'partial_output';
|
|
1041
|
-
text?: string | undefined;
|
|
1042
|
-
data?: Record<string, unknown>;
|
|
1043
|
-
};
|
|
1044
|
-
} | {
|
|
1045
|
-
type: 'message_truncated';
|
|
1046
|
-
ts: string;
|
|
1047
|
-
before: number;
|
|
1048
|
-
after: number;
|
|
1049
|
-
} | {
|
|
1050
|
-
type: 'provider_retry';
|
|
1051
|
-
ts: string;
|
|
1052
|
-
providerId: string;
|
|
1053
|
-
attempt: number;
|
|
1054
|
-
delayMs: number;
|
|
1055
|
-
status?: number | undefined;
|
|
1056
|
-
description: string;
|
|
1057
|
-
} | {
|
|
1058
|
-
type: 'provider_error';
|
|
1059
|
-
ts: string;
|
|
1060
|
-
providerId: string;
|
|
1061
|
-
status?: number | undefined;
|
|
1062
|
-
description: string;
|
|
1063
|
-
retryable: boolean;
|
|
1064
|
-
} | {
|
|
1065
|
-
type: 'checkpoint';
|
|
1066
|
-
ts: string;
|
|
1067
|
-
promptIndex: number;
|
|
1068
|
-
promptPreview: string;
|
|
1069
|
-
/** Content-addressed Git HEAD + dirty/untracked workspace manifest. */
|
|
1070
|
-
workspaceCheckpoint?: WorkspaceCheckpointRef | undefined;
|
|
1071
|
-
} | {
|
|
1072
|
-
type: 'file_snapshot';
|
|
1073
|
-
ts: string;
|
|
1074
|
-
promptIndex: number;
|
|
1075
|
-
files: FileSnapshot[];
|
|
1076
|
-
} | {
|
|
1077
|
-
/**
|
|
1078
|
-
* Hash of a file version observed by a tool. The latest observation per
|
|
1079
|
-
* path is revalidated when the session resumes so stale tool context is
|
|
1080
|
-
* surfaced to the model before it continues.
|
|
1081
|
-
*/
|
|
1082
|
-
type: 'file_observation';
|
|
1083
|
-
ts: string;
|
|
1084
|
-
path: string;
|
|
1085
|
-
hash: string;
|
|
1086
|
-
mtimeMs: number;
|
|
1087
|
-
source: 'user' | 'write';
|
|
1088
|
-
} | {
|
|
1089
|
-
type: 'rewound';
|
|
1090
|
-
ts: string;
|
|
1091
|
-
toPromptIndex: number;
|
|
1092
|
-
revertedFiles: string[];
|
|
1093
|
-
} | {
|
|
1094
|
-
/**
|
|
1095
|
-
* Idea #1 from IDEAS.md — Stateful Session Recovery.
|
|
1096
|
-
*
|
|
1097
|
-
* Marks the start of "the process is currently working on this
|
|
1098
|
-
* point in the log". If the process exits cleanly, a matching
|
|
1099
|
-
* `in_flight_end` follows. If the process dies (crash, OOM,
|
|
1100
|
-
* machine sleep, SIGKILL), ordinary request/response/tool events may
|
|
1101
|
-
* follow the start marker but no later lifecycle boundary closes it.
|
|
1102
|
-
* `SessionRecovery.detectStale` scans for that latest unmatched
|
|
1103
|
-
* lifecycle boundary and flags the session as resumable.
|
|
1104
|
-
*
|
|
1105
|
-
* `context` is a free-form description of the current
|
|
1106
|
-
* operation (e.g. "iteration 14 / tool: read / id: tu-7") so
|
|
1107
|
-
* the recovery UI can show "what was the agent doing when it
|
|
1108
|
-
* died?".
|
|
1109
|
-
*/
|
|
1110
|
-
type: 'in_flight_start';
|
|
1111
|
-
ts: string;
|
|
1112
|
-
context: string;
|
|
1113
|
-
} | {
|
|
1114
|
-
type: 'in_flight_end';
|
|
1115
|
-
ts: string;
|
|
1116
|
-
reason: 'clean' | 'aborted' | 'recovered';
|
|
1117
|
-
} | {
|
|
1118
|
-
/**
|
|
1119
|
-
* Structured side-effect audit record (P2 #5). Appended by tools that
|
|
1120
|
-
* perform non-filesystem mutations (bash, install, fetch) so /diag and
|
|
1121
|
-
* session replay can show what the agent did beyond file edits.
|
|
1122
|
-
* Unlike file_snapshot, this is purely for observability — no undo.
|
|
1123
|
-
*/
|
|
1124
|
-
type: 'side_effect';
|
|
1125
|
-
ts: string;
|
|
1126
|
-
toolUseId: string;
|
|
1127
|
-
toolName: string;
|
|
1128
|
-
input: Record<string, unknown>;
|
|
1129
|
-
outcome?: string | undefined;
|
|
1130
|
-
risk: 'fs.write' | 'shell' | 'package' | 'network' | 'config';
|
|
1131
|
-
};
|
|
1132
|
-
type FileSnapshot = {
|
|
1133
|
-
path: string;
|
|
1134
|
-
action: 'created' | 'modified' | 'deleted';
|
|
1135
|
-
before: string | null;
|
|
1136
|
-
after: string | null;
|
|
1137
|
-
};
|
|
1138
|
-
interface WorkspaceCheckpointRef {
|
|
1139
|
-
manifestHash: string;
|
|
1140
|
-
baseHead: string;
|
|
1141
|
-
entryCount: number;
|
|
1142
|
-
unresolvedCount: number;
|
|
1143
|
-
capturedAt: string;
|
|
1144
|
-
/** Base Git tree plus every non-ignored changed/untracked path. */
|
|
1145
|
-
coverage: 'git-head-plus-dirty';
|
|
1146
|
-
}
|
|
1147
|
-
interface WorkspaceMaterializationResult {
|
|
1148
|
-
targetRoot: string;
|
|
1149
|
-
writtenFiles: string[];
|
|
1150
|
-
deletedFiles: string[];
|
|
1151
|
-
errors: string[];
|
|
1152
|
-
}
|
|
1153
|
-
type ResumeFileStatus = 'modified' | 'deleted' | 'unreadable' | 'outside_project';
|
|
1154
|
-
interface ResumeFileValidationEntry {
|
|
1155
|
-
/** Absolute path recorded by the original tool observation. */
|
|
1156
|
-
path: string;
|
|
1157
|
-
/** Timestamp of the latest observation that was checked. */
|
|
1158
|
-
observedAt: string;
|
|
1159
|
-
status: ResumeFileStatus;
|
|
1160
|
-
expectedHash: string;
|
|
1161
|
-
actualHash?: string | undefined;
|
|
1162
|
-
detail?: string | undefined;
|
|
1163
|
-
}
|
|
1164
|
-
interface ResumeValidation {
|
|
1165
|
-
checkedAt: string;
|
|
1166
|
-
/** Number of distinct paths with a valid persisted observation. */
|
|
1167
|
-
checkedFileCount: number;
|
|
1168
|
-
/** Changed, missing, unreadable, or out-of-scope paths. */
|
|
1169
|
-
staleFiles: ResumeFileValidationEntry[];
|
|
1170
|
-
}
|
|
1171
|
-
interface SessionSummary {
|
|
1172
|
-
id: string;
|
|
1173
|
-
title: string;
|
|
1174
|
-
/**
|
|
1175
|
-
* Optional user-supplied name for the session. Unlike {@link title} (which
|
|
1176
|
-
* is auto-derived from the first user message and overwritten on every
|
|
1177
|
-
* rebuild), `name` is set explicitly via {@link SessionStore.rename} and
|
|
1178
|
-
* persisted in the `.summary.json` sidecar and `_index.jsonl`. Listings
|
|
1179
|
-
* should prefer `name` over `title` when present; `title` remains the
|
|
1180
|
-
* fallback and stays in sync as the conversation evolves.
|
|
1181
|
-
*/
|
|
1182
|
-
name?: string | undefined;
|
|
1183
|
-
startedAt: string;
|
|
1184
|
-
/** When the session finished (null if still running / crashed). */
|
|
1185
|
-
endedAt?: string | undefined;
|
|
1186
|
-
model: string;
|
|
1187
|
-
provider: string;
|
|
1188
|
-
tokenTotal: number;
|
|
1189
|
-
/** Number of LLM iterations (turn cycles). */
|
|
1190
|
-
iterationCount?: number | undefined;
|
|
1191
|
-
/** Number of tool calls executed. */
|
|
1192
|
-
toolCallCount?: number | undefined;
|
|
1193
|
-
/** Number of tool calls that returned an error. */
|
|
1194
|
-
toolErrorCount?: number | undefined;
|
|
1195
|
-
/** Number of files changed (created + modified + deleted). */
|
|
1196
|
-
fileChangeCount?: number | undefined;
|
|
1197
|
-
/** Per-tool breakdown: tool name → call count. */
|
|
1198
|
-
toolBreakdown?: Record<string, number>;
|
|
1199
|
-
/** Number of compaction events. */
|
|
1200
|
-
compactionCount?: number | undefined;
|
|
1201
|
-
/** Session outcome: 'completed', 'error', 'timeout', 'aborted', or undefined. */
|
|
1202
|
-
outcome?: 'completed' | 'error' | 'timeout' | 'aborted' | undefined;
|
|
1203
|
-
}
|
|
1204
|
-
interface SessionData {
|
|
1205
|
-
metadata: SessionMetadata;
|
|
1206
|
-
events: SessionEvent[];
|
|
1207
|
-
messages: Message[];
|
|
1208
|
-
usage: Usage;
|
|
1209
|
-
/** Tool execution records extracted from `tool_call_end` events — used for TUI tool entry rendering on resume. */
|
|
1210
|
-
toolCallEnds: Array<{
|
|
1211
|
-
name: string;
|
|
1212
|
-
id: string;
|
|
1213
|
-
durationMs: number;
|
|
1214
|
-
ok: boolean;
|
|
1215
|
-
outputBytes?: number | undefined;
|
|
1216
|
-
outputTokens?: number | undefined;
|
|
1217
|
-
outputLines?: number | undefined;
|
|
1218
|
-
}>;
|
|
1219
|
-
/** Present on resume when the store is configured with a project root. */
|
|
1220
|
-
resumeValidation?: ResumeValidation | undefined;
|
|
1221
|
-
}
|
|
1222
|
-
interface ResumedSession {
|
|
1223
|
-
writer: SessionWriter;
|
|
1224
|
-
data: SessionData;
|
|
1225
|
-
}
|
|
1226
|
-
interface SessionForkOptions {
|
|
1227
|
-
/** Omit to fork the latest persisted event boundary. */
|
|
1228
|
-
checkpointPromptIndex?: number | undefined;
|
|
1229
|
-
}
|
|
1230
|
-
interface ForkedSession {
|
|
1231
|
-
id: string;
|
|
1232
|
-
data: SessionData;
|
|
1233
|
-
parentSessionId: string;
|
|
1234
|
-
checkpointPromptIndex?: number | undefined;
|
|
1235
|
-
/** SHA-256 of the exact parent event prefix used to create this branch. */
|
|
1236
|
-
checkpointHash: string;
|
|
1237
|
-
/** Session history is isolated, but both branches still see the same files. */
|
|
1238
|
-
workspace: 'shared-current';
|
|
1239
|
-
/** Available for checkpoint forks captured by workspace-CAS-aware writers. */
|
|
1240
|
-
workspaceCheckpoint?: WorkspaceCheckpointRef | undefined;
|
|
1241
|
-
}
|
|
1242
|
-
interface SessionStore {
|
|
1243
|
-
create(meta: Omit<SessionMetadata, 'startedAt'>): Promise<SessionWriter>;
|
|
1244
|
-
load(id: string): Promise<SessionData>;
|
|
1245
|
-
/**
|
|
1246
|
-
* Open an existing session for append, returning both a writer that
|
|
1247
|
-
* continues writing to the same JSONL file and the replayed state
|
|
1248
|
-
* (messages + usage) so the caller can hydrate a Context. A
|
|
1249
|
-
* `session_resumed` marker is appended for audit.
|
|
1250
|
-
*/
|
|
1251
|
-
resume(id: string): Promise<ResumedSession>;
|
|
1252
|
-
/**
|
|
1253
|
-
* Create a non-destructive child journal from a persisted parent boundary.
|
|
1254
|
-
* Parent file snapshots are intentionally not inherited as rewind authority;
|
|
1255
|
-
* filesystem isolation is the caller's worktree/CAS responsibility.
|
|
1256
|
-
*/
|
|
1257
|
-
fork?(id: string, opts?: SessionForkOptions): Promise<ForkedSession>;
|
|
1258
|
-
/** Apply a captured workspace manifest to an already-isolated checkout. */
|
|
1259
|
-
materializeWorkspaceCheckpoint?(checkpoint: WorkspaceCheckpointRef, targetRoot: string): Promise<WorkspaceMaterializationResult>;
|
|
1260
|
-
list(limit?: number): Promise<SessionSummary[]>;
|
|
1261
|
-
/**
|
|
1262
|
-
* Set or clear a user-supplied name on a session. An empty/whitespace
|
|
1263
|
-
* `name` clears the field (the summary's auto-derived `title` remains).
|
|
1264
|
-
* Persists the change to the `.summary.json` sidecar and updates the
|
|
1265
|
-
* `_index.jsonl` cache so subsequent `list()` calls reflect it.
|
|
1266
|
-
* Returns the refreshed summary. Throws if the session does not exist.
|
|
1267
|
-
*/
|
|
1268
|
-
rename(id: string, name: string): Promise<SessionSummary>;
|
|
1269
|
-
delete(id: string): Promise<void>;
|
|
1270
|
-
/**
|
|
1271
|
-
* Rewrite the session JSONL file to contain only a fresh session_start
|
|
1272
|
-
* event, effectively clearing all conversation history for that session.
|
|
1273
|
-
* Called by /clear to wipe persistent chat history.
|
|
1274
|
-
*/
|
|
1275
|
-
clearHistory(id: string): Promise<void>;
|
|
1276
|
-
/**
|
|
1277
|
-
* Delete sessions whose JSONL file mtime is older than maxAgeDays.
|
|
1278
|
-
* Also removes associated summary files, plan/todos sidecars, and
|
|
1279
|
-
* session directories. Returns the count of deleted sessions.
|
|
1280
|
-
* Sessions referenced by active.json are never pruned.
|
|
1281
|
-
*/
|
|
1282
|
-
prune(maxAgeDays?: number): Promise<number>;
|
|
1283
|
-
/**
|
|
1284
|
-
* Rebuild the session index from disk. Scans all session directories,
|
|
1285
|
-
* computes summaries, and writes a fresh _index.jsonl. Returns the
|
|
1286
|
-
* number of sessions indexed.
|
|
1287
|
-
*/
|
|
1288
|
-
rebuildIndex?(): Promise<number>;
|
|
1289
|
-
/**
|
|
1290
|
-
* Streaming event-level search. Walks the JSONL once without buffering
|
|
1291
|
-
* the whole file, calling `predicate(event, eventIndex, ts)` for each
|
|
1292
|
-
* parsed event. Stops as soon as `limit` matches are collected (when
|
|
1293
|
-
* provided) and yields only the matching events back to the caller.
|
|
1294
|
-
*
|
|
1295
|
-
* Implementations that don't support streaming MUST omit this method;
|
|
1296
|
-
* the SessionReader fallback path will then call `load()` instead. The
|
|
1297
|
-
* method is intentionally non-throwing for missing files — a missing
|
|
1298
|
-
* session yields an empty array, matching `load()` semantics for ENOENT.
|
|
1299
|
-
*
|
|
1300
|
-
* @param id Session id (with or without the `.jsonl` suffix).
|
|
1301
|
-
* @param predicate Returns true to keep the event in the result set.
|
|
1302
|
-
* @param opts.limit Maximum number of hits to keep. Omit for unbounded.
|
|
1303
|
-
* @param opts.signal Optional AbortSignal for early termination.
|
|
1304
|
-
*/
|
|
1305
|
-
searchEvents?(id: string, predicate: (event: SessionEvent, eventIndex: number, ts: string) => boolean, opts?: {
|
|
1306
|
-
limit?: number | undefined;
|
|
1307
|
-
signal?: AbortSignal | undefined;
|
|
1308
|
-
}): Promise<Array<{
|
|
1309
|
-
event: SessionEvent;
|
|
1310
|
-
eventIndex: number;
|
|
1311
|
-
ts: string;
|
|
1312
|
-
}>>;
|
|
1313
|
-
}
|
|
1314
|
-
interface SessionWriter {
|
|
1315
|
-
readonly id: string;
|
|
1316
|
-
/**
|
|
1317
|
-
* Session-level trace ID for correlating storage events with agent
|
|
1318
|
-
* iterations in observability pipelines. Generated once at Context
|
|
1319
|
-
* creation time and stored here so storage operations can include it
|
|
1320
|
-
* in `storage.*` events even though the store has no direct handle
|
|
1321
|
-
* on the Context.
|
|
1322
|
-
*/
|
|
1323
|
-
traceId?: string | undefined;
|
|
1324
|
-
/**
|
|
1325
|
-
* Absolute path to the JSONL file this writer appends to, when one
|
|
1326
|
-
* exists. In-memory writers (tests, ephemeral sessions) leave it
|
|
1327
|
-
* undefined. Observability surfaces (`/fleet log`, FleetPanel) use
|
|
1328
|
-
* this to tell the user *where* the transcript lives without
|
|
1329
|
-
* having to recompute the path from session metadata.
|
|
1330
|
-
*/
|
|
1331
|
-
readonly transcriptPath?: string | undefined;
|
|
1332
|
-
/** IDs of tool_use blocks that have been sent but not yet received a tool_result.
|
|
1333
|
-
* Used by the REPL to serialize pending state into `session_end` for proper resume. */
|
|
1334
|
-
readonly pendingToolUses: string[];
|
|
1335
|
-
append(event: SessionEvent): Promise<void>;
|
|
1336
|
-
/**
|
|
1337
|
-
* Append a batch of events in one call. Semantically equivalent to calling
|
|
1338
|
-
* `append()` for each event sequentially, but avoids N individual function
|
|
1339
|
-
* calls, scrub/observe cycles, and timer rescheduling. The caller is
|
|
1340
|
-
* responsible for ensuring events are in the correct order.
|
|
1341
|
-
*/
|
|
1342
|
-
appendBatch(events: SessionEvent[]): Promise<void>;
|
|
1343
|
-
/**
|
|
1344
|
-
* Flush any buffered events to disk immediately. Use after critical
|
|
1345
|
-
* events (user_input, llm_response) to ensure they survive a crash
|
|
1346
|
-
* or SIGKILL that would otherwise leave them in the in-memory buffer.
|
|
1347
|
-
* Idempotent — safe to call even when the buffer is empty. File-backed
|
|
1348
|
-
* writers reject on a failed disk append while retaining the batch for a
|
|
1349
|
-
* later retry; callers may log/degrade without losing event chronology.
|
|
1350
|
-
*/
|
|
1351
|
-
flush(): Promise<void>;
|
|
1352
|
-
/**
|
|
1353
|
-
* Last-gasp synchronous drain for hard-exit paths (e.g. `process.exit`
|
|
1354
|
-
* after rapid Ctrl+C) where the async `flush()` cannot be awaited.
|
|
1355
|
-
* Writes whatever is still in the in-memory buffer with a blocking
|
|
1356
|
-
* append. Best-effort — errors are swallowed. Optional: in-memory
|
|
1357
|
-
* writers have nothing durable to drain.
|
|
1358
|
-
*/
|
|
1359
|
-
flushSync?(): void;
|
|
1360
|
-
close(): Promise<void>;
|
|
1361
|
-
/**
|
|
1362
|
-
* Register a file change for later snapshotting.
|
|
1363
|
-
* Called by write/edit/delete tools to track pending changes.
|
|
1364
|
-
*/
|
|
1365
|
-
recordFileChange(input: {
|
|
1366
|
-
path: string;
|
|
1367
|
-
action: 'created' | 'modified' | 'deleted';
|
|
1368
|
-
before: string | null;
|
|
1369
|
-
after: string | null;
|
|
1370
|
-
}): void;
|
|
1371
|
-
/**
|
|
1372
|
-
* Persist the hash of a file version observed by a tool. Optional for
|
|
1373
|
-
* alternate/in-memory writers; file-backed writers use it for stale-file
|
|
1374
|
-
* validation during resume.
|
|
1375
|
-
*/
|
|
1376
|
-
recordFileObservation?(input: {
|
|
1377
|
-
path: string;
|
|
1378
|
-
hash: string;
|
|
1379
|
-
mtimeMs: number;
|
|
1380
|
-
source: 'user' | 'write';
|
|
1381
|
-
}): void;
|
|
1382
|
-
/**
|
|
1383
|
-
* Record a structured side effect for audit (P2 #5). Implementations
|
|
1384
|
-
* append a `side_effect` event to the session JSONL. Best-effort —
|
|
1385
|
-
* callers fire-and-forget; errors are swallowed.
|
|
1386
|
-
*/
|
|
1387
|
-
recordSideEffect(input: {
|
|
1388
|
-
toolUseId: string;
|
|
1389
|
-
toolName: string;
|
|
1390
|
-
input: Record<string, unknown>;
|
|
1391
|
-
outcome?: string | undefined;
|
|
1392
|
-
risk: 'fs.write' | 'shell' | 'package' | 'network' | 'config';
|
|
1393
|
-
}): void;
|
|
1394
|
-
/**
|
|
1395
|
-
* Write a checkpoint marker after a user input is processed.
|
|
1396
|
-
* Also flushes any pending file snapshots.
|
|
1397
|
-
*/
|
|
1398
|
-
writeCheckpoint(promptIndex: number, promptPreview: string): Promise<void>;
|
|
1399
|
-
/**
|
|
1400
|
-
* Write a file snapshot after file changes are detected.
|
|
1401
|
-
* Called by the file watcher or tool interceptor.
|
|
1402
|
-
*/
|
|
1403
|
-
writeFileSnapshot(promptIndex: number, files: FileSnapshot[]): Promise<void>;
|
|
1404
|
-
/**
|
|
1405
|
-
* Truncate conversation history to a given checkpoint promptIndex.
|
|
1406
|
-
* Called after rewind — removes user_input/llm_response/tool_result events
|
|
1407
|
-
* that come after the target checkpoint, then writes a rewound event.
|
|
1408
|
-
* Returns the number of events removed.
|
|
1409
|
-
*/
|
|
1410
|
-
truncateToCheckpoint(promptIndex: number): Promise<number>;
|
|
1411
|
-
/**
|
|
1412
|
-
* Clear the session transcript file, resetting the on-disk history.
|
|
1413
|
-
* Called by /clear to wipe chat history from persistent storage.
|
|
1414
|
-
*/
|
|
1415
|
-
clearSession(): Promise<void>;
|
|
1416
|
-
/**
|
|
1417
|
-
* Idea #1 from IDEAS.md — Stateful Session Recovery.
|
|
1418
|
-
*
|
|
1419
|
-
* Writes an `in_flight_start` event at the current point in the
|
|
1420
|
-
* log. The agent loop should call this at the start of every
|
|
1421
|
-
* long-running operation (an iteration, a tool execution, a
|
|
1422
|
-
* streaming LLM call) so that a crashed process leaves a
|
|
1423
|
-
* visible "what was I doing?" marker. Pair with
|
|
1424
|
-
* `clearInFlightMarker` on clean shutdown.
|
|
1425
|
-
*
|
|
1426
|
-
* The `context` string is surfaced verbatim by
|
|
1427
|
-
* `SessionRecovery.detectStale` and the `/resume --incomplete`
|
|
1428
|
-
* CLI command, so prefer something a human can read at a glance:
|
|
1429
|
-
* "iteration 14 / tool: read / id: tu-7"
|
|
1430
|
-
*/
|
|
1431
|
-
writeInFlightMarker(context: string): Promise<void>;
|
|
1432
|
-
/**
|
|
1433
|
-
* Writes an `in_flight_end` event. Call on every clean exit
|
|
1434
|
-
* point (after a successful iteration, after the user issues
|
|
1435
|
-
* /exit, after a graceful SIGINT, etc.). The `reason` is
|
|
1436
|
-
* surfaced in the session log for postmortem review.
|
|
1437
|
-
*/
|
|
1438
|
-
clearInFlightMarker(reason: 'clean' | 'aborted' | 'recovered'): Promise<void>;
|
|
1439
|
-
}
|
|
1440
|
-
|
|
1441
|
-
type ToolEvidenceStatus = 'seen' | 'referenced';
|
|
1442
|
-
interface ToolOutputMetadata {
|
|
1443
|
-
toolUseId: string;
|
|
1444
|
-
toolName: string;
|
|
1445
|
-
ok: boolean;
|
|
1446
|
-
inputSummary?: string | undefined;
|
|
1447
|
-
summary: string;
|
|
1448
|
-
files: string[];
|
|
1449
|
-
symbols: string[];
|
|
1450
|
-
commands: string[];
|
|
1451
|
-
errors: string[];
|
|
1452
|
-
status: ToolEvidenceStatus;
|
|
1453
|
-
referenceCount: number;
|
|
1454
|
-
seenAt: number;
|
|
1455
|
-
referencedAt?: number | undefined;
|
|
1456
|
-
outputBytes?: number | undefined;
|
|
1457
|
-
outputTokens?: number | undefined;
|
|
1458
|
-
outputLines?: number | undefined;
|
|
1459
|
-
}
|
|
1460
|
-
interface ContextFileEvidence {
|
|
1461
|
-
path: string;
|
|
1462
|
-
reads: number;
|
|
1463
|
-
writes: number;
|
|
1464
|
-
tools: string[];
|
|
1465
|
-
referenced: boolean;
|
|
1466
|
-
lastToolUseId?: string | undefined;
|
|
1467
|
-
}
|
|
1468
|
-
interface ContextIntentEvidence {
|
|
1469
|
-
text: string;
|
|
1470
|
-
updatedAt: number;
|
|
1471
|
-
}
|
|
1472
|
-
interface ContextRepeatedReadEvidence {
|
|
1473
|
-
file: string;
|
|
1474
|
-
count: number;
|
|
1475
|
-
lastToolUseId: string;
|
|
1476
|
-
}
|
|
1477
|
-
/** Where a completed-work ledger entry came from. */
|
|
1478
|
-
type CompletedWorkSource = 'todo' | 'plan' | 'task' | 'verification' | 'manual';
|
|
1479
|
-
/**
|
|
1480
|
-
* One unit of finished work, kept in the session's completed-work ledger so
|
|
1481
|
-
* the model (and a resumed session) can see what is already done and build
|
|
1482
|
-
* on it instead of redoing it. Persisted via the completed-work checkpoint
|
|
1483
|
-
* (`storage/completed-work-checkpoint.ts`).
|
|
1484
|
-
*/
|
|
1485
|
-
interface CompletedWorkEvidence {
|
|
1486
|
-
/** Stable dedupe key — completing the same unit twice updates in place (e.g. "task:<id>"). */
|
|
1487
|
-
key: string;
|
|
1488
|
-
source: CompletedWorkSource;
|
|
1489
|
-
summary: string;
|
|
1490
|
-
/** Epoch ms when the work was marked complete. */
|
|
1491
|
-
completedAt: number;
|
|
1492
|
-
/** Optional pointer to proof (test run, commit hash, file path). */
|
|
1493
|
-
evidence?: string | undefined;
|
|
1494
|
-
}
|
|
1495
|
-
interface ContextEvidenceState {
|
|
1496
|
-
currentIntent?: ContextIntentEvidence | undefined;
|
|
1497
|
-
sessionGoals: string[];
|
|
1498
|
-
implicitFacts: string[];
|
|
1499
|
-
activeErrors: string[];
|
|
1500
|
-
toolCalls: ToolOutputMetadata[];
|
|
1501
|
-
fileGraph: Record<string, ContextFileEvidence>;
|
|
1502
|
-
repeatedReads: ContextRepeatedReadEvidence[];
|
|
1503
|
-
/** Ledger of finished work (tasks, todos, verifications) — see {@link CompletedWorkEvidence}. */
|
|
1504
|
-
completedWork: CompletedWorkEvidence[];
|
|
1505
|
-
lastReadPath?: string | undefined;
|
|
1506
|
-
updatedAt: number;
|
|
1507
|
-
}
|
|
1508
|
-
|
|
1509
|
-
interface CacheStats {
|
|
1510
|
-
/** Tokens served from cache (cheaper). */
|
|
1511
|
-
readTokens: number;
|
|
1512
|
-
/** Tokens written into the cache (more expensive than input on first hit). */
|
|
1513
|
-
writeTokens: number;
|
|
1514
|
-
/** Hit ratio: cacheRead / (cacheRead + input). 0 when nothing cached. */
|
|
1515
|
-
hitRatio: number;
|
|
1516
|
-
}
|
|
1517
|
-
interface TokenCounter {
|
|
1518
|
-
account(usage: Usage, model?: string): void | undefined;
|
|
1519
|
-
/** Optional live session binding used by token.accounted events. */
|
|
1520
|
-
setSessionId?(sessionId: string | (() => string | undefined) | undefined): void;
|
|
1521
|
-
/**
|
|
1522
|
-
* Disjoint token counts from the most recently-accounted request. Sum
|
|
1523
|
-
* input + cacheRead + cacheWrite for per-request context pressure tracking
|
|
1524
|
-
* (e.g. status bar ctx bar) — tokenCounter.total() is cumulative across all
|
|
1525
|
-
* requests and cannot be compared meaningfully against a per-request
|
|
1526
|
-
* maxContext ceiling.
|
|
1527
|
-
*/
|
|
1528
|
-
currentRequestTokens(): {
|
|
1529
|
-
input: number;
|
|
1530
|
-
cacheRead: number;
|
|
1531
|
-
cacheWrite: number;
|
|
1532
|
-
};
|
|
1533
|
-
/**
|
|
1534
|
-
* Override the last-request token snapshot. Used by slash commands like
|
|
1535
|
-
* /compact that modify ctx.messages without making an API request —
|
|
1536
|
-
* after calling this, the TUI/REPL context bar reflects the new size.
|
|
1537
|
-
*/
|
|
1538
|
-
setCurrentRequestTokens(input: number, cacheRead?: number, cacheWrite?: number): void;
|
|
1539
|
-
total(): Usage;
|
|
1540
|
-
estimateCost(): {
|
|
1541
|
-
input: number;
|
|
1542
|
-
output: number;
|
|
1543
|
-
total: number;
|
|
1544
|
-
currency: 'USD';
|
|
1545
|
-
};
|
|
1546
|
-
cacheStats(): CacheStats;
|
|
1547
|
-
reset(): void;
|
|
1548
|
-
}
|
|
1549
|
-
|
|
1550
|
-
/**
|
|
1551
|
-
* Observable wrapper for mutable conversation state. Production code should
|
|
1552
|
-
* mutate messages, todos, and meta through this API so subscribers see a
|
|
1553
|
-
* deterministic change stream. The underlying Context arrays are still
|
|
1554
|
-
* exposed for read compatibility and legacy tests.
|
|
1555
|
-
*
|
|
1556
|
-
* L1-A invariant: direct mutations of `ctx.messages` / `ctx.todos` bypass
|
|
1557
|
-
* the observer layer. Prefer `ctx.state.appendMessage()` etc. to keep
|
|
1558
|
-
* subscribers in sync. The compatibility arrays exist so existing code
|
|
1559
|
-
* that reads `ctx.messages` directly still works — they are NOT safe for
|
|
1560
|
-
* external writes.
|
|
1561
|
-
*/
|
|
1562
|
-
type StateChange = {
|
|
1563
|
-
kind: 'message_appended';
|
|
1564
|
-
message: Message;
|
|
1565
|
-
} | {
|
|
1566
|
-
kind: 'messages_replaced';
|
|
1567
|
-
messages: readonly Message[];
|
|
1568
|
-
} | {
|
|
1569
|
-
kind: 'message_updated';
|
|
1570
|
-
index: number;
|
|
1571
|
-
message: Message;
|
|
1572
|
-
} | {
|
|
1573
|
-
kind: 'todos_replaced';
|
|
1574
|
-
todos: readonly TodoItem[];
|
|
1575
|
-
} | {
|
|
1576
|
-
kind: 'meta_set';
|
|
1577
|
-
key: string;
|
|
1578
|
-
value: unknown;
|
|
1579
|
-
} | {
|
|
1580
|
-
kind: 'meta_deleted';
|
|
1581
|
-
key: string;
|
|
1582
|
-
} | {
|
|
1583
|
-
kind: 'meta_cleared';
|
|
1584
|
-
};
|
|
1585
|
-
type StateChangeHandler = (change: StateChange, state: ConversationState) => void;
|
|
1586
|
-
interface ReadonlyConversationState {
|
|
1587
|
-
readonly messages: readonly Message[];
|
|
1588
|
-
readonly todos: readonly TodoItem[];
|
|
1589
|
-
readonly meta: Readonly<Record<string, unknown>>;
|
|
1590
|
-
}
|
|
1591
|
-
declare class ConversationState {
|
|
1592
|
-
private readonly ctx;
|
|
1593
|
-
private readonly listeners;
|
|
1594
|
-
private _revision;
|
|
1595
|
-
constructor(ctx: Context);
|
|
1596
|
-
get messages(): readonly Message[];
|
|
1597
|
-
get todos(): readonly TodoItem[];
|
|
1598
|
-
get meta(): Readonly<Record<string, unknown>>;
|
|
1599
|
-
/** Monotonic mutation counter for consumers that need to detect rewrites. */
|
|
1600
|
-
get revision(): number;
|
|
1601
|
-
/**
|
|
1602
|
-
* Cheap immutable snapshot. Useful for tests and for compaction passes
|
|
1603
|
-
* that need a stable view across an async boundary.
|
|
1604
|
-
*
|
|
1605
|
-
* Uses shallow-freeze instead of deep-freeze: only the wrapper object
|
|
1606
|
-
* and the three content arrays are frozen. Individual message/todo
|
|
1607
|
-
* objects are NOT recursively frozen — they are reconstructed via
|
|
1608
|
-
* spread copies and are immutable by convention. This cuts the freeze
|
|
1609
|
-
* count from O(n·m·d) (n=messages, m=content blocks, d=depth) to O(1).
|
|
1610
|
-
*/
|
|
1611
|
-
snapshot(): ReadonlyConversationState;
|
|
1612
|
-
appendMessage(message: Message): void;
|
|
1613
|
-
/**
|
|
1614
|
-
* Append a content block to the trailing user message's content array.
|
|
1615
|
-
* Mutates only that one message (a single indexed assignment) — avoids
|
|
1616
|
-
* the O(n) array copy + token-cache re-walk that `replaceMessages()`
|
|
1617
|
-
* would do for a single-message edit. Used by the agent loop to fold
|
|
1618
|
-
* btw-notes / queued-mailbox blocks into the conversation.
|
|
1619
|
-
*
|
|
1620
|
-
* The block is folded only into a *user* message (preserves
|
|
1621
|
-
* user/assistant alternation between tool batches). Returns false when
|
|
1622
|
-
* there is no trailing user message to fold into — callers should
|
|
1623
|
-
* `appendMessage({ role: 'user', content: [block] })` instead.
|
|
1624
|
-
*/
|
|
1625
|
-
appendBlockToLastUserMessage(block: ContentBlock): boolean;
|
|
1626
|
-
replaceMessages(messages: Message[]): void;
|
|
1627
|
-
replaceTodos(todos: TodoItem[]): void;
|
|
1628
|
-
setMeta(key: string, value: unknown): void;
|
|
1629
|
-
deleteMeta(key: string): void;
|
|
1630
|
-
clearMeta(): void;
|
|
1631
|
-
/**
|
|
1632
|
-
* Subscribe to mutations that go through this wrapper. Direct mutations of
|
|
1633
|
-
* the compatibility arrays are intentionally not observed.
|
|
1634
|
-
*/
|
|
1635
|
-
onChange(listener: StateChangeHandler): () => void;
|
|
1636
|
-
private emit;
|
|
1637
|
-
}
|
|
1638
|
-
/**
|
|
1639
|
-
* Convenience constructor. The wrapper holds a reference, not a copy.
|
|
1640
|
-
*/
|
|
1641
|
-
declare function wrapAsState(ctx: Context): ConversationState;
|
|
1642
|
-
|
|
1643
|
-
/**
|
|
1644
|
-
* Immutable run environment — the set-once dependencies for an agent run.
|
|
1645
|
-
*
|
|
1646
|
-
* `Context` today doubles as both a DI bag (provider, session, tokenCounter,
|
|
1647
|
-
* cwd, …) and a mutable state container (messages, todos, meta). That makes
|
|
1648
|
-
* it hard to test (every test reconstructs the full bag) and easy to abuse
|
|
1649
|
-
* (any tool can swap the provider mid-run).
|
|
1650
|
-
*
|
|
1651
|
-
* `RunEnv` is the immutable half: a read-only projection that subsystems
|
|
1652
|
-
* can hold instead of the whole `Context`. It's a view, not a copy — pulling
|
|
1653
|
-
* a `RunEnv` from a `Context` is O(1) and reflects the same underlying
|
|
1654
|
-
* references. The opposite direction (set things on Context) still works,
|
|
1655
|
-
* and `extractRunEnv` rebuilds the view if you need a snapshot.
|
|
1656
|
-
*
|
|
1657
|
-
* Migration path: new APIs accept `RunEnv` instead of `Context` when they
|
|
1658
|
-
* only need read access. Existing APIs continue to accept `Context` until
|
|
1659
|
-
* a full split is scheduled.
|
|
1660
|
-
*/
|
|
1661
|
-
interface RunEnv {
|
|
1662
|
-
readonly provider: Provider;
|
|
1663
|
-
readonly session: SessionWriter;
|
|
1664
|
-
readonly signal: AbortSignal;
|
|
1665
|
-
readonly tokenCounter: TokenCounter;
|
|
1666
|
-
readonly cwd: string;
|
|
1667
|
-
readonly projectRoot: string;
|
|
1668
|
-
/** Mutable working directory — starts as `cwd`. */
|
|
1669
|
-
readonly workingDir: string;
|
|
1670
|
-
readonly model: string;
|
|
1671
|
-
readonly systemPrompt: readonly TextBlock[];
|
|
1672
|
-
readonly tools: readonly Tool[];
|
|
1673
|
-
readonly agentId: string;
|
|
1674
|
-
readonly agentName: string;
|
|
1675
|
-
}
|
|
1676
|
-
/**
|
|
1677
|
-
* Build a `RunEnv` view from a Context. The returned object is a shallow
|
|
1678
|
-
* frozen view — mutations to `Context` are visible (it's the same
|
|
1679
|
-
* references), but the view itself can't be mutated.
|
|
1680
|
-
*
|
|
1681
|
-
* Use this in subsystems that want to declare "I only need read access to
|
|
1682
|
-
* the env" without rewriting their signature to accept the full Context.
|
|
1683
|
-
*/
|
|
1684
|
-
declare function extractRunEnv(ctx: Context): RunEnv;
|
|
1685
|
-
|
|
1686
|
-
interface TodoItem {
|
|
1687
|
-
id: string;
|
|
1688
|
-
content: string;
|
|
1689
|
-
status: 'pending' | 'in_progress' | 'completed';
|
|
1690
|
-
activeForm?: string | undefined;
|
|
1691
|
-
/** When promoted from a plan item, stores the plan item's id. */
|
|
1692
|
-
promotedFromPlan?: string | undefined;
|
|
1693
|
-
/** When promoted from a task, stores the task's id. */
|
|
1694
|
-
promotedFromTask?: string | undefined;
|
|
1695
|
-
}
|
|
1696
|
-
interface RunOptions {
|
|
1697
|
-
signal?: AbortSignal | undefined;
|
|
1698
|
-
model?: string | undefined;
|
|
1699
|
-
executionStrategy?: 'parallel' | 'sequential' | 'smart' | undefined;
|
|
1700
|
-
maxIterations?: number | undefined;
|
|
1701
|
-
/**
|
|
1702
|
-
* Enable autonomous continue for this specific run. When true, the agent
|
|
1703
|
-
* loop re-runs on `[continue]`/`[next step]`/`[proceed]` markers or
|
|
1704
|
-
* `continue_to_next_iteration()` tool calls instead of returning.
|
|
1705
|
-
* Overrides `AgentInit.autonomousContinue` for this call only.
|
|
1706
|
-
*/
|
|
1707
|
-
autonomousContinue?: boolean | undefined;
|
|
1708
|
-
}
|
|
1709
|
-
interface ContextInit {
|
|
1710
|
-
systemPrompt: TextBlock[];
|
|
1711
|
-
provider: Provider;
|
|
1712
|
-
session: SessionWriter;
|
|
1713
|
-
signal: AbortSignal;
|
|
1714
|
-
tokenCounter: TokenCounter;
|
|
1715
|
-
cwd: string;
|
|
1716
|
-
projectRoot: string;
|
|
1717
|
-
/** Mutable working directory. Defaults to `cwd`. Must stay within `projectRoot`. */
|
|
1718
|
-
workingDir?: string | undefined;
|
|
1719
|
-
/**
|
|
1720
|
-
* When false, file tools and `setWorkingDir()` are confined to `projectRoot`.
|
|
1721
|
-
* Defaults to `false` (restrictive) when omitted so directly-constructed
|
|
1722
|
-
* contexts (tests, embedded callers) keep the safe behavior; the runtime
|
|
1723
|
-
* passes the config-derived value (default `true` — permissive) explicitly.
|
|
1724
|
-
*/
|
|
1725
|
-
allowOutsideProjectRoot?: boolean | undefined;
|
|
1726
|
-
model: string;
|
|
1727
|
-
tools?: Tool[] | undefined;
|
|
1728
|
-
/** Agent id performing this run (e.g. 'leader', 'executor', 'tech-stack'). */
|
|
1729
|
-
agentId?: string | undefined;
|
|
1730
|
-
/** Human-readable agent name. */
|
|
1731
|
-
agentName?: string | undefined;
|
|
1732
|
-
/**
|
|
1733
|
-
* Session-level trace ID for correlating storage events with agent
|
|
1734
|
-
* iterations in observability pipelines. Stored on the SessionWriter
|
|
1735
|
-
* so that storage operations can emit it in `storage.*` events.
|
|
1736
|
-
* When set, the Context constructor propagates it to
|
|
1737
|
-
* `session.traceId` automatically.
|
|
1738
|
-
*/
|
|
1739
|
-
traceId?: string | undefined;
|
|
1740
|
-
}
|
|
1741
|
-
/**
|
|
1742
|
-
* L1-A: `Context` is the live agent-run object. Its read-only environment
|
|
1743
|
-
* shape is exposed by the `RunEnv` interface (every field below the
|
|
1744
|
-
* conversation state) and its mutable shape by `ConversationState` (the
|
|
1745
|
-
* `state` accessor). New code should declare the narrower type at its
|
|
1746
|
-
* parameter — pass `ctx` for it. Existing tools that accept `Context`
|
|
1747
|
-
* still work because `Context` structurally satisfies both.
|
|
1748
|
-
*
|
|
1749
|
-
* The single source of truth for the project directory is `projectRoot`.
|
|
1750
|
-
* All tools (read/write/bash/exec) resolve paths relative to this.
|
|
1751
|
-
* Sessions, config, memory, and logs are also stored under this root.
|
|
1752
|
-
*
|
|
1753
|
-
* There IS a mutable `workingDir` (separate from `projectRoot`) that can be
|
|
1754
|
-
* changed at runtime via `setWorkingDir()`. It starts as `cwd` and allows
|
|
1755
|
-
* the agent and user to navigate within the project without spawning a new
|
|
1756
|
-
* process. All changes must stay inside `projectRoot`.
|
|
1757
|
-
*/
|
|
1758
|
-
declare class Context implements RunEnv {
|
|
1759
|
-
messages: Message[];
|
|
1760
|
-
todos: TodoItem[];
|
|
1761
|
-
/**
|
|
1762
|
-
* Files whose content the **user / model has explicitly seen** via the
|
|
1763
|
-
* `read` tool (or an edit's auto-read, which surfaces the content to the
|
|
1764
|
-
* model). This is the set the permission policy's write-smart-bypass
|
|
1765
|
-
* (step 7) checks — writing a file the model has already read is treated
|
|
1766
|
-
* as "no new content to approve". It must NEVER contain files only touched
|
|
1767
|
-
* by `edit`/`write`, otherwise the model could repeatedly overwrite a file
|
|
1768
|
-
* whose content the user never saw (P1 #1, before-release.md).
|
|
1769
|
-
*
|
|
1770
|
-
* Tool-driven mutations record via `writtenFiles` + `recordRead(..., 'write')`
|
|
1771
|
-
* so mtime tracking still works without widening the bypass.
|
|
1772
|
-
*/
|
|
1773
|
-
readFiles: Set<string>;
|
|
1774
|
-
/**
|
|
1775
|
-
* Files written by `edit`/`write` in this session. Tracked for observability
|
|
1776
|
-
* and to keep `readFiles` (the permission-bypass source of truth) clean.
|
|
1777
|
-
* `recordRead(path, mtime, 'write')` adds here instead of `readFiles`.
|
|
1778
|
-
*/
|
|
1779
|
-
writtenFiles: Set<string>;
|
|
1780
|
-
fileMtimes: Map<string, number>;
|
|
1781
|
-
/**
|
|
1782
|
-
* sha-256 (hex) of file content at the last recorded read/write, when the
|
|
1783
|
-
* recording tool had the content in hand. Used by `edit` as the authoritative
|
|
1784
|
-
* staleness arbiter: mtime comparison has a 2 s tolerance window on Windows
|
|
1785
|
-
* (FAT/NTFS granularity) during which an external modification is invisible,
|
|
1786
|
-
* and conversely a bare `touch` bumps mtime without changing content. Hash
|
|
1787
|
-
* equality resolves both cases exactly. Entries are dropped whenever a
|
|
1788
|
-
* hash-less `recordRead` observes a *different* mtime (content may have
|
|
1789
|
-
* changed under us — fall back to the mtime heuristic rather than trust a
|
|
1790
|
-
* stale hash).
|
|
1791
|
-
*/
|
|
1792
|
-
fileHashes: Map<string, string>;
|
|
1793
|
-
/**
|
|
1794
|
-
* Structured side-effect records accumulated during the current run
|
|
1795
|
-
* (P2 #5). Populated by `recordSideEffect()` — read by /diag for an
|
|
1796
|
-
* in-memory audit trail without parsing the JSONL file. Cleared by
|
|
1797
|
-
* `clearFileTracking()` alongside read/written-file tracking.
|
|
1798
|
-
*/
|
|
1799
|
-
sideEffects: SideEffect[];
|
|
1800
|
-
contextEvidence: ContextEvidenceState;
|
|
1801
|
-
systemPrompt: TextBlock[];
|
|
1802
|
-
provider: Provider;
|
|
1803
|
-
session: SessionWriter;
|
|
1804
|
-
signal: AbortSignal;
|
|
1805
|
-
tokenCounter: TokenCounter;
|
|
1806
|
-
cwd: string;
|
|
1807
|
-
projectRoot: string;
|
|
1808
|
-
/** Mutable working directory — starts as `cwd`. Change via `setWorkingDir()`. */
|
|
1809
|
-
workingDir: string;
|
|
1810
|
-
/**
|
|
1811
|
-
* When true, file tools (via `_util.ts`) and `setWorkingDir()` reject paths
|
|
1812
|
-
* outside `projectRoot`. When false, those boundary checks are bypassed so
|
|
1813
|
-
* tools may reach paths outside the project (still gated by permission
|
|
1814
|
-
* tiers). Mutable so `/settings` can toggle it live on the running session.
|
|
1815
|
-
*/
|
|
1816
|
-
allowOutsideProjectRoot: boolean;
|
|
1817
|
-
model: string;
|
|
1818
|
-
tools: Tool[];
|
|
1819
|
-
meta: Record<string, unknown>;
|
|
1820
|
-
/** Agent id performing this run (e.g. 'leader', 'executor'). */
|
|
1821
|
-
agentId: string;
|
|
1822
|
-
/** Human-readable agent name. */
|
|
1823
|
-
agentName: string;
|
|
1824
|
-
/**
|
|
1825
|
-
* Session-level trace ID for correlating storage events with agent
|
|
1826
|
-
* iterations. Stored here and also propagated to `session.traceId`
|
|
1827
|
-
* so storage operations can include it in `storage.*` events.
|
|
1828
|
-
*/
|
|
1829
|
-
traceId: string | undefined;
|
|
1830
|
-
/** Callbacks fired when `setWorkingDir()` changes the working directory. */
|
|
1831
|
-
private _onWorkingDirChanged;
|
|
1832
|
-
/**
|
|
1833
|
-
* Set to true when the conversation gains new tool_use or tool_result
|
|
1834
|
-
* blocks — the only time repairToolUseAdjacency() can find new issues.
|
|
1835
|
-
* buildAndRunRequestPipeline() checks this flag to skip an O(n) scan
|
|
1836
|
-
* on iterations where no tool content was added (pure text responses).
|
|
1837
|
-
*/
|
|
1838
|
-
toolAdjacencyDirty: boolean;
|
|
1839
|
-
/**
|
|
1840
|
-
* H1: pre-computed total-request token estimate from the most recent
|
|
1841
|
-
* `estimateRequestTokens()` call in the agent loop's pre-flight step.
|
|
1842
|
-
* The middleware that decides when to compact, the `emitContextPct`
|
|
1843
|
-
* helper that drives the live context-fill bar, and the pre-flight
|
|
1844
|
-
* itself all need this number; previously each one walked the same
|
|
1845
|
-
* messages/system/tools arrays independently. Stashing it here lets
|
|
1846
|
-
* the three call sites share a single compute per iteration.
|
|
1847
|
-
*
|
|
1848
|
-
* The value is the **uncalibrated** total. Callers that want the
|
|
1849
|
-
* calibrated number apply the per-(provider,model) ratio themselves.
|
|
1850
|
-
*/
|
|
1851
|
-
lastRequestTokens: number | undefined;
|
|
1852
|
-
constructor(init: ContextInit);
|
|
1853
|
-
/**
|
|
1854
|
-
* Observable wrapper over the mutable conversation state. Lazy so
|
|
1855
|
-
* subsystems that don't subscribe pay nothing. Mutations made directly
|
|
1856
|
-
* on `ctx.messages` / `ctx.todos` are still visible through this
|
|
1857
|
-
* wrapper's read API (it holds a reference, not a copy) but only
|
|
1858
|
-
* mutations that go through `state.appendMessage()` etc. fire
|
|
1859
|
-
* `onChange`. New code should prefer the wrapper API.
|
|
1860
|
-
*/
|
|
1861
|
-
private _state;
|
|
1862
|
-
get state(): ConversationState;
|
|
1863
|
-
/**
|
|
1864
|
-
* Register a teardown hook tied to the current run's abort signal.
|
|
1865
|
-
* Hooks registered before a run starts are stored and fired when the
|
|
1866
|
-
* next run ends; there is no immediate fire when no run is active.
|
|
1867
|
-
*
|
|
1868
|
-
* **Scope:** these hooks fire on the **whole agent run's** abort, not on
|
|
1869
|
-
* an individual tool call. For per-tool teardown of resources owned by
|
|
1870
|
-
* the tool author (child processes, handles), prefer `Tool.cleanup` —
|
|
1871
|
-
* see its JSDoc for the full rule.
|
|
1872
|
-
*/
|
|
1873
|
-
private abortHooks;
|
|
1874
|
-
registerAbortHook(fn: () => void | Promise<void>): () => void;
|
|
1875
|
-
drainAbortHooks(): Promise<void>;
|
|
1876
|
-
/**
|
|
1877
|
-
* Record that a file's content was seen / mtime was observed.
|
|
1878
|
-
*
|
|
1879
|
-
* `source` controls which tracking set is populated — and therefore whether
|
|
1880
|
-
* the permission policy's write-smart-bypass (step 7) will auto-approve a
|
|
1881
|
-
* subsequent `write` to this path:
|
|
1882
|
-
*
|
|
1883
|
-
* - `'user'` (default): the model/user saw the content (via `read`, or an
|
|
1884
|
-
* edit's auto-read that surfaced it). Adds to `readFiles` → bypass applies.
|
|
1885
|
-
* - `'write'`: a tool wrote the file (`edit`/`write`) and is recording the
|
|
1886
|
-
* new mtime so subsequent edits detect external modification. Adds to
|
|
1887
|
-
* `writtenFiles` only — the bypass does NOT apply, because the user never
|
|
1888
|
-
* approved the new content (P1 #1, before-release.md).
|
|
1889
|
-
*
|
|
1890
|
-
* `fileMtimes` is updated in both cases so mtime-based staleness checks work.
|
|
1891
|
-
*
|
|
1892
|
-
* `contentHash` (sha-256 hex of the exact content seen) is optional so
|
|
1893
|
-
* existing callers keep working. When provided it is stored in `fileHashes`
|
|
1894
|
-
* and becomes the authoritative staleness arbiter for later edits. When
|
|
1895
|
-
* omitted, a previously stored hash survives only if the observed mtime is
|
|
1896
|
-
* unchanged — a different mtime with no fresh hash means the content may
|
|
1897
|
-
* have changed, so the stale hash is dropped and staleness checks fall back
|
|
1898
|
-
* to mtime comparison.
|
|
1899
|
-
*/
|
|
1900
|
-
recordRead(absPath: string, mtimeMs: number, source?: 'user' | 'write', contentHash?: string): void;
|
|
1901
|
-
/** Clear accumulated file-read metadata after compaction or at boundaries
|
|
1902
|
-
* where stale read history could cause tools to skip legitimate re-reads.
|
|
1903
|
-
* The agent re-populates this naturally on the next file access. */
|
|
1904
|
-
clearFileTracking(): void;
|
|
1905
|
-
/**
|
|
1906
|
-
* Record a structured side effect for the audit trail (P2 #5).
|
|
1907
|
-
* Called by tools that perform non-filesystem mutations (bash, install,
|
|
1908
|
-
* fetch) so /diag and session replay can show what the agent did beyond
|
|
1909
|
-
* file edits.
|
|
1910
|
-
*
|
|
1911
|
-
* Unlike recordFileChange(), this does NOT support undo — it is purely
|
|
1912
|
-
* for observability and audit. The event is appended to the session
|
|
1913
|
-
* JSONL fire-and-forget; errors are swallowed so recording never blocks
|
|
1914
|
-
* tool execution.
|
|
1915
|
-
*/
|
|
1916
|
-
recordSideEffect(sideEffect: SideEffect): void;
|
|
1917
|
-
/**
|
|
1918
|
-
* True if the model/user has explicitly seen this file's content via `read`
|
|
1919
|
-
* (or an edit auto-read). Tool-only writes (`source: 'write'`) do NOT count
|
|
1920
|
-
* — this is the source of truth for the permission policy's write bypass.
|
|
1921
|
-
*/
|
|
1922
|
-
hasRead(absPath: string): boolean;
|
|
1923
|
-
/** True if `edit`/`write` wrote this file in the current session. */
|
|
1924
|
-
hasWritten(absPath: string): boolean;
|
|
1925
|
-
lastReadMtime(absPath: string): number | undefined;
|
|
1926
|
-
/** sha-256 (hex) of the content at the last recorded read/write, if the
|
|
1927
|
-
* recording tool supplied one. See `fileHashes` for drop semantics. */
|
|
1928
|
-
lastReadHash(absPath: string): string | undefined;
|
|
1929
|
-
/**
|
|
1930
|
-
* Change the working directory for path resolution. Resolves relative paths
|
|
1931
|
-
* against `projectRoot` and validates the result is within the project root.
|
|
1932
|
-
* Fires all registered `onWorkingDirChanged` callbacks.
|
|
1933
|
-
* Returns the resolved absolute path.
|
|
1934
|
-
*/
|
|
1935
|
-
setWorkingDir(dir: string): string;
|
|
1936
|
-
/**
|
|
1937
|
-
* Register a callback that fires when the working directory changes.
|
|
1938
|
-
* Returns an unsubscribe function. Callbacks are fired synchronously
|
|
1939
|
-
* inside `setWorkingDir()` — errors in callbacks are swallowed so one
|
|
1940
|
-
* bad listener doesn't prevent others from executing.
|
|
1941
|
-
*/
|
|
1942
|
-
onWorkingDirChanged(cb: (newDir: string, oldDir: string) => void): () => void;
|
|
1943
|
-
usage(): Usage;
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
|
-
type Permission = 'auto' | 'confirm' | 'deny';
|
|
1947
|
-
/**
|
|
1948
|
-
* Risk tier for tools in YOLO mode. YOLO auto-approves normal project work,
|
|
1949
|
-
* while clearly destructive calls still require confirmation.
|
|
1950
|
-
*
|
|
1951
|
-
* - `safe` — read-only, no side effects (read, glob, grep, etc.)
|
|
1952
|
-
* - `standard` — non-destructive writes and mutations (write, edit, safe shell commands)
|
|
1953
|
-
* - `destructive` — irreversible or broadside effects (recursive deletes, db drops, etc.)
|
|
1954
|
-
*/
|
|
1955
|
-
type RiskTier = 'safe' | 'standard' | 'destructive';
|
|
1956
|
-
/**
|
|
1957
|
-
* Icon identifiers for tools — each UI (WebUI/TUI/REPL) maps these to its own icon library.
|
|
1958
|
-
* Add the icon directly on each Tool so all UIs consume the same canonical value.
|
|
1959
|
-
*/
|
|
1960
|
-
type ToolIconId = 'file' | 'edit' | 'search' | 'folder' | 'terminal' | 'web' | 'git' | 'tree' | 'code' | 'test' | 'package' | 'document' | 'scaffold' | 'todo' | 'plan' | 'task' | 'meta' | 'index' | 'json' | 'diff' | 'logs' | 'settings' | 'fallback';
|
|
1961
|
-
interface JSONSchema {
|
|
1962
|
-
type?: string | undefined;
|
|
1963
|
-
properties?: Record<string, JSONSchema>;
|
|
1964
|
-
required?: string[] | undefined;
|
|
1965
|
-
items?: JSONSchema | undefined;
|
|
1966
|
-
enum?: unknown[] | undefined;
|
|
1967
|
-
description?: string | undefined;
|
|
1968
|
-
[k: string]: unknown;
|
|
1969
|
-
}
|
|
1970
|
-
/**
|
|
1971
|
-
* Tool progress event — yielded by `Tool.executeStream` to give the UI
|
|
1972
|
-
* something to render while a long-running tool works. The executor
|
|
1973
|
-
* publishes each event via EventBus as `tool.progress` so the TUI, logger,
|
|
1974
|
-
* and observability layer can consume them uniformly.
|
|
1975
|
-
*
|
|
1976
|
-
* Keep events small. They are buffered through the EventBus synchronously
|
|
1977
|
-
* and rendered on the main thread.
|
|
1978
|
-
*/
|
|
1979
|
-
interface ToolProgressEvent {
|
|
1980
|
-
/**
|
|
1981
|
-
* - `log` — verbose informational message (e.g. "scanning…")
|
|
1982
|
-
* - `warning` — non-fatal issue (e.g. "skipped X due to ENOENT")
|
|
1983
|
-
* - `metric` — numeric data (e.g. files scanned so far)
|
|
1984
|
-
* - `file_changed` — a tool that mutates the workspace announces a write
|
|
1985
|
-
* - `partial_output` — stream of textual output (bash stdout, fetch body)
|
|
1986
|
-
*/
|
|
1987
|
-
type: 'log' | 'warning' | 'metric' | 'file_changed' | 'partial_output';
|
|
1988
|
-
text?: string | undefined;
|
|
1989
|
-
data?: Record<string, unknown>;
|
|
1990
|
-
}
|
|
1991
|
-
/**
|
|
1992
|
-
* Terminal event for `executeStream`. The output must match the tool's
|
|
1993
|
-
* declared output type — the executor unwraps `output` and treats it like
|
|
1994
|
-
* a normal `execute` return value.
|
|
1995
|
-
*/
|
|
1996
|
-
interface ToolFinalEvent<O> {
|
|
1997
|
-
type: 'final';
|
|
1998
|
-
output: O;
|
|
1999
|
-
}
|
|
2000
|
-
type ToolStreamEvent<O = unknown> = ToolProgressEvent | ToolFinalEvent<O>;
|
|
2001
|
-
interface Tool<I = unknown, O = unknown> {
|
|
2002
|
-
name: string;
|
|
2003
|
-
description: string;
|
|
2004
|
-
/**
|
|
2005
|
-
* Pre-computed token estimate for this tool's definition (name +
|
|
2006
|
-
* description + JSON-serialized inputSchema). Set by ToolRegistry on
|
|
2007
|
-
* registration; consumed by estimateToolDefTokens / estimateRequestTokens
|
|
2008
|
-
* to skip redundant JSON.stringify on every context-pressure check.
|
|
2009
|
-
*/
|
|
2010
|
-
_estDefTokens?: number | undefined;
|
|
2011
|
-
usageHint?: string | undefined;
|
|
2012
|
-
/** Structured guidance for choosing between similar tools. */
|
|
2013
|
-
selection?: {
|
|
2014
|
-
/** A concise boundary where this tool should not be selected. */
|
|
2015
|
-
doNotUseWhen: string;
|
|
2016
|
-
/** Tool names the model should prefer for that boundary. */
|
|
2017
|
-
useInstead?: readonly string[] | undefined;
|
|
2018
|
-
} | undefined;
|
|
2019
|
-
/** Optional category for grouping in help lists and system prompts. */
|
|
2020
|
-
category?: string | undefined;
|
|
2021
|
-
inputSchema: JSONSchema;
|
|
2022
|
-
permission: Permission;
|
|
2023
|
-
mutating: boolean;
|
|
2024
|
-
/**
|
|
2025
|
-
* Risk tier for selective YOLO gating. When YOLO is active, clearly
|
|
2026
|
-
* destructive calls still emit `confirm`. Defaults to `standard` when
|
|
2027
|
-
* omitted — callers should always check `riskTier` after the basic
|
|
2028
|
-
* permission decision.
|
|
2029
|
-
*/
|
|
2030
|
-
riskTier?: RiskTier | undefined;
|
|
2031
|
-
/**
|
|
2032
|
-
* Input-field name that the permission policy should match trust rules
|
|
2033
|
-
* against. Without this, the policy falls back to a heuristic
|
|
2034
|
-
* (`command` / `path` / `url` / `name`) that can collide across tools —
|
|
2035
|
-
* e.g. an HTTP tool whose `path` means "request path" would be checked
|
|
2036
|
-
* against filesystem-path trust rules. Set explicitly to avoid the
|
|
2037
|
-
* cross-tool subject collision.
|
|
2038
|
-
*
|
|
2039
|
-
* The named field's value must be a string at runtime; non-string values
|
|
2040
|
-
* fall back to the heuristic.
|
|
2041
|
-
*/
|
|
2042
|
-
subjectKey?: string | undefined;
|
|
2043
|
-
maxOutputBytes?: number | undefined;
|
|
2044
|
-
timeoutMs?: number | undefined;
|
|
2045
|
-
/**
|
|
2046
|
-
* Hint for the TUI spinner — does NOT affect actual timeout enforcement.
|
|
2047
|
-
* Use `timeoutMs` for hard limits. Leave undefined when duration varies
|
|
2048
|
-
* unpredictably.
|
|
2049
|
-
*/
|
|
2050
|
-
estimatedDurationMs?: number | undefined;
|
|
2051
|
-
/**
|
|
2052
|
-
* Declarative security capabilities granted by this tool.
|
|
2053
|
-
*
|
|
2054
|
-
* Examples: "shell.arbitrary", "fs.write", "fs.write.outside-project",
|
|
2055
|
-
* "net.outbound", "mcp.proxy", "subagent.spawn", "config.mutate".
|
|
2056
|
-
*
|
|
2057
|
-
* These are used by permission policies (especially subagent guards) and
|
|
2058
|
-
* future capability-based allowlists. Prefer well-known values over ad-hoc strings.
|
|
2059
|
-
*
|
|
2060
|
-
* This field is optional for backward compatibility. Tools without it are
|
|
2061
|
-
* treated conservatively by guards.
|
|
2062
|
-
*/
|
|
2063
|
-
capabilities?: readonly string[] | undefined;
|
|
2064
|
-
/**
|
|
2065
|
-
* Icon identifier for this tool — consumed by all UIs (WebUI/TUI/REPL) to
|
|
2066
|
-
* render a tool-specific icon instead of a generic fallback.
|
|
2067
|
-
* Each UI maps this id to its own icon library.
|
|
2068
|
-
*/
|
|
2069
|
-
icon?: ToolIconId | undefined;
|
|
2070
|
-
execute(input: I, ctx: Context, opts: {
|
|
2071
|
-
signal: AbortSignal;
|
|
2072
|
-
}): Promise<O>;
|
|
2073
|
-
/**
|
|
2074
|
-
* Optional cross-field validation hook. Called by the executor AFTER
|
|
2075
|
-
* JSON Schema validation passes and AFTER PreToolUse hooks may have
|
|
2076
|
-
* rewritten the input, but BEFORE permission checks and execution.
|
|
2077
|
-
*
|
|
2078
|
-
* Use this for invariants the JSON Schema cannot express — e.g.
|
|
2079
|
-
* `old_string !== new_string` in edit, or `end > start` in a range tool.
|
|
2080
|
-
* Return an array of validation errors (empty = valid). The executor
|
|
2081
|
-
* surfaces them to the model just like schema validation errors, so the
|
|
2082
|
-
* model can self-correct without the tool's `execute()` running.
|
|
2083
|
-
*
|
|
2084
|
-
* P3 #16 (before-release.md): tools that implement cross-field checks
|
|
2085
|
-
* inside `execute()` can migrate them here for earlier rejection and
|
|
2086
|
-
* consistent error formatting.
|
|
2087
|
-
*/
|
|
2088
|
-
validate?(input: I): string[];
|
|
2089
|
-
/**
|
|
2090
|
-
* Optional streaming variant. When defined, the executor prefers this
|
|
2091
|
-
* over `execute` — yielded events become `tool.progress` EventBus events
|
|
2092
|
-
* and the terminal `final` event provides the output. Tools that don't
|
|
2093
|
-
* have intermediate state shouldn't implement this; the default `execute`
|
|
2094
|
-
* path is more efficient.
|
|
2095
|
-
*/
|
|
2096
|
-
executeStream?(input: I, ctx: Context, opts: {
|
|
2097
|
-
signal: AbortSignal;
|
|
2098
|
-
}): AsyncIterable<ToolStreamEvent<O>>;
|
|
2099
|
-
/**
|
|
2100
|
-
* Optional teardown hook fired by the executor when the tool's run is
|
|
2101
|
-
* aborted (signal triggered). Errors thrown here are swallowed so they
|
|
2102
|
-
* never mask the originating failure.
|
|
2103
|
-
*
|
|
2104
|
-
* **When to use `cleanup` vs `ctx.registerAbortHook`:**
|
|
2105
|
-
*
|
|
2106
|
-
* - Use `cleanup` for resources **owned by the tool author** that are
|
|
2107
|
-
* established at execute-time: child processes spawned by the tool,
|
|
2108
|
-
* file handles opened by the tool, network connections initiated by
|
|
2109
|
-
* the tool. The lifecycle is co-located with the tool definition, so
|
|
2110
|
-
* readers see the resource and its teardown in one place.
|
|
2111
|
-
*
|
|
2112
|
-
* ```ts
|
|
2113
|
-
* async execute(input, ctx, opts) {
|
|
2114
|
-
* const child = spawn(...);
|
|
2115
|
-
* // … tool work …
|
|
2116
|
-
* },
|
|
2117
|
-
* async cleanup(_input, _ctx) {
|
|
2118
|
-
* // best-effort kill of any child still running
|
|
2119
|
-
* }
|
|
2120
|
-
* ```
|
|
2121
|
-
*
|
|
2122
|
-
* - Use `ctx.registerAbortHook` for **context-scoped teardown** registered
|
|
2123
|
-
* dynamically inside `execute`: when the tool delegates to a library
|
|
2124
|
-
* that needs cancellation, or when the resource is created lazily
|
|
2125
|
-
* somewhere down the call stack and the natural cleanup point isn't
|
|
2126
|
-
* at the tool boundary. The hook fires when the **agent run** ends,
|
|
2127
|
-
* not when this specific tool call aborts.
|
|
2128
|
-
*
|
|
2129
|
-
* ```ts
|
|
2130
|
-
* async execute(input, ctx, opts) {
|
|
2131
|
-
* const handle = openHelper();
|
|
2132
|
-
* ctx.registerAbortHook(() => handle.dispose());
|
|
2133
|
-
* // … work …
|
|
2134
|
-
* }
|
|
2135
|
-
* ```
|
|
2136
|
-
*
|
|
2137
|
-
* If both are registered for the same resource, `cleanup` fires first
|
|
2138
|
-
* (on tool abort) and the abort-hook fires after on the wider run abort.
|
|
2139
|
-
* Avoid double-free by gating one on the other's effect, or pick a single
|
|
2140
|
-
* teardown channel per resource.
|
|
2141
|
-
*/
|
|
2142
|
-
cleanup?(input: I, ctx: Context): Promise<void>;
|
|
2143
|
-
/**
|
|
2144
|
-
* Optional custom output serializer. When present, the executor's output
|
|
2145
|
-
* serializer calls this INSTEAD of the central `renderToolObject()` switch
|
|
2146
|
-
* — the tool owns its own pretty-printing.
|
|
2147
|
-
*
|
|
2148
|
-
* Return a string representation of the output that the model will see in
|
|
2149
|
-
* its tool_result block. The serializer applies the iteration output cap
|
|
2150
|
-
* AFTER this runs, so don't worry about truncation.
|
|
2151
|
-
*
|
|
2152
|
-
* P3 #21 (before-release.md): `renderToolObject()` is a god function with
|
|
2153
|
-
* 30+ per-tool branches, far from each tool's definition. New tools that
|
|
2154
|
-
* want custom output no longer need to add a branch there — they implement
|
|
2155
|
-
* this method instead. Existing branches stay until migrated incrementally.
|
|
2156
|
-
*/
|
|
2157
|
-
serialize?(output: O, input: I): string;
|
|
2158
|
-
}
|
|
2159
|
-
interface ToolCallContext {
|
|
2160
|
-
tool: Tool;
|
|
2161
|
-
input: unknown;
|
|
2162
|
-
callId: string;
|
|
2163
|
-
ctx: Context;
|
|
2164
|
-
signal: AbortSignal;
|
|
2165
|
-
}
|
|
2166
|
-
/**
|
|
2167
|
-
* Error categories for tool execution failures.
|
|
2168
|
-
* Used by the executor to classify errors and determine retry strategy.
|
|
2169
|
-
*/
|
|
2170
|
-
declare enum ToolErrorCategory {
|
|
2171
|
-
TRANSIENT = "transient",// ETIMEDOUT, ECONNRESET, network timeout, HTTP 429/503
|
|
2172
|
-
NOT_FOUND = "not_found",// ENOENT, ENOTDIR, HTTP 404
|
|
2173
|
-
PERMISSION = "permission",// EACCES, EPERM, HTTP 401/403
|
|
2174
|
-
VALIDATION = "validation",// schema validation error, HTTP 400
|
|
2175
|
-
FATAL = "fatal"
|
|
2176
|
-
}
|
|
2177
|
-
/**
|
|
2178
|
-
* Structured tool error information for the LLM and retry logic.
|
|
2179
|
-
*/
|
|
2180
|
-
interface ToolErrorInfo {
|
|
2181
|
-
readonly category: ToolErrorCategory;
|
|
2182
|
-
/** Whether the operation can be retried automatically. */
|
|
2183
|
-
readonly retryable: boolean;
|
|
2184
|
-
/** User-facing message describing the error. */
|
|
2185
|
-
readonly userMessage: string;
|
|
2186
|
-
/** Optional technical detail for debugging. */
|
|
2187
|
-
readonly detail?: string;
|
|
2188
|
-
}
|
|
2189
|
-
|
|
2190
|
-
export { type FileSnapshot as $, type TodoItem as A, type ToolUseBlock as B, type CacheStats as C, type ToolResultBlock as D, AgentError as E, type ForkedSession as F, type CompletedWorkEvidence as G, type CompletedWorkSource as H, ConfigError as I, type JSONSchema as J, type ContextEvidenceState as K, type ContextFileEvidence as L, type Message as M, type ContextInit as N, type ContextIntentEvidence as O, type Provider as P, type ContextRepeatedReadEvidence as Q, type ReasoningRequest as R, type SessionEvent as S, type TokenCounter as T, type Usage as U, ERROR_CODES as V, type WorkspaceCheckpointRef as W, type ErrorCode as X, type ErrorSeverity as Y, type ErrorSubsystem as Z, FetchError as _, type ReasoningConfig as a, FsError as a0, type ImageBlock as a1, type JsonSchemaSpec as a2, type MessageRole as a3, ParseError as a4, PluginError as a5, type ProviderErrorBody as a6, type ProviderErrorKind as a7, type ReadonlyConversationState as a8, type RequestCacheControl as a9, effectiveInputTokens as aA, extractRunEnv as aB, isAgentError as aC, isConfigError as aD, isFetchError as aE, isFsError as aF, isImageBlock as aG, isParseError as aH, isPluginError as aI, isRetryableKind as aJ, isSddError as aK, isSessionError as aL, isTextBlock as aM, isToolError as aN, isToolResultBlock as aO, isToolUseBlock as aP, isToolValidationError as aQ, isWrongStackError as aR, toWrongStackError as aS, wrapAsState as aT, type ResponseFormat as aa, type ResumeFileStatus as ab, type ResumeFileValidationEntry as ac, type ResumeValidation as ad, type RunEnv as ae, type SafetySetting as af, SddError as ag, SessionError as ah, type SideEffect as ai, type SideEffectRisk as aj, type StateChange as ak, type StateChangeHandler as al, type StopReason as am, type StreamEvent as an, StreamHangError as ao, type ThinkingBlock as ap, type ToolCallContext as aq, ToolError as ar, type ToolErrorInfo as as, type ToolEvidenceStatus as at, type ToolFinalEvent as au, type ToolIconId as av, type ToolStreamEvent as aw, ToolValidationError as ax, WrongStackError as ay, classifyProviderError as az, type SessionWriter as b, type Request as c, Context as d, type Response as e, type Permission as f, type Tool as g, ProviderError as h, type ContentBlock as i, type SessionMetadata as j, type SessionStore as k, ToolErrorCategory as l, type ToolProgressEvent as m, type RiskTier as n, type ToolOutputMetadata as o, type ReasoningEffort as p, type CacheTtl as q, type Capabilities as r, type TextBlock as s, type RunOptions as t, ConversationState as u, type SessionForkOptions as v, type WorkspaceMaterializationResult as w, type ResumedSession as x, type SessionData as y, type SessionSummary as z };
|