@namzu/sdk 43.0.0 → 44.1.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/CHANGELOG.md +520 -0
- package/README.md +41 -34
- package/dist/advisory/budget.js +3 -3
- package/dist/advisory/budget.js.map +1 -1
- package/dist/advisory/context.d.ts +5 -5
- package/dist/advisory/context.d.ts.map +1 -1
- package/dist/advisory/context.js +6 -6
- package/dist/advisory/context.js.map +1 -1
- package/dist/advisory/evaluator.js +2 -2
- package/dist/advisory/evaluator.js.map +1 -1
- package/dist/advisory/parse.d.ts +1 -1
- package/dist/advisory/parse.js +1 -1
- package/dist/agents/AbstractAgent.d.ts +47 -40
- package/dist/agents/AbstractAgent.d.ts.map +1 -1
- package/dist/agents/AbstractAgent.js +60 -46
- package/dist/agents/AbstractAgent.js.map +1 -1
- package/dist/agents/PipelineAgent.d.ts +7 -7
- package/dist/agents/PipelineAgent.d.ts.map +1 -1
- package/dist/agents/PipelineAgent.js +75 -23
- package/dist/agents/PipelineAgent.js.map +1 -1
- package/dist/agents/ReactiveAgent.d.ts +7 -7
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +32 -25
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/RouterAgent.d.ts +7 -7
- package/dist/agents/RouterAgent.d.ts.map +1 -1
- package/dist/agents/RouterAgent.js +29 -32
- package/dist/agents/RouterAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts +13 -10
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +50 -36
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/agents/budget.d.ts +17 -4
- package/dist/agents/budget.d.ts.map +1 -1
- package/dist/agents/budget.js +55 -14
- package/dist/agents/budget.js.map +1 -1
- package/dist/agents/defineAgent.d.ts +2 -2
- package/dist/agents/defineAgent.d.ts.map +1 -1
- package/dist/agents/defineAgent.js.map +1 -1
- package/dist/agents/handle.d.ts +12 -14
- package/dist/agents/handle.d.ts.map +1 -1
- package/dist/agents/handle.js +6 -6
- package/dist/agents/handle.js.map +1 -1
- package/dist/agents/lock.js +4 -4
- package/dist/agents/lock.js.map +1 -1
- package/dist/agents/runAgent.d.ts +42 -29
- package/dist/agents/runAgent.d.ts.map +1 -1
- package/dist/agents/runAgent.js +53 -14
- package/dist/agents/runAgent.js.map +1 -1
- package/dist/agents/storage.d.ts +21 -0
- package/dist/agents/storage.d.ts.map +1 -0
- package/dist/agents/storage.js +33 -0
- package/dist/agents/storage.js.map +1 -0
- package/dist/authorization/command-line.d.ts +1 -1
- package/dist/authorization/command-line.js +1 -1
- package/dist/authorization/gate.js +1 -1
- package/dist/authorization/gate.js.map +1 -1
- package/dist/authorization/permission-presets.d.ts +4 -4
- package/dist/authorization/permission-presets.d.ts.map +1 -1
- package/dist/authorization/permission-presets.js +2 -2
- package/dist/bridge/a2a/client.d.ts +1 -1
- package/dist/bridge/a2a/client.js +2 -2
- package/dist/bridge/a2a/client.js.map +1 -1
- package/dist/bridge/a2a/context.d.ts +26 -0
- package/dist/bridge/a2a/context.d.ts.map +1 -0
- package/dist/bridge/a2a/context.js +20 -0
- package/dist/bridge/a2a/context.js.map +1 -0
- package/dist/bridge/a2a/index.d.ts +4 -2
- package/dist/bridge/a2a/index.d.ts.map +1 -1
- package/dist/bridge/a2a/index.js +6 -2
- package/dist/bridge/a2a/index.js.map +1 -1
- package/dist/bridge/a2a/mapper.d.ts +12 -4
- package/dist/bridge/a2a/mapper.d.ts.map +1 -1
- package/dist/bridge/a2a/mapper.js +38 -31
- package/dist/bridge/a2a/mapper.js.map +1 -1
- package/dist/bridge/a2a/task.d.ts +39 -7
- package/dist/bridge/a2a/task.d.ts.map +1 -1
- package/dist/bridge/a2a/task.js +52 -31
- package/dist/bridge/a2a/task.js.map +1 -1
- package/dist/bridge/acp/permission.d.ts +2 -2
- package/dist/bridge/acp/server.d.ts +22 -8
- package/dist/bridge/acp/server.d.ts.map +1 -1
- package/dist/bridge/acp/server.js +18 -5
- package/dist/bridge/acp/server.js.map +1 -1
- package/dist/bridge/acp/update.d.ts +4 -4
- package/dist/bridge/acp/update.d.ts.map +1 -1
- package/dist/bridge/acp/update.js +6 -6
- package/dist/bridge/acp/update.js.map +1 -1
- package/dist/bridge/external-session.d.ts +43 -0
- package/dist/bridge/external-session.d.ts.map +1 -0
- package/dist/bridge/external-session.js +28 -0
- package/dist/bridge/external-session.js.map +1 -0
- package/dist/bridge/sse/index.d.ts +1 -1
- package/dist/bridge/sse/index.d.ts.map +1 -1
- package/dist/bridge/sse/index.js +1 -1
- package/dist/bridge/sse/index.js.map +1 -1
- package/dist/bridge/sse/mapper.d.ts +21 -13
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +100 -129
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/bus/breaker.d.ts +6 -6
- package/dist/bus/breaker.d.ts.map +1 -1
- package/dist/bus/breaker.js +28 -27
- package/dist/bus/breaker.js.map +1 -1
- package/dist/bus/index.d.ts +2 -2
- package/dist/bus/index.d.ts.map +1 -1
- package/dist/bus/index.js +6 -6
- package/dist/bus/index.js.map +1 -1
- package/dist/bus/lock.d.ts +5 -5
- package/dist/bus/lock.d.ts.map +1 -1
- package/dist/bus/lock.js.map +1 -1
- package/dist/bus/ownership.d.ts +8 -8
- package/dist/bus/ownership.d.ts.map +1 -1
- package/dist/bus/ownership.js.map +1 -1
- package/dist/compaction/consolidation.d.ts +23 -11
- package/dist/compaction/consolidation.d.ts.map +1 -1
- package/dist/compaction/consolidation.js +43 -13
- package/dist/compaction/consolidation.js.map +1 -1
- package/dist/compaction/context-window.d.ts +4 -4
- package/dist/compaction/context-window.js +4 -4
- package/dist/compaction/index.d.ts +1 -1
- package/dist/compaction/index.d.ts.map +1 -1
- package/dist/compaction/index.js +2 -2
- package/dist/compaction/index.js.map +1 -1
- package/dist/compaction/manager.d.ts +4 -4
- package/dist/compaction/manager.js +4 -4
- package/dist/compaction/manual.d.ts +2 -2
- package/dist/compaction/manual.js +3 -3
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/plan.d.ts +5 -5
- package/dist/compaction/plan.js +4 -4
- package/dist/compaction/plan.js.map +1 -1
- package/dist/compaction/reducer.d.ts +8 -8
- package/dist/compaction/reducer.d.ts.map +1 -1
- package/dist/compaction/retention.js +2 -2
- package/dist/compaction/salience/bm25.d.ts +2 -2
- package/dist/compaction/salience/bm25.js +2 -2
- package/dist/compaction/salience/goal.d.ts +3 -3
- package/dist/compaction/salience/goal.js +3 -3
- package/dist/compaction/salience/minhash.d.ts +1 -1
- package/dist/compaction/salience/minhash.js +1 -1
- package/dist/compaction/salience/score.d.ts +2 -2
- package/dist/compaction/salience/score.js +3 -3
- package/dist/compaction/salience/score.js.map +1 -1
- package/dist/compaction/salience/tokenize.d.ts +1 -1
- package/dist/compaction/salience/tokenize.js +1 -1
- package/dist/compaction/verifier.d.ts +6 -6
- package/dist/compaction/verifier.js +5 -5
- package/dist/compaction/verifier.js.map +1 -1
- package/dist/compaction/wire.d.ts +1 -1
- package/dist/config/registry.d.ts +4 -4
- package/dist/config/registry.js +2 -2
- package/dist/config/runtime.d.ts +24 -24
- package/dist/config/runtime.js +3 -3
- package/dist/connector/http-operation.d.ts +1 -1
- package/dist/connector/http-operation.js +1 -1
- package/dist/connector/mcp/adapter.js +1 -1
- package/dist/connector/mcp/client.d.ts +1 -1
- package/dist/connector/mcp/client.js +1 -1
- package/dist/connector/mcp/discovery.d.ts +1 -1
- package/dist/connector/mcp/discovery.js +1 -1
- package/dist/connector/mcp/discovery.js.map +1 -1
- package/dist/connector/mcp/policy.d.ts +1 -1
- package/dist/connector/mcp/prompt-adapter.d.ts +1 -1
- package/dist/connector/mcp/prompt-adapter.js +3 -3
- package/dist/connector/mcp/prompt-adapter.js.map +1 -1
- package/dist/constants/a2a/index.d.ts +8 -2
- package/dist/constants/a2a/index.d.ts.map +1 -1
- package/dist/constants/a2a/index.js +9 -2
- package/dist/constants/a2a/index.js.map +1 -1
- package/dist/constants/continuation.d.ts +1 -1
- package/dist/constants/continuation.js +1 -1
- package/dist/constants/index.d.ts +0 -1
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/index.js +0 -1
- package/dist/constants/index.js.map +1 -1
- package/dist/constants/limits.d.ts +2 -2
- package/dist/constants/limits.js +2 -2
- package/dist/constants/telemetry/index.d.ts +9 -3
- package/dist/constants/telemetry/index.d.ts.map +1 -1
- package/dist/constants/telemetry/index.js +14 -12
- package/dist/constants/telemetry/index.js.map +1 -1
- package/dist/constants/tools/index.d.ts +2 -2
- package/dist/constants/tools/index.js +2 -2
- package/dist/contracts/a2a.d.ts +2 -2
- package/dist/contracts/api.d.ts +11 -126
- package/dist/contracts/api.d.ts.map +1 -1
- package/dist/contracts/index.d.ts +3 -2
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +7 -2
- package/dist/contracts/index.js.map +1 -1
- package/dist/contracts/schemas.d.ts +6 -165
- package/dist/contracts/schemas.d.ts.map +1 -1
- package/dist/contracts/schemas.js +6 -36
- package/dist/contracts/schemas.js.map +1 -1
- package/dist/contracts/session/api.d.ts +94 -0
- package/dist/contracts/session/api.d.ts.map +1 -0
- package/dist/contracts/session/api.js +10 -0
- package/dist/contracts/session/api.js.map +1 -0
- package/dist/contracts/session/index.d.ts +7 -0
- package/dist/contracts/session/index.d.ts.map +1 -0
- package/dist/contracts/session/index.js +7 -0
- package/dist/contracts/session/index.js.map +1 -0
- package/dist/contracts/session/schemas.d.ts +173 -0
- package/dist/contracts/session/schemas.d.ts.map +1 -0
- package/dist/contracts/session/schemas.js +52 -0
- package/dist/contracts/session/schemas.js.map +1 -0
- package/dist/contracts/session/turn-status.d.ts +45 -0
- package/dist/contracts/session/turn-status.d.ts.map +1 -0
- package/dist/contracts/session/turn-status.js +46 -0
- package/dist/contracts/session/turn-status.js.map +1 -0
- package/dist/contracts/session/turn.d.ts +64 -0
- package/dist/contracts/session/turn.d.ts.map +1 -0
- package/dist/contracts/session/turn.js +2 -0
- package/dist/contracts/session/turn.js.map +1 -0
- package/dist/directory/derive-supervisor.d.ts +1 -1
- package/dist/directory/derive-supervisor.js +2 -2
- package/dist/directory/derive-supervisor.js.map +1 -1
- package/dist/directory/derive.d.ts +2 -2
- package/dist/directory/derive.d.ts.map +1 -1
- package/dist/directory/derive.js +2 -2
- package/dist/directory/derive.js.map +1 -1
- package/dist/directory/index.d.ts +2 -2
- package/dist/directory/index.d.ts.map +1 -1
- package/dist/directory/index.js +1 -1
- package/dist/directory/index.js.map +1 -1
- package/dist/directory/load.js +2 -2
- package/dist/directory/load.js.map +1 -1
- package/dist/directory/types.d.ts +2 -2
- package/dist/directory/types.d.ts.map +1 -1
- package/dist/eval/experiment.d.ts +5 -5
- package/dist/eval/experiment.d.ts.map +1 -1
- package/dist/eval/experiment.js +18 -18
- package/dist/eval/experiment.js.map +1 -1
- package/dist/eval/from-turn.d.ts +30 -0
- package/dist/eval/from-turn.d.ts.map +1 -0
- package/dist/eval/from-turn.js +46 -0
- package/dist/eval/from-turn.js.map +1 -0
- package/dist/eval/harness-verification.js +7 -7
- package/dist/eval/harness-verification.js.map +1 -1
- package/dist/eval/index.d.ts +2 -2
- package/dist/eval/index.d.ts.map +1 -1
- package/dist/eval/index.js +1 -1
- package/dist/eval/index.js.map +1 -1
- package/dist/eval/judge.d.ts +3 -3
- package/dist/eval/judge.d.ts.map +1 -1
- package/dist/eval/judge.js +6 -6
- package/dist/eval/judge.js.map +1 -1
- package/dist/eval/scorers.d.ts +8 -8
- package/dist/eval/scorers.d.ts.map +1 -1
- package/dist/eval/scorers.js +21 -21
- package/dist/eval/scorers.js.map +1 -1
- package/dist/eval/types.d.ts +12 -12
- package/dist/eval/types.d.ts.map +1 -1
- package/dist/eval/uncertainty.d.ts +2 -2
- package/dist/eval/uncertainty.js +2 -2
- package/dist/execution/code-runtime/types.d.ts +4 -4
- package/dist/execution/code-runtime/types.js +2 -2
- package/dist/execution/code-runtime/worker.d.ts +1 -1
- package/dist/execution/code-runtime/worker.js +1 -1
- package/dist/invariants/index.d.ts +1 -1
- package/dist/manager/agent/child-session.d.ts +49 -0
- package/dist/manager/agent/child-session.d.ts.map +1 -0
- package/dist/manager/agent/child-session.js +94 -0
- package/dist/manager/agent/child-session.js.map +1 -0
- package/dist/manager/agent/lifecycle.d.ts +90 -13
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +332 -88
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/index.d.ts +1 -2
- package/dist/manager/index.d.ts.map +1 -1
- package/dist/manager/index.js +1 -2
- package/dist/manager/index.js.map +1 -1
- package/dist/manager/plan/lifecycle.d.ts +11 -7
- package/dist/manager/plan/lifecycle.d.ts.map +1 -1
- package/dist/manager/plan/lifecycle.js +12 -9
- package/dist/manager/plan/lifecycle.js.map +1 -1
- package/dist/manager/resident/consumption.d.ts +12 -6
- package/dist/manager/resident/consumption.d.ts.map +1 -1
- package/dist/manager/resident/consumption.js +7 -5
- package/dist/manager/resident/consumption.js.map +1 -1
- package/dist/manager/resident/evidence-recall.d.ts +5 -5
- package/dist/manager/resident/evidence-recall.d.ts.map +1 -1
- package/dist/manager/resident/evidence-recall.js +9 -9
- package/dist/manager/resident/evidence-recall.js.map +1 -1
- package/dist/manager/resident/host.d.ts +2 -2
- package/dist/manager/resident/host.d.ts.map +1 -1
- package/dist/manager/resident/host.js +1 -1
- package/dist/manager/resident/learning-cycle.d.ts +8 -4
- package/dist/manager/resident/learning-cycle.d.ts.map +1 -1
- package/dist/manager/resident/learning-cycle.js +4 -2
- package/dist/manager/resident/learning-cycle.js.map +1 -1
- package/dist/manager/resident/learning-observation.d.ts +12 -7
- package/dist/manager/resident/learning-observation.d.ts.map +1 -1
- package/dist/manager/resident/learning-observation.js +8 -4
- package/dist/manager/resident/learning-observation.js.map +1 -1
- package/dist/manager/resident/learning-store.d.ts +13 -0
- package/dist/manager/resident/learning-store.d.ts.map +1 -1
- package/dist/manager/resident/learning-store.js +35 -16
- package/dist/manager/resident/learning-store.js.map +1 -1
- package/dist/manager/resident/learning.d.ts +14 -14
- package/dist/manager/resident/outbox.d.ts +4 -4
- package/dist/manager/resident/store.d.ts +8 -8
- package/dist/manager/resident/tool-evidence.d.ts +15 -10
- package/dist/manager/resident/tool-evidence.d.ts.map +1 -1
- package/dist/manager/resident/tool-evidence.js +14 -14
- package/dist/manager/resident/tool-evidence.js.map +1 -1
- package/dist/manager/session/turn-recorder.d.ts +261 -0
- package/dist/manager/session/turn-recorder.d.ts.map +1 -0
- package/dist/manager/session/turn-recorder.js +1115 -0
- package/dist/manager/session/turn-recorder.js.map +1 -0
- package/dist/plugin/lifecycle.d.ts +4 -4
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +17 -10
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +35 -12
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +52 -20
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/pricing/index.d.ts +4 -4
- package/dist/pricing/index.js +5 -5
- package/dist/pricing/index.js.map +1 -1
- package/dist/probe/context.d.ts +3 -2
- package/dist/probe/context.d.ts.map +1 -1
- package/dist/probe/context.js +2 -1
- package/dist/probe/context.js.map +1 -1
- package/dist/probe/registry.js +1 -1
- package/dist/probe/registry.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +1 -1
- package/dist/prompt/coding-agent-doctrine.js +1 -1
- package/dist/prompt/contributions.d.ts +27 -6
- package/dist/prompt/contributions.d.ts.map +1 -1
- package/dist/prompt/contributions.js +1 -1
- package/dist/prompt/contributions.js.map +1 -1
- package/dist/prompt/resident-learning.js +2 -2
- package/dist/prompt/resident-learning.js.map +1 -1
- package/dist/provider/collect-chat-completion.d.ts +2 -2
- package/dist/provider/collect-chat-completion.js +3 -3
- package/dist/provider/collect-chat-completion.js.map +1 -1
- package/dist/provider/conformance.d.ts +8 -1
- package/dist/provider/conformance.d.ts.map +1 -1
- package/dist/provider/conformance.js.map +1 -1
- package/dist/provider/errors.d.ts +1 -1
- package/dist/provider/errors.js +2 -2
- package/dist/provider/fallback.d.ts +4 -4
- package/dist/provider/fallback.js +6 -6
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/idle-timeout.d.ts +2 -2
- package/dist/provider/idle-timeout.d.ts.map +1 -1
- package/dist/provider/idle-timeout.js +3 -3
- package/dist/provider/idle-timeout.js.map +1 -1
- package/dist/provider/instrumentation.d.ts +5 -2
- package/dist/provider/instrumentation.d.ts.map +1 -1
- package/dist/provider/instrumentation.js +9 -5
- package/dist/provider/instrumentation.js.map +1 -1
- package/dist/provider/mock.d.ts +1 -1
- package/dist/provider/mock.js +1 -1
- package/dist/provider/retry.d.ts +2 -2
- package/dist/provider/retry.js +6 -6
- package/dist/provider/retry.js.map +1 -1
- package/dist/provider/stream-text.d.ts +1 -1
- package/dist/provider/stream-text.d.ts.map +1 -1
- package/dist/provider/stream-text.js +1 -1
- package/dist/provider/stream-text.js.map +1 -1
- package/dist/provider/thinking-support.js +2 -2
- package/dist/provider/thinking-support.js.map +1 -1
- package/dist/provider/token-budget.d.ts +2 -2
- package/dist/provider/token-budget.d.ts.map +1 -1
- package/dist/provider/token-budget.js.map +1 -1
- package/dist/public-runtime.d.ts +69 -55
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +104 -99
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +2 -2
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +7 -7
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +18 -16
- package/dist/public-types.d.ts.map +1 -1
- package/dist/rag/embedding.js +1 -1
- package/dist/rag/embedding.js.map +1 -1
- package/dist/read-model/index.d.ts +2 -2
- package/dist/read-model/index.d.ts.map +1 -1
- package/dist/read-model/index.js +1 -1
- package/dist/read-model/index.js.map +1 -1
- package/dist/read-model/registry.d.ts +11 -11
- package/dist/read-model/registry.d.ts.map +1 -1
- package/dist/read-model/registry.js +2 -2
- package/dist/read-model/registry.js.map +1 -1
- package/dist/read-model/session-status.d.ts +34 -0
- package/dist/read-model/session-status.d.ts.map +1 -0
- package/dist/read-model/session-status.js +58 -0
- package/dist/read-model/session-status.js.map +1 -0
- package/dist/registry/command/kernel-commands.d.ts +4 -4
- package/dist/registry/command/kernel-commands.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.js +6 -6
- package/dist/registry/command/kernel-commands.js.map +1 -1
- package/dist/registry/tool/dialect.js +1 -1
- package/dist/registry/tool/execute.d.ts +2 -2
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +19 -7
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/registry/tool/portable.d.ts +1 -1
- package/dist/registry/tool/portable.js +1 -1
- package/dist/registry/tool/presentation.d.ts +1 -1
- package/dist/registry/tool/presentation.js +1 -1
- package/dist/registry/tool/schema.js +1 -1
- package/dist/registry/tool/screen.js +3 -3
- package/dist/registry/tool/screen.js.map +1 -1
- package/dist/runtime/bidi/index.d.ts +2 -2
- package/dist/runtime/bidi/index.d.ts.map +1 -1
- package/dist/runtime/bidi/index.js +1 -1
- package/dist/runtime/bidi/index.js.map +1 -1
- package/dist/runtime/bidi/session.d.ts +14 -11
- package/dist/runtime/bidi/session.d.ts.map +1 -1
- package/dist/runtime/bidi/session.js +27 -21
- package/dist/runtime/bidi/session.js.map +1 -1
- package/dist/runtime/jobs/awaited-jobs.d.ts +15 -15
- package/dist/runtime/jobs/awaited-jobs.d.ts.map +1 -1
- package/dist/runtime/jobs/awaited-jobs.js +13 -13
- package/dist/runtime/jobs/awaited-jobs.js.map +1 -1
- package/dist/runtime/jobs/registry.d.ts +10 -10
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +5 -5
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/abandon-turn.d.ts +35 -0
- package/dist/runtime/query/abandon-turn.d.ts.map +1 -0
- package/dist/runtime/query/abandon-turn.js +81 -0
- package/dist/runtime/query/abandon-turn.js.map +1 -0
- package/dist/runtime/query/approval-policy.d.ts +10 -10
- package/dist/runtime/query/approval-policy.d.ts.map +1 -1
- package/dist/runtime/query/approval-policy.js +5 -5
- package/dist/runtime/query/approval-policy.js.map +1 -1
- package/dist/runtime/query/callback-inference.d.ts +1 -1
- package/dist/runtime/query/callback-inference.d.ts.map +1 -1
- package/dist/runtime/query/callback-inference.js +4 -4
- package/dist/runtime/query/callback-inference.js.map +1 -1
- package/dist/runtime/query/cancelled-before-start.d.ts +20 -20
- package/dist/runtime/query/cancelled-before-start.d.ts.map +1 -1
- package/dist/runtime/query/cancelled-before-start.js +72 -55
- package/dist/runtime/query/cancelled-before-start.js.map +1 -1
- package/dist/runtime/query/checkpoint.d.ts +153 -220
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +399 -370
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/runtime/query/compact-session.d.ts +20 -0
- package/dist/runtime/query/compact-session.d.ts.map +1 -0
- package/dist/runtime/query/compact-session.js +81 -0
- package/dist/runtime/query/compact-session.js.map +1 -0
- package/dist/runtime/query/context.d.ts +42 -85
- package/dist/runtime/query/context.d.ts.map +1 -1
- package/dist/runtime/query/context.js +36 -75
- package/dist/runtime/query/context.js.map +1 -1
- package/dist/runtime/query/events.d.ts +54 -26
- package/dist/runtime/query/events.d.ts.map +1 -1
- package/dist/runtime/query/events.js +122 -114
- package/dist/runtime/query/events.js.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +6 -5
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +56 -34
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +165 -85
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/file-evidence-seed.d.ts +1 -1
- package/dist/runtime/query/file-evidence-seed.d.ts.map +1 -1
- package/dist/runtime/query/file-evidence-seed.js +1 -1
- package/dist/runtime/query/finalize-turn.d.ts +55 -0
- package/dist/runtime/query/finalize-turn.d.ts.map +1 -0
- package/dist/runtime/query/finalize-turn.js +129 -0
- package/dist/runtime/query/finalize-turn.js.map +1 -0
- package/dist/runtime/query/fork/list.d.ts +15 -0
- package/dist/runtime/query/fork/list.d.ts.map +1 -0
- package/dist/runtime/query/fork/list.js +11 -0
- package/dist/runtime/query/fork/list.js.map +1 -0
- package/dist/runtime/query/fork/mutate.d.ts +17 -0
- package/dist/runtime/query/fork/mutate.d.ts.map +1 -0
- package/dist/runtime/query/fork/mutate.js +69 -0
- package/dist/runtime/query/fork/mutate.js.map +1 -0
- package/dist/runtime/query/fork/prepare.d.ts +52 -0
- package/dist/runtime/query/fork/prepare.d.ts.map +1 -0
- package/dist/runtime/query/fork/prepare.js +43 -0
- package/dist/runtime/query/fork/prepare.js.map +1 -0
- package/dist/runtime/query/guard.d.ts +16 -16
- package/dist/runtime/query/guard.d.ts.map +1 -1
- package/dist/runtime/query/guard.js +16 -16
- package/dist/runtime/query/guard.js.map +1 -1
- package/dist/runtime/query/guardrail-presets.d.ts +10 -10
- package/dist/runtime/query/guardrail-presets.js +12 -12
- package/dist/runtime/query/guardrail-presets.js.map +1 -1
- package/dist/runtime/query/guardrails.d.ts +4 -4
- package/dist/runtime/query/guardrails.js +11 -11
- package/dist/runtime/query/guardrails.js.map +1 -1
- package/dist/runtime/query/index.d.ts +193 -155
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +1295 -1260
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +16 -16
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +285 -243
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/outstanding-work.d.ts +22 -22
- package/dist/runtime/query/iteration/outstanding-work.d.ts.map +1 -1
- package/dist/runtime/query/iteration/outstanding-work.js +63 -63
- package/dist/runtime/query/iteration/outstanding-work.js.map +1 -1
- package/dist/runtime/query/iteration/phases/advisory.js +16 -16
- package/dist/runtime/query/iteration/phases/advisory.js.map +1 -1
- package/dist/runtime/query/iteration/phases/checkpoint.d.ts +2 -2
- package/dist/runtime/query/iteration/phases/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/checkpoint.js +25 -8
- package/dist/runtime/query/iteration/phases/checkpoint.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts +2 -2
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +74 -72
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +34 -29
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js +29 -29
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/plan.d.ts +2 -2
- package/dist/runtime/query/iteration/phases/plan.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/plan.js +5 -4
- package/dist/runtime/query/iteration/phases/plan.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts +2 -2
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +140 -25
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/phases/working-memory.d.ts +27 -3
- package/dist/runtime/query/iteration/phases/working-memory.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/working-memory.js +54 -20
- package/dist/runtime/query/iteration/phases/working-memory.js.map +1 -1
- package/dist/runtime/query/iteration/step-context.d.ts +11 -0
- package/dist/runtime/query/iteration/step-context.d.ts.map +1 -0
- package/dist/runtime/query/iteration/step-context.js +14 -0
- package/dist/runtime/query/iteration/step-context.js.map +1 -0
- package/dist/runtime/query/iteration/step-shaping.d.ts +4 -3
- package/dist/runtime/query/iteration/step-shaping.d.ts.map +1 -1
- package/dist/runtime/query/iteration/step-shaping.js +20 -19
- package/dist/runtime/query/iteration/step-shaping.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts +5 -3
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +32 -28
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/plugin-hooks.js +1 -1
- package/dist/runtime/query/plugin-hooks.js.map +1 -1
- package/dist/runtime/query/prepare-turn.d.ts +105 -0
- package/dist/runtime/query/prepare-turn.d.ts.map +1 -0
- package/dist/runtime/query/prepare-turn.js +779 -0
- package/dist/runtime/query/prepare-turn.js.map +1 -0
- package/dist/runtime/query/project-instructions.d.ts +5 -4
- package/dist/runtime/query/project-instructions.d.ts.map +1 -1
- package/dist/runtime/query/project-instructions.js.map +1 -1
- package/dist/runtime/query/prompt-cache.js +1 -1
- package/dist/runtime/query/prompt-cache.js.map +1 -1
- package/dist/runtime/query/prompt.d.ts +3 -3
- package/dist/runtime/query/prompt.d.ts.map +1 -1
- package/dist/runtime/query/prompt.js +3 -3
- package/dist/runtime/query/prompt.js.map +1 -1
- package/dist/runtime/query/question-park.d.ts +7 -7
- package/dist/runtime/query/question-park.d.ts.map +1 -1
- package/dist/runtime/query/question-park.js +5 -5
- package/dist/runtime/query/question-park.js.map +1 -1
- package/dist/runtime/query/release-turn.d.ts +53 -0
- package/dist/runtime/query/release-turn.d.ts.map +1 -0
- package/dist/runtime/query/release-turn.js +95 -0
- package/dist/runtime/query/release-turn.js.map +1 -0
- package/dist/runtime/query/repeat-call.d.ts +2 -2
- package/dist/runtime/query/repeat-call.js +7 -7
- package/dist/runtime/query/repeat-call.js.map +1 -1
- package/dist/runtime/query/result.d.ts +25 -17
- package/dist/runtime/query/result.d.ts.map +1 -1
- package/dist/runtime/query/result.js +110 -115
- package/dist/runtime/query/result.js.map +1 -1
- package/dist/runtime/query/resume-pending.d.ts +34 -17
- package/dist/runtime/query/resume-pending.d.ts.map +1 -1
- package/dist/runtime/query/resume-pending.js +70 -30
- package/dist/runtime/query/resume-pending.js.map +1 -1
- package/dist/runtime/query/resume-session.d.ts +65 -0
- package/dist/runtime/query/resume-session.d.ts.map +1 -0
- package/dist/runtime/query/resume-session.js +88 -0
- package/dist/runtime/query/resume-session.js.map +1 -0
- package/dist/runtime/query/review-policy.d.ts +57 -16
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +115 -11
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/sandbox-lifecycle.d.ts +5 -5
- package/dist/runtime/query/sandbox-lifecycle.d.ts.map +1 -1
- package/dist/runtime/query/sandbox-lifecycle.js +4 -4
- package/dist/runtime/query/sandbox-lifecycle.js.map +1 -1
- package/dist/runtime/query/session-storage.d.ts +75 -0
- package/dist/runtime/query/session-storage.d.ts.map +1 -0
- package/dist/runtime/query/session-storage.js +236 -0
- package/dist/runtime/query/session-storage.js.map +1 -0
- package/dist/runtime/query/steering.d.ts +9 -3
- package/dist/runtime/query/steering.d.ts.map +1 -1
- package/dist/runtime/query/steering.js +12 -2
- package/dist/runtime/query/steering.js.map +1 -1
- package/dist/runtime/query/token-budget.d.ts +19 -5
- package/dist/runtime/query/token-budget.d.ts.map +1 -1
- package/dist/runtime/query/token-budget.js +43 -74
- package/dist/runtime/query/token-budget.js.map +1 -1
- package/dist/runtime/query/tool-call-budget.d.ts +6 -5
- package/dist/runtime/query/tool-call-budget.d.ts.map +1 -1
- package/dist/runtime/query/tool-call-budget.js +10 -12
- package/dist/runtime/query/tool-call-budget.js.map +1 -1
- package/dist/runtime/query/tool-executions.d.ts +26 -0
- package/dist/runtime/query/tool-executions.d.ts.map +1 -0
- package/dist/runtime/query/tool-executions.js +66 -0
- package/dist/runtime/query/tool-executions.js.map +1 -0
- package/dist/runtime/query/tool-grants.d.ts +3 -3
- package/dist/runtime/query/tool-grants.js +3 -3
- package/dist/runtime/query/tool-output-budget.d.ts +2 -2
- package/dist/runtime/query/tool-output-budget.js +4 -4
- package/dist/runtime/query/tool-output-budget.js.map +1 -1
- package/dist/runtime/query/tool-pause.d.ts +4 -3
- package/dist/runtime/query/tool-pause.d.ts.map +1 -1
- package/dist/runtime/query/tool-pause.js +5 -4
- package/dist/runtime/query/tool-pause.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +15 -10
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +7 -4
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/runtime/query/turn-state.d.ts +56 -0
- package/dist/runtime/query/turn-state.d.ts.map +1 -0
- package/dist/runtime/query/turn-state.js +99 -0
- package/dist/runtime/query/turn-state.js.map +1 -0
- package/dist/sandbox/isolation.d.ts +1 -1
- package/dist/sandbox/isolation.js +2 -2
- package/dist/sandbox/isolation.js.map +1 -1
- package/dist/sandbox/provider/local.d.ts +2 -2
- package/dist/sandbox/provider/local.js +7 -7
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/scheduler/completion-inbox.d.ts +21 -21
- package/dist/scheduler/completion-inbox.js +36 -36
- package/dist/scheduler/completion-inbox.js.map +1 -1
- package/dist/scheduler/delegating.d.ts +6 -3
- package/dist/scheduler/delegating.d.ts.map +1 -1
- package/dist/scheduler/delegating.js +15 -8
- package/dist/scheduler/delegating.js.map +1 -1
- package/dist/scheduler/local.d.ts +10 -8
- package/dist/scheduler/local.d.ts.map +1 -1
- package/dist/scheduler/local.js +37 -11
- package/dist/scheduler/local.js.map +1 -1
- package/dist/session/events/index.d.ts +3 -3
- package/dist/session/events/index.d.ts.map +1 -1
- package/dist/session/events/index.js +4 -8
- package/dist/session/events/index.js.map +1 -1
- package/dist/session/handoff/broadcast.d.ts +3 -3
- package/dist/session/handoff/broadcast.d.ts.map +1 -1
- package/dist/session/handoff/broadcast.js +4 -4
- package/dist/session/handoff/broadcast.js.map +1 -1
- package/dist/session/handoff/events.d.ts +1 -1
- package/dist/session/handoff/events.js +1 -1
- package/dist/session/handoff/index.d.ts +1 -1
- package/dist/session/handoff/index.d.ts.map +1 -1
- package/dist/session/handoff/single.d.ts +12 -12
- package/dist/session/handoff/single.d.ts.map +1 -1
- package/dist/session/handoff/single.js +9 -9
- package/dist/session/handoff/single.js.map +1 -1
- package/dist/session/handoff/version.d.ts +7 -7
- package/dist/session/handoff/version.d.ts.map +1 -1
- package/dist/session/handoff/version.js +2 -2
- package/dist/session/handoff/version.js.map +1 -1
- package/dist/session/home.d.ts +23 -0
- package/dist/session/home.d.ts.map +1 -0
- package/dist/session/home.js +45 -0
- package/dist/session/home.js.map +1 -0
- package/dist/session/index.d.ts +1 -0
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +1 -0
- package/dist/session/index.js.map +1 -1
- package/dist/session/log-hash.d.ts +25 -0
- package/dist/session/log-hash.d.ts.map +1 -0
- package/dist/session/log-hash.js +82 -0
- package/dist/session/log-hash.js.map +1 -0
- package/dist/session/messages.d.ts +11 -0
- package/dist/session/messages.d.ts.map +1 -0
- package/dist/session/messages.js +32 -0
- package/dist/session/messages.js.map +1 -0
- package/dist/session/paths.d.ts +168 -0
- package/dist/session/paths.d.ts.map +1 -0
- package/dist/session/paths.js +338 -0
- package/dist/session/paths.js.map +1 -0
- package/dist/session/retention/archive.d.ts +8 -1
- package/dist/session/retention/archive.d.ts.map +1 -1
- package/dist/session/retention/archive.js +3 -5
- package/dist/session/retention/archive.js.map +1 -1
- package/dist/session/status/derive.d.ts +13 -13
- package/dist/session/status/derive.d.ts.map +1 -1
- package/dist/session/status/derive.js +20 -20
- package/dist/session/status/derive.js.map +1 -1
- package/dist/session/workspace/git-worktree.d.ts +8 -1
- package/dist/session/workspace/git-worktree.d.ts.map +1 -1
- package/dist/session/workspace/git-worktree.js +29 -1
- package/dist/session/workspace/git-worktree.js.map +1 -1
- package/dist/session/workspace/index.d.ts +2 -4
- package/dist/session/workspace/index.d.ts.map +1 -1
- package/dist/session/workspace/index.js +2 -3
- package/dist/session/workspace/index.js.map +1 -1
- package/dist/session/workspace/shared-session.d.ts +112 -0
- package/dist/session/workspace/shared-session.d.ts.map +1 -0
- package/dist/session/workspace/shared-session.js +290 -0
- package/dist/session/workspace/shared-session.js.map +1 -0
- package/dist/session-query/index.d.ts +67 -0
- package/dist/session-query/index.d.ts.map +1 -0
- package/dist/session-query/index.js +100 -0
- package/dist/session-query/index.js.map +1 -0
- package/dist/skills/registry.d.ts +1 -1
- package/dist/skills/registry.js +1 -1
- package/dist/store/activity/memory.d.ts +3 -3
- package/dist/store/activity/memory.d.ts.map +1 -1
- package/dist/store/activity/memory.js +4 -4
- package/dist/store/activity/memory.js.map +1 -1
- package/dist/store/attachment/index.d.ts +4 -4
- package/dist/store/attachment/index.d.ts.map +1 -1
- package/dist/store/attachment/index.js +3 -3
- package/dist/store/attachment/index.js.map +1 -1
- package/dist/store/budget/disk.d.ts +59 -0
- package/dist/store/budget/disk.d.ts.map +1 -0
- package/dist/store/budget/disk.js +179 -0
- package/dist/store/budget/disk.js.map +1 -0
- package/dist/store/budget/index.d.ts +6 -0
- package/dist/store/budget/index.d.ts.map +1 -0
- package/dist/store/budget/index.js +6 -0
- package/dist/store/budget/index.js.map +1 -0
- package/dist/store/budget/ledger.d.ts +156 -0
- package/dist/store/budget/ledger.d.ts.map +1 -0
- package/dist/store/budget/ledger.js +683 -0
- package/dist/store/budget/ledger.js.map +1 -0
- package/dist/store/budget/memory.d.ts +18 -0
- package/dist/store/budget/memory.d.ts.map +1 -0
- package/dist/store/budget/memory.js +31 -0
- package/dist/store/budget/memory.js.map +1 -0
- package/dist/store/checkpoint/contract.d.ts +140 -0
- package/dist/store/checkpoint/contract.d.ts.map +1 -0
- package/dist/store/checkpoint/contract.js +91 -0
- package/dist/store/checkpoint/contract.js.map +1 -0
- package/dist/store/checkpoint/disk.d.ts +44 -0
- package/dist/store/checkpoint/disk.d.ts.map +1 -0
- package/dist/store/checkpoint/disk.js +168 -0
- package/dist/store/checkpoint/disk.js.map +1 -0
- package/dist/store/checkpoint/index.d.ts +9 -0
- package/dist/store/checkpoint/index.d.ts.map +1 -0
- package/dist/store/checkpoint/index.js +7 -0
- package/dist/store/checkpoint/index.js.map +1 -0
- package/dist/store/checkpoint/memory.d.ts +27 -0
- package/dist/store/checkpoint/memory.d.ts.map +1 -0
- package/dist/store/checkpoint/memory.js +80 -0
- package/dist/store/checkpoint/memory.js.map +1 -0
- package/dist/store/checkpoint/prune.d.ts +45 -0
- package/dist/store/checkpoint/prune.d.ts.map +1 -0
- package/dist/store/checkpoint/prune.js +71 -0
- package/dist/store/checkpoint/prune.js.map +1 -0
- package/dist/store/config/index.d.ts +1 -1
- package/dist/store/config/index.js +1 -1
- package/dist/store/evidence/disk.d.ts +25 -8
- package/dist/store/evidence/disk.d.ts.map +1 -1
- package/dist/store/evidence/disk.js +148 -47
- package/dist/store/evidence/disk.js.map +1 -1
- package/dist/store/evidence/index-page.d.ts +31 -140
- package/dist/store/evidence/index-page.d.ts.map +1 -1
- package/dist/store/evidence/index-page.js +59 -129
- package/dist/store/evidence/index-page.js.map +1 -1
- package/dist/store/evidence/source-text.d.ts +7 -6
- package/dist/store/evidence/source-text.d.ts.map +1 -1
- package/dist/store/evidence/source-text.js +16 -23
- package/dist/store/evidence/source-text.js.map +1 -1
- package/dist/store/evidence/types.d.ts +38 -39
- package/dist/store/evidence/types.d.ts.map +1 -1
- package/dist/store/feedback/conformance.d.ts +6 -6
- package/dist/store/feedback/conformance.d.ts.map +1 -1
- package/dist/store/feedback/conformance.js +30 -29
- package/dist/store/feedback/conformance.js.map +1 -1
- package/dist/store/feedback/disk.d.ts +20 -19
- package/dist/store/feedback/disk.d.ts.map +1 -1
- package/dist/store/feedback/disk.js +53 -53
- package/dist/store/feedback/disk.js.map +1 -1
- package/dist/store/feedback/index.d.ts +1 -1
- package/dist/store/feedback/index.d.ts.map +1 -1
- package/dist/store/feedback/index.js +1 -1
- package/dist/store/feedback/index.js.map +1 -1
- package/dist/store/feedback/memory.d.ts +8 -5
- package/dist/store/feedback/memory.d.ts.map +1 -1
- package/dist/store/feedback/memory.js +0 -0
- package/dist/store/feedback/memory.js.map +1 -1
- package/dist/store/feedback/types.d.ts +12 -11
- package/dist/store/feedback/types.d.ts.map +1 -1
- package/dist/store/feedback/types.js +3 -3
- package/dist/store/feedback/types.js.map +1 -1
- package/dist/store/index.d.ts +7 -8
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +4 -16
- package/dist/store/index.js.map +1 -1
- package/dist/store/memory/digest.d.ts +15 -0
- package/dist/store/memory/digest.d.ts.map +1 -0
- package/dist/store/memory/digest.js +27 -0
- package/dist/store/memory/digest.js.map +1 -0
- package/dist/store/memory/disk.d.ts.map +1 -1
- package/dist/store/memory/disk.js +42 -7
- package/dist/store/memory/disk.js.map +1 -1
- package/dist/store/memory/index-file.d.ts +56 -0
- package/dist/store/memory/index-file.d.ts.map +1 -0
- package/dist/store/memory/index-file.js +92 -0
- package/dist/store/memory/index-file.js.map +1 -0
- package/dist/store/memory/index.d.ts.map +1 -1
- package/dist/store/memory/index.js +4 -2
- package/dist/store/memory/index.js.map +1 -1
- package/dist/store/memory/links.d.ts +15 -0
- package/dist/store/memory/links.d.ts.map +1 -0
- package/dist/store/memory/links.js +35 -0
- package/dist/store/memory/links.js.map +1 -0
- package/dist/store/memory/markdown-format.d.ts +88 -0
- package/dist/store/memory/markdown-format.d.ts.map +1 -0
- package/dist/store/memory/markdown-format.js +222 -0
- package/dist/store/memory/markdown-format.js.map +1 -0
- package/dist/store/memory/markdown.d.ts +109 -0
- package/dist/store/memory/markdown.d.ts.map +1 -0
- package/dist/store/memory/markdown.js +606 -0
- package/dist/store/memory/markdown.js.map +1 -0
- package/dist/store/memory/memory.d.ts.map +1 -1
- package/dist/store/memory/memory.js +17 -4
- package/dist/store/memory/memory.js.map +1 -1
- package/dist/store/memory/naming.d.ts +66 -0
- package/dist/store/memory/naming.d.ts.map +1 -0
- package/dist/store/memory/naming.js +162 -0
- package/dist/store/memory/naming.js.map +1 -0
- package/dist/store/memory/origin.d.ts +25 -0
- package/dist/store/memory/origin.d.ts.map +1 -0
- package/dist/store/memory/origin.js +26 -0
- package/dist/store/memory/origin.js.map +1 -0
- package/dist/store/session/disk.d.ts +21 -24
- package/dist/store/session/disk.d.ts.map +1 -1
- package/dist/store/session/disk.js +27 -132
- package/dist/store/session/disk.js.map +1 -1
- package/dist/store/session/index.d.ts +0 -3
- package/dist/store/session/index.d.ts.map +1 -1
- package/dist/store/session/index.js +5 -7
- package/dist/store/session/index.js.map +1 -1
- package/dist/store/session/memory.d.ts +1 -8
- package/dist/store/session/memory.d.ts.map +1 -1
- package/dist/store/session/memory.js +1 -58
- package/dist/store/session/memory.js.map +1 -1
- package/dist/store/session-claim.d.ts +30 -0
- package/dist/store/session-claim.d.ts.map +1 -0
- package/dist/store/session-claim.js +71 -0
- package/dist/store/session-claim.js.map +1 -0
- package/dist/store/session-index/fts.d.ts +60 -0
- package/dist/store/session-index/fts.d.ts.map +1 -0
- package/dist/store/session-index/fts.js +160 -0
- package/dist/store/session-index/fts.js.map +1 -0
- package/dist/store/session-index/index.d.ts +206 -0
- package/dist/store/session-index/index.d.ts.map +1 -0
- package/dist/store/session-index/index.js +22 -0
- package/dist/store/session-index/index.js.map +1 -0
- package/dist/store/session-index/rebuild.d.ts +180 -0
- package/dist/store/session-index/rebuild.d.ts.map +1 -0
- package/dist/store/session-index/rebuild.js +669 -0
- package/dist/store/session-index/rebuild.js.map +1 -0
- package/dist/store/session-index/refs.d.ts +66 -0
- package/dist/store/session-index/refs.d.ts.map +1 -0
- package/dist/store/session-index/refs.js +107 -0
- package/dist/store/session-index/refs.js.map +1 -0
- package/dist/store/session-index/scan.d.ts +42 -0
- package/dist/store/session-index/scan.d.ts.map +1 -0
- package/dist/store/session-index/scan.js +188 -0
- package/dist/store/session-index/scan.js.map +1 -0
- package/dist/store/session-index/sqlite.d.ts +76 -0
- package/dist/store/session-index/sqlite.d.ts.map +1 -0
- package/dist/store/session-index/sqlite.js +547 -0
- package/dist/store/session-index/sqlite.js.map +1 -0
- package/dist/store/session-log/chain.d.ts +111 -0
- package/dist/store/session-log/chain.d.ts.map +1 -0
- package/dist/store/session-log/chain.js +212 -0
- package/dist/store/session-log/chain.js.map +1 -0
- package/dist/store/session-log/conformance.d.ts +61 -0
- package/dist/store/session-log/conformance.d.ts.map +1 -0
- package/dist/store/session-log/conformance.js +392 -0
- package/dist/store/session-log/conformance.js.map +1 -0
- package/dist/store/session-log/core.d.ts +203 -0
- package/dist/store/session-log/core.d.ts.map +1 -0
- package/dist/store/session-log/core.js +516 -0
- package/dist/store/session-log/core.js.map +1 -0
- package/dist/store/session-log/disk.d.ts +56 -0
- package/dist/store/session-log/disk.d.ts.map +1 -0
- package/dist/store/session-log/disk.js +169 -0
- package/dist/store/session-log/disk.js.map +1 -0
- package/dist/store/session-log/fold.d.ts +115 -0
- package/dist/store/session-log/fold.d.ts.map +1 -0
- package/dist/store/session-log/fold.js +265 -0
- package/dist/store/session-log/fold.js.map +1 -0
- package/dist/store/session-log/heal.d.ts +34 -0
- package/dist/store/session-log/heal.d.ts.map +1 -0
- package/dist/store/session-log/heal.js +12 -0
- package/dist/store/session-log/heal.js.map +1 -0
- package/dist/store/session-log/held-leases.d.ts +56 -0
- package/dist/store/session-log/held-leases.d.ts.map +1 -0
- package/dist/store/session-log/held-leases.js +67 -0
- package/dist/store/session-log/held-leases.js.map +1 -0
- package/dist/store/session-log/index.d.ts +10 -0
- package/dist/store/session-log/index.d.ts.map +1 -0
- package/dist/store/session-log/index.js +16 -0
- package/dist/store/session-log/index.js.map +1 -0
- package/dist/store/session-log/lease.d.ts +126 -0
- package/dist/store/session-log/lease.d.ts.map +1 -0
- package/dist/store/session-log/lease.js +226 -0
- package/dist/store/session-log/lease.js.map +1 -0
- package/dist/store/session-log/memory.d.ts +43 -0
- package/dist/store/session-log/memory.d.ts.map +1 -0
- package/dist/store/session-log/memory.js +78 -0
- package/dist/store/session-log/memory.js.map +1 -0
- package/dist/store/session-log/spill.d.ts +109 -0
- package/dist/store/session-log/spill.d.ts.map +1 -0
- package/dist/store/session-log/spill.js +223 -0
- package/dist/store/session-log/spill.js.map +1 -0
- package/dist/store/task/context.d.ts +25 -0
- package/dist/store/task/context.d.ts.map +1 -0
- package/dist/store/task/context.js +18 -0
- package/dist/store/task/context.js.map +1 -0
- package/dist/store/task/disk.d.ts +29 -26
- package/dist/store/task/disk.d.ts.map +1 -1
- package/dist/store/task/disk.js +102 -137
- package/dist/store/task/disk.js.map +1 -1
- package/dist/store/task/memory.d.ts +2 -2
- package/dist/store/task/memory.d.ts.map +1 -1
- package/dist/store/task/memory.js +10 -6
- package/dist/store/task/memory.js.map +1 -1
- package/dist/store/topic/index.js +2 -2
- package/dist/store/topic/index.js.map +1 -1
- package/dist/store/topic/objective.d.ts.map +1 -1
- package/dist/store/topic/objective.js +10 -3
- package/dist/store/topic/objective.js.map +1 -1
- package/dist/store/topic/state.js +1 -1
- package/dist/streaming/coalesce.d.ts +3 -3
- package/dist/streaming/coalesce.d.ts.map +1 -1
- package/dist/streaming/coalesce.js +1 -1
- package/dist/streaming/coalesce.js.map +1 -1
- package/dist/telemetry/attributes.d.ts +9 -8
- package/dist/telemetry/attributes.d.ts.map +1 -1
- package/dist/telemetry/attributes.js +6 -5
- package/dist/telemetry/attributes.js.map +1 -1
- package/dist/telemetry/metrics.d.ts +2 -2
- package/dist/telemetry/metrics.d.ts.map +1 -1
- package/dist/telemetry/metrics.js +5 -5
- package/dist/telemetry/metrics.js.map +1 -1
- package/dist/telemetry/runtime-accessors.js +1 -1
- package/dist/telemetry/runtime-accessors.js.map +1 -1
- package/dist/test-support/ids.d.ts +4 -4
- package/dist/test-support/ids.d.ts.map +1 -1
- package/dist/test-support/ids.js +3 -3
- package/dist/test-support/ids.js.map +1 -1
- package/dist/testing.d.ts +4 -6
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +3 -5
- package/dist/testing.js.map +1 -1
- package/dist/tools/advisory/index.js +1 -1
- package/dist/tools/advisory/index.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts +6 -0
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +37 -5
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/content-fingerprint.d.ts +2 -2
- package/dist/tools/builtins/content-fingerprint.js +2 -2
- package/dist/tools/builtins/edit-apply.js +1 -1
- package/dist/tools/builtins/edit-apply.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +3 -0
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/glob.d.ts.map +1 -1
- package/dist/tools/builtins/glob.js +3 -0
- package/dist/tools/builtins/glob.js.map +1 -1
- package/dist/tools/builtins/grep.d.ts.map +1 -1
- package/dist/tools/builtins/grep.js +3 -0
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/job.js +5 -5
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/ls.d.ts +1 -1
- package/dist/tools/builtins/ls.d.ts.map +1 -1
- package/dist/tools/builtins/ls.js +3 -0
- package/dist/tools/builtins/ls.js.map +1 -1
- package/dist/tools/builtins/lsp.d.ts +1 -1
- package/dist/tools/builtins/lsp.d.ts.map +1 -1
- package/dist/tools/builtins/lsp.js +5 -2
- package/dist/tools/builtins/lsp.js.map +1 -1
- package/dist/tools/builtins/read-file.d.ts.map +1 -1
- package/dist/tools/builtins/read-file.js +3 -0
- package/dist/tools/builtins/read-file.js.map +1 -1
- package/dist/tools/builtins/run-code.js +9 -9
- package/dist/tools/builtins/run-code.js.map +1 -1
- package/dist/tools/builtins/skill.js +3 -3
- package/dist/tools/builtins/skill.js.map +1 -1
- package/dist/tools/builtins/wait-for-job-bounds.d.ts +4 -4
- package/dist/tools/builtins/wait-for-job-bounds.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job-bounds.js +2 -2
- package/dist/tools/builtins/wait-for-job-bounds.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +3 -3
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/tools/builtins/web-guidance.d.ts +2 -2
- package/dist/tools/builtins/web-guidance.js +2 -2
- package/dist/tools/builtins/web.js +3 -3
- package/dist/tools/builtins/web.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +3 -0
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/coordinator/agent.d.ts +1 -1
- package/dist/tools/coordinator/agent.js +7 -7
- package/dist/tools/coordinator/agent.js.map +1 -1
- package/dist/tools/coordinator/ask-user-question.d.ts +10 -9
- package/dist/tools/coordinator/ask-user-question.d.ts.map +1 -1
- package/dist/tools/coordinator/ask-user-question.js +9 -8
- package/dist/tools/coordinator/ask-user-question.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts +17 -11
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +45 -44
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/coordinator/outcome.d.ts +5 -5
- package/dist/tools/coordinator/outcome.js +7 -7
- package/dist/tools/coordinator/outcome.js.map +1 -1
- package/dist/tools/coordinator/plan-dependencies.js +1 -1
- package/dist/tools/coordinator/plan-dependencies.js.map +1 -1
- package/dist/tools/coordinator/wait-with-idle-bound.d.ts +4 -4
- package/dist/tools/coordinator/wait-with-idle-bound.d.ts.map +1 -1
- package/dist/tools/coordinator/wait-with-idle-bound.js +2 -2
- package/dist/tools/coordinator/wait-with-idle-bound.js.map +1 -1
- package/dist/tools/defineTool.d.ts +5 -1
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +4 -0
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/env-scrub.d.ts +1 -1
- package/dist/tools/env-scrub.js +1 -1
- package/dist/tools/goal/index.d.ts +10 -6
- package/dist/tools/goal/index.d.ts.map +1 -1
- package/dist/tools/goal/index.js +9 -9
- package/dist/tools/goal/index.js.map +1 -1
- package/dist/tools/memory/fields.d.ts +8 -0
- package/dist/tools/memory/fields.d.ts.map +1 -0
- package/dist/tools/memory/fields.js +22 -0
- package/dist/tools/memory/fields.js.map +1 -0
- package/dist/tools/memory/read.d.ts.map +1 -1
- package/dist/tools/memory/read.js +60 -7
- package/dist/tools/memory/read.js.map +1 -1
- package/dist/tools/memory/resolve.d.ts +21 -0
- package/dist/tools/memory/resolve.d.ts.map +1 -0
- package/dist/tools/memory/resolve.js +23 -0
- package/dist/tools/memory/resolve.js.map +1 -0
- package/dist/tools/memory/save.d.ts.map +1 -1
- package/dist/tools/memory/save.js +57 -18
- package/dist/tools/memory/save.js.map +1 -1
- package/dist/tools/memory/search.d.ts.map +1 -1
- package/dist/tools/memory/search.js +9 -2
- package/dist/tools/memory/search.js.map +1 -1
- package/dist/tools/memory/update.d.ts.map +1 -1
- package/dist/tools/memory/update.js +45 -7
- package/dist/tools/memory/update.js.map +1 -1
- package/dist/tools/paths.d.ts +29 -3
- package/dist/tools/paths.d.ts.map +1 -1
- package/dist/tools/paths.js +81 -23
- package/dist/tools/paths.js.map +1 -1
- package/dist/tools/posix-path.js +1 -1
- package/dist/tools/posix-path.js.map +1 -1
- package/dist/tools/resident-history.d.ts +1 -1
- package/dist/tools/resident-history.js +1 -1
- package/dist/tools/resident-tool-evidence.d.ts +1 -1
- package/dist/tools/resident-tool-evidence.d.ts.map +1 -1
- package/dist/tools/resident-tool-evidence.js +1 -1
- package/dist/tools/resident-tool-evidence.js.map +1 -1
- package/dist/tools/task/create.d.ts +2 -2
- package/dist/tools/task/create.d.ts.map +1 -1
- package/dist/tools/task/create.js +7 -3
- package/dist/tools/task/create.js.map +1 -1
- package/dist/tools/task/index.d.ts +16 -2
- package/dist/tools/task/index.d.ts.map +1 -1
- package/dist/tools/task/index.js +4 -3
- package/dist/tools/task/index.js.map +1 -1
- package/dist/tools/task/list.d.ts +4 -2
- package/dist/tools/task/list.d.ts.map +1 -1
- package/dist/tools/task/list.js +12 -5
- package/dist/tools/task/list.js.map +1 -1
- package/dist/tools/task/present.d.ts +18 -0
- package/dist/tools/task/present.d.ts.map +1 -0
- package/dist/tools/task/present.js +88 -0
- package/dist/tools/task/present.js.map +1 -0
- package/dist/tools/task/update.d.ts.map +1 -1
- package/dist/tools/task/update.js +9 -1
- package/dist/tools/task/update.js.map +1 -1
- package/dist/turn/LimitChecker.d.ts +30 -0
- package/dist/turn/LimitChecker.d.ts.map +1 -0
- package/dist/turn/LimitChecker.js +57 -0
- package/dist/turn/LimitChecker.js.map +1 -0
- package/dist/turn/command-gate.d.ts +107 -0
- package/dist/turn/command-gate.d.ts.map +1 -0
- package/dist/turn/command-gate.js +221 -0
- package/dist/turn/command-gate.js.map +1 -0
- package/dist/turn/drain.d.ts +138 -0
- package/dist/turn/drain.d.ts.map +1 -0
- package/dist/turn/drain.js +209 -0
- package/dist/turn/drain.js.map +1 -0
- package/dist/turn/evidence-query.d.ts +41 -0
- package/dist/turn/evidence-query.d.ts.map +1 -0
- package/dist/turn/evidence-query.js +270 -0
- package/dist/turn/evidence-query.js.map +1 -0
- package/dist/turn/evidence-recall.d.ts +102 -0
- package/dist/turn/evidence-recall.d.ts.map +1 -0
- package/dist/turn/evidence-recall.js +635 -0
- package/dist/turn/evidence-recall.js.map +1 -0
- package/dist/turn/index.d.ts +17 -0
- package/dist/turn/index.d.ts.map +1 -0
- package/dist/turn/index.js +9 -0
- package/dist/turn/index.js.map +1 -0
- package/dist/turn/json-claim-verifier.d.ts +83 -0
- package/dist/turn/json-claim-verifier.d.ts.map +1 -0
- package/dist/turn/json-claim-verifier.js +200 -0
- package/dist/turn/json-claim-verifier.js.map +1 -0
- package/dist/turn/memory-promoter.d.ts +43 -0
- package/dist/turn/memory-promoter.d.ts.map +1 -0
- package/dist/turn/memory-promoter.js +111 -0
- package/dist/turn/memory-promoter.js.map +1 -0
- package/dist/turn/memory-recall.d.ts +33 -0
- package/dist/turn/memory-recall.d.ts.map +1 -0
- package/dist/turn/memory-recall.js +248 -0
- package/dist/turn/memory-recall.js.map +1 -0
- package/dist/turn/preparation-context-error.d.ts.map +1 -0
- package/dist/turn/preparation-context-error.js.map +1 -0
- package/dist/turn/reporter.d.ts +8 -0
- package/dist/turn/reporter.d.ts.map +1 -0
- package/dist/turn/reporter.js +420 -0
- package/dist/turn/reporter.js.map +1 -0
- package/dist/turn/workspace-fingerprint.d.ts.map +1 -0
- package/dist/turn/workspace-fingerprint.js.map +1 -0
- package/dist/types/activity/index.d.ts +2 -2
- package/dist/types/activity/index.d.ts.map +1 -1
- package/dist/types/advisory/config.d.ts +7 -7
- package/dist/types/advisory/config.d.ts.map +1 -1
- package/dist/types/agent/base.d.ts +71 -44
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/core.d.ts +10 -10
- package/dist/types/agent/core.d.ts.map +1 -1
- package/dist/types/agent/delegate.d.ts +2 -2
- package/dist/types/agent/factory.d.ts +6 -4
- package/dist/types/agent/factory.d.ts.map +1 -1
- package/dist/types/agent/manager.d.ts +6 -6
- package/dist/types/agent/manager.d.ts.map +1 -1
- package/dist/types/agent/pipeline.d.ts +5 -4
- package/dist/types/agent/pipeline.d.ts.map +1 -1
- package/dist/types/agent/reactive.d.ts +11 -10
- package/dist/types/agent/reactive.d.ts.map +1 -1
- package/dist/types/agent/router.d.ts +1 -1
- package/dist/types/agent/scheduler.d.ts +27 -11
- package/dist/types/agent/scheduler.d.ts.map +1 -1
- package/dist/types/agent/supervisor.d.ts +13 -13
- package/dist/types/agent/task.d.ts +48 -12
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/agent/working-memory.d.ts +5 -4
- package/dist/types/agent/working-memory.d.ts.map +1 -1
- package/dist/types/authorization/index.d.ts +6 -6
- package/dist/types/bidi/index.d.ts +21 -12
- package/dist/types/bidi/index.d.ts.map +1 -1
- package/dist/types/bus/index.d.ts +34 -28
- package/dist/types/bus/index.d.ts.map +1 -1
- package/dist/types/code-navigation/index.d.ts +1 -1
- package/dist/types/common/index.d.ts +10 -18
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/index.js +3 -2
- package/dist/types/common/index.js.map +1 -1
- package/dist/types/connector/core.d.ts +2 -2
- package/dist/types/connector/definition.d.ts +1 -1
- package/dist/types/connector/mcp.d.ts +1 -1
- package/dist/types/errors/catalog.js +4 -4
- package/dist/types/errors/catalog.js.map +1 -1
- package/dist/types/errors/index.d.ts +5 -5
- package/dist/types/errors/index.d.ts.map +1 -1
- package/dist/types/guardrail/index.d.ts +12 -10
- package/dist/types/guardrail/index.d.ts.map +1 -1
- package/dist/types/hitl/index.d.ts +60 -117
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/hitl/policy.d.ts +8 -6
- package/dist/types/hitl/policy.d.ts.map +1 -1
- package/dist/types/ids/brand.d.ts +10 -3
- package/dist/types/ids/brand.d.ts.map +1 -1
- package/dist/types/ids/brand.js.map +1 -1
- package/dist/types/ids/index.d.ts +10 -4
- package/dist/types/ids/index.d.ts.map +1 -1
- package/dist/types/ids/index.js.map +1 -1
- package/dist/types/memory/index.d.ts +35 -0
- package/dist/types/memory/index.d.ts.map +1 -1
- package/dist/types/memory/index.js +17 -0
- package/dist/types/memory/index.js.map +1 -1
- package/dist/types/message/index.d.ts +4 -4
- package/dist/types/plan/index.d.ts +5 -3
- package/dist/types/plan/index.d.ts.map +1 -1
- package/dist/types/plugin/index.d.ts +27 -19
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +16 -3
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/probe/event-kind.d.ts +3 -3
- package/dist/types/probe/event-kind.d.ts.map +1 -1
- package/dist/types/probe/registry.d.ts +3 -2
- package/dist/types/probe/registry.d.ts.map +1 -1
- package/dist/types/project/entity.d.ts +3 -3
- package/dist/types/provider/config.d.ts +3 -3
- package/dist/types/provider/error.d.ts +1 -1
- package/dist/types/provider/errors.d.ts +2 -2
- package/dist/types/provider/errors.js +2 -2
- package/dist/types/provider/errors.js.map +1 -1
- package/dist/types/provider/interface.d.ts +5 -5
- package/dist/types/router/task-router.d.ts +1 -1
- package/dist/types/sandbox/index.d.ts +14 -14
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js +4 -4
- package/dist/types/session/answer-review.d.ts +80 -0
- package/dist/types/session/answer-review.d.ts.map +1 -0
- package/dist/types/session/answer-review.js.map +1 -0
- package/dist/types/session/audit.d.ts +153 -0
- package/dist/types/session/audit.d.ts.map +1 -0
- package/dist/types/session/audit.js +35 -0
- package/dist/types/session/audit.js.map +1 -0
- package/dist/types/session/cancel-cause.d.ts +49 -0
- package/dist/types/session/cancel-cause.d.ts.map +1 -0
- package/dist/types/session/cancel-cause.js +39 -0
- package/dist/types/session/cancel-cause.js.map +1 -0
- package/dist/types/session/checkpoint.d.ts +325 -0
- package/dist/types/session/checkpoint.d.ts.map +1 -0
- package/dist/types/session/checkpoint.js +100 -0
- package/dist/types/session/checkpoint.js.map +1 -0
- package/dist/types/session/config.d.ts +199 -0
- package/dist/types/session/config.d.ts.map +1 -0
- package/dist/types/session/config.js.map +1 -0
- package/dist/types/session/derive-status.d.ts +28 -0
- package/dist/types/session/derive-status.d.ts.map +1 -0
- package/dist/types/session/derive-status.js +49 -0
- package/dist/types/session/derive-status.js.map +1 -0
- package/dist/types/session/durable.d.ts +142 -0
- package/dist/types/session/durable.d.ts.map +1 -0
- package/dist/types/session/durable.js +11 -0
- package/dist/types/session/durable.js.map +1 -0
- package/dist/types/session/entity.d.ts +1 -1
- package/dist/types/session/events.d.ts +1147 -0
- package/dist/types/session/events.d.ts.map +1 -0
- package/dist/types/session/events.js +15 -0
- package/dist/types/session/events.js.map +1 -0
- package/dist/types/session/fork.d.ts +45 -0
- package/dist/types/session/fork.d.ts.map +1 -0
- package/dist/types/session/fork.js +15 -0
- package/dist/types/session/fork.js.map +1 -0
- package/dist/types/session/ids.d.ts +1 -1
- package/dist/types/session/ids.d.ts.map +1 -1
- package/dist/types/session/index.d.ts +20 -1
- package/dist/types/session/index.d.ts.map +1 -1
- package/dist/types/session/index.js +22 -4
- package/dist/types/session/index.js.map +1 -1
- package/dist/types/session/lineage.d.ts +15 -0
- package/dist/types/session/lineage.d.ts.map +1 -0
- package/dist/types/session/lineage.js.map +1 -0
- package/dist/types/session/log-cursor.d.ts +57 -0
- package/dist/types/session/log-cursor.d.ts.map +1 -0
- package/dist/types/session/log-cursor.js +34 -0
- package/dist/types/session/log-cursor.js.map +1 -0
- package/dist/types/session/memory-promotion.d.ts +91 -0
- package/dist/types/session/memory-promotion.d.ts.map +1 -0
- package/dist/types/session/memory-promotion.js +39 -0
- package/dist/types/session/memory-promotion.js.map +1 -0
- package/dist/types/session/messages.d.ts +1 -1
- package/dist/types/session/messages.js +1 -1
- package/dist/types/session/prepare-step.d.ts +278 -0
- package/dist/types/session/prepare-step.d.ts.map +1 -0
- package/dist/types/session/prepare-step.js.map +1 -0
- package/dist/types/session/records.d.ts +5597 -0
- package/dist/types/session/records.d.ts.map +1 -0
- package/dist/types/session/records.js +721 -0
- package/dist/types/session/records.js.map +1 -0
- package/dist/types/session/step.d.ts +195 -0
- package/dist/types/session/step.d.ts.map +1 -0
- package/dist/types/session/step.js +26 -0
- package/dist/types/session/step.js.map +1 -0
- package/dist/types/session/stop-reason.d.ts +67 -0
- package/dist/types/session/stop-reason.d.ts.map +1 -0
- package/dist/types/session/stop-reason.js.map +1 -0
- package/dist/types/session/store.d.ts +2 -43
- package/dist/types/session/store.d.ts.map +1 -1
- package/dist/types/session/tool-execution.d.ts +34 -0
- package/dist/types/session/tool-execution.d.ts.map +1 -0
- package/dist/types/session/tool-execution.js +11 -0
- package/dist/types/session/tool-execution.js.map +1 -0
- package/dist/types/session/turn-state.d.ts +74 -0
- package/dist/types/session/turn-state.d.ts.map +1 -0
- package/dist/types/session/turn-state.js +59 -0
- package/dist/types/session/turn-state.js.map +1 -0
- package/dist/types/session/turn.d.ts +215 -0
- package/dist/types/session/turn.d.ts.map +1 -0
- package/dist/types/session/turn.js +44 -0
- package/dist/types/session/turn.js.map +1 -0
- package/dist/types/structured-output/index.d.ts +2 -2
- package/dist/types/structured-output/index.d.ts.map +1 -1
- package/dist/types/summary/deliverable.d.ts +4 -4
- package/dist/types/summary/deliverable.d.ts.map +1 -1
- package/dist/types/task/index.d.ts +8 -4
- package/dist/types/task/index.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +73 -26
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/topic/entity.d.ts +6 -6
- package/dist/types/topic/objective.d.ts +10 -5
- package/dist/types/topic/objective.d.ts.map +1 -1
- package/dist/types/topic/objective.js.map +1 -1
- package/dist/types/topic/state.d.ts +4 -4
- package/dist/types/topic/store.d.ts +1 -1
- package/dist/types/topic/store.js +1 -1
- package/dist/types/workspace/index.d.ts +1 -1
- package/dist/types/workspace/index.d.ts.map +1 -1
- package/dist/types/workspace/index.js +1 -1
- package/dist/types/workspace/index.js.map +1 -1
- package/dist/types/workspace/ref.d.ts +3 -3
- package/dist/types/workspace/shared-session.d.ts +61 -0
- package/dist/types/workspace/shared-session.d.ts.map +1 -0
- package/dist/types/workspace/shared-session.js +2 -0
- package/dist/types/workspace/shared-session.js.map +1 -0
- package/dist/utils/abort.js +4 -4
- package/dist/utils/abort.js.map +1 -1
- package/dist/utils/atomic-write.d.ts +29 -1
- package/dist/utils/atomic-write.d.ts.map +1 -1
- package/dist/utils/atomic-write.js +60 -4
- package/dist/utils/atomic-write.js.map +1 -1
- package/dist/utils/cost.d.ts +3 -3
- package/dist/utils/cost.d.ts.map +1 -1
- package/dist/utils/cost.js +11 -12
- package/dist/utils/cost.js.map +1 -1
- package/dist/utils/env.d.ts +1 -1
- package/dist/utils/env.js +1 -1
- package/dist/utils/id.d.ts +9 -8
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/id.js +20 -13
- package/dist/utils/id.js.map +1 -1
- package/dist/utils/log/create-logger.js +1 -1
- package/dist/utils/log/create-logger.js.map +1 -1
- package/dist/utils/log/redact.js +1 -1
- package/dist/utils/log/redact.js.map +1 -1
- package/dist/utils/log/sinks.d.ts +1 -1
- package/dist/utils/log/sinks.js +2 -2
- package/dist/utils/log/sinks.js.map +1 -1
- package/dist/utils/log/types.js +1 -1
- package/dist/utils/log/types.js.map +1 -1
- package/dist/utils/shell-compress.js +2 -2
- package/dist/utils/shell-compress.js.map +1 -1
- package/dist/utils/uuidv7.d.ts +33 -0
- package/dist/utils/uuidv7.d.ts.map +1 -0
- package/dist/utils/uuidv7.js +70 -0
- package/dist/utils/uuidv7.js.map +1 -0
- package/dist/vault/instrumentation.d.ts +5 -2
- package/dist/vault/instrumentation.d.ts.map +1 -1
- package/dist/vault/instrumentation.js +12 -6
- package/dist/vault/instrumentation.js.map +1 -1
- package/package.json +1 -1
- package/src/advisory/budget.ts +3 -3
- package/src/advisory/context.ts +9 -9
- package/src/advisory/evaluator.ts +2 -2
- package/src/advisory/parse.ts +1 -1
- package/src/agents/AbstractAgent.ts +74 -50
- package/src/agents/PipelineAgent.ts +91 -26
- package/src/agents/ReactiveAgent.ts +35 -29
- package/src/agents/RouterAgent.ts +32 -44
- package/src/agents/SupervisorAgent.ts +55 -41
- package/src/agents/budget.ts +73 -16
- package/src/agents/defineAgent.ts +7 -3
- package/src/agents/handle.ts +17 -19
- package/src/agents/lock.ts +4 -4
- package/src/agents/runAgent.ts +96 -38
- package/src/agents/storage.ts +36 -0
- package/src/authorization/command-line.ts +1 -1
- package/src/authorization/gate.ts +1 -1
- package/src/authorization/permission-presets.ts +4 -4
- package/src/bridge/a2a/client.ts +2 -2
- package/src/bridge/a2a/context.ts +46 -0
- package/src/bridge/a2a/index.ts +12 -5
- package/src/bridge/a2a/mapper.ts +48 -38
- package/src/bridge/a2a/task.ts +91 -37
- package/src/bridge/acp/permission.ts +2 -2
- package/src/bridge/acp/server.ts +45 -11
- package/src/bridge/acp/update.ts +9 -9
- package/src/bridge/external-session.ts +82 -0
- package/src/bridge/sse/index.ts +1 -1
- package/src/bridge/sse/mapper.ts +117 -145
- package/src/bus/breaker.ts +30 -29
- package/src/bus/index.ts +7 -7
- package/src/bus/lock.ts +7 -7
- package/src/bus/ownership.ts +8 -8
- package/src/compaction/consolidation.ts +61 -15
- package/src/compaction/context-window.ts +4 -4
- package/src/compaction/index.ts +2 -2
- package/src/compaction/manager.ts +4 -4
- package/src/compaction/manual.ts +5 -5
- package/src/compaction/plan.ts +8 -8
- package/src/compaction/reducer.ts +8 -8
- package/src/compaction/retention.ts +2 -2
- package/src/compaction/salience/bm25.ts +2 -2
- package/src/compaction/salience/goal.ts +3 -3
- package/src/compaction/salience/minhash.ts +1 -1
- package/src/compaction/salience/score.ts +3 -3
- package/src/compaction/salience/tokenize.ts +1 -1
- package/src/compaction/verifier.ts +7 -7
- package/src/compaction/wire.ts +1 -1
- package/src/config/registry.ts +4 -4
- package/src/config/runtime.ts +3 -3
- package/src/connector/http-operation.ts +1 -1
- package/src/connector/mcp/adapter.ts +1 -1
- package/src/connector/mcp/client.ts +1 -1
- package/src/connector/mcp/discovery.ts +2 -2
- package/src/connector/mcp/policy.ts +1 -1
- package/src/connector/mcp/prompt-adapter.ts +3 -3
- package/src/constants/a2a/index.ts +10 -3
- package/src/constants/continuation.ts +1 -1
- package/src/constants/index.ts +0 -1
- package/src/constants/limits.ts +2 -2
- package/src/constants/telemetry/index.ts +15 -12
- package/src/constants/tools/index.ts +2 -2
- package/src/contracts/api.ts +11 -202
- package/src/contracts/index.ts +8 -15
- package/src/contracts/schemas.ts +6 -39
- package/src/contracts/session/api.ts +150 -0
- package/src/contracts/session/index.ts +29 -0
- package/src/contracts/session/schemas.ts +60 -0
- package/src/contracts/session/turn-status.ts +83 -0
- package/src/contracts/session/turn.ts +67 -0
- package/src/directory/derive-supervisor.ts +2 -2
- package/src/directory/derive.ts +4 -4
- package/src/directory/index.ts +2 -2
- package/src/directory/load.ts +2 -2
- package/src/directory/types.ts +2 -2
- package/src/eval/experiment.ts +23 -23
- package/src/eval/from-turn.ts +50 -0
- package/src/eval/harness-verification.ts +7 -7
- package/src/eval/index.ts +2 -2
- package/src/eval/judge.ts +10 -10
- package/src/eval/scorers.ts +23 -23
- package/src/eval/types.ts +12 -12
- package/src/eval/uncertainty.ts +2 -2
- package/src/execution/code-runtime/types.ts +4 -4
- package/src/execution/code-runtime/worker.ts +1 -1
- package/src/invariants/index.ts +2 -2
- package/src/manager/agent/child-session.ts +120 -0
- package/src/manager/agent/lifecycle.ts +422 -102
- package/src/manager/index.ts +1 -2
- package/src/manager/plan/lifecycle.ts +16 -10
- package/src/manager/resident/consumption.ts +8 -6
- package/src/manager/resident/evidence-recall.ts +14 -14
- package/src/manager/resident/host.ts +2 -2
- package/src/manager/resident/learning-cycle.ts +5 -3
- package/src/manager/resident/learning-observation.ts +9 -4
- package/src/manager/resident/learning-store.ts +46 -16
- package/src/manager/resident/tool-evidence.ts +38 -31
- package/src/manager/session/turn-recorder.ts +1291 -0
- package/src/plugin/lifecycle.ts +20 -13
- package/src/plugin/shell-hook.ts +64 -25
- package/src/pricing/index.ts +5 -5
- package/src/pricing/rates.source.json +5 -5
- package/src/probe/context.ts +5 -3
- package/src/probe/registry.ts +1 -1
- package/src/prompt/coding-agent-doctrine.ts +1 -1
- package/src/prompt/contributions.ts +28 -6
- package/src/prompt/resident-learning.ts +2 -2
- package/src/provider/collect-chat-completion.ts +3 -3
- package/src/provider/conformance.ts +8 -5
- package/src/provider/errors.ts +2 -2
- package/src/provider/fallback.ts +8 -8
- package/src/provider/idle-timeout.ts +4 -4
- package/src/provider/instrumentation.ts +14 -7
- package/src/provider/mock.ts +1 -1
- package/src/provider/retry.ts +7 -7
- package/src/provider/stream-text.ts +1 -1
- package/src/provider/thinking-support.ts +2 -2
- package/src/provider/token-budget.ts +2 -2
- package/src/public-runtime.ts +213 -141
- package/src/public-tools.ts +14 -7
- package/src/public-types.ts +71 -59
- package/src/rag/embedding.ts +1 -1
- package/src/read-model/index.ts +2 -2
- package/src/read-model/registry.ts +11 -11
- package/src/read-model/session-status.ts +87 -0
- package/src/registry/command/kernel-commands.ts +10 -10
- package/src/registry/tool/dialect.ts +1 -1
- package/src/registry/tool/execute.ts +20 -7
- package/src/registry/tool/portable.ts +1 -1
- package/src/registry/tool/presentation.ts +1 -1
- package/src/registry/tool/schema.ts +1 -1
- package/src/registry/tool/screen.ts +3 -3
- package/src/runtime/bidi/index.ts +2 -2
- package/src/runtime/bidi/session.ts +45 -34
- package/src/runtime/jobs/awaited-jobs.ts +13 -13
- package/src/runtime/jobs/registry.ts +11 -11
- package/src/runtime/query/abandon-turn.ts +110 -0
- package/src/runtime/query/approval-policy.ts +13 -13
- package/src/runtime/query/callback-inference.ts +8 -5
- package/src/runtime/query/cancelled-before-start.ts +96 -79
- package/src/runtime/query/checkpoint.ts +519 -420
- package/src/runtime/query/compact-session.ts +92 -0
- package/src/runtime/query/context.ts +80 -136
- package/src/runtime/query/events.ts +160 -126
- package/src/runtime/query/executor/tool-call-admission.ts +6 -5
- package/src/runtime/query/executor.ts +206 -111
- package/src/runtime/query/file-evidence-seed.ts +2 -2
- package/src/runtime/query/finalize-turn.ts +209 -0
- package/src/runtime/query/fork/list.ts +20 -0
- package/src/runtime/query/fork/mutate.ts +82 -0
- package/src/runtime/query/fork/prepare.ts +92 -0
- package/src/runtime/query/guard.ts +22 -22
- package/src/runtime/query/guardrail-presets.ts +12 -12
- package/src/runtime/query/guardrails.ts +11 -11
- package/src/runtime/query/index.ts +1624 -1533
- package/src/runtime/query/iteration/index.ts +304 -253
- package/src/runtime/query/iteration/outstanding-work.ts +65 -65
- package/src/runtime/query/iteration/phases/advisory.ts +16 -16
- package/src/runtime/query/iteration/phases/checkpoint.ts +26 -10
- package/src/runtime/query/iteration/phases/compaction.ts +74 -72
- package/src/runtime/query/iteration/phases/context.ts +59 -60
- package/src/runtime/query/iteration/phases/plan.ts +9 -6
- package/src/runtime/query/iteration/phases/tool-review.ts +153 -28
- package/src/runtime/query/iteration/phases/working-memory.ts +57 -22
- package/src/runtime/query/iteration/step-context.ts +17 -0
- package/src/runtime/query/iteration/step-shaping.ts +21 -24
- package/src/runtime/query/iteration/stream-turn.ts +36 -32
- package/src/runtime/query/plugin-hooks.ts +1 -1
- package/src/runtime/query/prepare-turn.ts +932 -0
- package/src/runtime/query/project-instructions.ts +5 -4
- package/src/runtime/query/prompt-cache.ts +1 -1
- package/src/runtime/query/prompt.ts +5 -5
- package/src/runtime/query/question-park.ts +7 -7
- package/src/runtime/query/release-turn.ts +157 -0
- package/src/runtime/query/repeat-call.ts +7 -7
- package/src/runtime/query/result.ts +123 -131
- package/src/runtime/query/resume-pending.ts +101 -44
- package/src/runtime/query/resume-session.ts +153 -0
- package/src/runtime/query/review-policy.ts +147 -19
- package/src/runtime/query/sandbox-lifecycle.ts +5 -5
- package/src/runtime/query/session-storage.ts +302 -0
- package/src/runtime/query/steering.ts +17 -4
- package/src/runtime/query/token-budget.ts +59 -93
- package/src/runtime/query/tool-call-budget.ts +14 -14
- package/src/runtime/query/tool-executions.ts +77 -0
- package/src/runtime/query/tool-grants.ts +3 -3
- package/src/runtime/query/tool-output-budget.ts +4 -4
- package/src/runtime/query/tool-pause.ts +8 -6
- package/src/runtime/query/tooling.ts +22 -14
- package/src/runtime/query/turn-state.ts +153 -0
- package/src/sandbox/isolation.ts +2 -2
- package/src/sandbox/provider/local.ts +8 -8
- package/src/scheduler/completion-inbox.ts +36 -36
- package/src/scheduler/delegating.ts +27 -13
- package/src/scheduler/local.ts +49 -21
- package/src/session/events/index.ts +10 -14
- package/src/session/handoff/broadcast.ts +7 -7
- package/src/session/handoff/events.ts +1 -1
- package/src/session/handoff/index.ts +1 -1
- package/src/session/handoff/single.ts +21 -21
- package/src/session/handoff/version.ts +11 -7
- package/src/session/home.ts +66 -0
- package/src/session/index.ts +1 -0
- package/src/session/log-hash.ts +115 -0
- package/src/session/messages.ts +39 -0
- package/src/session/paths.ts +449 -0
- package/src/session/retention/archive.ts +13 -5
- package/src/session/status/derive.ts +21 -21
- package/src/session/workspace/git-worktree.ts +31 -2
- package/src/session/workspace/index.ts +5 -8
- package/src/session/workspace/shared-session.ts +354 -0
- package/src/session-query/index.ts +152 -0
- package/src/skills/registry.ts +1 -1
- package/src/store/activity/memory.ts +5 -5
- package/src/store/attachment/index.ts +5 -5
- package/src/store/budget/disk.ts +243 -0
- package/src/store/budget/index.ts +24 -0
- package/src/store/budget/ledger.ts +836 -0
- package/src/store/budget/memory.ts +39 -0
- package/src/store/checkpoint/contract.ts +225 -0
- package/src/store/checkpoint/disk.ts +209 -0
- package/src/store/checkpoint/index.ts +22 -0
- package/src/store/checkpoint/memory.ts +112 -0
- package/src/store/checkpoint/prune.ts +93 -0
- package/src/store/config/index.ts +1 -1
- package/src/store/evidence/disk.ts +185 -81
- package/src/store/evidence/index-page.ts +67 -140
- package/src/store/evidence/source-text.ts +23 -28
- package/src/store/evidence/types.ts +51 -41
- package/src/store/feedback/conformance.ts +37 -35
- package/src/store/feedback/disk.ts +61 -63
- package/src/store/feedback/index.ts +1 -1
- package/src/store/feedback/memory.ts +0 -0
- package/src/store/feedback/types.ts +14 -13
- package/src/store/index.ts +24 -28
- package/src/store/memory/digest.ts +35 -0
- package/src/store/memory/disk.ts +66 -20
- package/src/store/memory/index-file.ts +121 -0
- package/src/store/memory/index.ts +4 -2
- package/src/store/memory/links.ts +37 -0
- package/src/store/memory/markdown-format.ts +276 -0
- package/src/store/memory/markdown.ts +741 -0
- package/src/store/memory/memory.ts +39 -17
- package/src/store/memory/naming.ts +195 -0
- package/src/store/memory/origin.ts +35 -0
- package/src/store/session/disk.ts +27 -200
- package/src/store/session/index.ts +5 -9
- package/src/store/session/memory.ts +1 -78
- package/src/store/session-claim.ts +101 -0
- package/src/store/session-index/fts.ts +215 -0
- package/src/store/session-index/index.ts +253 -0
- package/src/store/session-index/rebuild.ts +869 -0
- package/src/store/session-index/refs.ts +164 -0
- package/src/store/session-index/scan.ts +273 -0
- package/src/store/session-index/sqlite.ts +772 -0
- package/src/store/session-log/chain.ts +314 -0
- package/src/store/session-log/conformance.ts +487 -0
- package/src/store/session-log/core.ts +809 -0
- package/src/store/session-log/disk.ts +217 -0
- package/src/store/session-log/fold.ts +368 -0
- package/src/store/session-log/heal.ts +44 -0
- package/src/store/session-log/held-leases.ts +103 -0
- package/src/store/session-log/index.ts +87 -0
- package/src/store/session-log/lease.ts +354 -0
- package/src/store/session-log/memory.ts +111 -0
- package/src/store/session-log/spill.ts +311 -0
- package/src/store/task/context.ts +33 -0
- package/src/store/task/disk.ts +122 -141
- package/src/store/task/memory.ts +14 -8
- package/src/store/topic/index.ts +2 -2
- package/src/store/topic/objective.ts +12 -3
- package/src/store/topic/state.ts +1 -1
- package/src/streaming/coalesce.ts +8 -7
- package/src/telemetry/attributes.ts +10 -9
- package/src/telemetry/metrics.ts +6 -6
- package/src/telemetry/runtime-accessors.ts +1 -1
- package/src/test-support/ids.ts +5 -6
- package/src/testing.ts +11 -16
- package/src/tools/advisory/index.ts +1 -1
- package/src/tools/builtins/bash.ts +43 -5
- package/src/tools/builtins/content-fingerprint.ts +2 -2
- package/src/tools/builtins/edit-apply.ts +1 -1
- package/src/tools/builtins/edit.ts +3 -0
- package/src/tools/builtins/glob.ts +3 -0
- package/src/tools/builtins/grep.ts +3 -0
- package/src/tools/builtins/job.ts +5 -5
- package/src/tools/builtins/ls.ts +3 -0
- package/src/tools/builtins/lsp.ts +5 -2
- package/src/tools/builtins/read-file.ts +3 -0
- package/src/tools/builtins/run-code.ts +11 -11
- package/src/tools/builtins/skill.ts +3 -3
- package/src/tools/builtins/wait-for-job-bounds.ts +6 -6
- package/src/tools/builtins/wait-for-job.ts +3 -3
- package/src/tools/builtins/web-guidance.ts +2 -2
- package/src/tools/builtins/web.ts +3 -3
- package/src/tools/builtins/write-file.ts +3 -0
- package/src/tools/coordinator/agent.ts +8 -8
- package/src/tools/coordinator/ask-user-question.ts +16 -14
- package/src/tools/coordinator/index.ts +64 -54
- package/src/tools/coordinator/outcome.ts +7 -7
- package/src/tools/coordinator/plan-dependencies.ts +1 -1
- package/src/tools/coordinator/wait-with-idle-bound.ts +6 -6
- package/src/tools/defineTool.ts +9 -1
- package/src/tools/env-scrub.ts +1 -1
- package/src/tools/goal/index.ts +16 -12
- package/src/tools/memory/fields.ts +26 -0
- package/src/tools/memory/read.ts +75 -8
- package/src/tools/memory/resolve.ts +37 -0
- package/src/tools/memory/save.ts +54 -18
- package/src/tools/memory/search.ts +9 -5
- package/src/tools/memory/update.ts +43 -7
- package/src/tools/paths.ts +87 -27
- package/src/tools/posix-path.ts +1 -1
- package/src/tools/resident-history.ts +1 -1
- package/src/tools/resident-tool-evidence.ts +1 -1
- package/src/tools/task/create.ts +11 -4
- package/src/tools/task/index.ts +20 -4
- package/src/tools/task/list.ts +16 -7
- package/src/tools/task/present.ts +102 -0
- package/src/tools/task/update.ts +9 -1
- package/src/turn/LimitChecker.ts +99 -0
- package/src/turn/command-gate.ts +294 -0
- package/src/turn/drain.ts +324 -0
- package/src/turn/evidence-query.ts +333 -0
- package/src/turn/evidence-recall.ts +860 -0
- package/src/turn/index.ts +38 -0
- package/src/turn/json-claim-verifier.ts +298 -0
- package/src/turn/memory-promoter.ts +160 -0
- package/src/turn/memory-recall.ts +285 -0
- package/src/turn/reporter.ts +469 -0
- package/src/types/activity/index.ts +2 -2
- package/src/types/advisory/config.ts +7 -7
- package/src/types/agent/base.ts +74 -44
- package/src/types/agent/core.ts +10 -10
- package/src/types/agent/delegate.ts +2 -2
- package/src/types/agent/factory.ts +8 -4
- package/src/types/agent/manager.ts +6 -6
- package/src/types/agent/pipeline.ts +5 -4
- package/src/types/agent/reactive.ts +11 -10
- package/src/types/agent/router.ts +1 -1
- package/src/types/agent/scheduler.ts +28 -11
- package/src/types/agent/supervisor.ts +13 -13
- package/src/types/agent/task.ts +53 -12
- package/src/types/agent/working-memory.ts +6 -4
- package/src/types/bidi/index.ts +31 -12
- package/src/types/bus/index.ts +32 -26
- package/src/types/code-navigation/index.ts +1 -1
- package/src/types/common/index.ts +12 -26
- package/src/types/connector/core.ts +2 -2
- package/src/types/connector/definition.ts +1 -1
- package/src/types/connector/mcp.ts +1 -1
- package/src/types/errors/catalog.ts +4 -4
- package/src/types/errors/index.ts +5 -5
- package/src/types/guardrail/index.ts +12 -10
- package/src/types/hitl/index.ts +81 -125
- package/src/types/hitl/policy.ts +8 -6
- package/src/types/ids/brand.ts +10 -2
- package/src/types/ids/index.ts +10 -4
- package/src/types/memory/index.ts +53 -0
- package/src/types/message/index.ts +4 -4
- package/src/types/plan/index.ts +5 -3
- package/src/types/plugin/index.ts +41 -24
- package/src/types/probe/event-kind.ts +3 -3
- package/src/types/probe/registry.ts +3 -2
- package/src/types/project/entity.ts +3 -3
- package/src/types/provider/config.ts +3 -3
- package/src/types/provider/error.ts +1 -1
- package/src/types/provider/errors.ts +3 -3
- package/src/types/provider/interface.ts +5 -5
- package/src/types/router/task-router.ts +1 -1
- package/src/types/sandbox/index.ts +12 -12
- package/src/types/session/answer-review.ts +85 -0
- package/src/types/session/audit.ts +167 -0
- package/src/types/session/cancel-cause.ts +60 -0
- package/src/types/session/checkpoint.ts +167 -0
- package/src/types/session/config.ts +212 -0
- package/src/types/session/derive-status.ts +61 -0
- package/src/types/session/durable.ts +150 -0
- package/src/types/session/entity.ts +1 -1
- package/src/types/session/events.ts +1195 -0
- package/src/types/session/fork.ts +52 -0
- package/src/types/session/ids.ts +1 -1
- package/src/types/session/index.ts +24 -4
- package/src/types/session/lineage.ts +15 -0
- package/src/types/session/log-cursor.ts +69 -0
- package/src/types/session/memory-promotion.ts +116 -0
- package/src/types/session/messages.ts +1 -1
- package/src/types/session/prepare-step.ts +299 -0
- package/src/types/session/records.ts +931 -0
- package/src/types/session/step.ts +214 -0
- package/src/types/session/stop-reason.ts +83 -0
- package/src/types/session/store.ts +5 -52
- package/src/types/session/tool-execution.ts +32 -0
- package/src/types/session/turn-state.ts +136 -0
- package/src/types/session/turn.ts +289 -0
- package/src/types/structured-output/index.ts +4 -4
- package/src/types/summary/deliverable.ts +4 -4
- package/src/types/task/index.ts +8 -4
- package/src/types/tool/index.ts +74 -27
- package/src/types/topic/entity.ts +6 -6
- package/src/types/topic/objective.ts +7 -5
- package/src/types/topic/state.ts +4 -4
- package/src/types/topic/store.ts +1 -1
- package/src/types/workspace/index.ts +8 -8
- package/src/types/workspace/ref.ts +3 -3
- package/src/types/workspace/shared-session.ts +65 -0
- package/src/utils/abort.ts +4 -4
- package/src/utils/atomic-write.ts +67 -4
- package/src/utils/cost.ts +11 -12
- package/src/utils/env.ts +1 -1
- package/src/utils/id.ts +25 -18
- package/src/utils/log/attributes.ts +2 -2
- package/src/utils/log/create-logger.ts +1 -1
- package/src/utils/log/redact.ts +1 -1
- package/src/utils/log/sinks.ts +2 -2
- package/src/utils/log/types.ts +1 -1
- package/src/utils/shell-compress.ts +2 -2
- package/src/utils/uuidv7.ts +107 -0
- package/src/vault/instrumentation.ts +21 -8
- package/dist/constants/emergency.d.ts +0 -4
- package/dist/constants/emergency.d.ts.map +0 -1
- package/dist/constants/emergency.js +0 -4
- package/dist/constants/emergency.js.map +0 -1
- package/dist/contracts/run-status.d.ts +0 -17
- package/dist/contracts/run-status.d.ts.map +0 -1
- package/dist/contracts/run-status.js +0 -41
- package/dist/contracts/run-status.js.map +0 -1
- package/dist/eval/from-run.d.ts +0 -30
- package/dist/eval/from-run.d.ts.map +0 -1
- package/dist/eval/from-run.js +0 -46
- package/dist/eval/from-run.js.map +0 -1
- package/dist/manager/run/emergency.d.ts +0 -19
- package/dist/manager/run/emergency.d.ts.map +0 -1
- package/dist/manager/run/emergency.js +0 -122
- package/dist/manager/run/emergency.js.map +0 -1
- package/dist/manager/run/persistence.d.ts +0 -312
- package/dist/manager/run/persistence.d.ts.map +0 -1
- package/dist/manager/run/persistence.js +0 -656
- package/dist/manager/run/persistence.js.map +0 -1
- package/dist/read-model/run-status.d.ts +0 -43
- package/dist/read-model/run-status.d.ts.map +0 -1
- package/dist/read-model/run-status.js +0 -89
- package/dist/read-model/run-status.js.map +0 -1
- package/dist/run/LimitChecker.d.ts +0 -30
- package/dist/run/LimitChecker.d.ts.map +0 -1
- package/dist/run/LimitChecker.js +0 -57
- package/dist/run/LimitChecker.js.map +0 -1
- package/dist/run/command-gate.d.ts +0 -107
- package/dist/run/command-gate.d.ts.map +0 -1
- package/dist/run/command-gate.js +0 -221
- package/dist/run/command-gate.js.map +0 -1
- package/dist/run/drain.d.ts +0 -204
- package/dist/run/drain.d.ts.map +0 -1
- package/dist/run/drain.js +0 -238
- package/dist/run/drain.js.map +0 -1
- package/dist/run/evidence-query.d.ts +0 -41
- package/dist/run/evidence-query.d.ts.map +0 -1
- package/dist/run/evidence-query.js +0 -270
- package/dist/run/evidence-query.js.map +0 -1
- package/dist/run/evidence-recall.d.ts +0 -99
- package/dist/run/evidence-recall.d.ts.map +0 -1
- package/dist/run/evidence-recall.js +0 -633
- package/dist/run/evidence-recall.js.map +0 -1
- package/dist/run/index.d.ts +0 -19
- package/dist/run/index.d.ts.map +0 -1
- package/dist/run/index.js +0 -11
- package/dist/run/index.js.map +0 -1
- package/dist/run/json-claim-verifier.d.ts +0 -83
- package/dist/run/json-claim-verifier.d.ts.map +0 -1
- package/dist/run/json-claim-verifier.js +0 -200
- package/dist/run/json-claim-verifier.js.map +0 -1
- package/dist/run/memory-promoter.d.ts +0 -38
- package/dist/run/memory-promoter.d.ts.map +0 -1
- package/dist/run/memory-promoter.js +0 -109
- package/dist/run/memory-promoter.js.map +0 -1
- package/dist/run/memory-recall.d.ts +0 -25
- package/dist/run/memory-recall.d.ts.map +0 -1
- package/dist/run/memory-recall.js +0 -228
- package/dist/run/memory-recall.js.map +0 -1
- package/dist/run/preparation-context-error.d.ts.map +0 -1
- package/dist/run/preparation-context-error.js.map +0 -1
- package/dist/run/reporter.d.ts +0 -8
- package/dist/run/reporter.d.ts.map +0 -1
- package/dist/run/reporter.js +0 -420
- package/dist/run/reporter.js.map +0 -1
- package/dist/run/token-budget.d.ts +0 -116
- package/dist/run/token-budget.d.ts.map +0 -1
- package/dist/run/token-budget.js +0 -626
- package/dist/run/token-budget.js.map +0 -1
- package/dist/run/workspace-fingerprint.d.ts.map +0 -1
- package/dist/run/workspace-fingerprint.js.map +0 -1
- package/dist/run-query/index.d.ts +0 -90
- package/dist/run-query/index.d.ts.map +0 -1
- package/dist/run-query/index.js +0 -127
- package/dist/run-query/index.js.map +0 -1
- package/dist/runtime/query/finalize-run.d.ts +0 -55
- package/dist/runtime/query/finalize-run.d.ts.map +0 -1
- package/dist/runtime/query/finalize-run.js +0 -113
- package/dist/runtime/query/finalize-run.js.map +0 -1
- package/dist/runtime/query/prepare-run.d.ts +0 -94
- package/dist/runtime/query/prepare-run.d.ts.map +0 -1
- package/dist/runtime/query/prepare-run.js +0 -589
- package/dist/runtime/query/prepare-run.js.map +0 -1
- package/dist/runtime/query/release-run.d.ts +0 -56
- package/dist/runtime/query/release-run.d.ts.map +0 -1
- package/dist/runtime/query/release-run.js +0 -101
- package/dist/runtime/query/release-run.js.map +0 -1
- package/dist/runtime/query/replay/list.d.ts +0 -40
- package/dist/runtime/query/replay/list.d.ts.map +0 -1
- package/dist/runtime/query/replay/list.js +0 -38
- package/dist/runtime/query/replay/list.js.map +0 -1
- package/dist/runtime/query/replay/mutate.d.ts +0 -17
- package/dist/runtime/query/replay/mutate.d.ts.map +0 -1
- package/dist/runtime/query/replay/mutate.js +0 -69
- package/dist/runtime/query/replay/mutate.js.map +0 -1
- package/dist/runtime/query/replay/prepare.d.ts +0 -66
- package/dist/runtime/query/replay/prepare.d.ts.map +0 -1
- package/dist/runtime/query/replay/prepare.js +0 -81
- package/dist/runtime/query/replay/prepare.js.map +0 -1
- package/dist/runtime/query/resume-run.d.ts +0 -103
- package/dist/runtime/query/resume-run.d.ts.map +0 -1
- package/dist/runtime/query/resume-run.js +0 -105
- package/dist/runtime/query/resume-run.js.map +0 -1
- package/dist/runtime/query/run-state.d.ts +0 -57
- package/dist/runtime/query/run-state.d.ts.map +0 -1
- package/dist/runtime/query/run-state.js +0 -96
- package/dist/runtime/query/run-state.js.map +0 -1
- package/dist/session/workspace/path-builder.d.ts +0 -50
- package/dist/session/workspace/path-builder.d.ts.map +0 -1
- package/dist/session/workspace/path-builder.js +0 -51
- package/dist/session/workspace/path-builder.js.map +0 -1
- package/dist/session/workspace/shared-run.d.ts +0 -112
- package/dist/session/workspace/shared-run.d.ts.map +0 -1
- package/dist/session/workspace/shared-run.js +0 -290
- package/dist/session/workspace/shared-run.js.map +0 -1
- package/dist/store/evidence/compaction-archive.d.ts +0 -109
- package/dist/store/evidence/compaction-archive.d.ts.map +0 -1
- package/dist/store/evidence/compaction-archive.js +0 -125
- package/dist/store/evidence/compaction-archive.js.map +0 -1
- package/dist/store/evidence/linked.d.ts +0 -9
- package/dist/store/evidence/linked.d.ts.map +0 -1
- package/dist/store/evidence/linked.js +0 -314
- package/dist/store/evidence/linked.js.map +0 -1
- package/dist/store/evidence/record-chain.d.ts +0 -42
- package/dist/store/evidence/record-chain.d.ts.map +0 -1
- package/dist/store/evidence/record-chain.js +0 -111
- package/dist/store/evidence/record-chain.js.map +0 -1
- package/dist/store/run/checkpoint-disk.d.ts +0 -98
- package/dist/store/run/checkpoint-disk.d.ts.map +0 -1
- package/dist/store/run/checkpoint-disk.js +0 -190
- package/dist/store/run/checkpoint-disk.js.map +0 -1
- package/dist/store/run/checkpoint-memory.d.ts +0 -51
- package/dist/store/run/checkpoint-memory.d.ts.map +0 -1
- package/dist/store/run/checkpoint-memory.js +0 -178
- package/dist/store/run/checkpoint-memory.js.map +0 -1
- package/dist/store/run/claim-disk.d.ts +0 -130
- package/dist/store/run/claim-disk.d.ts.map +0 -1
- package/dist/store/run/claim-disk.js +0 -570
- package/dist/store/run/claim-disk.js.map +0 -1
- package/dist/store/run/conformance.d.ts +0 -159
- package/dist/store/run/conformance.d.ts.map +0 -1
- package/dist/store/run/conformance.js +0 -466
- package/dist/store/run/conformance.js.map +0 -1
- package/dist/store/run/disk.d.ts +0 -189
- package/dist/store/run/disk.d.ts.map +0 -1
- package/dist/store/run/disk.js +0 -804
- package/dist/store/run/disk.js.map +0 -1
- package/dist/store/run/listing.d.ts +0 -118
- package/dist/store/run/listing.d.ts.map +0 -1
- package/dist/store/run/listing.js +0 -333
- package/dist/store/run/listing.js.map +0 -1
- package/dist/store/run/memory.d.ts +0 -55
- package/dist/store/run/memory.d.ts.map +0 -1
- package/dist/store/run/memory.js +0 -176
- package/dist/store/run/memory.js.map +0 -1
- package/dist/store/run/token-budget-disk.d.ts +0 -37
- package/dist/store/run/token-budget-disk.d.ts.map +0 -1
- package/dist/store/run/token-budget-disk.js +0 -211
- package/dist/store/run/token-budget-disk.js.map +0 -1
- package/dist/store/run/tool-executions.d.ts +0 -13
- package/dist/store/run/tool-executions.d.ts.map +0 -1
- package/dist/store/run/tool-executions.js +0 -99
- package/dist/store/run/tool-executions.js.map +0 -1
- package/dist/store/session/sqlite.d.ts +0 -57
- package/dist/store/session/sqlite.d.ts.map +0 -1
- package/dist/store/session/sqlite.js +0 -430
- package/dist/store/session/sqlite.js.map +0 -1
- package/dist/types/run/answer-review.d.ts +0 -79
- package/dist/types/run/answer-review.d.ts.map +0 -1
- package/dist/types/run/answer-review.js.map +0 -1
- package/dist/types/run/audit.d.ts +0 -150
- package/dist/types/run/audit.d.ts.map +0 -1
- package/dist/types/run/audit.js +0 -39
- package/dist/types/run/audit.js.map +0 -1
- package/dist/types/run/cancel-cause.d.ts +0 -49
- package/dist/types/run/cancel-cause.d.ts.map +0 -1
- package/dist/types/run/cancel-cause.js +0 -39
- package/dist/types/run/cancel-cause.js.map +0 -1
- package/dist/types/run/checkpoint-store.d.ts +0 -511
- package/dist/types/run/checkpoint-store.d.ts.map +0 -1
- package/dist/types/run/checkpoint-store.js +0 -12
- package/dist/types/run/checkpoint-store.js.map +0 -1
- package/dist/types/run/config.d.ts +0 -207
- package/dist/types/run/config.d.ts.map +0 -1
- package/dist/types/run/config.js.map +0 -1
- package/dist/types/run/derive-status.d.ts +0 -29
- package/dist/types/run/derive-status.d.ts.map +0 -1
- package/dist/types/run/derive-status.js +0 -49
- package/dist/types/run/derive-status.js.map +0 -1
- package/dist/types/run/emergency.d.ts +0 -32
- package/dist/types/run/emergency.d.ts.map +0 -1
- package/dist/types/run/emergency.js +0 -6
- package/dist/types/run/emergency.js.map +0 -1
- package/dist/types/run/entity.d.ts +0 -151
- package/dist/types/run/entity.d.ts.map +0 -1
- package/dist/types/run/entity.js +0 -2
- package/dist/types/run/entity.js.map +0 -1
- package/dist/types/run/event-cursor.d.ts +0 -90
- package/dist/types/run/event-cursor.d.ts.map +0 -1
- package/dist/types/run/event-cursor.js +0 -47
- package/dist/types/run/event-cursor.js.map +0 -1
- package/dist/types/run/events.d.ts +0 -1064
- package/dist/types/run/events.d.ts.map +0 -1
- package/dist/types/run/events.js +0 -31
- package/dist/types/run/events.js.map +0 -1
- package/dist/types/run/index.d.ts +0 -24
- package/dist/types/run/index.d.ts.map +0 -1
- package/dist/types/run/index.js +0 -23
- package/dist/types/run/index.js.map +0 -1
- package/dist/types/run/lineage.d.ts +0 -15
- package/dist/types/run/lineage.d.ts.map +0 -1
- package/dist/types/run/lineage.js.map +0 -1
- package/dist/types/run/memory-promotion.d.ts +0 -90
- package/dist/types/run/memory-promotion.d.ts.map +0 -1
- package/dist/types/run/memory-promotion.js +0 -38
- package/dist/types/run/memory-promotion.js.map +0 -1
- package/dist/types/run/metadata.d.ts +0 -47
- package/dist/types/run/metadata.d.ts.map +0 -1
- package/dist/types/run/metadata.js +0 -2
- package/dist/types/run/metadata.js.map +0 -1
- package/dist/types/run/prepare-step.d.ts +0 -271
- package/dist/types/run/prepare-step.d.ts.map +0 -1
- package/dist/types/run/prepare-step.js.map +0 -1
- package/dist/types/run/replay.d.ts +0 -53
- package/dist/types/run/replay.d.ts.map +0 -1
- package/dist/types/run/replay.js +0 -15
- package/dist/types/run/replay.js.map +0 -1
- package/dist/types/run/schema-version.d.ts +0 -19
- package/dist/types/run/schema-version.d.ts.map +0 -1
- package/dist/types/run/schema-version.js +0 -18
- package/dist/types/run/schema-version.js.map +0 -1
- package/dist/types/run/state.d.ts +0 -109
- package/dist/types/run/state.d.ts.map +0 -1
- package/dist/types/run/state.js +0 -109
- package/dist/types/run/state.js.map +0 -1
- package/dist/types/run/status.d.ts +0 -26
- package/dist/types/run/status.d.ts.map +0 -1
- package/dist/types/run/status.js +0 -2
- package/dist/types/run/status.js.map +0 -1
- package/dist/types/run/step.d.ts +0 -198
- package/dist/types/run/step.d.ts.map +0 -1
- package/dist/types/run/step.js +0 -26
- package/dist/types/run/step.js.map +0 -1
- package/dist/types/run/stop-reason.d.ts +0 -67
- package/dist/types/run/stop-reason.d.ts.map +0 -1
- package/dist/types/run/stop-reason.js.map +0 -1
- package/dist/types/run/store.d.ts +0 -300
- package/dist/types/run/store.d.ts.map +0 -1
- package/dist/types/run/store.js +0 -2
- package/dist/types/run/store.js.map +0 -1
- package/dist/types/run/subsession-events.d.ts +0 -64
- package/dist/types/run/subsession-events.d.ts.map +0 -1
- package/dist/types/run/subsession-events.js +0 -2
- package/dist/types/run/subsession-events.js.map +0 -1
- package/dist/types/run/token-budget-store.d.ts +0 -29
- package/dist/types/run/token-budget-store.d.ts.map +0 -1
- package/dist/types/run/token-budget-store.js +0 -25
- package/dist/types/run/token-budget-store.js.map +0 -1
- package/dist/types/workspace/shared-run.d.ts +0 -61
- package/dist/types/workspace/shared-run.d.ts.map +0 -1
- package/dist/types/workspace/shared-run.js +0 -2
- package/dist/types/workspace/shared-run.js.map +0 -1
- package/src/constants/emergency.ts +0 -3
- package/src/contracts/run-status.ts +0 -43
- package/src/eval/from-run.ts +0 -48
- package/src/manager/run/emergency.ts +0 -148
- package/src/manager/run/persistence.ts +0 -746
- package/src/read-model/run-status.ts +0 -127
- package/src/run/LimitChecker.ts +0 -99
- package/src/run/command-gate.ts +0 -294
- package/src/run/drain.ts +0 -403
- package/src/run/evidence-query.ts +0 -333
- package/src/run/evidence-recall.ts +0 -854
- package/src/run/index.ts +0 -42
- package/src/run/json-claim-verifier.ts +0 -298
- package/src/run/memory-promoter.ts +0 -147
- package/src/run/memory-recall.ts +0 -254
- package/src/run/reporter.ts +0 -469
- package/src/run/token-budget.ts +0 -733
- package/src/run-query/index.ts +0 -177
- package/src/runtime/query/finalize-run.ts +0 -192
- package/src/runtime/query/prepare-run.ts +0 -718
- package/src/runtime/query/release-run.ts +0 -168
- package/src/runtime/query/replay/list.ts +0 -66
- package/src/runtime/query/replay/mutate.ts +0 -82
- package/src/runtime/query/replay/prepare.ts +0 -147
- package/src/runtime/query/resume-run.ts +0 -202
- package/src/runtime/query/run-state.ts +0 -138
- package/src/session/workspace/path-builder.ts +0 -72
- package/src/session/workspace/shared-run.ts +0 -354
- package/src/store/evidence/compaction-archive.ts +0 -139
- package/src/store/evidence/linked.ts +0 -365
- package/src/store/evidence/record-chain.ts +0 -108
- package/src/store/run/checkpoint-disk.ts +0 -264
- package/src/store/run/checkpoint-memory.ts +0 -216
- package/src/store/run/claim-disk.ts +0 -638
- package/src/store/run/conformance.ts +0 -728
- package/src/store/run/disk.ts +0 -911
- package/src/store/run/listing.ts +0 -422
- package/src/store/run/memory.ts +0 -204
- package/src/store/run/token-budget-disk.ts +0 -250
- package/src/store/run/tool-executions.ts +0 -112
- package/src/store/session/sqlite.ts +0 -584
- package/src/types/run/answer-review.ts +0 -84
- package/src/types/run/audit.ts +0 -164
- package/src/types/run/cancel-cause.ts +0 -60
- package/src/types/run/checkpoint-store.ts +0 -545
- package/src/types/run/config.ts +0 -221
- package/src/types/run/derive-status.ts +0 -62
- package/src/types/run/emergency.ts +0 -28
- package/src/types/run/entity.ts +0 -161
- package/src/types/run/event-cursor.ts +0 -118
- package/src/types/run/events.ts +0 -1146
- package/src/types/run/index.ts +0 -32
- package/src/types/run/lineage.ts +0 -15
- package/src/types/run/memory-promotion.ts +0 -112
- package/src/types/run/metadata.ts +0 -51
- package/src/types/run/prepare-step.ts +0 -292
- package/src/types/run/replay.ts +0 -61
- package/src/types/run/schema-version.ts +0 -19
- package/src/types/run/state.ts +0 -206
- package/src/types/run/status.ts +0 -33
- package/src/types/run/step.ts +0 -217
- package/src/types/run/stop-reason.ts +0 -83
- package/src/types/run/store.ts +0 -325
- package/src/types/run/subsession-events.ts +0 -71
- package/src/types/run/token-budget-store.ts +0 -54
- package/src/types/workspace/shared-run.ts +0 -65
- /package/dist/{run → turn}/preparation-context-error.d.ts +0 -0
- /package/dist/{run → turn}/preparation-context-error.js +0 -0
- /package/dist/{run → turn}/workspace-fingerprint.d.ts +0 -0
- /package/dist/{run → turn}/workspace-fingerprint.js +0 -0
- /package/dist/types/{run → session}/answer-review.js +0 -0
- /package/dist/types/{run → session}/config.js +0 -0
- /package/dist/types/{run → session}/lineage.js +0 -0
- /package/dist/types/{run → session}/prepare-step.js +0 -0
- /package/dist/types/{run → session}/stop-reason.js +0 -0
- /package/src/{run → turn}/preparation-context-error.ts +0 -0
- /package/src/{run → turn}/workspace-fingerprint.ts +0 -0
|
@@ -33,14 +33,14 @@ import {
|
|
|
33
33
|
} from '../../../types/message/index.js'
|
|
34
34
|
import { classifyProviderError } from '../../../types/provider/errors.js'
|
|
35
35
|
import type { ChatCompletionResponse } from '../../../types/provider/index.js'
|
|
36
|
-
import type { AnswerReview, AnswerReviewContext } from '../../../types/
|
|
36
|
+
import type { AnswerReview, AnswerReviewContext } from '../../../types/session/answer-review.js'
|
|
37
37
|
import type {
|
|
38
|
-
|
|
38
|
+
SessionEvent,
|
|
39
39
|
StepFailure,
|
|
40
40
|
StepProvenance,
|
|
41
41
|
StepResult,
|
|
42
42
|
StopReason,
|
|
43
|
-
} from '../../../types/
|
|
43
|
+
} from '../../../types/session/index.js'
|
|
44
44
|
import type { LLMToolSchema, ToolRegistryContract } from '../../../types/tool/index.js'
|
|
45
45
|
import { toErrorMessage } from '../../../utils/error.js'
|
|
46
46
|
import { stableDigest } from '../../../utils/hash.js'
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
import type { IterationContext } from './phases/index.js'
|
|
75
75
|
import { runPlanGate } from './phases/plan.js'
|
|
76
76
|
import { runToolReview } from './phases/tool-review.js'
|
|
77
|
-
import { refreshWorkingMemory } from './phases/working-memory.js'
|
|
77
|
+
import { refreshWorkingMemory, splitWorkingMemoryForRequest } from './phases/working-memory.js'
|
|
78
78
|
import { streamWithProviderRejectedImageRecovery } from './provider-rejected-image.js'
|
|
79
79
|
import {
|
|
80
80
|
type StepShaping,
|
|
@@ -105,16 +105,16 @@ export type { PhaseSignal } from './phases/index.js'
|
|
|
105
105
|
export type { ToolReviewOutcome } from './phases/index.js'
|
|
106
106
|
|
|
107
107
|
/**
|
|
108
|
-
* How many times an answer may be handed back before the
|
|
108
|
+
* How many times an answer may be handed back before the turn stops.
|
|
109
109
|
*
|
|
110
110
|
* Bounded for the same reason the structured-output re-prompt is: a judge
|
|
111
111
|
* that never accepts would otherwise spend the whole token budget
|
|
112
|
-
* rediscovering that, and the
|
|
112
|
+
* rediscovering that, and the turn would end on a budget error rather than
|
|
113
113
|
* on the thing that actually went wrong.
|
|
114
114
|
*/
|
|
115
115
|
const DEFAULT_ANSWER_REVIEW_LIMIT = 3
|
|
116
116
|
|
|
117
|
-
// Ending a
|
|
117
|
+
// Ending a turn changes the available actions, not the strength of its evidence.
|
|
118
118
|
// Use the same standard for warning closure and empty-completion recovery.
|
|
119
119
|
const CLOSING_RESPONSE_GUIDANCE =
|
|
120
120
|
'Give a concise response using only what the available evidence supports. Attribute unverified statements to their source instead of presenting them as observed facts. If evidence is missing or conflicting, state what cannot be established. Do not claim unfinished work is complete. Do not request any more tool calls.'
|
|
@@ -136,20 +136,20 @@ export class IterationOrchestrator {
|
|
|
136
136
|
| import('../../../advisory/executor.js').AdvisoryTurnContext
|
|
137
137
|
| undefined {
|
|
138
138
|
const turn = this.advisoryTurn
|
|
139
|
-
if (!turn || turn.iteration !== this.ctx.
|
|
140
|
-
const start = this.ctx.
|
|
139
|
+
if (!turn || turn.iteration !== this.ctx.recorder.currentIteration) return undefined
|
|
140
|
+
const start = this.ctx.recorder.messages.indexOf(turn.response)
|
|
141
141
|
if (start < 0) return undefined
|
|
142
142
|
return {
|
|
143
143
|
iteration: turn.iteration,
|
|
144
144
|
requestMessages: turn.requestMessages,
|
|
145
|
-
subsequentMessages: this.ctx.
|
|
145
|
+
subsequentMessages: this.ctx.recorder.messages.slice(start),
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
/** Rejections so far. See {@link DEFAULT_ANSWER_REVIEW_LIMIT}. */
|
|
149
149
|
private answerReviewAttempts = 0
|
|
150
150
|
/**
|
|
151
|
-
* The last request envelope this
|
|
152
|
-
* costs a hash and no event. Per RUNNER, not module-level: two
|
|
151
|
+
* The last request envelope this turn recorded, so an unchanged one
|
|
152
|
+
* costs a hash and no event. Per RUNNER, not module-level: two turns in
|
|
153
153
|
* one process must not suppress each other's first envelope.
|
|
154
154
|
*/
|
|
155
155
|
private lastEnvelopeKey: string | undefined
|
|
@@ -166,10 +166,10 @@ export class IterationOrchestrator {
|
|
|
166
166
|
/**
|
|
167
167
|
* The previous iteration held a `stopWhen` decision open for a worker.
|
|
168
168
|
*
|
|
169
|
-
* Set when the stop predicate fired and the
|
|
170
|
-
* read a delegated result, so the turn that then ends the
|
|
169
|
+
* Set when the stop predicate fired and the turn took one extra turn to
|
|
170
|
+
* read a delegated result, so the turn that then ends the turn can report
|
|
171
171
|
* WHY it is over. Without it the outcome was right and the record was
|
|
172
|
-
* wrong: the
|
|
172
|
+
* wrong: the turn stopped because the host said so and reported `end_turn`,
|
|
173
173
|
* and this repo carries thirteen `StopReason` values precisely so that a
|
|
174
174
|
* run which ends for a nameable reason names it.
|
|
175
175
|
*
|
|
@@ -266,7 +266,7 @@ export class IterationOrchestrator {
|
|
|
266
266
|
})
|
|
267
267
|
await this.ctx.emitEvent({
|
|
268
268
|
type: 'capability_warning',
|
|
269
|
-
|
|
269
|
+
turnId: this.ctx.recorder.turnId,
|
|
270
270
|
capability,
|
|
271
271
|
contentSource: 'tool-result',
|
|
272
272
|
providerId: this.ctx.provider.id,
|
|
@@ -279,19 +279,19 @@ export class IterationOrchestrator {
|
|
|
279
279
|
}
|
|
280
280
|
|
|
281
281
|
/**
|
|
282
|
-
* Adopt the
|
|
282
|
+
* Adopt the turn's span after construction.
|
|
283
283
|
*
|
|
284
284
|
* The orchestrator is built before `query()` enters its generator body,
|
|
285
|
-
* which is where the
|
|
285
|
+
* which is where the turn span is created — so the parent cannot be a
|
|
286
286
|
* constructor argument without reordering setup around one field.
|
|
287
287
|
*/
|
|
288
288
|
setRootSpan(span: Span): void {
|
|
289
289
|
this.ctx = { ...this.ctx, rootSpan: span }
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
async *runLoop(): AsyncGenerator<
|
|
293
|
-
const {
|
|
294
|
-
const { model } =
|
|
292
|
+
async *runLoop(): AsyncGenerator<SessionEvent> {
|
|
293
|
+
const { turnConfig, recorder } = this.ctx
|
|
294
|
+
const { model } = turnConfig
|
|
295
295
|
const tracer = getTracer()
|
|
296
296
|
// Resume hydration happens after construction, before the loop starts.
|
|
297
297
|
this.latestUserMessage = this.ctx.checkpointMgr.restoredLatestUserMessage
|
|
@@ -299,22 +299,29 @@ export class IterationOrchestrator {
|
|
|
299
299
|
this.structuredReviewAttempts = this.ctx.checkpointMgr.restoredStructuredReviewAttempts ?? 0
|
|
300
300
|
this.nativeStructuredAttempts = this.ctx.checkpointMgr.restoredNativeStructuredAttempts ?? 0
|
|
301
301
|
if (!this.latestUserMessage) {
|
|
302
|
-
for (const message of
|
|
302
|
+
for (const message of recorder.messages) this.rememberUserMessage(message, false)
|
|
303
303
|
}
|
|
304
304
|
// The restored field can outlive the historical message it describes.
|
|
305
305
|
// Only known post-checkpoint arrivals may supersede it, never an old
|
|
306
306
|
// retained user turn encountered while scanning restored history.
|
|
307
307
|
for (const message of this.ctx.resumedInput ?? []) this.rememberUserMessage(message)
|
|
308
308
|
|
|
309
|
-
//
|
|
309
|
+
// What a recoverable failure pauses on when it lands before this
|
|
310
|
+
// loop wrote a checkpoint of its own: without it a 429 on the first
|
|
311
|
+
// request failed the turn, while the same 429 one request later
|
|
312
|
+
// paused it. Taken after the intent above is known, so the
|
|
313
|
+
// checkpoint names the message the turn is answering.
|
|
314
|
+
await this.ctx.checkpointMgr.markLoopStart?.(recorder)
|
|
315
|
+
|
|
316
|
+
// One context-overflow relief per *stuck point*, not per turn.
|
|
310
317
|
//
|
|
311
318
|
// The latch exists so that a second overflow immediately after a
|
|
312
319
|
// successful compaction — meaning the prompt is irreducible — stops
|
|
313
320
|
// instead of looping. It was never meant to disarm the mechanism for
|
|
314
|
-
// the rest of the
|
|
321
|
+
// the rest of the turn, which is what a turn-scoped flag did: one
|
|
315
322
|
// relief at iteration 3 left iteration 40 to die on an overflow with
|
|
316
323
|
// obvious moves left. It is cleared by a turn that actually
|
|
317
|
-
// succeeded, which is the evidence that the
|
|
324
|
+
// succeeded, which is the evidence that the turn is no longer stuck.
|
|
318
325
|
let overflowRelieved = false
|
|
319
326
|
|
|
320
327
|
const planSignal = yield* runPlanGate(this.ctx)
|
|
@@ -324,7 +331,7 @@ export class IterationOrchestrator {
|
|
|
324
331
|
// beside `iterSpan.end()` below: this loop leaves by eight `break`s,
|
|
325
332
|
// two `return`s and a `throw`, and a rule every future edit has to
|
|
326
333
|
// remember is a rule that gets forgotten — measured, it had been. Only
|
|
327
|
-
// the ordinary final-answer exit consulted the inbox, so a
|
|
334
|
+
// the ordinary final-answer exit consulted the inbox, so a turn that
|
|
328
335
|
// ended on a terminal tool, a structured output or the host's
|
|
329
336
|
// `stopWhen` settled over a finished worker's output and threw it away.
|
|
330
337
|
// A `finally` also covers a generator abandoned by its consumer, which
|
|
@@ -332,22 +339,22 @@ export class IterationOrchestrator {
|
|
|
332
339
|
try {
|
|
333
340
|
while (true) {
|
|
334
341
|
if (this.ctx.abortController.signal.aborted) {
|
|
335
|
-
|
|
336
|
-
|
|
342
|
+
recorder.setStopReason('cancelled')
|
|
343
|
+
recorder.markCancelled()
|
|
337
344
|
break
|
|
338
345
|
}
|
|
339
346
|
if (
|
|
340
347
|
this.ctx.structuredOutput?.mode === 'native' &&
|
|
341
348
|
this.nativeStructuredAttempts > this.structuredOutputRetryLimit()
|
|
342
349
|
) {
|
|
343
|
-
|
|
350
|
+
recorder.setStopReason('structured_output_failed')
|
|
344
351
|
break
|
|
345
352
|
}
|
|
346
353
|
if (
|
|
347
354
|
this.ctx.reviewAnswer &&
|
|
348
355
|
this.answerReviewAttempts > (this.ctx.maxAnswerReviews ?? DEFAULT_ANSWER_REVIEW_LIMIT)
|
|
349
356
|
) {
|
|
350
|
-
|
|
357
|
+
recorder.setStopReason('answer_rejected')
|
|
351
358
|
break
|
|
352
359
|
}
|
|
353
360
|
if (
|
|
@@ -355,7 +362,7 @@ export class IterationOrchestrator {
|
|
|
355
362
|
this.structuredReviewAttempts >
|
|
356
363
|
(this.ctx.structuredOutput.maxReviews ?? DEFAULT_ANSWER_REVIEW_LIMIT)
|
|
357
364
|
) {
|
|
358
|
-
|
|
365
|
+
recorder.setStopReason('answer_rejected')
|
|
359
366
|
break
|
|
360
367
|
}
|
|
361
368
|
// Read AND clear, in that order, in this one place.
|
|
@@ -372,30 +379,33 @@ export class IterationOrchestrator {
|
|
|
372
379
|
const stopWasDeferredForOutstandingWork = this.stopDeferredForOutstandingWork
|
|
373
380
|
this.stopDeferredForOutstandingWork = false
|
|
374
381
|
|
|
375
|
-
const guardResult = this.ctx.guard.beforeIteration(
|
|
382
|
+
const guardResult = this.ctx.guard.beforeIteration(
|
|
383
|
+
recorder,
|
|
384
|
+
this.ctx.abortController.signal,
|
|
385
|
+
)
|
|
376
386
|
|
|
377
387
|
if (guardResult.shouldStop) {
|
|
378
388
|
if (guardResult.isCancelled) {
|
|
379
|
-
this.ctx.log.info('
|
|
380
|
-
[NAMZU.
|
|
389
|
+
this.ctx.log.info('Turn cancelled by signal', {
|
|
390
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
381
391
|
})
|
|
382
|
-
|
|
383
|
-
|
|
392
|
+
recorder.setStopReason('cancelled')
|
|
393
|
+
recorder.markCancelled()
|
|
384
394
|
break
|
|
385
395
|
}
|
|
386
396
|
|
|
387
397
|
const stopReason = guardResult.stopReason ?? 'end_turn'
|
|
388
398
|
this.ctx.log.info('Guard enforcing stop', {
|
|
389
|
-
[NAMZU.
|
|
399
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
390
400
|
'namzu.runtime.stop_reason': stopReason,
|
|
391
|
-
[NAMZU.ITERATION]:
|
|
392
|
-
'namzu.runtime.input_tokens':
|
|
393
|
-
'namzu.runtime.output_tokens':
|
|
401
|
+
[NAMZU.ITERATION]: recorder.currentIteration,
|
|
402
|
+
'namzu.runtime.input_tokens': recorder.tokenUsage.promptTokens,
|
|
403
|
+
'namzu.runtime.output_tokens': recorder.tokenUsage.completionTokens,
|
|
394
404
|
})
|
|
395
405
|
// A hard stop has no budget left for another model request.
|
|
396
406
|
// Closing prose is requested at the warning threshold while
|
|
397
407
|
// headroom remains; the completed work is already in history.
|
|
398
|
-
|
|
408
|
+
recorder.setStopReason(stopReason)
|
|
399
409
|
break
|
|
400
410
|
}
|
|
401
411
|
|
|
@@ -404,13 +414,13 @@ export class IterationOrchestrator {
|
|
|
404
414
|
// and so can only speak after the step it disliked has already
|
|
405
415
|
// run and been paid for; this is the seam a host with a live
|
|
406
416
|
// rate limit or a revoked tenant actually needs.
|
|
407
|
-
const veto = await beforeStep(this.stepShaping(),
|
|
408
|
-
// The hook may settle because its
|
|
417
|
+
const veto = await beforeStep(this.stepShaping(), recorder.currentIteration + 1)
|
|
418
|
+
// The hook may settle because its turn signal was aborted. Stop
|
|
409
419
|
// before interpreting that settlement as a policy refusal or
|
|
410
420
|
// counting an iteration that will never reach the provider.
|
|
411
421
|
if (this.ctx.abortController.signal.aborted) {
|
|
412
|
-
|
|
413
|
-
|
|
422
|
+
recorder.setStopReason('cancelled')
|
|
423
|
+
recorder.markCancelled()
|
|
414
424
|
break
|
|
415
425
|
}
|
|
416
426
|
if (veto) {
|
|
@@ -418,23 +428,23 @@ export class IterationOrchestrator {
|
|
|
418
428
|
// the frozen inventory LOG-22 exists to drain; a new call site
|
|
419
429
|
// has no reason to join it.
|
|
420
430
|
this.ctx.log.info('Step refused by beforeStep', {
|
|
421
|
-
[NAMZU.
|
|
422
|
-
[NAMZU.ITERATION]:
|
|
431
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
432
|
+
[NAMZU.ITERATION]: recorder.currentIteration + 1,
|
|
423
433
|
'namzu.step.veto_reason': veto.reason,
|
|
424
434
|
})
|
|
425
|
-
|
|
426
|
-
|
|
435
|
+
recorder.setLastError(`beforeStep refused the next step: ${veto.reason}`)
|
|
436
|
+
recorder.setStopReason('step_refused')
|
|
427
437
|
break
|
|
428
438
|
}
|
|
429
439
|
|
|
430
440
|
const forceFinalize = guardResult.forceFinalize
|
|
431
|
-
const iterationNum =
|
|
441
|
+
const iterationNum = recorder.incrementIteration()
|
|
432
442
|
this.ctx.log.debug('Iteration started', {
|
|
433
|
-
[NAMZU.
|
|
443
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
434
444
|
[NAMZU.ITERATION]: iterationNum,
|
|
435
445
|
[GENAI.REQUEST_MODEL]: model,
|
|
436
446
|
'namzu.runtime.force_finalize': forceFinalize,
|
|
437
|
-
'namzu.runtime.message_count':
|
|
447
|
+
'namzu.runtime.message_count': recorder.messages.length,
|
|
438
448
|
})
|
|
439
449
|
|
|
440
450
|
const iterationActivity = this.ctx.activityStore.create({
|
|
@@ -447,7 +457,7 @@ export class IterationOrchestrator {
|
|
|
447
457
|
|
|
448
458
|
// Parent explicitly: this body is an async generator, so the
|
|
449
459
|
// ambient context at resume time belongs to the CONSUMER, not to
|
|
450
|
-
// whoever created the
|
|
460
|
+
// whoever created the turn span. Without this every iteration
|
|
451
461
|
// emits as its own root and a 20-turn run shows up as 21
|
|
452
462
|
// disconnected traces.
|
|
453
463
|
const iterSpan = tracer.startSpan(
|
|
@@ -472,8 +482,8 @@ export class IterationOrchestrator {
|
|
|
472
482
|
// where they always did, so compaction and the working-memory
|
|
473
483
|
// refresh stay outside a successful step's window.
|
|
474
484
|
let stepStartedAt = Date.now()
|
|
475
|
-
let usageBefore: TokenUsage = { ...
|
|
476
|
-
let costBefore: CostInfo = { ...
|
|
485
|
+
let usageBefore: TokenUsage = { ...recorder.tokenUsage }
|
|
486
|
+
let costBefore: CostInfo = { ...recorder.costInfo }
|
|
477
487
|
let stepModel = model
|
|
478
488
|
let stepMessageId: MessageId | undefined
|
|
479
489
|
let stepResponse: ChatCompletionResponse | undefined
|
|
@@ -484,18 +494,19 @@ export class IterationOrchestrator {
|
|
|
484
494
|
// the try rather than before it: a throw from any of these left
|
|
485
495
|
// the span open, and an iteration span that never ends is a
|
|
486
496
|
// trace that never closes — the export is incomplete for exactly
|
|
487
|
-
// the
|
|
497
|
+
// the turn that failed.
|
|
488
498
|
this.ctx.toolExecutor.setParentSpan(iterSpan)
|
|
489
499
|
|
|
490
500
|
iterSpan.setAttributes({
|
|
491
501
|
[NAMZU.ITERATION]: iterationNum,
|
|
492
|
-
[
|
|
502
|
+
[GENAI.CONVERSATION_ID]: recorder.sessionId,
|
|
503
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
493
504
|
[GENAI.REQUEST_MODEL]: model,
|
|
494
505
|
})
|
|
495
506
|
|
|
496
507
|
await this.ctx.emitEvent({
|
|
497
508
|
type: 'iteration_started',
|
|
498
|
-
|
|
509
|
+
turnId: recorder.turnId,
|
|
499
510
|
iteration: iterationNum,
|
|
500
511
|
})
|
|
501
512
|
yield* this.ctx.drainPending()
|
|
@@ -504,7 +515,8 @@ export class IterationOrchestrator {
|
|
|
504
515
|
const hookResults = await this.ctx.pluginManager.executeHooks(
|
|
505
516
|
'iteration_start',
|
|
506
517
|
{
|
|
507
|
-
|
|
518
|
+
sessionId: recorder.sessionId,
|
|
519
|
+
turnId: recorder.turnId,
|
|
508
520
|
iteration: iterationNum,
|
|
509
521
|
signal: this.ctx.abortController.signal,
|
|
510
522
|
},
|
|
@@ -528,7 +540,7 @@ export class IterationOrchestrator {
|
|
|
528
540
|
// risks a 400 because the history still carries
|
|
529
541
|
// tool_use/tool_result blocks.
|
|
530
542
|
// Snapshot the cumulative counters so the step can report ITS
|
|
531
|
-
// own usage rather than the
|
|
543
|
+
// own usage rather than the turn total.
|
|
532
544
|
stepStartedAt = Date.now()
|
|
533
545
|
|
|
534
546
|
// Shape this step before calling the model. `stopWhen` decides
|
|
@@ -536,9 +548,9 @@ export class IterationOrchestrator {
|
|
|
536
548
|
// supplied no hook.
|
|
537
549
|
const contextModelBeforePreparation = this.ctx.contextModel ?? model
|
|
538
550
|
const step = await prepareStep(this.stepShaping(), iterationNum)
|
|
539
|
-
// Preparation inference belongs to the
|
|
540
|
-
usageBefore = { ...
|
|
541
|
-
costBefore = { ...
|
|
551
|
+
// Preparation inference belongs to the turn, not the main-model step.
|
|
552
|
+
usageBefore = { ...recorder.tokenUsage }
|
|
553
|
+
costBefore = { ...recorder.costInfo }
|
|
542
554
|
stepModel = step.model ?? model
|
|
543
555
|
await selectContextModel(this.stepShaping(), stepModel)
|
|
544
556
|
// Preserve post-compaction preparation/recall semantics. A changed
|
|
@@ -564,20 +576,21 @@ export class IterationOrchestrator {
|
|
|
564
576
|
const enforceToolInputSchema = enforcedModelInputToolNames(this.ctx.tools, llmTools)
|
|
565
577
|
stepModel = step.model ?? model
|
|
566
578
|
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
:
|
|
579
|
+
// The closing directive is appended LAST, after every piece of
|
|
580
|
+
// request-only context below, so it is the final thing the model
|
|
581
|
+
// reads on a forced-final step.
|
|
582
|
+
const closingDirective = forceFinalize
|
|
583
|
+
? createRuntimeContextMessage(
|
|
584
|
+
`[SYSTEM] You are approaching your resource limits. ${CLOSING_RESPONSE_GUIDANCE}`,
|
|
585
|
+
'limit-finalization',
|
|
586
|
+
)
|
|
587
|
+
: undefined
|
|
588
|
+
const baseMessages = recorder.messages
|
|
576
589
|
|
|
577
590
|
// Step guidance is appended to the REQUEST, never pushed onto
|
|
578
|
-
// the
|
|
591
|
+
// the turn's history: it applies to this step only, and pushing
|
|
579
592
|
// it would accumulate one stale instruction per iteration.
|
|
580
|
-
// Copy before it crosses the provider boundary. `
|
|
593
|
+
// Copy before it crosses the provider boundary. `recorder.messages`
|
|
581
594
|
// is the LIVE run array, and the loop pushes onto it after the
|
|
582
595
|
// call returns — so a driver that retains what it was handed
|
|
583
596
|
// (to log it, cache it, or replay it on retry) watched its own
|
|
@@ -597,7 +610,7 @@ export class IterationOrchestrator {
|
|
|
597
610
|
// A supervision change rides the same ephemeral slot, and for
|
|
598
611
|
// the same reason: it applies to what happens next, not to the
|
|
599
612
|
// run's history. The model plans around how closely it is being
|
|
600
|
-
// watched — a
|
|
613
|
+
// watched — a turn that silently stops asking a human leaves it
|
|
601
614
|
// batching destructive calls it expects to be reviewed, and one
|
|
602
615
|
// that silently starts leaves it waiting on permission nobody
|
|
603
616
|
// is left to give.
|
|
@@ -609,7 +622,7 @@ export class IterationOrchestrator {
|
|
|
609
622
|
const policyNotice = policyChange
|
|
610
623
|
? `Approval policy changed from "${policyChange.from}" to "${policyChange.to}" (${policyChange.reason}). Tool calls from here on are reviewed under the new policy.`
|
|
611
624
|
: null
|
|
612
|
-
// State that changed during the
|
|
625
|
+
// State that changed during the turn, reported once per turn.
|
|
613
626
|
// `turn` contributions are recomputed here, not fixed when the
|
|
614
627
|
// run's prompt is assembled. They retain system authority and
|
|
615
628
|
// may affect caching just like the other system contributions.
|
|
@@ -618,31 +631,51 @@ export class IterationOrchestrator {
|
|
|
618
631
|
iteration: iterationNum,
|
|
619
632
|
}) ?? []
|
|
620
633
|
|
|
634
|
+
// Request-only context: observations that need no system
|
|
635
|
+
// authority and change from request to request. They ride
|
|
636
|
+
// runtime-context messages of kind `step-context` after the
|
|
637
|
+
// history, which every driver keeps there and a caching driver
|
|
638
|
+
// ends its breakpoint before — so a changed pin or a new turn
|
|
639
|
+
// snapshot costs its own tokens, not a re-read of the history.
|
|
640
|
+
// The working-memory slot keeps its place in the turn's history
|
|
641
|
+
// (compaction preserves it there) and leaves the request's
|
|
642
|
+
// system run here.
|
|
643
|
+
const workingMemory = splitWorkingMemoryForRequest(baseMessages)
|
|
644
|
+
const contextSections =
|
|
645
|
+
this.ctx.promptContributions?.render('context', {
|
|
646
|
+
iteration: iterationNum,
|
|
647
|
+
}) ?? []
|
|
648
|
+
|
|
621
649
|
const stepPreamble = [step.system, stepSkills, policyNotice, ...turnSections]
|
|
622
650
|
.filter(Boolean)
|
|
623
651
|
.join('\n\n')
|
|
624
652
|
const requestHistory = stepPreamble
|
|
625
|
-
? [...
|
|
626
|
-
: [...
|
|
653
|
+
? [...workingMemory.history, createSystemMessage(stepPreamble)]
|
|
654
|
+
: [...workingMemory.history]
|
|
655
|
+
if (workingMemory.context) requestHistory.push(workingMemory.context)
|
|
656
|
+
if (contextSections.length > 0)
|
|
657
|
+
requestHistory.push(stepContextMessage(contextSections.join('\n\n')))
|
|
627
658
|
if (step.context) requestHistory.push(stepContextMessage(step.context))
|
|
628
659
|
const messages = projectRequestRichContent(
|
|
629
660
|
this.projectObservations(requestHistory),
|
|
630
|
-
this.ctx.
|
|
661
|
+
this.ctx.turnConfig.maxRequestRichContentBytes ??
|
|
662
|
+
DEFAULT_MAX_REQUEST_RICH_CONTENT_BYTES,
|
|
631
663
|
)
|
|
632
664
|
appendWorkContext(this.stepShaping(), messages, iterationNum, step)
|
|
665
|
+
if (closingDirective) messages.push(closingDirective)
|
|
633
666
|
await this.reportUnsupportedToolResults(messages)
|
|
634
667
|
yield* this.ctx.drainPending()
|
|
635
668
|
|
|
636
669
|
// What the model is about to be ASKED, recorded when it
|
|
637
|
-
// changed. `
|
|
670
|
+
// changed. `turn_started` carries one system prompt and tool
|
|
638
671
|
// schemas never reached the transcript at all — while
|
|
639
672
|
// `prepareStep` rewrites the system text, narrows the tool
|
|
640
673
|
// list or swaps the model, and a step's skills ride the
|
|
641
674
|
// ephemeral preamble above. So a transcript showed one
|
|
642
|
-
// question for a
|
|
675
|
+
// question for a turn that had asked several.
|
|
643
676
|
//
|
|
644
677
|
// Emitted only on a change: the digest is compared against
|
|
645
|
-
// the last one this
|
|
678
|
+
// the last one this turn recorded, so the common case costs
|
|
646
679
|
// one hash and nothing else. Copying an unchanged system
|
|
647
680
|
// prompt every iteration is the fastest way to make a
|
|
648
681
|
// durable log too large to read.
|
|
@@ -650,7 +683,7 @@ export class IterationOrchestrator {
|
|
|
650
683
|
model: stepModel,
|
|
651
684
|
// Read off `messages`, which is what the request is actually
|
|
652
685
|
// built from — including the ephemeral preamble. Recomputing
|
|
653
|
-
// it from the
|
|
686
|
+
// it from the turn's history would describe a request nobody
|
|
654
687
|
// sent the moment the two diverge.
|
|
655
688
|
systemPrompt: messages
|
|
656
689
|
.filter((m) => m.role === 'system')
|
|
@@ -669,7 +702,7 @@ export class IterationOrchestrator {
|
|
|
669
702
|
this.lastEnvelopeKey = envelopeKey
|
|
670
703
|
await this.ctx.emitEvent?.({
|
|
671
704
|
type: 'request_envelope',
|
|
672
|
-
|
|
705
|
+
turnId: recorder.turnId,
|
|
673
706
|
iteration: iterationNum,
|
|
674
707
|
...envelope,
|
|
675
708
|
toolNames: Object.freeze([...envelope.toolNames]),
|
|
@@ -690,21 +723,22 @@ export class IterationOrchestrator {
|
|
|
690
723
|
const hookResults = await this.ctx.pluginManager.executeHooks(
|
|
691
724
|
'pre_llm_call',
|
|
692
725
|
{
|
|
693
|
-
|
|
726
|
+
sessionId: recorder.sessionId,
|
|
727
|
+
turnId: recorder.turnId,
|
|
694
728
|
iteration: iterationNum,
|
|
695
729
|
signal: this.ctx.abortController.signal,
|
|
696
|
-
// Built inside the guard: a
|
|
730
|
+
// Built inside the guard: a turn with no plugins installed
|
|
697
731
|
// pays nothing for a projection nobody reads.
|
|
698
732
|
request: Object.freeze({
|
|
699
733
|
context,
|
|
700
734
|
model: stepModel,
|
|
701
735
|
// Copied per turn, not handed over live: these are the
|
|
702
736
|
// run's own message objects, and a hook writing into
|
|
703
|
-
// one would edit the history the
|
|
737
|
+
// one would edit the history the turn is about to send.
|
|
704
738
|
messages: Object.freeze(messages.map((m) => Object.freeze({ ...m }))),
|
|
705
739
|
toolNames: Object.freeze(llmTools.map((t) => t.function.name)),
|
|
706
|
-
temperature: step.temperature ??
|
|
707
|
-
maxTokens: step.maxResponseTokens ??
|
|
740
|
+
temperature: step.temperature ?? turnConfig.temperature,
|
|
741
|
+
maxTokens: step.maxResponseTokens ?? turnConfig.maxResponseTokens,
|
|
708
742
|
}),
|
|
709
743
|
},
|
|
710
744
|
this.ctx.emitEvent,
|
|
@@ -716,7 +750,7 @@ export class IterationOrchestrator {
|
|
|
716
750
|
// Phase 4 (ses_001-tool-stream-events): consume the
|
|
717
751
|
// streaming response natively, emitting message and
|
|
718
752
|
// tool-input lifecycle events as deltas arrive. The
|
|
719
|
-
// helper yields
|
|
753
|
+
// helper yields SessionEvents through drainPending() so SSE
|
|
720
754
|
// consumers see live progress; its return value is the
|
|
721
755
|
// aggregated `ChatCompletionResponse` for the legacy
|
|
722
756
|
// downstream paths (assistantMsg construction, working
|
|
@@ -776,20 +810,22 @@ export class IterationOrchestrator {
|
|
|
776
810
|
: llmTools.length > 0
|
|
777
811
|
? step.toolChoice
|
|
778
812
|
: undefined,
|
|
779
|
-
temperature: step.temperature ??
|
|
780
|
-
maxTokens: step.maxResponseTokens ??
|
|
813
|
+
temperature: step.temperature ?? turnConfig.temperature,
|
|
814
|
+
maxTokens: step.maxResponseTokens ?? turnConfig.maxResponseTokens,
|
|
781
815
|
cacheControl: { type: 'auto' },
|
|
782
|
-
...(
|
|
783
|
-
...(
|
|
784
|
-
...(!forceFinalize &&
|
|
785
|
-
|
|
816
|
+
...(turnConfig.thinking ? { thinking: turnConfig.thinking } : {}),
|
|
817
|
+
...(turnConfig.effort ? { effort: turnConfig.effort } : {}),
|
|
818
|
+
...(!forceFinalize && turnConfig.webSearch
|
|
819
|
+
? { webSearch: turnConfig.webSearch }
|
|
820
|
+
: {}),
|
|
821
|
+
// Thread the turn abort into the model call so a Stop tears the
|
|
786
822
|
// in-flight turn down (provider passes it to fetch; the consumer
|
|
787
823
|
// also races it). Inert when never aborted.
|
|
788
824
|
signal: this.ctx.abortController.signal,
|
|
789
825
|
},
|
|
790
826
|
this.ctx.emitEvent,
|
|
791
827
|
this.ctx.drainPending,
|
|
792
|
-
|
|
828
|
+
recorder.turnId,
|
|
793
829
|
iterationNum,
|
|
794
830
|
forceFinalize,
|
|
795
831
|
this.ctx.log,
|
|
@@ -801,6 +837,7 @@ export class IterationOrchestrator {
|
|
|
801
837
|
Boolean(
|
|
802
838
|
this.ctx.reviewAnswer || this.ctx.structuredOutput?.review || this.ctx.advisoryCtx,
|
|
803
839
|
),
|
|
840
|
+
recorder.sessionId,
|
|
804
841
|
)
|
|
805
842
|
stepResponse = response
|
|
806
843
|
const reviewRequest: ReviewRequest = {
|
|
@@ -841,13 +878,13 @@ export class IterationOrchestrator {
|
|
|
841
878
|
// model it was asked for. This is the seam that ended the
|
|
842
879
|
// always-zero cost: the rate lookup happens per turn,
|
|
843
880
|
// against who actually answered, rather than against one
|
|
844
|
-
// table the
|
|
845
|
-
|
|
881
|
+
// table the turn was constructed with.
|
|
882
|
+
recorder.recordTurnUsage(response.usage, {
|
|
846
883
|
providerId: servedBy.providerId,
|
|
847
884
|
model: servedBy.model,
|
|
848
885
|
})
|
|
849
886
|
|
|
850
|
-
// The turn went through, so the
|
|
887
|
+
// The turn went through, so the turn is not sitting on an
|
|
851
888
|
// irreducible prompt any more. Re-arm relief for the next one.
|
|
852
889
|
overflowRelieved = false
|
|
853
890
|
|
|
@@ -855,7 +892,8 @@ export class IterationOrchestrator {
|
|
|
855
892
|
const hookResults = await this.ctx.pluginManager.executeHooks(
|
|
856
893
|
'post_llm_call',
|
|
857
894
|
{
|
|
858
|
-
|
|
895
|
+
sessionId: recorder.sessionId,
|
|
896
|
+
turnId: recorder.turnId,
|
|
859
897
|
iteration: iterationNum,
|
|
860
898
|
signal: this.ctx.abortController.signal,
|
|
861
899
|
response: Object.freeze({
|
|
@@ -874,7 +912,7 @@ export class IterationOrchestrator {
|
|
|
874
912
|
}
|
|
875
913
|
|
|
876
914
|
this.ctx.log.debug('LLM response received', {
|
|
877
|
-
[NAMZU.
|
|
915
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
878
916
|
[NAMZU.ITERATION]: iterationNum,
|
|
879
917
|
'namzu.runtime.finish_reason': response.finishReason,
|
|
880
918
|
'namzu.runtime.has_content':
|
|
@@ -882,8 +920,8 @@ export class IterationOrchestrator {
|
|
|
882
920
|
'namzu.runtime.tool_call_count': response.message.toolCalls?.length ?? 0,
|
|
883
921
|
[GENAI.USAGE_INPUT_TOKENS]: response.usage.promptTokens,
|
|
884
922
|
[GENAI.USAGE_OUTPUT_TOKENS]: response.usage.completionTokens,
|
|
885
|
-
'namzu.usage.total_tokens':
|
|
886
|
-
'namzu.runtime.total_cost':
|
|
923
|
+
'namzu.usage.total_tokens': recorder.tokenUsage.totalTokens,
|
|
924
|
+
'namzu.runtime.total_cost': recorder.costInfo.totalCost,
|
|
887
925
|
})
|
|
888
926
|
|
|
889
927
|
// The context figures ride with the spend figures because a
|
|
@@ -893,7 +931,7 @@ export class IterationOrchestrator {
|
|
|
893
931
|
// are measured here rather than left to be derived, since the
|
|
894
932
|
// only correct derivation needs internals a host cannot see.
|
|
895
933
|
//
|
|
896
|
-
// Absent when the
|
|
934
|
+
// Absent when the turn has no compaction config: nothing then
|
|
897
935
|
// resolves a window, and inventing one would be the guess this
|
|
898
936
|
// replaces.
|
|
899
937
|
const contextFigures = this.ctx.compactionConfig
|
|
@@ -911,10 +949,10 @@ export class IterationOrchestrator {
|
|
|
911
949
|
|
|
912
950
|
await this.ctx.emitEvent({
|
|
913
951
|
type: 'token_usage_updated',
|
|
914
|
-
|
|
915
|
-
usage:
|
|
916
|
-
budget:
|
|
917
|
-
cost:
|
|
952
|
+
turnId: recorder.turnId,
|
|
953
|
+
usage: recorder.tokenUsage,
|
|
954
|
+
budget: recorder.budget?.summary(),
|
|
955
|
+
cost: recorder.costInfo,
|
|
918
956
|
...contextFigures,
|
|
919
957
|
})
|
|
920
958
|
|
|
@@ -939,7 +977,7 @@ export class IterationOrchestrator {
|
|
|
939
977
|
},
|
|
940
978
|
response.message.textParts,
|
|
941
979
|
)
|
|
942
|
-
|
|
980
|
+
recorder.pushMessage(assistantMsg)
|
|
943
981
|
if (this.ctx.advisoryCtx && requestMessages) {
|
|
944
982
|
this.advisoryTurn = { iteration: iterationNum, requestMessages, response: assistantMsg }
|
|
945
983
|
}
|
|
@@ -988,7 +1026,7 @@ export class IterationOrchestrator {
|
|
|
988
1026
|
// Every task-dispatch tool (create_task, continue_task, Agent)
|
|
989
1027
|
// is BLOCKING: the worker's output returns as the dispatching
|
|
990
1028
|
// tool_use's canonical tool_result, so by the time the model
|
|
991
|
-
// ends its turn nothing launched by this
|
|
1029
|
+
// ends its turn nothing launched by this turn should still be
|
|
992
1030
|
// in flight. A running task here is an orphan (interrupted
|
|
993
1031
|
// tool execution, cancel race) with no delivery path back to
|
|
994
1032
|
// the parent — the <task-notification> producer was removed
|
|
@@ -996,9 +1034,9 @@ export class IterationOrchestrator {
|
|
|
996
1034
|
// out. Log the orphans honestly and end the turn normally.
|
|
997
1035
|
if (!forceFinalize && this.hasRunningAgentTasks()) {
|
|
998
1036
|
this.ctx.log.warn(
|
|
999
|
-
'LLM ended turn with agent tasks still running — ending
|
|
1037
|
+
'LLM ended turn with agent tasks still running — ending turn without waiting (orphan tasks have no delivery path)',
|
|
1000
1038
|
{
|
|
1001
|
-
[NAMZU.
|
|
1039
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1002
1040
|
[NAMZU.ITERATION]: iterationNum,
|
|
1003
1041
|
},
|
|
1004
1042
|
)
|
|
@@ -1009,7 +1047,7 @@ export class IterationOrchestrator {
|
|
|
1009
1047
|
// It did not, and the ledger's own contract said it should:
|
|
1010
1048
|
// `StepResult` is documented as "what one iteration of the
|
|
1011
1049
|
// agent loop did" and `stepNumber` as "1-based, matching
|
|
1012
|
-
// `iteration` on the
|
|
1050
|
+
// `iteration` on the turn events". Every path below emits
|
|
1013
1051
|
// `iteration_completed` with this iteration's number, and
|
|
1014
1052
|
// none of them recorded a step — so the events said
|
|
1015
1053
|
// iteration N happened and `steps` had no entry N. The
|
|
@@ -1041,7 +1079,7 @@ export class IterationOrchestrator {
|
|
|
1041
1079
|
// executor, and the empty-completion retry a few lines below
|
|
1042
1080
|
// all spend tokens inside an iteration without being one.
|
|
1043
1081
|
// Their usage reaches `run.tokenUsage` and no step, so the
|
|
1044
|
-
// ledger reconciles with the
|
|
1082
|
+
// ledger reconciles with the turn total for a turn that makes
|
|
1045
1083
|
// no side calls and undercounts by exactly those calls for a
|
|
1046
1084
|
// run that does. That residual is named rather than fixed
|
|
1047
1085
|
// here: attributing a side call needs a record that is not a
|
|
@@ -1075,16 +1113,16 @@ export class IterationOrchestrator {
|
|
|
1075
1113
|
)
|
|
1076
1114
|
else {
|
|
1077
1115
|
this.nativeStructuredAttempts++
|
|
1078
|
-
|
|
1116
|
+
recorder.pushMessage(
|
|
1079
1117
|
createRuntimeContextMessage(
|
|
1080
1118
|
'Return a complete JSON value matching the supplied response schema. Do not continue a partial JSON fragment.',
|
|
1081
1119
|
'structured-output',
|
|
1082
1120
|
),
|
|
1083
1121
|
)
|
|
1084
|
-
const checkpoint = await this.ctx.checkpointMgr.create(
|
|
1122
|
+
const checkpoint = await this.ctx.checkpointMgr.create(recorder, iterationNum)
|
|
1085
1123
|
await this.ctx.emitEvent({
|
|
1086
1124
|
type: 'checkpoint_created',
|
|
1087
|
-
|
|
1125
|
+
turnId: recorder.turnId,
|
|
1088
1126
|
checkpointId: checkpoint.id,
|
|
1089
1127
|
iteration: iterationNum,
|
|
1090
1128
|
})
|
|
@@ -1095,14 +1133,14 @@ export class IterationOrchestrator {
|
|
|
1095
1133
|
}
|
|
1096
1134
|
await this.ctx.emitEvent({
|
|
1097
1135
|
type: 'iteration_completed',
|
|
1098
|
-
|
|
1136
|
+
turnId: recorder.turnId,
|
|
1099
1137
|
iteration: iterationNum,
|
|
1100
1138
|
hasToolCalls: false,
|
|
1101
1139
|
})
|
|
1102
1140
|
yield* this.ctx.drainPending()
|
|
1103
1141
|
if (this.ctx.abortController.signal.aborted || outcome === 'cancelled') {
|
|
1104
|
-
|
|
1105
|
-
|
|
1142
|
+
recorder.setStopReason('cancelled')
|
|
1143
|
+
recorder.markCancelled()
|
|
1106
1144
|
break
|
|
1107
1145
|
}
|
|
1108
1146
|
if (outcome === 'accepted') {
|
|
@@ -1114,16 +1152,16 @@ export class IterationOrchestrator {
|
|
|
1114
1152
|
if (changed || inbound > 0) continue
|
|
1115
1153
|
}
|
|
1116
1154
|
if (this.ctx.abortController.signal.aborted) {
|
|
1117
|
-
|
|
1118
|
-
|
|
1155
|
+
recorder.setStopReason('cancelled')
|
|
1156
|
+
recorder.markCancelled()
|
|
1119
1157
|
break
|
|
1120
1158
|
}
|
|
1121
1159
|
this.publishStructuredOutput()
|
|
1122
|
-
|
|
1160
|
+
recorder.setStopReason('end_turn')
|
|
1123
1161
|
break
|
|
1124
1162
|
}
|
|
1125
1163
|
if (outcome === 'exhausted') {
|
|
1126
|
-
|
|
1164
|
+
recorder.setStopReason(
|
|
1127
1165
|
candidate.success ? 'answer_rejected' : 'structured_output_failed',
|
|
1128
1166
|
)
|
|
1129
1167
|
break
|
|
@@ -1155,16 +1193,16 @@ export class IterationOrchestrator {
|
|
|
1155
1193
|
// - max_iterations bounds the loop in any case.
|
|
1156
1194
|
if (!forceFinalize && response.finishReason === 'length' && hasContent) {
|
|
1157
1195
|
this.ctx.log.info('LLM hit max_tokens mid-text — auto-continuing', {
|
|
1158
|
-
[NAMZU.
|
|
1196
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1159
1197
|
[NAMZU.ITERATION]: iterationNum,
|
|
1160
1198
|
[GENAI.USAGE_OUTPUT_TOKENS]: response.usage.completionTokens,
|
|
1161
1199
|
})
|
|
1162
|
-
|
|
1200
|
+
recorder.pushMessage(
|
|
1163
1201
|
createRuntimeContextMessage(AUTO_CONTINUATION_USER_MESSAGE, 'auto-continuation'),
|
|
1164
1202
|
)
|
|
1165
1203
|
await this.ctx.emitEvent({
|
|
1166
1204
|
type: 'iteration_completed',
|
|
1167
|
-
|
|
1205
|
+
turnId: recorder.turnId,
|
|
1168
1206
|
iteration: iterationNum,
|
|
1169
1207
|
hasToolCalls: false,
|
|
1170
1208
|
})
|
|
@@ -1182,23 +1220,23 @@ export class IterationOrchestrator {
|
|
|
1182
1220
|
const limit = this.structuredOutputRetryLimit()
|
|
1183
1221
|
if (attempt > limit) {
|
|
1184
1222
|
this.ctx.log.warn('Structured output not produced within its retries', {
|
|
1185
|
-
[NAMZU.
|
|
1223
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1186
1224
|
'namzu.runtime.attempts': attempt - 1,
|
|
1187
1225
|
})
|
|
1188
|
-
|
|
1226
|
+
recorder.setStopReason('structured_output_failed')
|
|
1189
1227
|
break
|
|
1190
1228
|
}
|
|
1191
1229
|
this.ctx.log.info('Re-prompting for structured output', {
|
|
1192
|
-
[NAMZU.
|
|
1230
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1193
1231
|
'namzu.retry.attempt': attempt,
|
|
1194
1232
|
'namzu.runtime.limit': limit,
|
|
1195
1233
|
})
|
|
1196
|
-
|
|
1234
|
+
recorder.pushMessage(
|
|
1197
1235
|
createRuntimeContextMessage(STRUCTURED_OUTPUT_REPROMPT, 'structured-output'),
|
|
1198
1236
|
)
|
|
1199
1237
|
await this.ctx.emitEvent({
|
|
1200
1238
|
type: 'iteration_completed',
|
|
1201
|
-
|
|
1239
|
+
turnId: recorder.turnId,
|
|
1202
1240
|
iteration: iterationNum,
|
|
1203
1241
|
hasToolCalls: false,
|
|
1204
1242
|
})
|
|
@@ -1210,10 +1248,10 @@ export class IterationOrchestrator {
|
|
|
1210
1248
|
//
|
|
1211
1249
|
// The stop predicate is only consulted after tools ran, so
|
|
1212
1250
|
// there was no seam here at all: the moment the model
|
|
1213
|
-
// stopped calling tools the
|
|
1251
|
+
// stopped calling tools the turn finalized, whatever it had
|
|
1214
1252
|
// produced. Verify-then-fix — run the build, feed the
|
|
1215
1253
|
// failure back, let it try again — meant starting a whole
|
|
1216
|
-
// new
|
|
1254
|
+
// new turn and re-supplying the context the first one had.
|
|
1217
1255
|
//
|
|
1218
1256
|
// Shaped after the structured-output re-prompt directly
|
|
1219
1257
|
// above, which solves the same problem for one specific
|
|
@@ -1226,45 +1264,45 @@ export class IterationOrchestrator {
|
|
|
1226
1264
|
stepModel,
|
|
1227
1265
|
)
|
|
1228
1266
|
if (this.ctx.abortController.signal.aborted) {
|
|
1229
|
-
|
|
1230
|
-
|
|
1267
|
+
recorder.setStopReason('cancelled')
|
|
1268
|
+
recorder.markCancelled()
|
|
1231
1269
|
break
|
|
1232
1270
|
}
|
|
1233
1271
|
if (review && !review.accept) {
|
|
1234
1272
|
const attempt = ++this.answerReviewAttempts
|
|
1235
|
-
|
|
1273
|
+
recorder.pushMessage(createRuntimeContextMessage(review.feedback, 'answer-review'))
|
|
1236
1274
|
// Commit the consumed allowance with its feedback before another
|
|
1237
1275
|
// request, including exhaustion. Compaction cannot reset this quota.
|
|
1238
|
-
const checkpoint = await this.ctx.checkpointMgr.create(
|
|
1276
|
+
const checkpoint = await this.ctx.checkpointMgr.create(recorder, iterationNum)
|
|
1239
1277
|
await this.ctx.emitEvent({
|
|
1240
1278
|
type: 'checkpoint_created',
|
|
1241
|
-
|
|
1279
|
+
turnId: recorder.turnId,
|
|
1242
1280
|
checkpointId: checkpoint.id,
|
|
1243
1281
|
iteration: iterationNum,
|
|
1244
1282
|
})
|
|
1245
1283
|
if (this.ctx.abortController.signal.aborted) {
|
|
1246
|
-
|
|
1247
|
-
|
|
1284
|
+
recorder.setStopReason('cancelled')
|
|
1285
|
+
recorder.markCancelled()
|
|
1248
1286
|
break
|
|
1249
1287
|
}
|
|
1250
1288
|
const limit = this.ctx.maxAnswerReviews ?? DEFAULT_ANSWER_REVIEW_LIMIT
|
|
1251
1289
|
if (attempt > limit) {
|
|
1252
|
-
this.ctx.log.warn('Answer rejected more times than the
|
|
1253
|
-
[NAMZU.
|
|
1290
|
+
this.ctx.log.warn('Answer rejected more times than the turn allows', {
|
|
1291
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1254
1292
|
'namzu.runtime.attempts': attempt - 1,
|
|
1255
1293
|
'namzu.runtime.limit': limit,
|
|
1256
1294
|
})
|
|
1257
|
-
|
|
1295
|
+
recorder.setStopReason('answer_rejected')
|
|
1258
1296
|
break
|
|
1259
1297
|
}
|
|
1260
1298
|
this.ctx.log.info('Answer rejected — returning it to the model', {
|
|
1261
|
-
[NAMZU.
|
|
1299
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1262
1300
|
'namzu.retry.attempt': attempt,
|
|
1263
1301
|
'namzu.runtime.limit': limit,
|
|
1264
1302
|
})
|
|
1265
1303
|
await this.ctx.emitEvent({
|
|
1266
1304
|
type: 'iteration_completed',
|
|
1267
|
-
|
|
1305
|
+
turnId: recorder.turnId,
|
|
1268
1306
|
iteration: iterationNum,
|
|
1269
1307
|
hasToolCalls: false,
|
|
1270
1308
|
})
|
|
@@ -1274,11 +1312,11 @@ export class IterationOrchestrator {
|
|
|
1274
1312
|
}
|
|
1275
1313
|
|
|
1276
1314
|
// A background worker is still out there, and this turn was
|
|
1277
|
-
// about to end the
|
|
1315
|
+
// about to end the turn.
|
|
1278
1316
|
//
|
|
1279
1317
|
// Settling here would throw away the very thing the launch
|
|
1280
1318
|
// existed to produce: the supervisor said "launched", the
|
|
1281
|
-
// worker had not finished, and the
|
|
1319
|
+
// worker had not finished, and the turn closed over it.
|
|
1282
1320
|
if (
|
|
1283
1321
|
!forceFinalize &&
|
|
1284
1322
|
(yield* holdForOutstandingWork(this.ctx, iterationNum, false, () =>
|
|
@@ -1300,7 +1338,7 @@ export class IterationOrchestrator {
|
|
|
1300
1338
|
if (!forceFinalize && this.deliverInbound() > 0) {
|
|
1301
1339
|
await this.ctx.emitEvent({
|
|
1302
1340
|
type: 'iteration_completed',
|
|
1303
|
-
|
|
1341
|
+
turnId: recorder.turnId,
|
|
1304
1342
|
iteration: iterationNum,
|
|
1305
1343
|
hasToolCalls: false,
|
|
1306
1344
|
})
|
|
@@ -1325,18 +1363,18 @@ export class IterationOrchestrator {
|
|
|
1325
1363
|
|
|
1326
1364
|
await this.ctx.emitEvent({
|
|
1327
1365
|
type: 'iteration_completed',
|
|
1328
|
-
|
|
1366
|
+
turnId: recorder.turnId,
|
|
1329
1367
|
iteration: iterationNum,
|
|
1330
1368
|
hasToolCalls: false,
|
|
1331
1369
|
})
|
|
1332
1370
|
yield* this.ctx.drainPending()
|
|
1333
1371
|
// A Stop that lands AFTER the final turn streamed but before
|
|
1334
|
-
// this break must settle the
|
|
1372
|
+
// this break must settle the turn as cancelled, not end_turn —
|
|
1335
1373
|
// otherwise the just-produced answer is recorded as a clean
|
|
1336
1374
|
// completion. Mirrors the between-iteration cancel at :511.
|
|
1337
1375
|
if (this.ctx.abortController.signal.aborted) {
|
|
1338
|
-
|
|
1339
|
-
|
|
1376
|
+
recorder.setStopReason('cancelled')
|
|
1377
|
+
recorder.markCancelled()
|
|
1340
1378
|
break
|
|
1341
1379
|
}
|
|
1342
1380
|
// The host's stop predicate, if the previous turn deferred it
|
|
@@ -1344,13 +1382,13 @@ export class IterationOrchestrator {
|
|
|
1344
1382
|
// is prose, and `stopWhen` is consulted only after a tool
|
|
1345
1383
|
// batch, so the predicate is never asked again — reporting
|
|
1346
1384
|
// `end_turn` would name the shape of the last message rather
|
|
1347
|
-
// than the reason the
|
|
1385
|
+
// than the reason the turn is over.
|
|
1348
1386
|
//
|
|
1349
1387
|
// Only here. A terminal tool and a captured structured output
|
|
1350
1388
|
// also settle as `end_turn`, and there the deferred predicate
|
|
1351
|
-
// is not why the
|
|
1389
|
+
// is not why the turn ended: those decided the answer
|
|
1352
1390
|
// themselves.
|
|
1353
|
-
|
|
1391
|
+
recorder.setStopReason(
|
|
1354
1392
|
closingStopReason ??
|
|
1355
1393
|
(stopWasDeferredForOutstandingWork ? 'stop_condition' : 'end_turn'),
|
|
1356
1394
|
)
|
|
@@ -1359,7 +1397,7 @@ export class IterationOrchestrator {
|
|
|
1359
1397
|
|
|
1360
1398
|
const reviewOutcome = yield* runToolReview(this.ctx, response, iterationNum)
|
|
1361
1399
|
|
|
1362
|
-
// The step record is built even for a rejected batch: a
|
|
1400
|
+
// The step record is built even for a rejected batch: a turn that
|
|
1363
1401
|
// spent a turn getting its tools refused still spent the tokens,
|
|
1364
1402
|
// and a caller reconstructing cost per step must see it.
|
|
1365
1403
|
this.recordStep({
|
|
@@ -1404,34 +1442,34 @@ export class IterationOrchestrator {
|
|
|
1404
1442
|
) {
|
|
1405
1443
|
await this.ctx.emitEvent({
|
|
1406
1444
|
type: 'iteration_completed',
|
|
1407
|
-
|
|
1445
|
+
turnId: recorder.turnId,
|
|
1408
1446
|
iteration: iterationNum,
|
|
1409
1447
|
hasToolCalls: true,
|
|
1410
1448
|
})
|
|
1411
1449
|
yield* this.ctx.drainPending()
|
|
1412
1450
|
if (this.ctx.abortController.signal.aborted) {
|
|
1413
|
-
|
|
1414
|
-
|
|
1451
|
+
recorder.setStopReason('cancelled')
|
|
1452
|
+
recorder.markCancelled()
|
|
1415
1453
|
break
|
|
1416
1454
|
}
|
|
1417
1455
|
if (structuredOutcome === 'retry') continue
|
|
1418
|
-
|
|
1456
|
+
recorder.setStopReason(
|
|
1419
1457
|
structuredOutcome === 'cancelled' ? 'cancelled' : 'answer_rejected',
|
|
1420
1458
|
)
|
|
1421
|
-
if (structuredOutcome === 'cancelled')
|
|
1459
|
+
if (structuredOutcome === 'cancelled') recorder.markCancelled()
|
|
1422
1460
|
break
|
|
1423
1461
|
}
|
|
1424
1462
|
if (structuredOutcome === 'accepted') {
|
|
1425
1463
|
await this.ctx.emitEvent({
|
|
1426
1464
|
type: 'iteration_completed',
|
|
1427
|
-
|
|
1465
|
+
turnId: recorder.turnId,
|
|
1428
1466
|
iteration: iterationNum,
|
|
1429
1467
|
hasToolCalls: true,
|
|
1430
1468
|
})
|
|
1431
1469
|
yield* this.ctx.drainPending()
|
|
1432
1470
|
if (this.ctx.abortController.signal.aborted) {
|
|
1433
|
-
|
|
1434
|
-
|
|
1471
|
+
recorder.setStopReason('cancelled')
|
|
1472
|
+
recorder.markCancelled()
|
|
1435
1473
|
break
|
|
1436
1474
|
}
|
|
1437
1475
|
if (!forceFinalize) {
|
|
@@ -1441,20 +1479,20 @@ export class IterationOrchestrator {
|
|
|
1441
1479
|
if (inbound > 0 || this.latestUserMessage !== operatorInputAtDispatch) continue
|
|
1442
1480
|
}
|
|
1443
1481
|
if (this.ctx.abortController.signal.aborted) {
|
|
1444
|
-
|
|
1445
|
-
|
|
1482
|
+
recorder.setStopReason('cancelled')
|
|
1483
|
+
recorder.markCancelled()
|
|
1446
1484
|
break
|
|
1447
1485
|
}
|
|
1448
|
-
this.ctx.log.info('Structured output produced — ending
|
|
1449
|
-
[NAMZU.
|
|
1486
|
+
this.ctx.log.info('Structured output produced — ending turn', {
|
|
1487
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1450
1488
|
[NAMZU.ITERATION]: iterationNum,
|
|
1451
1489
|
})
|
|
1452
1490
|
this.publishStructuredOutput()
|
|
1453
|
-
|
|
1491
|
+
recorder.setStopReason('end_turn')
|
|
1454
1492
|
break
|
|
1455
1493
|
}
|
|
1456
1494
|
|
|
1457
|
-
// A tool the author declared terminal settles the
|
|
1495
|
+
// A tool the author declared terminal settles the turn with its
|
|
1458
1496
|
// own output, the same rule `structured_output` has always
|
|
1459
1497
|
// had. Without it a delegation cost the parent one more model
|
|
1460
1498
|
// call at full context whose only job was to restate what the
|
|
@@ -1463,16 +1501,16 @@ export class IterationOrchestrator {
|
|
|
1463
1501
|
// worker's words.
|
|
1464
1502
|
const settled = this.terminalToolOutput(reviewOutcome.results, response)
|
|
1465
1503
|
if (settled !== undefined) {
|
|
1466
|
-
this.ctx.log.info('Terminal tool produced the answer — ending
|
|
1467
|
-
[NAMZU.
|
|
1504
|
+
this.ctx.log.info('Terminal tool produced the answer — ending turn', {
|
|
1505
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1468
1506
|
[NAMZU.ITERATION]: iterationNum,
|
|
1469
1507
|
[GENAI.TOOL_NAME]: settled.toolName,
|
|
1470
1508
|
})
|
|
1471
|
-
|
|
1472
|
-
|
|
1509
|
+
recorder.setResult(settled.output, 'review')
|
|
1510
|
+
recorder.setStopReason('end_turn')
|
|
1473
1511
|
await this.ctx.emitEvent({
|
|
1474
1512
|
type: 'iteration_completed',
|
|
1475
|
-
|
|
1513
|
+
turnId: recorder.turnId,
|
|
1476
1514
|
iteration: iterationNum,
|
|
1477
1515
|
hasToolCalls: true,
|
|
1478
1516
|
})
|
|
@@ -1507,7 +1545,7 @@ export class IterationOrchestrator {
|
|
|
1507
1545
|
// outstanding. One task deferred it once; two awaited
|
|
1508
1546
|
// jobs exiting a minute apart defer it twice, each time
|
|
1509
1547
|
// for a turn the model spends on news it has not read.
|
|
1510
|
-
// `maxIterations` and the
|
|
1548
|
+
// `maxIterations` and the turn's own deadline bound all of
|
|
1511
1549
|
// it regardless, and a leg with nothing pending never
|
|
1512
1550
|
// opens a hold at all.
|
|
1513
1551
|
if (
|
|
@@ -1516,20 +1554,20 @@ export class IterationOrchestrator {
|
|
|
1516
1554
|
)
|
|
1517
1555
|
) {
|
|
1518
1556
|
// Remember WHY the next turn exists, so the turn that
|
|
1519
|
-
// ends the
|
|
1557
|
+
// ends the turn can name the host's decision instead of
|
|
1520
1558
|
// reporting the shape of the last message.
|
|
1521
1559
|
this.stopDeferredForOutstandingWork = true
|
|
1522
1560
|
continue
|
|
1523
1561
|
}
|
|
1524
1562
|
|
|
1525
1563
|
this.ctx.log.info('Stop condition met', {
|
|
1526
|
-
[NAMZU.
|
|
1564
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1527
1565
|
[NAMZU.ITERATION]: iterationNum,
|
|
1528
1566
|
})
|
|
1529
|
-
|
|
1567
|
+
recorder.setStopReason('stop_condition')
|
|
1530
1568
|
await this.ctx.emitEvent({
|
|
1531
1569
|
type: 'iteration_completed',
|
|
1532
|
-
|
|
1570
|
+
turnId: recorder.turnId,
|
|
1533
1571
|
iteration: iterationNum,
|
|
1534
1572
|
hasToolCalls: true,
|
|
1535
1573
|
})
|
|
@@ -1564,11 +1602,11 @@ export class IterationOrchestrator {
|
|
|
1564
1602
|
const unheard = this.ctx.completionInbox?.drain() ?? []
|
|
1565
1603
|
if (unheard.length > 0) {
|
|
1566
1604
|
this.ctx.log.info('Delivering unawaited task completions', {
|
|
1567
|
-
[NAMZU.
|
|
1605
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1568
1606
|
[NAMZU.ITERATION]: iterationNum,
|
|
1569
1607
|
'namzu.runtime.tasks': unheard.map((h) => h.taskId),
|
|
1570
1608
|
})
|
|
1571
|
-
|
|
1609
|
+
recorder.pushMessage(
|
|
1572
1610
|
createRuntimeContextMessage(formatCompletionNotification(unheard), 'task-completion'),
|
|
1573
1611
|
)
|
|
1574
1612
|
}
|
|
@@ -1585,7 +1623,8 @@ export class IterationOrchestrator {
|
|
|
1585
1623
|
const hookResults = await this.ctx.pluginManager.executeHooks(
|
|
1586
1624
|
'iteration_end',
|
|
1587
1625
|
{
|
|
1588
|
-
|
|
1626
|
+
sessionId: recorder.sessionId,
|
|
1627
|
+
turnId: recorder.turnId,
|
|
1589
1628
|
iteration: iterationNum,
|
|
1590
1629
|
signal: this.ctx.abortController.signal,
|
|
1591
1630
|
},
|
|
@@ -1597,7 +1636,7 @@ export class IterationOrchestrator {
|
|
|
1597
1636
|
|
|
1598
1637
|
await this.ctx.emitEvent({
|
|
1599
1638
|
type: 'iteration_completed',
|
|
1600
|
-
|
|
1639
|
+
turnId: recorder.turnId,
|
|
1601
1640
|
iteration: iterationNum,
|
|
1602
1641
|
hasToolCalls: true,
|
|
1603
1642
|
})
|
|
@@ -1623,7 +1662,7 @@ export class IterationOrchestrator {
|
|
|
1623
1662
|
// wrote down for itself. All three exits spend a turn: the
|
|
1624
1663
|
// cancellation breaks, the overflow-relief retry continues
|
|
1625
1664
|
// under a NEW iteration number (so its tokens belong to no
|
|
1626
|
-
// later step), and the re-throw ends the
|
|
1665
|
+
// later step), and the re-throw ends the turn.
|
|
1627
1666
|
//
|
|
1628
1667
|
// What it carries is what the iteration got as far as knowing.
|
|
1629
1668
|
// `usage` is the same subtraction a successful step makes, so
|
|
@@ -1640,10 +1679,10 @@ export class IterationOrchestrator {
|
|
|
1640
1679
|
// class of wrong as dropping them and harder to notice, since
|
|
1641
1680
|
// the ledger would look fuller rather than emptier. That turn's
|
|
1642
1681
|
// own verdict is already written down; the failure that
|
|
1643
|
-
// followed it reaches the caller as the
|
|
1682
|
+
// followed it reaches the caller as the turn's error.
|
|
1644
1683
|
if (this.steps.at(-1)?.stepNumber === iterationNum) {
|
|
1645
1684
|
this.ctx.log.warn('Iteration failed after its step was already recorded', {
|
|
1646
|
-
[NAMZU.
|
|
1685
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1647
1686
|
[NAMZU.ITERATION]: iterationNum,
|
|
1648
1687
|
'exception.message': toErrorMessage(err),
|
|
1649
1688
|
})
|
|
@@ -1674,15 +1713,15 @@ export class IterationOrchestrator {
|
|
|
1674
1713
|
}
|
|
1675
1714
|
|
|
1676
1715
|
// A Stop that aborted the in-flight turn surfaces here as a
|
|
1677
|
-
// thrown abort (the provider stream was raced against the
|
|
1716
|
+
// thrown abort (the provider stream was raced against the turn
|
|
1678
1717
|
// signal). Settle it as a CANCELLATION — mirroring the
|
|
1679
1718
|
// between-iteration cancel at the top of the loop — rather than
|
|
1680
1719
|
// recording it as an SDK failure (error span + failed activity)
|
|
1681
|
-
// and re-throwing. The
|
|
1720
|
+
// and re-throwing. The turn then returns cleanly with a
|
|
1682
1721
|
// 'cancelled' stop reason instead of propagating an error.
|
|
1683
1722
|
if (cancelled) {
|
|
1684
|
-
|
|
1685
|
-
|
|
1723
|
+
recorder.setStopReason('cancelled')
|
|
1724
|
+
recorder.markCancelled()
|
|
1686
1725
|
break
|
|
1687
1726
|
}
|
|
1688
1727
|
|
|
@@ -1690,8 +1729,8 @@ export class IterationOrchestrator {
|
|
|
1690
1729
|
// about. `context_length_exceeded` is correctly non-retryable —
|
|
1691
1730
|
// resending the identical prompt cannot help — but the kernel
|
|
1692
1731
|
// owns a compaction subsystem that can make the prompt smaller.
|
|
1693
|
-
// Without this the
|
|
1694
|
-
// path had simply guessed low, which a
|
|
1732
|
+
// Without this the turn died holding the remedy: the threshold
|
|
1733
|
+
// path had simply guessed low, which a turn carrying images or a
|
|
1695
1734
|
// language the chars-per-token ratio does not fit will do.
|
|
1696
1735
|
//
|
|
1697
1736
|
// Relief is attempted ONCE per iteration and only when it
|
|
@@ -1707,7 +1746,7 @@ export class IterationOrchestrator {
|
|
|
1707
1746
|
const shed = await relieveOverflow(this.ctx)
|
|
1708
1747
|
if (shed) {
|
|
1709
1748
|
this.ctx.log.info('Retrying the turn after relieving a context overflow', {
|
|
1710
|
-
[NAMZU.
|
|
1749
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1711
1750
|
[NAMZU.ITERATION]: iterationNum,
|
|
1712
1751
|
})
|
|
1713
1752
|
if (iterationActivity) {
|
|
@@ -1756,7 +1795,7 @@ export class IterationOrchestrator {
|
|
|
1756
1795
|
}
|
|
1757
1796
|
}
|
|
1758
1797
|
|
|
1759
|
-
/** Steps completed so far, exposed on the returned `
|
|
1798
|
+
/** Steps completed so far, exposed on the returned `Turn`. */
|
|
1760
1799
|
private readonly steps: StepResult[] = []
|
|
1761
1800
|
|
|
1762
1801
|
getSteps(): readonly StepResult[] {
|
|
@@ -1768,17 +1807,17 @@ export class IterationOrchestrator {
|
|
|
1768
1807
|
*
|
|
1769
1808
|
* Every field here was already computed somewhere in the loop; the only
|
|
1770
1809
|
* new work is subtracting the cumulative counters so the step carries
|
|
1771
|
-
* ITS usage rather than the
|
|
1810
|
+
* ITS usage rather than the turn's running total, which is the number a
|
|
1772
1811
|
* caller asking "what did this step cost" actually wants.
|
|
1773
1812
|
*/
|
|
1774
1813
|
/**
|
|
1775
|
-
* Take everything queued for this
|
|
1814
|
+
* Take everything queued for this turn since the last turn.
|
|
1776
1815
|
*
|
|
1777
1816
|
* Both channels drain here. `inboundMessages` is the manager's queue —
|
|
1778
1817
|
* what `continueTask` and `queueMessage` push onto and nothing ever
|
|
1779
1818
|
* collected. `steering` is the host's, and it could only ride on a tool
|
|
1780
1819
|
* result, so guidance queued during a turn that called no tools stayed
|
|
1781
|
-
* pending until the
|
|
1820
|
+
* pending until the turn ended.
|
|
1782
1821
|
*
|
|
1783
1822
|
* Returns the count so a caller can decide whether a turn is owed. An
|
|
1784
1823
|
* empty drain must change nothing at all: a `continue` on nothing queued
|
|
@@ -1799,7 +1838,7 @@ export class IterationOrchestrator {
|
|
|
1799
1838
|
private deliverInbound(): number {
|
|
1800
1839
|
const queued = this.ctx.inboundMessages?.() ?? []
|
|
1801
1840
|
for (const message of queued) {
|
|
1802
|
-
this.ctx.
|
|
1841
|
+
this.ctx.recorder.pushMessage(message)
|
|
1803
1842
|
this.rememberUserMessage(message)
|
|
1804
1843
|
}
|
|
1805
1844
|
|
|
@@ -1809,7 +1848,7 @@ export class IterationOrchestrator {
|
|
|
1809
1848
|
const stranded = this.ctx.steering?.drain()
|
|
1810
1849
|
if (stranded) {
|
|
1811
1850
|
const message = createRuntimeContextMessage(formatSteeringNote(stranded), 'steering')
|
|
1812
|
-
this.ctx.
|
|
1851
|
+
this.ctx.recorder.pushMessage(message)
|
|
1813
1852
|
this.rememberUserMessage(createRuntimeContextMessage(stranded, 'steering'))
|
|
1814
1853
|
}
|
|
1815
1854
|
|
|
@@ -1841,7 +1880,7 @@ export class IterationOrchestrator {
|
|
|
1841
1880
|
*/
|
|
1842
1881
|
unfinished?: { finishReason: 'error' | 'cancelled'; failure?: StepFailure }
|
|
1843
1882
|
}): void {
|
|
1844
|
-
const {
|
|
1883
|
+
const { recorder } = this.ctx
|
|
1845
1884
|
const toolCalls = input.response?.message.toolCalls ?? []
|
|
1846
1885
|
const byId = new Map(input.toolResults.map((r) => [r.toolCallId, r]))
|
|
1847
1886
|
|
|
@@ -1882,10 +1921,10 @@ export class IterationOrchestrator {
|
|
|
1882
1921
|
// tool execution did not end in `tool_calls`.
|
|
1883
1922
|
finishReason: input.unfinished?.finishReason ?? input.response?.finishReason ?? 'error',
|
|
1884
1923
|
...(input.unfinished?.failure ? { failure: input.unfinished.failure } : {}),
|
|
1885
|
-
usage: subtractUsage(
|
|
1924
|
+
usage: subtractUsage(recorder.tokenUsage, input.usageBefore),
|
|
1886
1925
|
costDelta: {
|
|
1887
|
-
...
|
|
1888
|
-
totalCost: round6(
|
|
1926
|
+
...recorder.costInfo,
|
|
1927
|
+
totalCost: round6(recorder.costInfo.totalCost - input.costBefore.totalCost),
|
|
1889
1928
|
},
|
|
1890
1929
|
startedAt: input.startedAt,
|
|
1891
1930
|
durationMs: Date.now() - input.startedAt,
|
|
@@ -1902,13 +1941,13 @@ export class IterationOrchestrator {
|
|
|
1902
1941
|
// Nothing here is allowed to throw over the failure that is already
|
|
1903
1942
|
// unwinding — the same rule `settleCancelledTurn` states for the
|
|
1904
1943
|
// cancellation path. A host callback that throws while being told a
|
|
1905
|
-
// turn failed would REPLACE the reason the turn failed, so the
|
|
1944
|
+
// turn failed would REPLACE the reason the turn failed, so the turn
|
|
1906
1945
|
// would report the observer's bug and lose the original.
|
|
1907
1946
|
try {
|
|
1908
1947
|
this.ctx.onStepFinish?.(step)
|
|
1909
1948
|
} catch (err) {
|
|
1910
1949
|
this.ctx.log.warn('onStepFinish threw while recording a failed step', {
|
|
1911
|
-
[NAMZU.
|
|
1950
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1912
1951
|
'namzu.runtime.step': input.stepNumber,
|
|
1913
1952
|
'exception.message': toErrorMessage(err),
|
|
1914
1953
|
})
|
|
@@ -1934,7 +1973,7 @@ export class IterationOrchestrator {
|
|
|
1934
1973
|
/**
|
|
1935
1974
|
* The answer a terminal tool produced, or `undefined` to keep looping.
|
|
1936
1975
|
*
|
|
1937
|
-
* Deliberately narrow. A terminal call decides the
|
|
1976
|
+
* Deliberately narrow. A terminal call decides the turn only when it is
|
|
1938
1977
|
* the ONLY call the model made in that turn: a model that asked for
|
|
1939
1978
|
* other work meant to see those results, and settling here would throw
|
|
1940
1979
|
* away answers it requested. Same for a failed terminal call — an
|
|
@@ -1954,7 +1993,7 @@ export class IterationOrchestrator {
|
|
|
1954
1993
|
const callCount = response.message.toolCalls?.length ?? 0
|
|
1955
1994
|
if (callCount > 1) {
|
|
1956
1995
|
this.ctx.log.info('Terminal tool shared its turn — relaying instead of settling', {
|
|
1957
|
-
[NAMZU.
|
|
1996
|
+
[NAMZU.TURN_ID]: this.ctx.recorder.turnId,
|
|
1958
1997
|
[GENAI.TOOL_NAME]: terminal[0]?.toolName,
|
|
1959
1998
|
'namzu.runtime.calls_in_turn': callCount,
|
|
1960
1999
|
})
|
|
@@ -1964,7 +2003,7 @@ export class IterationOrchestrator {
|
|
|
1964
2003
|
const hit = terminal[0]
|
|
1965
2004
|
if (!hit || hit.isError) {
|
|
1966
2005
|
this.ctx.log.info('Terminal tool failed — returning the error to the model', {
|
|
1967
|
-
[NAMZU.
|
|
2006
|
+
[NAMZU.TURN_ID]: this.ctx.recorder.turnId,
|
|
1968
2007
|
[GENAI.TOOL_NAME]: hit?.toolName,
|
|
1969
2008
|
})
|
|
1970
2009
|
return undefined
|
|
@@ -1987,7 +2026,7 @@ export class IterationOrchestrator {
|
|
|
1987
2026
|
* by the time this runs — `runToolReview` settles it, side effects
|
|
1988
2027
|
* included, before either of these is consulted — so settling here is
|
|
1989
2028
|
* worse than discarding an answer the model wanted: the work happened,
|
|
1990
|
-
* its results went into the transcript, and the
|
|
2029
|
+
* its results went into the transcript, and the turn ended before any
|
|
1991
2030
|
* model turn could read them. Nothing consumed what was spent, and
|
|
1992
2031
|
* nothing said so.
|
|
1993
2032
|
*
|
|
@@ -2009,7 +2048,7 @@ export class IterationOrchestrator {
|
|
|
2009
2048
|
* avoids it by not pairing.
|
|
2010
2049
|
*
|
|
2011
2050
|
* NOT charged to `maxRetries`. That budget bounds a model that cannot
|
|
2012
|
-
* satisfy the SCHEMA, and this one did. A
|
|
2051
|
+
* satisfy the SCHEMA, and this one did. A turn reading two files a turn
|
|
2013
2052
|
* while optimistically attaching its answer is making progress, and it
|
|
2014
2053
|
* must not die reported as `structured_output_failed` — a failure that
|
|
2015
2054
|
* did not happen. `maxIterations` is the bound for a model that keeps
|
|
@@ -2030,7 +2069,7 @@ export class IterationOrchestrator {
|
|
|
2030
2069
|
const callCount = response.message.toolCalls?.length ?? 0
|
|
2031
2070
|
if (callCount > 1) {
|
|
2032
2071
|
this.ctx.log.info('Structured output shared its turn — relaying instead of settling', {
|
|
2033
|
-
[NAMZU.
|
|
2072
|
+
[NAMZU.TURN_ID]: this.ctx.recorder.turnId,
|
|
2034
2073
|
'namzu.runtime.calls_in_turn': callCount,
|
|
2035
2074
|
})
|
|
2036
2075
|
return 'absent'
|
|
@@ -2052,7 +2091,7 @@ export class IterationOrchestrator {
|
|
|
2052
2091
|
}
|
|
2053
2092
|
|
|
2054
2093
|
private publishStructuredOutput(): void {
|
|
2055
|
-
this.ctx.
|
|
2094
|
+
this.ctx.recorder.setStructuredOutput(this.pendingStructuredOutput)
|
|
2056
2095
|
this.structuredOutputDone = true
|
|
2057
2096
|
}
|
|
2058
2097
|
|
|
@@ -2078,10 +2117,11 @@ export class IterationOrchestrator {
|
|
|
2078
2117
|
Promise.resolve().then(() => {
|
|
2079
2118
|
signal.throwIfAborted()
|
|
2080
2119
|
return reviewer(structuredClone(parsed), {
|
|
2081
|
-
|
|
2082
|
-
|
|
2120
|
+
sessionId: this.ctx.recorder.sessionId,
|
|
2121
|
+
turnId: this.ctx.recorder.turnId,
|
|
2122
|
+
iteration: this.ctx.recorder.currentIteration,
|
|
2083
2123
|
signal,
|
|
2084
|
-
messages: this.ctx.
|
|
2124
|
+
messages: this.ctx.recorder.messages,
|
|
2085
2125
|
...reviewRequest,
|
|
2086
2126
|
generateText: inference.generateText,
|
|
2087
2127
|
})
|
|
@@ -2102,18 +2142,20 @@ export class IterationOrchestrator {
|
|
|
2102
2142
|
if (typeof verdict.feedback !== 'string' || verdict.feedback.trim().length === 0)
|
|
2103
2143
|
throw new Error('Structured reviewer rejection requires feedback')
|
|
2104
2144
|
this.structuredReviewAttempts++
|
|
2105
|
-
this.ctx.
|
|
2145
|
+
this.ctx.recorder.pushMessage(
|
|
2146
|
+
createRuntimeContextMessage(verdict.feedback, 'answer-review'),
|
|
2147
|
+
)
|
|
2106
2148
|
// Persist both the feedback and its consumed allowance before the
|
|
2107
2149
|
// next request. This checkpoint is not an approval/park boundary.
|
|
2108
2150
|
const checkpoint = await this.ctx.checkpointMgr.create(
|
|
2109
|
-
this.ctx.
|
|
2110
|
-
this.ctx.
|
|
2151
|
+
this.ctx.recorder,
|
|
2152
|
+
this.ctx.recorder.currentIteration,
|
|
2111
2153
|
)
|
|
2112
2154
|
await this.ctx.emitEvent({
|
|
2113
2155
|
type: 'checkpoint_created',
|
|
2114
|
-
|
|
2156
|
+
turnId: this.ctx.recorder.turnId,
|
|
2115
2157
|
checkpointId: checkpoint.id,
|
|
2116
|
-
iteration: this.ctx.
|
|
2158
|
+
iteration: this.ctx.recorder.currentIteration,
|
|
2117
2159
|
})
|
|
2118
2160
|
if (signal.aborted) return 'cancelled'
|
|
2119
2161
|
return this.structuredReviewAttempts >
|
|
@@ -2146,10 +2188,11 @@ export class IterationOrchestrator {
|
|
|
2146
2188
|
Promise.resolve().then(() => {
|
|
2147
2189
|
signal.throwIfAborted()
|
|
2148
2190
|
return reviewer(answer, {
|
|
2149
|
-
|
|
2150
|
-
|
|
2191
|
+
sessionId: this.ctx.recorder.sessionId,
|
|
2192
|
+
turnId: this.ctx.recorder.turnId,
|
|
2193
|
+
iteration: this.ctx.recorder.currentIteration,
|
|
2151
2194
|
signal,
|
|
2152
|
-
messages: this.ctx.
|
|
2195
|
+
messages: this.ctx.recorder.messages,
|
|
2153
2196
|
...reviewRequest,
|
|
2154
2197
|
generateText: inference.generateText,
|
|
2155
2198
|
})
|
|
@@ -2180,14 +2223,14 @@ export class IterationOrchestrator {
|
|
|
2180
2223
|
return await stopWhen({
|
|
2181
2224
|
steps: this.steps,
|
|
2182
2225
|
latestStep,
|
|
2183
|
-
totalUsage: this.ctx.
|
|
2184
|
-
totalCost: this.ctx.
|
|
2226
|
+
totalUsage: this.ctx.recorder.tokenUsage,
|
|
2227
|
+
totalCost: this.ctx.recorder.costInfo,
|
|
2185
2228
|
})
|
|
2186
2229
|
} catch (err) {
|
|
2187
|
-
// A throwing predicate must not kill a
|
|
2230
|
+
// A throwing predicate must not kill a turn that is otherwise
|
|
2188
2231
|
// healthy; failing open keeps the existing budgets in charge.
|
|
2189
|
-
this.ctx.log.error('Stop condition threw — continuing the
|
|
2190
|
-
[NAMZU.
|
|
2232
|
+
this.ctx.log.error('Stop condition threw — continuing the turn', {
|
|
2233
|
+
[NAMZU.TURN_ID]: this.ctx.recorder.turnId,
|
|
2191
2234
|
'exception.message': toErrorMessage(err),
|
|
2192
2235
|
})
|
|
2193
2236
|
return false
|
|
@@ -2202,14 +2245,14 @@ export class IterationOrchestrator {
|
|
|
2202
2245
|
}
|
|
2203
2246
|
|
|
2204
2247
|
private async acceptProviderRejectedImage(identity: RequestImageIdentity): Promise<void> {
|
|
2205
|
-
const repaired = markProviderRejectedImage(this.ctx.
|
|
2248
|
+
const repaired = markProviderRejectedImage(this.ctx.recorder.messages, identity)
|
|
2206
2249
|
if (repaired.count === 0) {
|
|
2207
2250
|
throw new Error('Provider-rejected image recovery could not find its durable source image')
|
|
2208
2251
|
}
|
|
2209
|
-
this.ctx.
|
|
2252
|
+
this.ctx.recorder.replaceMessages(repaired.messages)
|
|
2210
2253
|
await this.ctx.emitEvent?.({
|
|
2211
2254
|
type: 'message_history_repaired',
|
|
2212
|
-
|
|
2255
|
+
turnId: this.ctx.recorder.turnId,
|
|
2213
2256
|
source: 'provider-rejected-image',
|
|
2214
2257
|
duplicateToolResultsRemoved: 0,
|
|
2215
2258
|
orphanedToolResultsRemoved: 0,
|
|
@@ -2224,7 +2267,7 @@ export class IterationOrchestrator {
|
|
|
2224
2267
|
): Promise<StopReason | undefined> {
|
|
2225
2268
|
if (this.ctx.structuredOutput?.mode === 'native') return 'structured_output_failed'
|
|
2226
2269
|
|
|
2227
|
-
const lastAssistant = [...this.ctx.
|
|
2270
|
+
const lastAssistant = [...this.ctx.recorder.messages]
|
|
2228
2271
|
.reverse()
|
|
2229
2272
|
.find((m) => m.role === 'assistant')
|
|
2230
2273
|
|
|
@@ -2234,11 +2277,11 @@ export class IterationOrchestrator {
|
|
|
2234
2277
|
lastAssistant.content.length > 0
|
|
2235
2278
|
|
|
2236
2279
|
if (hasResult) return
|
|
2237
|
-
// An empty completion may itself have exhausted the
|
|
2280
|
+
// An empty completion may itself have exhausted the turn. This fallback
|
|
2238
2281
|
// is another billed request, so it must pass the same hard limits as
|
|
2239
2282
|
// the next normal iteration and preserve their unfinished stop reason.
|
|
2240
2283
|
const guardResult = this.ctx.guard.beforeIteration(
|
|
2241
|
-
this.ctx.
|
|
2284
|
+
this.ctx.recorder,
|
|
2242
2285
|
this.ctx.abortController.signal,
|
|
2243
2286
|
)
|
|
2244
2287
|
if (guardResult.shouldStop) return guardResult.stopReason
|
|
@@ -2248,18 +2291,26 @@ export class IterationOrchestrator {
|
|
|
2248
2291
|
})
|
|
2249
2292
|
|
|
2250
2293
|
try {
|
|
2294
|
+
// The working-memory slot leaves the system run exactly as it does
|
|
2295
|
+
// for a normal step, and for the same cache reason.
|
|
2296
|
+
const workingMemory = splitWorkingMemoryForRequest(this.ctx.recorder.messages)
|
|
2251
2297
|
const finalHistory = [
|
|
2252
|
-
...
|
|
2253
|
-
|
|
2254
|
-
`[SYSTEM] Run is ending due to ${reason}. ${CLOSING_RESPONSE_GUIDANCE}`,
|
|
2255
|
-
'limit-finalization',
|
|
2256
|
-
),
|
|
2298
|
+
...workingMemory.history,
|
|
2299
|
+
...(workingMemory.context ? [workingMemory.context] : []),
|
|
2257
2300
|
]
|
|
2258
2301
|
const finalMessages = projectRequestRichContent(
|
|
2259
2302
|
this.projectObservations(finalHistory),
|
|
2260
|
-
this.ctx.
|
|
2303
|
+
this.ctx.turnConfig.maxRequestRichContentBytes ?? DEFAULT_MAX_REQUEST_RICH_CONTENT_BYTES,
|
|
2261
2304
|
)
|
|
2262
2305
|
appendWorkContext(this.stepShaping(), finalMessages, this.steps.length + 1, { model })
|
|
2306
|
+
// The closing directive is the last thing the model reads: after
|
|
2307
|
+
// the working memory and any work context above.
|
|
2308
|
+
finalMessages.push(
|
|
2309
|
+
createRuntimeContextMessage(
|
|
2310
|
+
`[SYSTEM] Turn is ending due to ${reason}. ${CLOSING_RESPONSE_GUIDANCE}`,
|
|
2311
|
+
'limit-finalization',
|
|
2312
|
+
),
|
|
2313
|
+
)
|
|
2263
2314
|
await this.reportUnsupportedToolResults(finalMessages)
|
|
2264
2315
|
|
|
2265
2316
|
// Same cache discipline as the forced-final iteration: keep the
|
|
@@ -2283,14 +2334,14 @@ export class IterationOrchestrator {
|
|
|
2283
2334
|
tools: finalTools.length > 0 ? finalTools : undefined,
|
|
2284
2335
|
...(finalEnforced ? { enforceToolInputSchema: finalEnforced } : {}),
|
|
2285
2336
|
toolChoice: finalTools.length > 0 ? 'none' : undefined,
|
|
2286
|
-
temperature: this.ctx.
|
|
2287
|
-
maxTokens: this.ctx.
|
|
2337
|
+
temperature: this.ctx.turnConfig.temperature,
|
|
2338
|
+
maxTokens: this.ctx.turnConfig.maxResponseTokens,
|
|
2288
2339
|
cacheControl: { type: 'auto' },
|
|
2289
|
-
...(this.ctx.
|
|
2340
|
+
...(this.ctx.turnConfig.thinking ? { thinking: this.ctx.turnConfig.thinking } : {}),
|
|
2290
2341
|
// This turn is a hand-maintained duplicate of the one above, which
|
|
2291
2342
|
// is exactly the shape a field goes missing from — so it is tested
|
|
2292
2343
|
// separately rather than assumed to have been kept in step.
|
|
2293
|
-
...(this.ctx.
|
|
2344
|
+
...(this.ctx.turnConfig.effort ? { effort: this.ctx.turnConfig.effort } : {}),
|
|
2294
2345
|
// Cancellable too: a Stop during the closing summary must not
|
|
2295
2346
|
// stream to completion.
|
|
2296
2347
|
signal: this.ctx.abortController.signal,
|
|
@@ -2307,7 +2358,7 @@ export class IterationOrchestrator {
|
|
|
2307
2358
|
model: servingMember.model ?? model,
|
|
2308
2359
|
chainIndex: servingMember.index,
|
|
2309
2360
|
}
|
|
2310
|
-
this.ctx.
|
|
2361
|
+
this.ctx.recorder.accumulateUsage(response.usage, {
|
|
2311
2362
|
providerId: servedBy.providerId,
|
|
2312
2363
|
model: servedBy.model,
|
|
2313
2364
|
})
|
|
@@ -2326,19 +2377,19 @@ export class IterationOrchestrator {
|
|
|
2326
2377
|
},
|
|
2327
2378
|
response.message.textParts,
|
|
2328
2379
|
)
|
|
2329
|
-
this.ctx.
|
|
2380
|
+
this.ctx.recorder.pushMessage(assistantMsg)
|
|
2330
2381
|
|
|
2331
2382
|
const finalMessageId = generateMessageId()
|
|
2332
2383
|
await this.ctx.emitEvent({
|
|
2333
2384
|
type: 'message_started',
|
|
2334
|
-
|
|
2335
|
-
iteration: this.ctx.
|
|
2385
|
+
turnId: this.ctx.recorder.turnId,
|
|
2386
|
+
iteration: this.ctx.recorder.currentIteration,
|
|
2336
2387
|
messageId: finalMessageId,
|
|
2337
2388
|
})
|
|
2338
2389
|
await this.ctx.emitEvent({
|
|
2339
2390
|
type: 'message_completed',
|
|
2340
|
-
|
|
2341
|
-
iteration: this.ctx.
|
|
2391
|
+
turnId: this.ctx.recorder.turnId,
|
|
2392
|
+
iteration: this.ctx.recorder.currentIteration,
|
|
2342
2393
|
messageId: finalMessageId,
|
|
2343
2394
|
stopReason: 'forced_finalize',
|
|
2344
2395
|
usage: response.usage,
|