@namzu/sdk 68.0.1 → 69.1.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 +96 -0
- package/dist/agents/QueryAgent.d.ts.map +1 -1
- package/dist/agents/QueryAgent.js +2 -0
- package/dist/agents/QueryAgent.js.map +1 -1
- package/dist/authorization/skill-grant.d.ts.map +1 -1
- package/dist/authorization/skill-grant.js +1 -0
- package/dist/authorization/skill-grant.js.map +1 -1
- package/dist/bridge/acp/permission.d.ts +10 -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 +12 -0
- package/dist/bridge/acp/server.d.ts.map +1 -1
- package/dist/bridge/acp/server.js +21 -0
- package/dist/bridge/acp/server.js.map +1 -1
- package/dist/compaction/context-window.d.ts +8 -0
- package/dist/compaction/context-window.d.ts.map +1 -1
- package/dist/compaction/context-window.js +14 -0
- package/dist/compaction/context-window.js.map +1 -1
- package/dist/compaction/loaded-skills.d.ts +10 -0
- package/dist/compaction/loaded-skills.d.ts.map +1 -1
- package/dist/compaction/loaded-skills.js +45 -1
- package/dist/compaction/loaded-skills.js.map +1 -1
- package/dist/compaction/manager.d.ts +8 -0
- package/dist/compaction/manager.d.ts.map +1 -1
- package/dist/compaction/manager.js +31 -0
- package/dist/compaction/manager.js.map +1 -1
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +7 -1
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/model-summary.js +2 -2
- package/dist/compaction/model-summary.js.map +1 -1
- package/dist/compaction/restore.d.ts +8 -0
- package/dist/compaction/restore.d.ts.map +1 -1
- package/dist/compaction/restore.js +65 -0
- package/dist/compaction/restore.js.map +1 -1
- package/dist/compaction/salience/working-set.d.ts.map +1 -1
- package/dist/compaction/salience/working-set.js +2 -2
- package/dist/compaction/salience/working-set.js.map +1 -1
- package/dist/compaction/tool-result-editing.d.ts +6 -0
- package/dist/compaction/tool-result-editing.d.ts.map +1 -1
- package/dist/compaction/tool-result-editing.js +7 -1
- package/dist/compaction/tool-result-editing.js.map +1 -1
- package/dist/compaction/types.d.ts +2 -0
- package/dist/compaction/types.d.ts.map +1 -1
- package/dist/compaction/wire.d.ts.map +1 -1
- package/dist/compaction/wire.js +4 -0
- package/dist/compaction/wire.js.map +1 -1
- package/dist/connector/index.d.ts +2 -2
- package/dist/connector/index.d.ts.map +1 -1
- package/dist/connector/index.js +1 -1
- package/dist/connector/index.js.map +1 -1
- package/dist/connector/mcp/client.d.ts +29 -0
- package/dist/connector/mcp/client.d.ts.map +1 -1
- package/dist/connector/mcp/client.js +59 -2
- package/dist/connector/mcp/client.js.map +1 -1
- package/dist/connector/mcp/errors.d.ts +7 -0
- package/dist/connector/mcp/errors.d.ts.map +1 -1
- package/dist/connector/mcp/errors.js +14 -0
- package/dist/connector/mcp/errors.js.map +1 -1
- package/dist/connector/mcp/index.d.ts +5 -1
- package/dist/connector/mcp/index.d.ts.map +1 -1
- package/dist/connector/mcp/index.js +3 -1
- package/dist/connector/mcp/index.js.map +1 -1
- package/dist/connector/mcp/skill-source.d.ts +144 -0
- package/dist/connector/mcp/skill-source.d.ts.map +1 -0
- package/dist/connector/mcp/skill-source.js +375 -0
- package/dist/connector/mcp/skill-source.js.map +1 -0
- package/dist/connector/mcp/skills.d.ts +137 -0
- package/dist/connector/mcp/skills.d.ts.map +1 -0
- package/dist/connector/mcp/skills.js +303 -0
- package/dist/connector/mcp/skills.js.map +1 -0
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +23 -1
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/network/audit.d.ts +1 -1
- package/dist/network/audit.d.ts.map +1 -1
- package/dist/network/audit.js +2 -0
- package/dist/network/audit.js.map +1 -1
- package/dist/network/computer.d.ts +107 -0
- package/dist/network/computer.d.ts.map +1 -0
- package/dist/network/computer.js +250 -0
- package/dist/network/computer.js.map +1 -0
- package/dist/network/index.d.ts +2 -0
- package/dist/network/index.d.ts.map +1 -1
- package/dist/network/index.js +1 -0
- package/dist/network/index.js.map +1 -1
- package/dist/network/join.d.ts +13 -1
- package/dist/network/join.d.ts.map +1 -1
- package/dist/network/join.js +21 -3
- package/dist/network/join.js.map +1 -1
- package/dist/network/roster.d.ts +5 -0
- package/dist/network/roster.d.ts.map +1 -1
- package/dist/network/roster.js.map +1 -1
- package/dist/network/service.d.ts +12 -2
- package/dist/network/service.d.ts.map +1 -1
- package/dist/network/service.js +539 -60
- package/dist/network/service.js.map +1 -1
- package/dist/network/store.d.ts +33 -1
- package/dist/network/store.d.ts.map +1 -1
- package/dist/network/store.js +48 -4
- package/dist/network/store.js.map +1 -1
- package/dist/network/transport.d.ts +1 -1
- package/dist/network/transport.js +1 -1
- package/dist/network/wire.d.ts +14 -0
- package/dist/network/wire.d.ts.map +1 -1
- package/dist/network/wire.js +17 -1
- package/dist/network/wire.js.map +1 -1
- package/dist/plugin/shell-hook-tool-names.d.ts.map +1 -1
- package/dist/plugin/shell-hook-tool-names.js +1 -0
- package/dist/plugin/shell-hook-tool-names.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +8 -3
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +132 -7
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +4 -4
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +7 -2
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +9 -0
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/idle-timeout.d.ts.map +1 -1
- package/dist/provider/idle-timeout.js +8 -0
- package/dist/provider/idle-timeout.js.map +1 -1
- package/dist/provider/instrumentation.d.ts.map +1 -1
- package/dist/provider/instrumentation.js +10 -0
- package/dist/provider/instrumentation.js.map +1 -1
- package/dist/provider/model-window-suffix.d.ts.map +1 -1
- package/dist/provider/model-window-suffix.js +2 -0
- package/dist/provider/model-window-suffix.js.map +1 -1
- package/dist/provider/retry.d.ts.map +1 -1
- package/dist/provider/retry.js +8 -0
- package/dist/provider/retry.js.map +1 -1
- package/dist/public-runtime.d.ts +10 -7
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +12 -5
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +7 -4
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +9 -3
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +4 -1
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/tool/presentation.d.ts +8 -1
- package/dist/registry/tool/presentation.d.ts.map +1 -1
- package/dist/registry/tool/presentation.js +14 -5
- package/dist/registry/tool/presentation.js.map +1 -1
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +2 -1
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/classifier.js +19 -3
- package/dist/runtime/query/auto-review/classifier.js.map +1 -1
- package/dist/runtime/query/auto-review/failure.d.ts +12 -0
- package/dist/runtime/query/auto-review/failure.d.ts.map +1 -0
- package/dist/runtime/query/auto-review/failure.js +46 -0
- package/dist/runtime/query/auto-review/failure.js.map +1 -0
- package/dist/runtime/query/auto-review/index.d.ts +1 -0
- package/dist/runtime/query/auto-review/index.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/index.js +1 -0
- package/dist/runtime/query/auto-review/index.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 +10 -1
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +12 -0
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +43 -9
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/file-evidence-replay.d.ts.map +1 -1
- package/dist/runtime/query/file-evidence-replay.js +6 -6
- package/dist/runtime/query/file-evidence-replay.js.map +1 -1
- package/dist/runtime/query/index.d.ts +4 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +40 -1
- 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 +2 -0
- 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 +21 -3
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts +4 -0
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/per-call-review.d.ts +6 -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 +24 -9
- package/dist/runtime/query/iteration/phases/per-call-review.js.map +1 -1
- package/dist/runtime/query/iteration/step-shaping.d.ts.map +1 -1
- package/dist/runtime/query/iteration/step-shaping.js +4 -0
- package/dist/runtime/query/iteration/step-shaping.js.map +1 -1
- package/dist/runtime/query/prepare-turn.d.ts +5 -1
- package/dist/runtime/query/prepare-turn.d.ts.map +1 -1
- package/dist/runtime/query/prepare-turn.js +13 -3
- package/dist/runtime/query/prepare-turn.js.map +1 -1
- package/dist/runtime/query/review-policy.d.ts +15 -4
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +15 -4
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/shell-line-escalation.d.ts +24 -0
- package/dist/runtime/query/shell-line-escalation.d.ts.map +1 -0
- package/dist/runtime/query/shell-line-escalation.js +38 -0
- package/dist/runtime/query/shell-line-escalation.js.map +1 -0
- package/dist/runtime/query/tooling.d.ts +7 -0
- package/dist/runtime/query/tooling.d.ts.map +1 -1
- package/dist/runtime/query/tooling.js +2 -0
- package/dist/runtime/query/tooling.js.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.d.ts +4 -0
- package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.js +47 -1
- package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
- package/dist/sandbox/provider/local.d.ts.map +1 -1
- package/dist/sandbox/provider/local.js +3 -1
- package/dist/sandbox/provider/local.js.map +1 -1
- package/dist/scheduler/local.d.ts.map +1 -1
- package/dist/scheduler/local.js +3 -1
- package/dist/scheduler/local.js.map +1 -1
- package/dist/skills/index.d.ts +4 -0
- package/dist/skills/index.d.ts.map +1 -1
- package/dist/skills/index.js +2 -0
- package/dist/skills/index.js.map +1 -1
- package/dist/skills/inline-shell-host.d.ts +103 -0
- package/dist/skills/inline-shell-host.d.ts.map +1 -0
- package/dist/skills/inline-shell-host.js +238 -0
- package/dist/skills/inline-shell-host.js.map +1 -0
- package/dist/skills/inline-shell.d.ts +176 -0
- package/dist/skills/inline-shell.d.ts.map +1 -0
- package/dist/skills/inline-shell.js +646 -0
- package/dist/skills/inline-shell.js.map +1 -0
- package/dist/store/index.d.ts +2 -0
- package/dist/store/index.d.ts.map +1 -1
- package/dist/store/index.js +1 -0
- package/dist/store/index.js.map +1 -1
- package/dist/store/task/file.d.ts +124 -0
- package/dist/store/task/file.d.ts.map +1 -0
- package/dist/store/task/file.js +498 -0
- package/dist/store/task/file.js.map +1 -0
- package/dist/teams/backend.d.ts +28 -0
- package/dist/teams/backend.d.ts.map +1 -0
- package/dist/teams/backend.js +2 -0
- package/dist/teams/backend.js.map +1 -0
- package/dist/teams/fs-sync.d.ts +19 -0
- package/dist/teams/fs-sync.d.ts.map +1 -0
- package/dist/teams/fs-sync.js +81 -0
- package/dist/teams/fs-sync.js.map +1 -0
- package/dist/teams/index.d.ts +14 -0
- package/dist/teams/index.d.ts.map +1 -0
- package/dist/teams/index.js +11 -0
- package/dist/teams/index.js.map +1 -0
- package/dist/teams/names.d.ts +15 -0
- package/dist/teams/names.d.ts.map +1 -0
- package/dist/teams/names.js +43 -0
- package/dist/teams/names.js.map +1 -0
- package/dist/teams/store.d.ts +133 -0
- package/dist/teams/store.d.ts.map +1 -0
- package/dist/teams/store.js +536 -0
- package/dist/teams/store.js.map +1 -0
- package/dist/teams/types.d.ts +97 -0
- package/dist/teams/types.d.ts.map +1 -0
- package/dist/teams/types.js +70 -0
- package/dist/teams/types.js.map +1 -0
- package/dist/tools/admit-facts.d.ts.map +1 -1
- package/dist/tools/admit-facts.js +28 -0
- package/dist/tools/admit-facts.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +5 -2
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/browser.js +1 -1
- package/dist/tools/builtins/browser.js.map +1 -1
- package/dist/tools/builtins/computer-use.d.ts +60 -2
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +695 -80
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
- package/dist/tools/builtins/content-fingerprint.js +2 -1
- package/dist/tools/builtins/content-fingerprint.js.map +1 -1
- package/dist/tools/builtins/edit-apply.d.ts +1 -0
- package/dist/tools/builtins/edit-apply.d.ts.map +1 -1
- package/dist/tools/builtins/edit-apply.js +108 -21
- package/dist/tools/builtins/edit-apply.js.map +1 -1
- package/dist/tools/builtins/edit-match.d.ts +37 -0
- package/dist/tools/builtins/edit-match.d.ts.map +1 -1
- package/dist/tools/builtins/edit-match.js +193 -0
- package/dist/tools/builtins/edit-match.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +14 -7
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/exit-semantics.d.ts +8 -0
- package/dist/tools/builtins/exit-semantics.d.ts.map +1 -1
- package/dist/tools/builtins/exit-semantics.js +19 -0
- package/dist/tools/builtins/exit-semantics.js.map +1 -1
- package/dist/tools/builtins/index.d.ts +3 -1
- package/dist/tools/builtins/index.d.ts.map +1 -1
- package/dist/tools/builtins/index.js +1 -0
- package/dist/tools/builtins/index.js.map +1 -1
- package/dist/tools/builtins/present-file.d.ts +24 -0
- package/dist/tools/builtins/present-file.d.ts.map +1 -0
- package/dist/tools/builtins/present-file.js +116 -0
- package/dist/tools/builtins/present-file.js.map +1 -0
- package/dist/tools/builtins/read-file.js +1 -1
- package/dist/tools/builtins/read-file.js.map +1 -1
- package/dist/tools/builtins/read-render.d.ts +12 -1
- package/dist/tools/builtins/read-render.d.ts.map +1 -1
- package/dist/tools/builtins/read-render.js +16 -3
- package/dist/tools/builtins/read-render.js.map +1 -1
- package/dist/tools/builtins/search-tools.d.ts +10 -0
- package/dist/tools/builtins/search-tools.d.ts.map +1 -1
- package/dist/tools/builtins/search-tools.js +36 -2
- package/dist/tools/builtins/search-tools.js.map +1 -1
- package/dist/tools/builtins/skill.d.ts +31 -0
- package/dist/tools/builtins/skill.d.ts.map +1 -1
- package/dist/tools/builtins/skill.js +232 -88
- package/dist/tools/builtins/skill.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +5 -0
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/tools/builtins/web.d.ts.map +1 -1
- package/dist/tools/builtins/web.js +13 -2
- package/dist/tools/builtins/web.js.map +1 -1
- package/dist/tools/task/create.d.ts.map +1 -1
- package/dist/tools/task/create.js +13 -4
- package/dist/tools/task/create.js.map +1 -1
- package/dist/tools/task/get.d.ts +8 -0
- package/dist/tools/task/get.d.ts.map +1 -0
- package/dist/tools/task/get.js +51 -0
- package/dist/tools/task/get.js.map +1 -0
- package/dist/tools/task/index.d.ts +7 -0
- package/dist/tools/task/index.d.ts.map +1 -1
- package/dist/tools/task/index.js +10 -2
- package/dist/tools/task/index.js.map +1 -1
- package/dist/tools/task/list.d.ts.map +1 -1
- package/dist/tools/task/list.js +10 -2
- package/dist/tools/task/list.js.map +1 -1
- package/dist/tools/task/number.d.ts +13 -0
- package/dist/tools/task/number.d.ts.map +1 -0
- package/dist/tools/task/number.js +30 -0
- package/dist/tools/task/number.js.map +1 -0
- package/dist/tools/task/present.d.ts.map +1 -1
- package/dist/tools/task/present.js +17 -3
- package/dist/tools/task/present.js.map +1 -1
- package/dist/tools/task/update.d.ts +2 -1
- package/dist/tools/task/update.d.ts.map +1 -1
- package/dist/tools/task/update.js +87 -20
- package/dist/tools/task/update.js.map +1 -1
- package/dist/types/acp/index.d.ts +10 -0
- package/dist/types/acp/index.d.ts.map +1 -1
- package/dist/types/agent/base.d.ts +4 -0
- package/dist/types/agent/base.d.ts.map +1 -1
- package/dist/types/agent/scheduler.d.ts +9 -0
- package/dist/types/agent/scheduler.d.ts.map +1 -1
- package/dist/types/computer-use/index.d.ts +7 -0
- package/dist/types/computer-use/index.d.ts.map +1 -1
- package/dist/types/computer-use/index.js.map +1 -1
- package/dist/types/connector/mcp.d.ts +10 -0
- package/dist/types/connector/mcp.d.ts.map +1 -1
- package/dist/types/permission/index.d.ts +20 -0
- package/dist/types/permission/index.d.ts.map +1 -1
- package/dist/types/permission/index.js +25 -0
- package/dist/types/permission/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +47 -3
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +4 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +8 -0
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/interface.d.ts +16 -0
- package/dist/types/provider/interface.d.ts.map +1 -1
- package/dist/types/provider/model.d.ts +6 -0
- package/dist/types/provider/model.d.ts.map +1 -1
- package/dist/types/provider/stream.d.ts +2 -0
- package/dist/types/provider/stream.d.ts.map +1 -1
- package/dist/types/tool/index.d.ts +28 -2
- 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 +15 -0
- package/dist/types/tool/presentation.d.ts.map +1 -1
- package/dist/utils/node-on-path.d.ts +27 -0
- package/dist/utils/node-on-path.d.ts.map +1 -0
- package/dist/utils/node-on-path.js +70 -0
- package/dist/utils/node-on-path.js.map +1 -0
- package/package.json +1 -1
- package/src/agents/QueryAgent.ts +2 -0
- package/src/authorization/skill-grant.ts +1 -0
- package/src/bridge/acp/permission.ts +11 -1
- package/src/bridge/acp/server.ts +26 -0
- package/src/compaction/context-window.ts +18 -0
- package/src/compaction/loaded-skills.ts +42 -1
- package/src/compaction/manager.ts +28 -0
- package/src/compaction/manual.ts +9 -1
- package/src/compaction/model-summary.ts +2 -2
- package/src/compaction/restore.ts +69 -0
- package/src/compaction/salience/working-set.ts +6 -2
- package/src/compaction/tool-result-editing.ts +8 -1
- package/src/compaction/types.ts +2 -0
- package/src/compaction/wire.ts +4 -0
- package/src/connector/index.ts +27 -0
- package/src/connector/mcp/client.ts +71 -2
- package/src/connector/mcp/errors.ts +14 -0
- package/src/connector/mcp/index.ts +36 -0
- package/src/connector/mcp/skill-source.ts +499 -0
- package/src/connector/mcp/skills.ts +367 -0
- package/src/manager/session/turn-recorder.ts +24 -1
- package/src/network/audit.ts +2 -0
- package/src/network/computer.ts +347 -0
- package/src/network/index.ts +20 -0
- package/src/network/join.ts +21 -2
- package/src/network/roster.ts +5 -0
- package/src/network/service.ts +674 -84
- package/src/network/store.ts +57 -4
- package/src/network/transport.ts +1 -1
- package/src/network/wire.ts +18 -1
- package/src/plugin/shell-hook-tool-names.ts +1 -0
- package/src/plugin/shell-hook.ts +144 -7
- package/src/prompt/coding-agent-doctrine.ts +7 -2
- package/src/provider/fallback.ts +10 -0
- package/src/provider/idle-timeout.ts +9 -0
- package/src/provider/instrumentation.ts +12 -0
- package/src/provider/model-window-suffix.ts +2 -0
- package/src/provider/retry.ts +9 -0
- package/src/public-runtime.ts +100 -0
- package/src/public-tools.ts +18 -0
- package/src/public-types.ts +29 -0
- package/src/registry/tool/presentation.ts +14 -4
- package/src/runtime/jobs/registry.ts +2 -1
- package/src/runtime/query/auto-review/classifier.ts +19 -3
- package/src/runtime/query/auto-review/failure.ts +50 -0
- package/src/runtime/query/auto-review/index.ts +1 -0
- package/src/runtime/query/executor/tool-call-admission.ts +10 -1
- package/src/runtime/query/executor.ts +57 -8
- package/src/runtime/query/file-evidence-replay.ts +6 -5
- package/src/runtime/query/index.ts +62 -0
- package/src/runtime/query/iteration/index.ts +2 -0
- package/src/runtime/query/iteration/phases/compaction.ts +25 -2
- package/src/runtime/query/iteration/phases/context.ts +4 -0
- package/src/runtime/query/iteration/phases/per-call-review.ts +24 -7
- package/src/runtime/query/iteration/step-shaping.ts +4 -0
- package/src/runtime/query/prepare-turn.ts +20 -2
- package/src/runtime/query/review-policy.ts +31 -5
- package/src/runtime/query/shell-line-escalation.ts +49 -0
- package/src/runtime/query/tooling.ts +6 -0
- package/src/runtime/query/turn/outcome-ledger.ts +56 -1
- package/src/sandbox/provider/local.ts +3 -1
- package/src/scheduler/local.ts +3 -1
- package/src/skills/index.ts +43 -0
- package/src/skills/inline-shell-host.ts +303 -0
- package/src/skills/inline-shell.ts +765 -0
- package/src/store/index.ts +8 -0
- package/src/store/task/file.ts +641 -0
- package/src/teams/backend.ts +29 -0
- package/src/teams/fs-sync.ts +91 -0
- package/src/teams/index.ts +47 -0
- package/src/teams/names.ts +49 -0
- package/src/teams/store.ts +607 -0
- package/src/teams/types.ts +102 -0
- package/src/tools/admit-facts.ts +26 -0
- package/src/tools/builtins/bash.ts +5 -2
- package/src/tools/builtins/browser.ts +1 -1
- package/src/tools/builtins/computer-use.ts +799 -86
- package/src/tools/builtins/content-fingerprint.ts +2 -1
- package/src/tools/builtins/edit-apply.ts +124 -24
- package/src/tools/builtins/edit-match.ts +200 -0
- package/src/tools/builtins/edit.ts +16 -7
- package/src/tools/builtins/exit-semantics.ts +23 -0
- package/src/tools/builtins/index.ts +3 -0
- package/src/tools/builtins/present-file.ts +127 -0
- package/src/tools/builtins/read-file.ts +1 -1
- package/src/tools/builtins/read-render.ts +18 -3
- package/src/tools/builtins/search-tools.ts +36 -2
- package/src/tools/builtins/skill.ts +291 -95
- package/src/tools/builtins/wait-for-job.ts +5 -0
- package/src/tools/builtins/web.ts +15 -2
- package/src/tools/task/create.ts +13 -4
- package/src/tools/task/get.ts +53 -0
- package/src/tools/task/index.ts +14 -2
- package/src/tools/task/list.ts +10 -2
- package/src/tools/task/number.ts +32 -0
- package/src/tools/task/present.ts +18 -3
- package/src/tools/task/update.ts +94 -20
- package/src/types/acp/index.ts +11 -1
- package/src/types/agent/base.ts +6 -0
- package/src/types/agent/scheduler.ts +9 -0
- package/src/types/computer-use/index.ts +7 -0
- package/src/types/connector/mcp.ts +10 -0
- package/src/types/permission/index.ts +29 -0
- package/src/types/plugin/index.ts +95 -39
- package/src/types/provider/chat.ts +9 -0
- package/src/types/provider/interface.ts +18 -0
- package/src/types/provider/model.ts +6 -0
- package/src/types/provider/stream.ts +2 -0
- package/src/types/tool/index.ts +23 -2
- package/src/types/tool/presentation.ts +14 -0
- package/src/utils/node-on-path.ts +81 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The computer secret: how two Namzu homes of one person on one computer prove they share a computer.
|
|
3
|
+
*
|
|
4
|
+
* A "machine" on the Namzu network is a key, one per home, so the default home, a scheduler service home,
|
|
5
|
+
* Desktop and a WSL terminal are each another machine. They may join without a person's Allow only when
|
|
6
|
+
* the joiner shows it holds the same secret as the member it reached. That is the whole evidence: a source
|
|
7
|
+
* address, a machine name, a hostname or a flag in the request prove nothing and are never consulted.
|
|
8
|
+
*
|
|
9
|
+
* One 32-byte secret per OS user lives at `<default home>/network/machine-secret` (mode 0600 in a 0700
|
|
10
|
+
* directory). It is never sent: a proof is an HMAC over both ends of the TLS leg and the joiner's nonce.
|
|
11
|
+
*
|
|
12
|
+
* @experimental
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { createHmac, randomBytes, timingSafeEqual } from 'node:crypto'
|
|
16
|
+
import { link, lstat, mkdir, open, readFile, unlink, writeFile } from 'node:fs/promises'
|
|
17
|
+
import { basename, dirname, join, posix, resolve } from 'node:path'
|
|
18
|
+
import { hardenPeerRuntimeDir } from '../peers/dir.js'
|
|
19
|
+
|
|
20
|
+
export const COMPUTER_SECRET_FILE = 'machine-secret'
|
|
21
|
+
/** Beside the native secret on WSL: where the Windows profile's copy was found, so a service without interop finds it too. */
|
|
22
|
+
export const COMPUTER_SECRET_WINDOWS_PATH_FILE = 'machine-secret.windows-path'
|
|
23
|
+
|
|
24
|
+
const SECRET_BYTES = 32
|
|
25
|
+
const SECRET_HEX_LENGTH = SECRET_BYTES * 2
|
|
26
|
+
const KEY_DOMAIN = 'namzu-net/computer/key/1'
|
|
27
|
+
const JOIN_DOMAIN = 'namzu-net/computer/join/1'
|
|
28
|
+
const MEMBER_DOMAIN = 'namzu-net/computer/member/1'
|
|
29
|
+
const FINGERPRINT_DOMAIN = 'namzu-net/computer/fp/1'
|
|
30
|
+
|
|
31
|
+
/** How a secret file is trusted: by inspecting it (POSIX), or by where it lives (a Windows profile seen from WSL). */
|
|
32
|
+
export type ComputerSecretCheck = 'posix' | 'path-only'
|
|
33
|
+
|
|
34
|
+
export interface ComputerSecretSource {
|
|
35
|
+
readonly path: string
|
|
36
|
+
readonly check: ComputerSecretCheck
|
|
37
|
+
/** True when this home may create the file when it is absent. */
|
|
38
|
+
readonly create: boolean
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type ComputerSecretRead =
|
|
42
|
+
| { readonly status: 'ok'; readonly secret: Buffer }
|
|
43
|
+
| { readonly status: 'absent' }
|
|
44
|
+
| { readonly status: 'unsafe'; readonly reason: string }
|
|
45
|
+
|
|
46
|
+
export interface ReadSecretOptions {
|
|
47
|
+
readonly uid?: number | undefined
|
|
48
|
+
/** Tests: pretend to be this platform. */
|
|
49
|
+
readonly platform?: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const currentUid = () => (typeof process.getuid === 'function' ? process.getuid() : undefined)
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Read the secret, refusing anything that could be someone else's or could have been read by someone else:
|
|
56
|
+
* a symbolic link, a file that is not regular, one owned by another user, one readable or writable by
|
|
57
|
+
* group or others, a directory others can write, or a file of the wrong size. A refusal is reported, never
|
|
58
|
+
* repaired, and never replaced (a new secret would split the homes).
|
|
59
|
+
*/
|
|
60
|
+
export async function readComputerSecret(
|
|
61
|
+
source: Pick<ComputerSecretSource, 'path' | 'check'>,
|
|
62
|
+
options: ReadSecretOptions = {},
|
|
63
|
+
): Promise<ComputerSecretRead> {
|
|
64
|
+
let info: Awaited<ReturnType<typeof lstat>>
|
|
65
|
+
try {
|
|
66
|
+
info = await lstat(source.path)
|
|
67
|
+
} catch {
|
|
68
|
+
return { status: 'absent' }
|
|
69
|
+
}
|
|
70
|
+
if (info.isSymbolicLink()) return { status: 'unsafe', reason: 'the secret is a symbolic link' }
|
|
71
|
+
if (!info.isFile()) return { status: 'unsafe', reason: 'the secret is not a regular file' }
|
|
72
|
+
const platform = options.platform ?? process.platform
|
|
73
|
+
if (source.check === 'posix' && platform !== 'win32') {
|
|
74
|
+
const uid = 'uid' in options ? options.uid : currentUid()
|
|
75
|
+
if (uid !== undefined && info.uid !== uid)
|
|
76
|
+
return { status: 'unsafe', reason: 'the secret belongs to another user' }
|
|
77
|
+
if ((info.mode & 0o077) !== 0)
|
|
78
|
+
return {
|
|
79
|
+
status: 'unsafe',
|
|
80
|
+
reason: 'the secret can be read by others (mode is not 0600)',
|
|
81
|
+
}
|
|
82
|
+
let parent: Awaited<ReturnType<typeof lstat>>
|
|
83
|
+
try {
|
|
84
|
+
parent = await lstat(dirname(source.path))
|
|
85
|
+
} catch {
|
|
86
|
+
return {
|
|
87
|
+
status: 'unsafe',
|
|
88
|
+
reason: 'the folder of the secret cannot be read',
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (uid !== undefined && parent.uid !== uid)
|
|
92
|
+
return {
|
|
93
|
+
status: 'unsafe',
|
|
94
|
+
reason: 'the folder of the secret belongs to another user',
|
|
95
|
+
}
|
|
96
|
+
if ((parent.mode & 0o022) !== 0)
|
|
97
|
+
return {
|
|
98
|
+
status: 'unsafe',
|
|
99
|
+
reason: 'the folder of the secret can be written by others',
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
let text: string
|
|
103
|
+
try {
|
|
104
|
+
text = (await readFile(source.path, 'utf8')).trim()
|
|
105
|
+
} catch {
|
|
106
|
+
return { status: 'unsafe', reason: 'the secret cannot be read' }
|
|
107
|
+
}
|
|
108
|
+
if (!/^[0-9a-f]+$/.test(text) || text.length !== SECRET_HEX_LENGTH)
|
|
109
|
+
return { status: 'unsafe', reason: 'the secret is not the expected size' }
|
|
110
|
+
return { status: 'ok', secret: Buffer.from(text, 'hex') }
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Create the secret when no file is there. Two homes starting together race: the file is written whole to a
|
|
115
|
+
* private name and then linked into place, which fails for the loser, who reads the winner's. An existing
|
|
116
|
+
* file (good or bad) is never overwritten.
|
|
117
|
+
*/
|
|
118
|
+
export async function ensureComputerSecret(
|
|
119
|
+
source: ComputerSecretSource,
|
|
120
|
+
harden: (dir: string) => void = (dir) => hardenPeerRuntimeDir(dir, currentUid()),
|
|
121
|
+
): Promise<'created' | 'exists'> {
|
|
122
|
+
if (!source.create) return 'exists'
|
|
123
|
+
try {
|
|
124
|
+
await lstat(source.path)
|
|
125
|
+
return 'exists'
|
|
126
|
+
} catch {
|
|
127
|
+
// absent: create below
|
|
128
|
+
}
|
|
129
|
+
const dir = dirname(source.path)
|
|
130
|
+
harden(dir)
|
|
131
|
+
await mkdir(dir, { recursive: true, mode: 0o700 })
|
|
132
|
+
const staging = join(
|
|
133
|
+
dir,
|
|
134
|
+
`.${COMPUTER_SECRET_FILE}.${process.pid}.${randomBytes(6).toString('hex')}`,
|
|
135
|
+
)
|
|
136
|
+
const body = `${randomBytes(SECRET_BYTES).toString('hex')}\n`
|
|
137
|
+
try {
|
|
138
|
+
const handle = await open(staging, 'wx', 0o600)
|
|
139
|
+
try {
|
|
140
|
+
await handle.writeFile(body)
|
|
141
|
+
} finally {
|
|
142
|
+
await handle.close()
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
await link(staging, source.path)
|
|
146
|
+
return 'created'
|
|
147
|
+
} catch (error) {
|
|
148
|
+
if ((error as NodeJS.ErrnoException).code === 'EEXIST') return 'exists'
|
|
149
|
+
// A filesystem without hard links: create exclusively instead.
|
|
150
|
+
try {
|
|
151
|
+
await writeFile(source.path, body, { flag: 'wx', mode: 0o600 })
|
|
152
|
+
return 'created'
|
|
153
|
+
} catch (inner) {
|
|
154
|
+
if ((inner as NodeJS.ErrnoException).code === 'EEXIST') return 'exists'
|
|
155
|
+
throw inner
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
} finally {
|
|
159
|
+
await unlink(staging).catch(() => undefined)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const computerKey = (secret: Buffer): Buffer =>
|
|
164
|
+
createHmac('sha256', secret).update(KEY_DOMAIN).digest()
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* The proof a joiner attaches to its join request. It names both ends of the TLS leg as each side sees them
|
|
168
|
+
* and the joiner's nonce, so a machine relaying between the two cannot reuse it and a copy of it from
|
|
169
|
+
* another key does not verify.
|
|
170
|
+
*/
|
|
171
|
+
export function computerJoinProof(
|
|
172
|
+
secret: Buffer,
|
|
173
|
+
joinerMachineId: string,
|
|
174
|
+
memberMachineId: string,
|
|
175
|
+
joinerNonce: string,
|
|
176
|
+
): string {
|
|
177
|
+
return createHmac('sha256', computerKey(secret))
|
|
178
|
+
.update(JSON.stringify([JOIN_DOMAIN, joinerMachineId, memberMachineId, joinerNonce]), 'utf8')
|
|
179
|
+
.digest('base64')
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function verifyComputerJoinProof(
|
|
183
|
+
secret: Buffer,
|
|
184
|
+
proof: string,
|
|
185
|
+
joinerMachineId: string,
|
|
186
|
+
memberMachineId: string,
|
|
187
|
+
joinerNonce: string,
|
|
188
|
+
): boolean {
|
|
189
|
+
const expected = Buffer.from(
|
|
190
|
+
computerJoinProof(secret, joinerMachineId, memberMachineId, joinerNonce),
|
|
191
|
+
'utf8',
|
|
192
|
+
)
|
|
193
|
+
const given = Buffer.from(proof, 'utf8')
|
|
194
|
+
return given.length === expected.length && timingSafeEqual(given, expected)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The member's counter-proof in the `admitted` frame, under its own domain string so a join proof can never
|
|
199
|
+
* stand in for it. It names both ends and both nonces: the joiner records "this computer" only when it
|
|
200
|
+
* verifies, so a member that merely claims the flag is not marked.
|
|
201
|
+
*/
|
|
202
|
+
export function computerMemberProof(
|
|
203
|
+
secret: Buffer,
|
|
204
|
+
memberMachineId: string,
|
|
205
|
+
joinerMachineId: string,
|
|
206
|
+
joinerNonce: string,
|
|
207
|
+
memberNonce: string,
|
|
208
|
+
): string {
|
|
209
|
+
return createHmac('sha256', computerKey(secret))
|
|
210
|
+
.update(
|
|
211
|
+
JSON.stringify([MEMBER_DOMAIN, memberMachineId, joinerMachineId, joinerNonce, memberNonce]),
|
|
212
|
+
'utf8',
|
|
213
|
+
)
|
|
214
|
+
.digest('base64')
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export function verifyComputerMemberProof(
|
|
218
|
+
secret: Buffer,
|
|
219
|
+
proof: string,
|
|
220
|
+
memberMachineId: string,
|
|
221
|
+
joinerMachineId: string,
|
|
222
|
+
joinerNonce: string,
|
|
223
|
+
memberNonce: string,
|
|
224
|
+
): boolean {
|
|
225
|
+
const expected = Buffer.from(
|
|
226
|
+
computerMemberProof(secret, memberMachineId, joinerMachineId, joinerNonce, memberNonce),
|
|
227
|
+
'utf8',
|
|
228
|
+
)
|
|
229
|
+
const given = Buffer.from(proof, 'utf8')
|
|
230
|
+
return given.length === expected.length && timingSafeEqual(given, expected)
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** A short public tag of a secret (not reversible), kept beside the remembered machines so a reset secret drops the marks. */
|
|
234
|
+
export function computerSecretFingerprint(secret: Buffer): string {
|
|
235
|
+
return createHmac('sha256', computerKey(secret))
|
|
236
|
+
.update(FINGERPRINT_DOMAIN)
|
|
237
|
+
.digest()
|
|
238
|
+
.subarray(0, 8)
|
|
239
|
+
.toString('hex')
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// ─── which secret a home may use ─────────────────────────────────────────
|
|
243
|
+
|
|
244
|
+
export interface ResolveSecretDeps {
|
|
245
|
+
readonly realpath: (path: string) => Promise<string>
|
|
246
|
+
readonly exists: (path: string) => Promise<boolean>
|
|
247
|
+
readonly readText: (path: string) => Promise<string | undefined>
|
|
248
|
+
readonly writeText: (path: string, text: string) => Promise<void>
|
|
249
|
+
/** Run a program and return its trimmed standard output, or undefined when it cannot run. */
|
|
250
|
+
readonly exec: (command: string, args: readonly string[]) => Promise<string | undefined>
|
|
251
|
+
/**
|
|
252
|
+
* The user id the file system reports as owning a file (undefined when it cannot be read). On WSL a
|
|
253
|
+
* Windows drive is mounted as one Linux user, so this is how a Windows file is tied to a Linux user.
|
|
254
|
+
* Without it the Windows copy is never trusted.
|
|
255
|
+
*/
|
|
256
|
+
readonly fileOwner?: (path: string) => Promise<number | undefined>
|
|
257
|
+
/** The user id of this process (undefined where there is none); the Windows copy is trusted only for the user that owns it. */
|
|
258
|
+
readonly uid?: number | undefined
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export interface ResolveSecretInput {
|
|
262
|
+
/** This home (`NAMZU_HOME` or the default). */
|
|
263
|
+
readonly home: string
|
|
264
|
+
/** The OS user's home directory; the default Namzu home is `<osHome>/.namzu`. */
|
|
265
|
+
readonly osHome: string
|
|
266
|
+
readonly platform: string
|
|
267
|
+
readonly env: NodeJS.ProcessEnv
|
|
268
|
+
readonly deps: ResolveSecretDeps
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/** Where a Windows profile seen from WSL may live: `/mnt/<drive>/Users/<name>`. Anything else is refused. */
|
|
272
|
+
const WINDOWS_PROFILE_FROM_WSL = /^\/mnt\/[a-z]\/Users\/[^/\0]+$/
|
|
273
|
+
|
|
274
|
+
export const windowsProfilePathOk = (path: string): boolean =>
|
|
275
|
+
WINDOWS_PROFILE_FROM_WSL.test(path) && posix.normalize(path) === path
|
|
276
|
+
|
|
277
|
+
/** Whether `home` is the default home or a scheduler service home directly under it. */
|
|
278
|
+
export async function homeQualifies(
|
|
279
|
+
home: string,
|
|
280
|
+
osHome: string,
|
|
281
|
+
realpath: (path: string) => Promise<string>,
|
|
282
|
+
): Promise<boolean> {
|
|
283
|
+
const real = async (p: string) => realpath(p).catch(() => resolve(p))
|
|
284
|
+
const defaultHome = await real(join(osHome, '.namzu'))
|
|
285
|
+
const mine = await real(home)
|
|
286
|
+
if (mine === defaultHome) return true
|
|
287
|
+
const parent = dirname(mine)
|
|
288
|
+
return basename(parent) === 'services' && dirname(parent) === defaultHome && mine !== parent
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const isWsl = (platform: string, env: NodeJS.ProcessEnv) =>
|
|
292
|
+
platform === 'linux' &&
|
|
293
|
+
(typeof env.WSL_DISTRO_NAME === 'string' || typeof env.WSL_INTEROP === 'string')
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Which secret this home uses, or undefined when it uses none (it then asks a person like any other machine).
|
|
297
|
+
*
|
|
298
|
+
* Only the default home and a service home directly under it qualify; any other `NAMZU_HOME` (a scratch or
|
|
299
|
+
* sandboxed home) never joins the person's network by itself. On Windows, Linux and macOS the native copy
|
|
300
|
+
* is the secret. On WSL the Windows profile's copy is the source of truth when it can be read (so Desktop
|
|
301
|
+
* and the WSL terminal agree) and the Linux user that the Windows drive mount maps the file to is the
|
|
302
|
+
* current one, else the native WSL copy in this user's own home; Windows never reaches into WSL, whose distro may
|
|
303
|
+
* not be running.
|
|
304
|
+
*/
|
|
305
|
+
export async function resolveComputerSecret(
|
|
306
|
+
input: ResolveSecretInput,
|
|
307
|
+
): Promise<ComputerSecretSource | undefined> {
|
|
308
|
+
const { home, osHome, platform, env, deps } = input
|
|
309
|
+
if (!(await homeQualifies(home, osHome, deps.realpath))) return undefined
|
|
310
|
+
const nativeDir = join(osHome, '.namzu', 'network')
|
|
311
|
+
const native: ComputerSecretSource = {
|
|
312
|
+
path: join(nativeDir, COMPUTER_SECRET_FILE),
|
|
313
|
+
check: platform === 'win32' ? 'path-only' : 'posix',
|
|
314
|
+
create: true,
|
|
315
|
+
}
|
|
316
|
+
if (!isWsl(platform, env)) return native
|
|
317
|
+
|
|
318
|
+
const cachePath = join(nativeDir, COMPUTER_SECRET_WINDOWS_PATH_FILE)
|
|
319
|
+
let profile: string | undefined
|
|
320
|
+
// With interop the Windows profile of the account running this very process is asked for afresh and
|
|
321
|
+
// wins over the cache, so a stale or planted cache cannot point at another Windows account's folder.
|
|
322
|
+
// The cache serves only a home that has no interop (a service).
|
|
323
|
+
if (typeof env.WSL_INTEROP === 'string') {
|
|
324
|
+
const raw = await deps.exec('cmd.exe', ['/c', 'echo %USERPROFILE%'])
|
|
325
|
+
const win = raw?.replace(/\r/g, '').trim()
|
|
326
|
+
if (win && !win.includes('%')) {
|
|
327
|
+
const unix = (await deps.exec('wslpath', ['-u', win]))?.trim()
|
|
328
|
+
if (unix !== undefined && windowsProfilePathOk(unix)) {
|
|
329
|
+
profile = unix
|
|
330
|
+
await deps.writeText(cachePath, `${unix}\n`).catch(() => undefined)
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
} else {
|
|
334
|
+
const cached = (await deps.readText(cachePath))?.trim()
|
|
335
|
+
if (cached !== undefined && windowsProfilePathOk(cached)) profile = cached
|
|
336
|
+
}
|
|
337
|
+
if (profile === undefined) return native
|
|
338
|
+
const windowsPath = join(profile, '.namzu', 'network', COMPUTER_SECRET_FILE)
|
|
339
|
+
// Only a copy Windows made: from here nothing is ever created in the Windows profile.
|
|
340
|
+
if (!(await deps.exists(windowsPath))) return native
|
|
341
|
+
// A Windows drive is mounted into the distro as one Linux user, so every other Linux user of the
|
|
342
|
+
// distro would reach the same file. Only the user the mount maps the file to may trust it; any
|
|
343
|
+
// other uses the copy in its own home, and a file whose owner cannot be seen is not trusted.
|
|
344
|
+
const owner = await deps.fileOwner?.(windowsPath).catch(() => undefined)
|
|
345
|
+
if (owner === undefined || deps.uid === undefined || owner !== deps.uid) return native
|
|
346
|
+
return { path: windowsPath, check: 'path-only', create: false }
|
|
347
|
+
}
|
package/src/network/index.ts
CHANGED
|
@@ -61,6 +61,26 @@ export type {
|
|
|
61
61
|
export { createNetworkStore } from './store.js'
|
|
62
62
|
export type { NetworkStore, NetworkStoreOptions } from './store.js'
|
|
63
63
|
|
|
64
|
+
export {
|
|
65
|
+
COMPUTER_SECRET_FILE,
|
|
66
|
+
COMPUTER_SECRET_WINDOWS_PATH_FILE,
|
|
67
|
+
computerJoinProof,
|
|
68
|
+
ensureComputerSecret,
|
|
69
|
+
homeQualifies,
|
|
70
|
+
readComputerSecret,
|
|
71
|
+
resolveComputerSecret,
|
|
72
|
+
verifyComputerJoinProof,
|
|
73
|
+
windowsProfilePathOk,
|
|
74
|
+
} from './computer.js'
|
|
75
|
+
export type {
|
|
76
|
+
ComputerSecretCheck,
|
|
77
|
+
ComputerSecretRead,
|
|
78
|
+
ComputerSecretSource,
|
|
79
|
+
ReadSecretOptions,
|
|
80
|
+
ResolveSecretDeps,
|
|
81
|
+
ResolveSecretInput,
|
|
82
|
+
} from './computer.js'
|
|
83
|
+
|
|
64
84
|
export { formatJoinCode, joinCode } from './join.js'
|
|
65
85
|
export type { PendingJoin } from './join.js'
|
|
66
86
|
|
package/src/network/join.ts
CHANGED
|
@@ -39,7 +39,13 @@ export function formatJoinCode(code: string): string {
|
|
|
39
39
|
|
|
40
40
|
export const JOIN_EXPIRY_MS = 10 * 60 * 1000
|
|
41
41
|
export const MAX_PENDING_JOINS = 8
|
|
42
|
+
/** A request whose connection is gone is kept this long for another terminal of the machine to take over. */
|
|
43
|
+
export const JOIN_ORPHAN_MS = 60 * 1000
|
|
42
44
|
export const JOIN_ADDRESS_WINDOW_MS = 60 * 1000
|
|
45
|
+
/** After a person denied the ask, this machine does not ask that network again on its own for this long. */
|
|
46
|
+
export const JOIN_BACKOFF_DENIED_MS = 60 * 60 * 1000
|
|
47
|
+
/** After the ask expired unanswered or was refused: shorter, because nobody said no. */
|
|
48
|
+
export const JOIN_BACKOFF_OTHER_MS = 10 * 60 * 1000
|
|
43
49
|
|
|
44
50
|
export interface PendingJoin {
|
|
45
51
|
readonly requestId: string
|
|
@@ -71,16 +77,24 @@ export class JoinTable {
|
|
|
71
77
|
private readonly lastByAddress = new Map<string, number>()
|
|
72
78
|
constructor(private readonly options: JoinTableOptions) {}
|
|
73
79
|
|
|
80
|
+
/** Whether this address asked less than a minute ago. */
|
|
81
|
+
tooSoon(sourceAddr: string): boolean {
|
|
82
|
+
const last = this.lastByAddress.get(sourceAddr)
|
|
83
|
+
return last !== undefined && this.options.clock.now() - last < JOIN_ADDRESS_WINDOW_MS
|
|
84
|
+
}
|
|
85
|
+
|
|
74
86
|
/** A request that arrived on this machine. Refused when the address asked too recently or the table is full. */
|
|
75
87
|
addLocal(
|
|
76
88
|
input: Omit<PendingJoin, 'local' | 'expiresAt' | 'createdAt'>,
|
|
89
|
+
/** A joiner that proved it holds this computer's secret does not meet the per-address limit. */
|
|
90
|
+
exemptFromRate = false,
|
|
77
91
|
): { ok: true; entry: PendingJoin } | { ok: false; reason: 'rate' | 'full' } {
|
|
78
92
|
const now = this.options.clock.now()
|
|
79
93
|
const last = this.lastByAddress.get(input.sourceAddr)
|
|
80
|
-
if (last !== undefined && now - last < JOIN_ADDRESS_WINDOW_MS)
|
|
94
|
+
if (!exemptFromRate && last !== undefined && now - last < JOIN_ADDRESS_WINDOW_MS)
|
|
81
95
|
return { ok: false, reason: 'rate' }
|
|
82
96
|
if (this.localCount() >= MAX_PENDING_JOINS) return { ok: false, reason: 'full' }
|
|
83
|
-
this.lastByAddress.set(input.sourceAddr, now)
|
|
97
|
+
if (!exemptFromRate) this.lastByAddress.set(input.sourceAddr, now)
|
|
84
98
|
return {
|
|
85
99
|
ok: true,
|
|
86
100
|
entry: this.insert({
|
|
@@ -121,6 +135,11 @@ export class JoinTable {
|
|
|
121
135
|
return n
|
|
122
136
|
}
|
|
123
137
|
|
|
138
|
+
/** The request waiting from this machine, if any: a machine has at most one. */
|
|
139
|
+
findByJoiner(joinerMachineId: string): PendingJoin | undefined {
|
|
140
|
+
return this.list().find((e) => e.joinerMachineId === joinerMachineId)
|
|
141
|
+
}
|
|
142
|
+
|
|
124
143
|
get(requestId: string): PendingJoin | undefined {
|
|
125
144
|
return this.entries.get(requestId)
|
|
126
145
|
}
|
package/src/network/roster.ts
CHANGED
|
@@ -79,6 +79,11 @@ export interface RosterMachineView {
|
|
|
79
79
|
/** Epoch ms of the last answer; absent for this machine. */
|
|
80
80
|
readonly seenAt?: number
|
|
81
81
|
readonly role?: string
|
|
82
|
+
/**
|
|
83
|
+
* True when this machine is another home of the same person on this computer: it joined, or let this one
|
|
84
|
+
* in, by proving the computer secret, and the secret still reads. A live fact, not part of any signed record.
|
|
85
|
+
*/
|
|
86
|
+
readonly sameComputer?: boolean
|
|
82
87
|
readonly sessions: readonly RosterSession[]
|
|
83
88
|
}
|
|
84
89
|
|