@allbluecn/web-app 0.27.41 → 0.28.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/package.json +1 -1
- package/public/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/78-H.bcmap +0 -0
- package/public/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/78-V.bcmap +0 -0
- package/public/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Add-H.bcmap +0 -0
- package/public/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Add-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
- package/public/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
- package/public/pdfjs/cmaps/B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/B5pc-H.bcmap +0 -0
- package/public/pdfjs/cmaps/B5pc-V.bcmap +0 -0
- package/public/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/CNS1-H.bcmap +0 -0
- package/public/pdfjs/cmaps/CNS1-V.bcmap +0 -0
- package/public/pdfjs/cmaps/CNS2-H.bcmap +0 -0
- package/public/pdfjs/cmaps/CNS2-V.bcmap +3 -0
- package/public/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
- package/public/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Ext-H.bcmap +0 -0
- package/public/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Ext-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GB-H.bcmap +4 -0
- package/public/pdfjs/cmaps/GB-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GBT-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GBT-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/H.bcmap +0 -0
- package/public/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
- package/public/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Hankaku.bcmap +0 -0
- package/public/pdfjs/cmaps/Hiragana.bcmap +0 -0
- package/public/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/KSC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
- package/public/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
- package/public/pdfjs/cmaps/KSC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
- package/public/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
- package/public/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
- package/public/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Katakana.bcmap +0 -0
- package/public/pdfjs/cmaps/LICENSE +36 -0
- package/public/pdfjs/cmaps/NWP-H.bcmap +0 -0
- package/public/pdfjs/cmaps/NWP-V.bcmap +0 -0
- package/public/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
- package/public/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
- package/public/pdfjs/cmaps/Roman.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
- package/public/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
- package/public/pdfjs/cmaps/V.bcmap +0 -0
- package/public/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
- package/src/components/ai/ai-prompt-input/index.tsx +3 -87
- package/src/components/ai-elements/__tests__/context.test.tsx +167 -0
- package/src/components/ai-elements/context.tsx +182 -94
- package/src/components/ai-elements/prompt-input.tsx +6 -104
- package/src/components/harness/__tests__/composer-attachments.test.tsx +17 -9
- package/src/components/harness/__tests__/composer-click-focus.test.tsx +175 -0
- package/src/components/harness/__tests__/composer-focus.test.tsx +7 -0
- package/src/components/harness/__tests__/composer-keymap.test.ts +57 -0
- package/src/components/harness/__tests__/composer-paste.test.tsx +7 -0
- package/src/components/harness/__tests__/composer-pending-guard.test.tsx +207 -0
- package/src/components/harness/__tests__/composer-placeholder.test.ts +7 -6
- package/src/components/harness/__tests__/composer-plus-menu.test.tsx +202 -0
- package/src/components/harness/__tests__/composer-primary-button.test.tsx +7 -0
- package/src/components/harness/__tests__/composer-send.test.tsx +12 -4
- package/src/components/harness/__tests__/composer-undo.test.tsx +7 -0
- package/src/components/harness/__tests__/dock-registry.test.ts +3 -0
- package/src/components/harness/__tests__/harness-workbench-auth-error.test.tsx +42 -4
- package/src/components/harness/__tests__/mention-kbid.test.ts +69 -0
- package/src/components/harness/__tests__/undo-last-turn.test.ts +134 -0
- package/src/components/harness/__tests__/voice-activity.test.tsx +2 -2
- package/src/components/harness/conversation-panel/composer/__tests__/file-chip-open.test.tsx +195 -0
- package/src/components/harness/conversation-panel/composer/__tests__/menu-view.test.tsx +107 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/claim-attachments.test.tsx +271 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/claim-client-submit.test.tsx +291 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/claim-guard.test.tsx +275 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/command-permission.test.tsx +286 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/command-plan.test.tsx +344 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/command-popup.test.tsx +193 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/command-server-source.test.tsx +235 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/command-suggestion-menu.test.tsx +151 -1
- package/src/components/harness/conversation-panel/composer/command/__tests__/command-undo.test.tsx +168 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/exclude-composer-seat.test.ts +106 -0
- package/src/components/harness/conversation-panel/composer/command/__tests__/menu-view.test.tsx +55 -2
- package/src/components/harness/conversation-panel/composer/command/__tests__/skill-source.test.tsx +336 -0
- package/src/components/harness/conversation-panel/composer/command/claim.ts +7 -1
- package/src/components/harness/conversation-panel/composer/command/command-popup.tsx +140 -0
- package/src/components/harness/conversation-panel/composer/command/command-suggestion-menu.tsx +261 -75
- package/src/components/harness/conversation-panel/composer/command/menu-view.tsx +188 -50
- package/src/components/harness/conversation-panel/composer/command/popup-panel.tsx +106 -0
- package/src/components/harness/conversation-panel/composer/command/skill-source.ts +231 -0
- package/src/components/harness/conversation-panel/composer/composer-editor.tsx +216 -14
- package/src/components/harness/conversation-panel/composer/composer-keymap.ts +26 -0
- package/src/components/harness/conversation-panel/composer/extension/__tests__/command-menu.test.ts +128 -12
- package/src/components/harness/conversation-panel/composer/extension/command-menu.ts +303 -44
- package/src/components/harness/conversation-panel/composer/extension/index.ts +8 -0
- package/src/components/harness/conversation-panel/composer/harness-composer.tsx +551 -83
- package/src/components/harness/conversation-panel/composer/mention/__tests__/file-mention.test.tsx +517 -0
- package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-source-registration.test.tsx +5 -2
- package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-suggestion-menu.test.tsx +120 -0
- package/src/components/harness/conversation-panel/composer/mention/__tests__/mention-trigger-source.test.ts +52 -9
- package/src/components/harness/conversation-panel/composer/mention/__tests__/story-mention.test.tsx +356 -0
- package/src/components/harness/conversation-panel/composer/mention/__tests__/thread-mention.test.tsx +377 -0
- package/src/components/harness/conversation-panel/composer/mention/file-mention.ts +162 -0
- package/src/components/harness/conversation-panel/composer/mention/mention-resolvers.ts +6 -0
- package/src/components/harness/conversation-panel/composer/mention/mention-suggestion-menu.tsx +212 -107
- package/src/components/harness/conversation-panel/composer/mention/mention-trigger-source.ts +71 -8
- package/src/components/harness/conversation-panel/composer/mention/story-mention.ts +131 -0
- package/src/components/harness/conversation-panel/composer/mention/thread-mention.ts +159 -0
- package/src/components/harness/conversation-panel/composer/mention/use-mention-sources.ts +9 -1
- package/src/components/harness/conversation-panel/composer/model-selector/__tests__/model-selector.test.tsx +401 -0
- package/src/components/harness/conversation-panel/composer/model-selector/__tests__/wiring.test.ts +117 -0
- package/src/components/harness/conversation-panel/composer/model-selector/model-selector-panel.tsx +411 -0
- package/src/components/harness/conversation-panel/composer/model-selector/model-selector-trigger.tsx +254 -0
- package/src/components/harness/conversation-panel/composer/model-selector/wiring.ts +112 -0
- package/src/components/harness/conversation-panel/composer/permission/__tests__/permission-select.test.tsx +264 -0
- package/src/components/harness/conversation-panel/composer/permission/permission-policy.ts +76 -0
- package/src/components/harness/conversation-panel/composer/permission/permission-popup.tsx +302 -0
- package/src/components/harness/conversation-panel/composer/permission/permission-select-button.tsx +140 -0
- package/src/components/harness/conversation-panel/composer/workspace/__tests__/workspace-select.test.tsx +390 -0
- package/src/components/harness/conversation-panel/composer/workspace/workspace-select-button.tsx +367 -0
- package/src/components/harness/conversation-panel/messages/harness-chain/__tests__/use-harness-session-putmedia.test.tsx +17 -0
- package/src/components/harness/conversation-panel/messages/harness-chain/use-harness-chat-adapter.ts +26 -6
- package/src/components/harness/conversation-panel/messages/harness-chain/use-harness-session.ts +21 -3
- package/src/components/harness/extension-panel/dock/__tests__/dock-persist.test.ts +2 -1
- package/src/components/harness/extension-panel/dock/__tests__/guide-page.test.tsx +44 -3
- package/src/components/harness/extension-panel/dock/dock-persist.ts +6 -4
- package/src/components/harness/extension-panel/dock/dock-registry.ts +35 -14
- package/src/components/harness/extension-panel/dock/dock-surface.tsx +2 -0
- package/src/components/harness/extension-panel/dock/guide-page.tsx +75 -45
- package/src/components/harness/extension-panel/panels/plugin/__tests__/install-dialog.test.tsx +260 -0
- package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-page.test.tsx +912 -0
- package/src/components/harness/extension-panel/panels/plugin/__tests__/plugin-row.test.tsx +215 -0
- package/src/components/harness/extension-panel/panels/plugin/builtin-section.tsx +204 -0
- package/src/components/harness/extension-panel/panels/plugin/install-dialog.tsx +195 -0
- package/src/components/harness/extension-panel/panels/plugin/installed-section.tsx +378 -0
- package/src/components/harness/extension-panel/panels/plugin/kind.tsx +17 -4
- package/src/components/harness/extension-panel/panels/plugin/pending-builds-block.tsx +49 -0
- package/src/components/harness/extension-panel/panels/plugin/plugin-page.tsx +257 -0
- package/src/components/harness/extension-panel/panels/plugin/plugin-row.tsx +206 -0
- package/src/components/harness/extension-panel/panels/plugin/plugin-types.ts +13 -0
- package/src/components/harness/extension-panel/panels/plugin/worker-section.tsx +322 -0
- package/src/components/harness/workbench/__tests__/provider-model-groups.test.ts +301 -0
- package/src/components/harness/workbench/harness-workbench-page.tsx +164 -2
- package/src/components/harness/workbench/provider-model-groups.ts +140 -0
- package/src/components/harness/workbench/undo-last-turn.ts +79 -0
- package/src/components/harness/workbench/workbench-context.tsx +53 -3
- package/src/components/tiptap/hooks/__tests__/use-floating-element.test.tsx +131 -0
- package/src/components/tiptap/hooks/use-floating-element.ts +15 -2
- package/src/components/tiptap/hooks/use-menu-navigation.ts +5 -0
- package/src/components/tiptap/node/mention-extension.ts +33 -0
- package/src/components/tiptap/ui/suggestion-menu/__tests__/suggestion-menu.test.tsx +366 -0
- package/src/components/tiptap/ui/suggestion-menu/suggestion-menu-types.ts +54 -0
- package/src/components/tiptap/ui/suggestion-menu/suggestion-menu.tsx +176 -45
- package/src/lib/changelog/sdk-versions.ts +2 -2
- package/src/lib/queries/__tests__/harness-plugin-queries.test.ts +49 -0
- package/src/lib/queries/harness.ts +50 -0
- package/src/paraglide/messages/_index.js +1574 -311
- package/src/paraglide/messages/en.js +513 -103
- package/src/paraglide/messages/zh.js +514 -104
- package/src/routes/_nav/harness/route.lazy.tsx +13 -0
- package/src/server/ai-gateway/sandbox/policy.ts +6 -6
- package/src/server/harness/__tests__/compact-plugin.server.test.ts +46 -0
- package/src/server/harness/__tests__/define-expose.test.ts +17 -0
- package/src/server/harness/__tests__/thread-reference.server.test.ts +258 -0
- package/src/server/harness/define.server.ts +21 -3
- package/src/server/harness/thread-reference.server.ts +446 -0
- package/src/server/serverFns/chat/__tests__/conversations-sandbox-default.test.ts +23 -0
- package/src/server/serverFns/chat/conversations.ts +18 -3
- package/src/server/serverFns/harness/search-mention-candidates.ts +14 -1
- package/src/shared/harness/__tests__/thread-reference-format.test.ts +128 -0
- package/src/shared/harness/thread-reference-format.ts +98 -0
- package/LICENSE +0 -661
- package/src/components/agents/slash-skill-menu.tsx +0 -75
- package/src/components/harness/conversation-panel/composer/extension/__tests__/demo-story-reference.test.tsx +0 -177
- package/src/components/harness/conversation-panel/composer/extension/demo-story-reference.tsx +0 -227
- package/src/components/harness/conversation-panel/composer/plugin-mention-menu.tsx +0 -109
- package/src/components/harness/extension-panel/panels/plugin-panel.tsx +0 -1021
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// This program is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU Affero General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 沙箱三档菜单(任务 4 从 command-popup.tsx 迁出;2026-11-21 打磨改版双宿主拆分):
|
|
20
|
+
*
|
|
21
|
+
* - **PermissionMenu**(菜单本体 = 逻辑 + 内容,无定位外壳):三行 MenuView(档位
|
|
22
|
+
* 图标 + 档名,**描述行移除**,当档 **Check 图标右侧槽**——打磨裁决;lucide 图标
|
|
23
|
+
* 非 emoji)+ full 档 AlertDialog 二次确认(叠加在宿主之上——modal focus trap,
|
|
24
|
+
* 取消回菜单且状态保留)。受控/非受控双形态:onLevelChange 在 = 按钮宿主(父 open
|
|
25
|
+
* 时直读下发,applyLevel 成功上提回流,写入体单点保留在 Menu 内);缺省 = 内部
|
|
26
|
+
* state 自管。onConfirmOpenChange 把 confirmOpen 镜像给 PopupPanel 宿主(抑制
|
|
27
|
+
* Esc/外点监听)。
|
|
28
|
+
* - **PermissionPopup**(/permission 斜杠命令宿主):PopupPanel 钉卡外壳包裹 Menu,
|
|
29
|
+
* 行为与迁出前一致。
|
|
30
|
+
* - 按钮宿主(permission-select-button):Base UI Popover 锚触发钮上方(2026-11-21
|
|
31
|
+
* 打磨裁决与工作区选择同构),open 态经 onOpenChange 并入 menuOpen 通道。
|
|
32
|
+
*
|
|
33
|
+
* 空态语义(P2 #782,用户裁决 2026-11-20 对齐 DSH blank 会话)原样保留:threadId
|
|
34
|
+
* 可为 null(blank 会话)——不读服务端(requireOwnedThread 必炸),初始高亮
|
|
35
|
+
* SANDBOX_CLIENT_DEFAULT_LEVEL,选档走 onPendingLevel(pending 档随建线落库),
|
|
36
|
+
* 本地高亮即时切换。
|
|
37
|
+
*/
|
|
38
|
+
import { useCallback, useEffect, useState } from "react"
|
|
39
|
+
import { Check, Eye, FolderPen, ShieldAlert, type LucideIcon } from "lucide-react"
|
|
40
|
+
import { cn } from "cn"
|
|
41
|
+
import { MenuView, type MenuViewEntry } from "../command/menu-view"
|
|
42
|
+
import { PopupPanel } from "../command/popup-panel"
|
|
43
|
+
import type { CommandPopupCloseReason } from "../command/command-popup"
|
|
44
|
+
import {
|
|
45
|
+
AlertDialog,
|
|
46
|
+
AlertDialogAction,
|
|
47
|
+
AlertDialogCancel,
|
|
48
|
+
AlertDialogContent,
|
|
49
|
+
AlertDialogDescription,
|
|
50
|
+
AlertDialogFooter,
|
|
51
|
+
AlertDialogHeader,
|
|
52
|
+
AlertDialogTitle,
|
|
53
|
+
} from "@/components/ui/alert-dialog"
|
|
54
|
+
import { toast } from "@/components/ui/toast"
|
|
55
|
+
import { m } from "@/paraglide/messages.js"
|
|
56
|
+
import {
|
|
57
|
+
SANDBOX_POLICY_LEVELS,
|
|
58
|
+
SANDBOX_CLIENT_DEFAULT_LEVEL,
|
|
59
|
+
getSandboxPolicy,
|
|
60
|
+
setSandboxPolicy,
|
|
61
|
+
type SandboxPolicyLevel,
|
|
62
|
+
} from "./permission-policy"
|
|
63
|
+
|
|
64
|
+
/** 三档图标映射(触发钮 + 菜单行共用,2026-11-21 打磨:行加图标):readonly=Eye
|
|
65
|
+
* (只读观察)/ workspace-write=FolderPen(工作区可写)/ full=ShieldAlert(告警)。 */
|
|
66
|
+
export const LEVEL_ICONS: Record<SandboxPolicyLevel, LucideIcon> = {
|
|
67
|
+
readonly: Eye,
|
|
68
|
+
"workspace-write": FolderPen,
|
|
69
|
+
full: ShieldAlert,
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface PermissionPopupProps {
|
|
73
|
+
/**
|
|
74
|
+
* 目标线程 id;**null = 空态(thread 未建)**——不读服务端(requireOwnedThread 必炸),
|
|
75
|
+
* 初始高亮默认档,选档走 onPendingLevel(pending 档随建线落库,用户裁决 2026-11-20
|
|
76
|
+
* 对齐 DSH blank 会话)。
|
|
77
|
+
*/
|
|
78
|
+
threadId: string | null
|
|
79
|
+
onClose: (reason: CommandPopupCloseReason) => void
|
|
80
|
+
/** 空态选档上报(workbench 记 pendingSandboxPolicy 槽);有线程时不调。 */
|
|
81
|
+
onPendingLevel?: (level: SandboxPolicyLevel) => void
|
|
82
|
+
/**
|
|
83
|
+
* 受控当前档(任务 4 触发钮用法):与 onLevelChange 成对出现——档位由父 open 时
|
|
84
|
+
* 直读并下发,本组件不再自读(单次直调,不重复打服务端);null = 尚未读到(无 ✓
|
|
85
|
+
* 高亮)。非受控用法(/permission 斜杠命令 popup)不传。
|
|
86
|
+
*/
|
|
87
|
+
level?: SandboxPolicyLevel | null
|
|
88
|
+
/**
|
|
89
|
+
* 受控写回:applyLevel 成功后上提新档(父置 state 回流显示)。缺省 = 非受控,
|
|
90
|
+
* 内部 state 自管(/permission 用法行为零变化)。
|
|
91
|
+
*/
|
|
92
|
+
onLevelChange?: (level: SandboxPolicyLevel) => void
|
|
93
|
+
/**
|
|
94
|
+
* 面板外壳外点豁免域(PopupPanel extraInsideSelector 直通,任务 4):触发钮用法
|
|
95
|
+
* 传触发钮 selector。缺省 undefined = 行为零变化(/permission 用法)。
|
|
96
|
+
*/
|
|
97
|
+
extraInsideSelector?: string
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** 三档展示文案(thunk 渲染期求值——paraglide 不冻结 locale,SUGGESTIONS 同款)。 */
|
|
101
|
+
export const POLICY_LABELS: Record<SandboxPolicyLevel, () => string> = {
|
|
102
|
+
readonly: m.harness_command_permissionReadonly,
|
|
103
|
+
"workspace-write": m.harness_command_permissionWorkspaceWrite,
|
|
104
|
+
full: m.harness_command_permissionFull,
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** 菜单本体 props(受控双形态:onLevelChange 在 = 按钮宿主,缺省 = 内部 state 自管)。 */
|
|
108
|
+
interface PermissionMenuProps {
|
|
109
|
+
threadId: string | null
|
|
110
|
+
onPendingLevel?: (level: SandboxPolicyLevel) => void
|
|
111
|
+
/** 受控当前档(按钮宿主父 open 时直读下发;null = 尚未读到,无 Check 高亮)。 */
|
|
112
|
+
level?: SandboxPolicyLevel | null
|
|
113
|
+
/** 受控写回:applyLevel 成功后上提新档(父置 state 回流显示)。 */
|
|
114
|
+
onLevelChange?: (level: SandboxPolicyLevel) => void
|
|
115
|
+
/** confirmOpen 镜像上报(PopupPanel 宿主抑制 Esc/外点监听;Popover 宿主不需要)。 */
|
|
116
|
+
onConfirmOpenChange?: (open: boolean) => void
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* 菜单本体(逻辑 + 内容,无定位外壳)。受控判定(onLevelChange 在 = 触发钮用法):
|
|
121
|
+
* 显示父下发值,applyLevel 成功后经回调上提;非受控保持内部 state。有线程时打开直读
|
|
122
|
+
* 一次(仅非受控——受控由父单次直调下发);读取失败静默(无 ✓ 高亮,行仍可选)。
|
|
123
|
+
*/
|
|
124
|
+
export function PermissionMenu({
|
|
125
|
+
threadId,
|
|
126
|
+
onPendingLevel,
|
|
127
|
+
level: controlledLevel,
|
|
128
|
+
onLevelChange,
|
|
129
|
+
onConfirmOpenChange,
|
|
130
|
+
}: PermissionMenuProps) {
|
|
131
|
+
const isControlled = onLevelChange != null
|
|
132
|
+
const [internalLevel, setInternalLevel] = useState<SandboxPolicyLevel | null>(
|
|
133
|
+
threadId == null ? SANDBOX_CLIENT_DEFAULT_LEVEL : null,
|
|
134
|
+
)
|
|
135
|
+
const [confirmOpen, setConfirmOpen] = useState(false)
|
|
136
|
+
const [busy, setBusy] = useState(false)
|
|
137
|
+
|
|
138
|
+
const level = isControlled ? (controlledLevel ?? null) : internalLevel
|
|
139
|
+
|
|
140
|
+
// confirmOpen 镜像(PopupPanel 宿主抑制监听);统一 setConfirmOpen 单点
|
|
141
|
+
const changeConfirmOpen = useCallback(
|
|
142
|
+
(open: boolean) => {
|
|
143
|
+
setConfirmOpen(open)
|
|
144
|
+
onConfirmOpenChange?.(open)
|
|
145
|
+
},
|
|
146
|
+
[onConfirmOpenChange],
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
useEffect(() => {
|
|
150
|
+
if (isControlled) return
|
|
151
|
+
if (threadId == null) return
|
|
152
|
+
let cancelled = false
|
|
153
|
+
getSandboxPolicy({ threadId })
|
|
154
|
+
.then((v) => {
|
|
155
|
+
if (!cancelled) setInternalLevel(v)
|
|
156
|
+
})
|
|
157
|
+
.catch((error: unknown) => {
|
|
158
|
+
console.error("[permission-popup] 沙箱策略档读取失败", error)
|
|
159
|
+
})
|
|
160
|
+
return () => {
|
|
161
|
+
cancelled = true
|
|
162
|
+
}
|
|
163
|
+
}, [threadId, isControlled])
|
|
164
|
+
|
|
165
|
+
const applyLevel = useCallback(
|
|
166
|
+
async (next: SandboxPolicyLevel, confirmFull: boolean) => {
|
|
167
|
+
if (busy) return
|
|
168
|
+
// 空态分流:不调 setSandboxPolicy(服务端 requireOwnedThread 必炸),pending 档
|
|
169
|
+
// 上报 + 本地高亮即时切换;菜单保持(用户可继续改选,最终以建线前最后一次为准)。
|
|
170
|
+
if (threadId == null) {
|
|
171
|
+
if (isControlled) onLevelChange?.(next)
|
|
172
|
+
else setInternalLevel(next)
|
|
173
|
+
onPendingLevel?.(next)
|
|
174
|
+
toast.success(m.harness_command_permissionPendingApplied())
|
|
175
|
+
return
|
|
176
|
+
}
|
|
177
|
+
setBusy(true)
|
|
178
|
+
try {
|
|
179
|
+
await setSandboxPolicy({ threadId, level: next, confirmFull })
|
|
180
|
+
// 受控:上提父置新值回流(显示态归父);非受控:内部 state(迁出前行为)。
|
|
181
|
+
if (isControlled) onLevelChange?.(next)
|
|
182
|
+
else setInternalLevel(next)
|
|
183
|
+
toast.success(m.harness_command_permissionChanged())
|
|
184
|
+
} catch (error: unknown) {
|
|
185
|
+
// 失败 toast + 菜单保持(本地高亮不变,可重试);错误面复用 runFailed
|
|
186
|
+
console.error("[permission-popup] 沙箱策略档切换失败", error)
|
|
187
|
+
toast.error(m.harness_command_runFailed())
|
|
188
|
+
} finally {
|
|
189
|
+
setBusy(false)
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
[busy, threadId, isControlled, onLevelChange],
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
const handleSelect = useCallback(
|
|
196
|
+
(lvl: SandboxPolicyLevel) => {
|
|
197
|
+
if (busy) return
|
|
198
|
+
// full 档放宽命令与网络拦截:先弹 AlertDialog 二次确认(服务端 confirmFull
|
|
199
|
+
// 校验才是安全边界)
|
|
200
|
+
if (lvl === "full") {
|
|
201
|
+
changeConfirmOpen(true)
|
|
202
|
+
return
|
|
203
|
+
}
|
|
204
|
+
void applyLevel(lvl, false)
|
|
205
|
+
},
|
|
206
|
+
[busy, applyLevel, changeConfirmOpen],
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
const entries: ReadonlyArray<MenuViewEntry<SandboxPolicyLevel>> =
|
|
210
|
+
SANDBOX_POLICY_LEVELS.map((lvl) => ({
|
|
211
|
+
key: lvl,
|
|
212
|
+
groupLabel: m.harness_command_permission(),
|
|
213
|
+
item: lvl,
|
|
214
|
+
}))
|
|
215
|
+
|
|
216
|
+
return (
|
|
217
|
+
// **裸内容**(无自承载卡):按钮宿主 = PopoverContent 默认 chrome(工作区 POP 同款
|
|
218
|
+
// ring-1 细边描边,用户裁决「参考工作区 POP 的描边」);PopupPanel 宿主由
|
|
219
|
+
// PermissionPopup 自包卡片。MenuView unstyled——内层不再自带第二层 border/圆角
|
|
220
|
+
//(双边框/描边过粗根因)。
|
|
221
|
+
<>
|
|
222
|
+
<MenuView
|
|
223
|
+
unstyled
|
|
224
|
+
entries={entries}
|
|
225
|
+
selectedIndex={-1}
|
|
226
|
+
onSelect={handleSelect}
|
|
227
|
+
selector="command-popup"
|
|
228
|
+
loading={false}
|
|
229
|
+
isCurrent={(lvl) => lvl === level}
|
|
230
|
+
// 打磨裁决(2026-11-21):行加档位图标 + 描述行移除 + 当档 Check 右侧槽
|
|
231
|
+
//(lucide 图标非 emoji)
|
|
232
|
+
renderMedia={(lvl) => {
|
|
233
|
+
const Icon = LEVEL_ICONS[lvl]
|
|
234
|
+
return <Icon aria-hidden className="size-3.5 text-muted-foreground" />
|
|
235
|
+
}}
|
|
236
|
+
renderTitle={(lvl) => (
|
|
237
|
+
<span className={cn("truncate", lvl === level && "font-semibold")}>
|
|
238
|
+
{POLICY_LABELS[lvl]()}
|
|
239
|
+
</span>
|
|
240
|
+
)}
|
|
241
|
+
renderTrailing={(lvl) =>
|
|
242
|
+
lvl === level ? <Check aria-hidden className="size-4 text-primary" /> : null
|
|
243
|
+
}
|
|
244
|
+
/>
|
|
245
|
+
<AlertDialog
|
|
246
|
+
open={confirmOpen}
|
|
247
|
+
onOpenChange={changeConfirmOpen}
|
|
248
|
+
>
|
|
249
|
+
<AlertDialogContent>
|
|
250
|
+
<AlertDialogHeader>
|
|
251
|
+
<AlertDialogTitle>{m.harness_command_permissionFullTitle()}</AlertDialogTitle>
|
|
252
|
+
<AlertDialogDescription>
|
|
253
|
+
{m.harness_command_permissionFullBody()}
|
|
254
|
+
</AlertDialogDescription>
|
|
255
|
+
</AlertDialogHeader>
|
|
256
|
+
<AlertDialogFooter>
|
|
257
|
+
{/* Cancel = Base UI Close 包装(点击自动关弹窗 → onOpenChange(false)
|
|
258
|
+
→ 回菜单,菜单状态保留) */}
|
|
259
|
+
<AlertDialogCancel>{m.harness_command_permissionFullCancel()}</AlertDialogCancel>
|
|
260
|
+
{/* Action 是普通 Button(非 Close):显式关弹窗回菜单 + 确认切换 */}
|
|
261
|
+
<AlertDialogAction
|
|
262
|
+
onClick={() => {
|
|
263
|
+
changeConfirmOpen(false)
|
|
264
|
+
void applyLevel("full", true)
|
|
265
|
+
}}
|
|
266
|
+
>
|
|
267
|
+
{m.harness_command_permissionFullConfirm()}
|
|
268
|
+
</AlertDialogAction>
|
|
269
|
+
</AlertDialogFooter>
|
|
270
|
+
</AlertDialogContent>
|
|
271
|
+
</AlertDialog>
|
|
272
|
+
</>
|
|
273
|
+
)
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** /permission 斜杠命令宿主(PopupPanel 钉卡外壳;非受控自管档位)。 */
|
|
277
|
+
export function PermissionPopup({
|
|
278
|
+
threadId,
|
|
279
|
+
onClose,
|
|
280
|
+
onPendingLevel,
|
|
281
|
+
extraInsideSelector,
|
|
282
|
+
}: PermissionPopupProps) {
|
|
283
|
+
// confirmOpen 镜像:AlertDialog 开启期抑制 PopupPanel 的 Esc/外点监听(Esc 归
|
|
284
|
+
// AlertDialog 取消回菜单,事件放行;外点归弹窗语义)
|
|
285
|
+
const [confirmOpen, setConfirmOpen] = useState(false)
|
|
286
|
+
return (
|
|
287
|
+
<PopupPanel
|
|
288
|
+
onClose={onClose}
|
|
289
|
+
confirmOpen={confirmOpen}
|
|
290
|
+
extraInsideSelector={extraInsideSelector}
|
|
291
|
+
>
|
|
292
|
+
{/* 斜杠宿主自包卡片(按钮宿主的卡由 PopoverContent 默认 chrome 承载) */}
|
|
293
|
+
<div className="w-64 rounded-xl border bg-background text-card-foreground shadow-md">
|
|
294
|
+
<PermissionMenu
|
|
295
|
+
threadId={threadId}
|
|
296
|
+
onPendingLevel={onPendingLevel}
|
|
297
|
+
onConfirmOpenChange={setConfirmOpen}
|
|
298
|
+
/>
|
|
299
|
+
</div>
|
|
300
|
+
</PopupPanel>
|
|
301
|
+
)
|
|
302
|
+
}
|
package/src/components/harness/conversation-panel/composer/permission/permission-select-button.tsx
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// AllBlue - 理想之海
|
|
3
|
+
// Copyright (C) 2026 AllBlue Contributors
|
|
4
|
+
//
|
|
5
|
+
// This program is free software: you can redistribute it and/or modify
|
|
6
|
+
// it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
// the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
// (at your option) any later version.
|
|
9
|
+
//
|
|
10
|
+
// This program is distributed in the hope that it will be useful,
|
|
11
|
+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
// GNU Affero General Public License for more details.
|
|
14
|
+
//
|
|
15
|
+
// You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 控制行工作区权限按钮(任务 4;2026-11-21 打磨改版):`+` 钮与语音钮之间的三档快捷
|
|
20
|
+
* 入口(DSH 控制行次序;任务 5 工作区按钮在本钮与 `+` 之间)。**Popover 锚触发钮上方
|
|
21
|
+
* 弹出**(与工作区选择同构,弃 PopupPanel 钉卡)——**挂载即直读**当前档(getSandboxPolicy
|
|
22
|
+
* P0 直调口径;用户裁决 2026-11-21:钮上自动回显档名,不点开也要显示;线程切换重读)
|
|
23
|
+
* 经受控 props 下发 PermissionMenu;写入体 applyLevel 单点保留在 Menu 内,成功后经
|
|
24
|
+
* onLevelChange 上提回流(钮文案/图标即时更新)。读取失败占位「权限」不锁菜单
|
|
25
|
+
* (open 时档位仍空 → 重试)。
|
|
26
|
+
*
|
|
27
|
+
* open 态统一经 Popover onOpenChange=changeOpen 同步上报 onMenuOpenChange(与 @ 菜单
|
|
28
|
+
* / `+` 菜单 / ModelSelector / WorkspaceSelectButton 同款——menuOpen=true 屏蔽
|
|
29
|
+
* Esc-Esc 停止序列双保险);PopoverTrigger 自带 toggle(open 态再点触发钮净关闭,
|
|
30
|
+
* Base UI 原生语义,PopupPanel extraInsideSelector 豁免域随之退役)。
|
|
31
|
+
*
|
|
32
|
+
* composer 门控(permissionEnabled && threadId != null)在 harness-composer 接线处
|
|
33
|
+
* ——本钮 open 直读服务端当前档,blank 会话无档可读(不渲染);空态选档仍走
|
|
34
|
+
* /permission 斜杠命令 popup 的 onPendingLevel pending 通道。
|
|
35
|
+
*/
|
|
36
|
+
import { useCallback, useEffect, useState } from "react"
|
|
37
|
+
import { ChevronDown, type LucideIcon } from "lucide-react"
|
|
38
|
+
import { cn } from "cn"
|
|
39
|
+
import { PromptInputButton } from "@/components/ai-elements/prompt-input"
|
|
40
|
+
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"
|
|
41
|
+
import { m } from "@/paraglide/messages.js"
|
|
42
|
+
import { getSandboxPolicy, type SandboxPolicyLevel } from "./permission-policy"
|
|
43
|
+
import { LEVEL_ICONS, POLICY_LABELS, PermissionMenu } from "./permission-popup"
|
|
44
|
+
|
|
45
|
+
export interface PermissionSelectButtonProps {
|
|
46
|
+
/** 目标线程 id(composer 门控保证非空——blank 会话不渲染本钮)。 */
|
|
47
|
+
threadId: string
|
|
48
|
+
/** open 态上报(composer 的 setMenuOpen——Esc-Esc 停止序列屏蔽通道)。 */
|
|
49
|
+
onMenuOpenChange: (open: boolean) => void
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function PermissionSelectButton({
|
|
53
|
+
threadId,
|
|
54
|
+
onMenuOpenChange,
|
|
55
|
+
}: PermissionSelectButtonProps) {
|
|
56
|
+
const [open, setOpen] = useState(false)
|
|
57
|
+
// 当前档(受控 Menu 的父):open 时直读;null = 尚未读到/读取失败(占位「权限」)。
|
|
58
|
+
const [level, setLevel] = useState<SandboxPolicyLevel | null>(null)
|
|
59
|
+
|
|
60
|
+
// open 变化统一经此(点钮开 / Esc 外点关)——同步上报 onMenuOpenChange
|
|
61
|
+
// (menuOpen=true 屏蔽 Esc-Esc 停止序列)
|
|
62
|
+
const changeOpen = useCallback(
|
|
63
|
+
(next: boolean) => {
|
|
64
|
+
setOpen(next)
|
|
65
|
+
onMenuOpenChange(next)
|
|
66
|
+
},
|
|
67
|
+
[onMenuOpenChange],
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
// 直读当前档(P0 直调 serverFn,幂等 GET)。**挂载即读**(用户裁决 2026-11-21:钮上
|
|
71
|
+
// 自动回显档名,不点开也显示;线程切换随 threadId 重读)——此前 open 门控导致刷新后
|
|
72
|
+
// 占位「权限」直到手动开面板,回显缺失。open 翻真时档位仍空(挂载读失败)→ 重试;
|
|
73
|
+
// 重复读为幂等 GET 无害(无 in-flight 守卫——守卫会把失败后的重试吞掉)。失败静默
|
|
74
|
+
// 降级:占位「权限」+ 无 Check 高亮,行仍可选。
|
|
75
|
+
const readPolicy = useCallback(async () => {
|
|
76
|
+
try {
|
|
77
|
+
const v = await getSandboxPolicy({ threadId })
|
|
78
|
+
setLevel(v)
|
|
79
|
+
} catch (error: unknown) {
|
|
80
|
+
console.error("[permission-select-button] 沙箱策略档读取失败", error)
|
|
81
|
+
}
|
|
82
|
+
}, [threadId])
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
void readPolicy()
|
|
86
|
+
}, [readPolicy])
|
|
87
|
+
|
|
88
|
+
// open 翻真且档位仍空(挂载读失败)→ 重试;已有档不重复打服务端
|
|
89
|
+
useEffect(() => {
|
|
90
|
+
if (!open) return
|
|
91
|
+
if (level != null) return
|
|
92
|
+
void readPolicy()
|
|
93
|
+
}, [open, level, readPolicy])
|
|
94
|
+
|
|
95
|
+
const label = level != null ? POLICY_LABELS[level]() : m.harness_command_permission()
|
|
96
|
+
const LevelIcon: LucideIcon | null = level != null ? LEVEL_ICONS[level] : null
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<Popover open={open} onOpenChange={changeOpen}>
|
|
100
|
+
<PopoverTrigger
|
|
101
|
+
render={
|
|
102
|
+
<PromptInputButton
|
|
103
|
+
size="sm"
|
|
104
|
+
variant="outline"
|
|
105
|
+
className="rounded-full"
|
|
106
|
+
// 测试钩子(marker):权限面板定位/防误查(Popover 迁移后豁免域语义退役)
|
|
107
|
+
data-permission-select-trigger=""
|
|
108
|
+
aria-label={m.harness_permission_aria({ name: label })}
|
|
109
|
+
>
|
|
110
|
+
{LevelIcon != null && <LevelIcon aria-hidden className="size-3.5 shrink-0" />}
|
|
111
|
+
<span className="max-w-24 truncate text-xs">{label}</span>
|
|
112
|
+
<ChevronDown
|
|
113
|
+
aria-hidden
|
|
114
|
+
className={cn(
|
|
115
|
+
"size-3.5 shrink-0 text-muted-foreground transition-transform",
|
|
116
|
+
open && "rotate-180",
|
|
117
|
+
)}
|
|
118
|
+
/>
|
|
119
|
+
</PromptInputButton>
|
|
120
|
+
}
|
|
121
|
+
/>
|
|
122
|
+
{open && (
|
|
123
|
+
// 锚触发钮上方弹出(与工作区选择同构);Menu 自承载 chrome,Popover 外壳
|
|
124
|
+
// 只做定位(chrome 全剥,避免双层卡)
|
|
125
|
+
<PopoverContent
|
|
126
|
+
side="top"
|
|
127
|
+
align="start"
|
|
128
|
+
sideOffset={8}
|
|
129
|
+
className="w-64 gap-0 p-1"
|
|
130
|
+
>
|
|
131
|
+
<PermissionMenu
|
|
132
|
+
threadId={threadId}
|
|
133
|
+
level={level}
|
|
134
|
+
onLevelChange={setLevel}
|
|
135
|
+
/>
|
|
136
|
+
</PopoverContent>
|
|
137
|
+
)}
|
|
138
|
+
</Popover>
|
|
139
|
+
)
|
|
140
|
+
}
|