openclacky 1.5.21 → 1.5.23
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +119 -0
- data/docs/secretary-prototype.md +286 -0
- data/lib/clacky/agent/session_serializer.rb +15 -11
- data/lib/clacky/agent.rb +58 -15
- data/lib/clacky/agent_config.rb +3 -1
- data/lib/clacky/agent_profile.rb +33 -6
- data/lib/clacky/billing/platform_billing.rb +9 -0
- data/lib/clacky/default_extensions/advisor/README.md +25 -0
- data/lib/clacky/default_extensions/advisor/README.zh.md +25 -0
- data/lib/clacky/default_extensions/advisor/ext.yml +1 -1
- data/lib/clacky/default_extensions/advisor/icon.svg +14 -0
- data/lib/clacky/default_extensions/coding/ext.yml +0 -1
- data/lib/clacky/default_extensions/computer-use/README.md +48 -0
- data/lib/clacky/default_extensions/computer-use/README.zh.md +48 -0
- data/lib/clacky/default_extensions/computer-use/ext.yml +1 -1
- data/lib/clacky/default_extensions/computer-use/icon.svg +16 -0
- data/lib/clacky/default_extensions/ext-studio/ext.yml +0 -1
- data/lib/clacky/default_extensions/general/ext.yml +0 -1
- data/lib/clacky/default_extensions/git/README.md +41 -0
- data/lib/clacky/default_extensions/git/README.zh.md +41 -0
- data/lib/clacky/default_extensions/git/ext.yml +1 -1
- data/lib/clacky/default_extensions/git/icon.svg +15 -0
- data/lib/clacky/default_extensions/git/panels/git/view.js +1960 -399
- data/lib/clacky/default_extensions/meeting/README.md +46 -0
- data/lib/clacky/default_extensions/meeting/README.zh.md +47 -0
- data/lib/clacky/default_extensions/meeting/ext.yml +1 -1
- data/lib/clacky/default_extensions/meeting/icon.svg +13 -0
- data/lib/clacky/default_extensions/preview/README.md +29 -0
- data/lib/clacky/default_extensions/preview/README.zh.md +29 -0
- data/lib/clacky/default_extensions/preview/ext.yml +1 -1
- data/lib/clacky/default_extensions/preview/icon.svg +13 -0
- data/lib/clacky/default_extensions/preview/panels/preview/view.js +199 -34
- data/lib/clacky/default_extensions/secretary/agents/secretary.md +41 -0
- data/lib/clacky/default_extensions/secretary/agents/worker.md +35 -0
- data/lib/clacky/default_extensions/secretary/api/handler.rb +8 -0
- data/lib/clacky/default_extensions/secretary/ext.yml +39 -0
- data/lib/clacky/default_extensions/secretary/panels/work/view.js +344 -0
- data/lib/clacky/default_extensions/secretary/tools/delegate_work.rb +37 -0
- data/lib/clacky/default_extensions/secretary/tools/manage_work.rb +22 -0
- data/lib/clacky/default_extensions/secretary/tools/yield_work.rb +35 -0
- data/lib/clacky/default_extensions/time_machine/README.md +32 -0
- data/lib/clacky/default_extensions/time_machine/README.zh.md +32 -0
- data/lib/clacky/default_extensions/time_machine/ext.yml +1 -1
- data/lib/clacky/default_extensions/time_machine/icon.svg +14 -0
- data/lib/clacky/default_skills/channel-manager/SKILL.md +79 -8
- data/lib/clacky/default_skills/channel-manager/discord_setup.rb +5 -1
- data/lib/clacky/default_skills/channel-manager/weixin_setup.rb +8 -1
- data/lib/clacky/default_skills/cron-task-creator/SKILL.md +183 -206
- data/lib/clacky/default_skills/cron-task-creator/evals/evals.json +45 -0
- data/lib/clacky/default_skills/media-gen/SKILL.md +17 -8
- data/lib/clacky/extension/api_extension.rb +10 -2
- data/lib/clacky/extension/loader.rb +2 -0
- data/lib/clacky/extension/verifier.rb +2 -2
- data/lib/clacky/locales/en.rb +14 -0
- data/lib/clacky/locales/zh.rb +14 -0
- data/lib/clacky/prompts/base.md +1 -1
- data/lib/clacky/providers.rb +68 -31
- data/lib/clacky/search_config.rb +33 -11
- data/lib/clacky/server/channel/adapters/base.rb +18 -0
- data/lib/clacky/server/channel/adapters/feishu/message_parser.rb +1 -0
- data/lib/clacky/server/channel/adapters/telegram/adapter.rb +1 -0
- data/lib/clacky/server/channel/channel_config.rb +185 -48
- data/lib/clacky/server/channel/channel_manager.rb +179 -66
- data/lib/clacky/server/git_panel.rb +362 -35
- data/lib/clacky/server/http_server.rb +530 -181
- data/lib/clacky/server/preview.rb +118 -17
- data/lib/clacky/server/scheduler.rb +211 -51
- data/lib/clacky/server/web_ui_controller.rb +35 -27
- data/lib/clacky/session_manager.rb +56 -6
- data/lib/clacky/tools/base.rb +7 -1
- data/lib/clacky/utils/file_processor.rb +20 -10
- data/lib/clacky/utils/mac_app_detector.rb +8 -7
- data/lib/clacky/utils/model_pricing.rb +60 -2
- data/lib/clacky/utils/windows_app_detector.rb +3 -1
- data/lib/clacky/version.rb +1 -1
- data/lib/clacky/web/app.css +1114 -205
- data/lib/clacky/web/app.js +143 -8
- data/lib/clacky/web/auth.js +1 -1
- data/lib/clacky/web/components/code-editor.js +73 -4
- data/lib/clacky/web/components/composer.js +107 -8
- data/lib/clacky/web/components/image-zoom.js +165 -0
- data/lib/clacky/web/components/model-picker.js +7 -5
- data/lib/clacky/web/components/notify.js +39 -12
- data/lib/clacky/web/components/onboard.js +1 -1
- data/lib/clacky/web/core/aside.js +60 -3
- data/lib/clacky/web/features/billing/view.js +2 -2
- data/lib/clacky/web/features/channels/store.js +19 -4
- data/lib/clacky/web/features/channels/view.js +92 -28
- data/lib/clacky/web/features/extensions/view.js +17 -10
- data/lib/clacky/web/features/new-session/store.js +79 -2
- data/lib/clacky/web/features/new-session/view.js +516 -75
- data/lib/clacky/web/features/skills/store.js +1 -1
- data/lib/clacky/web/features/tasks/store.js +5 -3
- data/lib/clacky/web/features/tasks/view.js +249 -66
- data/lib/clacky/web/features/workspace/store.js +13 -6
- data/lib/clacky/web/features/workspace/view.js +340 -214
- data/lib/clacky/web/i18n.js +366 -68
- data/lib/clacky/web/index.html +196 -165
- data/lib/clacky/web/projects.js +37 -4
- data/lib/clacky/web/sessions.js +263 -146
- data/lib/clacky/web/settings.js +241 -53
- data/lib/clacky/web/skills.js +2 -2
- data/lib/clacky/web/theme.js +17 -2
- data/lib/clacky/web/utils.js +234 -2
- data/lib/clacky/web/weixin-qr.html +2 -1
- data/lib/clacky/web/ws-dispatcher.js +14 -31
- data/lib/clacky/work/service.rb +542 -0
- data/lib/clacky/work/store.rb +57 -0
- metadata +31 -1
|
@@ -32,21 +32,22 @@ const ModelPicker = (() => {
|
|
|
32
32
|
// tile's white ink; `brandSvg` keeps the official multi-color/gradient
|
|
33
33
|
// artwork, so those tiles take a light background and skip the currentColor
|
|
34
34
|
// fill. Unknown models fall back to their initial on a neutral tile.
|
|
35
|
+
// `tint` keeps a monochrome mark in brand color when drawn on a neutral tile.
|
|
35
36
|
const _VENDOR_RULES = [
|
|
36
37
|
// "auto" is the routing feature, not a vendor model: circular arrows
|
|
37
38
|
// wrapping a bold "A" mark the automatic model pick.
|
|
38
|
-
{ re: /^auto$/i, label: "A", color: "#4f46e5",
|
|
39
|
+
{ re: /^auto$/i, label: "A", color: "#4f46e5", tint: "#4f46e5",
|
|
39
40
|
svg: '<path d="M19.79 7.5A9 9 0 1 0 19.79 16.5" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round"/>'
|
|
40
41
|
+ '<path d="M17.49 3.51 21.52 6.5 18.06 8.5Z"/>'
|
|
41
42
|
+ '<path d="M22.09 12.51 21.52 17.5 18.06 15.5Z"/>'
|
|
42
43
|
+ '<path fill-rule="evenodd" d="M12 5.8 16.4 17.6H14.35L13.5 15.1H10.5L9.65 17.6H7.6ZM12 8.8 13.05 12.8H10.95Z"/>' },
|
|
43
44
|
{ re: /claude|anthropic/i, label: "A", color: "#fff",
|
|
44
45
|
brandSvg: '<path d="M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z" fill="#D97757" fill-rule="nonzero"/>' },
|
|
45
|
-
{ re: /deepseek/i, label: "D", color: "#4D6BFE", viewBox: "0 1.5 27 20.5",
|
|
46
|
+
{ re: /deepseek/i, label: "D", color: "#4D6BFE", tint: "#4D6BFE", viewBox: "0 1.5 27 20.5",
|
|
46
47
|
svg: '<path d="M26.5174 3.39471C26.235 3.2567 26.1137 3.52006 25.9487 3.65346C25.8923 3.69659 25.8446 3.75294 25.7969 3.80469C25.3846 4.24516 24.9027 4.53439 24.2737 4.49989C23.3536 4.44814 22.5682 4.73737 21.8735 5.44119C21.7258 4.57349 21.2353 4.0554 20.4889 3.72304C20.0985 3.55054 19.7034 3.37746 19.4297 3.00197C19.2388 2.73459 19.1865 2.43673 19.091 2.14289C19.0301 1.96579 18.9697 1.78466 18.7656 1.75418C18.5442 1.71968 18.4574 1.90541 18.3705 2.06067C18.0232 2.69549 17.8887 3.39471 17.9019 4.10313C17.9324 5.6965 18.6051 6.96556 19.9421 7.86834C20.0939 7.97184 20.133 8.07535 20.0852 8.22658C19.9938 8.53766 19.8857 8.83955 19.7903 9.15063C19.7293 9.34901 19.6384 9.39271 19.4257 9.30588C18.692 8.9994 18.0583 8.54571 17.4982 7.99772C16.5477 7.07827 15.6881 6.06336 14.6162 5.26869C14.3644 5.08296 14.1125 4.91045 13.8521 4.746C12.7584 3.68394 13.9952 2.81164 14.2816 2.70814C14.5812 2.60003 14.3857 2.22857 13.4179 2.23317C12.4502 2.2372 11.5646 2.56151 10.4359 2.99335C10.2708 3.05832 10.0972 3.10547 9.91951 3.14457C8.8954 2.95022 7.83162 2.90709 6.72069 3.03245C4.62877 3.26533 2.95777 4.25436 1.72954 5.94261C0.254043 7.97184 -0.0932678 10.2777 0.33167 12.6824C0.778458 15.2171 2.07225 17.3153 4.06008 18.9558C6.12152 20.6567 8.49577 21.4905 11.2047 21.3306C12.8498 21.2358 14.6812 21.0155 16.7473 19.2669C17.2682 19.5262 17.8151 19.6297 18.7219 19.7074C19.4205 19.7723 20.0933 19.6729 20.6143 19.5648C21.4302 19.3923 21.3739 18.6367 21.0789 18.4981C18.6874 17.3843 19.2124 17.8374 18.7351 17.4706C19.9501 16.033 21.8063 13.4776 22.379 9.99821C22.4353 9.61409 22.5072 9.073 22.4986 8.76192C22.494 8.57216 22.5377 8.49856 22.7545 8.47671C23.3536 8.40771 23.935 8.24383 24.4692 7.94999C26.0188 7.10357 26.6439 5.71318 26.7911 4.04678C26.8129 3.79204 26.7865 3.52869 26.5174 3.39471ZM13.0143 18.3946C10.6964 16.5724 9.5722 15.9726 9.10816 15.9985C8.67402 16.0244 8.75222 16.5212 8.84768 16.8449C8.94773 17.1646 9.07768 17.3849 9.25996 17.6655C9.38589 17.8512 9.47272 18.1272 9.13404 18.3348C8.38766 18.7965 7.08985 18.1796 7.0289 18.1491C5.51833 17.2595 4.25559 16.0853 3.36546 14.4793C2.50581 12.9337 2.0067 11.2753 1.92447 9.50542C1.90262 9.07818 2.02855 8.92695 2.45406 8.84932C3.01413 8.74582 3.59144 8.72397 4.15093 8.80619C6.51656 9.15178 8.53027 10.2092 10.2185 11.8848C11.1822 12.8388 11.9114 13.979 12.6623 15.0929C13.461 16.2757 14.3201 17.4027 15.4144 18.3268C15.8008 18.6505 16.109 18.8966 16.404 19.0783C15.5144 19.1778 14.0297 19.1991 13.0143 18.3958V18.3946ZM14.1252 11.2489C14.1252 11.0591 14.277 10.9079 14.4679 10.9079C14.511 10.9079 14.5501 10.9165 14.5852 10.9292C14.6329 10.9464 14.6766 10.9723 14.7111 11.0114C14.7721 11.0718 14.8066 11.158 14.8066 11.2489C14.8066 11.4386 14.6548 11.5899 14.4639 11.5899C14.273 11.5899 14.1252 11.4386 14.1252 11.2489ZM17.5759 13.0188C17.3545 13.1096 17.1331 13.1873 16.9203 13.1959C16.5903 13.2131 16.2303 13.0791 16.0348 12.9153C15.7312 12.6605 15.5139 12.5179 15.423 12.0734C15.3839 11.8837 15.4057 11.5899 15.4402 11.4214C15.5185 11.0585 15.4316 10.8257 15.1757 10.614C14.9676 10.4415 14.7025 10.3938 14.4115 10.3938C14.3029 10.3938 14.2034 10.3461 14.1292 10.3076C14.0079 10.2472 13.9078 10.096 14.0033 9.91023C14.0338 9.84985 14.1815 9.70322 14.216 9.67734C14.6111 9.45251 15.0665 9.52612 15.488 9.6946C15.8784 9.85445 16.174 10.1477 16.5989 10.5623C17.033 11.0631 17.1112 11.2011 17.3585 11.5772C17.554 11.871 17.7317 12.1729 17.8536 12.5185C17.9272 12.7341 17.8317 12.9107 17.5759 13.0188Z"/>' },
|
|
47
48
|
{ re: /glm|zhipu|bigmodel/i, label: "Z", color: "#131212", viewBox: "0 0 32 27",
|
|
48
49
|
svg: '<path d="M16.5376 0.0307374L14.3326 3.13223C14.1617 3.37577 13.9331 3.57415 13.6667 3.71001C13.4004 3.84586 13.1045 3.91504 12.8048 3.9115H0.787598V0.015152H16.5376V0.0307374Z"/><path d="M31.5 0.0321655L12.6 26.5273H0L18.9 0.0321655H31.5Z"/><path d="M14.9624 26.5272L17.1832 23.4101C17.3564 23.1689 17.5856 22.9723 17.8513 22.8368C18.1171 22.7012 18.4119 22.6306 18.7109 22.6308H30.7124V26.5272H14.9624Z"/>' },
|
|
49
|
-
{ re: /gemini/i,
|
|
50
|
+
{ re: /gemini|veo|imagen/i, label: "G", color: "#fff",
|
|
50
51
|
brandSvg: '<path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="#3186FF"/><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="url(#lobe-icons-gemini-0-_R_0_)"/><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="url(#lobe-icons-gemini-1-_R_0_)"/><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z" fill="url(#lobe-icons-gemini-2-_R_0_)"/><defs><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-gemini-0-_R_0_" x1="7" x2="11" y1="15.5" y2="12"><stop stop-color="#08B962"/><stop offset="1" stop-color="#08B962" stop-opacity="0"/></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-gemini-1-_R_0_" x1="8" x2="11.5" y1="5.5" y2="11"><stop stop-color="#F94543"/><stop offset="1" stop-color="#F94543" stop-opacity="0"/></linearGradient><linearGradient gradientUnits="userSpaceOnUse" id="lobe-icons-gemini-2-_R_0_" x1="3.5" x2="17.5" y1="13.5" y2="12"><stop stop-color="#FABC12"/><stop offset=".46" stop-color="#FABC12" stop-opacity="0"/></linearGradient></defs>' },
|
|
51
52
|
{ re: /gpt|openai/i, label: "G", color: "#000",
|
|
52
53
|
svg: '<path d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z"/>' },
|
|
@@ -64,7 +65,7 @@ const ModelPicker = (() => {
|
|
|
64
65
|
brandSvg: '<path d="M19.44 10.153l-2.936 11.586a.215.215 0 00.214.261h5.87a.215.215 0 00.214-.261l-2.95-11.586a.214.214 0 00-.412 0zM3.28 12.778l-2.275 8.96A.214.214 0 001.22 22h4.532a.212.212 0 00.214-.165.214.214 0 000-.097l-2.276-8.96a.214.214 0 00-.41 0z" fill="#00E5E5"/><path d="M7.29 5.359L3.148 21.738a.215.215 0 00.203.261h8.29a.214.214 0 00.215-.261L7.7 5.358a.214.214 0 00-.41 0z" fill="#006EFF"/><path d="M14.44.15a.214.214 0 00-.41 0L8.366 21.739a.214.214 0 00.214.261H19.9a.216.216 0 00.171-.078.214.214 0 00.044-.183L14.439.15z" fill="#006EFF"/><path d="M10.278 7.741L6.685 21.736a.214.214 0 00.214.264h7.17a.215.215 0 00.214-.264L10.688 7.741a.214.214 0 00-.41 0z" fill="#00E5E5"/>' },
|
|
65
66
|
{ re: /llama/i, label: "L", color: "#fff", ink: "#111827",
|
|
66
67
|
svg: '<path d="M7.905 1.09c.216.085.411.225.588.41.295.306.544.744.734 1.263.191.522.315 1.1.362 1.68a5.054 5.054 0 012.049-.636l.051-.004c.87-.07 1.73.087 2.48.474.101.053.2.11.297.17.05-.569.172-1.134.36-1.644.19-.52.439-.957.733-1.264a1.67 1.67 0 01.589-.41c.257-.1.53-.118.796-.042.401.114.745.368 1.016.737.248.337.434.769.561 1.287.23.934.27 2.163.115 3.645l.053.04.026.019c.757.576 1.284 1.397 1.563 2.35.435 1.487.216 3.155-.534 4.088l-.018.021.002.003c.417.762.67 1.567.724 2.4l.002.03c.064 1.065-.2 2.137-.814 3.19l-.007.01.01.024c.472 1.157.62 2.322.438 3.486l-.006.039a.651.651 0 01-.747.536.648.648 0 01-.54-.742c.167-1.033.01-2.069-.48-3.123a.643.643 0 01.04-.617l.004-.006c.604-.924.854-1.83.8-2.72-.046-.779-.325-1.544-.8-2.273a.644.644 0 01.18-.886l.009-.006c.243-.159.467-.565.58-1.12a4.229 4.229 0 00-.095-1.974c-.205-.7-.58-1.284-1.105-1.683-.595-.454-1.383-.673-2.38-.61a.653.653 0 01-.632-.371c-.314-.665-.772-1.141-1.343-1.436a3.288 3.288 0 00-1.772-.332c-1.245.099-2.343.801-2.67 1.686a.652.652 0 01-.61.425c-1.067.002-1.893.252-2.497.703-.522.39-.878.935-1.066 1.588a4.07 4.07 0 00-.068 1.886c.112.558.331 1.02.582 1.269l.008.007c.212.207.257.53.109.785-.36.622-.629 1.549-.673 2.44-.05 1.018.186 1.902.719 2.536l.016.019a.643.643 0 01.095.69c-.576 1.236-.753 2.252-.562 3.052a.652.652 0 01-1.269.298c-.243-1.018-.078-2.184.473-3.498l.014-.035-.008-.012a4.339 4.339 0 01-.598-1.309l-.005-.019a5.764 5.764 0 01-.177-1.785c.044-.91.278-1.842.622-2.59l.012-.026-.002-.002c-.293-.418-.51-.953-.63-1.545l-.005-.024a5.352 5.352 0 01.093-2.49c.262-.915.777-1.701 1.536-2.269.06-.045.123-.09.186-.132-.159-1.493-.119-2.73.112-3.67.127-.518.314-.95.562-1.287.27-.368.614-.622 1.015-.737.266-.076.54-.059.797.042zm4.116 9.09c.936 0 1.8.313 2.446.855.63.527 1.005 1.235 1.005 1.94 0 .888-.406 1.58-1.133 2.022-.62.375-1.451.557-2.403.557-1.009 0-1.871-.259-2.493-.734-.617-.47-.963-1.13-.963-1.845 0-.707.398-1.417 1.056-1.946.668-.537 1.55-.849 2.485-.849zm0 .896a3.07 3.07 0 00-1.916.65c-.461.37-.722.835-.722 1.25 0 .428.21.829.61 1.134.455.347 1.124.548 1.943.548.799 0 1.473-.147 1.932-.426.463-.28.7-.686.7-1.257 0-.423-.246-.89-.683-1.256-.484-.405-1.14-.643-1.864-.643zm.662 1.21l.004.004c.12.151.095.37-.056.49l-.292.23v.446a.375.375 0 01-.376.373.375.375 0 01-.376-.373v-.46l-.271-.218a.347.347 0 01-.052-.49.353.353 0 01.494-.051l.215.172.22-.174a.353.353 0 01.49.051zm-5.04-1.919c.478 0 .867.39.867.871a.87.87 0 01-.868.871.87.87 0 01-.867-.87.87.87 0 01.867-.872zm8.706 0c.48 0 .868.39.868.871a.87.87 0 01-.868.871.87.87 0 01-.867-.87.87.87 0 01.867-.872zM7.44 2.3l-.003.002a.659.659 0 00-.285.238l-.005.006c-.138.189-.258.467-.348.832-.17.692-.216 1.631-.124 2.782.43-.128.899-.208 1.404-.237l.01-.001.019-.034c.046-.082.095-.161.148-.239.123-.771.022-1.692-.253-2.444-.134-.364-.297-.65-.453-.813a.628.628 0 00-.107-.09L7.44 2.3zm9.174.04l-.002.001a.628.628 0 00-.107.09c-.156.163-.32.45-.453.814-.29.794-.387 1.776-.23 2.572l.058.097.008.014h.03a5.184 5.184 0 011.466.212c.086-1.124.038-2.043-.128-2.722-.09-.365-.21-.643-.349-.832l-.004-.006a.659.659 0 00-.285-.239h-.004z"/>' },
|
|
67
|
-
{ re: /mistral/i, label: "M", color: "#F26B1D",
|
|
68
|
+
{ re: /mistral/i, label: "M", color: "#F26B1D", tint: "#F26B1D",
|
|
68
69
|
svg: '<path d="M17.143 3.429v3.428h-3.429v3.429h-3.428V6.857H6.857V3.43H3.43v13.714H0v3.428h10.286v-3.428H6.857v-3.429h3.429v3.429h3.429v-3.429h3.428v3.429h-3.428v3.428H24v-3.428h-3.43V3.429z"/>' },
|
|
69
70
|
{ re: /hunyuan/i, label: "H", color: "#fff",
|
|
70
71
|
brandSvg: '<circle cx="12" cy="12" fill="#0055E9" r="12"/><path d="M12 0c.518 0 1.028.033 1.528.096A6.188 6.188 0 0112.12 12.28l-.12.001c-2.99 0-5.242 2.179-5.554 5.11-.223 2.086.353 4.412 2.242 6.146C3.672 22.1 0 17.479 0 12 0 5.373 5.373 0 12 0z" fill="#A8DFF5"/><path d="M5.286 5a2.438 2.438 0 01.682 3.38c-3.962 5.966-3.215 10.743 2.648 15.136C3.636 22.056 0 17.452 0 12c0-1.787.39-3.482 1.09-5.006.253-.435.525-.872.817-1.311A2.438 2.438 0 015.286 5z" fill="#0055E9"/><path d="M12.98.04c.272.021.543.053.81.093.583.106 1.117.254 1.538.44 6.638 2.927 8.07 10.052 1.748 15.642a4.125 4.125 0 01-5.822-.358c-1.51-1.706-1.3-4.184.357-5.822.858-.848 3.108-1.223 4.045-2.441 1.257-1.634 2.122-6.009-2.523-7.506L12.98.039z" fill="#00BCFF"/><path d="M13.528.096A6.187 6.187 0 0112 12.281a5.75 5.75 0 00-1.71.255c.147-.905.595-1.784 1.321-2.501.858-.848 3.108-1.223 4.045-2.441 1.27-1.651 2.14-6.104-2.676-7.554.184.014.367.033.548.056z" fill="#ECECEE"/>' },
|
|
@@ -84,7 +85,8 @@ const ModelPicker = (() => {
|
|
|
84
85
|
const el = document.createElement("span");
|
|
85
86
|
el.className = "sib-vendor-badge";
|
|
86
87
|
el.style.setProperty("--vendor-color", rule ? rule.color : "#7A8B99");
|
|
87
|
-
if (rule && rule.ink) el.style.
|
|
88
|
+
if (rule && rule.ink) el.style.setProperty("--vendor-ink", rule.ink);
|
|
89
|
+
if (rule && rule.tint) el.style.setProperty("--vendor-tint", rule.tint);
|
|
88
90
|
if (rule && rule.color === "#fff") el.classList.add("is-light");
|
|
89
91
|
if (rule && rule.brandSvg) {
|
|
90
92
|
el.classList.add("is-brand");
|
|
@@ -136,17 +136,44 @@ const Notify = (() => {
|
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
// ── Desktop notification ─────────────────────────────────────────────
|
|
139
|
-
|
|
139
|
+
const TITLE_NAME_MAX = 40;
|
|
140
|
+
|
|
141
|
+
// Session name (never message content) so the toast names the task that
|
|
142
|
+
// finished. The server passes the name along with `task_finished`; the local
|
|
143
|
+
// lookup is only a fallback for events that predate it. Truncated in code
|
|
144
|
+
// points so a long title cannot swallow the whole banner.
|
|
145
|
+
function _sessionLabel(sid, given) {
|
|
146
|
+
let name = typeof given === "string" ? given.trim() : "";
|
|
147
|
+
if (!name && sid && typeof Sessions !== "undefined" && typeof Sessions.find === "function") {
|
|
148
|
+
const session = Sessions.find(sid);
|
|
149
|
+
name = session && typeof session.name === "string" ? session.name.trim() : "";
|
|
150
|
+
}
|
|
151
|
+
if (!name) return "";
|
|
152
|
+
const chars = Array.from(name);
|
|
153
|
+
return chars.length > TITLE_NAME_MAX
|
|
154
|
+
? chars.slice(0, TITLE_NAME_MAX - 1).join("") + "…"
|
|
155
|
+
: name;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function _desktopTitle(awaiting, sid, sessionName) {
|
|
159
|
+
const name = _sessionLabel(sid, sessionName);
|
|
160
|
+
const named = awaiting
|
|
161
|
+
? "notify.desktop.awaiting.titleWithName"
|
|
162
|
+
: "notify.desktop.titleWithName";
|
|
163
|
+
const plain = awaiting ? "notify.desktop.awaiting.title" : "notify.desktop.title";
|
|
164
|
+
if (typeof I18n !== "undefined") return I18n.t(name ? named : plain, { name });
|
|
165
|
+
const base = awaiting ? "Waiting for your reply" : "Task complete";
|
|
166
|
+
return name ? `${base} · ${name}` : base;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function _notifyDesktop(sid, awaiting, sessionName) {
|
|
140
170
|
if (!_notificationsSupported()) return;
|
|
141
171
|
if (Notification.permission !== "granted") return;
|
|
142
172
|
|
|
143
|
-
//
|
|
144
|
-
//
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
const title = typeof I18n !== "undefined"
|
|
148
|
-
? I18n.t(titleKey)
|
|
149
|
-
: (awaiting ? "Waiting for your reply" : "Task complete");
|
|
173
|
+
// The body stays generic — it never quotes the prompt or the answer.
|
|
174
|
+
// Click focuses the window and navigates to the session.
|
|
175
|
+
const bodyKey = awaiting ? "notify.desktop.awaiting.body" : "notify.desktop.body";
|
|
176
|
+
const title = _desktopTitle(awaiting, sid, sessionName);
|
|
150
177
|
const body = typeof I18n !== "undefined"
|
|
151
178
|
? I18n.t(bodyKey)
|
|
152
179
|
: (awaiting ? "The agent asked you a question. Click to answer." : "A background task finished. Click to open it.");
|
|
@@ -194,11 +221,11 @@ const Notify = (() => {
|
|
|
194
221
|
// signal the server broadcasts to every client the moment an agent task
|
|
195
222
|
// completes. We only decide whether the user is looking at that session;
|
|
196
223
|
// the "did a task just finish" judgement lives on the backend.
|
|
197
|
-
function onTaskFinished(sid, awaiting) {
|
|
224
|
+
function onTaskFinished(sid, awaiting, sessionName) {
|
|
198
225
|
if (!enabled()) return;
|
|
199
226
|
if (!_userIsAway(sid)) return;
|
|
200
227
|
_play();
|
|
201
|
-
_notifyDesktop(sid, awaiting);
|
|
228
|
+
_notifyDesktop(sid, awaiting, sessionName);
|
|
202
229
|
}
|
|
203
230
|
|
|
204
231
|
// ── Toggle button UI ───────────────────────────────────────────────────
|
|
@@ -230,9 +257,9 @@ const Notify = (() => {
|
|
|
230
257
|
btn.classList.toggle("notify-on", on);
|
|
231
258
|
if (typeof I18n !== "undefined") {
|
|
232
259
|
const tip = I18n.t(_tooltipKey(on));
|
|
233
|
-
btn.
|
|
260
|
+
btn.setAttribute("data-tooltip", tip);
|
|
234
261
|
btn.setAttribute("aria-label", tip);
|
|
235
|
-
btn.setAttribute("data-i18n-
|
|
262
|
+
btn.setAttribute("data-i18n-tooltip", _tooltipKey(on));
|
|
236
263
|
}
|
|
237
264
|
}
|
|
238
265
|
|
|
@@ -164,7 +164,7 @@ const Onboard = (() => {
|
|
|
164
164
|
if (p.id === "openclacky") {
|
|
165
165
|
const nameSpan = document.createElement("span");
|
|
166
166
|
nameSpan.textContent = displayName;
|
|
167
|
-
opt.innerHTML = nameSpan.outerHTML + ` <span class="provider-badge-recommended">${I18n.t("provider.recommended")}</span>`;
|
|
167
|
+
opt.innerHTML = nameSpan.outerHTML + ` <span class="provider-badge-recommended" data-tooltip-pos="right" data-tooltip-wide data-tooltip="${I18n.t("provider.recommended.tooltip")}">${I18n.t("provider.recommended")}</span>`;
|
|
168
168
|
} else {
|
|
169
169
|
opt.textContent = displayName;
|
|
170
170
|
}
|
|
@@ -23,6 +23,10 @@
|
|
|
23
23
|
const OPEN_KEY = "clacky.aside.open";
|
|
24
24
|
const FULLSCREEN_KEY = "clacky.aside.fullscreen";
|
|
25
25
|
const MIN_W = 256;
|
|
26
|
+
// Narrower than this the chat column stops being readable — composer and
|
|
27
|
+
// message bubbles fold into a one-character-wide strip. Once the aside
|
|
28
|
+
// crosses the line it takes the whole workspace instead.
|
|
29
|
+
const CHAT_MIN_W = 300;
|
|
26
30
|
const maxW = () => Math.max(MIN_W, Math.round(window.innerWidth * 0.8));
|
|
27
31
|
// Matches the CSS breakpoint where the aside becomes a fixed overlay drawer.
|
|
28
32
|
const isNarrow = () => window.matchMedia("(max-width: 768px)").matches;
|
|
@@ -57,6 +61,19 @@
|
|
|
57
61
|
function setWidth(px) {
|
|
58
62
|
const aside = $("session-aside");
|
|
59
63
|
if (aside) aside.style.setProperty("--session-aside-width", px + "px");
|
|
64
|
+
syncChatCollapse();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// The aside wins the whole workspace as soon as it would leave the chat
|
|
68
|
+
// column below CHAT_MIN_W. Width itself stays driven by the drag value, so
|
|
69
|
+
// pulling the handle back past the threshold restores the split at once.
|
|
70
|
+
function syncChatCollapse() {
|
|
71
|
+
const panel = $("chat-panel");
|
|
72
|
+
if (!panel) return;
|
|
73
|
+
const panelWidth = panel.getBoundingClientRect().width;
|
|
74
|
+
const collapsed = !isNarrow() && isOpen() && !slotEmpty() &&
|
|
75
|
+
panelWidth > CHAT_MIN_W && panelWidth - currentWidth() < CHAT_MIN_W;
|
|
76
|
+
panel.classList.toggle("chat-collapsed", collapsed);
|
|
60
77
|
}
|
|
61
78
|
|
|
62
79
|
// Reconcile temporary requests centrally so nested panels can close in any
|
|
@@ -144,6 +161,7 @@
|
|
|
144
161
|
// A fullscreen class with an empty slot would show an empty column over
|
|
145
162
|
// the whole workspace (the fullscreen rule outranks the empty-slot one).
|
|
146
163
|
if (empty) setFullscreen(false);
|
|
164
|
+
syncChatCollapse();
|
|
147
165
|
}
|
|
148
166
|
|
|
149
167
|
function isOpen() {
|
|
@@ -214,12 +232,29 @@
|
|
|
214
232
|
}
|
|
215
233
|
}
|
|
216
234
|
|
|
235
|
+
function shortcutLabel() {
|
|
236
|
+
const uaData = navigator.userAgentData && navigator.userAgentData.platform;
|
|
237
|
+
const platform = (uaData || navigator.platform || "").toString();
|
|
238
|
+
return /mac/i.test(platform) ? "⌘L" : "Ctrl+L";
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Both hints carry the shortcut, so they are composed here rather than
|
|
242
|
+
// through data-i18n-tooltip (which would drop the suffix on a lang switch).
|
|
243
|
+
function applyAsideTitles() {
|
|
244
|
+
if (!window.Clacky || !Clacky.I18n) return;
|
|
245
|
+
const label = (key) => Clacky.I18n.t(key) + " (" + shortcutLabel() + ")";
|
|
246
|
+
const collapse = $("btn-aside-collapse");
|
|
247
|
+
if (collapse) collapse.setAttribute("data-tooltip", label("aside.collapse"));
|
|
248
|
+
const opener = $("btn-aside-open");
|
|
249
|
+
if (opener) opener.setAttribute("data-tooltip", label("aside.expand"));
|
|
250
|
+
}
|
|
251
|
+
|
|
217
252
|
function applyFullscreenState() {
|
|
218
253
|
const chatPanel = $("chat-panel");
|
|
219
254
|
if (chatPanel) chatPanel.classList.toggle("aside-fullscreen", isFullscreen());
|
|
220
255
|
const btn = $("btn-aside-fullscreen");
|
|
221
256
|
if (btn && window.Clacky && Clacky.I18n) {
|
|
222
|
-
btn.
|
|
257
|
+
btn.setAttribute("data-tooltip", Clacky.I18n.t(isFullscreen() ? "aside.exitFullscreen" : "aside.fullscreen"));
|
|
223
258
|
}
|
|
224
259
|
}
|
|
225
260
|
|
|
@@ -255,7 +290,7 @@
|
|
|
255
290
|
|
|
256
291
|
try {
|
|
257
292
|
const saved = parseFloat(localStorage.getItem(WIDTH_KEY));
|
|
258
|
-
if (saved >= MIN_W && saved <= maxW())
|
|
293
|
+
if (saved >= MIN_W && saved <= maxW()) setWidth(saved);
|
|
259
294
|
} catch (_e) { /* ignore */ }
|
|
260
295
|
|
|
261
296
|
let dragging = false;
|
|
@@ -277,7 +312,7 @@
|
|
|
277
312
|
if (!dragging) return;
|
|
278
313
|
const dx = startX - e.clientX;
|
|
279
314
|
const w = Math.min(maxW(), Math.max(MIN_W, startW + dx));
|
|
280
|
-
|
|
315
|
+
setWidth(w);
|
|
281
316
|
});
|
|
282
317
|
|
|
283
318
|
document.addEventListener("mouseup", () => {
|
|
@@ -320,6 +355,21 @@
|
|
|
320
355
|
if (opener) opener.addEventListener("click", () => setOpen(true));
|
|
321
356
|
if (overlay) overlay.addEventListener("click", () => setOpen(false));
|
|
322
357
|
if (fsBtn) fsBtn.addEventListener("click", () => setFullscreen(!isFullscreen()));
|
|
358
|
+
applyAsideTitles();
|
|
359
|
+
document.addEventListener("langchange", applyAsideTitles);
|
|
360
|
+
document.addEventListener("langchange", applyFullscreenState);
|
|
361
|
+
document.addEventListener("keydown", (e) => {
|
|
362
|
+
// ⌘L is the advertised shortcut; browsers keep it for the address bar,
|
|
363
|
+
// so ⌘\ stays as a working fallback wherever the keystroke is swallowed.
|
|
364
|
+
const isBackslash = e.key === "\\" || e.code === "Backslash";
|
|
365
|
+
const isL = e.key === "l" || e.key === "L" || e.code === "KeyL";
|
|
366
|
+
if (!isL && !isBackslash) return;
|
|
367
|
+
if (e.altKey || e.shiftKey) return;
|
|
368
|
+
if (!(e.metaKey || e.ctrlKey)) return;
|
|
369
|
+
if (slotEmpty()) return;
|
|
370
|
+
e.preventDefault();
|
|
371
|
+
setOpen(!isOpen());
|
|
372
|
+
});
|
|
323
373
|
document.addEventListener("keydown", (e) => {
|
|
324
374
|
if (e.key !== "Escape" || !isFullscreen()) return;
|
|
325
375
|
// Let overlay panels (settings / skills) consume Esc first.
|
|
@@ -343,6 +393,13 @@
|
|
|
343
393
|
requestAnimationFrame(() => { clampScheduled = false; clampWidth(); });
|
|
344
394
|
});
|
|
345
395
|
|
|
396
|
+
// Sidebar collapse, session switches and window resizes all change how
|
|
397
|
+
// much room the chat panel has without going through setWidth.
|
|
398
|
+
const chatPanel = $("chat-panel");
|
|
399
|
+
if (chatPanel && window.ResizeObserver) {
|
|
400
|
+
new ResizeObserver(() => syncChatCollapse()).observe(chatPanel);
|
|
401
|
+
}
|
|
402
|
+
|
|
346
403
|
// Re-evaluate opener visibility whenever the slot content changes (panels
|
|
347
404
|
// re-render on session / agent switch).
|
|
348
405
|
const slot = $("ext-slot-session-aside");
|
|
@@ -219,8 +219,8 @@ const BillingView = (() => {
|
|
|
219
219
|
</div>
|
|
220
220
|
`;
|
|
221
221
|
|
|
222
|
-
|
|
223
|
-
btn.addEventListener("click", (
|
|
222
|
+
container.querySelectorAll(".segmented-control__btn").forEach(btn => {
|
|
223
|
+
btn.addEventListener("click", () => Billing.setPeriod(btn.dataset.period));
|
|
224
224
|
});
|
|
225
225
|
|
|
226
226
|
const billingModelWrap = document.getElementById("billing-model-filter");
|
|
@@ -69,18 +69,31 @@ const ChannelsStore = (() => {
|
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
|
|
72
|
-
/** Toggle a channel's enabled flag; reload silently on success. */
|
|
73
|
-
async toggle(platform, desired) {
|
|
72
|
+
/** Toggle a channel instance's enabled flag; reload silently on success. */
|
|
73
|
+
async toggle(platform, desired, instanceId) {
|
|
74
|
+
const body = { enabled: desired };
|
|
75
|
+
if (instanceId) body.instance_id = instanceId;
|
|
74
76
|
const res = await fetch(`/api/channels/${encodeURIComponent(platform)}/enabled`, {
|
|
75
77
|
method: "PATCH",
|
|
76
78
|
headers: { "Content-Type": "application/json" },
|
|
77
|
-
body: JSON.stringify(
|
|
79
|
+
body: JSON.stringify(body),
|
|
78
80
|
});
|
|
79
81
|
const data = await res.json();
|
|
80
82
|
if (!res.ok || !data.ok) throw new Error(data.error || "toggle failed");
|
|
81
83
|
await Channels.load({ silent: true });
|
|
82
84
|
},
|
|
83
85
|
|
|
86
|
+
/** Delete a channel instance; reload silently on success. */
|
|
87
|
+
async remove(platform, instanceId) {
|
|
88
|
+
const id = instanceId || "default";
|
|
89
|
+
const res = await fetch(`/api/channels/${encodeURIComponent(platform)}/instances/${encodeURIComponent(id)}`, {
|
|
90
|
+
method: "DELETE",
|
|
91
|
+
});
|
|
92
|
+
const data = await res.json();
|
|
93
|
+
if (!res.ok || !data.ok) throw new Error(data.error || "delete failed");
|
|
94
|
+
await Channels.load({ silent: true });
|
|
95
|
+
},
|
|
96
|
+
|
|
84
97
|
/** Toggle the global status messages flag; reload silently on success. */
|
|
85
98
|
async setStatusMessages(desired) {
|
|
86
99
|
const res = await fetch("/api/channels/status_messages", {
|
|
@@ -118,10 +131,12 @@ const ChannelsStore = (() => {
|
|
|
118
131
|
},
|
|
119
132
|
|
|
120
133
|
/** Start a QQ QR/link bind task; returns { task_id, connect_url }. */
|
|
121
|
-
async qrStart() {
|
|
134
|
+
async qrStart(instanceId) {
|
|
135
|
+
const body = instanceId ? { instance_id: instanceId } : {};
|
|
122
136
|
const res = await fetch("/api/channels/qq/qr/start", {
|
|
123
137
|
method: "POST",
|
|
124
138
|
headers: { "Content-Type": "application/json" },
|
|
139
|
+
body: JSON.stringify(body),
|
|
125
140
|
});
|
|
126
141
|
const data = await res.json();
|
|
127
142
|
if (!res.ok || !data.ok) throw new Error(data.error || "failed to start QQ binding");
|
|
@@ -77,6 +77,8 @@ const ChannelsView = (() => {
|
|
|
77
77
|
const MENU_ICONS = {
|
|
78
78
|
test: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><polyline points="22 4 12 14.01 9 11.01"/></svg>',
|
|
79
79
|
setup: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>',
|
|
80
|
+
add: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="M8 12h8M12 8v8"/></svg>',
|
|
81
|
+
delete: '<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M10 11v6M14 11v6"/><path d="M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/></svg>',
|
|
80
82
|
};
|
|
81
83
|
const CUSTOM_DEV_SVG = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/></svg>';
|
|
82
84
|
|
|
@@ -96,7 +98,12 @@ const ChannelsView = (() => {
|
|
|
96
98
|
|
|
97
99
|
Object.keys(meta).forEach(pid => {
|
|
98
100
|
const serverData = channels.find(c => c.platform == pid) || {};
|
|
99
|
-
(serverData.
|
|
101
|
+
const instances = Array.isArray(serverData.instances) ? serverData.instances : [];
|
|
102
|
+
if (instances.length === 0) {
|
|
103
|
+
unconfigured.push(_renderRow(pid, serverData, meta[pid], 0));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
instances.forEach((inst, idx) => configured.push(_renderRow(pid, inst, meta[pid], idx)));
|
|
100
107
|
});
|
|
101
108
|
unconfigured.push(_renderCustomDevRow());
|
|
102
109
|
|
|
@@ -124,24 +131,34 @@ const ChannelsView = (() => {
|
|
|
124
131
|
return group;
|
|
125
132
|
}
|
|
126
133
|
|
|
127
|
-
function _renderRow(platform, data, meta) {
|
|
134
|
+
function _renderRow(platform, data, meta, index = 0) {
|
|
128
135
|
const hasConfig = !!data.has_config;
|
|
136
|
+
// One row per configured instance. The first row keeps the historical DOM
|
|
137
|
+
// ids so existing selectors/tests keep working.
|
|
138
|
+
const instanceId = hasConfig ? (data.id || "default") : null;
|
|
139
|
+
const suffix = hasConfig && index > 0 ? `-${instanceId}` : "";
|
|
129
140
|
const row = document.createElement("div");
|
|
130
141
|
row.className = "channel-row";
|
|
131
|
-
row.id = `channel-card-${platform}`;
|
|
142
|
+
row.id = `channel-card-${platform}${suffix}`;
|
|
132
143
|
|
|
144
|
+
const instanceName = hasConfig ? String(data.name || "").trim() : "";
|
|
145
|
+
const title = instanceName || (index > 0 ? `${meta.name} (${instanceId})` : meta.name);
|
|
146
|
+
|
|
147
|
+
// Rows survive a language switch, so the tooltip also carries the lookup
|
|
148
|
+
// key that I18n.applyAll() rewrites in place.
|
|
133
149
|
const action = hasConfig
|
|
134
|
-
? `${_toggleHtml(platform, !!data.enabled)}
|
|
150
|
+
? `${_toggleHtml(platform, !!data.enabled, instanceId, suffix)}
|
|
135
151
|
<button type="button" class="channel-row-btn" data-channel-more="${_esc(platform)}"
|
|
152
|
+
data-channel-instance="${_esc(instanceId)}"
|
|
136
153
|
title="${_esc(I18n.t("channels.btn.more"))}" aria-haspopup="menu" aria-expanded="false">${MORE_SVG}</button>`
|
|
137
154
|
: `<button type="button" class="channel-row-btn" data-channel-setup="${_esc(platform)}"
|
|
138
|
-
|
|
155
|
+
data-tooltip="${_esc(I18n.t("channels.btn.setup"))}" data-i18n-tooltip="channels.btn.setup">${PLUS_SVG}</button>`;
|
|
139
156
|
|
|
140
157
|
row.innerHTML = `
|
|
141
158
|
<span class="channel-logo ${_esc(meta.logoClass)}">${meta.logo}</span>
|
|
142
159
|
<div class="channel-row-text">
|
|
143
160
|
<div class="channel-row-name">
|
|
144
|
-
<span class="channel-row-title">${_esc(
|
|
161
|
+
<span class="channel-row-title">${_esc(title)}</span>
|
|
145
162
|
${hasConfig ? _statusBadge(!!data.enabled, !!data.running) : ""}
|
|
146
163
|
</div>
|
|
147
164
|
<div class="channel-row-desc" title="${_esc(meta.desc)}">${_esc(meta.desc)}</div>
|
|
@@ -149,14 +166,14 @@ const ChannelsView = (() => {
|
|
|
149
166
|
<div class="channel-row-action">${action}</div>
|
|
150
167
|
`;
|
|
151
168
|
|
|
152
|
-
row.querySelector(`#toggle-${platform}`)?.addEventListener("change", (ev) => _onToggle(platform, ev.target));
|
|
169
|
+
row.querySelector(`#toggle-${platform}${suffix}`)?.addEventListener("change", (ev) => _onToggle(platform, instanceId, ev.target));
|
|
153
170
|
const setupBtn = row.querySelector("[data-channel-setup]");
|
|
154
171
|
setupBtn?.addEventListener("click", () => {
|
|
155
172
|
if (platform === "qq") _openQrBind();
|
|
156
173
|
else _openSetup(platform);
|
|
157
174
|
});
|
|
158
175
|
const more = row.querySelector("[data-channel-more]");
|
|
159
|
-
more?.addEventListener("click", (ev) => { ev.stopPropagation(); _toggleMenu(more, platform); });
|
|
176
|
+
more?.addEventListener("click", (ev) => { ev.stopPropagation(); _toggleMenu(more, platform, instanceId); });
|
|
160
177
|
return row;
|
|
161
178
|
}
|
|
162
179
|
|
|
@@ -177,7 +194,8 @@ const ChannelsView = (() => {
|
|
|
177
194
|
<div class="channel-row-desc" title="${_esc(desc)}">${_esc(desc)}</div>
|
|
178
195
|
</div>
|
|
179
196
|
<div class="channel-row-action">
|
|
180
|
-
<button type="button" class="channel-row-btn" id="btn-custom-dev-guide"
|
|
197
|
+
<button type="button" class="channel-row-btn" id="btn-custom-dev-guide"
|
|
198
|
+
data-tooltip="${_esc(I18n.t("channels.customDev.btn"))}" data-i18n-tooltip="channels.customDev.btn">${PLUS_SVG}</button>
|
|
181
199
|
</div>
|
|
182
200
|
`;
|
|
183
201
|
row.querySelector("#btn-custom-dev-guide").addEventListener("click", () => {
|
|
@@ -207,11 +225,11 @@ const ChannelsView = (() => {
|
|
|
207
225
|
return row;
|
|
208
226
|
}
|
|
209
227
|
|
|
210
|
-
function _toggleHtml(platform, enabled) {
|
|
228
|
+
function _toggleHtml(platform, enabled, instanceId, suffix = "") {
|
|
211
229
|
const aria = I18n.t(enabled ? "channels.toggle.on" : "channels.toggle.off");
|
|
212
230
|
return `
|
|
213
231
|
<label class="toggle-switch" title="${_esc(aria)}">
|
|
214
|
-
<input type="checkbox" id="toggle-${_esc(platform)}" ${enabled ? "checked" : ""} aria-label="${_esc(aria)}">
|
|
232
|
+
<input type="checkbox" id="toggle-${_esc(platform)}${_esc(suffix)}" ${enabled ? "checked" : ""} aria-label="${_esc(aria)}" data-instance-id="${_esc(instanceId || "")}">
|
|
215
233
|
<span class="toggle-slider"></span>
|
|
216
234
|
</label>
|
|
217
235
|
`;
|
|
@@ -219,7 +237,7 @@ const ChannelsView = (() => {
|
|
|
219
237
|
|
|
220
238
|
// One shared floating menu: rows are rebuilt on every store change, so a
|
|
221
239
|
// menu nested inside a row would vanish mid-interaction.
|
|
222
|
-
function _toggleMenu(btn, platform) {
|
|
240
|
+
function _toggleMenu(btn, platform, instanceId) {
|
|
223
241
|
if (_menuBtn === btn && _menuEl && !_menuEl.hidden) { _closeMenu(); return; }
|
|
224
242
|
_closeMenu();
|
|
225
243
|
|
|
@@ -230,9 +248,13 @@ const ChannelsView = (() => {
|
|
|
230
248
|
_menuEl.addEventListener("click", _onMenuClick);
|
|
231
249
|
document.body.appendChild(_menuEl);
|
|
232
250
|
}
|
|
233
|
-
const item = (kind, label) =>
|
|
234
|
-
`<button type="button" role="menuitem" class="ext-row-menu-item" data-channel-menu="${kind}" data-channel-platform="${_esc(platform)}">${MENU_ICONS[kind]}<span>${_esc(label)}</span></button>`;
|
|
235
|
-
_menuEl.innerHTML =
|
|
251
|
+
const item = (kind, label, danger = false) =>
|
|
252
|
+
`<button type="button" role="menuitem" class="ext-row-menu-item${danger ? " ext-row-menu-danger" : ""}" data-channel-menu="${kind}" data-channel-platform="${_esc(platform)}" data-channel-instance="${_esc(instanceId || "")}">${MENU_ICONS[kind]}<span>${_esc(label)}</span></button>`;
|
|
253
|
+
_menuEl.innerHTML =
|
|
254
|
+
item("test", I18n.t("channels.btn.test")) +
|
|
255
|
+
item("setup", I18n.t("channels.btn.reconfigure")) +
|
|
256
|
+
item("add", I18n.t("channels.btn.addInstance")) +
|
|
257
|
+
item("delete", I18n.t("channels.btn.delete"), true);
|
|
236
258
|
_menuEl.hidden = false;
|
|
237
259
|
_menuBtn = btn;
|
|
238
260
|
btn.setAttribute("aria-expanded", "true");
|
|
@@ -256,19 +278,39 @@ const ChannelsView = (() => {
|
|
|
256
278
|
function _onMenuClick(e) {
|
|
257
279
|
const item = e.target.closest("[data-channel-menu]");
|
|
258
280
|
if (!item) return;
|
|
259
|
-
const platform
|
|
260
|
-
const
|
|
281
|
+
const platform = item.getAttribute("data-channel-platform");
|
|
282
|
+
const instanceId = item.getAttribute("data-channel-instance");
|
|
283
|
+
const kind = item.getAttribute("data-channel-menu");
|
|
261
284
|
_closeMenu();
|
|
262
285
|
if (kind === "test") _runTest(platform);
|
|
263
|
-
else if (
|
|
264
|
-
else
|
|
286
|
+
else if (kind === "add") _openAddInstance(platform);
|
|
287
|
+
else if (kind === "delete") _onDeleteInstance(platform, instanceId);
|
|
288
|
+
else if (platform === "qq") _openQrBind(instanceId);
|
|
289
|
+
else _openSetup(platform, instanceId);
|
|
265
290
|
}
|
|
266
291
|
|
|
267
|
-
async function
|
|
292
|
+
async function _onDeleteInstance(platform, instanceId) {
|
|
293
|
+
const channel = ChannelsStore.state.channels.find(c => c.platform === platform);
|
|
294
|
+
const inst = (channel?.instances || []).find(i => i.id === instanceId);
|
|
295
|
+
const meta = PLATFORM_META()[platform];
|
|
296
|
+
const label = String(inst?.name || "").trim() || `${meta.name} (${instanceId || "default"})`;
|
|
297
|
+
|
|
298
|
+
const confirmed = await Modal.confirm(I18n.t("channels.confirm.deleteInstance", { name: label }));
|
|
299
|
+
if (!confirmed) return;
|
|
300
|
+
|
|
301
|
+
try {
|
|
302
|
+
await Channels.remove(platform, instanceId);
|
|
303
|
+
Modal.toast(I18n.t("channels.toast.deleted", { name: label }), "success");
|
|
304
|
+
} catch (e) {
|
|
305
|
+
Modal.toast(I18n.t("channels.toast.deleteFail", { msg: e.message }), "error");
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
async function _onToggle(platform, instanceId, checkbox) {
|
|
268
310
|
const desired = checkbox.checked;
|
|
269
311
|
checkbox.disabled = true;
|
|
270
312
|
try {
|
|
271
|
-
await Channels.toggle(platform, desired);
|
|
313
|
+
await Channels.toggle(platform, desired, instanceId);
|
|
272
314
|
} catch (e) {
|
|
273
315
|
checkbox.checked = !desired;
|
|
274
316
|
Modal.toast("Error: " + e.message, "error");
|
|
@@ -321,9 +363,31 @@ const ChannelsView = (() => {
|
|
|
321
363
|
return Channels.runTest(meta.testCmd, `Channel E2E Test — ${meta.name}`);
|
|
322
364
|
}
|
|
323
365
|
|
|
324
|
-
function _openSetup(platform) {
|
|
366
|
+
function _openSetup(platform, instanceId) {
|
|
325
367
|
const meta = PLATFORM_META()[platform];
|
|
326
|
-
|
|
368
|
+
const extra = instanceId && instanceId !== "default"
|
|
369
|
+
? `\n\nUpdate only the instance with instance_id "${instanceId}". Keep other instances unchanged.`
|
|
370
|
+
: "";
|
|
371
|
+
return Channels.openSetup(`${meta.setupCmd}${extra}`, `Channel Setup — ${meta.name}`);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function _openAddInstance(platform) {
|
|
375
|
+
const meta = PLATFORM_META()[platform];
|
|
376
|
+
if (platform === "qq") return _openQrBind(_nextQqInstanceId());
|
|
377
|
+
return Channels.sendToAgent(
|
|
378
|
+
I18n.t("channels.prompt.addInstance", { platform: meta.name, cmd: meta.setupCmd }),
|
|
379
|
+
`Channel Setup — ${meta.name}`
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// Pick a free client-side id for a new QQ instance; the QR flow has no agent
|
|
384
|
+
// step to ask the user for a name first.
|
|
385
|
+
function _nextQqInstanceId() {
|
|
386
|
+
const serverData = ChannelsStore.state.channels.find(c => c.platform === "qq") || {};
|
|
387
|
+
const used = (serverData.instances || []).map(i => i.id);
|
|
388
|
+
let n = used.length + 1;
|
|
389
|
+
while (used.includes(`qq-${n}`)) n += 1;
|
|
390
|
+
return `qq-${n}`;
|
|
327
391
|
}
|
|
328
392
|
|
|
329
393
|
// ── QQ one-click bind (official QR page) ─────────────────────────────────
|
|
@@ -338,17 +402,17 @@ const ChannelsView = (() => {
|
|
|
338
402
|
_qrAbort = true;
|
|
339
403
|
}
|
|
340
404
|
|
|
341
|
-
async function _startQrTask() {
|
|
405
|
+
async function _startQrTask(instanceId) {
|
|
342
406
|
_stopQrPolling();
|
|
343
|
-
const task = await Channels.qrStart();
|
|
407
|
+
const task = await Channels.qrStart(instanceId);
|
|
344
408
|
_qrAbort = false;
|
|
345
409
|
return task;
|
|
346
410
|
}
|
|
347
411
|
|
|
348
|
-
async function _openQrBind() {
|
|
412
|
+
async function _openQrBind(instanceId) {
|
|
349
413
|
let task;
|
|
350
414
|
try {
|
|
351
|
-
task = await _startQrTask();
|
|
415
|
+
task = await _startQrTask(instanceId);
|
|
352
416
|
} catch (e) {
|
|
353
417
|
Modal.toast("Error: " + e.message, "error");
|
|
354
418
|
return;
|
|
@@ -418,7 +482,7 @@ const ChannelsView = (() => {
|
|
|
418
482
|
const btn = $("qq-qr-refresh");
|
|
419
483
|
btn.disabled = true;
|
|
420
484
|
try {
|
|
421
|
-
task = await _startQrTask();
|
|
485
|
+
task = await _startQrTask(instanceId);
|
|
422
486
|
} catch (e) {
|
|
423
487
|
Modal.toast("Error: " + e.message, "error");
|
|
424
488
|
btn.disabled = false;
|