@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,1843 @@
|
|
|
1
|
+
(globalThis.__DSC_UI_FACTORIES__ ??= {})["composer"] = 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 ui$1 = require("@dsc/ui");
|
|
7
|
+
const MAX_FILES = 500;
|
|
8
|
+
const MAX_DEPTH = 4;
|
|
9
|
+
const CACHE_MS = 6e4;
|
|
10
|
+
const MAX_CANDIDATES = 8;
|
|
11
|
+
let cache$1 = null;
|
|
12
|
+
async function listWorkspaceFiles(channel) {
|
|
13
|
+
if (cache$1 !== null && Date.now() - cache$1.at < CACHE_MS) return cache$1.files;
|
|
14
|
+
const files = [];
|
|
15
|
+
const walk = async (dir, depth) => {
|
|
16
|
+
if (depth > MAX_DEPTH || files.length >= MAX_FILES) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
let entries = [];
|
|
20
|
+
try {
|
|
21
|
+
const listing = await channel.invoke("dock", [
|
|
22
|
+
"fs-list",
|
|
23
|
+
{ dir }
|
|
24
|
+
]);
|
|
25
|
+
entries = listing.entries ?? [];
|
|
26
|
+
} catch {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
for (const entry of entries) {
|
|
30
|
+
const path = dir === "." ? entry.name : `${dir}/${entry.name}`;
|
|
31
|
+
if (entry.dir) {
|
|
32
|
+
await walk(path, depth + 1);
|
|
33
|
+
if (files.length >= MAX_FILES) return;
|
|
34
|
+
} else {
|
|
35
|
+
files.push(path.replaceAll("\\", "/"));
|
|
36
|
+
if (files.length >= MAX_FILES) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
await walk(".", 1);
|
|
43
|
+
cache$1 = { at: Date.now(), files };
|
|
44
|
+
return files;
|
|
45
|
+
}
|
|
46
|
+
function rankFiles(files, query) {
|
|
47
|
+
const q = query.toLowerCase();
|
|
48
|
+
const scored = [];
|
|
49
|
+
for (const path of files) {
|
|
50
|
+
const lower = path.toLowerCase();
|
|
51
|
+
const nameAt = lower.lastIndexOf("/");
|
|
52
|
+
const name = nameAt < 0 ? lower : lower.slice(nameAt + 1);
|
|
53
|
+
let score = null;
|
|
54
|
+
if (q === "") score = 0;
|
|
55
|
+
else if (name.startsWith(q)) score = 0;
|
|
56
|
+
else if (name.includes(q)) score = 1;
|
|
57
|
+
else if (lower.includes(q)) score = 2;
|
|
58
|
+
if (score !== null) scored.push({ path, score });
|
|
59
|
+
}
|
|
60
|
+
return scored.sort((left, right) => left.score - right.score || left.path.length - right.path.length).slice(0, MAX_CANDIDATES).map((item) => item.path);
|
|
61
|
+
}
|
|
62
|
+
function tokenBefore(value, caret) {
|
|
63
|
+
let at = -1;
|
|
64
|
+
for (let index = caret - 1; index >= 0; index -= 1) {
|
|
65
|
+
const char = value[index];
|
|
66
|
+
if (char === "@") {
|
|
67
|
+
at = index;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
if (char === " " || char === "\n" || char === " ") return null;
|
|
71
|
+
}
|
|
72
|
+
if (at < 0) return null;
|
|
73
|
+
const query = value.slice(at + 1, caret);
|
|
74
|
+
if (query.length > 120) return null;
|
|
75
|
+
return { from: at, query };
|
|
76
|
+
}
|
|
77
|
+
function useMention(options) {
|
|
78
|
+
const { channel, area, apply } = options;
|
|
79
|
+
const [open, setOpen] = react.useState(false);
|
|
80
|
+
const [items, setItems] = react.useState([]);
|
|
81
|
+
const [loading, setLoading] = react.useState(false);
|
|
82
|
+
const [at, setAt] = react.useState(0);
|
|
83
|
+
const latest = react.useRef(null);
|
|
84
|
+
const dismissed = react.useRef(null);
|
|
85
|
+
const current = react.useRef([]);
|
|
86
|
+
const track = (value, caret) => {
|
|
87
|
+
const token = tokenBefore(value, caret);
|
|
88
|
+
if (token === null) {
|
|
89
|
+
latest.current = null;
|
|
90
|
+
if (open) setOpen(false);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const key = `${token.from}:${token.query}`;
|
|
94
|
+
if (dismissed.current === key) return;
|
|
95
|
+
latest.current = { value, caret, ...token };
|
|
96
|
+
setOpen(true);
|
|
97
|
+
if (cache$1 === null) {
|
|
98
|
+
setLoading(true);
|
|
99
|
+
void listWorkspaceFiles(channel).then((files) => {
|
|
100
|
+
const ranked = rankFiles(files, token.query);
|
|
101
|
+
current.current = ranked;
|
|
102
|
+
setItems(ranked);
|
|
103
|
+
setAt(0);
|
|
104
|
+
setLoading(false);
|
|
105
|
+
}).catch(() => {
|
|
106
|
+
setLoading(false);
|
|
107
|
+
});
|
|
108
|
+
} else {
|
|
109
|
+
const ranked = rankFiles(cache$1.files, token.query);
|
|
110
|
+
current.current = ranked;
|
|
111
|
+
setItems(ranked);
|
|
112
|
+
setAt(0);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const move = (delta) => {
|
|
116
|
+
const count = current.current.length;
|
|
117
|
+
if (count === 0) return;
|
|
118
|
+
setAt((index) => (index + delta + count) % count);
|
|
119
|
+
};
|
|
120
|
+
const close = () => {
|
|
121
|
+
const token = latest.current;
|
|
122
|
+
if (token !== null) dismissed.current = `${token.from}:${token.query}`;
|
|
123
|
+
latest.current = null;
|
|
124
|
+
setOpen(false);
|
|
125
|
+
};
|
|
126
|
+
const pick = () => {
|
|
127
|
+
const token = latest.current;
|
|
128
|
+
const path = current.current[at];
|
|
129
|
+
if (token === null || path === void 0) return;
|
|
130
|
+
const before = token.value.slice(0, token.from);
|
|
131
|
+
const after = token.value.slice(token.caret);
|
|
132
|
+
const inserted = `@${path} `;
|
|
133
|
+
const next = `${before}${inserted}${after}`;
|
|
134
|
+
const caret = token.from + inserted.length;
|
|
135
|
+
latest.current = null;
|
|
136
|
+
setOpen(false);
|
|
137
|
+
apply(next, caret);
|
|
138
|
+
area.current?.focus();
|
|
139
|
+
};
|
|
140
|
+
return { open, items, loading, at, track, move, pick, close };
|
|
141
|
+
}
|
|
142
|
+
function commandQuery(value, caret) {
|
|
143
|
+
if (!value.startsWith("/")) return null;
|
|
144
|
+
if (caret < 1) return null;
|
|
145
|
+
const word = value.slice(1, caret);
|
|
146
|
+
if (/\s/.test(word)) return null;
|
|
147
|
+
return word.toLowerCase();
|
|
148
|
+
}
|
|
149
|
+
function filterCommands(commands, query) {
|
|
150
|
+
const lower = query.toLowerCase();
|
|
151
|
+
return commands.filter((command) => command.name.toLowerCase().startsWith(lower));
|
|
152
|
+
}
|
|
153
|
+
function insertCommand(command) {
|
|
154
|
+
return `/${command.name}${command.args === "" ? "" : " "}`;
|
|
155
|
+
}
|
|
156
|
+
function blockedNow(command, working) {
|
|
157
|
+
return working && command.duringTask === "deny";
|
|
158
|
+
}
|
|
159
|
+
let cache = null;
|
|
160
|
+
let unavailable = false;
|
|
161
|
+
function useCommandMenu(options) {
|
|
162
|
+
const { channel, apply, onUnavailable } = options;
|
|
163
|
+
const [open, setOpen] = react.useState(false);
|
|
164
|
+
const [rows, setRows] = react.useState([]);
|
|
165
|
+
const [loading, setLoading] = react.useState(false);
|
|
166
|
+
const [at, setAt] = react.useState(0);
|
|
167
|
+
const latest = react.useRef(null);
|
|
168
|
+
const dismissed = react.useRef(null);
|
|
169
|
+
const current = react.useRef([]);
|
|
170
|
+
const show = (query) => {
|
|
171
|
+
const filtered = filterCommands(cache ?? [], query);
|
|
172
|
+
current.current = filtered;
|
|
173
|
+
setRows(filtered);
|
|
174
|
+
setAt(0);
|
|
175
|
+
};
|
|
176
|
+
const track = (value, caret) => {
|
|
177
|
+
const query = commandQuery(value, caret);
|
|
178
|
+
if (query === null || unavailable) {
|
|
179
|
+
latest.current = null;
|
|
180
|
+
if (open) setOpen(false);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
if (cache !== null) {
|
|
184
|
+
if (dismissed.current === query) return;
|
|
185
|
+
latest.current = { value, caret, query };
|
|
186
|
+
setOpen(true);
|
|
187
|
+
show(query);
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (dismissed.current === query) return;
|
|
191
|
+
latest.current = { value, caret, query };
|
|
192
|
+
setOpen(true);
|
|
193
|
+
setLoading(true);
|
|
194
|
+
void channel.invoke("listUiCommands").then((list) => {
|
|
195
|
+
cache = Array.isArray(list) ? list : [];
|
|
196
|
+
setLoading(false);
|
|
197
|
+
const now = latest.current;
|
|
198
|
+
if (now !== null) show(now.query);
|
|
199
|
+
}).catch(() => {
|
|
200
|
+
unavailable = true;
|
|
201
|
+
setLoading(false);
|
|
202
|
+
latest.current = null;
|
|
203
|
+
setOpen(false);
|
|
204
|
+
onUnavailable?.();
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
const move = (delta) => {
|
|
208
|
+
const count = current.current.length;
|
|
209
|
+
if (count === 0) return;
|
|
210
|
+
setAt((index) => (index + delta + count) % count);
|
|
211
|
+
};
|
|
212
|
+
const close = () => {
|
|
213
|
+
const token = latest.current;
|
|
214
|
+
if (token !== null) dismissed.current = token.query;
|
|
215
|
+
latest.current = null;
|
|
216
|
+
setOpen(false);
|
|
217
|
+
};
|
|
218
|
+
const pick = () => {
|
|
219
|
+
const inserted = insertText();
|
|
220
|
+
if (inserted === null) return;
|
|
221
|
+
latest.current = null;
|
|
222
|
+
dismissed.current = null;
|
|
223
|
+
setOpen(false);
|
|
224
|
+
apply(inserted, inserted.length);
|
|
225
|
+
};
|
|
226
|
+
const insertText = () => {
|
|
227
|
+
if (latest.current === null) return null;
|
|
228
|
+
const command = current.current[at];
|
|
229
|
+
return command === void 0 ? null : insertCommand(command);
|
|
230
|
+
};
|
|
231
|
+
return { open, rows, loading, at, track, move, pick, close, insertText };
|
|
232
|
+
}
|
|
233
|
+
const EMPTY_DRAFT = { value: "", history: [] };
|
|
234
|
+
function draftScopeOf(input) {
|
|
235
|
+
if (input.unsaved && input.cwd !== "") {
|
|
236
|
+
return { key: `new:${input.cwd}`, sessionId: input.sessionId, unsaved: true };
|
|
237
|
+
}
|
|
238
|
+
return { key: input.sessionPath, sessionId: input.sessionId, unsaved: false };
|
|
239
|
+
}
|
|
240
|
+
function carryDraft(store, previous, next, current) {
|
|
241
|
+
if (previous.key === next.key) return current;
|
|
242
|
+
const sameSessionSettled = previous.unsaved && !next.unsaved && previous.sessionId !== "" && previous.sessionId === next.sessionId;
|
|
243
|
+
if (sameSessionSettled) store.set(previous.key, EMPTY_DRAFT);
|
|
244
|
+
else store.set(previous.key, current);
|
|
245
|
+
return store.get(next.key) ?? EMPTY_DRAFT;
|
|
246
|
+
}
|
|
247
|
+
const TEAMMATE_REPORT_OPEN = "<teammate-report ";
|
|
248
|
+
const REVIEW_FINDINGS_OPEN = "<review-findings ";
|
|
249
|
+
const MESSAGE_OPEN = "<message ";
|
|
250
|
+
const DETAIL_CHARS = 120;
|
|
251
|
+
function attrOf(text, key) {
|
|
252
|
+
const match = new RegExp(`${key}="([^"]*)"`).exec(text);
|
|
253
|
+
return match?.[1] ?? "";
|
|
254
|
+
}
|
|
255
|
+
function flatten(text) {
|
|
256
|
+
const flat = text.replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim();
|
|
257
|
+
const chars = Array.from(flat);
|
|
258
|
+
return chars.length > DETAIL_CHARS ? `${chars.slice(0, DETAIL_CHARS).join("")}…` : flat;
|
|
259
|
+
}
|
|
260
|
+
function summarizeNotice(text) {
|
|
261
|
+
if (text.startsWith(TEAMMATE_REPORT_OPEN)) {
|
|
262
|
+
const name = attrOf(text, "from");
|
|
263
|
+
const state = attrOf(text, "state");
|
|
264
|
+
const who = name === "" ? "一个队友" : `队友 ${name}`;
|
|
265
|
+
const reportAt = text.indexOf("它的汇报:");
|
|
266
|
+
const body = reportAt === -1 ? text : text.slice(reportAt + "它的汇报:".length);
|
|
267
|
+
return {
|
|
268
|
+
label: `${who}${state === "" ? "" : ` ${state}`},汇报了,本步结束会交给模型`,
|
|
269
|
+
detail: flatten(body)
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
if (text.startsWith(REVIEW_FINDINGS_OPEN)) {
|
|
273
|
+
const name = attrOf(text, "teammate");
|
|
274
|
+
const state = attrOf(text, "state");
|
|
275
|
+
const who = name === "" ? "审查队友" : `审查队友 ${name}`;
|
|
276
|
+
const open = text.indexOf(">");
|
|
277
|
+
const close = text.lastIndexOf("</review-findings>");
|
|
278
|
+
const body = open === -1 ? text : close === -1 ? text.slice(open + 1) : text.slice(open + 1, close);
|
|
279
|
+
return {
|
|
280
|
+
label: `${who}${state === "" ? "" : ` ${state}`},交回了 findings,本步结束会交给模型`,
|
|
281
|
+
detail: flatten(body)
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
if (text.startsWith(MESSAGE_OPEN)) {
|
|
285
|
+
const from = attrOf(text, "from");
|
|
286
|
+
const who = from === "" || from === "user" ? "队友" : `队友 ${from}`;
|
|
287
|
+
const open = text.indexOf(">");
|
|
288
|
+
const close = text.lastIndexOf("</message>");
|
|
289
|
+
const body = open === -1 ? text : close === -1 ? text.slice(open + 1) : text.slice(open + 1, close);
|
|
290
|
+
return {
|
|
291
|
+
label: `${who} 传来一条消息,本步结束会交给模型`,
|
|
292
|
+
detail: flatten(body)
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
return { label: "有一条待投递通知,本步结束会交给模型", detail: flatten(text) };
|
|
296
|
+
}
|
|
297
|
+
const EFFORT_LABELS = {
|
|
298
|
+
default: "默认",
|
|
299
|
+
off: "关",
|
|
300
|
+
low: "低",
|
|
301
|
+
high: "高",
|
|
302
|
+
max: "最大"
|
|
303
|
+
};
|
|
304
|
+
const EFFORT_FALLBACK = ["default", "off", "low", "high", "max"];
|
|
305
|
+
function groupModels(choices) {
|
|
306
|
+
const groups = /* @__PURE__ */ new Map();
|
|
307
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
308
|
+
for (const choice of choices) {
|
|
309
|
+
const bucket = buckets.get(choice.provider);
|
|
310
|
+
if (bucket === void 0) buckets.set(choice.provider, [choice]);
|
|
311
|
+
else bucket.push(choice);
|
|
312
|
+
if (!groups.has(choice.provider)) {
|
|
313
|
+
groups.set(choice.provider, {
|
|
314
|
+
provider: choice.provider,
|
|
315
|
+
displayName: choice.providerDisplayName === "" ? choice.provider : choice.providerDisplayName,
|
|
316
|
+
models: []
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return [...groups.values()].map((group) => ({
|
|
321
|
+
...group,
|
|
322
|
+
models: buckets.get(group.provider) ?? []
|
|
323
|
+
}));
|
|
324
|
+
}
|
|
325
|
+
function findCurrent(groups, provider, model) {
|
|
326
|
+
if (model === "") return { entry: void 0, group: void 0, exact: false };
|
|
327
|
+
if (provider !== "") {
|
|
328
|
+
const group = groups.find((item) => item.provider === provider);
|
|
329
|
+
const entry = group?.models.find((item) => item.model === model);
|
|
330
|
+
if (entry !== void 0 && group !== void 0) return { entry, group, exact: true };
|
|
331
|
+
}
|
|
332
|
+
for (const group of groups) {
|
|
333
|
+
const entry = group.models.find((item) => item.value === model);
|
|
334
|
+
if (entry !== void 0) return { entry, group, exact: group.provider === provider };
|
|
335
|
+
}
|
|
336
|
+
for (const group of groups) {
|
|
337
|
+
const entry = group.models.find((item) => item.model === model);
|
|
338
|
+
if (entry !== void 0) return { entry, group, exact: false };
|
|
339
|
+
}
|
|
340
|
+
return { entry: void 0, group: void 0, exact: false };
|
|
341
|
+
}
|
|
342
|
+
function modelChipText(groups, provider, model) {
|
|
343
|
+
const current = findCurrent(groups, provider, model);
|
|
344
|
+
const name = current.entry?.model ?? (model === "" ? "未知模型" : model);
|
|
345
|
+
const displayName = current.group?.displayName ?? groups.find((item) => item.provider === provider)?.displayName ?? provider;
|
|
346
|
+
const usable = groups.length > 1 && displayName !== "" && name !== "未知模型";
|
|
347
|
+
const prefix = usable ? `${displayName}/` : "";
|
|
348
|
+
return { prefix, name, full: `${prefix}${name}` };
|
|
349
|
+
}
|
|
350
|
+
function effortChoices(entry) {
|
|
351
|
+
if (entry === void 0) return EFFORT_FALLBACK;
|
|
352
|
+
const levels = entry.thinkingLevels;
|
|
353
|
+
const rest = [];
|
|
354
|
+
for (const level of levels) {
|
|
355
|
+
if (level === "off" || level === "low" || level === "high" || level === "max") rest.push(level);
|
|
356
|
+
}
|
|
357
|
+
return ["default", ...rest];
|
|
358
|
+
}
|
|
359
|
+
function effortSwitchable(options) {
|
|
360
|
+
return options.length > 1;
|
|
361
|
+
}
|
|
362
|
+
function effortLabel(effort) {
|
|
363
|
+
return EFFORT_LABELS[effort] ?? effort;
|
|
364
|
+
}
|
|
365
|
+
function modelBadges(entry) {
|
|
366
|
+
const badges = [];
|
|
367
|
+
if (entry.modalities.includes("image")) badges.push("图");
|
|
368
|
+
if (entry.modalities.includes("video")) badges.push("视频");
|
|
369
|
+
return badges;
|
|
370
|
+
}
|
|
371
|
+
function contextLabel(contextWindow) {
|
|
372
|
+
if (!Number.isFinite(contextWindow) || contextWindow <= 0) return "";
|
|
373
|
+
return `${Math.round(contextWindow / 1e3)}k`;
|
|
374
|
+
}
|
|
375
|
+
function shouldShowProviderLevel(groups) {
|
|
376
|
+
return groups.length > 1;
|
|
377
|
+
}
|
|
378
|
+
function providerHint(group, current) {
|
|
379
|
+
if (current.group === void 0 || current.group.provider !== group.provider) return "";
|
|
380
|
+
if (current.entry === void 0) return "";
|
|
381
|
+
return current.entry.model;
|
|
382
|
+
}
|
|
383
|
+
const FLYOUT_WIDTH = 264;
|
|
384
|
+
const FLYOUT_MAX_HEIGHT = 288;
|
|
385
|
+
function chooseFlyoutSide(panel, bounds, cardWidth, gap = 6, margin = 8) {
|
|
386
|
+
const roomRight = bounds.right - margin - panel.right;
|
|
387
|
+
const roomLeft = panel.left - bounds.left - margin;
|
|
388
|
+
if (roomRight >= cardWidth + gap) return "right";
|
|
389
|
+
if (roomLeft >= cardWidth + gap) return "left";
|
|
390
|
+
return "overlay";
|
|
391
|
+
}
|
|
392
|
+
function clampShift(panel, bounds, margin = 4) {
|
|
393
|
+
const overLeft = bounds.left + margin - panel.left;
|
|
394
|
+
if (overLeft > 0) return overLeft;
|
|
395
|
+
const overRight = panel.right - (bounds.right - margin);
|
|
396
|
+
if (overRight > 0) return -overRight;
|
|
397
|
+
return 0;
|
|
398
|
+
}
|
|
399
|
+
function placeFlyout(rowTop, rowBottom, panelHeight, cardHeight, pad = 12) {
|
|
400
|
+
const room = Math.max(0, panelHeight - pad * 2);
|
|
401
|
+
const height = Math.min(cardHeight, FLYOUT_MAX_HEIGHT, room);
|
|
402
|
+
const wanted = rowTop + height <= panelHeight - pad ? rowTop : rowBottom - height;
|
|
403
|
+
const top = Math.max(pad, Math.min(wanted, panelHeight - pad - height));
|
|
404
|
+
return { top, maxHeight: height };
|
|
405
|
+
}
|
|
406
|
+
function filteredBranches(rows, query) {
|
|
407
|
+
const needle = query.trim().toLowerCase();
|
|
408
|
+
if (needle === "") return rows;
|
|
409
|
+
return rows.filter((row) => row.name.toLowerCase().includes(needle));
|
|
410
|
+
}
|
|
411
|
+
function wouldOverwrite(text) {
|
|
412
|
+
return /would be overwritten|Please commit your changes or stash/i.test(text);
|
|
413
|
+
}
|
|
414
|
+
const MAX_INPUT_HEIGHT = 200;
|
|
415
|
+
const PREVIEW_CHARS = 200;
|
|
416
|
+
const HISTORY_LIMIT = 50;
|
|
417
|
+
const EMPTY_PERMISSION_PRESETS = { current: "", defaultName: "", options: [] };
|
|
418
|
+
const EMPTY_PRESET = { current: "", defaultName: "", options: [], droppable: [] };
|
|
419
|
+
const EMPTY_GIT = { repo: false, branch: "", detached: false, dirtyFileCount: 0 };
|
|
420
|
+
const ui = ui$1.defineUiPlugin({
|
|
421
|
+
name: "输入区",
|
|
422
|
+
apply(ui2) {
|
|
423
|
+
ui2.slots.register("shell.composer", { id: "composer.notices", order: 40 }, NoticeStrip);
|
|
424
|
+
ui2.slots.register("shell.composer", { id: "composer.box", order: 50 }, ComposerBox);
|
|
425
|
+
ui2.slots.register("shell.composer", { id: "composer.queue", order: 60 }, QueueDock);
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
function ComposerBox() {
|
|
429
|
+
const channel = ui$1.useHostChannel();
|
|
430
|
+
const turnState = ui$1.useHostSelector(readTurnState);
|
|
431
|
+
const blocked = ui$1.useHostSelector(readHasApproval);
|
|
432
|
+
const queuedCount = ui$1.useHostSelector(readInboxCount);
|
|
433
|
+
const permissionPresets = ui$1.useHostSelector(readPermissionPresets, samePermissionPresets);
|
|
434
|
+
const preset = ui$1.useHostSelector(readPresetSurface, samePresetSurface);
|
|
435
|
+
const git = ui$1.useHostSelector(readGit, sameGit);
|
|
436
|
+
const model = ui$1.useHostSelector(readModel);
|
|
437
|
+
const effort = ui$1.useHostSelector(readEffort);
|
|
438
|
+
const draftKey = ui$1.useHostSelector(readSessionPath);
|
|
439
|
+
const [text, setText] = react.useState("");
|
|
440
|
+
const [fault, setFault] = react.useState(null);
|
|
441
|
+
const [sending, setSending] = react.useState(false);
|
|
442
|
+
const [models, setModels] = react.useState([]);
|
|
443
|
+
const [modelOpen, setModelOpen] = react.useState(false);
|
|
444
|
+
const [effortOpen, setEffortOpen] = react.useState(false);
|
|
445
|
+
const [hoverProvider, setHoverProvider] = react.useState(null);
|
|
446
|
+
const [flyout, setFlyout] = react.useState(null);
|
|
447
|
+
const [flyoutSide, setFlyoutSide] = react.useState("right");
|
|
448
|
+
const [dropPrefix, setDropPrefix] = react.useState(false);
|
|
449
|
+
const [panelShift, setPanelShift] = react.useState(0);
|
|
450
|
+
const [permOpen, setPermOpen] = react.useState(false);
|
|
451
|
+
const [presetOpen, setPresetOpen] = react.useState(false);
|
|
452
|
+
const [branchOpen, setBranchOpen] = react.useState(false);
|
|
453
|
+
const [branchList, setBranchList] = react.useState(null);
|
|
454
|
+
const [branchQuery, setBranchQuery] = react.useState("");
|
|
455
|
+
const [branchBusy, setBranchBusy] = react.useState(false);
|
|
456
|
+
const [branchCreateOpen, setBranchCreateOpen] = react.useState(false);
|
|
457
|
+
const [newBranchName, setNewBranchName] = react.useState("");
|
|
458
|
+
const branchRows = react.useRef(null);
|
|
459
|
+
const modelPanelRef = react.useRef(null);
|
|
460
|
+
const modelRows = react.useRef(null);
|
|
461
|
+
const flyoutCardRef = react.useRef(null);
|
|
462
|
+
const barRef = react.useRef(null);
|
|
463
|
+
const [barWidth, setBarWidth] = react.useState(0);
|
|
464
|
+
react.useEffect(() => {
|
|
465
|
+
const node = barRef.current;
|
|
466
|
+
if (node === null || typeof ResizeObserver === "undefined") return void 0;
|
|
467
|
+
setBarWidth(node.clientWidth);
|
|
468
|
+
const observer = new ResizeObserver(() => {
|
|
469
|
+
setBarWidth(node.clientWidth);
|
|
470
|
+
});
|
|
471
|
+
observer.observe(node);
|
|
472
|
+
return () => {
|
|
473
|
+
observer.disconnect();
|
|
474
|
+
};
|
|
475
|
+
}, []);
|
|
476
|
+
const modelChipRef = react.useRef(null);
|
|
477
|
+
react.useEffect(() => {
|
|
478
|
+
if (!modelOpen && !effortOpen) return void 0;
|
|
479
|
+
const onKey = (event) => {
|
|
480
|
+
if (event.key !== "Escape" || event.defaultPrevented) return;
|
|
481
|
+
event.preventDefault();
|
|
482
|
+
setModelOpen(false);
|
|
483
|
+
setEffortOpen(false);
|
|
484
|
+
};
|
|
485
|
+
window.addEventListener("keydown", onKey);
|
|
486
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
487
|
+
}, [modelOpen, effortOpen]);
|
|
488
|
+
react.useEffect(() => {
|
|
489
|
+
if (!branchOpen) return void 0;
|
|
490
|
+
let alive = true;
|
|
491
|
+
setBranchQuery("");
|
|
492
|
+
setBranchCreateOpen(false);
|
|
493
|
+
setNewBranchName("");
|
|
494
|
+
void channel.invoke("dock", ["git-branches", {}]).then((list) => {
|
|
495
|
+
if (alive) setBranchList(list);
|
|
496
|
+
}).catch((reason) => {
|
|
497
|
+
if (!alive) return;
|
|
498
|
+
setBranchList(null);
|
|
499
|
+
setFault(`读分支清单失败:${reason instanceof Error ? reason.message : String(reason)}`);
|
|
500
|
+
});
|
|
501
|
+
return () => {
|
|
502
|
+
alive = false;
|
|
503
|
+
};
|
|
504
|
+
}, [branchOpen, channel, git.branch]);
|
|
505
|
+
react.useEffect(() => {
|
|
506
|
+
if (!branchOpen || branchList === null) return;
|
|
507
|
+
const node = branchRows.current?.querySelector('[data-branch-current="true"]');
|
|
508
|
+
node?.scrollIntoView({ block: "nearest" });
|
|
509
|
+
}, [branchOpen, branchList]);
|
|
510
|
+
const area = react.useRef(null);
|
|
511
|
+
const history = react.useRef([]);
|
|
512
|
+
const [historyAt, setHistoryAt] = react.useState(null);
|
|
513
|
+
const drafts = react.useRef(/* @__PURE__ */ new Map());
|
|
514
|
+
const draftSessionId = ui$1.useHostSelector(readSessionId);
|
|
515
|
+
const draftCwd = ui$1.useHostSelector(readDraftCwd);
|
|
516
|
+
const draftUnsaved = ui$1.useHostSelector(readSessionUnsaved);
|
|
517
|
+
const draftScope = draftScopeOf({
|
|
518
|
+
sessionPath: draftKey,
|
|
519
|
+
sessionId: draftSessionId,
|
|
520
|
+
cwd: draftCwd,
|
|
521
|
+
unsaved: draftUnsaved
|
|
522
|
+
});
|
|
523
|
+
const draftScopeRef = react.useRef(draftScope);
|
|
524
|
+
const working = turnState !== "idle";
|
|
525
|
+
react.useEffect(() => {
|
|
526
|
+
if (draftScopeRef.current.key === draftScope.key) return;
|
|
527
|
+
const next = carryDraft(drafts.current, draftScopeRef.current, draftScope, {
|
|
528
|
+
value: text,
|
|
529
|
+
history: history.current
|
|
530
|
+
});
|
|
531
|
+
draftScopeRef.current = draftScope;
|
|
532
|
+
setText(next.value);
|
|
533
|
+
history.current = [...next.history];
|
|
534
|
+
setHistoryAt(null);
|
|
535
|
+
}, [draftScope.key, draftScope.sessionId, draftScope.unsaved, text]);
|
|
536
|
+
react.useEffect(() => {
|
|
537
|
+
const node = area.current;
|
|
538
|
+
if (node === null) return;
|
|
539
|
+
node.style.height = "auto";
|
|
540
|
+
node.style.height = `${String(Math.min(node.scrollHeight, MAX_INPUT_HEIGHT))}px`;
|
|
541
|
+
}, [text]);
|
|
542
|
+
react.useEffect(() => {
|
|
543
|
+
let alive = true;
|
|
544
|
+
void channel.invoke("listModels").then((list) => {
|
|
545
|
+
if (alive) setModels(Array.isArray(list) ? list : []);
|
|
546
|
+
}).catch(() => {
|
|
547
|
+
});
|
|
548
|
+
return () => {
|
|
549
|
+
alive = false;
|
|
550
|
+
};
|
|
551
|
+
}, [channel, modelOpen]);
|
|
552
|
+
const send = (steer) => {
|
|
553
|
+
const typed = text.trim();
|
|
554
|
+
const picked = command.open && typed !== "/" ? command.insertText()?.trim() ?? null : null;
|
|
555
|
+
const value = picked ?? typed;
|
|
556
|
+
if (value === "" || blocked || sending) return;
|
|
557
|
+
if (value.startsWith("/")) {
|
|
558
|
+
const target = value;
|
|
559
|
+
setFault(null);
|
|
560
|
+
void channel.invoke("runUiCommand", [target]).then(() => {
|
|
561
|
+
history.current = [...history.current.filter((item) => item !== target), target].slice(-HISTORY_LIMIT);
|
|
562
|
+
setHistoryAt(null);
|
|
563
|
+
setText("");
|
|
564
|
+
}).catch((reason) => {
|
|
565
|
+
const message = reason instanceof Error ? reason.message : String(reason);
|
|
566
|
+
setFault(
|
|
567
|
+
message.includes("协议不允许调用的方法") ? "“/” 命令要宿主支持:当前宿主没把这条路接到界面通道,请在桌面端或终端里执行" : message
|
|
568
|
+
);
|
|
569
|
+
});
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
const steerIndex = steer && working ? queuedCount : null;
|
|
573
|
+
setSending(true);
|
|
574
|
+
setFault(null);
|
|
575
|
+
void (async () => {
|
|
576
|
+
try {
|
|
577
|
+
await channel.invoke("submit", [value]);
|
|
578
|
+
history.current = [...history.current.filter((item) => item !== value), value].slice(-HISTORY_LIMIT);
|
|
579
|
+
setHistoryAt(null);
|
|
580
|
+
void channel.invoke("refreshSessions").catch(() => void 0);
|
|
581
|
+
if (steerIndex !== null) {
|
|
582
|
+
const done = await channel.invoke("steerQueued", [steerIndex]);
|
|
583
|
+
if (done !== true) setFault("插话没赶上:这一轮刚结束,这条消息会自己发出去");
|
|
584
|
+
}
|
|
585
|
+
setText("");
|
|
586
|
+
} catch (reason) {
|
|
587
|
+
setFault(reason instanceof Error ? reason.message : String(reason));
|
|
588
|
+
} finally {
|
|
589
|
+
setSending(false);
|
|
590
|
+
}
|
|
591
|
+
})();
|
|
592
|
+
};
|
|
593
|
+
const interrupt = () => {
|
|
594
|
+
setFault(null);
|
|
595
|
+
void channel.invoke("interrupt").catch((reason) => {
|
|
596
|
+
setFault(reason instanceof Error ? reason.message : String(reason));
|
|
597
|
+
});
|
|
598
|
+
};
|
|
599
|
+
const choosePermissionPreset = (name, label) => {
|
|
600
|
+
setPermOpen(false);
|
|
601
|
+
setFault(null);
|
|
602
|
+
const native = ui$1.getHostNative();
|
|
603
|
+
if (!native.available) {
|
|
604
|
+
setFault("切权限预设这条口子只在桌面窗口里开(浏览器页签与远程页面够不着),请用桌面端或终端改");
|
|
605
|
+
return;
|
|
606
|
+
}
|
|
607
|
+
void native.invoke("usePermissionPreset", [name]).then(() => {
|
|
608
|
+
ui$1.toastOk(`权限预设已切到「${label}」`);
|
|
609
|
+
}).catch((reason) => {
|
|
610
|
+
setFault(`切权限预设失败:${reason instanceof Error ? reason.message : String(reason)}`);
|
|
611
|
+
});
|
|
612
|
+
};
|
|
613
|
+
const choosePreset = (name, label) => {
|
|
614
|
+
setPresetOpen(false);
|
|
615
|
+
setFault(null);
|
|
616
|
+
void channel.invoke("usePreset", [name]).then(() => {
|
|
617
|
+
ui$1.toastOk(`已切到「${label}」模式`);
|
|
618
|
+
}).catch((reason) => {
|
|
619
|
+
ui$1.toastErr(`切换失败:${reason instanceof Error ? reason.message : String(reason)}`);
|
|
620
|
+
});
|
|
621
|
+
};
|
|
622
|
+
const switchBranch = (name) => {
|
|
623
|
+
setBranchBusy(true);
|
|
624
|
+
setFault(null);
|
|
625
|
+
setBranchOpen(false);
|
|
626
|
+
void channel.invoke("dock", ["git-checkout", { branch: name }], { timeoutMs: ui$1.HUMAN_WAIT_TIMEOUT_MS }).then(() => {
|
|
627
|
+
ui$1.toastOk(`已切到分支「${name}」`);
|
|
628
|
+
}).catch((reason) => {
|
|
629
|
+
const text2 = reason instanceof Error ? reason.message : String(reason);
|
|
630
|
+
setFault(wouldOverwrite(text2) ? `${text2}(先提交或暂存这些改动再切:右侧边栏「变更」页签可以提交)` : text2);
|
|
631
|
+
}).finally(() => {
|
|
632
|
+
setBranchBusy(false);
|
|
633
|
+
});
|
|
634
|
+
};
|
|
635
|
+
const createBranch = () => {
|
|
636
|
+
const name = newBranchName.trim();
|
|
637
|
+
if (name === "") return;
|
|
638
|
+
setBranchBusy(true);
|
|
639
|
+
setFault(null);
|
|
640
|
+
setBranchOpen(false);
|
|
641
|
+
void channel.invoke("dock", ["git-branch-create", { branch: name }], { timeoutMs: ui$1.HUMAN_WAIT_TIMEOUT_MS }).then(() => {
|
|
642
|
+
setBranchCreateOpen(false);
|
|
643
|
+
setNewBranchName("");
|
|
644
|
+
ui$1.toastOk(`已新建并切到分支「${name}」`);
|
|
645
|
+
}).catch((reason) => {
|
|
646
|
+
setFault(reason instanceof Error ? reason.message : String(reason));
|
|
647
|
+
}).finally(() => {
|
|
648
|
+
setBranchBusy(false);
|
|
649
|
+
});
|
|
650
|
+
};
|
|
651
|
+
const mention = useMention({
|
|
652
|
+
channel,
|
|
653
|
+
area,
|
|
654
|
+
apply: (next, caret) => {
|
|
655
|
+
setText(next);
|
|
656
|
+
window.requestAnimationFrame(() => {
|
|
657
|
+
area.current?.setSelectionRange(caret, caret);
|
|
658
|
+
});
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
const command = useCommandMenu({
|
|
662
|
+
channel,
|
|
663
|
+
apply: (next, caret) => {
|
|
664
|
+
setText(next);
|
|
665
|
+
window.requestAnimationFrame(() => {
|
|
666
|
+
area.current?.setSelectionRange(caret, caret);
|
|
667
|
+
});
|
|
668
|
+
},
|
|
669
|
+
onUnavailable: () => {
|
|
670
|
+
setFault("当前宿主没接“/”命令通道:菜单不可用,请用桌面端或终端执行(升级宿主后自动可用)");
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
const onKeyDown = (event) => {
|
|
674
|
+
if (command.open) {
|
|
675
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
676
|
+
event.preventDefault();
|
|
677
|
+
command.move(event.key === "ArrowDown" ? 1 : -1);
|
|
678
|
+
return;
|
|
679
|
+
}
|
|
680
|
+
if (event.key === "Tab") {
|
|
681
|
+
event.preventDefault();
|
|
682
|
+
event.stopPropagation();
|
|
683
|
+
command.pick();
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
if (event.key === "Escape") {
|
|
687
|
+
event.preventDefault();
|
|
688
|
+
command.close();
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
if (mention.open) {
|
|
693
|
+
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
694
|
+
event.preventDefault();
|
|
695
|
+
mention.move(event.key === "ArrowDown" ? 1 : -1);
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
if (event.key === "Tab" || event.key === "Enter") {
|
|
699
|
+
event.preventDefault();
|
|
700
|
+
event.stopPropagation();
|
|
701
|
+
mention.pick();
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
if (event.key === "Escape") {
|
|
705
|
+
event.preventDefault();
|
|
706
|
+
mention.close();
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
if (event.key === "Enter") {
|
|
711
|
+
if (event.shiftKey || event.nativeEvent.isComposing) return;
|
|
712
|
+
event.preventDefault();
|
|
713
|
+
send(event.ctrlKey || event.metaKey);
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
if (event.key === "ArrowUp" && (text === "" || historyAt !== null) && history.current.length > 0) {
|
|
717
|
+
event.preventDefault();
|
|
718
|
+
const next = historyAt === null ? history.current.length - 1 : Math.max(0, historyAt - 1);
|
|
719
|
+
setHistoryAt(next);
|
|
720
|
+
setText(history.current[next] ?? "");
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
if (event.key === "ArrowDown" && historyAt !== null) {
|
|
724
|
+
event.preventDefault();
|
|
725
|
+
const next = historyAt + 1;
|
|
726
|
+
if (next >= history.current.length) {
|
|
727
|
+
setHistoryAt(null);
|
|
728
|
+
setText("");
|
|
729
|
+
} else {
|
|
730
|
+
setHistoryAt(next);
|
|
731
|
+
setText(history.current[next] ?? "");
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
};
|
|
735
|
+
const onTextChange = (value, caret) => {
|
|
736
|
+
setText(value);
|
|
737
|
+
setHistoryAt(null);
|
|
738
|
+
command.track(value, caret);
|
|
739
|
+
if (commandQuery(value, caret) === null) mention.track(value, caret);
|
|
740
|
+
else mention.close();
|
|
741
|
+
};
|
|
742
|
+
const sendable = text.trim() !== "";
|
|
743
|
+
const queueing = working && sendable;
|
|
744
|
+
const permOption = permissionPresets.options.find((item) => item.name === permissionPresets.current);
|
|
745
|
+
const presetOption = preset.options.find((item) => item.name === preset.current);
|
|
746
|
+
const groups = groupModels(models);
|
|
747
|
+
const provider = ui$1.useHostSelector(readProvider);
|
|
748
|
+
const current = findCurrent(groups, provider, model);
|
|
749
|
+
const chip = modelChipText(groups, provider, model);
|
|
750
|
+
const twoLevel = shouldShowProviderLevel(groups);
|
|
751
|
+
const hoveredGroup = groups.find((item) => item.provider === hoverProvider);
|
|
752
|
+
const visibleModels = twoLevel ? hoveredGroup?.models ?? [] : groups[0]?.models ?? [];
|
|
753
|
+
const flyoutShown = twoLevel && flyout !== null && hoveredGroup !== void 0;
|
|
754
|
+
const levelOptions = effortChoices(current.entry);
|
|
755
|
+
const switchEffort = effortSwitchable(levelOptions);
|
|
756
|
+
const effortText = effortLabel(effort);
|
|
757
|
+
const clipBoxOf = (el) => {
|
|
758
|
+
let node = el.parentElement;
|
|
759
|
+
while (node !== null) {
|
|
760
|
+
if (getComputedStyle(node).overflowX !== "visible") {
|
|
761
|
+
const box = node.getBoundingClientRect();
|
|
762
|
+
return { left: box.left, right: box.right };
|
|
763
|
+
}
|
|
764
|
+
node = node.parentElement;
|
|
765
|
+
}
|
|
766
|
+
return { left: 0, right: window.innerWidth };
|
|
767
|
+
};
|
|
768
|
+
const openFlyout = (providerName, row) => {
|
|
769
|
+
setHoverProvider(providerName);
|
|
770
|
+
const panel = modelPanelRef.current;
|
|
771
|
+
if (panel === null || row === null) return;
|
|
772
|
+
const panelBox = panel.getBoundingClientRect();
|
|
773
|
+
const rowBox = row.getBoundingClientRect();
|
|
774
|
+
setFlyoutSide(
|
|
775
|
+
chooseFlyoutSide(
|
|
776
|
+
{ left: panelBox.left, right: panelBox.right },
|
|
777
|
+
clipBoxOf(panel),
|
|
778
|
+
FLYOUT_WIDTH
|
|
779
|
+
)
|
|
780
|
+
);
|
|
781
|
+
setFlyout(
|
|
782
|
+
placeFlyout(
|
|
783
|
+
rowBox.top - panelBox.top,
|
|
784
|
+
rowBox.bottom - panelBox.top,
|
|
785
|
+
panelBox.height,
|
|
786
|
+
Number.POSITIVE_INFINITY
|
|
787
|
+
)
|
|
788
|
+
);
|
|
789
|
+
};
|
|
790
|
+
react.useLayoutEffect(() => {
|
|
791
|
+
if (hoverProvider === null) return;
|
|
792
|
+
const panel = modelPanelRef.current;
|
|
793
|
+
const card = flyoutCardRef.current;
|
|
794
|
+
if (panel === null || card === null) return;
|
|
795
|
+
const row = panel.querySelector(`[data-model-provider="${CSS.escape(hoverProvider)}"]`);
|
|
796
|
+
if (row === null) return;
|
|
797
|
+
const panelBox = panel.getBoundingClientRect();
|
|
798
|
+
const rowBox = row.getBoundingClientRect();
|
|
799
|
+
const next = placeFlyout(
|
|
800
|
+
rowBox.top - panelBox.top,
|
|
801
|
+
rowBox.bottom - panelBox.top,
|
|
802
|
+
panelBox.height,
|
|
803
|
+
card.scrollHeight
|
|
804
|
+
);
|
|
805
|
+
setFlyout(
|
|
806
|
+
(prev) => prev !== null && prev.top === next.top && prev.maxHeight === next.maxHeight ? prev : next
|
|
807
|
+
);
|
|
808
|
+
}, [hoverProvider, models.length, flyoutSide]);
|
|
809
|
+
react.useLayoutEffect(() => {
|
|
810
|
+
if (!modelOpen) return;
|
|
811
|
+
const panel = modelPanelRef.current;
|
|
812
|
+
if (panel === null) return;
|
|
813
|
+
const box = panel.getBoundingClientRect();
|
|
814
|
+
const shift = clampShift({ left: box.left, right: box.right }, clipBoxOf(panel));
|
|
815
|
+
setPanelShift((prev) => prev === shift ? prev : shift);
|
|
816
|
+
}, [modelOpen, models.length, twoLevel]);
|
|
817
|
+
react.useEffect(() => {
|
|
818
|
+
if (!modelOpen) return;
|
|
819
|
+
if (hoverProvider === null) return;
|
|
820
|
+
modelRows.current?.querySelector('[data-model-current="true"]')?.scrollIntoView({ block: "nearest" });
|
|
821
|
+
}, [modelOpen, hoverProvider, models.length]);
|
|
822
|
+
const modelRowList = (choices) => {
|
|
823
|
+
if (choices.length === 0) {
|
|
824
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pop-item", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "name", children: models.length === 0 ? "清单没取到" : "这个端点还没有模型" }) });
|
|
825
|
+
}
|
|
826
|
+
return choices.map((choice) => {
|
|
827
|
+
const on = current.entry?.value === choice.value;
|
|
828
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
829
|
+
"button",
|
|
830
|
+
{
|
|
831
|
+
type: "button",
|
|
832
|
+
role: "menuitemradio",
|
|
833
|
+
"aria-checked": on,
|
|
834
|
+
className: `pop-item model-picker-row${on ? " on" : ""}`,
|
|
835
|
+
title: choice.description,
|
|
836
|
+
"data-model-current": on ? "true" : void 0,
|
|
837
|
+
onClick: () => {
|
|
838
|
+
setModelOpen(false);
|
|
839
|
+
setFault(null);
|
|
840
|
+
void channel.invoke("setModel", [choice.value]).catch((reason) => {
|
|
841
|
+
setFault(reason instanceof Error ? reason.message : String(reason));
|
|
842
|
+
});
|
|
843
|
+
},
|
|
844
|
+
children: [
|
|
845
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "name", children: choice.model }),
|
|
846
|
+
modelBadges(choice).map((badge) => /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pop-badge", children: badge }, badge)),
|
|
847
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "ctx", children: contextLabel(choice.contextWindow) }),
|
|
848
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "model-picker-check", children: on ? /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCheck, { size: 14, className: "check" }) : null })
|
|
849
|
+
]
|
|
850
|
+
},
|
|
851
|
+
choice.value
|
|
852
|
+
);
|
|
853
|
+
});
|
|
854
|
+
};
|
|
855
|
+
const chipMeasureKey = `${chip.full}|${String(models.length)}|${String(barWidth)}`;
|
|
856
|
+
react.useLayoutEffect(() => {
|
|
857
|
+
setDropPrefix(false);
|
|
858
|
+
}, [chipMeasureKey]);
|
|
859
|
+
react.useLayoutEffect(() => {
|
|
860
|
+
if (dropPrefix) return;
|
|
861
|
+
const node = modelChipRef.current;
|
|
862
|
+
const bar = barRef.current;
|
|
863
|
+
if (node === null || bar === null) return;
|
|
864
|
+
const cut = (selector) => {
|
|
865
|
+
const el = node.querySelector(selector);
|
|
866
|
+
return el !== null && el.scrollWidth > el.clientWidth + 1;
|
|
867
|
+
};
|
|
868
|
+
const tight = cut(".model-name") || cut(".composer-model-provider") || bar.scrollWidth > bar.clientWidth + 1;
|
|
869
|
+
if (tight) setDropPrefix(true);
|
|
870
|
+
}, [dropPrefix, chipMeasureKey]);
|
|
871
|
+
const openModelsSettings = () => {
|
|
872
|
+
window.dispatchEvent(new CustomEvent("shell.settings.open", { detail: { section: "models" } }));
|
|
873
|
+
};
|
|
874
|
+
const placeholder = blocked ? "等待审批…" : working ? "回合进行中:回车把消息排进队里,Ctrl+Enter 插话(打断当前输出)" : "发消息,@ 引用文件,回车发送,Ctrl+Enter 插话";
|
|
875
|
+
return (
|
|
876
|
+
// 这一层是「输入框外面那一列」:分支行在上、输入框在下,各占一行、各带自己的边。
|
|
877
|
+
// 为什么不让分支行长在 `.composer` 里(原来就是):`.composer` 是带描边和圆角的
|
|
878
|
+
// 输入框本体,住在里面的东西会被同一个外框一起圈住,分支钮看着就成了输入框的一部分
|
|
879
|
+
// (用户报「git 管理按钮,需要与输入框作出区分」)。参考实现里这一行也在输入框上方的
|
|
880
|
+
// 框外。`.composer-zone` 的「与正文列同宽」打在插件根节点上,所以这一层要接住它。
|
|
881
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "composer-stack", style: { marginTop: 10 }, children: [
|
|
882
|
+
git.repo ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "composer-git", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "model-anchor", children: [
|
|
883
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
884
|
+
"button",
|
|
885
|
+
{
|
|
886
|
+
type: "button",
|
|
887
|
+
className: `model-btn git-btn${branchOpen ? " open" : ""}`,
|
|
888
|
+
"data-tip": git.detached ? "HEAD 已分离(不在任何分支上);点开可以切回一个分支" : `当前分支:${git.branch}`,
|
|
889
|
+
"aria-haspopup": "menu",
|
|
890
|
+
"aria-expanded": branchOpen,
|
|
891
|
+
onClick: () => {
|
|
892
|
+
setBranchOpen((open) => !open);
|
|
893
|
+
setPermOpen(false);
|
|
894
|
+
setPresetOpen(false);
|
|
895
|
+
setModelOpen(false);
|
|
896
|
+
setEffortOpen(false);
|
|
897
|
+
},
|
|
898
|
+
children: [
|
|
899
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconBranch, { size: 13 }),
|
|
900
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "git-branch-name", children: git.branch }),
|
|
901
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconChevronDown, { size: 12 })
|
|
902
|
+
]
|
|
903
|
+
}
|
|
904
|
+
),
|
|
905
|
+
branchOpen ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
906
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
907
|
+
"div",
|
|
908
|
+
{
|
|
909
|
+
className: "pop-mask",
|
|
910
|
+
onClick: () => {
|
|
911
|
+
setBranchOpen(false);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
),
|
|
915
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "model-pop git-pop", role: "menu", "aria-label": "切换分支", children: [
|
|
916
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pop-label", children: [
|
|
917
|
+
"切换分支",
|
|
918
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "pop-note", children: [
|
|
919
|
+
branchList?.detached === true ? "HEAD 已分离" : `当前 ${branchList?.current ?? git.branch}`,
|
|
920
|
+
git.dirtyFileCount > 0 ? ` · ${String(git.dirtyFileCount)} 个文件已更改` : ""
|
|
921
|
+
] })
|
|
922
|
+
] }),
|
|
923
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "git-search", children: [
|
|
924
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconSearch, { size: 13 }),
|
|
925
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
926
|
+
"input",
|
|
927
|
+
{
|
|
928
|
+
type: "text",
|
|
929
|
+
value: branchQuery,
|
|
930
|
+
placeholder: "搜索分支…",
|
|
931
|
+
"aria-label": "搜索分支",
|
|
932
|
+
autoFocus: true,
|
|
933
|
+
onChange: (event) => {
|
|
934
|
+
setBranchQuery(event.target.value);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
)
|
|
938
|
+
] }),
|
|
939
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "model-list git-branch-list", ref: branchRows, children: branchList === null ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pop-item", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "name", children: "正在读取分支…" }) }) : filteredBranches(branchList.branches, branchQuery).length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pop-item", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "name", children: branchQuery.trim() === "" ? "这个仓库还没有分支" : "没有匹配的分支" }) }) : filteredBranches(branchList.branches, branchQuery).map((row) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
940
|
+
"button",
|
|
941
|
+
{
|
|
942
|
+
type: "button",
|
|
943
|
+
role: "menuitemradio",
|
|
944
|
+
"aria-checked": row.current,
|
|
945
|
+
className: `pop-item${row.current ? " on" : ""}`,
|
|
946
|
+
title: row.current ? `${row.name}(当前分支)` : `切到 ${row.name}`,
|
|
947
|
+
disabled: row.current || branchBusy,
|
|
948
|
+
...row.current ? { "data-branch-current": "true" } : {},
|
|
949
|
+
onClick: () => {
|
|
950
|
+
switchBranch(row.name);
|
|
951
|
+
},
|
|
952
|
+
children: [
|
|
953
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconBranch, { size: 13, className: "git-item-icon" }),
|
|
954
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "name", children: row.name }),
|
|
955
|
+
row.current ? /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCheck, { size: 14, className: "check" }) : null
|
|
956
|
+
]
|
|
957
|
+
},
|
|
958
|
+
row.name
|
|
959
|
+
)) }),
|
|
960
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "git-foot", children: branchCreateOpen ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
961
|
+
"form",
|
|
962
|
+
{
|
|
963
|
+
className: "git-create",
|
|
964
|
+
onSubmit: (event) => {
|
|
965
|
+
event.preventDefault();
|
|
966
|
+
createBranch();
|
|
967
|
+
},
|
|
968
|
+
children: [
|
|
969
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
970
|
+
"input",
|
|
971
|
+
{
|
|
972
|
+
type: "text",
|
|
973
|
+
value: newBranchName,
|
|
974
|
+
placeholder: "新分支名,如 feat/xxx",
|
|
975
|
+
"aria-label": "新分支名",
|
|
976
|
+
autoFocus: true,
|
|
977
|
+
disabled: branchBusy,
|
|
978
|
+
onChange: (event) => {
|
|
979
|
+
setNewBranchName(event.target.value);
|
|
980
|
+
},
|
|
981
|
+
onKeyDown: (event) => {
|
|
982
|
+
if (event.key === "Escape") {
|
|
983
|
+
event.preventDefault();
|
|
984
|
+
setBranchCreateOpen(false);
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
),
|
|
989
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", disabled: branchBusy || newBranchName.trim() === "", children: "创建并切换" })
|
|
990
|
+
]
|
|
991
|
+
}
|
|
992
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
993
|
+
"button",
|
|
994
|
+
{
|
|
995
|
+
type: "button",
|
|
996
|
+
className: "git-foot-btn",
|
|
997
|
+
disabled: branchBusy,
|
|
998
|
+
onClick: () => {
|
|
999
|
+
setBranchCreateOpen(true);
|
|
1000
|
+
},
|
|
1001
|
+
children: [
|
|
1002
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconPlus, { size: 13 }),
|
|
1003
|
+
"新建分支…"
|
|
1004
|
+
]
|
|
1005
|
+
}
|
|
1006
|
+
) })
|
|
1007
|
+
] })
|
|
1008
|
+
] }) : null
|
|
1009
|
+
] }) }) : null,
|
|
1010
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1011
|
+
"div",
|
|
1012
|
+
{
|
|
1013
|
+
className: "composer",
|
|
1014
|
+
onClick: (event) => {
|
|
1015
|
+
const target = event.target;
|
|
1016
|
+
if (target !== null && target.closest("button, textarea, input, .model-pop, .pop-mask") !== null) return;
|
|
1017
|
+
area.current?.focus();
|
|
1018
|
+
},
|
|
1019
|
+
onPaste: (event) => {
|
|
1020
|
+
if (event.clipboardData.files.length === 0) return;
|
|
1021
|
+
setFault("贴图这一版还不支持:界面通道的单图上限只有 32KB,普通截图压到那个档位已经看不清了");
|
|
1022
|
+
},
|
|
1023
|
+
onDrop: (event) => {
|
|
1024
|
+
if (event.dataTransfer.files.length === 0) return;
|
|
1025
|
+
event.preventDefault();
|
|
1026
|
+
setFault("拖文件进来这一版还不支持:界面通道目前只能发文本");
|
|
1027
|
+
},
|
|
1028
|
+
onDragOver: (event) => {
|
|
1029
|
+
if (event.dataTransfer.types.includes("Files")) event.preventDefault();
|
|
1030
|
+
},
|
|
1031
|
+
children: [
|
|
1032
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1033
|
+
"textarea",
|
|
1034
|
+
{
|
|
1035
|
+
ref: area,
|
|
1036
|
+
rows: 1,
|
|
1037
|
+
value: text,
|
|
1038
|
+
placeholder,
|
|
1039
|
+
disabled: blocked,
|
|
1040
|
+
"aria-label": "消息输入框",
|
|
1041
|
+
onChange: (event) => {
|
|
1042
|
+
onTextChange(event.target.value, event.target.selectionStart ?? event.target.value.length);
|
|
1043
|
+
},
|
|
1044
|
+
onKeyDown
|
|
1045
|
+
}
|
|
1046
|
+
),
|
|
1047
|
+
command.open ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "slash-pop", role: "listbox", "aria-label": "命令候选", children: [
|
|
1048
|
+
command.loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "slash-item", "data-loading": "1", children: "正在读取命令清单…" }) : command.rows.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "slash-item", "data-empty": "1", children: "没有匹配的命令" }) : command.rows.map((row, index) => {
|
|
1049
|
+
const off = blockedNow(row, working);
|
|
1050
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1051
|
+
"button",
|
|
1052
|
+
{
|
|
1053
|
+
type: "button",
|
|
1054
|
+
role: "option",
|
|
1055
|
+
"aria-selected": index === command.at,
|
|
1056
|
+
className: `slash-item${index === command.at ? " on" : ""}${off ? " off" : ""}`,
|
|
1057
|
+
title: row.description,
|
|
1058
|
+
onMouseDown: (event) => {
|
|
1059
|
+
event.preventDefault();
|
|
1060
|
+
command.pick();
|
|
1061
|
+
},
|
|
1062
|
+
children: [
|
|
1063
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "slash-name", children: [
|
|
1064
|
+
"/",
|
|
1065
|
+
row.name
|
|
1066
|
+
] }),
|
|
1067
|
+
row.args === "" ? null : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "slash-args", children: row.args }),
|
|
1068
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "slash-desc", children: row.description }),
|
|
1069
|
+
off ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "slash-flag", children: "回合中不可用" }) : null
|
|
1070
|
+
]
|
|
1071
|
+
},
|
|
1072
|
+
row.name
|
|
1073
|
+
);
|
|
1074
|
+
}),
|
|
1075
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "slash-hint", children: "↑↓ 选 · Tab 补全 · Enter 执行 · Esc 关闭" })
|
|
1076
|
+
] }) : null,
|
|
1077
|
+
mention.open ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mention-pop", role: "listbox", "aria-label": "文件提及候选", children: [
|
|
1078
|
+
mention.loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mention-item", "data-loading": "1", children: "正在读取工作区文件…" }) : mention.items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mention-item", "data-empty": "1", children: "没有匹配的文件" }) : mention.items.map((path, index) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1079
|
+
"button",
|
|
1080
|
+
{
|
|
1081
|
+
type: "button",
|
|
1082
|
+
role: "option",
|
|
1083
|
+
"aria-selected": index === mention.at,
|
|
1084
|
+
className: `mention-item${index === mention.at ? " on" : ""}`,
|
|
1085
|
+
title: path,
|
|
1086
|
+
onMouseDown: (event) => {
|
|
1087
|
+
event.preventDefault();
|
|
1088
|
+
mention.pick();
|
|
1089
|
+
},
|
|
1090
|
+
children: path
|
|
1091
|
+
},
|
|
1092
|
+
path
|
|
1093
|
+
)),
|
|
1094
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mention-hint", children: "↑↓ 选 · Tab/Enter 补全 · Esc 关闭" })
|
|
1095
|
+
] }) : null,
|
|
1096
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "composer-bar", ref: barRef, children: [
|
|
1097
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bar-left", children: [
|
|
1098
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1099
|
+
"button",
|
|
1100
|
+
{
|
|
1101
|
+
type: "button",
|
|
1102
|
+
className: "icon-btn",
|
|
1103
|
+
"data-tip": "插入指令(/)",
|
|
1104
|
+
"aria-label": "插入指令",
|
|
1105
|
+
onClick: () => {
|
|
1106
|
+
if (text.trim() !== "") return;
|
|
1107
|
+
setText("/");
|
|
1108
|
+
window.requestAnimationFrame(() => {
|
|
1109
|
+
area.current?.focus();
|
|
1110
|
+
area.current?.setSelectionRange(1, 1);
|
|
1111
|
+
});
|
|
1112
|
+
},
|
|
1113
|
+
children: "+"
|
|
1114
|
+
}
|
|
1115
|
+
),
|
|
1116
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "model-anchor model-anchor-sheet", children: [
|
|
1117
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1118
|
+
"button",
|
|
1119
|
+
{
|
|
1120
|
+
type: "button",
|
|
1121
|
+
className: `model-btn${permOpen ? " open" : ""}`,
|
|
1122
|
+
"data-tip": permOption?.description ?? "当前三项旋钮的组合不匹配任何预设;在设置里逐格改出来的状态",
|
|
1123
|
+
"aria-haspopup": "menu",
|
|
1124
|
+
"aria-expanded": permOpen,
|
|
1125
|
+
onClick: () => {
|
|
1126
|
+
setPermOpen((open) => !open);
|
|
1127
|
+
setPresetOpen(false);
|
|
1128
|
+
setModelOpen(false);
|
|
1129
|
+
setEffortOpen(false);
|
|
1130
|
+
setBranchOpen(false);
|
|
1131
|
+
},
|
|
1132
|
+
children: [
|
|
1133
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconShield, { size: 13 }),
|
|
1134
|
+
permOption?.label ?? "自定义",
|
|
1135
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconChevronDown, { size: 12 })
|
|
1136
|
+
]
|
|
1137
|
+
}
|
|
1138
|
+
),
|
|
1139
|
+
permOpen ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1140
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1141
|
+
"div",
|
|
1142
|
+
{
|
|
1143
|
+
className: "pop-mask",
|
|
1144
|
+
onClick: () => {
|
|
1145
|
+
setPermOpen(false);
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
),
|
|
1149
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "model-pop policy-pop", role: "menu", "aria-label": "权限预设", children: [
|
|
1150
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pop-label", children: [
|
|
1151
|
+
"权限预设",
|
|
1152
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pop-note", children: "沙箱 + 权限 + 审阅者 三合一" })
|
|
1153
|
+
] }),
|
|
1154
|
+
permissionPresets.options.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pop-item", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "name", children: "清单没取到" }) }) : permissionPresets.options.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1155
|
+
"button",
|
|
1156
|
+
{
|
|
1157
|
+
type: "button",
|
|
1158
|
+
role: "menuitemradio",
|
|
1159
|
+
"aria-checked": item.name === permissionPresets.current,
|
|
1160
|
+
className: `pop-item${item.name === permissionPresets.current ? " on" : ""}`,
|
|
1161
|
+
title: item.description,
|
|
1162
|
+
disabled: item.name === permissionPresets.current,
|
|
1163
|
+
onClick: () => {
|
|
1164
|
+
choosePermissionPreset(item.name, item.label);
|
|
1165
|
+
},
|
|
1166
|
+
children: [
|
|
1167
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "name", children: item.label }),
|
|
1168
|
+
item.name === permissionPresets.current ? /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCheck, { size: 14, className: "check" }) : null
|
|
1169
|
+
]
|
|
1170
|
+
},
|
|
1171
|
+
item.name
|
|
1172
|
+
))
|
|
1173
|
+
] })
|
|
1174
|
+
] }) : null
|
|
1175
|
+
] }),
|
|
1176
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "model-anchor model-anchor-sheet", children: [
|
|
1177
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1178
|
+
"button",
|
|
1179
|
+
{
|
|
1180
|
+
type: "button",
|
|
1181
|
+
className: `model-btn${presetOpen ? " open" : ""}`,
|
|
1182
|
+
"data-tip": presetOption?.problem ?? presetOption?.description ?? "模式:模型是谁、手上有什么、被叮嘱了什么",
|
|
1183
|
+
"aria-haspopup": "menu",
|
|
1184
|
+
"aria-expanded": presetOpen,
|
|
1185
|
+
onClick: () => {
|
|
1186
|
+
setPresetOpen((open) => !open);
|
|
1187
|
+
setPermOpen(false);
|
|
1188
|
+
setModelOpen(false);
|
|
1189
|
+
setEffortOpen(false);
|
|
1190
|
+
setBranchOpen(false);
|
|
1191
|
+
},
|
|
1192
|
+
children: [
|
|
1193
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconLayers, { size: 13 }),
|
|
1194
|
+
presetOption?.label ?? preset.current,
|
|
1195
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconChevronDown, { size: 12 })
|
|
1196
|
+
]
|
|
1197
|
+
}
|
|
1198
|
+
),
|
|
1199
|
+
presetOpen ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1200
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1201
|
+
"div",
|
|
1202
|
+
{
|
|
1203
|
+
className: "pop-mask",
|
|
1204
|
+
onClick: () => {
|
|
1205
|
+
setPresetOpen(false);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
),
|
|
1209
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "model-pop preset-pop", role: "menu", "aria-label": "模式", children: [
|
|
1210
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pop-label", children: [
|
|
1211
|
+
"模式",
|
|
1212
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "pop-note", children: "新建/编辑:设置 → 模式" })
|
|
1213
|
+
] }),
|
|
1214
|
+
preset.options.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pop-item", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "name", children: "清单没取到" }) }) : preset.options.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1215
|
+
"button",
|
|
1216
|
+
{
|
|
1217
|
+
type: "button",
|
|
1218
|
+
role: "menuitemradio",
|
|
1219
|
+
"aria-checked": item.name === preset.current,
|
|
1220
|
+
className: `pop-item${item.name === preset.current ? " on" : ""}`,
|
|
1221
|
+
title: item.problem ?? item.description,
|
|
1222
|
+
disabled: item.name === preset.current,
|
|
1223
|
+
onClick: () => {
|
|
1224
|
+
choosePreset(item.name, item.label);
|
|
1225
|
+
},
|
|
1226
|
+
children: [
|
|
1227
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "name", children: [
|
|
1228
|
+
item.label,
|
|
1229
|
+
item.name === preset.defaultName && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pop-badge", children: "默认" }),
|
|
1230
|
+
item.problem !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pop-badge warn", children: "有问题" })
|
|
1231
|
+
] }),
|
|
1232
|
+
item.name === preset.current ? /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCheck, { size: 14, className: "check" }) : null
|
|
1233
|
+
]
|
|
1234
|
+
},
|
|
1235
|
+
item.name
|
|
1236
|
+
))
|
|
1237
|
+
] })
|
|
1238
|
+
] }) : null
|
|
1239
|
+
] })
|
|
1240
|
+
] }),
|
|
1241
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bar-right", children: [
|
|
1242
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "model-anchor", children: [
|
|
1243
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1244
|
+
"button",
|
|
1245
|
+
{
|
|
1246
|
+
type: "button",
|
|
1247
|
+
ref: modelChipRef,
|
|
1248
|
+
className: `model-btn composer-model-chip${modelOpen ? " open" : ""}`,
|
|
1249
|
+
title: `模型:${chip.full}(点开换)`,
|
|
1250
|
+
"aria-haspopup": "menu",
|
|
1251
|
+
"aria-expanded": modelOpen,
|
|
1252
|
+
"aria-label": `当前模型 ${chip.full}`,
|
|
1253
|
+
"data-composer-model": current.entry?.value ?? chip.full,
|
|
1254
|
+
onClick: () => {
|
|
1255
|
+
setModelOpen((open) => !open);
|
|
1256
|
+
setHoverProvider(null);
|
|
1257
|
+
setFlyout(null);
|
|
1258
|
+
setEffortOpen(false);
|
|
1259
|
+
setPermOpen(false);
|
|
1260
|
+
setPresetOpen(false);
|
|
1261
|
+
setBranchOpen(false);
|
|
1262
|
+
},
|
|
1263
|
+
children: [
|
|
1264
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconPackage, { size: 13 }),
|
|
1265
|
+
chip.prefix === "" || dropPrefix ? null : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "composer-model-provider", children: chip.prefix }),
|
|
1266
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "model-name", children: chip.name }),
|
|
1267
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconChevronDown, { size: 12 })
|
|
1268
|
+
]
|
|
1269
|
+
}
|
|
1270
|
+
),
|
|
1271
|
+
modelOpen ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1272
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1273
|
+
"div",
|
|
1274
|
+
{
|
|
1275
|
+
className: "pop-mask",
|
|
1276
|
+
onClick: () => {
|
|
1277
|
+
setModelOpen(false);
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
),
|
|
1281
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1282
|
+
"div",
|
|
1283
|
+
{
|
|
1284
|
+
className: `model-pop model-picker${twoLevel ? "" : " flat"}`,
|
|
1285
|
+
role: "menu",
|
|
1286
|
+
"aria-label": "选择模型",
|
|
1287
|
+
ref: modelPanelRef,
|
|
1288
|
+
"data-flyout-side": flyoutShown ? flyoutSide : void 0,
|
|
1289
|
+
style: panelShift === 0 ? void 0 : { transform: `translateX(${String(panelShift)}px)` },
|
|
1290
|
+
onMouseLeave: () => {
|
|
1291
|
+
setHoverProvider(null);
|
|
1292
|
+
setFlyout(null);
|
|
1293
|
+
},
|
|
1294
|
+
children: [
|
|
1295
|
+
current.entry === void 0 && model !== "" ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pop-item model-unknown", "data-model-unknown": "true", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "name", children: [
|
|
1296
|
+
"当前:",
|
|
1297
|
+
model,
|
|
1298
|
+
" —— 清单里没有这个模型"
|
|
1299
|
+
] }) }) : null,
|
|
1300
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "model-picker-body", children: twoLevel ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1301
|
+
"div",
|
|
1302
|
+
{
|
|
1303
|
+
className: "model-providers",
|
|
1304
|
+
"data-model-providers": "",
|
|
1305
|
+
onScroll: () => {
|
|
1306
|
+
if (hoverProvider === null) return;
|
|
1307
|
+
const row = modelPanelRef.current?.querySelector(
|
|
1308
|
+
`[data-model-provider="${CSS.escape(hoverProvider)}"]`
|
|
1309
|
+
) ?? null;
|
|
1310
|
+
openFlyout(hoverProvider, row);
|
|
1311
|
+
},
|
|
1312
|
+
children: groups.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pop-item", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "name", children: "清单没取到" }) }) : groups.map((group) => {
|
|
1313
|
+
const owns = current.group?.provider === group.provider;
|
|
1314
|
+
const hint = providerHint(group, current);
|
|
1315
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1316
|
+
"button",
|
|
1317
|
+
{
|
|
1318
|
+
type: "button",
|
|
1319
|
+
role: "menuitem",
|
|
1320
|
+
"aria-current": owns,
|
|
1321
|
+
className: `pop-item provider-row${group.provider === hoverProvider ? " on" : ""}`,
|
|
1322
|
+
"data-model-provider": group.provider,
|
|
1323
|
+
"data-provider-current": owns ? "true" : void 0,
|
|
1324
|
+
title: hint === "" ? `${group.displayName} · ${String(group.models.length)} 个模型` : `${group.displayName} · 当前 ${hint}`,
|
|
1325
|
+
onMouseEnter: (event) => {
|
|
1326
|
+
openFlyout(group.provider, event.currentTarget);
|
|
1327
|
+
},
|
|
1328
|
+
onFocus: (event) => {
|
|
1329
|
+
openFlyout(group.provider, event.currentTarget);
|
|
1330
|
+
},
|
|
1331
|
+
onClick: (event) => {
|
|
1332
|
+
openFlyout(group.provider, event.currentTarget);
|
|
1333
|
+
},
|
|
1334
|
+
children: [
|
|
1335
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "name", children: group.displayName }),
|
|
1336
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "model-picker-check", children: owns ? /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCheck, { size: 13, className: "check" }) : null }),
|
|
1337
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconChevronRight, { size: 12, className: "provider-arrow" })
|
|
1338
|
+
]
|
|
1339
|
+
},
|
|
1340
|
+
group.provider
|
|
1341
|
+
);
|
|
1342
|
+
})
|
|
1343
|
+
}
|
|
1344
|
+
) : modelRowList(visibleModels) }),
|
|
1345
|
+
flyoutShown ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1346
|
+
"div",
|
|
1347
|
+
{
|
|
1348
|
+
className: `model-flyout${flyoutSide === "overlay" ? " model-flyout-inline" : ""}`,
|
|
1349
|
+
"data-model-flyout": "",
|
|
1350
|
+
"data-side": flyoutSide,
|
|
1351
|
+
style: flyoutSide === "overlay" ? void 0 : {
|
|
1352
|
+
"--flyout-top": `${String(flyout.top)}px`,
|
|
1353
|
+
"--flyout-max": `${String(flyout.maxHeight)}px`,
|
|
1354
|
+
"--flyout-w": `${String(FLYOUT_WIDTH)}px`
|
|
1355
|
+
},
|
|
1356
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1357
|
+
"div",
|
|
1358
|
+
{
|
|
1359
|
+
className: "model-flyout-card",
|
|
1360
|
+
role: "menu",
|
|
1361
|
+
"aria-label": `${hoveredGroup.displayName} 的模型`,
|
|
1362
|
+
ref: flyoutCardRef,
|
|
1363
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "model-picker-rows", "data-model-rows": "", ref: modelRows, children: modelRowList(visibleModels) })
|
|
1364
|
+
}
|
|
1365
|
+
)
|
|
1366
|
+
}
|
|
1367
|
+
) : null,
|
|
1368
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1369
|
+
"button",
|
|
1370
|
+
{
|
|
1371
|
+
type: "button",
|
|
1372
|
+
className: "pop-item model-manage",
|
|
1373
|
+
"data-model-manage": "",
|
|
1374
|
+
onClick: () => {
|
|
1375
|
+
setModelOpen(false);
|
|
1376
|
+
openModelsSettings();
|
|
1377
|
+
},
|
|
1378
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "name", children: "管理模型" })
|
|
1379
|
+
}
|
|
1380
|
+
)
|
|
1381
|
+
]
|
|
1382
|
+
}
|
|
1383
|
+
)
|
|
1384
|
+
] }) : null
|
|
1385
|
+
] }),
|
|
1386
|
+
switchEffort ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "model-anchor model-anchor-sheet", children: [
|
|
1387
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1388
|
+
"button",
|
|
1389
|
+
{
|
|
1390
|
+
type: "button",
|
|
1391
|
+
className: `model-btn composer-effort-chip${effortOpen ? " open" : ""}`,
|
|
1392
|
+
title: `思考强度:${effortText}(点开换档)`,
|
|
1393
|
+
"aria-haspopup": "menu",
|
|
1394
|
+
"aria-expanded": effortOpen,
|
|
1395
|
+
"aria-label": `当前思考强度 ${effortText}`,
|
|
1396
|
+
"data-composer-effort": effort,
|
|
1397
|
+
onClick: () => {
|
|
1398
|
+
setEffortOpen((open) => !open);
|
|
1399
|
+
setModelOpen(false);
|
|
1400
|
+
setPermOpen(false);
|
|
1401
|
+
setPresetOpen(false);
|
|
1402
|
+
setBranchOpen(false);
|
|
1403
|
+
},
|
|
1404
|
+
children: [
|
|
1405
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconBrain, { size: 13 }),
|
|
1406
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "model-name", children: effortText }),
|
|
1407
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconChevronDown, { size: 12 })
|
|
1408
|
+
]
|
|
1409
|
+
}
|
|
1410
|
+
),
|
|
1411
|
+
effortOpen ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1412
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1413
|
+
"div",
|
|
1414
|
+
{
|
|
1415
|
+
className: "pop-mask",
|
|
1416
|
+
onClick: () => {
|
|
1417
|
+
setEffortOpen(false);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
),
|
|
1421
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "model-pop effort-pop", role: "menu", "aria-label": "思考强度", children: [
|
|
1422
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pop-label", children: [
|
|
1423
|
+
"思考强度",
|
|
1424
|
+
current.entry === void 0 && model !== "" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pop-note", children: "模型不在清单里,列的是全部档位" }) : null
|
|
1425
|
+
] }),
|
|
1426
|
+
levelOptions.map((level) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1427
|
+
"button",
|
|
1428
|
+
{
|
|
1429
|
+
type: "button",
|
|
1430
|
+
role: "menuitemradio",
|
|
1431
|
+
"aria-checked": level === effort,
|
|
1432
|
+
className: `pop-item${level === effort ? " on" : ""}`,
|
|
1433
|
+
"data-effort-option": level,
|
|
1434
|
+
onClick: () => {
|
|
1435
|
+
setEffortOpen(false);
|
|
1436
|
+
setFault(null);
|
|
1437
|
+
void channel.invoke("setEffort", [level]).catch((reason) => {
|
|
1438
|
+
setFault(reason instanceof Error ? reason.message : String(reason));
|
|
1439
|
+
});
|
|
1440
|
+
},
|
|
1441
|
+
children: [
|
|
1442
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "name", children: effortLabel(level) }),
|
|
1443
|
+
level === effort ? /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCheck, { size: 14, className: "check" }) : null
|
|
1444
|
+
]
|
|
1445
|
+
},
|
|
1446
|
+
level
|
|
1447
|
+
))
|
|
1448
|
+
] })
|
|
1449
|
+
] }) : null
|
|
1450
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1451
|
+
"span",
|
|
1452
|
+
{
|
|
1453
|
+
className: "model-btn composer-effort-chip fixed",
|
|
1454
|
+
title: `思考强度:${effortText}(这个模型没有可切换的档位)`,
|
|
1455
|
+
"data-composer-effort": effort,
|
|
1456
|
+
children: [
|
|
1457
|
+
/* @__PURE__ */ jsxRuntime.jsx(ui$1.IconBrain, { size: 13 }),
|
|
1458
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "model-name", children: effortText })
|
|
1459
|
+
]
|
|
1460
|
+
}
|
|
1461
|
+
),
|
|
1462
|
+
working ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1463
|
+
"button",
|
|
1464
|
+
{
|
|
1465
|
+
type: "button",
|
|
1466
|
+
className: `send-btn stop${queueing ? " dim" : ""}`,
|
|
1467
|
+
"aria-label": "停止生成",
|
|
1468
|
+
"data-tip": "停止生成",
|
|
1469
|
+
onClick: interrupt,
|
|
1470
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconStop, { size: 16 })
|
|
1471
|
+
}
|
|
1472
|
+
) : null,
|
|
1473
|
+
!working || queueing ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1474
|
+
"button",
|
|
1475
|
+
{
|
|
1476
|
+
type: "button",
|
|
1477
|
+
className: "send-btn",
|
|
1478
|
+
"aria-label": working ? "排队发送" : "发送",
|
|
1479
|
+
disabled: !sendable || blocked || sending,
|
|
1480
|
+
"data-tip": working ? "排队发送:这一轮跑完立刻发出(Ctrl+Enter 插话:打断当前输出先发这条)" : "发送,快捷键 Enter",
|
|
1481
|
+
onClick: () => {
|
|
1482
|
+
send(false);
|
|
1483
|
+
},
|
|
1484
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconArrowUp, { size: 16 })
|
|
1485
|
+
}
|
|
1486
|
+
) : null
|
|
1487
|
+
] })
|
|
1488
|
+
] })
|
|
1489
|
+
]
|
|
1490
|
+
}
|
|
1491
|
+
),
|
|
1492
|
+
fault === null ? null : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shell-composer-fault", children: fault })
|
|
1493
|
+
] })
|
|
1494
|
+
);
|
|
1495
|
+
}
|
|
1496
|
+
function previewOf(text) {
|
|
1497
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
1498
|
+
const chars = Array.from(flat);
|
|
1499
|
+
return chars.length > PREVIEW_CHARS ? `${chars.slice(0, PREVIEW_CHARS).join("")}…` : flat;
|
|
1500
|
+
}
|
|
1501
|
+
function NoticeStrip() {
|
|
1502
|
+
const notices = ui$1.useHostSelector(readNotices, sameNotices);
|
|
1503
|
+
if (notices.length === 0) return null;
|
|
1504
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "notice-strip", "data-notice-strip": "", children: notices.map((item) => {
|
|
1505
|
+
const summary = summarizeNotice(item.text);
|
|
1506
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "notice-row", children: [
|
|
1507
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "notice-lead", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconSpark, { size: 13 }) }),
|
|
1508
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "notice-label", "data-tip": summary.detail === "" ? summary.label : summary.detail, children: summary.label }),
|
|
1509
|
+
summary.detail === "" ? null : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "notice-detail", children: summary.detail })
|
|
1510
|
+
] }, item.index);
|
|
1511
|
+
}) });
|
|
1512
|
+
}
|
|
1513
|
+
function QueueDock() {
|
|
1514
|
+
const channel = ui$1.useHostChannel();
|
|
1515
|
+
const items = ui$1.useHostSelector(readQueued, sameQueued);
|
|
1516
|
+
const turnState = ui$1.useHostSelector(readTurnState);
|
|
1517
|
+
const [collapsed, setCollapsed] = react.useState(true);
|
|
1518
|
+
const [editing, setEditing] = react.useState(null);
|
|
1519
|
+
const [busy, setBusy] = react.useState(false);
|
|
1520
|
+
const [fault, setFault] = react.useState(null);
|
|
1521
|
+
const count = items.length;
|
|
1522
|
+
react.useEffect(() => {
|
|
1523
|
+
if (count === 0 && !collapsed) setCollapsed(true);
|
|
1524
|
+
if (editing !== null && !items.some((item) => item.index === editing.index)) setEditing(null);
|
|
1525
|
+
}, [collapsed, editing, items, count]);
|
|
1526
|
+
if (count === 0) return null;
|
|
1527
|
+
const expanded = count === 1 || !collapsed || editing !== null;
|
|
1528
|
+
const running = turnState !== "idle";
|
|
1529
|
+
const act = async (work, failure) => {
|
|
1530
|
+
setBusy(true);
|
|
1531
|
+
setFault(null);
|
|
1532
|
+
try {
|
|
1533
|
+
return await work() ? "ok" : "rejected";
|
|
1534
|
+
} catch (error) {
|
|
1535
|
+
setFault(`${failure}:${error instanceof Error ? error.message : String(error)}`);
|
|
1536
|
+
return "failed";
|
|
1537
|
+
} finally {
|
|
1538
|
+
setBusy(false);
|
|
1539
|
+
}
|
|
1540
|
+
};
|
|
1541
|
+
const save = async (index) => {
|
|
1542
|
+
const value = editing?.text.trim() ?? "";
|
|
1543
|
+
if (value === "") return;
|
|
1544
|
+
const outcome = await act(() => channel.invoke("editQueued", [index, value]), "编辑失败");
|
|
1545
|
+
if (outcome === "ok") {
|
|
1546
|
+
setEditing(null);
|
|
1547
|
+
return;
|
|
1548
|
+
}
|
|
1549
|
+
if (outcome === "rejected") setFault("编辑失败:这条已经开始发送了");
|
|
1550
|
+
};
|
|
1551
|
+
const remove = async (index) => {
|
|
1552
|
+
const outcome = await act(() => channel.invoke("removeQueued", [index]), "撤掉失败");
|
|
1553
|
+
if (outcome === "rejected") setFault("撤掉失败:这条已经开始发送了");
|
|
1554
|
+
};
|
|
1555
|
+
const steer = async (index) => {
|
|
1556
|
+
const ahead = index;
|
|
1557
|
+
const detail = ahead > 0 ? `会打断模型当前的输出,让这条以及排在它前面的 ${String(ahead)} 条立刻作为新一轮发出去(模型已经说出的半截会保留)。` : "会打断模型当前的输出,让这条立刻作为新一轮发出去(模型已经说出的半截会保留)。";
|
|
1558
|
+
if (!window.confirm(`打断并插话?
|
|
1559
|
+
|
|
1560
|
+
${detail}`)) return;
|
|
1561
|
+
const outcome = await act(() => channel.invoke("steerQueued", [index]), "插话失败");
|
|
1562
|
+
if (outcome === "rejected") setFault("插话没赶上:这一轮刚结束,排队消息会自己发出去");
|
|
1563
|
+
};
|
|
1564
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "queue-dock", "data-queue-dock": "", children: [
|
|
1565
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "queue-panel", children: [
|
|
1566
|
+
count > 1 ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1567
|
+
"button",
|
|
1568
|
+
{
|
|
1569
|
+
type: "button",
|
|
1570
|
+
className: "queue-head",
|
|
1571
|
+
"aria-expanded": expanded,
|
|
1572
|
+
disabled: busy || editing !== null,
|
|
1573
|
+
"data-tip": expanded ? "收起排队消息" : "展开排队消息",
|
|
1574
|
+
onClick: () => {
|
|
1575
|
+
setCollapsed((current) => !current);
|
|
1576
|
+
},
|
|
1577
|
+
children: [
|
|
1578
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "queue-lead", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconQueue, { size: 13 }) }),
|
|
1579
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "queue-count", children: [
|
|
1580
|
+
count,
|
|
1581
|
+
" 条排队消息"
|
|
1582
|
+
] }),
|
|
1583
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "queue-note", children: "这一轮跑完自动发出" }),
|
|
1584
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "queue-caret", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconChevronDown, { size: 13 }) })
|
|
1585
|
+
]
|
|
1586
|
+
}
|
|
1587
|
+
) : null,
|
|
1588
|
+
expanded ? /* @__PURE__ */ jsxRuntime.jsx("ul", { className: "queue-list", children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx("li", { className: "queue-row", children: editing?.index === item.index ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1589
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1590
|
+
"textarea",
|
|
1591
|
+
{
|
|
1592
|
+
className: "queue-edit-box",
|
|
1593
|
+
value: editing.text,
|
|
1594
|
+
autoFocus: true,
|
|
1595
|
+
rows: Math.min(8, Math.max(1, editing.text.split("\n").length)),
|
|
1596
|
+
"aria-label": "编辑排队消息",
|
|
1597
|
+
onChange: (event) => {
|
|
1598
|
+
setEditing({ index: item.index, text: event.target.value });
|
|
1599
|
+
},
|
|
1600
|
+
onKeyDown: (event) => {
|
|
1601
|
+
if (event.key === "Enter" && !event.shiftKey) {
|
|
1602
|
+
event.preventDefault();
|
|
1603
|
+
void save(item.index);
|
|
1604
|
+
return;
|
|
1605
|
+
}
|
|
1606
|
+
if (event.key === "Escape") {
|
|
1607
|
+
event.preventDefault();
|
|
1608
|
+
setEditing(null);
|
|
1609
|
+
}
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
),
|
|
1613
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1614
|
+
"button",
|
|
1615
|
+
{
|
|
1616
|
+
type: "button",
|
|
1617
|
+
className: "queue-act",
|
|
1618
|
+
"aria-label": "保存排队消息",
|
|
1619
|
+
"data-tip": "保存(回车)",
|
|
1620
|
+
disabled: busy || editing.text.trim() === "",
|
|
1621
|
+
onClick: () => void save(item.index),
|
|
1622
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconCheck, { size: 13 })
|
|
1623
|
+
}
|
|
1624
|
+
),
|
|
1625
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1626
|
+
"button",
|
|
1627
|
+
{
|
|
1628
|
+
type: "button",
|
|
1629
|
+
className: "queue-act",
|
|
1630
|
+
"aria-label": "取消编辑",
|
|
1631
|
+
"data-tip": "取消(Esc)",
|
|
1632
|
+
disabled: busy,
|
|
1633
|
+
onClick: () => {
|
|
1634
|
+
setEditing(null);
|
|
1635
|
+
},
|
|
1636
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconClose, { size: 13 })
|
|
1637
|
+
}
|
|
1638
|
+
)
|
|
1639
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1640
|
+
count === 1 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "queue-lead", "aria-hidden": "true", children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconQueue, { size: 13 }) }) : null,
|
|
1641
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "queue-text", "data-tip": item.text, children: previewOf(item.text) }),
|
|
1642
|
+
item.images === void 0 || item.images.length === 0 ? null : /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "queue-badge", "data-tip": `随这条一起排队的 ${String(item.images.length)} 张图`, children: [
|
|
1643
|
+
"+",
|
|
1644
|
+
item.images.length,
|
|
1645
|
+
" 图"
|
|
1646
|
+
] }),
|
|
1647
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "queue-acts", children: [
|
|
1648
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1649
|
+
"button",
|
|
1650
|
+
{
|
|
1651
|
+
type: "button",
|
|
1652
|
+
className: "queue-act",
|
|
1653
|
+
"aria-label": "编辑排队消息",
|
|
1654
|
+
"data-tip": "改这条排队消息",
|
|
1655
|
+
disabled: busy,
|
|
1656
|
+
onClick: () => {
|
|
1657
|
+
setEditing({ index: item.index, text: item.text });
|
|
1658
|
+
},
|
|
1659
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconEdit, { size: 13 })
|
|
1660
|
+
}
|
|
1661
|
+
),
|
|
1662
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1663
|
+
"button",
|
|
1664
|
+
{
|
|
1665
|
+
type: "button",
|
|
1666
|
+
className: "queue-act",
|
|
1667
|
+
"aria-label": "撤回排队消息",
|
|
1668
|
+
"data-tip": "撤掉这条(还没发出去)",
|
|
1669
|
+
disabled: busy,
|
|
1670
|
+
onClick: () => void remove(item.index),
|
|
1671
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconTrash, { size: 13 })
|
|
1672
|
+
}
|
|
1673
|
+
),
|
|
1674
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1675
|
+
"button",
|
|
1676
|
+
{
|
|
1677
|
+
type: "button",
|
|
1678
|
+
className: "queue-act",
|
|
1679
|
+
"aria-label": "插话发送",
|
|
1680
|
+
"data-tip": running ? "打断当前输出,让这条立刻发出去(模型已说出的半截保留)" : "这一轮已经跑完,排队消息会自己发出去",
|
|
1681
|
+
disabled: busy || !running,
|
|
1682
|
+
onClick: () => void steer(item.index),
|
|
1683
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(ui$1.IconArrowUp, { size: 13 })
|
|
1684
|
+
}
|
|
1685
|
+
)
|
|
1686
|
+
] })
|
|
1687
|
+
] }) }, item.index)) }) : null
|
|
1688
|
+
] }),
|
|
1689
|
+
fault === null ? null : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "shell-composer-fault", children: fault })
|
|
1690
|
+
] });
|
|
1691
|
+
}
|
|
1692
|
+
function sameQueued(left, right) {
|
|
1693
|
+
if (left === right) return true;
|
|
1694
|
+
if (left.length !== right.length) return false;
|
|
1695
|
+
return left.every((item, index) => {
|
|
1696
|
+
const other = right[index];
|
|
1697
|
+
if (other === void 0) return false;
|
|
1698
|
+
return item.index === other.index && item.text === other.text && (item.images?.join("|") ?? "") === (other.images?.join("|") ?? "");
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
function readTurnState(snapshot) {
|
|
1702
|
+
const status = snapshot?.["status"];
|
|
1703
|
+
if (typeof status !== "object" || status === null) return "idle";
|
|
1704
|
+
const value = status["turnState"];
|
|
1705
|
+
return typeof value === "string" ? value : "idle";
|
|
1706
|
+
}
|
|
1707
|
+
function readModel(snapshot) {
|
|
1708
|
+
const status = snapshot?.["status"];
|
|
1709
|
+
if (typeof status !== "object" || status === null) return "";
|
|
1710
|
+
const value = status["model"];
|
|
1711
|
+
return typeof value === "string" ? value : "";
|
|
1712
|
+
}
|
|
1713
|
+
function readProvider(snapshot) {
|
|
1714
|
+
const status = snapshot?.["status"];
|
|
1715
|
+
if (typeof status !== "object" || status === null) return "";
|
|
1716
|
+
const value = status["provider"];
|
|
1717
|
+
return typeof value === "string" ? value : "";
|
|
1718
|
+
}
|
|
1719
|
+
function readEffort(snapshot) {
|
|
1720
|
+
const status = snapshot?.["status"];
|
|
1721
|
+
if (typeof status !== "object" || status === null) return "default";
|
|
1722
|
+
const value = status["effort"];
|
|
1723
|
+
return typeof value === "string" ? value : "default";
|
|
1724
|
+
}
|
|
1725
|
+
function readHasApproval(snapshot) {
|
|
1726
|
+
const surfaces = snapshot?.["surfaces"];
|
|
1727
|
+
if (typeof surfaces !== "object" || surfaces === null) return false;
|
|
1728
|
+
const pending = surfaces["pendingApproval"];
|
|
1729
|
+
return pending !== null && pending !== void 0;
|
|
1730
|
+
}
|
|
1731
|
+
function readSessionPath(snapshot) {
|
|
1732
|
+
const status = snapshot?.["status"];
|
|
1733
|
+
if (typeof status !== "object" || status === null) return "";
|
|
1734
|
+
const path = status["sessionPath"];
|
|
1735
|
+
return typeof path === "string" ? path : "";
|
|
1736
|
+
}
|
|
1737
|
+
function readSessionId(snapshot) {
|
|
1738
|
+
const status = snapshot?.["status"];
|
|
1739
|
+
if (typeof status !== "object" || status === null) return "";
|
|
1740
|
+
const value = status["sessionId"];
|
|
1741
|
+
return typeof value === "string" ? value : "";
|
|
1742
|
+
}
|
|
1743
|
+
function readDraftCwd(snapshot) {
|
|
1744
|
+
const status = snapshot?.["status"];
|
|
1745
|
+
if (typeof status !== "object" || status === null) return "";
|
|
1746
|
+
const value = status["cwd"];
|
|
1747
|
+
return typeof value === "string" ? value : "";
|
|
1748
|
+
}
|
|
1749
|
+
function readSessionUnsaved(snapshot) {
|
|
1750
|
+
const status = snapshot?.["status"];
|
|
1751
|
+
if (typeof status !== "object" || status === null) return false;
|
|
1752
|
+
return status["sessionUnsaved"] === true;
|
|
1753
|
+
}
|
|
1754
|
+
function readPermissionPresets(snapshot) {
|
|
1755
|
+
const surfaces = snapshot?.["surfaces"];
|
|
1756
|
+
if (typeof surfaces !== "object" || surfaces === null) return EMPTY_PERMISSION_PRESETS;
|
|
1757
|
+
const presets = surfaces["permissionPresets"];
|
|
1758
|
+
if (typeof presets !== "object" || presets === null) return EMPTY_PERMISSION_PRESETS;
|
|
1759
|
+
const record = presets;
|
|
1760
|
+
const current = record["current"];
|
|
1761
|
+
const options = record["options"];
|
|
1762
|
+
if (typeof current !== "string" || !Array.isArray(options)) return EMPTY_PERMISSION_PRESETS;
|
|
1763
|
+
return {
|
|
1764
|
+
current,
|
|
1765
|
+
defaultName: typeof record["defaultName"] === "string" ? record["defaultName"] : "",
|
|
1766
|
+
options
|
|
1767
|
+
};
|
|
1768
|
+
}
|
|
1769
|
+
function samePermissionPresets(left, right) {
|
|
1770
|
+
if (left === right) return true;
|
|
1771
|
+
if (left.current !== right.current || left.defaultName !== right.defaultName) return false;
|
|
1772
|
+
if (left.options.length !== right.options.length) return false;
|
|
1773
|
+
return left.options.every((item, index) => {
|
|
1774
|
+
const other = right.options[index];
|
|
1775
|
+
return other !== void 0 && item.name === other.name && item.label === other.label && item.description === other.description && item.builtin === other.builtin;
|
|
1776
|
+
});
|
|
1777
|
+
}
|
|
1778
|
+
function readPresetSurface(snapshot) {
|
|
1779
|
+
const surfaces = snapshot?.["surfaces"];
|
|
1780
|
+
if (typeof surfaces !== "object" || surfaces === null) return EMPTY_PRESET;
|
|
1781
|
+
const preset = surfaces["preset"];
|
|
1782
|
+
if (typeof preset !== "object" || preset === null) return EMPTY_PRESET;
|
|
1783
|
+
const record = preset;
|
|
1784
|
+
const current = record["current"];
|
|
1785
|
+
const options = record["options"];
|
|
1786
|
+
if (typeof current !== "string" || !Array.isArray(options)) return EMPTY_PRESET;
|
|
1787
|
+
return {
|
|
1788
|
+
current,
|
|
1789
|
+
defaultName: typeof record["defaultName"] === "string" ? record["defaultName"] : "",
|
|
1790
|
+
options,
|
|
1791
|
+
droppable: Array.isArray(record["droppable"]) ? record["droppable"] : []
|
|
1792
|
+
};
|
|
1793
|
+
}
|
|
1794
|
+
function samePresetSurface(left, right) {
|
|
1795
|
+
if (left === right) return true;
|
|
1796
|
+
if (left.current !== right.current || left.defaultName !== right.defaultName) return false;
|
|
1797
|
+
if (left.options.length !== right.options.length) return false;
|
|
1798
|
+
return left.options.every((item, index) => {
|
|
1799
|
+
const other = right.options[index];
|
|
1800
|
+
return other !== void 0 && item.name === other.name && item.label === other.label && item.description === other.description && item.problem === other.problem;
|
|
1801
|
+
});
|
|
1802
|
+
}
|
|
1803
|
+
function readInboxCount(snapshot) {
|
|
1804
|
+
const queued = snapshot?.["queued"];
|
|
1805
|
+
const notices = snapshot?.["notices"];
|
|
1806
|
+
return (Array.isArray(queued) ? queued.length : 0) + (Array.isArray(notices) ? notices.length : 0);
|
|
1807
|
+
}
|
|
1808
|
+
function readQueued(snapshot) {
|
|
1809
|
+
const value = snapshot?.["queued"];
|
|
1810
|
+
return Array.isArray(value) ? value : EMPTY_QUEUE;
|
|
1811
|
+
}
|
|
1812
|
+
const EMPTY_QUEUE = Object.freeze([]);
|
|
1813
|
+
function sameNotices(left, right) {
|
|
1814
|
+
if (left === right) return true;
|
|
1815
|
+
if (left.length !== right.length) return false;
|
|
1816
|
+
return left.every((item, index) => {
|
|
1817
|
+
const other = right[index];
|
|
1818
|
+
return other !== void 0 && item.index === other.index && item.text === other.text;
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1821
|
+
function readNotices(snapshot) {
|
|
1822
|
+
const value = snapshot?.["notices"];
|
|
1823
|
+
return Array.isArray(value) ? value : EMPTY_NOTICES;
|
|
1824
|
+
}
|
|
1825
|
+
const EMPTY_NOTICES = Object.freeze([]);
|
|
1826
|
+
function readGit(snapshot) {
|
|
1827
|
+
const surfaces = snapshot?.["surfaces"];
|
|
1828
|
+
if (typeof surfaces !== "object" || surfaces === null) return EMPTY_GIT;
|
|
1829
|
+
const raw = surfaces["git"];
|
|
1830
|
+
if (typeof raw !== "object" || raw === null) return EMPTY_GIT;
|
|
1831
|
+
const record = raw;
|
|
1832
|
+
return {
|
|
1833
|
+
repo: record["repo"] === true,
|
|
1834
|
+
branch: typeof record["branch"] === "string" ? record["branch"] : "",
|
|
1835
|
+
detached: record["detached"] === true,
|
|
1836
|
+
dirtyFileCount: typeof record["dirtyFileCount"] === "number" ? record["dirtyFileCount"] : 0
|
|
1837
|
+
};
|
|
1838
|
+
}
|
|
1839
|
+
function sameGit(left, right) {
|
|
1840
|
+
return left.repo === right.repo && left.branch === right.branch && left.detached === right.detached && left.dirtyFileCount === right.dirtyFileCount;
|
|
1841
|
+
}
|
|
1842
|
+
exports.default = ui;
|
|
1843
|
+
};
|