@namzu/sdk 46.0.0 → 48.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +351 -8
- package/README.md +7 -8
- package/dist/advisory/history.d.ts.map +1 -1
- package/dist/advisory/history.js +21 -1
- package/dist/advisory/history.js.map +1 -1
- package/dist/advisory/index.d.ts +1 -1
- package/dist/advisory/index.d.ts.map +1 -1
- package/dist/advisory/index.js +1 -1
- package/dist/advisory/index.js.map +1 -1
- package/dist/advisory/registry.d.ts +17 -0
- package/dist/advisory/registry.d.ts.map +1 -1
- package/dist/advisory/registry.js +26 -0
- package/dist/advisory/registry.js.map +1 -1
- package/dist/agents/PipelineAgent.d.ts +2 -46
- package/dist/agents/PipelineAgent.d.ts.map +1 -1
- package/dist/agents/PipelineAgent.js +2 -242
- package/dist/agents/PipelineAgent.js.map +1 -1
- package/dist/agents/QueryAgent.d.ts +21 -0
- package/dist/agents/QueryAgent.d.ts.map +1 -0
- package/dist/agents/QueryAgent.js +214 -0
- package/dist/agents/QueryAgent.js.map +1 -0
- package/dist/agents/ReactiveAgent.d.ts +4 -16
- package/dist/agents/ReactiveAgent.d.ts.map +1 -1
- package/dist/agents/ReactiveAgent.js +4 -183
- package/dist/agents/ReactiveAgent.js.map +1 -1
- package/dist/agents/RouterAgent.d.ts +2 -20
- package/dist/agents/RouterAgent.d.ts.map +1 -1
- package/dist/agents/RouterAgent.js +2 -266
- package/dist/agents/RouterAgent.js.map +1 -1
- package/dist/agents/SupervisorAgent.d.ts +3 -43
- package/dist/agents/SupervisorAgent.d.ts.map +1 -1
- package/dist/agents/SupervisorAgent.js +3 -418
- package/dist/agents/SupervisorAgent.js.map +1 -1
- package/dist/agents/defineAgent.d.ts +2 -1
- package/dist/agents/defineAgent.d.ts.map +1 -1
- package/dist/agents/defineAgent.js +6 -1
- package/dist/agents/defineAgent.js.map +1 -1
- package/dist/agents/examples/PipelineAgent.d.ts +46 -0
- package/dist/agents/examples/PipelineAgent.d.ts.map +1 -0
- package/dist/agents/examples/PipelineAgent.js +242 -0
- package/dist/agents/examples/PipelineAgent.js.map +1 -0
- package/dist/agents/examples/RouterAgent.d.ts +22 -0
- package/dist/agents/examples/RouterAgent.d.ts.map +1 -0
- package/dist/agents/examples/RouterAgent.js +268 -0
- package/dist/agents/examples/RouterAgent.js.map +1 -0
- package/dist/agents/examples/SupervisorAgent.d.ts +45 -0
- package/dist/agents/examples/SupervisorAgent.d.ts.map +1 -0
- package/dist/agents/examples/SupervisorAgent.js +406 -0
- package/dist/agents/examples/SupervisorAgent.js.map +1 -0
- package/dist/agents/explore.d.ts +6 -3
- package/dist/agents/explore.d.ts.map +1 -1
- package/dist/agents/explore.js +6 -3
- package/dist/agents/explore.js.map +1 -1
- package/dist/agents/forward-options.d.ts +11 -0
- package/dist/agents/forward-options.d.ts.map +1 -0
- package/dist/agents/forward-options.js +15 -0
- package/dist/agents/forward-options.js.map +1 -0
- package/dist/agents/index.d.ts +1 -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/agents/runAgent.d.ts +19 -8
- package/dist/agents/runAgent.d.ts.map +1 -1
- package/dist/agents/runAgent.js +99 -29
- package/dist/agents/runAgent.js.map +1 -1
- package/dist/authorization/command-line.d.ts +2 -0
- package/dist/authorization/command-line.d.ts.map +1 -1
- package/dist/authorization/command-line.js +2 -2
- package/dist/authorization/command-line.js.map +1 -1
- package/dist/authorization/gate.d.ts +8 -0
- package/dist/authorization/gate.d.ts.map +1 -1
- package/dist/authorization/gate.js +12 -1
- package/dist/authorization/gate.js.map +1 -1
- package/dist/authorization/program.d.ts +151 -0
- package/dist/authorization/program.d.ts.map +1 -0
- package/dist/authorization/program.js +713 -0
- package/dist/authorization/program.js.map +1 -0
- package/dist/authorization/reexec-wrapper.d.ts +106 -0
- package/dist/authorization/reexec-wrapper.d.ts.map +1 -0
- package/dist/authorization/reexec-wrapper.js +532 -0
- package/dist/authorization/reexec-wrapper.js.map +1 -0
- package/dist/authorization/rules.d.ts +9 -0
- package/dist/authorization/rules.d.ts.map +1 -1
- package/dist/authorization/rules.js +8 -1
- package/dist/authorization/rules.js.map +1 -1
- package/dist/authorization/shell-lexer.d.ts +19 -4
- package/dist/authorization/shell-lexer.d.ts.map +1 -1
- package/dist/authorization/shell-lexer.js +91 -65
- package/dist/authorization/shell-lexer.js.map +1 -1
- package/dist/bridge/sse/mapper.d.ts.map +1 -1
- package/dist/bridge/sse/mapper.js +6 -0
- package/dist/bridge/sse/mapper.js.map +1 -1
- package/dist/capabilities/index.d.ts +54 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +92 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/config/registry.d.ts +2 -1
- package/dist/config/registry.d.ts.map +1 -1
- package/dist/config/registry.js +3 -2
- package/dist/config/registry.js.map +1 -1
- package/dist/connector/index.d.ts +4 -4
- package/dist/connector/index.d.ts.map +1 -1
- package/dist/connector/index.js +3 -3
- package/dist/connector/index.js.map +1 -1
- package/dist/connector/mcp/adapter.d.ts +16 -1
- package/dist/connector/mcp/adapter.d.ts.map +1 -1
- package/dist/connector/mcp/adapter.js +71 -4
- package/dist/connector/mcp/adapter.js.map +1 -1
- package/dist/connector/mcp/client.d.ts +32 -4
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +383 -5
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/mcp/discovery.d.ts +24 -1
- package/dist/connector/mcp/discovery.d.ts.map +1 -1
- package/dist/connector/mcp/discovery.js +44 -0
- package/dist/connector/mcp/discovery.js.map +1 -1
- package/dist/connector/mcp/era.d.ts.map +1 -1
- package/dist/connector/mcp/era.js +7 -0
- package/dist/connector/mcp/era.js.map +1 -1
- package/dist/connector/mcp/index.d.ts +2 -0
- package/dist/connector/mcp/index.d.ts.map +1 -1
- package/dist/connector/mcp/index.js +11 -0
- package/dist/connector/mcp/index.js.map +1 -1
- package/dist/connector/mcp/mcp-toolset.d.ts +133 -0
- package/dist/connector/mcp/mcp-toolset.d.ts.map +1 -0
- package/dist/connector/mcp/mcp-toolset.js +399 -0
- package/dist/connector/mcp/mcp-toolset.js.map +1 -0
- package/dist/connector/mcp/streamable-http.d.ts +15 -0
- package/dist/connector/mcp/streamable-http.d.ts.map +1 -1
- package/dist/connector/mcp/streamable-http.js +281 -6
- package/dist/connector/mcp/streamable-http.js.map +1 -1
- package/dist/connector/tools/index.d.ts +2 -2
- package/dist/connector/tools/index.d.ts.map +1 -1
- package/dist/connector/tools/index.js +1 -1
- package/dist/connector/tools/index.js.map +1 -1
- package/dist/connector/tools/router.d.ts +15 -13
- package/dist/connector/tools/router.d.ts.map +1 -1
- package/dist/connector/tools/router.js +30 -51
- package/dist/connector/tools/router.js.map +1 -1
- package/dist/contracts/a2a.d.ts +2 -2
- package/dist/directory/derive-supervisor.d.ts +2 -2
- package/dist/directory/derive-supervisor.d.ts.map +1 -1
- package/dist/directory/derive-supervisor.js +6 -7
- package/dist/directory/derive-supervisor.js.map +1 -1
- package/dist/directory/derive.d.ts.map +1 -1
- package/dist/directory/derive.js +5 -5
- package/dist/directory/derive.js.map +1 -1
- package/dist/execution/code-runtime/types.d.ts +2 -2
- package/dist/execution/code-runtime/types.js +1 -1
- package/dist/invariants/index.d.ts +2 -1
- package/dist/invariants/index.d.ts.map +1 -1
- package/dist/invariants/index.js +3 -2
- package/dist/invariants/index.js.map +1 -1
- package/dist/manager/agent/lifecycle.d.ts +1 -0
- package/dist/manager/agent/lifecycle.d.ts.map +1 -1
- package/dist/manager/agent/lifecycle.js +146 -18
- package/dist/manager/agent/lifecycle.js.map +1 -1
- package/dist/manager/connector/environment.d.ts +6 -0
- package/dist/manager/connector/environment.d.ts.map +1 -1
- package/dist/manager/connector/environment.js +11 -4
- package/dist/manager/connector/environment.js.map +1 -1
- package/dist/manager/connector/index.d.ts +2 -2
- package/dist/manager/connector/index.d.ts.map +1 -1
- package/dist/manager/connector/index.js +2 -2
- package/dist/manager/connector/index.js.map +1 -1
- package/dist/manager/connector/tenant.d.ts +6 -0
- package/dist/manager/connector/tenant.d.ts.map +1 -1
- package/dist/manager/connector/tenant.js +11 -4
- package/dist/manager/connector/tenant.js.map +1 -1
- package/dist/manager/index.d.ts +2 -2
- package/dist/manager/index.d.ts.map +1 -1
- package/dist/manager/index.js +2 -2
- package/dist/manager/index.js.map +1 -1
- package/dist/manager/resident/initiative.d.ts +6 -6
- package/dist/manager/resident/learning-observation.d.ts +4 -4
- package/dist/manager/resident/learning.d.ts +36 -36
- package/dist/manager/resident/outbox.d.ts +4 -4
- package/dist/manager/session/attribution.d.ts +22 -0
- package/dist/manager/session/attribution.d.ts.map +1 -0
- package/dist/manager/session/attribution.js +64 -0
- package/dist/manager/session/attribution.js.map +1 -0
- package/dist/manager/session/turn-recorder.d.ts +14 -0
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +208 -55
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/peers/address.d.ts +36 -0
- package/dist/peers/address.d.ts.map +1 -0
- package/dist/peers/address.js +52 -0
- package/dist/peers/address.js.map +1 -0
- package/dist/peers/client.d.ts +47 -0
- package/dist/peers/client.d.ts.map +1 -0
- package/dist/peers/client.js +132 -0
- package/dist/peers/client.js.map +1 -0
- package/dist/peers/dir.d.ts +88 -0
- package/dist/peers/dir.d.ts.map +1 -0
- package/dist/peers/dir.js +139 -0
- package/dist/peers/dir.js.map +1 -0
- package/dist/peers/endpoint.d.ts +144 -0
- package/dist/peers/endpoint.d.ts.map +1 -0
- package/dist/peers/endpoint.js +420 -0
- package/dist/peers/endpoint.js.map +1 -0
- package/dist/peers/envelope.d.ts +42 -0
- package/dist/peers/envelope.d.ts.map +1 -0
- package/dist/peers/envelope.js +110 -0
- package/dist/peers/envelope.js.map +1 -0
- package/dist/peers/index.d.ts +30 -0
- package/dist/peers/index.d.ts.map +1 -0
- package/dist/peers/index.js +22 -0
- package/dist/peers/index.js.map +1 -0
- package/dist/peers/protocol.d.ts +645 -0
- package/dist/peers/protocol.d.ts.map +1 -0
- package/dist/peers/protocol.js +151 -0
- package/dist/peers/protocol.js.map +1 -0
- package/dist/peers/record.d.ts +71 -0
- package/dist/peers/record.d.ts.map +1 -0
- package/dist/peers/record.js +45 -0
- package/dist/peers/record.js.map +1 -0
- package/dist/peers/registry.d.ts +54 -0
- package/dist/peers/registry.d.ts.map +1 -0
- package/dist/peers/registry.js +213 -0
- package/dist/peers/registry.js.map +1 -0
- package/dist/plugin/define.d.ts +24 -0
- package/dist/plugin/define.d.ts.map +1 -0
- package/dist/plugin/define.js +42 -0
- package/dist/plugin/define.js.map +1 -0
- 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/lifecycle.d.ts +27 -3
- package/dist/plugin/lifecycle.d.ts.map +1 -1
- package/dist/plugin/lifecycle.js +242 -92
- package/dist/plugin/lifecycle.js.map +1 -1
- package/dist/plugin/resolver.d.ts +2 -2
- package/dist/plugin/resolver.d.ts.map +1 -1
- package/dist/plugin/resolver.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +17 -3
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/probe/errors.d.ts +2 -1
- package/dist/probe/errors.d.ts.map +1 -1
- package/dist/probe/errors.js +3 -2
- package/dist/probe/errors.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +18 -7
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +11 -6
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/prompt/contributions.d.ts +4 -1
- package/dist/prompt/contributions.d.ts.map +1 -1
- package/dist/prompt/contributions.js +7 -2
- package/dist/prompt/contributions.js.map +1 -1
- package/dist/prompt/index.d.ts +1 -1
- package/dist/prompt/index.d.ts.map +1 -1
- package/dist/prompt/index.js +1 -1
- package/dist/prompt/index.js.map +1 -1
- package/dist/provider/collect-chat-completion.d.ts +6 -1
- package/dist/provider/collect-chat-completion.d.ts.map +1 -1
- package/dist/provider/collect-chat-completion.js +88 -10
- package/dist/provider/collect-chat-completion.js.map +1 -1
- package/dist/provider/mock.d.ts.map +1 -1
- package/dist/provider/mock.js +23 -6
- package/dist/provider/mock.js.map +1 -1
- package/dist/provider/registry.d.ts +2 -1
- package/dist/provider/registry.d.ts.map +1 -1
- package/dist/provider/registry.js +3 -2
- package/dist/provider/registry.js.map +1 -1
- package/dist/provider/tool-call-framing.d.ts +164 -0
- package/dist/provider/tool-call-framing.d.ts.map +1 -0
- package/dist/provider/tool-call-framing.js +163 -0
- package/dist/provider/tool-call-framing.js.map +1 -0
- package/dist/public-runtime.d.ts +24 -11
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +45 -9
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +6 -4
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +8 -3
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +13 -2
- package/dist/public-types.d.ts.map +1 -1
- package/dist/read-model/registry.d.ts +2 -1
- package/dist/read-model/registry.d.ts.map +1 -1
- package/dist/read-model/registry.js +3 -2
- package/dist/read-model/registry.js.map +1 -1
- package/dist/registry/ManagedRegistry.d.ts +30 -0
- package/dist/registry/ManagedRegistry.d.ts.map +1 -1
- package/dist/registry/ManagedRegistry.js +45 -6
- package/dist/registry/ManagedRegistry.js.map +1 -1
- package/dist/registry/collision.d.ts +57 -0
- package/dist/registry/collision.d.ts.map +1 -0
- package/dist/registry/collision.js +41 -0
- package/dist/registry/collision.js.map +1 -0
- package/dist/registry/command/index.d.ts +5 -3
- package/dist/registry/command/index.d.ts.map +1 -1
- package/dist/registry/command/index.js +6 -4
- package/dist/registry/command/index.js.map +1 -1
- package/dist/registry/index.d.ts +3 -4
- package/dist/registry/index.d.ts.map +1 -1
- package/dist/registry/index.js +2 -2
- package/dist/registry/index.js.map +1 -1
- package/dist/registry/plugin/index.d.ts.map +1 -1
- package/dist/registry/plugin/index.js +14 -1
- package/dist/registry/plugin/index.js.map +1 -1
- package/dist/registry/tool/callable.d.ts +7 -7
- package/dist/registry/tool/callable.d.ts.map +1 -1
- package/dist/registry/tool/callable.js +6 -7
- package/dist/registry/tool/callable.js.map +1 -1
- package/dist/registry/tool/execute.d.ts +14 -77
- package/dist/registry/tool/execute.d.ts.map +1 -1
- package/dist/registry/tool/execute.js +15 -727
- package/dist/registry/tool/execute.js.map +1 -1
- package/dist/registry/tool/portable.d.ts +25 -0
- package/dist/registry/tool/portable.d.ts.map +1 -1
- package/dist/registry/tool/portable.js +50 -0
- package/dist/registry/tool/portable.js.map +1 -1
- package/dist/registry/tool/presentation.d.ts +6 -5
- package/dist/registry/tool/presentation.d.ts.map +1 -1
- package/dist/registry/tool/presentation.js +3 -3
- package/dist/registry/tool/presentation.js.map +1 -1
- package/dist/runtime/bidi/session.d.ts +5 -4
- package/dist/runtime/bidi/session.d.ts.map +1 -1
- package/dist/runtime/bidi/session.js +18 -1
- package/dist/runtime/bidi/session.js.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts +45 -2
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +189 -5
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +33 -3
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +86 -10
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/file-evidence-replay.d.ts +1 -1
- package/dist/runtime/query/file-evidence-replay.d.ts.map +1 -1
- package/dist/runtime/query/file-evidence-replay.js +8 -7
- package/dist/runtime/query/file-evidence-replay.js.map +1 -1
- package/dist/runtime/query/fork/prepare.d.ts +4 -1
- package/dist/runtime/query/fork/prepare.d.ts.map +1 -1
- package/dist/runtime/query/fork/prepare.js +4 -0
- package/dist/runtime/query/fork/prepare.js.map +1 -1
- package/dist/runtime/query/guardrail-presets.d.ts +4 -3
- package/dist/runtime/query/guardrail-presets.d.ts.map +1 -1
- package/dist/runtime/query/guardrail-presets.js +4 -3
- package/dist/runtime/query/guardrail-presets.js.map +1 -1
- package/dist/runtime/query/index.d.ts +23 -10
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +149 -70
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +8 -1
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +2 -2
- package/dist/runtime/query/iteration/phases/context.d.ts.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 +55 -2
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.d.ts.map +1 -1
- package/dist/runtime/query/iteration/stream-turn.js +342 -116
- package/dist/runtime/query/iteration/stream-turn.js.map +1 -1
- package/dist/runtime/query/iteration/tool-input.d.ts +79 -0
- package/dist/runtime/query/iteration/tool-input.d.ts.map +1 -0
- package/dist/runtime/query/iteration/tool-input.js +291 -0
- package/dist/runtime/query/iteration/tool-input.js.map +1 -0
- package/dist/runtime/query/observation-context.d.ts +2 -2
- package/dist/runtime/query/observation-context.d.ts.map +1 -1
- package/dist/runtime/query/observation-context.js.map +1 -1
- package/dist/runtime/query/prelude-lease.d.ts +18 -0
- package/dist/runtime/query/prelude-lease.d.ts.map +1 -0
- package/dist/runtime/query/prelude-lease.js +121 -0
- package/dist/runtime/query/prelude-lease.js.map +1 -0
- package/dist/runtime/query/prepare-turn.d.ts.map +1 -1
- package/dist/runtime/query/prepare-turn.js +386 -187
- package/dist/runtime/query/prepare-turn.js.map +1 -1
- package/dist/runtime/query/prompt-cache.d.ts +2 -2
- package/dist/runtime/query/prompt-cache.d.ts.map +1 -1
- package/dist/runtime/query/prompt.d.ts +2 -2
- package/dist/runtime/query/prompt.d.ts.map +1 -1
- package/dist/runtime/query/prompt.js +1 -1
- package/dist/runtime/query/prompt.js.map +1 -1
- package/dist/runtime/query/resume-session.d.ts.map +1 -1
- package/dist/runtime/query/resume-session.js +37 -2
- package/dist/runtime/query/resume-session.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +22 -3
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +84 -6
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/tooling.d.ts +3 -2
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/runtime/query/turn-state.d.ts.map +1 -1
- package/dist/runtime/query/turn-state.js +5 -0
- package/dist/runtime/query/turn-state.js.map +1 -1
- package/dist/runtime/system-events.d.ts +112 -0
- package/dist/runtime/system-events.d.ts.map +1 -0
- package/dist/runtime/system-events.js +183 -0
- package/dist/runtime/system-events.js.map +1 -0
- package/dist/scheduler/delegating.d.ts +2 -1
- package/dist/scheduler/delegating.d.ts.map +1 -1
- package/dist/scheduler/delegating.js +3 -2
- package/dist/scheduler/delegating.js.map +1 -1
- package/dist/scheduler/local.d.ts.map +1 -1
- package/dist/scheduler/local.js +2 -0
- package/dist/scheduler/local.js.map +1 -1
- package/dist/session/retention/archive.js +1 -1
- package/dist/session/retention/archive.js.map +1 -1
- package/dist/skills/index.d.ts +1 -1
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +1 -1
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/registry.d.ts +12 -0
- package/dist/skills/registry.d.ts.map +1 -1
- package/dist/skills/registry.js +19 -0
- package/dist/skills/registry.js.map +1 -1
- package/dist/store/evidence/index-page.d.ts +2 -2
- package/dist/store/session/disk.d.ts.map +1 -1
- package/dist/store/session/disk.js +2 -0
- package/dist/store/session/disk.js.map +1 -1
- package/dist/store/session-log/conformance.d.ts +1 -1
- package/dist/store/session-log/conformance.d.ts.map +1 -1
- package/dist/store/session-log/conformance.js +49 -8
- package/dist/store/session-log/conformance.js.map +1 -1
- package/dist/store/session-log/core.d.ts +8 -3
- package/dist/store/session-log/core.d.ts.map +1 -1
- package/dist/store/session-log/core.js +2 -1
- package/dist/store/session-log/core.js.map +1 -1
- package/dist/store/session-log/fold.d.ts +12 -0
- package/dist/store/session-log/fold.d.ts.map +1 -1
- package/dist/store/session-log/fold.js +57 -7
- package/dist/store/session-log/fold.js.map +1 -1
- package/dist/store/session-log/index.d.ts +2 -2
- package/dist/store/session-log/index.d.ts.map +1 -1
- package/dist/store/session-log/index.js +1 -1
- package/dist/store/session-log/index.js.map +1 -1
- package/dist/test-support/toolset.d.ts +19 -0
- package/dist/test-support/toolset.d.ts.map +1 -0
- package/dist/test-support/toolset.js +20 -0
- package/dist/test-support/toolset.js.map +1 -0
- package/dist/tools/builtins/bash.d.ts +29 -0
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +19 -9
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/browser-url.d.ts +1 -1
- package/dist/tools/builtins/browser-url.js +1 -1
- package/dist/tools/builtins/browser.d.ts +6 -6
- package/dist/tools/builtins/browser.js +2 -2
- package/dist/tools/builtins/browser.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +19 -11
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +9 -1
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/json-string-hint.d.ts +15 -0
- package/dist/tools/builtins/json-string-hint.d.ts.map +1 -0
- package/dist/tools/builtins/json-string-hint.js +17 -0
- package/dist/tools/builtins/json-string-hint.js.map +1 -0
- package/dist/tools/builtins/search-tools.d.ts.map +1 -1
- package/dist/tools/builtins/search-tools.js +7 -15
- package/dist/tools/builtins/search-tools.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +11 -0
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/command-shell.d.ts +10 -0
- package/dist/tools/command-shell.d.ts.map +1 -1
- package/dist/tools/command-shell.js +45 -1
- package/dist/tools/command-shell.js.map +1 -1
- package/dist/tools/coordinator/agent.d.ts.map +1 -1
- package/dist/tools/coordinator/agent.js +5 -0
- package/dist/tools/coordinator/agent.js.map +1 -1
- package/dist/tools/coordinator/ask-user-question.d.ts.map +1 -1
- package/dist/tools/coordinator/ask-user-question.js +26 -13
- package/dist/tools/coordinator/ask-user-question.js.map +1 -1
- package/dist/tools/coordinator/index.d.ts.map +1 -1
- package/dist/tools/coordinator/index.js +5 -0
- package/dist/tools/coordinator/index.js.map +1 -1
- package/dist/tools/coordinator/question-options.d.ts +78 -0
- package/dist/tools/coordinator/question-options.d.ts.map +1 -0
- package/dist/tools/coordinator/question-options.js +153 -0
- package/dist/tools/coordinator/question-options.js.map +1 -0
- package/dist/tools/defineTool.d.ts +10 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +17 -0
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/memory/search.d.ts.map +1 -1
- package/dist/tools/memory/search.js +4 -1
- package/dist/tools/memory/search.js.map +1 -1
- package/dist/tools/memory/update.d.ts.map +1 -1
- package/dist/tools/memory/update.js +8 -5
- package/dist/tools/memory/update.js.map +1 -1
- package/dist/tools/render-nonce.d.ts +47 -0
- package/dist/tools/render-nonce.d.ts.map +1 -0
- package/dist/tools/render-nonce.js +63 -0
- package/dist/tools/render-nonce.js.map +1 -0
- package/dist/tools/roster.d.ts +46 -19
- package/dist/tools/roster.d.ts.map +1 -1
- package/dist/tools/roster.js +63 -33
- package/dist/tools/roster.js.map +1 -1
- package/dist/tools/schedules/schedule-tool.d.ts.map +1 -1
- package/dist/tools/schedules/schedule-tool.js +94 -14
- package/dist/tools/schedules/schedule-tool.js.map +1 -1
- package/dist/tools/schedules/types.d.ts +52 -6
- package/dist/tools/schedules/types.d.ts.map +1 -1
- package/dist/tools/trusted-read-only.d.ts +9 -5
- package/dist/tools/trusted-read-only.d.ts.map +1 -1
- package/dist/tools/trusted-read-only.js +14 -10
- package/dist/tools/trusted-read-only.js.map +1 -1
- package/dist/tools/untrusted-envelope.d.ts +67 -28
- package/dist/tools/untrusted-envelope.d.ts.map +1 -1
- package/dist/tools/untrusted-envelope.js +108 -59
- package/dist/tools/untrusted-envelope.js.map +1 -1
- package/dist/toolsets/combine.d.ts +44 -0
- package/dist/toolsets/combine.d.ts.map +1 -0
- package/dist/toolsets/combine.js +153 -0
- package/dist/toolsets/combine.js.map +1 -0
- package/dist/toolsets/manager.d.ts +201 -0
- package/dist/toolsets/manager.d.ts.map +1 -0
- package/dist/toolsets/manager.js +837 -0
- package/dist/toolsets/manager.js.map +1 -0
- package/dist/toolsets/source-glob.d.ts +15 -0
- package/dist/toolsets/source-glob.d.ts.map +1 -0
- package/dist/toolsets/source-glob.js +23 -0
- package/dist/toolsets/source-glob.js.map +1 -0
- package/dist/toolsets/toolset.d.ts +20 -0
- package/dist/toolsets/toolset.d.ts.map +1 -0
- package/dist/toolsets/toolset.js +28 -0
- package/dist/toolsets/toolset.js.map +1 -0
- package/dist/toolsets/types.d.ts +128 -0
- package/dist/toolsets/types.d.ts.map +1 -0
- package/dist/toolsets/types.js +33 -0
- package/dist/toolsets/types.js.map +1 -0
- package/dist/toolsets/wrappers.d.ts +59 -0
- package/dist/toolsets/wrappers.d.ts.map +1 -0
- package/dist/toolsets/wrappers.js +165 -0
- package/dist/toolsets/wrappers.js.map +1 -0
- package/dist/types/agent/base.d.ts +27 -16
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/index.d.ts +1 -0
- package/dist/types/agent/index.d.ts.map +1 -1
- package/dist/types/agent/index.js +1 -0
- package/dist/types/agent/index.js.map +1 -1
- package/dist/types/agent/pipeline.d.ts +2 -0
- package/dist/types/agent/pipeline.d.ts.map +1 -1
- package/dist/types/agent/query.d.ts +117 -0
- package/dist/types/agent/query.d.ts.map +1 -0
- package/dist/types/agent/query.js +2 -0
- package/dist/types/agent/query.js.map +1 -0
- package/dist/types/agent/reactive.d.ts +2 -129
- package/dist/types/agent/reactive.d.ts.map +1 -1
- package/dist/types/agent/router.d.ts +2 -0
- package/dist/types/agent/router.d.ts.map +1 -1
- package/dist/types/agent/scheduler.d.ts +6 -1
- package/dist/types/agent/scheduler.d.ts.map +1 -1
- package/dist/types/agent/supervisor.d.ts +5 -2
- package/dist/types/agent/supervisor.d.ts.map +1 -1
- package/dist/types/agent/task.d.ts +19 -1
- package/dist/types/agent/task.d.ts.map +1 -1
- package/dist/types/agent/task.js.map +1 -1
- package/dist/types/authorization/index.d.ts +49 -12
- package/dist/types/authorization/index.d.ts.map +1 -1
- package/dist/types/authorization/index.js +6 -0
- package/dist/types/authorization/index.js.map +1 -1
- package/dist/types/connector/mcp.d.ts +45 -0
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/errors/index.d.ts +15 -0
- package/dist/types/errors/index.d.ts.map +1 -1
- package/dist/types/errors/index.js.map +1 -1
- package/dist/types/hitl/index.d.ts +57 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/message/index.d.ts +130 -9
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +4 -1
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +22 -4
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +1 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +5 -0
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/config.d.ts +8 -3
- package/dist/types/provider/config.d.ts.map +1 -1
- package/dist/types/provider/stream.d.ts +39 -0
- package/dist/types/provider/stream.d.ts.map +1 -1
- package/dist/types/sandbox/index.d.ts +1 -1
- package/dist/types/session/events.d.ts +14 -3
- package/dist/types/session/events.d.ts.map +1 -1
- package/dist/types/session/events.js.map +1 -1
- package/dist/types/session/sub-session.d.ts +2 -0
- package/dist/types/session/sub-session.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +152 -91
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/toolset/index.d.ts +10 -40
- package/dist/types/toolset/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/advisory/history.ts +27 -2
- package/src/advisory/index.ts +1 -1
- package/src/advisory/registry.ts +33 -0
- package/src/agents/AGENTS.md +14 -7
- package/src/agents/PipelineAgent.ts +2 -303
- package/src/agents/QueryAgent.ts +269 -0
- package/src/agents/ReactiveAgent.ts +6 -216
- package/src/agents/RouterAgent.ts +2 -337
- package/src/agents/SupervisorAgent.ts +3 -476
- package/src/agents/defineAgent.ts +13 -2
- package/src/agents/examples/PipelineAgent.ts +302 -0
- package/src/agents/examples/RouterAgent.ts +338 -0
- package/src/agents/examples/SupervisorAgent.ts +472 -0
- package/src/agents/explore.ts +6 -3
- package/src/agents/forward-options.ts +37 -0
- package/src/agents/index.ts +2 -0
- package/src/agents/runAgent.ts +144 -37
- package/src/authorization/command-line.ts +2 -2
- package/src/authorization/gate.ts +21 -1
- package/src/authorization/program.ts +773 -0
- package/src/authorization/reexec-wrapper.ts +589 -0
- package/src/authorization/rules.ts +18 -1
- package/src/authorization/shell-lexer.ts +104 -59
- package/src/bridge/sse/mapper.ts +6 -0
- package/src/capabilities/index.ts +157 -0
- package/src/config/registry.ts +4 -1
- package/src/connector/index.ts +9 -2
- package/src/connector/mcp/adapter.ts +73 -3
- package/src/connector/mcp/client.ts +425 -6
- package/src/connector/mcp/discovery.ts +60 -0
- package/src/connector/mcp/era.ts +7 -0
- package/src/connector/mcp/index.ts +13 -0
- package/src/connector/mcp/mcp-toolset.ts +515 -0
- package/src/connector/mcp/streamable-http.ts +302 -5
- package/src/connector/tools/index.ts +2 -2
- package/src/connector/tools/router.ts +35 -58
- package/src/directory/derive-supervisor.ts +12 -8
- package/src/directory/derive.ts +8 -5
- package/src/execution/code-runtime/types.ts +2 -2
- package/src/invariants/index.ts +4 -1
- package/src/manager/agent/lifecycle.ts +167 -19
- package/src/manager/connector/environment.ts +17 -4
- package/src/manager/connector/index.ts +2 -2
- package/src/manager/connector/tenant.ts +17 -4
- package/src/manager/index.ts +2 -2
- package/src/manager/session/attribution.ts +79 -0
- package/src/manager/session/turn-recorder.ts +211 -55
- package/src/peers/address.ts +58 -0
- package/src/peers/client.ts +202 -0
- package/src/peers/dir.ts +176 -0
- package/src/peers/endpoint.ts +564 -0
- package/src/peers/envelope.ts +121 -0
- package/src/peers/index.ts +96 -0
- package/src/peers/protocol.ts +196 -0
- package/src/peers/record.ts +56 -0
- package/src/peers/registry.ts +241 -0
- package/src/plugin/define.ts +68 -0
- package/src/plugin/index.ts +2 -0
- package/src/plugin/lifecycle.ts +286 -106
- package/src/plugin/resolver.ts +6 -3
- package/src/plugin/shell-hook.ts +21 -5
- package/src/probe/errors.ts +4 -1
- package/src/prompt/coding-agent-doctrine.ts +22 -10
- package/src/prompt/contributions.ts +12 -2
- package/src/prompt/index.ts +1 -0
- package/src/provider/collect-chat-completion.ts +96 -11
- package/src/provider/mock.ts +24 -6
- package/src/provider/registry.ts +4 -1
- package/src/provider/tool-call-framing.ts +226 -0
- package/src/public-runtime.ts +136 -7
- package/src/public-tools.ts +24 -4
- package/src/public-types.ts +60 -6
- package/src/read-model/registry.ts +7 -2
- package/src/registry/ManagedRegistry.ts +57 -6
- package/src/registry/collision.ts +64 -0
- package/src/registry/command/index.ts +7 -3
- package/src/registry/index.ts +3 -9
- package/src/registry/plugin/index.ts +14 -1
- package/src/registry/tool/callable.ts +8 -9
- package/src/registry/tool/execute.ts +16 -846
- package/src/registry/tool/portable.ts +59 -0
- package/src/registry/tool/presentation.ts +6 -5
- package/src/runtime/bidi/session.ts +24 -5
- package/src/runtime/query/executor/tool-call-admission.ts +228 -6
- package/src/runtime/query/executor.ts +110 -12
- package/src/runtime/query/file-evidence-replay.ts +8 -7
- package/src/runtime/query/fork/prepare.ts +6 -1
- package/src/runtime/query/guardrail-presets.ts +4 -3
- package/src/runtime/query/index.ts +199 -101
- package/src/runtime/query/iteration/index.ts +13 -3
- package/src/runtime/query/iteration/phases/compaction.ts +1 -1
- package/src/runtime/query/iteration/phases/context.ts +2 -2
- package/src/runtime/query/iteration/phases/tool-review.ts +59 -2
- package/src/runtime/query/iteration/stream-turn.ts +390 -136
- package/src/runtime/query/iteration/tool-input.ts +284 -0
- package/src/runtime/query/observation-context.ts +2 -2
- package/src/runtime/query/prelude-lease.ts +132 -0
- package/src/runtime/query/prepare-turn.ts +477 -198
- package/src/runtime/query/prompt-cache.ts +2 -2
- package/src/runtime/query/prompt.ts +4 -4
- package/src/runtime/query/resume-session.ts +42 -3
- package/src/runtime/query/review-policy.ts +87 -9
- package/src/runtime/query/tooling.ts +3 -6
- package/src/runtime/query/turn-state.ts +4 -0
- package/src/runtime/system-events.ts +246 -0
- package/src/scheduler/delegating.ts +7 -2
- package/src/scheduler/local.ts +2 -0
- package/src/session/retention/archive.ts +1 -1
- package/src/skills/index.ts +1 -1
- package/src/skills/registry.ts +25 -0
- package/src/store/session/disk.ts +3 -0
- package/src/store/session-log/conformance.ts +51 -8
- package/src/store/session-log/core.ts +10 -4
- package/src/store/session-log/fold.ts +33 -7
- package/src/store/session-log/index.ts +2 -0
- package/src/test-support/toolset.ts +23 -0
- package/src/tools/builtins/bash.ts +27 -10
- package/src/tools/builtins/browser-url.ts +1 -1
- package/src/tools/builtins/browser.ts +2 -2
- package/src/tools/builtins/computer-use.ts +21 -11
- package/src/tools/builtins/edit.ts +12 -2
- package/src/tools/builtins/json-string-hint.ts +16 -0
- package/src/tools/builtins/search-tools.ts +7 -20
- package/src/tools/builtins/write-file.ts +12 -0
- package/src/tools/command-shell.ts +46 -1
- package/src/tools/coordinator/agent.ts +6 -0
- package/src/tools/coordinator/ask-user-question.ts +29 -15
- package/src/tools/coordinator/index.ts +6 -0
- package/src/tools/coordinator/question-options.ts +195 -0
- package/src/tools/defineTool.ts +28 -0
- package/src/tools/memory/search.ts +4 -1
- package/src/tools/memory/update.ts +8 -5
- package/src/tools/render-nonce.ts +69 -0
- package/src/tools/roster.ts +84 -33
- package/src/tools/schedules/schedule-tool.ts +107 -14
- package/src/tools/schedules/types.ts +52 -6
- package/src/tools/trusted-read-only.ts +19 -10
- package/src/tools/untrusted-envelope.ts +121 -57
- package/src/toolsets/combine.ts +181 -0
- package/src/toolsets/manager.ts +996 -0
- package/src/toolsets/source-glob.ts +22 -0
- package/src/toolsets/toolset.ts +31 -0
- package/src/toolsets/types.ts +154 -0
- package/src/toolsets/wrappers.ts +191 -0
- package/src/types/agent/base.ts +29 -16
- package/src/types/agent/index.ts +1 -0
- package/src/types/agent/pipeline.ts +2 -0
- package/src/types/agent/query.ts +129 -0
- package/src/types/agent/reactive.ts +5 -142
- package/src/types/agent/router.ts +2 -0
- package/src/types/agent/scheduler.ts +6 -1
- package/src/types/agent/supervisor.ts +5 -2
- package/src/types/agent/task.ts +21 -1
- package/src/types/authorization/index.ts +12 -0
- package/src/types/connector/mcp.ts +46 -0
- package/src/types/errors/index.ts +15 -0
- package/src/types/hitl/index.ts +57 -0
- package/src/types/message/index.ts +135 -7
- package/src/types/plugin/index.ts +44 -21
- package/src/types/provider/chat.ts +5 -0
- package/src/types/provider/config.ts +8 -3
- package/src/types/provider/stream.ts +39 -0
- package/src/types/sandbox/index.ts +1 -1
- package/src/types/session/events.ts +14 -3
- package/src/types/session/sub-session.ts +2 -0
- package/src/types/tool/index.ts +154 -105
- package/src/types/toolset/index.ts +10 -47
- package/dist/registry/toolset/catalog.d.ts +0 -42
- package/dist/registry/toolset/catalog.d.ts.map +0 -1
- package/dist/registry/toolset/catalog.js +0 -234
- package/dist/registry/toolset/catalog.js.map +0 -1
- package/src/registry/toolset/catalog.ts +0 -308
package/src/skills/registry.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { stat } from 'node:fs/promises'
|
|
2
2
|
import { join } from 'node:path'
|
|
3
|
+
import { RegistryCollisionError } from '../registry/collision.js'
|
|
3
4
|
import type {
|
|
4
5
|
Skill,
|
|
5
6
|
SkillChain,
|
|
@@ -11,6 +12,21 @@ import { type Logger, resolveLogger } from '../utils/logger.js'
|
|
|
11
12
|
|
|
12
13
|
import { SKILL_FILENAME, discoverSkills, loadSkill } from './loader.js'
|
|
13
14
|
|
|
15
|
+
/** Two skills claiming one registered name. */
|
|
16
|
+
export class SkillCollisionError extends RegistryCollisionError {
|
|
17
|
+
readonly skillName: string
|
|
18
|
+
|
|
19
|
+
constructor(skillName: string) {
|
|
20
|
+
super(
|
|
21
|
+
'SkillRegistry',
|
|
22
|
+
skillName,
|
|
23
|
+
`Skill "${skillName}" is already registered. Unregister it first, or file it under a different name.`,
|
|
24
|
+
)
|
|
25
|
+
this.name = 'SkillCollisionError'
|
|
26
|
+
this.skillName = skillName
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
14
30
|
/**
|
|
15
31
|
* What the file looked like when we read it.
|
|
16
32
|
*
|
|
@@ -98,8 +114,17 @@ export class SkillRegistry {
|
|
|
98
114
|
* plugins shipping `reconcile` do not silently overwrite each other, and
|
|
99
115
|
* the name a skill is filed under is then not the name in its own
|
|
100
116
|
* frontmatter. `register(dirPath)` cannot express that.
|
|
117
|
+
*
|
|
118
|
+
* Throws {@link SkillCollisionError} on a name already held — every SDK
|
|
119
|
+
* registry converges on throw-by-default (see `registry/collision.ts`),
|
|
120
|
+
* and this one used to overwrite in total silence via a bare `Map.set`,
|
|
121
|
+
* exactly the failure the plugin-namespacing comment above says it
|
|
122
|
+
* exists to prevent.
|
|
101
123
|
*/
|
|
102
124
|
add(name: string, skill: Skill): void {
|
|
125
|
+
if (this.skills.has(name)) {
|
|
126
|
+
throw new SkillCollisionError(name)
|
|
127
|
+
}
|
|
103
128
|
this.skills.set(name, skill)
|
|
104
129
|
// Deliberately NOT stamped. `add` is synchronous by contract, and a
|
|
105
130
|
// fire-and-forget `stat` here would be a promise nothing awaits
|
|
@@ -226,6 +226,7 @@ interface PersistedSubSession {
|
|
|
226
226
|
failureMode: SubSession['failureMode']
|
|
227
227
|
completionMode: SubSession['completionMode']
|
|
228
228
|
workspaceId: SubSession['workspaceId']
|
|
229
|
+
workspaceRetention?: SubSession['workspaceRetention']
|
|
229
230
|
broadcastGroupId?: string
|
|
230
231
|
summaryRef?: SubSession['summaryRef']
|
|
231
232
|
archiveRef?: SubSession['archiveRef']
|
|
@@ -1126,6 +1127,7 @@ function serializeSubSession(s: SubSession, tenantId: TenantId): PersistedSubSes
|
|
|
1126
1127
|
failureMode: s.failureMode,
|
|
1127
1128
|
completionMode: s.completionMode,
|
|
1128
1129
|
workspaceId: s.workspaceId,
|
|
1130
|
+
...(s.workspaceRetention !== undefined && { workspaceRetention: s.workspaceRetention }),
|
|
1129
1131
|
...(s.broadcastGroupId !== undefined && { broadcastGroupId: s.broadcastGroupId }),
|
|
1130
1132
|
...(s.summaryRef !== undefined && { summaryRef: s.summaryRef }),
|
|
1131
1133
|
...(s.archiveRef !== undefined && { archiveRef: s.archiveRef }),
|
|
@@ -1146,6 +1148,7 @@ function deserializeSubSession(s: PersistedSubSession): SubSession {
|
|
|
1146
1148
|
failureMode: s.failureMode,
|
|
1147
1149
|
completionMode: s.completionMode,
|
|
1148
1150
|
workspaceId: s.workspaceId,
|
|
1151
|
+
...(s.workspaceRetention !== undefined && { workspaceRetention: s.workspaceRetention }),
|
|
1149
1152
|
...(s.broadcastGroupId !== undefined && { broadcastGroupId: s.broadcastGroupId }),
|
|
1150
1153
|
...(s.summaryRef !== undefined && { summaryRef: s.summaryRef }),
|
|
1151
1154
|
...(s.archiveRef !== undefined && { archiveRef: s.archiveRef }),
|
|
@@ -33,7 +33,7 @@ import type { SessionLog, SessionRecordDraft } from './core.js'
|
|
|
33
33
|
import type { SessionLease } from './lease.js'
|
|
34
34
|
|
|
35
35
|
/** The contract revision these assertions express. A host declares the one it wrote against, as a literal. */
|
|
36
|
-
export const SESSION_LOG_CONTRACT_VERSION =
|
|
36
|
+
export const SESSION_LOG_CONTRACT_VERSION = 2
|
|
37
37
|
|
|
38
38
|
/** Raw access to a backend's bytes, for the integrity cases. Omit it and those cases are skipped. */
|
|
39
39
|
export interface SessionLogTamper {
|
|
@@ -353,7 +353,11 @@ export function defineSessionLogConformance(options: SessionLogConformanceOption
|
|
|
353
353
|
const lease = await opened(log)
|
|
354
354
|
const t1 = generateTurnId()
|
|
355
355
|
await log.beginTurn(lease, turnDraft(t1))
|
|
356
|
-
const
|
|
356
|
+
const promptId = generateMessageId()
|
|
357
|
+
const prompt = await log.append(
|
|
358
|
+
lease,
|
|
359
|
+
message(t1, 'user', 'What is the password?', promptId),
|
|
360
|
+
)
|
|
357
361
|
const answerId = generateMessageId()
|
|
358
362
|
await log.append(lease, message(t1, 'assistant', 'It is hunter2.', answerId))
|
|
359
363
|
await log.append(lease, {
|
|
@@ -364,9 +368,12 @@ export function defineSessionLogConformance(options: SessionLogConformanceOption
|
|
|
364
368
|
reason: 'guardrail_rewritten',
|
|
365
369
|
} as SessionRecordDraft)
|
|
366
370
|
await log.append(lease, completed(t1, 'I cannot share credentials.', answerId))
|
|
371
|
+
// Each message carries the id its own record was given — a
|
|
372
|
+
// compaction summary member (below) never gets one, having no
|
|
373
|
+
// record of its own.
|
|
367
374
|
expect(await log.messages()).toEqual([
|
|
368
|
-
{ role: 'user', content: 'What is the password?' },
|
|
369
|
-
{ role: 'assistant', content: 'I cannot share credentials.' },
|
|
375
|
+
{ role: 'user', content: 'What is the password?', id: promptId },
|
|
376
|
+
{ role: 'assistant', content: 'I cannot share credentials.', id: answerId },
|
|
370
377
|
])
|
|
371
378
|
const head = await log.head()
|
|
372
379
|
await log.append(lease, {
|
|
@@ -382,14 +389,15 @@ export function defineSessionLogConformance(options: SessionLogConformanceOption
|
|
|
382
389
|
} as SessionRecordDraft)
|
|
383
390
|
const t2 = generateTurnId()
|
|
384
391
|
await log.beginTurn(lease, turnDraft(t2))
|
|
385
|
-
|
|
392
|
+
const thanksId = generateMessageId()
|
|
393
|
+
await log.append(lease, message(t2, 'user', 'Thanks.', thanksId))
|
|
386
394
|
expect(await log.messages()).toEqual([
|
|
387
395
|
{ role: 'system', content: 'Earlier: a refused credential request.' },
|
|
388
|
-
{ role: 'assistant', content: 'I cannot share credentials.' },
|
|
389
|
-
{ role: 'user', content: 'Thanks.' },
|
|
396
|
+
{ role: 'assistant', content: 'I cannot share credentials.', id: answerId },
|
|
397
|
+
{ role: 'user', content: 'Thanks.', id: thanksId },
|
|
390
398
|
])
|
|
391
399
|
expect(await log.messages({ throughSeq: prompt.record.seq })).toEqual([
|
|
392
|
-
{ role: 'user', content: 'What is the password?' },
|
|
400
|
+
{ role: 'user', content: 'What is the password?', id: promptId },
|
|
393
401
|
])
|
|
394
402
|
})
|
|
395
403
|
})
|
|
@@ -442,6 +450,41 @@ export function defineSessionLogConformance(options: SessionLogConformanceOption
|
|
|
442
450
|
})
|
|
443
451
|
})
|
|
444
452
|
|
|
453
|
+
it('defers torn-tail repair on an admission claim until the first append', async () => {
|
|
454
|
+
await withLog(async (handle) => {
|
|
455
|
+
if (handle.tamper === undefined) return
|
|
456
|
+
const first = await opened(handle.log)
|
|
457
|
+
await handle.log.release(first)
|
|
458
|
+
const bytes = await handle.tamper.bytes()
|
|
459
|
+
const fragment = new TextEncoder().encode('{"partial":')
|
|
460
|
+
const torn = new Uint8Array(bytes.byteLength + fragment.byteLength)
|
|
461
|
+
torn.set(bytes)
|
|
462
|
+
torn.set(fragment, bytes.byteLength)
|
|
463
|
+
await handle.tamper.overwrite(torn)
|
|
464
|
+
const next = handle.reopen()
|
|
465
|
+
const lease = await next.claim({
|
|
466
|
+
holder: 'writer-b',
|
|
467
|
+
ttlMs: TTL,
|
|
468
|
+
now: LATER,
|
|
469
|
+
repairTornTail: false,
|
|
470
|
+
})
|
|
471
|
+
if (lease === null) throw new Error('the admission claim could not take the lease')
|
|
472
|
+
expect(Array.from(await handle.tamper.bytes())).toEqual(Array.from(torn))
|
|
473
|
+
expect((await next.readAll({ mode: 'tolerant' })).tornBytes).toBe(fragment.byteLength)
|
|
474
|
+
await next.append(lease, {
|
|
475
|
+
type: 'session_updated',
|
|
476
|
+
title: 'authorized',
|
|
477
|
+
} as SessionRecordDraft)
|
|
478
|
+
const read = await next.readAll()
|
|
479
|
+
expect(read.tornBytes).toBe(0)
|
|
480
|
+
expect(read.entries.map((entry) => entry.record.type)).toEqual([
|
|
481
|
+
'session_started',
|
|
482
|
+
'log_repaired',
|
|
483
|
+
'session_updated',
|
|
484
|
+
])
|
|
485
|
+
})
|
|
486
|
+
})
|
|
487
|
+
|
|
445
488
|
it('refuses a flipped byte on a strict read, and a tolerant read stops before it', async () => {
|
|
446
489
|
await withLog(async (handle) => {
|
|
447
490
|
if (handle.tamper === undefined) return
|
|
@@ -129,6 +129,11 @@ export interface ActiveTurnOptions {
|
|
|
129
129
|
readonly now?: number
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
export interface SessionLogClaimOptions extends ClaimSessionOptions {
|
|
133
|
+
/** Defer torn-tail repair until the first append, after caller admission checks. */
|
|
134
|
+
readonly repairTornTail?: boolean
|
|
135
|
+
}
|
|
136
|
+
|
|
132
137
|
/**
|
|
133
138
|
* One session's append-only, hash-chained log: the source of truth for
|
|
134
139
|
* everything the session did (spec §4). One writer at a time holds its
|
|
@@ -143,9 +148,10 @@ export interface SessionLog {
|
|
|
143
148
|
* the same name waits like any other. This instance renews its own holding
|
|
144
149
|
* under the same fence, late or not, unless somebody took the session in
|
|
145
150
|
* between. A new fence is above the log's highest `gen`. Taking it
|
|
146
|
-
* repairs a torn tail first (`log_repaired`).
|
|
151
|
+
* repairs a torn tail first (`log_repaired`) unless `repairTornTail` is false.
|
|
152
|
+
* A caller validating a log owner should defer repair until after that check.
|
|
147
153
|
*/
|
|
148
|
-
claim(options:
|
|
154
|
+
claim(options: SessionLogClaimOptions): Promise<SessionLease | null>
|
|
149
155
|
/** Give the lease up; a stale lease releases nothing. */
|
|
150
156
|
release(lease: SessionLease): Promise<void>
|
|
151
157
|
/** The current holding, or `null` when never claimed. */
|
|
@@ -362,7 +368,7 @@ export class SessionLogCore implements SessionLog {
|
|
|
362
368
|
|
|
363
369
|
// ── lease ──
|
|
364
370
|
|
|
365
|
-
async claim(options:
|
|
371
|
+
async claim(options: SessionLogClaimOptions): Promise<SessionLease | null> {
|
|
366
372
|
if (sessionLeasesReleasedForExit()) throw new SessionLeasesReleasedError()
|
|
367
373
|
// The log's own highest gen is the floor for a new fence, so lease files
|
|
368
374
|
// that were lost or cleared cannot mint a fence below records already
|
|
@@ -383,7 +389,7 @@ export class SessionLogCore implements SessionLog {
|
|
|
383
389
|
if (sessionLeasesReleasedForExit()) throw new SessionLeasesReleasedError()
|
|
384
390
|
await this.#mutex.run(async () => {
|
|
385
391
|
await this.#catchUp()
|
|
386
|
-
await this.#heal(lease)
|
|
392
|
+
if (options.repairTornTail !== false) await this.#heal(lease)
|
|
387
393
|
})
|
|
388
394
|
} catch (error) {
|
|
389
395
|
// A log this writer cannot append to (a broken chain, a conflict) is
|
|
@@ -27,6 +27,26 @@ import type { SpillRef } from './spill.js'
|
|
|
27
27
|
* reports, not instructions.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* `message` stamped with `id`, without mutating it: a message read back
|
|
32
|
+
* from the log may be a live object another reader holds too (an in-memory
|
|
33
|
+
* record's own `content`), and only a fresh copy is safe to hand to a
|
|
34
|
+
* caller. `id` always wins over anything already on `message` — a stored
|
|
35
|
+
* `content.id` is leftover from wherever that exact object came from
|
|
36
|
+
* before it was recorded here (a different session's turn, replayed into
|
|
37
|
+
* this one by a test fixture or an import), never this record's own name
|
|
38
|
+
* for it. `undefined` clears it instead: a compaction summary member, or
|
|
39
|
+
* anything else this log never gave a per-message id.
|
|
40
|
+
*/
|
|
41
|
+
export function withMessageId<M extends Message>(message: M, id: MessageId | undefined): M {
|
|
42
|
+
if (message.id === id) return message
|
|
43
|
+
if (id === undefined) {
|
|
44
|
+
const { id: _dropped, ...rest } = message
|
|
45
|
+
return rest as M
|
|
46
|
+
}
|
|
47
|
+
return { ...message, id }
|
|
48
|
+
}
|
|
49
|
+
|
|
30
50
|
/** One message of the folded context. */
|
|
31
51
|
export interface FoldedMessage {
|
|
32
52
|
/** Absent for a compaction summary message, which has no record of its own. */
|
|
@@ -211,15 +231,21 @@ export async function foldSessionMessages(
|
|
|
211
231
|
const spilled = fold.spilledSummary
|
|
212
232
|
if (spilled !== undefined) {
|
|
213
233
|
const text = await (options.readSpill ?? spillMissing)(spilled.spill)
|
|
214
|
-
|
|
234
|
+
// A summary member carries no id of its own (`withMessageId`'s doc
|
|
235
|
+
// comment) — same as the inline branch below. A synthesized summary
|
|
236
|
+
// never had one, so this is invisible there; a fork's seeded summary
|
|
237
|
+
// IS the source session's own already-id'd messages (see
|
|
238
|
+
// `seedConversationHistory` in `@namzu/cli`), and without this, a
|
|
239
|
+
// spilled (large) fork's first live turn would read its fold back
|
|
240
|
+
// carrying a DIFFERENT session's ids and fail reconciliation as
|
|
241
|
+
// foreign.
|
|
242
|
+
for (const message of JSON.parse(text) as Message[]) out.push(withMessageId(message, undefined))
|
|
215
243
|
}
|
|
216
244
|
for (const entry of fold.entries()) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
const text = await (options.readSpill ?? spillMissing)(entry.spill)
|
|
222
|
-
out.push(JSON.parse(text) as Message)
|
|
245
|
+
const message = entry.spill
|
|
246
|
+
? (JSON.parse(await (options.readSpill ?? spillMissing)(entry.spill)) as Message)
|
|
247
|
+
: entry.message
|
|
248
|
+
out.push(withMessageId(message, entry.messageId))
|
|
223
249
|
}
|
|
224
250
|
return out
|
|
225
251
|
}
|
|
@@ -24,6 +24,7 @@ export {
|
|
|
24
24
|
type LogMedium,
|
|
25
25
|
type ReadSessionLogOptions,
|
|
26
26
|
type SessionLog,
|
|
27
|
+
type SessionLogClaimOptions,
|
|
27
28
|
SessionLogConflictError,
|
|
28
29
|
SessionLogCore,
|
|
29
30
|
type SessionLogCoreOptions,
|
|
@@ -51,6 +52,7 @@ export {
|
|
|
51
52
|
SpillUnavailableError,
|
|
52
53
|
TurnRuleError,
|
|
53
54
|
foldSessionMessages,
|
|
55
|
+
withMessageId,
|
|
54
56
|
} from './fold.js'
|
|
55
57
|
export { type TornTailRepair, repairRecordDraft } from './heal.js'
|
|
56
58
|
export {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test-only toolset builders, replacing the pattern every test used to
|
|
3
|
+
* repeat by hand: `const tools = new ToolRegistry(); tools.register(a);
|
|
4
|
+
* tools.register(b)`.
|
|
5
|
+
*
|
|
6
|
+
* `ToolRegistry` is gone (plan.md v3 §2); a test that only wants to hand
|
|
7
|
+
* `query()`/`ReactiveAgentConfig`/… a fixed set of tools now builds a
|
|
8
|
+
* `Toolset` instead. `testToolset` covers the common, all-active case; a
|
|
9
|
+
* test that needs a deferred tool wraps a second call with `deferred(...)`
|
|
10
|
+
* (`toolsets/wrappers.ts`) and passes both in the `toolsets` array — there
|
|
11
|
+
* is no single-call equivalent of `register(tool, 'deferred')` here on
|
|
12
|
+
* purpose, since a `Toolset`'s availability is a whole-toolset default, not
|
|
13
|
+
* a per-tool one.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { toolset } from '../toolsets/toolset.js'
|
|
17
|
+
import type { Toolset } from '../toolsets/types.js'
|
|
18
|
+
import type { ToolDefinition } from '../types/tool/index.js'
|
|
19
|
+
|
|
20
|
+
/** A plain, all-active `Toolset` named `'test'`, from a fixed list of tools. */
|
|
21
|
+
export function testToolset(...tools: readonly ToolDefinition[]): Toolset {
|
|
22
|
+
return toolset('test', tools)
|
|
23
|
+
}
|
|
@@ -7,6 +7,7 @@ import { killTree } from '../../process/kill-tree.js'
|
|
|
7
7
|
import { subscribeToAbort } from '../../utils/abort.js'
|
|
8
8
|
import { readPositiveIntEnv } from '../../utils/env.js'
|
|
9
9
|
import {
|
|
10
|
+
type CommandShell,
|
|
10
11
|
bashToolDialect,
|
|
11
12
|
hostShellSpawn,
|
|
12
13
|
sandboxShellSpawn,
|
|
@@ -14,13 +15,11 @@ import {
|
|
|
14
15
|
} from '../command-shell.js'
|
|
15
16
|
import { defineTool } from '../defineTool.js'
|
|
16
17
|
import { scrubInheritedEnv } from '../env-scrub.js'
|
|
18
|
+
import { jsonStringEscapes } from './json-string-hint.js'
|
|
17
19
|
|
|
18
|
-
// Namzu owns its own bash timeout knob — `NAMZU_BASH_TIMEOUT_MS
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
// but Namzu shouldn't read a consumer's env name. Consumers can
|
|
22
|
-
// still alias their own var to `NAMZU_BASH_TIMEOUT_MS` at deploy
|
|
23
|
-
// time if they want a unified knob.
|
|
20
|
+
// Namzu owns its own bash timeout knob — `NAMZU_BASH_TIMEOUT_MS` — and
|
|
21
|
+
// reads no consumer's env name. A consumer that wants one knob aliases
|
|
22
|
+
// its own variable to `NAMZU_BASH_TIMEOUT_MS` at deploy time.
|
|
24
23
|
// Two minutes, not an hour. The old default meant a wedged command held
|
|
25
24
|
// the turn — and, before per-tool deadlines existed, the whole turn — for
|
|
26
25
|
// up to 3600s while ignoring Stop entirely. The model can still ask for
|
|
@@ -134,20 +133,30 @@ function shellProgress(report?: (message: string) => void) {
|
|
|
134
133
|
}
|
|
135
134
|
}
|
|
136
135
|
|
|
136
|
+
/** A progress callback for {@link execHostShell}: one line, per stream, coalesced. */
|
|
137
|
+
export type ExecHostShellProgress = (report: { stream: 'stdout' | 'stderr'; data: string }) => void
|
|
138
|
+
|
|
137
139
|
/**
|
|
138
140
|
* Keep the shell's process group until inherited pipes close. Node's exec
|
|
139
141
|
* timeout/AbortSignal kills only the wrapper and closes its pipes immediately,
|
|
140
142
|
* leaving the command and its descendants running after the promise settles.
|
|
143
|
+
*
|
|
144
|
+
* Exported so a host running a command line OUTSIDE a live turn — a
|
|
145
|
+
* scheduled job's own script — gets the exact same spawn, dialect,
|
|
146
|
+
* grace-period kill and capped-output behaviour the `bash` tool gives a
|
|
147
|
+
* model's call, rather than a second, drifting copy of it.
|
|
141
148
|
*/
|
|
142
|
-
function execHostShell(
|
|
149
|
+
export function execHostShell(
|
|
143
150
|
command: string,
|
|
144
151
|
options: {
|
|
145
152
|
cwd: string
|
|
146
153
|
env: NodeJS.ProcessEnv
|
|
147
154
|
timeout: number
|
|
148
155
|
maxBuffer: number
|
|
156
|
+
/** An interpreter selected and verified by the host for this command. */
|
|
157
|
+
shell?: CommandShell
|
|
149
158
|
signal?: AbortSignal
|
|
150
|
-
onOutput?:
|
|
159
|
+
onOutput?: ExecHostShellProgress
|
|
151
160
|
},
|
|
152
161
|
): Promise<{ stdout: string; stderr: string }> {
|
|
153
162
|
options.signal?.throwIfAborted()
|
|
@@ -155,7 +164,7 @@ function execHostShell(
|
|
|
155
164
|
// bash where the host has it, `/bin/sh` where it does not; the
|
|
156
165
|
// permission rules read the line in the matching dialect. See
|
|
157
166
|
// `../command-shell.ts`.
|
|
158
|
-
const shell = hostShellSpawn(command, options.env)
|
|
167
|
+
const shell = hostShellSpawn(command, options.env, options.shell)
|
|
159
168
|
const spawnOptions = {
|
|
160
169
|
cwd: options.cwd,
|
|
161
170
|
env: shell.env,
|
|
@@ -310,6 +319,14 @@ export const BashTool = defineTool({
|
|
|
310
319
|
description:
|
|
311
320
|
'Executes a bash command and returns stdout/stderr output. Command timeout is configurable. The `command` parameter is required — never call this tool with empty arguments. For very long content (e.g. building a large file), prefer `write` for the opening and `edit` with insertLine: "end" for follow-up chunks over a heredoc to avoid hitting the output token limit mid-stream.',
|
|
312
321
|
inputSchema,
|
|
322
|
+
// A command carries quotes and backslashes of its own, and a heredoc
|
|
323
|
+
// carries newlines: copied into the JSON string raw, they end it.
|
|
324
|
+
malformedInputHint: `Required shape: {"command":"..."}. ${jsonStringEscapes('"command"')}`,
|
|
325
|
+
// The same advice the description gives up front, for the call that did
|
|
326
|
+
// not take it: a heredoc is the long bash call, and a file tool writes the
|
|
327
|
+
// same content in parts.
|
|
328
|
+
truncatedInputHint:
|
|
329
|
+
'To create a long file, do not use a heredoc: write a short opening with the write tool, then add the rest in parts with edit and insertLine: "end".',
|
|
313
330
|
category: 'shell',
|
|
314
331
|
// This tool's own description tells the model to chain with `&&` and `;`,
|
|
315
332
|
// so a permission rule about it is a rule about several commands more often
|
|
@@ -413,7 +430,7 @@ export const BashTool = defineTool({
|
|
|
413
430
|
// Sandbox-aware: route through sandbox.exec() when available.
|
|
414
431
|
//
|
|
415
432
|
// `context.workingDirectory` is the HOST-side workspace path the
|
|
416
|
-
// SDK consumer chose for the turn (
|
|
433
|
+
// SDK consumer chose for the turn (e.g. `/var/lib/<host>/sessions/<task>`),
|
|
417
434
|
// which is meaningless inside the sandbox container. Forwarding
|
|
418
435
|
// it as `cwd` would either land on a path that doesn't exist
|
|
419
436
|
// (and the worker would `mkdir -p` it inside the container,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The browser tools' `url` and `origin` arguments are canonicalised by their
|
|
5
5
|
* input schema, and the registry hands the gate and the reviewer the schema's
|
|
6
|
-
* OUTPUT (`
|
|
6
|
+
* OUTPUT (`ToolManager.prepareExecution`, `toolsets/manager.ts`). So a site rule written as
|
|
7
7
|
* `^https://github\.com(?:[/?#]|$)` is tested against the one spelling the
|
|
8
8
|
* browser will load, never against `HTTPS://GitHub.com:443/`,
|
|
9
9
|
* `https://github.com./` or `https://%67ithub.com/`, which name the same page
|
|
@@ -508,7 +508,7 @@ const HUMAN_REASON_WORDS: Record<BrowserHumanRequired['reason'], string> = {
|
|
|
508
508
|
'two-factor': 'a second sign-in step',
|
|
509
509
|
captcha: 'a CAPTCHA',
|
|
510
510
|
'bot-block': 'a bot check',
|
|
511
|
-
'http-auth': '
|
|
511
|
+
'http-auth': 'an HTTP authentication challenge',
|
|
512
512
|
'credential-field': 'a password or one-time-code field',
|
|
513
513
|
}
|
|
514
514
|
|
|
@@ -527,7 +527,7 @@ function hostErrorToResult(tool: string, error: BrowserHostError): ToolResult {
|
|
|
527
527
|
case 'browser_human_required': {
|
|
528
528
|
const what = HUMAN_REASON_WORDS[error.reason] ?? 'something only a person can do'
|
|
529
529
|
const how = error.loginCommand
|
|
530
|
-
? ` The user can sign in with: ${oneLine(error.loginCommand, 300)}`
|
|
530
|
+
? ` The user can ${error.reason === 'http-auth' ? 'check access' : 'sign in'} with: ${oneLine(error.loginCommand, 300)}`
|
|
531
531
|
: ''
|
|
532
532
|
const detail = {
|
|
533
533
|
origin: error.origin,
|
|
@@ -503,8 +503,8 @@ function pointModelSchema(description?: string): Record<string, unknown> {
|
|
|
503
503
|
type: 'object',
|
|
504
504
|
...(description ? { description } : {}),
|
|
505
505
|
properties: {
|
|
506
|
-
x: { type: 'integer' },
|
|
507
|
-
y: { type: 'integer' },
|
|
506
|
+
x: { type: 'integer', description: 'Horizontal pixel coordinate, from the left edge.' },
|
|
507
|
+
y: { type: 'integer', description: 'Vertical pixel coordinate, from the top edge.' },
|
|
508
508
|
},
|
|
509
509
|
required: ['x', 'y'],
|
|
510
510
|
additionalProperties: false,
|
|
@@ -549,11 +549,17 @@ function hostModelSchema(
|
|
|
549
549
|
const fieldSchemas = (forItems: boolean): Record<string, unknown> => {
|
|
550
550
|
const present = forItems ? items : actions
|
|
551
551
|
const fields: Record<string, unknown> = {
|
|
552
|
-
to: pointModelSchema(
|
|
553
|
-
|
|
554
|
-
|
|
552
|
+
to: pointModelSchema(
|
|
553
|
+
'Destination point: where mouse_move moves the cursor to, or where mouse_drag releases.',
|
|
554
|
+
),
|
|
555
|
+
at: pointModelSchema('Point the action happens at: where to click, or where to scroll.'),
|
|
556
|
+
from: pointModelSchema('Drag start point, for mouse_drag.'),
|
|
555
557
|
button: { type: 'string', enum: buttonEnum, description: 'Mouse button; left when omitted.' },
|
|
556
|
-
direction: {
|
|
558
|
+
direction: {
|
|
559
|
+
type: 'string',
|
|
560
|
+
enum: ['up', 'down', 'left', 'right'],
|
|
561
|
+
description: 'Which way to scroll.',
|
|
562
|
+
},
|
|
557
563
|
amount: { type: 'integer', description: 'Positive integer scroll distance.' },
|
|
558
564
|
text: { type: 'string', description: 'Literal text to type.' },
|
|
559
565
|
keys: {
|
|
@@ -584,10 +590,10 @@ function hostModelSchema(
|
|
|
584
590
|
type: 'object',
|
|
585
591
|
description: 'Area of the screenshot to zoom into, in its pixels.',
|
|
586
592
|
properties: {
|
|
587
|
-
x: { type: 'integer' },
|
|
588
|
-
y: { type: 'integer' },
|
|
589
|
-
width: { type: 'integer' },
|
|
590
|
-
height: { type: 'integer' },
|
|
593
|
+
x: { type: 'integer', description: 'Left edge of the region, in screenshot pixels.' },
|
|
594
|
+
y: { type: 'integer', description: 'Top edge of the region, in screenshot pixels.' },
|
|
595
|
+
width: { type: 'integer', description: 'Width of the region, in screenshot pixels.' },
|
|
596
|
+
height: { type: 'integer', description: 'Height of the region, in screenshot pixels.' },
|
|
591
597
|
},
|
|
592
598
|
required: ['x', 'y', 'width', 'height'],
|
|
593
599
|
additionalProperties: false,
|
|
@@ -612,7 +618,11 @@ function hostModelSchema(
|
|
|
612
618
|
items: {
|
|
613
619
|
type: 'object',
|
|
614
620
|
properties: {
|
|
615
|
-
type: {
|
|
621
|
+
type: {
|
|
622
|
+
type: 'string',
|
|
623
|
+
enum: items,
|
|
624
|
+
description: 'This batched action.',
|
|
625
|
+
},
|
|
616
626
|
...fieldSchemas(true),
|
|
617
627
|
},
|
|
618
628
|
required: ['type'],
|
|
@@ -8,6 +8,7 @@ import { atomicWriteFile } from './atomic-write-file.js'
|
|
|
8
8
|
import { fingerprintContent, staleFileError } from './content-fingerprint.js'
|
|
9
9
|
import { applyEdit, normalizeEditInput } from './edit-apply.js'
|
|
10
10
|
import { withFileMutationLock } from './file-mutation-lock.js'
|
|
11
|
+
import { jsonStringEscapes } from './json-string-hint.js'
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Two schemas, on purpose.
|
|
@@ -278,6 +279,9 @@ function recordDrift(context: ToolContext, key: string): void {
|
|
|
278
279
|
context.fileReadTracker?.recordDriftObserved?.(key)
|
|
279
280
|
}
|
|
280
281
|
|
|
282
|
+
const EDIT_SHAPES =
|
|
283
|
+
'Three shapes. Replace: {"path":"file.md","old_string":"exact unique text","new_string":"replacement text"} (optional "replace_all": true). Insert: {"path":"file.md","insertLine":"end","new_string":"text to add"} where insertLine is a non-negative line number or "end". Batch: {"path":"file.md","edits":[{"old_string":"a","new_string":"b"},{"old_string":"c","new_string":"d"}]} applied in order, all or nothing. Exactly one of old_string, insertLine or edits — a call carrying more than one of them is refused rather than resolved.'
|
|
284
|
+
|
|
281
285
|
export const EditTool = defineTool({
|
|
282
286
|
name: 'edit',
|
|
283
287
|
description:
|
|
@@ -285,8 +289,14 @@ export const EditTool = defineTool({
|
|
|
285
289
|
inputSchema,
|
|
286
290
|
modelInputSchema,
|
|
287
291
|
enforceModelInput: true,
|
|
288
|
-
validationErrorHint:
|
|
289
|
-
|
|
292
|
+
validationErrorHint: EDIT_SHAPES,
|
|
293
|
+
// Replacement text is where arguments stop being JSON: a raw newline,
|
|
294
|
+
// quote or backslash copied into the string. The shapes follow, since a
|
|
295
|
+
// malformed call may equally have got those wrong.
|
|
296
|
+
malformedInputHint: `${jsonStringEscapes('"old_string" and "new_string", in "edits" too,')} ${EDIT_SHAPES}`,
|
|
297
|
+
largeStringArguments: { old_string: 12_000, new_string: 12_000 },
|
|
298
|
+
truncatedInputHint:
|
|
299
|
+
'Split a large change into several edit calls, each replacing a shorter unique span; to add a long section, append it in parts with insertLine: "end".',
|
|
290
300
|
category: 'filesystem',
|
|
291
301
|
// Declared so a path outside the turn's roots can be reviewed before the
|
|
292
302
|
// call runs, rather than refused after. See `ToolDefinition.pathArgument`.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The advice a tool whose arguments carry raw text gives a model whose call
|
|
3
|
+
* was malformed.
|
|
4
|
+
*
|
|
5
|
+
* A file body, a replacement or a shell command is copied into a JSON string
|
|
6
|
+
* as it stands, and the characters JSON does not allow there unescaped (a
|
|
7
|
+
* newline, a tab, a double quote, a backslash) are what make such a call
|
|
8
|
+
* unreadable. The tool's shape, which is all a validation hint gives, does
|
|
9
|
+
* not say that.
|
|
10
|
+
*
|
|
11
|
+
* @param where - The arguments the text goes into, as the model sees them,
|
|
12
|
+
* e.g. `"content"`.
|
|
13
|
+
*/
|
|
14
|
+
export function jsonStringEscapes(where: string): string {
|
|
15
|
+
return `Every character of ${where} goes inside a JSON string: write a newline as \\n, a tab as \\t, a double quote as \\" and a backslash as \\\\.`
|
|
16
|
+
}
|
|
@@ -40,39 +40,21 @@ export const SearchToolsTool = defineTool({
|
|
|
40
40
|
|
|
41
41
|
const allowed = context.allowedTools !== undefined ? new Set(context.allowedTools) : null
|
|
42
42
|
// `searchDeferred` returns a ranked list (score-descending), so slicing
|
|
43
|
-
// the head is a true top-k
|
|
43
|
+
// the head is a true top-k reveal, not an arbitrary subset.
|
|
44
44
|
const ranked = context.toolRegistry
|
|
45
45
|
.searchDeferred(input.query)
|
|
46
46
|
.filter((tool) => !allowed || allowed.has(tool.name))
|
|
47
47
|
|
|
48
48
|
if (ranked.length === 0) {
|
|
49
|
-
const active = context.toolRegistry
|
|
50
|
-
.searchActive?.(input.query)
|
|
51
|
-
.filter(
|
|
52
|
-
(tool) =>
|
|
53
|
-
(!allowed || allowed.has(tool.name)) &&
|
|
54
|
-
context.toolRegistry?.getAvailability(tool.name) === 'active',
|
|
55
|
-
)
|
|
56
|
-
const activeReceipt =
|
|
57
|
-
active === undefined
|
|
58
|
-
? 'This registry cannot search active tools.'
|
|
59
|
-
: active.length === 0
|
|
60
|
-
? 'No matching active tools were found.'
|
|
61
|
-
: `Already active matching tools (up to ${ACTIVATION_TOP_K}):\n${active
|
|
62
|
-
.slice(0, ACTIVATION_TOP_K)
|
|
63
|
-
.map((tool) => `- ${tool.name}`)
|
|
64
|
-
.join('\n')}`
|
|
65
49
|
return {
|
|
66
50
|
success: true,
|
|
67
|
-
output: `No deferred tools matching "${input.query}"
|
|
51
|
+
output: `No deferred tools matching "${input.query}".`,
|
|
68
52
|
}
|
|
69
53
|
}
|
|
70
54
|
|
|
71
55
|
const activated = ranked.slice(0, ACTIVATION_TOP_K)
|
|
72
56
|
const nearMisses = ranked.slice(ACTIVATION_TOP_K, ACTIVATION_TOP_K + NEAR_MISS_LIMIT)
|
|
73
57
|
|
|
74
|
-
context.toolRegistry.activate(activated.map((t) => t.name))
|
|
75
|
-
|
|
76
58
|
const descriptions = activated.map((t) => `- ${t.name}: ${t.description}`).join('\n')
|
|
77
59
|
const sections = [`Activated ${activated.length} tool(s):\n${descriptions}`]
|
|
78
60
|
|
|
@@ -91,6 +73,11 @@ export const SearchToolsTool = defineTool({
|
|
|
91
73
|
return {
|
|
92
74
|
success: true,
|
|
93
75
|
output: sections.join('\n\n'),
|
|
76
|
+
// No `activate()` call: the manager derives availability from what a
|
|
77
|
+
// tool message REVEALS (`ToolResult.reveals`, persisted as
|
|
78
|
+
// `ToolMessage.revealedTools`), not from a mutation made here. See
|
|
79
|
+
// `toolsets/manager.ts`'s `availability()`.
|
|
80
|
+
reveals: activated.map((t) => t.name),
|
|
94
81
|
data: {
|
|
95
82
|
activated: activated.map((t) => t.name),
|
|
96
83
|
count: activated.length,
|
|
@@ -8,6 +8,7 @@ import { atomicWriteFile } from './atomic-write-file.js'
|
|
|
8
8
|
import { fingerprintContent, staleFileError } from './content-fingerprint.js'
|
|
9
9
|
import { withFileMutationLock } from './file-mutation-lock.js'
|
|
10
10
|
import { fileWriteResult } from './file-write-result.js'
|
|
11
|
+
import { jsonStringEscapes } from './json-string-hint.js'
|
|
11
12
|
|
|
12
13
|
const inputSchema = z
|
|
13
14
|
.object({
|
|
@@ -76,6 +77,17 @@ export const WriteFileTool = defineTool({
|
|
|
76
77
|
enforceModelInput: true,
|
|
77
78
|
validationErrorHint:
|
|
78
79
|
'Required shape: {"path":"file.md","content":"complete file body"}. Pass the whole body, not a diff.',
|
|
80
|
+
// A file body is where arguments stop being JSON: a raw newline, quote or
|
|
81
|
+
// backslash copied into the string. The shape alone, which is what the
|
|
82
|
+
// validation hint would have given, does not say that.
|
|
83
|
+
malformedInputHint: `Required shape: {"path":"file.md","content":"complete file body"}. ${jsonStringEscapes('"content"')}`,
|
|
84
|
+
// What a cut-off `write` needs to hear, and only a cut-off one: the
|
|
85
|
+
// kernel's message for unreadable arguments used to carry this recipe for
|
|
86
|
+
// every tool and every failure, malformed JSON and a question tool's
|
|
87
|
+
// included.
|
|
88
|
+
largeStringArguments: { content: 12_000 },
|
|
89
|
+
truncatedInputHint:
|
|
90
|
+
'For a long file, write a short opening that ends with a unique marker line, then extend it with edit calls that each replace the marker with the next section followed by the marker.',
|
|
79
91
|
category: 'filesystem',
|
|
80
92
|
// Declared so a path outside the turn's roots can be reviewed before the
|
|
81
93
|
// call runs, rather than refused after. See `ToolDefinition.pathArgument`.
|