@namzu/sdk 65.2.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 +161 -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 +98 -8
- 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/browser/index.d.ts +12 -0
- package/dist/types/browser/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/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 +121 -8
- 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/browser/index.ts +9 -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/index.ts +1 -0
- package/src/types/provider/interface.ts +13 -0
- package/src/types/provider/limits.ts +35 -0
- package/src/types/tool/index.ts +30 -2
- package/src/types/tool/presentation.ts +4 -0
- package/src/utils/file-lock.ts +328 -0
- package/src/utils/state-backup.ts +318 -0
- package/src/utils/temp-sweep.ts +327 -0
- package/src/utils/temp.ts +73 -2
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which local network is this machine on? A fingerprint of the subnet an
|
|
3
|
+
* address belongs to plus the hardware address of that subnet's default
|
|
4
|
+
* gateway, hashed. It answers "is this the same Wi-Fi or wire as last time"
|
|
5
|
+
* well enough to remember that the person trusts it, and nothing more: it is
|
|
6
|
+
* not a secret and not proof of anything.
|
|
7
|
+
*
|
|
8
|
+
* The gateway's hardware address is read without privileges and without
|
|
9
|
+
* sending a packet of our own where the system keeps it already:
|
|
10
|
+
* - Linux: `/proc/net/route` for the default route, `/proc/net/arp` for the
|
|
11
|
+
* neighbour table.
|
|
12
|
+
* - macOS: `route -n get default`, then `arp -n <gateway>`.
|
|
13
|
+
* - Windows: `Get-NetRoute` and `Get-NetNeighbor` through PowerShell.
|
|
14
|
+
* None of them needs administrator rights. When the gateway or its hardware
|
|
15
|
+
* address cannot be read, the network is UNKNOWN: it has no fingerprint, so it
|
|
16
|
+
* is never trusted automatically. WSL2 in NAT mode sees only the Windows
|
|
17
|
+
* host's virtual adapter as its gateway, so every WSL2 machine fingerprints
|
|
18
|
+
* its own private network; mirrored networking removes that.
|
|
19
|
+
*
|
|
20
|
+
* Every reader is injected, so tests feed fixtures and never run a command.
|
|
21
|
+
*
|
|
22
|
+
* @experimental
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { createHash } from 'node:crypto'
|
|
26
|
+
import type { NetworkInterfaceInfo } from 'node:os'
|
|
27
|
+
import type { NetworkClock } from './clock.js'
|
|
28
|
+
|
|
29
|
+
export interface Gateway {
|
|
30
|
+
readonly ip: string
|
|
31
|
+
/** Lowercase `aa:bb:cc:dd:ee:ff`. */
|
|
32
|
+
readonly mac: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type GatewayReader = () => Promise<Gateway | undefined>
|
|
36
|
+
|
|
37
|
+
export type CommandRunner = (
|
|
38
|
+
command: string,
|
|
39
|
+
args: readonly string[],
|
|
40
|
+
) => Promise<string | undefined>
|
|
41
|
+
|
|
42
|
+
const MAC = /^[0-9a-f]{2}(:[0-9a-f]{2}){5}$/
|
|
43
|
+
|
|
44
|
+
/** A hardware address worth hashing: six octets, not all zero, not broadcast. */
|
|
45
|
+
function usableMac(text: string): string | undefined {
|
|
46
|
+
const mac = text.trim().toLowerCase().replace(/-/g, ':')
|
|
47
|
+
if (!MAC.test(mac)) return undefined
|
|
48
|
+
if (mac === '00:00:00:00:00:00' || mac === 'ff:ff:ff:ff:ff:ff') return undefined
|
|
49
|
+
return mac
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** `0101A8C0` (little-endian hex as `/proc/net/route` writes it) to `192.168.1.1`. */
|
|
53
|
+
function hexToIPv4(hex: string): string | undefined {
|
|
54
|
+
if (!/^[0-9A-Fa-f]{8}$/.test(hex)) return undefined
|
|
55
|
+
const n = Number.parseInt(hex, 16)
|
|
56
|
+
return [n & 0xff, (n >>> 8) & 0xff, (n >>> 16) & 0xff, (n >>> 24) & 0xff].join('.')
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** The default route of `/proc/net/route`: the gateway of the up route to 0.0.0.0/0 with the lowest metric. */
|
|
60
|
+
export function parseLinuxDefaultRoute(
|
|
61
|
+
text: string,
|
|
62
|
+
): { readonly ip: string; readonly iface: string } | undefined {
|
|
63
|
+
let best: { ip: string; iface: string; metric: number } | undefined
|
|
64
|
+
for (const line of text.split('\n').slice(1)) {
|
|
65
|
+
const cols = line.trim().split(/\s+/)
|
|
66
|
+
if (cols.length < 8) continue
|
|
67
|
+
const [iface, destination, gateway, flags, , , metric, mask] = cols as string[]
|
|
68
|
+
if (destination !== '00000000' || mask !== '00000000') continue
|
|
69
|
+
const f = Number.parseInt(flags ?? '0', 16)
|
|
70
|
+
// RTF_UP (1) and RTF_GATEWAY (2)
|
|
71
|
+
if ((f & 3) !== 3) continue
|
|
72
|
+
const ip = hexToIPv4(gateway ?? '')
|
|
73
|
+
if (!ip || ip === '0.0.0.0') continue
|
|
74
|
+
const m = Number(metric)
|
|
75
|
+
if (!best || m < best.metric) best = { ip, iface: iface ?? '', metric: m }
|
|
76
|
+
}
|
|
77
|
+
return best ? { ip: best.ip, iface: best.iface } : undefined
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The hardware address of `ip` in `/proc/net/arp`; an entry that is not complete (flags 0x0) does not count. */
|
|
81
|
+
export function parseLinuxArp(text: string, ip: string): string | undefined {
|
|
82
|
+
for (const line of text.split('\n').slice(1)) {
|
|
83
|
+
const cols = line.trim().split(/\s+/)
|
|
84
|
+
if (cols.length < 6 || cols[0] !== ip) continue
|
|
85
|
+
if (Number.parseInt(cols[2] ?? '0', 16) === 0) continue
|
|
86
|
+
return usableMac(cols[3] ?? '')
|
|
87
|
+
}
|
|
88
|
+
return undefined
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** `route -n get default` on macOS: the `gateway:` line. */
|
|
92
|
+
export function parseMacDefaultRoute(text: string): string | undefined {
|
|
93
|
+
const match = /^\s*gateway:\s*(\d{1,3}(?:\.\d{1,3}){3})\s*$/m.exec(text)
|
|
94
|
+
return match?.[1]
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** `arp -n 192.168.1.1` on macOS: `? (192.168.1.1) at aa:bb:... on en0 ifscope [ethernet]`. Macs drop leading zeros. */
|
|
98
|
+
export function parseMacArp(text: string, ip: string): string | undefined {
|
|
99
|
+
const match = /\(([\d.]+)\) at ([0-9a-f]{1,2}(?::[0-9a-f]{1,2}){5})/i.exec(text)
|
|
100
|
+
if (!match || match[1] !== ip) return undefined
|
|
101
|
+
return usableMac(
|
|
102
|
+
(match[2] as string)
|
|
103
|
+
.split(':')
|
|
104
|
+
.map((o) => o.padStart(2, '0'))
|
|
105
|
+
.join(':'),
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** PowerShell output of the one-line script below: `192.168.1.1 AA-BB-CC-DD-EE-FF`. */
|
|
110
|
+
export const WINDOWS_GATEWAY_SCRIPT =
|
|
111
|
+
'$r = Get-NetRoute -DestinationPrefix \'0.0.0.0/0\' | Sort-Object RouteMetric | Select-Object -First 1; if ($r) { $n = Get-NetNeighbor -IPAddress $r.NextHop -ErrorAction SilentlyContinue | Where-Object { $_.LinkLayerAddress } | Select-Object -First 1; if ($n) { "$($r.NextHop) $($n.LinkLayerAddress)" } }'
|
|
112
|
+
|
|
113
|
+
export function parseWindowsGateway(text: string): Gateway | undefined {
|
|
114
|
+
const match =
|
|
115
|
+
/^\s*(\d{1,3}(?:\.\d{1,3}){3})\s+([0-9A-Fa-f]{2}(?:[-:][0-9A-Fa-f]{2}){5})\s*$/m.exec(text)
|
|
116
|
+
if (!match) return undefined
|
|
117
|
+
const mac = usableMac(match[2] as string)
|
|
118
|
+
return mac ? { ip: match[1] as string, mac } : undefined
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface SystemGatewayOptions {
|
|
122
|
+
readonly platform?: NodeJS.Platform
|
|
123
|
+
/** Read a small text file; undefined when it cannot be read. */
|
|
124
|
+
readonly readText: (path: string) => Promise<string | undefined>
|
|
125
|
+
/** Run a command with no shell and a short timeout; undefined when it fails. */
|
|
126
|
+
readonly run: CommandRunner
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** The reader for this machine's system. Nothing here needs administrator rights. */
|
|
130
|
+
export function createSystemGatewayReader(options: SystemGatewayOptions): GatewayReader {
|
|
131
|
+
const platform = options.platform ?? process.platform
|
|
132
|
+
return async () => {
|
|
133
|
+
if (platform === 'linux') {
|
|
134
|
+
const route = await options.readText('/proc/net/route')
|
|
135
|
+
const found = route ? parseLinuxDefaultRoute(route) : undefined
|
|
136
|
+
if (!found) return undefined
|
|
137
|
+
const arp = await options.readText('/proc/net/arp')
|
|
138
|
+
const mac = arp ? parseLinuxArp(arp, found.ip) : undefined
|
|
139
|
+
return mac ? { ip: found.ip, mac } : undefined
|
|
140
|
+
}
|
|
141
|
+
if (platform === 'darwin') {
|
|
142
|
+
const route = await options.run('route', ['-n', 'get', 'default'])
|
|
143
|
+
const ip = route ? parseMacDefaultRoute(route) : undefined
|
|
144
|
+
if (!ip) return undefined
|
|
145
|
+
const arp = await options.run('arp', ['-n', ip])
|
|
146
|
+
const mac = arp ? parseMacArp(arp, ip) : undefined
|
|
147
|
+
return mac ? { ip, mac } : undefined
|
|
148
|
+
}
|
|
149
|
+
if (platform === 'win32') {
|
|
150
|
+
const out = await options.run('powershell.exe', [
|
|
151
|
+
'-NoProfile',
|
|
152
|
+
'-NonInteractive',
|
|
153
|
+
'-Command',
|
|
154
|
+
WINDOWS_GATEWAY_SCRIPT,
|
|
155
|
+
])
|
|
156
|
+
return out ? parseWindowsGateway(out) : undefined
|
|
157
|
+
}
|
|
158
|
+
return undefined
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function ipv4ToInt(address: string): number | undefined {
|
|
163
|
+
const parts = address.split('.')
|
|
164
|
+
if (parts.length !== 4) return undefined
|
|
165
|
+
let n = 0
|
|
166
|
+
for (const p of parts) {
|
|
167
|
+
if (!/^\d{1,3}$/.test(p) || Number(p) > 255) return undefined
|
|
168
|
+
n = n * 256 + Number(p)
|
|
169
|
+
}
|
|
170
|
+
return n
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function prefixLength(netmask: string): number | undefined {
|
|
174
|
+
const n = ipv4ToInt(netmask)
|
|
175
|
+
if (n === undefined) return undefined
|
|
176
|
+
let bits = 0
|
|
177
|
+
for (let i = 31; i >= 0 && (n >>> i) & 1; i--) bits++
|
|
178
|
+
return bits
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** The IPv4 subnet (`192.168.1.0/24`) of the interface address that contains `address`, if any. */
|
|
182
|
+
export function subnetOf(
|
|
183
|
+
address: string,
|
|
184
|
+
interfaces: NodeJS.Dict<NetworkInterfaceInfo[]>,
|
|
185
|
+
): string | undefined {
|
|
186
|
+
const target = ipv4ToInt(address)
|
|
187
|
+
if (target === undefined) return undefined
|
|
188
|
+
for (const list of Object.values(interfaces)) {
|
|
189
|
+
for (const info of list ?? []) {
|
|
190
|
+
if (info.family !== 'IPv4') continue
|
|
191
|
+
const bits = prefixLength(info.netmask)
|
|
192
|
+
const base = ipv4ToInt(info.address)
|
|
193
|
+
if (bits === undefined || base === undefined || bits === 0) continue
|
|
194
|
+
const mask = bits === 32 ? 0xffffffff : (~0 << (32 - bits)) >>> 0
|
|
195
|
+
if ((target & mask) >>> 0 === (base & mask) >>> 0)
|
|
196
|
+
return `${[24, 16, 8, 0].map((s) => ((base & mask) >>> s) & 0xff).join('.')}/${bits}`
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return undefined
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** The network id: 16 hex of sha256 over the subnet and the gateway's hardware address. */
|
|
203
|
+
export function networkFingerprint(subnet: string, gatewayMac: string): string {
|
|
204
|
+
return createHash('sha256')
|
|
205
|
+
.update(`namzu-net/lan/1\n${subnet}\n${gatewayMac}`)
|
|
206
|
+
.digest('hex')
|
|
207
|
+
.slice(0, 16)
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export interface NetworkIdentityOptions {
|
|
211
|
+
readonly interfaces: () => NodeJS.Dict<NetworkInterfaceInfo[]>
|
|
212
|
+
readonly gateway: GatewayReader
|
|
213
|
+
readonly clock: NetworkClock
|
|
214
|
+
/** How long a read of the gateway is reused. */
|
|
215
|
+
readonly cacheMs?: number
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* `identify(address)`: the fingerprint of the network `address` is on, or undefined when this machine is not
|
|
220
|
+
* on that subnet, the gateway cannot be read, or the gateway is not on that subnet (so it is not that network's
|
|
221
|
+
* gateway). Unknown means never trusted.
|
|
222
|
+
*/
|
|
223
|
+
export function createNetworkIdentity(
|
|
224
|
+
options: NetworkIdentityOptions,
|
|
225
|
+
): (address: string) => Promise<string | undefined> {
|
|
226
|
+
const cacheMs = options.cacheMs ?? 30_000
|
|
227
|
+
let cached: { at: number; gateway: Gateway | undefined } | undefined
|
|
228
|
+
return async (address) => {
|
|
229
|
+
const interfaces = options.interfaces()
|
|
230
|
+
const subnet = subnetOf(address, interfaces)
|
|
231
|
+
if (!subnet) return undefined
|
|
232
|
+
const now = options.clock.now()
|
|
233
|
+
if (!cached || now - cached.at >= cacheMs) {
|
|
234
|
+
cached = { at: now, gateway: await options.gateway().catch(() => undefined) }
|
|
235
|
+
}
|
|
236
|
+
const gateway = cached.gateway
|
|
237
|
+
if (!gateway) return undefined
|
|
238
|
+
if (subnetOf(gateway.ip, interfaces) !== subnet) return undefined
|
|
239
|
+
return networkFingerprint(subnet, gateway.mac)
|
|
240
|
+
}
|
|
241
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Machine identity: one Ed25519 key pair per machine, and the small helpers
|
|
3
|
+
* every other module of the Namzu network uses to name and sign with it.
|
|
4
|
+
*
|
|
5
|
+
* Nothing here implements a cryptographic primitive; it is `node:crypto`
|
|
6
|
+
* (`generateKeyPairSync`, `sign`, `verify`, `createHash`) with fixed
|
|
7
|
+
* encodings so that two machines always compute the same id from the same key.
|
|
8
|
+
*
|
|
9
|
+
* - `machineId`: lowercase hex sha256 of the public key's SPKI DER (64 hex).
|
|
10
|
+
* - `netId`: the first 16 hex of the same digest over the FOUNDER's key. It is
|
|
11
|
+
* not secret and not a name.
|
|
12
|
+
*
|
|
13
|
+
* @experimental
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
type KeyObject,
|
|
18
|
+
createHash,
|
|
19
|
+
createPrivateKey,
|
|
20
|
+
createPublicKey,
|
|
21
|
+
generateKeyPairSync,
|
|
22
|
+
sign,
|
|
23
|
+
verify,
|
|
24
|
+
} from 'node:crypto'
|
|
25
|
+
|
|
26
|
+
export interface MachineKey {
|
|
27
|
+
readonly privateKey: KeyObject
|
|
28
|
+
readonly publicKey: KeyObject
|
|
29
|
+
/** SPKI DER of the public key. */
|
|
30
|
+
readonly publicKeyDer: Buffer
|
|
31
|
+
readonly machineId: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const NET_ID_LENGTH = 16
|
|
35
|
+
|
|
36
|
+
export function sha256Hex(data: Buffer | string): string {
|
|
37
|
+
return createHash('sha256').update(data).digest('hex')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The id of a machine, from the SPKI DER of its public key. */
|
|
41
|
+
export function machineIdOf(publicKeyDer: Buffer): string {
|
|
42
|
+
return sha256Hex(publicKeyDer)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The id of a network, from the SPKI DER of its founder's public key. */
|
|
46
|
+
export function netIdOf(founderPublicKeyDer: Buffer): string {
|
|
47
|
+
return sha256Hex(founderPublicKeyDer).slice(0, NET_ID_LENGTH)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Short form of a machine id for a screen. */
|
|
51
|
+
export function shortMachineId(machineId: string): string {
|
|
52
|
+
return machineId.slice(0, 12)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function fromPrivateKey(privateKey: KeyObject): MachineKey {
|
|
56
|
+
const publicKey = createPublicKey(privateKey)
|
|
57
|
+
const publicKeyDer = publicKey.export({ type: 'spki', format: 'der' })
|
|
58
|
+
return {
|
|
59
|
+
privateKey,
|
|
60
|
+
publicKey,
|
|
61
|
+
publicKeyDer,
|
|
62
|
+
machineId: machineIdOf(publicKeyDer),
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function generateMachineKey(): MachineKey {
|
|
67
|
+
return fromPrivateKey(generateKeyPairSync('ed25519').privateKey)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** PKCS#8 PEM of the private key. The only place a private key is serialised; callers write it 0600 and never log it. */
|
|
71
|
+
export function exportMachineKeyPem(key: MachineKey): string {
|
|
72
|
+
return key.privateKey.export({ type: 'pkcs8', format: 'pem' }).toString()
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function importMachineKeyPem(pem: string): MachineKey {
|
|
76
|
+
const privateKey = createPrivateKey(pem)
|
|
77
|
+
if (privateKey.asymmetricKeyType !== 'ed25519') {
|
|
78
|
+
throw new Error('The machine key is not an Ed25519 key.')
|
|
79
|
+
}
|
|
80
|
+
return fromPrivateKey(privateKey)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function publicKeyFromDer(der: Buffer): KeyObject {
|
|
84
|
+
return createPublicKey({ key: der, type: 'spki', format: 'der' })
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function signBytes(key: MachineKey, data: Buffer): Buffer {
|
|
88
|
+
return sign(null, data, key.privateKey)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** False for any malformed key or signature rather than throwing. */
|
|
92
|
+
export function verifyBytes(publicKeyDer: Buffer, data: Buffer, signature: Buffer): boolean {
|
|
93
|
+
try {
|
|
94
|
+
return verify(null, data, publicKeyFromDer(publicKeyDer), signature)
|
|
95
|
+
} catch {
|
|
96
|
+
return false
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Your Namzu network: machines of one person find each other on the local
|
|
3
|
+
* network, show one roster of sessions, pass roles and messages, and keep the
|
|
4
|
+
* safety rules of local messaging across machines.
|
|
5
|
+
*
|
|
6
|
+
* Host-neutral. A host supplies a {@link NetworkHost} and a discovery; the
|
|
7
|
+
* terminal does so today and the desktop can later.
|
|
8
|
+
*
|
|
9
|
+
* @experimental
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export { createManualClock, systemClock } from './clock.js'
|
|
13
|
+
export type { ManualClock, NetworkClock } from './clock.js'
|
|
14
|
+
|
|
15
|
+
export {
|
|
16
|
+
createDiscoveryHub,
|
|
17
|
+
createFakeDiscovery,
|
|
18
|
+
isPrivateNetworkAddress,
|
|
19
|
+
privateInterfaces,
|
|
20
|
+
} from './discovery.js'
|
|
21
|
+
export type {
|
|
22
|
+
Advertisement,
|
|
23
|
+
DiscoveredEndpoint,
|
|
24
|
+
DiscoveryHub,
|
|
25
|
+
FakeDiscovery,
|
|
26
|
+
ListenAddress,
|
|
27
|
+
NetworkDiscovery,
|
|
28
|
+
PrivateInterfaceOptions,
|
|
29
|
+
} from './discovery.js'
|
|
30
|
+
|
|
31
|
+
export { MDNS_GROUP, MDNS_PORT, SERVICE_NAME, createMdnsDiscovery } from './discovery-mdns.js'
|
|
32
|
+
export type { DgramLike, DgramSocketLike, MdnsOptions } from './discovery-mdns.js'
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
AUDIT_EVENTS,
|
|
36
|
+
createFileAuditSink,
|
|
37
|
+
createMemoryAuditSink,
|
|
38
|
+
textHash,
|
|
39
|
+
} from './audit.js'
|
|
40
|
+
export type { AuditEntry, AuditEventName, AuditSink, FileAuditSinkOptions } from './audit.js'
|
|
41
|
+
|
|
42
|
+
export {
|
|
43
|
+
createNetworkIdentity,
|
|
44
|
+
createSystemGatewayReader,
|
|
45
|
+
networkFingerprint,
|
|
46
|
+
parseLinuxArp,
|
|
47
|
+
parseLinuxDefaultRoute,
|
|
48
|
+
parseMacArp,
|
|
49
|
+
parseMacDefaultRoute,
|
|
50
|
+
parseWindowsGateway,
|
|
51
|
+
subnetOf,
|
|
52
|
+
} from './fingerprint.js'
|
|
53
|
+
export type {
|
|
54
|
+
CommandRunner,
|
|
55
|
+
Gateway,
|
|
56
|
+
GatewayReader,
|
|
57
|
+
NetworkIdentityOptions,
|
|
58
|
+
SystemGatewayOptions,
|
|
59
|
+
} from './fingerprint.js'
|
|
60
|
+
|
|
61
|
+
export { createNetworkStore } from './store.js'
|
|
62
|
+
export type { NetworkStore, NetworkStoreOptions } from './store.js'
|
|
63
|
+
|
|
64
|
+
export { formatJoinCode, joinCode } from './join.js'
|
|
65
|
+
export type { PendingJoin } from './join.js'
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
HOLD_EXPIRY_MS,
|
|
69
|
+
HoldQueue,
|
|
70
|
+
MAX_HELD_PER_TERMINAL,
|
|
71
|
+
SlidingCounter,
|
|
72
|
+
decideMail,
|
|
73
|
+
} from './mail-policy.js'
|
|
74
|
+
export type {
|
|
75
|
+
HeldEntry,
|
|
76
|
+
HoldQueueOptions,
|
|
77
|
+
MailDecision,
|
|
78
|
+
MailDecisionInput,
|
|
79
|
+
MailSetting,
|
|
80
|
+
} from './mail-policy.js'
|
|
81
|
+
|
|
82
|
+
export { generateMachineKey } from './identity.js'
|
|
83
|
+
export type { MachineKey } from './identity.js'
|
|
84
|
+
|
|
85
|
+
export { createFounding, evaluateMembership, mergeMembership } from './membership.js'
|
|
86
|
+
export type { Admission, MembershipState, MembershipView, Revocation } from './membership.js'
|
|
87
|
+
|
|
88
|
+
export {
|
|
89
|
+
generateSessionName,
|
|
90
|
+
machineLabel,
|
|
91
|
+
resolveSessionTarget,
|
|
92
|
+
sessionDisplayName,
|
|
93
|
+
sessionLabel,
|
|
94
|
+
} from './roster.js'
|
|
95
|
+
export type {
|
|
96
|
+
LocalSession,
|
|
97
|
+
RosterMachineView,
|
|
98
|
+
RosterView,
|
|
99
|
+
TargetResolution,
|
|
100
|
+
} from './roster.js'
|
|
101
|
+
|
|
102
|
+
export {
|
|
103
|
+
BROWSE_WINDOW_MS,
|
|
104
|
+
FRESH_NETWORK_MS,
|
|
105
|
+
DEFAULT_LISTEN_PORT,
|
|
106
|
+
createNamzuNetwork,
|
|
107
|
+
parseHostPort,
|
|
108
|
+
} from './service.js'
|
|
109
|
+
export type {
|
|
110
|
+
HeldMail,
|
|
111
|
+
AutoAdmitSetting,
|
|
112
|
+
NetworkEvent,
|
|
113
|
+
NetworkRef,
|
|
114
|
+
TrustedNetwork,
|
|
115
|
+
NetworkHost,
|
|
116
|
+
NetworkService,
|
|
117
|
+
NetworkServiceOptions,
|
|
118
|
+
NetworkState,
|
|
119
|
+
NetworkStatus,
|
|
120
|
+
RemoteMail,
|
|
121
|
+
} from './service.js'
|
|
122
|
+
|
|
123
|
+
export { NetworkError } from './transport.js'
|
|
124
|
+
export type { NetworkErrorCode } from './transport.js'
|
|
125
|
+
|
|
126
|
+
export {
|
|
127
|
+
MAX_NET_LINE_BYTES,
|
|
128
|
+
MAX_PREAUTH_LINE_BYTES,
|
|
129
|
+
MAX_ROLE_BYTES,
|
|
130
|
+
NET_PROTOCOL,
|
|
131
|
+
sanitizeName,
|
|
132
|
+
sanitizeRole,
|
|
133
|
+
} from './wire.js'
|
|
134
|
+
export type { HostPort, RosterSession } from './wire.js'
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The join handshake's two small pieces: the short code both screens show,
|
|
3
|
+
* and the table of pending requests.
|
|
4
|
+
*
|
|
5
|
+
* The code is bound to the channel: it is computed from the two certificates'
|
|
6
|
+
* machine ids as each side saw them plus both nonces. A machine relaying
|
|
7
|
+
* between the joiner and a member presents different certificates on each leg,
|
|
8
|
+
* so the two screens differ. Skipping the glance is allowed; it is the
|
|
9
|
+
* documented residual risk.
|
|
10
|
+
*
|
|
11
|
+
* @experimental
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { createHash } from 'node:crypto'
|
|
15
|
+
import type { NetworkClock } from './clock.js'
|
|
16
|
+
|
|
17
|
+
const CODE_DOMAIN = 'namzu-net/join/1'
|
|
18
|
+
|
|
19
|
+
/** Six digits from the channel facts. Same inputs, same code; any swapped fingerprint, a different one. */
|
|
20
|
+
export function joinCode(
|
|
21
|
+
joinerMachineId: string,
|
|
22
|
+
memberMachineId: string,
|
|
23
|
+
joinerNonce: string,
|
|
24
|
+
memberNonce: string,
|
|
25
|
+
): string {
|
|
26
|
+
const digest = createHash('sha256')
|
|
27
|
+
.update(
|
|
28
|
+
JSON.stringify([CODE_DOMAIN, joinerMachineId, memberMachineId, joinerNonce, memberNonce]),
|
|
29
|
+
'utf8',
|
|
30
|
+
)
|
|
31
|
+
.digest()
|
|
32
|
+
return String(digest.readUInt32BE(0) % 1_000_000).padStart(6, '0')
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** `482913` as `482 913`. */
|
|
36
|
+
export function formatJoinCode(code: string): string {
|
|
37
|
+
return `${code.slice(0, 3)} ${code.slice(3)}`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const JOIN_EXPIRY_MS = 10 * 60 * 1000
|
|
41
|
+
export const MAX_PENDING_JOINS = 8
|
|
42
|
+
export const JOIN_ADDRESS_WINDOW_MS = 60 * 1000
|
|
43
|
+
|
|
44
|
+
export interface PendingJoin {
|
|
45
|
+
readonly requestId: string
|
|
46
|
+
readonly name: string
|
|
47
|
+
readonly code: string
|
|
48
|
+
readonly sourceAddr: string
|
|
49
|
+
readonly createdAt: number
|
|
50
|
+
readonly expiresAt: number
|
|
51
|
+
/** The member the joiner is connected to. */
|
|
52
|
+
readonly viaMachineId: string
|
|
53
|
+
/** True on the member the joiner reached; only there is the joiner's connection held. */
|
|
54
|
+
readonly local: boolean
|
|
55
|
+
readonly joinerMachineId?: string
|
|
56
|
+
readonly joinerPublicKey?: string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type JoinDecisionOutcome = 'ok' | 'already' | 'unknown'
|
|
60
|
+
|
|
61
|
+
const MAX_DECIDED = 512
|
|
62
|
+
|
|
63
|
+
export interface JoinTableOptions {
|
|
64
|
+
readonly clock: NetworkClock
|
|
65
|
+
readonly onExpire: (entry: PendingJoin) => void
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export class JoinTable {
|
|
69
|
+
private readonly entries = new Map<string, PendingJoin & { cancel: () => void }>()
|
|
70
|
+
private readonly decided = new Map<string, 'allow' | 'deny' | 'expired'>()
|
|
71
|
+
private readonly lastByAddress = new Map<string, number>()
|
|
72
|
+
constructor(private readonly options: JoinTableOptions) {}
|
|
73
|
+
|
|
74
|
+
/** A request that arrived on this machine. Refused when the address asked too recently or the table is full. */
|
|
75
|
+
addLocal(
|
|
76
|
+
input: Omit<PendingJoin, 'local' | 'expiresAt' | 'createdAt'>,
|
|
77
|
+
): { ok: true; entry: PendingJoin } | { ok: false; reason: 'rate' | 'full' } {
|
|
78
|
+
const now = this.options.clock.now()
|
|
79
|
+
const last = this.lastByAddress.get(input.sourceAddr)
|
|
80
|
+
if (last !== undefined && now - last < JOIN_ADDRESS_WINDOW_MS)
|
|
81
|
+
return { ok: false, reason: 'rate' }
|
|
82
|
+
if (this.localCount() >= MAX_PENDING_JOINS) return { ok: false, reason: 'full' }
|
|
83
|
+
this.lastByAddress.set(input.sourceAddr, now)
|
|
84
|
+
return {
|
|
85
|
+
ok: true,
|
|
86
|
+
entry: this.insert({
|
|
87
|
+
...input,
|
|
88
|
+
local: true,
|
|
89
|
+
createdAt: now,
|
|
90
|
+
expiresAt: now + JOIN_EXPIRY_MS,
|
|
91
|
+
}),
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** A request another member told us about. */
|
|
96
|
+
addRemote(input: Omit<PendingJoin, 'local' | 'expiresAt'>): PendingJoin | undefined {
|
|
97
|
+
if (this.entries.has(input.requestId) || this.decided.has(input.requestId)) return undefined
|
|
98
|
+
if (this.entries.size >= MAX_PENDING_JOINS * 2) return undefined
|
|
99
|
+
const now = this.options.clock.now()
|
|
100
|
+
// A request is as old as it says only up to now: a member cannot make one outlive its ten minutes.
|
|
101
|
+
const createdAt = Math.min(input.createdAt, now)
|
|
102
|
+
const expiresAt = createdAt + JOIN_EXPIRY_MS
|
|
103
|
+
if (expiresAt <= now) return undefined
|
|
104
|
+
return this.insert({ ...input, createdAt, local: false, expiresAt }, expiresAt - now)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private insert(entry: PendingJoin, ttl = JOIN_EXPIRY_MS): PendingJoin {
|
|
108
|
+
const cancel = this.options.clock.setTimer(() => {
|
|
109
|
+
if (this.entries.delete(entry.requestId)) {
|
|
110
|
+
this.remember(entry.requestId, 'expired')
|
|
111
|
+
this.options.onExpire(entry)
|
|
112
|
+
}
|
|
113
|
+
}, ttl)
|
|
114
|
+
this.entries.set(entry.requestId, { ...entry, cancel })
|
|
115
|
+
return entry
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private localCount(): number {
|
|
119
|
+
let n = 0
|
|
120
|
+
for (const e of this.entries.values()) if (e.local) n++
|
|
121
|
+
return n
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
get(requestId: string): PendingJoin | undefined {
|
|
125
|
+
return this.entries.get(requestId)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** Find by request id, code (with or without the space) or the joiner's name. */
|
|
129
|
+
find(query: string): PendingJoin | undefined {
|
|
130
|
+
const q = query.trim()
|
|
131
|
+
const digits = q.replace(/\s+/g, '')
|
|
132
|
+
const all = this.list()
|
|
133
|
+
// A name is only an address while it is unique: two requests with one name (a stranger copying
|
|
134
|
+
// the real one) are told apart by their codes, never by whichever came first.
|
|
135
|
+
const byName = all.filter((e) => e.name.toLowerCase() === q.toLowerCase())
|
|
136
|
+
return (
|
|
137
|
+
all.find((e) => e.requestId === q) ??
|
|
138
|
+
all.find((e) => /^\d{6}$/.test(digits) && e.code === digits) ??
|
|
139
|
+
(byName.length === 1 ? byName[0] : undefined)
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
list(): readonly PendingJoin[] {
|
|
144
|
+
return [...this.entries.values()].map(({ cancel: _cancel, ...rest }) => rest)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** The first decision wins; a later one is `already`. */
|
|
148
|
+
decide(requestId: string, decision: 'allow' | 'deny'): JoinDecisionOutcome {
|
|
149
|
+
const entry = this.entries.get(requestId)
|
|
150
|
+
if (!entry) return this.decided.has(requestId) ? 'already' : 'unknown'
|
|
151
|
+
entry.cancel()
|
|
152
|
+
this.entries.delete(requestId)
|
|
153
|
+
this.remember(requestId, decision)
|
|
154
|
+
return 'ok'
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** Record a decision made elsewhere (a gossiped `join_decision`). */
|
|
158
|
+
settle(requestId: string, decision: 'allow' | 'deny'): void {
|
|
159
|
+
const entry = this.entries.get(requestId)
|
|
160
|
+
if (entry) {
|
|
161
|
+
entry.cancel()
|
|
162
|
+
this.entries.delete(requestId)
|
|
163
|
+
}
|
|
164
|
+
this.remember(requestId, decision)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
private remember(requestId: string, decision: 'allow' | 'deny' | 'expired'): void {
|
|
168
|
+
this.decided.set(requestId, decision)
|
|
169
|
+
if (this.decided.size > MAX_DECIDED)
|
|
170
|
+
this.decided.delete(this.decided.keys().next().value as string)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
clear(): void {
|
|
174
|
+
for (const e of this.entries.values()) e.cancel()
|
|
175
|
+
this.entries.clear()
|
|
176
|
+
}
|
|
177
|
+
}
|