@namzu/sdk 43.0.0 → 44.0.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 +506 -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 +99 -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 +121 -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 +178 -155
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +1294 -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 +32 -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 +129 -24
- 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 +3 -2
- 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 +8 -4
- package/dist/tools/task/list.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 +1139 -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/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 +116 -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 +159 -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 +1607 -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 +57 -60
- package/src/runtime/query/iteration/phases/plan.ts +9 -6
- package/src/runtime/query/iteration/phases/tool-review.ts +141 -27
- 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 +7 -3
- package/src/tools/task/index.ts +20 -4
- package/src/tools/task/list.ts +12 -6
- 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 +1187 -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/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
|
@@ -29,7 +29,7 @@ import { runIterationCheckpoint } from './phases/checkpoint.js';
|
|
|
29
29
|
import { activeContextWindow, measureContext, relieveOverflow, runCompactionCheck, } from './phases/compaction.js';
|
|
30
30
|
import { runPlanGate } from './phases/plan.js';
|
|
31
31
|
import { runToolReview } from './phases/tool-review.js';
|
|
32
|
-
import { refreshWorkingMemory } from './phases/working-memory.js';
|
|
32
|
+
import { refreshWorkingMemory, splitWorkingMemoryForRequest } from './phases/working-memory.js';
|
|
33
33
|
import { streamWithProviderRejectedImageRecovery } from './provider-rejected-image.js';
|
|
34
34
|
import { appendWorkContext, beforeStep, prepareStep, selectContextModel, stepContextMessage, } from './step-shaping.js';
|
|
35
35
|
import { streamProviderTurn } from './stream-turn.js';
|
|
@@ -46,15 +46,15 @@ class AnswerReviewFailure extends NamzuError {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* How many times an answer may be handed back before the
|
|
49
|
+
* How many times an answer may be handed back before the turn stops.
|
|
50
50
|
*
|
|
51
51
|
* Bounded for the same reason the structured-output re-prompt is: a judge
|
|
52
52
|
* that never accepts would otherwise spend the whole token budget
|
|
53
|
-
* rediscovering that, and the
|
|
53
|
+
* rediscovering that, and the turn would end on a budget error rather than
|
|
54
54
|
* on the thing that actually went wrong.
|
|
55
55
|
*/
|
|
56
56
|
const DEFAULT_ANSWER_REVIEW_LIMIT = 3;
|
|
57
|
-
// Ending a
|
|
57
|
+
// Ending a turn changes the available actions, not the strength of its evidence.
|
|
58
58
|
// Use the same standard for warning closure and empty-completion recovery.
|
|
59
59
|
const CLOSING_RESPONSE_GUIDANCE = '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.';
|
|
60
60
|
export { awaitedJobGraceMs, settleGraceMs } from './outstanding-work.js';
|
|
@@ -64,22 +64,22 @@ export class IterationOrchestrator {
|
|
|
64
64
|
/** Live only within its iteration; never joined by a guessed array offset. */
|
|
65
65
|
getAdvisoryTurnContext() {
|
|
66
66
|
const turn = this.advisoryTurn;
|
|
67
|
-
if (!turn || turn.iteration !== this.ctx.
|
|
67
|
+
if (!turn || turn.iteration !== this.ctx.recorder.currentIteration)
|
|
68
68
|
return undefined;
|
|
69
|
-
const start = this.ctx.
|
|
69
|
+
const start = this.ctx.recorder.messages.indexOf(turn.response);
|
|
70
70
|
if (start < 0)
|
|
71
71
|
return undefined;
|
|
72
72
|
return {
|
|
73
73
|
iteration: turn.iteration,
|
|
74
74
|
requestMessages: turn.requestMessages,
|
|
75
|
-
subsequentMessages: this.ctx.
|
|
75
|
+
subsequentMessages: this.ctx.recorder.messages.slice(start),
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
/** Rejections so far. See {@link DEFAULT_ANSWER_REVIEW_LIMIT}. */
|
|
79
79
|
answerReviewAttempts = 0;
|
|
80
80
|
/**
|
|
81
|
-
* The last request envelope this
|
|
82
|
-
* costs a hash and no event. Per RUNNER, not module-level: two
|
|
81
|
+
* The last request envelope this turn recorded, so an unchanged one
|
|
82
|
+
* costs a hash and no event. Per RUNNER, not module-level: two turns in
|
|
83
83
|
* one process must not suppress each other's first envelope.
|
|
84
84
|
*/
|
|
85
85
|
lastEnvelopeKey;
|
|
@@ -95,10 +95,10 @@ export class IterationOrchestrator {
|
|
|
95
95
|
/**
|
|
96
96
|
* The previous iteration held a `stopWhen` decision open for a worker.
|
|
97
97
|
*
|
|
98
|
-
* Set when the stop predicate fired and the
|
|
99
|
-
* read a delegated result, so the turn that then ends the
|
|
98
|
+
* Set when the stop predicate fired and the turn took one extra turn to
|
|
99
|
+
* read a delegated result, so the turn that then ends the turn can report
|
|
100
100
|
* WHY it is over. Without it the outcome was right and the record was
|
|
101
|
-
* wrong: the
|
|
101
|
+
* wrong: the turn stopped because the host said so and reported `end_turn`,
|
|
102
102
|
* and this repo carries thirteen `StopReason` values precisely so that a
|
|
103
103
|
* run which ends for a nameable reason names it.
|
|
104
104
|
*
|
|
@@ -185,7 +185,7 @@ export class IterationOrchestrator {
|
|
|
185
185
|
});
|
|
186
186
|
await this.ctx.emitEvent({
|
|
187
187
|
type: 'capability_warning',
|
|
188
|
-
|
|
188
|
+
turnId: this.ctx.recorder.turnId,
|
|
189
189
|
capability,
|
|
190
190
|
contentSource: 'tool-result',
|
|
191
191
|
providerId: this.ctx.provider.id,
|
|
@@ -196,18 +196,18 @@ export class IterationOrchestrator {
|
|
|
196
196
|
await report(documents, 'documents', 'document');
|
|
197
197
|
}
|
|
198
198
|
/**
|
|
199
|
-
* Adopt the
|
|
199
|
+
* Adopt the turn's span after construction.
|
|
200
200
|
*
|
|
201
201
|
* The orchestrator is built before `query()` enters its generator body,
|
|
202
|
-
* which is where the
|
|
202
|
+
* which is where the turn span is created — so the parent cannot be a
|
|
203
203
|
* constructor argument without reordering setup around one field.
|
|
204
204
|
*/
|
|
205
205
|
setRootSpan(span) {
|
|
206
206
|
this.ctx = { ...this.ctx, rootSpan: span };
|
|
207
207
|
}
|
|
208
208
|
async *runLoop() {
|
|
209
|
-
const {
|
|
210
|
-
const { model } =
|
|
209
|
+
const { turnConfig, recorder } = this.ctx;
|
|
210
|
+
const { model } = turnConfig;
|
|
211
211
|
const tracer = getTracer();
|
|
212
212
|
// Resume hydration happens after construction, before the loop starts.
|
|
213
213
|
this.latestUserMessage = this.ctx.checkpointMgr.restoredLatestUserMessage;
|
|
@@ -215,7 +215,7 @@ export class IterationOrchestrator {
|
|
|
215
215
|
this.structuredReviewAttempts = this.ctx.checkpointMgr.restoredStructuredReviewAttempts ?? 0;
|
|
216
216
|
this.nativeStructuredAttempts = this.ctx.checkpointMgr.restoredNativeStructuredAttempts ?? 0;
|
|
217
217
|
if (!this.latestUserMessage) {
|
|
218
|
-
for (const message of
|
|
218
|
+
for (const message of recorder.messages)
|
|
219
219
|
this.rememberUserMessage(message, false);
|
|
220
220
|
}
|
|
221
221
|
// The restored field can outlive the historical message it describes.
|
|
@@ -223,15 +223,21 @@ export class IterationOrchestrator {
|
|
|
223
223
|
// retained user turn encountered while scanning restored history.
|
|
224
224
|
for (const message of this.ctx.resumedInput ?? [])
|
|
225
225
|
this.rememberUserMessage(message);
|
|
226
|
-
//
|
|
226
|
+
// What a recoverable failure pauses on when it lands before this
|
|
227
|
+
// loop wrote a checkpoint of its own: without it a 429 on the first
|
|
228
|
+
// request failed the turn, while the same 429 one request later
|
|
229
|
+
// paused it. Taken after the intent above is known, so the
|
|
230
|
+
// checkpoint names the message the turn is answering.
|
|
231
|
+
await this.ctx.checkpointMgr.markLoopStart?.(recorder);
|
|
232
|
+
// One context-overflow relief per *stuck point*, not per turn.
|
|
227
233
|
//
|
|
228
234
|
// The latch exists so that a second overflow immediately after a
|
|
229
235
|
// successful compaction — meaning the prompt is irreducible — stops
|
|
230
236
|
// instead of looping. It was never meant to disarm the mechanism for
|
|
231
|
-
// the rest of the
|
|
237
|
+
// the rest of the turn, which is what a turn-scoped flag did: one
|
|
232
238
|
// relief at iteration 3 left iteration 40 to die on an overflow with
|
|
233
239
|
// obvious moves left. It is cleared by a turn that actually
|
|
234
|
-
// succeeded, which is the evidence that the
|
|
240
|
+
// succeeded, which is the evidence that the turn is no longer stuck.
|
|
235
241
|
let overflowRelieved = false;
|
|
236
242
|
const planSignal = yield* runPlanGate(this.ctx);
|
|
237
243
|
if (planSignal === 'stop')
|
|
@@ -240,7 +246,7 @@ export class IterationOrchestrator {
|
|
|
240
246
|
// beside `iterSpan.end()` below: this loop leaves by eight `break`s,
|
|
241
247
|
// two `return`s and a `throw`, and a rule every future edit has to
|
|
242
248
|
// remember is a rule that gets forgotten — measured, it had been. Only
|
|
243
|
-
// the ordinary final-answer exit consulted the inbox, so a
|
|
249
|
+
// the ordinary final-answer exit consulted the inbox, so a turn that
|
|
244
250
|
// ended on a terminal tool, a structured output or the host's
|
|
245
251
|
// `stopWhen` settled over a finished worker's output and threw it away.
|
|
246
252
|
// A `finally` also covers a generator abandoned by its consumer, which
|
|
@@ -248,24 +254,24 @@ export class IterationOrchestrator {
|
|
|
248
254
|
try {
|
|
249
255
|
while (true) {
|
|
250
256
|
if (this.ctx.abortController.signal.aborted) {
|
|
251
|
-
|
|
252
|
-
|
|
257
|
+
recorder.setStopReason('cancelled');
|
|
258
|
+
recorder.markCancelled();
|
|
253
259
|
break;
|
|
254
260
|
}
|
|
255
261
|
if (this.ctx.structuredOutput?.mode === 'native' &&
|
|
256
262
|
this.nativeStructuredAttempts > this.structuredOutputRetryLimit()) {
|
|
257
|
-
|
|
263
|
+
recorder.setStopReason('structured_output_failed');
|
|
258
264
|
break;
|
|
259
265
|
}
|
|
260
266
|
if (this.ctx.reviewAnswer &&
|
|
261
267
|
this.answerReviewAttempts > (this.ctx.maxAnswerReviews ?? DEFAULT_ANSWER_REVIEW_LIMIT)) {
|
|
262
|
-
|
|
268
|
+
recorder.setStopReason('answer_rejected');
|
|
263
269
|
break;
|
|
264
270
|
}
|
|
265
271
|
if (this.ctx.structuredOutput?.review &&
|
|
266
272
|
this.structuredReviewAttempts >
|
|
267
273
|
(this.ctx.structuredOutput.maxReviews ?? DEFAULT_ANSWER_REVIEW_LIMIT)) {
|
|
268
|
-
|
|
274
|
+
recorder.setStopReason('answer_rejected');
|
|
269
275
|
break;
|
|
270
276
|
}
|
|
271
277
|
// Read AND clear, in that order, in this one place.
|
|
@@ -281,28 +287,28 @@ export class IterationOrchestrator {
|
|
|
281
287
|
// path by which a stale deferral can reach a later turn.
|
|
282
288
|
const stopWasDeferredForOutstandingWork = this.stopDeferredForOutstandingWork;
|
|
283
289
|
this.stopDeferredForOutstandingWork = false;
|
|
284
|
-
const guardResult = this.ctx.guard.beforeIteration(
|
|
290
|
+
const guardResult = this.ctx.guard.beforeIteration(recorder, this.ctx.abortController.signal);
|
|
285
291
|
if (guardResult.shouldStop) {
|
|
286
292
|
if (guardResult.isCancelled) {
|
|
287
|
-
this.ctx.log.info('
|
|
288
|
-
[NAMZU.
|
|
293
|
+
this.ctx.log.info('Turn cancelled by signal', {
|
|
294
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
289
295
|
});
|
|
290
|
-
|
|
291
|
-
|
|
296
|
+
recorder.setStopReason('cancelled');
|
|
297
|
+
recorder.markCancelled();
|
|
292
298
|
break;
|
|
293
299
|
}
|
|
294
300
|
const stopReason = guardResult.stopReason ?? 'end_turn';
|
|
295
301
|
this.ctx.log.info('Guard enforcing stop', {
|
|
296
|
-
[NAMZU.
|
|
302
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
297
303
|
'namzu.runtime.stop_reason': stopReason,
|
|
298
|
-
[NAMZU.ITERATION]:
|
|
299
|
-
'namzu.runtime.input_tokens':
|
|
300
|
-
'namzu.runtime.output_tokens':
|
|
304
|
+
[NAMZU.ITERATION]: recorder.currentIteration,
|
|
305
|
+
'namzu.runtime.input_tokens': recorder.tokenUsage.promptTokens,
|
|
306
|
+
'namzu.runtime.output_tokens': recorder.tokenUsage.completionTokens,
|
|
301
307
|
});
|
|
302
308
|
// A hard stop has no budget left for another model request.
|
|
303
309
|
// Closing prose is requested at the warning threshold while
|
|
304
310
|
// headroom remains; the completed work is already in history.
|
|
305
|
-
|
|
311
|
+
recorder.setStopReason(stopReason);
|
|
306
312
|
break;
|
|
307
313
|
}
|
|
308
314
|
// Consulted here, after the guard and BEFORE the iteration is
|
|
@@ -310,13 +316,13 @@ export class IterationOrchestrator {
|
|
|
310
316
|
// and so can only speak after the step it disliked has already
|
|
311
317
|
// run and been paid for; this is the seam a host with a live
|
|
312
318
|
// rate limit or a revoked tenant actually needs.
|
|
313
|
-
const veto = await beforeStep(this.stepShaping(),
|
|
314
|
-
// The hook may settle because its
|
|
319
|
+
const veto = await beforeStep(this.stepShaping(), recorder.currentIteration + 1);
|
|
320
|
+
// The hook may settle because its turn signal was aborted. Stop
|
|
315
321
|
// before interpreting that settlement as a policy refusal or
|
|
316
322
|
// counting an iteration that will never reach the provider.
|
|
317
323
|
if (this.ctx.abortController.signal.aborted) {
|
|
318
|
-
|
|
319
|
-
|
|
324
|
+
recorder.setStopReason('cancelled');
|
|
325
|
+
recorder.markCancelled();
|
|
320
326
|
break;
|
|
321
327
|
}
|
|
322
328
|
if (veto) {
|
|
@@ -324,22 +330,22 @@ export class IterationOrchestrator {
|
|
|
324
330
|
// the frozen inventory LOG-22 exists to drain; a new call site
|
|
325
331
|
// has no reason to join it.
|
|
326
332
|
this.ctx.log.info('Step refused by beforeStep', {
|
|
327
|
-
[NAMZU.
|
|
328
|
-
[NAMZU.ITERATION]:
|
|
333
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
334
|
+
[NAMZU.ITERATION]: recorder.currentIteration + 1,
|
|
329
335
|
'namzu.step.veto_reason': veto.reason,
|
|
330
336
|
});
|
|
331
|
-
|
|
332
|
-
|
|
337
|
+
recorder.setLastError(`beforeStep refused the next step: ${veto.reason}`);
|
|
338
|
+
recorder.setStopReason('step_refused');
|
|
333
339
|
break;
|
|
334
340
|
}
|
|
335
341
|
const forceFinalize = guardResult.forceFinalize;
|
|
336
|
-
const iterationNum =
|
|
342
|
+
const iterationNum = recorder.incrementIteration();
|
|
337
343
|
this.ctx.log.debug('Iteration started', {
|
|
338
|
-
[NAMZU.
|
|
344
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
339
345
|
[NAMZU.ITERATION]: iterationNum,
|
|
340
346
|
[GENAI.REQUEST_MODEL]: model,
|
|
341
347
|
'namzu.runtime.force_finalize': forceFinalize,
|
|
342
|
-
'namzu.runtime.message_count':
|
|
348
|
+
'namzu.runtime.message_count': recorder.messages.length,
|
|
343
349
|
});
|
|
344
350
|
const iterationActivity = this.ctx.activityStore.create({
|
|
345
351
|
type: 'llm_turn',
|
|
@@ -350,7 +356,7 @@ export class IterationOrchestrator {
|
|
|
350
356
|
}
|
|
351
357
|
// Parent explicitly: this body is an async generator, so the
|
|
352
358
|
// ambient context at resume time belongs to the CONSUMER, not to
|
|
353
|
-
// whoever created the
|
|
359
|
+
// whoever created the turn span. Without this every iteration
|
|
354
360
|
// emits as its own root and a 20-turn run shows up as 21
|
|
355
361
|
// disconnected traces.
|
|
356
362
|
const iterSpan = tracer.startSpan(agentIterationSpanName(iterationNum), {}, parentContext(this.ctx.rootSpan));
|
|
@@ -370,8 +376,8 @@ export class IterationOrchestrator {
|
|
|
370
376
|
// where they always did, so compaction and the working-memory
|
|
371
377
|
// refresh stay outside a successful step's window.
|
|
372
378
|
let stepStartedAt = Date.now();
|
|
373
|
-
let usageBefore = { ...
|
|
374
|
-
let costBefore = { ...
|
|
379
|
+
let usageBefore = { ...recorder.tokenUsage };
|
|
380
|
+
let costBefore = { ...recorder.costInfo };
|
|
375
381
|
let stepModel = model;
|
|
376
382
|
let stepMessageId;
|
|
377
383
|
let stepResponse;
|
|
@@ -381,22 +387,24 @@ export class IterationOrchestrator {
|
|
|
381
387
|
// the try rather than before it: a throw from any of these left
|
|
382
388
|
// the span open, and an iteration span that never ends is a
|
|
383
389
|
// trace that never closes — the export is incomplete for exactly
|
|
384
|
-
// the
|
|
390
|
+
// the turn that failed.
|
|
385
391
|
this.ctx.toolExecutor.setParentSpan(iterSpan);
|
|
386
392
|
iterSpan.setAttributes({
|
|
387
393
|
[NAMZU.ITERATION]: iterationNum,
|
|
388
|
-
[
|
|
394
|
+
[GENAI.CONVERSATION_ID]: recorder.sessionId,
|
|
395
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
389
396
|
[GENAI.REQUEST_MODEL]: model,
|
|
390
397
|
});
|
|
391
398
|
await this.ctx.emitEvent({
|
|
392
399
|
type: 'iteration_started',
|
|
393
|
-
|
|
400
|
+
turnId: recorder.turnId,
|
|
394
401
|
iteration: iterationNum,
|
|
395
402
|
});
|
|
396
403
|
yield* this.ctx.drainPending();
|
|
397
404
|
if (this.ctx.pluginManager) {
|
|
398
405
|
const hookResults = await this.ctx.pluginManager.executeHooks('iteration_start', {
|
|
399
|
-
|
|
406
|
+
sessionId: recorder.sessionId,
|
|
407
|
+
turnId: recorder.turnId,
|
|
400
408
|
iteration: iterationNum,
|
|
401
409
|
signal: this.ctx.abortController.signal,
|
|
402
410
|
}, this.ctx.emitEvent);
|
|
@@ -416,16 +424,16 @@ export class IterationOrchestrator {
|
|
|
416
424
|
// risks a 400 because the history still carries
|
|
417
425
|
// tool_use/tool_result blocks.
|
|
418
426
|
// Snapshot the cumulative counters so the step can report ITS
|
|
419
|
-
// own usage rather than the
|
|
427
|
+
// own usage rather than the turn total.
|
|
420
428
|
stepStartedAt = Date.now();
|
|
421
429
|
// Shape this step before calling the model. `stopWhen` decides
|
|
422
430
|
// whether to keep going; this decides HOW. No-op when the host
|
|
423
431
|
// supplied no hook.
|
|
424
432
|
const contextModelBeforePreparation = this.ctx.contextModel ?? model;
|
|
425
433
|
const step = await prepareStep(this.stepShaping(), iterationNum);
|
|
426
|
-
// Preparation inference belongs to the
|
|
427
|
-
usageBefore = { ...
|
|
428
|
-
costBefore = { ...
|
|
434
|
+
// Preparation inference belongs to the turn, not the main-model step.
|
|
435
|
+
usageBefore = { ...recorder.tokenUsage };
|
|
436
|
+
costBefore = { ...recorder.costInfo };
|
|
429
437
|
stepModel = step.model ?? model;
|
|
430
438
|
await selectContextModel(this.stepShaping(), stepModel);
|
|
431
439
|
// Preserve post-compaction preparation/recall semantics. A changed
|
|
@@ -447,16 +455,17 @@ export class IterationOrchestrator {
|
|
|
447
455
|
this.ctx.toolExecutor.setStepAllowedTools(stepAllowedTools);
|
|
448
456
|
const enforceToolInputSchema = enforcedModelInputToolNames(this.ctx.tools, llmTools);
|
|
449
457
|
stepModel = step.model ?? model;
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
]
|
|
455
|
-
:
|
|
458
|
+
// The closing directive is appended LAST, after every piece of
|
|
459
|
+
// request-only context below, so it is the final thing the model
|
|
460
|
+
// reads on a forced-final step.
|
|
461
|
+
const closingDirective = forceFinalize
|
|
462
|
+
? createRuntimeContextMessage(`[SYSTEM] You are approaching your resource limits. ${CLOSING_RESPONSE_GUIDANCE}`, 'limit-finalization')
|
|
463
|
+
: undefined;
|
|
464
|
+
const baseMessages = recorder.messages;
|
|
456
465
|
// Step guidance is appended to the REQUEST, never pushed onto
|
|
457
|
-
// the
|
|
466
|
+
// the turn's history: it applies to this step only, and pushing
|
|
458
467
|
// it would accumulate one stale instruction per iteration.
|
|
459
|
-
// Copy before it crosses the provider boundary. `
|
|
468
|
+
// Copy before it crosses the provider boundary. `recorder.messages`
|
|
460
469
|
// is the LIVE run array, and the loop pushes onto it after the
|
|
461
470
|
// call returns — so a driver that retains what it was handed
|
|
462
471
|
// (to log it, cache it, or replay it on retry) watched its own
|
|
@@ -476,7 +485,7 @@ export class IterationOrchestrator {
|
|
|
476
485
|
// A supervision change rides the same ephemeral slot, and for
|
|
477
486
|
// the same reason: it applies to what happens next, not to the
|
|
478
487
|
// run's history. The model plans around how closely it is being
|
|
479
|
-
// watched — a
|
|
488
|
+
// watched — a turn that silently stops asking a human leaves it
|
|
480
489
|
// batching destructive calls it expects to be reviewed, and one
|
|
481
490
|
// that silently starts leaves it waiting on permission nobody
|
|
482
491
|
// is left to give.
|
|
@@ -488,35 +497,55 @@ export class IterationOrchestrator {
|
|
|
488
497
|
const policyNotice = policyChange
|
|
489
498
|
? `Approval policy changed from "${policyChange.from}" to "${policyChange.to}" (${policyChange.reason}). Tool calls from here on are reviewed under the new policy.`
|
|
490
499
|
: null;
|
|
491
|
-
// State that changed during the
|
|
500
|
+
// State that changed during the turn, reported once per turn.
|
|
492
501
|
// `turn` contributions are recomputed here, not fixed when the
|
|
493
502
|
// run's prompt is assembled. They retain system authority and
|
|
494
503
|
// may affect caching just like the other system contributions.
|
|
495
504
|
const turnSections = this.ctx.promptContributions?.render('turn', {
|
|
496
505
|
iteration: iterationNum,
|
|
497
506
|
}) ?? [];
|
|
507
|
+
// Request-only context: observations that need no system
|
|
508
|
+
// authority and change from request to request. They ride
|
|
509
|
+
// runtime-context messages of kind `step-context` after the
|
|
510
|
+
// history, which every driver keeps there and a caching driver
|
|
511
|
+
// ends its breakpoint before — so a changed pin or a new turn
|
|
512
|
+
// snapshot costs its own tokens, not a re-read of the history.
|
|
513
|
+
// The working-memory slot keeps its place in the turn's history
|
|
514
|
+
// (compaction preserves it there) and leaves the request's
|
|
515
|
+
// system run here.
|
|
516
|
+
const workingMemory = splitWorkingMemoryForRequest(baseMessages);
|
|
517
|
+
const contextSections = this.ctx.promptContributions?.render('context', {
|
|
518
|
+
iteration: iterationNum,
|
|
519
|
+
}) ?? [];
|
|
498
520
|
const stepPreamble = [step.system, stepSkills, policyNotice, ...turnSections]
|
|
499
521
|
.filter(Boolean)
|
|
500
522
|
.join('\n\n');
|
|
501
523
|
const requestHistory = stepPreamble
|
|
502
|
-
? [...
|
|
503
|
-
: [...
|
|
524
|
+
? [...workingMemory.history, createSystemMessage(stepPreamble)]
|
|
525
|
+
: [...workingMemory.history];
|
|
526
|
+
if (workingMemory.context)
|
|
527
|
+
requestHistory.push(workingMemory.context);
|
|
528
|
+
if (contextSections.length > 0)
|
|
529
|
+
requestHistory.push(stepContextMessage(contextSections.join('\n\n')));
|
|
504
530
|
if (step.context)
|
|
505
531
|
requestHistory.push(stepContextMessage(step.context));
|
|
506
|
-
const messages = projectRequestRichContent(this.projectObservations(requestHistory), this.ctx.
|
|
532
|
+
const messages = projectRequestRichContent(this.projectObservations(requestHistory), this.ctx.turnConfig.maxRequestRichContentBytes ??
|
|
533
|
+
DEFAULT_MAX_REQUEST_RICH_CONTENT_BYTES);
|
|
507
534
|
appendWorkContext(this.stepShaping(), messages, iterationNum, step);
|
|
535
|
+
if (closingDirective)
|
|
536
|
+
messages.push(closingDirective);
|
|
508
537
|
await this.reportUnsupportedToolResults(messages);
|
|
509
538
|
yield* this.ctx.drainPending();
|
|
510
539
|
// What the model is about to be ASKED, recorded when it
|
|
511
|
-
// changed. `
|
|
540
|
+
// changed. `turn_started` carries one system prompt and tool
|
|
512
541
|
// schemas never reached the transcript at all — while
|
|
513
542
|
// `prepareStep` rewrites the system text, narrows the tool
|
|
514
543
|
// list or swaps the model, and a step's skills ride the
|
|
515
544
|
// ephemeral preamble above. So a transcript showed one
|
|
516
|
-
// question for a
|
|
545
|
+
// question for a turn that had asked several.
|
|
517
546
|
//
|
|
518
547
|
// Emitted only on a change: the digest is compared against
|
|
519
|
-
// the last one this
|
|
548
|
+
// the last one this turn recorded, so the common case costs
|
|
520
549
|
// one hash and nothing else. Copying an unchanged system
|
|
521
550
|
// prompt every iteration is the fastest way to make a
|
|
522
551
|
// durable log too large to read.
|
|
@@ -524,7 +553,7 @@ export class IterationOrchestrator {
|
|
|
524
553
|
model: stepModel,
|
|
525
554
|
// Read off `messages`, which is what the request is actually
|
|
526
555
|
// built from — including the ephemeral preamble. Recomputing
|
|
527
|
-
// it from the
|
|
556
|
+
// it from the turn's history would describe a request nobody
|
|
528
557
|
// sent the moment the two diverge.
|
|
529
558
|
systemPrompt: messages
|
|
530
559
|
.filter((m) => m.role === 'system')
|
|
@@ -541,7 +570,7 @@ export class IterationOrchestrator {
|
|
|
541
570
|
this.lastEnvelopeKey = envelopeKey;
|
|
542
571
|
await this.ctx.emitEvent?.({
|
|
543
572
|
type: 'request_envelope',
|
|
544
|
-
|
|
573
|
+
turnId: recorder.turnId,
|
|
545
574
|
iteration: iterationNum,
|
|
546
575
|
...envelope,
|
|
547
576
|
toolNames: Object.freeze([...envelope.toolNames]),
|
|
@@ -559,21 +588,22 @@ export class IterationOrchestrator {
|
|
|
559
588
|
});
|
|
560
589
|
this.previousRequestContext = snapshot;
|
|
561
590
|
const hookResults = await this.ctx.pluginManager.executeHooks('pre_llm_call', {
|
|
562
|
-
|
|
591
|
+
sessionId: recorder.sessionId,
|
|
592
|
+
turnId: recorder.turnId,
|
|
563
593
|
iteration: iterationNum,
|
|
564
594
|
signal: this.ctx.abortController.signal,
|
|
565
|
-
// Built inside the guard: a
|
|
595
|
+
// Built inside the guard: a turn with no plugins installed
|
|
566
596
|
// pays nothing for a projection nobody reads.
|
|
567
597
|
request: Object.freeze({
|
|
568
598
|
context,
|
|
569
599
|
model: stepModel,
|
|
570
600
|
// Copied per turn, not handed over live: these are the
|
|
571
601
|
// run's own message objects, and a hook writing into
|
|
572
|
-
// one would edit the history the
|
|
602
|
+
// one would edit the history the turn is about to send.
|
|
573
603
|
messages: Object.freeze(messages.map((m) => Object.freeze({ ...m }))),
|
|
574
604
|
toolNames: Object.freeze(llmTools.map((t) => t.function.name)),
|
|
575
|
-
temperature: step.temperature ??
|
|
576
|
-
maxTokens: step.maxResponseTokens ??
|
|
605
|
+
temperature: step.temperature ?? turnConfig.temperature,
|
|
606
|
+
maxTokens: step.maxResponseTokens ?? turnConfig.maxResponseTokens,
|
|
577
607
|
}),
|
|
578
608
|
}, this.ctx.emitEvent);
|
|
579
609
|
applyLifecycleHookResults('pre_llm_call', hookResults);
|
|
@@ -582,7 +612,7 @@ export class IterationOrchestrator {
|
|
|
582
612
|
// Phase 4 (ses_001-tool-stream-events): consume the
|
|
583
613
|
// streaming response natively, emitting message and
|
|
584
614
|
// tool-input lifecycle events as deltas arrive. The
|
|
585
|
-
// helper yields
|
|
615
|
+
// helper yields SessionEvents through drainPending() so SSE
|
|
586
616
|
// consumers see live progress; its return value is the
|
|
587
617
|
// aggregated `ChatCompletionResponse` for the legacy
|
|
588
618
|
// downstream paths (assistantMsg construction, working
|
|
@@ -638,19 +668,21 @@ export class IterationOrchestrator {
|
|
|
638
668
|
: llmTools.length > 0
|
|
639
669
|
? step.toolChoice
|
|
640
670
|
: undefined,
|
|
641
|
-
temperature: step.temperature ??
|
|
642
|
-
maxTokens: step.maxResponseTokens ??
|
|
671
|
+
temperature: step.temperature ?? turnConfig.temperature,
|
|
672
|
+
maxTokens: step.maxResponseTokens ?? turnConfig.maxResponseTokens,
|
|
643
673
|
cacheControl: { type: 'auto' },
|
|
644
|
-
...(
|
|
645
|
-
...(
|
|
646
|
-
...(!forceFinalize &&
|
|
647
|
-
|
|
674
|
+
...(turnConfig.thinking ? { thinking: turnConfig.thinking } : {}),
|
|
675
|
+
...(turnConfig.effort ? { effort: turnConfig.effort } : {}),
|
|
676
|
+
...(!forceFinalize && turnConfig.webSearch
|
|
677
|
+
? { webSearch: turnConfig.webSearch }
|
|
678
|
+
: {}),
|
|
679
|
+
// Thread the turn abort into the model call so a Stop tears the
|
|
648
680
|
// in-flight turn down (provider passes it to fetch; the consumer
|
|
649
681
|
// also races it). Inert when never aborted.
|
|
650
682
|
signal: this.ctx.abortController.signal,
|
|
651
|
-
}, this.ctx.emitEvent, this.ctx.drainPending,
|
|
683
|
+
}, this.ctx.emitEvent, this.ctx.drainPending, recorder.turnId, iterationNum, forceFinalize, this.ctx.log, iterSpan, stepMessageId, {
|
|
652
684
|
onAccepted: (identity) => this.acceptProviderRejectedImage(identity),
|
|
653
|
-
}, Boolean(this.ctx.reviewAnswer || this.ctx.structuredOutput?.review || this.ctx.advisoryCtx));
|
|
685
|
+
}, Boolean(this.ctx.reviewAnswer || this.ctx.structuredOutput?.review || this.ctx.advisoryCtx), recorder.sessionId);
|
|
654
686
|
stepResponse = response;
|
|
655
687
|
const reviewRequest = {
|
|
656
688
|
...(requestMessages ? { requestMessages } : {}),
|
|
@@ -688,17 +720,18 @@ export class IterationOrchestrator {
|
|
|
688
720
|
// model it was asked for. This is the seam that ended the
|
|
689
721
|
// always-zero cost: the rate lookup happens per turn,
|
|
690
722
|
// against who actually answered, rather than against one
|
|
691
|
-
// table the
|
|
692
|
-
|
|
723
|
+
// table the turn was constructed with.
|
|
724
|
+
recorder.recordTurnUsage(response.usage, {
|
|
693
725
|
providerId: servedBy.providerId,
|
|
694
726
|
model: servedBy.model,
|
|
695
727
|
});
|
|
696
|
-
// The turn went through, so the
|
|
728
|
+
// The turn went through, so the turn is not sitting on an
|
|
697
729
|
// irreducible prompt any more. Re-arm relief for the next one.
|
|
698
730
|
overflowRelieved = false;
|
|
699
731
|
if (this.ctx.pluginManager) {
|
|
700
732
|
const hookResults = await this.ctx.pluginManager.executeHooks('post_llm_call', {
|
|
701
|
-
|
|
733
|
+
sessionId: recorder.sessionId,
|
|
734
|
+
turnId: recorder.turnId,
|
|
702
735
|
iteration: iterationNum,
|
|
703
736
|
signal: this.ctx.abortController.signal,
|
|
704
737
|
response: Object.freeze({
|
|
@@ -712,15 +745,15 @@ export class IterationOrchestrator {
|
|
|
712
745
|
yield* this.ctx.drainPending();
|
|
713
746
|
}
|
|
714
747
|
this.ctx.log.debug('LLM response received', {
|
|
715
|
-
[NAMZU.
|
|
748
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
716
749
|
[NAMZU.ITERATION]: iterationNum,
|
|
717
750
|
'namzu.runtime.finish_reason': response.finishReason,
|
|
718
751
|
'namzu.runtime.has_content': response.message.content !== null && response.message.content.length > 0,
|
|
719
752
|
'namzu.runtime.tool_call_count': response.message.toolCalls?.length ?? 0,
|
|
720
753
|
[GENAI.USAGE_INPUT_TOKENS]: response.usage.promptTokens,
|
|
721
754
|
[GENAI.USAGE_OUTPUT_TOKENS]: response.usage.completionTokens,
|
|
722
|
-
'namzu.usage.total_tokens':
|
|
723
|
-
'namzu.runtime.total_cost':
|
|
755
|
+
'namzu.usage.total_tokens': recorder.tokenUsage.totalTokens,
|
|
756
|
+
'namzu.runtime.total_cost': recorder.costInfo.totalCost,
|
|
724
757
|
});
|
|
725
758
|
// The context figures ride with the spend figures because a
|
|
726
759
|
// surface showing one almost always wants the other — and
|
|
@@ -729,7 +762,7 @@ export class IterationOrchestrator {
|
|
|
729
762
|
// are measured here rather than left to be derived, since the
|
|
730
763
|
// only correct derivation needs internals a host cannot see.
|
|
731
764
|
//
|
|
732
|
-
// Absent when the
|
|
765
|
+
// Absent when the turn has no compaction config: nothing then
|
|
733
766
|
// resolves a window, and inventing one would be the guess this
|
|
734
767
|
// replaces.
|
|
735
768
|
const contextFigures = this.ctx.compactionConfig
|
|
@@ -746,10 +779,10 @@ export class IterationOrchestrator {
|
|
|
746
779
|
: {};
|
|
747
780
|
await this.ctx.emitEvent({
|
|
748
781
|
type: 'token_usage_updated',
|
|
749
|
-
|
|
750
|
-
usage:
|
|
751
|
-
budget:
|
|
752
|
-
cost:
|
|
782
|
+
turnId: recorder.turnId,
|
|
783
|
+
usage: recorder.tokenUsage,
|
|
784
|
+
budget: recorder.budget?.summary(),
|
|
785
|
+
cost: recorder.costInfo,
|
|
753
786
|
...contextFigures,
|
|
754
787
|
});
|
|
755
788
|
// Durable reasoning and its adapter-private replay envelope ride
|
|
@@ -767,7 +800,7 @@ export class IterationOrchestrator {
|
|
|
767
800
|
? { replayState: response.message.replayState }
|
|
768
801
|
: {}),
|
|
769
802
|
}, response.message.textParts);
|
|
770
|
-
|
|
803
|
+
recorder.pushMessage(assistantMsg);
|
|
771
804
|
if (this.ctx.advisoryCtx && requestMessages) {
|
|
772
805
|
this.advisoryTurn = { iteration: iterationNum, requestMessages, response: assistantMsg };
|
|
773
806
|
}
|
|
@@ -806,15 +839,15 @@ export class IterationOrchestrator {
|
|
|
806
839
|
// Every task-dispatch tool (create_task, continue_task, Agent)
|
|
807
840
|
// is BLOCKING: the worker's output returns as the dispatching
|
|
808
841
|
// tool_use's canonical tool_result, so by the time the model
|
|
809
|
-
// ends its turn nothing launched by this
|
|
842
|
+
// ends its turn nothing launched by this turn should still be
|
|
810
843
|
// in flight. A running task here is an orphan (interrupted
|
|
811
844
|
// tool execution, cancel race) with no delivery path back to
|
|
812
845
|
// the parent — the <task-notification> producer was removed
|
|
813
846
|
// in dc16d58, so waiting on the queue could only ever time
|
|
814
847
|
// out. Log the orphans honestly and end the turn normally.
|
|
815
848
|
if (!forceFinalize && this.hasRunningAgentTasks()) {
|
|
816
|
-
this.ctx.log.warn('LLM ended turn with agent tasks still running — ending
|
|
817
|
-
[NAMZU.
|
|
849
|
+
this.ctx.log.warn('LLM ended turn with agent tasks still running — ending turn without waiting (orphan tasks have no delivery path)', {
|
|
850
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
818
851
|
[NAMZU.ITERATION]: iterationNum,
|
|
819
852
|
});
|
|
820
853
|
}
|
|
@@ -823,7 +856,7 @@ export class IterationOrchestrator {
|
|
|
823
856
|
// It did not, and the ledger's own contract said it should:
|
|
824
857
|
// `StepResult` is documented as "what one iteration of the
|
|
825
858
|
// agent loop did" and `stepNumber` as "1-based, matching
|
|
826
|
-
// `iteration` on the
|
|
859
|
+
// `iteration` on the turn events". Every path below emits
|
|
827
860
|
// `iteration_completed` with this iteration's number, and
|
|
828
861
|
// none of them recorded a step — so the events said
|
|
829
862
|
// iteration N happened and `steps` had no entry N. The
|
|
@@ -855,7 +888,7 @@ export class IterationOrchestrator {
|
|
|
855
888
|
// executor, and the empty-completion retry a few lines below
|
|
856
889
|
// all spend tokens inside an iteration without being one.
|
|
857
890
|
// Their usage reaches `run.tokenUsage` and no step, so the
|
|
858
|
-
// ledger reconciles with the
|
|
891
|
+
// ledger reconciles with the turn total for a turn that makes
|
|
859
892
|
// no side calls and undercounts by exactly those calls for a
|
|
860
893
|
// run that does. That residual is named rather than fixed
|
|
861
894
|
// here: attributing a side call needs a record that is not a
|
|
@@ -879,11 +912,11 @@ export class IterationOrchestrator {
|
|
|
879
912
|
outcome = await this.reviewStructuredOutput(candidate.value, reviewRequest, stepModel);
|
|
880
913
|
else {
|
|
881
914
|
this.nativeStructuredAttempts++;
|
|
882
|
-
|
|
883
|
-
const checkpoint = await this.ctx.checkpointMgr.create(
|
|
915
|
+
recorder.pushMessage(createRuntimeContextMessage('Return a complete JSON value matching the supplied response schema. Do not continue a partial JSON fragment.', 'structured-output'));
|
|
916
|
+
const checkpoint = await this.ctx.checkpointMgr.create(recorder, iterationNum);
|
|
884
917
|
await this.ctx.emitEvent({
|
|
885
918
|
type: 'checkpoint_created',
|
|
886
|
-
|
|
919
|
+
turnId: recorder.turnId,
|
|
887
920
|
checkpointId: checkpoint.id,
|
|
888
921
|
iteration: iterationNum,
|
|
889
922
|
});
|
|
@@ -894,14 +927,14 @@ export class IterationOrchestrator {
|
|
|
894
927
|
}
|
|
895
928
|
await this.ctx.emitEvent({
|
|
896
929
|
type: 'iteration_completed',
|
|
897
|
-
|
|
930
|
+
turnId: recorder.turnId,
|
|
898
931
|
iteration: iterationNum,
|
|
899
932
|
hasToolCalls: false,
|
|
900
933
|
});
|
|
901
934
|
yield* this.ctx.drainPending();
|
|
902
935
|
if (this.ctx.abortController.signal.aborted || outcome === 'cancelled') {
|
|
903
|
-
|
|
904
|
-
|
|
936
|
+
recorder.setStopReason('cancelled');
|
|
937
|
+
recorder.markCancelled();
|
|
905
938
|
break;
|
|
906
939
|
}
|
|
907
940
|
if (outcome === 'accepted') {
|
|
@@ -912,16 +945,16 @@ export class IterationOrchestrator {
|
|
|
912
945
|
continue;
|
|
913
946
|
}
|
|
914
947
|
if (this.ctx.abortController.signal.aborted) {
|
|
915
|
-
|
|
916
|
-
|
|
948
|
+
recorder.setStopReason('cancelled');
|
|
949
|
+
recorder.markCancelled();
|
|
917
950
|
break;
|
|
918
951
|
}
|
|
919
952
|
this.publishStructuredOutput();
|
|
920
|
-
|
|
953
|
+
recorder.setStopReason('end_turn');
|
|
921
954
|
break;
|
|
922
955
|
}
|
|
923
956
|
if (outcome === 'exhausted') {
|
|
924
|
-
|
|
957
|
+
recorder.setStopReason(candidate.success ? 'answer_rejected' : 'structured_output_failed');
|
|
925
958
|
break;
|
|
926
959
|
}
|
|
927
960
|
continue;
|
|
@@ -948,14 +981,14 @@ export class IterationOrchestrator {
|
|
|
948
981
|
// - max_iterations bounds the loop in any case.
|
|
949
982
|
if (!forceFinalize && response.finishReason === 'length' && hasContent) {
|
|
950
983
|
this.ctx.log.info('LLM hit max_tokens mid-text — auto-continuing', {
|
|
951
|
-
[NAMZU.
|
|
984
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
952
985
|
[NAMZU.ITERATION]: iterationNum,
|
|
953
986
|
[GENAI.USAGE_OUTPUT_TOKENS]: response.usage.completionTokens,
|
|
954
987
|
});
|
|
955
|
-
|
|
988
|
+
recorder.pushMessage(createRuntimeContextMessage(AUTO_CONTINUATION_USER_MESSAGE, 'auto-continuation'));
|
|
956
989
|
await this.ctx.emitEvent({
|
|
957
990
|
type: 'iteration_completed',
|
|
958
|
-
|
|
991
|
+
turnId: recorder.turnId,
|
|
959
992
|
iteration: iterationNum,
|
|
960
993
|
hasToolCalls: false,
|
|
961
994
|
});
|
|
@@ -972,21 +1005,21 @@ export class IterationOrchestrator {
|
|
|
972
1005
|
const limit = this.structuredOutputRetryLimit();
|
|
973
1006
|
if (attempt > limit) {
|
|
974
1007
|
this.ctx.log.warn('Structured output not produced within its retries', {
|
|
975
|
-
[NAMZU.
|
|
1008
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
976
1009
|
'namzu.runtime.attempts': attempt - 1,
|
|
977
1010
|
});
|
|
978
|
-
|
|
1011
|
+
recorder.setStopReason('structured_output_failed');
|
|
979
1012
|
break;
|
|
980
1013
|
}
|
|
981
1014
|
this.ctx.log.info('Re-prompting for structured output', {
|
|
982
|
-
[NAMZU.
|
|
1015
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
983
1016
|
'namzu.retry.attempt': attempt,
|
|
984
1017
|
'namzu.runtime.limit': limit,
|
|
985
1018
|
});
|
|
986
|
-
|
|
1019
|
+
recorder.pushMessage(createRuntimeContextMessage(STRUCTURED_OUTPUT_REPROMPT, 'structured-output'));
|
|
987
1020
|
await this.ctx.emitEvent({
|
|
988
1021
|
type: 'iteration_completed',
|
|
989
|
-
|
|
1022
|
+
turnId: recorder.turnId,
|
|
990
1023
|
iteration: iterationNum,
|
|
991
1024
|
hasToolCalls: false,
|
|
992
1025
|
});
|
|
@@ -997,10 +1030,10 @@ export class IterationOrchestrator {
|
|
|
997
1030
|
//
|
|
998
1031
|
// The stop predicate is only consulted after tools ran, so
|
|
999
1032
|
// there was no seam here at all: the moment the model
|
|
1000
|
-
// stopped calling tools the
|
|
1033
|
+
// stopped calling tools the turn finalized, whatever it had
|
|
1001
1034
|
// produced. Verify-then-fix — run the build, feed the
|
|
1002
1035
|
// failure back, let it try again — meant starting a whole
|
|
1003
|
-
// new
|
|
1036
|
+
// new turn and re-supplying the context the first one had.
|
|
1004
1037
|
//
|
|
1005
1038
|
// Shaped after the structured-output re-prompt directly
|
|
1006
1039
|
// above, which solves the same problem for one specific
|
|
@@ -1009,45 +1042,45 @@ export class IterationOrchestrator {
|
|
|
1009
1042
|
if (!forceFinalize && this.ctx.reviewAnswer) {
|
|
1010
1043
|
const review = await this.reviewAnswer(response.message.content ?? '', reviewRequest, stepModel);
|
|
1011
1044
|
if (this.ctx.abortController.signal.aborted) {
|
|
1012
|
-
|
|
1013
|
-
|
|
1045
|
+
recorder.setStopReason('cancelled');
|
|
1046
|
+
recorder.markCancelled();
|
|
1014
1047
|
break;
|
|
1015
1048
|
}
|
|
1016
1049
|
if (review && !review.accept) {
|
|
1017
1050
|
const attempt = ++this.answerReviewAttempts;
|
|
1018
|
-
|
|
1051
|
+
recorder.pushMessage(createRuntimeContextMessage(review.feedback, 'answer-review'));
|
|
1019
1052
|
// Commit the consumed allowance with its feedback before another
|
|
1020
1053
|
// request, including exhaustion. Compaction cannot reset this quota.
|
|
1021
|
-
const checkpoint = await this.ctx.checkpointMgr.create(
|
|
1054
|
+
const checkpoint = await this.ctx.checkpointMgr.create(recorder, iterationNum);
|
|
1022
1055
|
await this.ctx.emitEvent({
|
|
1023
1056
|
type: 'checkpoint_created',
|
|
1024
|
-
|
|
1057
|
+
turnId: recorder.turnId,
|
|
1025
1058
|
checkpointId: checkpoint.id,
|
|
1026
1059
|
iteration: iterationNum,
|
|
1027
1060
|
});
|
|
1028
1061
|
if (this.ctx.abortController.signal.aborted) {
|
|
1029
|
-
|
|
1030
|
-
|
|
1062
|
+
recorder.setStopReason('cancelled');
|
|
1063
|
+
recorder.markCancelled();
|
|
1031
1064
|
break;
|
|
1032
1065
|
}
|
|
1033
1066
|
const limit = this.ctx.maxAnswerReviews ?? DEFAULT_ANSWER_REVIEW_LIMIT;
|
|
1034
1067
|
if (attempt > limit) {
|
|
1035
|
-
this.ctx.log.warn('Answer rejected more times than the
|
|
1036
|
-
[NAMZU.
|
|
1068
|
+
this.ctx.log.warn('Answer rejected more times than the turn allows', {
|
|
1069
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1037
1070
|
'namzu.runtime.attempts': attempt - 1,
|
|
1038
1071
|
'namzu.runtime.limit': limit,
|
|
1039
1072
|
});
|
|
1040
|
-
|
|
1073
|
+
recorder.setStopReason('answer_rejected');
|
|
1041
1074
|
break;
|
|
1042
1075
|
}
|
|
1043
1076
|
this.ctx.log.info('Answer rejected — returning it to the model', {
|
|
1044
|
-
[NAMZU.
|
|
1077
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1045
1078
|
'namzu.retry.attempt': attempt,
|
|
1046
1079
|
'namzu.runtime.limit': limit,
|
|
1047
1080
|
});
|
|
1048
1081
|
await this.ctx.emitEvent({
|
|
1049
1082
|
type: 'iteration_completed',
|
|
1050
|
-
|
|
1083
|
+
turnId: recorder.turnId,
|
|
1051
1084
|
iteration: iterationNum,
|
|
1052
1085
|
hasToolCalls: false,
|
|
1053
1086
|
});
|
|
@@ -1056,11 +1089,11 @@ export class IterationOrchestrator {
|
|
|
1056
1089
|
}
|
|
1057
1090
|
}
|
|
1058
1091
|
// A background worker is still out there, and this turn was
|
|
1059
|
-
// about to end the
|
|
1092
|
+
// about to end the turn.
|
|
1060
1093
|
//
|
|
1061
1094
|
// Settling here would throw away the very thing the launch
|
|
1062
1095
|
// existed to produce: the supervisor said "launched", the
|
|
1063
|
-
// worker had not finished, and the
|
|
1096
|
+
// worker had not finished, and the turn closed over it.
|
|
1064
1097
|
if (!forceFinalize &&
|
|
1065
1098
|
(yield* holdForOutstandingWork(this.ctx, iterationNum, false, () => this.deliverInbound()))) {
|
|
1066
1099
|
continue;
|
|
@@ -1077,7 +1110,7 @@ export class IterationOrchestrator {
|
|
|
1077
1110
|
if (!forceFinalize && this.deliverInbound() > 0) {
|
|
1078
1111
|
await this.ctx.emitEvent({
|
|
1079
1112
|
type: 'iteration_completed',
|
|
1080
|
-
|
|
1113
|
+
turnId: recorder.turnId,
|
|
1081
1114
|
iteration: iterationNum,
|
|
1082
1115
|
hasToolCalls: false,
|
|
1083
1116
|
});
|
|
@@ -1100,18 +1133,18 @@ export class IterationOrchestrator {
|
|
|
1100
1133
|
}
|
|
1101
1134
|
await this.ctx.emitEvent({
|
|
1102
1135
|
type: 'iteration_completed',
|
|
1103
|
-
|
|
1136
|
+
turnId: recorder.turnId,
|
|
1104
1137
|
iteration: iterationNum,
|
|
1105
1138
|
hasToolCalls: false,
|
|
1106
1139
|
});
|
|
1107
1140
|
yield* this.ctx.drainPending();
|
|
1108
1141
|
// A Stop that lands AFTER the final turn streamed but before
|
|
1109
|
-
// this break must settle the
|
|
1142
|
+
// this break must settle the turn as cancelled, not end_turn —
|
|
1110
1143
|
// otherwise the just-produced answer is recorded as a clean
|
|
1111
1144
|
// completion. Mirrors the between-iteration cancel at :511.
|
|
1112
1145
|
if (this.ctx.abortController.signal.aborted) {
|
|
1113
|
-
|
|
1114
|
-
|
|
1146
|
+
recorder.setStopReason('cancelled');
|
|
1147
|
+
recorder.markCancelled();
|
|
1115
1148
|
break;
|
|
1116
1149
|
}
|
|
1117
1150
|
// The host's stop predicate, if the previous turn deferred it
|
|
@@ -1119,18 +1152,18 @@ export class IterationOrchestrator {
|
|
|
1119
1152
|
// is prose, and `stopWhen` is consulted only after a tool
|
|
1120
1153
|
// batch, so the predicate is never asked again — reporting
|
|
1121
1154
|
// `end_turn` would name the shape of the last message rather
|
|
1122
|
-
// than the reason the
|
|
1155
|
+
// than the reason the turn is over.
|
|
1123
1156
|
//
|
|
1124
1157
|
// Only here. A terminal tool and a captured structured output
|
|
1125
1158
|
// also settle as `end_turn`, and there the deferred predicate
|
|
1126
|
-
// is not why the
|
|
1159
|
+
// is not why the turn ended: those decided the answer
|
|
1127
1160
|
// themselves.
|
|
1128
|
-
|
|
1161
|
+
recorder.setStopReason(closingStopReason ??
|
|
1129
1162
|
(stopWasDeferredForOutstandingWork ? 'stop_condition' : 'end_turn'));
|
|
1130
1163
|
break;
|
|
1131
1164
|
}
|
|
1132
1165
|
const reviewOutcome = yield* runToolReview(this.ctx, response, iterationNum);
|
|
1133
|
-
// The step record is built even for a rejected batch: a
|
|
1166
|
+
// The step record is built even for a rejected batch: a turn that
|
|
1134
1167
|
// spent a turn getting its tools refused still spent the tokens,
|
|
1135
1168
|
// and a caller reconstructing cost per step must see it.
|
|
1136
1169
|
this.recordStep({
|
|
@@ -1165,34 +1198,34 @@ export class IterationOrchestrator {
|
|
|
1165
1198
|
structuredOutcome === 'cancelled') {
|
|
1166
1199
|
await this.ctx.emitEvent({
|
|
1167
1200
|
type: 'iteration_completed',
|
|
1168
|
-
|
|
1201
|
+
turnId: recorder.turnId,
|
|
1169
1202
|
iteration: iterationNum,
|
|
1170
1203
|
hasToolCalls: true,
|
|
1171
1204
|
});
|
|
1172
1205
|
yield* this.ctx.drainPending();
|
|
1173
1206
|
if (this.ctx.abortController.signal.aborted) {
|
|
1174
|
-
|
|
1175
|
-
|
|
1207
|
+
recorder.setStopReason('cancelled');
|
|
1208
|
+
recorder.markCancelled();
|
|
1176
1209
|
break;
|
|
1177
1210
|
}
|
|
1178
1211
|
if (structuredOutcome === 'retry')
|
|
1179
1212
|
continue;
|
|
1180
|
-
|
|
1213
|
+
recorder.setStopReason(structuredOutcome === 'cancelled' ? 'cancelled' : 'answer_rejected');
|
|
1181
1214
|
if (structuredOutcome === 'cancelled')
|
|
1182
|
-
|
|
1215
|
+
recorder.markCancelled();
|
|
1183
1216
|
break;
|
|
1184
1217
|
}
|
|
1185
1218
|
if (structuredOutcome === 'accepted') {
|
|
1186
1219
|
await this.ctx.emitEvent({
|
|
1187
1220
|
type: 'iteration_completed',
|
|
1188
|
-
|
|
1221
|
+
turnId: recorder.turnId,
|
|
1189
1222
|
iteration: iterationNum,
|
|
1190
1223
|
hasToolCalls: true,
|
|
1191
1224
|
});
|
|
1192
1225
|
yield* this.ctx.drainPending();
|
|
1193
1226
|
if (this.ctx.abortController.signal.aborted) {
|
|
1194
|
-
|
|
1195
|
-
|
|
1227
|
+
recorder.setStopReason('cancelled');
|
|
1228
|
+
recorder.markCancelled();
|
|
1196
1229
|
break;
|
|
1197
1230
|
}
|
|
1198
1231
|
if (!forceFinalize) {
|
|
@@ -1203,19 +1236,19 @@ export class IterationOrchestrator {
|
|
|
1203
1236
|
continue;
|
|
1204
1237
|
}
|
|
1205
1238
|
if (this.ctx.abortController.signal.aborted) {
|
|
1206
|
-
|
|
1207
|
-
|
|
1239
|
+
recorder.setStopReason('cancelled');
|
|
1240
|
+
recorder.markCancelled();
|
|
1208
1241
|
break;
|
|
1209
1242
|
}
|
|
1210
|
-
this.ctx.log.info('Structured output produced — ending
|
|
1211
|
-
[NAMZU.
|
|
1243
|
+
this.ctx.log.info('Structured output produced — ending turn', {
|
|
1244
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1212
1245
|
[NAMZU.ITERATION]: iterationNum,
|
|
1213
1246
|
});
|
|
1214
1247
|
this.publishStructuredOutput();
|
|
1215
|
-
|
|
1248
|
+
recorder.setStopReason('end_turn');
|
|
1216
1249
|
break;
|
|
1217
1250
|
}
|
|
1218
|
-
// A tool the author declared terminal settles the
|
|
1251
|
+
// A tool the author declared terminal settles the turn with its
|
|
1219
1252
|
// own output, the same rule `structured_output` has always
|
|
1220
1253
|
// had. Without it a delegation cost the parent one more model
|
|
1221
1254
|
// call at full context whose only job was to restate what the
|
|
@@ -1224,16 +1257,16 @@ export class IterationOrchestrator {
|
|
|
1224
1257
|
// worker's words.
|
|
1225
1258
|
const settled = this.terminalToolOutput(reviewOutcome.results, response);
|
|
1226
1259
|
if (settled !== undefined) {
|
|
1227
|
-
this.ctx.log.info('Terminal tool produced the answer — ending
|
|
1228
|
-
[NAMZU.
|
|
1260
|
+
this.ctx.log.info('Terminal tool produced the answer — ending turn', {
|
|
1261
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1229
1262
|
[NAMZU.ITERATION]: iterationNum,
|
|
1230
1263
|
[GENAI.TOOL_NAME]: settled.toolName,
|
|
1231
1264
|
});
|
|
1232
|
-
|
|
1233
|
-
|
|
1265
|
+
recorder.setResult(settled.output, 'review');
|
|
1266
|
+
recorder.setStopReason('end_turn');
|
|
1234
1267
|
await this.ctx.emitEvent({
|
|
1235
1268
|
type: 'iteration_completed',
|
|
1236
|
-
|
|
1269
|
+
turnId: recorder.turnId,
|
|
1237
1270
|
iteration: iterationNum,
|
|
1238
1271
|
hasToolCalls: true,
|
|
1239
1272
|
});
|
|
@@ -1267,24 +1300,24 @@ export class IterationOrchestrator {
|
|
|
1267
1300
|
// outstanding. One task deferred it once; two awaited
|
|
1268
1301
|
// jobs exiting a minute apart defer it twice, each time
|
|
1269
1302
|
// for a turn the model spends on news it has not read.
|
|
1270
|
-
// `maxIterations` and the
|
|
1303
|
+
// `maxIterations` and the turn's own deadline bound all of
|
|
1271
1304
|
// it regardless, and a leg with nothing pending never
|
|
1272
1305
|
// opens a hold at all.
|
|
1273
1306
|
if (yield* holdForOutstandingWork(this.ctx, iterationNum, true, () => this.deliverInbound())) {
|
|
1274
1307
|
// Remember WHY the next turn exists, so the turn that
|
|
1275
|
-
// ends the
|
|
1308
|
+
// ends the turn can name the host's decision instead of
|
|
1276
1309
|
// reporting the shape of the last message.
|
|
1277
1310
|
this.stopDeferredForOutstandingWork = true;
|
|
1278
1311
|
continue;
|
|
1279
1312
|
}
|
|
1280
1313
|
this.ctx.log.info('Stop condition met', {
|
|
1281
|
-
[NAMZU.
|
|
1314
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1282
1315
|
[NAMZU.ITERATION]: iterationNum,
|
|
1283
1316
|
});
|
|
1284
|
-
|
|
1317
|
+
recorder.setStopReason('stop_condition');
|
|
1285
1318
|
await this.ctx.emitEvent({
|
|
1286
1319
|
type: 'iteration_completed',
|
|
1287
|
-
|
|
1320
|
+
turnId: recorder.turnId,
|
|
1288
1321
|
iteration: iterationNum,
|
|
1289
1322
|
hasToolCalls: true,
|
|
1290
1323
|
});
|
|
@@ -1317,11 +1350,11 @@ export class IterationOrchestrator {
|
|
|
1317
1350
|
const unheard = this.ctx.completionInbox?.drain() ?? [];
|
|
1318
1351
|
if (unheard.length > 0) {
|
|
1319
1352
|
this.ctx.log.info('Delivering unawaited task completions', {
|
|
1320
|
-
[NAMZU.
|
|
1353
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1321
1354
|
[NAMZU.ITERATION]: iterationNum,
|
|
1322
1355
|
'namzu.runtime.tasks': unheard.map((h) => h.taskId),
|
|
1323
1356
|
});
|
|
1324
|
-
|
|
1357
|
+
recorder.pushMessage(createRuntimeContextMessage(formatCompletionNotification(unheard), 'task-completion'));
|
|
1325
1358
|
}
|
|
1326
1359
|
// The same seam, for the two channels that could accept text
|
|
1327
1360
|
// and never deliver it. Placed here rather than at the top of
|
|
@@ -1331,7 +1364,8 @@ export class IterationOrchestrator {
|
|
|
1331
1364
|
await runAdvisoryPhase(this.ctx, iterationNum, response, this.getAdvisoryTurnContext());
|
|
1332
1365
|
if (this.ctx.pluginManager) {
|
|
1333
1366
|
const hookResults = await this.ctx.pluginManager.executeHooks('iteration_end', {
|
|
1334
|
-
|
|
1367
|
+
sessionId: recorder.sessionId,
|
|
1368
|
+
turnId: recorder.turnId,
|
|
1335
1369
|
iteration: iterationNum,
|
|
1336
1370
|
signal: this.ctx.abortController.signal,
|
|
1337
1371
|
}, this.ctx.emitEvent);
|
|
@@ -1340,7 +1374,7 @@ export class IterationOrchestrator {
|
|
|
1340
1374
|
}
|
|
1341
1375
|
await this.ctx.emitEvent({
|
|
1342
1376
|
type: 'iteration_completed',
|
|
1343
|
-
|
|
1377
|
+
turnId: recorder.turnId,
|
|
1344
1378
|
iteration: iterationNum,
|
|
1345
1379
|
hasToolCalls: true,
|
|
1346
1380
|
});
|
|
@@ -1366,7 +1400,7 @@ export class IterationOrchestrator {
|
|
|
1366
1400
|
// wrote down for itself. All three exits spend a turn: the
|
|
1367
1401
|
// cancellation breaks, the overflow-relief retry continues
|
|
1368
1402
|
// under a NEW iteration number (so its tokens belong to no
|
|
1369
|
-
// later step), and the re-throw ends the
|
|
1403
|
+
// later step), and the re-throw ends the turn.
|
|
1370
1404
|
//
|
|
1371
1405
|
// What it carries is what the iteration got as far as knowing.
|
|
1372
1406
|
// `usage` is the same subtraction a successful step makes, so
|
|
@@ -1383,10 +1417,10 @@ export class IterationOrchestrator {
|
|
|
1383
1417
|
// class of wrong as dropping them and harder to notice, since
|
|
1384
1418
|
// the ledger would look fuller rather than emptier. That turn's
|
|
1385
1419
|
// own verdict is already written down; the failure that
|
|
1386
|
-
// followed it reaches the caller as the
|
|
1420
|
+
// followed it reaches the caller as the turn's error.
|
|
1387
1421
|
if (this.steps.at(-1)?.stepNumber === iterationNum) {
|
|
1388
1422
|
this.ctx.log.warn('Iteration failed after its step was already recorded', {
|
|
1389
|
-
[NAMZU.
|
|
1423
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1390
1424
|
[NAMZU.ITERATION]: iterationNum,
|
|
1391
1425
|
'exception.message': toErrorMessage(err),
|
|
1392
1426
|
});
|
|
@@ -1417,23 +1451,23 @@ export class IterationOrchestrator {
|
|
|
1417
1451
|
});
|
|
1418
1452
|
}
|
|
1419
1453
|
// A Stop that aborted the in-flight turn surfaces here as a
|
|
1420
|
-
// thrown abort (the provider stream was raced against the
|
|
1454
|
+
// thrown abort (the provider stream was raced against the turn
|
|
1421
1455
|
// signal). Settle it as a CANCELLATION — mirroring the
|
|
1422
1456
|
// between-iteration cancel at the top of the loop — rather than
|
|
1423
1457
|
// recording it as an SDK failure (error span + failed activity)
|
|
1424
|
-
// and re-throwing. The
|
|
1458
|
+
// and re-throwing. The turn then returns cleanly with a
|
|
1425
1459
|
// 'cancelled' stop reason instead of propagating an error.
|
|
1426
1460
|
if (cancelled) {
|
|
1427
|
-
|
|
1428
|
-
|
|
1461
|
+
recorder.setStopReason('cancelled');
|
|
1462
|
+
recorder.markCancelled();
|
|
1429
1463
|
break;
|
|
1430
1464
|
}
|
|
1431
1465
|
// The one provider failure the kernel can actually do something
|
|
1432
1466
|
// about. `context_length_exceeded` is correctly non-retryable —
|
|
1433
1467
|
// resending the identical prompt cannot help — but the kernel
|
|
1434
1468
|
// owns a compaction subsystem that can make the prompt smaller.
|
|
1435
|
-
// Without this the
|
|
1436
|
-
// path had simply guessed low, which a
|
|
1469
|
+
// Without this the turn died holding the remedy: the threshold
|
|
1470
|
+
// path had simply guessed low, which a turn carrying images or a
|
|
1437
1471
|
// language the chars-per-token ratio does not fit will do.
|
|
1438
1472
|
//
|
|
1439
1473
|
// Relief is attempted ONCE per iteration and only when it
|
|
@@ -1447,7 +1481,7 @@ export class IterationOrchestrator {
|
|
|
1447
1481
|
const shed = await relieveOverflow(this.ctx);
|
|
1448
1482
|
if (shed) {
|
|
1449
1483
|
this.ctx.log.info('Retrying the turn after relieving a context overflow', {
|
|
1450
|
-
[NAMZU.
|
|
1484
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1451
1485
|
[NAMZU.ITERATION]: iterationNum,
|
|
1452
1486
|
});
|
|
1453
1487
|
if (iterationActivity) {
|
|
@@ -1494,7 +1528,7 @@ export class IterationOrchestrator {
|
|
|
1494
1528
|
steps: () => this.steps,
|
|
1495
1529
|
};
|
|
1496
1530
|
}
|
|
1497
|
-
/** Steps completed so far, exposed on the returned `
|
|
1531
|
+
/** Steps completed so far, exposed on the returned `Turn`. */
|
|
1498
1532
|
steps = [];
|
|
1499
1533
|
getSteps() {
|
|
1500
1534
|
return this.steps;
|
|
@@ -1504,17 +1538,17 @@ export class IterationOrchestrator {
|
|
|
1504
1538
|
*
|
|
1505
1539
|
* Every field here was already computed somewhere in the loop; the only
|
|
1506
1540
|
* new work is subtracting the cumulative counters so the step carries
|
|
1507
|
-
* ITS usage rather than the
|
|
1541
|
+
* ITS usage rather than the turn's running total, which is the number a
|
|
1508
1542
|
* caller asking "what did this step cost" actually wants.
|
|
1509
1543
|
*/
|
|
1510
1544
|
/**
|
|
1511
|
-
* Take everything queued for this
|
|
1545
|
+
* Take everything queued for this turn since the last turn.
|
|
1512
1546
|
*
|
|
1513
1547
|
* Both channels drain here. `inboundMessages` is the manager's queue —
|
|
1514
1548
|
* what `continueTask` and `queueMessage` push onto and nothing ever
|
|
1515
1549
|
* collected. `steering` is the host's, and it could only ride on a tool
|
|
1516
1550
|
* result, so guidance queued during a turn that called no tools stayed
|
|
1517
|
-
* pending until the
|
|
1551
|
+
* pending until the turn ended.
|
|
1518
1552
|
*
|
|
1519
1553
|
* Returns the count so a caller can decide whether a turn is owed. An
|
|
1520
1554
|
* empty drain must change nothing at all: a `continue` on nothing queued
|
|
@@ -1535,7 +1569,7 @@ export class IterationOrchestrator {
|
|
|
1535
1569
|
deliverInbound() {
|
|
1536
1570
|
const queued = this.ctx.inboundMessages?.() ?? [];
|
|
1537
1571
|
for (const message of queued) {
|
|
1538
|
-
this.ctx.
|
|
1572
|
+
this.ctx.recorder.pushMessage(message);
|
|
1539
1573
|
this.rememberUserMessage(message);
|
|
1540
1574
|
}
|
|
1541
1575
|
// The steering channel's remainder. `attachSteering` already took
|
|
@@ -1544,13 +1578,13 @@ export class IterationOrchestrator {
|
|
|
1544
1578
|
const stranded = this.ctx.steering?.drain();
|
|
1545
1579
|
if (stranded) {
|
|
1546
1580
|
const message = createRuntimeContextMessage(formatSteeringNote(stranded), 'steering');
|
|
1547
|
-
this.ctx.
|
|
1581
|
+
this.ctx.recorder.pushMessage(message);
|
|
1548
1582
|
this.rememberUserMessage(createRuntimeContextMessage(stranded, 'steering'));
|
|
1549
1583
|
}
|
|
1550
1584
|
return queued.length + (stranded ? 1 : 0);
|
|
1551
1585
|
}
|
|
1552
1586
|
recordStep(input) {
|
|
1553
|
-
const {
|
|
1587
|
+
const { recorder } = this.ctx;
|
|
1554
1588
|
const toolCalls = input.response?.message.toolCalls ?? [];
|
|
1555
1589
|
const byId = new Map(input.toolResults.map((r) => [r.toolCallId, r]));
|
|
1556
1590
|
const step = {
|
|
@@ -1591,10 +1625,10 @@ export class IterationOrchestrator {
|
|
|
1591
1625
|
// tool execution did not end in `tool_calls`.
|
|
1592
1626
|
finishReason: input.unfinished?.finishReason ?? input.response?.finishReason ?? 'error',
|
|
1593
1627
|
...(input.unfinished?.failure ? { failure: input.unfinished.failure } : {}),
|
|
1594
|
-
usage: subtractUsage(
|
|
1628
|
+
usage: subtractUsage(recorder.tokenUsage, input.usageBefore),
|
|
1595
1629
|
costDelta: {
|
|
1596
|
-
...
|
|
1597
|
-
totalCost: round6(
|
|
1630
|
+
...recorder.costInfo,
|
|
1631
|
+
totalCost: round6(recorder.costInfo.totalCost - input.costBefore.totalCost),
|
|
1598
1632
|
},
|
|
1599
1633
|
startedAt: input.startedAt,
|
|
1600
1634
|
durationMs: Date.now() - input.startedAt,
|
|
@@ -1608,14 +1642,14 @@ export class IterationOrchestrator {
|
|
|
1608
1642
|
// Nothing here is allowed to throw over the failure that is already
|
|
1609
1643
|
// unwinding — the same rule `settleCancelledTurn` states for the
|
|
1610
1644
|
// cancellation path. A host callback that throws while being told a
|
|
1611
|
-
// turn failed would REPLACE the reason the turn failed, so the
|
|
1645
|
+
// turn failed would REPLACE the reason the turn failed, so the turn
|
|
1612
1646
|
// would report the observer's bug and lose the original.
|
|
1613
1647
|
try {
|
|
1614
1648
|
this.ctx.onStepFinish?.(step);
|
|
1615
1649
|
}
|
|
1616
1650
|
catch (err) {
|
|
1617
1651
|
this.ctx.log.warn('onStepFinish threw while recording a failed step', {
|
|
1618
|
-
[NAMZU.
|
|
1652
|
+
[NAMZU.TURN_ID]: recorder.turnId,
|
|
1619
1653
|
'namzu.runtime.step': input.stepNumber,
|
|
1620
1654
|
'exception.message': toErrorMessage(err),
|
|
1621
1655
|
});
|
|
@@ -1637,7 +1671,7 @@ export class IterationOrchestrator {
|
|
|
1637
1671
|
/**
|
|
1638
1672
|
* The answer a terminal tool produced, or `undefined` to keep looping.
|
|
1639
1673
|
*
|
|
1640
|
-
* Deliberately narrow. A terminal call decides the
|
|
1674
|
+
* Deliberately narrow. A terminal call decides the turn only when it is
|
|
1641
1675
|
* the ONLY call the model made in that turn: a model that asked for
|
|
1642
1676
|
* other work meant to see those results, and settling here would throw
|
|
1643
1677
|
* away answers it requested. Same for a failed terminal call — an
|
|
@@ -1655,7 +1689,7 @@ export class IterationOrchestrator {
|
|
|
1655
1689
|
const callCount = response.message.toolCalls?.length ?? 0;
|
|
1656
1690
|
if (callCount > 1) {
|
|
1657
1691
|
this.ctx.log.info('Terminal tool shared its turn — relaying instead of settling', {
|
|
1658
|
-
[NAMZU.
|
|
1692
|
+
[NAMZU.TURN_ID]: this.ctx.recorder.turnId,
|
|
1659
1693
|
[GENAI.TOOL_NAME]: terminal[0]?.toolName,
|
|
1660
1694
|
'namzu.runtime.calls_in_turn': callCount,
|
|
1661
1695
|
});
|
|
@@ -1664,7 +1698,7 @@ export class IterationOrchestrator {
|
|
|
1664
1698
|
const hit = terminal[0];
|
|
1665
1699
|
if (!hit || hit.isError) {
|
|
1666
1700
|
this.ctx.log.info('Terminal tool failed — returning the error to the model', {
|
|
1667
|
-
[NAMZU.
|
|
1701
|
+
[NAMZU.TURN_ID]: this.ctx.recorder.turnId,
|
|
1668
1702
|
[GENAI.TOOL_NAME]: hit?.toolName,
|
|
1669
1703
|
});
|
|
1670
1704
|
return undefined;
|
|
@@ -1686,7 +1720,7 @@ export class IterationOrchestrator {
|
|
|
1686
1720
|
* by the time this runs — `runToolReview` settles it, side effects
|
|
1687
1721
|
* included, before either of these is consulted — so settling here is
|
|
1688
1722
|
* worse than discarding an answer the model wanted: the work happened,
|
|
1689
|
-
* its results went into the transcript, and the
|
|
1723
|
+
* its results went into the transcript, and the turn ended before any
|
|
1690
1724
|
* model turn could read them. Nothing consumed what was spent, and
|
|
1691
1725
|
* nothing said so.
|
|
1692
1726
|
*
|
|
@@ -1708,7 +1742,7 @@ export class IterationOrchestrator {
|
|
|
1708
1742
|
* avoids it by not pairing.
|
|
1709
1743
|
*
|
|
1710
1744
|
* NOT charged to `maxRetries`. That budget bounds a model that cannot
|
|
1711
|
-
* satisfy the SCHEMA, and this one did. A
|
|
1745
|
+
* satisfy the SCHEMA, and this one did. A turn reading two files a turn
|
|
1712
1746
|
* while optimistically attaching its answer is making progress, and it
|
|
1713
1747
|
* must not die reported as `structured_output_failed` — a failure that
|
|
1714
1748
|
* did not happen. `maxIterations` is the bound for a model that keeps
|
|
@@ -1724,7 +1758,7 @@ export class IterationOrchestrator {
|
|
|
1724
1758
|
const callCount = response.message.toolCalls?.length ?? 0;
|
|
1725
1759
|
if (callCount > 1) {
|
|
1726
1760
|
this.ctx.log.info('Structured output shared its turn — relaying instead of settling', {
|
|
1727
|
-
[NAMZU.
|
|
1761
|
+
[NAMZU.TURN_ID]: this.ctx.recorder.turnId,
|
|
1728
1762
|
'namzu.runtime.calls_in_turn': callCount,
|
|
1729
1763
|
});
|
|
1730
1764
|
return 'absent';
|
|
@@ -1743,7 +1777,7 @@ export class IterationOrchestrator {
|
|
|
1743
1777
|
return this.reviewStructuredOutput(parsed, reviewRequest, model);
|
|
1744
1778
|
}
|
|
1745
1779
|
publishStructuredOutput() {
|
|
1746
|
-
this.ctx.
|
|
1780
|
+
this.ctx.recorder.setStructuredOutput(this.pendingStructuredOutput);
|
|
1747
1781
|
this.structuredOutputDone = true;
|
|
1748
1782
|
}
|
|
1749
1783
|
async reviewStructuredOutput(parsed, reviewRequest, model) {
|
|
@@ -1766,10 +1800,11 @@ export class IterationOrchestrator {
|
|
|
1766
1800
|
Promise.resolve().then(() => {
|
|
1767
1801
|
signal.throwIfAborted();
|
|
1768
1802
|
return reviewer(structuredClone(parsed), {
|
|
1769
|
-
|
|
1770
|
-
|
|
1803
|
+
sessionId: this.ctx.recorder.sessionId,
|
|
1804
|
+
turnId: this.ctx.recorder.turnId,
|
|
1805
|
+
iteration: this.ctx.recorder.currentIteration,
|
|
1771
1806
|
signal,
|
|
1772
|
-
messages: this.ctx.
|
|
1807
|
+
messages: this.ctx.recorder.messages,
|
|
1773
1808
|
...reviewRequest,
|
|
1774
1809
|
generateText: inference.generateText,
|
|
1775
1810
|
});
|
|
@@ -1794,15 +1829,15 @@ export class IterationOrchestrator {
|
|
|
1794
1829
|
if (typeof verdict.feedback !== 'string' || verdict.feedback.trim().length === 0)
|
|
1795
1830
|
throw new Error('Structured reviewer rejection requires feedback');
|
|
1796
1831
|
this.structuredReviewAttempts++;
|
|
1797
|
-
this.ctx.
|
|
1832
|
+
this.ctx.recorder.pushMessage(createRuntimeContextMessage(verdict.feedback, 'answer-review'));
|
|
1798
1833
|
// Persist both the feedback and its consumed allowance before the
|
|
1799
1834
|
// next request. This checkpoint is not an approval/park boundary.
|
|
1800
|
-
const checkpoint = await this.ctx.checkpointMgr.create(this.ctx.
|
|
1835
|
+
const checkpoint = await this.ctx.checkpointMgr.create(this.ctx.recorder, this.ctx.recorder.currentIteration);
|
|
1801
1836
|
await this.ctx.emitEvent({
|
|
1802
1837
|
type: 'checkpoint_created',
|
|
1803
|
-
|
|
1838
|
+
turnId: this.ctx.recorder.turnId,
|
|
1804
1839
|
checkpointId: checkpoint.id,
|
|
1805
|
-
iteration: this.ctx.
|
|
1840
|
+
iteration: this.ctx.recorder.currentIteration,
|
|
1806
1841
|
});
|
|
1807
1842
|
if (signal.aborted)
|
|
1808
1843
|
return 'cancelled';
|
|
@@ -1832,10 +1867,11 @@ export class IterationOrchestrator {
|
|
|
1832
1867
|
Promise.resolve().then(() => {
|
|
1833
1868
|
signal.throwIfAborted();
|
|
1834
1869
|
return reviewer(answer, {
|
|
1835
|
-
|
|
1836
|
-
|
|
1870
|
+
sessionId: this.ctx.recorder.sessionId,
|
|
1871
|
+
turnId: this.ctx.recorder.turnId,
|
|
1872
|
+
iteration: this.ctx.recorder.currentIteration,
|
|
1837
1873
|
signal,
|
|
1838
|
-
messages: this.ctx.
|
|
1874
|
+
messages: this.ctx.recorder.messages,
|
|
1839
1875
|
...reviewRequest,
|
|
1840
1876
|
generateText: inference.generateText,
|
|
1841
1877
|
});
|
|
@@ -1870,15 +1906,15 @@ export class IterationOrchestrator {
|
|
|
1870
1906
|
return await stopWhen({
|
|
1871
1907
|
steps: this.steps,
|
|
1872
1908
|
latestStep,
|
|
1873
|
-
totalUsage: this.ctx.
|
|
1874
|
-
totalCost: this.ctx.
|
|
1909
|
+
totalUsage: this.ctx.recorder.tokenUsage,
|
|
1910
|
+
totalCost: this.ctx.recorder.costInfo,
|
|
1875
1911
|
});
|
|
1876
1912
|
}
|
|
1877
1913
|
catch (err) {
|
|
1878
|
-
// A throwing predicate must not kill a
|
|
1914
|
+
// A throwing predicate must not kill a turn that is otherwise
|
|
1879
1915
|
// healthy; failing open keeps the existing budgets in charge.
|
|
1880
|
-
this.ctx.log.error('Stop condition threw — continuing the
|
|
1881
|
-
[NAMZU.
|
|
1916
|
+
this.ctx.log.error('Stop condition threw — continuing the turn', {
|
|
1917
|
+
[NAMZU.TURN_ID]: this.ctx.recorder.turnId,
|
|
1882
1918
|
'exception.message': toErrorMessage(err),
|
|
1883
1919
|
});
|
|
1884
1920
|
return false;
|
|
@@ -1892,14 +1928,14 @@ export class IterationOrchestrator {
|
|
|
1892
1928
|
.some((t) => t.state !== 'completed' && t.state !== 'failed' && t.state !== 'canceled');
|
|
1893
1929
|
}
|
|
1894
1930
|
async acceptProviderRejectedImage(identity) {
|
|
1895
|
-
const repaired = markProviderRejectedImage(this.ctx.
|
|
1931
|
+
const repaired = markProviderRejectedImage(this.ctx.recorder.messages, identity);
|
|
1896
1932
|
if (repaired.count === 0) {
|
|
1897
1933
|
throw new Error('Provider-rejected image recovery could not find its durable source image');
|
|
1898
1934
|
}
|
|
1899
|
-
this.ctx.
|
|
1935
|
+
this.ctx.recorder.replaceMessages(repaired.messages);
|
|
1900
1936
|
await this.ctx.emitEvent?.({
|
|
1901
1937
|
type: 'message_history_repaired',
|
|
1902
|
-
|
|
1938
|
+
turnId: this.ctx.recorder.turnId,
|
|
1903
1939
|
source: 'provider-rejected-image',
|
|
1904
1940
|
duplicateToolResultsRemoved: 0,
|
|
1905
1941
|
orphanedToolResultsRemoved: 0,
|
|
@@ -1910,7 +1946,7 @@ export class IterationOrchestrator {
|
|
|
1910
1946
|
async requestFinalResponse(model, reason) {
|
|
1911
1947
|
if (this.ctx.structuredOutput?.mode === 'native')
|
|
1912
1948
|
return 'structured_output_failed';
|
|
1913
|
-
const lastAssistant = [...this.ctx.
|
|
1949
|
+
const lastAssistant = [...this.ctx.recorder.messages]
|
|
1914
1950
|
.reverse()
|
|
1915
1951
|
.find((m) => m.role === 'assistant');
|
|
1916
1952
|
const hasResult = lastAssistant?.content !== null &&
|
|
@@ -1918,22 +1954,28 @@ export class IterationOrchestrator {
|
|
|
1918
1954
|
lastAssistant.content.length > 0;
|
|
1919
1955
|
if (hasResult)
|
|
1920
1956
|
return;
|
|
1921
|
-
// An empty completion may itself have exhausted the
|
|
1957
|
+
// An empty completion may itself have exhausted the turn. This fallback
|
|
1922
1958
|
// is another billed request, so it must pass the same hard limits as
|
|
1923
1959
|
// the next normal iteration and preserve their unfinished stop reason.
|
|
1924
|
-
const guardResult = this.ctx.guard.beforeIteration(this.ctx.
|
|
1960
|
+
const guardResult = this.ctx.guard.beforeIteration(this.ctx.recorder, this.ctx.abortController.signal);
|
|
1925
1961
|
if (guardResult.shouldStop)
|
|
1926
1962
|
return guardResult.stopReason;
|
|
1927
1963
|
this.ctx.log.info('Requesting final response after empty completion', {
|
|
1928
1964
|
'namzu.runtime.reason': reason,
|
|
1929
1965
|
});
|
|
1930
1966
|
try {
|
|
1967
|
+
// The working-memory slot leaves the system run exactly as it does
|
|
1968
|
+
// for a normal step, and for the same cache reason.
|
|
1969
|
+
const workingMemory = splitWorkingMemoryForRequest(this.ctx.recorder.messages);
|
|
1931
1970
|
const finalHistory = [
|
|
1932
|
-
...
|
|
1933
|
-
|
|
1971
|
+
...workingMemory.history,
|
|
1972
|
+
...(workingMemory.context ? [workingMemory.context] : []),
|
|
1934
1973
|
];
|
|
1935
|
-
const finalMessages = projectRequestRichContent(this.projectObservations(finalHistory), this.ctx.
|
|
1974
|
+
const finalMessages = projectRequestRichContent(this.projectObservations(finalHistory), this.ctx.turnConfig.maxRequestRichContentBytes ?? DEFAULT_MAX_REQUEST_RICH_CONTENT_BYTES);
|
|
1936
1975
|
appendWorkContext(this.stepShaping(), finalMessages, this.steps.length + 1, { model });
|
|
1976
|
+
// The closing directive is the last thing the model reads: after
|
|
1977
|
+
// the working memory and any work context above.
|
|
1978
|
+
finalMessages.push(createRuntimeContextMessage(`[SYSTEM] Turn is ending due to ${reason}. ${CLOSING_RESPONSE_GUIDANCE}`, 'limit-finalization'));
|
|
1937
1979
|
await this.reportUnsupportedToolResults(finalMessages);
|
|
1938
1980
|
// Same cache discipline as the forced-final iteration: keep the
|
|
1939
1981
|
// tools param identical to prior iterations (cache prefix intact,
|
|
@@ -1956,14 +1998,14 @@ export class IterationOrchestrator {
|
|
|
1956
1998
|
tools: finalTools.length > 0 ? finalTools : undefined,
|
|
1957
1999
|
...(finalEnforced ? { enforceToolInputSchema: finalEnforced } : {}),
|
|
1958
2000
|
toolChoice: finalTools.length > 0 ? 'none' : undefined,
|
|
1959
|
-
temperature: this.ctx.
|
|
1960
|
-
maxTokens: this.ctx.
|
|
2001
|
+
temperature: this.ctx.turnConfig.temperature,
|
|
2002
|
+
maxTokens: this.ctx.turnConfig.maxResponseTokens,
|
|
1961
2003
|
cacheControl: { type: 'auto' },
|
|
1962
|
-
...(this.ctx.
|
|
2004
|
+
...(this.ctx.turnConfig.thinking ? { thinking: this.ctx.turnConfig.thinking } : {}),
|
|
1963
2005
|
// This turn is a hand-maintained duplicate of the one above, which
|
|
1964
2006
|
// is exactly the shape a field goes missing from — so it is tested
|
|
1965
2007
|
// separately rather than assumed to have been kept in step.
|
|
1966
|
-
...(this.ctx.
|
|
2008
|
+
...(this.ctx.turnConfig.effort ? { effort: this.ctx.turnConfig.effort } : {}),
|
|
1967
2009
|
// Cancellable too: a Stop during the closing summary must not
|
|
1968
2010
|
// stream to completion.
|
|
1969
2011
|
signal: this.ctx.abortController.signal,
|
|
@@ -1975,7 +2017,7 @@ export class IterationOrchestrator {
|
|
|
1975
2017
|
model: servingMember.model ?? model,
|
|
1976
2018
|
chainIndex: servingMember.index,
|
|
1977
2019
|
};
|
|
1978
|
-
this.ctx.
|
|
2020
|
+
this.ctx.recorder.accumulateUsage(response.usage, {
|
|
1979
2021
|
providerId: servedBy.providerId,
|
|
1980
2022
|
model: servedBy.model,
|
|
1981
2023
|
});
|
|
@@ -1986,18 +2028,18 @@ export class IterationOrchestrator {
|
|
|
1986
2028
|
? { replayState: response.message.replayState }
|
|
1987
2029
|
: {}),
|
|
1988
2030
|
}, response.message.textParts);
|
|
1989
|
-
this.ctx.
|
|
2031
|
+
this.ctx.recorder.pushMessage(assistantMsg);
|
|
1990
2032
|
const finalMessageId = generateMessageId();
|
|
1991
2033
|
await this.ctx.emitEvent({
|
|
1992
2034
|
type: 'message_started',
|
|
1993
|
-
|
|
1994
|
-
iteration: this.ctx.
|
|
2035
|
+
turnId: this.ctx.recorder.turnId,
|
|
2036
|
+
iteration: this.ctx.recorder.currentIteration,
|
|
1995
2037
|
messageId: finalMessageId,
|
|
1996
2038
|
});
|
|
1997
2039
|
await this.ctx.emitEvent({
|
|
1998
2040
|
type: 'message_completed',
|
|
1999
|
-
|
|
2000
|
-
iteration: this.ctx.
|
|
2041
|
+
turnId: this.ctx.recorder.turnId,
|
|
2042
|
+
iteration: this.ctx.recorder.currentIteration,
|
|
2001
2043
|
messageId: finalMessageId,
|
|
2002
2044
|
stopReason: 'forced_finalize',
|
|
2003
2045
|
usage: response.usage,
|