@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
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The working set: which messages stay whole for the next call.
|
|
3
|
+
*
|
|
4
|
+
* Given every message's salience, choose the cheapest actions that bring
|
|
5
|
+
* the estimated context under a target, lowest salience first, then the
|
|
6
|
+
* larger result among equally salient candidates:
|
|
7
|
+
*
|
|
8
|
+
* clear replace a tool result with the same excerpt the stale pass
|
|
9
|
+
* uses, retaining a saved-artifact pointer when one exists;
|
|
10
|
+
* stub cut an assistant narration to its first sentence — the
|
|
11
|
+
* decision survives, the paragraph around it does not.
|
|
12
|
+
*
|
|
13
|
+
* Nothing protected is touched, and a message is never removed: the
|
|
14
|
+
* shape of the conversation — every `tool_use` beside its `tool_result`,
|
|
15
|
+
* every turn boundary — is exactly what it was, which is what makes this
|
|
16
|
+
* safe to run on every iteration. Folding a span into the structured
|
|
17
|
+
* state and summarising stay with the existing plan, which runs after
|
|
18
|
+
* this when the target could not be reached. Pure, like the rest of the
|
|
19
|
+
* compaction arithmetic.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { CHARS_PER_TOKEN } from '../../constants/limits.js'
|
|
23
|
+
import type { AssistantMessage, Message, ToolMessage } from '../../types/message/index.js'
|
|
24
|
+
import { estimateMessageTokens } from '../token-estimate.js'
|
|
25
|
+
import { clearToolResult, isClearedToolResult } from '../tool-result-editing.js'
|
|
26
|
+
import type { ScoredMessage } from './score.js'
|
|
27
|
+
|
|
28
|
+
export interface WorkingSetAction {
|
|
29
|
+
readonly kind: 'clear' | 'stub'
|
|
30
|
+
readonly index: number
|
|
31
|
+
readonly charsReclaimed: number
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface WorkingSetPlan {
|
|
35
|
+
readonly messages: Message[]
|
|
36
|
+
readonly actions: readonly WorkingSetAction[]
|
|
37
|
+
readonly clearedCount: number
|
|
38
|
+
readonly stubbedCount: number
|
|
39
|
+
readonly charsReclaimed: number
|
|
40
|
+
readonly reclaimedTokens: number
|
|
41
|
+
/** Whether the actions brought the estimate under the target. */
|
|
42
|
+
readonly reachedTarget: boolean
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface WorkingSetOptions {
|
|
46
|
+
readonly estimatedTokens: number
|
|
47
|
+
readonly targetTokens: number
|
|
48
|
+
/** Tool results smaller than this are not worth a placeholder. */
|
|
49
|
+
readonly minToolResultChars?: number
|
|
50
|
+
/** Assistant narrations shorter than this keep their whole text. */
|
|
51
|
+
readonly minNarrationChars?: number
|
|
52
|
+
/** Tools whose results are never cleared. */
|
|
53
|
+
readonly preserveTools?: readonly string[]
|
|
54
|
+
/**
|
|
55
|
+
* A message the goal names or a later turn cited is not evicted to
|
|
56
|
+
* reach the target while it scores above this fraction of the most
|
|
57
|
+
* salient evictable message. A strict target evicted the one result
|
|
58
|
+
* the goal named to shave the last few tokens — an eval watched it
|
|
59
|
+
* happen — and a pass that stops short and says so is the better
|
|
60
|
+
* answer: the trigger threshold still guards the hard limit.
|
|
61
|
+
*/
|
|
62
|
+
readonly keepAboveFraction?: number
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const STUB_MARK = '… (elided'
|
|
66
|
+
|
|
67
|
+
function firstSentence(text: string): string {
|
|
68
|
+
const match = /^[\s\S]*?[.!?](?=\s|$)/u.exec(text.trim())
|
|
69
|
+
return (match ? match[0] : (text.trim().split('\n')[0] ?? '')).slice(0, 240)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function isStubbedNarration(content: unknown): boolean {
|
|
73
|
+
return typeof content === 'string' && content.includes(STUB_MARK)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function planWorkingSet(
|
|
77
|
+
messages: readonly Message[],
|
|
78
|
+
scored: readonly ScoredMessage[],
|
|
79
|
+
options: WorkingSetOptions,
|
|
80
|
+
): WorkingSetPlan {
|
|
81
|
+
const minTool = options.minToolResultChars ?? 1_000
|
|
82
|
+
const minNarration = options.minNarrationChars ?? 240
|
|
83
|
+
const preserve = new Set(options.preserveTools ?? [])
|
|
84
|
+
const toolNameByCallId = new Map<string, string>()
|
|
85
|
+
for (const m of messages) {
|
|
86
|
+
if (m.role !== 'assistant') continue
|
|
87
|
+
for (const call of (m as AssistantMessage).toolCalls ?? []) {
|
|
88
|
+
toolNameByCallId.set(call.id, call.function.name)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Ordered by salience, not salience per token. Per token was the plan's
|
|
93
|
+
// first answer and it evicts the wrong thing: a large result the goal
|
|
94
|
+
// names loses to a small one it does not, because size divides the
|
|
95
|
+
// score. Among equals the larger goes first, which is where the tokens
|
|
96
|
+
// are.
|
|
97
|
+
type Candidate = {
|
|
98
|
+
readonly index: number
|
|
99
|
+
readonly kind: 'clear' | 'stub'
|
|
100
|
+
readonly salience: number
|
|
101
|
+
readonly tokens: number
|
|
102
|
+
/** Named by the goal or cited by a later turn: what the floor protects. */
|
|
103
|
+
readonly goalBound: boolean
|
|
104
|
+
}
|
|
105
|
+
const candidates: Candidate[] = []
|
|
106
|
+
for (const s of scored) {
|
|
107
|
+
if (s.protected !== null || s.tokens === 0) continue
|
|
108
|
+
const m = messages[s.index] as Message
|
|
109
|
+
if (m.role === 'tool') {
|
|
110
|
+
const tool = m as ToolMessage
|
|
111
|
+
if (tool.isError || isClearedToolResult(tool.content)) continue
|
|
112
|
+
if (preserve.has(toolNameByCallId.get(tool.toolCallId) ?? '')) continue
|
|
113
|
+
if (s.tokens * CHARS_PER_TOKEN < minTool) continue
|
|
114
|
+
candidates.push({
|
|
115
|
+
index: s.index,
|
|
116
|
+
kind: 'clear',
|
|
117
|
+
salience: s.salience,
|
|
118
|
+
tokens: s.tokens,
|
|
119
|
+
goalBound: s.relevance >= 0.5 || s.utility >= 1,
|
|
120
|
+
})
|
|
121
|
+
} else if (m.role === 'assistant' && !Array.isArray((m as AssistantMessage).toolCalls)) {
|
|
122
|
+
const text = typeof m.content === 'string' ? m.content : ''
|
|
123
|
+
if (text.length < minNarration || isStubbedNarration(text)) continue
|
|
124
|
+
candidates.push({
|
|
125
|
+
index: s.index,
|
|
126
|
+
kind: 'stub',
|
|
127
|
+
salience: s.salience,
|
|
128
|
+
tokens: s.tokens,
|
|
129
|
+
goalBound: s.relevance >= 0.5 || s.utility >= 1,
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
candidates.sort((a, b) => a.salience - b.salience || b.tokens - a.tokens || a.index - b.index)
|
|
134
|
+
const maxSalience = candidates.reduce((m, c) => Math.max(m, c.salience), Number.NEGATIVE_INFINITY)
|
|
135
|
+
const floor = maxSalience * (options.keepAboveFraction ?? 0.5)
|
|
136
|
+
|
|
137
|
+
const next = [...messages]
|
|
138
|
+
const actions: WorkingSetAction[] = []
|
|
139
|
+
let charsReclaimed = 0
|
|
140
|
+
let reclaimedTokens = 0
|
|
141
|
+
let clearedCount = 0
|
|
142
|
+
let stubbedCount = 0
|
|
143
|
+
const excess = () => options.estimatedTokens - reclaimedTokens - options.targetTokens
|
|
144
|
+
for (const candidate of candidates) {
|
|
145
|
+
if (excess() <= 0) break
|
|
146
|
+
// The floor guards what the goal names or a later turn used, not
|
|
147
|
+
// every above-average message: a run of look-alike dumps must still
|
|
148
|
+
// be evicted from the bottom when the target asks for it.
|
|
149
|
+
if (candidate.goalBound && candidate.salience > floor && candidate.salience > 0) continue
|
|
150
|
+
const m = next[candidate.index] as Message
|
|
151
|
+
if (candidate.kind === 'clear') {
|
|
152
|
+
const tool = m as ToolMessage
|
|
153
|
+
const cleared = clearToolResult(tool, toolNameByCallId.get(tool.toolCallId) ?? 'unknown')
|
|
154
|
+
const tokenSaving = estimateMessageTokens(tool) - estimateMessageTokens(cleared.message)
|
|
155
|
+
if (tokenSaving <= 0) continue
|
|
156
|
+
next[candidate.index] = cleared.message
|
|
157
|
+
charsReclaimed += cleared.charsReclaimed
|
|
158
|
+
reclaimedTokens += tokenSaving
|
|
159
|
+
clearedCount += 1
|
|
160
|
+
actions.push({
|
|
161
|
+
kind: 'clear',
|
|
162
|
+
index: candidate.index,
|
|
163
|
+
charsReclaimed: cleared.charsReclaimed,
|
|
164
|
+
})
|
|
165
|
+
} else {
|
|
166
|
+
const text = m.content as string
|
|
167
|
+
const stub = `${firstSentence(text)} ${STUB_MARK}; ${(text.length - firstSentence(text).length).toLocaleString('en-US')} characters of narration)`
|
|
168
|
+
const reclaimed = text.length - stub.length
|
|
169
|
+
if (reclaimed <= 0) continue
|
|
170
|
+
const stubbed = { ...(m as AssistantMessage), content: stub }
|
|
171
|
+
next[candidate.index] = stubbed
|
|
172
|
+
charsReclaimed += reclaimed
|
|
173
|
+
reclaimedTokens += estimateMessageTokens(m) - estimateMessageTokens(stubbed)
|
|
174
|
+
stubbedCount += 1
|
|
175
|
+
actions.push({ kind: 'stub', index: candidate.index, charsReclaimed: reclaimed })
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
messages: next,
|
|
180
|
+
actions,
|
|
181
|
+
clearedCount,
|
|
182
|
+
stubbedCount,
|
|
183
|
+
charsReclaimed,
|
|
184
|
+
reclaimedTokens,
|
|
185
|
+
reachedTarget: excess() <= 0,
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -58,6 +58,20 @@ function renderToolResults(results: { tool: string; summary: string }[], evicted
|
|
|
58
58
|
return lines.join('\n')
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/** The pinned-facts section alone, or null when nothing is pinned. */
|
|
62
|
+
export function renderPins(state: WorkingState): string | null {
|
|
63
|
+
const pins = state.pins ? [...state.pins.values()] : []
|
|
64
|
+
if (pins.length === 0) return null
|
|
65
|
+
const lines = pins.map((p) => `- **${p.key}**: ${p.text} _(${p.source})_`)
|
|
66
|
+
const dropped = state.evicted.pins ?? 0
|
|
67
|
+
if (dropped > 0) {
|
|
68
|
+
lines.push(
|
|
69
|
+
`- _(${dropped} older ${dropped === 1 ? 'pin' : 'pins'} dropped to stay within the pin budget)_`,
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
return `${SECTION_HEADERS.pins}\n\n${lines.join('\n')}`
|
|
73
|
+
}
|
|
74
|
+
|
|
61
75
|
export function serializeState(state: WorkingState): string {
|
|
62
76
|
const sections: string[] = []
|
|
63
77
|
|
|
@@ -74,6 +88,8 @@ export function serializeState(state: WorkingState): string {
|
|
|
74
88
|
if (state.plan.length > 0) {
|
|
75
89
|
sections.push(`${SECTION_HEADERS.plan}\n\n${renderPlan(state.plan)}`)
|
|
76
90
|
}
|
|
91
|
+
const pinned = renderPins(state)
|
|
92
|
+
if (pinned) sections.push(pinned)
|
|
77
93
|
|
|
78
94
|
if (state.environment.length > 0) {
|
|
79
95
|
sections.push(
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { CHARS_PER_TOKEN } from '../constants/limits.js'
|
|
2
|
+
import type { Message, MessageAttachment, ToolResultBlock } from '../types/message/index.js'
|
|
3
|
+
|
|
4
|
+
// Heuristic allowances, not provider billing formulas or upper bounds. Encoded
|
|
5
|
+
// byte length depends on compression, not the number of visual tokens. The
|
|
6
|
+
// provider's measured prompt usage replaces these guesses after the next call.
|
|
7
|
+
const IMAGE_TOKENS = 1_024
|
|
8
|
+
const DOCUMENT_TOKENS = 4_096
|
|
9
|
+
const OMITTED_IMAGE_TOKENS = 64
|
|
10
|
+
|
|
11
|
+
function richTokens(block: Exclude<ToolResultBlock, { type: 'text' }> | MessageAttachment): number {
|
|
12
|
+
if (block.type === 'stored') return block.kind === 'image' ? IMAGE_TOKENS : DOCUMENT_TOKENS
|
|
13
|
+
if (block.type === 'document') return DOCUMENT_TOKENS
|
|
14
|
+
return block.modelOmission ? OMITTED_IMAGE_TOKENS : IMAGE_TOKENS
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Provider-neutral prompt estimate shared by triggers, retention and eviction.
|
|
19
|
+
*
|
|
20
|
+
* Text and tool inputs use the existing characters-per-token approximation.
|
|
21
|
+
* Images and documents have an explicit allowance independent of compression
|
|
22
|
+
* and of whether the bytes are inline or stored externally. Without dimensions,
|
|
23
|
+
* page counts and a provider tokenizer their exact cost is unknown. In
|
|
24
|
+
* particular, serialized base64 is never treated as model-visible prose.
|
|
25
|
+
*/
|
|
26
|
+
export function estimateMessageTokens(message: Message): number {
|
|
27
|
+
let chars = 0
|
|
28
|
+
let rich = 0
|
|
29
|
+
if (typeof message.content === 'string') chars += message.content.length
|
|
30
|
+
else if (message.content) {
|
|
31
|
+
for (const block of message.content) {
|
|
32
|
+
if (block.type === 'text') chars += block.text.length
|
|
33
|
+
else {
|
|
34
|
+
rich += richTokens(block)
|
|
35
|
+
if (block.type === 'document') chars += block.name?.length ?? 0
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (message.role === 'assistant') {
|
|
40
|
+
for (const call of message.toolCalls ?? []) {
|
|
41
|
+
chars += call.function.name.length + call.function.arguments.length
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (message.role === 'user') {
|
|
45
|
+
for (const attachment of message.attachments ?? []) {
|
|
46
|
+
rich += richTokens(attachment)
|
|
47
|
+
if (attachment.type === 'document' || attachment.type === 'stored') {
|
|
48
|
+
chars += attachment.name?.length ?? 0
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return Math.ceil(chars / CHARS_PER_TOKEN) + rich
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function estimateMessagesTokens(messages: readonly Message[]): number {
|
|
56
|
+
return messages.reduce((total, message) => total + estimateMessageTokens(message), 0)
|
|
57
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { CHARS_PER_TOKEN } from '../constants/limits.js'
|
|
1
2
|
import { SPILL_MARKER } from '../runtime/query/tool-output-budget.js'
|
|
2
3
|
import { toolResultToText } from '../types/message/content.js'
|
|
3
4
|
import type { Message, ToolMessage, ToolResultBlock } from '../types/message/index.js'
|
|
4
5
|
import { findRetainedIndices } from './retention.js'
|
|
6
|
+
import { estimateMessageTokens } from './token-estimate.js'
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* Clear stale tool OUTPUT in place, without touching the conversation's
|
|
@@ -91,7 +93,9 @@ function clearedPlaceholder(
|
|
|
91
93
|
'Read a window of it with `read` (offset/limit) or search it with `grep`.',
|
|
92
94
|
)
|
|
93
95
|
} else {
|
|
94
|
-
parts.push(
|
|
96
|
+
parts.push(
|
|
97
|
+
'Full result unavailable here. Recover from a saved artifact or a read-only observation; do not repeat a state-changing action to recover its output.',
|
|
98
|
+
)
|
|
95
99
|
}
|
|
96
100
|
|
|
97
101
|
if (text.length > KEEP_HEAD_CHARS + KEEP_TAIL_CHARS) {
|
|
@@ -116,10 +120,23 @@ function clearedPlaceholder(
|
|
|
116
120
|
export interface ToolResultEditOutcome {
|
|
117
121
|
readonly messages: Message[]
|
|
118
122
|
readonly clearedCount: number
|
|
119
|
-
/**
|
|
123
|
+
/** Payload characters removed, including encoded data; not a token estimate. */
|
|
120
124
|
readonly charsReclaimed: number
|
|
121
125
|
}
|
|
122
126
|
|
|
127
|
+
/**
|
|
128
|
+
* One result cleared on its own, for a caller that chose it by some
|
|
129
|
+
* other rule than staleness. The same placeholder, the same accounting.
|
|
130
|
+
*/
|
|
131
|
+
export function clearToolResult(
|
|
132
|
+
tool: ToolMessage,
|
|
133
|
+
toolName: string,
|
|
134
|
+
): { readonly message: ToolMessage; readonly charsReclaimed: number } {
|
|
135
|
+
const size = measureContent(tool.content)
|
|
136
|
+
const content = clearedPlaceholder(tool.content, toolName, size)
|
|
137
|
+
return { message: { ...tool, content }, charsReclaimed: Math.max(0, size - content.length) }
|
|
138
|
+
}
|
|
139
|
+
|
|
123
140
|
export function isClearedToolResult(content: unknown): boolean {
|
|
124
141
|
return typeof content === 'string' && content.startsWith(CLEARED_PREFIX)
|
|
125
142
|
}
|
|
@@ -183,39 +200,24 @@ export function clearStaleToolResults(
|
|
|
183
200
|
if (preserve.has(toolName)) return msg
|
|
184
201
|
|
|
185
202
|
const size = measureContent(tool.content)
|
|
186
|
-
if (
|
|
203
|
+
if (estimateMessageTokens(tool) * CHARS_PER_TOKEN < minChars) return msg
|
|
187
204
|
|
|
205
|
+
const content = clearedPlaceholder(tool.content, toolName, size)
|
|
206
|
+
if (estimateMessageTokens({ ...tool, content }) >= estimateMessageTokens(tool)) return msg
|
|
188
207
|
clearedCount++
|
|
189
|
-
charsReclaimed += size -
|
|
208
|
+
charsReclaimed += size - content.length
|
|
190
209
|
return {
|
|
191
210
|
...tool,
|
|
192
|
-
content
|
|
211
|
+
content,
|
|
193
212
|
} satisfies ToolMessage
|
|
194
213
|
})
|
|
195
214
|
|
|
196
|
-
|
|
197
|
-
// caller uses to decide "was that enough?" is the real saving and not
|
|
198
|
-
// an overstatement.
|
|
199
|
-
if (clearedCount > 0) {
|
|
200
|
-
let placeholderChars = 0
|
|
201
|
-
for (const msg of edited) {
|
|
202
|
-
if (msg.role === 'tool' && isClearedToolResult(msg.content)) {
|
|
203
|
-
placeholderChars += measureContent(msg.content)
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
charsReclaimed = Math.max(0, charsReclaimed - placeholderChars)
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return { messages: edited, clearedCount, charsReclaimed }
|
|
215
|
+
return { messages: edited, clearedCount, charsReclaimed: Math.max(0, charsReclaimed) }
|
|
210
216
|
}
|
|
211
217
|
|
|
212
218
|
/**
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
* An image block is measured by its base64 payload, which is the whole
|
|
216
|
-
* point: a screenshot is the single largest thing a tool result can carry,
|
|
217
|
-
* and it is exactly the kind of output an agent reads once and never
|
|
218
|
-
* needs again.
|
|
219
|
+
* Payload character count for storage telemetry. Encoded image length is
|
|
220
|
+
* independent of visual token cost; context decisions use the shared estimate.
|
|
219
221
|
*/
|
|
220
222
|
function measureContent(content: ToolMessage['content']): number {
|
|
221
223
|
if (typeof content === 'string') return content.length
|
|
@@ -223,7 +225,7 @@ function measureContent(content: ToolMessage['content']): number {
|
|
|
223
225
|
let total = 0
|
|
224
226
|
for (const block of content as readonly ToolResultBlock[]) {
|
|
225
227
|
if (block.type === 'text') total += block.text.length
|
|
226
|
-
else if (block.type === 'image') total += block.data.length
|
|
228
|
+
else if (block.type === 'image' || block.type === 'document') total += block.data.length
|
|
227
229
|
}
|
|
228
230
|
return total
|
|
229
231
|
}
|
package/src/compaction/types.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
export interface WorkingState {
|
|
2
2
|
task: string
|
|
3
3
|
plan: PlanSlot[]
|
|
4
|
+
/**
|
|
5
|
+
* Facts pinned by tools, by key. A tool that knows something the model
|
|
6
|
+
* must not lose — what its controls do, where the piece is, what has
|
|
7
|
+
* already failed — pins it with a key, and a later pin under the same
|
|
8
|
+
* key replaces it. Pins live in the working-memory slot, so they are in
|
|
9
|
+
* front of the model every iteration and survive compaction; the
|
|
10
|
+
* rule-based extractor below only guesses, a pin is stated.
|
|
11
|
+
*/
|
|
12
|
+
pins: Map<string, PinSlot>
|
|
4
13
|
files: Map<string, FileSlot>
|
|
5
14
|
decisions: string[]
|
|
6
15
|
failures: string[]
|
|
@@ -21,6 +30,20 @@ export interface WorkingState {
|
|
|
21
30
|
evicted: Record<string, number>
|
|
22
31
|
}
|
|
23
32
|
|
|
33
|
+
export interface PinSlot {
|
|
34
|
+
key: string
|
|
35
|
+
text: string
|
|
36
|
+
/** The tool that pinned it. */
|
|
37
|
+
source: string
|
|
38
|
+
updatedAt: number
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** What a tool result carries to pin a fact; see `ToolResult.workingState`. */
|
|
42
|
+
export interface WorkingStatePin {
|
|
43
|
+
readonly key: string
|
|
44
|
+
readonly text: string
|
|
45
|
+
}
|
|
46
|
+
|
|
24
47
|
export interface PlanSlot {
|
|
25
48
|
id: string
|
|
26
49
|
label: string
|
|
@@ -44,4 +67,4 @@ export interface ToolResultSlot {
|
|
|
44
67
|
timestamp: number
|
|
45
68
|
}
|
|
46
69
|
|
|
47
|
-
export type CompactionStrategy = 'structured' | 'sliding-window' | 'disabled'
|
|
70
|
+
export type CompactionStrategy = 'structured' | 'salience' | 'sliding-window' | 'disabled'
|
package/src/compaction/wire.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CompactionConfig } from '../config/runtime.js'
|
|
2
2
|
import { WorkingStateManager } from './manager.js'
|
|
3
|
-
import type { FileSlot, PlanSlot, ToolResultSlot, WorkingState } from './types.js'
|
|
3
|
+
import type { FileSlot, PinSlot, PlanSlot, ToolResultSlot, WorkingState } from './types.js'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* The working state in a form that survives a process boundary.
|
|
@@ -26,6 +26,8 @@ import type { FileSlot, PlanSlot, ToolResultSlot, WorkingState } from './types.j
|
|
|
26
26
|
export interface WorkingStateSnapshot {
|
|
27
27
|
readonly task: string
|
|
28
28
|
readonly plan: readonly PlanSlot[]
|
|
29
|
+
/** Absent in snapshots written before pins existed; restored as none. */
|
|
30
|
+
readonly pins?: readonly PinSlot[]
|
|
29
31
|
readonly files: readonly FileSlot[]
|
|
30
32
|
readonly decisions: readonly string[]
|
|
31
33
|
readonly failures: readonly string[]
|
|
@@ -47,6 +49,7 @@ export function snapshotWorkingState(manager: WorkingStateManager): WorkingState
|
|
|
47
49
|
return {
|
|
48
50
|
task: state.task,
|
|
49
51
|
plan: [...state.plan],
|
|
52
|
+
pins: [...(state.pins?.values() ?? [])],
|
|
50
53
|
files: [...state.files.values()],
|
|
51
54
|
decisions: [...state.decisions],
|
|
52
55
|
failures: [...state.failures],
|
|
@@ -76,6 +79,7 @@ export function restoreWorkingState(
|
|
|
76
79
|
const state: WorkingState = {
|
|
77
80
|
task: snapshot.task,
|
|
78
81
|
plan: [...snapshot.plan],
|
|
82
|
+
pins: new Map((snapshot.pins ?? []).map((p) => [p.key, p])),
|
|
79
83
|
files: new Map(snapshot.files.map((f) => [f.path, f])),
|
|
80
84
|
decisions: [...snapshot.decisions],
|
|
81
85
|
failures: [...snapshot.failures],
|
package/src/config/runtime.ts
CHANGED
|
@@ -17,7 +17,19 @@ export const TaskRouterConfigSchema = z
|
|
|
17
17
|
.optional()
|
|
18
18
|
|
|
19
19
|
export const CompactionConfigSchema = z.object({
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* `salience` is the default: every message scored without a model, the
|
|
22
|
+
* context held from half the window. `structured` is the previous
|
|
23
|
+
* default — positional retention, a pass only at the trigger — and one
|
|
24
|
+
* word away for a host that wants it back.
|
|
25
|
+
*/
|
|
26
|
+
strategy: z.enum(['structured', 'salience', 'sliding-window', 'disabled']).default('salience'),
|
|
27
|
+
/**
|
|
28
|
+
* `salience` only: the fraction of the window at which the working-set
|
|
29
|
+
* pass starts evicting low-salience messages, well before
|
|
30
|
+
* `triggerThreshold` summarises. The context is held around here.
|
|
31
|
+
*/
|
|
32
|
+
softTarget: z.number().min(0).max(1).optional(),
|
|
21
33
|
/**
|
|
22
34
|
* Optional model context-window size (tokens) the compaction trigger
|
|
23
35
|
* measures the CURRENT window against. NO default: when omitted the
|
|
@@ -71,14 +71,8 @@ function stripTrailingSlashes(value: string): string {
|
|
|
71
71
|
return value.slice(0, end)
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
/**
|
|
75
|
-
|
|
76
|
-
*
|
|
77
|
-
* `'conn_http' as const` typed this as its own literal, which satisfied
|
|
78
|
-
* `ConnectorId` only because the id types are still structural. The
|
|
79
|
-
* constructor is what makes the prefix a fact rather than a spelling.
|
|
80
|
-
*/
|
|
81
|
-
const HTTP_CONNECTOR_ID = asConnectorId('conn_http')
|
|
74
|
+
/** Stable UUID for this built-in definition, checked once at module load. */
|
|
75
|
+
const HTTP_CONNECTOR_ID = asConnectorId('dafa33b2-7035-47d2-986c-8a6d2ef338f3')
|
|
82
76
|
|
|
83
77
|
export class HttpConnector extends BaseConnector<HttpConnectorConfig> {
|
|
84
78
|
readonly id = HTTP_CONNECTOR_ID
|
|
@@ -56,8 +56,8 @@ const WebhookSendInputSchema = z.object({
|
|
|
56
56
|
url: z.string().url().optional(),
|
|
57
57
|
})
|
|
58
58
|
|
|
59
|
-
/**
|
|
60
|
-
const WEBHOOK_CONNECTOR_ID = asConnectorId('
|
|
59
|
+
/** Stable UUID for this built-in definition, checked once at module load. */
|
|
60
|
+
const WEBHOOK_CONNECTOR_ID = asConnectorId('5d1e831d-d079-47c8-bdb6-ddf4489bb000')
|
|
61
61
|
|
|
62
62
|
export class WebhookConnector extends BaseConnector<WebhookConnectorConfig> {
|
|
63
63
|
readonly id = WEBHOOK_CONNECTOR_ID
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
import { zodToJsonSchema } from 'zod-to-json-schema'
|
|
3
|
+
import type { WorkingStatePin } from '../../compaction/types.js'
|
|
3
4
|
import { type UntrustedEnvelope, wrapUntrusted } from '../../tools/untrusted-envelope.js'
|
|
4
5
|
import type {
|
|
5
6
|
MCPJsonSchema,
|
|
@@ -11,6 +12,28 @@ import type { ToolContext, ToolDefinition, ToolResult } from '../../types/tool/i
|
|
|
11
12
|
import type { MCPClient } from './client.js'
|
|
12
13
|
import { MCPHttpRedirectError } from './http-redirect.js'
|
|
13
14
|
import { admitMcpImageBatch } from './image-admission.js'
|
|
15
|
+
|
|
16
|
+
/** The resource type an MCP server returns to pin facts into working memory. */
|
|
17
|
+
export const WORKING_STATE_MIME = 'application/vnd.namzu.working-state+json'
|
|
18
|
+
|
|
19
|
+
function parsePins(text: string | undefined): WorkingStatePin[] {
|
|
20
|
+
if (!text) return []
|
|
21
|
+
try {
|
|
22
|
+
const raw: unknown = JSON.parse(text)
|
|
23
|
+
if (!Array.isArray(raw)) return []
|
|
24
|
+
return raw
|
|
25
|
+
.filter(
|
|
26
|
+
(p): p is { key: string; text: string } =>
|
|
27
|
+
typeof p === 'object' &&
|
|
28
|
+
p !== null &&
|
|
29
|
+
typeof (p as { key?: unknown }).key === 'string' &&
|
|
30
|
+
typeof (p as { text?: unknown }).text === 'string',
|
|
31
|
+
)
|
|
32
|
+
.map((p) => ({ key: p.key, text: p.text }))
|
|
33
|
+
} catch {
|
|
34
|
+
return []
|
|
35
|
+
}
|
|
36
|
+
}
|
|
14
37
|
import { inlineSchemaRefs } from './schema-refs.js'
|
|
15
38
|
|
|
16
39
|
/**
|
|
@@ -579,7 +602,15 @@ export function mcpToolResultToToolResult(result: MCPToolResult): ToolResult {
|
|
|
579
602
|
// modelled `image` and `resource` blocks all along. Pass them through
|
|
580
603
|
// as model-visible content when any are present.
|
|
581
604
|
const blocks: ToolResultBlock[] = []
|
|
605
|
+
const pins: WorkingStatePin[] = []
|
|
582
606
|
for (const block of result.content) {
|
|
607
|
+
if (block.type === 'resource' && block.resource?.mimeType === WORKING_STATE_MIME) {
|
|
608
|
+
// A server pins facts by returning them as a resource of this type:
|
|
609
|
+
// a JSON array of { key, text }. Not text for the model; the kernel
|
|
610
|
+
// keeps them in the working-memory slot.
|
|
611
|
+
for (const pin of parsePins(block.resource.text)) pins.push(pin)
|
|
612
|
+
continue
|
|
613
|
+
}
|
|
583
614
|
if (block.type === 'text') {
|
|
584
615
|
blocks.push({ type: 'text', text: block.text })
|
|
585
616
|
} else if (block.type === 'image') {
|
|
@@ -620,6 +651,7 @@ export function mcpToolResultToToolResult(result: MCPToolResult): ToolResult {
|
|
|
620
651
|
const output = [visibleText, invalidImageNotice].filter((part) => part.length > 0).join('\n')
|
|
621
652
|
|
|
622
653
|
return {
|
|
654
|
+
...(pins.length > 0 ? { workingState: pins } : {}),
|
|
623
655
|
success: !result.isError,
|
|
624
656
|
output,
|
|
625
657
|
...(hasRichContent ? { content: blocks } : {}),
|
|
@@ -4,7 +4,7 @@ import { renderToolSchema } from '../../registry/tool/schema.js'
|
|
|
4
4
|
import type { ConnectorMethod } from '../../types/connector/index.js'
|
|
5
5
|
import type { ConnectorId, ConnectorInstanceId } from '../../types/ids/index.js'
|
|
6
6
|
import type { ToolContext, ToolDefinition, ToolResult } from '../../types/tool/index.js'
|
|
7
|
-
import {
|
|
7
|
+
import { asConnectorInstanceId } from '../../utils/id.js'
|
|
8
8
|
import { connectorToolError } from './result.js'
|
|
9
9
|
|
|
10
10
|
export function connectorMethodToTool(
|
|
@@ -96,7 +96,7 @@ export function createConnectorRouterTool(
|
|
|
96
96
|
isConcurrencySafe: () => true,
|
|
97
97
|
|
|
98
98
|
async execute(input: ConnectorRouterInput, context: ToolContext): Promise<ToolResult> {
|
|
99
|
-
const instanceId =
|
|
99
|
+
const instanceId = asConnectorInstanceId(String(input.instanceId))
|
|
100
100
|
const instance = manager.getInstance(instanceId)
|
|
101
101
|
if (!instance) {
|
|
102
102
|
return {
|
|
@@ -2,7 +2,7 @@ import { z } from 'zod'
|
|
|
2
2
|
import type { ConnectorManager } from '../../manager/connector/lifecycle.js'
|
|
3
3
|
import { defineTool } from '../../tools/defineTool.js'
|
|
4
4
|
import type { ToolDefinition } from '../../types/tool/index.js'
|
|
5
|
-
import {
|
|
5
|
+
import { asConnectorInstanceId } from '../../utils/id.js'
|
|
6
6
|
import { connectorToolError } from './result.js'
|
|
7
7
|
|
|
8
8
|
export interface ConnectorToolConfig {
|
|
@@ -30,7 +30,7 @@ export function createConnectorExecuteTool(config: ConnectorToolConfig): ToolDef
|
|
|
30
30
|
concurrencySafe: true,
|
|
31
31
|
|
|
32
32
|
async execute(input, context) {
|
|
33
|
-
const instanceId =
|
|
33
|
+
const instanceId = asConnectorInstanceId(String(input.instance_id))
|
|
34
34
|
const instance = config.manager.getInstance(instanceId)
|
|
35
35
|
|
|
36
36
|
if (!instance) {
|
|
@@ -146,7 +146,6 @@ export const BOOT_EVENT_NAMES = {
|
|
|
146
146
|
CAPABILITY_DETECTED: 'namzu.capability.detected',
|
|
147
147
|
CAPABILITY_BROKEN: 'namzu.capability.broken',
|
|
148
148
|
TELEMETRY_STATUS: 'namzu.telemetry.status',
|
|
149
|
-
MIGRATION_COMPLETED: 'namzu.migration.completed',
|
|
150
149
|
DISCOVERY_COMPLETED: 'namzu.discovery.completed',
|
|
151
150
|
BOOT_REFUSED: 'namzu.boot.refused',
|
|
152
151
|
BOOT_READY: 'namzu.boot.ready',
|
package/src/contracts/api.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentCapabilities, AgentType } from '../types/agent/base.js'
|
|
2
2
|
import type { ProjectId, RunId, SessionId } from '../types/ids/index.js'
|
|
3
3
|
import type { MessageRole } from '../types/message/index.js'
|
|
4
|
+
import type { PermissionMode } from '../types/permission/index.js'
|
|
4
5
|
import type { StopReason } from '../types/run/events.js'
|
|
5
6
|
|
|
6
7
|
export type { MessageRole, StopReason, AgentType, AgentCapabilities }
|
|
@@ -106,7 +107,8 @@ export interface RunHierarchyNode {
|
|
|
106
107
|
children: RunHierarchyNode[]
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
|
|
110
|
+
/** The wire name for the kernel's `PermissionMode`; one union, not a second copy of it. */
|
|
111
|
+
export type ApiPermissionMode = PermissionMode
|
|
110
112
|
|
|
111
113
|
export interface RunConfig {
|
|
112
114
|
model?: string
|
|
@@ -168,6 +170,8 @@ export type StreamEventType =
|
|
|
168
170
|
| 'compaction.completed'
|
|
169
171
|
/** Oversized tool results were emptied instead of the history summarized. */
|
|
170
172
|
| 'compaction.tool_results_cleared'
|
|
173
|
+
| 'memory.consolidated'
|
|
174
|
+
| 'background_job.exited'
|
|
171
175
|
| 'compaction.failed'
|
|
172
176
|
/** A guardrail refused or corrected the run. */
|
|
173
177
|
| 'guardrail.triggered'
|