@waq666/pneuma 0.7.1 → 0.8.1
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/README.md +242 -206
- package/bin/dsc.js +9 -3
- package/bin/headless.cjs +1 -1
- package/lib/adapter/transcript.d.ts +19 -2
- package/lib/adapter/transcript.js +71 -14
- package/lib/app/AgentsOverlay.js +7 -6
- package/lib/app/App.js +1 -1
- package/lib/app/ApprovalCard.js +15 -9
- package/lib/app/ChatView.d.ts +3 -1
- package/lib/app/ChatView.js +21 -17
- package/lib/app/Composer.js +22 -4
- package/lib/app/MarkdownView.js +2 -1
- package/lib/app/ModelPicker.js +7 -6
- package/lib/app/PickerFrame.d.ts +4 -0
- package/lib/app/PickerFrame.js +18 -0
- package/lib/app/PlanReviewCard.js +2 -1
- package/lib/app/PresetPicker.js +8 -7
- package/lib/app/SessionPicker.js +21 -20
- package/lib/app/SettingsOverlay.js +1 -1
- package/lib/app/SkillsPicker.js +7 -6
- package/lib/app/StatusBar.js +3 -15
- package/lib/app/TaskStrips.js +1 -4
- package/lib/app/TimelineRail.js +2 -1
- package/lib/app/ToolCard.js +2 -6
- package/lib/app/Welcome.d.ts +1 -0
- package/lib/app/Welcome.js +1 -4
- package/lib/app/click.d.ts +0 -2
- package/lib/app/click.js +2 -21
- package/lib/app/display-width.d.ts +16 -0
- package/lib/app/display-width.js +33 -0
- package/lib/app/markdown.d.ts +1 -3
- package/lib/app/markdown.js +2 -19
- package/lib/app/scroll-model.js +1 -1
- package/lib/contract/approval.d.ts +91 -0
- package/lib/contract/approval.js +1 -0
- package/lib/contract/mode.d.ts +69 -0
- package/lib/contract/mode.js +1 -0
- package/lib/contract/plugin.d.ts +240 -0
- package/lib/contract/plugin.js +1 -0
- package/lib/contract/runtime.d.ts +282 -0
- package/lib/contract/runtime.js +1 -0
- package/lib/contract/session.d.ts +208 -0
- package/lib/contract/session.js +36 -0
- package/lib/contract/settings.d.ts +242 -0
- package/lib/contract/settings.js +1 -0
- package/lib/contract/snapshot.d.ts +453 -0
- package/lib/contract/snapshot.js +1 -0
- package/lib/contract/task.d.ts +189 -0
- package/lib/contract/task.js +10 -0
- package/lib/contract/transcript.d.ts +358 -0
- package/lib/contract/transcript.js +1 -0
- package/lib/contract/usage.d.ts +132 -0
- package/lib/contract/usage.js +10 -0
- package/lib/contract.d.ts +20 -1968
- package/lib/contract.js +19 -30
- package/lib/core/agent-roles.d.ts +1 -1
- package/lib/core/agent-roles.js +6 -5
- package/lib/core/approval-floor.d.ts +9 -0
- package/lib/core/approval-floor.js +152 -25
- package/lib/core/attachments.d.ts +185 -0
- package/lib/core/attachments.js +425 -0
- package/lib/core/bytes.d.ts +14 -0
- package/lib/core/bytes.js +28 -0
- package/lib/core/call-meaning.d.ts +20 -0
- package/lib/core/call-meaning.js +347 -0
- package/lib/core/cdp/actions.js +6 -0
- package/lib/core/cdp/launch.js +2 -2
- package/lib/core/cdp/report.d.ts +27 -0
- package/lib/core/cdp/report.js +50 -0
- package/lib/core/cdp/ring-buffer.d.ts +25 -0
- package/lib/core/cdp/ring-buffer.js +44 -0
- package/lib/core/cdp/snapshot.js +5 -9
- package/lib/core/cdp/transport.js +1 -1
- package/lib/core/clamp.d.ts +20 -0
- package/lib/core/clamp.js +24 -0
- package/lib/core/clock.d.ts +16 -0
- package/lib/core/clock.js +20 -0
- package/lib/core/command-policy.js +33 -1
- package/lib/core/commands-completion.d.ts +28 -0
- package/lib/core/commands-completion.js +108 -30
- package/lib/core/compact.d.ts +36 -6
- package/lib/core/compact.js +89 -17
- package/lib/core/desktop-control.js +1 -3
- package/lib/core/dsh-compat/llm-usage-event.d.ts +78 -0
- package/lib/core/dsh-compat/llm-usage-event.js +91 -0
- package/lib/core/dsh-compat/presentation.d.ts +84 -0
- package/lib/core/dsh-compat/presentation.js +105 -0
- package/lib/core/dsh-compat/resolve-hook.d.ts +3 -3
- package/lib/core/dsh-compat/resolve-hook.js +41 -13
- package/lib/core/dsh-compat/service-map.d.ts +52 -0
- package/lib/core/dsh-compat/service-map.js +87 -0
- package/lib/core/dsh-compat/session-bridge.d.ts +107 -0
- package/lib/core/dsh-compat/session-bridge.js +376 -0
- package/lib/core/dsh-compat/session-events.d.ts +54 -0
- package/lib/core/dsh-compat/session-events.js +297 -0
- package/lib/core/dsh-compat/shims/credentials.d.ts +62 -0
- package/lib/core/dsh-compat/shims/credentials.js +86 -0
- package/lib/core/dsh-compat/shims/home-paths.d.ts +77 -0
- package/lib/core/dsh-compat/shims/home-paths.js +143 -0
- package/lib/core/dsh-compat/tools-facade.d.ts +31 -1
- package/lib/core/dsh-compat/tools-facade.js +207 -3
- package/lib/core/err-text.d.ts +5 -0
- package/lib/core/err-text.js +5 -0
- package/lib/core/events.d.ts +31 -2
- package/lib/core/git-info.d.ts +127 -15
- package/lib/core/git-info.js +315 -34
- package/lib/core/git-surface.d.ts +17 -0
- package/lib/core/git-surface.js +7 -0
- package/lib/core/hooks.d.ts +19 -2
- package/lib/core/hooks.js +57 -13
- package/lib/core/host-methods.d.ts +1 -1
- package/lib/core/host-methods.js +4 -0
- package/lib/core/image-diet.js +1 -4
- package/lib/core/json-text.d.ts +11 -0
- package/lib/core/json-text.js +18 -0
- package/lib/core/learnings/skill-write.d.ts +1 -7
- package/lib/core/learnings/skill-write.js +3 -37
- package/lib/core/lifecycle-hooks.d.ts +11 -3
- package/lib/core/lifecycle-hooks.js +33 -42
- package/lib/core/llm.d.ts +42 -0
- package/lib/core/llm.js +40 -25
- package/lib/core/loop.d.ts +11 -1
- package/lib/core/loop.js +95 -28
- package/lib/core/lsp/client.js +30 -17
- package/lib/core/lsp/normalize.d.ts +0 -2
- package/lib/core/lsp/normalize.js +1 -6
- package/lib/core/lsp/servers.js +1 -4
- package/lib/core/mcp.d.ts +18 -0
- package/lib/core/mcp.js +60 -16
- package/lib/core/microcompact.d.ts +45 -0
- package/lib/core/microcompact.js +128 -0
- package/lib/core/native-bridge.js +2 -10
- package/lib/core/path-policy.d.ts +13 -1
- package/lib/core/path-policy.js +87 -18
- package/lib/core/permission-presets.d.ts +9 -5
- package/lib/core/permission-presets.js +14 -7
- package/lib/core/permission-scope.d.ts +65 -0
- package/lib/core/permission-scope.js +109 -0
- package/lib/core/plugin-bundle.d.ts +95 -0
- package/lib/core/plugin-bundle.js +137 -0
- package/lib/core/plugin-loader.d.ts +36 -1
- package/lib/core/plugin-loader.js +336 -12
- package/lib/core/plugin-patch.d.ts +64 -0
- package/lib/core/plugin-patch.js +146 -0
- package/lib/core/plugin-registry.d.ts +14 -0
- package/lib/core/plugin-registry.js +2 -0
- package/lib/core/prefs.js +40 -2
- package/lib/core/presets.d.ts +11 -0
- package/lib/core/presets.js +61 -22
- package/lib/core/profile-dir.d.ts +5 -0
- package/lib/core/profile-dir.js +40 -0
- package/lib/core/prompt.js +55 -19
- package/lib/core/ptc.d.ts +8 -2
- package/lib/core/ptc.js +18 -4
- package/lib/core/records.d.ts +16 -0
- package/lib/core/records.js +22 -0
- package/lib/core/remote/notify.js +1 -3
- package/lib/core/remote/push.js +2 -6
- package/lib/core/sandbox/execpolicy.js +27 -3
- package/lib/core/sandbox/net-proxy.js +2 -2
- package/lib/core/sandbox/policy.d.ts +1 -1
- package/lib/core/sandbox/policy.js +21 -15
- package/lib/core/sandbox/win/account.js +1 -4
- package/lib/core/sandbox/win/acl.js +1 -6
- package/lib/core/sandbox/win/backend.d.ts +24 -3
- package/lib/core/sandbox/win/backend.js +73 -23
- package/lib/core/sandbox/win/doctor.js +1 -4
- package/lib/core/sandbox/win/runner-entry.js +1 -6
- package/lib/core/sandbox/win/setup.js +1 -4
- package/lib/core/sandbox/win/utf16.d.ts +11 -0
- package/lib/core/sandbox/win/utf16.js +15 -0
- package/lib/core/sandbox/win/wfp.js +1 -4
- package/lib/core/schedule/rule.d.ts +0 -17
- package/lib/core/schedule/rule.js +1 -3
- package/lib/core/schedule/runner.d.ts +5 -2
- package/lib/core/schedule/runner.js +32 -9
- package/lib/core/schedule/store.d.ts +0 -2
- package/lib/core/schedule/store.js +2 -9
- package/lib/core/session-index.d.ts +50 -0
- package/lib/core/session-index.js +169 -3
- package/lib/core/session.d.ts +89 -13
- package/lib/core/session.js +385 -32
- package/lib/core/shell-quote.d.ts +21 -0
- package/lib/core/shell-quote.js +24 -0
- package/lib/core/side-ask.d.ts +52 -0
- package/lib/core/side-ask.js +89 -0
- package/lib/core/skills.d.ts +16 -0
- package/lib/core/skills.js +45 -8
- package/lib/core/snapshot-throttle.d.ts +8 -0
- package/lib/core/snapshot-throttle.js +24 -0
- package/lib/core/spill.d.ts +11 -5
- package/lib/core/spill.js +35 -36
- package/lib/core/strings.d.ts +21 -0
- package/lib/core/strings.js +33 -0
- package/lib/core/terminal-env.d.ts +61 -0
- package/lib/core/terminal-env.js +327 -0
- package/lib/core/text-format.d.ts +17 -0
- package/lib/core/text-format.js +26 -0
- package/lib/core/todo-reminder.d.ts +19 -14
- package/lib/core/todo-reminder.js +14 -23
- package/lib/core/token-estimate.d.ts +18 -2
- package/lib/core/token-estimate.js +10 -2
- package/lib/core/tool-result-prune.d.ts +42 -0
- package/lib/core/tool-result-prune.js +47 -0
- package/lib/core/tool-search.d.ts +3 -2
- package/lib/core/tool-search.js +3 -2
- package/lib/core/tools/bash.d.ts +35 -3
- package/lib/core/tools/bash.js +168 -41
- package/lib/core/tools/fs-tools.js +18 -17
- package/lib/core/tools/image-tool.d.ts +2 -0
- package/lib/core/tools/image-tool.js +59 -0
- package/lib/core/tools/path-args.d.ts +4 -0
- package/lib/core/tools/path-args.js +22 -0
- package/lib/core/tools/search-tools.d.ts +30 -0
- package/lib/core/tools/search-tools.js +321 -34
- package/lib/core/tools.d.ts +82 -0
- package/lib/core/tools.js +21 -0
- package/lib/core/transcript-text.d.ts +19 -0
- package/lib/core/transcript-text.js +44 -0
- package/lib/core/ui-boot-source.d.ts +5 -0
- package/lib/core/ui-boot-source.js +10 -3
- package/lib/core/ui-bundles.d.ts +80 -6
- package/lib/core/ui-bundles.js +700 -76
- package/lib/core/ui-events.d.ts +10 -0
- package/lib/core/ui-events.js +25 -0
- package/lib/core/ui-methods.d.ts +1 -1
- package/lib/core/ui-methods.js +42 -13
- package/lib/core/ui-route.js +11 -7
- package/lib/core/ui-server.d.ts +6 -0
- package/lib/core/ui-server.js +106 -1
- package/lib/core/unified-diff.d.ts +35 -0
- package/lib/core/unified-diff.js +86 -0
- package/lib/core/usage-log.js +39 -0
- package/lib/core/web-http.d.ts +1 -1
- package/lib/core/web-http.js +1 -3
- package/lib/host/kernel.js +57 -41
- package/lib/plugins/agent.js +101 -20
- package/lib/plugins/approval-floor.js +12 -8
- package/lib/plugins/approval.js +252 -80
- package/lib/plugins/ask.js +60 -8
- package/lib/plugins/browser.js +32 -84
- package/lib/plugins/commands.js +167 -57
- package/lib/plugins/compact.d.ts +2 -2
- package/lib/plugins/compact.js +200 -30
- package/lib/plugins/computer-use.js +34 -18
- package/lib/plugins/dock-browser.js +24 -65
- package/lib/plugins/dsh-compat.js +7 -0
- package/lib/plugins/file-review.js +59 -15
- package/lib/plugins/git.js +16 -8
- package/lib/plugins/goal.js +9 -8
- package/lib/plugins/hooks.js +4 -2
- package/lib/plugins/host-stdio.js +14 -16
- package/lib/plugins/lifecycle-hooks.d.ts +5 -4
- package/lib/plugins/lifecycle-hooks.js +12 -10
- package/lib/plugins/llm.js +74 -33
- package/lib/plugins/lsp.js +22 -27
- package/lib/plugins/mcp.js +16 -17
- package/lib/plugins/memory.js +3 -24
- package/lib/plugins/microcompact.d.ts +4 -1
- package/lib/plugins/microcompact.js +117 -19
- package/lib/plugins/mode.js +30 -11
- package/lib/plugins/permission-presets.d.ts +2 -1
- package/lib/plugins/permission-presets.js +55 -35
- package/lib/plugins/plugin-manager.js +4 -6
- package/lib/plugins/presets.js +56 -27
- package/lib/plugins/prompt.js +54 -11
- package/lib/plugins/ptc.d.ts +13 -0
- package/lib/plugins/ptc.js +121 -24
- package/lib/plugins/remote/types.d.ts +1 -1
- package/lib/plugins/remote/types.js +11 -0
- package/lib/plugins/remote.js +14 -15
- package/lib/plugins/runtime.js +91 -14
- package/lib/plugins/sandbox.js +181 -60
- package/lib/plugins/schedule.js +12 -11
- package/lib/plugins/self-improve.js +28 -18
- package/lib/plugins/session-search.js +18 -13
- package/lib/plugins/session-title.js +1 -1
- package/lib/plugins/session.js +103 -25
- package/lib/plugins/settings.js +16 -40
- package/lib/plugins/skills.js +18 -1
- package/lib/plugins/spill.js +18 -11
- package/lib/plugins/subagent.js +208 -42
- package/lib/plugins/team.js +11 -5
- package/lib/plugins/todo.d.ts +1 -1
- package/lib/plugins/todo.js +25 -19
- package/lib/plugins/tool-search.js +47 -28
- package/lib/plugins/tools-default.js +89 -5
- package/lib/plugins/tools.js +3 -3
- package/lib/plugins/transcript.js +116 -9
- package/lib/plugins/web-search.d.ts +1 -1
- package/lib/plugins/web-search.js +25 -16
- package/lib/plugins/webserver.js +40 -7
- package/lib/remote/assets/app-B3Id1EBq.js +14 -0
- package/lib/remote/assets/index.html +2 -2
- package/lib/remote/assets/{style-DIB6729x.css → style-NtlpbKOI.css} +1 -1
- package/lib/services/types.d.ts +247 -29
- package/lib/tools/plugin-cli.d.ts +1 -0
- package/lib/tools/plugin-cli.js +209 -0
- package/lib/ui/assets/app-B-Jx5dnh.js +90 -0
- package/lib/ui/assets/{chunk-BajyYBss.js → chunk-Bfdlo8Me.js} +1 -1
- package/lib/ui/assets/chunk-DGX-i4eb.js +12 -0
- package/lib/ui/assets/index.html +62 -14
- package/lib/ui/assets/style-WzxwEPaE.css +1 -0
- package/lib/ui/frames.js +1 -3
- package/lib/ui/index.d.ts +30 -1
- package/lib/ui/index.js +29 -0
- package/lib/ui/manifest.d.ts +24 -6
- package/lib/ui/manifest.js +3 -2
- package/lib/ui/plugins/actions/bundle.json +8 -0
- package/lib/ui/plugins/actions/client.js +43 -0
- package/lib/ui/plugins/ask/bundle.json +8 -0
- package/lib/ui/plugins/ask/client.js +415 -0
- package/lib/ui/plugins/browser/bundle.json +8 -0
- package/lib/ui/plugins/composer/bundle.json +9 -0
- package/lib/ui/plugins/composer/client.js +1806 -1087
- package/lib/ui/plugins/files/bundle.json +8 -0
- package/lib/ui/plugins/files/client.js +13 -98
- package/lib/ui/plugins/manifest.json +1 -104
- package/lib/ui/plugins/palette/bundle.json +8 -0
- package/lib/ui/plugins/palette/client.js +360 -0
- package/lib/ui/plugins/plugins/bundle.json +8 -0
- package/lib/ui/plugins/plugins/client.js +116 -38
- package/lib/ui/plugins/preview/bundle.json +8 -0
- package/lib/ui/plugins/preview/client.js +6 -16
- package/lib/ui/plugins/prompt/bundle.json +8 -0
- package/lib/ui/plugins/prompt/client.js +81 -47
- package/lib/ui/plugins/sessions/bundle.json +8 -0
- package/lib/ui/plugins/sessions/client.js +157 -111
- package/lib/ui/plugins/settings/bundle.json +8 -0
- package/lib/ui/plugins/settings/client.js +184 -170
- package/lib/ui/plugins/skills/bundle.json +8 -0
- package/lib/ui/plugins/skills/client.js +161 -79
- package/lib/ui/plugins/status/bundle.json +8 -0
- package/lib/ui/plugins/status/client.js +165 -26
- package/lib/ui/plugins/statusbar/bundle.json +9 -0
- package/lib/ui/plugins/statusbar/client.js +100 -144
- package/lib/ui/plugins/tasks/bundle.json +8 -0
- package/lib/ui/plugins/team/bundle.json +8 -0
- package/lib/ui/plugins/team/client.js +60 -58
- package/lib/ui/plugins/terminal/bundle.json +8 -0
- package/lib/ui/plugins/terminal/client.js +1 -7
- package/lib/ui/plugins/trace/bundle.json +11 -0
- package/lib/ui/plugins/trace/client.js +86 -179
- package/lib/ui/plugins/transcript/bundle.json +8 -0
- package/lib/ui/plugins/transcript/client.js +1608 -1243
- package/lib/ui/sdk/@dsc/ui/index.d.ts +54 -16
- package/lib/ui/sdk/@dsc/ui/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +20 -1968
- package/lib/ui/sdk/@dsc/ui-core/core/attachments.d.ts +185 -0
- package/lib/ui/sdk/@dsc/ui-core/core/bytes.d.ts +14 -0
- package/lib/ui/sdk/@dsc/ui-core/core/err-text.d.ts +18 -0
- package/lib/ui/sdk/@dsc/ui-core/core/git-surface.d.ts +17 -0
- package/lib/ui/sdk/@dsc/ui-core/core/json-text.d.ts +11 -0
- package/lib/ui/sdk/@dsc/ui-core/core/path-policy.d.ts +44 -0
- package/lib/ui/sdk/@dsc/ui-core/core/records.d.ts +16 -0
- package/lib/ui/sdk/@dsc/ui-core/core/throughput.d.ts +46 -0
- package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +18 -2
- package/lib/ui/sdk/@dsc/ui-core/core/unified-diff.d.ts +35 -0
- package/lib/ui/sdk/@dsc/ui-core/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +30 -1
- package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +24 -6
- package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +19 -8
- package/lib/ui/sdk/@dsc/ui-core/ui/signal.d.ts +49 -0
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +17 -3
- package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-dockkit/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +4 -0
- package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +6 -1
- package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +1 -0
- package/lib/ui/sdk/@dsc/ui-layout/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +10 -1
- package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-layout/usage-today.d.ts +11 -0
- package/lib/ui/sdk/@dsc/ui-primitives/dialog-focus.d.ts +30 -0
- package/lib/ui/sdk/@dsc/ui-primitives/error-text.d.ts +12 -0
- package/lib/ui/sdk/@dsc/ui-primitives/git-surface.d.ts +9 -0
- package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +23 -0
- package/lib/ui/sdk/@dsc/ui-primitives/humanize-error.d.ts +35 -0
- package/lib/ui/sdk/@dsc/ui-primitives/icons-workspace.d.ts +33 -0
- package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +21 -3
- package/lib/ui/sdk/@dsc/ui-primitives/image-lightbox.d.ts +21 -0
- package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +16 -0
- package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +10 -14
- package/lib/ui/sdk/@dsc/ui-primitives/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +31 -8
- package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +2 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-findings-card.d.ts +25 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-findings.d.ts +64 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-notice-card.d.ts +27 -0
- package/lib/ui/sdk/@dsc/ui-primitives/review-notice.d.ts +80 -0
- package/lib/ui/sdk/@dsc/ui-primitives/signal.d.ts +9 -0
- package/lib/ui/sdk/@dsc/ui-primitives/sizes.d.ts +15 -0
- package/lib/ui/sdk/@dsc/ui-primitives/skeleton.d.ts +39 -0
- package/lib/ui/sdk/@dsc/ui-primitives/snapshot.d.ts +46 -0
- package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +3 -3
- package/lib/ui/sdk/@dsc/ui-primitives/throughput.d.ts +13 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +9 -0
- package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +1 -1
- package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +30 -6
- package/lib/ui/sdk/@dsc/ui-primitives/unified-diff.d.ts +10 -0
- package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +10 -1
- package/lib/ui/sdk/@dsc/ui-renderer/cordis-host.d.ts +113 -0
- package/lib/ui/sdk/@dsc/ui-renderer/package.json +1 -1
- package/lib/ui/sdk/@dsc/ui-slots/package.json +1 -1
- package/lib/ui/services.d.ts +19 -8
- package/lib/ui/services.js +20 -12
- package/lib/ui/signal.d.ts +49 -0
- package/lib/ui/signal.js +57 -0
- package/lib/ui/tui-plugins.js +36 -16
- package/package.json +71 -58
- package/lib/remote/assets/app-DAcUCOEn.js +0 -14
- package/lib/ui/assets/app-B70nVIKd.js +0 -69
- package/lib/ui/assets/chunk-BGcgwlCI.js +0 -12
- package/lib/ui/assets/style-Bq01xH_b.css +0 -1
package/lib/ui/frames.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
*
|
|
18
18
|
* @module dsc/ui/frames
|
|
19
19
|
*/
|
|
20
|
+
import { asRecord } from '../core/records.js';
|
|
20
21
|
/** 认不出的帧抛这个(严格版:宁可报错也不要画出一份半对不对的状态)。 */
|
|
21
22
|
export class HostFrameError extends Error {
|
|
22
23
|
}
|
|
@@ -31,9 +32,6 @@ export class HostFrameError extends Error {
|
|
|
31
32
|
*/
|
|
32
33
|
export class HostFrameGapError extends HostFrameError {
|
|
33
34
|
}
|
|
34
|
-
function asRecord(value) {
|
|
35
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value) ? value : null;
|
|
36
|
-
}
|
|
37
35
|
/** 帧顶层是不是全量(先看 `full`,再看 `type`)。 */
|
|
38
36
|
export function isFullFrame(raw) {
|
|
39
37
|
const frame = asRecord(raw);
|
package/lib/ui/index.d.ts
CHANGED
|
@@ -48,6 +48,35 @@ export * from '../core/model-caps.js';
|
|
|
48
48
|
* 从参数 + 盘上现值推演 diff,用的就是宿主算轮尾差异的同一份算法。
|
|
49
49
|
*/
|
|
50
50
|
export * from '../core/diff-text.js';
|
|
51
|
+
/**
|
|
52
|
+
* 错误文案(`core/err-text.ts`)也进共享面:界面侧到处要写「失败:<一句话>」,
|
|
53
|
+
* 这份实现全仓只能有一份,壳与第三方插件经 `@dsc/ui-primitives` 拿。
|
|
54
|
+
*/
|
|
55
|
+
export * from '../core/err-text.js';
|
|
56
|
+
/**
|
|
57
|
+
* 吞吐读数(`core/throughput.ts`):速度与首字延迟的口径,界面侧照它算,
|
|
58
|
+
* 免得状态栏各写一份。`@dsc/ui-primitives` 再转出一手给插件。
|
|
59
|
+
*/
|
|
60
|
+
export * from '../core/throughput.js';
|
|
61
|
+
/**
|
|
62
|
+
* git 读数的相等判断(`core/git-surface.ts`):宿主判断「要不要推这一帧」与输入区判断
|
|
63
|
+
* 「要不要重画」必须是同一条口径——一边认为变了、另一边认为没变,界面就停在旧分支名上。
|
|
64
|
+
* `@dsc/ui-primitives` 再转出一手给插件。
|
|
65
|
+
*/
|
|
66
|
+
export * from '../core/git-surface.js';
|
|
67
|
+
/**
|
|
68
|
+
* git diff 文本的解析(`core/unified-diff.ts`)也进共享面:审查面板与差异区都要把
|
|
69
|
+
* diff 文本读成结构化 hunk,旧渲染层与界面壳此前各有一份逐字相同的实现。
|
|
70
|
+
* `@dsc/ui-primitives` 再转出一手给插件。
|
|
71
|
+
*/
|
|
72
|
+
export * from '../core/unified-diff.js';
|
|
73
|
+
/**
|
|
74
|
+
* 模块级信号(`signal.ts`):`Set<() => void>` + `subscribe` + 通知这套写法原先在壳里
|
|
75
|
+
* 手抄七遍,抄漏「复制订阅者再遍历」「没变就不通知」这类语义不会报错,只会表现成
|
|
76
|
+
* 「界面停在旧值上」。多字段状态写成**一个对象**、一次 `set` 发出,避免半套新值先渲染。
|
|
77
|
+
* `@dsc/ui-primitives` 再转出一手给插件。
|
|
78
|
+
*/
|
|
79
|
+
export * from './signal.js';
|
|
51
80
|
/**
|
|
52
81
|
* 宿主那些**界面要读的**视图类型的再导出。
|
|
53
82
|
*
|
|
@@ -56,4 +85,4 @@ export * from '../core/diff-text.js';
|
|
|
56
85
|
* 靠 `unknown` 手写类型收窄的话,宿主改一个字段名壳这边不会报错——那恰好是最该被
|
|
57
86
|
* 编译器抓住的一类改动。
|
|
58
87
|
*/
|
|
59
|
-
export type { ApprovalAnswer, ArchivedPage, ArchivedSessionView, ApprovalDiffView, ApprovalPolicy, ApprovalReviewer, PermissionPresetSurface, PermissionPresetView, ApprovalRequestView, AskOptionView, AskUserView, BackgroundOutputView, BackgroundWorkView, ChangedFileView, CollaborationMode, ConnectionTestOutcome, ConnectionTestView, ContextSegmentsView, DiffHunkView, DiffLineView, EffortLevel, EffortMap, GitSurface, GoalView, LinkShareData, ModeSurface, ModelChoiceView, ModelConfigView, Modality, NoticeMessageView, PairShareData, PlanDecision, PlanEntryView, PlanView, PolicySurface, PresetDraft, PresetFileView, PresetSurface, PresetView, ProviderDraft, ProviderModelView, ProviderView, QueuedMessageView, RuntimeSnapshot, ScheduledTaskView, SessionRunState, SessionSummary, SettingsField, SettingsGroupView, SettingsMutation, SettingsSectionView, SettingsValue, SettingsValues, StatusView, SubagentCardView, TeammateView, ThemeMode, ThinkingLevel, ThinkingParam, TierOption, TodoItemView, TodoStatus, TodoView, TokenUsageView, ToolCallView, ToolEntryView, ToolStatus, TranscriptEntry, TurnEndReason, UiDensity, UiFontSize, UiCommandView, UiPrefsView, UsageDayView, UsageModelView, UsageStatsView, } from '../contract.js';
|
|
88
|
+
export type { ApprovalAnswer, ArchivedPage, ArchivedSessionView, ApprovalDiffView, ApprovalPolicy, ApprovalReviewer, PermissionPresetSurface, PermissionPresetView, ApprovalRequestView, AskOptionView, AskUserView, BackgroundOutputView, BackgroundWorkView, ChangedFileView, CollaborationMode, ConnectionTestOutcome, ConnectionTestView, ContextSegmentsView, DiffHunkView, DiffLineView, EffortLevel, EffortMap, GitSurface, GoalView, LinkShareData, ModeSurface, ModelChoiceView, ModelConfigView, Modality, NoticeMessageView, PairShareData, PlanDecision, PlanEntryView, PlanView, PolicySurface, PresetDraft, PresetFileView, PresetSurface, PresetView, ProviderDraft, ProviderModelView, ProviderView, QueuedMessageView, RuntimeSnapshot, ScheduledTaskView, SessionRunState, SessionSummary, SettingsField, SettingsGroupView, SettingsMutation, SettingsSectionView, SettingsValue, SettingsValues, StatusView, SubagentCardView, TeammateView, ThemeMode, ThinkingLevel, ThinkingParam, TierOption, TodoItemView, TodoStatus, TodoView, TokenUsageView, ToolCallView, ToolEntryView, ToolStatus, TranscriptEntry, TurnEndReason, UiDensity, UiFontSize, UiCommandView, UiPrefsView, UsageDayView, UsageModelView, UsageStatsView, UserFileAttachment, } from '../contract.js';
|
package/lib/ui/index.js
CHANGED
|
@@ -48,3 +48,32 @@ export * from '../core/model-caps.js';
|
|
|
48
48
|
* 从参数 + 盘上现值推演 diff,用的就是宿主算轮尾差异的同一份算法。
|
|
49
49
|
*/
|
|
50
50
|
export * from '../core/diff-text.js';
|
|
51
|
+
/**
|
|
52
|
+
* 错误文案(`core/err-text.ts`)也进共享面:界面侧到处要写「失败:<一句话>」,
|
|
53
|
+
* 这份实现全仓只能有一份,壳与第三方插件经 `@dsc/ui-primitives` 拿。
|
|
54
|
+
*/
|
|
55
|
+
export * from '../core/err-text.js';
|
|
56
|
+
/**
|
|
57
|
+
* 吞吐读数(`core/throughput.ts`):速度与首字延迟的口径,界面侧照它算,
|
|
58
|
+
* 免得状态栏各写一份。`@dsc/ui-primitives` 再转出一手给插件。
|
|
59
|
+
*/
|
|
60
|
+
export * from '../core/throughput.js';
|
|
61
|
+
/**
|
|
62
|
+
* git 读数的相等判断(`core/git-surface.ts`):宿主判断「要不要推这一帧」与输入区判断
|
|
63
|
+
* 「要不要重画」必须是同一条口径——一边认为变了、另一边认为没变,界面就停在旧分支名上。
|
|
64
|
+
* `@dsc/ui-primitives` 再转出一手给插件。
|
|
65
|
+
*/
|
|
66
|
+
export * from '../core/git-surface.js';
|
|
67
|
+
/**
|
|
68
|
+
* git diff 文本的解析(`core/unified-diff.ts`)也进共享面:审查面板与差异区都要把
|
|
69
|
+
* diff 文本读成结构化 hunk,旧渲染层与界面壳此前各有一份逐字相同的实现。
|
|
70
|
+
* `@dsc/ui-primitives` 再转出一手给插件。
|
|
71
|
+
*/
|
|
72
|
+
export * from '../core/unified-diff.js';
|
|
73
|
+
/**
|
|
74
|
+
* 模块级信号(`signal.ts`):`Set<() => void>` + `subscribe` + 通知这套写法原先在壳里
|
|
75
|
+
* 手抄七遍,抄漏「复制订阅者再遍历」「没变就不通知」这类语义不会报错,只会表现成
|
|
76
|
+
* 「界面停在旧值上」。多字段状态写成**一个对象**、一次 `set` 发出,避免半套新值先渲染。
|
|
77
|
+
* `@dsc/ui-primitives` 再转出一手给插件。
|
|
78
|
+
*/
|
|
79
|
+
export * from './signal.js';
|
package/lib/ui/manifest.d.ts
CHANGED
|
@@ -46,14 +46,21 @@ export interface UiPluginRow {
|
|
|
46
46
|
/** 允许它 import 的额外模块名;其余一律拒绝(白名单,见界面壳的加载器)。 */
|
|
47
47
|
external?: string[];
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
* 再按「服务名」解(A1 的服务表里有没有提供者)。
|
|
49
|
+
* 依赖的**插件 id**(拓扑排序用的就是它)。
|
|
51
50
|
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
51
|
+
* 2.0 起不再兼职服务名:服务依赖写 {@link services}。2.0 之前这一个字段两种含义
|
|
52
|
+
* 混着用,装错时只能靠「这个 id 不在清单里」猜——那种猜法在插件改名后必然出错。
|
|
53
|
+
*
|
|
54
|
+
* 硬语义在装载器:依赖的插件没装成时这个插件**不 apply**,报告里留一行中文原因。
|
|
55
55
|
*/
|
|
56
56
|
inject?: string[];
|
|
57
|
+
/**
|
|
58
|
+
* 依赖的**服务名**(`ui.provide` 登记的那些)。
|
|
59
|
+
*
|
|
60
|
+
* 提供者缺席就等待,报告里写「服务 X 还没有提供者」。要软降级的(有回落实现)
|
|
61
|
+
* 不要写进来,用 `ui.consume` 在渲染期读。
|
|
62
|
+
*/
|
|
63
|
+
services?: string[];
|
|
57
64
|
/** 第一档预取:需要尽早出现的插件(大小药丸、状态条之类)。与 phase 正交。 */
|
|
58
65
|
immediately?: boolean;
|
|
59
66
|
/** 调度档位;缺省 application。只对 web 载体的批有意义(TUI 是同进程顺序装载)。 */
|
|
@@ -75,7 +82,10 @@ export interface UiPluginEntry {
|
|
|
75
82
|
url: string;
|
|
76
83
|
/** 产物版本:文件内容的短哈希,换字节就换地址。 */
|
|
77
84
|
rev: string;
|
|
85
|
+
/** 依赖的插件 id(见 {@link UiPluginRow.inject})。 */
|
|
78
86
|
inject?: string[];
|
|
87
|
+
/** 依赖的服务名(见 {@link UiPluginRow.services})。 */
|
|
88
|
+
services?: string[];
|
|
79
89
|
external?: string[];
|
|
80
90
|
immediately?: boolean;
|
|
81
91
|
}
|
|
@@ -94,6 +104,13 @@ export interface UiBootGraph {
|
|
|
94
104
|
name: string;
|
|
95
105
|
version: string;
|
|
96
106
|
};
|
|
107
|
+
/**
|
|
108
|
+
* 声明了、装得上、但被用户停用的插件 id(不在这张图里)。
|
|
109
|
+
*
|
|
110
|
+
* 为什么图里要带这一项:装载器报「依赖没满足」时要区分「被停用」与「没有这个插件」,
|
|
111
|
+
* 前者翻一下开关就好,后者要去装。不进 rev——它不影响要装什么,只是解释口径。
|
|
112
|
+
*/
|
|
113
|
+
disabled?: string[];
|
|
97
114
|
}
|
|
98
115
|
/** 摘要函数:把若干字段拼成一个短哈希。默认那份不依赖 node,浏览器壳也能算。 */
|
|
99
116
|
export type HashFn = (...parts: readonly string[]) => string;
|
|
@@ -163,10 +180,11 @@ export declare function orderUiPlugins<T extends UiPluginRow>(rows: readonly T[]
|
|
|
163
180
|
*
|
|
164
181
|
* @param host - 宿主身份
|
|
165
182
|
* @param artifacts - 已算出 rev 的插件包(顺序即扫描顺序)
|
|
183
|
+
* @param disabled - 声明了但被停用的 id(只随图带出去,不参与组图与 rev)
|
|
166
184
|
*/
|
|
167
185
|
export declare function composeUiBootGraph(host: {
|
|
168
186
|
name: string;
|
|
169
187
|
version: string;
|
|
170
188
|
}, artifacts: readonly (UiPluginRow & {
|
|
171
189
|
rev: string;
|
|
172
|
-
})[]): UiBootGraph;
|
|
190
|
+
})[], disabled?: readonly string[]): UiBootGraph;
|
package/lib/ui/manifest.js
CHANGED
|
@@ -129,8 +129,9 @@ export function orderUiPlugins(rows) {
|
|
|
129
129
|
*
|
|
130
130
|
* @param host - 宿主身份
|
|
131
131
|
* @param artifacts - 已算出 rev 的插件包(顺序即扫描顺序)
|
|
132
|
+
* @param disabled - 声明了但被停用的 id(只随图带出去,不参与组图与 rev)
|
|
132
133
|
*/
|
|
133
|
-
export function composeUiBootGraph(host, artifacts) {
|
|
134
|
+
export function composeUiBootGraph(host, artifacts, disabled = []) {
|
|
134
135
|
const ordered = orderUiPlugins(artifacts);
|
|
135
136
|
const entries = ordered.map((artifact) => ({
|
|
136
137
|
id: artifact.id,
|
|
@@ -154,5 +155,5 @@ export function composeUiBootGraph(host, artifacts) {
|
|
|
154
155
|
});
|
|
155
156
|
}
|
|
156
157
|
const rev = shortHash('uiboot', JSON.stringify(entries), JSON.stringify(batches));
|
|
157
|
-
return { rev, entries, batches, host };
|
|
158
|
+
return { rev, entries, batches, host, ...(disabled.length === 0 ? {} : { disabled: [...disabled] }) };
|
|
158
159
|
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
(globalThis.__DSC_UI_FACTORIES__ ??= {})["actions"] = function (require, module, exports) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
4
|
+
const ui$1 = require("@dsc/ui");
|
|
5
|
+
const byOwner = /* @__PURE__ */ new Map();
|
|
6
|
+
const snapshot = ui$1.createSignal(Object.freeze([]));
|
|
7
|
+
function rebuild() {
|
|
8
|
+
const seen = /* @__PURE__ */ new Set();
|
|
9
|
+
const next = [];
|
|
10
|
+
for (const actions of byOwner.values()) {
|
|
11
|
+
for (const action of actions) {
|
|
12
|
+
if (seen.has(action.id)) {
|
|
13
|
+
console.warn(`动作表:${action.id} 被重复登记,后一条已忽略`);
|
|
14
|
+
continue;
|
|
15
|
+
}
|
|
16
|
+
seen.add(action.id);
|
|
17
|
+
next.push(Object.freeze({ ...action }));
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
snapshot.set(Object.freeze(next));
|
|
21
|
+
}
|
|
22
|
+
const handle = {
|
|
23
|
+
register(owner, actions) {
|
|
24
|
+
const stored = actions.length === 0 ? void 0 : [...actions];
|
|
25
|
+
if (stored === void 0) byOwner.delete(owner);
|
|
26
|
+
else byOwner.set(owner, stored);
|
|
27
|
+
rebuild();
|
|
28
|
+
return () => {
|
|
29
|
+
if (stored !== void 0 && byOwner.get(owner) !== stored) return;
|
|
30
|
+
if (byOwner.delete(owner)) rebuild();
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
list: () => snapshot.get(),
|
|
34
|
+
subscribe: snapshot.subscribe
|
|
35
|
+
};
|
|
36
|
+
const ui = ui$1.defineUiPlugin({
|
|
37
|
+
name: "动作表",
|
|
38
|
+
apply(ui2) {
|
|
39
|
+
ui2.provide(ui$1.ACTIONS_SERVICE, handle);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
exports.default = ui;
|
|
43
|
+
};
|
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
(globalThis.__DSC_UI_FACTORIES__ ??= {})["ask"] = function (require, module, exports) {
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
|
|
4
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
5
|
+
const react = require("react");
|
|
6
|
+
const reactDom = require("react-dom");
|
|
7
|
+
const ui$1 = require("@dsc/ui");
|
|
8
|
+
const uiPrimitives = require("@dsc/ui-primitives");
|
|
9
|
+
const MIN_SELECTION_CHARS = 4;
|
|
10
|
+
const MAX_SELECTION_CHARS = 8e3;
|
|
11
|
+
const ANCHOR_GAP = 8;
|
|
12
|
+
const BUBBLE_W = 92;
|
|
13
|
+
const BUBBLE_H = 30;
|
|
14
|
+
function normalizeSelection(raw) {
|
|
15
|
+
const lines = raw.replace(/\r\n?/g, "\n").split("\n").map((line) => line.replace(/[ \t\u00a0]+/g, " ").trim());
|
|
16
|
+
const kept = [];
|
|
17
|
+
for (const line of lines) {
|
|
18
|
+
if (line === "" && kept.length > 0 && kept[kept.length - 1] === "") continue;
|
|
19
|
+
kept.push(line);
|
|
20
|
+
}
|
|
21
|
+
const text = kept.join("\n").trim();
|
|
22
|
+
if (text.length < MIN_SELECTION_CHARS) return null;
|
|
23
|
+
if (text.length <= MAX_SELECTION_CHARS) return text;
|
|
24
|
+
return text.slice(0, MAX_SELECTION_CHARS) + "…";
|
|
25
|
+
}
|
|
26
|
+
function anchorOf(selection, viewport) {
|
|
27
|
+
const maxLeft = Math.max(ANCHOR_GAP, viewport.width - BUBBLE_W - ANCHOR_GAP);
|
|
28
|
+
const left = Math.min(Math.max(ANCHOR_GAP, selection.right - BUBBLE_W), maxLeft);
|
|
29
|
+
const below = selection.bottom + ANCHOR_GAP;
|
|
30
|
+
const top = below + BUBBLE_H <= viewport.height - ANCHOR_GAP ? below : Math.max(ANCHOR_GAP, selection.top - BUBBLE_H - ANCHOR_GAP);
|
|
31
|
+
return { left, top };
|
|
32
|
+
}
|
|
33
|
+
const EMPTY = Object.freeze([]);
|
|
34
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
35
|
+
const askChannel = ui$1.createSignal(0);
|
|
36
|
+
let pendingQuote = null;
|
|
37
|
+
let pendingVersionOf = 0;
|
|
38
|
+
function subscribeAsk(listener) {
|
|
39
|
+
return askChannel.subscribe(listener);
|
|
40
|
+
}
|
|
41
|
+
function askSnapshot(sessionId) {
|
|
42
|
+
return buckets.get(sessionId) ?? EMPTY;
|
|
43
|
+
}
|
|
44
|
+
function pendingVersion() {
|
|
45
|
+
return pendingVersionOf;
|
|
46
|
+
}
|
|
47
|
+
function takePendingQuote() {
|
|
48
|
+
const quote = pendingQuote;
|
|
49
|
+
pendingQuote = null;
|
|
50
|
+
return quote;
|
|
51
|
+
}
|
|
52
|
+
function requestAskOpen(quote) {
|
|
53
|
+
pendingQuote = quote ?? null;
|
|
54
|
+
pendingVersionOf += 1;
|
|
55
|
+
askChannel.notify();
|
|
56
|
+
}
|
|
57
|
+
function updateAsk(sessionId, change) {
|
|
58
|
+
buckets.set(sessionId, change(askSnapshot(sessionId)));
|
|
59
|
+
askChannel.notify();
|
|
60
|
+
}
|
|
61
|
+
function addBubble(sessionId, bubble) {
|
|
62
|
+
updateAsk(sessionId, (list) => [...list, bubble]);
|
|
63
|
+
}
|
|
64
|
+
function patchBubble(sessionId, id, patch) {
|
|
65
|
+
updateAsk(sessionId, (list) => list.map((item) => item.id === id ? { ...item, ...patch } : item));
|
|
66
|
+
}
|
|
67
|
+
function appendAnswer(sessionId, id, delta) {
|
|
68
|
+
if (delta === "") return;
|
|
69
|
+
updateAsk(sessionId, (list) => list.map((item) => item.id === id ? { ...item, answer: item.answer + delta } : item));
|
|
70
|
+
}
|
|
71
|
+
function removeBubble(sessionId, id) {
|
|
72
|
+
updateAsk(sessionId, (list) => list.filter((item) => item.id !== id));
|
|
73
|
+
}
|
|
74
|
+
const ASK_MODEL_KEY = "dsc.ask.model";
|
|
75
|
+
function readSessionId(snapshot) {
|
|
76
|
+
const status = snapshot?.["status"];
|
|
77
|
+
if (typeof status !== "object" || status === null) return null;
|
|
78
|
+
const id = status["sessionId"];
|
|
79
|
+
return typeof id === "string" && id !== "" ? id : null;
|
|
80
|
+
}
|
|
81
|
+
function currentSelection() {
|
|
82
|
+
const selection = window.getSelection();
|
|
83
|
+
if (selection === null || selection.isCollapsed) return null;
|
|
84
|
+
const node = selection.anchorNode;
|
|
85
|
+
const host = node === null ? null : node instanceof Element ? node : node.parentElement;
|
|
86
|
+
if (host === null || host.closest(".chat") === null) return null;
|
|
87
|
+
return normalizeSelection(selection.toString());
|
|
88
|
+
}
|
|
89
|
+
function openAsk(quote) {
|
|
90
|
+
requestAskOpen(quote);
|
|
91
|
+
ui$1.openDockTab("ask");
|
|
92
|
+
}
|
|
93
|
+
const ui = ui$1.defineUiPlugin({
|
|
94
|
+
name: "旁问",
|
|
95
|
+
apply(ui2) {
|
|
96
|
+
ui$1.registerDockTab({
|
|
97
|
+
kind: "ask",
|
|
98
|
+
label: "旁问",
|
|
99
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconSpark, { size: 13 }),
|
|
100
|
+
component: AskTab,
|
|
101
|
+
// 切页签只藏不卸:正在回答的那条不该被切走打断(答案回来时还要写进气泡)。
|
|
102
|
+
keepMounted: true
|
|
103
|
+
});
|
|
104
|
+
ui2.slots.register("shell.header", { id: "ask.triggers", order: 80 }, AskTriggers);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
function AskTriggers() {
|
|
108
|
+
const actions = ui$1.useService(ui$1.ACTIONS_SERVICE);
|
|
109
|
+
react.useEffect(() => {
|
|
110
|
+
if (actions === void 0) return void 0;
|
|
111
|
+
return actions.register("ask", [
|
|
112
|
+
{
|
|
113
|
+
id: "ask.open",
|
|
114
|
+
label: "打开旁问",
|
|
115
|
+
hint: "在右侧栏问一句,不动主会话",
|
|
116
|
+
group: "旁问",
|
|
117
|
+
keywords: ["btw", "side", "ask", "问", "旁问"],
|
|
118
|
+
shortcut: "Ctrl+Shift+K",
|
|
119
|
+
run: () => {
|
|
120
|
+
openAsk();
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: "ask.selection",
|
|
125
|
+
label: "就选中内容旁问",
|
|
126
|
+
hint: "把正文里选中的文字带进旁问",
|
|
127
|
+
group: "旁问",
|
|
128
|
+
keywords: ["选中", "selection", "explain", "解释"],
|
|
129
|
+
run: () => {
|
|
130
|
+
const quote = currentSelection();
|
|
131
|
+
if (quote === null) {
|
|
132
|
+
openAsk();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
openAsk(quote);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
]);
|
|
139
|
+
}, [actions]);
|
|
140
|
+
react.useEffect(() => {
|
|
141
|
+
const onKey = (event) => {
|
|
142
|
+
if (!event.ctrlKey || !event.shiftKey || event.key.toLowerCase() !== "k") return;
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
openAsk(currentSelection() ?? void 0);
|
|
145
|
+
};
|
|
146
|
+
window.addEventListener("keydown", onKey);
|
|
147
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
148
|
+
}, []);
|
|
149
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SelectionBubble, {});
|
|
150
|
+
}
|
|
151
|
+
function SelectionBubble() {
|
|
152
|
+
const [pick, setPick] = react.useState(null);
|
|
153
|
+
react.useEffect(() => {
|
|
154
|
+
let timer = 0;
|
|
155
|
+
const read = () => {
|
|
156
|
+
const selection = window.getSelection();
|
|
157
|
+
if (selection === null || selection.isCollapsed || selection.rangeCount === 0) {
|
|
158
|
+
setPick(null);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const range = selection.getRangeAt(0);
|
|
162
|
+
const node = range.commonAncestorContainer;
|
|
163
|
+
const host = node instanceof Element ? node : node.parentElement;
|
|
164
|
+
if (host === null || host.closest(".chat") === null) {
|
|
165
|
+
setPick(null);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const text = normalizeSelection(selection.toString());
|
|
169
|
+
if (text === null) {
|
|
170
|
+
setPick(null);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const box = range.getBoundingClientRect();
|
|
174
|
+
const anchor = anchorOf(
|
|
175
|
+
{ left: box.left, top: box.top, right: box.right, bottom: box.bottom },
|
|
176
|
+
{ width: window.innerWidth, height: window.innerHeight }
|
|
177
|
+
);
|
|
178
|
+
setPick({ text, ...anchor });
|
|
179
|
+
};
|
|
180
|
+
const later = () => {
|
|
181
|
+
window.clearTimeout(timer);
|
|
182
|
+
timer = window.setTimeout(read, 0);
|
|
183
|
+
};
|
|
184
|
+
const onDown = (event) => {
|
|
185
|
+
if (event.target instanceof Element && event.target.closest(".ask-sel-btn") !== null) return;
|
|
186
|
+
later();
|
|
187
|
+
};
|
|
188
|
+
const onScroll = () => {
|
|
189
|
+
setPick(null);
|
|
190
|
+
};
|
|
191
|
+
document.addEventListener("mouseup", onDown);
|
|
192
|
+
document.addEventListener("keyup", later);
|
|
193
|
+
window.addEventListener("scroll", onScroll, true);
|
|
194
|
+
return () => {
|
|
195
|
+
window.clearTimeout(timer);
|
|
196
|
+
document.removeEventListener("mouseup", onDown);
|
|
197
|
+
document.removeEventListener("keyup", later);
|
|
198
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
199
|
+
};
|
|
200
|
+
}, []);
|
|
201
|
+
if (pick === null) return null;
|
|
202
|
+
return reactDom.createPortal(
|
|
203
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
204
|
+
"button",
|
|
205
|
+
{
|
|
206
|
+
type: "button",
|
|
207
|
+
className: "ask-sel-btn",
|
|
208
|
+
style: { left: pick.left, top: pick.top },
|
|
209
|
+
onMouseDown: (event) => {
|
|
210
|
+
event.preventDefault();
|
|
211
|
+
},
|
|
212
|
+
onClick: () => {
|
|
213
|
+
openAsk(pick.text);
|
|
214
|
+
setPick(null);
|
|
215
|
+
},
|
|
216
|
+
children: [
|
|
217
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconSpark, { size: 13 }),
|
|
218
|
+
"问 AI"
|
|
219
|
+
]
|
|
220
|
+
}
|
|
221
|
+
),
|
|
222
|
+
document.body
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
function AskTab({ active }) {
|
|
226
|
+
const channel = ui$1.useHostChannel();
|
|
227
|
+
const sessionId = ui$1.useHostSelector(readSessionId) ?? "";
|
|
228
|
+
const bubbles = react.useSyncExternalStore(
|
|
229
|
+
subscribeAsk,
|
|
230
|
+
() => askSnapshot(sessionId),
|
|
231
|
+
() => askSnapshot(sessionId)
|
|
232
|
+
);
|
|
233
|
+
const openVersion = react.useSyncExternalStore(subscribeAsk, pendingVersion, pendingVersion);
|
|
234
|
+
const [question, setQuestion] = react.useState("");
|
|
235
|
+
const [quote, setQuote] = react.useState("");
|
|
236
|
+
const input = react.useRef(null);
|
|
237
|
+
const list = react.useRef(null);
|
|
238
|
+
const [picked, setPicked] = react.useState(() => window.localStorage.getItem(ASK_MODEL_KEY) ?? "");
|
|
239
|
+
const [models, setModels] = react.useState([]);
|
|
240
|
+
react.useEffect(() => {
|
|
241
|
+
void channel.invoke("listModels").then((rows) => {
|
|
242
|
+
setModels(Array.isArray(rows) ? rows : []);
|
|
243
|
+
}).catch(() => void 0);
|
|
244
|
+
}, [channel]);
|
|
245
|
+
ui$1.useAskStream((chunk) => {
|
|
246
|
+
appendAnswer(sessionId, chunk.id, chunk.delta);
|
|
247
|
+
});
|
|
248
|
+
react.useEffect(() => {
|
|
249
|
+
const element = list.current;
|
|
250
|
+
if (element !== null) element.scrollTop = element.scrollHeight;
|
|
251
|
+
}, [bubbles]);
|
|
252
|
+
react.useEffect(() => {
|
|
253
|
+
if (active) input.current?.focus();
|
|
254
|
+
}, [active]);
|
|
255
|
+
react.useEffect(() => {
|
|
256
|
+
const pending = takePendingQuote();
|
|
257
|
+
if (pending === null) return;
|
|
258
|
+
setQuote(pending);
|
|
259
|
+
window.setTimeout(() => input.current?.focus(), 0);
|
|
260
|
+
}, [openVersion]);
|
|
261
|
+
const send = () => {
|
|
262
|
+
const text = question.trim();
|
|
263
|
+
if (text === "") return;
|
|
264
|
+
const id = "ask-" + String(Date.now()) + "-" + Math.random().toString(36).slice(2, 8);
|
|
265
|
+
const cited = quote;
|
|
266
|
+
const choice = models.find((item) => item.value === picked);
|
|
267
|
+
addBubble(sessionId, { id, question: text, quote: cited, answer: "", status: "running" });
|
|
268
|
+
setQuestion("");
|
|
269
|
+
setQuote("");
|
|
270
|
+
void channel.invoke("sideAsk", [text, cited, id, choice?.provider ?? "", choice?.model ?? ""]).then((result) => {
|
|
271
|
+
patchBubble(sessionId, id, {
|
|
272
|
+
answer: result.text,
|
|
273
|
+
status: result.stopped ? "stopped" : "done",
|
|
274
|
+
model: result.model,
|
|
275
|
+
ms: result.ms
|
|
276
|
+
});
|
|
277
|
+
}).catch((error) => {
|
|
278
|
+
patchBubble(sessionId, id, { status: "error", error: uiPrimitives.humanErrorText(error).text });
|
|
279
|
+
});
|
|
280
|
+
};
|
|
281
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ask", children: [
|
|
282
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "ask-list", ref: list, children: bubbles.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ask-empty", children: [
|
|
283
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ask-empty-icon", children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconSpark, { size: 18 }) }),
|
|
284
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "ask-empty-title", children: "只回答,不动手" }),
|
|
285
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "ask-empty-desc", children: "在左边正文里选中一段文字,点浮出的「问 AI」;也可以直接在下面提问。 旁问不会执行工具、不会写进主会话,答案只留在这个面板里。" })
|
|
286
|
+
] }) : bubbles.map((bubble) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
287
|
+
AskCard,
|
|
288
|
+
{
|
|
289
|
+
bubble,
|
|
290
|
+
onStop: () => {
|
|
291
|
+
void channel.invoke("sideAskCancel", [bubble.id]);
|
|
292
|
+
},
|
|
293
|
+
onRemove: () => {
|
|
294
|
+
removeBubble(sessionId, bubble.id);
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
bubble.id
|
|
298
|
+
)) }),
|
|
299
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ask-composer", children: [
|
|
300
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ask-model", children: [
|
|
301
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ask-model-label", children: "模型" }),
|
|
302
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
303
|
+
uiPrimitives.Select,
|
|
304
|
+
{
|
|
305
|
+
value: picked,
|
|
306
|
+
ariaLabel: "旁问使用的模型",
|
|
307
|
+
className: "ask-model-select",
|
|
308
|
+
options: [
|
|
309
|
+
{ value: "", label: "跟随主会话" },
|
|
310
|
+
...models.map((item) => ({ value: item.value, label: item.providerDisplayName + " · " + item.model }))
|
|
311
|
+
],
|
|
312
|
+
onPick: (value) => {
|
|
313
|
+
setPicked(value);
|
|
314
|
+
window.localStorage.setItem(ASK_MODEL_KEY, value);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
)
|
|
318
|
+
] }),
|
|
319
|
+
quote === "" ? null : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ask-quote-chip", children: [
|
|
320
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ask-quote-text", children: quote }),
|
|
321
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
322
|
+
"button",
|
|
323
|
+
{
|
|
324
|
+
type: "button",
|
|
325
|
+
className: "ask-quote-drop",
|
|
326
|
+
"aria-label": "去掉这段引用",
|
|
327
|
+
onClick: () => {
|
|
328
|
+
setQuote("");
|
|
329
|
+
},
|
|
330
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconClose, { size: 12 })
|
|
331
|
+
}
|
|
332
|
+
)
|
|
333
|
+
] }),
|
|
334
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
335
|
+
"textarea",
|
|
336
|
+
{
|
|
337
|
+
ref: input,
|
|
338
|
+
className: "ask-input",
|
|
339
|
+
rows: 2,
|
|
340
|
+
value: question,
|
|
341
|
+
placeholder: "问点什么(Enter 发送,Shift+Enter 换行)",
|
|
342
|
+
"aria-label": "旁问的问题",
|
|
343
|
+
onChange: (event) => {
|
|
344
|
+
setQuestion(event.target.value);
|
|
345
|
+
},
|
|
346
|
+
onKeyDown: (event) => {
|
|
347
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
348
|
+
event.preventDefault();
|
|
349
|
+
send();
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
),
|
|
354
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
355
|
+
"button",
|
|
356
|
+
{
|
|
357
|
+
type: "button",
|
|
358
|
+
className: "ask-send",
|
|
359
|
+
disabled: question.trim() === "",
|
|
360
|
+
"aria-label": "发送旁问",
|
|
361
|
+
onClick: send,
|
|
362
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconArrowUp, { size: 14 })
|
|
363
|
+
}
|
|
364
|
+
)
|
|
365
|
+
] })
|
|
366
|
+
] });
|
|
367
|
+
}
|
|
368
|
+
function AskCard(props) {
|
|
369
|
+
const { bubble } = props;
|
|
370
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("article", { className: "ask-bubble", "data-status": bubble.status, children: [
|
|
371
|
+
bubble.quote === "" ? null : /* @__PURE__ */ jsxRuntime.jsx("blockquote", { className: "ask-quote", children: bubble.quote }),
|
|
372
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "ask-q", children: bubble.question }),
|
|
373
|
+
bubble.status === "error" ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "ask-error", children: bubble.error }) : bubble.status === "running" && bubble.answer === "" ? (
|
|
374
|
+
// 还没吐第一个字:三点呼吸占位。
|
|
375
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ask-typing", role: "status", "aria-label": "正在回答", children: [
|
|
376
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", {}),
|
|
377
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", {}),
|
|
378
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", {})
|
|
379
|
+
] })
|
|
380
|
+
) : (
|
|
381
|
+
// 流式:已经到的正文先画出来,末尾给一个闪动的光标;收尾后光标自己消失。
|
|
382
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ask-a", children: [
|
|
383
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.MarkdownView, { text: bubble.answer, path: "" }),
|
|
384
|
+
bubble.status === "running" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ask-caret", "aria-hidden": "true" }) : null
|
|
385
|
+
] })
|
|
386
|
+
),
|
|
387
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ask-foot", children: [
|
|
388
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ask-meta", children: bubble.status === "running" ? "正在回答…" : bubble.status === "stopped" ? "已停止" : bubble.model === void 0 ? "" : bubble.model + (bubble.ms === void 0 ? "" : " · " + (bubble.ms / 1e3).toFixed(1) + "s") }),
|
|
389
|
+
bubble.status === "running" ? /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "ask-stop", onClick: props.onStop, children: "停止" }) : null,
|
|
390
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
391
|
+
"button",
|
|
392
|
+
{
|
|
393
|
+
type: "button",
|
|
394
|
+
className: "ask-icon-btn",
|
|
395
|
+
"aria-label": "复制这条答案",
|
|
396
|
+
disabled: bubble.answer === "",
|
|
397
|
+
onClick: () => {
|
|
398
|
+
void navigator.clipboard.writeText(bubble.answer).then(
|
|
399
|
+
() => {
|
|
400
|
+
ui$1.toastOk("答案已复制");
|
|
401
|
+
},
|
|
402
|
+
() => {
|
|
403
|
+
ui$1.toastOk("复制失败,请手动选中");
|
|
404
|
+
}
|
|
405
|
+
);
|
|
406
|
+
},
|
|
407
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCopy, { size: 13 })
|
|
408
|
+
}
|
|
409
|
+
),
|
|
410
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "ask-icon-btn", "aria-label": "删掉这条", onClick: props.onRemove, children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconClose, { size: 13 }) })
|
|
411
|
+
] })
|
|
412
|
+
] });
|
|
413
|
+
}
|
|
414
|
+
exports.default = ui;
|
|
415
|
+
};
|