@namzu/sdk 65.3.0 → 68.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +167 -0
- package/dist/account/lock.d.ts +4 -12
- package/dist/account/lock.d.ts.map +1 -1
- package/dist/account/lock.js +5 -140
- package/dist/account/lock.js.map +1 -1
- package/dist/account/registry.d.ts.map +1 -1
- package/dist/account/registry.js +50 -6
- package/dist/account/registry.js.map +1 -1
- package/dist/account/types.d.ts +7 -5
- package/dist/account/types.d.ts.map +1 -1
- package/dist/account/types.js +6 -7
- package/dist/account/types.js.map +1 -1
- package/dist/authorization/dangerous-commands.d.ts +64 -0
- package/dist/authorization/dangerous-commands.d.ts.map +1 -0
- package/dist/authorization/dangerous-commands.js +479 -0
- package/dist/authorization/dangerous-commands.js.map +1 -0
- package/dist/authorization/gate.d.ts.map +1 -1
- package/dist/authorization/gate.js +19 -5
- package/dist/authorization/gate.js.map +1 -1
- package/dist/authorization/protected-paths.d.ts +11 -6
- package/dist/authorization/protected-paths.d.ts.map +1 -1
- package/dist/authorization/protected-paths.js +13 -8
- package/dist/authorization/protected-paths.js.map +1 -1
- package/dist/authorization/readonly-commands.d.ts +6 -1
- package/dist/authorization/readonly-commands.d.ts.map +1 -1
- package/dist/authorization/readonly-commands.js +35 -1
- package/dist/authorization/readonly-commands.js.map +1 -1
- package/dist/authorization/removal.d.ts +10 -0
- package/dist/authorization/removal.d.ts.map +1 -1
- package/dist/authorization/removal.js +7 -7
- package/dist/authorization/removal.js.map +1 -1
- package/dist/authorization/rules.d.ts +10 -0
- package/dist/authorization/rules.d.ts.map +1 -1
- package/dist/authorization/rules.js +60 -14
- package/dist/authorization/rules.js.map +1 -1
- package/dist/authorization/shell-lexer.d.ts +10 -0
- package/dist/authorization/shell-lexer.d.ts.map +1 -1
- package/dist/authorization/shell-lexer.js +15 -0
- package/dist/authorization/shell-lexer.js.map +1 -1
- package/dist/bridge/acp/permission.d.ts +5 -0
- package/dist/bridge/acp/permission.d.ts.map +1 -1
- package/dist/bridge/acp/permission.js.map +1 -1
- package/dist/bridge/acp/server.d.ts +8 -1
- package/dist/bridge/acp/server.d.ts.map +1 -1
- package/dist/bridge/acp/server.js +48 -6
- package/dist/bridge/acp/server.js.map +1 -1
- package/dist/compaction/context-breakdown.d.ts +25 -6
- package/dist/compaction/context-breakdown.d.ts.map +1 -1
- package/dist/compaction/context-breakdown.js +27 -7
- package/dist/compaction/context-breakdown.js.map +1 -1
- package/dist/compaction/dangling.d.ts.map +1 -1
- package/dist/compaction/dangling.js +2 -0
- package/dist/compaction/dangling.js.map +1 -1
- package/dist/compaction/extractor.d.ts +7 -1
- package/dist/compaction/extractor.d.ts.map +1 -1
- package/dist/compaction/extractor.js +8 -1
- package/dist/compaction/extractor.js.map +1 -1
- package/dist/compaction/index.d.ts +1 -1
- package/dist/compaction/index.d.ts.map +1 -1
- package/dist/compaction/index.js +1 -1
- package/dist/compaction/index.js.map +1 -1
- package/dist/compaction/managers/structured.js +2 -2
- package/dist/compaction/managers/structured.js.map +1 -1
- package/dist/compaction/manual.d.ts.map +1 -1
- package/dist/compaction/manual.js +11 -6
- package/dist/compaction/manual.js.map +1 -1
- package/dist/compaction/model-summary.d.ts.map +1 -1
- package/dist/compaction/model-summary.js +7 -1
- package/dist/compaction/model-summary.js.map +1 -1
- package/dist/compaction/summary.d.ts +13 -2
- package/dist/compaction/summary.d.ts.map +1 -1
- package/dist/compaction/summary.js +46 -3
- package/dist/compaction/summary.js.map +1 -1
- package/dist/constants/tools/index.d.ts +18 -1
- package/dist/constants/tools/index.d.ts.map +1 -1
- package/dist/constants/tools/index.js +28 -16
- package/dist/constants/tools/index.js.map +1 -1
- package/dist/manager/session/turn-recorder.d.ts +6 -0
- package/dist/manager/session/turn-recorder.d.ts.map +1 -1
- package/dist/manager/session/turn-recorder.js +29 -1
- package/dist/manager/session/turn-recorder.js.map +1 -1
- package/dist/network/audit.d.ts +49 -0
- package/dist/network/audit.d.ts.map +1 -0
- package/dist/network/audit.js +84 -0
- package/dist/network/audit.js.map +1 -0
- package/dist/network/clock.d.ts +21 -0
- package/dist/network/clock.d.ts.map +1 -0
- package/dist/network/clock.js +51 -0
- package/dist/network/clock.js.map +1 -0
- package/dist/network/discovery-mdns.d.ts +120 -0
- package/dist/network/discovery-mdns.d.ts.map +1 -0
- package/dist/network/discovery-mdns.js +442 -0
- package/dist/network/discovery-mdns.js.map +1 -0
- package/dist/network/discovery.d.ts +63 -0
- package/dist/network/discovery.d.ts.map +1 -0
- package/dist/network/discovery.js +163 -0
- package/dist/network/discovery.js.map +1 -0
- package/dist/network/fingerprint.d.ts +73 -0
- package/dist/network/fingerprint.d.ts.map +1 -0
- package/dist/network/fingerprint.js +208 -0
- package/dist/network/fingerprint.js.map +1 -0
- package/dist/network/identity.d.ts +38 -0
- package/dist/network/identity.d.ts.map +1 -0
- package/dist/network/identity.js +71 -0
- package/dist/network/identity.js.map +1 -0
- package/dist/network/index.d.ts +39 -0
- package/dist/network/index.d.ts.map +1 -0
- package/dist/network/index.js +25 -0
- package/dist/network/index.js.map +1 -0
- package/dist/network/join.d.ts +69 -0
- package/dist/network/join.d.ts.map +1 -0
- package/dist/network/join.js +136 -0
- package/dist/network/join.js.map +1 -0
- package/dist/network/mail-policy.d.ts +97 -0
- package/dist/network/mail-policy.d.ts.map +1 -0
- package/dist/network/mail-policy.js +147 -0
- package/dist/network/mail-policy.js.map +1 -0
- package/dist/network/membership.d.ts +76 -0
- package/dist/network/membership.d.ts.map +1 -0
- package/dist/network/membership.js +225 -0
- package/dist/network/membership.js.map +1 -0
- package/dist/network/roster.d.ts +59 -0
- package/dist/network/roster.d.ts.map +1 -0
- package/dist/network/roster.js +120 -0
- package/dist/network/roster.js.map +1 -0
- package/dist/network/service.d.ts +303 -0
- package/dist/network/service.d.ts.map +1 -0
- package/dist/network/service.js +1891 -0
- package/dist/network/service.js.map +1 -0
- package/dist/network/store.d.ts +141 -0
- package/dist/network/store.d.ts.map +1 -0
- package/dist/network/store.js +198 -0
- package/dist/network/store.js.map +1 -0
- package/dist/network/transport.d.ts +96 -0
- package/dist/network/transport.d.ts.map +1 -0
- package/dist/network/transport.js +342 -0
- package/dist/network/transport.js.map +1 -0
- package/dist/network/wire.d.ts +345 -0
- package/dist/network/wire.d.ts.map +1 -0
- package/dist/network/wire.js +212 -0
- package/dist/network/wire.js.map +1 -0
- package/dist/network/x509.d.ts +28 -0
- package/dist/network/x509.d.ts.map +1 -0
- package/dist/network/x509.js +84 -0
- package/dist/network/x509.js.map +1 -0
- package/dist/pals/activity/causality.d.ts.map +1 -1
- package/dist/pals/activity/causality.js +14 -2
- package/dist/pals/activity/causality.js.map +1 -1
- package/dist/peers/endpoint.d.ts.map +1 -1
- package/dist/peers/endpoint.js +6 -0
- package/dist/peers/endpoint.js.map +1 -1
- package/dist/peers/envelope.d.ts +18 -0
- package/dist/peers/envelope.d.ts.map +1 -1
- package/dist/peers/envelope.js +68 -5
- package/dist/peers/envelope.js.map +1 -1
- package/dist/peers/index.d.ts +5 -4
- package/dist/peers/index.d.ts.map +1 -1
- package/dist/peers/index.js +3 -2
- package/dist/peers/index.js.map +1 -1
- package/dist/peers/mode-word.d.ts +10 -0
- package/dist/peers/mode-word.d.ts.map +1 -0
- package/dist/peers/mode-word.js +19 -0
- package/dist/peers/mode-word.js.map +1 -0
- package/dist/peers/protocol.d.ts +42 -0
- package/dist/peers/protocol.d.ts.map +1 -1
- package/dist/peers/protocol.js +22 -1
- package/dist/peers/protocol.js.map +1 -1
- package/dist/peers/record.d.ts +8 -0
- package/dist/peers/record.d.ts.map +1 -1
- package/dist/peers/record.js +5 -0
- package/dist/peers/record.js.map +1 -1
- package/dist/plugin/session-hook-env.d.ts.map +1 -1
- package/dist/plugin/session-hook-env.js +22 -2
- package/dist/plugin/session-hook-env.js.map +1 -1
- package/dist/plugin/shell-hook.d.ts +16 -2
- package/dist/plugin/shell-hook.d.ts.map +1 -1
- package/dist/plugin/shell-hook.js +183 -14
- package/dist/plugin/shell-hook.js.map +1 -1
- package/dist/pricing/catalogue.generated.d.ts.map +1 -1
- package/dist/pricing/catalogue.generated.js +6 -0
- package/dist/pricing/catalogue.generated.js.map +1 -1
- package/dist/prompt/coding-agent-doctrine.d.ts +4 -2
- package/dist/prompt/coding-agent-doctrine.d.ts.map +1 -1
- package/dist/prompt/coding-agent-doctrine.js +33 -38
- package/dist/prompt/coding-agent-doctrine.js.map +1 -1
- package/dist/provider/fallback.d.ts.map +1 -1
- package/dist/provider/fallback.js +12 -0
- package/dist/provider/fallback.js.map +1 -1
- package/dist/provider/idle-timeout.d.ts.map +1 -1
- package/dist/provider/idle-timeout.js +5 -0
- package/dist/provider/idle-timeout.js.map +1 -1
- package/dist/provider/model-window-suffix.d.ts.map +1 -1
- package/dist/provider/model-window-suffix.js +1 -0
- package/dist/provider/model-window-suffix.js.map +1 -1
- package/dist/provider/retry.d.ts.map +1 -1
- package/dist/provider/retry.js +5 -0
- package/dist/provider/retry.js.map +1 -1
- package/dist/public-runtime.d.ts +16 -8
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-runtime.js +24 -7
- package/dist/public-runtime.js.map +1 -1
- package/dist/public-tools.d.ts +3 -2
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +2 -2
- package/dist/public-tools.js.map +1 -1
- package/dist/public-types.d.ts +10 -5
- package/dist/public-types.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.d.ts +11 -1
- package/dist/registry/command/kernel-commands.d.ts.map +1 -1
- package/dist/registry/command/kernel-commands.js +114 -46
- package/dist/registry/command/kernel-commands.js.map +1 -1
- package/dist/runtime/jobs/registry.d.ts +29 -1
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +64 -0
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/query/auto-review/classifier.d.ts +30 -6
- package/dist/runtime/query/auto-review/classifier.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/classifier.js +40 -12
- package/dist/runtime/query/auto-review/classifier.js.map +1 -1
- package/dist/runtime/query/auto-review/feedback.d.ts +37 -0
- package/dist/runtime/query/auto-review/feedback.d.ts.map +1 -0
- package/dist/runtime/query/auto-review/feedback.js +45 -0
- package/dist/runtime/query/auto-review/feedback.js.map +1 -0
- package/dist/runtime/query/auto-review/git-status.d.ts +59 -0
- package/dist/runtime/query/auto-review/git-status.d.ts.map +1 -0
- package/dist/runtime/query/auto-review/git-status.js +379 -0
- package/dist/runtime/query/auto-review/git-status.js.map +1 -0
- package/dist/runtime/query/auto-review/index.d.ts +3 -3
- package/dist/runtime/query/auto-review/index.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/index.js +2 -2
- package/dist/runtime/query/auto-review/index.js.map +1 -1
- package/dist/runtime/query/auto-review/prompt.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/prompt.js +6 -1
- package/dist/runtime/query/auto-review/prompt.js.map +1 -1
- package/dist/runtime/query/auto-review/transcript.d.ts +14 -1
- package/dist/runtime/query/auto-review/transcript.d.ts.map +1 -1
- package/dist/runtime/query/auto-review/transcript.js +48 -2
- package/dist/runtime/query/auto-review/transcript.js.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.d.ts.map +1 -1
- package/dist/runtime/query/executor/tool-call-admission.js +40 -3
- package/dist/runtime/query/executor/tool-call-admission.js.map +1 -1
- package/dist/runtime/query/executor.d.ts +32 -10
- package/dist/runtime/query/executor.d.ts.map +1 -1
- package/dist/runtime/query/executor.js +78 -17
- package/dist/runtime/query/executor.js.map +1 -1
- package/dist/runtime/query/index.d.ts +9 -0
- package/dist/runtime/query/index.d.ts.map +1 -1
- package/dist/runtime/query/index.js +54 -17
- package/dist/runtime/query/index.js.map +1 -1
- package/dist/runtime/query/iteration/index.d.ts +1 -1
- package/dist/runtime/query/iteration/index.d.ts.map +1 -1
- package/dist/runtime/query/iteration/index.js +20 -6
- package/dist/runtime/query/iteration/index.js.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/compaction.js +5 -2
- package/dist/runtime/query/iteration/phases/compaction.js.map +1 -1
- package/dist/runtime/query/iteration/phases/context.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/context.js +5 -0
- package/dist/runtime/query/iteration/phases/context.js.map +1 -1
- package/dist/runtime/query/iteration/phases/per-call-review.d.ts +1 -2
- package/dist/runtime/query/iteration/phases/per-call-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/per-call-review.js +2 -5
- package/dist/runtime/query/iteration/phases/per-call-review.js.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.d.ts.map +1 -1
- package/dist/runtime/query/iteration/phases/tool-review.js +6 -1
- package/dist/runtime/query/iteration/phases/tool-review.js.map +1 -1
- package/dist/runtime/query/pasted-frames.d.ts +34 -0
- package/dist/runtime/query/pasted-frames.d.ts.map +1 -0
- package/dist/runtime/query/pasted-frames.js +108 -0
- package/dist/runtime/query/pasted-frames.js.map +1 -0
- package/dist/runtime/query/path-escalation.d.ts +6 -0
- package/dist/runtime/query/path-escalation.d.ts.map +1 -1
- package/dist/runtime/query/path-escalation.js +15 -3
- package/dist/runtime/query/path-escalation.js.map +1 -1
- package/dist/runtime/query/request-interrupted-turns.d.ts +20 -0
- package/dist/runtime/query/request-interrupted-turns.d.ts.map +1 -0
- package/dist/runtime/query/request-interrupted-turns.js +43 -0
- package/dist/runtime/query/request-interrupted-turns.js.map +1 -0
- package/dist/runtime/query/review-policy.d.ts +16 -6
- package/dist/runtime/query/review-policy.d.ts.map +1 -1
- package/dist/runtime/query/review-policy.js +111 -15
- package/dist/runtime/query/review-policy.js.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.d.ts +9 -0
- package/dist/runtime/query/turn/outcome-ledger.d.ts.map +1 -1
- package/dist/runtime/query/turn/outcome-ledger.js +94 -6
- package/dist/runtime/query/turn/outcome-ledger.js.map +1 -1
- package/dist/runtime/query/unanswered.d.ts +19 -0
- package/dist/runtime/query/unanswered.d.ts.map +1 -0
- package/dist/runtime/query/unanswered.js +25 -0
- package/dist/runtime/query/unanswered.js.map +1 -0
- package/dist/runtime/system-events.d.ts +4 -4
- package/dist/runtime/system-events.d.ts.map +1 -1
- package/dist/runtime/system-events.js +2 -0
- package/dist/runtime/system-events.js.map +1 -1
- package/dist/session/workspace/git-worktree.d.ts +8 -0
- package/dist/session/workspace/git-worktree.d.ts.map +1 -1
- package/dist/session/workspace/git-worktree.js +21 -3
- package/dist/session/workspace/git-worktree.js.map +1 -1
- package/dist/store/evidence/source-kind.d.ts +1 -1
- package/dist/store/evidence/source-kind.d.ts.map +1 -1
- package/dist/store/evidence/source-kind.js +1 -1
- package/dist/store/evidence/source-kind.js.map +1 -1
- package/dist/store/goal/index.d.ts +53 -3
- package/dist/store/goal/index.d.ts.map +1 -1
- package/dist/store/goal/index.js +245 -9
- package/dist/store/goal/index.js.map +1 -1
- package/dist/store/session-index/sqlite.d.ts.map +1 -1
- package/dist/store/session-index/sqlite.js +42 -3
- package/dist/store/session-index/sqlite.js.map +1 -1
- package/dist/store/session-log/disk.js +1 -1
- package/dist/store/session-log/disk.js.map +1 -1
- package/dist/store/session-log/lease.d.ts.map +1 -1
- package/dist/store/session-log/lease.js +3 -2
- package/dist/store/session-log/lease.js.map +1 -1
- package/dist/tools/admit-facts.d.ts.map +1 -1
- package/dist/tools/admit-facts.js +2 -0
- package/dist/tools/admit-facts.js.map +1 -1
- package/dist/tools/builtins/bash.d.ts +10 -2
- package/dist/tools/builtins/bash.d.ts.map +1 -1
- package/dist/tools/builtins/bash.js +56 -17
- package/dist/tools/builtins/bash.js.map +1 -1
- package/dist/tools/builtins/browser-local.d.ts +117 -0
- package/dist/tools/builtins/browser-local.d.ts.map +1 -0
- package/dist/tools/builtins/browser-local.js +437 -0
- package/dist/tools/builtins/browser-local.js.map +1 -0
- package/dist/tools/builtins/browser.d.ts +18 -1
- package/dist/tools/builtins/browser.d.ts.map +1 -1
- package/dist/tools/builtins/browser.js +84 -6
- package/dist/tools/builtins/browser.js.map +1 -1
- package/dist/tools/builtins/computer-use-window-id.d.ts +16 -0
- package/dist/tools/builtins/computer-use-window-id.d.ts.map +1 -0
- package/dist/tools/builtins/computer-use-window-id.js +52 -0
- package/dist/tools/builtins/computer-use-window-id.js.map +1 -0
- package/dist/tools/builtins/computer-use.d.ts +65 -7
- package/dist/tools/builtins/computer-use.d.ts.map +1 -1
- package/dist/tools/builtins/computer-use.js +384 -71
- package/dist/tools/builtins/computer-use.js.map +1 -1
- package/dist/tools/builtins/content-fingerprint.d.ts +6 -0
- package/dist/tools/builtins/content-fingerprint.d.ts.map +1 -1
- package/dist/tools/builtins/content-fingerprint.js +7 -1
- package/dist/tools/builtins/content-fingerprint.js.map +1 -1
- package/dist/tools/builtins/edit.d.ts.map +1 -1
- package/dist/tools/builtins/edit.js +89 -7
- package/dist/tools/builtins/edit.js.map +1 -1
- package/dist/tools/builtins/file-write-result.d.ts.map +1 -1
- package/dist/tools/builtins/file-write-result.js +2 -1
- package/dist/tools/builtins/file-write-result.js.map +1 -1
- package/dist/tools/builtins/grep.js +1 -1
- package/dist/tools/builtins/grep.js.map +1 -1
- package/dist/tools/builtins/job.d.ts.map +1 -1
- package/dist/tools/builtins/job.js +4 -2
- package/dist/tools/builtins/job.js.map +1 -1
- package/dist/tools/builtins/monitor.d.ts.map +1 -1
- package/dist/tools/builtins/monitor.js +6 -1
- package/dist/tools/builtins/monitor.js.map +1 -1
- package/dist/tools/builtins/search-tools.d.ts +12 -1
- package/dist/tools/builtins/search-tools.d.ts.map +1 -1
- package/dist/tools/builtins/search-tools.js +166 -20
- package/dist/tools/builtins/search-tools.js.map +1 -1
- package/dist/tools/builtins/shell-read-credit.d.ts +18 -6
- package/dist/tools/builtins/shell-read-credit.d.ts.map +1 -1
- package/dist/tools/builtins/shell-read-credit.js +95 -27
- package/dist/tools/builtins/shell-read-credit.js.map +1 -1
- package/dist/tools/builtins/wait-for-job.d.ts.map +1 -1
- package/dist/tools/builtins/wait-for-job.js +14 -3
- package/dist/tools/builtins/wait-for-job.js.map +1 -1
- package/dist/tools/builtins/web-guidance.d.ts +6 -0
- package/dist/tools/builtins/web-guidance.d.ts.map +1 -1
- package/dist/tools/builtins/web-guidance.js +6 -0
- package/dist/tools/builtins/web-guidance.js.map +1 -1
- package/dist/tools/builtins/web.d.ts.map +1 -1
- package/dist/tools/builtins/web.js +2 -1
- package/dist/tools/builtins/web.js.map +1 -1
- package/dist/tools/builtins/write-file.d.ts.map +1 -1
- package/dist/tools/builtins/write-file.js +32 -2
- package/dist/tools/builtins/write-file.js.map +1 -1
- package/dist/tools/command-shell.d.ts +1 -1
- package/dist/tools/command-shell.d.ts.map +1 -1
- package/dist/tools/command-shell.js +6 -8
- package/dist/tools/command-shell.js.map +1 -1
- package/dist/tools/defineTool.d.ts +2 -0
- package/dist/tools/defineTool.d.ts.map +1 -1
- package/dist/tools/defineTool.js +17 -1
- package/dist/tools/defineTool.js.map +1 -1
- package/dist/tools/goal/confirmation.d.ts +82 -1
- package/dist/tools/goal/confirmation.d.ts.map +1 -1
- package/dist/tools/goal/confirmation.js +153 -3
- package/dist/tools/goal/confirmation.js.map +1 -1
- package/dist/tools/goal/index.d.ts.map +1 -1
- package/dist/tools/goal/index.js +34 -3
- package/dist/tools/goal/index.js.map +1 -1
- package/dist/tools/schedules/index.d.ts +1 -0
- package/dist/tools/schedules/index.d.ts.map +1 -1
- package/dist/tools/schedules/index.js +1 -0
- package/dist/tools/schedules/index.js.map +1 -1
- package/dist/tools/schedules/loop-tool.d.ts.map +1 -1
- package/dist/tools/schedules/loop-tool.js +8 -6
- package/dist/tools/schedules/loop-tool.js.map +1 -1
- package/dist/tools/schedules/present.js +1 -1
- package/dist/tools/schedules/present.js.map +1 -1
- package/dist/tools/schedules/timer-tools.d.ts +36 -0
- package/dist/tools/schedules/timer-tools.d.ts.map +1 -0
- package/dist/tools/schedules/timer-tools.js +234 -0
- package/dist/tools/schedules/timer-tools.js.map +1 -0
- package/dist/tools/schedules/types.d.ts +68 -3
- package/dist/tools/schedules/types.d.ts.map +1 -1
- package/dist/tools/task/create.d.ts.map +1 -1
- package/dist/tools/task/create.js +2 -0
- package/dist/tools/task/create.js.map +1 -1
- package/dist/toolsets/manager.d.ts +49 -7
- package/dist/toolsets/manager.d.ts.map +1 -1
- package/dist/toolsets/manager.js +239 -40
- package/dist/toolsets/manager.js.map +1 -1
- package/dist/turn/evidence-query.d.ts +18 -1
- package/dist/turn/evidence-query.d.ts.map +1 -1
- package/dist/turn/evidence-query.js +177 -35
- package/dist/turn/evidence-query.js.map +1 -1
- package/dist/turn/evidence-recall.d.ts +8 -1
- package/dist/turn/evidence-recall.d.ts.map +1 -1
- package/dist/turn/evidence-recall.js +82 -22
- package/dist/turn/evidence-recall.js.map +1 -1
- package/dist/turn/history-shed.d.ts +15 -0
- package/dist/turn/history-shed.d.ts.map +1 -0
- package/dist/turn/history-shed.js +23 -0
- package/dist/turn/history-shed.js.map +1 -0
- package/dist/types/acp/index.d.ts +26 -0
- package/dist/types/acp/index.d.ts.map +1 -1
- package/dist/types/authorization/index.d.ts +9 -1
- package/dist/types/authorization/index.d.ts.map +1 -1
- package/dist/types/authorization/index.js +11 -2
- package/dist/types/authorization/index.js.map +1 -1
- package/dist/types/command/index.d.ts +26 -2
- package/dist/types/command/index.d.ts.map +1 -1
- package/dist/types/command/index.js +5 -2
- package/dist/types/command/index.js.map +1 -1
- package/dist/types/common/index.d.ts +4 -2
- package/dist/types/common/index.d.ts.map +1 -1
- package/dist/types/common/index.js.map +1 -1
- package/dist/types/goal/index.d.ts +59 -0
- package/dist/types/goal/index.d.ts.map +1 -1
- package/dist/types/hitl/index.d.ts +10 -0
- package/dist/types/hitl/index.d.ts.map +1 -1
- package/dist/types/hitl/index.js.map +1 -1
- package/dist/types/message/index.d.ts +56 -1
- package/dist/types/message/index.d.ts.map +1 -1
- package/dist/types/message/index.js +2 -1
- package/dist/types/message/index.js.map +1 -1
- package/dist/types/permission/index.d.ts +14 -0
- package/dist/types/permission/index.d.ts.map +1 -1
- package/dist/types/permission/index.js +14 -0
- package/dist/types/permission/index.js.map +1 -1
- package/dist/types/plugin/index.d.ts +148 -1
- package/dist/types/plugin/index.d.ts.map +1 -1
- package/dist/types/plugin/index.js +9 -0
- package/dist/types/plugin/index.js.map +1 -1
- package/dist/types/provider/chat.d.ts +10 -5
- package/dist/types/provider/chat.d.ts.map +1 -1
- package/dist/types/provider/index.d.ts +1 -0
- package/dist/types/provider/index.d.ts.map +1 -1
- package/dist/types/provider/interface.d.ts +19 -0
- package/dist/types/provider/interface.d.ts.map +1 -1
- package/dist/types/provider/limits.d.ts +33 -0
- package/dist/types/provider/limits.d.ts.map +1 -0
- package/dist/types/provider/limits.js +7 -0
- package/dist/types/provider/limits.js.map +1 -0
- package/dist/types/provider/model.d.ts +5 -0
- package/dist/types/provider/model.d.ts.map +1 -1
- package/dist/types/session/config.d.ts +2 -2
- package/dist/types/session/outcome.d.ts +5 -2
- package/dist/types/session/outcome.d.ts.map +1 -1
- package/dist/types/session/outcome.js.map +1 -1
- package/dist/types/tool/index.d.ts +30 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/dist/types/tool/presentation.d.ts +4 -0
- package/dist/types/tool/presentation.d.ts.map +1 -1
- package/dist/utils/cost.d.ts +1 -1
- package/dist/utils/cost.d.ts.map +1 -1
- package/dist/utils/cost.js +14 -5
- package/dist/utils/cost.js.map +1 -1
- package/dist/utils/file-lock.d.ts +88 -0
- package/dist/utils/file-lock.d.ts.map +1 -0
- package/dist/utils/file-lock.js +281 -0
- package/dist/utils/file-lock.js.map +1 -0
- package/dist/utils/state-backup.d.ts +87 -0
- package/dist/utils/state-backup.d.ts.map +1 -0
- package/dist/utils/state-backup.js +272 -0
- package/dist/utils/state-backup.js.map +1 -0
- package/dist/utils/temp-sweep.d.ts +66 -0
- package/dist/utils/temp-sweep.d.ts.map +1 -0
- package/dist/utils/temp-sweep.js +311 -0
- package/dist/utils/temp-sweep.js.map +1 -0
- package/dist/utils/temp.d.ts +14 -0
- package/dist/utils/temp.d.ts.map +1 -1
- package/dist/utils/temp.js +70 -2
- package/dist/utils/temp.js.map +1 -1
- package/package.json +1 -1
- package/src/account/lock.ts +13 -133
- package/src/account/registry.ts +75 -21
- package/src/account/types.ts +8 -9
- package/src/authorization/dangerous-commands.ts +542 -0
- package/src/authorization/gate.ts +19 -5
- package/src/authorization/protected-paths.ts +13 -8
- package/src/authorization/readonly-commands.ts +35 -1
- package/src/authorization/removal.ts +7 -7
- package/src/authorization/rules.ts +75 -15
- package/src/authorization/shell-lexer.ts +19 -0
- package/src/bridge/acp/permission.ts +2 -0
- package/src/bridge/acp/server.ts +66 -6
- package/src/compaction/context-breakdown.ts +53 -11
- package/src/compaction/dangling.ts +2 -0
- package/src/compaction/extractor.ts +9 -1
- package/src/compaction/index.ts +1 -0
- package/src/compaction/managers/structured.ts +2 -2
- package/src/compaction/manual.ts +11 -3
- package/src/compaction/model-summary.ts +8 -1
- package/src/compaction/summary.ts +54 -7
- package/src/constants/tools/index.ts +30 -16
- package/src/manager/session/turn-recorder.ts +37 -1
- package/src/network/audit.ts +113 -0
- package/src/network/clock.ts +62 -0
- package/src/network/discovery-mdns.ts +485 -0
- package/src/network/discovery.ts +210 -0
- package/src/network/fingerprint.ts +241 -0
- package/src/network/identity.ts +98 -0
- package/src/network/index.ts +134 -0
- package/src/network/join.ts +177 -0
- package/src/network/mail-policy.ts +199 -0
- package/src/network/membership.ts +290 -0
- package/src/network/roster.ts +165 -0
- package/src/network/service.ts +2304 -0
- package/src/network/store.ts +261 -0
- package/src/network/transport.ts +445 -0
- package/src/network/wire.ts +250 -0
- package/src/network/x509.ts +114 -0
- package/src/pals/activity/causality.ts +16 -2
- package/src/peers/endpoint.ts +6 -0
- package/src/peers/envelope.ts +82 -5
- package/src/peers/index.ts +10 -2
- package/src/peers/mode-word.ts +18 -0
- package/src/peers/protocol.ts +24 -1
- package/src/peers/record.ts +5 -0
- package/src/plugin/session-hook-env.ts +25 -2
- package/src/plugin/shell-hook.ts +208 -14
- package/src/pricing/catalogue.generated.ts +6 -0
- package/src/pricing/rates.source.json +13 -7
- package/src/prompt/coding-agent-doctrine.ts +33 -38
- package/src/provider/fallback.ts +11 -0
- package/src/provider/idle-timeout.ts +5 -0
- package/src/provider/model-window-suffix.ts +1 -0
- package/src/provider/retry.ts +5 -0
- package/src/public-runtime.ts +116 -1
- package/src/public-tools.ts +11 -0
- package/src/public-types.ts +74 -1
- package/src/registry/command/kernel-commands.ts +136 -49
- package/src/runtime/jobs/registry.ts +93 -3
- package/src/runtime/query/auto-review/classifier.ts +76 -14
- package/src/runtime/query/auto-review/feedback.ts +50 -0
- package/src/runtime/query/auto-review/git-status.ts +437 -0
- package/src/runtime/query/auto-review/index.ts +7 -2
- package/src/runtime/query/auto-review/prompt.ts +6 -1
- package/src/runtime/query/auto-review/transcript.ts +67 -4
- package/src/runtime/query/executor/tool-call-admission.ts +49 -3
- package/src/runtime/query/executor.ts +104 -21
- package/src/runtime/query/index.ts +66 -17
- package/src/runtime/query/iteration/index.ts +33 -9
- package/src/runtime/query/iteration/phases/compaction.ts +4 -0
- package/src/runtime/query/iteration/phases/context.ts +5 -0
- package/src/runtime/query/iteration/phases/per-call-review.ts +8 -13
- package/src/runtime/query/iteration/phases/tool-review.ts +7 -1
- package/src/runtime/query/pasted-frames.ts +119 -0
- package/src/runtime/query/path-escalation.ts +27 -3
- package/src/runtime/query/request-interrupted-turns.ts +47 -0
- package/src/runtime/query/review-policy.ts +125 -22
- package/src/runtime/query/turn/outcome-ledger.ts +99 -6
- package/src/runtime/query/unanswered.ts +35 -0
- package/src/runtime/system-events.ts +2 -0
- package/src/session/workspace/git-worktree.ts +34 -3
- package/src/store/evidence/source-kind.ts +1 -1
- package/src/store/goal/index.ts +320 -21
- package/src/store/session-index/sqlite.ts +40 -3
- package/src/store/session-log/disk.ts +1 -1
- package/src/store/session-log/lease.ts +3 -2
- package/src/tools/admit-facts.ts +2 -0
- package/src/tools/builtins/bash.ts +62 -19
- package/src/tools/builtins/browser-local.ts +504 -0
- package/src/tools/builtins/browser.ts +108 -6
- package/src/tools/builtins/computer-use-window-id.ts +50 -0
- package/src/tools/builtins/computer-use.ts +460 -68
- package/src/tools/builtins/content-fingerprint.ts +8 -1
- package/src/tools/builtins/edit.ts +93 -7
- package/src/tools/builtins/file-write-result.ts +2 -1
- package/src/tools/builtins/grep.ts +1 -1
- package/src/tools/builtins/job.ts +4 -2
- package/src/tools/builtins/monitor.ts +6 -1
- package/src/tools/builtins/search-tools.ts +196 -21
- package/src/tools/builtins/shell-read-credit.ts +97 -33
- package/src/tools/builtins/wait-for-job.ts +13 -3
- package/src/tools/builtins/web-guidance.ts +6 -0
- package/src/tools/builtins/web.ts +2 -1
- package/src/tools/builtins/write-file.ts +31 -3
- package/src/tools/command-shell.ts +6 -8
- package/src/tools/defineTool.ts +20 -1
- package/src/tools/goal/confirmation.ts +227 -3
- package/src/tools/goal/index.ts +40 -4
- package/src/tools/schedules/index.ts +11 -0
- package/src/tools/schedules/loop-tool.ts +10 -6
- package/src/tools/schedules/present.ts +1 -1
- package/src/tools/schedules/timer-tools.ts +258 -0
- package/src/tools/schedules/types.ts +72 -3
- package/src/tools/task/create.ts +2 -0
- package/src/toolsets/manager.ts +262 -46
- package/src/turn/evidence-query.ts +183 -42
- package/src/turn/evidence-recall.ts +96 -19
- package/src/turn/history-shed.ts +30 -0
- package/src/types/acp/index.ts +24 -0
- package/src/types/authorization/index.ts +20 -3
- package/src/types/command/index.ts +27 -2
- package/src/types/common/index.ts +4 -2
- package/src/types/goal/index.ts +61 -0
- package/src/types/hitl/index.ts +10 -0
- package/src/types/message/index.ts +65 -0
- package/src/types/permission/index.ts +18 -0
- package/src/types/plugin/index.ts +205 -26
- package/src/types/provider/chat.ts +10 -5
- package/src/types/provider/index.ts +1 -0
- package/src/types/provider/interface.ts +21 -0
- package/src/types/provider/limits.ts +35 -0
- package/src/types/provider/model.ts +5 -0
- package/src/types/session/config.ts +2 -2
- package/src/types/session/outcome.ts +3 -1
- package/src/types/tool/index.ts +30 -2
- package/src/types/tool/presentation.ts +4 -0
- package/src/utils/cost.ts +15 -6
- package/src/utils/file-lock.ts +328 -0
- package/src/utils/state-backup.ts +318 -0
- package/src/utils/temp-sweep.ts +327 -0
- package/src/utils/temp.ts +73 -2
|
@@ -109,10 +109,11 @@ export interface ChatCompletionParams {
|
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* Inference speed. `'fast'` asks a provider for its premium low-latency
|
|
112
|
-
* mode, billed at a multiple of the standard rate;
|
|
112
|
+
* mode, billed at a multiple of the standard rate; `'ultrafast'` asks for
|
|
113
|
+
* a tier above it where a provider offers one. Absent and `'standard'`
|
|
113
114
|
* are the same request. A driver with no such mode, or a model without it,
|
|
114
|
-
* must refuse `'fast'` rather than serve
|
|
115
|
-
* caller believe
|
|
115
|
+
* must refuse `'fast'` and `'ultrafast'` rather than serve them at standard
|
|
116
|
+
* speed and let the caller believe they were honoured.
|
|
116
117
|
*/
|
|
117
118
|
speed?: InferenceSpeed
|
|
118
119
|
}
|
|
@@ -183,8 +184,12 @@ export interface ThinkingConfig {
|
|
|
183
184
|
* transport or leave the vendor to refuse an unknown compatible-endpoint
|
|
184
185
|
* extension explicitly.
|
|
185
186
|
*/
|
|
186
|
-
/**
|
|
187
|
-
|
|
187
|
+
/**
|
|
188
|
+
* `'fast'` is a premium low-latency mode; `'ultrafast'` is a tier above it on
|
|
189
|
+
* providers that offer one; `'standard'` is the ordinary request. See
|
|
190
|
+
* {@link ChatCompletionParams.speed}.
|
|
191
|
+
*/
|
|
192
|
+
export type InferenceSpeed = 'standard' | 'fast' | 'ultrafast'
|
|
188
193
|
|
|
189
194
|
export type ReasoningEffort =
|
|
190
195
|
| 'none'
|
|
@@ -2,6 +2,7 @@ import type { DoctorCheckResult } from '../doctor/index.js'
|
|
|
2
2
|
|
|
3
3
|
import type { ChatCompletionParams } from './chat.js'
|
|
4
4
|
import type { ProviderCapabilities } from './config.js'
|
|
5
|
+
import type { ProviderLimits } from './limits.js'
|
|
5
6
|
import type { ModelInfo } from './model.js'
|
|
6
7
|
import type { StreamChunk } from './stream.js'
|
|
7
8
|
|
|
@@ -106,6 +107,18 @@ export interface LLMProvider {
|
|
|
106
107
|
*/
|
|
107
108
|
probeCredential?(signal?: AbortSignal): Promise<void>
|
|
108
109
|
|
|
110
|
+
/**
|
|
111
|
+
* What the vendor says about the account behind this credential: usage windows, or credit left.
|
|
112
|
+
*
|
|
113
|
+
* Optional, and absent means "not reported" for this driver, which a host shows as exactly that
|
|
114
|
+
* and never as zero. A driver whose vendor sends the numbers on responses it already makes
|
|
115
|
+
* answers from the last one with no request of its own; one that must ask makes at most one
|
|
116
|
+
* small request per call, so a host decides how often to call. Resolve `undefined` when the
|
|
117
|
+
* vendor said nothing usable. The result is account data: a host keeps it in memory and does
|
|
118
|
+
* not log its values, store it or put it in a prompt.
|
|
119
|
+
*/
|
|
120
|
+
readLimits?(signal?: AbortSignal): Promise<ProviderLimits | undefined>
|
|
121
|
+
|
|
109
122
|
/**
|
|
110
123
|
* Is this driver able to serve traffic? A summary bit; `doctorCheck` is
|
|
111
124
|
* the same probe with its reasoning intact.
|
|
@@ -174,6 +187,14 @@ export interface LLMProvider {
|
|
|
174
187
|
* stale on the next model release and goes stale SILENTLY — surfacing as
|
|
175
188
|
* a vendor rejection rather than a failing build.
|
|
176
189
|
*/
|
|
190
|
+
/**
|
|
191
|
+
* The speed tiers above standard that `model` offers on this route, when the
|
|
192
|
+
* driver learned them from the account's own model listing. `undefined`
|
|
193
|
+
* means unknown (the listing has not answered, or the model is not in it);
|
|
194
|
+
* `[]` means none. Same convention as {@link ModelInfo.speedTiers}.
|
|
195
|
+
*/
|
|
196
|
+
speedTiersFor?(model: string): readonly ('fast' | 'ultrafast')[] | undefined
|
|
197
|
+
|
|
177
198
|
reasoningEffortLevelsFor?(
|
|
178
199
|
model: string,
|
|
179
200
|
thinking?: import('./chat.js').ThinkingConfig,
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a provider can say about the account behind its credential: how much of a usage window is
|
|
3
|
+
* used, or what credit is left. Every field is something the vendor reported; nothing here is a
|
|
4
|
+
* guess, and a driver that does not know returns nothing at all rather than a zero.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/** One usage window of a subscription, such as the last five hours. */
|
|
8
|
+
export interface ProviderLimitWindow {
|
|
9
|
+
/** A short name the person reads, such as "5-hour limit". */
|
|
10
|
+
label: string
|
|
11
|
+
/** How much of the window is used, 0 to 1, as the vendor gave it. */
|
|
12
|
+
usedFraction: number
|
|
13
|
+
/** When the window resets, in milliseconds since the epoch. */
|
|
14
|
+
resetsAt?: number
|
|
15
|
+
/** The vendor refused requests because this window is used up. */
|
|
16
|
+
rejected?: boolean
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Money or credit the vendor reports for the account or key. */
|
|
20
|
+
export interface ProviderLimitCredit {
|
|
21
|
+
/** ISO 4217 code ("USD", "CNY"), or "credits" where the vendor counts in its own unit. */
|
|
22
|
+
currency: string
|
|
23
|
+
used?: number
|
|
24
|
+
limit?: number
|
|
25
|
+
remaining?: number
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ProviderLimits {
|
|
29
|
+
windows?: readonly ProviderLimitWindow[]
|
|
30
|
+
credit?: ProviderLimitCredit
|
|
31
|
+
/** The plan's name, only when the vendor gives one. */
|
|
32
|
+
plan?: string
|
|
33
|
+
/** When this was read, in milliseconds since the epoch. */
|
|
34
|
+
asOf: number
|
|
35
|
+
}
|
|
@@ -18,6 +18,11 @@ export interface ModelInfo {
|
|
|
18
18
|
reasoningEffortLevels?: readonly import('./chat.js').ReasoningEffort[]
|
|
19
19
|
/** Published default, when established; must belong to reasoningEffortLevels when both are present. */
|
|
20
20
|
reasoningEffortDefault?: import('./chat.js').ReasoningEffort
|
|
21
|
+
/**
|
|
22
|
+
* Speed tiers above standard that the listing established for this model
|
|
23
|
+
* and route. Absent means the listing did not say; `[]` means none.
|
|
24
|
+
*/
|
|
25
|
+
speedTiers?: readonly ('fast' | 'ultrafast')[]
|
|
21
26
|
/**
|
|
22
27
|
* Tokens the model's context holds, when the driver knows.
|
|
23
28
|
*
|
|
@@ -72,10 +72,10 @@ export interface TurnConfig {
|
|
|
72
72
|
/**
|
|
73
73
|
* Inference speed for every model call in the turn: `'fast'` asks for the
|
|
74
74
|
* provider's premium low-latency mode (billed at a multiple of the standard
|
|
75
|
-
* rate), absent and `'standard'` are the ordinary request. Turn-level for
|
|
75
|
+
* rate), `'ultrafast'` for a tier above it where one is offered, absent and `'standard'` are the ordinary request. Turn-level for
|
|
76
76
|
* the same reason as {@link TurnConfig.effort}: speeds do not share a
|
|
77
77
|
* prompt-cache prefix, so a value that moves between steps pays for a cache
|
|
78
|
-
* miss each time. A driver or model without the mode REFUSES
|
|
78
|
+
* miss each time. A driver or model without the mode REFUSES the tier
|
|
79
79
|
* rather than serving it slowly.
|
|
80
80
|
*/
|
|
81
81
|
speed?: import('../provider/index.js').InferenceSpeed
|
|
@@ -124,11 +124,13 @@ export interface TurnOutcomeConfig {
|
|
|
124
124
|
* sentence goes to the model as a runtime note and the turn goes on; nothing
|
|
125
125
|
* returned lets the turn end. A turn that is being stopped by a limit, a
|
|
126
126
|
* cancellation or a forced final answer is not asked, so a limit always wins
|
|
127
|
-
* over this hook.
|
|
127
|
+
* over this hook. `context.finalMessage` is the answer the model just gave.
|
|
128
|
+
* At most 16 notes are honoured in one turn. A hook that
|
|
128
129
|
* throws is read as nothing returned.
|
|
129
130
|
*/
|
|
130
131
|
readonly beforeEnd?: (
|
|
131
132
|
read: () => Promise<TurnOutcome | undefined>,
|
|
133
|
+
context?: { readonly finalMessage?: string },
|
|
132
134
|
) => string | undefined | Promise<string | undefined>
|
|
133
135
|
}
|
|
134
136
|
|
package/src/types/tool/index.ts
CHANGED
|
@@ -29,6 +29,17 @@ export interface ToolsView {
|
|
|
29
29
|
has(name: string): boolean
|
|
30
30
|
availability(name: string): ToolAvailability
|
|
31
31
|
searchDeferred(query: string, limit?: number): readonly ToolDefinition[]
|
|
32
|
+
/**
|
|
33
|
+
* Resolve exact names for `search_tools`' `select:` form: the deferred tools
|
|
34
|
+
* they name (an MCP tool also by its short name), the names that are already
|
|
35
|
+
* loaded, and the ones nothing matched. Optional so a structural view written
|
|
36
|
+
* before it existed stays valid; `search_tools` falls back to a name search.
|
|
37
|
+
*/
|
|
38
|
+
select?(names: readonly string[]): {
|
|
39
|
+
readonly found: readonly ToolDefinition[]
|
|
40
|
+
readonly available: readonly string[]
|
|
41
|
+
readonly missing: readonly string[]
|
|
42
|
+
}
|
|
32
43
|
}
|
|
33
44
|
|
|
34
45
|
/**
|
|
@@ -217,9 +228,11 @@ export interface MonitorWebSocketTarget {
|
|
|
217
228
|
* outlives, or is billed to, somebody else's run.
|
|
218
229
|
*/
|
|
219
230
|
export interface BackgroundJobRegistryRef {
|
|
220
|
-
start(params: { command: string; workingDirectory: string }): {
|
|
231
|
+
start(params: { command: string; workingDirectory: string; description?: string }): {
|
|
221
232
|
id: string
|
|
222
233
|
status: string
|
|
234
|
+
/** The file the job's output is also written to, when the host keeps one. */
|
|
235
|
+
outputFile?: string
|
|
223
236
|
}
|
|
224
237
|
/**
|
|
225
238
|
* Start a command whose stdout lines reach the model as events while it
|
|
@@ -256,6 +269,8 @@ export interface BackgroundJobRegistryRef {
|
|
|
256
269
|
error?: string
|
|
257
270
|
/** When it last wrote output (epoch ms); absent until it has. */
|
|
258
271
|
lastOutputAt?: number
|
|
272
|
+
/** The file the job's output is also written to, when the host keeps one. */
|
|
273
|
+
outputFile?: string
|
|
259
274
|
}
|
|
260
275
|
/**
|
|
261
276
|
* Take over a process the caller already started and is waiting on, so a
|
|
@@ -265,10 +280,11 @@ export interface BackgroundJobRegistryRef {
|
|
|
265
280
|
*/
|
|
266
281
|
adopt?(params: {
|
|
267
282
|
command: string
|
|
283
|
+
description?: string
|
|
268
284
|
child: ChildProcess
|
|
269
285
|
workingDirectory?: string
|
|
270
286
|
initialOutput?: readonly { readonly stream: 'stdout' | 'stderr'; readonly text: string }[]
|
|
271
|
-
}): { id: string; status: string }
|
|
287
|
+
}): { id: string; status: string; outputFile?: string }
|
|
272
288
|
/**
|
|
273
289
|
* Offer a foreground command this call is waiting on for hand-over to the
|
|
274
290
|
* background, until the returned function is called. `background` is asked
|
|
@@ -1295,6 +1311,18 @@ export interface ToolDefinition<TInput = unknown> extends ToolPresentation<TInpu
|
|
|
1295
1311
|
* the safe direction to be wrong in.
|
|
1296
1312
|
*/
|
|
1297
1313
|
pathArgument?: string
|
|
1314
|
+
/**
|
|
1315
|
+
* Names of tools that are needed right after this one in ordinary use, so
|
|
1316
|
+
* `search_tools` loads them in the same call when it loads this one.
|
|
1317
|
+
*
|
|
1318
|
+
* Declared for a pair that is only useful together (a tool that looks and
|
|
1319
|
+
* a tool that acts on what it saw), so a deferred session pays one search
|
|
1320
|
+
* and one extra model request, not two. A name that is not deferred, not
|
|
1321
|
+
* permitted this turn or not served at all is skipped; a companion's own
|
|
1322
|
+
* `loadsWith` is not followed. Keep it to a tool the next step would
|
|
1323
|
+
* otherwise have to search for: a loaded schema rides every later request.
|
|
1324
|
+
*/
|
|
1325
|
+
loadsWith?: readonly string[]
|
|
1298
1326
|
/**
|
|
1299
1327
|
* A refusal that needs no person's answer: the call cannot run as it stands,
|
|
1300
1328
|
* and the tool can already tell.
|
|
@@ -153,6 +153,10 @@ export type ToolFacts =
|
|
|
153
153
|
readonly background?: true
|
|
154
154
|
/** The command was already running when it was handed over (a key, a message, an interrupt or its timeout). */
|
|
155
155
|
readonly continued?: true
|
|
156
|
+
/** The background job this call started or took over, so a host can show what it is doing now. */
|
|
157
|
+
readonly jobId?: string
|
|
158
|
+
/** The time limit, in milliseconds, whose end moved the command to the background. */
|
|
159
|
+
readonly timeLimitMs?: number
|
|
156
160
|
}
|
|
157
161
|
| {
|
|
158
162
|
readonly kind: 'read'
|
package/src/utils/cost.ts
CHANGED
|
@@ -43,7 +43,7 @@ export interface ModelPricing {
|
|
|
43
43
|
cache?: CacheRates
|
|
44
44
|
/**
|
|
45
45
|
* The vendor's published multiple of every rate on this card for a request
|
|
46
|
-
* served in fast mode (`TokenUsage.speed === 'fast'`). Absent means there is
|
|
46
|
+
* served in fast mode (`TokenUsage.speed === 'fast'`; it does not apply to `'ultrafast'`). Absent means there is
|
|
47
47
|
* no published fast price: fast usage is then counted as unpriced, never
|
|
48
48
|
* charged at the standard rate, which would under-report it.
|
|
49
49
|
*/
|
|
@@ -71,22 +71,31 @@ function priceUsage(usage: TokenUsage, pricing: ModelPricing): Priced {
|
|
|
71
71
|
const searches = usage.webSearchRequests ?? 0
|
|
72
72
|
if (searches === 0 || pricing.webSearchCostPer1000 === undefined) return tokens
|
|
73
73
|
// Per request, so no speed or tier multiple applies to it.
|
|
74
|
-
return {
|
|
74
|
+
return {
|
|
75
|
+
...tokens,
|
|
76
|
+
cost: tokens.cost + (searches / 1000) * pricing.webSearchCostPer1000,
|
|
77
|
+
}
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
/**
|
|
78
|
-
* Tiers with a published per-token price (anything but `priority
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
+
* Tiers with a published per-token price (anything but `priority`, `batch`,
|
|
82
|
+
* `flex` and `scale`; a compatible endpoint may report `default` or `auto`).
|
|
83
|
+
* The vendor lists none for `priority` (a capacity commitment), `batch` (a
|
|
84
|
+
* different endpoint), `flex` or `scale`, so tokens served on one are
|
|
85
|
+
* unpriced rather than charged at the standard rate.
|
|
81
86
|
*/
|
|
82
87
|
function isStandardTier(tier: string | undefined): boolean {
|
|
83
|
-
return tier !== 'priority' && tier !== 'batch'
|
|
88
|
+
return tier !== 'priority' && tier !== 'batch' && tier !== 'flex' && tier !== 'scale'
|
|
84
89
|
}
|
|
85
90
|
|
|
86
91
|
function priceTokens(usage: TokenUsage, pricing: ModelPricing): Priced {
|
|
87
92
|
if (!isStandardTier(usage.serviceTier)) {
|
|
88
93
|
return { cost: 0, cacheDiscount: 0, unpriced: usage.totalTokens }
|
|
89
94
|
}
|
|
95
|
+
if (usage.speed === 'ultrafast') {
|
|
96
|
+
// No published per-token price: counted as unpriced, never at the standard rate.
|
|
97
|
+
return { cost: 0, cacheDiscount: 0, unpriced: usage.totalTokens }
|
|
98
|
+
}
|
|
90
99
|
if (usage.speed === 'fast') {
|
|
91
100
|
const multiplier = pricing.fastMultiplier
|
|
92
101
|
if (multiplier === undefined) {
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto'
|
|
2
|
+
import {
|
|
3
|
+
type Stats,
|
|
4
|
+
closeSync,
|
|
5
|
+
fstatSync,
|
|
6
|
+
mkdirSync,
|
|
7
|
+
openSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
rmSync,
|
|
10
|
+
statSync,
|
|
11
|
+
writeSync,
|
|
12
|
+
} from 'node:fs'
|
|
13
|
+
import { dirname } from 'node:path'
|
|
14
|
+
import { isMainThread } from 'node:worker_threads'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A lock file beside a shared record, so two processes that read, change and
|
|
18
|
+
* write the same file never lose one another's change.
|
|
19
|
+
*
|
|
20
|
+
* The protocol, which any writer of the same files must follow (Desktop has
|
|
21
|
+
* its own copy because it cannot load this package at run time):
|
|
22
|
+
*
|
|
23
|
+
* - The lock is `<file>.lock`, created with `O_CREAT | O_EXCL` (`'wx'`) and
|
|
24
|
+
* mode 0600. Its whole body is `<pid>:<epoch ms>:<random hex>`. A creator
|
|
25
|
+
* whose body write fails removes the lock again before it reports the error.
|
|
26
|
+
* - A lock is stale, and is reclaimed, when its recorded pid no longer exists;
|
|
27
|
+
* when it records no pid (an empty or cut-off body) and its last change is
|
|
28
|
+
* more than {@link EMPTY_LOCK_GRACE_MS} away from now, so a creator that
|
|
29
|
+
* died between creating it and writing its body cannot block the file for
|
|
30
|
+
* good; or when it records this process's own pid while this process does
|
|
31
|
+
* not hold it, which is a lock left by an earlier process that had the same
|
|
32
|
+
* pid. Reclaimers are serialised by `<file>.lock.reclaim` (body: the
|
|
33
|
+
* reclaimer's pid), and the lock is checked again under that guard, so a
|
|
34
|
+
* lock that a live owner took in the meantime is never removed. There is no
|
|
35
|
+
* age timer for a lock with a live owner: a slow owner keeps its lock.
|
|
36
|
+
* - The owner removes the lock when done, and only while the lock still holds
|
|
37
|
+
* its own body.
|
|
38
|
+
*
|
|
39
|
+
* The lock is held across local read and write work, never across a prompt,
|
|
40
|
+
* and only from a process's main thread.
|
|
41
|
+
*/
|
|
42
|
+
export class FileLockError extends Error {
|
|
43
|
+
override readonly name: string = 'FileLockError'
|
|
44
|
+
constructor(
|
|
45
|
+
readonly lockPath: string,
|
|
46
|
+
message: string,
|
|
47
|
+
) {
|
|
48
|
+
super(message)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface FileLockOptions {
|
|
53
|
+
/** How many times to try before refusing. Default 1: a held lock is refused at once. */
|
|
54
|
+
readonly attempts?: number
|
|
55
|
+
/** Waits between attempts; injected so a test never depends on the clock. */
|
|
56
|
+
readonly wait?: (attempt: number) => Promise<void>
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface FileLockSyncOptions {
|
|
60
|
+
/** How many times to try before refusing. Default 1. */
|
|
61
|
+
readonly attempts?: number
|
|
62
|
+
/** Blocks between attempts; injected so a test never depends on the clock. */
|
|
63
|
+
readonly wait?: (attempt: number) => void
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* How long a lock that records no owner is left alone. Its creator writes the
|
|
68
|
+
* body right after creating the file, so a lock still without one this long
|
|
69
|
+
* after its last change was left by a creator that failed or was killed.
|
|
70
|
+
*/
|
|
71
|
+
export const EMPTY_LOCK_GRACE_MS = 10_000
|
|
72
|
+
|
|
73
|
+
/** The lock file the protocol above uses for `file`. */
|
|
74
|
+
export function lockPathFor(file: string): string {
|
|
75
|
+
return `${file}.lock`
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The bodies of the locks this process holds right now, shared by every copy
|
|
80
|
+
* of this module loaded in the same thread, so a lock with this process's pid
|
|
81
|
+
* that none of them holds is known to be left over.
|
|
82
|
+
*/
|
|
83
|
+
const HELD_KEY = Symbol.for('namzu.file-lock.held')
|
|
84
|
+
function heldBodies(): Set<string> {
|
|
85
|
+
const scope = globalThis as { [HELD_KEY]?: Set<string> }
|
|
86
|
+
scope[HELD_KEY] ??= new Set<string>()
|
|
87
|
+
return scope[HELD_KEY]
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function writeBody(fd: number, body: string): void {
|
|
91
|
+
const bytes = Buffer.from(body, 'utf8')
|
|
92
|
+
let written = 0
|
|
93
|
+
while (written < bytes.length) written += writeSync(fd, bytes, written)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function sameFile(a: Stats, b: Stats): boolean {
|
|
97
|
+
return a.dev === b.dev && a.ino === b.ino
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function acquire(lockPath: string): string | undefined {
|
|
101
|
+
const token = `${process.pid}:${Date.now()}:${randomBytes(12).toString('hex')}`
|
|
102
|
+
mkdirSync(dirname(lockPath), { recursive: true, mode: 0o700 })
|
|
103
|
+
for (let pass = 0; pass < 2; pass++) {
|
|
104
|
+
let fd: number
|
|
105
|
+
try {
|
|
106
|
+
fd = openSync(lockPath, 'wx', 0o600)
|
|
107
|
+
} catch (error) {
|
|
108
|
+
if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error
|
|
109
|
+
if (pass === 0 && reclaimIfStale(lockPath)) continue
|
|
110
|
+
return undefined
|
|
111
|
+
}
|
|
112
|
+
try {
|
|
113
|
+
writeBody(fd, token)
|
|
114
|
+
} catch (error) {
|
|
115
|
+
// A full disk creates the file and then fails its body. An empty lock
|
|
116
|
+
// left behind would refuse every later change, so it goes now, while
|
|
117
|
+
// it is still the file this call created.
|
|
118
|
+
try {
|
|
119
|
+
if (sameFile(fstatSync(fd), statSync(lockPath))) rmSync(lockPath, { force: true })
|
|
120
|
+
} catch {
|
|
121
|
+
// Already gone, or replaced by someone else: not ours to remove.
|
|
122
|
+
}
|
|
123
|
+
closeSync(fd)
|
|
124
|
+
throw error
|
|
125
|
+
}
|
|
126
|
+
closeSync(fd)
|
|
127
|
+
heldBodies().add(token)
|
|
128
|
+
return token
|
|
129
|
+
}
|
|
130
|
+
return undefined
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function pidOf(token: string): number | undefined {
|
|
134
|
+
const pid = Number.parseInt(token.split(':', 1)[0] ?? '', 10)
|
|
135
|
+
return Number.isInteger(pid) && pid > 0 ? pid : undefined
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function processIsDead(pid: number): boolean {
|
|
139
|
+
try {
|
|
140
|
+
process.kill(pid, 0)
|
|
141
|
+
return false
|
|
142
|
+
} catch (error) {
|
|
143
|
+
// EPERM means the process exists but belongs to someone else: alive.
|
|
144
|
+
return (error as NodeJS.ErrnoException).code === 'ESRCH'
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** What a lock file says about its owner, read once. */
|
|
149
|
+
interface LockSighting {
|
|
150
|
+
readonly body: string
|
|
151
|
+
readonly stat: Stats
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function sight(lockPath: string): LockSighting | undefined {
|
|
155
|
+
try {
|
|
156
|
+
const stat = statSync(lockPath)
|
|
157
|
+
return { body: readFileSync(lockPath, 'utf8'), stat }
|
|
158
|
+
} catch {
|
|
159
|
+
return undefined
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function isStale(seen: LockSighting, now: number): boolean {
|
|
164
|
+
const pid = pidOf(seen.body)
|
|
165
|
+
if (pid === undefined) return Math.abs(now - seen.stat.mtimeMs) > EMPTY_LOCK_GRACE_MS
|
|
166
|
+
if (pid === process.pid) return isMainThread && !heldBodies().has(seen.body)
|
|
167
|
+
return processIsDead(pid)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** True when `again` is the very lock `seen` described: same file, same body, unchanged since. */
|
|
171
|
+
function unchanged(seen: LockSighting, again: LockSighting): boolean {
|
|
172
|
+
return (
|
|
173
|
+
again.body === seen.body &&
|
|
174
|
+
sameFile(again.stat, seen.stat) &&
|
|
175
|
+
again.stat.mtimeMs === seen.stat.mtimeMs &&
|
|
176
|
+
again.stat.size === seen.stat.size
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Remove a lock that is stale (see the protocol above). Reclaimers are
|
|
182
|
+
* serialised by a guard file, and the lock is re-read under the guard, so a
|
|
183
|
+
* lock that was replaced by a live owner in the meantime is never removed.
|
|
184
|
+
*/
|
|
185
|
+
function reclaimIfStale(lockPath: string): boolean {
|
|
186
|
+
const seen = sight(lockPath)
|
|
187
|
+
if (seen === undefined) return true // already gone; the caller may simply try again
|
|
188
|
+
if (!isStale(seen, Date.now())) return false
|
|
189
|
+
const guard = `${lockPath}.reclaim`
|
|
190
|
+
let fd: number
|
|
191
|
+
try {
|
|
192
|
+
fd = openSync(guard, 'wx', 0o600)
|
|
193
|
+
} catch (error) {
|
|
194
|
+
if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error
|
|
195
|
+
try {
|
|
196
|
+
const holder = sight(guard)
|
|
197
|
+
if (holder && isStale(holder, Date.now())) rmSync(guard, { force: true })
|
|
198
|
+
} catch {
|
|
199
|
+
// The guard vanished or is unreadable; the next attempt decides.
|
|
200
|
+
}
|
|
201
|
+
return false
|
|
202
|
+
}
|
|
203
|
+
try {
|
|
204
|
+
try {
|
|
205
|
+
writeBody(fd, `${process.pid}`)
|
|
206
|
+
} finally {
|
|
207
|
+
closeSync(fd)
|
|
208
|
+
}
|
|
209
|
+
const again = sight(lockPath)
|
|
210
|
+
if (again === undefined) return true
|
|
211
|
+
if (!unchanged(seen, again)) return false
|
|
212
|
+
rmSync(lockPath, { force: true })
|
|
213
|
+
return true
|
|
214
|
+
} finally {
|
|
215
|
+
rmSync(guard, { force: true })
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function release(lockPath: string, token: string): void {
|
|
220
|
+
heldBodies().delete(token)
|
|
221
|
+
// Never remove a successor's lock if something else replaced the file.
|
|
222
|
+
try {
|
|
223
|
+
if (readFileSync(lockPath, 'utf8') === token) rmSync(lockPath, { force: true })
|
|
224
|
+
} catch {
|
|
225
|
+
// The work already has its result; a missing lock is not its failure.
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** Who holds a lock file, as {@link inspectFileLock} reads it. */
|
|
230
|
+
export type FileLockState =
|
|
231
|
+
| { readonly state: 'free' }
|
|
232
|
+
/** `pid` is absent while the lock's creator is still writing its body. */
|
|
233
|
+
| { readonly state: 'held'; readonly pid?: number }
|
|
234
|
+
/** Left by a process that exited (or by an earlier process with this one's pid), or never given an owner. */
|
|
235
|
+
| { readonly state: 'stale'; readonly pid?: number }
|
|
236
|
+
| { readonly state: 'unreadable'; readonly reason: string }
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Read who holds the lock at `lockPath` without taking or changing it. A stale
|
|
240
|
+
* lock is taken over by the next change that meets it, so this is for saying
|
|
241
|
+
* what is there (as `namzu doctor` does), not for deciding to write.
|
|
242
|
+
*/
|
|
243
|
+
export function inspectFileLock(lockPath: string, now: number = Date.now()): FileLockState {
|
|
244
|
+
let seen: LockSighting
|
|
245
|
+
try {
|
|
246
|
+
seen = { stat: statSync(lockPath), body: readFileSync(lockPath, 'utf8') }
|
|
247
|
+
} catch (error) {
|
|
248
|
+
const code = (error as NodeJS.ErrnoException).code
|
|
249
|
+
if (code === 'ENOENT') return { state: 'free' }
|
|
250
|
+
return { state: 'unreadable', reason: code ?? String(error) }
|
|
251
|
+
}
|
|
252
|
+
const pid = pidOf(seen.body)
|
|
253
|
+
if (isStale(seen, now)) return pid === undefined ? { state: 'stale' } : { state: 'stale', pid }
|
|
254
|
+
return pid === undefined ? { state: 'held' } : { state: 'held', pid }
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
function fileLockRefusal(lockPath: string): FileLockError {
|
|
258
|
+
return new FileLockError(
|
|
259
|
+
lockPath,
|
|
260
|
+
`another process holds the lock ${lockPath}. The lock is reclaimed on its own when the process that recorded it has exited; if that process is still running, wait for it to finish.`,
|
|
261
|
+
)
|
|
262
|
+
}
|
|
263
|
+
/** The shared body of every async lock in this package; `refusal` names the error a caller sees. */
|
|
264
|
+
export async function runLocked<T>(
|
|
265
|
+
lockPath: string,
|
|
266
|
+
operation: () => Promise<T> | T,
|
|
267
|
+
options: FileLockOptions,
|
|
268
|
+
refusal: (lockPath: string) => Error,
|
|
269
|
+
): Promise<T> {
|
|
270
|
+
const attempts = Math.max(1, options.attempts ?? 1)
|
|
271
|
+
let token: string | undefined
|
|
272
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
273
|
+
token = acquire(lockPath)
|
|
274
|
+
if (token !== undefined) break
|
|
275
|
+
if (attempt + 1 < attempts && options.wait) await options.wait(attempt)
|
|
276
|
+
}
|
|
277
|
+
if (token === undefined) throw refusal(lockPath)
|
|
278
|
+
try {
|
|
279
|
+
return await operation()
|
|
280
|
+
} finally {
|
|
281
|
+
release(lockPath, token)
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** The shared body of every sync lock in this package; `refusal` names the error a caller sees. */
|
|
286
|
+
export function runLockedSync<T>(
|
|
287
|
+
lockPath: string,
|
|
288
|
+
operation: () => T,
|
|
289
|
+
options: FileLockSyncOptions,
|
|
290
|
+
refusal: (lockPath: string) => Error,
|
|
291
|
+
): T {
|
|
292
|
+
const attempts = Math.max(1, options.attempts ?? 1)
|
|
293
|
+
let token: string | undefined
|
|
294
|
+
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
295
|
+
token = acquire(lockPath)
|
|
296
|
+
if (token !== undefined) break
|
|
297
|
+
if (attempt + 1 < attempts && options.wait) options.wait(attempt)
|
|
298
|
+
}
|
|
299
|
+
if (token === undefined) throw refusal(lockPath)
|
|
300
|
+
try {
|
|
301
|
+
return operation()
|
|
302
|
+
} finally {
|
|
303
|
+
release(lockPath, token)
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* Run `operation` while holding the lock file at `lockPath` (usually
|
|
309
|
+
* {@link lockPathFor} of the record it guards). A lock whose recorded process
|
|
310
|
+
* has exited is reclaimed; a lock held by a live process is a
|
|
311
|
+
* {@link FileLockError} (or a wait, when attempts and a wait function are given).
|
|
312
|
+
*/
|
|
313
|
+
export function withFileLock<T>(
|
|
314
|
+
lockPath: string,
|
|
315
|
+
operation: () => Promise<T> | T,
|
|
316
|
+
options: FileLockOptions = {},
|
|
317
|
+
): Promise<T> {
|
|
318
|
+
return runLocked(lockPath, operation, options, fileLockRefusal)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/** Synchronous form of {@link withFileLock}, for short read-change-write work on a small file. */
|
|
322
|
+
export function withFileLockSync<T>(
|
|
323
|
+
lockPath: string,
|
|
324
|
+
operation: () => T,
|
|
325
|
+
options: FileLockSyncOptions = {},
|
|
326
|
+
): T {
|
|
327
|
+
return runLockedSync(lockPath, operation, options, fileLockRefusal)
|
|
328
|
+
}
|