@namzu/sdk 65.3.0 → 68.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +167 -0
- package/dist/account/lock.d.ts +4 -12
- package/dist/account/lock.d.ts.map +1 -1
- package/dist/account/lock.js +5 -140
- package/dist/account/lock.js.map +1 -1
- package/dist/account/registry.d.ts.map +1 -1
- package/dist/account/registry.js +50 -6
- package/dist/account/registry.js.map +1 -1
- package/dist/account/types.d.ts +7 -5
- package/dist/account/types.d.ts.map +1 -1
- package/dist/account/types.js +6 -7
- package/dist/account/types.js.map +1 -1
- package/dist/authorization/dangerous-commands.d.ts +64 -0
- package/dist/authorization/dangerous-commands.d.ts.map +1 -0
- package/dist/authorization/dangerous-commands.js +479 -0
- package/dist/authorization/dangerous-commands.js.map +1 -0
- package/dist/authorization/gate.d.ts.map +1 -1
- package/dist/authorization/gate.js +19 -5
- package/dist/authorization/gate.js.map +1 -1
- package/dist/authorization/protected-paths.d.ts +11 -6
- package/dist/authorization/protected-paths.d.ts.map +1 -1
- package/dist/authorization/protected-paths.js +13 -8
- package/dist/authorization/protected-paths.js.map +1 -1
- package/dist/authorization/readonly-commands.d.ts +6 -1
- package/dist/authorization/readonly-commands.d.ts.map +1 -1
- package/dist/authorization/readonly-commands.js +35 -1
- package/dist/authorization/readonly-commands.js.map +1 -1
- package/dist/authorization/removal.d.ts +10 -0
- package/dist/authorization/removal.d.ts.map +1 -1
- package/dist/authorization/removal.js +7 -7
- package/dist/authorization/removal.js.map +1 -1
- package/dist/authorization/rules.d.ts +10 -0
- package/dist/authorization/rules.d.ts.map +1 -1
- package/dist/authorization/rules.js +60 -14
- package/dist/authorization/rules.js.map +1 -1
- package/dist/authorization/shell-lexer.d.ts +10 -0
- package/dist/authorization/shell-lexer.d.ts.map +1 -1
- package/dist/authorization/shell-lexer.js +15 -0
- package/dist/authorization/shell-lexer.js.map +1 -1
- package/dist/bridge/acp/permission.d.ts +5 -0
- package/dist/bridge/acp/permission.d.ts.map +1 -1
- package/dist/bridge/acp/permission.js.map +1 -1
- package/dist/bridge/acp/server.d.ts +8 -1
- package/dist/bridge/acp/server.d.ts.map +1 -1
- package/dist/bridge/acp/server.js +48 -6
- package/dist/bridge/acp/server.js.map +1 -1
- package/dist/compaction/context-breakdown.d.ts +25 -6
- package/dist/compaction/context-breakdown.d.ts.map +1 -1
- package/dist/compaction/context-breakdown.js +27 -7
- package/dist/compaction/context-breakdown.js.map +1 -1
- package/dist/compaction/dangling.d.ts.map +1 -1
- package/dist/compaction/dangling.js +2 -0
- package/dist/compaction/dangling.js.map +1 -1
- package/dist/compaction/extractor.d.ts +7 -1
- package/dist/compaction/extractor.d.ts.map +1 -1
- package/dist/compaction/extractor.js +8 -1
- package/dist/compaction/extractor.js.map +1 -1
- package/dist/compaction/index.d.ts +1 -1
- package/dist/compaction/index.d.ts.map +1 -1
- package/dist/compaction/index.js +1 -1
- package/dist/compaction/index.js.map +1 -1
- package/dist/compaction/managers/structured.js +2 -2
- package/dist/compaction/managers/structured.js.map +1 -1
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +11 -6
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/model-summary.d.ts.map +1 -1
- package/dist/compaction/model-summary.js +7 -1
- package/dist/compaction/model-summary.js.map +1 -1
- package/dist/compaction/summary.d.ts +13 -2
- package/dist/compaction/summary.d.ts.map +1 -1
- package/dist/compaction/summary.js +46 -3
- package/dist/compaction/summary.js.map +1 -1
- package/dist/constants/tools/index.d.ts +18 -1
- package/dist/constants/tools/index.d.ts.map +1 -1
- package/dist/constants/tools/index.js +28 -16
- package/dist/constants/tools/index.js.map +1 -1
- package/dist/manager/session/turn-recorder.d.ts +6 -0
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +29 -1
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/network/audit.d.ts +49 -0
- package/dist/network/audit.d.ts.map +1 -0
- package/dist/network/audit.js +84 -0
- package/dist/network/audit.js.map +1 -0
- package/dist/network/clock.d.ts +21 -0
- package/dist/network/clock.d.ts.map +1 -0
- package/dist/network/clock.js +51 -0
- package/dist/network/clock.js.map +1 -0
- package/dist/network/discovery-mdns.d.ts +120 -0
- package/dist/network/discovery-mdns.d.ts.map +1 -0
- package/dist/network/discovery-mdns.js +442 -0
- package/dist/network/discovery-mdns.js.map +1 -0
- package/dist/network/discovery.d.ts +63 -0
- package/dist/network/discovery.d.ts.map +1 -0
- package/dist/network/discovery.js +163 -0
- package/dist/network/discovery.js.map +1 -0
- package/dist/network/fingerprint.d.ts +73 -0
- package/dist/network/fingerprint.d.ts.map +1 -0
- package/dist/network/fingerprint.js +208 -0
- package/dist/network/fingerprint.js.map +1 -0
- package/dist/network/identity.d.ts +38 -0
- package/dist/network/identity.d.ts.map +1 -0
- package/dist/network/identity.js +71 -0
- package/dist/network/identity.js.map +1 -0
- package/dist/network/index.d.ts +39 -0
- package/dist/network/index.d.ts.map +1 -0
- package/dist/network/index.js +25 -0
- package/dist/network/index.js.map +1 -0
- package/dist/network/join.d.ts +69 -0
- package/dist/network/join.d.ts.map +1 -0
- package/dist/network/join.js +136 -0
- package/dist/network/join.js.map +1 -0
- package/dist/network/mail-policy.d.ts +97 -0
- package/dist/network/mail-policy.d.ts.map +1 -0
- package/dist/network/mail-policy.js +147 -0
- package/dist/network/mail-policy.js.map +1 -0
- package/dist/network/membership.d.ts +76 -0
- package/dist/network/membership.d.ts.map +1 -0
- package/dist/network/membership.js +225 -0
- package/dist/network/membership.js.map +1 -0
- package/dist/network/roster.d.ts +59 -0
- package/dist/network/roster.d.ts.map +1 -0
- package/dist/network/roster.js +120 -0
- package/dist/network/roster.js.map +1 -0
- package/dist/network/service.d.ts +303 -0
- package/dist/network/service.d.ts.map +1 -0
- package/dist/network/service.js +1891 -0
- package/dist/network/service.js.map +1 -0
- package/dist/network/store.d.ts +141 -0
- package/dist/network/store.d.ts.map +1 -0
- package/dist/network/store.js +198 -0
- package/dist/network/store.js.map +1 -0
- package/dist/network/transport.d.ts +96 -0
- package/dist/network/transport.d.ts.map +1 -0
- package/dist/network/transport.js +342 -0
- package/dist/network/transport.js.map +1 -0
- package/dist/network/wire.d.ts +345 -0
- package/dist/network/wire.d.ts.map +1 -0
- package/dist/network/wire.js +212 -0
- package/dist/network/wire.js.map +1 -0
- package/dist/network/x509.d.ts +28 -0
- package/dist/network/x509.d.ts.map +1 -0
- package/dist/network/x509.js +84 -0
- package/dist/network/x509.js.map +1 -0
- package/dist/pals/activity/causality.d.ts.map +1 -1
- package/dist/pals/activity/causality.js +14 -2
- package/dist/pals/activity/causality.js.map +1 -1
- package/dist/peers/endpoint.d.ts.map +1 -1
- package/dist/peers/endpoint.js +6 -0
- package/dist/peers/endpoint.js.map +1 -1
- package/dist/peers/envelope.d.ts +18 -0
- package/dist/peers/envelope.d.ts.map +1 -1
- package/dist/peers/envelope.js +68 -5
- package/dist/peers/envelope.js.map +1 -1
- package/dist/peers/index.d.ts +5 -4
- package/dist/peers/index.d.ts.map +1 -1
- package/dist/peers/index.js +3 -2
- package/dist/peers/index.js.map +1 -1
- package/dist/peers/mode-word.d.ts +10 -0
- package/dist/peers/mode-word.d.ts.map +1 -0
- package/dist/peers/mode-word.js +19 -0
- package/dist/peers/mode-word.js.map +1 -0
- package/dist/peers/protocol.d.ts +42 -0
- package/dist/peers/protocol.d.ts.map +1 -1
- package/dist/peers/protocol.js +22 -1
- package/dist/peers/protocol.js.map +1 -1
- package/dist/peers/record.d.ts +8 -0
- package/dist/peers/record.d.ts.map +1 -1
- package/dist/peers/record.js +5 -0
- package/dist/peers/record.js.map +1 -1
- package/dist/plugin/session-hook-env.d.ts.map +1 -1
- package/dist/plugin/session-hook-env.js +22 -2
- package/dist/plugin/session-hook-env.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +16 -2
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +183 -14
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/pricing/catalogue.generated.d.ts.map +1 -1
- package/dist/pricing/catalogue.generated.js +6 -0
- package/dist/pricing/catalogue.generated.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +4 -2
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +33 -38
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +12 -0
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/idle-timeout.d.ts.map +1 -1
- package/dist/provider/idle-timeout.js +5 -0
- package/dist/provider/idle-timeout.js.map +1 -1
- package/dist/provider/model-window-suffix.d.ts.map +1 -1
- package/dist/provider/model-window-suffix.js +1 -0
- package/dist/provider/model-window-suffix.js.map +1 -1
- package/dist/provider/retry.d.ts.map +1 -1
- package/dist/provider/retry.js +5 -0
- package/dist/provider/retry.js.map +1 -1
- package/dist/public-runtime.d.ts +16 -8
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +24 -7
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +3 -2
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +2 -2
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +10 -5
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.d.ts +11 -1
- package/dist/registry/command/kernel-commands.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.js +114 -46
- package/dist/registry/command/kernel-commands.js.map +1 -1
- package/dist/runtime/jobs/registry.d.ts +29 -1
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +64 -0
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/auto-review/classifier.d.ts +30 -6
- package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/classifier.js +40 -12
- package/dist/runtime/query/auto-review/classifier.js.map +1 -1
- package/dist/runtime/query/auto-review/feedback.d.ts +37 -0
- package/dist/runtime/query/auto-review/feedback.d.ts.map +1 -0
- package/dist/runtime/query/auto-review/feedback.js +45 -0
- package/dist/runtime/query/auto-review/feedback.js.map +1 -0
- package/dist/runtime/query/auto-review/git-status.d.ts +59 -0
- package/dist/runtime/query/auto-review/git-status.d.ts.map +1 -0
- package/dist/runtime/query/auto-review/git-status.js +379 -0
- package/dist/runtime/query/auto-review/git-status.js.map +1 -0
- package/dist/runtime/query/auto-review/index.d.ts +3 -3
- package/dist/runtime/query/auto-review/index.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/index.js +2 -2
- package/dist/runtime/query/auto-review/index.js.map +1 -1
- package/dist/runtime/query/auto-review/prompt.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/prompt.js +6 -1
- package/dist/runtime/query/auto-review/prompt.js.map +1 -1
- package/dist/runtime/query/auto-review/transcript.d.ts +14 -1
- package/dist/runtime/query/auto-review/transcript.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/transcript.js +48 -2
- package/dist/runtime/query/auto-review/transcript.js.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +40 -3
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +32 -10
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +78 -17
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts +9 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +54 -17
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +20 -6
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +5 -2
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js +5 -0
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/per-call-review.d.ts +1 -2
- package/dist/runtime/query/iteration/phases/per-call-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/per-call-review.js +2 -5
- package/dist/runtime/query/iteration/phases/per-call-review.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +6 -1
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/pasted-frames.d.ts +34 -0
- package/dist/runtime/query/pasted-frames.d.ts.map +1 -0
- package/dist/runtime/query/pasted-frames.js +108 -0
- package/dist/runtime/query/pasted-frames.js.map +1 -0
- package/dist/runtime/query/path-escalation.d.ts +6 -0
- package/dist/runtime/query/path-escalation.d.ts.map +1 -1
- package/dist/runtime/query/path-escalation.js +15 -3
- package/dist/runtime/query/path-escalation.js.map +1 -1
- package/dist/runtime/query/request-interrupted-turns.d.ts +20 -0
- package/dist/runtime/query/request-interrupted-turns.d.ts.map +1 -0
- package/dist/runtime/query/request-interrupted-turns.js +43 -0
- package/dist/runtime/query/request-interrupted-turns.js.map +1 -0
- package/dist/runtime/query/review-policy.d.ts +16 -6
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +111 -15
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.d.ts +9 -0
- package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.js +94 -6
- package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
- package/dist/runtime/query/unanswered.d.ts +19 -0
- package/dist/runtime/query/unanswered.d.ts.map +1 -0
- package/dist/runtime/query/unanswered.js +25 -0
- package/dist/runtime/query/unanswered.js.map +1 -0
- package/dist/runtime/system-events.d.ts +4 -4
- package/dist/runtime/system-events.d.ts.map +1 -1
- package/dist/runtime/system-events.js +2 -0
- package/dist/runtime/system-events.js.map +1 -1
- package/dist/session/workspace/git-worktree.d.ts +8 -0
- package/dist/session/workspace/git-worktree.d.ts.map +1 -1
- package/dist/session/workspace/git-worktree.js +21 -3
- package/dist/session/workspace/git-worktree.js.map +1 -1
- package/dist/store/evidence/source-kind.d.ts +1 -1
- package/dist/store/evidence/source-kind.d.ts.map +1 -1
- package/dist/store/evidence/source-kind.js +1 -1
- package/dist/store/evidence/source-kind.js.map +1 -1
- package/dist/store/goal/index.d.ts +53 -3
- package/dist/store/goal/index.d.ts.map +1 -1
- package/dist/store/goal/index.js +245 -9
- package/dist/store/goal/index.js.map +1 -1
- package/dist/store/session-index/sqlite.d.ts.map +1 -1
- package/dist/store/session-index/sqlite.js +42 -3
- package/dist/store/session-index/sqlite.js.map +1 -1
- package/dist/store/session-log/disk.js +1 -1
- package/dist/store/session-log/disk.js.map +1 -1
- package/dist/store/session-log/lease.d.ts.map +1 -1
- package/dist/store/session-log/lease.js +3 -2
- package/dist/store/session-log/lease.js.map +1 -1
- package/dist/tools/admit-facts.d.ts.map +1 -1
- package/dist/tools/admit-facts.js +2 -0
- package/dist/tools/admit-facts.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts +10 -2
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +56 -17
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/browser-local.d.ts +117 -0
- package/dist/tools/builtins/browser-local.d.ts.map +1 -0
- package/dist/tools/builtins/browser-local.js +437 -0
- package/dist/tools/builtins/browser-local.js.map +1 -0
- package/dist/tools/builtins/browser.d.ts +18 -1
- package/dist/tools/builtins/browser.d.ts.map +1 -1
- package/dist/tools/builtins/browser.js +84 -6
- package/dist/tools/builtins/browser.js.map +1 -1
- package/dist/tools/builtins/computer-use-window-id.d.ts +16 -0
- package/dist/tools/builtins/computer-use-window-id.d.ts.map +1 -0
- package/dist/tools/builtins/computer-use-window-id.js +52 -0
- package/dist/tools/builtins/computer-use-window-id.js.map +1 -0
- package/dist/tools/builtins/computer-use.d.ts +65 -7
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +384 -71
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/content-fingerprint.d.ts +6 -0
- package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
- package/dist/tools/builtins/content-fingerprint.js +7 -1
- package/dist/tools/builtins/content-fingerprint.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +89 -7
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/file-write-result.d.ts.map +1 -1
- package/dist/tools/builtins/file-write-result.js +2 -1
- package/dist/tools/builtins/file-write-result.js.map +1 -1
- package/dist/tools/builtins/grep.js +1 -1
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/job.d.ts.map +1 -1
- package/dist/tools/builtins/job.js +4 -2
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/monitor.d.ts.map +1 -1
- package/dist/tools/builtins/monitor.js +6 -1
- package/dist/tools/builtins/monitor.js.map +1 -1
- package/dist/tools/builtins/search-tools.d.ts +12 -1
- package/dist/tools/builtins/search-tools.d.ts.map +1 -1
- package/dist/tools/builtins/search-tools.js +166 -20
- package/dist/tools/builtins/search-tools.js.map +1 -1
- package/dist/tools/builtins/shell-read-credit.d.ts +18 -6
- package/dist/tools/builtins/shell-read-credit.d.ts.map +1 -1
- package/dist/tools/builtins/shell-read-credit.js +95 -27
- package/dist/tools/builtins/shell-read-credit.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +14 -3
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/tools/builtins/web-guidance.d.ts +6 -0
- package/dist/tools/builtins/web-guidance.d.ts.map +1 -1
- package/dist/tools/builtins/web-guidance.js +6 -0
- package/dist/tools/builtins/web-guidance.js.map +1 -1
- package/dist/tools/builtins/web.d.ts.map +1 -1
- package/dist/tools/builtins/web.js +2 -1
- package/dist/tools/builtins/web.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +32 -2
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/command-shell.d.ts +1 -1
- package/dist/tools/command-shell.d.ts.map +1 -1
- package/dist/tools/command-shell.js +6 -8
- package/dist/tools/command-shell.js.map +1 -1
- package/dist/tools/defineTool.d.ts +2 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +17 -1
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/goal/confirmation.d.ts +82 -1
- package/dist/tools/goal/confirmation.d.ts.map +1 -1
- package/dist/tools/goal/confirmation.js +153 -3
- package/dist/tools/goal/confirmation.js.map +1 -1
- package/dist/tools/goal/index.d.ts.map +1 -1
- package/dist/tools/goal/index.js +34 -3
- package/dist/tools/goal/index.js.map +1 -1
- package/dist/tools/schedules/index.d.ts +1 -0
- package/dist/tools/schedules/index.d.ts.map +1 -1
- package/dist/tools/schedules/index.js +1 -0
- package/dist/tools/schedules/index.js.map +1 -1
- package/dist/tools/schedules/loop-tool.d.ts.map +1 -1
- package/dist/tools/schedules/loop-tool.js +8 -6
- package/dist/tools/schedules/loop-tool.js.map +1 -1
- package/dist/tools/schedules/present.js +1 -1
- package/dist/tools/schedules/present.js.map +1 -1
- package/dist/tools/schedules/timer-tools.d.ts +36 -0
- package/dist/tools/schedules/timer-tools.d.ts.map +1 -0
- package/dist/tools/schedules/timer-tools.js +234 -0
- package/dist/tools/schedules/timer-tools.js.map +1 -0
- package/dist/tools/schedules/types.d.ts +68 -3
- package/dist/tools/schedules/types.d.ts.map +1 -1
- package/dist/tools/task/create.d.ts.map +1 -1
- package/dist/tools/task/create.js +2 -0
- package/dist/tools/task/create.js.map +1 -1
- package/dist/toolsets/manager.d.ts +49 -7
- package/dist/toolsets/manager.d.ts.map +1 -1
- package/dist/toolsets/manager.js +239 -40
- package/dist/toolsets/manager.js.map +1 -1
- package/dist/turn/evidence-query.d.ts +18 -1
- package/dist/turn/evidence-query.d.ts.map +1 -1
- package/dist/turn/evidence-query.js +177 -35
- package/dist/turn/evidence-query.js.map +1 -1
- package/dist/turn/evidence-recall.d.ts +8 -1
- package/dist/turn/evidence-recall.d.ts.map +1 -1
- package/dist/turn/evidence-recall.js +82 -22
- package/dist/turn/evidence-recall.js.map +1 -1
- package/dist/turn/history-shed.d.ts +15 -0
- package/dist/turn/history-shed.d.ts.map +1 -0
- package/dist/turn/history-shed.js +23 -0
- package/dist/turn/history-shed.js.map +1 -0
- package/dist/types/acp/index.d.ts +26 -0
- package/dist/types/acp/index.d.ts.map +1 -1
- package/dist/types/authorization/index.d.ts +9 -1
- package/dist/types/authorization/index.d.ts.map +1 -1
- package/dist/types/authorization/index.js +11 -2
- package/dist/types/authorization/index.js.map +1 -1
- package/dist/types/command/index.d.ts +26 -2
- package/dist/types/command/index.d.ts.map +1 -1
- package/dist/types/command/index.js +5 -2
- package/dist/types/command/index.js.map +1 -1
- package/dist/types/common/index.d.ts +4 -2
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/index.js.map +1 -1
- package/dist/types/goal/index.d.ts +59 -0
- package/dist/types/goal/index.d.ts.map +1 -1
- package/dist/types/hitl/index.d.ts +10 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/message/index.d.ts +56 -1
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +2 -1
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/permission/index.d.ts +14 -0
- package/dist/types/permission/index.d.ts.map +1 -1
- package/dist/types/permission/index.js +14 -0
- package/dist/types/permission/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +148 -1
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +9 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +10 -5
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/index.d.ts +1 -0
- package/dist/types/provider/index.d.ts.map +1 -1
- package/dist/types/provider/interface.d.ts +19 -0
- package/dist/types/provider/interface.d.ts.map +1 -1
- package/dist/types/provider/limits.d.ts +33 -0
- package/dist/types/provider/limits.d.ts.map +1 -0
- package/dist/types/provider/limits.js +7 -0
- package/dist/types/provider/limits.js.map +1 -0
- package/dist/types/provider/model.d.ts +5 -0
- package/dist/types/provider/model.d.ts.map +1 -1
- package/dist/types/session/config.d.ts +2 -2
- package/dist/types/session/outcome.d.ts +5 -2
- package/dist/types/session/outcome.d.ts.map +1 -1
- package/dist/types/session/outcome.js.map +1 -1
- package/dist/types/tool/index.d.ts +30 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/tool/presentation.d.ts +4 -0
- package/dist/types/tool/presentation.d.ts.map +1 -1
- package/dist/utils/cost.d.ts +1 -1
- package/dist/utils/cost.d.ts.map +1 -1
- package/dist/utils/cost.js +14 -5
- package/dist/utils/cost.js.map +1 -1
- package/dist/utils/file-lock.d.ts +88 -0
- package/dist/utils/file-lock.d.ts.map +1 -0
- package/dist/utils/file-lock.js +281 -0
- package/dist/utils/file-lock.js.map +1 -0
- package/dist/utils/state-backup.d.ts +87 -0
- package/dist/utils/state-backup.d.ts.map +1 -0
- package/dist/utils/state-backup.js +272 -0
- package/dist/utils/state-backup.js.map +1 -0
- package/dist/utils/temp-sweep.d.ts +66 -0
- package/dist/utils/temp-sweep.d.ts.map +1 -0
- package/dist/utils/temp-sweep.js +311 -0
- package/dist/utils/temp-sweep.js.map +1 -0
- package/dist/utils/temp.d.ts +14 -0
- package/dist/utils/temp.d.ts.map +1 -1
- package/dist/utils/temp.js +70 -2
- package/dist/utils/temp.js.map +1 -1
- package/package.json +1 -1
- package/src/account/lock.ts +13 -133
- package/src/account/registry.ts +75 -21
- package/src/account/types.ts +8 -9
- package/src/authorization/dangerous-commands.ts +542 -0
- package/src/authorization/gate.ts +19 -5
- package/src/authorization/protected-paths.ts +13 -8
- package/src/authorization/readonly-commands.ts +35 -1
- package/src/authorization/removal.ts +7 -7
- package/src/authorization/rules.ts +75 -15
- package/src/authorization/shell-lexer.ts +19 -0
- package/src/bridge/acp/permission.ts +2 -0
- package/src/bridge/acp/server.ts +66 -6
- package/src/compaction/context-breakdown.ts +53 -11
- package/src/compaction/dangling.ts +2 -0
- package/src/compaction/extractor.ts +9 -1
- package/src/compaction/index.ts +1 -0
- package/src/compaction/managers/structured.ts +2 -2
- package/src/compaction/manual.ts +11 -3
- package/src/compaction/model-summary.ts +8 -1
- package/src/compaction/summary.ts +54 -7
- package/src/constants/tools/index.ts +30 -16
- package/src/manager/session/turn-recorder.ts +37 -1
- package/src/network/audit.ts +113 -0
- package/src/network/clock.ts +62 -0
- package/src/network/discovery-mdns.ts +485 -0
- package/src/network/discovery.ts +210 -0
- package/src/network/fingerprint.ts +241 -0
- package/src/network/identity.ts +98 -0
- package/src/network/index.ts +134 -0
- package/src/network/join.ts +177 -0
- package/src/network/mail-policy.ts +199 -0
- package/src/network/membership.ts +290 -0
- package/src/network/roster.ts +165 -0
- package/src/network/service.ts +2304 -0
- package/src/network/store.ts +261 -0
- package/src/network/transport.ts +445 -0
- package/src/network/wire.ts +250 -0
- package/src/network/x509.ts +114 -0
- package/src/pals/activity/causality.ts +16 -2
- package/src/peers/endpoint.ts +6 -0
- package/src/peers/envelope.ts +82 -5
- package/src/peers/index.ts +10 -2
- package/src/peers/mode-word.ts +18 -0
- package/src/peers/protocol.ts +24 -1
- package/src/peers/record.ts +5 -0
- package/src/plugin/session-hook-env.ts +25 -2
- package/src/plugin/shell-hook.ts +208 -14
- package/src/pricing/catalogue.generated.ts +6 -0
- package/src/pricing/rates.source.json +13 -7
- package/src/prompt/coding-agent-doctrine.ts +33 -38
- package/src/provider/fallback.ts +11 -0
- package/src/provider/idle-timeout.ts +5 -0
- package/src/provider/model-window-suffix.ts +1 -0
- package/src/provider/retry.ts +5 -0
- package/src/public-runtime.ts +116 -1
- package/src/public-tools.ts +11 -0
- package/src/public-types.ts +74 -1
- package/src/registry/command/kernel-commands.ts +136 -49
- package/src/runtime/jobs/registry.ts +93 -3
- package/src/runtime/query/auto-review/classifier.ts +76 -14
- package/src/runtime/query/auto-review/feedback.ts +50 -0
- package/src/runtime/query/auto-review/git-status.ts +437 -0
- package/src/runtime/query/auto-review/index.ts +7 -2
- package/src/runtime/query/auto-review/prompt.ts +6 -1
- package/src/runtime/query/auto-review/transcript.ts +67 -4
- package/src/runtime/query/executor/tool-call-admission.ts +49 -3
- package/src/runtime/query/executor.ts +104 -21
- package/src/runtime/query/index.ts +66 -17
- package/src/runtime/query/iteration/index.ts +33 -9
- package/src/runtime/query/iteration/phases/compaction.ts +4 -0
- package/src/runtime/query/iteration/phases/context.ts +5 -0
- package/src/runtime/query/iteration/phases/per-call-review.ts +8 -13
- package/src/runtime/query/iteration/phases/tool-review.ts +7 -1
- package/src/runtime/query/pasted-frames.ts +119 -0
- package/src/runtime/query/path-escalation.ts +27 -3
- package/src/runtime/query/request-interrupted-turns.ts +47 -0
- package/src/runtime/query/review-policy.ts +125 -22
- package/src/runtime/query/turn/outcome-ledger.ts +99 -6
- package/src/runtime/query/unanswered.ts +35 -0
- package/src/runtime/system-events.ts +2 -0
- package/src/session/workspace/git-worktree.ts +34 -3
- package/src/store/evidence/source-kind.ts +1 -1
- package/src/store/goal/index.ts +320 -21
- package/src/store/session-index/sqlite.ts +40 -3
- package/src/store/session-log/disk.ts +1 -1
- package/src/store/session-log/lease.ts +3 -2
- package/src/tools/admit-facts.ts +2 -0
- package/src/tools/builtins/bash.ts +62 -19
- package/src/tools/builtins/browser-local.ts +504 -0
- package/src/tools/builtins/browser.ts +108 -6
- package/src/tools/builtins/computer-use-window-id.ts +50 -0
- package/src/tools/builtins/computer-use.ts +460 -68
- package/src/tools/builtins/content-fingerprint.ts +8 -1
- package/src/tools/builtins/edit.ts +93 -7
- package/src/tools/builtins/file-write-result.ts +2 -1
- package/src/tools/builtins/grep.ts +1 -1
- package/src/tools/builtins/job.ts +4 -2
- package/src/tools/builtins/monitor.ts +6 -1
- package/src/tools/builtins/search-tools.ts +196 -21
- package/src/tools/builtins/shell-read-credit.ts +97 -33
- package/src/tools/builtins/wait-for-job.ts +13 -3
- package/src/tools/builtins/web-guidance.ts +6 -0
- package/src/tools/builtins/web.ts +2 -1
- package/src/tools/builtins/write-file.ts +31 -3
- package/src/tools/command-shell.ts +6 -8
- package/src/tools/defineTool.ts +20 -1
- package/src/tools/goal/confirmation.ts +227 -3
- package/src/tools/goal/index.ts +40 -4
- package/src/tools/schedules/index.ts +11 -0
- package/src/tools/schedules/loop-tool.ts +10 -6
- package/src/tools/schedules/present.ts +1 -1
- package/src/tools/schedules/timer-tools.ts +258 -0
- package/src/tools/schedules/types.ts +72 -3
- package/src/tools/task/create.ts +2 -0
- package/src/toolsets/manager.ts +262 -46
- package/src/turn/evidence-query.ts +183 -42
- package/src/turn/evidence-recall.ts +96 -19
- package/src/turn/history-shed.ts +30 -0
- package/src/types/acp/index.ts +24 -0
- package/src/types/authorization/index.ts +20 -3
- package/src/types/command/index.ts +27 -2
- package/src/types/common/index.ts +4 -2
- package/src/types/goal/index.ts +61 -0
- package/src/types/hitl/index.ts +10 -0
- package/src/types/message/index.ts +65 -0
- package/src/types/permission/index.ts +18 -0
- package/src/types/plugin/index.ts +205 -26
- package/src/types/provider/chat.ts +10 -5
- package/src/types/provider/index.ts +1 -0
- package/src/types/provider/interface.ts +21 -0
- package/src/types/provider/limits.ts +35 -0
- package/src/types/provider/model.ts +5 -0
- package/src/types/session/config.ts +2 -2
- package/src/types/session/outcome.ts +3 -1
- package/src/types/tool/index.ts +30 -2
- package/src/types/tool/presentation.ts +4 -0
- package/src/utils/cost.ts +15 -6
- package/src/utils/file-lock.ts +328 -0
- package/src/utils/state-backup.ts +318 -0
- package/src/utils/temp-sweep.ts +327 -0
- package/src/utils/temp.ts +73 -2
|
@@ -20,7 +20,12 @@
|
|
|
20
20
|
* refuses the line, because the directory it enters may hold a repository
|
|
21
21
|
* the person never looked at.
|
|
22
22
|
*
|
|
23
|
-
*
|
|
23
|
+
* `sed` is read-only only as a printer: `-n` (and `-E`, `-r`, `-s`, `-u`) with
|
|
24
|
+
* one script of print commands, `sed -n '1,40p' file`, `sed -n '5p;$p' file`.
|
|
25
|
+
* No `-i`, `-e`, `-f`, no substitution, no `w`, `r`, `e`, `y` or `d`, no
|
|
26
|
+
* regular-expression address: every one of those is refused.
|
|
27
|
+
*
|
|
28
|
+
* Not ported, and so never read-only here: `ps`, `lsof`, `ss`, `date`,
|
|
24
29
|
* `man`, `xargs`, `fd`, `gh`, `docker logs|inspect`, `printf`, `[[`, `test`
|
|
25
30
|
* and the shell builtins other than `cd`. The check of the working
|
|
26
31
|
* directory for a planted bare repository needs the directory, which the tool
|
|
@@ -584,6 +589,33 @@ function uniqIsReadOnly(args: readonly string[]): boolean {
|
|
|
584
589
|
return true
|
|
585
590
|
}
|
|
586
591
|
|
|
592
|
+
const SED_ADDRESS = String.raw`(?:\d+(?:~\d+)?|\$)`
|
|
593
|
+
const SED_PRINT = new RegExp(
|
|
594
|
+
String.raw`^\s*(?:${SED_ADDRESS}(?:\s*,\s*(?:${SED_ADDRESS}|\+\d+|~\d+))?)?\s*p\s*$`,
|
|
595
|
+
)
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* `sed` as a printer: switches that only change how the script is read, one
|
|
599
|
+
* script (the first word that is not a switch) made of print commands over
|
|
600
|
+
* line numbers, and the rest files. Anything that could write, run a program
|
|
601
|
+
* or read a script from elsewhere is a switch or a command not on this list.
|
|
602
|
+
*/
|
|
603
|
+
function sedIsReadOnly(args: readonly string[]): boolean {
|
|
604
|
+
let script: string | undefined
|
|
605
|
+
for (const word of args) {
|
|
606
|
+
if (word === '') continue
|
|
607
|
+
if (script === undefined && /^-[nEsru]+$/.test(word)) continue
|
|
608
|
+
if (script === undefined && word !== '--' && !word.startsWith('-')) {
|
|
609
|
+
script = word
|
|
610
|
+
continue
|
|
611
|
+
}
|
|
612
|
+
// After the script every word is a file; a flag-like one is refused.
|
|
613
|
+
if (script === undefined || word.startsWith('-')) return false
|
|
614
|
+
}
|
|
615
|
+
if (script === undefined) return false
|
|
616
|
+
return script.split(';').every((part) => SED_PRINT.test(part))
|
|
617
|
+
}
|
|
618
|
+
|
|
587
619
|
function jqIsReadOnly(args: readonly string[]): boolean {
|
|
588
620
|
const text = args.join(' ')
|
|
589
621
|
if (/\b(?:env|include|import)\b|\$ENV/.test(text)) return false
|
|
@@ -652,6 +684,8 @@ function commandIsReadOnly(argv: readonly string[], text: string): boolean {
|
|
|
652
684
|
return uniqIsReadOnly(rest)
|
|
653
685
|
case 'jq':
|
|
654
686
|
return jqIsReadOnly(rest)
|
|
687
|
+
case 'sed':
|
|
688
|
+
return sedIsReadOnly(rest)
|
|
655
689
|
case 'find':
|
|
656
690
|
return findIsReadOnly(rest)
|
|
657
691
|
case 'docker':
|
|
@@ -60,13 +60,13 @@ export interface RemovalContext {
|
|
|
60
60
|
const TOP_LEVEL =
|
|
61
61
|
'bin|boot|dev|etc|home|lib|lib32|lib64|libx32|media|mnt|opt|proc|root|run|sbin|srv|sys|tmp|usr|var|snap|nix|lost\\+found|private|cores|Applications|Library|System|Users|Volumes|Windows|ProgramData|cygdrive'
|
|
62
62
|
|
|
63
|
-
const VAR = '(?:\\{([A-Za-z_][A-Za-z0-9_]*)(?::?-[^}]*)?\\}|([A-Za-z_][A-Za-z0-9_]*))'
|
|
63
|
+
export const VAR = '(?:\\{([A-Za-z_][A-Za-z0-9_]*)(?::?-[^}]*)?\\}|([A-Za-z_][A-Za-z0-9_]*))'
|
|
64
64
|
/** `$VAR/` followed by something that cannot name a child: end, a glob, another expansion, a slash. */
|
|
65
|
-
const EMPTY_VARIABLE_ROOT = new RegExp(`^\\$${VAR}/(?:[*?[{]|\\$|/|$)`)
|
|
66
|
-
const EMPTY_VARIABLE_TOP = new RegExp(`^\\$${VAR}/(${TOP_LEVEL})(?:/+\\*+)*/?$`, 'i')
|
|
67
|
-
const BARE_HOME = /^\$(?:\{HOME\}|HOME)(?:\/+\*?)?$/
|
|
65
|
+
export const EMPTY_VARIABLE_ROOT = new RegExp(`^\\$${VAR}/(?:[*?[{]|\\$|/|$)`)
|
|
66
|
+
export const EMPTY_VARIABLE_TOP = new RegExp(`^\\$${VAR}/(${TOP_LEVEL})(?:/+\\*+)*/?$`, 'i')
|
|
67
|
+
export const BARE_HOME = /^\$(?:\{HOME\}|HOME)(?:\/+\*?)?$/
|
|
68
68
|
|
|
69
|
-
function fold(name: string): string {
|
|
69
|
+
export function fold(name: string): string {
|
|
70
70
|
return name.toLowerCase().replace(/ı/g, 'i').replace(/ſ/g, 's')
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -90,7 +90,7 @@ function canonical(path: string): string {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
function slashes(path: string): string {
|
|
93
|
+
export function slashes(path: string): string {
|
|
94
94
|
return path.replace(/[\\/]+/g, '/')
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -122,7 +122,7 @@ function isRecursive(args: readonly ShellWord[]): boolean {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
/** Operands of `rm`/`rmdir`: everything after `--` and everything from the first non-flag on. */
|
|
125
|
-
function targetsOf(args: readonly ShellWord[]): ShellWord[] {
|
|
125
|
+
export function targetsOf(args: readonly ShellWord[]): ShellWord[] {
|
|
126
126
|
const out: ShellWord[] = []
|
|
127
127
|
let afterDashes = false
|
|
128
128
|
let started = false
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { DANGEROUS_PATTERNS } from '../constants/tools/index.js'
|
|
2
1
|
import { isTrustedReadOnly } from '../tools/trusted-read-only.js'
|
|
3
2
|
import { matchesSourceIdGlob } from '../toolsets/source-glob.js'
|
|
4
3
|
import type { ToolSourceRef } from '../toolsets/types.js'
|
|
5
4
|
import type { AuthorizationRule, GateDecision } from '../types/authorization/index.js'
|
|
6
5
|
import type { ToolDefinition } from '../types/tool/index.js'
|
|
7
|
-
import { decodedCommands, decomposeCommandLine } from './command-line.js'
|
|
6
|
+
import { decodedCommands, decomposeCommandLine, writesThroughRedirection } from './command-line.js'
|
|
7
|
+
import { type DangerousFinding, findDangerousCommand } from './dangerous-commands.js'
|
|
8
|
+
import { isReadOnlyCommandLine } from './readonly-commands.js'
|
|
8
9
|
import type { ShellDialect } from './shell-lexer.js'
|
|
9
10
|
|
|
10
11
|
export interface EvaluateRuleOptions {
|
|
@@ -36,18 +37,43 @@ export interface EvaluateRuleOptions {
|
|
|
36
37
|
* running it, and a delegated child's own shell calls are floored when they
|
|
37
38
|
* run. A call with no definition to ask is read whole, as it always was.
|
|
38
39
|
*/
|
|
39
|
-
function executedText(
|
|
40
|
-
|
|
40
|
+
function executedText(
|
|
41
|
+
toolDef: ToolDefinition | undefined,
|
|
42
|
+
toolInput: unknown,
|
|
43
|
+
): { readonly text: string; readonly serialized: boolean } | undefined {
|
|
44
|
+
if (toolDef === undefined) return { text: JSON.stringify(toolInput) ?? '', serialized: true }
|
|
41
45
|
const argument = toolDef.commandArgument
|
|
42
46
|
if (argument !== undefined) {
|
|
43
47
|
const value = (toolInput as Record<string, unknown> | null | undefined)?.[argument]
|
|
44
48
|
if (value === undefined || value === null) return undefined
|
|
45
|
-
return typeof value === 'string'
|
|
49
|
+
return typeof value === 'string'
|
|
50
|
+
? { text: value, serialized: false }
|
|
51
|
+
: { text: JSON.stringify(value) ?? '', serialized: true }
|
|
46
52
|
}
|
|
47
|
-
if (toolDef.category === 'shell')
|
|
53
|
+
if (toolDef.category === 'shell')
|
|
54
|
+
return { text: JSON.stringify(toolInput) ?? '', serialized: true }
|
|
48
55
|
return undefined
|
|
49
56
|
}
|
|
50
57
|
|
|
58
|
+
/**
|
|
59
|
+
* What the dangerous-command floor found in a call, or `undefined`: an act that
|
|
60
|
+
* cannot be undone (`stop`, a denial in every mode) or one that is a person's
|
|
61
|
+
* call (`ask`). `strict` keeps every entry of the raw list a `stop`.
|
|
62
|
+
*/
|
|
63
|
+
export function dangerousFindingFor(
|
|
64
|
+
toolDef: ToolDefinition | undefined,
|
|
65
|
+
toolInput: unknown,
|
|
66
|
+
options: { readonly commandDialect?: ShellDialect; readonly strict?: boolean } = {},
|
|
67
|
+
): DangerousFinding | undefined {
|
|
68
|
+
const executed = executedText(toolDef, toolInput)
|
|
69
|
+
if (executed === undefined) return undefined
|
|
70
|
+
return findDangerousCommand(executed.text, {
|
|
71
|
+
dialect: options.commandDialect ?? 'sh',
|
|
72
|
+
serialized: executed.serialized,
|
|
73
|
+
...(options.strict === true ? { strict: true } : {}),
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
|
|
51
77
|
export function evaluateRule(
|
|
52
78
|
rule: AuthorizationRule,
|
|
53
79
|
toolName: string,
|
|
@@ -90,14 +116,15 @@ export function evaluateRule(
|
|
|
90
116
|
}
|
|
91
117
|
|
|
92
118
|
case 'deny_dangerous_patterns': {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
119
|
+
const finding = dangerousFindingFor(toolDef, toolInput, {
|
|
120
|
+
commandDialect: dialect,
|
|
121
|
+
strict: rule.strict === true,
|
|
122
|
+
})
|
|
123
|
+
if (finding === undefined) return null
|
|
124
|
+
// A `stop` is refused in every mode. An `ask` is a question: the gate
|
|
125
|
+
// answers `review`, which the modes that ask put to the person and
|
|
126
|
+
// bypass and auto lift like any other.
|
|
127
|
+
return finding.tier === 'stop' ? 'deny' : 'review'
|
|
101
128
|
}
|
|
102
129
|
|
|
103
130
|
case 'allow_by_category': {
|
|
@@ -219,7 +246,14 @@ export function evaluateRule(
|
|
|
219
246
|
// let `git status && rm -rf ~` through an allow rule for
|
|
220
247
|
// `^git status`.
|
|
221
248
|
if (opaque) return null
|
|
222
|
-
|
|
249
|
+
if (toolDef?.commandArgument !== rule.argument) {
|
|
250
|
+
return segments.every((segment) => compiledPattern.test(segment)) ? 'allow' : null
|
|
251
|
+
}
|
|
252
|
+
return coversCommandLine(segments, subject, dialect, (segment) =>
|
|
253
|
+
compiledPattern.test(segment),
|
|
254
|
+
)
|
|
255
|
+
? 'allow'
|
|
256
|
+
: null
|
|
223
257
|
}
|
|
224
258
|
|
|
225
259
|
case 'allow_by_tier': {
|
|
@@ -252,6 +286,32 @@ export function evaluateRule(
|
|
|
252
286
|
}
|
|
253
287
|
}
|
|
254
288
|
|
|
289
|
+
/**
|
|
290
|
+
* Whether the rule's pattern covers a whole command line: every command in it
|
|
291
|
+
* either matches the pattern or only reads (`tail`, `head`, `grep`, `wc`, a
|
|
292
|
+
* `2>&1`), and at least one matches, so a rule for `npm test *` covers
|
|
293
|
+
* `npm test 2>&1 | tail -20` and not `npm test | sh`. A line that writes a
|
|
294
|
+
* file through a redirection is covered by no rule: a pattern names commands,
|
|
295
|
+
* not the file a redirection opens.
|
|
296
|
+
*/
|
|
297
|
+
function coversCommandLine(
|
|
298
|
+
segments: readonly string[],
|
|
299
|
+
line: string,
|
|
300
|
+
dialect: ShellDialect,
|
|
301
|
+
matches: (segment: string) => boolean,
|
|
302
|
+
): boolean {
|
|
303
|
+
if (writesThroughRedirection(line, dialect)) return false
|
|
304
|
+
let matched = false
|
|
305
|
+
for (const segment of segments) {
|
|
306
|
+
if (matches(segment)) {
|
|
307
|
+
matched = true
|
|
308
|
+
continue
|
|
309
|
+
}
|
|
310
|
+
if (segments.length === 1 || !isReadOnlyCommandLine(segment, dialect)) return false
|
|
311
|
+
}
|
|
312
|
+
return matched
|
|
313
|
+
}
|
|
314
|
+
|
|
255
315
|
function capturesScreen(toolDef: ToolDefinition | undefined, toolInput: unknown): boolean {
|
|
256
316
|
if (!toolDef?.capturesScreen) return false
|
|
257
317
|
try {
|
|
@@ -201,6 +201,24 @@ export function nestedShellCommand(words: readonly ShellWord[]): NestedShellComm
|
|
|
201
201
|
return { shell: invocation.shell, payload: found.payload }
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Where each command sits in the string it was read from, by command. Kept
|
|
206
|
+
* beside the command rather than on it, so the public shape stays as it is.
|
|
207
|
+
*/
|
|
208
|
+
const SPANS = new WeakMap<ShellCommand, { readonly start: number; readonly end: number }>()
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Where `command` sits in the string it was read from: `start` is its first
|
|
212
|
+
* character and `end` one past its last, so `text` is that slice. For a
|
|
213
|
+
* command of the line itself (`origin: 'line'`, `depth: 0`) the offsets are
|
|
214
|
+
* into the line. Undefined for a command this lexer did not produce.
|
|
215
|
+
*/
|
|
216
|
+
export function commandSpan(
|
|
217
|
+
command: ShellCommand,
|
|
218
|
+
): { readonly start: number; readonly end: number } | undefined {
|
|
219
|
+
return SPANS.get(command)
|
|
220
|
+
}
|
|
221
|
+
|
|
204
222
|
/** How many `bash -c` payloads deep the lexer follows before it gives up. */
|
|
205
223
|
const MAX_SHELL_DEPTH = 4
|
|
206
224
|
/** How deep compound commands and expansions may nest before it gives up. */
|
|
@@ -1160,6 +1178,7 @@ class Parser {
|
|
|
1160
1178
|
origin: this.origin,
|
|
1161
1179
|
depth: this.depth,
|
|
1162
1180
|
}
|
|
1181
|
+
SPANS.set(command, { start, end })
|
|
1163
1182
|
this.context.commands.push(command)
|
|
1164
1183
|
this.inspect(command)
|
|
1165
1184
|
}
|
|
@@ -26,6 +26,8 @@ export interface AcpPermissionRequest {
|
|
|
26
26
|
* `mustAskPerson`; a gateway that sends none keeps the old behaviour.
|
|
27
27
|
*/
|
|
28
28
|
readonly alwaysAsk?: boolean
|
|
29
|
+
/** Rides to the client untouched; see `AcpRequestPermissionParams`. */
|
|
30
|
+
readonly computer?: { readonly app?: string; readonly consequence?: string }
|
|
29
31
|
})[]
|
|
30
32
|
}
|
|
31
33
|
|
package/src/bridge/acp/server.ts
CHANGED
|
@@ -89,6 +89,8 @@ export interface AcpAgentGateway {
|
|
|
89
89
|
readonly prompt: string
|
|
90
90
|
readonly attachments?: AcpSessionPromptParams['attachments']
|
|
91
91
|
readonly options?: AcpSessionPromptParams['options']
|
|
92
|
+
/** Pasted stretches of `prompt`, already checked: in range, in order, apart. */
|
|
93
|
+
readonly pasted?: AcpSessionPromptParams['pasted']
|
|
92
94
|
readonly cwd: string
|
|
93
95
|
readonly onEvent: (event: SessionEvent) => void
|
|
94
96
|
readonly signal: AbortSignal
|
|
@@ -145,12 +147,16 @@ export interface AcpServerOptions {
|
|
|
145
147
|
readonly supportsPromptAttachments?: boolean
|
|
146
148
|
/** The host applies optional effort and permission settings to the exact turn. */
|
|
147
149
|
readonly supportsPromptOptions?: boolean
|
|
150
|
+
/** The gateway frames `pasted` ranges of a prompt itself; announced as `promptPasted`. */
|
|
151
|
+
readonly supportsPromptPasted?: boolean
|
|
148
152
|
/**
|
|
149
153
|
* Which of the newer review modes, `bypass` and `classify`, the gateway
|
|
150
154
|
* applies when a prompt asks for one in its options. Omitted, a prompt that
|
|
151
155
|
* asks for either is refused with an error that says so, before any turn
|
|
152
156
|
* starts, rather than reaching a gateway that cannot honour it. Advertised
|
|
153
|
-
* as `promptPermissionModes` at initialization.
|
|
157
|
+
* as `promptPermissionModes` at initialization. An empty list is advertised
|
|
158
|
+
* as empty (the host closes both), which a client tells apart from an older
|
|
159
|
+
* host that sends no list at all.
|
|
154
160
|
*/
|
|
155
161
|
readonly promptPermissionModes?: readonly ('bypass' | 'classify')[]
|
|
156
162
|
/** Emit planning notifications only to clients declaring namzu/tasks. */
|
|
@@ -220,6 +226,19 @@ class AcpError extends Error {
|
|
|
220
226
|
}
|
|
221
227
|
}
|
|
222
228
|
|
|
229
|
+
/**
|
|
230
|
+
* A stable machine code a host may attach to a failure it throws (`data: { code }` on the error).
|
|
231
|
+
* It goes out as the JSON-RPC error's `data`, so a client can pick its own wording by code and
|
|
232
|
+
* keep the sentence as the fallback. Anything else on the error is not sent.
|
|
233
|
+
*/
|
|
234
|
+
function stableErrorData(err: unknown): { code: string } | undefined {
|
|
235
|
+
if (!err || typeof err !== 'object') return undefined
|
|
236
|
+
const data = (err as { data?: unknown }).data
|
|
237
|
+
if (!data || typeof data !== 'object') return undefined
|
|
238
|
+
const code = (data as { code?: unknown }).code
|
|
239
|
+
return typeof code === 'string' && /^[a-z][a-z0-9-]{0,63}$/.test(code) ? { code } : undefined
|
|
240
|
+
}
|
|
241
|
+
|
|
223
242
|
export class ACPServer {
|
|
224
243
|
private readonly log: Logger
|
|
225
244
|
private readonly sessions = new Map<string, Session>()
|
|
@@ -419,7 +438,12 @@ export class ACPServer {
|
|
|
419
438
|
}
|
|
420
439
|
} catch (err) {
|
|
421
440
|
const code = err instanceof AcpError ? err.code : ACP_ERROR_CODES.INTERNAL_ERROR
|
|
422
|
-
await this.respondError(
|
|
441
|
+
await this.respondError(
|
|
442
|
+
message.id,
|
|
443
|
+
code,
|
|
444
|
+
err instanceof Error ? err.message : String(err),
|
|
445
|
+
stableErrorData(err),
|
|
446
|
+
)
|
|
423
447
|
}
|
|
424
448
|
}
|
|
425
449
|
|
|
@@ -427,6 +451,7 @@ export class ACPServer {
|
|
|
427
451
|
id: MCPJsonRpcMessage['id'],
|
|
428
452
|
code: number,
|
|
429
453
|
message: string,
|
|
454
|
+
data?: { code: string },
|
|
430
455
|
): Promise<void> {
|
|
431
456
|
// A notification (no id) that failed has nowhere to send an error, so
|
|
432
457
|
// it is logged instead of dropped silently — on stderr, where it does
|
|
@@ -438,7 +463,7 @@ export class ACPServer {
|
|
|
438
463
|
})
|
|
439
464
|
return
|
|
440
465
|
}
|
|
441
|
-
await this.send({ jsonrpc: '2.0', id, error: { code, message } })
|
|
466
|
+
await this.send({ jsonrpc: '2.0', id, error: { code, message, ...(data ? { data } : {}) } })
|
|
442
467
|
}
|
|
443
468
|
|
|
444
469
|
private async send(message: MCPJsonRpcMessage, requireDelivery = false): Promise<void> {
|
|
@@ -493,7 +518,8 @@ export class ACPServer {
|
|
|
493
518
|
},
|
|
494
519
|
...(this.options.supportsPromptAttachments ? { promptAttachments: true } : {}),
|
|
495
520
|
...(this.options.supportsPromptOptions ? { promptOptions: true } : {}),
|
|
496
|
-
...(this.options.
|
|
521
|
+
...(this.options.supportsPromptPasted ? { promptPasted: true } : {}),
|
|
522
|
+
...(this.options.supportsPromptOptions && this.options.promptPermissionModes !== undefined
|
|
497
523
|
? { promptPermissionModes: [...this.options.promptPermissionModes] }
|
|
498
524
|
: {}),
|
|
499
525
|
agentInfo: this.options.agentInfo,
|
|
@@ -676,6 +702,7 @@ export class ACPServer {
|
|
|
676
702
|
throw new AcpError(ACP_ERROR_CODES.INVALID_PARAMS, 'Invalid prompt text.')
|
|
677
703
|
const attachments = this.readPromptAttachments(params.attachments)
|
|
678
704
|
const options = this.readPromptOptions(params.options)
|
|
705
|
+
const pasted = this.readPromptPasted(params.pasted, params.prompt)
|
|
679
706
|
if (attachments.length && this.options.supportsPromptAttachments !== true)
|
|
680
707
|
throw new AcpError(
|
|
681
708
|
ACP_ERROR_CODES.INVALID_REQUEST,
|
|
@@ -703,6 +730,7 @@ export class ACPServer {
|
|
|
703
730
|
prompt: params.prompt,
|
|
704
731
|
...(attachments.length ? { attachments } : {}),
|
|
705
732
|
...(options ? { options } : {}),
|
|
733
|
+
...(pasted ? { pasted } : {}),
|
|
706
734
|
cwd: session.cwd,
|
|
707
735
|
signal: controller.signal,
|
|
708
736
|
onEvent: (event) => {
|
|
@@ -867,6 +895,34 @@ export class ACPServer {
|
|
|
867
895
|
}
|
|
868
896
|
}
|
|
869
897
|
|
|
898
|
+
private readPromptPasted(value: unknown, prompt: string): AcpSessionPromptParams['pasted'] {
|
|
899
|
+
if (value === undefined) return undefined
|
|
900
|
+
if (this.options.supportsPromptPasted !== true)
|
|
901
|
+
throw new AcpError(
|
|
902
|
+
ACP_ERROR_CODES.INVALID_REQUEST,
|
|
903
|
+
'This agent does not accept pasted ranges.',
|
|
904
|
+
)
|
|
905
|
+
if (!Array.isArray(value) || value.length > 64)
|
|
906
|
+
throw new AcpError(ACP_ERROR_CODES.INVALID_PARAMS, 'Invalid pasted ranges.')
|
|
907
|
+
let floor = 0
|
|
908
|
+
const ranges = value.map((item) => {
|
|
909
|
+
const range = item as { start?: unknown; end?: unknown } | null
|
|
910
|
+
if (
|
|
911
|
+
!range ||
|
|
912
|
+
typeof range !== 'object' ||
|
|
913
|
+
!Number.isInteger(range.start) ||
|
|
914
|
+
!Number.isInteger(range.end) ||
|
|
915
|
+
(range.start as number) < floor ||
|
|
916
|
+
(range.end as number) <= (range.start as number) ||
|
|
917
|
+
(range.end as number) > prompt.length
|
|
918
|
+
)
|
|
919
|
+
throw new AcpError(ACP_ERROR_CODES.INVALID_PARAMS, 'Invalid pasted ranges.')
|
|
920
|
+
floor = range.end as number
|
|
921
|
+
return { start: range.start as number, end: range.end as number }
|
|
922
|
+
})
|
|
923
|
+
return ranges.length ? ranges : undefined
|
|
924
|
+
}
|
|
925
|
+
|
|
870
926
|
private readPromptOptions(value: unknown): AcpSessionPromptParams['options'] {
|
|
871
927
|
if (value === undefined) return undefined
|
|
872
928
|
if (this.options.supportsPromptOptions !== true)
|
|
@@ -876,9 +932,12 @@ export class ACPServer {
|
|
|
876
932
|
)
|
|
877
933
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
878
934
|
throw new AcpError(ACP_ERROR_CODES.INVALID_PARAMS, 'Invalid prompt settings.')
|
|
879
|
-
const { effort, permissionMode } = value as Record<string, unknown>
|
|
935
|
+
const { effort, permissionMode, hypermode } = value as Record<string, unknown>
|
|
880
936
|
if (
|
|
881
|
-
Object.keys(value).some(
|
|
937
|
+
Object.keys(value).some(
|
|
938
|
+
(key) => key !== 'effort' && key !== 'permissionMode' && key !== 'hypermode',
|
|
939
|
+
) ||
|
|
940
|
+
(hypermode !== undefined && typeof hypermode !== 'boolean') ||
|
|
882
941
|
(effort !== undefined &&
|
|
883
942
|
(typeof effort !== 'string' ||
|
|
884
943
|
!['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra'].includes(
|
|
@@ -907,6 +966,7 @@ export class ACPServer {
|
|
|
907
966
|
>['permissionMode'],
|
|
908
967
|
}
|
|
909
968
|
: {}),
|
|
969
|
+
...(typeof hypermode === 'boolean' ? { hypermode } : {}),
|
|
910
970
|
}
|
|
911
971
|
}
|
|
912
972
|
private readPromptAttachments(
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
*
|
|
9
9
|
* The conversation's own share is never counted separately: it is whatever the
|
|
10
10
|
* measured prompt size is once the fixed parts are taken out, so the categories
|
|
11
|
-
* always add up to the figure the provider reported.
|
|
11
|
+
* always add up to the figure the provider reported. A figure the kernel only
|
|
12
|
+
* estimated covers less than a provider's, and is read that way.
|
|
12
13
|
*/
|
|
13
14
|
|
|
14
15
|
import { CHARS_PER_TOKEN } from '../constants/limits.js'
|
|
@@ -29,8 +30,18 @@ export const CONTEXT_CATEGORY_ORDER = [
|
|
|
29
30
|
'messages',
|
|
30
31
|
] as const
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Tool definitions that are not sent yet (they load only when the model asks
|
|
35
|
+
* for them) are sized as `deferred`. They are never counted as used.
|
|
36
|
+
*/
|
|
37
|
+
export const DEFERRED_CATEGORY_ORDER = ['deferred-tools', 'deferred-mcp-tools'] as const
|
|
38
|
+
|
|
39
|
+
export type ContextCategoryId =
|
|
40
|
+
| (typeof CONTEXT_CATEGORY_ORDER)[number]
|
|
41
|
+
| (typeof DEFERRED_CATEGORY_ORDER)[number]
|
|
42
|
+
| 'buffer'
|
|
43
|
+
| 'free'
|
|
44
|
+
export type ContextCategoryKind = 'used' | 'deferred' | 'free' | 'buffer'
|
|
34
45
|
|
|
35
46
|
export interface ContextCategory {
|
|
36
47
|
readonly id: ContextCategoryId
|
|
@@ -39,6 +50,11 @@ export interface ContextCategory {
|
|
|
39
50
|
readonly kind: ContextCategoryKind
|
|
40
51
|
}
|
|
41
52
|
|
|
53
|
+
const DEFERRED_NAMES: Record<(typeof DEFERRED_CATEGORY_ORDER)[number], string> = {
|
|
54
|
+
'deferred-tools': 'System tools (deferred)',
|
|
55
|
+
'deferred-mcp-tools': 'MCP tools (deferred)',
|
|
56
|
+
}
|
|
57
|
+
|
|
42
58
|
const NAMES: Record<(typeof CONTEXT_CATEGORY_ORDER)[number], string> = {
|
|
43
59
|
'system-prompt': 'System prompt',
|
|
44
60
|
'system-tools': 'System tools',
|
|
@@ -53,9 +69,11 @@ const NAMES: Record<(typeof CONTEXT_CATEGORY_ORDER)[number], string> = {
|
|
|
53
69
|
export interface ContextUsageInput {
|
|
54
70
|
readonly windowTokens: number
|
|
55
71
|
/**
|
|
56
|
-
* `auto` when the window is what the provider or model table declares
|
|
57
|
-
*
|
|
58
|
-
*
|
|
72
|
+
* `auto` when the window is what the provider or model table declares;
|
|
73
|
+
* `config` or `default` when it was overridden or guessed. The compaction
|
|
74
|
+
* buffer is drawn for every source whenever the session summarises on its
|
|
75
|
+
* own, so this no longer changes the numbers; it stays so a host can say
|
|
76
|
+
* where the window came from.
|
|
59
77
|
*/
|
|
60
78
|
readonly windowSource: 'auto' | 'config' | 'default'
|
|
61
79
|
/** What the model may write in one reply; absent reserves the full cap. */
|
|
@@ -67,6 +85,13 @@ export interface ContextUsageInput {
|
|
|
67
85
|
* Absent, the conversation is estimated from `messages`.
|
|
68
86
|
*/
|
|
69
87
|
readonly contextTokens?: number
|
|
88
|
+
/**
|
|
89
|
+
* Who counted `contextTokens`. A provider counts the whole request. The
|
|
90
|
+
* kernel's own estimate covers only the messages and the tool catalogue, so
|
|
91
|
+
* the system prompt, instruction files, skills and agents are added on top
|
|
92
|
+
* of it instead of being taken out of it. Absent is read as `provider`.
|
|
93
|
+
*/
|
|
94
|
+
readonly measuredBy?: 'provider' | 'estimate'
|
|
70
95
|
readonly systemPromptTokens?: number
|
|
71
96
|
/** Tokens of the built-in tool definitions. */
|
|
72
97
|
readonly systemToolTokens?: number
|
|
@@ -75,6 +100,10 @@ export interface ContextUsageInput {
|
|
|
75
100
|
readonly agentTokens?: number
|
|
76
101
|
readonly memoryTokens?: number
|
|
77
102
|
readonly skillTokens?: number
|
|
103
|
+
/** Tokens of built-in tool definitions that load only when needed; not counted as used. */
|
|
104
|
+
readonly deferredToolTokens?: number
|
|
105
|
+
/** Tokens of tool-server tool definitions that load only when needed; not counted as used. */
|
|
106
|
+
readonly deferredMcpToolTokens?: number
|
|
78
107
|
/** The conversation, for the estimate and for the per-tool breakdown. */
|
|
79
108
|
readonly messages?: readonly Message[]
|
|
80
109
|
}
|
|
@@ -125,9 +154,8 @@ function nonNegative(value: number | undefined): number {
|
|
|
125
154
|
|
|
126
155
|
function bufferFor(input: ContextUsageInput): number {
|
|
127
156
|
if (input.autoCompact) {
|
|
128
|
-
// Drawn
|
|
129
|
-
//
|
|
130
|
-
if (input.windowSource === 'auto') return 0
|
|
157
|
+
// Drawn whenever the session summarises on its own, for every window
|
|
158
|
+
// source: it is the room the trigger keeps for the next reply.
|
|
131
159
|
const reserve = Math.min(
|
|
132
160
|
input.maxOutputTokens !== undefined && input.maxOutputTokens > 0
|
|
133
161
|
? input.maxOutputTokens
|
|
@@ -191,6 +219,13 @@ export function analyzeContextUsage(input: ContextUsageInput): ContextBreakdown
|
|
|
191
219
|
messages: 0,
|
|
192
220
|
}
|
|
193
221
|
const fixedTotal = Object.values(fixed).reduce((sum, tokens) => sum + tokens, 0)
|
|
222
|
+
// The kernel's estimate counts the messages (recorded context included) and
|
|
223
|
+
// the tool catalogue, and nothing else; the rest sits on top of it.
|
|
224
|
+
const estimated = input.measuredBy === 'estimate'
|
|
225
|
+
const inEstimate = estimated
|
|
226
|
+
? fixed['system-tools'] + fixed['mcp-tools'] + recordedTokens
|
|
227
|
+
: fixedTotal
|
|
228
|
+
const outsideEstimate = fixedTotal - inEstimate
|
|
194
229
|
const messages = input.messages ?? []
|
|
195
230
|
const bufferTokens = Math.min(bufferFor(input), windowTokens)
|
|
196
231
|
|
|
@@ -199,19 +234,26 @@ export function analyzeContextUsage(input: ContextUsageInput): ContextBreakdown
|
|
|
199
234
|
const measured = nonNegative(input.contextTokens)
|
|
200
235
|
const rawMessages =
|
|
201
236
|
measured > 0
|
|
202
|
-
? Math.max(0, measured -
|
|
237
|
+
? Math.max(0, measured - inEstimate)
|
|
203
238
|
: messages.reduce(
|
|
204
239
|
(sum, message) => (isTurnContextEntry(message) ? sum : sum + tokensOfContent(message)),
|
|
205
240
|
0,
|
|
206
241
|
)
|
|
207
242
|
fixed.messages = Math.min(rawMessages, Math.max(0, windowTokens - fixedTotal - bufferTokens))
|
|
208
243
|
|
|
209
|
-
const totalTokens =
|
|
244
|
+
const totalTokens =
|
|
245
|
+
measured > 0 ? Math.max(measured + outsideEstimate, fixedTotal) : fixedTotal + rawMessages
|
|
210
246
|
const used = fixedTotal + fixed.messages
|
|
211
247
|
const categories: ContextCategory[] = []
|
|
212
248
|
for (const id of CONTEXT_CATEGORY_ORDER) {
|
|
213
249
|
if (fixed[id] > 0) categories.push({ id, name: NAMES[id], tokens: fixed[id], kind: 'used' })
|
|
214
250
|
}
|
|
251
|
+
for (const id of DEFERRED_CATEGORY_ORDER) {
|
|
252
|
+
const tokens = nonNegative(
|
|
253
|
+
id === 'deferred-tools' ? input.deferredToolTokens : input.deferredMcpToolTokens,
|
|
254
|
+
)
|
|
255
|
+
if (tokens > 0) categories.push({ id, name: DEFERRED_NAMES[id], tokens, kind: 'deferred' })
|
|
256
|
+
}
|
|
215
257
|
const free = Math.max(0, windowTokens - used - bufferTokens)
|
|
216
258
|
if (bufferTokens > 0) {
|
|
217
259
|
categories.push({
|
|
@@ -296,6 +296,7 @@ function unknownOutcomeResult(
|
|
|
296
296
|
role: CONSTANTS.TOOL_ROLE,
|
|
297
297
|
toolCallId: call.id,
|
|
298
298
|
isError: true,
|
|
299
|
+
outcome: 'interrupted',
|
|
299
300
|
content: `The \`${call.function.name}\` call did not run: the session ended before it started (it may have been waiting for the user's approval, which was never given). Nothing was changed. If it is still needed, call it again.`,
|
|
300
301
|
...(assistant.timestamp !== undefined ? { timestamp: assistant.timestamp } : {}),
|
|
301
302
|
}
|
|
@@ -304,6 +305,7 @@ function unknownOutcomeResult(
|
|
|
304
305
|
role: CONSTANTS.TOOL_ROLE,
|
|
305
306
|
toolCallId: call.id,
|
|
306
307
|
isError: true,
|
|
308
|
+
outcome: 'interrupted',
|
|
307
309
|
content: `Tool execution was interrupted and no durable result is available for \`${call.function.name}\`. Its outcome is unknown. Retry only if the tool is read-only or idempotent; otherwise verify external state or ask the user before retrying.`,
|
|
308
310
|
...(assistant.timestamp !== undefined ? { timestamp: assistant.timestamp } : {}),
|
|
309
311
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { CompactionConfig } from '../config/runtime.js'
|
|
2
2
|
import { EDIT_TOOLS, READ_TOOLS, SEARCH_TOOLS, SHELL_TOOLS } from '../constants/compaction/index.js'
|
|
3
|
+
import { PASTED_MARKER, typedTextOf } from '../runtime/query/pasted-frames.js'
|
|
4
|
+
import type { UserMessage } from '../types/message/index.js'
|
|
3
5
|
import { type WorkingStateManager, truncateStateText } from './manager.js'
|
|
4
6
|
|
|
5
7
|
function tryParseJson(raw: string): Record<string, unknown> | null {
|
|
@@ -185,11 +187,17 @@ function describeShape(value: unknown): string {
|
|
|
185
187
|
return typeof value
|
|
186
188
|
}
|
|
187
189
|
|
|
190
|
+
/**
|
|
191
|
+
* The operator's message as the task or a requirement. A message may be given
|
|
192
|
+
* whole: text the person pasted is material, not something they said, so it
|
|
193
|
+
* is left out of what is filed as theirs and a marker stands in its place.
|
|
194
|
+
*/
|
|
188
195
|
export function extractFromUserMessage(
|
|
189
196
|
manager: WorkingStateManager,
|
|
190
|
-
|
|
197
|
+
message: string | UserMessage,
|
|
191
198
|
isFirst: boolean,
|
|
192
199
|
): void {
|
|
200
|
+
const content = typeof message === 'string' ? message : typedTextOf(message, PASTED_MARKER)
|
|
193
201
|
if (!content.trim()) return
|
|
194
202
|
|
|
195
203
|
if (isFirst) {
|
package/src/compaction/index.ts
CHANGED
|
@@ -49,7 +49,7 @@ export class StructuredCompactionManager implements ConversationManager {
|
|
|
49
49
|
for (const message of messages) {
|
|
50
50
|
if (message.role === 'user') {
|
|
51
51
|
if (!isOperatorUserMessage(message)) continue
|
|
52
|
-
extractFromUserMessage(stateManager, message
|
|
52
|
+
extractFromUserMessage(stateManager, message, isFirstUserMessage)
|
|
53
53
|
isFirstUserMessage = false
|
|
54
54
|
} else if (message.role === 'assistant' && message.content) {
|
|
55
55
|
extractFromAssistantMessage(stateManager, message.content, this.config)
|
|
@@ -129,7 +129,7 @@ export class StructuredCompactionManager implements ConversationManager {
|
|
|
129
129
|
for (const message of messages) {
|
|
130
130
|
if (message.role === 'user') {
|
|
131
131
|
if (!isOperatorUserMessage(message)) continue
|
|
132
|
-
extractFromUserMessage(stateManager, message
|
|
132
|
+
extractFromUserMessage(stateManager, message, isFirstUserMessage)
|
|
133
133
|
isFirstUserMessage = false
|
|
134
134
|
} else if (message.role === 'assistant' && message.content) {
|
|
135
135
|
extractFromAssistantMessage(stateManager, message.content, this.config)
|