@namzu/sdk 65.3.0 → 68.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 +167 -0
- package/dist/account/lock.d.ts +4 -12
- package/dist/account/lock.d.ts.map +1 -1
- package/dist/account/lock.js +5 -140
- package/dist/account/lock.js.map +1 -1
- package/dist/account/registry.d.ts.map +1 -1
- package/dist/account/registry.js +50 -6
- package/dist/account/registry.js.map +1 -1
- package/dist/account/types.d.ts +7 -5
- package/dist/account/types.d.ts.map +1 -1
- package/dist/account/types.js +6 -7
- package/dist/account/types.js.map +1 -1
- package/dist/authorization/dangerous-commands.d.ts +64 -0
- package/dist/authorization/dangerous-commands.d.ts.map +1 -0
- package/dist/authorization/dangerous-commands.js +479 -0
- package/dist/authorization/dangerous-commands.js.map +1 -0
- package/dist/authorization/gate.d.ts.map +1 -1
- package/dist/authorization/gate.js +19 -5
- package/dist/authorization/gate.js.map +1 -1
- package/dist/authorization/protected-paths.d.ts +11 -6
- package/dist/authorization/protected-paths.d.ts.map +1 -1
- package/dist/authorization/protected-paths.js +13 -8
- package/dist/authorization/protected-paths.js.map +1 -1
- package/dist/authorization/readonly-commands.d.ts +6 -1
- package/dist/authorization/readonly-commands.d.ts.map +1 -1
- package/dist/authorization/readonly-commands.js +35 -1
- package/dist/authorization/readonly-commands.js.map +1 -1
- package/dist/authorization/removal.d.ts +10 -0
- package/dist/authorization/removal.d.ts.map +1 -1
- package/dist/authorization/removal.js +7 -7
- package/dist/authorization/removal.js.map +1 -1
- package/dist/authorization/rules.d.ts +10 -0
- package/dist/authorization/rules.d.ts.map +1 -1
- package/dist/authorization/rules.js +60 -14
- package/dist/authorization/rules.js.map +1 -1
- package/dist/authorization/shell-lexer.d.ts +10 -0
- package/dist/authorization/shell-lexer.d.ts.map +1 -1
- package/dist/authorization/shell-lexer.js +15 -0
- package/dist/authorization/shell-lexer.js.map +1 -1
- package/dist/bridge/acp/permission.d.ts +5 -0
- package/dist/bridge/acp/permission.d.ts.map +1 -1
- package/dist/bridge/acp/permission.js.map +1 -1
- package/dist/bridge/acp/server.d.ts +8 -1
- package/dist/bridge/acp/server.d.ts.map +1 -1
- package/dist/bridge/acp/server.js +48 -6
- package/dist/bridge/acp/server.js.map +1 -1
- package/dist/compaction/context-breakdown.d.ts +25 -6
- package/dist/compaction/context-breakdown.d.ts.map +1 -1
- package/dist/compaction/context-breakdown.js +27 -7
- package/dist/compaction/context-breakdown.js.map +1 -1
- package/dist/compaction/dangling.d.ts.map +1 -1
- package/dist/compaction/dangling.js +2 -0
- package/dist/compaction/dangling.js.map +1 -1
- package/dist/compaction/extractor.d.ts +7 -1
- package/dist/compaction/extractor.d.ts.map +1 -1
- package/dist/compaction/extractor.js +8 -1
- package/dist/compaction/extractor.js.map +1 -1
- package/dist/compaction/index.d.ts +1 -1
- package/dist/compaction/index.d.ts.map +1 -1
- package/dist/compaction/index.js +1 -1
- package/dist/compaction/index.js.map +1 -1
- package/dist/compaction/managers/structured.js +2 -2
- package/dist/compaction/managers/structured.js.map +1 -1
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +11 -6
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/model-summary.d.ts.map +1 -1
- package/dist/compaction/model-summary.js +7 -1
- package/dist/compaction/model-summary.js.map +1 -1
- package/dist/compaction/summary.d.ts +13 -2
- package/dist/compaction/summary.d.ts.map +1 -1
- package/dist/compaction/summary.js +46 -3
- package/dist/compaction/summary.js.map +1 -1
- package/dist/constants/tools/index.d.ts +18 -1
- package/dist/constants/tools/index.d.ts.map +1 -1
- package/dist/constants/tools/index.js +28 -16
- package/dist/constants/tools/index.js.map +1 -1
- package/dist/manager/session/turn-recorder.d.ts +6 -0
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +29 -1
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/network/audit.d.ts +49 -0
- package/dist/network/audit.d.ts.map +1 -0
- package/dist/network/audit.js +84 -0
- package/dist/network/audit.js.map +1 -0
- package/dist/network/clock.d.ts +21 -0
- package/dist/network/clock.d.ts.map +1 -0
- package/dist/network/clock.js +51 -0
- package/dist/network/clock.js.map +1 -0
- package/dist/network/discovery-mdns.d.ts +120 -0
- package/dist/network/discovery-mdns.d.ts.map +1 -0
- package/dist/network/discovery-mdns.js +442 -0
- package/dist/network/discovery-mdns.js.map +1 -0
- package/dist/network/discovery.d.ts +63 -0
- package/dist/network/discovery.d.ts.map +1 -0
- package/dist/network/discovery.js +163 -0
- package/dist/network/discovery.js.map +1 -0
- package/dist/network/fingerprint.d.ts +73 -0
- package/dist/network/fingerprint.d.ts.map +1 -0
- package/dist/network/fingerprint.js +208 -0
- package/dist/network/fingerprint.js.map +1 -0
- package/dist/network/identity.d.ts +38 -0
- package/dist/network/identity.d.ts.map +1 -0
- package/dist/network/identity.js +71 -0
- package/dist/network/identity.js.map +1 -0
- package/dist/network/index.d.ts +39 -0
- package/dist/network/index.d.ts.map +1 -0
- package/dist/network/index.js +25 -0
- package/dist/network/index.js.map +1 -0
- package/dist/network/join.d.ts +69 -0
- package/dist/network/join.d.ts.map +1 -0
- package/dist/network/join.js +136 -0
- package/dist/network/join.js.map +1 -0
- package/dist/network/mail-policy.d.ts +97 -0
- package/dist/network/mail-policy.d.ts.map +1 -0
- package/dist/network/mail-policy.js +147 -0
- package/dist/network/mail-policy.js.map +1 -0
- package/dist/network/membership.d.ts +76 -0
- package/dist/network/membership.d.ts.map +1 -0
- package/dist/network/membership.js +225 -0
- package/dist/network/membership.js.map +1 -0
- package/dist/network/roster.d.ts +59 -0
- package/dist/network/roster.d.ts.map +1 -0
- package/dist/network/roster.js +120 -0
- package/dist/network/roster.js.map +1 -0
- package/dist/network/service.d.ts +303 -0
- package/dist/network/service.d.ts.map +1 -0
- package/dist/network/service.js +1891 -0
- package/dist/network/service.js.map +1 -0
- package/dist/network/store.d.ts +141 -0
- package/dist/network/store.d.ts.map +1 -0
- package/dist/network/store.js +198 -0
- package/dist/network/store.js.map +1 -0
- package/dist/network/transport.d.ts +96 -0
- package/dist/network/transport.d.ts.map +1 -0
- package/dist/network/transport.js +342 -0
- package/dist/network/transport.js.map +1 -0
- package/dist/network/wire.d.ts +345 -0
- package/dist/network/wire.d.ts.map +1 -0
- package/dist/network/wire.js +212 -0
- package/dist/network/wire.js.map +1 -0
- package/dist/network/x509.d.ts +28 -0
- package/dist/network/x509.d.ts.map +1 -0
- package/dist/network/x509.js +84 -0
- package/dist/network/x509.js.map +1 -0
- package/dist/pals/activity/causality.d.ts.map +1 -1
- package/dist/pals/activity/causality.js +14 -2
- package/dist/pals/activity/causality.js.map +1 -1
- package/dist/peers/endpoint.d.ts.map +1 -1
- package/dist/peers/endpoint.js +6 -0
- package/dist/peers/endpoint.js.map +1 -1
- package/dist/peers/envelope.d.ts +18 -0
- package/dist/peers/envelope.d.ts.map +1 -1
- package/dist/peers/envelope.js +68 -5
- package/dist/peers/envelope.js.map +1 -1
- package/dist/peers/index.d.ts +5 -4
- package/dist/peers/index.d.ts.map +1 -1
- package/dist/peers/index.js +3 -2
- package/dist/peers/index.js.map +1 -1
- package/dist/peers/mode-word.d.ts +10 -0
- package/dist/peers/mode-word.d.ts.map +1 -0
- package/dist/peers/mode-word.js +19 -0
- package/dist/peers/mode-word.js.map +1 -0
- package/dist/peers/protocol.d.ts +42 -0
- package/dist/peers/protocol.d.ts.map +1 -1
- package/dist/peers/protocol.js +22 -1
- package/dist/peers/protocol.js.map +1 -1
- package/dist/peers/record.d.ts +8 -0
- package/dist/peers/record.d.ts.map +1 -1
- package/dist/peers/record.js +5 -0
- package/dist/peers/record.js.map +1 -1
- package/dist/plugin/session-hook-env.d.ts.map +1 -1
- package/dist/plugin/session-hook-env.js +22 -2
- package/dist/plugin/session-hook-env.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +16 -2
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +183 -14
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/pricing/catalogue.generated.d.ts.map +1 -1
- package/dist/pricing/catalogue.generated.js +6 -0
- package/dist/pricing/catalogue.generated.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +4 -2
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +33 -38
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +12 -0
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/idle-timeout.d.ts.map +1 -1
- package/dist/provider/idle-timeout.js +5 -0
- package/dist/provider/idle-timeout.js.map +1 -1
- package/dist/provider/model-window-suffix.d.ts.map +1 -1
- package/dist/provider/model-window-suffix.js +1 -0
- package/dist/provider/model-window-suffix.js.map +1 -1
- package/dist/provider/retry.d.ts.map +1 -1
- package/dist/provider/retry.js +5 -0
- package/dist/provider/retry.js.map +1 -1
- package/dist/public-runtime.d.ts +16 -8
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +24 -7
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +3 -2
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +2 -2
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +10 -5
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.d.ts +11 -1
- package/dist/registry/command/kernel-commands.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.js +114 -46
- package/dist/registry/command/kernel-commands.js.map +1 -1
- package/dist/runtime/jobs/registry.d.ts +29 -1
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +64 -0
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/auto-review/classifier.d.ts +30 -6
- package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/classifier.js +40 -12
- package/dist/runtime/query/auto-review/classifier.js.map +1 -1
- package/dist/runtime/query/auto-review/feedback.d.ts +37 -0
- package/dist/runtime/query/auto-review/feedback.d.ts.map +1 -0
- package/dist/runtime/query/auto-review/feedback.js +45 -0
- package/dist/runtime/query/auto-review/feedback.js.map +1 -0
- package/dist/runtime/query/auto-review/git-status.d.ts +59 -0
- package/dist/runtime/query/auto-review/git-status.d.ts.map +1 -0
- package/dist/runtime/query/auto-review/git-status.js +379 -0
- package/dist/runtime/query/auto-review/git-status.js.map +1 -0
- package/dist/runtime/query/auto-review/index.d.ts +3 -3
- package/dist/runtime/query/auto-review/index.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/index.js +2 -2
- package/dist/runtime/query/auto-review/index.js.map +1 -1
- package/dist/runtime/query/auto-review/prompt.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/prompt.js +6 -1
- package/dist/runtime/query/auto-review/prompt.js.map +1 -1
- package/dist/runtime/query/auto-review/transcript.d.ts +14 -1
- package/dist/runtime/query/auto-review/transcript.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/transcript.js +48 -2
- package/dist/runtime/query/auto-review/transcript.js.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +40 -3
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +32 -10
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +78 -17
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts +9 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +54 -17
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +20 -6
- 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 +5 -2
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js +5 -0
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/per-call-review.d.ts +1 -2
- package/dist/runtime/query/iteration/phases/per-call-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/per-call-review.js +2 -5
- package/dist/runtime/query/iteration/phases/per-call-review.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 +6 -1
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/pasted-frames.d.ts +34 -0
- package/dist/runtime/query/pasted-frames.d.ts.map +1 -0
- package/dist/runtime/query/pasted-frames.js +108 -0
- package/dist/runtime/query/pasted-frames.js.map +1 -0
- package/dist/runtime/query/path-escalation.d.ts +6 -0
- package/dist/runtime/query/path-escalation.d.ts.map +1 -1
- package/dist/runtime/query/path-escalation.js +15 -3
- package/dist/runtime/query/path-escalation.js.map +1 -1
- package/dist/runtime/query/request-interrupted-turns.d.ts +20 -0
- package/dist/runtime/query/request-interrupted-turns.d.ts.map +1 -0
- package/dist/runtime/query/request-interrupted-turns.js +43 -0
- package/dist/runtime/query/request-interrupted-turns.js.map +1 -0
- package/dist/runtime/query/review-policy.d.ts +16 -6
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +111 -15
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.d.ts +9 -0
- package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.js +94 -6
- package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
- package/dist/runtime/query/unanswered.d.ts +19 -0
- package/dist/runtime/query/unanswered.d.ts.map +1 -0
- package/dist/runtime/query/unanswered.js +25 -0
- package/dist/runtime/query/unanswered.js.map +1 -0
- package/dist/runtime/system-events.d.ts +4 -4
- package/dist/runtime/system-events.d.ts.map +1 -1
- package/dist/runtime/system-events.js +2 -0
- package/dist/runtime/system-events.js.map +1 -1
- package/dist/session/workspace/git-worktree.d.ts +8 -0
- package/dist/session/workspace/git-worktree.d.ts.map +1 -1
- package/dist/session/workspace/git-worktree.js +21 -3
- package/dist/session/workspace/git-worktree.js.map +1 -1
- package/dist/store/evidence/source-kind.d.ts +1 -1
- package/dist/store/evidence/source-kind.d.ts.map +1 -1
- package/dist/store/evidence/source-kind.js +1 -1
- package/dist/store/evidence/source-kind.js.map +1 -1
- package/dist/store/goal/index.d.ts +53 -3
- package/dist/store/goal/index.d.ts.map +1 -1
- package/dist/store/goal/index.js +245 -9
- package/dist/store/goal/index.js.map +1 -1
- package/dist/store/session-index/sqlite.d.ts.map +1 -1
- package/dist/store/session-index/sqlite.js +42 -3
- package/dist/store/session-index/sqlite.js.map +1 -1
- package/dist/store/session-log/disk.js +1 -1
- package/dist/store/session-log/disk.js.map +1 -1
- package/dist/store/session-log/lease.d.ts.map +1 -1
- package/dist/store/session-log/lease.js +3 -2
- package/dist/store/session-log/lease.js.map +1 -1
- package/dist/tools/admit-facts.d.ts.map +1 -1
- package/dist/tools/admit-facts.js +2 -0
- package/dist/tools/admit-facts.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts +10 -2
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +56 -17
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/browser-local.d.ts +117 -0
- package/dist/tools/builtins/browser-local.d.ts.map +1 -0
- package/dist/tools/builtins/browser-local.js +437 -0
- package/dist/tools/builtins/browser-local.js.map +1 -0
- package/dist/tools/builtins/browser.d.ts +18 -1
- package/dist/tools/builtins/browser.d.ts.map +1 -1
- package/dist/tools/builtins/browser.js +84 -6
- package/dist/tools/builtins/browser.js.map +1 -1
- package/dist/tools/builtins/computer-use-window-id.d.ts +16 -0
- package/dist/tools/builtins/computer-use-window-id.d.ts.map +1 -0
- package/dist/tools/builtins/computer-use-window-id.js +52 -0
- package/dist/tools/builtins/computer-use-window-id.js.map +1 -0
- package/dist/tools/builtins/computer-use.d.ts +65 -7
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +384 -71
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/content-fingerprint.d.ts +6 -0
- package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
- package/dist/tools/builtins/content-fingerprint.js +7 -1
- package/dist/tools/builtins/content-fingerprint.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +89 -7
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/file-write-result.d.ts.map +1 -1
- package/dist/tools/builtins/file-write-result.js +2 -1
- package/dist/tools/builtins/file-write-result.js.map +1 -1
- package/dist/tools/builtins/grep.js +1 -1
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/job.d.ts.map +1 -1
- package/dist/tools/builtins/job.js +4 -2
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/monitor.d.ts.map +1 -1
- package/dist/tools/builtins/monitor.js +6 -1
- package/dist/tools/builtins/monitor.js.map +1 -1
- package/dist/tools/builtins/search-tools.d.ts +12 -1
- package/dist/tools/builtins/search-tools.d.ts.map +1 -1
- package/dist/tools/builtins/search-tools.js +166 -20
- package/dist/tools/builtins/search-tools.js.map +1 -1
- package/dist/tools/builtins/shell-read-credit.d.ts +18 -6
- package/dist/tools/builtins/shell-read-credit.d.ts.map +1 -1
- package/dist/tools/builtins/shell-read-credit.js +95 -27
- package/dist/tools/builtins/shell-read-credit.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +14 -3
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/tools/builtins/web-guidance.d.ts +6 -0
- package/dist/tools/builtins/web-guidance.d.ts.map +1 -1
- package/dist/tools/builtins/web-guidance.js +6 -0
- package/dist/tools/builtins/web-guidance.js.map +1 -1
- package/dist/tools/builtins/web.d.ts.map +1 -1
- package/dist/tools/builtins/web.js +2 -1
- package/dist/tools/builtins/web.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +32 -2
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/command-shell.d.ts +1 -1
- package/dist/tools/command-shell.d.ts.map +1 -1
- package/dist/tools/command-shell.js +6 -8
- package/dist/tools/command-shell.js.map +1 -1
- package/dist/tools/defineTool.d.ts +2 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +17 -1
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/goal/confirmation.d.ts +82 -1
- package/dist/tools/goal/confirmation.d.ts.map +1 -1
- package/dist/tools/goal/confirmation.js +153 -3
- package/dist/tools/goal/confirmation.js.map +1 -1
- package/dist/tools/goal/index.d.ts.map +1 -1
- package/dist/tools/goal/index.js +34 -3
- package/dist/tools/goal/index.js.map +1 -1
- package/dist/tools/schedules/index.d.ts +1 -0
- package/dist/tools/schedules/index.d.ts.map +1 -1
- package/dist/tools/schedules/index.js +1 -0
- package/dist/tools/schedules/index.js.map +1 -1
- package/dist/tools/schedules/loop-tool.d.ts.map +1 -1
- package/dist/tools/schedules/loop-tool.js +8 -6
- package/dist/tools/schedules/loop-tool.js.map +1 -1
- package/dist/tools/schedules/present.js +1 -1
- package/dist/tools/schedules/present.js.map +1 -1
- package/dist/tools/schedules/timer-tools.d.ts +36 -0
- package/dist/tools/schedules/timer-tools.d.ts.map +1 -0
- package/dist/tools/schedules/timer-tools.js +234 -0
- package/dist/tools/schedules/timer-tools.js.map +1 -0
- package/dist/tools/schedules/types.d.ts +68 -3
- package/dist/tools/schedules/types.d.ts.map +1 -1
- package/dist/tools/task/create.d.ts.map +1 -1
- package/dist/tools/task/create.js +2 -0
- package/dist/tools/task/create.js.map +1 -1
- package/dist/toolsets/manager.d.ts +49 -7
- package/dist/toolsets/manager.d.ts.map +1 -1
- package/dist/toolsets/manager.js +239 -40
- package/dist/toolsets/manager.js.map +1 -1
- package/dist/turn/evidence-query.d.ts +18 -1
- package/dist/turn/evidence-query.d.ts.map +1 -1
- package/dist/turn/evidence-query.js +177 -35
- package/dist/turn/evidence-query.js.map +1 -1
- package/dist/turn/evidence-recall.d.ts +8 -1
- package/dist/turn/evidence-recall.d.ts.map +1 -1
- package/dist/turn/evidence-recall.js +82 -22
- package/dist/turn/evidence-recall.js.map +1 -1
- package/dist/turn/history-shed.d.ts +15 -0
- package/dist/turn/history-shed.d.ts.map +1 -0
- package/dist/turn/history-shed.js +23 -0
- package/dist/turn/history-shed.js.map +1 -0
- package/dist/types/acp/index.d.ts +26 -0
- package/dist/types/acp/index.d.ts.map +1 -1
- package/dist/types/authorization/index.d.ts +9 -1
- package/dist/types/authorization/index.d.ts.map +1 -1
- package/dist/types/authorization/index.js +11 -2
- package/dist/types/authorization/index.js.map +1 -1
- package/dist/types/command/index.d.ts +26 -2
- package/dist/types/command/index.d.ts.map +1 -1
- package/dist/types/command/index.js +5 -2
- package/dist/types/command/index.js.map +1 -1
- package/dist/types/common/index.d.ts +4 -2
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/index.js.map +1 -1
- package/dist/types/goal/index.d.ts +59 -0
- package/dist/types/goal/index.d.ts.map +1 -1
- package/dist/types/hitl/index.d.ts +10 -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 +56 -1
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +2 -1
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/permission/index.d.ts +14 -0
- package/dist/types/permission/index.d.ts.map +1 -1
- package/dist/types/permission/index.js +14 -0
- package/dist/types/permission/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +148 -1
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +9 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +10 -5
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/index.d.ts +1 -0
- package/dist/types/provider/index.d.ts.map +1 -1
- package/dist/types/provider/interface.d.ts +19 -0
- package/dist/types/provider/interface.d.ts.map +1 -1
- package/dist/types/provider/limits.d.ts +33 -0
- package/dist/types/provider/limits.d.ts.map +1 -0
- package/dist/types/provider/limits.js +7 -0
- package/dist/types/provider/limits.js.map +1 -0
- package/dist/types/provider/model.d.ts +5 -0
- package/dist/types/provider/model.d.ts.map +1 -1
- package/dist/types/session/config.d.ts +2 -2
- package/dist/types/session/outcome.d.ts +5 -2
- package/dist/types/session/outcome.d.ts.map +1 -1
- package/dist/types/session/outcome.js.map +1 -1
- package/dist/types/tool/index.d.ts +30 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/tool/presentation.d.ts +4 -0
- package/dist/types/tool/presentation.d.ts.map +1 -1
- package/dist/utils/cost.d.ts +1 -1
- package/dist/utils/cost.d.ts.map +1 -1
- package/dist/utils/cost.js +14 -5
- package/dist/utils/cost.js.map +1 -1
- package/dist/utils/file-lock.d.ts +88 -0
- package/dist/utils/file-lock.d.ts.map +1 -0
- package/dist/utils/file-lock.js +281 -0
- package/dist/utils/file-lock.js.map +1 -0
- package/dist/utils/state-backup.d.ts +87 -0
- package/dist/utils/state-backup.d.ts.map +1 -0
- package/dist/utils/state-backup.js +272 -0
- package/dist/utils/state-backup.js.map +1 -0
- package/dist/utils/temp-sweep.d.ts +66 -0
- package/dist/utils/temp-sweep.d.ts.map +1 -0
- package/dist/utils/temp-sweep.js +311 -0
- package/dist/utils/temp-sweep.js.map +1 -0
- package/dist/utils/temp.d.ts +14 -0
- package/dist/utils/temp.d.ts.map +1 -1
- package/dist/utils/temp.js +70 -2
- package/dist/utils/temp.js.map +1 -1
- package/package.json +1 -1
- package/src/account/lock.ts +13 -133
- package/src/account/registry.ts +75 -21
- package/src/account/types.ts +8 -9
- package/src/authorization/dangerous-commands.ts +542 -0
- package/src/authorization/gate.ts +19 -5
- package/src/authorization/protected-paths.ts +13 -8
- package/src/authorization/readonly-commands.ts +35 -1
- package/src/authorization/removal.ts +7 -7
- package/src/authorization/rules.ts +75 -15
- package/src/authorization/shell-lexer.ts +19 -0
- package/src/bridge/acp/permission.ts +2 -0
- package/src/bridge/acp/server.ts +66 -6
- package/src/compaction/context-breakdown.ts +53 -11
- package/src/compaction/dangling.ts +2 -0
- package/src/compaction/extractor.ts +9 -1
- package/src/compaction/index.ts +1 -0
- package/src/compaction/managers/structured.ts +2 -2
- package/src/compaction/manual.ts +11 -3
- package/src/compaction/model-summary.ts +8 -1
- package/src/compaction/summary.ts +54 -7
- package/src/constants/tools/index.ts +30 -16
- package/src/manager/session/turn-recorder.ts +37 -1
- package/src/network/audit.ts +113 -0
- package/src/network/clock.ts +62 -0
- package/src/network/discovery-mdns.ts +485 -0
- package/src/network/discovery.ts +210 -0
- package/src/network/fingerprint.ts +241 -0
- package/src/network/identity.ts +98 -0
- package/src/network/index.ts +134 -0
- package/src/network/join.ts +177 -0
- package/src/network/mail-policy.ts +199 -0
- package/src/network/membership.ts +290 -0
- package/src/network/roster.ts +165 -0
- package/src/network/service.ts +2304 -0
- package/src/network/store.ts +261 -0
- package/src/network/transport.ts +445 -0
- package/src/network/wire.ts +250 -0
- package/src/network/x509.ts +114 -0
- package/src/pals/activity/causality.ts +16 -2
- package/src/peers/endpoint.ts +6 -0
- package/src/peers/envelope.ts +82 -5
- package/src/peers/index.ts +10 -2
- package/src/peers/mode-word.ts +18 -0
- package/src/peers/protocol.ts +24 -1
- package/src/peers/record.ts +5 -0
- package/src/plugin/session-hook-env.ts +25 -2
- package/src/plugin/shell-hook.ts +208 -14
- package/src/pricing/catalogue.generated.ts +6 -0
- package/src/pricing/rates.source.json +13 -7
- package/src/prompt/coding-agent-doctrine.ts +33 -38
- package/src/provider/fallback.ts +11 -0
- package/src/provider/idle-timeout.ts +5 -0
- package/src/provider/model-window-suffix.ts +1 -0
- package/src/provider/retry.ts +5 -0
- package/src/public-runtime.ts +116 -1
- package/src/public-tools.ts +11 -0
- package/src/public-types.ts +74 -1
- package/src/registry/command/kernel-commands.ts +136 -49
- package/src/runtime/jobs/registry.ts +93 -3
- package/src/runtime/query/auto-review/classifier.ts +76 -14
- package/src/runtime/query/auto-review/feedback.ts +50 -0
- package/src/runtime/query/auto-review/git-status.ts +437 -0
- package/src/runtime/query/auto-review/index.ts +7 -2
- package/src/runtime/query/auto-review/prompt.ts +6 -1
- package/src/runtime/query/auto-review/transcript.ts +67 -4
- package/src/runtime/query/executor/tool-call-admission.ts +49 -3
- package/src/runtime/query/executor.ts +104 -21
- package/src/runtime/query/index.ts +66 -17
- package/src/runtime/query/iteration/index.ts +33 -9
- package/src/runtime/query/iteration/phases/compaction.ts +4 -0
- package/src/runtime/query/iteration/phases/context.ts +5 -0
- package/src/runtime/query/iteration/phases/per-call-review.ts +8 -13
- package/src/runtime/query/iteration/phases/tool-review.ts +7 -1
- package/src/runtime/query/pasted-frames.ts +119 -0
- package/src/runtime/query/path-escalation.ts +27 -3
- package/src/runtime/query/request-interrupted-turns.ts +47 -0
- package/src/runtime/query/review-policy.ts +125 -22
- package/src/runtime/query/turn/outcome-ledger.ts +99 -6
- package/src/runtime/query/unanswered.ts +35 -0
- package/src/runtime/system-events.ts +2 -0
- package/src/session/workspace/git-worktree.ts +34 -3
- package/src/store/evidence/source-kind.ts +1 -1
- package/src/store/goal/index.ts +320 -21
- package/src/store/session-index/sqlite.ts +40 -3
- package/src/store/session-log/disk.ts +1 -1
- package/src/store/session-log/lease.ts +3 -2
- package/src/tools/admit-facts.ts +2 -0
- package/src/tools/builtins/bash.ts +62 -19
- package/src/tools/builtins/browser-local.ts +504 -0
- package/src/tools/builtins/browser.ts +108 -6
- package/src/tools/builtins/computer-use-window-id.ts +50 -0
- package/src/tools/builtins/computer-use.ts +460 -68
- package/src/tools/builtins/content-fingerprint.ts +8 -1
- package/src/tools/builtins/edit.ts +93 -7
- package/src/tools/builtins/file-write-result.ts +2 -1
- package/src/tools/builtins/grep.ts +1 -1
- package/src/tools/builtins/job.ts +4 -2
- package/src/tools/builtins/monitor.ts +6 -1
- package/src/tools/builtins/search-tools.ts +196 -21
- package/src/tools/builtins/shell-read-credit.ts +97 -33
- package/src/tools/builtins/wait-for-job.ts +13 -3
- package/src/tools/builtins/web-guidance.ts +6 -0
- package/src/tools/builtins/web.ts +2 -1
- package/src/tools/builtins/write-file.ts +31 -3
- package/src/tools/command-shell.ts +6 -8
- package/src/tools/defineTool.ts +20 -1
- package/src/tools/goal/confirmation.ts +227 -3
- package/src/tools/goal/index.ts +40 -4
- package/src/tools/schedules/index.ts +11 -0
- package/src/tools/schedules/loop-tool.ts +10 -6
- package/src/tools/schedules/present.ts +1 -1
- package/src/tools/schedules/timer-tools.ts +258 -0
- package/src/tools/schedules/types.ts +72 -3
- package/src/tools/task/create.ts +2 -0
- package/src/toolsets/manager.ts +262 -46
- package/src/turn/evidence-query.ts +183 -42
- package/src/turn/evidence-recall.ts +96 -19
- package/src/turn/history-shed.ts +30 -0
- package/src/types/acp/index.ts +24 -0
- package/src/types/authorization/index.ts +20 -3
- package/src/types/command/index.ts +27 -2
- package/src/types/common/index.ts +4 -2
- package/src/types/goal/index.ts +61 -0
- package/src/types/hitl/index.ts +10 -0
- package/src/types/message/index.ts +65 -0
- package/src/types/permission/index.ts +18 -0
- package/src/types/plugin/index.ts +205 -26
- package/src/types/provider/chat.ts +10 -5
- package/src/types/provider/index.ts +1 -0
- package/src/types/provider/interface.ts +21 -0
- package/src/types/provider/limits.ts +35 -0
- package/src/types/provider/model.ts +5 -0
- package/src/types/session/config.ts +2 -2
- package/src/types/session/outcome.ts +3 -1
- package/src/types/tool/index.ts +30 -2
- package/src/types/tool/presentation.ts +4 -0
- package/src/utils/cost.ts +15 -6
- package/src/utils/file-lock.ts +328 -0
- package/src/utils/state-backup.ts +318 -0
- package/src/utils/temp-sweep.ts +327 -0
- package/src/utils/temp.ts +73 -2
package/src/toolsets/manager.ts
CHANGED
|
@@ -19,8 +19,8 @@ import { failureFactsFromError } from '../tools/failure-facts.js'
|
|
|
19
19
|
import { isTrustedReadOnly } from '../tools/trusted-read-only.js'
|
|
20
20
|
import { wrapUntrusted } from '../tools/untrusted-envelope.js'
|
|
21
21
|
import type { ToolResultGuardrailSpec } from '../types/guardrail/index.js'
|
|
22
|
-
import type { Message, ToolRevealReceipt } from '../types/message/index.js'
|
|
23
|
-
import { PLAN_MODE_REFUSAL } from '../types/permission/index.js'
|
|
22
|
+
import type { Message, SystemMessage, ToolRevealReceipt } from '../types/message/index.js'
|
|
23
|
+
import { PLAN_MODE_REFUSAL, PLAN_MODE_REFUSAL_WITH_PLAN_FILE } from '../types/permission/index.js'
|
|
24
24
|
import type {
|
|
25
25
|
LLMToolSchema,
|
|
26
26
|
PreparedToolExecution,
|
|
@@ -115,12 +115,23 @@ const SEARCH_STOP_TOKENS = new Set([
|
|
|
115
115
|
'search',
|
|
116
116
|
])
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
const
|
|
121
|
-
const
|
|
118
|
+
// A word of the tool's name sits far above a word of its description, so a
|
|
119
|
+
// tool called `web_search` outranks one that merely mentions the web.
|
|
120
|
+
const SEARCH_WEIGHT_NAME_WORD = 10
|
|
121
|
+
const SEARCH_WEIGHT_NAME_WORD_MCP = 12
|
|
122
|
+
const SEARCH_WEIGHT_NAME_PART = 5
|
|
123
|
+
const SEARCH_WEIGHT_NAME_PART_MCP = 6
|
|
124
|
+
const SEARCH_WEIGHT_NAME_ANY = 3
|
|
125
|
+
const SEARCH_WEIGHT_DESCRIPTION = 2
|
|
126
|
+
const SEARCH_WEIGHT_ARGUMENT = 2
|
|
127
|
+
/** A query is clipped to this many characters and words before it is read. */
|
|
128
|
+
const MAX_SEARCH_QUERY_CHARS = 16_384
|
|
129
|
+
const MAX_SEARCH_QUERY_WORDS = 32
|
|
122
130
|
const MAX_DEFERRED_MCP_HINT_CHARS = 4_000
|
|
123
131
|
|
|
132
|
+
/** Most characters of tool names one tools-changed announcement spells out; the rest is a count. */
|
|
133
|
+
const MAX_TOOLS_CHANGED_CHARS = 1_500
|
|
134
|
+
|
|
124
135
|
/**
|
|
125
136
|
* The runtime-owned resolver of {@link Toolset}s.
|
|
126
137
|
*
|
|
@@ -387,6 +398,53 @@ export class ToolManager {
|
|
|
387
398
|
return { added, removed, drifted, refused }
|
|
388
399
|
}
|
|
389
400
|
|
|
401
|
+
/**
|
|
402
|
+
* What to tell the model after {@link refresh} reported a change, or an
|
|
403
|
+
* empty string when nothing it can act on changed. The catalogue in the
|
|
404
|
+
* system prompt is written once, so a server that connects, or lists more
|
|
405
|
+
* tools, after that would otherwise be invisible. Deferred names are
|
|
406
|
+
* announced the way the catalogue lists them; a tool an MCP server wrote
|
|
407
|
+
* is named without its description, which is the server's text and goes
|
|
408
|
+
* through the provenance-labelled context instead.
|
|
409
|
+
*/
|
|
410
|
+
describeChange(report: ToolsetChangeReport): string {
|
|
411
|
+
const lines: string[] = []
|
|
412
|
+
const deferredNow = report.added.filter((name) => this.availability(name) === 'deferred')
|
|
413
|
+
const loadedNow = report.added.filter((name) => this.availability(name) === 'active')
|
|
414
|
+
const searchable = this.has('search_tools') && this.availability('search_tools') === 'active'
|
|
415
|
+
if (deferredNow.length > 0) {
|
|
416
|
+
const entries = deferredNow.map((name) => {
|
|
417
|
+
const tool = this.toolsByName.get(name)
|
|
418
|
+
const hint =
|
|
419
|
+
!tool || this.sourceKindOf(name) === 'mcp_server'
|
|
420
|
+
? ''
|
|
421
|
+
: toolDiscoveryHint(tool.description)
|
|
422
|
+
return hint.length > 0 ? `- ${name}: ${hint}` : `- ${name}`
|
|
423
|
+
})
|
|
424
|
+
const { shown, more } = capEntries(entries)
|
|
425
|
+
lines.push(
|
|
426
|
+
searchable
|
|
427
|
+
? 'These tools are now available but deferred. Their schemas are not loaded; use search_tools with "select:<name>" (exact names, comma-separated) to load one before calling it:'
|
|
428
|
+
: 'These tools are now available but deferred; wait for runtime activation before calling them:',
|
|
429
|
+
...shown,
|
|
430
|
+
)
|
|
431
|
+
if (more > 0) {
|
|
432
|
+
lines.push(
|
|
433
|
+
searchable
|
|
434
|
+
? `...and ${more} more deferred tools; find them with search_tools.`
|
|
435
|
+
: `...and ${more} more deferred tools.`,
|
|
436
|
+
)
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
if (loadedNow.length > 0) {
|
|
440
|
+
lines.push(`These tools are now loaded and can be called: ${capNames(loadedNow)}.`)
|
|
441
|
+
}
|
|
442
|
+
if (report.removed.length > 0) {
|
|
443
|
+
lines.push(`These tools are no longer available: ${capNames(report.removed)}.`)
|
|
444
|
+
}
|
|
445
|
+
return lines.join('\n')
|
|
446
|
+
}
|
|
447
|
+
|
|
390
448
|
has(name: string): boolean {
|
|
391
449
|
return this.toolsByName.has(name)
|
|
392
450
|
}
|
|
@@ -426,13 +484,13 @@ export class ToolManager {
|
|
|
426
484
|
* Nothing here is stored: this is a pure read of the toolset's own
|
|
427
485
|
* declaration plus a scan of `messages()`, recomputed on every call — the
|
|
428
486
|
* same "safe to call repeatedly, byte-identical between calls" property
|
|
429
|
-
* `toLLMTools` already has. The scan
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
*
|
|
487
|
+
* `toLLMTools` already has. The scan reads the last compaction summary
|
|
488
|
+
* (`compaction/summary.ts`'s `isCompactionMessage` — the one marker a
|
|
489
|
+
* compacted history carries, a system message whose content starts with
|
|
490
|
+
* `COMPACTION_HEADER`) and the window AFTER it. The summary carries, as
|
|
491
|
+
* its own `revealedTools`, the tools the pass found loaded in the
|
|
492
|
+
* messages it cut, so a loaded tool stays loaded across a compaction
|
|
493
|
+
* while the messages that loaded it are gone. A tool message's own `revealedTools`
|
|
436
494
|
* (`types/message/index.ts`) is written by the executor from
|
|
437
495
|
* `ToolResult.reveals`, persisted like any other message field — there is
|
|
438
496
|
* no separate store to keep in sync, restore on resume, or lose across a
|
|
@@ -449,18 +507,16 @@ export class ToolManager {
|
|
|
449
507
|
private wasRevealed(name: string): boolean {
|
|
450
508
|
const owner = this.ownerToolsetByName.get(name)
|
|
451
509
|
if (!owner) return false
|
|
452
|
-
const
|
|
510
|
+
const owns = (receipt: ToolRevealReceipt) =>
|
|
511
|
+
receipt.name === name &&
|
|
512
|
+
receipt.sourceId === owner.source.id &&
|
|
513
|
+
receipt.sourceKind === owner.source.kind
|
|
514
|
+
const { summary, window } = postCompactionWindow(this.messagesAccessor())
|
|
515
|
+
// What the last summary carries was loaded before the pass cut the
|
|
516
|
+
// messages that loaded it; it is still loaded.
|
|
517
|
+
if (summary?.revealedTools?.some(owns)) return true
|
|
453
518
|
for (const message of window) {
|
|
454
|
-
if (
|
|
455
|
-
message.role === 'tool' &&
|
|
456
|
-
!message.isError &&
|
|
457
|
-
message.revealedTools?.some(
|
|
458
|
-
(receipt) =>
|
|
459
|
-
receipt.name === name &&
|
|
460
|
-
receipt.sourceId === owner.source.id &&
|
|
461
|
-
receipt.sourceKind === owner.source.kind,
|
|
462
|
-
)
|
|
463
|
-
)
|
|
519
|
+
if (message.role === 'tool' && !message.isError && message.revealedTools?.some(owns))
|
|
464
520
|
return true
|
|
465
521
|
}
|
|
466
522
|
return false
|
|
@@ -496,32 +552,132 @@ export class ToolManager {
|
|
|
496
552
|
return limit === undefined ? results : results.slice(0, limit)
|
|
497
553
|
}
|
|
498
554
|
|
|
555
|
+
/**
|
|
556
|
+
* Load exact tools by name, the `select:a,b` form of `search_tools`. A
|
|
557
|
+
* name matches a tool exactly (case-insensitive); failing that, an MCP
|
|
558
|
+
* tool by its short name, the part after the last `__`, which can name
|
|
559
|
+
* more than one tool when two servers expose the same one. `available`
|
|
560
|
+
* lists names that are already loaded, `missing` the ones nothing matched.
|
|
561
|
+
* Nothing is searched by description here: a wrong name is reported, not
|
|
562
|
+
* guessed at.
|
|
563
|
+
*/
|
|
564
|
+
select(names: readonly string[]): {
|
|
565
|
+
readonly found: readonly ToolDefinition[]
|
|
566
|
+
readonly available: readonly string[]
|
|
567
|
+
readonly missing: readonly string[]
|
|
568
|
+
} {
|
|
569
|
+
const found: ToolDefinition[] = []
|
|
570
|
+
const seen = new Set<string>()
|
|
571
|
+
const available: string[] = []
|
|
572
|
+
const missing: string[] = []
|
|
573
|
+
const byLowerName = new Map<string, ToolDefinition>()
|
|
574
|
+
const byShortName = new Map<string, ToolDefinition[]>()
|
|
575
|
+
for (const tool of this.toolsByName.values()) {
|
|
576
|
+
byLowerName.set(tool.name.toLowerCase(), tool)
|
|
577
|
+
if (this.sourceKindOf(tool.name) === 'mcp_server') {
|
|
578
|
+
const short = mcpShortName(tool.name)
|
|
579
|
+
if (short !== undefined) byShortName.set(short, [...(byShortName.get(short) ?? []), tool])
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
for (const raw of names) {
|
|
583
|
+
const wanted = raw.trim().toLowerCase()
|
|
584
|
+
if (wanted.length === 0) continue
|
|
585
|
+
const exact = byLowerName.get(wanted)
|
|
586
|
+
const matches = exact ? [exact] : (byShortName.get(wanted) ?? [])
|
|
587
|
+
if (matches.length === 0) {
|
|
588
|
+
if (!missing.includes(raw.trim())) missing.push(raw.trim())
|
|
589
|
+
continue
|
|
590
|
+
}
|
|
591
|
+
for (const tool of matches) {
|
|
592
|
+
if (seen.has(tool.name)) continue
|
|
593
|
+
seen.add(tool.name)
|
|
594
|
+
if (this.availability(tool.name) === 'deferred') found.push(tool)
|
|
595
|
+
else available.push(tool.name)
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
return { found, available, missing }
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
private sourceKindOf(name: string): ToolSourceRef['kind'] | undefined {
|
|
602
|
+
return this.ownerToolsetByName.get(name)?.source.kind
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/**
|
|
606
|
+
* Ranked lexical search. Rules, in order:
|
|
607
|
+
* - A query that is exactly one tool's name returns that tool alone.
|
|
608
|
+
* - A term written `+term` is required: a tool that does not carry it in
|
|
609
|
+
* its name, description or argument names is left out.
|
|
610
|
+
* - A term scores by where it sits. A whole word of the name is far above
|
|
611
|
+
* a piece of a word, which is far above a word of the description;
|
|
612
|
+
* an MCP tool's name counts a little more.
|
|
613
|
+
* - Generic words (`tool`, `list`, `read`, ...) are ignored. `search` is
|
|
614
|
+
* ignored too, unless a tool's name has it (`web_search`).
|
|
615
|
+
*/
|
|
499
616
|
private searchByAvailability(query: string, state: ToolsetAvailability): ToolDefinition[] {
|
|
500
|
-
const q = query.toLowerCase().trim()
|
|
617
|
+
const q = query.toLowerCase().trim().slice(0, MAX_SEARCH_QUERY_CHARS)
|
|
501
618
|
if (q.length === 0) return []
|
|
502
|
-
const
|
|
619
|
+
const candidates = [...this.toolsByName.values()].filter(
|
|
620
|
+
(tool) => this.availability(tool.name) === state,
|
|
621
|
+
)
|
|
622
|
+
const exact = candidates.find((tool) => tool.name.toLowerCase() === q)
|
|
623
|
+
if (exact) return [exact]
|
|
624
|
+
|
|
625
|
+
const profiles = candidates.map((tool) => ({
|
|
626
|
+
tool,
|
|
627
|
+
words: nameWords(tool.name),
|
|
628
|
+
name: tool.name.toLowerCase(),
|
|
629
|
+
mcp: this.sourceKindOf(tool.name) === 'mcp_server',
|
|
630
|
+
}))
|
|
631
|
+
const nameHasWord = (term: string) => profiles.some((p) => p.words.includes(term))
|
|
632
|
+
// `search` is generic in a request ("search the web") but is also the name of
|
|
633
|
+
// tools (`web_search`, `search_memory`); it counts when a tool's name has it.
|
|
634
|
+
// The other generic words stay ignored: they would reveal whole catalogues.
|
|
635
|
+
|
|
636
|
+
const required: string[] = []
|
|
637
|
+
const optional: string[] = []
|
|
638
|
+
for (const tok of q.split(/\s+/).slice(0, MAX_SEARCH_QUERY_WORDS)) {
|
|
639
|
+
if (tok.length > 1 && tok.startsWith('+')) {
|
|
640
|
+
required.push(tok.slice(1))
|
|
641
|
+
} else if (
|
|
642
|
+
tok.length >= 3 &&
|
|
643
|
+
(!SEARCH_STOP_TOKENS.has(tok) || (tok === 'search' && nameHasWord(tok)))
|
|
644
|
+
) {
|
|
645
|
+
optional.push(tok)
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
const terms = [...new Set([...required, ...optional])]
|
|
649
|
+
if (terms.length === 0) return []
|
|
650
|
+
const descriptionPatterns = new Map(
|
|
651
|
+
terms.map((term) => [term, new RegExp(`(?<![a-z0-9])${escapeRegExp(term)}(?![a-z0-9])`)]),
|
|
652
|
+
)
|
|
503
653
|
|
|
504
654
|
const scored: Array<{ tool: ToolDefinition; score: number }> = []
|
|
505
|
-
for (const tool of
|
|
506
|
-
if (this.availability(tool.name) !== state) continue
|
|
507
|
-
const name = tool.name.toLowerCase()
|
|
655
|
+
for (const { tool, words, name, mcp } of profiles) {
|
|
508
656
|
const description = tool.description.toLowerCase()
|
|
509
657
|
const argumentNames = listArgumentNames(tool)
|
|
510
|
-
let score =
|
|
658
|
+
let score = 0
|
|
659
|
+
let allRequired = true
|
|
511
660
|
for (const term of terms) {
|
|
512
|
-
|
|
513
|
-
|
|
661
|
+
let termScore = 0
|
|
662
|
+
const inDescription = descriptionPatterns.get(term)?.test(description) ?? false
|
|
663
|
+
const inArguments = argumentNames.some((arg) => arg.includes(term))
|
|
664
|
+
if (words.includes(term)) {
|
|
665
|
+
termScore += mcp ? SEARCH_WEIGHT_NAME_WORD_MCP : SEARCH_WEIGHT_NAME_WORD
|
|
666
|
+
} else if (words.some((word) => word.includes(term))) {
|
|
667
|
+
termScore += mcp ? SEARCH_WEIGHT_NAME_PART_MCP : SEARCH_WEIGHT_NAME_PART
|
|
514
668
|
} else if (name.includes(term)) {
|
|
515
|
-
|
|
669
|
+
termScore += SEARCH_WEIGHT_NAME_ANY
|
|
516
670
|
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
if (
|
|
521
|
-
|
|
671
|
+
const inName = termScore > 0
|
|
672
|
+
if (inDescription) termScore += SEARCH_WEIGHT_DESCRIPTION
|
|
673
|
+
if (inArguments) termScore += SEARCH_WEIGHT_ARGUMENT
|
|
674
|
+
if (required.includes(term) && !inName && !inDescription && !inArguments) {
|
|
675
|
+
allRequired = false
|
|
676
|
+
break
|
|
522
677
|
}
|
|
678
|
+
score += termScore
|
|
523
679
|
}
|
|
524
|
-
if (score > 0) scored.push({ tool, score })
|
|
680
|
+
if (allRequired && score > 0) scored.push({ tool, score })
|
|
525
681
|
}
|
|
526
682
|
|
|
527
683
|
scored.sort((a, b) => b.score - a.score || a.tool.name.localeCompare(b.tool.name))
|
|
@@ -531,7 +687,18 @@ export class ToolManager {
|
|
|
531
687
|
// ---- Rendering to the model ----------------------------------------------
|
|
532
688
|
|
|
533
689
|
toLLMTools(names?: readonly string[]): LLMToolSchema[] {
|
|
534
|
-
|
|
690
|
+
return this.renderTools(this.getByAvailability(['active'], names))
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* The definitions that are not sent yet because they load only when the
|
|
695
|
+
* model asks, rendered the way they will be once loaded. For sizing only.
|
|
696
|
+
*/
|
|
697
|
+
toDeferredLLMTools(names?: readonly string[]): LLMToolSchema[] {
|
|
698
|
+
return this.renderTools(this.getByAvailability(['deferred'], names))
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
private renderTools(tools: readonly ToolDefinition[]): LLMToolSchema[] {
|
|
535
702
|
return tools.map((tool) => {
|
|
536
703
|
let description = tool.description
|
|
537
704
|
if (this.tierConfig?.labelInDescription && tool.tier) {
|
|
@@ -572,7 +739,10 @@ Executable tool names, descriptions, and JSON input schemas are attached through
|
|
|
572
739
|
// request-only, provenance-labelled context below.
|
|
573
740
|
const hint =
|
|
574
741
|
this.sourceOf(t.name)?.kind === 'mcp_server' ? '' : toolDiscoveryHint(t.description)
|
|
575
|
-
|
|
742
|
+
const base = hint.length > 0 ? `- ${t.name}: ${hint}` : `- ${t.name}`
|
|
743
|
+
return t.loadsWith && t.loadsWith.length > 0
|
|
744
|
+
? `${base} (loads with ${t.loadsWith.join(', ')})`
|
|
745
|
+
: base
|
|
576
746
|
})
|
|
577
747
|
.join('\n')
|
|
578
748
|
const deferredIntro =
|
|
@@ -667,6 +837,7 @@ Executable tool names, descriptions, and JSON input schemas are attached through
|
|
|
667
837
|
has: (name) => this.has(name),
|
|
668
838
|
availability: (name) => this.availability(name),
|
|
669
839
|
searchDeferred: (query, limit) => this.searchDeferred(query, limit),
|
|
840
|
+
select: (names) => this.select(names),
|
|
670
841
|
}
|
|
671
842
|
}
|
|
672
843
|
|
|
@@ -857,7 +1028,10 @@ Executable tool names, descriptions, and JSON input schemas are attached through
|
|
|
857
1028
|
// not read off a stored map. See `availability` above.
|
|
858
1029
|
const availability = this.availability(toolName)
|
|
859
1030
|
if (availability !== 'active') {
|
|
860
|
-
const msg =
|
|
1031
|
+
const msg =
|
|
1032
|
+
availability === 'deferred'
|
|
1033
|
+
? `Tool "${toolName}" is not loaded yet. Call search_tools with its exact name, then call it again.`
|
|
1034
|
+
: `Tool "${toolName}" is ${availability} and cannot be executed`
|
|
861
1035
|
this.log.warn(msg)
|
|
862
1036
|
span.setAttributes({
|
|
863
1037
|
[NAMZU.TOOL_SUCCESS]: false,
|
|
@@ -897,7 +1071,9 @@ Executable tool names, descriptions, and JSON input schemas are attached through
|
|
|
897
1071
|
if (mode === 'plan') {
|
|
898
1072
|
const isReadOnly = isTrustedReadOnly(tool, finalInput, source)
|
|
899
1073
|
if (!isReadOnly) {
|
|
900
|
-
const msg = `plan mode: non-read-only tool "${toolName}" blocked. ${
|
|
1074
|
+
const msg = `plan mode: non-read-only tool "${toolName}" blocked. ${
|
|
1075
|
+
this.has('exit_plan_mode') ? PLAN_MODE_REFUSAL_WITH_PLAN_FILE : PLAN_MODE_REFUSAL
|
|
1076
|
+
}`
|
|
901
1077
|
span.setAttributes({
|
|
902
1078
|
[NAMZU.TOOL_SUCCESS]: false,
|
|
903
1079
|
[NAMZU.TOOL_ERROR]: msg,
|
|
@@ -1066,14 +1242,37 @@ function sourceToProvenance(source: ToolSourceRef): ToolProvenance | undefined {
|
|
|
1066
1242
|
* message means nothing has been compacted yet, so the whole history is the
|
|
1067
1243
|
* window.
|
|
1068
1244
|
*/
|
|
1069
|
-
function postCompactionWindow(messages: readonly Message[]):
|
|
1245
|
+
function postCompactionWindow(messages: readonly Message[]): {
|
|
1246
|
+
readonly summary?: SystemMessage
|
|
1247
|
+
readonly window: readonly Message[]
|
|
1248
|
+
} {
|
|
1070
1249
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
1071
1250
|
const message = messages[i]
|
|
1072
1251
|
if (message?.role === 'system' && isCompactionMessage(message.content)) {
|
|
1073
|
-
return messages.slice(i + 1)
|
|
1252
|
+
return { summary: message, window: messages.slice(i + 1) }
|
|
1074
1253
|
}
|
|
1075
1254
|
}
|
|
1076
|
-
return messages
|
|
1255
|
+
return { window: messages }
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
/** The words of a tool name: `mcp__github__create_issue` is mcp, github, create, issue. */
|
|
1259
|
+
function nameWords(name: string): string[] {
|
|
1260
|
+
return name
|
|
1261
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1 $2')
|
|
1262
|
+
.toLowerCase()
|
|
1263
|
+
.split(/[^a-z0-9]+/)
|
|
1264
|
+
.filter((word) => word.length > 0)
|
|
1265
|
+
}
|
|
1266
|
+
|
|
1267
|
+
/** The tool part of an `mcp__<server>__<tool>` name, lower-cased. */
|
|
1268
|
+
function mcpShortName(name: string): string | undefined {
|
|
1269
|
+
const at = name.lastIndexOf('__')
|
|
1270
|
+
if (!name.startsWith('mcp__') || at < 5 || at + 2 >= name.length) return undefined
|
|
1271
|
+
return name.slice(at + 2).toLowerCase()
|
|
1272
|
+
}
|
|
1273
|
+
|
|
1274
|
+
function escapeRegExp(text: string): string {
|
|
1275
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
1077
1276
|
}
|
|
1078
1277
|
|
|
1079
1278
|
/**
|
|
@@ -1147,3 +1346,20 @@ function failureFactsField(err: unknown): { facts?: ToolFacts } {
|
|
|
1147
1346
|
const facts = failureFactsFromError(err)
|
|
1148
1347
|
return facts ? { facts } : {}
|
|
1149
1348
|
}
|
|
1349
|
+
|
|
1350
|
+
/** The leading entries that fit the announcement budget, and how many were left out. */
|
|
1351
|
+
function capEntries(entries: readonly string[]): { shown: string[]; more: number } {
|
|
1352
|
+
const shown: string[] = []
|
|
1353
|
+
let chars = 0
|
|
1354
|
+
for (const entry of entries) {
|
|
1355
|
+
if (shown.length > 0 && chars + entry.length + 1 > MAX_TOOLS_CHANGED_CHARS) break
|
|
1356
|
+
shown.push(entry)
|
|
1357
|
+
chars += entry.length + 1
|
|
1358
|
+
}
|
|
1359
|
+
return { shown, more: entries.length - shown.length }
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
function capNames(names: readonly string[]): string {
|
|
1363
|
+
const { shown, more } = capEntries(names)
|
|
1364
|
+
return more > 0 ? `${shown.join(', ')} and ${more} more` : shown.join(', ')
|
|
1365
|
+
}
|