@namzu/sdk 65.3.0 → 67.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 +153 -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/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/public-runtime.d.ts +14 -6
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +22 -5
- 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 +7 -2
- package/dist/public-types.d.ts.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.map +1 -1
- package/dist/runtime/query/iteration/index.js +17 -3
- 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/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/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/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/index.d.ts +1 -0
- package/dist/types/provider/index.d.ts.map +1 -1
- package/dist/types/provider/interface.d.ts +12 -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/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/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/prompt/coding-agent-doctrine.ts +33 -38
- package/src/public-runtime.ts +107 -1
- package/src/public-tools.ts +11 -0
- package/src/public-types.ts +67 -1
- 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 +24 -3
- 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/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/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/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/index.ts +1 -0
- package/src/types/provider/interface.ts +13 -0
- package/src/types/provider/limits.ts +35 -0
- package/src/types/tool/index.ts +30 -2
- package/src/types/tool/presentation.ts +4 -0
- 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
|
@@ -51,7 +51,7 @@ export function unreadEditShownError(path: string, content: string): string | un
|
|
|
51
51
|
if (lines.length > 1 && lines[lines.length - 1] === '') lines.pop()
|
|
52
52
|
if (lines.length > UNREAD_EDIT_SHOWN_MAX_LINES) return undefined
|
|
53
53
|
const numbered = lines.map((line, i) => `${i + 1}\t${line}`).join('\n')
|
|
54
|
-
return `${path} had not been read in this session, so this edit was not applied. It has now been read for you; its current contents follow. Repeat the edit against them. Nothing was written.\n\n${numbered}`
|
|
54
|
+
return `${path} had not been read in this session, so this edit was not applied. It has now been read for you; its current contents follow. Repeat the edit against them, without reading the file again. Nothing was written.\n\n${numbered}`
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/** What `edit` tells the agent when the file was never read and is too large to hand over. */
|
|
@@ -78,3 +78,10 @@ export function movedSinceRead(
|
|
|
78
78
|
const seen = tracker.fingerprint?.(key)
|
|
79
79
|
return seen !== undefined && seen !== fingerprintContent(current)
|
|
80
80
|
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Said after a write or an edit went through. A model that is told only "done"
|
|
84
|
+
* reads the file back to be sure, which costs a request and shows it what it
|
|
85
|
+
* just wrote; the result already is the proof.
|
|
86
|
+
*/
|
|
87
|
+
export const CURRENT_ON_DISK = 'The file on disk is now exactly this; no need to read it back.'
|
|
@@ -8,6 +8,7 @@ import { resolveWithinAnyReal, toolRoots } from '../paths.js'
|
|
|
8
8
|
import { atomicWriteFile } from './atomic-write-file.js'
|
|
9
9
|
import { clip, describeChange } from './classifier-input.js'
|
|
10
10
|
import {
|
|
11
|
+
CURRENT_ON_DISK,
|
|
11
12
|
fingerprintContent,
|
|
12
13
|
staleFileError,
|
|
13
14
|
unreadEditShownError,
|
|
@@ -408,16 +409,23 @@ function recordDrift(context: ToolContext, key: string): void {
|
|
|
408
409
|
|
|
409
410
|
type EditAdmission =
|
|
410
411
|
| { success: false; output: ''; error: string; facts: ToolFacts }
|
|
411
|
-
| { success: true; result: ReturnType<typeof applyEdit
|
|
412
|
+
| { success: true; result: ReturnType<typeof applyEdit>; unreadNote?: string }
|
|
413
|
+
|
|
414
|
+
/** Appended to the result of an edit that was applied to a file the session had not read. */
|
|
415
|
+
const UNREAD_APPLIED_NOTE = '(file was not read before; the edit matched exactly and was applied)'
|
|
412
416
|
|
|
413
417
|
/**
|
|
414
418
|
* Decide whether this edit may run against the body now on disk, and apply it.
|
|
415
419
|
*
|
|
416
420
|
* Two rules, in this order:
|
|
417
421
|
*
|
|
418
|
-
* 1. A file the session never read is
|
|
419
|
-
*
|
|
420
|
-
*
|
|
422
|
+
* 1. A file the session never read is read here. When every replacement in the
|
|
423
|
+
* call matches the body exactly (once, or at least once under `replace_all`)
|
|
424
|
+
* the model plainly knew the text, from a shell print or a search, so the
|
|
425
|
+
* edit is applied and the read is credited. Otherwise (no match, an
|
|
426
|
+
* ambiguous match, an insertion, or a body that is not text) the edit is
|
|
427
|
+
* refused and, for a small file, the contents are handed back. A host that
|
|
428
|
+
* supplies no tracker has no ledger to ask and is not refused.
|
|
421
429
|
* 2. A file that moved since the read is refused, whatever the operations are.
|
|
422
430
|
* There is no recovery: a replacement that "still applies" to the moved body
|
|
423
431
|
* can apply somewhere the model never meant (the read said `a = 1`, the file
|
|
@@ -434,6 +442,13 @@ function admitAgainstRead(
|
|
|
434
442
|
): EditAdmission {
|
|
435
443
|
const tracker = context.fileReadTracker
|
|
436
444
|
if (tracker && !tracker.hasRead(key)) {
|
|
445
|
+
if (!content.includes('\u0000') && operations.every((op) => op.operation === 'replace')) {
|
|
446
|
+
const applied = applyEdit(content, operations)
|
|
447
|
+
if (applied.success) {
|
|
448
|
+
tracker.recordRead(key, content)
|
|
449
|
+
return { success: true, result: applied, unreadNote: UNREAD_APPLIED_NOTE }
|
|
450
|
+
}
|
|
451
|
+
}
|
|
437
452
|
// The file is already in hand, so a small one is shown and the read that
|
|
438
453
|
// showing amounts to is credited: the repeat is one call and is admitted.
|
|
439
454
|
const shown = unreadEditShownError(key, content)
|
|
@@ -495,6 +510,77 @@ function refusedEdit(result: EditApplyFailure, path: string) {
|
|
|
495
510
|
}
|
|
496
511
|
}
|
|
497
512
|
|
|
513
|
+
/**
|
|
514
|
+
* The refusals `execute` would give that need no person's answer, asked before
|
|
515
|
+
* a reviewer is: arguments that name no change, a file the session never read
|
|
516
|
+
* whose text the call does not match, a file that moved since the read, and
|
|
517
|
+
* replacements that do not apply. The text is the one `execute` gives, so the
|
|
518
|
+
* model sees the same words with or without a dialog. It says nothing when it
|
|
519
|
+
* cannot tell (an unreadable or missing file, a path outside the roots); those
|
|
520
|
+
* keep their own answers at run time.
|
|
521
|
+
*/
|
|
522
|
+
async function refuseEditBeforeReview(
|
|
523
|
+
input: EditInput,
|
|
524
|
+
context: ToolContext,
|
|
525
|
+
): Promise<{ readonly error: string; readonly facts?: ToolFacts } | undefined> {
|
|
526
|
+
const parsed = inputSchema.safeParse(input)
|
|
527
|
+
if (!parsed.success) return undefined
|
|
528
|
+
const normalized = normalizeEditInput(parsed.data)
|
|
529
|
+
if (!normalized.success) return { error: normalized.error }
|
|
530
|
+
const noOp = normalized.operations.findIndex(
|
|
531
|
+
(operation) => operation.operation === 'replace' && operation.oldString === operation.newString,
|
|
532
|
+
)
|
|
533
|
+
if (noOp >= 0) {
|
|
534
|
+
return {
|
|
535
|
+
error:
|
|
536
|
+
normalized.operations.length === 1
|
|
537
|
+
? 'old_string/oldStr and new_string/newStr are identical — no change needed'
|
|
538
|
+
: `edits[${noOp}]: old_string and new_string are identical — no change needed. Nothing was written.`,
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
// In a sandbox only the moved-since-read check runs here, as before; the
|
|
542
|
+
// unread-file refusals are given when the call runs there, so a guest that is
|
|
543
|
+
// not admitted yet, or that holds a file the host has never seen, is not
|
|
544
|
+
// judged from a read made before anyone approved the call.
|
|
545
|
+
if (context.sandbox) return staleBeforeReview(context, parsed.data.path, 'edit')
|
|
546
|
+
let key: string
|
|
547
|
+
let content: string
|
|
548
|
+
try {
|
|
549
|
+
key = await resolveWithinAnyReal(toolRoots(context), parsed.data.path)
|
|
550
|
+
content = await readFile(key, 'utf-8')
|
|
551
|
+
} catch {
|
|
552
|
+
return undefined
|
|
553
|
+
}
|
|
554
|
+
const tracker = context.fileReadTracker
|
|
555
|
+
if (tracker && !tracker.hasRead(key)) {
|
|
556
|
+
// An unread file is edited when every replacement matches it exactly.
|
|
557
|
+
if (
|
|
558
|
+
!content.includes('\u0000') &&
|
|
559
|
+
normalized.operations.every((op) => op.operation === 'replace')
|
|
560
|
+
) {
|
|
561
|
+
if (applyEdit(content, normalized.operations).success) return undefined
|
|
562
|
+
}
|
|
563
|
+
const shown = unreadEditShownError(key, content)
|
|
564
|
+
if (shown !== undefined) tracker.recordRead(key, content)
|
|
565
|
+
return {
|
|
566
|
+
error: shown ?? unreadEditTooLargeError(key),
|
|
567
|
+
facts: { kind: 'failure', reason: 'not_read', subject: key },
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
const stale = await staleBeforeReview(context, parsed.data.path, 'edit')
|
|
571
|
+
if (stale) return stale
|
|
572
|
+
const applied = applyEdit(content, normalized.operations)
|
|
573
|
+
if (!applied.success) {
|
|
574
|
+
return {
|
|
575
|
+
error: applied.error,
|
|
576
|
+
...(applied.reason
|
|
577
|
+
? { facts: { kind: 'failure' as const, reason: applied.reason, subject: key } }
|
|
578
|
+
: {}),
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
return undefined
|
|
582
|
+
}
|
|
583
|
+
|
|
498
584
|
export const EditTool = defineTool({
|
|
499
585
|
name: 'edit',
|
|
500
586
|
description:
|
|
@@ -516,7 +602,7 @@ export const EditTool = defineTool({
|
|
|
516
602
|
pathArgument: 'path',
|
|
517
603
|
// A file that moved since the read is refused whatever the replacement is,
|
|
518
604
|
// so the person is not asked to approve one that cannot run.
|
|
519
|
-
refuseBeforeReview:
|
|
605
|
+
refuseBeforeReview: refuseEditBeforeReview,
|
|
520
606
|
// The classifier judges which file changes and in what way, in a line.
|
|
521
607
|
classifierInput: (input: EditInput) => {
|
|
522
608
|
if (input.edits !== undefined && input.edits.length > 0) {
|
|
@@ -639,7 +725,7 @@ export const EditTool = defineTool({
|
|
|
639
725
|
const changed = editFacts(parsed.data.path, result.replacements, content, result.content)
|
|
640
726
|
return {
|
|
641
727
|
success: true as const,
|
|
642
|
-
output: `Edited ${parsed.data.path}: ${result.replacements} replacement(s) (+${changed.diff.added} -${changed.diff.removed}) [sandboxed]`,
|
|
728
|
+
output: `Edited ${parsed.data.path}: ${result.replacements} replacement(s) (+${changed.diff.added} -${changed.diff.removed}) [sandboxed]${admitted.unreadNote ? ` ${admitted.unreadNote}` : ''}. ${CURRENT_ON_DISK}`,
|
|
643
729
|
data: {
|
|
644
730
|
path: parsed.data.path,
|
|
645
731
|
replacements: result.replacements,
|
|
@@ -670,7 +756,7 @@ export const EditTool = defineTool({
|
|
|
670
756
|
const changed = editFacts(hostPath, result.replacements, content, result.content)
|
|
671
757
|
return {
|
|
672
758
|
success: true as const,
|
|
673
|
-
output: `Edited ${hostPath}: ${result.replacements} replacement(s) (+${changed.diff.added} -${changed.diff.removed})`,
|
|
759
|
+
output: `Edited ${hostPath}: ${result.replacements} replacement(s) (+${changed.diff.added} -${changed.diff.removed})${admitted.unreadNote ? ` ${admitted.unreadNote}` : ''}. ${CURRENT_ON_DISK}`,
|
|
674
760
|
data: { path: hostPath, replacements: result.replacements },
|
|
675
761
|
facts: changed.facts,
|
|
676
762
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto'
|
|
2
2
|
import type { ToolDiffHunk, ToolResult } from '../../types/tool/index.js'
|
|
3
|
+
import { CURRENT_ON_DISK } from './content-fingerprint.js'
|
|
3
4
|
import { lineDiff } from './line-diff.js'
|
|
4
5
|
|
|
5
6
|
/** One side of a change, context included: the rows that exist before (`-`) or after (`+`). */
|
|
@@ -44,7 +45,7 @@ export function fileWriteResult(
|
|
|
44
45
|
const summary = `${label} ${path}${before === null ? '' : ` (+${diff.added} -${diff.removed})`}${newlineChanged ? ' · final newline changed' : ''}`
|
|
45
46
|
return {
|
|
46
47
|
success: true,
|
|
47
|
-
output: `${summary} · ${bytes} bytes`,
|
|
48
|
+
output: `${summary} · ${bytes} bytes. ${CURRENT_ON_DISK}`,
|
|
48
49
|
facts: {
|
|
49
50
|
kind: 'write',
|
|
50
51
|
path,
|
|
@@ -382,7 +382,7 @@ export const GrepTool = defineTool({
|
|
|
382
382
|
return {
|
|
383
383
|
success: false,
|
|
384
384
|
output: '',
|
|
385
|
-
error: `Invalid regex pattern: ${err instanceof Error ? err.message : String(err)}
|
|
385
|
+
error: `Invalid regex pattern: ${err instanceof Error ? err.message : String(err)}. Patterns are JavaScript regular expressions with no inline flags such as (?i); for a case-insensitive search set \`case_sensitive: false\`.`,
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
388
|
|
|
@@ -83,7 +83,7 @@ export const JobTool = defineTool({
|
|
|
83
83
|
if (all.length === 0) return { success: true, output: 'No background jobs.' }
|
|
84
84
|
const now = Date.now()
|
|
85
85
|
const lines = all.map((job) => {
|
|
86
|
-
const label = job.
|
|
86
|
+
const label = job.description ?? job.command
|
|
87
87
|
if (job.startedAt === undefined) {
|
|
88
88
|
return `${job.id} ${job.status.padEnd(8)} ${job.kind === 'monitor' ? `monitor · ${label}` : label}`
|
|
89
89
|
}
|
|
@@ -160,14 +160,16 @@ export const JobTool = defineTool({
|
|
|
160
160
|
? `failed to start: ${read.error}`
|
|
161
161
|
: `${read.status}${read.exitCode === undefined ? '' : ` with code ${read.exitCode}`}`
|
|
162
162
|
|
|
163
|
+
const outputFile = jobs.get(input.id)?.outputFile
|
|
163
164
|
return {
|
|
164
165
|
success: true,
|
|
165
|
-
output: `${notice}${read.chunk || '(no new output)'}\n\n[job ${input.id} is ${status}; next_offset ${read.nextOffset}]`,
|
|
166
|
+
output: `${notice}${read.chunk || '(no new output)'}\n\n[job ${input.id} is ${status}; next_offset ${read.nextOffset}${outputFile === undefined ? '' : `; the whole output is in ${outputFile}`}]`,
|
|
166
167
|
data: {
|
|
167
168
|
jobId: input.id,
|
|
168
169
|
status: read.status,
|
|
169
170
|
nextOffset: read.nextOffset,
|
|
170
171
|
droppedBytes: read.droppedBytes,
|
|
172
|
+
...(outputFile === undefined ? {} : { outputFile }),
|
|
171
173
|
...(read.exitCode === undefined ? {} : { exitCode: read.exitCode }),
|
|
172
174
|
...(read.error === undefined ? {} : { error: read.error }),
|
|
173
175
|
},
|
|
@@ -349,7 +349,12 @@ export function createMonitorTool(options: MonitorToolOptions = {}) {
|
|
|
349
349
|
success: true,
|
|
350
350
|
output: `Monitor started (job ${job.id}, expires in ${formatMonitorDuration(timeoutMs)} unless the command ends first; you get one notice at expiry — start it again if you still need the watch). Each line the command prints to stdout reaches you as an event while you keep working; do not poll or sleep. Stop it with job {"action":"kill","id":"${job.id}"}. An event may arrive while you are waiting for the user — it is not their reply.`,
|
|
351
351
|
data: { jobId: job.id, monitor: true, timeoutMs },
|
|
352
|
-
facts: {
|
|
352
|
+
facts: {
|
|
353
|
+
kind: 'command',
|
|
354
|
+
command: input.command as string,
|
|
355
|
+
background: true,
|
|
356
|
+
jobId: job.id,
|
|
357
|
+
},
|
|
353
358
|
}
|
|
354
359
|
} catch (err) {
|
|
355
360
|
// The per-owner cap, most likely; naming the limit is actionable.
|
|
@@ -1,16 +1,35 @@
|
|
|
1
1
|
import { z } from 'zod'
|
|
2
2
|
import { toolDiscoveryHint } from '../../registry/tool/execute.js'
|
|
3
|
+
import type { ToolDefinition } from '../../types/tool/index.js'
|
|
3
4
|
import { defineTool } from '../defineTool.js'
|
|
4
5
|
|
|
6
|
+
/** The most names one `select:` list loads. */
|
|
7
|
+
export const MAX_SELECT_NAMES = 64
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Results a search loads when `max_results` is not given. Top-5 is the
|
|
11
|
+
* literature's sweet spot (retrieval at k=5 matches oracle toolsets) and
|
|
12
|
+
* bounds how much schema weight a single search can add to every later
|
|
13
|
+
* iteration; each activation also busts the prompt-cache prefix once.
|
|
14
|
+
*/
|
|
15
|
+
export const DEFAULT_MAX_RESULTS = 5
|
|
16
|
+
|
|
5
17
|
const inputSchema = z.object({
|
|
6
|
-
query: z
|
|
18
|
+
query: z
|
|
19
|
+
.string()
|
|
20
|
+
.describe(
|
|
21
|
+
'"select:name1,name2" to load exactly those tools by name, or keywords to search, or "+term" words that every result must contain',
|
|
22
|
+
),
|
|
23
|
+
max_results: z
|
|
24
|
+
.number()
|
|
25
|
+
.int()
|
|
26
|
+
.min(1)
|
|
27
|
+
.max(MAX_SELECT_NAMES)
|
|
28
|
+
.optional()
|
|
29
|
+
.describe(`Most tools a keyword search loads (default ${DEFAULT_MAX_RESULTS})`),
|
|
7
30
|
})
|
|
8
31
|
|
|
9
|
-
|
|
10
|
-
// spot (retrieval at k=5 matches oracle toolsets) and bounds how much
|
|
11
|
-
// schema weight a single search can add to every subsequent iteration —
|
|
12
|
-
// each activation also busts the prompt-cache prefix once.
|
|
13
|
-
const ACTIVATION_TOP_K = 5
|
|
32
|
+
const SELECT_PREFIX = /^select:(.*)$/is
|
|
14
33
|
|
|
15
34
|
// Near-misses are reported name+hint WITHOUT activating, so a retrieval
|
|
16
35
|
// miss becomes one cheap re-query instead of a dead end (the fixed-top-k
|
|
@@ -20,8 +39,13 @@ const NEAR_MISS_LIMIT = 5
|
|
|
20
39
|
export const SearchToolsTool = defineTool({
|
|
21
40
|
name: 'search_tools',
|
|
22
41
|
description:
|
|
23
|
-
'
|
|
24
|
-
'Use this only when a needed deferred tool schema is absent from the current runtime tools parameter. If its schema is already visible, call the tool directly without searching again
|
|
42
|
+
'Load deferred tools so they can be called. ' +
|
|
43
|
+
'Use this only when a needed deferred tool schema is absent from the current runtime tools parameter. If its schema is already visible, call the tool directly without searching again.\n\n' +
|
|
44
|
+
'Query forms:\n' +
|
|
45
|
+
'- "select:read_memory,save_memory" loads exactly those tools by name. Use it when you know the names.\n' +
|
|
46
|
+
'- "notebook jupyter" searches by keywords. A word in a tool\'s name ranks far above a word in its description. Loads the best matches, up to max_results (default 5).\n' +
|
|
47
|
+
'- "+slack send" requires "slack" in the result and ranks by the rest.\n' +
|
|
48
|
+
"A query that is exactly one tool's name loads that tool and no other match, plus any companions it declares.",
|
|
25
49
|
inputSchema,
|
|
26
50
|
category: 'analysis',
|
|
27
51
|
permissions: [],
|
|
@@ -37,26 +61,135 @@ export const SearchToolsTool = defineTool({
|
|
|
37
61
|
error: 'Tool registry not available in this context.',
|
|
38
62
|
}
|
|
39
63
|
}
|
|
40
|
-
|
|
64
|
+
const registry = context.toolRegistry
|
|
41
65
|
const allowed = context.allowedTools !== undefined ? new Set(context.allowedTools) : null
|
|
66
|
+
const permitted = (name: string) => !allowed || allowed.has(name)
|
|
67
|
+
|
|
68
|
+
const select = SELECT_PREFIX.exec(input.query.trim())
|
|
69
|
+
if (select) {
|
|
70
|
+
const requested = (select[1] ?? '')
|
|
71
|
+
.split(',')
|
|
72
|
+
.map((name) => name.trim())
|
|
73
|
+
.filter((name) => name.length > 0)
|
|
74
|
+
const names = requested.slice(0, MAX_SELECT_NAMES)
|
|
75
|
+
const dropped = requested.slice(MAX_SELECT_NAMES)
|
|
76
|
+
const picked = registry.select
|
|
77
|
+
? registry.select(names)
|
|
78
|
+
: selectByName(registry.searchDeferred.bind(registry), registry.has.bind(registry), names)
|
|
79
|
+
const found = picked.found.filter((tool) => permitted(tool.name))
|
|
80
|
+
const refused = picked.found.filter((tool) => !permitted(tool.name)).map((tool) => tool.name)
|
|
81
|
+
const sections: string[] = []
|
|
82
|
+
if (found.length > 0) sections.push(describeLoaded(found, new Map()))
|
|
83
|
+
const companions = found.flatMap((tool) =>
|
|
84
|
+
(tool.loadsWith ?? []).filter(
|
|
85
|
+
(name) => !found.some((other) => other.name === name) && permitted(name),
|
|
86
|
+
),
|
|
87
|
+
)
|
|
88
|
+
if (companions.length > 0) {
|
|
89
|
+
sections.push(
|
|
90
|
+
`Related tools that are not loaded: ${[...new Set(companions)].join(', ')}. Select them too if you need them.`,
|
|
91
|
+
)
|
|
92
|
+
}
|
|
93
|
+
// A short MCP name that matched several tools loads all of them; say so,
|
|
94
|
+
// so the model is not surprised by tools it did not name in full.
|
|
95
|
+
const ambiguous = names.flatMap((name) => {
|
|
96
|
+
const suffix = `__${name.toLowerCase()}`
|
|
97
|
+
const hits = found.filter(
|
|
98
|
+
(tool) =>
|
|
99
|
+
tool.name.toLowerCase() !== name.toLowerCase() &&
|
|
100
|
+
tool.name.toLowerCase().endsWith(suffix),
|
|
101
|
+
)
|
|
102
|
+
return hits.length > 1 ? [`${name} (${hits.map((tool) => tool.name).join(', ')})`] : []
|
|
103
|
+
})
|
|
104
|
+
if (ambiguous.length > 0) {
|
|
105
|
+
sections.push(
|
|
106
|
+
`A short name matched more than one tool, and all of them are loaded: ${ambiguous.join('; ')}. Use the full name to load one.`,
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
if (dropped.length > 0) {
|
|
110
|
+
sections.push(
|
|
111
|
+
`Not loaded, because one select takes at most ${MAX_SELECT_NAMES} names: ${dropped.join(', ')}. Select them in another call.`,
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
if (picked.available.length > 0) {
|
|
115
|
+
sections.push(`Already loaded, call directly: ${picked.available.join(', ')}.`)
|
|
116
|
+
}
|
|
117
|
+
const missing = [...picked.missing, ...refused]
|
|
118
|
+
if (missing.length > 0) {
|
|
119
|
+
sections.push(
|
|
120
|
+
`No tool named: ${missing.join(', ')}. A name must be exact; search by keywords to find it.`,
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
if (sections.length === 0) {
|
|
124
|
+
return { success: true, output: 'No tool names given after "select:".' }
|
|
125
|
+
}
|
|
126
|
+
return {
|
|
127
|
+
success: true,
|
|
128
|
+
output: sections.join('\n\n'),
|
|
129
|
+
reveals: found.map((tool) => tool.name),
|
|
130
|
+
data: {
|
|
131
|
+
activated: found.map((tool) => tool.name),
|
|
132
|
+
count: found.length,
|
|
133
|
+
...(picked.available.length > 0 ? { alreadyLoaded: picked.available } : {}),
|
|
134
|
+
...(missing.length > 0 ? { missing } : {}),
|
|
135
|
+
...(dropped.length > 0 ? { notSelected: dropped } : {}),
|
|
136
|
+
},
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const limit = input.max_results ?? DEFAULT_MAX_RESULTS
|
|
42
141
|
// `searchDeferred` returns a ranked list (score-descending), so slicing
|
|
43
142
|
// the head is a true top-k reveal, not an arbitrary subset.
|
|
44
|
-
const ranked =
|
|
45
|
-
.searchDeferred(input.query)
|
|
46
|
-
.filter((tool) => !allowed || allowed.has(tool.name))
|
|
143
|
+
const ranked = registry.searchDeferred(input.query).filter((tool) => permitted(tool.name))
|
|
47
144
|
|
|
48
145
|
if (ranked.length === 0) {
|
|
146
|
+
// One sentence for three different states read as "this tool does not exist", and a model
|
|
147
|
+
// that had just used the tool went looking for its own words on disk. Say which state it is.
|
|
148
|
+
const asked = input.query.trim()
|
|
149
|
+
if (registry.has(asked)) {
|
|
150
|
+
if (!permitted(asked)) {
|
|
151
|
+
return {
|
|
152
|
+
success: true,
|
|
153
|
+
output: `${asked} is not available in this session. Carry on without it.`,
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
if (registry.availability(asked) === 'active') {
|
|
157
|
+
return { success: true, output: `${asked} is already loaded: call it directly.` }
|
|
158
|
+
}
|
|
159
|
+
}
|
|
49
160
|
return {
|
|
50
161
|
success: true,
|
|
51
|
-
output: `No deferred tools matching "${input.query}".`,
|
|
162
|
+
output: `No deferred tools matching "${input.query}". A tool whose schema you can already see is loaded: call it directly. Only names listed under deferred_tools can be loaded; a tool that is not listed there does not exist in this session, so carry on without it.`,
|
|
52
163
|
}
|
|
53
164
|
}
|
|
54
165
|
|
|
55
|
-
const activated = ranked.slice(0,
|
|
56
|
-
const nearMisses = ranked.slice(
|
|
166
|
+
const activated = ranked.slice(0, limit)
|
|
167
|
+
const nearMisses = ranked.slice(limit, limit + NEAR_MISS_LIMIT)
|
|
57
168
|
|
|
58
|
-
|
|
59
|
-
|
|
169
|
+
// A tool may declare companions that are needed right after it. They
|
|
170
|
+
// load in this same call, from the deferred roster and inside the same
|
|
171
|
+
// allow-list, so the model does not pay a second search for them.
|
|
172
|
+
// Names already activated or already loaded are skipped; one level only.
|
|
173
|
+
const activatedNames = new Set(activated.map((t) => t.name))
|
|
174
|
+
const companions: ToolDefinition[] = []
|
|
175
|
+
for (const tool of activated) {
|
|
176
|
+
for (const name of tool.loadsWith ?? []) {
|
|
177
|
+
if (activatedNames.has(name)) continue
|
|
178
|
+
const companion = registry
|
|
179
|
+
.searchDeferred(name)
|
|
180
|
+
.find((candidate) => candidate.name === name && permitted(name))
|
|
181
|
+
if (!companion) continue
|
|
182
|
+
activatedNames.add(name)
|
|
183
|
+
companions.push(companion)
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const loaded = [...activated, ...companions]
|
|
187
|
+
const companionOf = new Map<string, string>()
|
|
188
|
+
for (const tool of activated) {
|
|
189
|
+
for (const name of tool.loadsWith ?? []) companionOf.set(name, tool.name)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const sections = [describeLoaded(loaded, companionOf, companions)]
|
|
60
193
|
|
|
61
194
|
if (nearMisses.length > 0) {
|
|
62
195
|
const hints = nearMisses
|
|
@@ -66,7 +199,7 @@ export const SearchToolsTool = defineTool({
|
|
|
66
199
|
})
|
|
67
200
|
.join('\n')
|
|
68
201
|
sections.push(
|
|
69
|
-
`Also matched but NOT loaded (
|
|
202
|
+
`Also matched but NOT loaded (select one by exact name, "select:<name>", or raise max_results):\n${hints}`,
|
|
70
203
|
)
|
|
71
204
|
}
|
|
72
205
|
|
|
@@ -77,12 +210,54 @@ export const SearchToolsTool = defineTool({
|
|
|
77
210
|
// tool message REVEALS (`ToolResult.reveals`, persisted as
|
|
78
211
|
// `ToolMessage.revealedTools`), not from a mutation made here. See
|
|
79
212
|
// `toolsets/manager.ts`'s `availability()`.
|
|
80
|
-
reveals:
|
|
213
|
+
reveals: loaded.map((t) => t.name),
|
|
81
214
|
data: {
|
|
82
|
-
activated:
|
|
83
|
-
count:
|
|
215
|
+
activated: loaded.map((t) => t.name),
|
|
216
|
+
count: loaded.length,
|
|
84
217
|
nearMisses: nearMisses.map((t) => t.name),
|
|
218
|
+
...(companions.length > 0 ? { companions: companions.map((t) => t.name) } : {}),
|
|
85
219
|
},
|
|
86
220
|
}
|
|
87
221
|
},
|
|
88
222
|
})
|
|
223
|
+
|
|
224
|
+
function describeLoaded(
|
|
225
|
+
loaded: readonly ToolDefinition[],
|
|
226
|
+
companionOf: ReadonlyMap<string, string>,
|
|
227
|
+
companions: readonly ToolDefinition[] = [],
|
|
228
|
+
): string {
|
|
229
|
+
const lines = loaded
|
|
230
|
+
.map((t) => {
|
|
231
|
+
const owner = companionOf.get(t.name)
|
|
232
|
+
const note = companions.includes(t) && owner ? ` (loaded with ${owner})` : ''
|
|
233
|
+
return `- ${t.name}${note}: ${t.description}`
|
|
234
|
+
})
|
|
235
|
+
.join('\n')
|
|
236
|
+
return `Activated ${loaded.length} tool(s):\n${lines}`
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* `select:` against a view that has no `select` of its own: an exact-name
|
|
241
|
+
* match over the deferred search. Only full names match here; the MCP
|
|
242
|
+
* short-name form needs the manager's own `select`.
|
|
243
|
+
*/
|
|
244
|
+
function selectByName(
|
|
245
|
+
search: (query: string) => readonly ToolDefinition[],
|
|
246
|
+
has: (name: string) => boolean,
|
|
247
|
+
names: readonly string[],
|
|
248
|
+
): {
|
|
249
|
+
readonly found: readonly ToolDefinition[]
|
|
250
|
+
readonly available: readonly string[]
|
|
251
|
+
readonly missing: readonly string[]
|
|
252
|
+
} {
|
|
253
|
+
const found: ToolDefinition[] = []
|
|
254
|
+
const available: string[] = []
|
|
255
|
+
const missing: string[] = []
|
|
256
|
+
for (const name of names) {
|
|
257
|
+
const hit = search(name).find((tool) => tool.name.toLowerCase() === name.toLowerCase())
|
|
258
|
+
if (hit) found.push(hit)
|
|
259
|
+
else if (has(name)) available.push(name)
|
|
260
|
+
else missing.push(name)
|
|
261
|
+
}
|
|
262
|
+
return { found, available, missing }
|
|
263
|
+
}
|