@hualinge/relay-web 1.0.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 +31 -0
- package/dist/assets/AgentsPage-2u2kFBCH.js +68 -0
- package/dist/assets/AgentsPage-2u2kFBCH.js.map +1 -0
- package/dist/assets/AgentsPage-BGbbVmeL.css +1 -0
- package/dist/assets/Alert-D88Fk6to.js +2 -0
- package/dist/assets/Alert-D88Fk6to.js.map +1 -0
- package/dist/assets/AppModal-BYZTSuch.js +2 -0
- package/dist/assets/AppModal-BYZTSuch.js.map +1 -0
- package/dist/assets/CenteredLoadingState-DHor-9vF.js +2 -0
- package/dist/assets/CenteredLoadingState-DHor-9vF.js.map +1 -0
- package/dist/assets/ChannelsPage-CbI0kqkd.js +2 -0
- package/dist/assets/ChannelsPage-CbI0kqkd.js.map +1 -0
- package/dist/assets/EmptyDataState-6mNx2Xhl.js +2 -0
- package/dist/assets/EmptyDataState-6mNx2Xhl.js.map +1 -0
- package/dist/assets/HelpPrompt-BPzDcC8F.js +2 -0
- package/dist/assets/HelpPrompt-BPzDcC8F.js.map +1 -0
- package/dist/assets/HomePage-t78sDDUj.js +2 -0
- package/dist/assets/HomePage-t78sDDUj.js.map +1 -0
- package/dist/assets/InspirationPage-BTqLpcHY.js +3 -0
- package/dist/assets/InspirationPage-BTqLpcHY.js.map +1 -0
- package/dist/assets/ModelsPage-YF0gpUxy.js +2 -0
- package/dist/assets/ModelsPage-YF0gpUxy.js.map +1 -0
- package/dist/assets/NameInitialIcon-DP-6_HQY.js +7 -0
- package/dist/assets/NameInitialIcon-DP-6_HQY.js.map +1 -0
- package/dist/assets/NoSearchResultsState-BiiYdZ_Z.js +2 -0
- package/dist/assets/NoSearchResultsState-BiiYdZ_Z.js.map +1 -0
- package/dist/assets/OverflowTooltip-CE5PjAb-.js +2 -0
- package/dist/assets/OverflowTooltip-CE5PjAb-.js.map +1 -0
- package/dist/assets/PasswordField-DmzjtnCg.js +2 -0
- package/dist/assets/PasswordField-DmzjtnCg.js.map +1 -0
- package/dist/assets/RefreshButton-BzYzeo5A.js +2 -0
- package/dist/assets/RefreshButton-BzYzeo5A.js.map +1 -0
- package/dist/assets/RightContentHeader-DoNDQ9Lo.js +3 -0
- package/dist/assets/RightContentHeader-DoNDQ9Lo.js.map +1 -0
- package/dist/assets/SchedulePage-CfW6lZVI.js +2 -0
- package/dist/assets/SchedulePage-CfW6lZVI.js.map +1 -0
- package/dist/assets/SearchInput-tux8xXH1.js +2 -0
- package/dist/assets/SearchInput-tux8xXH1.js.map +1 -0
- package/dist/assets/SkillAvatar-DwGvsY4f.js +2 -0
- package/dist/assets/SkillAvatar-DwGvsY4f.js.map +1 -0
- package/dist/assets/SkillsPage-ppqwKMvj.js +2 -0
- package/dist/assets/SkillsPage-ppqwKMvj.js.map +1 -0
- package/dist/assets/SkillsTab-c_As1DIr.css +1 -0
- package/dist/assets/SkillsTab-kY7MNdxy.js +2 -0
- package/dist/assets/SkillsTab-kY7MNdxy.js.map +1 -0
- package/dist/assets/Tab-FE0F2EQP.js +2 -0
- package/dist/assets/Tab-FE0F2EQP.js.map +1 -0
- package/dist/assets/ThreadPage-B0jElW5R.js +53 -0
- package/dist/assets/ThreadPage-B0jElW5R.js.map +1 -0
- package/dist/assets/UploadSkillModal-DHZL12vm.js +8 -0
- package/dist/assets/UploadSkillModal-DHZL12vm.js.map +1 -0
- package/dist/assets/XlsxDocumentPreview-BY-ht09K.js +5 -0
- package/dist/assets/XlsxDocumentPreview-BY-ht09K.js.map +1 -0
- package/dist/assets/_commonjs-dynamic-modules-TDtrdbi3.js +2 -0
- package/dist/assets/_commonjs-dynamic-modules-TDtrdbi3.js.map +1 -0
- package/dist/assets/chat-input-options-CpkOtPgQ.js +2 -0
- package/dist/assets/chat-input-options-CpkOtPgQ.js.map +1 -0
- package/dist/assets/docx-preview-zfB-orwa.js +28 -0
- package/dist/assets/docx-preview-zfB-orwa.js.map +1 -0
- package/dist/assets/exceljs.min-BY7KKJsM.js +58 -0
- package/dist/assets/exceljs.min-BY7KKJsM.js.map +1 -0
- package/dist/assets/helpers-CCilgpNy.js +2 -0
- package/dist/assets/helpers-CCilgpNy.js.map +1 -0
- package/dist/assets/hub-agent-editor.client-2DmCRGuY.js +2 -0
- package/dist/assets/hub-agent-editor.client-2DmCRGuY.js.map +1 -0
- package/dist/assets/hub-agent-editor.payload-D4sgJRSH.js +4 -0
- package/dist/assets/hub-agent-editor.payload-D4sgJRSH.js.map +1 -0
- package/dist/assets/hub-tag-editor-BBdd-aHK.js +2 -0
- package/dist/assets/hub-tag-editor-BBdd-aHK.js.map +1 -0
- package/dist/assets/index-Bed0I5IL.css +1 -0
- package/dist/assets/index-Bxf2_cvh.js +2 -0
- package/dist/assets/index-Bxf2_cvh.js.map +1 -0
- package/dist/assets/index-Cb4fQgom.js +103 -0
- package/dist/assets/index-Cb4fQgom.js.map +1 -0
- package/dist/assets/index-DQ2vVjmV.js +30 -0
- package/dist/assets/index-DQ2vVjmV.js.map +1 -0
- package/dist/assets/index-UBJEdbMO.js +2 -0
- package/dist/assets/index-UBJEdbMO.js.map +1 -0
- package/dist/assets/jszip.min-DPdj3o0t.js +13 -0
- package/dist/assets/jszip.min-DPdj3o0t.js.map +1 -0
- package/dist/assets/quick-actions-DzZE-zyP.js +2 -0
- package/dist/assets/quick-actions-DzZE-zyP.js.map +1 -0
- package/dist/assets/skill-options-cache-D1BJGTCU.js +2 -0
- package/dist/assets/skill-options-cache-D1BJGTCU.js.map +1 -0
- package/dist/assets/status-helpers-BILdm2MI.js +2 -0
- package/dist/assets/status-helpers-BILdm2MI.js.map +1 -0
- package/dist/assets/thread-title-Cerb2mHa.js +2 -0
- package/dist/assets/thread-title-Cerb2mHa.js.map +1 -0
- package/dist/assets/thread-utils-Ct3yp4R3.js +2 -0
- package/dist/assets/thread-utils-Ct3yp4R3.js.map +1 -0
- package/dist/assets/useAgentData-D-k9cXfg.js +2 -0
- package/dist/assets/useAgentData-D-k9cXfg.js.map +1 -0
- package/dist/assets/useEscapeKey-CEQ6-8GR.js +2 -0
- package/dist/assets/useEscapeKey-CEQ6-8GR.js.map +1 -0
- package/dist/assets/useExpertCatalog-BZdw1CYs.js +2 -0
- package/dist/assets/useExpertCatalog-BZdw1CYs.js.map +1 -0
- package/dist/assets/usePromptBlocks-5sz8Qh51.js +2 -0
- package/dist/assets/usePromptBlocks-5sz8Qh51.js.map +1 -0
- package/dist/assets/useSocket-YigidotN.css +1 -0
- package/dist/assets/useSocket-y3-zWhVL.js +11 -0
- package/dist/assets/useSocket-y3-zWhVL.js.map +1 -0
- package/dist/assets/utils--_pbLpCq.js +2 -0
- package/dist/assets/utils--_pbLpCq.js.map +1 -0
- package/dist/assets/vad-web-C_R267y1.js +2 -0
- package/dist/assets/vad-web-C_R267y1.js.map +1 -0
- package/dist/avatars/agent-avatar-1.png +0 -0
- package/dist/avatars/agent-avatar-2.png +0 -0
- package/dist/avatars/agent-avatar-3.png +0 -0
- package/dist/avatars/agent-avatar-4.png +0 -0
- package/dist/avatars/agent-avatar-5.png +0 -0
- package/dist/avatars/agent-avatar-6.png +0 -0
- package/dist/avatars/agent-avatar-7.png +0 -0
- package/dist/avatars/agent-avatar-8.png +0 -0
- package/dist/avatars/agent-avatar-9.png +0 -0
- package/dist/avatars/agentteams.png +0 -0
- package/dist/avatars/antig-opus.png +0 -0
- package/dist/avatars/antigravity.png +0 -0
- package/dist/avatars/assistant.svg +17 -0
- package/dist/avatars/codex-kawaii.png +0 -0
- package/dist/avatars/codex.png +0 -0
- package/dist/avatars/codex_box.png +0 -0
- package/dist/avatars/codex_iquid.png +0 -0
- package/dist/avatars/dare.png +0 -0
- package/dist/avatars/gemini-kawaii.png +0 -0
- package/dist/avatars/gemini.png +0 -0
- package/dist/avatars/gemini25.png +0 -0
- package/dist/avatars/gpt52.png +0 -0
- package/dist/avatars/jiuwenclaw.png +0 -0
- package/dist/avatars/office.svg +17 -0
- package/dist/avatars/opencode.png +0 -0
- package/dist/avatars/opus-45.png +0 -0
- package/dist/avatars/opus-kawaii.png +0 -0
- package/dist/avatars/opus.png +0 -0
- package/dist/avatars/sonnet.png +0 -0
- package/dist/favicon.ico +0 -0
- package/dist/icons/arrow-left.svg +3 -0
- package/dist/icons/arrow-right.svg +3 -0
- package/dist/icons/attach.svg +9 -0
- package/dist/icons/chart/dislike.svg +3 -0
- package/dist/icons/chart/disliked.svg +3 -0
- package/dist/icons/chart/folder.svg +15 -0
- package/dist/icons/chart/home-loading.webp +0 -0
- package/dist/icons/chart/like.svg +3 -0
- package/dist/icons/chart/liked.svg +5 -0
- package/dist/icons/chart/loading.svg +26 -0
- package/dist/icons/chart/success.svg +7 -0
- package/dist/icons/check-line.svg +3 -0
- package/dist/icons/chevron-left.svg +3 -0
- package/dist/icons/chevron-right.svg +3 -0
- package/dist/icons/collapse.svg +14 -0
- package/dist/icons/common-delete.svg +4 -0
- package/dist/icons/common-folder.svg +4 -0
- package/dist/icons/copy.svg +4 -0
- package/dist/icons/cross-line.svg +4 -0
- package/dist/icons/data-analysis.svg +7 -0
- package/dist/icons/data-visualization.svg +10 -0
- package/dist/icons/deep-research.svg +4 -0
- package/dist/icons/document-processing.svg +5 -0
- package/dist/icons/edit.svg +4 -0
- package/dist/icons/expand.svg +6 -0
- package/dist/icons/expert-debate.svg +4 -0
- package/dist/icons/eye.svg +4 -0
- package/dist/icons/favicon.svg +7 -0
- package/dist/icons/file-docx.svg +60 -0
- package/dist/icons/file-folder.svg +4 -0
- package/dist/icons/file-gitignore.svg +35 -0
- package/dist/icons/file-html.svg +6 -0
- package/dist/icons/file-ini.svg +63 -0
- package/dist/icons/file-json.svg +4 -0
- package/dist/icons/file-md.svg +68 -0
- package/dist/icons/file-py.svg +4 -0
- package/dist/icons/file-sh.svg +7 -0
- package/dist/icons/file-txt.svg +37 -0
- package/dist/icons/file-zip.svg +21 -0
- package/dist/icons/file.svg +4 -0
- package/dist/icons/files-csv.svg +14 -0
- package/dist/icons/files-docx.svg +10 -0
- package/dist/icons/files-pdf.svg +14 -0
- package/dist/icons/files-ppt.svg +14 -0
- package/dist/icons/files-txt.svg +16 -0
- package/dist/icons/files-xlsx.svg +14 -0
- package/dist/icons/financial-services.svg +8 -0
- package/dist/icons/flie-html.svg +60 -0
- package/dist/icons/guided-mode.svg +9 -0
- package/dist/icons/icon-192x192.png +0 -0
- package/dist/icons/icon-512x512.png +0 -0
- package/dist/icons/icon-arrow-down.svg +4 -0
- package/dist/icons/icon-arrow-up.svg +4 -0
- package/dist/icons/icon-clear-all.svg +3 -0
- package/dist/icons/icon-close.svg +4 -0
- package/dist/icons/icon-code.svg +38 -0
- package/dist/icons/icon-drag-file.svg +26 -0
- package/dist/icons/icon-help.svg +4 -0
- package/dist/icons/icon-md.svg +53 -0
- package/dist/icons/icon-refresh.svg +4 -0
- package/dist/icons/icon-toggle.svg +6 -0
- package/dist/icons/icon-top.svg +7 -0
- package/dist/icons/icon-upload.svg +5 -0
- package/dist/icons/information.svg +6 -0
- package/dist/icons/inspiration/icon-excel.svg +14 -0
- package/dist/icons/inspiration/icon-inspiration.svg +5 -0
- package/dist/icons/inspiration/icon-markdown.svg +12 -0
- package/dist/icons/inspiration/icon-word.svg +10 -0
- package/dist/icons/link.svg +6 -0
- package/dist/icons/lock.svg +4 -0
- package/dist/icons/menu/agents.svg +39 -0
- package/dist/icons/menu/channels.svg +4 -0
- package/dist/icons/menu/icon-inspiration.svg +5 -0
- package/dist/icons/menu/models.svg +4 -0
- package/dist/icons/menu/new-chat.svg +59 -0
- package/dist/icons/menu/schedule.svg +4 -0
- package/dist/icons/menu/skills.svg +4 -0
- package/dist/icons/message-error.svg +6 -0
- package/dist/icons/message-prompt.svg +9 -0
- package/dist/icons/message-success.svg +6 -0
- package/dist/icons/message-warn.svg +8 -0
- package/dist/icons/more-trigger.svg +4 -0
- package/dist/icons/nss/1.svg +14 -0
- package/dist/icons/nss/2.svg +14 -0
- package/dist/icons/nss/3.svg +14 -0
- package/dist/icons/outline.svg +6 -0
- package/dist/icons/query_the_optical_power_border.svg +99 -0
- package/dist/icons/schedule.svg +4 -0
- package/dist/icons/settings-feedback/feedback-bug.svg +20 -0
- package/dist/icons/settings-feedback/feedback-file.svg +4 -0
- package/dist/icons/settings-feedback/feedback-idea.svg +14 -0
- package/dist/icons/settings-feedback/settings-gear.svg +4 -0
- package/dist/icons/settings-feedback/settings-link.svg +4 -0
- package/dist/icons/settings-feedback/settings-memory.svg +7 -0
- package/dist/icons/settings-feedback/settings-privacy.svg +37 -0
- package/dist/icons/settings-feedback/settings-search.svg +2 -0
- package/dist/icons/slides.svg +4 -0
- package/dist/icons/status/info-error.svg +9 -0
- package/dist/icons/style-template.svg +11 -0
- package/dist/icons/tool-error.svg +4 -0
- package/dist/icons/userprofile/help.svg +5 -0
- package/dist/icons/userprofile/keep-awake.svg +4 -0
- package/dist/icons/userprofile/question.svg +4 -0
- package/dist/icons/userprofile/security.svg +7 -0
- package/dist/icons/userprofile/style-template.svg +11 -0
- package/dist/icons/userprofile/theme.svg +14 -0
- package/dist/icons/userprofile/usage.svg +4 -0
- package/dist/icons/userprofile/version.svg +85 -0
- package/dist/icons/video-generation.svg +4 -0
- package/dist/images/OfficeClaw.svg +21 -0
- package/dist/images/add.svg +4 -0
- package/dist/images/agent-management-icons/agent-check.svg +23 -0
- package/dist/images/agent-management-icons/agent-close.svg +4 -0
- package/dist/images/agent-management-icons/agent-collab.svg +4 -0
- package/dist/images/agent-management-icons/agent-delete.svg +18 -0
- package/dist/images/agent-management-icons/agent-edit.svg +18 -0
- package/dist/images/agent-management-icons/agent-more.svg +4 -0
- package/dist/images/agent-management-icons/agent-persona.svg +4 -0
- package/dist/images/agent-management-icons/agent-random-avatar.svg +39 -0
- package/dist/images/agent-management-icons/agent-refresh.svg +4 -0
- package/dist/images/agent-management-icons/agent-skills.svg +4 -0
- package/dist/images/agent-management-icons/agent-template.svg +12 -0
- package/dist/images/agent-management-icons/anchor-current.svg +5 -0
- package/dist/images/agent-management-icons/anchor-other.svg +4 -0
- package/dist/images/chat-empty-agent.svg +12 -0
- package/dist/images/chat-empty-im.svg +14 -0
- package/dist/images/connectors/dingtalk.png +0 -0
- package/dist/images/connectors/dingtalk.svg +18 -0
- package/dist/images/connectors/feishu.png +0 -0
- package/dist/images/connectors/feishu.svg +12 -0
- package/dist/images/connectors/imessage.png +0 -0
- package/dist/images/connectors/wecom-agent.png +0 -0
- package/dist/images/connectors/wecom-bot.png +0 -0
- package/dist/images/connectors/weixin.png +0 -0
- package/dist/images/connectors/weixin.svg +19 -0
- package/dist/images/connectors/xiaoyi.png +0 -0
- package/dist/images/connectors/xiaoyi.svg +12 -0
- package/dist/images/create-agent-random-avatar.svg +39 -0
- package/dist/images/deepseek.svg +1 -0
- package/dist/images/default-ppt-template.png +0 -0
- package/dist/images/file-browser-tree/code.svg +60 -0
- package/dist/images/file-browser-tree/gitignore.svg +35 -0
- package/dist/images/file-browser-tree/image.svg +12 -0
- package/dist/images/file-browser-tree/markdown.svg +68 -0
- package/dist/images/file-browser-tree/pdf.svg +4 -0
- package/dist/images/file-browser-tree/ppt.svg +4 -0
- package/dist/images/file-browser-tree/public-file.svg +37 -0
- package/dist/images/file-browser-tree/word.svg +60 -0
- package/dist/images/file-browser-tree/xlsx.svg +4 -0
- package/dist/images/html-preview-toolbar/copy.svg +4 -0
- package/dist/images/html-preview-toolbar/open-external.svg +4 -0
- package/dist/images/html-preview-toolbar/refresh.svg +4 -0
- package/dist/images/information.svg +4 -0
- package/dist/images/inspiration/blue-bg.png +0 -0
- package/dist/images/inspiration/doc-example.png +0 -0
- package/dist/images/inspiration/excel-example.png +0 -0
- package/dist/images/inspiration/green-bg.png +0 -0
- package/dist/images/inspiration/markdown-example.png +0 -0
- package/dist/images/inspiration/orange-bg.png +0 -0
- package/dist/images/inspiration/purple-bg.png +0 -0
- package/dist/images/inspiration/task-bg.png +0 -0
- package/dist/images/inspiration-bg.png +0 -0
- package/dist/images/inspiration-products/default.svg +11 -0
- package/dist/images/invitation-background-4x.png +0 -0
- package/dist/images/kimi.svg +1 -0
- package/dist/images/link-blue.svg +4 -0
- package/dist/images/link.svg +4 -0
- package/dist/images/lobster.svg +118 -0
- package/dist/images/login1.svg +93 -0
- package/dist/images/login2.svg +80 -0
- package/dist/images/login3.svg +44 -0
- package/dist/images/login4.svg +18 -0
- package/dist/images/mode-default-icon.svg +22 -0
- package/dist/images/no-data.svg +26 -0
- package/dist/images/no-search-results.svg +25 -0
- package/dist/images/ppt-preview/placeholder-main.webp +0 -0
- package/dist/images/ppt-preview/placeholder-thumb.webp +0 -0
- package/dist/images/ppt-template/dark-tech.png +0 -0
- package/dist/images/ppt-template/huawei.png +0 -0
- package/dist/images/ppt-template/light-tech.png +0 -0
- package/dist/images/ppt-template/paper-humanities.png +0 -0
- package/dist/images/ppt-template/template-default.png +0 -0
- package/dist/images/ppt-template/template-error.png +0 -0
- package/dist/images/ppt-template/template-generate-bg.svg +9639 -0
- package/dist/images/qwen.svg +1 -0
- package/dist/images/task-list/empty-state.svg +4 -0
- package/dist/images/task-list.svg +1 -0
- package/dist/images/vendor.svg +4 -0
- package/dist/images/version-bg.svg +85 -0
- package/dist/images/version.svg +9 -0
- package/dist/images/zhipu.svg +1 -0
- package/dist/index.html +74 -0
- package/dist/loading-point-style.webp +0 -0
- package/dist/loading-small.webp +0 -0
- package/dist/manifest.json +25 -0
- package/package.json +126 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OfficeClaw Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @openjiuwen/relay-web
|
|
2
|
+
|
|
3
|
+
OfficeClaw 前端
|
|
4
|
+
|
|
5
|
+
## 本地启动
|
|
6
|
+
|
|
7
|
+
项目启动需要依赖:`Node.js`、`pnpm`、`Python`、`Redis`。
|
|
8
|
+
|
|
9
|
+
推荐依赖版本:
|
|
10
|
+
- `Node.js`: `>= 22.16.0`
|
|
11
|
+
- `pnpm`: `>= 9.15.4`
|
|
12
|
+
- `Python`: `>= 3.13.1`
|
|
13
|
+
- `Redis`: `>= 5.0.14.1`
|
|
14
|
+
|
|
15
|
+
方式1:一键启动
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm i
|
|
19
|
+
|
|
20
|
+
# alias pnpm dev:a
|
|
21
|
+
pnpm dev:all
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
方式2:前后端分开启动
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# alias pnpm dev:b
|
|
28
|
+
pnpm dev:backend
|
|
29
|
+
# alias pnpm dev:f
|
|
30
|
+
pnpm dev:frontend
|
|
31
|
+
```
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import{j as e,r,B as q,M as Z,a as Je,u as Ce,b as Ut,c as Ee,d as Ht}from"./index-Cb4fQgom.js";import{E as Le}from"./EmptyDataState-6mNx2Xhl.js";import{N as We}from"./NoSearchResultsState-BiiYdZ_Z.js";import{S as fe}from"./SearchInput-tux8xXH1.js";import{R as mt}from"./RefreshButton-BzYzeo5A.js";import{O as oe,a as B,A as Vt}from"./OverflowTooltip-CE5PjAb-.js";import{H as Te}from"./HelpPrompt-BPzDcC8F.js";import{N as ze}from"./NameInitialIcon-DP-6_HQY.js";import{M as Ie,b as Kt}from"./hub-agent-editor.payload-D4sgJRSH.js";import{T as Qt,n as Yt,p as Zt,a as Xt,H as Jt,F as ea,C as ta}from"./utils--_pbLpCq.js";import{A as aa}from"./Alert-D88Fk6to.js";import{n as sa}from"./skill-options-cache-D1BJGTCU.js";import{U as ra}from"./UploadSkillModal-DHZL12vm.js";import{u as na}from"./hub-agent-editor.client-2DmCRGuY.js";import{u as pt}from"./useAgentData-D-k9cXfg.js";import{A as la}from"./AppModal-BYZTSuch.js";import{n as et}from"./thread-title-Cerb2mHa.js";import{f as oa}from"./thread-utils-Ct3yp4R3.js";import{u as ia}from"./useExpertCatalog-BZdw1CYs.js";import{b as ca}from"./helpers-CCilgpNy.js";import"./quick-actions-DzZE-zyP.js";import"./usePromptBlocks-5sz8Qh51.js";import"./index-DQ2vVjmV.js";function da(t){return t?t.slice(0,1).toUpperCase():"智"}function ua(t){const a=[{bg:"#FFF4E6",border:"#FFE0B2",text:"#E65100"},{bg:"#E3F2FD",border:"#BBDEFB",text:"#1565C0"},{bg:"#F3E5F5",border:"#E1BEE7",text:"#7B1FA2"},{bg:"#E8F5E9",border:"#C8E6C9",text:"#2E7D32"},{bg:"#FFF3E0",border:"#FFE0B2",text:"#E65100"},{bg:"#E0F7FA",border:"#B2EBF2",text:"#00838F"},{bg:"#FCE4EC",border:"#F8BBD0",text:"#C2185B"},{bg:"#F1F8E9",border:"#DCEDC8",text:"#558B2F"}],s=t.charCodeAt(0)%a.length;return{background:a[s].bg,borderColor:a[s].border,textColor:a[s].text}}function xa({agent:t}){var o;const a=(o=t.avatar)==null?void 0:o.trim();if(a&&(a.startsWith("/uploads/")||a.startsWith("/avatars/")||/^https?:\/\//.test(a)))return e.jsx("img",{src:a,alt:t.displayName,className:"h-12 w-12 shrink-0 rounded-full object-cover"});const s=t.displayName??t.name??"智",n=ua(s);return e.jsx("div",{"aria-hidden":"true",className:"inline-flex h-12 w-12 shrink-0 items-center justify-center rounded-full border shadow-sm",style:{background:n.background,borderColor:n.borderColor},children:e.jsx("span",{className:"select-none text-xl font-bold leading-none tracking-[0.02em]",style:{color:n.textColor},children:da(s)})})}function ma({agent:t,onClick:a,onEdit:s,onDelete:n}){const o=t.defaultModel||"未配置模型",l=t.source==="seed"?"预置":t.creationSource==="experts-plaza"?"智能体广场":"自定义";return e.jsxs("article",{className:"ui-card ui-card-hover group relative flex h-[196px] cursor-pointer flex-col rounded-[16px] border border-[#e6e6e6] bg-white p-6",onClick:()=>a(t.id),onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),a(t.id))},role:"button",tabIndex:0,"aria-label":`查看智能体 ${t.displayName}`,children:[e.jsxs("div",{className:"mb-4 flex items-start gap-3",children:[e.jsx(xa,{agent:t}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-semibold text-[var(--text-primary)]",children:t.displayName}),e.jsx("p",{className:"mt-1 truncate text-[12px] text-[var(--text-muted)]",children:o})]})]}),t.roleDescription?e.jsx("p",{className:"line-clamp-2 mb-4 flex-1 text-[12px] leading-relaxed text-[var(--text-secondary)]",children:t.roleDescription}):e.jsx("p",{className:"line-clamp-2 mb-4 flex-1 text-[12px] leading-relaxed text-[var(--text-muted)]",children:"暂无描述"}),e.jsx("div",{className:`mt-auto flex items-center justify-between text-[12px] text-[var(--text-muted)] transition-opacity ${s||n?"group-hover:opacity-0 group-hover:pointer-events-none group-focus-within:opacity-0 group-focus-within:pointer-events-none":""}`,children:e.jsxs("span",{children:["来源:",l]})}),e.jsxs("div",{className:`absolute bottom-6 left-6 right-6 flex items-center gap-4 transition-opacity ${s||n?"opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto":""}`,children:[s&&e.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),s(t.id)},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.stopPropagation(),s(t.id))},className:"bg-transparent p-0 text-[14px] font-normal text-[var(--text-accent)] hover:underline",children:"编辑"}),n&&e.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),n(t.id)},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.stopPropagation(),n(t.id))},className:"bg-transparent p-0 text-[14px] font-normal text-[var(--text-accent)] hover:underline",children:"删除"})]})]})}const pa="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",Pe=[{id:"basic",label:"基础信息"},{id:"soul",label:"灵魂配置"},{id:"skills",label:"技能配置"}],ke=4,fa=335,Be=8,ha="Huawei MaaS",ft="relayclaw",_e="支持中文、数字、下划线、中划线和空格,长度 2-64 字符,但不允许以空格开头或结尾",qe=["/avatars/agent-avatar-1.png","/avatars/agent-avatar-2.png","/avatars/agent-avatar-3.png","/avatars/agent-avatar-4.png","/avatars/agent-avatar-5.png","/avatars/agent-avatar-6.png","/avatars/agent-avatar-7.png","/avatars/agent-avatar-8.png","/avatars/agent-avatar-9.png"],va=qe[0],pe=[{id:"customer-service",title:"专业客服助手",description:"遵循服务规范,礼貌应答、流程引导、问题定位与转接支持,严格遵守业务边界。",content:`### 人格定义 (Persona)
|
|
2
|
+
- 身份:资深客服顾问,擅长复杂问题拆解与安抚沟通。
|
|
3
|
+
- 性格:耐心克制、语气专业、表达清晰。
|
|
4
|
+
- 边界:优先给流程和升级路径,不承诺超出权限范围的结果。
|
|
5
|
+
|
|
6
|
+
### 行为准则 (Behavior)
|
|
7
|
+
- 精准识别用户诉求与情绪波动,先安抚再给处理路径。
|
|
8
|
+
- 优先提供标准流程与升级建议,避免模糊表述。
|
|
9
|
+
- 回复中同步标注下一步动作和责任归属,方便继续跟进。`},{id:"content-creation",title:"内容创作助手",description:"支持文案策写、标题优化、脚本创作与风格适配,结构清晰,表达自然。",content:`### 人格定义 (Persona)
|
|
10
|
+
- 身份:资深内容创作者,擅长短视频脚本、公众号与朋友圈文案。
|
|
11
|
+
- 性格:创意灵活、洞察强,适配多平台风格。
|
|
12
|
+
- 边界:只提供创作思路和文案优化,不涉及侵权内容。
|
|
13
|
+
|
|
14
|
+
### 行为准则 (Behavior)
|
|
15
|
+
- 先明确平台、受众、核心卖点与风格,再组织内容结构。
|
|
16
|
+
- 快速提供多版初稿,并标注亮点和适用场景。
|
|
17
|
+
- 根据反馈迭代修改,同时说明调整重点和原因。`},{id:"knowledge-answering",title:"知识解答专家",description:"以严谨准确为原则,科普概念、拆解原理、解释规则,输出可信且有条理。",content:`### 人格定义 (Persona)
|
|
18
|
+
- 身份:知识顾问,擅长多源信息整合与严谨解释。
|
|
19
|
+
- 性格:理性克制、客观中立、注重依据。
|
|
20
|
+
- 边界:不制造未经验证的结论,需要时先补充上下文。
|
|
21
|
+
|
|
22
|
+
### 行为准则 (Behavior)
|
|
23
|
+
- 先确认问题边界和上下文,再给出结构化解释。
|
|
24
|
+
- 需要时补充适用范围、风险提醒和可执行建议。
|
|
25
|
+
- 输出以结论、依据、行动项三段式为主,便于快速吸收。`},{id:"work-efficiency",title:"职场效率助手",description:"提供沟通话术、汇报提纲、流程梳理与决策辅助,帮助提升交付效率。",content:`### 人格定义 (Persona)
|
|
26
|
+
- 身份:项目协作教练,擅长流程梳理与任务推进。
|
|
27
|
+
- 性格:简洁务实、节奏明确、结果导向。
|
|
28
|
+
- 边界:优先提升沟通和推进效率,不替代最终业务判断。
|
|
29
|
+
|
|
30
|
+
### 行为准则 (Behavior)
|
|
31
|
+
- 优先沉淀行动项、责任人和时间节点。
|
|
32
|
+
- 必要时给出沟通模板、纪要模板和复盘建议。
|
|
33
|
+
- 遇到阻塞时先拆原因,再提供可落地的替代方案。`},{id:"project-management",title:"项目管理助手",description:"帮助拆解目标、制定里程碑、推动协作与风险跟踪,保持推进节奏清晰。",content:`### 人格定义 (Persona)
|
|
34
|
+
- 身份:项目经理与交付协调者,擅长推进计划落地。
|
|
35
|
+
- 性格:稳健清晰、节奏明确、关注依赖关系。
|
|
36
|
+
- 边界:聚焦项目推进与协作管理,不替代业务 owner 决策。
|
|
37
|
+
|
|
38
|
+
### 行为准则 (Behavior)
|
|
39
|
+
- 先明确目标与边界,再拆解任务、识别风险并推动闭环。
|
|
40
|
+
- 围绕依赖关系和优先级安排里程碑与检查点。
|
|
41
|
+
- 产出默认带负责人、时间节点和跟踪建议。`},{id:"data-analysis",title:"数据分析助手",description:"聚焦指标拆解、数据解读、洞察归纳与结论表达,适合业务分析场景。",content:`### 人格定义 (Persona)
|
|
42
|
+
- 身份:数据分析师,擅长从指标与样本中提炼业务洞察。
|
|
43
|
+
- 性格:严谨客观、表达简洁、重视证据。
|
|
44
|
+
- 边界:不在样本不足时输出确定性结论,会明确说明口径和限制。
|
|
45
|
+
|
|
46
|
+
### 行为准则 (Behavior)
|
|
47
|
+
- 先确认指标口径与样本范围,再给出分析过程。
|
|
48
|
+
- 输出结论时同步说明依据、异常点和建议动作。
|
|
49
|
+
- 默认补充图表建议、后续验证方向和数据缺口。`}];function Re(t){return`## ${t.title}
|
|
50
|
+
|
|
51
|
+
${t.content}`}function ba({agents:t,onSelectAgent:a,onEditAgent:s,onDeleteAgent:n,searchQuery:o="",sourceFilter:l="all",onClearSearch:c,onClearFilter:x}){return t.length===0?o.trim()||l!=="all"?e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(We,{onClear:()=>{c==null||c(),x==null||x()}})}):e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(Le,{title:"暂无智能体"})}):e.jsx("div",{className:pa,children:t.map(u=>e.jsx(ma,{agent:u,onClick:a,onEdit:s,onDelete:n},u.id))})}const De=[{value:"all",label:"全部"},{value:"seed",label:"预置智能体"},{value:"runtime",label:"自定义"},{value:"experts-plaza",label:"智能体广场"}];function ja({searchQuery:t,sourceFilter:a,onSearchChange:s,onClearSearch:n,onSourceFilterChange:o,onRefresh:l,loading:c}){var d;const[x,u]=r.useState(!1),p=((d=De.find(i=>i.value===a))==null?void 0:d.label)??"全部";return e.jsxs("div",{className:"flex w-full items-center gap-3",children:[e.jsxs("div",{className:"relative w-[120px] shrink-0",children:[e.jsx("select",{"aria-label":"筛选来源",value:a,onChange:i=>o(i.target.value),className:"sr-only",tabIndex:-1,children:De.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))}),e.jsxs("button",{type:"button",onClick:()=>u(i=>!i),className:`ui-field flex h-[28px] w-[120px] items-center justify-between rounded-[6px] px-[12px] py-[5px] text-xs transition-colors ${x?"border-[#191919]":""}`,"aria-haspopup":"listbox","aria-expanded":x,children:[e.jsx("span",{className:"truncate text-[var(--text-primary)]",children:p}),e.jsx("svg",{className:`h-3.5 w-3.5 text-[var(--text-muted)] transition-transform duration-200 ${x?"rotate-180":""}`,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),x?e.jsx("div",{role:"listbox",className:"absolute left-0 top-[calc(100%+4px)] z-30 w-[120px] rounded-[6px] bg-[var(--surface-panel)] py-[8px] shadow-[0_2px_12px_0_var(--tooltip-shadow-color)]",children:De.map(i=>{const h=i.value===a;return e.jsx("button",{type:"button",role:"option","aria-selected":h,onClick:()=>{o(i.value),u(!1)},className:`flex h-[32px] w-full items-center px-[16px] py-[7px] text-left text-xs transition-colors hover:bg-[var(--tag-bg)] ${h?"text-[var(--text-accent)]":"text-[var(--text-primary)]"}`,children:i.label},i.value)})}):null]}),e.jsx(fe,{value:t,onChange:s,onClear:n,placeholder:"搜索智能体","aria-label":"搜索智能体",clearAriaLabel:"清除搜索",wrapperClassName:"flex-1"}),e.jsx(mt,{onClick:l,disabled:c,"aria-label":"刷新列表"})]})}function ga({agent:t}){const a=t.defaultModel||"未配置模型",s=t.imageModel||"未配置";return e.jsxs("div",{className:"flex flex-col gap-4 pb-8",children:[e.jsx("h2",{className:"text-[16px] font-semibold text-[var(--text-primary)]",children:"基础信息"}),e.jsxs("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"min-w-0 flex flex-col gap-2",children:[e.jsx("h2",{className:"text-[12px] font-medium text-[var(--text-muted)]",children:"描述"}),e.jsx(oe,{content:t.roleDescription||"暂无描述",className:"block w-full min-w-0",placement:"top",children:e.jsx("span",{className:"block min-w-0 truncate text-[14px] text-[var(--text-primary)]",children:t.roleDescription||"暂无描述"})})]}),e.jsxs("div",{className:"min-w-0 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("h2",{className:"text-[12px] font-medium text-[var(--text-muted)]",children:"主模型"}),e.jsx(Te,{tooltip:"负责思考、推理、生成文本输出",ariaLabel:"主模型说明"})]}),e.jsx("p",{className:"break-words text-[14px] text-[var(--text-primary)]",children:a})]}),e.jsxs("div",{className:"min-w-0 flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("h2",{className:"text-[12px] font-medium text-[var(--text-muted)]",children:"图像理解模型(可选)"}),e.jsx(Te,{tooltip:"用于对图片内容的识别场景,对图片附件进行处理",ariaLabel:"图像理解模型说明"})]}),e.jsx("p",{className:"break-words text-[14px] text-[var(--text-primary)]",children:s})]})]})]})}let Ge=new Map;function tt(t){return Ge.get(t)}function wa(t,a){Ge.set(t,a)}function at(t){t.forEach(a=>{Ge.set(a.name,a)})}const ya="_skillGrid_1sdgq_7",Na="_skillCard_1sdgq_13",Sa="_cardIcon_1sdgq_23",ka="_cardContent_1sdgq_28",_a="_cardName_1sdgq_36",Ca="_cardDescription_1sdgq_45",Ea="_emptyState_1sdgq_53",Q={skillGrid:ya,skillCard:Na,cardIcon:Sa,cardContent:ka,cardName:_a,cardDescription:Ca,emptyState:Ea};function Ma({agent:t}){const a=t.skills,[s,n]=r.useState(new Set);return r.useEffect(()=>{if(!a||a.length===0)return;const o=a.filter(l=>!tt(l));o.length!==0&&(n(new Set(o)),Promise.all(o.map(async l=>{try{const c=await B(`/api/skills/detail?name=${encodeURIComponent(l)}`);if(c.ok){const x=await c.json();wa(l,{name:x.name,description:x.description})}}finally{n(c=>{const x=new Set(c);return x.delete(l),x})}})))},[a]),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h2",{className:"text-[16px] font-semibold text-[var(--text-primary)]",children:"技能配置"}),a&&a.length>0?e.jsx("div",{className:Q.skillGrid,children:a.map(o=>{const l=tt(o),c=s.has(o);return e.jsxs("div",{className:Q.skillCard,children:[e.jsx(ze,{name:o,className:Q.cardIcon}),e.jsxs("div",{className:Q.cardContent,children:[e.jsx("span",{className:Q.cardName,children:o}),c?e.jsx("span",{className:Q.cardDescription,children:"加载中..."}):(l==null?void 0:l.description)&&e.jsx("span",{className:Q.cardDescription,children:l.description})]})]},o)})}):e.jsx("p",{className:Q.emptyState,children:"未配置"})]})}function La(t){return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:t.className,children:e.jsx("path",{d:"M15 6L9 12L15 18",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ta(t){return e.jsx("svg",{viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",className:t.className,children:e.jsx("path",{d:"M9 6L15 12L9 18",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ia({activeTab:t,activeWorkingDraft:a,editorSurfaceRef:s,editorTextareaRef:n,isPersonaEmpty:o,onApplyTemplate:l,onAfterApplyTemplate:c,onDraftChange:x,onNextTemplatePage:u,onPrevTemplatePage:p,templatePage:d,templatePageCount:i,visibleTemplates:h,appliedTemplateKey:w}){const N=t==="persona";return e.jsxs("div",{"data-testid":o?"agent-tab-empty-editor":"agent-tab-editor",className:"relative flex min-h-0 flex-1 flex-col p-4 h-full",children:[e.jsx("div",{ref:s,className:"min-h-0 flex-1",children:e.jsx("textarea",{ref:n,value:a,onChange:v=>x(v.target.value),placeholder:"请输入你的智能体人格、语气、规则描述,或选择下方模板自动生成",className:"ui-textarea ui-textarea-plain block h-full min-h-0 w-full resize-none overflow-y-auto rounded-none text-[12px] leading-7","data-testid":"agent-tab-textarea"})}),N?e.jsx("div",{className:`mt-4 flex shrink-0 flex-col ${o?"":"hidden"}`,children:e.jsxs("div",{className:"mx-auto w-full",children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between gap-3 text-[12px] text-[var(--text-muted)]",children:[e.jsx("span",{children:"灵魂模板"}),i>1?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:p,disabled:d===0,className:"inline-flex h-6 w-6 items-center justify-center rounded-full text-[var(--text-muted)] transition enabled:hover:bg-[var(--surface-card-muted)] disabled:cursor-not-allowed disabled:opacity-40","aria-label":"上一页模板",children:e.jsx(La,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:u,disabled:d>=i-1,className:"inline-flex h-6 w-6 items-center justify-center rounded-full text-[var(--text-muted)] transition enabled:hover:bg-[var(--surface-card-muted)] disabled:cursor-not-allowed disabled:opacity-40","aria-label":"下一页模板",children:e.jsx(Ta,{className:"h-3.5 w-3.5"})})]}):null]}),e.jsx("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2 xl:grid-cols-4",children:h.map(v=>e.jsx(oe,{content:v.title,forceShow:!0,placement:"top",className:"block",customContent:e.jsxs("div",{className:"w-[320px] max-w-[calc(100vw-24px)] p-4","data-template-preview-tooltip":"1",children:[e.jsx("h3",{className:"text-[14px] font-semibold text-[var(--text-primary)]",children:v.title}),e.jsx("div",{className:"mt-3 min-h-0 max-h-[260px] overflow-y-auto",children:e.jsx(Ie,{content:Re(v),className:"text-[12px] leading-[1.55] text-[var(--text-secondary)] [&_h2]:mb-3 [&_h2]:text-[14px] [&_h2]:font-semibold [&_h2]:text-[var(--text-primary)] [&_h3]:mb-2 [&_h3]:text-[12px] [&_h3]:font-semibold [&_h3]:text-[var(--text-primary)] [&_ul]:mb-3 [&_ul]:space-y-1.5",disableCommandPrefix:!0})}),e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx(q,{variant:"major",onClick:()=>{l(v.id),c==null||c()},children:"插入模板"})})]}),children:e.jsxs("button",{type:"button",className:"h-[98px] w-full rounded-[8px] border border-[var(--border-default)] bg-[var(--surface-panel)] px-4 py-4 text-left transition-[border-color,background-color,box-shadow] hover:border-[var(--card-hover-border)] hover:bg-[var(--card-hover-bg)] hover:shadow-[var(--card-hover-shadow)]",children:[e.jsx("div",{className:"text-[14px] font-semibold text-[var(--text-primary)]",children:v.title}),e.jsx("div",{className:"mt-2 line-clamp-2 text-[12px] leading-5 text-[var(--text-muted)]",children:v.description})]})},`${v.id}-${w}`))})]})}):null]})}function ht({activeWorkingDraft:t,onDraftChange:a}){const s=r.useRef(null),n=r.useRef(null),[o,l]=r.useState(0),[c,x]=r.useState(0),u=Math.max(1,Math.ceil(pe.length/ke)),p=pe.slice(o*ke,o*ke+ke),d=r.useCallback(h=>{const w=pe.find(g=>g.id===h);if(!w)return;const N=Re(w),v=t.trim();a(v?`${v}
|
|
52
|
+
|
|
53
|
+
${N}`:N),x(g=>g+1)},[t,a]),i=r.useCallback(()=>{x(h=>h+1)},[]);return e.jsx(Ia,{activeTab:"persona",activeWorkingDraft:t,editorSurfaceRef:s,editorTextareaRef:n,isPersonaEmpty:!t.trim(),onApplyTemplate:d,onAfterApplyTemplate:i,onDraftChange:a,onNextTemplatePage:()=>l(h=>Math.min(u-1,h+1)),onPrevTemplatePage:()=>l(h=>Math.max(0,h-1)),templatePage:o,templatePageCount:u,visibleTemplates:p,appliedTemplateKey:c})}function vt({personality:t,agentId:a,readOnly:s=!1,muted:n=!0,onDraftChange:o,showTitle:l=!1}){if(!a)return e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(Le,{title:"当前没有可展示的智能体"})});const c=l?e.jsx("h2",{className:"mb-4 text-[16px] font-semibold text-[var(--text-primary)]",children:"灵魂配置"}):null;return s?e.jsxs("div",{children:[c,e.jsx("div",{className:`h-[480px] overflow-auto rounded-lg border border-[var(--border-default)] p-6${n?" bg-[var(--surface-card-muted)]":""}`,children:e.jsx(Ie,{content:t??"",className:`max-w-none text-[14px] leading-7 ${n?"text-[var(--text-secondary)] opacity-80":"text-[var(--text-primary)]"} [&_h1]:mb-4 [&_h1]:text-[18px] [&_h1]:font-bold ${n?"[&_h1]:text-[var(--text-secondary)]":""} [&_h2]:mb-3 [&_h2]:text-[16px] [&_h2]:font-semibold ${n?"[&_h2]:text-[var(--text-secondary)]":""} [&_h3]:mb-2 [&_h3]:text-[14px] [&_h3]:font-semibold ${n?"[&_h3]:text-[var(--text-secondary)]":""} [&_p]:mb-3 [&_ul]:mb-3 [&_ol]:mb-3 [&_li]:mb-1`,disableCommandPrefix:!0})})]}):t!=null&&t.trim()?o?e.jsxs("div",{children:[c,e.jsx(ht,{activeWorkingDraft:t,onDraftChange:o})]}):e.jsxs("div",{children:[c,e.jsx("div",{className:"h-[480px] overflow-auto rounded-lg border border-[var(--border-default)] p-6",children:e.jsx(Ie,{content:t??"",className:"max-w-none text-[14px] leading-7 text-[var(--text-primary)] [&_h1]:mb-4 [&_h1]:text-[18px] [&_h1]:font-bold [&_h2]:mb-3 [&_h2]:text-[16px] [&_h2]:font-semibold [&_h3]:mb-2 [&_h3]:text-[14px] [&_h3]:font-semibold [&_p]:mb-3 [&_ul]:mb-3 [&_ol]:mb-3 [&_li]:mb-1",disableCommandPrefix:!0})})]}):e.jsxs("div",{className:"flex h-full min-h-0 flex-col items-center justify-center",children:[c,e.jsxs("div",{className:"h-[480px] w-full rounded-lg border border-[var(--border-default)] p-6 text-center",children:[e.jsx(Le,{title:"暂无内容"}),e.jsx("p",{className:"mt-1 text-[12px] text-[var(--text-secondary)]",children:"请编辑灵魂配置内容,定义智能体的人格、行为准则与底线"})]})]})}function Ra(t,a,s="all"){let n=t;s!=="all"&&(n=n.filter(l=>s==="experts-plaza"?l.creationSource==="experts-plaza":s==="seed"?l.source==="seed":s==="runtime"?l.source==="runtime"&&!l.creationSource:!0));const o=a.trim().toLowerCase();return o?n.filter(l=>{var c;return(c=l.displayName)==null?void 0:c.toLowerCase().includes(o)}):n}function Aa(t){const a=t.trim()||"BOT";let s=0;for(const n of a)s=(s*31+n.charCodeAt(0))%360;return`hsl(${s} 72% 62%)`}function $a(t){const a=(t.trim().slice(0,1)||"智").toUpperCase(),n=`
|
|
54
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="96" height="96" viewBox="0 0 96 96">
|
|
55
|
+
<defs>
|
|
56
|
+
<linearGradient id="g" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
57
|
+
<stop offset="0%" stop-color="${Aa(t)}" />
|
|
58
|
+
<stop offset="100%" stop-color="#8AA4FF" />
|
|
59
|
+
</linearGradient>
|
|
60
|
+
</defs>
|
|
61
|
+
<rect width="96" height="96" rx="48" fill="url(#g)" />
|
|
62
|
+
<circle cx="48" cy="48" r="38" fill="rgba(255,255,255,0.18)" />
|
|
63
|
+
<text x="50%" y="54%" text-anchor="middle" dominant-baseline="middle" font-family="Inter, Arial, sans-serif" font-size="38" font-weight="700" fill="#FFFFFF">${a}</text>
|
|
64
|
+
</svg>
|
|
65
|
+
`.trim();return`data:image/svg+xml;charset=UTF-8,${encodeURIComponent(n)}`}function Fa(t){var a;return((a=t==null?void 0:t.avatar)==null?void 0:a.trim())??""}function Oa(){const t=Math.floor(Math.random()*qe.length);return qe[t]}function Pa(t){return t.startsWith("/uploads/")?`${Vt}${t}`:t}function st(t){if(!t)return!1;const a=t.trim().toLowerCase();return a?a.includes("名称")&&a.includes("已被使用")||a.includes("duplicate")||a.includes("already exists")||a.includes("名称重复")||a.includes("名字重复")||a.includes("重名"):!1}const Ba=/model\s+["'][^"']+["']\s+is not available on provider/i,Da=/provider\s+["'][^"']+["']\s+not found/i;function rt(t){if(!t)return null;const a=t.trim();return a?Ba.test(a)||Da.test(a)?"模型不存在,请重新选择":a:null}const qa="/avatars/assistant.svg";function Wa(){return e.jsx("svg",{className:"h-4 w-4 text-[var(--text-muted)]",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M7 10L12 15L17 10",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})})}function bt({item:t}){var s;const a=((s=t.icon)==null?void 0:s.trim())||qa;return e.jsx("img",{src:a,alt:`${t.name} icon`,"data-testid":`model-logo-${t.name}`,className:"h-[18px] w-[18px] shrink-0 object-contain"})}function nt({item:t,placeholder:a="请选择模型",loading:s=!1}){return e.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[t&&!s?e.jsx(bt,{item:t}):null,e.jsx(oe,{content:s?"加载模型中...":(t==null?void 0:t.name)??a,className:"min-w-0",children:e.jsx("span",{className:`block min-w-0 truncate text-[12px] ${t?"text-[var(--text-primary)]":"text-[var(--text-muted)]"}`,style:{maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",wordBreak:"break-all"},children:s?"加载模型中...":(t==null?void 0:t.name)??a})})]})}function lt(){return e.jsx(Wa,{})}function ot({groups:t,selectedId:a=null,searchPlaceholder:s="输入关键字搜索",allowClear:n=!1,onSelect:o,onClear:l}){const[c,x]=r.useState(""),u=r.useMemo(()=>{const p=c.trim().toLowerCase();return p?t.map(d=>({...d,items:d.items.filter(i=>[i.name,i.providerGroup,i.experienceText,i.statusText,i.rightLabel].filter(Boolean).join(" ").toLowerCase().includes(p))})).filter(d=>d.items.length>0):t},[t,c]);return e.jsxs("div",{className:"ui-panel flex max-h-[335px] w-full py-2 flex-col overflow-hidden rounded-[var(--radius-md)] bg-[var(--surface-panel)] shadow-[0_10px_24px_rgba(0,0,0,0.09)]","data-testid":"model-select-dropdown",children:[e.jsx("div",{className:"px-4 py-1",children:e.jsx(fe,{"aria-label":"搜索模型",value:c,onChange:p=>x(p),onClear:()=>x(""),placeholder:s,wrapperClassName:"w-full",inputClassName:"rounded-[var(--radius-pill)]"})}),e.jsx("div",{"aria-hidden":"true",className:"my-[6px] h-px w-full bg-[var(--panel-border-outer)]"}),e.jsxs("div",{role:"listbox",className:"flex min-h-0 flex-1 flex-col overflow-y-auto",children:[n&&!c.trim()?e.jsx("button",{type:"button",role:"option","aria-selected":a===null||a==="","data-testid":"model-row-clear",onClick:()=>l==null?void 0:l(),className:`flex min-h-[34px] w-full items-center border-0 px-4 py-1.5 text-left transition-colors ${a===null||a===""?"bg-[var(--menu-active-bg)] text-[var(--text-accent)]":"bg-[var(--surface-panel)] text-[var(--modal-text)] hover:bg-[var(--menu-hover-bg)] hover:text-[var(--text-accent)]"}`,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("div",{className:"h-[18px] w-[18px] shrink-0 rounded-full border border-dashed border-[var(--border-default)]"}),e.jsx("div",{className:"min-w-0",children:e.jsx("span",{className:"block truncate text-[14px] leading-[20px] font-normal text-[var(--text-muted)]",children:"不选择"})})]})}):null,u.map(p=>e.jsxs("div",{children:[e.jsx("div",{className:"px-4 text-[12px] font-medium leading-[32px] text-[var(--text-label-secondary)]",children:p.label}),p.items.map(d=>{const i=d.id===a;return e.jsx("button",{type:"button",role:"option","aria-selected":i,"data-testid":`model-row-${d.id}`,onClick:()=>o==null?void 0:o(d),className:`flex min-h-[34px] w-full items-center border-0 px-4 py-1.5 text-left transition-colors ${i?"bg-[var(--menu-active-bg)] text-[var(--text-accent)]":"bg-[var(--surface-panel)] text-[var(--modal-text)] hover:bg-[var(--menu-hover-bg)] hover:text-[var(--text-accent)]"}`,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx(bt,{item:d}),e.jsx("div",{className:"min-w-0",children:e.jsx(oe,{content:d.name,className:"w-full",children:e.jsx("div",{className:"block min-w-0 truncate text-[14px] leading-[20px] font-normal text-current",style:{maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",wordBreak:"break-all"},children:d.name})})})]})},d.id)})]},p.id)),u.length===0?e.jsx("div",{className:"px-3 py-6 text-center text-sm text-[var(--text-muted)]",children:"没有匹配的模型"}):null]})]})}function za(){return e.jsx(Z,{name:"random",className:"block h-[28px] w-[28px]"})}function Ga({avatarError:t,displayAvatar:a,draftDefaultModel:s,draftImageModel:n,draftDescription:o,draftName:l,fileInputRef:c,inlineNameError:x,loadingModels:u,modelGroups:p,modelMenuOpen:d,modelMenuPosition:i,modelMenuRef:h,modelTriggerRef:w,modelError:N,loadingImageModels:v,imageModelGroups:g,imageModelMenuOpen:j,imageModelMenuPosition:f,imageModelMenuRef:b,imageModelTriggerRef:y,missingImageModel:C,onAvatarUpload:I,onDescriptionChange:$,onNameChange:S,onRandomAvatar:R,onSelectModel:E,onToggleModelMenu:G,onSelectImageModel:O,onClearImageModel:X,onToggleImageModelMenu:ie,selectedModel:W,selectedImageModel:P,openAbove:J,imageModelOpenAbove:U,uploadingAvatar:D}){return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("h2",{className:"text-[16px] font-semibold text-[var(--text-primary)]",children:"基础信息"}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[12px] text-[var(--text-primary)]",children:"名称"}),e.jsx("input",{type:"text",value:l,onChange:F=>S(F.target.value),maxLength:64,className:"ui-input h-[36px] w-full rounded-[6px] px-4 text-[14px]",placeholder:"请输入智能体名称"}),x?e.jsx("p",{className:"text-[12px] text-[var(--state-error-text)]",children:x}):null]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[12px] text-[var(--text-primary)]",children:"描述(可选)"}),e.jsx(Qt,{value:o,onChange:F=>$(F.target.value),placeholder:"请输入描述",maxLength:1e3,showCount:!0,formatCount:(F,H)=>`${F}/${H??0}`,className:"h-[80px] min-h-[80px] max-h-[160px] w-full overflow-y-auto text-[14px]"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-[12px] text-[var(--text-primary)]",children:"图标"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>{var F;return(F=c.current)==null?void 0:F.click()},className:"group relative flex h-11 w-11 items-center justify-center rounded-full border border-transparent transition",children:[e.jsx("img",{src:Pa(a),alt:"Avatar",className:"h-full w-full rounded-full object-cover"}),e.jsx("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center rounded-full bg-[var(--modal-loading-overlay)] opacity-0 transition group-hover:opacity-100",children:e.jsx(Z,{name:"edit",preserveOriginalColor:!0,className:"h-4 w-4"})})]}),e.jsx("input",{ref:c,type:"file",accept:"image/png,image/jpeg,image/jpg",onChange:I,className:"hidden"}),e.jsx("div",{className:"h-11 pt-[22px]",children:e.jsx("div",{"aria-hidden":"true",className:"h-[16px] w-px bg-[var(--border-default)]"})}),e.jsx("div",{className:"h-11 pt-[16px]",children:e.jsx("button",{type:"button",onClick:R,title:"换一换",className:"h-[28px] w-[28px] min-h-[28px] min-w-[28px] rounded-[6px]",children:e.jsx(za,{})})})]}),t?e.jsx("p",{className:"text-[12px] text-[var(--state-error-text)]",children:t}):null,e.jsx("p",{className:"text-[12px] text-[var(--text-muted)]",children:D?"上传中...":"支持 png、jpeg、jpg 格式,限制 200KB 内"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("label",{className:"text-[12px] text-[var(--text-primary)]",children:"主模型"}),e.jsx(Te,{tooltip:"负责思考、推理、生成文本输出",ariaLabel:"主模型说明"})]}),p.length>0||W?e.jsxs(e.Fragment,{children:[e.jsxs("button",{ref:w,type:"button","aria-label":"Model","aria-haspopup":"listbox","aria-expanded":d,"aria-invalid":!!N,onClick:G,className:"ui-field flex h-[28px] w-full items-center justify-between rounded-[6px] bg-[var(--surface-panel)] px-[10px] text-left text-[12px]",children:[e.jsx(nt,{item:W,loading:u}),e.jsx(lt,{})]}),N?e.jsx("p",{className:"text-[12px] text-[var(--state-error-text)]",children:N}):null,d&&i?Je.createPortal(e.jsx("div",{ref:h,className:"fixed z-[70]",style:{top:i.top,left:i.left,width:i.width,transform:J?"translateY(-100%)":void 0},children:e.jsx(ot,{groups:p,selectedId:(W==null?void 0:W.id)??s,onSelect:F=>E(F.id)})}),document.body):null]}):e.jsx("div",{className:"ui-field flex h-[28px] w-full items-center rounded-[6px] px-4 text-[12px] text-[var(--text-muted)]",children:u?"加载模型中...":"暂无可用模型"})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("label",{className:"text-[12px] text-[var(--text-primary)]",children:"图像理解模型(可选)"}),e.jsx(Te,{tooltip:"用于对图片内容的识别场景,对图片附件进行处理",ariaLabel:"图像理解模型说明"})]}),g.length>0||P?e.jsxs(e.Fragment,{children:[e.jsxs("button",{ref:y,type:"button","aria-label":"Image Model","aria-haspopup":"listbox","aria-expanded":j,onClick:ie,className:"ui-field flex h-[28px] w-full items-center justify-between rounded-[6px] bg-[var(--surface-panel)] px-[10px] text-left text-[12px]",children:[e.jsx(nt,{item:P,loading:v,placeholder:"请选择图像理解模型(可选)"}),e.jsx(lt,{})]}),j&&f?Je.createPortal(e.jsx("div",{ref:b,className:"fixed z-[70]",style:{top:f.top,left:f.left,width:f.width,transform:U?"translateY(-100%)":void 0},children:e.jsx(ot,{groups:g,selectedId:(P==null?void 0:P.id)??n,allowClear:!0,onSelect:F=>O(F.id),onClear:X})}),document.body):null]}):e.jsx("div",{className:"ui-field flex h-[28px] w-full items-center rounded-[6px] px-4 text-[12px] text-[var(--text-muted)]",children:v?"加载模型中...":"暂无可用模型"})]})]})}function Ua({error:t,formMode:a,isConfirmDisabled:s,onCancel:n,onSave:o,saving:l}){return e.jsxs("div",{className:"flex flex-col gap-3 border-t border-[var(--panel-divider)] bg-[var(--surface-panel)] px-8 py-4",children:[t?e.jsx("div",{className:"rounded-[var(--radius-md)] bg-[var(--state-error-bg)] px-4 py-[6px] text-[14px] text-[var(--state-error-text)]",children:t}):null,e.jsxs("div",{className:"flex items-center justify-end gap-3",children:[e.jsx(q,{variant:"default",onClick:n,children:"取消"}),e.jsx(q,{variant:"major",onClick:o,disabled:s,children:l?a==="edit"?"保存中...":"创建中...":a==="edit"?"保存":"创建"})]})]})}function Ha({displayName:t,formMode:a,onBackToDetail:s,onBackToList:n}){const[o,l]=r.useState(!0);return a==="create"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:n,className:"text-[12px] text-[var(--text-secondary)] transition hover:text-[var(--text-primary)]",children:"智能体管理"}),e.jsx("span",{className:"text-[12px] text-[var(--text-muted)]",children:"/"}),e.jsx("span",{className:"text-[12px] font-bold text-[var(--text-primary)]",children:"创建智能体"})]}),e.jsx("h2",{className:"text-[18px] font-bold text-[var(--text-primary)] mt-2",children:"创建智能体"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:n,className:"text-[12px] text-[var(--text-secondary)] transition hover:text-[var(--text-primary)]",children:"智能体管理"}),e.jsx("span",{className:"text-[12px] text-[var(--text-muted)]",children:"/"}),e.jsx("button",{type:"button",onClick:s,className:"text-[12px] text-[var(--text-primary)] transition hover:text-[var(--accent-primary)]",children:t}),e.jsx("span",{className:"text-[12px] text-[var(--text-muted)]",children:"/"}),e.jsx("span",{className:"text-[12px] font-bold text-[var(--text-primary)]",children:"编辑智能体"})]}),e.jsx("h2",{className:"text-[18px] font-bold text-[var(--text-primary)] mt-2",children:"编辑智能体"}),o&&e.jsx("div",{className:"mt-3",children:e.jsx(aa,{mode:"prompt",closable:!0,onClose:()=>l(!1),children:"若智能体正在执行任务中,建议暂时不要编辑以免影响任务执行"})})]})}function Va(){const[t,a]=r.useState(new Map),s=r.useRef(new Map),n=r.useCallback((l,c)=>{a(u=>new Map(u).set(l,c));const x=s.current.get(l);if(x&&clearTimeout(x),typeof c=="string"&&c!=="installing"){const u=setTimeout(()=>{a(p=>{const d=new Map(p);return d.delete(l),d}),s.current.delete(l)},3e3);s.current.set(l,u)}},[]),o=r.useCallback(l=>{a(x=>{const u=new Map(x);return u.delete(l),u});const c=s.current.get(l);c&&(clearTimeout(c),s.current.delete(l))},[]);return{installStatus:t,setInstallStatusWithTimer:n,clearInstallStatus:o}}const Ka=24,jt={"ai-intelligence":"AI 智能","developer-tools":"开发工具",productivity:"效率提升","content-creation":"内容创作","data-analysis":"数据分析","security-compliance":"安全合规","communication-collaboration":"沟通协作"};function gt(t){return jt[t]??t}function Qa(t){var a;return!t||t==="全部"?null:((a=Object.entries(jt).find(([,s])=>s===t))==null?void 0:a[0])??t}function Ya(){const[t,a]=r.useState(null),[s,n]=r.useState(!1),[o,l]=r.useState(!1),[c,x]=r.useState(1),[u,p]=r.useState([]),[d,i]=r.useState("全部"),h=r.useRef(0),w=r.useRef(null),N=r.useCallback((f,b)=>{const y=new URLSearchParams({page:String(f),limit:String(Ka)}),C=Qa(b);return C&&y.set("category",C),`/api/skills/all?${y.toString()}`},[]),v=r.useCallback(async({page:f,append:b=!1,category:y="全部"})=>{var S;const C=++h.current;(S=w.current)==null||S.abort();const I=new AbortController;w.current=I;const $=b?l:n;$(!0);try{const R=await B(N(f,y??"全部"),{signal:I.signal});if(!R.ok)return;const E=await R.json();if(C!==h.current)return;a(G=>!b||!G?E:{...E,skills:[...G.skills,...E.skills]}),x(f)}catch(R){if(R instanceof DOMException&&R.name==="AbortError")return}finally{C===h.current&&$(!1)}},[N]),g=r.useCallback(async()=>{try{const f=await B("/api/skills/categories");if(f.ok){const b=await f.json(),y=[...new Set(b.categories)].sort((C,I)=>C.localeCompare(I,"zh-CN"));p(y.map(gt))}}catch{}},[]),j=r.useCallback(()=>{o||!(t!=null&&t.hasMore)||v({page:c+1,append:!0,category:d})},[o,t==null?void 0:t.hasMore,c,v,d]);return{searchResults:t,setSearchResults:a,searchLoading:s,loadingMore:o,currentPage:c,categories:u,activeCategory:d,loadPage:v,loadCategories:g,handleLoadMore:j,setActiveCategory:i}}function Za({onInstallSuccess:t,onInstallError:a}={}){return{handleInstall:r.useCallback(async(n,o,l,c,x)=>{try{const u=await B("/api/skills/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({owner:n,repo:o,skill:l,description:c,version:x})});if(u.ok)sa(),Ce.getState().addToast({type:"success",title:"安装成功",message:`"${l}" 安装成功,可在我的技能中查看`,duration:4e3}),t==null||t(l);else{const d=(await u.json().catch(()=>({}))).error??`HTTP ${u.status}`;Ce.getState().addToast({type:"error",title:"安装失败",message:d,duration:4e3}),a==null||a(l,d)}}catch{Ce.getState().addToast({type:"error",title:"安装失败",message:"网络错误,请重试",duration:4e3}),a==null||a(l,"网络错误,请重试")}},[t,a])}}const Xa="_backdrop_1qwya_8",Ja="_drawer_1qwya_19",es="_header_1qwya_34",ts="_title_1qwya_43",as="_closeButton_1qwya_50",ss="_body_1qwya_71",rs="_searchWrapper_1qwya_80",ns="_content_1qwya_87",ls="_emptyState_1qwya_95",os="_footer_1qwya_105",is="_tabsWrapper_1qwya_122",cs="_tabs_1qwya_122",ds="_tab_1qwya_122",us="_tabActive_1qwya_148",xs="_categoriesWrapper_1qwya_165",ms="_categories_1qwya_165",ps="_categoryItem_1qwya_177",fs="_categoryDivider_1qwya_182",hs="_categoryTab_1qwya_189",vs="_categoryTabActive_1qwya_207",bs="_skillGrid_1qwya_213",js="_card_1qwya_222",gs="_cardSelected_1qwya_239",ws="_cardHeader_1qwya_249",ys="_cardContent_1qwya_255",Ns="_badge_1qwya_260",Ss="_cardTitle_1qwya_272",ks="_cardDescription_1qwya_280",_s="_checkbox_1qwya_294",Cs="_checkboxChecked_1qwya_307",Es="_cardFooter_1qwya_314",Ms="_installButton_1qwya_319",Ls="_loadMore_1qwya_340",k={backdrop:Xa,drawer:Ja,header:es,title:ts,closeButton:as,body:ss,searchWrapper:rs,content:ns,emptyState:ls,footer:os,tabsWrapper:is,tabs:cs,tab:ds,tabActive:us,categoriesWrapper:xs,categories:ms,categoryItem:ps,categoryDivider:fs,categoryTab:hs,categoryTabActive:vs,skillGrid:bs,card:js,cardSelected:gs,cardHeader:ws,cardContent:ys,badge:Ns,cardTitle:Ss,cardDescription:ks,checkbox:_s,checkboxChecked:Cs,cardFooter:Es,installButton:Ms,loadMore:Ls},Ts="我的技能",Is="技能广场",ee="全部",it="其他",Me="all",Rs=[{id:Me,label:"全部"},{id:"external",label:"我添加的"},{id:"builtin",label:"平台精选"}],As="筛选分类";function $s(t,a){const s=a.toLowerCase();return t.id.toLowerCase().includes(s)||t.name.toLowerCase().includes(s)||t.description.toLowerCase().includes(s)}function Fs(t,a){a(s=>{if(!s)return s;let n=!1;const o=s.skills.map(l=>l.slug!==t||l.isInstalled?l:(n=!0,{...l,isInstalled:!0}));return n?{...s,skills:o}:s})}function Os({open:t,selectedSkills:a,skillBasicInfos:s,onConfirm:n,onClose:o}){const[l,c]=r.useState("installed"),[x,u]=r.useState(""),[p,d]=r.useState([]),[i,h]=r.useState([]),[w,N]=r.useState(new Map),[v,g]=r.useState(!1),[j,f]=r.useState(Me),[b,y]=r.useState(!1),[C,I]=r.useState(!1),$=r.useRef(null),S=r.useRef(!1),R=r.useRef(null),{setInstallStatusWithTimer:E,clearInstallStatus:G}=Va(),{searchResults:O,setSearchResults:X,searchLoading:ie,loadingMore:W,loadPage:P,loadCategories:J,handleLoadMore:U,activeCategory:D,setActiveCategory:F,categories:H}=Ya(),{handleInstall:he}=Za();r.useEffect(()=>{t&&(d(a),u(""),g(!0),B("/api/skills").then(m=>m.ok?m.json():null).then(m=>{if(m!=null&&m.skills){const M=m.skills.map(_=>({id:_.name,name:_.name,description:typeof _.description=="string"?_.description:"",category:_.category,trigger:_.trigger,source:_.source==="skillhub"?"external":"builtin"}));h(M);const T=new Map;m.skills.forEach(_=>{T.set(_.name,{name:_.name,description:_.description})}),N(T),at(Array.from(T.values()))}}).finally(()=>g(!1)))},[t,a]),r.useEffect(()=>{l==="plaza"&&(J(),P({page:1,category:ee}))},[l,J,P]),r.useEffect(()=>{if(!S.current){S.current=!0;return}if(l!=="plaza"||!x.trim())return;const m=setTimeout(()=>{F(ee),P({page:1,category:ee})},300);return()=>clearTimeout(m)},[x,l,P,F]);const te=r.useCallback(m=>{u(""),F(m),P({page:1,category:m})},[P,F]),ve=r.useCallback(()=>{I(!1),B("/api/skills").then(m=>m.ok?m.json():null).then(m=>{if(m!=null&&m.skills){const M=m.skills.map(_=>({id:_.name,name:_.name,description:typeof _.description=="string"?_.description:"",category:_.category,trigger:_.trigger,source:_.source==="skillhub"?"external":"builtin"}));h(M);const T=new Map;m.skills.forEach(_=>{T.set(_.name,{name:_.name,description:_.description})}),N(T),at(Array.from(T.values()))}})},[]);r.useEffect(()=>{const m=R.current;if(!m||!(O!=null&&O.hasMore)||W)return;const M=new IntersectionObserver(T=>{T[0].isIntersecting&&U()},{rootMargin:"200px"});return M.observe(m),()=>M.disconnect()},[O==null?void 0:O.hasMore,W,U]),r.useEffect(()=>{if(!t)return;const m=M=>{M.key==="Escape"&&o()};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[o,t]),r.useEffect(()=>{if(!b)return;const m=M=>{var _;const T=M.target;T&&((_=$.current)!=null&&_.contains(T)||y(!1))};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[b]);const be=r.useMemo(()=>{if(l==="plaza")return[];let m=i;j!==Me&&(m=m.filter(T=>T.source===j)),D!==ee&&(m=m.filter(T=>{var _;return(((_=T.category)==null?void 0:_.trim())||it)===D}));const M=x.trim().toLowerCase();return M?m.filter(T=>$s(T,M)):m},[l,x,i,j,D]),ae=r.useMemo(()=>{var M;const m=new Set;for(const T of i)j!==Me&&T.source!==j||m.add(((M=T.category)==null?void 0:M.trim())||it);return Array.from(m).sort()},[i,j]),je=r.useMemo(()=>l!=="plaza"?[]:(O==null?void 0:O.skills)??[],[l,O]),ge=r.useCallback(m=>{d(M=>M.includes(m)?M.filter(T=>T!==m):[...M,m])},[]),we=r.useCallback(()=>{const m=new Map([...s??new Map,...w]);n(p,m)},[p,s,w,n]),ye=r.useCallback(async(m,M,T,_,V)=>{E(T,"installing"),await he(m,M,T,_,V),G(T),Fs(T,X)},[he,E,G]);if(!t)return null;const se=l==="installed"?be:je,Ne=l==="installed"?v:ie,Ae=se.length>0;return e.jsxs("div",{className:k.backdrop,"data-testid":"skill-selector-drawer",children:[e.jsxs("div",{className:k.drawer,children:[e.jsxs("div",{className:k.header,children:[e.jsx("h2",{className:k.title,children:"选择技能"}),e.jsx("button",{type:"button",onClick:o,className:k.closeButton,"aria-label":"关闭技能选择",children:e.jsxs("svg",{className:"h-[18px] w-[18px]",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M6 6L18 18",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),e.jsx("path",{d:"M18 6L6 18",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]})})]}),e.jsxs("div",{className:k.body,children:[e.jsx("div",{className:k.tabsWrapper,children:e.jsxs("div",{className:k.tabs,children:[e.jsx("button",{type:"button",onClick:()=>c("installed"),className:`${k.tab} ${l==="installed"?k.tabActive:""}`,children:Ts}),e.jsx("button",{type:"button",onClick:()=>c("plaza"),className:`${k.tab} ${l==="plaza"?k.tabActive:""}`,children:Is})]})}),l==="installed"&&e.jsx("div",{className:k.categoriesWrapper,children:e.jsx("div",{className:k.categories,children:Rs.map((m,M)=>e.jsxs("div",{className:k.categoryItem,children:[M>0?e.jsx("div",{"aria-hidden":"true",className:k.categoryDivider}):null,e.jsx("button",{type:"button",onClick:()=>f(m.id),className:`${k.categoryTab} ${j===m.id?k.categoryTabActive:""}`,children:m.label})]},m.id))})}),l==="plaza"&&H.length>0&&e.jsx("div",{className:k.categoriesWrapper,children:e.jsx("div",{className:k.categories,children:[ee,...H].map((m,M)=>e.jsxs("div",{className:k.categoryItem,children:[M>0?e.jsx("div",{"aria-hidden":"true",className:k.categoryDivider}):null,e.jsx("button",{type:"button",onClick:()=>te(m),className:`${k.categoryTab} ${D===m?k.categoryTabActive:""}`,children:m})]},m))})}),l==="installed"&&e.jsx("div",{className:k.categoriesWrapper,children:e.jsx(q,{variant:"default",onClick:()=>I(!0),children:"导入技能"})}),e.jsxs("div",{className:k.searchWrapper,children:[l==="installed"&&ae.length>0&&e.jsxs("div",{ref:$,className:"relative w-[200px] shrink-0",children:[e.jsx("select",{"aria-label":As,value:D,onChange:m=>te(m.target.value),className:"sr-only",tabIndex:-1,children:[ee,...ae].map(m=>e.jsx("option",{value:m,children:m},m))}),e.jsxs("button",{type:"button",onClick:()=>y(m=>!m),className:`ui-field flex h-[28px] w-[200px] items-center justify-between rounded-[6px] px-[12px] py-[5px] text-xs transition-colors ${b?"border-[#191919]":""}`,"aria-haspopup":"listbox","aria-expanded":b,children:[e.jsx("span",{className:"truncate text-[var(--text-primary)]",children:D}),e.jsx("svg",{className:`h-3.5 w-3.5 text-[var(--text-muted)] transition-transform duration-200 ${b?"rotate-180":""}`,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:e.jsx("path",{d:"M4 6L8 10L12 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),b&&e.jsx("div",{role:"listbox",className:"absolute left-0 top-[calc(100%+4px)] z-30 w-[200px] rounded-[6px] bg-[var(--surface-panel)] py-[8px] shadow-[0_2px_12px_0_var(--tooltip-shadow-color)]",children:[ee,...ae].map(m=>{const M=m===D;return e.jsx("button",{type:"button",role:"option","aria-selected":M,onClick:()=>{te(m),y(!1)},className:`flex h-[32px] w-full items-center px-[16px] py-[7px] text-left text-xs transition-colors hover:bg-[var(--tag-bg)] ${M?"text-[var(--text-accent)]":"text-[var(--text-primary)]"}`,children:m},m)})})]}),e.jsx(fe,{wrapperClassName:"w-full",value:x,onChange:m=>u(m),placeholder:l==="installed"?"输入关键字搜索技能":"搜索技能广场","aria-label":"搜索技能","data-testid":"skill-search-input"})]}),e.jsx("div",{className:k.content,children:Ne?e.jsx("div",{className:k.emptyState,children:"加载中..."}):Ae?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:k.skillGrid,children:se.map(m=>{const M=l==="installed"?m.id:m.slug,T=m.name,_=m.description,V=l==="installed"?m.category:gt(m.category??""),re=p.includes(M),ce=l==="plaza"?m.isInstalled:!1;return e.jsxs("article",{className:`${k.card} ${re?k.cardSelected:""}`,onClick:()=>{l==="plaza"&&!ce||ge(M)},children:[e.jsxs("div",{className:k.cardHeader,children:[e.jsx(ze,{name:T||M}),e.jsxs("div",{className:k.cardContent,children:[e.jsx(oe,{content:T,className:"min-w-0",as:"h3",textClassName:`${k.cardTitle} block truncate`}),e.jsx("div",{className:"mt-1 flex flex-wrap items-center gap-2 leading-[18px] text-xs",children:V&&e.jsx("span",{className:k.badge,children:V})})]}),l==="plaza"&&!ce?null:e.jsx("div",{className:`${k.checkbox} ${re?k.checkboxChecked:""}`,children:re?e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})}):e.jsx("svg",{className:"h-4 w-4",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true",children:e.jsx("rect",{x:"3",y:"3",width:"14",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"})})})]}),e.jsx(oe,{content:_||"暂未提供技能描述。",className:"w-full",children:e.jsx("p",{className:k.cardDescription,children:_||"暂未提供技能描述。"})}),l==="plaza"&&e.jsx("div",{className:k.cardFooter,children:ce?e.jsx("span",{className:"shrink-0 text-xs",style:{color:"var(--text-disabled)"},children:"已安装"}):m.repo.githubOwner&&m.repo.githubRepoName?e.jsx("button",{type:"button",className:k.installButton,onClick:de=>{de.stopPropagation(),ye(m.repo.githubOwner,m.repo.githubRepoName,m.slug,m.description,m.version??"")},children:"安装"}):null})]},M)})}),l==="plaza"&&(O==null?void 0:O.hasMore)&&e.jsx("div",{ref:R,className:k.loadMore,children:W&&e.jsx("span",{className:"text-sm text-[var(--text-muted)]",children:"加载中..."})})]}):e.jsx("div",{className:k.emptyState,children:"没有匹配到技能"})})]}),e.jsxs("div",{className:k.footer,children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--text-primary)",lineHeight:"18px"},children:["已选:",p.length]}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(q,{onClick:o,variant:"default",children:"取消"}),e.jsx(q,{onClick:we,color:"major",children:"确认"})]})]})]}),e.jsx(ra,{open:C,onClose:()=>I(!1),onSuccess:ve})]})}const Ps="_skillGrid_qcha4_7",Bs="_skillCard_qcha4_13",Ds="_deleteButton_qcha4_31",qs="_cardIcon_qcha4_35",Ws="_cardContent_qcha4_40",zs="_cardName_qcha4_48",Gs="_cardDescription_qcha4_57",Us="_emptyState_qcha4_104",Y={skillGrid:Ps,skillCard:Bs,deleteButton:Ds,cardIcon:qs,cardContent:Ws,cardName:zs,cardDescription:Gs,emptyState:Us};function Hs({editingAgent:t,skills:a,skillBasicInfos:s,onSkillsChange:n}){const[o,l]=r.useState(!1),c=(t==null?void 0:t.source)==="seed",x=r.useCallback(p=>{const d=a.filter(h=>h!==p),i=new Map(s);i.delete(p),n(d,i)},[a,s,n]),u=r.useCallback((p,d)=>{n(p,d),l(!1)},[n]);return e.jsxs("div",{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 pb-4",children:[e.jsx("h2",{className:"text-[16px] font-semibold text-[var(--text-primary)]",children:"技能配置"}),!c&&e.jsxs("button",{type:"button",onClick:()=>l(!0),className:"inline-flex h-[18px] shrink-0 items-center gap-1 text-[12px] text-[var(--text-primary)] transition hover:underline hover:underline-offset-2",children:[e.jsx(Z,{name:"add",className:"h-3.5 w-3.5"}),e.jsx("span",{children:"添加技能"})]})]}),a.length>0?e.jsx("div",{className:Y.skillGrid,children:a.map(p=>{var d,i;return e.jsxs("div",{className:Y.skillCard,children:[e.jsx(ze,{name:p,className:Y.cardIcon}),e.jsxs("div",{className:Y.cardContent,children:[e.jsx("span",{className:Y.cardName,children:p}),((d=s==null?void 0:s.get(p))==null?void 0:d.description)&&e.jsx("span",{className:Y.cardDescription,children:(i=s.get(p))==null?void 0:i.description})]}),!c&&e.jsx("button",{type:"button",onClick:()=>x(p),className:Y.deleteButton,"aria-label":`删除技能 ${p}`,children:e.jsx(Z,{name:"delete",className:"h-4 w-4"})})]},p)})}):e.jsx("div",{className:Y.emptyState,children:"暂未配置技能"}),e.jsx(Os,{open:o,selectedSkills:a,skillBasicInfos:s,onConfirm:u,onClose:()=>l(!1)})]})}const Vs=900,Ks=150,Qs=16,wt=8,Ys=Qs-wt,Zs=240,Xs=Zs+wt,Js=596;function er(){return e.jsx(Z,{name:"refresh",className:"h-[18px] w-[18px]"})}function tr(){return e.jsxs("svg",{className:"h-[18px] w-[18px]",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:[e.jsx("path",{d:"M6 6L18 18",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"}),e.jsx("path",{d:"M18 6L6 18",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round"})]})}function ar(t){return t.trim().toLowerCase()}function sr({item:t}){return e.jsx("div",{className:"h-full overflow-y-auto",children:e.jsx(Ie,{content:t.content,className:"text-[12px] leading-7 text-[var(--modal-text)] [&_h1]:mb-3 [&_h1]:text-[16px] [&_h1]:font-semibold [&_h2]:mb-3 [&_h2]:text-[16px] [&_h2]:font-semibold [&_h3]:mb-2 [&_h3]:text-[16px] [&_h3]:font-semibold [&_ul]:mb-3 [&_li]:text-[var(--modal-text)] [&_p]:text-[var(--modal-text)]",disableCommandPrefix:!0})})}function rr(t){const a=t.description.trim();return a||t.content.replace(/^#{1,6}\s+/gm,"").replace(/[*_`>#-]/g,"").replace(/\s+/g," ").trim()}function nr(t){return[t.id,t.title,t.description,t.content]}function lr(t,a){const s=a.toLowerCase();return nr(t).some(n=>n.toLowerCase().includes(s))}function or({open:t,items:a,initialSelectedId:s=null,title:n="灵魂模板",searchPlaceholder:o="输入关键字搜索",cancelLabel:l="取消",confirmLabel:c="插入",onClose:x,onConfirm:u}){const[p,d]=r.useState(""),[i,h]=r.useState(s);r.useEffect(()=>{var g;t&&(d(""),h(s??((g=a[0])==null?void 0:g.id)??null))},[s,a,t]),r.useEffect(()=>{if(!t)return;const g=j=>{j.key==="Escape"&&x()};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[x,t]);const w=r.useMemo(()=>{const g=ar(p);return g?a.filter(j=>lr(j,g)):a},[a,p]),N=w.length===0,v=r.useMemo(()=>N?null:w.find(g=>g.id===i)??w[0],[w,N,i]);return r.useEffect(()=>{if(t){if(!v){h(null);return}v.id!==i&&h(v.id)}},[t,i,v]),t?e.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-[var(--overlay-backdrop-strong)] px-6 pb-[50px] pt-[100px]","data-testid":"prompt-selection-modal",children:e.jsxs("div",{className:"flex w-full max-w-[900px] flex-col overflow-y-auto rounded-[8px] border border-[var(--modal-border)] bg-[var(--modal-surface)] p-6 shadow-[var(--modal-shadow)]",style:{width:Vs,maxHeight:`calc(100vh - ${Ks}px)`},children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-[18px] font-semibold leading-none text-[var(--modal-title-text)]",children:n}),e.jsx("button",{type:"button",onClick:x,className:"rounded-md p-1 text-[var(--text-label-secondary)] transition-colors hover:text-[var(--text-primary)]","aria-label":"关闭提示词选择",children:e.jsx(tr,{})})]}),e.jsxs("div",{className:"mt-4 flex min-h-0 flex-col",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fe,{wrapperClassName:"min-w-0 flex-1",value:p,onChange:g=>d(g),placeholder:o,"aria-label":o,"data-testid":"prompt-search-input"}),e.jsx("button",{type:"button",onClick:()=>d(""),className:"flex h-8 w-8 items-center justify-center rounded-[6px] border border-[var(--modal-muted-border)] bg-[var(--modal-surface)] transition hover:bg-[var(--modal-muted-surface-hover)]","aria-label":"清空搜索",children:e.jsx(er,{})})]}),e.jsx("div",{className:"mt-4 flex min-h-0",style:{gap:Ys},children:N?e.jsx("section",{"data-testid":"prompt-empty-state",className:"flex min-h-[420px] flex-1 items-center justify-center rounded-[10px] border border-[var(--modal-muted-border)] bg-[var(--modal-surface)] px-8 py-10",children:e.jsx(We,{onClear:()=>d(""),title:"暂未匹配到数据",description:"没有匹配到符合条件的数据",clearLabel:"清除筛选器"})}):e.jsxs(e.Fragment,{children:[e.jsx("aside",{className:"flex shrink-0 flex-col gap-2 overflow-x-hidden overflow-y-auto bg-[var(--modal-surface)] pr-2",style:{width:Xs},children:w.map(g=>{const j=g.id===(v==null?void 0:v.id);return e.jsx("button",{type:"button",onClick:()=>h(g.id),className:`block h-[68px] min-h-[68px] shrink-0 overflow-hidden rounded-[8px] p-3 text-left transition ${j?"border border-[var(--modal-selected-border)] bg-[var(--modal-surface)] shadow-[var(--modal-selected-shadow)]":"border border-[var(--modal-muted-border)] bg-[var(--modal-muted-surface)] hover:bg-[var(--modal-surface)]"}`,"data-testid":`prompt-list-item-${g.id}`,children:e.jsxs("div",{className:"flex h-full min-w-0 w-full flex-col justify-center overflow-hidden",children:[e.jsx("div",{className:"h-[22px] w-full truncate text-[14px] font-semibold leading-[22px] text-[var(--modal-text)]",children:g.title}),e.jsx("div",{className:"mt-1 h-[18px] w-full truncate overflow-hidden text-[12px] leading-[18px] text-[var(--modal-text-muted)]",children:rr(g)})]})},g.id)})}),e.jsx("section",{"data-testid":"prompt-detail-panel",className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-[10px] border border-[var(--modal-muted-border)] bg-[var(--modal-surface)] p-4",style:{width:Js},children:v?e.jsx(sr,{item:v}):e.jsx("div",{className:"flex h-full items-center justify-center text-[13px] text-[var(--modal-empty-text)]",children:"请选择左侧提示词"})})]})}),e.jsxs("div",{className:"mt-3 flex justify-end gap-3",children:[e.jsx(q,{onClick:x,color:"default",children:l}),e.jsx(q,{onClick:()=>v&&u(v),color:"major",disabled:!v,"data-testid":"prompt-confirm-button",children:c})]})]})]})}):null}const ct=pe.map(t=>({id:t.id,title:t.title,description:t.description,content:Re(t)}));function ir({activeWorkingDraft:t,editingAgent:a,onDraftChange:s}){const[n,o]=r.useState(!1),l=r.useMemo(()=>{var u;return((u=ct[0])==null?void 0:u.id)??null},[]),c=(a==null?void 0:a.source)==="seed",x=r.useCallback(u=>{const p=pe.find(h=>h.id===u);if(!p)return;const d=Re(p),i=t.trim();s(i?`${i}
|
|
66
|
+
|
|
67
|
+
${d}`:d),o(!1)},[t,s]);return e.jsxs("div",{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4 pb-4",children:[e.jsx("h2",{className:"text-[16px] font-semibold text-[var(--text-primary)]",children:"灵魂配置"}),c?null:e.jsxs("button",{type:"button",onClick:()=>o(!0),className:"inline-flex h-[18px] shrink-0 items-center gap-1 text-[12px] text-[var(--text-primary)] transition hover:underline hover:underline-offset-2","data-testid":"soul-template-trigger",children:[e.jsx(Z,{name:"template",className:"h-3.5 w-3.5"}),e.jsx("span",{children:"模板"})]})]}),c?e.jsx(vt,{personality:a==null?void 0:a.personality,agentId:(a==null?void 0:a.id)??null,readOnly:!0}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"h-[480px] rounded-lg border border-[var(--border-default)]",children:e.jsx(ht,{activeWorkingDraft:t,onDraftChange:s})}),e.jsx(or,{open:n,items:ct,title:"灵魂模板",searchPlaceholder:"输入关键字搜索",cancelLabel:"取消",confirmLabel:"插入",initialSelectedId:l,onClose:()=>o(!1),onConfirm:u=>x(u.id)})]})]})}function cr({activeStep:t,onStepClick:a}){return e.jsx("nav",{className:"flex flex-col items-start gap-0 px-2","aria-label":"表单步骤",children:Pe.map(s=>e.jsxs("button",{type:"button",onClick:()=>a(s.id),className:`group flex w-full items-start text-left text-[12px] font-medium transition-colors ${t===s.id?"text-[var(--text-primary)]":"text-[var(--text-tertiary)]"}`,children:[e.jsxs("span",{className:"flex w-5 shrink-0 flex-col items-center",children:[e.jsx("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-transparent",children:e.jsx(Z,{src:t===s.id?"/images/agent-management-icons/anchor-current.svg":"/images/agent-management-icons/anchor-other.svg",className:"mt-[7px] h-2 w-2"})}),s.id!==Pe[Pe.length-1].id?e.jsx("span",{className:"mt-1 h-5 w-px bg-[var(--border-default)]","aria-hidden":"true"}):null]}),e.jsx("span",{className:"ml-3 pt-[1px] leading-5",children:s.label})]},s.id))})}const dr=800;function ur({scrollContainerRef:t,stepRefs:a,isManualOperating:s,setIsManualOperating:n}){const o=r.useRef(null),l=r.useCallback(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),c=r.useCallback(()=>{const d=t.current,i=a.soul.current;if(!d||!i)return;const h=d.getBoundingClientRect();i.getBoundingClientRect().top-h.top},[t,a.soul]),x=r.useCallback(d=>{const i=t.current,h=a[d];if(!i||!h.current)return;const w=i.getBoundingClientRect(),v=h.current.getBoundingClientRect().top-w.top+i.scrollTop,g=Math.max(0,v-24);i.scrollTo({top:g,behavior:"smooth"})},[t,a]),u=r.useCallback(()=>{const d=t.current;d&&d.scrollTo({top:0,behavior:"smooth"})},[t]),p=r.useCallback(d=>{l(),n(!0),d==="basic"?u():x(d),o.current=window.setTimeout(()=>{o.current=null,n(!1)},dr)},[l,n,u,x]);return r.useEffect(()=>{const d=t.current;if(!d)return;const i=()=>{s||c()};return d.addEventListener("scroll",i,{passive:!0}),()=>d.removeEventListener("scroll",i)},[t,s,c]),r.useEffect(()=>()=>{l()},[l]),{handleStepClick:p}}function dt({modelGroupCount:t,modelItemCount:a,modelMenuOpen:s,modelMenuRef:n,modelTriggerRef:o,onClose:l}){const[c,x]=r.useState(!1),[u,p]=r.useState(null),d=r.useCallback(()=>{var v;if(!s||!o.current)return;const i=o.current.getBoundingClientRect(),h=((v=n.current)==null?void 0:v.offsetHeight)??Math.min(Math.max(a,1)*36+t*22+54,fa),N=window.innerHeight-i.bottom<h+Be;x(N),p({top:N?i.top-Be:i.bottom+Be,left:i.left,width:i.width})},[t,a,s,n,o]);return r.useEffect(()=>{if(!s)return;const i=w=>{var v,g;const N=w.target;(v=n.current)!=null&&v.contains(N)||(g=o.current)!=null&&g.contains(N)||l()},h=w=>{var N;w.key==="Escape"&&(l(),(N=o.current)==null||N.focus())};return document.addEventListener("mousedown",i),document.addEventListener("keydown",h),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",h)}},[s,n,o,l]),r.useLayoutEffect(()=>{if(!s){p(null),x(!1);return}d()},[s,d]),r.useEffect(()=>{if(!s)return;const i=()=>d();return window.addEventListener("resize",i),window.addEventListener("scroll",i,!0),()=>{window.removeEventListener("resize",i),window.removeEventListener("scroll",i,!0)}},[s,d]),{modelMenuPosition:u,openAbove:c}}function me(t){const a=(t==null?void 0:t.trim())??"";if(!a)return"";if(!a.startsWith("model_config:"))return a;const s=a.split(":");return s.length>=3?s.slice(2).join(":").trim():a}function ut(t,a){for(const s of a){const n=t[s];if(typeof n=="string"&&n.trim().length>0)return n.trim()}}function xr(t){if(typeof t.accountRef=="string"&&t.accountRef.trim().length>0)return t.accountRef.trim();if(t.provider===ha)return"huawei-maas";const a=typeof t.id=="string"?t.id.trim():"";if(!a||!a.startsWith("model_config:"))return null;const s=a.slice(13),n=s.indexOf(":");return n>=0?s.slice(0,n):null}function mr(t,a,s){if(!t.startsWith("model_config:"))return s;const n=`model_config:${a}:`;return t.startsWith(n)&&t.slice(n.length)||s}function pr(t,a){if(t.enabled===!1)return null;const s=t,n=Yt(t,a),o=n.name,l=xr(t);if(!o||!l)return null;const c=ut(s,["provider"])??n.developer,x=typeof t.id=="string"&&t.id.trim().length>0?t.id.trim():`${l}::${o}`,u=mr(x,l,o);return{id:x,name:o,icon:ut(s,["icon","logo","image","avatar"]),providerGroup:c,accountRef:l,client:ft,model:u,modelLabel:o,groupId:Xt(n),groupLabel:Zt(n)}}function fr(t,a){if(!a)return null;const s=t??"huawei-maas",n=s==="huawei-maas",o=n?Jt:"custom_models";return{id:`${s}::${a}`,name:a,accountRef:s,client:ft,model:a,modelLabel:a,groupId:o,groupLabel:n?ea:ta}}function xt({editingDefaultModel:t,editingAccountRef:a,defaultToFirstModel:s=!1}={}){const[n,o]=r.useState([]),[l,c]=r.useState(!1),[x,u]=r.useState(null);r.useEffect(()=>{let j=!1;return c(!0),(async()=>{try{const f=await B("/api/maas-models");if(!f.ok)throw new Error(`模型广场加载失败 (${f.status})`);const b=await f.json(),y=Array.isArray(b.list)?b.list:Array.isArray(b.models)?b.models:[];j||o(y)}catch{j||o([])}finally{j||c(!1)}})(),()=>{j=!0}},[]);const p=me(t??null),d=r.useMemo(()=>{const j=n.map((b,y)=>pr(b,y)).filter(b=>b!==null),f=new Map;for(const b of j)f.set(b.id,b);return Array.from(f.values())},[n]),i=r.useMemo(()=>d.reduce((j,f)=>{const b=j.find(y=>y.id===f.groupId);return b?(b.items.push(f),j):(j.push({id:f.groupId,label:f.groupLabel,items:[f]}),j)},[]),[d]),h=r.useMemo(()=>({model:p||null,accountRef:a??null}),[p,a]),w=r.useMemo(()=>{if(x==="")return null;if(x){const j=d.find(f=>f.id===x);if(j)return j}if(h.accountRef&&h.model){const j=d.find(f=>f.accountRef===h.accountRef&&f.model===h.model);if(j)return j}if(h.model){const j=d.find(f=>f.model===h.model);if(j)return j}return s&&d.length>0?d[0]:fr(h.accountRef,h.model)},[d,x,h,s]),N=r.useMemo(()=>h.model?!d.some(j=>j.model===h.model&&j.accountRef===h.accountRef):!1,[d,h]);r.useEffect(()=>{w&&x!==w.id&&u(w.id)},[w,x]);const v=r.useCallback(j=>{u(j)},[]),g=r.useCallback(()=>w?{accountRef:w.accountRef,model:w.model}:null,[w]);return{models:d,modelGroups:i,loading:l,selectedModel:w,selectedModelId:x,missingModel:N,onSelectModel:v,resolveForSave:g}}const hr=200*1024;function vr({onSuccess:t,maxSizeBytes:a=hr}={}){const[s,n]=r.useState(!1),[o,l]=r.useState(null),c=r.useCallback(async x=>{var p;const u=(p=x.target.files)==null?void 0:p[0];if(u){if(u.size>a){l("图片大小不能超过 200KB");return}n(!0),l(null);try{const d=await na(u);t==null||t(d)}catch(d){l(d instanceof Error?d.message:"上传失败")}finally{n(!1)}}},[a,t]);return{uploading:s,error:o,handleUpload:c}}function br(t){return t.trim().toLowerCase().replace(/[\s_]+/g,"-").replace(/[^a-z0-9\u4e00-\u9fff-]/g,"").slice(0,40)}function jr(t){return!t||t!==t.trim()||t.length<2||t.length>64||!/^[\u4e00-\u9fffA-Za-z0-9 _-]+$/.test(t)?_e:null}function gr(){const t=Date.now().toString(36),a=Math.random().toString(36).slice(2,8);return`agent-${t}${a}`.slice(0,64)}const wr="通用智能体助手";function yr({editingAgent:t,formMode:a,prefillData:s,onCancel:n,onSaveSuccess:o,onBackToDetail:l,onBackToList:c}){const[x,u]=r.useState((t==null?void 0:t.displayName)??(s==null?void 0:s.displayName)??"BOT"),[p,d]=r.useState((t==null?void 0:t.roleDescription)??(s==null?void 0:s.roleDescription)??""),[i,h]=r.useState(t?Fa(t):(s==null?void 0:s.avatar)??va),[w,N]=r.useState(me((t==null?void 0:t.defaultModel)??(s==null?void 0:s.defaultModel))),[v,g]=r.useState(me((t==null?void 0:t.imageModel)??(s==null?void 0:s.imageModel))),[j,f]=r.useState((t==null?void 0:t.personality)??(s==null?void 0:s.personality)??""),[b,y]=r.useState(!1),[C,I]=r.useState(!1),[$,S]=r.useState(null),[R,E]=r.useState(null),[G,O]=r.useState(null),[X,ie]=r.useState((t==null?void 0:t.skills)??(s==null?void 0:s.skills)??[]),[W,P]=r.useState(new Map),[J,U]=r.useState(!1),[D,F]=r.useState(!1),[H]=r.useState(()=>(t==null?void 0:t.id)??gr()),he=r.useRef(null),te=r.useRef(null),ve=r.useRef(null),be=r.useRef(null),ae=r.useRef(null),je=r.useRef(null),ge=r.useRef(null),we=r.useRef(null),ye=r.useRef(null),se=r.useMemo(()=>jr(x),[x]),Ne=se??R,Ae=!!Ne||C,m=i||$a(x||"智"),M={basic:ge,soul:we,skills:ye},{handleStepClick:T}=ur({scrollContainerRef:je,stepRefs:M,isManualOperating:b,setIsManualOperating:y}),_=(t==null?void 0:t.accountRef)??(t==null?void 0:t.providerProfileId)??null,V=(t==null?void 0:t.imageAccountRef)??null,{models:re,loading:ce,modelGroups:de,selectedModel:K,missingModel:yt,onSelectModel:Ue,resolveForSave:He}=xt({editingDefaultModel:t==null?void 0:t.defaultModel,editingAccountRef:_,defaultToFirstModel:a==="create"}),{models:Ve,loading:Nt,modelGroups:Ke,selectedModel:ue,missingModel:St,onSelectModel:Se,resolveForSave:Qe}=xt({editingDefaultModel:t==null?void 0:t.imageModel,editingAccountRef:V,defaultToFirstModel:!1}),$e=r.useMemo(()=>Ke.map(L=>({...L,items:L.items.filter(A=>A.model.toLowerCase().includes("-vl-"))})).filter(L=>L.items.length>0),[Ke]),{modelMenuPosition:kt,openAbove:_t}=dt({modelGroupCount:de.length,modelItemCount:de.reduce((L,A)=>L+A.items.length,0),modelMenuOpen:J,modelMenuRef:ve,modelTriggerRef:te,onClose:()=>U(!1)}),{modelMenuPosition:Ct,openAbove:Et}=dt({modelGroupCount:$e.length,modelItemCount:$e.reduce((L,A)=>L+A.items.length,0),modelMenuOpen:D,modelMenuRef:ae,modelTriggerRef:be,onClose:()=>F(!1)}),{uploading:Mt,error:Lt,handleUpload:Tt}=vr({onSuccess:L=>h(L)}),It=r.useCallback(L=>{Ue(L);const A=re.find(ne=>ne.id===L);N((A==null?void 0:A.model)??me(L)),O(null),U(!1)},[Ue,re]),Rt=r.useCallback(L=>{Se(L);const A=Ve.find(ne=>ne.id===L);g((A==null?void 0:A.model)??me(L)),F(!1)},[Se,Ve]),At=r.useCallback(()=>{Se(""),g(""),F(!1)},[Se]),$t=r.useCallback(async()=>{if(!se){I(!0),S(null),O(null);try{const L=He(),A=(L==null?void 0:L.accountRef)??_??"",ne=(L==null?void 0:L.model)??(K==null?void 0:K.model)??w;if(!ne){O("请选择一个模型");return}const Fe=x.trim(),Ot=p.trim()||(a==="create"?wr:(t==null?void 0:t.roleDescription)??""),Pt=br(Fe)||H,le=Qe(),Bt=(le==null?void 0:le.accountRef)??V??void 0,Oe=(le==null?void 0:le.model)??(ue==null?void 0:ue.model)??v,Ye=Oe&&Oe.trim()!==""?Oe.trim():void 0,Dt=Ye?Bt??"huawei-maas":void 0,qt={agentId:H,name:Fe,displayName:Fe,nickname:"",avatar:i,colorPrimary:"#9B7EBD",colorSecondary:"#E8DFF5",mentionPatterns:`@${Pt}`,roleDescription:Ot,personality:j,teamStrengths:"",caution:"",strengths:"",client:(K==null?void 0:K.client)??"relayclaw",accountRef:A,defaultModel:ne,imageModel:Ye,imageAccountRef:Dt,commandArgs:"",cliConfigArgs:[],ocProviderName:"",embeddedAcpExecutablePath:"",embeddedAcpArgs:"",embeddedAcpCwd:"",embeddedAcpEnvText:"",sessionChain:"true",maxPromptTokens:"",maxContextTokens:"",maxMessages:"",maxContentLengthPerMsg:"",...s!=null&&s.creationSource?{creationSource:s.creationSource}:{}},Ze=Kt(qt,t??null);Ze.skills=X;const Wt=a==="edit"&&t?"PATCH":"POST",zt=a==="edit"&&t?`/api/agents/${t.id}`:"/api/agents",Xe=await B(zt,{method:Wt,headers:{"Content-Type":"application/json"},body:JSON.stringify(Ze)});if(!Xe.ok){const Gt=await Xe.json().catch(()=>({})),xe=rt(Gt.error)??(a==="edit"?"保存失败":"创建失败");if(xe==="模型不存在,请重新选择"){O(xe);return}if(st(xe)){E(xe);return}throw new Error(xe)}o()}catch(L){const A=rt(L instanceof Error?L.message:null)??(a==="edit"?"保存失败":"创建失败");A==="模型不存在,请重新选择"?O(A):st(A)?E(A):S(A)}finally{I(!1)}}},[x,p,w,v,i,X,j,a,t,_,V,se,H,s,He,Qe,K,ue,o]),Ft=(t==null?void 0:t.displayName)??(s==null?void 0:s.displayName)??"";return e.jsxs("div",{className:"flex h-full min-h-0 flex-col",children:[e.jsx("div",{ref:je,className:"min-h-0 flex-1 overflow-y-auto",children:e.jsxs("div",{className:"mx-auto grid min-h-full w-full max-w-[1480px] grid-cols-[minmax(112px,132px)_minmax(0,1092px)_minmax(112px,132px)] gap-x-8 px-6 pb-6 lg:px-8",children:[e.jsx("div",{className:"sticky top-0 z-10 row-span-2 min-w-0 self-start justify-self-stretch",children:e.jsx("div",{className:"flex justify-end",children:e.jsx(cr,{activeStep:"basic",onStepClick:T})})}),e.jsx("div",{className:"sticky top-0 z-10 col-start-2 row-start-1 min-w-0 bg-[var(--surface-panel)] pb-4",children:e.jsx(Ha,{displayName:Ft,formMode:a,onBackToDetail:l,onBackToList:c})}),e.jsx("div",{className:"col-start-2 row-start-2 min-w-0 mt-4",children:e.jsxs("div",{ref:ge,className:"flex flex-col gap-12",children:[e.jsx(Ga,{avatarError:Lt,displayAvatar:m,draftDefaultModel:w,draftImageModel:v??"",draftDescription:p,draftName:x,fileInputRef:he,inlineNameError:Ne,loadingModels:ce,modelGroups:de,modelMenuOpen:J,modelMenuPosition:kt,modelMenuRef:ve,modelTriggerRef:te,modelError:G??(yt?"模型不存在,请重新选择":null),loadingImageModels:Nt,imageModelGroups:$e,imageModelMenuOpen:D,imageModelMenuPosition:Ct,imageModelMenuRef:ae,imageModelTriggerRef:be,missingImageModel:St,onAvatarUpload:Tt,onDescriptionChange:d,onNameChange:L=>{u(L),E(null)},onRandomAvatar:()=>h(Oa()),onSelectModel:It,onToggleModelMenu:()=>U(L=>!L),onSelectImageModel:Rt,onClearImageModel:At,onToggleImageModelMenu:()=>F(L=>!L),selectedModel:K,selectedImageModel:ue,openAbove:_t,imageModelOpenAbove:Et,uploadingAvatar:Mt}),e.jsx("div",{ref:we,children:e.jsx(ir,{activeWorkingDraft:j,editingAgent:t,onDraftChange:f})}),e.jsx("div",{ref:ye,children:e.jsx(Hs,{editingAgent:t,skills:X,skillBasicInfos:W,onSkillsChange:(L,A)=>{ie(L),A&&P(A)}})})]})})]})}),e.jsx(Ua,{error:$,formMode:a,isConfirmDisabled:Ae,onCancel:n,onSave:$t,saving:C})]})}function Nr({agents:t,filteredAgents:a,searchQuery:s,sourceFilter:n,onSearchChange:o,onClearSearch:l,onSourceFilterChange:c,onRefresh:x,onSelectAgent:u,onOpenCreate:p,onOpenEdit:d,onDeleteAgent:i,loading:h}){return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-6",children:[e.jsxs("div",{className:"flex items-center justify-between shrink-0",children:[e.jsxs("h1",{className:"ui-page-title",children:["智能体管理(",t.length,")"]}),e.jsx(q,{variant:"major",onClick:p,children:"新建智能体"})]}),e.jsx("div",{className:"flex items-center gap-3 shrink-0",children:e.jsx(ja,{searchQuery:s,sourceFilter:n,onSearchChange:o,onClearSearch:l,onSourceFilterChange:c,onRefresh:x,loading:h})}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:e.jsx(ba,{agents:a,onSelectAgent:u,onEditAgent:d,onDeleteAgent:i,searchQuery:s,sourceFilter:n,onClearSearch:l,onClearFilter:()=>c("all")})})]})}function Sr({agent:t,onOpenEdit:a,onBackToList:s}){return e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-8 overflow-hidden",children:[e.jsx("div",{className:"flex items-center justify-between py-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",onClick:s,className:"text-[12px] text-[var(--text-secondary)] transition hover:text-[var(--text-primary)]",children:"智能体管理"}),e.jsx("span",{className:"text-[12px] text-[var(--text-muted)]",children:"/"}),e.jsx("span",{className:"text-[12px] font-bold text-[var(--text-primary)]",children:t.displayName})]})}),e.jsxs("div",{className:"min-h-0 flex-1 overflow-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 pb-8",children:[t.avatar&&(t.avatar.startsWith("/uploads/")||t.avatar.startsWith("/avatars/")||/^https?:\/\//.test(t.avatar))?e.jsx("img",{src:t.avatar,alt:t.displayName,className:"h-10 w-10 shrink-0 rounded-full object-cover"}):e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-[var(--accent-primary)] text-[14px] font-medium text-white",children:t.displayName.charAt(0)}),e.jsx("h1",{className:"min-w-0 flex-1 text-[20px] font-bold text-[var(--text-primary)]",children:t.displayName}),e.jsxs("button",{type:"button",onClick:()=>a(t.id),className:"inline-flex h-[18px] shrink-0 items-center gap-1 text-[12px] text-[var(--text-primary)] transition hover:underline hover:underline-offset-2",children:[e.jsx(Z,{name:"edit",className:"h-3.5 w-3.5"}),e.jsx("span",{children:"编辑"})]})]}),e.jsx("div",{className:"border-b border-[var(--panel-border-outer)] ",children:e.jsx(ga,{agent:t})}),e.jsx("div",{className:"mt-8",children:e.jsx(vt,{personality:t.personality,agentId:t.id,readOnly:!0,muted:!1,showTitle:!0})}),e.jsx("div",{className:"mt-8",children:e.jsx(Ma,{agent:t})})]})]})}function kr({editingAgent:t,formMode:a,prefillData:s,onCancel:n,onSaveSuccess:o,onBackToDetail:l,onBackToList:c}){return e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:e.jsx(yr,{editingAgent:t,formMode:a,prefillData:s,onCancel:n,onSaveSuccess:o,onBackToDetail:l,onBackToList:c})})}function _r({agents:t,filteredAgents:a,searchQuery:s,sourceFilter:n,selectedAgent:o,currentView:l,formMode:c,editingAgent:x,previousView:u,prefillData:p,loading:d,onSearchChange:i,onClearSearch:h,onSourceFilterChange:w,onRefresh:N,onSelectAgent:v,onOpenCreate:g,onOpenEdit:j,onDeleteAgent:f,onCancel:b,onSaveSuccess:y,onBackToDetail:C,onBackToList:I}){let $;return l==="form"?$=e.jsx(kr,{editingAgent:x,formMode:c,prefillData:p,onCancel:b,onSaveSuccess:y,onBackToDetail:C,onBackToList:I}):l==="detail"&&o?$=e.jsx(Sr,{agent:o,onOpenEdit:j,onBackToList:I}):$=e.jsx(Nr,{agents:t,filteredAgents:a,searchQuery:s,sourceFilter:n,onSearchChange:i,onClearSearch:h,onSourceFilterChange:w,onRefresh:N,onSelectAgent:v,onOpenCreate:g,onOpenEdit:j,onDeleteAgent:f,loading:d}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:$})}function Cr(){const{agents:t=[],refresh:a}=pt(),[s,n]=r.useState(""),[o,l]=r.useState("all"),[c,x]=r.useState(null),[u,p]=r.useState("list"),[d,i]=r.useState("create"),[h,w]=r.useState(null),[N,v]=r.useState(null),[g,j]=r.useState(null),f=r.useMemo(()=>Ra(t,s,o),[t,s,o]),b=r.useMemo(()=>c?t.find(E=>E.id===c)??null:null,[t,c]),y=r.useMemo(()=>h?t.find(E=>E.id===h)??null:null,[t,h]),C=r.useCallback(E=>{x(E),v(u),p("detail")},[u]),I=r.useCallback(()=>{w(null),i("create"),v(u),p("form")},[u]),$=r.useCallback(E=>{w(E),x(E),i("edit"),v(u),p("form")},[u]),S=r.useCallback(()=>{N?(p(N),v(null)):p("list"),w(null),j(null)},[N]),R=r.useCallback(E=>{j(E),i("create"),v(u),p("form")},[u]);return{agents:t,filteredAgents:f,searchQuery:s,sourceFilter:o,selectedAgentId:c,selectedAgent:b,currentView:u,formMode:d,editingAgentId:h,editingAgent:y,previousView:N,prefillData:g,setSearchQuery:n,setSourceFilter:l,setSelectedAgentId:x,setCurrentView:p,setFormMode:i,setEditingAgentId:w,setPreviousView:v,handleSelectAgent:C,handleOpenCreate:I,handleOpenEdit:$,handleCancel:S,refresh:a,prefillAgent:R}}function Er({prefillData:t,onPrefillConsumed:a,onViewChange:s}={}){const n=Cr(),o=Ut(),l=Ce(i=>i.addToast);r.useEffect(()=>{t&&(n.prefillAgent(t),a==null||a())},[t]),r.useEffect(()=>{s==null||s(n.currentView)},[n.currentView,s]);const c=r.useCallback(i=>{n.handleOpenEdit(i)},[n]),x=r.useCallback(async i=>{const h=n.agents.find(N=>N.id===i);if(!(!h||!await o({title:"确认删除智能体",message:`确定要删除智能体「${h.displayName}」吗?删除后将不可恢复。`,confirmLabel:"删除",cancelLabel:"取消"})))try{const N=await B(`/api/agents/${encodeURIComponent(i)}`,{method:"DELETE"});if(!N.ok)throw new Error(`HTTP ${N.status}`);l({type:"success",title:"删除成功",message:`智能体「${h.displayName}」已删除`,duration:2600}),await n.refresh()}catch{l({type:"error",title:"删除失败",message:"智能体删除失败,请稍后重试",duration:2600})}},[n,o]),u=r.useCallback(()=>{n.setCurrentView("detail")},[n]),p=r.useCallback(()=>{n.handleCancel(),n.refresh()},[n]),d=r.useCallback(()=>{n.setCurrentView("list")},[n]);return e.jsx("div",{className:"flex min-h-0 flex-1 flex-col",children:e.jsx(_r,{agents:n.agents,filteredAgents:n.filteredAgents,searchQuery:n.searchQuery,sourceFilter:n.sourceFilter,selectedAgent:n.selectedAgent,currentView:n.currentView,formMode:n.formMode,editingAgent:n.editingAgent,previousView:n.previousView,prefillData:n.prefillData,onSearchChange:n.setSearchQuery,onClearSearch:()=>n.setSearchQuery(""),onSourceFilterChange:n.setSourceFilter,onRefresh:n.refresh,onSelectAgent:n.handleSelectAgent,onOpenCreate:n.handleOpenCreate,onOpenEdit:c,onDeleteAgent:x,onCancel:n.handleCancel,onSaveSuccess:p,onBackToDetail:u,onBackToList:d})})}const Mr={insight:"洞察研究",finance:"金融服务",product:"产品研发",business:"商务销售",office:"通用办公"},Lr=[{id:"all",label:"全部"},{id:"insight",label:"洞察研究"},{id:"finance",label:"金融服务"},{id:"product",label:"产品研发"},{id:"business",label:"商务销售"},{id:"office",label:"通用办公"}];function Tr({expert:t,onInvoke:a,onAdd:s}){return e.jsxs("article",{className:"ui-card ui-card-hover group relative flex h-[196px] cursor-pointer flex-col rounded-[16px] border border-[#e6e6e6] bg-white p-6",onClick:()=>a(t.expertId),onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&(n.preventDefault(),a(t.expertId))},role:"button",tabIndex:0,"aria-label":`召唤智能体 ${t.displayName}`,children:[e.jsxs("div",{className:"mb-4 flex items-start gap-3",children:[e.jsx("div",{className:"h-12 w-12 shrink-0 overflow-hidden rounded-full",children:e.jsx("img",{src:t.avatar,alt:t.displayName,className:"h-full w-full object-cover"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"truncate text-[14px] font-semibold text-[var(--text-primary)]",children:t.displayName}),e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1",children:e.jsx("span",{className:"inline-flex h-[18px] items-center rounded px-[6px] text-[11px] leading-[18px] font-medium",style:{backgroundColor:"#E6E6E6",color:"rgba(25, 25, 25, 0.85)"},children:Mr[t.category]})})]})]}),t.roleDescription?e.jsx("p",{className:"line-clamp-2 mb-4 flex-1 text-[12px] leading-relaxed text-[var(--text-secondary)]",children:t.roleDescription}):e.jsx("p",{className:"line-clamp-2 mb-4 flex-1 text-[12px] leading-relaxed text-[var(--text-muted)]",children:"暂无描述"}),e.jsxs("div",{className:"absolute bottom-6 left-6 right-6 flex items-center gap-4 transition-opacity opacity-0 pointer-events-none group-hover:opacity-100 group-hover:pointer-events-auto group-focus-within:opacity-100 group-focus-within:pointer-events-auto",children:[e.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),a(t.expertId)},className:"bg-transparent p-0 text-[14px] font-normal text-[var(--text-accent)] hover:underline",children:"立即召唤"}),e.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),s(t)},className:"bg-transparent p-0 text-[14px] font-normal text-[var(--text-accent)] hover:underline",children:"添加"})]})]})}function Ir({experts:t,onInvoke:a,onAdd:s,searchQuery:n="",onClearSearch:o}){return t.length===0?n.trim()?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(We,{onClear:o})}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(Le,{title:"暂无相关专家"})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:t.map(l=>e.jsx("div",{className:"w-full",children:e.jsx(Tr,{expert:l,onInvoke:a,onAdd:s})},l.expertId))})}const z="/avatars/codex.png";function Rr(t){const a=t==null?void 0:t.trim();return a?a.startsWith("/uploads/")?`/uploads/${a.replace("/uploads/","")}`:a.startsWith("/")?a:null:null}function Ar({open:t,onClose:a,expertId:s,expertMentionPattern:n,onConfirm:o,onCreateNew:l}){const c=Ee(f=>f.threads),{agents:x}=pt(),{getExpertById:u}=ia(),p=r.useMemo(()=>new Map(x.map(f=>[f.id,f])),[x]),[d,i]=r.useState(null),[h,w]=r.useState(""),N=r.useMemo(()=>{const f=h.toLowerCase();return c.filter(b=>{var y;return b.id!=="default"&&(!f||(((y=et(b.title))==null?void 0:y.toLowerCase())??"").includes(f)||b.id.toLowerCase().includes(f))})},[c,h]),v=r.useMemo(()=>N.map(f=>{const b=Array.isArray(f.participants)?f.participants:[],y=b.includes(s),C=b.map(S=>{var R,E;return((R=p.get(S))==null?void 0:R.displayName)??((E=u(S))==null?void 0:E.displayName)??S}).filter(S=>!!S.trim()),I=C.length>0?C.join(","):"通用助手",$=b.slice(0,4).map(S=>{var R,E;return Rr(((R=p.get(S))==null?void 0:R.avatar)??((E=u(S))==null?void 0:E.avatar))??z});return{id:f.id,label:et(f.title)??"未命名对话",subtitle:I,avatarSources:$,timeText:oa(Number(f.lastActiveAt)||0,!0),isInvited:y}}),[N,p,s,u]),g=()=>{d&&(o(d),a())},j=()=>{l(),a()};return e.jsx(la,{open:t,onClose:a,title:"选择会话",panelStyle:{width:680},panelClassName:"rounded-2xl",bodyClassName:"p-0",children:e.jsxs("div",{className:"flex flex-col gap-5 mt-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"hidden w-[176px] h-7 px-3 rounded-[6px] border border-[#D7DEE8] bg-white cursor-pointer",children:[e.jsx("span",{className:"text-xs font-medium text-[#2D3643]",children:"全部渠道"}),e.jsx("svg",{className:"w-4 h-4 text-[#8D97A6]",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("path",{d:"M6 9l6 6 6-6"})})]}),e.jsxs("div",{className:"flex-1 flex items-center gap-2 h-7 px-3 rounded-[6px] border border-[#D7DEE8] bg-white",children:[e.jsxs("svg",{className:"w-3.5 h-3.5 text-[#A4ADBA]",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("path",{d:"M21 21l-4.35-4.35"})]}),e.jsx("input",{type:"text",value:h,onChange:f=>w(f.target.value),placeholder:"搜索会话名称或描述",className:"flex-1 text-xs text-[#A4ADBA] bg-transparent outline-none"})]})]}),e.jsx("div",{className:"flex flex-col gap-2 overflow-y-auto max-h-[340px]",children:v.length===0?e.jsx("div",{className:"flex items-center justify-center h-20 text-[#667085] text-sm",children:"暂无相关会话"}):v.map(f=>{const b=f.id===d;return e.jsxs("button",{type:"button",onClick:()=>i(f.id),className:["flex w-full items-start gap-3 rounded-[8px] px-6 transition",b?"border-[1.5px] border-[rgba(20,118,255,1)] bg-white":"border border-[rgba(240,240,240,1)] bg-[rgba(250,250,250,1)] hover:border-[var(--connector-tab-border-hover)] hover:bg-[var(--connector-tab-bg-hover)]"].join(" "),style:{height:"68px",paddingTop:12,paddingBottom:12},children:[e.jsx("div",{className:"relative h-8 w-8 shrink-0",children:f.avatarSources.length<=1?e.jsx("img",{src:f.avatarSources[0]??z,alt:"","aria-hidden":"true",className:"h-8 w-8 rounded-full object-cover"}):f.avatarSources.length===2?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:f.avatarSources[0]??z,alt:"","aria-hidden":"true",className:"absolute left-[1px] top-[6px] h-5 w-5 rounded-full object-cover"}),e.jsx("img",{src:f.avatarSources[1]??z,alt:"","aria-hidden":"true",className:"absolute left-[11px] top-[6px] h-5 w-5 rounded-full object-cover"})]}):f.avatarSources.length===3?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:f.avatarSources[0]??z,alt:"","aria-hidden":"true",className:"absolute left-[8px] top-0 h-4 w-4 rounded-full object-cover"}),e.jsx("img",{src:f.avatarSources[1]??z,alt:"","aria-hidden":"true",className:"absolute left-0 top-[16px] h-4 w-4 rounded-full object-cover"}),e.jsx("img",{src:f.avatarSources[2]??z,alt:"","aria-hidden":"true",className:"absolute left-[16px] top-[16px] h-4 w-4 rounded-full object-cover"})]}):e.jsxs(e.Fragment,{children:[e.jsx("img",{src:f.avatarSources[0]??z,alt:"","aria-hidden":"true",className:"absolute left-0 top-0 h-4 w-4 rounded-full object-cover"}),e.jsx("img",{src:f.avatarSources[1]??z,alt:"","aria-hidden":"true",className:"absolute left-[16px] top-0 h-4 w-4 rounded-full object-cover"}),e.jsx("img",{src:f.avatarSources[2]??z,alt:"","aria-hidden":"true",className:"absolute left-0 top-[16px] h-4 w-4 rounded-full object-cover"}),e.jsx("img",{src:f.avatarSources[3]??z,alt:"","aria-hidden":"true",className:"absolute left-[16px] top-[16px] h-4 w-4 rounded-full object-cover"})]})}),e.jsxs("div",{className:"flex flex-col items-start min-w-0 flex-1 self-start",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 w-full",children:[e.jsx("span",{className:"block min-w-0 truncate text-[14px] font-semibold leading-5 text-[#344054]",children:f.label}),e.jsx("span",{className:"shrink-0 text-[14px] leading-5 text-[#344054]",children:f.timeText})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"truncate text-[12px] leading-5 text-[#667085]",children:f.subtitle}),f.isInvited&&e.jsx("span",{className:"shrink-0 text-[12px] leading-5 text-[#16A34A] font-medium",children:"已邀请"})]})]})]},f.id)})}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pb-6",children:[e.jsx(q,{variant:"default",size:"sm",onClick:a,children:"取消"}),e.jsx(q,{variant:"default",size:"sm",onClick:j,children:"新建会话"}),e.jsx(q,{variant:"major",size:"sm",onClick:g,disabled:!d,children:"确定"})]})]})})}function $r(t={}){const{threadId:a}=t,[s,n]=r.useState("all"),[o,l]=r.useState([]),[c,x]=r.useState([]),[u,p]=r.useState(!1),[d,i]=r.useState(null),[h,w]=r.useState(""),N=r.useCallback(async b=>{p(!0),i(null);try{const y=b&&b!=="all"?`?category=${b}`:"",C=await B(`/api/experts${y}`);if(!C.ok)throw new Error("Failed to fetch experts");const I=await C.json();l(I.experts??[])}catch(y){i(y instanceof Error?y.message:"Unknown error")}finally{p(!1)}},[]),v=r.useCallback(async()=>{if(a)try{const b=await B(`/api/threads/${a}/experts`);if(!b.ok)throw new Error("Failed to fetch invited experts");const y=await b.json();x(y.invitedExperts.map(C=>C.expertId))}catch(b){console.error("Failed to fetch invited experts:",b)}},[a]),g=r.useCallback(async(b,y)=>{const C=y??a;if(!C)return!1;try{const I=await B(`/api/threads/${C}/experts/${b}/invite`,{method:"POST"});if(!I.ok){const $=await I.json();throw new Error($.message||"Failed to invite expert")}return await v(),!0}catch(I){return i(I instanceof Error?I.message:"Unknown error"),!1}},[a,v]),j=r.useCallback(async b=>{if(!a)return!1;try{const y=await B(`/api/threads/${a}/experts/${b}`,{method:"DELETE"});if(!y.ok){const C=await y.json();throw new Error(C.message||"Failed to remove expert")}return await v(),!0}catch(y){return i(y instanceof Error?y.message:"Unknown error"),!1}},[a,v]);return{experts:r.useMemo(()=>{let b=o;if(s!=="all"&&(b=b.filter(y=>y.category===s)),h.trim()){const y=h.trim().toLowerCase();b=b.filter(C=>C.displayName.toLowerCase().includes(y)||C.roleDescription.toLowerCase().includes(y)||C.skills&&C.skills.some(I=>I.toLowerCase().includes(y)))}return b},[o,s,h]),allExperts:o,category:s,setCategory:n,invitedExpertIds:c,isLoading:u,error:d,fetchExperts:N,fetchInvitedExperts:v,inviteExpert:g,removeExpert:j,searchQuery:h,setSearchQuery:w}}function Fr({onAddExpert:t}={}){const a=Ht(),s=Ee(S=>S.currentThreadId),{experts:n,allExperts:o,category:l,setCategory:c,isLoading:x,fetchExperts:u,inviteExpert:p,searchQuery:d,setSearchQuery:i}=$r({threadId:s}),h=Ee(S=>S.setCurrentThread),w=Ee(S=>S.setPendingChatInsert);r.useEffect(()=>{u()},[u]);const[N,v]=r.useState(!1),[g,j]=r.useState(null),[f,b]=r.useState(null),y=S=>{const R=n.find(E=>E.expertId===S);j(S),b(R?ca(R):null),v(!0)},C=S=>{g&&p(g,S).then(R=>{R&&f&&(w({threadId:S,text:`${f} `,replaceTrailingMentionTrigger:!0,suppressMentionMenu:!0,mentionRefs:[{catId:g,mention:f}]}),h(S),a(`/thread/${S}`),typeof window<"u"&&window.dispatchEvent(new CustomEvent("office-claw:threads-refresh")))}),v(!1)},I=async()=>{if(!(!g||!f)){try{const S=await B("/api/threads",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({})});if(!S.ok)throw new Error("Failed to create thread");const E=(await S.json()).id;await p(g,E)&&(w({threadId:E,text:`${f} `,replaceTrailingMentionTrigger:!0,suppressMentionMenu:!0,mentionRefs:[{catId:g,mention:f}]}),h(E),a(`/thread/${E}`),typeof window<"u"&&window.dispatchEvent(new CustomEvent("office-claw:threads-refresh")))}catch(S){console.error("Failed to create thread:",S)}v(!1)}},$=S=>{t==null||t(S)};return e.jsxs("div",{className:"ui-page-shell gap-6 overflow-hidden",children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx("div",{className:"ui-page-header-inline items-start",children:e.jsx("div",{className:"flex flex-wrap items-center gap-4",children:Lr.map(S=>e.jsxs("div",{className:"flex items-center",children:[S.id!=="all"?e.jsx("div",{"aria-hidden":"true",className:"mr-4 h-4 w-px self-center bg-[#dbdbdb]"}):null,e.jsx("button",{type:"button",onClick:()=>c(S.id),className:`inline-flex min-h-7 items-center leading-none text-sm transition-colors ${l===S.id?"font-semibold text-[var(--text-primary)]":"text-[var(--text-muted)] hover:text-[var(--text-primary)]"}`,children:S.label})]},S.id))})}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("h1",{className:"ui-page-title",children:["智能体广场(",o.length,")"]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(fe,{value:d,onChange:S=>i(S),onClear:()=>i(""),placeholder:"搜索专家名称、职责或技能","aria-label":"搜索专家",clearAriaLabel:"清除搜索",wrapperClassName:"flex-1"}),e.jsx(mt,{onClick:()=>{u()},disabled:x,"aria-label":"刷新专家列表"})]})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:x?e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("span",{className:"text-[var(--text-muted)]",children:"加载中..."})}):e.jsx(Ir,{experts:n,onInvoke:y,onAdd:$,searchQuery:d,onClearSearch:()=>i("")})}),e.jsx(Ar,{open:N,onClose:()=>v(!1),expertId:g||"",expertMentionPattern:f||void 0,onConfirm:C,onCreateNew:I})]})}const Or=[{id:"agents",label:"智能体管理"},{id:"experts",label:"智能体广场"}];function Pr(){const[t,a]=r.useState("agents"),[s,n]=r.useState(null),[o,l]=r.useState("list");r.useEffect(()=>{const u=()=>a("agents");return window.addEventListener("agents-panel:switch-to-agents",u),()=>{window.removeEventListener("agents-panel:switch-to-agents",u)}},[]);const c=u=>{n({...u,creationSource:"experts-plaza"}),a("agents")},x=t==="experts"||t==="agents"&&o==="list";return e.jsxs("div",{className:"ui-page-shell",children:[x&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex shrink-0 items-center gap-6 px-1",children:Or.map(u=>{const p=u.id===t;return e.jsx("button",{type:"button","data-testid":`agents-panel-tab-${u.id}`,"aria-pressed":p,onClick:()=>a(u.id),className:`relative pb-2 text-[14px] transition ${p?"font-semibold text-[var(--text-primary)]":"font-medium text-[var(--text-label-secondary)] hover:text-[var(--text-secondary)]"}`,children:u.label},u.id)})}),e.jsx("div",{"data-testid":"agents-panel-divider",className:"mb-6 h-px w-full shrink-0 bg-[var(--border-elevated)]"})]}),e.jsx("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden",children:t==="agents"?e.jsx(Er,{prefillData:s,onPrefillConsumed:()=>n(null),onViewChange:l}):e.jsx(Fr,{onAddExpert:c})})]})}function cn(){return e.jsx("div",{className:"h-full overflow-hidden ui-shell-surface px-8 py-8",children:e.jsx(Pr,{})})}export{cn as default};
|
|
68
|
+
//# sourceMappingURL=AgentsPage-2u2kFBCH.js.map
|