@namzu/sdk 34.2.0 → 36.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 +171 -0
- package/README.md +2 -6
- package/dist/agents/PipelineAgent.d.ts.map +1 -1
- package/dist/agents/PipelineAgent.js +118 -100
- package/dist/agents/PipelineAgent.js.map +1 -1
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +2 -0
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/RouterAgent.d.ts.map +1 -1
- package/dist/agents/RouterAgent.js +105 -61
- package/dist/agents/RouterAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +8 -4
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/agents/budget.d.ts +6 -0
- package/dist/agents/budget.d.ts.map +1 -0
- package/dist/agents/budget.js +33 -0
- package/dist/agents/budget.js.map +1 -0
- package/dist/agents/explore.d.ts +20 -0
- package/dist/agents/explore.d.ts.map +1 -0
- package/dist/agents/explore.js +26 -0
- package/dist/agents/explore.js.map +1 -0
- package/dist/agents/file-definitions.d.ts +80 -0
- package/dist/agents/file-definitions.d.ts.map +1 -0
- package/dist/agents/file-definitions.js +179 -0
- package/dist/agents/file-definitions.js.map +1 -0
- package/dist/agents/index.d.ts +3 -0
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +2 -0
- package/dist/agents/index.js.map +1 -1
- package/dist/bridge/a2a/mapper.d.ts.map +1 -1
- package/dist/bridge/a2a/mapper.js +6 -0
- package/dist/bridge/a2a/mapper.js.map +1 -1
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +22 -0
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/bus/lock.d.ts.map +1 -1
- package/dist/bus/lock.js +1 -10
- package/dist/bus/lock.js.map +1 -1
- package/dist/compaction/consolidation.d.ts +31 -0
- package/dist/compaction/consolidation.d.ts.map +1 -0
- package/dist/compaction/consolidation.js +63 -0
- package/dist/compaction/consolidation.js.map +1 -0
- package/dist/compaction/factory.d.ts.map +1 -1
- package/dist/compaction/factory.js +3 -0
- package/dist/compaction/factory.js.map +1 -1
- package/dist/compaction/index.d.ts +6 -1
- package/dist/compaction/index.d.ts.map +1 -1
- package/dist/compaction/index.js +6 -0
- package/dist/compaction/index.js.map +1 -1
- package/dist/compaction/manager.d.ts +7 -0
- package/dist/compaction/manager.d.ts.map +1 -1
- package/dist/compaction/manager.js +31 -0
- package/dist/compaction/manager.js.map +1 -1
- package/dist/compaction/plan.d.ts +23 -0
- package/dist/compaction/plan.d.ts.map +1 -1
- package/dist/compaction/plan.js +41 -24
- package/dist/compaction/plan.js.map +1 -1
- package/dist/compaction/salience/bm25.d.ts +26 -0
- package/dist/compaction/salience/bm25.d.ts.map +1 -0
- package/dist/compaction/salience/bm25.js +56 -0
- package/dist/compaction/salience/bm25.js.map +1 -0
- package/dist/compaction/salience/goal.d.ts +21 -0
- package/dist/compaction/salience/goal.d.ts.map +1 -0
- package/dist/compaction/salience/goal.js +32 -0
- package/dist/compaction/salience/goal.js.map +1 -0
- package/dist/compaction/salience/index.d.ts +4 -0
- package/dist/compaction/salience/index.d.ts.map +1 -0
- package/dist/compaction/salience/index.js +4 -0
- package/dist/compaction/salience/index.js.map +1 -0
- package/dist/compaction/salience/minhash.d.ts +17 -0
- package/dist/compaction/salience/minhash.d.ts.map +1 -0
- package/dist/compaction/salience/minhash.js +54 -0
- package/dist/compaction/salience/minhash.js.map +1 -0
- package/dist/compaction/salience/score.d.ts +64 -0
- package/dist/compaction/salience/score.d.ts.map +1 -0
- package/dist/compaction/salience/score.js +256 -0
- package/dist/compaction/salience/score.js.map +1 -0
- package/dist/compaction/salience/tokenize.d.ts +20 -0
- package/dist/compaction/salience/tokenize.d.ts.map +1 -0
- package/dist/compaction/salience/tokenize.js +92 -0
- package/dist/compaction/salience/tokenize.js.map +1 -0
- package/dist/compaction/salience/working-set.d.ts +59 -0
- package/dist/compaction/salience/working-set.d.ts.map +1 -0
- package/dist/compaction/salience/working-set.js +137 -0
- package/dist/compaction/salience/working-set.js.map +1 -0
- package/dist/compaction/serializer.d.ts +2 -0
- package/dist/compaction/serializer.d.ts.map +1 -1
- package/dist/compaction/serializer.js +15 -0
- package/dist/compaction/serializer.js.map +1 -1
- package/dist/compaction/token-estimate.d.ts +13 -0
- package/dist/compaction/token-estimate.d.ts.map +1 -0
- package/dist/compaction/token-estimate.js +58 -0
- package/dist/compaction/token-estimate.js.map +1 -0
- package/dist/compaction/tool-result-editing.d.ts +10 -2
- package/dist/compaction/tool-result-editing.d.ts.map +1 -1
- package/dist/compaction/tool-result-editing.js +22 -24
- package/dist/compaction/tool-result-editing.js.map +1 -1
- package/dist/compaction/types.d.ts +22 -1
- package/dist/compaction/types.d.ts.map +1 -1
- package/dist/compaction/wire.d.ts +3 -1
- package/dist/compaction/wire.d.ts.map +1 -1
- package/dist/compaction/wire.js +2 -0
- package/dist/compaction/wire.js.map +1 -1
- package/dist/config/runtime.d.ts +58 -28
- package/dist/config/runtime.d.ts.map +1 -1
- package/dist/config/runtime.js +13 -1
- package/dist/config/runtime.js.map +1 -1
- package/dist/connector/builtins/http.d.ts.map +1 -1
- package/dist/connector/builtins/http.js +2 -8
- package/dist/connector/builtins/http.js.map +1 -1
- package/dist/connector/builtins/webhook.js +2 -2
- package/dist/connector/builtins/webhook.js.map +1 -1
- package/dist/connector/mcp/adapter.d.ts +2 -0
- package/dist/connector/mcp/adapter.d.ts.map +1 -1
- package/dist/connector/mcp/adapter.js +30 -0
- package/dist/connector/mcp/adapter.js.map +1 -1
- package/dist/connector/tools/adapter.js +2 -2
- package/dist/connector/tools/adapter.js.map +1 -1
- package/dist/connector/tools/definitions.js +2 -2
- package/dist/connector/tools/definitions.js.map +1 -1
- package/dist/constants/compaction/index.d.ts +1 -0
- package/dist/constants/compaction/index.d.ts.map +1 -1
- package/dist/constants/compaction/index.js +1 -0
- package/dist/constants/compaction/index.js.map +1 -1
- package/dist/constants/telemetry/index.d.ts +0 -1
- package/dist/constants/telemetry/index.d.ts.map +1 -1
- package/dist/constants/telemetry/index.js +0 -1
- package/dist/constants/telemetry/index.js.map +1 -1
- package/dist/contracts/a2a.d.ts +5 -5
- package/dist/contracts/api.d.ts +4 -2
- package/dist/contracts/api.d.ts.map +1 -1
- package/dist/contracts/schemas.d.ts +1 -15
- package/dist/contracts/schemas.d.ts.map +1 -1
- package/dist/contracts/schemas.js +5 -20
- package/dist/contracts/schemas.js.map +1 -1
- package/dist/invariants/index.d.ts +1 -1
- package/dist/manager/agent/lifecycle.d.ts +2 -18
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +373 -340
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/run/persistence.d.ts +3 -0
- package/dist/manager/run/persistence.d.ts.map +1 -1
- package/dist/manager/run/persistence.js +35 -5
- package/dist/manager/run/persistence.js.map +1 -1
- package/dist/plugin/index.d.ts +2 -0
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +1 -0
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +128 -0
- package/dist/plugin/shell-hook.d.ts.map +1 -0
- package/dist/plugin/shell-hook.js +299 -0
- package/dist/plugin/shell-hook.js.map +1 -0
- package/dist/prompt/coding-agent-doctrine.d.ts +63 -0
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -0
- package/dist/prompt/coding-agent-doctrine.js +100 -0
- package/dist/prompt/coding-agent-doctrine.js.map +1 -0
- package/dist/prompt/index.d.ts +2 -0
- package/dist/prompt/index.d.ts.map +1 -1
- package/dist/prompt/index.js +1 -0
- package/dist/prompt/index.js.map +1 -1
- package/dist/provider/errors.d.ts +1 -1
- package/dist/provider/errors.js +1 -1
- package/dist/provider/fallback.d.ts +2 -0
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +3 -1
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/retry.d.ts +2 -0
- package/dist/provider/retry.d.ts.map +1 -1
- package/dist/provider/retry.js +3 -1
- package/dist/provider/retry.js.map +1 -1
- package/dist/provider/token-budget.d.ts +13 -0
- package/dist/provider/token-budget.d.ts.map +1 -0
- package/dist/provider/token-budget.js +150 -0
- package/dist/provider/token-budget.js.map +1 -0
- package/dist/public-runtime.d.ts +14 -14
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +15 -10
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +2 -0
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +2 -0
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +12 -2
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.js +18 -6
- package/dist/registry/command/kernel-commands.js.map +1 -1
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +4 -1
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/run/LimitChecker.js +1 -1
- package/dist/run/LimitChecker.js.map +1 -1
- package/dist/run/drain.js +1 -1
- package/dist/run/reporter.d.ts.map +1 -1
- package/dist/run/reporter.js +15 -0
- package/dist/run/reporter.js.map +1 -1
- package/dist/run/token-budget.d.ts +108 -0
- package/dist/run/token-budget.d.ts.map +1 -0
- package/dist/run/token-budget.js +591 -0
- package/dist/run/token-budget.js.map +1 -0
- package/dist/runtime/jobs/registry.d.ts +29 -0
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +98 -18
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/checkpoint.d.ts.map +1 -1
- package/dist/runtime/query/checkpoint.js +10 -3
- package/dist/runtime/query/checkpoint.js.map +1 -1
- package/dist/runtime/query/context.d.ts +2 -26
- package/dist/runtime/query/context.d.ts.map +1 -1
- package/dist/runtime/query/context.js +1 -29
- package/dist/runtime/query/context.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +13 -9
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +144 -55
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/guard.d.ts.map +1 -1
- package/dist/runtime/query/guard.js +8 -0
- package/dist/runtime/query/guard.js.map +1 -1
- package/dist/runtime/query/index.d.ts +42 -4
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +153 -52
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +3 -3
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +47 -11
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +98 -30
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +4 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +29 -7
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/phases/working-memory.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/working-memory.js +25 -15
- package/dist/runtime/query/iteration/phases/working-memory.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +10 -5
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/plugin-hooks.d.ts +1 -1
- package/dist/runtime/query/plugin-hooks.d.ts.map +1 -1
- package/dist/runtime/query/plugin-hooks.js +20 -1
- package/dist/runtime/query/plugin-hooks.js.map +1 -1
- package/dist/runtime/query/prompt.d.ts.map +1 -1
- package/dist/runtime/query/prompt.js +14 -4
- package/dist/runtime/query/prompt.js.map +1 -1
- package/dist/runtime/query/repeat-call.d.ts +20 -2
- package/dist/runtime/query/repeat-call.d.ts.map +1 -1
- package/dist/runtime/query/repeat-call.js +35 -7
- package/dist/runtime/query/repeat-call.js.map +1 -1
- package/dist/runtime/query/result.d.ts.map +1 -1
- package/dist/runtime/query/result.js +9 -0
- package/dist/runtime/query/result.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +142 -0
- package/dist/runtime/query/review-policy.d.ts.map +1 -0
- package/dist/runtime/query/review-policy.js +144 -0
- package/dist/runtime/query/review-policy.js.map +1 -0
- package/dist/runtime/query/run-state.d.ts.map +1 -1
- package/dist/runtime/query/run-state.js +4 -0
- package/dist/runtime/query/run-state.js.map +1 -1
- package/dist/runtime/query/steering.d.ts +4 -0
- package/dist/runtime/query/steering.d.ts.map +1 -1
- package/dist/runtime/query/steering.js +29 -0
- package/dist/runtime/query/steering.js.map +1 -1
- package/dist/runtime/query/token-budget.d.ts +7 -0
- package/dist/runtime/query/token-budget.d.ts.map +1 -0
- package/dist/runtime/query/token-budget.js +101 -0
- package/dist/runtime/query/token-budget.js.map +1 -0
- package/dist/runtime/query/tool-output-budget.d.ts +2 -0
- package/dist/runtime/query/tool-output-budget.d.ts.map +1 -1
- package/dist/runtime/query/tool-output-budget.js +29 -11
- package/dist/runtime/query/tool-output-budget.js.map +1 -1
- package/dist/runtime/query/tool-pause.d.ts.map +1 -1
- package/dist/runtime/query/tool-pause.js +4 -2
- package/dist/runtime/query/tool-pause.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +4 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +4 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/sandbox/file-walk-program.d.ts +3 -0
- package/dist/sandbox/file-walk-program.d.ts.map +1 -0
- package/dist/sandbox/file-walk-program.js +94 -0
- package/dist/sandbox/file-walk-program.js.map +1 -0
- package/dist/sandbox/file-walk.d.ts +12 -0
- package/dist/sandbox/file-walk.d.ts.map +1 -0
- package/dist/sandbox/file-walk.js +429 -0
- package/dist/sandbox/file-walk.js.map +1 -0
- package/dist/sandbox/index.d.ts +2 -0
- package/dist/sandbox/index.d.ts.map +1 -1
- package/dist/sandbox/index.js +1 -0
- package/dist/sandbox/index.js.map +1 -1
- package/dist/sandbox/provider/local.d.ts +3 -1
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +121 -12
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/scheduler/completion-inbox.d.ts +3 -2
- package/dist/scheduler/completion-inbox.d.ts.map +1 -1
- package/dist/scheduler/completion-inbox.js +29 -15
- package/dist/scheduler/completion-inbox.js.map +1 -1
- package/dist/scheduler/delegating.d.ts +1 -0
- package/dist/scheduler/delegating.d.ts.map +1 -1
- package/dist/scheduler/delegating.js +29 -12
- package/dist/scheduler/delegating.js.map +1 -1
- package/dist/scheduler/local.d.ts +1 -0
- package/dist/scheduler/local.d.ts.map +1 -1
- package/dist/scheduler/local.js +4 -7
- package/dist/scheduler/local.js.map +1 -1
- package/dist/session/index.d.ts +0 -1
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +0 -1
- package/dist/session/index.js.map +1 -1
- package/dist/session/workspace/path-builder.d.ts.map +1 -1
- package/dist/session/workspace/path-builder.js +5 -4
- package/dist/session/workspace/path-builder.js.map +1 -1
- package/dist/store/feedback/disk.d.ts.map +1 -1
- package/dist/store/feedback/disk.js +4 -6
- package/dist/store/feedback/disk.js.map +1 -1
- package/dist/store/index.d.ts +2 -0
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +1 -0
- package/dist/store/index.js.map +1 -1
- package/dist/store/memory/disk.d.ts.map +1 -1
- package/dist/store/memory/disk.js +3 -12
- package/dist/store/memory/disk.js.map +1 -1
- package/dist/store/run/checkpoint-disk.d.ts +3 -3
- package/dist/store/run/checkpoint-disk.d.ts.map +1 -1
- package/dist/store/run/checkpoint-disk.js +14 -26
- package/dist/store/run/checkpoint-disk.js.map +1 -1
- package/dist/store/run/claim-disk.js +1 -1
- package/dist/store/run/conformance.d.ts +1 -1
- package/dist/store/run/conformance.d.ts.map +1 -1
- package/dist/store/run/conformance.js +41 -33
- package/dist/store/run/conformance.js.map +1 -1
- package/dist/store/run/disk.d.ts.map +1 -1
- package/dist/store/run/disk.js +20 -4
- package/dist/store/run/disk.js.map +1 -1
- package/dist/store/run/token-budget-disk.d.ts +37 -0
- package/dist/store/run/token-budget-disk.d.ts.map +1 -0
- package/dist/store/run/token-budget-disk.js +208 -0
- package/dist/store/run/token-budget-disk.js.map +1 -0
- package/dist/store/session/disk.d.ts +4 -13
- package/dist/store/session/disk.d.ts.map +1 -1
- package/dist/store/session/disk.js +34 -31
- package/dist/store/session/disk.js.map +1 -1
- package/dist/store/session/memory.d.ts +2 -0
- package/dist/store/session/memory.d.ts.map +1 -1
- package/dist/store/session/memory.js +41 -2
- package/dist/store/session/memory.js.map +1 -1
- package/dist/store/task/disk.d.ts.map +1 -1
- package/dist/store/task/disk.js +7 -8
- package/dist/store/task/disk.js.map +1 -1
- package/dist/store/topic/memory.d.ts +2 -0
- package/dist/store/topic/memory.d.ts.map +1 -1
- package/dist/store/topic/memory.js +13 -1
- package/dist/store/topic/memory.js.map +1 -1
- package/dist/test-support/ids.d.ts +4 -19
- package/dist/test-support/ids.d.ts.map +1 -1
- package/dist/test-support/ids.js +51 -59
- package/dist/test-support/ids.js.map +1 -1
- package/dist/tools/advisory/index.d.ts.map +1 -1
- package/dist/tools/advisory/index.js +3 -1
- package/dist/tools/advisory/index.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts +2 -0
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +224 -70
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts +2 -2
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +4 -2
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/edit.js +2 -2
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/glob.d.ts +2 -1
- package/dist/tools/builtins/glob.d.ts.map +1 -1
- package/dist/tools/builtins/glob.js +95 -103
- 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 +155 -111
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/ls.js +4 -4
- package/dist/tools/builtins/ls.js.map +1 -1
- package/dist/tools/builtins/lsp.js +2 -2
- package/dist/tools/builtins/lsp.js.map +1 -1
- package/dist/tools/builtins/read-file.js +2 -2
- package/dist/tools/builtins/read-file.js.map +1 -1
- package/dist/tools/builtins/write-file.js +2 -2
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/coordinator/ask-user-question.d.ts +33 -0
- package/dist/tools/coordinator/ask-user-question.d.ts.map +1 -0
- package/dist/tools/coordinator/ask-user-question.js +237 -0
- package/dist/tools/coordinator/ask-user-question.js.map +1 -0
- package/dist/tools/coordinator/index.d.ts +1 -2
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +4 -220
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/memory/read.d.ts.map +1 -1
- package/dist/tools/memory/read.js +2 -4
- package/dist/tools/memory/read.js.map +1 -1
- package/dist/tools/paths.d.ts +13 -0
- package/dist/tools/paths.d.ts.map +1 -1
- package/dist/tools/paths.js +53 -0
- package/dist/tools/paths.js.map +1 -1
- package/dist/tools/roster.d.ts +27 -0
- package/dist/tools/roster.d.ts.map +1 -0
- package/dist/tools/roster.js +42 -0
- package/dist/tools/roster.js.map +1 -0
- package/dist/types/agent/base.d.ts +5 -0
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/pipeline.d.ts +3 -0
- package/dist/types/agent/pipeline.d.ts.map +1 -1
- package/dist/types/agent/router.d.ts +2 -3
- package/dist/types/agent/router.d.ts.map +1 -1
- package/dist/types/agent/scheduler.d.ts +3 -0
- package/dist/types/agent/scheduler.d.ts.map +1 -1
- package/dist/types/agent/task.d.ts +5 -16
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/agent/task.js.map +1 -1
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/index.js +3 -0
- package/dist/types/common/index.js.map +1 -1
- package/dist/types/computer-use/index.d.ts +8 -0
- package/dist/types/computer-use/index.d.ts.map +1 -1
- package/dist/types/computer-use/index.js.map +1 -1
- package/dist/types/hitl/index.d.ts +5 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/ids/brand.d.ts +5 -47
- package/dist/types/ids/brand.d.ts.map +1 -1
- package/dist/types/ids/brand.js +2 -39
- package/dist/types/ids/brand.js.map +1 -1
- package/dist/types/ids/index.d.ts +59 -69
- package/dist/types/ids/index.d.ts.map +1 -1
- package/dist/types/ids/index.js +12 -10
- package/dist/types/ids/index.js.map +1 -1
- package/dist/types/permission/index.d.ts +9 -0
- package/dist/types/permission/index.d.ts.map +1 -1
- package/dist/types/permission/index.js +9 -1
- package/dist/types/permission/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +45 -4
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +7 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/run/config.d.ts +3 -0
- package/dist/types/run/config.d.ts.map +1 -1
- package/dist/types/run/emergency.d.ts +5 -0
- package/dist/types/run/emergency.d.ts.map +1 -1
- package/dist/types/run/emergency.js.map +1 -1
- package/dist/types/run/entity.d.ts +6 -2
- package/dist/types/run/entity.d.ts.map +1 -1
- package/dist/types/run/events.d.ts +35 -0
- package/dist/types/run/events.d.ts.map +1 -1
- package/dist/types/run/events.js.map +1 -1
- package/dist/types/run/index.d.ts +1 -0
- package/dist/types/run/index.d.ts.map +1 -1
- package/dist/types/run/index.js +1 -0
- package/dist/types/run/index.js.map +1 -1
- package/dist/types/run/state.d.ts +16 -15
- package/dist/types/run/state.d.ts.map +1 -1
- package/dist/types/run/state.js +41 -22
- package/dist/types/run/state.js.map +1 -1
- package/dist/types/run/stop-reason.d.ts +3 -14
- package/dist/types/run/stop-reason.d.ts.map +1 -1
- package/dist/types/run/token-budget-store.d.ts +29 -0
- package/dist/types/run/token-budget-store.d.ts.map +1 -0
- package/dist/types/run/token-budget-store.js +25 -0
- package/dist/types/run/token-budget-store.js.map +1 -0
- package/dist/types/sandbox/index.d.ts +47 -2
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/session/store.d.ts +8 -0
- package/dist/types/session/store.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +15 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/utils/frontmatter.d.ts +1 -1
- package/dist/utils/frontmatter.js +1 -1
- package/dist/utils/id-format.d.ts +3 -0
- package/dist/utils/id-format.d.ts.map +1 -0
- package/dist/utils/id-format.js +9 -0
- package/dist/utils/id-format.js.map +1 -0
- package/dist/utils/id.d.ts +65 -32
- package/dist/utils/id.d.ts.map +1 -1
- package/dist/utils/id.js +168 -148
- package/dist/utils/id.js.map +1 -1
- package/dist/utils/log/exception.js +1 -1
- package/dist/utils/log/exception.js.map +1 -1
- package/dist/utils/log/index.d.ts.map +1 -1
- package/dist/utils/log/index.js +1 -2
- package/dist/utils/log/index.js.map +1 -1
- package/dist/utils/log/templates.d.ts.map +1 -1
- package/dist/utils/log/templates.js +0 -1
- package/dist/utils/log/templates.js.map +1 -1
- package/package.json +6 -1
- package/src/agents/AGENTS.md +1 -1
- package/src/agents/PipelineAgent.ts +129 -109
- package/src/agents/ReactiveAgent.ts +2 -0
- package/src/agents/RouterAgent.ts +120 -73
- package/src/agents/SupervisorAgent.ts +12 -4
- package/src/agents/budget.ts +42 -0
- package/src/agents/explore.ts +29 -0
- package/src/agents/file-definitions.ts +237 -0
- package/src/agents/index.ts +15 -0
- package/src/bridge/a2a/mapper.ts +6 -0
- package/src/bridge/sse/mapper.ts +22 -0
- package/src/bus/lock.ts +1 -10
- package/src/compaction/consolidation.ts +79 -0
- package/src/compaction/factory.ts +3 -0
- package/src/compaction/index.ts +34 -4
- package/src/compaction/manager.ts +39 -1
- package/src/compaction/plan.ts +52 -21
- package/src/compaction/salience/bm25.ts +72 -0
- package/src/compaction/salience/goal.ts +44 -0
- package/src/compaction/salience/index.ts +19 -0
- package/src/compaction/salience/minhash.ts +53 -0
- package/src/compaction/salience/score.ts +305 -0
- package/src/compaction/salience/tokenize.ts +89 -0
- package/src/compaction/salience/working-set.ts +187 -0
- package/src/compaction/serializer.ts +16 -0
- package/src/compaction/token-estimate.ts +57 -0
- package/src/compaction/tool-result-editing.ts +28 -26
- package/src/compaction/types.ts +24 -1
- package/src/compaction/wire.ts +5 -1
- package/src/config/runtime.ts +13 -1
- package/src/connector/builtins/http.ts +2 -8
- package/src/connector/builtins/webhook.ts +2 -2
- package/src/connector/mcp/adapter.ts +32 -0
- package/src/connector/tools/adapter.ts +2 -2
- package/src/connector/tools/definitions.ts +2 -2
- package/src/constants/compaction/index.ts +1 -0
- package/src/constants/telemetry/index.ts +0 -1
- package/src/contracts/api.ts +5 -1
- package/src/contracts/schemas.ts +6 -20
- package/src/invariants/index.ts +1 -1
- package/src/manager/agent/lifecycle.ts +380 -352
- package/src/manager/run/persistence.ts +35 -5
- package/src/plugin/index.ts +19 -0
- package/src/plugin/shell-hook.ts +403 -0
- package/src/prompt/coding-agent-doctrine.ts +118 -0
- package/src/prompt/index.ts +8 -0
- package/src/provider/errors.ts +1 -1
- package/src/provider/fallback.ts +4 -1
- package/src/provider/retry.ts +4 -1
- package/src/provider/token-budget.ts +158 -0
- package/src/public-runtime.ts +56 -28
- package/src/public-tools.ts +5 -0
- package/src/public-types.ts +65 -0
- package/src/registry/command/kernel-commands.ts +16 -6
- package/src/registry/tool/execute.ts +4 -1
- package/src/run/LimitChecker.ts +1 -1
- package/src/run/drain.ts +1 -1
- package/src/run/reporter.ts +15 -0
- package/src/run/token-budget.ts +692 -0
- package/src/runtime/jobs/registry.ts +123 -17
- package/src/runtime/query/checkpoint.ts +10 -3
- package/src/runtime/query/context.ts +3 -57
- package/src/runtime/query/executor.ts +181 -71
- package/src/runtime/query/guard.ts +8 -0
- package/src/runtime/query/index.ts +209 -62
- package/src/runtime/query/iteration/index.ts +53 -15
- package/src/runtime/query/iteration/phases/compaction.ts +130 -31
- package/src/runtime/query/iteration/phases/context.ts +4 -0
- package/src/runtime/query/iteration/phases/tool-review.ts +39 -7
- package/src/runtime/query/iteration/phases/working-memory.ts +23 -14
- package/src/runtime/query/iteration/stream-turn.ts +9 -5
- package/src/runtime/query/plugin-hooks.ts +24 -2
- package/src/runtime/query/prompt.ts +21 -4
- package/src/runtime/query/repeat-call.ts +42 -7
- package/src/runtime/query/result.ts +9 -0
- package/src/runtime/query/review-policy.ts +231 -0
- package/src/runtime/query/run-state.ts +4 -0
- package/src/runtime/query/steering.ts +32 -0
- package/src/runtime/query/token-budget.ts +127 -0
- package/src/runtime/query/tool-output-budget.ts +33 -10
- package/src/runtime/query/tool-pause.ts +4 -2
- package/src/runtime/query/tooling.ts +8 -0
- package/src/sandbox/file-walk-program.ts +93 -0
- package/src/sandbox/file-walk.ts +463 -0
- package/src/sandbox/index.ts +2 -0
- package/src/sandbox/provider/local.ts +136 -13
- package/src/scheduler/completion-inbox.ts +29 -19
- package/src/scheduler/delegating.ts +35 -13
- package/src/scheduler/local.ts +5 -7
- package/src/session/index.ts +0 -1
- package/src/session/workspace/path-builder.ts +5 -4
- package/src/store/feedback/disk.ts +4 -6
- package/src/store/index.ts +2 -0
- package/src/store/memory/disk.ts +3 -11
- package/src/store/run/checkpoint-disk.ts +14 -27
- package/src/store/run/claim-disk.ts +1 -1
- package/src/store/run/conformance.ts +55 -39
- package/src/store/run/disk.ts +19 -4
- package/src/store/run/token-budget-disk.ts +247 -0
- package/src/store/session/disk.ts +36 -29
- package/src/store/session/memory.ts +38 -1
- package/src/store/task/disk.ts +7 -8
- package/src/store/topic/memory.ts +13 -1
- package/src/test-support/ids.ts +62 -59
- package/src/tools/advisory/index.ts +3 -1
- package/src/tools/builtins/bash.ts +241 -70
- package/src/tools/builtins/computer-use.ts +6 -2
- package/src/tools/builtins/edit.ts +2 -2
- package/src/tools/builtins/glob.ts +104 -122
- package/src/tools/builtins/grep.ts +166 -132
- package/src/tools/builtins/ls.ts +4 -4
- package/src/tools/builtins/lsp.ts +2 -2
- package/src/tools/builtins/read-file.ts +2 -2
- package/src/tools/builtins/write-file.ts +2 -2
- package/src/tools/coordinator/ask-user-question.ts +284 -0
- package/src/tools/coordinator/index.ts +5 -248
- package/src/tools/memory/read.ts +2 -4
- package/src/tools/paths.ts +64 -0
- package/src/tools/roster.ts +46 -0
- package/src/types/agent/base.ts +6 -0
- package/src/types/agent/pipeline.ts +3 -0
- package/src/types/agent/router.ts +2 -3
- package/src/types/agent/scheduler.ts +4 -0
- package/src/types/agent/task.ts +5 -18
- package/src/types/common/index.ts +3 -0
- package/src/types/computer-use/index.ts +8 -0
- package/src/types/hitl/index.ts +5 -0
- package/src/types/ids/brand.ts +5 -48
- package/src/types/ids/index.ts +66 -75
- package/src/types/permission/index.ts +11 -0
- package/src/types/plugin/index.ts +49 -1
- package/src/types/run/config.ts +3 -0
- package/src/types/run/emergency.ts +5 -0
- package/src/types/run/entity.ts +6 -2
- package/src/types/run/events.ts +37 -0
- package/src/types/run/index.ts +1 -0
- package/src/types/run/state.ts +58 -30
- package/src/types/run/stop-reason.ts +3 -14
- package/src/types/run/token-budget-store.ts +54 -0
- package/src/types/sandbox/index.ts +53 -0
- package/src/types/session/store.ts +8 -0
- package/src/types/tool/index.ts +15 -0
- package/src/utils/frontmatter.ts +1 -1
- package/src/utils/id-format.ts +9 -0
- package/src/utils/id.ts +222 -181
- package/src/utils/log/exception.ts +1 -1
- package/src/utils/log/index.ts +1 -2
- package/src/utils/log/templates.ts +0 -1
- package/dist/session/migration/errors.d.ts +0 -26
- package/dist/session/migration/errors.d.ts.map +0 -1
- package/dist/session/migration/errors.js +0 -22
- package/dist/session/migration/errors.js.map +0 -1
- package/dist/session/migration/filesystem.d.ts +0 -122
- package/dist/session/migration/filesystem.d.ts.map +0 -1
- package/dist/session/migration/filesystem.js +0 -379
- package/dist/session/migration/filesystem.js.map +0 -1
- package/dist/session/migration/id-prefix.d.ts +0 -113
- package/dist/session/migration/id-prefix.d.ts.map +0 -1
- package/dist/session/migration/id-prefix.js +0 -132
- package/dist/session/migration/id-prefix.js.map +0 -1
- package/dist/session/migration/index.d.ts +0 -12
- package/dist/session/migration/index.d.ts.map +0 -1
- package/dist/session/migration/index.js +0 -12
- package/dist/session/migration/index.js.map +0 -1
- package/dist/session/migration/marker.d.ts +0 -57
- package/dist/session/migration/marker.d.ts.map +0 -1
- package/dist/session/migration/marker.js +0 -123
- package/dist/session/migration/marker.js.map +0 -1
- package/src/session/migration/errors.ts +0 -23
- package/src/session/migration/filesystem.ts +0 -468
- package/src/session/migration/id-prefix.ts +0 -166
- package/src/session/migration/index.ts +0 -41
- package/src/session/migration/marker.ts +0 -142
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../../../src/runtime/query/guard.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AA0BjF,MAAM,OAAO,gBAAgB;IACpB,WAAW,CAAoB;IAC/B,SAAS,CAAQ;IAEzB,YAAY,MAAmB;QAC9B,IAAI,CAAC,WAAW,GAAG,gBAAgB,CAClC,MAAM,CAAC,WAAW,EAClB,MAAM,CAAC,SAAS,EAChB,MAAM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AAC;QAED,OAAO;YACN,UAAU,EAAE,KAAK;YACjB,aAAa,EAAE,KAAK;YACpB,WAAW,EAAE,KAAK;SAClB,CAAA;IACF,CAAC;CACD"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ContextReducer } from '../../compaction/reducer.js';
|
|
2
|
-
import type
|
|
2
|
+
import { type CompactionConfig } from '../../config/runtime.js';
|
|
3
3
|
import { type ProviderChainMember } from '../../provider/fallback.js';
|
|
4
4
|
import { type ProviderRetryConfig } from '../../provider/retry.js';
|
|
5
|
+
import type { TokenBudget } from '../../run/token-budget.js';
|
|
5
6
|
import type { PathBuilder } from '../../session/workspace/path-builder.js';
|
|
6
7
|
import type { SerializedSpanContext } from '../../telemetry/attributes.js';
|
|
7
8
|
import type { AdvisoryConfig } from '../../types/advisory/index.js';
|
|
@@ -10,9 +11,10 @@ import type { AgentContextLevel } from '../../types/agent/factory.js';
|
|
|
10
11
|
import type { WorkingMemoryProvider } from '../../types/agent/working-memory.js';
|
|
11
12
|
import type { AuthorizationGateConfig } from '../../types/authorization/index.js';
|
|
12
13
|
import type { InputGuardrailSpec, OutputGuardrailSpec } from '../../types/guardrail/index.js';
|
|
13
|
-
import { type
|
|
14
|
-
import type { RunId, SessionId, TenantId } from '../../types/ids/index.js';
|
|
14
|
+
import { type HITLResumeDecision, type ResumeHandler } from '../../types/hitl/index.js';
|
|
15
|
+
import type { CheckpointId, RunId, SessionId, TenantId } from '../../types/ids/index.js';
|
|
15
16
|
import type { InvocationState } from '../../types/invocation/index.js';
|
|
17
|
+
import type { MemoryStore } from '../../types/memory/index.js';
|
|
16
18
|
import { type Message } from '../../types/message/index.js';
|
|
17
19
|
import type { AgentPersona } from '../../types/persona/index.js';
|
|
18
20
|
import type { LLMProvider } from '../../types/provider/index.js';
|
|
@@ -24,6 +26,7 @@ import type { AgentRunConfig, BeforeStep, PrepareStepChain, Run, RunEvent, RunEv
|
|
|
24
26
|
import type { PromoteMemory } from '../../types/run/memory-promotion.js';
|
|
25
27
|
import type { RunState } from '../../types/run/state.js';
|
|
26
28
|
import type { RunStore } from '../../types/run/store.js';
|
|
29
|
+
import type { TokenBudgetStore } from '../../types/run/token-budget-store.js';
|
|
27
30
|
import type { SandboxProvider } from '../../types/sandbox/index.js';
|
|
28
31
|
import type { ProjectId, TopicId } from '../../types/session/ids.js';
|
|
29
32
|
import type { Skill } from '../../types/skills/index.js';
|
|
@@ -37,8 +40,12 @@ import type { BackgroundJobRegistry } from '../jobs/registry.js';
|
|
|
37
40
|
import { type ProjectInstructionContext } from './project-instructions.js';
|
|
38
41
|
import type { PromptCache } from './prompt-cache.js';
|
|
39
42
|
import { PendingAnswers, QuestionParkBinding } from './question-park.js';
|
|
40
|
-
import type
|
|
43
|
+
import { type SteeringChannel } from './steering.js';
|
|
41
44
|
export interface QueryParams {
|
|
45
|
+
/** One account shared with the task scheduler and descendant runs. */
|
|
46
|
+
budget?: TokenBudget;
|
|
47
|
+
/** Canonical tree ledger; defaults to disk beside the root run. */
|
|
48
|
+
tokenBudgetStore?: TokenBudgetStore;
|
|
42
49
|
/**
|
|
43
50
|
* Notice when the model issues the identical tool call repeatedly, and
|
|
44
51
|
* say so on the next `tool_result`. Defaults on.
|
|
@@ -152,6 +159,16 @@ export interface QueryParams {
|
|
|
152
159
|
* background execution is refused rather than silently bypassing the sandbox.
|
|
153
160
|
*/
|
|
154
161
|
backgroundJobs?: BackgroundJobRegistry;
|
|
162
|
+
/**
|
|
163
|
+
* Which owner the run's background jobs belong to. Absent, the run id:
|
|
164
|
+
* jobs are stopped when the run ends. A host that wants a job to
|
|
165
|
+
* outlive the turn that started it — a dev server started in one turn
|
|
166
|
+
* and read in the next — passes its session id here and calls
|
|
167
|
+
* `backgroundJobs.killOwner(sessionId)` when the session ends; the run
|
|
168
|
+
* then stops nothing at its end and still tells the model when a job
|
|
169
|
+
* finishes.
|
|
170
|
+
*/
|
|
171
|
+
backgroundJobOwner?: string;
|
|
155
172
|
/**
|
|
156
173
|
* What else goes in this run's prompt.
|
|
157
174
|
*
|
|
@@ -329,6 +346,12 @@ export interface QueryParams {
|
|
|
329
346
|
agentId: string;
|
|
330
347
|
agentName: string;
|
|
331
348
|
workingDirectory?: string;
|
|
349
|
+
/**
|
|
350
|
+
* Directories besides the working directory the file tools may reach,
|
|
351
|
+
* absolute; a sandboxed run binds each read-write. See
|
|
352
|
+
* `ToolContext.additionalDirectories`.
|
|
353
|
+
*/
|
|
354
|
+
additionalDirectories?: readonly string[];
|
|
332
355
|
pricing?: ModelPricing;
|
|
333
356
|
enableActivityTracking?: boolean;
|
|
334
357
|
messages: Message[];
|
|
@@ -484,6 +507,13 @@ export interface QueryParams {
|
|
|
484
507
|
* started. See `BaseAgentConfig.inboundMessages` for what it closes.
|
|
485
508
|
*/
|
|
486
509
|
inboundMessages?: () => import('../../types/message/index.js').Message[];
|
|
510
|
+
/**
|
|
511
|
+
* Wake a background-task hold when operator input is available, without draining it.
|
|
512
|
+
* Resolve immediately if input is already pending. Otherwise wait for its arrival;
|
|
513
|
+
* the supplied signal ends the wait and must release any listeners. Messages are
|
|
514
|
+
* still consumed only through `inboundMessages` at a provider-valid boundary.
|
|
515
|
+
*/
|
|
516
|
+
waitForInbound?: (signal: AbortSignal) => Promise<void>;
|
|
487
517
|
/**
|
|
488
518
|
* Live project policy for this run. Unlike `inboundMessages`, snapshot
|
|
489
519
|
* replacement is durable state and never implies another model turn.
|
|
@@ -540,6 +570,14 @@ export interface QueryParams {
|
|
|
540
570
|
taskRouter?: TaskRouterConfig;
|
|
541
571
|
advisory?: AdvisoryConfig;
|
|
542
572
|
compactionConfig?: CompactionConfig;
|
|
573
|
+
/**
|
|
574
|
+
* Where what the run learned is written when it ends: its decisions,
|
|
575
|
+
* discoveries and failures, as one entry tagged `learning`. Episodic
|
|
576
|
+
* memory (the working state) dies with the run; this is the bridge to
|
|
577
|
+
* the semantic store a later run searches. Absent means nothing is
|
|
578
|
+
* written. A store that fails is logged and never fails the run.
|
|
579
|
+
*/
|
|
580
|
+
consolidateInto?: MemoryStore;
|
|
543
581
|
/**
|
|
544
582
|
* Optional neutral working-memory seam. When set, the iteration loop
|
|
545
583
|
* re-renders the provider's string into a single pinned leading system
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/query/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/query/index.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAGjE,OAAO,EAAE,KAAK,gBAAgB,EAA0B,MAAM,yBAAyB,CAAA;AAQvF,OAAO,EACN,KAAK,mBAAmB,EAGxB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAE,KAAK,mBAAmB,EAAqB,MAAM,yBAAyB,CAAA;AAErF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAA;AAS1E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAU1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AAC1F,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AACrE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAA;AAChF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAA;AAEjF,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AAC7F,OAAO,EACN,KAAK,kBAAkB,EACvB,KAAK,aAAa,EAElB,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,YAAY,EAAU,KAAK,EAAE,SAA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KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,cAAc,CAAC,QAAQ,EAAE,GAAG,CAAC,CAmzD/E;AAuDD,KAAK,gBAAgB,GAAG,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,GAAG;IAC5D,aAAa,CAAC,EAAE,aAAa,CAAA;CAC7B,CAAA;AAmBD,wBAAsB,UAAU,CAC/B,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,GAAG;IAC5C,aAAa,CAAC,EAAE,aAAa,CAAA;CAC7B,EACD,QAAQ,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,GAAG,CAAC,CAMd;AAED,wEAAwE;AACxE,wBAAsB,iCAAiC,CACtD,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,mBAAmB,EAC1B,QAAQ,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,GAAG,CAAC,CAWd"}
|
|
@@ -2,21 +2,23 @@ import { join } from 'node:path';
|
|
|
2
2
|
import { AdvisorRegistry, AdvisoryContext, AdvisoryExecutor, TriggerEvaluator, assertBudgetEnforceable, } from '../../advisory/index.js';
|
|
3
3
|
import { drainQueuedMessages } from '../../agents/handle.js';
|
|
4
4
|
import { AuthorizationGate } from '../../authorization/gate.js';
|
|
5
|
+
import { consolidationEntry } from '../../compaction/consolidation.js';
|
|
5
6
|
import { repairToolMessageHistory, toolHistoryRepairChanged, } from '../../compaction/dangling.js';
|
|
6
7
|
import { extractFromUserMessage } from '../../compaction/extractor.js';
|
|
7
8
|
import { WorkingStateManager } from '../../compaction/manager.js';
|
|
8
9
|
import { serializeState as serializeWorkingState } from '../../compaction/serializer.js';
|
|
9
10
|
import { restoreWorkingState, snapshotWorkingState } from '../../compaction/wire.js';
|
|
10
|
-
import {
|
|
11
|
+
import { CompactionConfigSchema } from '../../config/runtime.js';
|
|
11
12
|
import { TOOL_OUTPUT_DIR_NAME } from '../../constants/tools/index.js';
|
|
12
13
|
import { EmergencySaveManager } from '../../manager/run/emergency.js';
|
|
13
14
|
import { resolveModelPricing } from '../../pricing/index.js';
|
|
15
|
+
import { PromptContributionRegistry } from '../../prompt/contributions.js';
|
|
14
16
|
import { resolveProviderCapabilities } from '../../provider/capabilities.js';
|
|
15
17
|
import { isCallerAbortError } from '../../provider/errors.js';
|
|
16
18
|
import { withProviderFallback, } from '../../provider/fallback.js';
|
|
17
19
|
import { resolveStreamIdleTimeoutMs, withStreamIdleTimeout } from '../../provider/idle-timeout.js';
|
|
18
20
|
import { withProviderRetry } from '../../provider/retry.js';
|
|
19
|
-
import {
|
|
21
|
+
import { withTokenBudget } from '../../provider/token-budget.js';
|
|
20
22
|
import { resolveAttachments } from '../../store/attachment/index.js';
|
|
21
23
|
import { GENAI, NAMZU, agentRunSpanName, parentContext, serializeSpan, } from '../../telemetry/attributes.js';
|
|
22
24
|
import { recordRunDuration } from '../../telemetry/metrics.js';
|
|
@@ -32,9 +34,8 @@ import { cancelCauseOf } from '../../types/run/cancel-cause.js';
|
|
|
32
34
|
import { resolveRunEventReplay } from '../../types/run/event-cursor.js';
|
|
33
35
|
import { memoryCandidateFor } from '../../types/run/memory-promotion.js';
|
|
34
36
|
import { toErrorMessage } from '../../utils/error.js';
|
|
35
|
-
import { generateRunId } from '../../utils/id.js';
|
|
37
|
+
import { generateCheckpointId, generateRunId } from '../../utils/id.js';
|
|
36
38
|
import { errorAttributes } from '../../utils/log/exception.js';
|
|
37
|
-
import { EVENT_NAME_ATTRIBUTE } from '../../utils/log/types.js';
|
|
38
39
|
import { AUTO_APPROVE_POLICY_NAME, createRunApprovalPolicy } from './approval-policy.js';
|
|
39
40
|
import { CheckpointManager } from './checkpoint.js';
|
|
40
41
|
import { RunContextFactory } from './context.js';
|
|
@@ -53,6 +54,8 @@ import { resolveMaxRequestRichContentBytes } from './request-rich-content.js';
|
|
|
53
54
|
import { ResultAssembler } from './result.js';
|
|
54
55
|
import { applyPendingResume, planCrashResume, planPendingResume, recoverCompletedCalls, unansweredToolCalls, } from './resume-pending.js';
|
|
55
56
|
import { acquireSandbox, resolveSandboxTeardownTimeoutMs, teardownSandbox, } from './sandbox-lifecycle.js';
|
|
57
|
+
import { SteeringBinding } from './steering.js';
|
|
58
|
+
import { resolveQueryBudget } from './token-budget.js';
|
|
56
59
|
import { ToolGrantSet } from './tool-grants.js';
|
|
57
60
|
import { createToolPause } from './tool-pause.js';
|
|
58
61
|
import { ToolingBootstrap } from './tooling.js';
|
|
@@ -278,6 +281,7 @@ export async function* query(params) {
|
|
|
278
281
|
// generating it twice would silently hand the log and the run two
|
|
279
282
|
// different ids.
|
|
280
283
|
const runId = params.runId ?? generateRunId();
|
|
284
|
+
const budget = await resolveQueryBudget(params, runId, selectedResumeState);
|
|
281
285
|
const log = RunContextFactory.buildLogger({
|
|
282
286
|
agentName: params.agentName,
|
|
283
287
|
runConfig,
|
|
@@ -288,40 +292,6 @@ export async function* query(params) {
|
|
|
288
292
|
projectId: params.projectId,
|
|
289
293
|
tenantId: params.tenantId,
|
|
290
294
|
});
|
|
291
|
-
// Boot-time filesystem migration (session-hierarchy.md §13.4.1). First
|
|
292
|
-
// call per process per root actually runs; subsequent calls short-circuit
|
|
293
|
-
// via the in-memory guard in `context.ts`. Kept here rather than inside
|
|
294
|
-
// the synchronous `RunContextFactory.build` so the factory signature stays
|
|
295
|
-
// sync for tests / non-async call sites.
|
|
296
|
-
//
|
|
297
|
-
// The migrator built here — not `ensureMigrated`'s own default — is what
|
|
298
|
-
// turns the migration facts `DefaultFilesystemMigrator` already computes
|
|
299
|
-
// into a `namzu.migration.completed` record instead of discarding them.
|
|
300
|
-
// `ensureMigrated`'s default parameter stays
|
|
301
|
-
// `NOOP_FILESYSTEM_MIGRATION_SINK` (see `context.ts`), so any other path
|
|
302
|
-
// that reaches `ensureMigrated` keeps today's silent behaviour.
|
|
303
|
-
const cwdForMigration = params.workingDirectory ?? process.cwd();
|
|
304
|
-
const migrationRoot = params.pathBuilder?.rootDir() ?? join(cwdForMigration, '.namzu');
|
|
305
|
-
const migrationResult = await RunContextFactory.ensureMigrated(migrationRoot, new DefaultFilesystemMigrator(loggingMigrationSink(log)));
|
|
306
|
-
// `loggingMigrationSink` only ever hears about `kind: 'migrated'` — the
|
|
307
|
-
// only outcome `DefaultFilesystemMigrator` ever hands its sink (see the
|
|
308
|
-
// module doc on `FilesystemMigrationSink`). The other two are logged
|
|
309
|
-
// here, straight off the resolved result, rather than by widening
|
|
310
|
-
// `FilesystemMigrationEvent` to carry them: a wider union would need a
|
|
311
|
-
// new arm in every exhaustive switch already written over it — a major —
|
|
312
|
-
// for two outcomes `migrationResult.kind` already fully describes.
|
|
313
|
-
if (migrationResult.kind !== 'migrated') {
|
|
314
|
-
log.debug('filesystem migration: nothing to do', {
|
|
315
|
-
[EVENT_NAME_ATTRIBUTE]: BOOT_EVENT_NAMES.MIGRATION_COMPLETED,
|
|
316
|
-
// `namzu.migration.*`, matching `loggingMigrationSink` — the OTHER
|
|
317
|
-
// emitter of this same event name. Two emitters of one event writing
|
|
318
|
-
// two namespaces for the same fact is precisely the collision the
|
|
319
|
-
// namespaced-key rule exists to stop, and a per-module derivation is
|
|
320
|
-
// how it would be reintroduced.
|
|
321
|
-
'namzu.migration.kind': migrationResult.kind,
|
|
322
|
-
'namzu.migration.marker_path': migrationResult.markerPath,
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
295
|
// Every model call in the run — the loop's turns, the forced-final
|
|
326
296
|
// summary, advisory and compaction side calls — goes through this one
|
|
327
297
|
// wrapped provider, so the retry policy cannot be bypassed by a code
|
|
@@ -353,9 +323,14 @@ export async function* query(params) {
|
|
|
353
323
|
idleTimeoutMs: streamIdleTimeoutMs,
|
|
354
324
|
log,
|
|
355
325
|
});
|
|
326
|
+
const metered = withTokenBudget(withIdleBound, budget);
|
|
356
327
|
return params.retry === false
|
|
357
|
-
?
|
|
358
|
-
: withProviderRetry(
|
|
328
|
+
? metered
|
|
329
|
+
: withProviderRetry(metered, {
|
|
330
|
+
config: params.retry,
|
|
331
|
+
log,
|
|
332
|
+
canRetry: () => budget.remaining > 0,
|
|
333
|
+
});
|
|
359
334
|
};
|
|
360
335
|
// Who is serving right now, for the run RECORD rather than for the request.
|
|
361
336
|
//
|
|
@@ -372,6 +347,7 @@ export async function* query(params) {
|
|
|
372
347
|
provider: withRecovery(member.provider),
|
|
373
348
|
})), {
|
|
374
349
|
log,
|
|
350
|
+
canFallback: () => budget.remaining > 0,
|
|
375
351
|
onSwap: (to) => {
|
|
376
352
|
serving.current = to;
|
|
377
353
|
// `ctx` is declared below and is initialized before anything can
|
|
@@ -505,6 +481,7 @@ export async function* query(params) {
|
|
|
505
481
|
});
|
|
506
482
|
}
|
|
507
483
|
const ctx = RunContextFactory.build({
|
|
484
|
+
budget,
|
|
508
485
|
...(topicState ? { topicPermissionMode: topicState.permissionMode } : {}),
|
|
509
486
|
...(params.permissionModeRef ? { permissionModeRef: params.permissionModeRef } : {}),
|
|
510
487
|
agentId: params.agentId,
|
|
@@ -553,13 +530,19 @@ export async function* query(params) {
|
|
|
553
530
|
},
|
|
554
531
|
emit: (event) => eventTranslator.emitEvent(event),
|
|
555
532
|
});
|
|
533
|
+
const planApprovalIds = new Map();
|
|
556
534
|
ctx.planManager.setApprovalHandler(async (request) => {
|
|
535
|
+
let checkpointId = planApprovalIds.get(request.planId);
|
|
536
|
+
if (!checkpointId) {
|
|
537
|
+
checkpointId = generateCheckpointId();
|
|
538
|
+
planApprovalIds.set(request.planId, checkpointId);
|
|
539
|
+
}
|
|
557
540
|
// `.current.handler`, never a captured `params.resumeHandler`. That
|
|
558
541
|
// capture is what made changing the policy mean ending the run.
|
|
559
542
|
const decision = await approvalPolicy.current.handler({
|
|
560
543
|
type: 'plan_approval',
|
|
561
544
|
runId: ctx.runId,
|
|
562
|
-
checkpointId
|
|
545
|
+
checkpointId,
|
|
563
546
|
plan: {
|
|
564
547
|
planId: request.planId,
|
|
565
548
|
title: request.title,
|
|
@@ -872,6 +855,9 @@ export async function* query(params) {
|
|
|
872
855
|
tools: params.tools,
|
|
873
856
|
runId: ctx.runId,
|
|
874
857
|
workingDirectory: ctx.cwd,
|
|
858
|
+
...(params.additionalDirectories?.length
|
|
859
|
+
? { additionalDirectories: params.additionalDirectories }
|
|
860
|
+
: {}),
|
|
875
861
|
permissionMode: () => ctx.permissionMode.current,
|
|
876
862
|
env: runConfig.env ?? {},
|
|
877
863
|
abortSignal: ctx.abortController.signal,
|
|
@@ -879,6 +865,7 @@ export async function* query(params) {
|
|
|
879
865
|
invocationState: params.invocationState,
|
|
880
866
|
pluginManager: params.pluginManager,
|
|
881
867
|
...(params.backgroundJobs ? { backgroundJobs: params.backgroundJobs } : {}),
|
|
868
|
+
...(params.backgroundJobOwner ? { backgroundJobOwner: params.backgroundJobOwner } : {}),
|
|
882
869
|
// The `skill` tool's registry. Threaded from the run rather than
|
|
883
870
|
// held by the tool, because a tool that reached for a module-level
|
|
884
871
|
// registry would answer about whatever the last run configured.
|
|
@@ -917,11 +904,48 @@ export async function* query(params) {
|
|
|
917
904
|
pendingAnswers,
|
|
918
905
|
}),
|
|
919
906
|
}, ctx.activityStore, eventTranslator.emitEvent, ctx.log);
|
|
907
|
+
// A background job's exit reaches the model as a notice on its next tool
|
|
908
|
+
// result, and the host as an event — without either polling. Subscribed
|
|
909
|
+
// for the owner the run's jobs are bound to, so a session-owned job that
|
|
910
|
+
// ends during this run is reported here too.
|
|
911
|
+
const jobOwner = params.backgroundJobOwner ?? ctx.runId;
|
|
912
|
+
const jobNotices = params.backgroundJobs ? new SteeringBinding() : undefined;
|
|
913
|
+
const unsubscribeJobExits = params.backgroundJobs?.onExit((job) => {
|
|
914
|
+
if (job.owner !== jobOwner)
|
|
915
|
+
return;
|
|
916
|
+
const outcome = job.status === 'killed'
|
|
917
|
+
? 'was stopped'
|
|
918
|
+
: `exited with code ${job.exitCode ?? 'unknown'}${job.signal ? ` (${job.signal})` : ''}`;
|
|
919
|
+
jobNotices?.steer(`Background job ${job.id} (${job.command}) ${outcome}. Read its output with the job tool if you need it.`);
|
|
920
|
+
void eventTranslator
|
|
921
|
+
.emitEvent({
|
|
922
|
+
type: 'background_job_exited',
|
|
923
|
+
runId: ctx.runId,
|
|
924
|
+
jobId: job.id,
|
|
925
|
+
command: job.command,
|
|
926
|
+
status: job.status === 'killed' ? 'killed' : 'exited',
|
|
927
|
+
...(job.exitCode !== undefined ? { exitCode: job.exitCode } : {}),
|
|
928
|
+
...(job.signal ? { signal: job.signal } : {}),
|
|
929
|
+
})
|
|
930
|
+
.catch(() => { });
|
|
931
|
+
});
|
|
920
932
|
let workingStateManager;
|
|
921
|
-
|
|
922
|
-
|
|
933
|
+
// Normalised once, defaults applied. A host that passes a partial
|
|
934
|
+
// object — a strategy and a window, nothing else — used to reach the
|
|
935
|
+
// phase with `triggerThreshold` undefined, and `usage < undefined` is
|
|
936
|
+
// false: the pass ran on every iteration and the salience strategy fell
|
|
937
|
+
// through to the stale-result clearing it exists to replace. The eval
|
|
938
|
+
// suite that passed exactly that object found it.
|
|
939
|
+
const compactionConfig = params.compactionConfig
|
|
940
|
+
? CompactionConfigSchema.parse(params.compactionConfig)
|
|
941
|
+
: undefined;
|
|
942
|
+
if (compactionConfig && compactionConfig.strategy !== 'disabled') {
|
|
943
|
+
workingStateManager = new WorkingStateManager(compactionConfig);
|
|
923
944
|
toolExecutor.setWorkingStateManager(workingStateManager);
|
|
924
945
|
}
|
|
946
|
+
// The run's own registry when the host passed none, so a hook's
|
|
947
|
+
// annotation has somewhere to land.
|
|
948
|
+
const promptContributions = params.promptContributions ?? new PromptContributionRegistry();
|
|
925
949
|
const promptBuilder = new PromptBuilder({
|
|
926
950
|
systemPrompt: params.systemPrompt,
|
|
927
951
|
persona: params.persona,
|
|
@@ -930,7 +954,7 @@ export async function* query(params) {
|
|
|
930
954
|
tools: params.tools,
|
|
931
955
|
allowedTools: effectiveAllowedTools,
|
|
932
956
|
runtimeContext: params.runtimeContext,
|
|
933
|
-
|
|
957
|
+
contributions: promptContributions,
|
|
934
958
|
});
|
|
935
959
|
const guard = new GuardCoordinator({
|
|
936
960
|
tokenBudget: runConfig.tokenBudget,
|
|
@@ -974,10 +998,10 @@ export async function* query(params) {
|
|
|
974
998
|
// explicitly chosen provider/cancellation policy.
|
|
975
999
|
const boundedAdvisors = params.advisory.advisors.map((advisor) => ({
|
|
976
1000
|
...advisor,
|
|
977
|
-
provider: withStreamIdleTimeout(advisor.provider, {
|
|
1001
|
+
provider: withTokenBudget(withStreamIdleTimeout(advisor.provider, {
|
|
978
1002
|
idleTimeoutMs: streamIdleTimeoutMs,
|
|
979
1003
|
log: ctx.log,
|
|
980
|
-
}),
|
|
1004
|
+
}), budget),
|
|
981
1005
|
}));
|
|
982
1006
|
const advisorRegistry = new AdvisorRegistry(boundedAdvisors, params.advisory.defaultAdvisorId);
|
|
983
1007
|
// A budget the runtime cannot measure is refused here rather than
|
|
@@ -1050,8 +1074,9 @@ export async function* query(params) {
|
|
|
1050
1074
|
// question rather than the next run.
|
|
1051
1075
|
resumeHandler: (request) => approvalPolicy.current.handler(request),
|
|
1052
1076
|
takeApprovalPolicyChange: () => approvalPolicy.takeUnannouncedChange(),
|
|
1053
|
-
|
|
1077
|
+
promptContributions,
|
|
1054
1078
|
...(params.steering ? { steering: params.steering } : {}),
|
|
1079
|
+
...(jobNotices ? { jobNotices } : {}),
|
|
1055
1080
|
checkpointMgr,
|
|
1056
1081
|
planManager: ctx.planManager,
|
|
1057
1082
|
taskGateway: taskScheduler,
|
|
@@ -1064,8 +1089,9 @@ export async function* query(params) {
|
|
|
1064
1089
|
// run is a claim about work nobody repeated, and a module-level map
|
|
1065
1090
|
// would leak exactly that way.
|
|
1066
1091
|
...(params.repeatCallAdvisory === false ? {} : { repeatCalls: new RepeatCallTracker() }),
|
|
1067
|
-
compactionConfig
|
|
1092
|
+
compactionConfig,
|
|
1068
1093
|
...(params.inboundMessages ? { inboundMessages: params.inboundMessages } : {}),
|
|
1094
|
+
...(params.waitForInbound ? { waitForInbound: params.waitForInbound } : {}),
|
|
1069
1095
|
...(params.projectInstructionContext
|
|
1070
1096
|
? { projectInstructionContext: params.projectInstructionContext }
|
|
1071
1097
|
: {}),
|
|
@@ -1210,6 +1236,27 @@ export async function* query(params) {
|
|
|
1210
1236
|
'namzu.runtime.permission_mode': ctx.permissionMode.current,
|
|
1211
1237
|
'namzu.runtime.resume_from_checkpoint': params.resumeFromCheckpoint ?? null,
|
|
1212
1238
|
});
|
|
1239
|
+
// The operator's prompt, before the model sees it. A hook may
|
|
1240
|
+
// refuse it — the run ends here, before a prompt is built — or add
|
|
1241
|
+
// to what the model is told; the addition rides the prompt as a
|
|
1242
|
+
// dynamic contribution so every iteration of the run carries it.
|
|
1243
|
+
if (params.pluginManager) {
|
|
1244
|
+
const hookResults = await params.pluginManager.executeHooks('user_prompt_submit', {
|
|
1245
|
+
runId: ctx.runId,
|
|
1246
|
+
sessionId: params.sessionId,
|
|
1247
|
+
prompt: lastUserPrompt(initialMessages),
|
|
1248
|
+
signal: ctx.abortController.signal,
|
|
1249
|
+
}, eventTranslator.emitEvent);
|
|
1250
|
+
const annotations = applyLifecycleHookResults('user_prompt_submit', hookResults);
|
|
1251
|
+
if (annotations.length > 0) {
|
|
1252
|
+
promptContributions.replace({
|
|
1253
|
+
id: 'hooks:user_prompt_submit',
|
|
1254
|
+
placement: 'dynamic',
|
|
1255
|
+
render: () => `Context from the operator's hooks:\n\n${annotations.join('\n\n')}`,
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
yield* eventTranslator.drainPending();
|
|
1259
|
+
}
|
|
1213
1260
|
const contextLevel = params.contextLevel ?? 'full';
|
|
1214
1261
|
const cacheInput = {
|
|
1215
1262
|
systemPrompt: params.systemPrompt,
|
|
@@ -1219,7 +1266,7 @@ export async function* query(params) {
|
|
|
1219
1266
|
tools: params.tools,
|
|
1220
1267
|
allowedTools: effectiveAllowedTools,
|
|
1221
1268
|
runtimeContext: params.runtimeContext,
|
|
1222
|
-
|
|
1269
|
+
contributions: promptContributions,
|
|
1223
1270
|
};
|
|
1224
1271
|
const segments = promptCache
|
|
1225
1272
|
? promptCache.getSystemPromptSegmented(cacheInput, contextLevel, params.workingDirectory)
|
|
@@ -1263,8 +1310,8 @@ export async function* query(params) {
|
|
|
1263
1310
|
// would drop it and replace it with a summary covering only
|
|
1264
1311
|
// what happened after the resume, silently losing the run's
|
|
1265
1312
|
// first hour.
|
|
1266
|
-
if (workingStateManager && checkpoint.workingState &&
|
|
1267
|
-
const revived = restoreWorkingState(checkpoint.workingState,
|
|
1313
|
+
if (workingStateManager && checkpoint.workingState && compactionConfig) {
|
|
1314
|
+
const revived = restoreWorkingState(checkpoint.workingState, compactionConfig);
|
|
1268
1315
|
workingStateManager.replaceState(revived.getState());
|
|
1269
1316
|
ctx.log.info('Restored compaction working state from checkpoint', {
|
|
1270
1317
|
[NAMZU.RUN_ID]: ctx.runMgr.id,
|
|
@@ -1521,6 +1568,9 @@ export async function* query(params) {
|
|
|
1521
1568
|
provider: params.sandboxProvider,
|
|
1522
1569
|
config: {
|
|
1523
1570
|
...(rootAtCwd ? { workingDirectory: ctx.cwd } : {}),
|
|
1571
|
+
...(rootAtCwd && params.additionalDirectories?.length
|
|
1572
|
+
? { additionalDirectories: params.additionalDirectories }
|
|
1573
|
+
: {}),
|
|
1524
1574
|
timeoutMs: runConfig.sandbox?.timeoutMs,
|
|
1525
1575
|
memoryLimitMb: runConfig.sandbox?.memoryLimitMb,
|
|
1526
1576
|
maxProcesses: runConfig.sandbox?.maxProcesses,
|
|
@@ -1666,6 +1716,18 @@ export async function* query(params) {
|
|
|
1666
1716
|
const hookResults = await params.pluginManager.executeHooks('run_end', { runId: ctx.runId, signal: ctx.abortController.signal }, eventTranslator.emitEvent);
|
|
1667
1717
|
applyLifecycleHookResults('run_end', hookResults);
|
|
1668
1718
|
yield* eventTranslator.drainPending();
|
|
1719
|
+
// A delegated run says so once more, by name, so a hook that
|
|
1720
|
+
// only cares when a subagent finishes need not read parent ids
|
|
1721
|
+
// off every run_end.
|
|
1722
|
+
if (params.parentRunId !== undefined) {
|
|
1723
|
+
const stopResults = await params.pluginManager.executeHooks('subagent_stop', {
|
|
1724
|
+
runId: ctx.runId,
|
|
1725
|
+
parentRunId: params.parentRunId,
|
|
1726
|
+
signal: ctx.abortController.signal,
|
|
1727
|
+
}, eventTranslator.emitEvent);
|
|
1728
|
+
applyLifecycleHookResults('subagent_stop', stopResults);
|
|
1729
|
+
yield* eventTranslator.drainPending();
|
|
1730
|
+
}
|
|
1669
1731
|
}
|
|
1670
1732
|
// Hand the step record to the run before it settles, so the
|
|
1671
1733
|
// returned `Run` carries it.
|
|
@@ -1717,6 +1779,33 @@ export async function* query(params) {
|
|
|
1717
1779
|
ctx.runMgr.setResult(outputVerdict.rewritten);
|
|
1718
1780
|
}
|
|
1719
1781
|
}
|
|
1782
|
+
if (params.consolidateInto && workingStateManager) {
|
|
1783
|
+
const entry = consolidationEntry(workingStateManager.getState(), {
|
|
1784
|
+
runId: ctx.runId,
|
|
1785
|
+
at: Date.now(),
|
|
1786
|
+
});
|
|
1787
|
+
if (entry) {
|
|
1788
|
+
try {
|
|
1789
|
+
const { entry: saved } = await params.consolidateInto.create(entry);
|
|
1790
|
+
await eventTranslator.emitEvent({
|
|
1791
|
+
type: 'memory_consolidated',
|
|
1792
|
+
runId: ctx.runId,
|
|
1793
|
+
memoryId: saved.id,
|
|
1794
|
+
title: entry.title,
|
|
1795
|
+
decisions: workingStateManager.getState().decisions.length,
|
|
1796
|
+
discoveries: workingStateManager.getState().discoveries.length,
|
|
1797
|
+
failures: workingStateManager.getState().failures.length,
|
|
1798
|
+
});
|
|
1799
|
+
yield* eventTranslator.drainPending();
|
|
1800
|
+
}
|
|
1801
|
+
catch (error) {
|
|
1802
|
+
ctx.log.warn('consolidation into the memory store failed', {
|
|
1803
|
+
[NAMZU.RUN_ID]: ctx.runId,
|
|
1804
|
+
'namzu.memory.error': toErrorMessage(error),
|
|
1805
|
+
});
|
|
1806
|
+
}
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1720
1809
|
yield* resultAssembler.completeRun(rootSpan);
|
|
1721
1810
|
}
|
|
1722
1811
|
catch (err) {
|
|
@@ -1739,7 +1828,10 @@ export async function* query(params) {
|
|
|
1739
1828
|
//
|
|
1740
1829
|
// Awaited, and its failure swallowed. A job that would not die is
|
|
1741
1830
|
// worth a log line, and is not worth retracting a run's answer.
|
|
1742
|
-
|
|
1831
|
+
unsubscribeJobExits?.();
|
|
1832
|
+
// Only jobs bound to this run. Jobs a host bound to its session are
|
|
1833
|
+
// the host's to stop, when the session ends.
|
|
1834
|
+
if (params.backgroundJobs && (params.backgroundJobOwner ?? ctx.runId) === ctx.runId) {
|
|
1743
1835
|
try {
|
|
1744
1836
|
const stopped = await params.backgroundJobs.killOwner(ctx.runId);
|
|
1745
1837
|
if (stopped.length > 0) {
|
|
@@ -1819,6 +1911,15 @@ export async function* query(params) {
|
|
|
1819
1911
|
* either way — a stale cursor belongs to the client, and must not be able to
|
|
1820
1912
|
* stop the work.
|
|
1821
1913
|
*/
|
|
1914
|
+
/** The text of the newest user turn, which is what a prompt hook is asked about. */
|
|
1915
|
+
function lastUserPrompt(messages) {
|
|
1916
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
1917
|
+
const m = messages[i];
|
|
1918
|
+
if (m?.role === 'user' && typeof m.content === 'string')
|
|
1919
|
+
return m.content;
|
|
1920
|
+
}
|
|
1921
|
+
return '';
|
|
1922
|
+
}
|
|
1822
1923
|
async function* catchUpFromCursor(runMgr, cursor, onEventReplay, generation, onReplayObserverError) {
|
|
1823
1924
|
const missed = await runMgr.getRunStore().readEvents({ sinceSeq: cursor.sinceSeq });
|
|
1824
1925
|
const replay = resolveRunEventReplay(cursor, {
|