@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
package/src/compaction/manual.ts
CHANGED
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
import { planCompaction } from './plan.js'
|
|
33
33
|
import { recordRestorable, renderRestoredContext } from './restore.js'
|
|
34
34
|
import { findRetainedIndices } from './retention.js'
|
|
35
|
-
import { buildCompactionMessage, isCompactionMessage } from './summary.js'
|
|
35
|
+
import { buildCompactionMessage, collectRevealedTools, isCompactionMessage } from './summary.js'
|
|
36
36
|
import { estimateMessagesTokens } from './token-estimate.js'
|
|
37
37
|
import { type CompactionVerificationOptions, buildVerifiedSummary } from './verifier.js'
|
|
38
38
|
|
|
@@ -224,12 +224,18 @@ function splice(
|
|
|
224
224
|
retainedOlder: readonly Message[],
|
|
225
225
|
recentMessages: readonly Message[],
|
|
226
226
|
recoveryNote?: string,
|
|
227
|
+
cut: readonly Message[] = [],
|
|
227
228
|
): { messages: Message[]; summary: Message } {
|
|
228
229
|
// A host-triggered pass has no turn-scoped WorkingStateManager to carry the
|
|
229
230
|
// summary into a later query. Pin this summary itself: until a future turn
|
|
230
231
|
// has rebuilt equivalent state, this message is the only surviving record
|
|
231
232
|
// of what the pass removed.
|
|
232
|
-
|
|
233
|
+
// `cut` is every message the pass read: the tools it loaded are still loaded
|
|
234
|
+
// once the messages that loaded them are gone.
|
|
235
|
+
const summary = {
|
|
236
|
+
...buildCompactionMessage(summaryBody, recoveryNote, collectRevealedTools(cut)),
|
|
237
|
+
retain: true,
|
|
238
|
+
}
|
|
233
239
|
return { messages: [...preservedSystem, summary, ...retainedOlder, ...recentMessages], summary }
|
|
234
240
|
}
|
|
235
241
|
|
|
@@ -273,7 +279,7 @@ function populateWorkingState(
|
|
|
273
279
|
// text in the user role. They are neither the task nor a
|
|
274
280
|
// requirement the operator stated.
|
|
275
281
|
if (!isOperatorUserMessage(message)) break
|
|
276
|
-
extractFromUserMessage(manager, message
|
|
282
|
+
extractFromUserMessage(manager, message, firstUser)
|
|
277
283
|
firstUser = false
|
|
278
284
|
break
|
|
279
285
|
case 'assistant':
|
|
@@ -391,6 +397,7 @@ export async function compactNow(input: CompactNowInput): Promise<CompactionResu
|
|
|
391
397
|
retainedOlder,
|
|
392
398
|
plan.recentMessages,
|
|
393
399
|
input.recoveryNote,
|
|
400
|
+
input.messages,
|
|
394
401
|
)
|
|
395
402
|
const published = await publishManualCompaction(input, {
|
|
396
403
|
messages,
|
|
@@ -508,6 +515,7 @@ export async function compactRegion(input: CompactRegionInput): Promise<Compacti
|
|
|
508
515
|
...messages.slice(end),
|
|
509
516
|
]),
|
|
510
517
|
input.recoveryNote,
|
|
518
|
+
collectRevealedTools(messages),
|
|
511
519
|
),
|
|
512
520
|
retain: true,
|
|
513
521
|
}
|
|
@@ -3,6 +3,7 @@ import { frameOperatorHookContext } from '../plugin/hook-context.js'
|
|
|
3
3
|
import { collectChatCompletion } from '../provider/collect-chat-completion.js'
|
|
4
4
|
import { resolveStreamIdleTimeoutMs, withStreamIdleTimeout } from '../provider/idle-timeout.js'
|
|
5
5
|
import { chatStreamWithSamplingRepair } from '../runtime/query/iteration/side-call.js'
|
|
6
|
+
import { framePastedContent } from '../runtime/query/pasted-frames.js'
|
|
6
7
|
import { isOperatorUserMessage } from '../runtime/query/steering.js'
|
|
7
8
|
import {
|
|
8
9
|
generateRenderNonce,
|
|
@@ -140,7 +141,13 @@ export function renderTranscript(
|
|
|
140
141
|
let entry: string
|
|
141
142
|
if (message.role === 'user') {
|
|
142
143
|
const label = isOperatorUserMessage(message) ? 'person' : 'runtime note'
|
|
143
|
-
|
|
144
|
+
// A paste goes to the summary model inside its frame, as it goes to the
|
|
145
|
+
// main model, so directions inside it are not summarised as the ask.
|
|
146
|
+
const body =
|
|
147
|
+
typeof message.content === 'string' && message.pasted !== undefined
|
|
148
|
+
? quoteLabelLikeLines(framePastedContent(message))
|
|
149
|
+
: blockText(message, options.toolResultChars)
|
|
150
|
+
entry = `[${label}]: ${body}`
|
|
144
151
|
for (const attachment of message.attachments ?? []) {
|
|
145
152
|
entry += `\n${quoteLabelLikeLines([...attachmentExcerpt(attachment)].join(''))}`
|
|
146
153
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createSystemMessage } from '../types/message/index.js'
|
|
2
|
-
import type { Message } from '../types/message/index.js'
|
|
2
|
+
import type { Message, ToolRevealReceipt } from '../types/message/index.js'
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* The one marker that says a message is a compaction summary.
|
|
@@ -44,6 +44,48 @@ export const COMPACTION_RECOVERY_NOTE =
|
|
|
44
44
|
export const COMPACTION_RESUME_NOTE =
|
|
45
45
|
'Carry on from where this summary says the work stood, without asking the person to repeat it. Treat steps it marks done as done. Files may have changed or may not be shown in full, so read a file again before editing it. If it names something still running or waiting, check on that first.'
|
|
46
46
|
|
|
47
|
+
/** The opening of the line that names the deferred tools still loaded after a pass. */
|
|
48
|
+
export const COMPACTION_LOADED_TOOLS_PREFIX =
|
|
49
|
+
'Tools you loaded earlier with search_tools are still loaded'
|
|
50
|
+
|
|
51
|
+
/** Most tool names the loaded-tools line spells out. */
|
|
52
|
+
export const MAX_LOADED_TOOLS_NOTE_NAMES = 40
|
|
53
|
+
|
|
54
|
+
const LOADED_TOOLS_NOTE = new RegExp(`\\n\\n${COMPACTION_LOADED_TOOLS_PREFIX}[^\\n]*$`)
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The deferred tools a history had loaded: the receipts on its tool messages
|
|
58
|
+
* and on the compaction summaries it already holds, de-duplicated, oldest
|
|
59
|
+
* first. A pass reads this from the messages it is about to cut, so the new
|
|
60
|
+
* summary carries what the old ones did and what the cut span loaded.
|
|
61
|
+
*/
|
|
62
|
+
export function collectRevealedTools(messages: readonly Message[]): ToolRevealReceipt[] {
|
|
63
|
+
const seen = new Set<string>()
|
|
64
|
+
const out: ToolRevealReceipt[] = []
|
|
65
|
+
for (const message of messages) {
|
|
66
|
+
// A failed result loaded nothing; only tool results and summaries carry receipts.
|
|
67
|
+
if (message.role !== 'tool' && message.role !== 'system') continue
|
|
68
|
+
if (message.role === 'tool' && message.isError) continue
|
|
69
|
+
for (const receipt of message.revealedTools ?? []) {
|
|
70
|
+
const key = `${receipt.sourceKind}\u0000${receipt.sourceId}\u0000${receipt.name}`
|
|
71
|
+
if (seen.has(key)) continue
|
|
72
|
+
seen.add(key)
|
|
73
|
+
out.push(receipt)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return out
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function loadedToolsNote(revealed: readonly ToolRevealReceipt[]): string {
|
|
80
|
+
const names = [...new Set(revealed.map((receipt) => receipt.name))]
|
|
81
|
+
// The receipts on the message carry the full list; the line the model reads
|
|
82
|
+
// is bounded so a session that loaded many tools does not re-send it all.
|
|
83
|
+
const shown = names.slice(0, MAX_LOADED_TOOLS_NOTE_NAMES)
|
|
84
|
+
const more = names.length - shown.length
|
|
85
|
+
const list = more > 0 ? `${shown.join(', ')} and ${more} more` : shown.join(', ')
|
|
86
|
+
return `${COMPACTION_LOADED_TOOLS_PREFIX}: ${list}. Call them directly; load any other deferred tool with search_tools first.`
|
|
87
|
+
}
|
|
88
|
+
|
|
47
89
|
/**
|
|
48
90
|
* `text` without any closing notes this module adds, however many are stacked.
|
|
49
91
|
* An earlier summary is handed to the next pass whole, and a model may repeat
|
|
@@ -52,10 +94,9 @@ export const COMPACTION_RESUME_NOTE =
|
|
|
52
94
|
export function withoutClosingNotes(text: string): string {
|
|
53
95
|
let out = text.trimEnd()
|
|
54
96
|
for (;;) {
|
|
55
|
-
const next = [COMPACTION_RESUME_NOTE, COMPACTION_RECOVERY_NOTE]
|
|
56
|
-
(acc, note) => (acc.endsWith(note) ? acc.slice(0, -note.length).trimEnd() : acc),
|
|
57
|
-
|
|
58
|
-
)
|
|
97
|
+
const next = [COMPACTION_RESUME_NOTE, COMPACTION_RECOVERY_NOTE]
|
|
98
|
+
.reduce((acc, note) => (acc.endsWith(note) ? acc.slice(0, -note.length).trimEnd() : acc), out)
|
|
99
|
+
.replace(LOADED_TOOLS_NOTE, '')
|
|
59
100
|
if (next === out) return out
|
|
60
101
|
out = next
|
|
61
102
|
}
|
|
@@ -66,11 +107,17 @@ export function withoutClosingNotes(text: string): string {
|
|
|
66
107
|
* `recoveryNote` is appended as its own paragraph, then the resume note, which
|
|
67
108
|
* always closes the message.
|
|
68
109
|
*/
|
|
69
|
-
export function buildCompactionMessage(
|
|
110
|
+
export function buildCompactionMessage(
|
|
111
|
+
body: string,
|
|
112
|
+
recoveryNote?: string,
|
|
113
|
+
revealed: readonly ToolRevealReceipt[] = [],
|
|
114
|
+
): Message {
|
|
115
|
+
const loaded = revealed.length > 0 ? `\n\n${loadedToolsNote(revealed)}` : ''
|
|
70
116
|
return {
|
|
71
117
|
...createSystemMessage(
|
|
72
|
-
`${COMPACTION_HEADER}\n\n${withoutClosingNotes(body)}${recoveryNote ? `\n\n${recoveryNote}` : ''}\n\n${COMPACTION_RESUME_NOTE}`,
|
|
118
|
+
`${COMPACTION_HEADER}\n\n${withoutClosingNotes(body)}${recoveryNote ? `\n\n${recoveryNote}` : ''}${loaded}\n\n${COMPACTION_RESUME_NOTE}`,
|
|
73
119
|
),
|
|
74
120
|
source: { type: 'compaction-summary' },
|
|
121
|
+
...(revealed.length > 0 ? { revealedTools: revealed } : {}),
|
|
75
122
|
}
|
|
76
123
|
}
|
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
/**
|
|
2
|
+
* A fork bomb: a function whose own name is on both sides of a pipe, is
|
|
3
|
+
* backgrounded, and is then invoked. Read by the dangerous-command floor
|
|
4
|
+
* (`authorization/dangerous-commands.ts`) over a command line with its quoted
|
|
5
|
+
* text and comments blanked, and by {@link DANGEROUS_PATTERNS}.
|
|
6
|
+
*/
|
|
7
|
+
export const FORK_BOMB =
|
|
8
|
+
/([\w.]{1,32}|:)[ \t]{0,8}\([ \t]{0,8}\)[ \t]{0,8}\{[ \t]{0,8}\1[ \t]{0,8}\|[ \t]{0,8}\1[ \t]{0,8}&[ \t]{0,8};?[ \t]{0,8}\}[ \t]{0,8};?[ \t]{0,8}\1/
|
|
9
|
+
|
|
10
|
+
// The raw-text list behind the dangerous-command floor's STRICT mode
|
|
11
|
+
// (`denyDangerousPatterns: 'strict'`): every entry is a hard denial, matched
|
|
12
|
+
// against the text of the command wherever it appears, quoted or not.
|
|
8
13
|
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// (
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
14
|
+
// The default floor does not read this list. It reads what a command line
|
|
15
|
+
// RUNS (`authorization/dangerous-commands.ts`): the irreversible acts in it
|
|
16
|
+
// (a recursive removal of the root, the home folder or a top-level directory,
|
|
17
|
+
// a file system created on a device, a raw write to a device, a fork bomb, a
|
|
18
|
+
// world-writable root) are refused in every mode, and the rest (sudo, su -,
|
|
19
|
+
// ssh user@, eval, a download piped into a shell) are a question the person
|
|
20
|
+
// answers, which bypass and auto modes lift like any other.
|
|
21
|
+
//
|
|
22
|
+
// This is NOT a security boundary — bash denylists are bypassed via shell
|
|
23
|
+
// tricks like `e""cho`. Sandbox enforcement (FS isolation, network egress
|
|
24
|
+
// proxy) is the real boundary.
|
|
15
25
|
export const DANGEROUS_PATTERNS = [
|
|
16
26
|
// Filesystem wipe / fork bomb / raw disk write.
|
|
17
27
|
/rm\s+-rf\s+\//,
|
|
@@ -44,7 +54,7 @@ export const DANGEROUS_PATTERNS = [
|
|
|
44
54
|
* `[ \t]` rather than `\s`, because a shell function definition of this
|
|
45
55
|
* shape lives on one line, and the bound is generous for real spacing.
|
|
46
56
|
*/
|
|
47
|
-
|
|
57
|
+
FORK_BOMB,
|
|
48
58
|
// Privilege escalation + world-writable chmod on /.
|
|
49
59
|
/\bsudo\b/,
|
|
50
60
|
/\bsu\s+-/,
|
|
@@ -63,7 +73,7 @@ export const DANGEROUS_PATTERNS = [
|
|
|
63
73
|
* can say what to avoid instead of leaving the model to guess. Kept in step with
|
|
64
74
|
* the list above by position.
|
|
65
75
|
*/
|
|
66
|
-
const DANGEROUS_REASONS: readonly string[] = [
|
|
76
|
+
export const DANGEROUS_REASONS: readonly string[] = [
|
|
67
77
|
'it removes the file system root recursively',
|
|
68
78
|
'it creates a file system on a device',
|
|
69
79
|
'it writes raw data to a device or file with dd',
|
|
@@ -77,7 +87,11 @@ const DANGEROUS_REASONS: readonly string[] = [
|
|
|
77
87
|
'it evaluates a dynamic string with eval',
|
|
78
88
|
]
|
|
79
89
|
|
|
80
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* The reason {@link DANGEROUS_PATTERNS} (the strict list) refuses `command`, or a general one when
|
|
92
|
+
* none is recorded. For the reason the default floor gives, read
|
|
93
|
+
* `findDangerousCommand` in `authorization/dangerous-commands.ts`.
|
|
94
|
+
*/
|
|
81
95
|
export function dangerousCommandReason(command: string): string {
|
|
82
96
|
const index = DANGEROUS_PATTERNS.findIndex((pattern) => pattern.test(command))
|
|
83
97
|
return (
|
|
@@ -262,6 +262,8 @@ export class TurnRecorder {
|
|
|
262
262
|
#lastEntry: SessionLogEntry | undefined
|
|
263
263
|
#auditSeq = 0
|
|
264
264
|
#userMessageId: MessageId | undefined
|
|
265
|
+
/** The system prompt `turn_started` recorded for this turn, so a request record need not repeat it. */
|
|
266
|
+
#turnSystemPrompt: string | undefined
|
|
265
267
|
/** Set by {@link resume}: the next reconciliation re-bases the fold on the restored context. */
|
|
266
268
|
#rebasePending = false
|
|
267
269
|
/**
|
|
@@ -849,6 +851,7 @@ export class TurnRecorder {
|
|
|
849
851
|
.find((m) => m.role === 'user')
|
|
850
852
|
const userMessageId = pendingUser ? this.#idFor(pendingUser) : generateMessageId()
|
|
851
853
|
this.#userMessageId = userMessageId
|
|
854
|
+
this.#turnSystemPrompt = draft.systemPrompt
|
|
852
855
|
const binding = this.budget?.binding
|
|
853
856
|
const entry = await this.#enqueue(async () => {
|
|
854
857
|
const begun = await this.log.beginTurn(
|
|
@@ -1010,7 +1013,10 @@ export class TurnRecorder {
|
|
|
1010
1013
|
this.#syncMessages()
|
|
1011
1014
|
await this.#replaceAnswerIfOverridden()
|
|
1012
1015
|
}
|
|
1013
|
-
const draft =
|
|
1016
|
+
const draft = this.#withoutRepeatedPrompt(
|
|
1017
|
+
event,
|
|
1018
|
+
eventDraft(event, this.#turnOpen() ? this.turnId : undefined),
|
|
1019
|
+
)
|
|
1014
1020
|
this.#syncMessages()
|
|
1015
1021
|
// The outcome is a record of its own, just ahead of the one that ends the
|
|
1016
1022
|
// turn, never a field of the settlement.
|
|
@@ -1039,6 +1045,27 @@ export class TurnRecorder {
|
|
|
1039
1045
|
return entry
|
|
1040
1046
|
}
|
|
1041
1047
|
|
|
1048
|
+
/**
|
|
1049
|
+
* A `request_envelope` whose system prompt is the one `turn_started` already
|
|
1050
|
+
* holds records a pointer instead of the text, since the same prompt twice
|
|
1051
|
+
* per turn was a fifth of a long log. The request joins its system messages
|
|
1052
|
+
* with a blank line where the turn prompt joins its static and dynamic parts
|
|
1053
|
+
* with a rule, so the two are compared with that one separator swapped. A
|
|
1054
|
+
* request whose prompt differs (a step rewrote it) keeps its own text. The
|
|
1055
|
+
* live event is untouched; only the record is smaller.
|
|
1056
|
+
*/
|
|
1057
|
+
#withoutRepeatedPrompt(
|
|
1058
|
+
event: SessionEvent,
|
|
1059
|
+
draft: Parameters<SessionLog['append']>[1],
|
|
1060
|
+
): Parameters<SessionLog['append']>[1] {
|
|
1061
|
+
if (event.type !== 'request_envelope' || this.#turnSystemPrompt === undefined) return draft
|
|
1062
|
+
if (!requestPromptMatchesTurn(event.systemPrompt, this.#turnSystemPrompt)) return draft
|
|
1063
|
+
const { systemPrompt: _systemPrompt, ...rest } = draft as unknown as Record<string, unknown>
|
|
1064
|
+
return { ...rest, systemPromptFrom: 'turn_started' } as unknown as Parameters<
|
|
1065
|
+
SessionLog['append']
|
|
1066
|
+
>[1]
|
|
1067
|
+
}
|
|
1068
|
+
|
|
1042
1069
|
/** The turn is active and its closing record is not yet queued. */
|
|
1043
1070
|
#turnOpen(): boolean {
|
|
1044
1071
|
return this.#phase === 'active' && !this.#ending
|
|
@@ -1571,6 +1598,15 @@ export function snapshotTurnConfig(config: TurnRecorderConfig['turnConfig']): Tu
|
|
|
1571
1598
|
}
|
|
1572
1599
|
}
|
|
1573
1600
|
|
|
1601
|
+
/**
|
|
1602
|
+
* Whether a request's joined system messages are the turn's prompt, up to its one separator.
|
|
1603
|
+
* "Same" means same up to that swap: a reader rebuilds the request text from `turn_started`
|
|
1604
|
+
* with the rule, not the blank line, so the pointer does not say which join the request used.
|
|
1605
|
+
*/
|
|
1606
|
+
export function requestPromptMatchesTurn(requestPrompt: string, turnPrompt: string): boolean {
|
|
1607
|
+
return requestPrompt === turnPrompt || requestPrompt === turnPrompt.replace('\n\n---\n\n', '\n\n')
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1574
1610
|
/** A live event as a record draft: the payload minus the live-only fields. */
|
|
1575
1611
|
export function eventDraft(
|
|
1576
1612
|
event: SessionEvent,
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The audit log of the Namzu network: one JSON object per line, append-only,
|
|
3
|
+
* mode 0600, rotated once at 1 MiB. It records what happened and between whom,
|
|
4
|
+
* never what was said: a message is represented by a hash prefix and a size,
|
|
5
|
+
* and no key, token or certificate ever reaches a line.
|
|
6
|
+
*
|
|
7
|
+
* Writes go through an injected sink, so a host (or a test) decides where they
|
|
8
|
+
* land; a failing sink is reported once and then ignored. It must never stop
|
|
9
|
+
* the network.
|
|
10
|
+
*
|
|
11
|
+
* @experimental
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { createHash } from 'node:crypto'
|
|
15
|
+
import { appendFile, mkdir, rename, stat } from 'node:fs/promises'
|
|
16
|
+
import { dirname, join } from 'node:path'
|
|
17
|
+
|
|
18
|
+
export const AUDIT_EVENTS = [
|
|
19
|
+
'join_requested',
|
|
20
|
+
'join_allowed',
|
|
21
|
+
'join_denied',
|
|
22
|
+
'join_expired',
|
|
23
|
+
'admitted',
|
|
24
|
+
'network_trusted',
|
|
25
|
+
'network_untrusted',
|
|
26
|
+
'removed',
|
|
27
|
+
'role_set',
|
|
28
|
+
'role_refused',
|
|
29
|
+
'mail_accepted',
|
|
30
|
+
'mail_held',
|
|
31
|
+
'mail_allowed',
|
|
32
|
+
'mail_denied',
|
|
33
|
+
'mail_refused',
|
|
34
|
+
'mail_expired',
|
|
35
|
+
'network_on',
|
|
36
|
+
'network_off',
|
|
37
|
+
'machine_renamed',
|
|
38
|
+
'connection_refused',
|
|
39
|
+
] as const
|
|
40
|
+
export type AuditEventName = (typeof AUDIT_EVENTS)[number]
|
|
41
|
+
|
|
42
|
+
export interface AuditEntry {
|
|
43
|
+
readonly at: number
|
|
44
|
+
readonly event: AuditEventName
|
|
45
|
+
readonly machine?: { readonly id12: string; readonly name?: string }
|
|
46
|
+
readonly session?: string
|
|
47
|
+
/** `in`: another machine did it to this one; `out`: this machine did it to another. Absent for local events. */
|
|
48
|
+
readonly direction?: 'in' | 'out'
|
|
49
|
+
readonly decision?: string
|
|
50
|
+
readonly reason?: string
|
|
51
|
+
readonly bytes?: number
|
|
52
|
+
readonly textHash?: string
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface AuditSink {
|
|
56
|
+
append(entry: AuditEntry): Promise<void>
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** First 16 hex of sha256 of the text: enough to match two records, useless to recover the words. */
|
|
60
|
+
export function textHash(text: string): string {
|
|
61
|
+
return createHash('sha256').update(text, 'utf8').digest('hex').slice(0, 16)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const AUDIT_ROTATE_BYTES = 1024 * 1024
|
|
65
|
+
|
|
66
|
+
export interface FileAuditSinkOptions {
|
|
67
|
+
readonly dir: string
|
|
68
|
+
readonly rotateBytes?: number
|
|
69
|
+
/** Called once, with a plain sentence, when a write fails. */
|
|
70
|
+
readonly report?: (message: string) => void
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export const AUDIT_FILE = 'audit.jsonl'
|
|
74
|
+
export const AUDIT_BACKUP_FILE = 'audit.1.jsonl'
|
|
75
|
+
|
|
76
|
+
export function createFileAuditSink(options: FileAuditSinkOptions): AuditSink {
|
|
77
|
+
const file = join(options.dir, AUDIT_FILE)
|
|
78
|
+
const limit = options.rotateBytes ?? AUDIT_ROTATE_BYTES
|
|
79
|
+
let reported = false
|
|
80
|
+
let queue: Promise<void> = Promise.resolve()
|
|
81
|
+
const write = async (entry: AuditEntry): Promise<void> => {
|
|
82
|
+
try {
|
|
83
|
+
await mkdir(dirname(file), { recursive: true, mode: 0o700 })
|
|
84
|
+
const size = await stat(file)
|
|
85
|
+
.then((s) => s.size)
|
|
86
|
+
.catch(() => 0)
|
|
87
|
+
if (size >= limit) await rename(file, join(options.dir, AUDIT_BACKUP_FILE))
|
|
88
|
+
await appendFile(file, `${JSON.stringify(entry)}\n`, { mode: 0o600 })
|
|
89
|
+
} catch {
|
|
90
|
+
if (!reported) {
|
|
91
|
+
reported = true
|
|
92
|
+
options.report?.('The Namzu network audit log could not be written.')
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
append(entry) {
|
|
98
|
+
queue = queue.then(() => write(entry))
|
|
99
|
+
return queue
|
|
100
|
+
},
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** A sink that keeps entries in memory. */
|
|
105
|
+
export function createMemoryAuditSink(): AuditSink & { readonly entries: AuditEntry[] } {
|
|
106
|
+
const entries: AuditEntry[] = []
|
|
107
|
+
return {
|
|
108
|
+
entries,
|
|
109
|
+
async append(entry) {
|
|
110
|
+
entries.push(entry)
|
|
111
|
+
},
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The clock and timer the network code runs on. Every timer, deadline, bucket
|
|
3
|
+
* and expiry in this module reads these two functions so that a test (or a host
|
|
4
|
+
* with its own scheduler) can drive time deterministically instead of waiting.
|
|
5
|
+
*
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface NetworkClock {
|
|
10
|
+
now(): number
|
|
11
|
+
/** Run `fn` once after `ms`; returns a function that cancels it. */
|
|
12
|
+
setTimer(fn: () => void, ms: number): () => void
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const systemClock: NetworkClock = {
|
|
16
|
+
now: () => Date.now(),
|
|
17
|
+
setTimer(fn, ms) {
|
|
18
|
+
const handle = setTimeout(fn, ms)
|
|
19
|
+
handle.unref?.()
|
|
20
|
+
return () => clearTimeout(handle)
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ManualClock extends NetworkClock {
|
|
25
|
+
/** Move time forward and run every timer that became due, in order. */
|
|
26
|
+
advance(ms: number): void
|
|
27
|
+
readonly pending: number
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** A clock that moves only when told to. For tests and for hosts that schedule themselves. */
|
|
31
|
+
export function createManualClock(start = 1_700_000_000_000): ManualClock {
|
|
32
|
+
let current = start
|
|
33
|
+
let nextId = 0
|
|
34
|
+
const timers = new Map<number, { at: number; fn: () => void }>()
|
|
35
|
+
return {
|
|
36
|
+
now: () => current,
|
|
37
|
+
setTimer(fn, ms) {
|
|
38
|
+
const id = nextId++
|
|
39
|
+
timers.set(id, { at: current + ms, fn })
|
|
40
|
+
return () => {
|
|
41
|
+
timers.delete(id)
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
advance(ms) {
|
|
45
|
+
const target = current + ms
|
|
46
|
+
for (;;) {
|
|
47
|
+
let due: [number, { at: number; fn: () => void }] | undefined
|
|
48
|
+
for (const entry of timers) {
|
|
49
|
+
if (entry[1].at <= target && (!due || entry[1].at < due[1].at)) due = entry
|
|
50
|
+
}
|
|
51
|
+
if (!due) break
|
|
52
|
+
timers.delete(due[0])
|
|
53
|
+
current = Math.max(current, due[1].at)
|
|
54
|
+
due[1].fn()
|
|
55
|
+
}
|
|
56
|
+
current = target
|
|
57
|
+
},
|
|
58
|
+
get pending() {
|
|
59
|
+
return timers.size
|
|
60
|
+
},
|
|
61
|
+
}
|
|
62
|
+
}
|