@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
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dangerous-command floor, read from what a command line RUNS.
|
|
3
|
+
*
|
|
4
|
+
* The floor used to be eleven regular expressions tested against the raw text
|
|
5
|
+
* of the command, every hit a denial that no mode could lift. Two things were
|
|
6
|
+
* wrong with that. It read text, not commands, so `echo "needs sudo"` and a
|
|
7
|
+
* `# sudo` comment were refused as though they ran. And it put two different
|
|
8
|
+
* kinds of thing in one list: acts that cannot be undone, and acts that are
|
|
9
|
+
* merely a person's call (a root shell, a remote login, an `eval`). Bypass and
|
|
10
|
+
* auto mode exist so a person can say "I accept the risk"; a hard denial on
|
|
11
|
+
* `sudo -n true` left them no way to.
|
|
12
|
+
*
|
|
13
|
+
* So there are two tiers, and a finding says which:
|
|
14
|
+
*
|
|
15
|
+
* - `stop`: irreversible, refused in every mode. A recursive removal of the
|
|
16
|
+
* file system root, the home directory, a top-level directory, or a
|
|
17
|
+
* variable that may be empty followed by one; a file system created on a
|
|
18
|
+
* device; a raw write to a device with `dd of=/dev/…`; a fork bomb; a
|
|
19
|
+
* world-writable root.
|
|
20
|
+
* - `ask`: intent, not damage. `sudo`, `su -`, `ssh user@host`, `eval` of a
|
|
21
|
+
* dynamic string, a download piped into a shell. The person is asked in the
|
|
22
|
+
* modes that ask; bypass and auto lift it as they lift any other ask.
|
|
23
|
+
*
|
|
24
|
+
* Strict mode (`strict: true`) keeps the old list as it was: every entry a
|
|
25
|
+
* `stop`, matched on the raw text.
|
|
26
|
+
*
|
|
27
|
+
* This is not a security boundary (see `DANGEROUS_PATTERNS`). A command
|
|
28
|
+
* assembled at runtime is read as far as the lexer can see it; the sandbox is
|
|
29
|
+
* the boundary.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import { homedir } from 'node:os'
|
|
33
|
+
import { posix } from 'node:path'
|
|
34
|
+
|
|
35
|
+
import { DANGEROUS_PATTERNS, DANGEROUS_REASONS, FORK_BOMB } from '../constants/tools/index.js'
|
|
36
|
+
|
|
37
|
+
import { skipOneReexecWrapper } from './reexec-wrapper.js'
|
|
38
|
+
import {
|
|
39
|
+
BARE_HOME,
|
|
40
|
+
EMPTY_VARIABLE_ROOT,
|
|
41
|
+
EMPTY_VARIABLE_TOP,
|
|
42
|
+
fold,
|
|
43
|
+
slashes,
|
|
44
|
+
targetsOf,
|
|
45
|
+
} from './removal.js'
|
|
46
|
+
import {
|
|
47
|
+
type ShellCommand,
|
|
48
|
+
type ShellDialect,
|
|
49
|
+
type ShellWord,
|
|
50
|
+
basename,
|
|
51
|
+
lexShellCommandLine,
|
|
52
|
+
} from './shell-lexer.js'
|
|
53
|
+
|
|
54
|
+
export type DangerousTier = 'stop' | 'ask'
|
|
55
|
+
|
|
56
|
+
export interface DangerousFinding {
|
|
57
|
+
readonly tier: DangerousTier
|
|
58
|
+
/** What the command does, as a clause that starts with "it": "it removes the file system root". */
|
|
59
|
+
readonly reason: string
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface FindDangerousOptions {
|
|
63
|
+
/** The shell that runs the line; `sh` when unknown, which holds for every POSIX shell. */
|
|
64
|
+
readonly dialect?: ShellDialect
|
|
65
|
+
/** Every entry of the raw-text list is a `stop`. */
|
|
66
|
+
readonly strict?: boolean
|
|
67
|
+
/** The operator's home directory; the host's own when omitted. */
|
|
68
|
+
readonly home?: string
|
|
69
|
+
/** Environment deciding whether a variable may be empty; `process.env` when omitted. */
|
|
70
|
+
readonly env?: Readonly<Record<string, string | undefined>>
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** One program a command runs: the command's own head, or what a wrapper (`sudo`, `env`, `nice`) runs. */
|
|
74
|
+
interface Layer {
|
|
75
|
+
readonly program: string
|
|
76
|
+
readonly args: readonly ShellWord[]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const MAX_LAYERS = 8
|
|
80
|
+
|
|
81
|
+
type Variables = ReadonlyMap<string, string>
|
|
82
|
+
const NO_VARIABLES: Variables = new Map()
|
|
83
|
+
|
|
84
|
+
function plainWord(value: string): ShellWord {
|
|
85
|
+
return { text: value, value, expands: false, quoted: false, substitutes: false }
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** `NAME=value` assignments of the whole line whose value is written out, for a head word that is a variable. */
|
|
89
|
+
function variablesOf(commands: readonly ShellCommand[]): Variables {
|
|
90
|
+
const out = new Map<string, string>()
|
|
91
|
+
for (const command of commands) {
|
|
92
|
+
for (const word of command.words.slice(0, command.assignments)) {
|
|
93
|
+
const match = /^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/s.exec(word.value)
|
|
94
|
+
if (match !== null && !word.expands) out.set(match[1] as string, match[2] as string)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return out
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The program a head word that expands will run, when its text says so: a
|
|
102
|
+
* variable the line sets (`"$S" ls` after `S=sudo`), or a substitution that
|
|
103
|
+
* only prints a name (`$(echo sudo) ls`). `undefined` when it cannot be told.
|
|
104
|
+
*/
|
|
105
|
+
function resolveHead(head: ShellWord, vars: Variables): string | undefined {
|
|
106
|
+
const variable = /^"?\$(?:\{([A-Za-z_]\w*)\}|([A-Za-z_]\w*))"?$/.exec(head.text)
|
|
107
|
+
if (variable !== null) {
|
|
108
|
+
const value = vars.get((variable[1] ?? variable[2]) as string)
|
|
109
|
+
return value === undefined || /\s/.test(value) ? undefined : basename(value)
|
|
110
|
+
}
|
|
111
|
+
const printed =
|
|
112
|
+
/^"?(?:\$\(|`)\s*(?:echo|printf)\s+(?:-[A-Za-z]+\s+)*(?:'([^'\s]+)'|"([^"\s]+)"|([^\s'"$`()]+))\s*(?:\)|`)"?$/.exec(
|
|
113
|
+
head.text,
|
|
114
|
+
)
|
|
115
|
+
if (printed !== null) {
|
|
116
|
+
const name = printed[1] ?? printed[2] ?? printed[3]
|
|
117
|
+
return name === undefined ? undefined : basename(name)
|
|
118
|
+
}
|
|
119
|
+
return undefined
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** `xargs`' own options that take the next word as their value. */
|
|
123
|
+
const XARGS_VALUE_OPTIONS = new Set([
|
|
124
|
+
'-I',
|
|
125
|
+
'-n',
|
|
126
|
+
'-P',
|
|
127
|
+
'-L',
|
|
128
|
+
'-l',
|
|
129
|
+
'-s',
|
|
130
|
+
'-d',
|
|
131
|
+
'-E',
|
|
132
|
+
'-e',
|
|
133
|
+
'-a',
|
|
134
|
+
'-J',
|
|
135
|
+
'--arg-file',
|
|
136
|
+
'--delimiter',
|
|
137
|
+
'--max-args',
|
|
138
|
+
'--max-procs',
|
|
139
|
+
'--max-lines',
|
|
140
|
+
'--max-chars',
|
|
141
|
+
'--eof',
|
|
142
|
+
'--process-slot-var',
|
|
143
|
+
])
|
|
144
|
+
|
|
145
|
+
/** The command `xargs` runs, as a word list, or `undefined` when it has none. */
|
|
146
|
+
function xargsCommand(args: readonly ShellWord[]): readonly ShellWord[] | undefined {
|
|
147
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
148
|
+
const value = (args[i] as ShellWord).value
|
|
149
|
+
if (value === '--') return args.slice(i + 1)
|
|
150
|
+
if (!value.startsWith('-') || value === '-') return args.slice(i)
|
|
151
|
+
if (XARGS_VALUE_OPTIONS.has(value)) i += 1
|
|
152
|
+
}
|
|
153
|
+
return undefined
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const FIND_EXEC = new Set(['-exec', '-execdir', '-ok', '-okdir'])
|
|
157
|
+
|
|
158
|
+
/** The commands `find -exec … ;` (or `+`) runs, one word list each. */
|
|
159
|
+
function findCommands(args: readonly ShellWord[]): readonly ShellWord[][] {
|
|
160
|
+
const out: ShellWord[][] = []
|
|
161
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
162
|
+
if (!FIND_EXEC.has((args[i] as ShellWord).value)) continue
|
|
163
|
+
let end = i + 1
|
|
164
|
+
while (end < args.length && !['+', ';'].includes((args[end] as ShellWord).value)) end += 1
|
|
165
|
+
if (end > i + 1) out.push(args.slice(i + 1, end))
|
|
166
|
+
i = end
|
|
167
|
+
}
|
|
168
|
+
return out
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function layersOfWords(start: readonly ShellWord[], vars: Variables, used: { n: number }): Layer[] {
|
|
172
|
+
const layers: Layer[] = []
|
|
173
|
+
let words = start
|
|
174
|
+
while (used.n < MAX_LAYERS) {
|
|
175
|
+
used.n += 1
|
|
176
|
+
let head = words[0]
|
|
177
|
+
if (head === undefined) break
|
|
178
|
+
if (head.expands) {
|
|
179
|
+
const name = resolveHead(head, vars)
|
|
180
|
+
if (name === undefined) break
|
|
181
|
+
head = plainWord(name)
|
|
182
|
+
words = [head, ...words.slice(1)]
|
|
183
|
+
}
|
|
184
|
+
const program = basename(head.value)
|
|
185
|
+
const args = words.slice(1)
|
|
186
|
+
layers.push({ program, args })
|
|
187
|
+
if (program === 'xargs') {
|
|
188
|
+
const inner = xargsCommand(args)
|
|
189
|
+
if (inner !== undefined) layers.push(...layersOfWords(inner, vars, used))
|
|
190
|
+
break
|
|
191
|
+
}
|
|
192
|
+
if (program === 'find') {
|
|
193
|
+
for (const inner of findCommands(args)) layers.push(...layersOfWords(inner, vars, used))
|
|
194
|
+
break
|
|
195
|
+
}
|
|
196
|
+
const step = skipOneReexecWrapper(words)
|
|
197
|
+
if (step === null || !('rest' in step) || step.rest.length === 0) break
|
|
198
|
+
words = step.rest
|
|
199
|
+
}
|
|
200
|
+
return layers
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function layersOf(command: ShellCommand, vars: Variables = NO_VARIABLES): Layer[] {
|
|
204
|
+
return layersOfWords(command.words.slice(command.assignments), vars, { n: 0 })
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const SHELLS = new Set(['sh', 'bash', 'zsh', 'dash', 'ksh'])
|
|
208
|
+
const ELEVATORS = new Set(['sudo', 'sudoedit', 'doas', 'pkexec'])
|
|
209
|
+
const HARMLESS_DEVICES =
|
|
210
|
+
/^\/dev\/(?:null|zero|full|stdout|stderr|stdin|tty|fd\/|(?:shm|pts|tcp|udp)(?:\/|$))/
|
|
211
|
+
const isDevice = (value: string): boolean =>
|
|
212
|
+
value.startsWith('/dev/') && !HARMLESS_DEVICES.test(value)
|
|
213
|
+
|
|
214
|
+
/** Quoted text and comments blanked, so a word inside either never reads as a command. */
|
|
215
|
+
function blankQuotedText(line: string): string {
|
|
216
|
+
let out = ''
|
|
217
|
+
let quote: '"' | "'" | undefined
|
|
218
|
+
for (let i = 0; i < line.length; i += 1) {
|
|
219
|
+
const ch = line.charAt(i)
|
|
220
|
+
if (quote !== undefined) {
|
|
221
|
+
if (quote === '"' && ch === '\\') {
|
|
222
|
+
out += ' '
|
|
223
|
+
i += 1
|
|
224
|
+
continue
|
|
225
|
+
}
|
|
226
|
+
if (ch === quote) quote = undefined
|
|
227
|
+
out += ' '
|
|
228
|
+
continue
|
|
229
|
+
}
|
|
230
|
+
if (ch === '\\') {
|
|
231
|
+
out += ' '
|
|
232
|
+
i += 1
|
|
233
|
+
continue
|
|
234
|
+
}
|
|
235
|
+
if (ch === '"' || ch === "'") {
|
|
236
|
+
quote = ch
|
|
237
|
+
out += ' '
|
|
238
|
+
continue
|
|
239
|
+
}
|
|
240
|
+
const before = i === 0 ? ' ' : line.charAt(i - 1)
|
|
241
|
+
if (ch === '#' && /[\s;&|()]/.test(before)) {
|
|
242
|
+
const end = line.indexOf('\n', i)
|
|
243
|
+
const stop = end === -1 ? line.length : end
|
|
244
|
+
out += ' '.repeat(stop - i)
|
|
245
|
+
i = stop - 1
|
|
246
|
+
continue
|
|
247
|
+
}
|
|
248
|
+
out += ch
|
|
249
|
+
}
|
|
250
|
+
return out
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/** Whether `commands[index]` is a download that feeds the next command, a shell, through a pipe. */
|
|
254
|
+
function pipesDownloadIntoShell(
|
|
255
|
+
line: string,
|
|
256
|
+
commands: readonly ShellCommand[],
|
|
257
|
+
index: number,
|
|
258
|
+
cursors: { at: number },
|
|
259
|
+
vars: Variables,
|
|
260
|
+
): boolean {
|
|
261
|
+
const command = commands[index]
|
|
262
|
+
if (command === undefined || command.origin !== 'line') return false
|
|
263
|
+
const found = line.indexOf(command.text, cursors.at)
|
|
264
|
+
if (found === -1) return false
|
|
265
|
+
cursors.at = found + command.text.length
|
|
266
|
+
const downloads = layersOf(command, vars).some(
|
|
267
|
+
(layer) => layer.program === 'curl' || layer.program === 'wget',
|
|
268
|
+
)
|
|
269
|
+
if (!downloads) return false
|
|
270
|
+
const rest = line.slice(found + command.text.length)
|
|
271
|
+
const piped = /^[ \t]*(?:\\\n[ \t]*)*\|(?!\|)&?\s*/.exec(rest)
|
|
272
|
+
if (piped === null) return false
|
|
273
|
+
const next = commands[index + 1]
|
|
274
|
+
return next !== undefined && layersOf(next, vars).some((layer) => SHELLS.has(layer.program))
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
function hardStop(layer: Layer, options: FindDangerousOptions): string | undefined {
|
|
278
|
+
const { program, args } = layer
|
|
279
|
+
if (program === 'rm' || program === 'rmdir') return irreversibleRemoval(args, options)
|
|
280
|
+
if (/^mkfs(?:\.[A-Za-z0-9_]+)?$/.test(program)) {
|
|
281
|
+
return args.some((arg) => isDevice(arg.value))
|
|
282
|
+
? 'it creates a file system on a device'
|
|
283
|
+
: undefined
|
|
284
|
+
}
|
|
285
|
+
if (program === 'shred' && args.some((arg) => isDevice(arg.value))) {
|
|
286
|
+
return 'it overwrites a device with shred'
|
|
287
|
+
}
|
|
288
|
+
if (
|
|
289
|
+
program === 'wipefs' &&
|
|
290
|
+
args.some((arg) => ['-a', '--all', '-f', '--force'].includes(arg.value)) &&
|
|
291
|
+
args.some((arg) => isDevice(arg.value))
|
|
292
|
+
) {
|
|
293
|
+
return 'it erases the signatures of a device with wipefs'
|
|
294
|
+
}
|
|
295
|
+
if (program === 'find') return irreversibleFind(args, options)
|
|
296
|
+
if (program === 'dd') {
|
|
297
|
+
const target = args.find((arg) => arg.value.startsWith('of=/dev/'))
|
|
298
|
+
if (target !== undefined && isDevice(target.value.slice(3))) {
|
|
299
|
+
return 'it writes raw data to a device with dd'
|
|
300
|
+
}
|
|
301
|
+
return undefined
|
|
302
|
+
}
|
|
303
|
+
if (program === 'chmod') {
|
|
304
|
+
const modes = args.filter((arg) => /^0?777$/.test(arg.value))
|
|
305
|
+
const onRoot = args.some((arg) => /^\/(?:\*)?$/.test(arg.value))
|
|
306
|
+
if (modes.length > 0 && onRoot) return 'it makes the root directory world-writable'
|
|
307
|
+
}
|
|
308
|
+
return undefined
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** A redirection that writes to a device: `cat image > /dev/sda`. */
|
|
312
|
+
function deviceWrite(command: ShellCommand): string | undefined {
|
|
313
|
+
for (const redirection of command.redirections) {
|
|
314
|
+
if (!['>', '>>', '>|', '&>', '&>>'].includes(redirection.operator)) continue
|
|
315
|
+
if (isDevice(redirection.target.value))
|
|
316
|
+
return 'it writes raw data to a device with a redirection'
|
|
317
|
+
}
|
|
318
|
+
return undefined
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const FIND_PLAIN = new Set([
|
|
322
|
+
'-delete',
|
|
323
|
+
'-depth',
|
|
324
|
+
'-d',
|
|
325
|
+
'-xdev',
|
|
326
|
+
'-mount',
|
|
327
|
+
'-print',
|
|
328
|
+
'-print0',
|
|
329
|
+
'-maxdepth',
|
|
330
|
+
'-mindepth',
|
|
331
|
+
'-P',
|
|
332
|
+
'-L',
|
|
333
|
+
'-H',
|
|
334
|
+
'-ignore_readdir_race',
|
|
335
|
+
'-noignore_readdir_race',
|
|
336
|
+
'-follow',
|
|
337
|
+
])
|
|
338
|
+
const REMOVERS = new Set(['rm', 'rmdir', 'unlink', 'shred'])
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* `find / -delete` and `find ~ -exec rm {} +` remove what `rm -rf /` would,
|
|
342
|
+
* with the path named by `find` and not by the remover. It is a stop only when
|
|
343
|
+
* no test narrows the match (`-name`, `-type`, `-mtime`, …) and a remover
|
|
344
|
+
* runs; the path is then judged as `rm`'s own would be.
|
|
345
|
+
*/
|
|
346
|
+
function irreversibleFind(
|
|
347
|
+
args: readonly ShellWord[],
|
|
348
|
+
options: FindDangerousOptions,
|
|
349
|
+
): string | undefined {
|
|
350
|
+
const spans = findCommands(args)
|
|
351
|
+
const execs = new Set(args.map((arg) => arg.value).filter((value) => FIND_EXEC.has(value)))
|
|
352
|
+
const removes =
|
|
353
|
+
args.some((arg) => arg.value === '-delete') ||
|
|
354
|
+
spans.some((span) =>
|
|
355
|
+
layersOfWords(span, NO_VARIABLES, { n: 0 }).some((layer) => REMOVERS.has(layer.program)),
|
|
356
|
+
)
|
|
357
|
+
if (!removes) return undefined
|
|
358
|
+
const paths: ShellWord[] = []
|
|
359
|
+
let i = 0
|
|
360
|
+
for (; i < args.length; i += 1) {
|
|
361
|
+
const value = (args[i] as ShellWord).value
|
|
362
|
+
if (['-H', '-L', '-P'].includes(value)) continue
|
|
363
|
+
if (value.startsWith('-') || value === '(' || value === '!') break
|
|
364
|
+
paths.push(args[i] as ShellWord)
|
|
365
|
+
}
|
|
366
|
+
let inExec = false
|
|
367
|
+
for (const arg of args.slice(i)) {
|
|
368
|
+
if (inExec) {
|
|
369
|
+
if (arg.value === ';' || arg.value === '+') inExec = false
|
|
370
|
+
continue
|
|
371
|
+
}
|
|
372
|
+
if (execs.has(arg.value)) {
|
|
373
|
+
inExec = true
|
|
374
|
+
continue
|
|
375
|
+
}
|
|
376
|
+
if (arg.value === '(' || arg.value === ')' || arg.value === '!') return undefined
|
|
377
|
+
if (arg.value.startsWith('-') && !FIND_PLAIN.has(arg.value)) return undefined
|
|
378
|
+
}
|
|
379
|
+
const reason = irreversibleRemoval(paths, options, true)
|
|
380
|
+
return reason === undefined ? undefined : reason.replace(/^it removes/, 'it deletes')
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
function askReason(layer: Layer): string | undefined {
|
|
384
|
+
const { program, args } = layer
|
|
385
|
+
if (ELEVATORS.has(program)) return `it runs with elevated privileges (${program})`
|
|
386
|
+
if (program === 'su' && args.some((arg) => ['-', '-l', '--login'].includes(arg.value))) {
|
|
387
|
+
return 'it switches user with su -'
|
|
388
|
+
}
|
|
389
|
+
if (
|
|
390
|
+
program === 'ssh' &&
|
|
391
|
+
args.some((arg) => !arg.value.startsWith('-') && /^[^@\s]+@\S/.test(arg.value))
|
|
392
|
+
) {
|
|
393
|
+
return 'it opens a remote shell (ssh user@host)'
|
|
394
|
+
}
|
|
395
|
+
if (
|
|
396
|
+
/^mkfs(?:\.[A-Za-z0-9_]+)?$/.test(program) &&
|
|
397
|
+
args.some((arg) => arg.expands && !arg.value.startsWith('-'))
|
|
398
|
+
) {
|
|
399
|
+
return 'it creates a file system on a path that is only known when it runs'
|
|
400
|
+
}
|
|
401
|
+
if (program === 'eval' && args.some((arg) => arg.quoted || arg.expands)) {
|
|
402
|
+
return 'it evaluates a dynamic string with eval'
|
|
403
|
+
}
|
|
404
|
+
return undefined
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Why a removal can never be undone, or `undefined`: the file system root, the
|
|
409
|
+
* home directory, a top-level directory (`/usr`, `/etc`), or a variable that
|
|
410
|
+
* may be empty followed by one (`"$PREFIX/usr"`, `"$DIR/"`).
|
|
411
|
+
*
|
|
412
|
+
* This is the narrow class refused in every mode. `dangerousRemoval` is the
|
|
413
|
+
* wider one, which asks. A recursive removal of `/tmp/build` or
|
|
414
|
+
* `/usr/local/.wtest` is neither.
|
|
415
|
+
*/
|
|
416
|
+
function irreversibleRemoval(
|
|
417
|
+
args: readonly ShellWord[],
|
|
418
|
+
options: FindDangerousOptions,
|
|
419
|
+
operands = false,
|
|
420
|
+
): string | undefined {
|
|
421
|
+
const home = slashes(options.home ?? homedir()).replace(/(?<=.)\/$/, '')
|
|
422
|
+
const env = options.env ?? process.env
|
|
423
|
+
for (const target of operands ? args : targetsOf(args)) {
|
|
424
|
+
const spelled = target.value
|
|
425
|
+
if (spelled === '') continue
|
|
426
|
+
if (/^\\+$/.test(spelled)) return 'it removes the drive root'
|
|
427
|
+
if (BARE_HOME.test(spelled) || /^~\/*(?:\.?\*)?$/.test(spelled)) {
|
|
428
|
+
return 'it removes the home directory'
|
|
429
|
+
}
|
|
430
|
+
const root = EMPTY_VARIABLE_ROOT.exec(spelled)
|
|
431
|
+
if (root !== null) {
|
|
432
|
+
return `it removes the file system root when $${root[1] ?? root[2]} is empty`
|
|
433
|
+
}
|
|
434
|
+
const top = EMPTY_VARIABLE_TOP.exec(spelled)
|
|
435
|
+
if (top !== null) {
|
|
436
|
+
const name = top[1] ?? top[2] ?? ''
|
|
437
|
+
const value = env[name]
|
|
438
|
+
if (typeof value !== 'string' || value === '') {
|
|
439
|
+
return `it removes /${top[3]} when $${name} is empty`
|
|
440
|
+
}
|
|
441
|
+
continue
|
|
442
|
+
}
|
|
443
|
+
if (/[$`]/.test(spelled) || !spelled.startsWith('/')) continue
|
|
444
|
+
// Trailing slashes and globs reach the same directory's contents.
|
|
445
|
+
const bare = spelled.replace(/(?:\/+\.?\*+)*\/*$/, '')
|
|
446
|
+
const settled = posix.normalize(bare === '' ? '/' : bare).replace(/(?<=.)\/+$/, '')
|
|
447
|
+
if (settled === '/') return 'it removes the file system root'
|
|
448
|
+
if (/^\/[^/]+$/.test(settled)) return `it removes the top-level directory ${settled}`
|
|
449
|
+
if (fold(settled) === fold(home)) return 'it removes the home directory'
|
|
450
|
+
}
|
|
451
|
+
return undefined
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/** Raw-text entries by position in {@link DANGEROUS_PATTERNS}: which are irreversible. */
|
|
455
|
+
const STOP_INDEXES = new Set([0, 1, 2, 3, 6])
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* The reading for text that is not a command line the lexer can account for: a
|
|
459
|
+
* tool's whole serialized input, or a line that does not parse. The raw list,
|
|
460
|
+
* with the tier each entry has, and the uncertainty spent against the call.
|
|
461
|
+
*/
|
|
462
|
+
function findInRawText(text: string, options: FindDangerousOptions): DangerousFinding | undefined {
|
|
463
|
+
let found: DangerousFinding | undefined
|
|
464
|
+
for (const [index, pattern] of DANGEROUS_PATTERNS.entries()) {
|
|
465
|
+
if (!pattern.test(text)) continue
|
|
466
|
+
const tier: DangerousTier = options.strict === true || STOP_INDEXES.has(index) ? 'stop' : 'ask'
|
|
467
|
+
if (found !== undefined && (found.tier === 'stop' || tier === 'ask')) continue
|
|
468
|
+
found = { tier, reason: DANGEROUS_REASONS[index] ?? 'it matches a pattern this tool refuses' }
|
|
469
|
+
}
|
|
470
|
+
return found
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* What in `command` the floor refuses or asks about, read from the commands it
|
|
475
|
+
* runs, or `undefined` when nothing. A `stop` outranks an `ask`.
|
|
476
|
+
*
|
|
477
|
+
* `serialized` says `command` is a tool's whole JSON input, not a command line:
|
|
478
|
+
* there is no telling which field runs, so the raw list reads it.
|
|
479
|
+
*/
|
|
480
|
+
export function findDangerousCommand(
|
|
481
|
+
command: string,
|
|
482
|
+
options: FindDangerousOptions & { readonly serialized?: boolean } = {},
|
|
483
|
+
): DangerousFinding | undefined {
|
|
484
|
+
if (options.strict === true || options.serialized === true) return findInRawText(command, options)
|
|
485
|
+
|
|
486
|
+
const lexed = lexShellCommandLine(command, { dialect: options.dialect ?? 'sh' })
|
|
487
|
+
let asked: DangerousFinding | undefined
|
|
488
|
+
|
|
489
|
+
const masked = blankQuotedText(command)
|
|
490
|
+
if (FORK_BOMB.test(masked)) return { tier: 'stop', reason: 'it defines a fork bomb' }
|
|
491
|
+
|
|
492
|
+
const cursors = { at: 0 }
|
|
493
|
+
const vars = variablesOf(lexed.commands)
|
|
494
|
+
for (const [index, each] of lexed.commands.entries()) {
|
|
495
|
+
const layers = layersOf(each, vars)
|
|
496
|
+
const written = deviceWrite(each)
|
|
497
|
+
if (written !== undefined) return { tier: 'stop', reason: written }
|
|
498
|
+
for (const layer of layers) {
|
|
499
|
+
const stop = hardStop(layer, options)
|
|
500
|
+
if (stop !== undefined) return { tier: 'stop', reason: stop }
|
|
501
|
+
}
|
|
502
|
+
if (asked === undefined) {
|
|
503
|
+
for (const layer of layers) {
|
|
504
|
+
const reason = askReason(layer)
|
|
505
|
+
if (reason !== undefined) {
|
|
506
|
+
asked = { tier: 'ask', reason }
|
|
507
|
+
break
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
if (
|
|
512
|
+
asked === undefined &&
|
|
513
|
+
pipesDownloadIntoShell(command, lexed.commands, index, cursors, vars)
|
|
514
|
+
) {
|
|
515
|
+
asked = { tier: 'ask', reason: 'it pipes a download into a shell' }
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// A line the lexer stopped reading runs text it never showed. What it did
|
|
520
|
+
// not read is tested as raw text, quoted words and comments blanked, so the
|
|
521
|
+
// uncertainty spends against the call without refusing a harmless mention.
|
|
522
|
+
if (!lexed.complete) {
|
|
523
|
+
const rawFound = findInRawText(masked, options)
|
|
524
|
+
if (rawFound !== undefined && (asked === undefined || rawFound.tier === 'stop')) {
|
|
525
|
+
return rawFound
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
return asked
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/**
|
|
532
|
+
* The refusal text for a finding, in the two voices a refusal has. The first
|
|
533
|
+
* line is a plain sentence for the person; the rest tells the model what to do
|
|
534
|
+
* next. A `stop` is final; an `ask` is a question the person answers.
|
|
535
|
+
*/
|
|
536
|
+
export function describeDangerousFinding(finding: DangerousFinding): string {
|
|
537
|
+
const what = `this command ${finding.reason.replace(/^it /, '')}`
|
|
538
|
+
if (finding.tier === 'ask') {
|
|
539
|
+
return `${what}, so the person is asked before it runs`
|
|
540
|
+
}
|
|
541
|
+
return `${what}.\nNothing ran. Do not retry it or a reworded form; tell the user what you were trying to do and let them run it or decide.`
|
|
542
|
+
}
|
|
@@ -11,7 +11,8 @@ import { AuthorizationGateConfigSchema } from '../types/authorization/index.js'
|
|
|
11
11
|
import type { ToolDefinition } from '../types/tool/index.js'
|
|
12
12
|
import { SCOPE_ATTRIBUTE } from '../utils/log/types.js'
|
|
13
13
|
import type { Logger } from '../utils/logger.js'
|
|
14
|
-
import {
|
|
14
|
+
import { describeDangerousFinding } from './dangerous-commands.js'
|
|
15
|
+
import { dangerousFindingFor, evaluateRule } from './rules.js'
|
|
15
16
|
import type { ShellDialect } from './shell-lexer.js'
|
|
16
17
|
|
|
17
18
|
export interface ToolCallContext {
|
|
@@ -53,8 +54,18 @@ export interface ToolCallContext {
|
|
|
53
54
|
*/
|
|
54
55
|
export function describeRule(rule: AuthorizationRule, call?: AuthorizationPredicateCall): string {
|
|
55
56
|
switch (rule.type) {
|
|
56
|
-
case 'deny_dangerous_patterns':
|
|
57
|
-
|
|
57
|
+
case 'deny_dangerous_patterns': {
|
|
58
|
+
if (call === undefined) {
|
|
59
|
+
return 'this command is one the dangerous-command floor refuses or asks about'
|
|
60
|
+
}
|
|
61
|
+
const finding = dangerousFindingFor(call.toolDef, call.toolInput, {
|
|
62
|
+
commandDialect: call.commandDialect,
|
|
63
|
+
strict: rule.strict === true,
|
|
64
|
+
})
|
|
65
|
+
return finding === undefined
|
|
66
|
+
? 'this command is one the dangerous-command floor refuses or asks about'
|
|
67
|
+
: describeDangerousFinding(finding)
|
|
68
|
+
}
|
|
58
69
|
case 'allow_read_only':
|
|
59
70
|
return 'allowed because this tool only observes'
|
|
60
71
|
case 'allow_by_name':
|
|
@@ -147,7 +158,10 @@ export class AuthorizationGate {
|
|
|
147
158
|
// nobody wrote a rule about, rather than an override of the rules they
|
|
148
159
|
// did write. The denial above still outranks both.
|
|
149
160
|
if (parsed.denyDangerousPatterns) {
|
|
150
|
-
expandedRules.push({
|
|
161
|
+
expandedRules.push({
|
|
162
|
+
type: 'deny_dangerous_patterns',
|
|
163
|
+
...(parsed.denyDangerousPatterns === 'strict' ? { strict: true } : {}),
|
|
164
|
+
})
|
|
151
165
|
}
|
|
152
166
|
|
|
153
167
|
expandedRules.push(...parsed.rules)
|
|
@@ -265,7 +279,7 @@ export class AuthorizationGate {
|
|
|
265
279
|
decision,
|
|
266
280
|
matchedRule: rule,
|
|
267
281
|
reason:
|
|
268
|
-
rule.type === 'predicate'
|
|
282
|
+
rule.type === 'predicate' || rule.type === 'deny_dangerous_patterns'
|
|
269
283
|
? describeRule(rule, {
|
|
270
284
|
toolName: ctx.toolName,
|
|
271
285
|
toolInput: ctx.toolInput,
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
* existed, and none of them saw this path.
|
|
12
12
|
*
|
|
13
13
|
* The lists name the protected directories and protected files. The project
|
|
14
|
-
* directory is `.namzu
|
|
14
|
+
* directory is `.namzu`, which also holds the project's `settings.json` and
|
|
15
|
+
* `settings.local.json`, and the project file is `namzu.config.json`.
|
|
15
16
|
*
|
|
16
17
|
* Matching is by name, on every segment of the path. `.git` anywhere above a
|
|
17
18
|
* file protects it, and `.config/git` counts as one two-segment unit. Names
|
|
@@ -55,7 +56,8 @@ export const PROTECTED_FILE_NAMES: readonly string[] = [
|
|
|
55
56
|
'.ripgreprc',
|
|
56
57
|
'.mcp.json',
|
|
57
58
|
'namzu.config.json',
|
|
58
|
-
// The project's local
|
|
59
|
+
// The earlier name of the project's local settings, still read until a
|
|
60
|
+
// session moves it into `.namzu/settings.local.json`.
|
|
59
61
|
'namzu.config.local.json',
|
|
60
62
|
'.npmrc',
|
|
61
63
|
'.yarnrc',
|
|
@@ -81,17 +83,20 @@ export const PROTECTED_FILE_NAMES: readonly string[] = [
|
|
|
81
83
|
|
|
82
84
|
/**
|
|
83
85
|
* Folders under the project directory that hold what a person or the model
|
|
84
|
-
* authors on purpose (skills, agent definitions, commands)
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
86
|
+
* authors on purpose (skills, agent definitions, commands). Writing there is
|
|
87
|
+
* the point of the folder, so the project directory is not protected on their
|
|
88
|
+
* account. Only the first project directory in a path can be excused: a second
|
|
89
|
+
* one deeper down, or any other protected name below, still protects the path.
|
|
90
|
+
*
|
|
91
|
+
* `worktrees` is not one of them. The checkouts of delegated work live in the
|
|
92
|
+
* Namzu home (`projects/<slug>/worktrees/`), whose writes are judged by their
|
|
93
|
+
* own worktree root; a project's `.namzu/worktrees` is state an earlier version
|
|
94
|
+
* left there, and writing into it is asked about like the rest of `.namzu`.
|
|
89
95
|
*/
|
|
90
96
|
export const PROJECT_DIRECTORY_AUTHORED_FOLDERS: readonly string[] = [
|
|
91
97
|
'skills',
|
|
92
98
|
'agents',
|
|
93
99
|
'commands',
|
|
94
|
-
'worktrees',
|
|
95
100
|
]
|
|
96
101
|
|
|
97
102
|
const PROJECT_DIRECTORY = '.namzu'
|