@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,316 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 共享任务板与信箱:队友之间协调用的两个明文文件。
|
|
3
|
+
*
|
|
4
|
+
* dsh 把协调状态存在 Lead 的会话日志里(它有会话事件体系);dsc 没有那套东西,
|
|
5
|
+
* 所以这里直接落两个文件,你能用编辑器双击打开看:
|
|
6
|
+
*
|
|
7
|
+
* - `~/.dsc/team/boards/<会话 id>.json` —— 任务板:三态 + 单调 revision + CAS 抢单 +
|
|
8
|
+
* 依赖图 + 写作用域告警。板子按会话各一块(对照 dsh 团队挂在 lead 会话之下):
|
|
9
|
+
* 切到别的会话就是另一块板,互不见。写作用域只是提醒,不是锁:两个任务的作用域
|
|
10
|
+
* 重叠时照样允许开工,重叠会被记进 warnings,最后由 Lead 看 diff 裁决。
|
|
11
|
+
* - `~/.dsc/team/inbox/<队友名>.jsonl` —— 传话台账:要给队友的话先追加一条文件,
|
|
12
|
+
* 再交给它的循环。队友正在干活时,这条话排在它当前回合之后被看到。
|
|
13
|
+
*
|
|
14
|
+
* @module dsc/core/team-board
|
|
15
|
+
*/
|
|
16
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
17
|
+
import { join } from 'node:path';
|
|
18
|
+
import { dscPath } from './path-policy.js';
|
|
19
|
+
/** 团队目录(任务板 + 信箱)。 */
|
|
20
|
+
export const TEAM_ROOT = dscPath('team');
|
|
21
|
+
/** 任务板目录(每个会话一块板)。 */
|
|
22
|
+
export const BOARDS_DIR = join(TEAM_ROOT, 'boards');
|
|
23
|
+
/** 信箱目录(每个队友一个 jsonl)。 */
|
|
24
|
+
export const INBOX_DIR = join(TEAM_ROOT, 'inbox');
|
|
25
|
+
/**
|
|
26
|
+
* 队友干完活投给父会话的那条汇报,正文固定以这个开头。
|
|
27
|
+
*
|
|
28
|
+
* 为什么要有它、而不是两处各写一份字面量:adapter 靠这个前缀把这条消息认出来
|
|
29
|
+
* (跟压缩摘要的 `SUMMARY_BANNER` 同一个套路),认出后给条目打 `internal` 标记,
|
|
30
|
+
* 界面就不再把它当「人打的字」渲染(对照 dsh 的 turn-trigger 节点:非人发起的
|
|
31
|
+
* 唤醒消息渲染成一行可展开的「子任务状态更新」,不是用户气泡)。
|
|
32
|
+
* 插件与 adapter 共用同一个常量,改一处漏一处就会出现「汇报又原样冒出来」。
|
|
33
|
+
*/
|
|
34
|
+
export const TEAMMATE_REPORT_OPEN = '<teammate-report ';
|
|
35
|
+
/**
|
|
36
|
+
* 审查队友收工投给发起会话的那条 findings,正文固定以这个开头。
|
|
37
|
+
*
|
|
38
|
+
* 与 {@link TEAMMATE_REPORT_OPEN} 同一个套路、同一份理由:adapter 靠前缀认出它、
|
|
39
|
+
* 给条目打 `internal` 标记,界面就不把整段 `<review-findings …>` 当「人打的字」
|
|
40
|
+
* 原样渲染(那是审查队友的机器汇报,不是用户发言)。插件与 adapter 共用这一份字面量。
|
|
41
|
+
*/
|
|
42
|
+
export const REVIEW_FINDINGS_OPEN = '<review-findings ';
|
|
43
|
+
const STATUSES = ['pending', 'in_progress', 'completed'];
|
|
44
|
+
/** 任务板上限,防一个模型一口气写 500 条把文件灌爆。 */
|
|
45
|
+
const MAX_TASKS = 256;
|
|
46
|
+
/** 信箱单条消息长度上限。 */
|
|
47
|
+
const MAX_INBOX_CHARS = 8000;
|
|
48
|
+
function emptyBoard() {
|
|
49
|
+
return { version: 1, revision: 0, tasks: [] };
|
|
50
|
+
}
|
|
51
|
+
/** 一个会话的任务板文件路径(会话 id 只出现在 uuid 里,仍按文件名安全字符再滤一遍)。 */
|
|
52
|
+
export function boardFile(sessionId) {
|
|
53
|
+
const safe = sessionId.replace(/[^\w-]/g, '_');
|
|
54
|
+
return join(BOARDS_DIR, `${safe === '' ? 'unknown' : safe}.json`);
|
|
55
|
+
}
|
|
56
|
+
/** 读一块任务板(文件缺失或损坏都退回空板,绝不因为板子坏了起不来)。 */
|
|
57
|
+
export function readBoard(sessionId) {
|
|
58
|
+
const file = boardFile(sessionId);
|
|
59
|
+
try {
|
|
60
|
+
if (!existsSync(file))
|
|
61
|
+
return emptyBoard();
|
|
62
|
+
const doc = JSON.parse(readFileSync(file, 'utf8'));
|
|
63
|
+
const revision = typeof doc.revision === 'number' && doc.revision >= 0 ? Math.floor(doc.revision) : 0;
|
|
64
|
+
const rawTasks = Array.isArray(doc.tasks) ? doc.tasks : [];
|
|
65
|
+
const tasks = [];
|
|
66
|
+
for (const raw of rawTasks) {
|
|
67
|
+
if (raw === null || typeof raw !== 'object')
|
|
68
|
+
continue;
|
|
69
|
+
const item = raw;
|
|
70
|
+
const id = String(item.id ?? '');
|
|
71
|
+
if (id === '')
|
|
72
|
+
continue;
|
|
73
|
+
const status = STATUSES.includes(item.status) ? item.status : 'pending';
|
|
74
|
+
tasks.push({
|
|
75
|
+
id,
|
|
76
|
+
subject: String(item.subject ?? ''),
|
|
77
|
+
description: String(item.description ?? ''),
|
|
78
|
+
status,
|
|
79
|
+
owner: typeof item.owner === 'string' && item.owner !== '' ? item.owner : null,
|
|
80
|
+
blockedBy: Array.isArray(item.blockedBy)
|
|
81
|
+
? [...new Set(item.blockedBy.filter((dep) => typeof dep === 'string' && dep !== ''))]
|
|
82
|
+
: [],
|
|
83
|
+
writeScopes: Array.isArray(item.writeScopes)
|
|
84
|
+
? item.writeScopes.filter((scope) => typeof scope === 'string' && scope !== '')
|
|
85
|
+
: [],
|
|
86
|
+
createdAt: typeof item.createdAt === 'number' ? item.createdAt : Date.now(),
|
|
87
|
+
updatedAt: typeof item.updatedAt === 'number' ? item.updatedAt : Date.now(),
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
return { version: 1, revision, tasks };
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return emptyBoard();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function writeBoard(sessionId, board) {
|
|
97
|
+
mkdirSync(BOARDS_DIR, { recursive: true });
|
|
98
|
+
writeFileSync(boardFile(sessionId), `${JSON.stringify(board, null, 2)}\n`, 'utf8');
|
|
99
|
+
}
|
|
100
|
+
/** 路径前缀规范化:统一成正斜杠、去掉首尾斜杠,空串表示「整个工作目录」。 */
|
|
101
|
+
export function normalizeScope(scope) {
|
|
102
|
+
return scope.replace(/\\/g, '/').replace(/^\.?\//, '').replace(/\/+$/, '');
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* 这些作用域会不会碰到别人正在改的地方。
|
|
106
|
+
* @param excludeId - 跟本任务自己比没有意义,跳过这个 id。
|
|
107
|
+
*/
|
|
108
|
+
export function scopeWarnings(board, scopes, excludeId) {
|
|
109
|
+
const mine = scopes.map(normalizeScope);
|
|
110
|
+
if (mine.length === 0)
|
|
111
|
+
return [];
|
|
112
|
+
const warnings = [];
|
|
113
|
+
for (const other of board.tasks) {
|
|
114
|
+
if (other.id === excludeId || other.status === 'completed')
|
|
115
|
+
continue;
|
|
116
|
+
for (const raw of other.writeScopes) {
|
|
117
|
+
const theirs = normalizeScope(raw);
|
|
118
|
+
for (const ours of mine) {
|
|
119
|
+
const overlaps = ours === theirs || ours === '' || theirs === '' || ours.startsWith(`${theirs}/`) || theirs.startsWith(`${ours}/`);
|
|
120
|
+
if (overlaps) {
|
|
121
|
+
warnings.push(`${other.id}(${other.owner ?? '未认领'},${other.status})的作用域 ${theirs || '<整个工作目录>'} 与本次的 ${ours || '<整个工作目录>'} 重叠`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return [...new Set(warnings)];
|
|
127
|
+
}
|
|
128
|
+
/** 依赖图检查:禁自环、禁指向不存在的任务、禁成环。 */
|
|
129
|
+
function assertDependencies(board, id, deps) {
|
|
130
|
+
for (const dep of deps) {
|
|
131
|
+
if (dep === id)
|
|
132
|
+
throw new Error(`任务 ${id} 不能依赖自己`);
|
|
133
|
+
if (!board.tasks.some((task) => task.id === dep)) {
|
|
134
|
+
throw new Error(`依赖的任务 ${dep} 不存在(先 team_task list 确认 id)`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// 沿依赖链往下走,回到自己就是环
|
|
138
|
+
const seen = new Set();
|
|
139
|
+
const walk = (at) => {
|
|
140
|
+
if (at === id)
|
|
141
|
+
throw new Error(`依赖会成环:${id} → … → ${id}`);
|
|
142
|
+
if (seen.has(at))
|
|
143
|
+
return;
|
|
144
|
+
seen.add(at);
|
|
145
|
+
const task = board.tasks.find((candidate) => candidate.id === at);
|
|
146
|
+
for (const dep of task?.blockedBy ?? [])
|
|
147
|
+
walk(dep);
|
|
148
|
+
};
|
|
149
|
+
for (const dep of deps)
|
|
150
|
+
walk(dep);
|
|
151
|
+
}
|
|
152
|
+
/** 一个任务现在能不能开工(pending 且所有依赖都已 completed)。 */
|
|
153
|
+
export function isReady(board, task) {
|
|
154
|
+
if (task.status !== 'pending' || task.owner !== null)
|
|
155
|
+
return false;
|
|
156
|
+
return task.blockedBy.every((dep) => board.tasks.find((task2) => task2.id === dep)?.status === 'completed');
|
|
157
|
+
}
|
|
158
|
+
/** 下一个任务 id(t1、t2…单调递增,删过的号不回收)。 */
|
|
159
|
+
function nextTaskId(board) {
|
|
160
|
+
let max = 0;
|
|
161
|
+
for (const task of board.tasks) {
|
|
162
|
+
const digits = Number.parseInt(task.id.replace(/^t/i, ''), 10);
|
|
163
|
+
if (Number.isFinite(digits) && digits > max)
|
|
164
|
+
max = digits;
|
|
165
|
+
}
|
|
166
|
+
return `t${max + 1}`;
|
|
167
|
+
}
|
|
168
|
+
/** 新建任务(不需要 CAS:新增不会覆盖别人的改动)。带上写回后的板,紧接着要认领它才不用再读一遍。 */
|
|
169
|
+
export function boardCreate(sessionId, input) {
|
|
170
|
+
const board = readBoard(sessionId);
|
|
171
|
+
if (board.tasks.length >= MAX_TASKS) {
|
|
172
|
+
throw new Error(`任务板已有 ${board.tasks.length} 条,达到上限 ${MAX_TASKS};先清掉已完成的任务`);
|
|
173
|
+
}
|
|
174
|
+
const subject = input.subject.replace(/\s+/g, ' ').trim();
|
|
175
|
+
if (subject === '')
|
|
176
|
+
throw new Error('任务标题不能为空');
|
|
177
|
+
const now = Date.now();
|
|
178
|
+
const task = {
|
|
179
|
+
id: nextTaskId(board),
|
|
180
|
+
subject: subject.slice(0, 120),
|
|
181
|
+
description: (input.description ?? '').trim().slice(0, 2000),
|
|
182
|
+
status: 'pending',
|
|
183
|
+
owner: input.owner !== undefined && input.owner !== '' ? input.owner : null,
|
|
184
|
+
blockedBy: [...new Set(input.blockedBy ?? [])].filter((dep) => dep !== ''),
|
|
185
|
+
writeScopes: [...new Set((input.writeScopes ?? []).map(normalizeScope))].filter((scope) => scope !== ''),
|
|
186
|
+
createdAt: now,
|
|
187
|
+
updatedAt: now,
|
|
188
|
+
};
|
|
189
|
+
assertDependencies(board, task.id, task.blockedBy);
|
|
190
|
+
const warnings = scopeWarnings(board, task.writeScopes, task.id);
|
|
191
|
+
board.tasks.push(task);
|
|
192
|
+
board.revision += 1;
|
|
193
|
+
writeBoard(sessionId, board);
|
|
194
|
+
return { task, warnings, board };
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* 改一条任务。调用方必须带上自己看到的 board revision,
|
|
198
|
+
* 不匹配就抛错——两个队友同时抢同一个任务是常态,先到先得靠的就是这一条。
|
|
199
|
+
* @param payload.owner - claim 时填认领者名字。
|
|
200
|
+
* @param payload.blockedBy - set_dependencies 时填新的依赖清单。
|
|
201
|
+
*/
|
|
202
|
+
export function boardUpdate(sessionId, id, expectedRevision, action, payload) {
|
|
203
|
+
const board = readBoard(sessionId);
|
|
204
|
+
if (expectedRevision !== board.revision) {
|
|
205
|
+
throw new Error(`任务板在你读它之后被别人改过了(你报的是第 ${expectedRevision} 版,现在第 ${board.revision} 版)。先 team_task list 再决定`);
|
|
206
|
+
}
|
|
207
|
+
const index = board.tasks.findIndex((task) => task.id === id);
|
|
208
|
+
if (index < 0)
|
|
209
|
+
throw new Error(`任务板上没有 ${id}`);
|
|
210
|
+
const task = { ...board.tasks[index] };
|
|
211
|
+
switch (action) {
|
|
212
|
+
case 'claim': {
|
|
213
|
+
const owner = (payload?.owner ?? '').trim();
|
|
214
|
+
if (owner === '')
|
|
215
|
+
throw new Error('claim 要带上认领人(队友名)');
|
|
216
|
+
if (task.status === 'completed')
|
|
217
|
+
throw new Error(`${id} 已经完成了,不用再认领`);
|
|
218
|
+
if (task.owner !== null && task.owner !== owner) {
|
|
219
|
+
throw new Error(`${id} 已经被 ${task.owner} 认领了,换一个任务或先 team_task list`);
|
|
220
|
+
}
|
|
221
|
+
const pendingDeps = task.blockedBy.filter((dep) => board.tasks.find((candidate) => candidate.id === dep)?.status !== 'completed');
|
|
222
|
+
if (pendingDeps.length > 0) {
|
|
223
|
+
throw new Error(`${id} 还在等这些依赖完成:${pendingDeps.join('、')}`);
|
|
224
|
+
}
|
|
225
|
+
task.owner = owner;
|
|
226
|
+
task.status = 'in_progress';
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
case 'release':
|
|
230
|
+
if (task.status === 'completed')
|
|
231
|
+
throw new Error(`${id} 已经完成了,release 没有意义`);
|
|
232
|
+
task.owner = null;
|
|
233
|
+
task.status = 'pending';
|
|
234
|
+
break;
|
|
235
|
+
case 'complete':
|
|
236
|
+
if (task.status === 'pending')
|
|
237
|
+
throw new Error(`${id} 还没人认领,先 claim 再 complete`);
|
|
238
|
+
task.status = 'completed';
|
|
239
|
+
break;
|
|
240
|
+
case 'reopen':
|
|
241
|
+
task.status = 'pending';
|
|
242
|
+
task.owner = null;
|
|
243
|
+
break;
|
|
244
|
+
case 'set_dependencies': {
|
|
245
|
+
const deps = [...new Set(payload?.blockedBy ?? [])].filter((dep) => dep !== '');
|
|
246
|
+
assertDependencies(board, id, deps);
|
|
247
|
+
task.blockedBy = deps;
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
250
|
+
case 'delete': {
|
|
251
|
+
const dependents = board.tasks.filter((candidate) => candidate.id !== id && candidate.blockedBy.includes(id));
|
|
252
|
+
if (dependents.length > 0) {
|
|
253
|
+
throw new Error(`${dependents.map((entry) => entry.id).join('、')} 还依赖 ${id},先改掉它们的依赖`);
|
|
254
|
+
}
|
|
255
|
+
board.tasks.splice(index, 1);
|
|
256
|
+
board.revision += 1;
|
|
257
|
+
writeBoard(sessionId, board);
|
|
258
|
+
return { board, task };
|
|
259
|
+
}
|
|
260
|
+
default:
|
|
261
|
+
throw new Error(`未知动作 ${action}`);
|
|
262
|
+
}
|
|
263
|
+
task.updatedAt = Date.now();
|
|
264
|
+
board.tasks[index] = task;
|
|
265
|
+
board.revision += 1;
|
|
266
|
+
writeBoard(sessionId, board);
|
|
267
|
+
return { board, task };
|
|
268
|
+
}
|
|
269
|
+
/** 把一块任务板清空(设置页「清空任务板」按钮用;不动队友的运行记录)。 */
|
|
270
|
+
export function resetBoard(sessionId) {
|
|
271
|
+
const board = readBoard(sessionId);
|
|
272
|
+
const count = board.tasks.length;
|
|
273
|
+
board.tasks = [];
|
|
274
|
+
board.revision += 1;
|
|
275
|
+
writeBoard(sessionId, board);
|
|
276
|
+
return count;
|
|
277
|
+
}
|
|
278
|
+
/** 一个队友的信箱文件路径。 */
|
|
279
|
+
function inboxFile(teammate) {
|
|
280
|
+
return join(INBOX_DIR, `${teammate.replace(/[^\w-]/g, '_')}.jsonl`);
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* 往传话台账追加一条(调用方负责紧接着把它投给那个队友的循环)。
|
|
284
|
+
* @throws 内容为空,或超过单条长度上限时抛错。
|
|
285
|
+
*/
|
|
286
|
+
export function inboxAppend(teammate, text) {
|
|
287
|
+
const body = text.trim();
|
|
288
|
+
if (body === '')
|
|
289
|
+
throw new Error('要传的话不能是空的');
|
|
290
|
+
if (body.length > MAX_INBOX_CHARS)
|
|
291
|
+
throw new Error(`一条消息最长 ${MAX_INBOX_CHARS} 字,这条有 ${body.length} 字`);
|
|
292
|
+
mkdirSync(INBOX_DIR, { recursive: true });
|
|
293
|
+
appendFileSync(inboxFile(teammate), `${JSON.stringify({ at: Date.now(), text: body })}\n`, 'utf8');
|
|
294
|
+
}
|
|
295
|
+
/** 读一个队友信箱里的全部消息(按写入顺序)。 */
|
|
296
|
+
export function inboxRead(teammate) {
|
|
297
|
+
try {
|
|
298
|
+
if (!existsSync(inboxFile(teammate)))
|
|
299
|
+
return [];
|
|
300
|
+
return readFileSync(inboxFile(teammate), 'utf8')
|
|
301
|
+
.split(/\r?\n/)
|
|
302
|
+
.filter((line) => line !== '')
|
|
303
|
+
.map((line) => {
|
|
304
|
+
try {
|
|
305
|
+
return String(JSON.parse(line).text ?? '');
|
|
306
|
+
}
|
|
307
|
+
catch {
|
|
308
|
+
return line;
|
|
309
|
+
}
|
|
310
|
+
})
|
|
311
|
+
.filter((text) => text !== '');
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
return [];
|
|
315
|
+
}
|
|
316
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 输出速度(tok/s)与首字延迟的口径:唯一原件,界面与测试都从这里取。
|
|
3
|
+
*
|
|
4
|
+
* 算法照 dsh 的 sessionStats 投影(packages/session/session-stats/src/projection.ts:130-170):
|
|
5
|
+
* - 首字延迟 = 每次请求「发出 → 第一口输出」的墙钟,只在真拿到第一口的请求上累计;
|
|
6
|
+
* - 分子分母**成对**取:同一次请求既要有第一口输出的时刻、又要有服务端上报的输出 token,
|
|
7
|
+
* 才同时算进 decodeTokens 与 decodeMs——不能拿一部分请求的时间去除另一部分请求的 token;
|
|
8
|
+
* - 分母是**纯解码时间**(第一口输出 → 定稿),首字等待、工具执行、等下一个请求的空转
|
|
9
|
+
* 都不在里面;整个会话累计,不是「本轮」。
|
|
10
|
+
*
|
|
11
|
+
* 为什么单开一个文件:桌面状态栏、终端界面、测试必须同口径,谁也不许自己再写一遍除法。
|
|
12
|
+
* 渲染层经 `@dsc/runtime/core/throughput.js` 转出口取用(desktop/src/renderer/token-estimate.ts)。
|
|
13
|
+
*
|
|
14
|
+
* @module dsc/core/throughput
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* 一次会话(或一次测量窗口)的墙钟累计与样本数。
|
|
18
|
+
*
|
|
19
|
+
* 全部只累计「有真值」的那部分:缺样本的请求不占分子也不占分母(宁缺不假)。
|
|
20
|
+
*/
|
|
21
|
+
export interface ThroughputTotals {
|
|
22
|
+
/** 首字延迟的样本数:拿到第一口输出的请求数。 */
|
|
23
|
+
ttftSteps: number;
|
|
24
|
+
/** 这些请求「发出 → 第一口输出」的累计毫秒。 */
|
|
25
|
+
ttftMs: number;
|
|
26
|
+
/** 已定稿请求「发出 → 定稿」的累计毫秒(含内部重试与首字等待)。 */
|
|
27
|
+
llmMs: number;
|
|
28
|
+
/** 解码期的累计毫秒(第一口输出 → 定稿),分母样本与 decodeTokens 同一批请求。 */
|
|
29
|
+
decodeMs: number;
|
|
30
|
+
/** 与 decodeMs 同一批请求的服务端输出 token 之和。 */
|
|
31
|
+
decodeTokens: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 输出速度(token/秒):整个会话累计,除以纯解码时间。
|
|
35
|
+
*
|
|
36
|
+
* 解码期为 0(老日志没记时刻、或这一会话还没请求定稿)时返回 null——
|
|
37
|
+
* 界面据此整段省略,绝不去除一个 0 印出天文数字。
|
|
38
|
+
*/
|
|
39
|
+
export declare function tokensPerSecond(totals: Pick<ThroughputTotals, 'decodeMs' | 'decodeTokens'>): number | null;
|
|
40
|
+
/** 首字延迟平均(毫秒):没有样本时返回 null,界面据此省略这一行。 */
|
|
41
|
+
export declare function averageTtftMs(totals: Pick<ThroughputTotals, 'ttftMs' | 'ttftSteps'>): number | null;
|
|
42
|
+
/**
|
|
43
|
+
* 速度读数格式(对照 dsh 的 formatTokensPerSecond):
|
|
44
|
+
* 10 以上给整数,10 以下给一位小数——8.4 / 12,不写 8.40 / 11.7。
|
|
45
|
+
*/
|
|
46
|
+
export declare function formatTokensPerSecond(tps: number): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 输出速度(tok/s)与首字延迟的口径:唯一原件,界面与测试都从这里取。
|
|
3
|
+
*
|
|
4
|
+
* 算法照 dsh 的 sessionStats 投影(packages/session/session-stats/src/projection.ts:130-170):
|
|
5
|
+
* - 首字延迟 = 每次请求「发出 → 第一口输出」的墙钟,只在真拿到第一口的请求上累计;
|
|
6
|
+
* - 分子分母**成对**取:同一次请求既要有第一口输出的时刻、又要有服务端上报的输出 token,
|
|
7
|
+
* 才同时算进 decodeTokens 与 decodeMs——不能拿一部分请求的时间去除另一部分请求的 token;
|
|
8
|
+
* - 分母是**纯解码时间**(第一口输出 → 定稿),首字等待、工具执行、等下一个请求的空转
|
|
9
|
+
* 都不在里面;整个会话累计,不是「本轮」。
|
|
10
|
+
*
|
|
11
|
+
* 为什么单开一个文件:桌面状态栏、终端界面、测试必须同口径,谁也不许自己再写一遍除法。
|
|
12
|
+
* 渲染层经 `@dsc/runtime/core/throughput.js` 转出口取用(desktop/src/renderer/token-estimate.ts)。
|
|
13
|
+
*
|
|
14
|
+
* @module dsc/core/throughput
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* 输出速度(token/秒):整个会话累计,除以纯解码时间。
|
|
18
|
+
*
|
|
19
|
+
* 解码期为 0(老日志没记时刻、或这一会话还没请求定稿)时返回 null——
|
|
20
|
+
* 界面据此整段省略,绝不去除一个 0 印出天文数字。
|
|
21
|
+
*/
|
|
22
|
+
export function tokensPerSecond(totals) {
|
|
23
|
+
if (!(totals.decodeMs > 0))
|
|
24
|
+
return null;
|
|
25
|
+
return totals.decodeTokens / (totals.decodeMs / 1_000);
|
|
26
|
+
}
|
|
27
|
+
/** 首字延迟平均(毫秒):没有样本时返回 null,界面据此省略这一行。 */
|
|
28
|
+
export function averageTtftMs(totals) {
|
|
29
|
+
if (!(totals.ttftSteps > 0))
|
|
30
|
+
return null;
|
|
31
|
+
return totals.ttftMs / totals.ttftSteps;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 速度读数格式(对照 dsh 的 formatTokensPerSecond):
|
|
35
|
+
* 10 以上给整数,10 以下给一位小数——8.4 / 12,不写 8.40 / 11.7。
|
|
36
|
+
*/
|
|
37
|
+
export function formatTokensPerSecond(tps) {
|
|
38
|
+
const clamped = Math.max(0, tps);
|
|
39
|
+
return clamped >= 10 ? String(Math.round(clamped)) : String(Math.round(clamped * 10) / 10);
|
|
40
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* todo 节流提醒的纯逻辑(投影本体注册在 `plugins/todo.ts`,这里是可被探针直读的那层)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么要有这条提醒:dsc 把「做完一步就改状态」写死在 todo_write 的工具说明里,
|
|
5
|
+
* 长会话里模型还是会忘(ZCode 的做法是每 N 个用户回合往历史尾巴补一条节流的提醒,
|
|
6
|
+
* 比静态叮嘱更能拉回注意力)。代价是每个被注入的回合多一条 user 消息的 token,
|
|
7
|
+
* 所以**默认关**:只有用户自己开了才注入。
|
|
8
|
+
*
|
|
9
|
+
* 纯函数、不改日志:它只往「发给模型的那份消息」末尾追加一条 user 消息,不碰会话记录
|
|
10
|
+
* (投影链的既有约定——日志存原文,模型看见的内容由这条链可复算)。提醒是提示不是事实,
|
|
11
|
+
* 落成日志条目反而会污染历史、也会在下次被当作用户原话引用,所以刻意不落。
|
|
12
|
+
*
|
|
13
|
+
* @module dsc/core/todo-reminder
|
|
14
|
+
*/
|
|
15
|
+
import type { ChatMessage } from './llm.js';
|
|
16
|
+
/** 注入的那条提醒原文(user 角色;文案照 todo 工具说明的口径:2–4 字动词、无标点)。 */
|
|
17
|
+
export declare const TODO_REMINDER_TEXT = "\uFF08\u63D0\u9192\uFF1A\u4EFB\u52A1\u6E05\u5355\u6709\u672A\u5B8C\u6210\u9879\uFF0C\u505A\u5B8C\u4E00\u6B65\u5C31\u628A\u72B6\u6001\u6539\u6389\uFF09";
|
|
18
|
+
/** {@link appendTodoReminder} 的判断输入。 */
|
|
19
|
+
export interface TodoReminderOptions {
|
|
20
|
+
/** 总开关(默认 false:不能给所有会话凭空加 token)。 */
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
/** 距上次写清单过了几个用户回合才提醒(默认 10)。 */
|
|
23
|
+
everyTurns: number;
|
|
24
|
+
/** 当前清单里还有 pending / in_progress 的条目——没有未完成项就没什么可提醒的。 */
|
|
25
|
+
hasOpenTodos: boolean;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 数「距最近一次 `todo_write` 调用过了几个用户回合」。
|
|
29
|
+
*
|
|
30
|
+
* 「一个用户回合」= 一条**被模型应答过**的 user 消息。请求尾部那条程序自动附的环境快照
|
|
31
|
+
* (env-facts 投影,order 600,跑在本投影之前)与当前这轮还没被回答的用户话都没有后随的
|
|
32
|
+
* assistant,不算回合——否则环境快照每轮都会把计数多推一格,提醒就会提前一拍发出来。
|
|
33
|
+
*
|
|
34
|
+
* 历史里没有 todo_write 时从第 0 条起数(会话恢复的场景:清单从状态条目回来,工具调用可能
|
|
35
|
+
* 已被压缩掉)。
|
|
36
|
+
*/
|
|
37
|
+
export declare function countUserTurnsSinceLastTodoWrite(messages: readonly ChatMessage[]): number;
|
|
38
|
+
/**
|
|
39
|
+
* 该不该注入提醒、注入后是什么样——纯函数,返回新数组(不就地改输入)。
|
|
40
|
+
*
|
|
41
|
+
* 幂等:已经有这条提醒就不再追加(同一份历史重复投影——校验重算、流中断后的整轮重试
|
|
42
|
+
* 会重新组装——必须逐字节同结果)。`everyTurns` 夹到至少 1,免得配成 0 变成每轮都发。
|
|
43
|
+
*/
|
|
44
|
+
export declare function appendTodoReminder(messages: ChatMessage[], options: TodoReminderOptions): ChatMessage[];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** 注入的那条提醒原文(user 角色;文案照 todo 工具说明的口径:2–4 字动词、无标点)。 */
|
|
2
|
+
export const TODO_REMINDER_TEXT = '(提醒:任务清单有未完成项,做完一步就把状态改掉)';
|
|
3
|
+
/**
|
|
4
|
+
* 数「距最近一次 `todo_write` 调用过了几个用户回合」。
|
|
5
|
+
*
|
|
6
|
+
* 「一个用户回合」= 一条**被模型应答过**的 user 消息。请求尾部那条程序自动附的环境快照
|
|
7
|
+
* (env-facts 投影,order 600,跑在本投影之前)与当前这轮还没被回答的用户话都没有后随的
|
|
8
|
+
* assistant,不算回合——否则环境快照每轮都会把计数多推一格,提醒就会提前一拍发出来。
|
|
9
|
+
*
|
|
10
|
+
* 历史里没有 todo_write 时从第 0 条起数(会话恢复的场景:清单从状态条目回来,工具调用可能
|
|
11
|
+
* 已被压缩掉)。
|
|
12
|
+
*/
|
|
13
|
+
export function countUserTurnsSinceLastTodoWrite(messages) {
|
|
14
|
+
let lastWrite = -1;
|
|
15
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
16
|
+
const message = messages[index];
|
|
17
|
+
if (message.role !== 'assistant' || !Array.isArray(message.tool_calls))
|
|
18
|
+
continue;
|
|
19
|
+
if (message.tool_calls.some((call) => call.function?.name === 'todo_write')) {
|
|
20
|
+
lastWrite = index;
|
|
21
|
+
break;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
let lastAssistant = -1;
|
|
25
|
+
for (let index = messages.length - 1; index >= 0; index -= 1) {
|
|
26
|
+
if (messages[index].role === 'assistant') {
|
|
27
|
+
lastAssistant = index;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
let turns = 0;
|
|
32
|
+
// user 消息后面有 assistant ⟺ 它的下标小于最靠后的那条 assistant 的下标
|
|
33
|
+
for (let index = lastWrite + 1; index < lastAssistant; index += 1) {
|
|
34
|
+
if (messages[index].role === 'user')
|
|
35
|
+
turns += 1;
|
|
36
|
+
}
|
|
37
|
+
return turns;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 该不该注入提醒、注入后是什么样——纯函数,返回新数组(不就地改输入)。
|
|
41
|
+
*
|
|
42
|
+
* 幂等:已经有这条提醒就不再追加(同一份历史重复投影——校验重算、流中断后的整轮重试
|
|
43
|
+
* 会重新组装——必须逐字节同结果)。`everyTurns` 夹到至少 1,免得配成 0 变成每轮都发。
|
|
44
|
+
*/
|
|
45
|
+
export function appendTodoReminder(messages, options) {
|
|
46
|
+
if (!options.enabled || !options.hasOpenTodos)
|
|
47
|
+
return messages;
|
|
48
|
+
const everyTurns = Math.max(1, Math.floor(options.everyTurns));
|
|
49
|
+
if (countUserTurnsSinceLastTodoWrite(messages) < everyTurns)
|
|
50
|
+
return messages;
|
|
51
|
+
if (messages.some((message) => message.role === 'user' && message.content === TODO_REMINDER_TEXT)) {
|
|
52
|
+
return messages;
|
|
53
|
+
}
|
|
54
|
+
return [...messages, { role: 'user', content: TODO_REMINDER_TEXT }];
|
|
55
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 会话任务清单:模型自己维护、界面实时显示的那张单子。
|
|
3
|
+
*
|
|
4
|
+
* 语义抄两家的交集并各留一点长处:
|
|
5
|
+
* - 整表替换(Codex `update_plan`、DSH `todo_write` 都是整表,少一套增量 diff 协议);
|
|
6
|
+
* - 条目带 id 和可选 parent(Hermes `tools/todo_tool.py:26-31`),有 id 才谈得上「只改状态」,
|
|
7
|
+
* 有 parent 才显示得出「这一步是刚才那步的子任务」;
|
|
8
|
+
* - 每次真正变化的写入都让 revision +1,界面拿它拒绝过期帧(同文件 :32);
|
|
9
|
+
* - 有上限:清单本身会被压缩后重新注入,不设上限就等于把压缩省下的token又吃回去。
|
|
10
|
+
*
|
|
11
|
+
* @module dsc/core/todo
|
|
12
|
+
*/
|
|
13
|
+
import type { TodoStatus as ContractTodoStatus } from '../contract.js';
|
|
14
|
+
/**
|
|
15
|
+
* 任务状态;`cancelled` 是「决定不做了」,跟「没做完」不是一回事。
|
|
16
|
+
* 类型就是 contract 的那个 TodoStatus(会话日志、界面、存储共用一份声明)。
|
|
17
|
+
*/
|
|
18
|
+
export type TodoStatus = ContractTodoStatus;
|
|
19
|
+
export declare const TODO_STATUSES: readonly TodoStatus[];
|
|
20
|
+
/** 单条任务正文长度上限(界面一行显示得下,压缩重注入也扛得住)。 */
|
|
21
|
+
export declare const MAX_TODO_CONTENT_CHARS = 300;
|
|
22
|
+
/** 清单条数上限。 */
|
|
23
|
+
export declare const MAX_TODO_ITEMS = 64;
|
|
24
|
+
/** 四态符号:界面和纯文本回显共用一套,模型看到的和用户看到的是同一件事。 */
|
|
25
|
+
export declare const STATUS_MARKS: Record<TodoStatus, string>;
|
|
26
|
+
/** 一条任务。数组下标就是优先级顺序。 */
|
|
27
|
+
export interface TodoItem {
|
|
28
|
+
id: string;
|
|
29
|
+
content: string;
|
|
30
|
+
status: TodoStatus;
|
|
31
|
+
/** 父任务 id;省略 = 顶层任务。父不存在时这个字段会被丢掉(不报错,但界面按顶层显示)。 */
|
|
32
|
+
parent?: string;
|
|
33
|
+
}
|
|
34
|
+
/** 一次写入的结果:整表 + 新 revision + 对被静悄悄修掉的地方说的话。 */
|
|
35
|
+
export interface TodoWriteResult {
|
|
36
|
+
items: TodoItem[];
|
|
37
|
+
revision: number;
|
|
38
|
+
/** 校正说明(过长截断、父任务不存在、id 重复合并),原样回给模型。 */
|
|
39
|
+
notes: string[];
|
|
40
|
+
}
|
|
41
|
+
/** 会话级清单存储:一个会话一份,切会话时换一份。 */
|
|
42
|
+
export declare class TodoStore {
|
|
43
|
+
private items;
|
|
44
|
+
private revision;
|
|
45
|
+
/** 当前整表(浅拷贝,调用方改不动内部)。 */
|
|
46
|
+
read(): TodoItem[];
|
|
47
|
+
/** 当前版本号。 */
|
|
48
|
+
get rev(): number;
|
|
49
|
+
/** 清单是不是空的(空的时候界面不占位置)。 */
|
|
50
|
+
get empty(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* 写入整表或按 id 合并。
|
|
53
|
+
*
|
|
54
|
+
* @param todos - 新任务列表(整表替换时是完整清单)。
|
|
55
|
+
* @param merge - true = 只按 id 更新给出的字段并追加新条目;false(默认)= 整表替换。
|
|
56
|
+
*/
|
|
57
|
+
write(todos: readonly unknown[], merge?: boolean): TodoWriteResult;
|
|
58
|
+
/** 从会话日志恢复(不走 revision 递增,保持恢复前后的版本一致)。 */
|
|
59
|
+
restore(items: readonly unknown[]): void;
|
|
60
|
+
/** 清空(切会话、用户手动清)。 */
|
|
61
|
+
clear(): void;
|
|
62
|
+
/** 进度:完成数 / 有效总数(cancelled 不计入分母)。 */
|
|
63
|
+
progress(): {
|
|
64
|
+
done: number;
|
|
65
|
+
total: number;
|
|
66
|
+
active: string | null;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* 给模型看的纯文本(清单在压缩后要重新注入,靠这段把进度接回去)。
|
|
70
|
+
*/
|
|
71
|
+
formatForPrompt(): string;
|
|
72
|
+
/** 校验 + 补全(id 缺失自动补、正文过长截断、非法状态回落 pending)。 */
|
|
73
|
+
private normalize;
|
|
74
|
+
/** 合并写入:已有条目只改给出的字段,新条目校验后追加。 */
|
|
75
|
+
private mergeInto;
|
|
76
|
+
/** 校验并归一化单条。返回 null = 这条直接丢。 */
|
|
77
|
+
private one;
|
|
78
|
+
private cap;
|
|
79
|
+
/** 父任务不存在的条目降级成顶层任务(不是错误,但要说一句)。 */
|
|
80
|
+
private dropOrphanParents;
|
|
81
|
+
}
|