@waq666/pneuma 0.0.0-stage → 0.7.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/LICENSE +21 -0
- package/README.md +144 -2
- package/bin/dsc.js +91 -0
- package/bin/headless.cjs +40 -0
- package/lib/adapter/core-runtime.d.ts +11 -0
- package/lib/adapter/core-runtime.js +259 -0
- package/lib/adapter/host.d.ts +18 -0
- package/lib/adapter/host.js +14 -0
- package/lib/adapter/runtime.d.ts +15 -0
- package/lib/adapter/runtime.js +290 -0
- package/lib/adapter/transcript.d.ts +184 -0
- package/lib/adapter/transcript.js +605 -0
- package/lib/app/AgentsOverlay.d.ts +18 -0
- package/lib/app/AgentsOverlay.js +63 -0
- package/lib/app/App.d.ts +13 -0
- package/lib/app/App.js +1498 -0
- package/lib/app/ApprovalCard.d.ts +12 -0
- package/lib/app/ApprovalCard.js +76 -0
- package/lib/app/AskCard.d.ts +20 -0
- package/lib/app/AskCard.js +45 -0
- package/lib/app/ChatView.d.ts +32 -0
- package/lib/app/ChatView.js +198 -0
- package/lib/app/Composer.d.ts +50 -0
- package/lib/app/Composer.js +282 -0
- package/lib/app/DiffBlock.d.ts +6 -0
- package/lib/app/DiffBlock.js +37 -0
- package/lib/app/MarkdownView.d.ts +6 -0
- package/lib/app/MarkdownView.js +99 -0
- package/lib/app/ModelPicker.d.ts +7 -0
- package/lib/app/ModelPicker.js +18 -0
- package/lib/app/PlanReviewCard.d.ts +13 -0
- package/lib/app/PlanReviewCard.js +54 -0
- package/lib/app/PresetPicker.d.ts +11 -0
- package/lib/app/PresetPicker.js +19 -0
- package/lib/app/PreviewOverlay.d.ts +14 -0
- package/lib/app/PreviewOverlay.js +22 -0
- package/lib/app/SessionPicker.d.ts +43 -0
- package/lib/app/SessionPicker.js +56 -0
- package/lib/app/SettingsOverlay.d.ts +32 -0
- package/lib/app/SettingsOverlay.js +157 -0
- package/lib/app/SkillsPicker.d.ts +7 -0
- package/lib/app/SkillsPicker.js +19 -0
- package/lib/app/StatusBar.d.ts +22 -0
- package/lib/app/StatusBar.js +272 -0
- package/lib/app/TaskStrips.d.ts +13 -0
- package/lib/app/TaskStrips.js +40 -0
- package/lib/app/ToolCard.d.ts +5 -0
- package/lib/app/ToolCard.js +40 -0
- package/lib/app/TranscriptOverlay.d.ts +12 -0
- package/lib/app/TranscriptOverlay.js +17 -0
- package/lib/app/Welcome.d.ts +6 -0
- package/lib/app/Welcome.js +66 -0
- package/lib/app/attach.d.ts +16 -0
- package/lib/app/attach.js +58 -0
- package/lib/app/click.d.ts +27 -0
- package/lib/app/click.js +89 -0
- package/lib/app/clipboard-image.d.ts +11 -0
- package/lib/app/clipboard-image.js +66 -0
- package/lib/app/cursor.d.ts +4 -0
- package/lib/app/cursor.js +24 -0
- package/lib/app/hello.d.ts +11 -0
- package/lib/app/hello.js +8 -0
- package/lib/app/history-store.d.ts +4 -0
- package/lib/app/history-store.js +41 -0
- package/lib/app/image-blocks.d.ts +12 -0
- package/lib/app/image-blocks.js +125 -0
- package/lib/app/markdown.d.ts +54 -0
- package/lib/app/markdown.js +189 -0
- package/lib/app/settings-model.d.ts +69 -0
- package/lib/app/settings-model.js +114 -0
- package/lib/app/theme.d.ts +166 -0
- package/lib/app/theme.js +141 -0
- package/lib/boot.d.ts +1 -0
- package/lib/boot.js +34 -0
- package/lib/commands.d.ts +49 -0
- package/lib/commands.js +115 -0
- package/lib/contract.d.ts +1973 -0
- package/lib/contract.js +36 -0
- package/lib/core/agent-roles.d.ts +52 -0
- package/lib/core/agent-roles.js +274 -0
- package/lib/core/approval-floor.d.ts +183 -0
- package/lib/core/approval-floor.js +679 -0
- package/lib/core/approval.d.ts +42 -0
- package/lib/core/approval.js +8 -0
- package/lib/core/audit.d.ts +61 -0
- package/lib/core/audit.js +59 -0
- package/lib/core/boot-notices.d.ts +6 -0
- package/lib/core/boot-notices.js +61 -0
- package/lib/core/cdp/actions.d.ts +182 -0
- package/lib/core/cdp/actions.js +649 -0
- package/lib/core/cdp/launch.d.ts +192 -0
- package/lib/core/cdp/launch.js +491 -0
- package/lib/core/cdp/snapshot.d.ts +139 -0
- package/lib/core/cdp/snapshot.js +316 -0
- package/lib/core/cdp/transport.d.ts +160 -0
- package/lib/core/cdp/transport.js +359 -0
- package/lib/core/command-policy.d.ts +108 -0
- package/lib/core/command-policy.js +580 -0
- package/lib/core/commands-completion.d.ts +78 -0
- package/lib/core/commands-completion.js +167 -0
- package/lib/core/compact-anchors.d.ts +76 -0
- package/lib/core/compact-anchors.js +284 -0
- package/lib/core/compact.d.ts +110 -0
- package/lib/core/compact.js +210 -0
- package/lib/core/config-store.d.ts +38 -0
- package/lib/core/config-store.js +307 -0
- package/lib/core/config.d.ts +36 -0
- package/lib/core/config.js +124 -0
- package/lib/core/connection-test.d.ts +60 -0
- package/lib/core/connection-test.js +84 -0
- package/lib/core/desktop-control.d.ts +298 -0
- package/lib/core/desktop-control.js +1311 -0
- package/lib/core/diff-text.d.ts +74 -0
- package/lib/core/diff-text.js +257 -0
- package/lib/core/dock-browser.d.ts +137 -0
- package/lib/core/dock-browser.js +146 -0
- package/lib/core/dock-ops.d.ts +59 -0
- package/lib/core/dock-ops.js +104 -0
- package/lib/core/dock-session.d.ts +39 -0
- package/lib/core/dock-session.js +28 -0
- package/lib/core/dsh-compat/hook.d.ts +18 -0
- package/lib/core/dsh-compat/hook.js +52 -0
- package/lib/core/dsh-compat/resolve-hook.d.ts +5 -0
- package/lib/core/dsh-compat/resolve-hook.js +59 -0
- package/lib/core/dsh-compat/tools-facade.d.ts +47 -0
- package/lib/core/dsh-compat/tools-facade.js +108 -0
- package/lib/core/err-text.d.ts +13 -0
- package/lib/core/err-text.js +15 -0
- package/lib/core/events.d.ts +149 -0
- package/lib/core/events.js +1 -0
- package/lib/core/git-exec.d.ts +23 -0
- package/lib/core/git-exec.js +72 -0
- package/lib/core/git-info.d.ts +47 -0
- package/lib/core/git-info.js +157 -0
- package/lib/core/goal.d.ts +89 -0
- package/lib/core/goal.js +189 -0
- package/lib/core/hooks.d.ts +272 -0
- package/lib/core/hooks.js +818 -0
- package/lib/core/host-browser-link.d.ts +59 -0
- package/lib/core/host-browser-link.js +9 -0
- package/lib/core/host-methods.d.ts +25 -0
- package/lib/core/host-methods.js +103 -0
- package/lib/core/image-diet.d.ts +77 -0
- package/lib/core/image-diet.js +127 -0
- package/lib/core/learnings/ledger.d.ts +73 -0
- package/lib/core/learnings/ledger.js +273 -0
- package/lib/core/learnings/skill-write.d.ts +250 -0
- package/lib/core/learnings/skill-write.js +854 -0
- package/lib/core/learnings/store.d.ts +102 -0
- package/lib/core/learnings/store.js +266 -0
- package/lib/core/lifecycle-hooks.d.ts +189 -0
- package/lib/core/lifecycle-hooks.js +576 -0
- package/lib/core/llm.d.ts +272 -0
- package/lib/core/llm.js +548 -0
- package/lib/core/lockfile.d.ts +17 -0
- package/lib/core/lockfile.js +110 -0
- package/lib/core/loop.d.ts +185 -0
- package/lib/core/loop.js +587 -0
- package/lib/core/lsp/client.d.ts +189 -0
- package/lib/core/lsp/client.js +690 -0
- package/lib/core/lsp/framing.d.ts +84 -0
- package/lib/core/lsp/framing.js +181 -0
- package/lib/core/lsp/line-shift.d.ts +28 -0
- package/lib/core/lsp/line-shift.js +127 -0
- package/lib/core/lsp/manager.d.ts +93 -0
- package/lib/core/lsp/manager.js +418 -0
- package/lib/core/lsp/normalize.d.ts +32 -0
- package/lib/core/lsp/normalize.js +139 -0
- package/lib/core/lsp/servers.d.ts +106 -0
- package/lib/core/lsp/servers.js +352 -0
- package/lib/core/lsp/uri.d.ts +76 -0
- package/lib/core/lsp/uri.js +179 -0
- package/lib/core/market.d.ts +51 -0
- package/lib/core/market.js +358 -0
- package/lib/core/mcp.d.ts +201 -0
- package/lib/core/mcp.js +836 -0
- package/lib/core/memory-eval.d.ts +158 -0
- package/lib/core/memory-eval.js +215 -0
- package/lib/core/memory.d.ts +266 -0
- package/lib/core/memory.js +703 -0
- package/lib/core/mention.d.ts +57 -0
- package/lib/core/mention.js +129 -0
- package/lib/core/microcompact.d.ts +48 -0
- package/lib/core/microcompact.js +79 -0
- package/lib/core/migrate.d.ts +56 -0
- package/lib/core/migrate.js +134 -0
- package/lib/core/model-caps.d.ts +83 -0
- package/lib/core/model-caps.js +150 -0
- package/lib/core/model-discovery.d.ts +19 -0
- package/lib/core/model-discovery.js +69 -0
- package/lib/core/modes.d.ts +72 -0
- package/lib/core/modes.js +152 -0
- package/lib/core/native-bridge.d.ts +135 -0
- package/lib/core/native-bridge.js +563 -0
- package/lib/core/path-policy.d.ts +32 -0
- package/lib/core/path-policy.js +248 -0
- package/lib/core/permission-presets.d.ts +67 -0
- package/lib/core/permission-presets.js +75 -0
- package/lib/core/plugin-loader.d.ts +36 -0
- package/lib/core/plugin-loader.js +294 -0
- package/lib/core/plugin-registry.d.ts +113 -0
- package/lib/core/plugin-registry.js +256 -0
- package/lib/core/prefs.d.ts +82 -0
- package/lib/core/prefs.js +372 -0
- package/lib/core/presets.d.ts +80 -0
- package/lib/core/presets.js +373 -0
- package/lib/core/pricing.d.ts +90 -0
- package/lib/core/pricing.js +126 -0
- package/lib/core/prompt.d.ts +92 -0
- package/lib/core/prompt.js +339 -0
- package/lib/core/ptc.d.ts +66 -0
- package/lib/core/ptc.js +70 -0
- package/lib/core/remote/frames.d.ts +91 -0
- package/lib/core/remote/frames.js +174 -0
- package/lib/core/remote/notify.d.ts +54 -0
- package/lib/core/remote/notify.js +77 -0
- package/lib/core/remote/owner.d.ts +32 -0
- package/lib/core/remote/owner.js +75 -0
- package/lib/core/remote/pairing.d.ts +104 -0
- package/lib/core/remote/pairing.js +261 -0
- package/lib/core/remote/push.d.ts +80 -0
- package/lib/core/remote/push.js +222 -0
- package/lib/core/remote/store.d.ts +18 -0
- package/lib/core/remote/store.js +59 -0
- package/lib/core/remote/tickets.d.ts +20 -0
- package/lib/core/remote/tickets.js +49 -0
- package/lib/core/remote/uploads.d.ts +63 -0
- package/lib/core/remote/uploads.js +161 -0
- package/lib/core/request-attribution.d.ts +26 -0
- package/lib/core/request-attribution.js +86 -0
- package/lib/core/request-invariant.d.ts +61 -0
- package/lib/core/request-invariant.js +199 -0
- package/lib/core/sandbox/backends.d.ts +64 -0
- package/lib/core/sandbox/backends.js +194 -0
- package/lib/core/sandbox/execpolicy.d.ts +93 -0
- package/lib/core/sandbox/execpolicy.js +452 -0
- package/lib/core/sandbox/net-proxy.d.ts +31 -0
- package/lib/core/sandbox/net-proxy.js +162 -0
- package/lib/core/sandbox/policy.d.ts +211 -0
- package/lib/core/sandbox/policy.js +559 -0
- package/lib/core/sandbox/win/abi.d.ts +161 -0
- package/lib/core/sandbox/win/abi.js +169 -0
- package/lib/core/sandbox/win/account.d.ts +71 -0
- package/lib/core/sandbox/win/account.js +206 -0
- package/lib/core/sandbox/win/acl.d.ts +54 -0
- package/lib/core/sandbox/win/acl.js +339 -0
- package/lib/core/sandbox/win/backend.d.ts +61 -0
- package/lib/core/sandbox/win/backend.js +249 -0
- package/lib/core/sandbox/win/doctor.d.ts +24 -0
- package/lib/core/sandbox/win/doctor.js +272 -0
- package/lib/core/sandbox/win/ffi.d.ts +107 -0
- package/lib/core/sandbox/win/ffi.js +166 -0
- package/lib/core/sandbox/win/net-abi.d.ts +154 -0
- package/lib/core/sandbox/win/net-abi.js +316 -0
- package/lib/core/sandbox/win/runner-entry.d.ts +35 -0
- package/lib/core/sandbox/win/runner-entry.js +391 -0
- package/lib/core/sandbox/win/setup.d.ts +60 -0
- package/lib/core/sandbox/win/setup.js +986 -0
- package/lib/core/sandbox/win/token.d.ts +35 -0
- package/lib/core/sandbox/win/token.js +238 -0
- package/lib/core/sandbox/win/wfp.d.ts +41 -0
- package/lib/core/sandbox/win/wfp.js +200 -0
- package/lib/core/sandbox/win/workspace-sid.d.ts +9 -0
- package/lib/core/sandbox/win/workspace-sid.js +45 -0
- package/lib/core/schedule/rule.d.ts +184 -0
- package/lib/core/schedule/rule.js +745 -0
- package/lib/core/schedule/runner.d.ts +185 -0
- package/lib/core/schedule/runner.js +678 -0
- package/lib/core/schedule/store.d.ts +182 -0
- package/lib/core/schedule/store.js +455 -0
- package/lib/core/secrets.d.ts +41 -0
- package/lib/core/secrets.js +150 -0
- package/lib/core/session-export.d.ts +18 -0
- package/lib/core/session-export.js +73 -0
- package/lib/core/session-index.d.ts +159 -0
- package/lib/core/session-index.js +683 -0
- package/lib/core/session-meta.d.ts +41 -0
- package/lib/core/session-meta.js +97 -0
- package/lib/core/session.d.ts +356 -0
- package/lib/core/session.js +998 -0
- package/lib/core/skills.d.ts +60 -0
- package/lib/core/skills.js +171 -0
- package/lib/core/spill.d.ts +159 -0
- package/lib/core/spill.js +329 -0
- package/lib/core/surface-registry.d.ts +45 -0
- package/lib/core/surface-registry.js +67 -0
- package/lib/core/team-board.d.ts +95 -0
- package/lib/core/team-board.js +316 -0
- package/lib/core/throughput.d.ts +46 -0
- package/lib/core/throughput.js +40 -0
- package/lib/core/todo-reminder.d.ts +44 -0
- package/lib/core/todo-reminder.js +55 -0
- package/lib/core/todo.d.ts +81 -0
- package/lib/core/todo.js +222 -0
- package/lib/core/token-estimate.d.ts +55 -0
- package/lib/core/token-estimate.js +82 -0
- package/lib/core/tool-guards.d.ts +103 -0
- package/lib/core/tool-guards.js +77 -0
- package/lib/core/tool-search.d.ts +152 -0
- package/lib/core/tool-search.js +311 -0
- package/lib/core/tools/bash.d.ts +281 -0
- package/lib/core/tools/bash.js +871 -0
- package/lib/core/tools/command-runner.d.ts +84 -0
- package/lib/core/tools/command-runner.js +68 -0
- package/lib/core/tools/fs-tools.d.ts +23 -0
- package/lib/core/tools/fs-tools.js +247 -0
- package/lib/core/tools/index.d.ts +8 -0
- package/lib/core/tools/index.js +4 -0
- package/lib/core/tools/sandbox-args.d.ts +51 -0
- package/lib/core/tools/sandbox-args.js +90 -0
- package/lib/core/tools/search-tools.d.ts +3 -0
- package/lib/core/tools/search-tools.js +153 -0
- package/lib/core/tools.d.ts +96 -0
- package/lib/core/tools.js +53 -0
- package/lib/core/ui-boot-source.d.ts +71 -0
- package/lib/core/ui-boot-source.js +121 -0
- package/lib/core/ui-bundles.d.ts +249 -0
- package/lib/core/ui-bundles.js +830 -0
- package/lib/core/ui-combo.d.ts +49 -0
- package/lib/core/ui-combo.js +55 -0
- package/lib/core/ui-events.d.ts +81 -0
- package/lib/core/ui-events.js +364 -0
- package/lib/core/ui-hmr.d.ts +36 -0
- package/lib/core/ui-hmr.js +128 -0
- package/lib/core/ui-methods.d.ts +69 -0
- package/lib/core/ui-methods.js +341 -0
- package/lib/core/ui-route.d.ts +69 -0
- package/lib/core/ui-route.js +122 -0
- package/lib/core/ui-server.d.ts +75 -0
- package/lib/core/ui-server.js +369 -0
- package/lib/core/ui-trust.d.ts +47 -0
- package/lib/core/ui-trust.js +164 -0
- package/lib/core/untrusted.d.ts +30 -0
- package/lib/core/untrusted.js +48 -0
- package/lib/core/update-check.d.ts +81 -0
- package/lib/core/update-check.js +177 -0
- package/lib/core/usage-log.d.ts +82 -0
- package/lib/core/usage-log.js +306 -0
- package/lib/core/version.d.ts +1 -0
- package/lib/core/version.js +37 -0
- package/lib/core/web-http.d.ts +57 -0
- package/lib/core/web-http.js +137 -0
- package/lib/core/web-static.d.ts +31 -0
- package/lib/core/web-static.js +75 -0
- package/lib/headless.d.ts +1 -0
- package/lib/headless.js +31 -0
- package/lib/host/kernel.d.ts +33 -0
- package/lib/host/kernel.js +451 -0
- package/lib/index.d.ts +41 -0
- package/lib/index.js +35 -0
- package/lib/plugins/agent.d.ts +2 -0
- package/lib/plugins/agent.js +274 -0
- package/lib/plugins/approval-floor.d.ts +2 -0
- package/lib/plugins/approval-floor.js +223 -0
- package/lib/plugins/approval.d.ts +16 -0
- package/lib/plugins/approval.js +674 -0
- package/lib/plugins/ask.d.ts +2 -0
- package/lib/plugins/ask.js +245 -0
- package/lib/plugins/browser.d.ts +68 -0
- package/lib/plugins/browser.js +1341 -0
- package/lib/plugins/commands.d.ts +23 -0
- package/lib/plugins/commands.js +498 -0
- package/lib/plugins/compact.d.ts +21 -0
- package/lib/plugins/compact.js +274 -0
- package/lib/plugins/computer-use.d.ts +47 -0
- package/lib/plugins/computer-use.js +539 -0
- package/lib/plugins/desktop-dock.d.ts +2 -0
- package/lib/plugins/desktop-dock.js +626 -0
- package/lib/plugins/dock-browser.d.ts +34 -0
- package/lib/plugins/dock-browser.js +765 -0
- package/lib/plugins/dsh-compat.d.ts +25 -0
- package/lib/plugins/dsh-compat.js +37 -0
- package/lib/plugins/file-review.d.ts +108 -0
- package/lib/plugins/file-review.js +393 -0
- package/lib/plugins/git.d.ts +26 -0
- package/lib/plugins/git.js +132 -0
- package/lib/plugins/goal.d.ts +20 -0
- package/lib/plugins/goal.js +245 -0
- package/lib/plugins/guards.d.ts +14 -0
- package/lib/plugins/guards.js +18 -0
- package/lib/plugins/hooks.d.ts +19 -0
- package/lib/plugins/hooks.js +583 -0
- package/lib/plugins/host-stdio.d.ts +88 -0
- package/lib/plugins/host-stdio.js +317 -0
- package/lib/plugins/image-diet.d.ts +17 -0
- package/lib/plugins/image-diet.js +85 -0
- package/lib/plugins/lifecycle-hooks.d.ts +26 -0
- package/lib/plugins/lifecycle-hooks.js +338 -0
- package/lib/plugins/llm.d.ts +13 -0
- package/lib/plugins/llm.js +215 -0
- package/lib/plugins/lsp.d.ts +54 -0
- package/lib/plugins/lsp.js +608 -0
- package/lib/plugins/mcp.d.ts +16 -0
- package/lib/plugins/mcp.js +673 -0
- package/lib/plugins/memory.d.ts +17 -0
- package/lib/plugins/memory.js +858 -0
- package/lib/plugins/microcompact.d.ts +18 -0
- package/lib/plugins/microcompact.js +119 -0
- package/lib/plugins/mode.d.ts +18 -0
- package/lib/plugins/mode.js +115 -0
- package/lib/plugins/permission-presets.d.ts +18 -0
- package/lib/plugins/permission-presets.js +135 -0
- package/lib/plugins/plan.d.ts +2 -0
- package/lib/plugins/plan.js +192 -0
- package/lib/plugins/plugin-manager.d.ts +2 -0
- package/lib/plugins/plugin-manager.js +165 -0
- package/lib/plugins/presets.d.ts +2 -0
- package/lib/plugins/presets.js +182 -0
- package/lib/plugins/prompt.d.ts +2 -0
- package/lib/plugins/prompt.js +264 -0
- package/lib/plugins/ptc.d.ts +2 -0
- package/lib/plugins/ptc.js +272 -0
- package/lib/plugins/remote/http.d.ts +11 -0
- package/lib/plugins/remote/http.js +11 -0
- package/lib/plugins/remote/routes.d.ts +24 -0
- package/lib/plugins/remote/routes.js +384 -0
- package/lib/plugins/remote/types.d.ts +135 -0
- package/lib/plugins/remote/types.js +87 -0
- package/lib/plugins/remote.d.ts +17 -0
- package/lib/plugins/remote.js +1028 -0
- package/lib/plugins/runtime-api.d.ts +16 -0
- package/lib/plugins/runtime-api.js +99 -0
- package/lib/plugins/runtime.d.ts +10 -0
- package/lib/plugins/runtime.js +451 -0
- package/lib/plugins/sandbox.d.ts +2 -0
- package/lib/plugins/sandbox.js +761 -0
- package/lib/plugins/schedule.d.ts +26 -0
- package/lib/plugins/schedule.js +538 -0
- package/lib/plugins/self-improve.d.ts +61 -0
- package/lib/plugins/self-improve.js +953 -0
- package/lib/plugins/session-search.d.ts +16 -0
- package/lib/plugins/session-search.js +308 -0
- package/lib/plugins/session-title.d.ts +19 -0
- package/lib/plugins/session-title.js +109 -0
- package/lib/plugins/session.d.ts +7 -0
- package/lib/plugins/session.js +296 -0
- package/lib/plugins/settings.d.ts +3 -0
- package/lib/plugins/settings.js +705 -0
- package/lib/plugins/skills.d.ts +2 -0
- package/lib/plugins/skills.js +360 -0
- package/lib/plugins/spill.d.ts +16 -0
- package/lib/plugins/spill.js +200 -0
- package/lib/plugins/subagent.d.ts +2 -0
- package/lib/plugins/subagent.js +862 -0
- package/lib/plugins/surfaces.d.ts +11 -0
- package/lib/plugins/surfaces.js +20 -0
- package/lib/plugins/team.d.ts +16 -0
- package/lib/plugins/team.js +149 -0
- package/lib/plugins/todo.d.ts +19 -0
- package/lib/plugins/todo.js +188 -0
- package/lib/plugins/tool-search.d.ts +2 -0
- package/lib/plugins/tool-search.js +425 -0
- package/lib/plugins/tools-default.d.ts +12 -0
- package/lib/plugins/tools-default.js +275 -0
- package/lib/plugins/tools.d.ts +16 -0
- package/lib/plugins/tools.js +62 -0
- package/lib/plugins/transcript.d.ts +15 -0
- package/lib/plugins/transcript.js +311 -0
- package/lib/plugins/tui.d.ts +2 -0
- package/lib/plugins/tui.js +98 -0
- package/lib/plugins/waiting.d.ts +12 -0
- package/lib/plugins/waiting.js +34 -0
- package/lib/plugins/web-search.d.ts +14 -0
- package/lib/plugins/web-search.js +263 -0
- package/lib/plugins/webserver.d.ts +48 -0
- package/lib/plugins/webserver.js +228 -0
- package/lib/remote/assets/app-DAcUCOEn.js +14 -0
- package/lib/remote/assets/icon-192.png +0 -0
- package/lib/remote/assets/icon-512.png +0 -0
- package/lib/remote/assets/index.html +34 -0
- package/lib/remote/assets/manifest.json +27 -0
- package/lib/remote/assets/style-DIB6729x.css +1 -0
- package/lib/remote/assets/sw.js +66 -0
- package/lib/services/types.d.ts +1228 -0
- package/lib/services/types.js +1 -0
- package/lib/tools/config-cli.d.ts +1 -0
- package/lib/tools/config-cli.js +89 -0
- package/lib/ui/arrival.d.ts +72 -0
- package/lib/ui/arrival.js +105 -0
- package/lib/ui/assets/app-B70nVIKd.js +69 -0
- package/lib/ui/assets/chunk-2UxHyX5q.js +1 -0
- package/lib/ui/assets/chunk-B1dDrJ26.js +1 -0
- package/lib/ui/assets/chunk-B6aJPvgy.js +1 -0
- package/lib/ui/assets/chunk-BEwlwnbL.js +1 -0
- package/lib/ui/assets/chunk-BGcgwlCI.js +12 -0
- package/lib/ui/assets/chunk-BIGW1oBm.js +1 -0
- package/lib/ui/assets/chunk-BPQ3VLAy.js +1 -0
- package/lib/ui/assets/chunk-BRH0KZbk.js +141 -0
- package/lib/ui/assets/chunk-BX6H_ySx.js +1 -0
- package/lib/ui/assets/chunk-B_P3UbPa.js +1 -0
- package/lib/ui/assets/chunk-B_TYUkTI.js +1 -0
- package/lib/ui/assets/chunk-B_vNuMnf.js +1 -0
- package/lib/ui/assets/chunk-BajyYBss.js +10 -0
- package/lib/ui/assets/chunk-BdnUsdx6.js +1 -0
- package/lib/ui/assets/chunk-Buea-lGh.js +1 -0
- package/lib/ui/assets/chunk-C0PvZCCE.js +1 -0
- package/lib/ui/assets/chunk-C0m74zRD.js +1 -0
- package/lib/ui/assets/chunk-C27-OAKa.js +1 -0
- package/lib/ui/assets/chunk-C2oV4EkX.js +1 -0
- package/lib/ui/assets/chunk-C7zT0LnQ.js +1 -0
- package/lib/ui/assets/chunk-C9GSunVT.js +1 -0
- package/lib/ui/assets/chunk-C9tS-k6U.js +1 -0
- package/lib/ui/assets/chunk-CHLpvVh8.js +1 -0
- package/lib/ui/assets/chunk-CLxacb5B.js +1 -0
- package/lib/ui/assets/chunk-COt5Ahok.js +1 -0
- package/lib/ui/assets/chunk-CPTIWCL2.js +1 -0
- package/lib/ui/assets/chunk-CQLl-L-p.js +1 -0
- package/lib/ui/assets/chunk-CUWRgxuq.js +55 -0
- package/lib/ui/assets/chunk-CWanVSXC.js +1 -0
- package/lib/ui/assets/chunk-Cf5RLm7j.js +1 -0
- package/lib/ui/assets/chunk-CickPsom.js +1 -0
- package/lib/ui/assets/chunk-Cj5Yp3dK.js +1 -0
- package/lib/ui/assets/chunk-Cmh6b_Ma.js +1 -0
- package/lib/ui/assets/chunk-Cp-IABpG.js +1 -0
- package/lib/ui/assets/chunk-CqE71os6.js +1 -0
- package/lib/ui/assets/chunk-CtKP3W-j.js +1 -0
- package/lib/ui/assets/chunk-Cvjx9yec.js +1 -0
- package/lib/ui/assets/chunk-CxGP3dtY.js +1 -0
- package/lib/ui/assets/chunk-CylS5w8V.js +1 -0
- package/lib/ui/assets/chunk-D38fbIBN.js +1 -0
- package/lib/ui/assets/chunk-D97Zzqfu.js +1 -0
- package/lib/ui/assets/chunk-DAi9KRSo.js +1 -0
- package/lib/ui/assets/chunk-DHK4yRfg.js +1 -0
- package/lib/ui/assets/chunk-DJeabLx-.js +1 -0
- package/lib/ui/assets/chunk-DNRxmY5a.js +1 -0
- package/lib/ui/assets/chunk-DNSN1z5r.js +1 -0
- package/lib/ui/assets/chunk-DNasK_ZG.js +1 -0
- package/lib/ui/assets/chunk-DPvrY3IQ.js +1 -0
- package/lib/ui/assets/chunk-DXmwc3jG.js +1 -0
- package/lib/ui/assets/chunk-Dd0kTxKP.js +1 -0
- package/lib/ui/assets/chunk-De0Btta0.js +1 -0
- package/lib/ui/assets/chunk-Des-eS-w.js +1 -0
- package/lib/ui/assets/chunk-Df6bDoY_.js +1 -0
- package/lib/ui/assets/chunk-DijEV5ha.js +1 -0
- package/lib/ui/assets/chunk-DkvoVjww.js +1 -0
- package/lib/ui/assets/chunk-DlC-OlHO.js +1 -0
- package/lib/ui/assets/chunk-DnzrXTVv.js +1 -0
- package/lib/ui/assets/chunk-Dualf0xi.js +1 -0
- package/lib/ui/assets/chunk-EXT84bkm.js +1 -0
- package/lib/ui/assets/chunk-GwR3hkPK.js +1 -0
- package/lib/ui/assets/chunk-P80f7IUj.js +1 -0
- package/lib/ui/assets/chunk-VOosw3JB.js +1 -0
- package/lib/ui/assets/chunk-YQ4lDkt_.js +140 -0
- package/lib/ui/assets/chunk-Yzrsuije.js +1 -0
- package/lib/ui/assets/chunk-Z72CF80r.js +1 -0
- package/lib/ui/assets/chunk-g9-lgVsj.js +1 -0
- package/lib/ui/assets/chunk-vGWfd6FD.js +1 -0
- package/lib/ui/assets/chunk-wDzz0qaB.js +1 -0
- package/lib/ui/assets/chunk-ySF7HWmS.js +1 -0
- package/lib/ui/assets/icon.png +0 -0
- package/lib/ui/assets/index.html +14 -0
- package/lib/ui/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
- package/lib/ui/assets/style-Bq01xH_b.css +1 -0
- package/lib/ui/frames.d.ts +67 -0
- package/lib/ui/frames.js +146 -0
- package/lib/ui/index.d.ts +59 -0
- package/lib/ui/index.js +50 -0
- package/lib/ui/manifest.d.ts +172 -0
- package/lib/ui/manifest.js +158 -0
- package/lib/ui/plugin.d.ts +161 -0
- package/lib/ui/plugin.js +7 -0
- package/lib/ui/plugins/browser/client.js +290 -0
- package/lib/ui/plugins/browser/icon.png +0 -0
- package/lib/ui/plugins/composer/client.js +1843 -0
- package/lib/ui/plugins/composer/icon.png +0 -0
- package/lib/ui/plugins/files/client.js +646 -0
- package/lib/ui/plugins/files/icon.png +0 -0
- package/lib/ui/plugins/manifest.json +107 -0
- package/lib/ui/plugins/plugins/client.js +682 -0
- package/lib/ui/plugins/plugins/icon.png +0 -0
- package/lib/ui/plugins/preview/client.js +197 -0
- package/lib/ui/plugins/preview/icon.png +0 -0
- package/lib/ui/plugins/prompt/client.js +653 -0
- package/lib/ui/plugins/prompt/icon.png +0 -0
- package/lib/ui/plugins/sessions/client.js +1577 -0
- package/lib/ui/plugins/sessions/icon.png +0 -0
- package/lib/ui/plugins/settings/client.js +5470 -0
- package/lib/ui/plugins/settings/icon.png +0 -0
- package/lib/ui/plugins/skills/client.js +485 -0
- package/lib/ui/plugins/skills/icon.png +0 -0
- package/lib/ui/plugins/status/client.js +1420 -0
- package/lib/ui/plugins/status/icon.png +0 -0
- package/lib/ui/plugins/statusbar/client.js +504 -0
- package/lib/ui/plugins/statusbar/icon.png +0 -0
- package/lib/ui/plugins/tasks/client.js +52 -0
- package/lib/ui/plugins/tasks/icon.png +0 -0
- package/lib/ui/plugins/team/client.js +527 -0
- package/lib/ui/plugins/team/icon.png +0 -0
- package/lib/ui/plugins/terminal/client.js +232 -0
- package/lib/ui/plugins/terminal/icon.png +0 -0
- package/lib/ui/plugins/trace/client.js +1376 -0
- package/lib/ui/plugins/trace/icon.png +0 -0
- package/lib/ui/plugins/transcript/client.js +2661 -0
- package/lib/ui/plugins/transcript/icon.png +0 -0
- package/lib/ui/scoped-slots.d.ts +20 -0
- package/lib/ui/scoped-slots.js +21 -0
- package/lib/ui/sdk/@dsc/ui/index.d.ts +242 -0
- package/lib/ui/sdk/@dsc/ui/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +1973 -0
- package/lib/ui/sdk/@dsc/ui-core/core/diff-text.d.ts +74 -0
- package/lib/ui/sdk/@dsc/ui-core/core/dock-browser.d.ts +137 -0
- package/lib/ui/sdk/@dsc/ui-core/core/dock-ops.d.ts +59 -0
- package/lib/ui/sdk/@dsc/ui-core/core/model-caps.d.ts +83 -0
- package/lib/ui/sdk/@dsc/ui-core/core/native-bridge.d.ts +135 -0
- package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +55 -0
- package/lib/ui/sdk/@dsc/ui-core/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/arrival.d.ts +72 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/frames.d.ts +67 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +59 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +172 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/plugin.d.ts +161 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/scoped-slots.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/services-react.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +63 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/slots-react.d.ts +28 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/slots.d.ts +481 -0
- package/lib/ui/sdk/@dsc/ui-core/ui/store.d.ts +89 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +238 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +163 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/index.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +74 -0
- package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +70 -0
- package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +112 -0
- package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +34 -0
- package/lib/ui/sdk/@dsc/ui-layout/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-layout/review-pane.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +44 -0
- package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +28 -0
- package/lib/ui/sdk/@dsc/ui-layout/update-button.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-primitives/code-file-icon-artwork.d.ts +53 -0
- package/lib/ui/sdk/@dsc/ui-primitives/code-view.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/compat.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-primitives/completion-sound.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-primitives/confirm.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/css.d.ts +47 -0
- package/lib/ui/sdk/@dsc/ui-primitives/diff-rows.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-icons.d.ts +38 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-type-classify.d.ts +66 -0
- package/lib/ui/sdk/@dsc/ui-primitives/file-type-icon.d.ts +57 -0
- package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +24 -0
- package/lib/ui/sdk/@dsc/ui-primitives/hover-delay.d.ts +17 -0
- package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +109 -0
- package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +55 -0
- package/lib/ui/sdk/@dsc/ui-primitives/lang-table.d.ts +10 -0
- package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-primitives/native.d.ts +41 -0
- package/lib/ui/sdk/@dsc/ui-primitives/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +86 -0
- package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +11 -0
- package/lib/ui/sdk/@dsc/ui-primitives/pdf-view.d.ts +13 -0
- package/lib/ui/sdk/@dsc/ui-primitives/plugin-text.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/select.d.ts +35 -0
- package/lib/ui/sdk/@dsc/ui-primitives/table-view.d.ts +23 -0
- package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +22 -0
- package/lib/ui/sdk/@dsc/ui-primitives/time.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/toast.d.ts +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +49 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +64 -0
- package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +121 -0
- package/lib/ui/sdk/@dsc/ui-renderer/hmr.d.ts +43 -0
- package/lib/ui/sdk/@dsc/ui-renderer/index.d.ts +20 -0
- package/lib/ui/sdk/@dsc/ui-renderer/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-slots/index.d.ts +19 -0
- package/lib/ui/sdk/@dsc/ui-slots/package.json +16 -0
- package/lib/ui/sdk/@dsc/ui-slots/slots-react.d.ts +48 -0
- package/lib/ui/sdk/@dsc/ui-slots/slots.d.ts +102 -0
- package/lib/ui/services-react.d.ts +27 -0
- package/lib/ui/services-react.js +32 -0
- package/lib/ui/services.d.ts +63 -0
- package/lib/ui/services.js +121 -0
- package/lib/ui/slots-ink.d.ts +26 -0
- package/lib/ui/slots-ink.js +78 -0
- package/lib/ui/slots-react.d.ts +28 -0
- package/lib/ui/slots-react.js +88 -0
- package/lib/ui/slots.d.ts +481 -0
- package/lib/ui/slots.js +550 -0
- package/lib/ui/store.d.ts +89 -0
- package/lib/ui/store.js +62 -0
- package/lib/ui/tui-plugin-api.d.ts +23 -0
- package/lib/ui/tui-plugin-api.js +23 -0
- package/lib/ui/tui-plugins.d.ts +47 -0
- package/lib/ui/tui-plugins.js +220 -0
- package/package.json +58 -6
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 远程协议的帧流:**宿主级全局 seq** + 全量/增量 diff + 最近 120 帧环形缓冲。
|
|
3
|
+
*
|
|
4
|
+
* 协议 v3 定下的几条(remote-web 与宿主两批共用的契约):
|
|
5
|
+
*
|
|
6
|
+
* 全量帧 `{type:'snapshot', seq, full:true, ...快照字段}`
|
|
7
|
+
* 增量帧 `{type:'delta', seq, full:false, meta, added, updated, removedIds, liveEntries}`
|
|
8
|
+
*
|
|
9
|
+
* 条目按 `id` 认同(正数 id 的已定稿条目):与上一帧相比新出现的进 `added`、
|
|
10
|
+
* `JSON.stringify` 不同的进 `updated`、消失的进 `removedIds`。`liveEntries`(负 id 的直播尾)
|
|
11
|
+
* 每帧全量带——它本来就每几十毫秒整段改写,做 diff 只会更贵。`meta`(除 entries 与
|
|
12
|
+
* liveEntries 之外的所有快照字段)也每帧全量带:它很小,而且 status/surfaces 里的东西
|
|
13
|
+
* 没有稳定身份可以拿来做 diff。
|
|
14
|
+
*
|
|
15
|
+
* 为什么要有全量锚:增量是可以无限长的。客户端一旦漏了一帧(进程被杀、缓冲被覆盖),
|
|
16
|
+
* 靠增量永远补不回来。所以「连续 50 帧 delta」或「距上一全量 30 秒」必须重新发一帧全量,
|
|
17
|
+
* 会话切换(sessionId 变号)立刻发全量——那时条目的 id 空间整体换了一套,diff 没有意义。
|
|
18
|
+
*
|
|
19
|
+
* 这个模块是纯逻辑(不碰 cordis、不碰网络),所以 `scripts/remote-host-test.mjs`
|
|
20
|
+
* 能直接把 diff 规则与锚帧节奏逐格对掉。
|
|
21
|
+
*
|
|
22
|
+
* @module dsc/core/remote/frames
|
|
23
|
+
*/
|
|
24
|
+
/** 环形缓冲留多少帧(重连补帧能补多远)。 */
|
|
25
|
+
export const FRAME_BUFFER_SIZE = 120;
|
|
26
|
+
/** 连续多少帧 delta 之后必须给一帧全量。 */
|
|
27
|
+
export const FULL_ANCHOR_FRAMES = 50;
|
|
28
|
+
/** 距上一帧全量多久必须再给一帧全量。 */
|
|
29
|
+
export const FULL_ANCHOR_MS = 30_000;
|
|
30
|
+
export class RemoteFrameHub {
|
|
31
|
+
now;
|
|
32
|
+
capacity;
|
|
33
|
+
anchorFrames;
|
|
34
|
+
anchorMs;
|
|
35
|
+
/** 全局单调递增的帧号;跨连接、跨重连连续。 */
|
|
36
|
+
seq = 0;
|
|
37
|
+
/** 最近 capacity 帧(seq + 原样文本)。 */
|
|
38
|
+
buffer = [];
|
|
39
|
+
/** 上一帧的条目:id → JSON 文本(用来判「改了没有」)。 */
|
|
40
|
+
prevEntries = new Map();
|
|
41
|
+
/** 上一帧的 id 顺序(removedIds 按它出,顺序稳定好对账)。 */
|
|
42
|
+
prevOrder = [];
|
|
43
|
+
deltasSinceFull = 0;
|
|
44
|
+
lastFullAt = 0;
|
|
45
|
+
lastSessionId = null;
|
|
46
|
+
emitted = false;
|
|
47
|
+
constructor(options = {}) {
|
|
48
|
+
this.now = options.now ?? (() => Date.now());
|
|
49
|
+
this.capacity = options.capacity ?? FRAME_BUFFER_SIZE;
|
|
50
|
+
this.anchorFrames = options.anchorFrames ?? FULL_ANCHOR_FRAMES;
|
|
51
|
+
this.anchorMs = options.anchorMs ?? FULL_ANCHOR_MS;
|
|
52
|
+
}
|
|
53
|
+
/** 到现在为止一共造过几帧(= 最新一帧的 seq)。 */
|
|
54
|
+
get lastSeq() {
|
|
55
|
+
return this.seq;
|
|
56
|
+
}
|
|
57
|
+
/** 缓冲里最老那一帧的 seq;缓冲空时 null。 */
|
|
58
|
+
get oldestSeq() {
|
|
59
|
+
return this.buffer[0]?.seq ?? null;
|
|
60
|
+
}
|
|
61
|
+
/** 缓冲里最新那一帧的 seq;缓冲空时 null。 */
|
|
62
|
+
get newestSeq() {
|
|
63
|
+
const last = this.buffer[this.buffer.length - 1];
|
|
64
|
+
return last === undefined ? null : last.seq;
|
|
65
|
+
}
|
|
66
|
+
/** 缓冲里有几帧。 */
|
|
67
|
+
get buffered() {
|
|
68
|
+
return this.buffer.length;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 造下一帧:决定全量还是增量、算 diff、递增 seq、写环形缓冲。
|
|
72
|
+
*
|
|
73
|
+
* @param snapshot - 当前快照(会话身份 + 条目 + 其余字段)
|
|
74
|
+
* @param forceFull - 强制全量(新连接接不上缓冲、断线期间漏了变化时用)
|
|
75
|
+
*/
|
|
76
|
+
build(snapshot, forceFull = false) {
|
|
77
|
+
const record = snapshot;
|
|
78
|
+
const sessionChanged = this.emitted && this.lastSessionId !== snapshot.sessionId;
|
|
79
|
+
const full = forceFull ||
|
|
80
|
+
!this.emitted ||
|
|
81
|
+
sessionChanged ||
|
|
82
|
+
this.deltasSinceFull >= this.anchorFrames ||
|
|
83
|
+
this.now() - this.lastFullAt >= this.anchorMs;
|
|
84
|
+
// 先把字节造出来、把该记的都算进本地变量,**全都成功之后**再一次性提交状态。
|
|
85
|
+
// 之前是先自增 seq 再序列化:万一序列化抛错(快照里有循环引用之类),这一号就白吃了,
|
|
86
|
+
// 所有客户端下一帧都会看到跳号,各自重开一次流换全量——自愈但白跑一个往返。
|
|
87
|
+
const seq = this.seq + 1;
|
|
88
|
+
const nextEntries = new Map();
|
|
89
|
+
const nextOrder = [];
|
|
90
|
+
let deltasSinceFull = this.deltasSinceFull;
|
|
91
|
+
let lastFullAt = this.lastFullAt;
|
|
92
|
+
let text;
|
|
93
|
+
if (full) {
|
|
94
|
+
text = JSON.stringify({ type: 'snapshot', seq, full: true, ...record });
|
|
95
|
+
for (const entry of snapshot.entries) {
|
|
96
|
+
nextEntries.set(entry.id, JSON.stringify(entry));
|
|
97
|
+
nextOrder.push(entry.id);
|
|
98
|
+
}
|
|
99
|
+
deltasSinceFull = 0;
|
|
100
|
+
lastFullAt = this.now();
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const added = [];
|
|
104
|
+
const updated = [];
|
|
105
|
+
for (const entry of snapshot.entries ?? []) {
|
|
106
|
+
const json = JSON.stringify(entry);
|
|
107
|
+
const before = this.prevEntries.get(entry.id);
|
|
108
|
+
if (before === undefined)
|
|
109
|
+
added.push(entry);
|
|
110
|
+
else if (before !== json)
|
|
111
|
+
updated.push(entry);
|
|
112
|
+
nextEntries.set(entry.id, json);
|
|
113
|
+
nextOrder.push(entry.id);
|
|
114
|
+
}
|
|
115
|
+
const removedIds = [];
|
|
116
|
+
for (const id of this.prevOrder) {
|
|
117
|
+
if (!nextEntries.has(id))
|
|
118
|
+
removedIds.push(id);
|
|
119
|
+
}
|
|
120
|
+
const meta = {};
|
|
121
|
+
for (const [key, value] of Object.entries(record)) {
|
|
122
|
+
if (key === 'entries' || key === 'liveEntries')
|
|
123
|
+
continue;
|
|
124
|
+
meta[key] = value;
|
|
125
|
+
}
|
|
126
|
+
text = JSON.stringify({
|
|
127
|
+
type: 'delta',
|
|
128
|
+
seq,
|
|
129
|
+
full: false,
|
|
130
|
+
meta,
|
|
131
|
+
added,
|
|
132
|
+
updated,
|
|
133
|
+
removedIds,
|
|
134
|
+
liveEntries: snapshot.liveEntries ?? [],
|
|
135
|
+
});
|
|
136
|
+
deltasSinceFull = this.deltasSinceFull + 1;
|
|
137
|
+
}
|
|
138
|
+
// —— 提交:到这里为止没有抛错,状态与帧号一起前进。
|
|
139
|
+
this.seq = seq;
|
|
140
|
+
this.prevEntries = nextEntries;
|
|
141
|
+
this.prevOrder = nextOrder;
|
|
142
|
+
this.deltasSinceFull = deltasSinceFull;
|
|
143
|
+
this.lastFullAt = lastFullAt;
|
|
144
|
+
this.lastSessionId = snapshot.sessionId;
|
|
145
|
+
this.emitted = true;
|
|
146
|
+
this.buffer.push({ seq, text });
|
|
147
|
+
while (this.buffer.length > this.capacity)
|
|
148
|
+
this.buffer.shift();
|
|
149
|
+
return { seq, full, text };
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* 重连补帧。
|
|
153
|
+
*
|
|
154
|
+
* @param after - 客户端已经收到的最后一帧 seq(0 或负数 = 要全量)
|
|
155
|
+
* @returns 该补发的帧文本(按 seq 升序,原样);接不上(要全量)时返回 null
|
|
156
|
+
*/
|
|
157
|
+
resume(after) {
|
|
158
|
+
if (!Number.isFinite(after) || after <= 0)
|
|
159
|
+
return null;
|
|
160
|
+
const oldest = this.oldestSeq;
|
|
161
|
+
const newest = this.newestSeq;
|
|
162
|
+
// 客户端手上的 seq 落在缓冲窗口之外就没法补:比最老还旧 = 已经滚出去了;
|
|
163
|
+
// 比最新还新 = 宿主这一进程重启过(seq 从头来过),客户端的号是上一世的。
|
|
164
|
+
// 两种都退回「hello + 全量帧」——协议里给接不上的客户端准备的就是这条路。
|
|
165
|
+
if (oldest === null || newest === null || after < oldest || after > newest)
|
|
166
|
+
return null;
|
|
167
|
+
const out = [];
|
|
168
|
+
for (const frame of this.buffer) {
|
|
169
|
+
if (frame.seq > after)
|
|
170
|
+
out.push(frame.text);
|
|
171
|
+
}
|
|
172
|
+
return out;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通知 Webhook:把「等你审批」和「一轮跑完」这件事推到用户已有的手机上(Bark / ntfy
|
|
3
|
+
* 这类现成 app),不用装本产品的 PWA,也不用管推送证书。
|
|
4
|
+
*
|
|
5
|
+
* 两种格式由 URL 自己决定(用户只要把地址粘进设置里,不用选模式):
|
|
6
|
+
*
|
|
7
|
+
* 1. **URL 里带 `{title}` / `{body}` / `{url}` 占位符 → GET**(Bark 风格)。
|
|
8
|
+
* 例:`https://api.day.app/你的KEY/{title}/{body}?url={url}`
|
|
9
|
+
* 占位符的值先 `encodeURIComponent` 再替换,所以中文、空格、斜杠都不会把 URL 拆坏。
|
|
10
|
+
* 2. **URL 里没有占位符 → POST JSON**(ntfy 风格)。
|
|
11
|
+
* body:`{"title":"…","body":"…","url":"…"}`。
|
|
12
|
+
* 例:`https://ntfy.sh/你的主题`
|
|
13
|
+
*
|
|
14
|
+
* 规矩两条:超时 5 秒;失败只把原因**返回**给调用方(调用方写一条 notice),这里绝不抛。
|
|
15
|
+
*
|
|
16
|
+
* @module dsc/core/remote/notify
|
|
17
|
+
*/
|
|
18
|
+
/** 一次 Webhook 请求的超时(连不上、对面不响应都按失败算)。 */
|
|
19
|
+
export declare const WEBHOOK_TIMEOUT_MS = 5000;
|
|
20
|
+
/** 三个占位符;出现任意一个就走 GET 替换模式。 */
|
|
21
|
+
export declare const WEBHOOK_PLACEHOLDERS: readonly ["{title}", "{body}", "{url}"];
|
|
22
|
+
/** 一条通知的内容。 */
|
|
23
|
+
export interface WebhookMessage {
|
|
24
|
+
title: string;
|
|
25
|
+
body: string;
|
|
26
|
+
url: string;
|
|
27
|
+
}
|
|
28
|
+
/** 发送结果:ok=false 时 error 是给人看的一句话。 */
|
|
29
|
+
export type WebhookResult = {
|
|
30
|
+
ok: true;
|
|
31
|
+
mode: 'get' | 'post';
|
|
32
|
+
} | {
|
|
33
|
+
ok: false;
|
|
34
|
+
mode: 'get' | 'post';
|
|
35
|
+
error: string;
|
|
36
|
+
};
|
|
37
|
+
/** 地址是不是 http(s)(设置页校验与读档回落共用这一条)。 */
|
|
38
|
+
export declare function isHttpUrl(raw: string): boolean;
|
|
39
|
+
/** URL 里有没有占位符(有 → GET 替换,没有 → POST JSON)。 */
|
|
40
|
+
export declare function webhookHasPlaceholder(raw: string): boolean;
|
|
41
|
+
/** 把占位符换成值之后的最终 URL。 */
|
|
42
|
+
export declare function buildWebhookUrl(raw: string, message: WebhookMessage): string;
|
|
43
|
+
export interface WebhookSendOptions {
|
|
44
|
+
/** 换掉 fetch(自检脚本用得到;默认就是全局 fetch)。 */
|
|
45
|
+
fetchImpl?: typeof fetch;
|
|
46
|
+
timeoutMs?: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* 发一条 Webhook 通知。
|
|
50
|
+
*
|
|
51
|
+
* @param raw - 设置里的地址(调用方负责确认它不是空串)
|
|
52
|
+
* @param message - 标题 / 正文 / 点击后打开的地址
|
|
53
|
+
*/
|
|
54
|
+
export declare function sendWebhook(raw: string, message: WebhookMessage, options?: WebhookSendOptions): Promise<WebhookResult>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 通知 Webhook:把「等你审批」和「一轮跑完」这件事推到用户已有的手机上(Bark / ntfy
|
|
3
|
+
* 这类现成 app),不用装本产品的 PWA,也不用管推送证书。
|
|
4
|
+
*
|
|
5
|
+
* 两种格式由 URL 自己决定(用户只要把地址粘进设置里,不用选模式):
|
|
6
|
+
*
|
|
7
|
+
* 1. **URL 里带 `{title}` / `{body}` / `{url}` 占位符 → GET**(Bark 风格)。
|
|
8
|
+
* 例:`https://api.day.app/你的KEY/{title}/{body}?url={url}`
|
|
9
|
+
* 占位符的值先 `encodeURIComponent` 再替换,所以中文、空格、斜杠都不会把 URL 拆坏。
|
|
10
|
+
* 2. **URL 里没有占位符 → POST JSON**(ntfy 风格)。
|
|
11
|
+
* body:`{"title":"…","body":"…","url":"…"}`。
|
|
12
|
+
* 例:`https://ntfy.sh/你的主题`
|
|
13
|
+
*
|
|
14
|
+
* 规矩两条:超时 5 秒;失败只把原因**返回**给调用方(调用方写一条 notice),这里绝不抛。
|
|
15
|
+
*
|
|
16
|
+
* @module dsc/core/remote/notify
|
|
17
|
+
*/
|
|
18
|
+
/** 一次 Webhook 请求的超时(连不上、对面不响应都按失败算)。 */
|
|
19
|
+
export const WEBHOOK_TIMEOUT_MS = 5_000;
|
|
20
|
+
/** 三个占位符;出现任意一个就走 GET 替换模式。 */
|
|
21
|
+
export const WEBHOOK_PLACEHOLDERS = ['{title}', '{body}', '{url}'];
|
|
22
|
+
/** 地址是不是 http(s)(设置页校验与读档回落共用这一条)。 */
|
|
23
|
+
export function isHttpUrl(raw) {
|
|
24
|
+
try {
|
|
25
|
+
const url = new URL(raw);
|
|
26
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** URL 里有没有占位符(有 → GET 替换,没有 → POST JSON)。 */
|
|
33
|
+
export function webhookHasPlaceholder(raw) {
|
|
34
|
+
return WEBHOOK_PLACEHOLDERS.some((placeholder) => raw.includes(placeholder));
|
|
35
|
+
}
|
|
36
|
+
/** 把占位符换成值之后的最终 URL。 */
|
|
37
|
+
export function buildWebhookUrl(raw, message) {
|
|
38
|
+
return raw
|
|
39
|
+
.replaceAll('{title}', encodeURIComponent(message.title))
|
|
40
|
+
.replaceAll('{body}', encodeURIComponent(message.body))
|
|
41
|
+
.replaceAll('{url}', encodeURIComponent(message.url));
|
|
42
|
+
}
|
|
43
|
+
function errorText(error) {
|
|
44
|
+
return error instanceof Error ? error.message : String(error);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 发一条 Webhook 通知。
|
|
48
|
+
*
|
|
49
|
+
* @param raw - 设置里的地址(调用方负责确认它不是空串)
|
|
50
|
+
* @param message - 标题 / 正文 / 点击后打开的地址
|
|
51
|
+
*/
|
|
52
|
+
export async function sendWebhook(raw, message, options = {}) {
|
|
53
|
+
const target = raw.trim();
|
|
54
|
+
const mode = webhookHasPlaceholder(target) ? 'get' : 'post';
|
|
55
|
+
if (target === '')
|
|
56
|
+
return { ok: false, mode, error: '通知 Webhook 是空的' };
|
|
57
|
+
if (!isHttpUrl(target))
|
|
58
|
+
return { ok: false, mode, error: '通知 Webhook 不是 http(s) 地址' };
|
|
59
|
+
const doFetch = options.fetchImpl ?? fetch;
|
|
60
|
+
const signal = AbortSignal.timeout(options.timeoutMs ?? WEBHOOK_TIMEOUT_MS);
|
|
61
|
+
try {
|
|
62
|
+
const response = mode === 'get'
|
|
63
|
+
? await doFetch(buildWebhookUrl(target, message), { method: 'GET', signal })
|
|
64
|
+
: await doFetch(target, {
|
|
65
|
+
method: 'POST',
|
|
66
|
+
headers: { 'content-type': 'application/json' },
|
|
67
|
+
body: JSON.stringify({ title: message.title, body: message.body, url: message.url }),
|
|
68
|
+
signal,
|
|
69
|
+
});
|
|
70
|
+
if (!response.ok)
|
|
71
|
+
return { ok: false, mode, error: `对面回了 HTTP ${String(response.status)}` };
|
|
72
|
+
return { ok: true, mode };
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
return { ok: false, mode, error: errorText(error) };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** `.owner.json` 的内容。 */
|
|
2
|
+
export interface OwnerInfo {
|
|
3
|
+
pid: number;
|
|
4
|
+
/** 本进程启动时的墙钟时刻(`now - uptime`),锁的主人是不是「原来那个进程」靠它分辨。 */
|
|
5
|
+
birth: number;
|
|
6
|
+
/** 主人正在听的端口(休眠方只用来显示「谁占着、在哪个口」)。 */
|
|
7
|
+
port: number;
|
|
8
|
+
/** 最后一次抢/刷主控位的时刻。 */
|
|
9
|
+
at: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class RemoteOwnerLock {
|
|
12
|
+
private readonly files;
|
|
13
|
+
private readonly now;
|
|
14
|
+
private readonly birth;
|
|
15
|
+
private held;
|
|
16
|
+
constructor(options?: {
|
|
17
|
+
dir?: string;
|
|
18
|
+
now?: () => number;
|
|
19
|
+
});
|
|
20
|
+
/** 本进程现在握着主控位吗。 */
|
|
21
|
+
get mine(): boolean;
|
|
22
|
+
/** 看一眼主控位被谁拿着(没有返回 null)。 */
|
|
23
|
+
peek(): OwnerInfo | null;
|
|
24
|
+
/**
|
|
25
|
+
* 抢主控位。
|
|
26
|
+
* @returns true = 现在归本进程(可以起服务了);false = 别的活进程拿着,本进程休眠
|
|
27
|
+
*/
|
|
28
|
+
tryAcquire(port: number): boolean;
|
|
29
|
+
/** 让出主控位(只删自己的那份;别人的文件一个字节都不动)。 */
|
|
30
|
+
release(): void;
|
|
31
|
+
private write;
|
|
32
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 远程控制的主控位:同一台机器上可能有不止一个 Pneuma 进程(桌面端一个、终端一个),
|
|
3
|
+
* 而一个端口只能被一个进程听。谁先拿到 `~/.dsc/remote/.owner.json` 谁负责伺服,
|
|
4
|
+
* 其余的进程保持休眠(不监听、不起服务),每 30 秒回头看一眼主控位空出来没有。
|
|
5
|
+
*
|
|
6
|
+
* 判据与调度锁同款:`pid + 进程启动时刻指纹`。只看 pid 会被系统回收骗过去——
|
|
7
|
+
* 前任进程死了、pid 被一个无关进程占了,我们就会一直让位;加上启动指纹就不会。
|
|
8
|
+
*
|
|
9
|
+
* @module dsc/core/remote/owner
|
|
10
|
+
*/
|
|
11
|
+
import { isProcessAlive } from '../schedule/runner.js';
|
|
12
|
+
import { readJsonFile, remoteFiles, removeFile, writeJsonFile } from './store.js';
|
|
13
|
+
export class RemoteOwnerLock {
|
|
14
|
+
files;
|
|
15
|
+
now;
|
|
16
|
+
birth;
|
|
17
|
+
held = false;
|
|
18
|
+
constructor(options = {}) {
|
|
19
|
+
this.files = remoteFiles(options.dir);
|
|
20
|
+
this.now = options.now ?? (() => Date.now());
|
|
21
|
+
this.birth = Math.round(this.now() - process.uptime() * 1_000);
|
|
22
|
+
}
|
|
23
|
+
/** 本进程现在握着主控位吗。 */
|
|
24
|
+
get mine() {
|
|
25
|
+
return this.held;
|
|
26
|
+
}
|
|
27
|
+
/** 看一眼主控位被谁拿着(没有返回 null)。 */
|
|
28
|
+
peek() {
|
|
29
|
+
const doc = readJsonFile(this.files.owner);
|
|
30
|
+
if (doc === null)
|
|
31
|
+
return null;
|
|
32
|
+
if (typeof doc['pid'] !== 'number' || typeof doc['birth'] !== 'number')
|
|
33
|
+
return null;
|
|
34
|
+
return {
|
|
35
|
+
pid: Math.round(doc['pid']),
|
|
36
|
+
birth: Math.round(doc['birth']),
|
|
37
|
+
port: typeof doc['port'] === 'number' ? Math.round(doc['port']) : 0,
|
|
38
|
+
at: typeof doc['at'] === 'number' ? doc['at'] : 0,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 抢主控位。
|
|
43
|
+
* @returns true = 现在归本进程(可以起服务了);false = 别的活进程拿着,本进程休眠
|
|
44
|
+
*/
|
|
45
|
+
tryAcquire(port) {
|
|
46
|
+
const info = this.peek();
|
|
47
|
+
if (info === null) {
|
|
48
|
+
this.write(port);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
if (info.pid === process.pid && info.birth === this.birth) {
|
|
52
|
+
// 本来就是自己的(可能是同一进程里第二次起服务):刷新端口
|
|
53
|
+
this.write(port);
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
if (isProcessAlive(info.pid)) {
|
|
57
|
+
this.held = false;
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
// 前任已经不在(或 pid 被复用了):接管
|
|
61
|
+
this.write(port);
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
/** 让出主控位(只删自己的那份;别人的文件一个字节都不动)。 */
|
|
65
|
+
release() {
|
|
66
|
+
const info = this.peek();
|
|
67
|
+
if (info !== null && info.pid === process.pid && info.birth === this.birth)
|
|
68
|
+
removeFile(this.files.owner);
|
|
69
|
+
this.held = false;
|
|
70
|
+
}
|
|
71
|
+
write(port) {
|
|
72
|
+
writeJsonFile(this.files.owner, { pid: process.pid, birth: this.birth, port, at: this.now() });
|
|
73
|
+
this.held = true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 配对码字母表:32 个字符,去掉 O/0/I/1/l 这些「看截图分不清」的。
|
|
3
|
+
* 大写 A–Z 去掉 I、O 剩 24 个,数字 2–9 八个,正好 32——所以每位的熵是 5 bit。
|
|
4
|
+
*/
|
|
5
|
+
export declare const CODE_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
6
|
+
/** 码长度(与 remote-web 的输入框长度一致,改这里要两边一起改)。 */
|
|
7
|
+
export declare const CODE_LENGTH = 8;
|
|
8
|
+
/** 码有效期半小时(30 分钟)。 */
|
|
9
|
+
export declare const CODE_TTL_MS = 1800000;
|
|
10
|
+
/** 同一张码允许连错几次。 */
|
|
11
|
+
export declare const MAX_CODE_ATTEMPTS = 5;
|
|
12
|
+
/** 连错超限后锁多久(与码的有效期无关,锁就是 1 小时)。 */
|
|
13
|
+
export declare const CODE_LOCK_MS = 3600000;
|
|
14
|
+
/** pending.json 里最多留几条记录(过期的会被清掉,正常只有一张活的)。 */
|
|
15
|
+
export declare const MAX_PENDING_RECORDS = 5;
|
|
16
|
+
/** 一台已配对的设备。 */
|
|
17
|
+
export interface DeviceRecord {
|
|
18
|
+
deviceId: string;
|
|
19
|
+
/** `sha256(token)` 的十六进制;token 本体不落盘。 */
|
|
20
|
+
tokenHash: string;
|
|
21
|
+
name: string;
|
|
22
|
+
createdAt: number;
|
|
23
|
+
lastSeenAt: number;
|
|
24
|
+
}
|
|
25
|
+
/** 配对结果:成功给 token,失败给 HTTP 状态码与给用户看的一句话。 */
|
|
26
|
+
export type PairOutcome = {
|
|
27
|
+
ok: true;
|
|
28
|
+
token: string;
|
|
29
|
+
deviceId: string;
|
|
30
|
+
name: string;
|
|
31
|
+
} | {
|
|
32
|
+
ok: false;
|
|
33
|
+
status: number;
|
|
34
|
+
error: string;
|
|
35
|
+
};
|
|
36
|
+
export interface PairingOptions {
|
|
37
|
+
/** 数据目录(默认 `~/.dsc/remote`;自检脚本换成临时目录)。 */
|
|
38
|
+
dir?: string;
|
|
39
|
+
/** 取时刻(自检注入假钟,测过期)。 */
|
|
40
|
+
now?: () => number;
|
|
41
|
+
}
|
|
42
|
+
/** 用户输进来的码先洗一遍:去掉空格与连字符、转大写(界面也做了,这里兜底)。 */
|
|
43
|
+
export declare function normalizeCode(input: string): string;
|
|
44
|
+
export declare class RemotePairing {
|
|
45
|
+
private readonly files;
|
|
46
|
+
private readonly now;
|
|
47
|
+
/** 上次给某台设备刷 lastSeenAt 的时刻(每台一分钟最多写一次盘,别为每次重连都写文件)。 */
|
|
48
|
+
private readonly lastSeenWritten;
|
|
49
|
+
constructor(options?: PairingOptions);
|
|
50
|
+
private loadCodes;
|
|
51
|
+
private saveCodes;
|
|
52
|
+
/** 还没过期、也没被锁的码有几张(设置页显示状态用)。 */
|
|
53
|
+
liveCodeCount(): number;
|
|
54
|
+
/**
|
|
55
|
+
* 发一张新码。
|
|
56
|
+
*
|
|
57
|
+
* @param options.replace - true = 先作废还没用掉的活码再发新的(「连接手机」弹窗与它
|
|
58
|
+
* 里面的「重新生成」走这条:明文码不落盘,旧码也重画不出来,界面要一直看得见一张码,
|
|
59
|
+
* 就只能换一张新的)。不传时保持一次一张的老语义——已经有一张没用过且没被锁的码时
|
|
60
|
+
* 返回 null,同一个屏幕上同时飘着两张有效码只会让人输错。
|
|
61
|
+
* @returns 新码与过期时刻;不传 replace 且已有活码时返回 null。
|
|
62
|
+
* 被锁的码不算「没用过」:它已经废了,用户当然可以再要一张。
|
|
63
|
+
*/
|
|
64
|
+
issueCode(options?: {
|
|
65
|
+
replace?: boolean;
|
|
66
|
+
}): {
|
|
67
|
+
code: string;
|
|
68
|
+
expiresAt: number;
|
|
69
|
+
} | null;
|
|
70
|
+
/**
|
|
71
|
+
* 用码换 token。失败按状态码分三类:
|
|
72
|
+
* 401 没有可用的码 / 码不对(不区分是哪张,免得探测出「这个码存在但错了」)
|
|
73
|
+
* 429 这张码被锁着(输错太多次)
|
|
74
|
+
*/
|
|
75
|
+
verifyCode(input: string, name: string): PairOutcome;
|
|
76
|
+
private loadDevices;
|
|
77
|
+
private saveDevices;
|
|
78
|
+
/** 验设备 token;认不出返回 null。认得出就顺手刷一次 lastSeenAt(每台一分钟最多写一次盘)。 */
|
|
79
|
+
verifyToken(token: string): DeviceRecord | null;
|
|
80
|
+
/**
|
|
81
|
+
* 吊销一个 token。
|
|
82
|
+
* @returns 被吊销的那台设备(调用方拿 deviceId 去断开它已经建好的连接);
|
|
83
|
+
* 本来就不认这个 token 时返回 null。
|
|
84
|
+
*/
|
|
85
|
+
revoke(token: string): DeviceRecord | null;
|
|
86
|
+
/** 吊销全部设备,返回吊销了几台。 */
|
|
87
|
+
revokeAll(): number;
|
|
88
|
+
/**
|
|
89
|
+
* 按 deviceId 吊销一台设备(设置页里每台设备一个「吊销」按钮走这条)。
|
|
90
|
+
*
|
|
91
|
+
* 为什么不是只留 `revoke(token)`:设置页手上只有 deviceId(token 本体从不落盘,
|
|
92
|
+
* 界面上也看不到),所以「逐台吊销」必须能按 identity 定位,而不是按凭据定位。
|
|
93
|
+
*
|
|
94
|
+
* @returns 被吊销的那台设备;本来就不在清单里时 null
|
|
95
|
+
*/
|
|
96
|
+
revokeDevice(deviceId: string): DeviceRecord | null;
|
|
97
|
+
/** 已配对设备清单(给设置分区显示;不含 token 哈希)。 */
|
|
98
|
+
devices(): Array<{
|
|
99
|
+
deviceId: string;
|
|
100
|
+
name: string;
|
|
101
|
+
createdAt: number;
|
|
102
|
+
lastSeenAt: number;
|
|
103
|
+
}>;
|
|
104
|
+
}
|