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
data/lib/clacky/web/settings.js
CHANGED
|
@@ -12,6 +12,7 @@ const Settings = (() => {
|
|
|
12
12
|
// backend's runtime inference decide.
|
|
13
13
|
let _modalSelectedProviderId = null;
|
|
14
14
|
let _modalProviderIsCustom = false;
|
|
15
|
+
let _noVisionTouched = false; // user clicked the no-vision box; stop auto-filling it
|
|
15
16
|
let _apiFormatSelect = null;
|
|
16
17
|
let _providerSelect = null;
|
|
17
18
|
let _providerFilterSelect = null;
|
|
@@ -30,6 +31,9 @@ const Settings = (() => {
|
|
|
30
31
|
// Last successfully activated tab. Dynamic extension tabs may be rebuilt
|
|
31
32
|
// while Settings is hidden, so the DOM alone cannot retain this state.
|
|
32
33
|
let _activeTab = "models";
|
|
34
|
+
// Masked web-search keys per provider. Module-level because the provider
|
|
35
|
+
// select and save handlers outlive the initializer that first bound them.
|
|
36
|
+
let _searchKeysMasked = {};
|
|
33
37
|
|
|
34
38
|
// ── Public API ──────────────────────────────────────────────────────────────
|
|
35
39
|
|
|
@@ -187,6 +191,37 @@ const Settings = (() => {
|
|
|
187
191
|
if (noVision) noVision.style.display = _modalProviderIsCustom ? "" : "none";
|
|
188
192
|
}
|
|
189
193
|
|
|
194
|
+
// Custom endpoints only: pre-fill "no vision" from what the presets declare
|
|
195
|
+
// for the same model name. Unknown or conflicting names leave the box alone.
|
|
196
|
+
function _syncNoVisionFromModel() {
|
|
197
|
+
if (!_modalProviderIsCustom || _noVisionTouched) return;
|
|
198
|
+
const vision = _knownVision(document.getElementById("model-modal-model").value);
|
|
199
|
+
if (vision !== null) document.getElementById("model-modal-no-vision").checked = !vision;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// "Z-AI/GLM_5.3" → "z-ai-glm-5-3", so relay prefixes/suffixes become plain segments.
|
|
203
|
+
function _modelKey(name) {
|
|
204
|
+
return String(name || "").trim().toLowerCase().replace(/[^a-z0-9]+/g, "-");
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// The longest known name found as whole segments wins: "x-glm-5.3-flash" is glm-5.3-flash, not glm-5.3.
|
|
208
|
+
function _knownVision(name) {
|
|
209
|
+
const key = _modelKey(name);
|
|
210
|
+
if (!key) return null;
|
|
211
|
+
const padded = "-" + key + "-";
|
|
212
|
+
let best = 0;
|
|
213
|
+
let seen = new Set();
|
|
214
|
+
_providers.forEach(p => {
|
|
215
|
+
Object.entries(p.model_capabilities || {}).forEach(([m, caps]) => {
|
|
216
|
+
const known = _modelKey(m);
|
|
217
|
+
if (typeof caps.vision !== "boolean" || known.length < best || !padded.includes("-" + known + "-")) return;
|
|
218
|
+
if (known.length > best) { best = known.length; seen = new Set(); }
|
|
219
|
+
seen.add(caps.vision);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
return seen.size === 1 ? seen.values().next().value : null;
|
|
223
|
+
}
|
|
224
|
+
|
|
190
225
|
// Preset providers auto-fill Base URL and Model, which leaves users unsure
|
|
191
226
|
// whether a key alone is enough. Only claim that when it is actually true:
|
|
192
227
|
// a custom endpoint also needs a Base URL and model, and a saved key (edit /
|
|
@@ -272,16 +307,20 @@ const Settings = (() => {
|
|
|
272
307
|
|
|
273
308
|
card.innerHTML = `
|
|
274
309
|
<div class="model-card-grid-info">
|
|
275
|
-
<div class="model-card-grid-
|
|
276
|
-
<
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
310
|
+
<div class="model-card-grid-head">
|
|
311
|
+
<div class="model-card-grid-head-text">
|
|
312
|
+
<div class="model-card-grid-name-row">
|
|
313
|
+
<span class="model-card-grid-name">${_esc(displayName)}</span>
|
|
314
|
+
${isDefault ? `<span class="badge badge-default">${I18n.t("settings.models.badge.default")}</span>` : ""}
|
|
315
|
+
${isLite ? `<span class="badge badge-lite">${I18n.t("settings.models.badge.lite")}</span>` : ""}
|
|
316
|
+
</div>
|
|
317
|
+
<div class="model-card-grid-provider">${_esc(providerName)}</div>
|
|
318
|
+
</div>
|
|
319
|
+
${!isDefault ? `<button class="btn-card-grid-action btn-card-grid-action-primary" data-index="${index}" data-action="default">
|
|
280
320
|
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/></svg>
|
|
281
321
|
<span>${I18n.t("settings.models.btn.setDefault")}</span>
|
|
282
322
|
</button>` : ""}
|
|
283
323
|
</div>
|
|
284
|
-
<div class="model-card-grid-provider">${_esc(providerName)}</div>
|
|
285
324
|
${model.api_key_masked ? `<div class="model-card-grid-model">${_esc(model.api_key_masked)}</div>` : ""}
|
|
286
325
|
${remark ? `<div class="model-card-grid-remark" title="${_esc(remark)}">
|
|
287
326
|
<span class="model-card-grid-remark-label">${I18n.t("settings.models.field.remark")}</span>
|
|
@@ -320,6 +359,7 @@ const Settings = (() => {
|
|
|
320
359
|
</div>
|
|
321
360
|
`;
|
|
322
361
|
|
|
362
|
+
card.querySelector(".model-card-grid-head").prepend(ModelPicker.vendorBadge(displayName));
|
|
323
363
|
container.appendChild(card);
|
|
324
364
|
_bindCompactCardEvents(card, index);
|
|
325
365
|
}
|
|
@@ -341,6 +381,23 @@ const Settings = (() => {
|
|
|
341
381
|
|
|
342
382
|
// ── Modal Functions ────────────────────────────────────────────────────────
|
|
343
383
|
|
|
384
|
+
// "Get API Key" link follows the currently resolved provider only; it must
|
|
385
|
+
// be re-synced on every modal open, or it leaks from the previous session.
|
|
386
|
+
function _syncApikeyLink() {
|
|
387
|
+
const link = document.getElementById("model-modal-apikey-link");
|
|
388
|
+
if (!link) return;
|
|
389
|
+
const preset = _modalSelectedProviderId
|
|
390
|
+
? _providers.find(p => p.id === _modalSelectedProviderId)
|
|
391
|
+
: null;
|
|
392
|
+
if (preset && preset.website_url) {
|
|
393
|
+
link.href = preset.website_url;
|
|
394
|
+
link.style.display = "";
|
|
395
|
+
} else {
|
|
396
|
+
link.removeAttribute("href");
|
|
397
|
+
link.style.display = "none";
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
|
|
344
401
|
function _openModal(index = -1) {
|
|
345
402
|
const modal = document.getElementById("model-edit-modal");
|
|
346
403
|
const titleEl = document.getElementById("model-modal-title");
|
|
@@ -350,6 +407,7 @@ const Settings = (() => {
|
|
|
350
407
|
document.getElementById("model-modal-source-id").value = "";
|
|
351
408
|
// Drop any model list fetched for a previously opened model/endpoint.
|
|
352
409
|
_modalRemoteModels = null;
|
|
410
|
+
_noVisionTouched = false;
|
|
353
411
|
|
|
354
412
|
// Populate provider dropdown
|
|
355
413
|
_populateModalProviderDropdown();
|
|
@@ -393,6 +451,7 @@ const Settings = (() => {
|
|
|
393
451
|
noVision.checked = !!(model.capabilities && model.capabilities.vision === false);
|
|
394
452
|
_syncRemarkField();
|
|
395
453
|
_syncApikeyHint();
|
|
454
|
+
_syncApikeyLink();
|
|
396
455
|
} else {
|
|
397
456
|
// Add mode
|
|
398
457
|
titleEl.textContent = I18n.t("settings.models.modal.add");
|
|
@@ -416,6 +475,7 @@ const Settings = (() => {
|
|
|
416
475
|
_syncApiFormatVisibility();
|
|
417
476
|
_syncRemarkField();
|
|
418
477
|
_syncApikeyHint();
|
|
478
|
+
_syncApikeyLink();
|
|
419
479
|
const providerValue = document.getElementById("model-modal-provider-value");
|
|
420
480
|
providerValue.textContent = I18n.t("settings.models.placeholder.provider");
|
|
421
481
|
providerValue.classList.add("placeholder");
|
|
@@ -485,6 +545,7 @@ const Settings = (() => {
|
|
|
485
545
|
}
|
|
486
546
|
_syncRemarkField();
|
|
487
547
|
_syncApikeyHint();
|
|
548
|
+
_syncApikeyLink();
|
|
488
549
|
}
|
|
489
550
|
|
|
490
551
|
// API Format only applies to custom providers: preset routing is owned by
|
|
@@ -503,7 +564,7 @@ const Settings = (() => {
|
|
|
503
564
|
dropdown.innerHTML = `
|
|
504
565
|
<div class="custom-select-list">
|
|
505
566
|
<div class="custom-select-option" data-value="">${I18n.t("settings.models.placeholder.provider")}</div>
|
|
506
|
-
${_providers.map(p => { const dn = _providerDisplayName(p); return `<div class="custom-select-option" data-value="${p.id}" data-label="${_esc(dn)}">${_esc(dn)}${p.id === "openclacky" ? ` <span class="provider-badge-recommended">${I18n.t("provider.recommended")}</span>` : ""}</div>`; }).join("")}
|
|
567
|
+
${_providers.map(p => { const dn = _providerDisplayName(p); return `<div class="custom-select-option" data-value="${p.id}" data-label="${_esc(dn)}">${_esc(dn)}${p.id === "openclacky" ? ` <span class="provider-badge-recommended" data-tooltip-pos="right" data-tooltip-wide data-tooltip="${_esc(I18n.t("provider.recommended.tooltip"))}">${I18n.t("provider.recommended")}</span>` : ""}</div>`; }).join("")}
|
|
507
568
|
</div>
|
|
508
569
|
<div class="custom-select-option custom-select-option-custom" data-value="custom" data-label="${_esc(I18n.t("settings.models.custom"))}">
|
|
509
570
|
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20h9"/><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"/></svg>
|
|
@@ -596,10 +657,10 @@ const Settings = (() => {
|
|
|
596
657
|
const payload = { model, base_url, anthropic_format, api_format, provider_id: _modalProviderIsCustom ? "custom" : (_modalSelectedProviderId || null) };
|
|
597
658
|
payload.remark = document.getElementById("model-modal-remark").value.trim();
|
|
598
659
|
// Vision override only applies to custom (non-preset) providers — preset
|
|
599
|
-
// capability tables live server-side.
|
|
600
|
-
//
|
|
660
|
+
// capability tables live server-side. The box is only hidden for presets,
|
|
661
|
+
// so its stale state must not leak; {} clears any previously-saved override.
|
|
601
662
|
const noVision = document.getElementById("model-modal-no-vision").checked;
|
|
602
|
-
payload.capabilities = noVision ? { vision: false } : {};
|
|
663
|
+
payload.capabilities = (_modalProviderIsCustom && noVision) ? { vision: false } : {};
|
|
603
664
|
const setDefault = document.getElementById("model-modal-set-default").checked;
|
|
604
665
|
payload.type = setDefault ? "default" : null;
|
|
605
666
|
if (setDefault) {
|
|
@@ -708,6 +769,7 @@ const Settings = (() => {
|
|
|
708
769
|
_syncApiFormatVisibility();
|
|
709
770
|
_syncRemarkField();
|
|
710
771
|
_syncApikeyHint();
|
|
772
|
+
_syncApikeyLink();
|
|
711
773
|
|
|
712
774
|
// Show/hide promo hint
|
|
713
775
|
const promoHint = document.getElementById("model-modal-promo-hint");
|
|
@@ -724,14 +786,6 @@ const Settings = (() => {
|
|
|
724
786
|
document.getElementById("model-modal-model").value = preset.default_model || "";
|
|
725
787
|
document.getElementById("model-modal-baseurl").value = preset.base_url || "";
|
|
726
788
|
|
|
727
|
-
const apikeyLink = document.getElementById("model-modal-apikey-link");
|
|
728
|
-
if (preset.website_url) {
|
|
729
|
-
apikeyLink.href = preset.website_url;
|
|
730
|
-
apikeyLink.style.display = "";
|
|
731
|
-
} else {
|
|
732
|
-
apikeyLink.style.display = "none";
|
|
733
|
-
}
|
|
734
|
-
|
|
735
789
|
// Update model dropdown with provider's models
|
|
736
790
|
setTimeout(() => _updateModalModelDropdown(), 0);
|
|
737
791
|
}
|
|
@@ -740,7 +794,6 @@ const Settings = (() => {
|
|
|
740
794
|
// clear leftover model/base_url so stale values never survive.
|
|
741
795
|
document.getElementById("model-modal-model").value = "";
|
|
742
796
|
document.getElementById("model-modal-baseurl").value = "";
|
|
743
|
-
document.getElementById("model-modal-apikey-link").style.display = "none";
|
|
744
797
|
setTimeout(() => _updateModalModelDropdown(), 0);
|
|
745
798
|
}
|
|
746
799
|
}
|
|
@@ -847,6 +900,14 @@ const Settings = (() => {
|
|
|
847
900
|
});
|
|
848
901
|
|
|
849
902
|
document.getElementById("model-modal-apikey").addEventListener("input", _syncApikeyHint);
|
|
903
|
+
modelInput.addEventListener("change", _syncNoVisionFromModel);
|
|
904
|
+
// pointerdown fires before the model input blurs, so a click straight from
|
|
905
|
+
// the model field onto the box is not overridden by the change handler.
|
|
906
|
+
const noVisionField = document.getElementById("model-modal-no-vision-field");
|
|
907
|
+
noVisionField.addEventListener("pointerdown", () => { _noVisionTouched = true; });
|
|
908
|
+
document.getElementById("model-modal-no-vision").addEventListener("change", () => {
|
|
909
|
+
_noVisionTouched = true;
|
|
910
|
+
});
|
|
850
911
|
|
|
851
912
|
// Close dropdowns on outside click
|
|
852
913
|
document.addEventListener("mousedown", (e) => {
|
|
@@ -914,6 +975,7 @@ const Settings = (() => {
|
|
|
914
975
|
opt.addEventListener("click", (e) => {
|
|
915
976
|
e.stopPropagation();
|
|
916
977
|
modelInput.value = opt.dataset.value;
|
|
978
|
+
_syncNoVisionFromModel();
|
|
917
979
|
modelDropdown.style.display = "none";
|
|
918
980
|
});
|
|
919
981
|
});
|
|
@@ -1069,8 +1131,12 @@ const Settings = (() => {
|
|
|
1069
1131
|
I18n.t("provider.promo.openclacky.2"),
|
|
1070
1132
|
I18n.t("provider.promo.openclacky.3"),
|
|
1071
1133
|
];
|
|
1072
|
-
const
|
|
1073
|
-
const
|
|
1134
|
+
const oc = _providers.find(p => p.id === "openclacky");
|
|
1135
|
+
const url = (oc && oc.website_url) || "https://www.openclacky.com/llm_keys";
|
|
1136
|
+
const arrow = `<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12h14"/><path d="M13 6l6 6-6 6"/></svg>`;
|
|
1137
|
+
const link = `<a class="promo-link" href="${_esc(url)}" target="_blank" rel="noopener">${I18n.t("settings.media.promo.btn")}${arrow}</a>`;
|
|
1138
|
+
const title = `<div class="promo-head"><span class="promo-title">${I18n.t("provider.promo.openclacky.title")}</span>${link}</div>`;
|
|
1139
|
+
const body = items.map(s => `<div class="promo-item"><span class="promo-dot" aria-hidden="true"></span><span>${s}</span></div>`).join("");
|
|
1074
1140
|
promoHint.innerHTML = `<div class="promo-inner">${title}${body}</div>`;
|
|
1075
1141
|
promoHint.classList.add("visible");
|
|
1076
1142
|
}
|
|
@@ -1788,7 +1854,10 @@ const Settings = (() => {
|
|
|
1788
1854
|
select = CustomSelect.init({
|
|
1789
1855
|
trigger: trigger,
|
|
1790
1856
|
dropdown: dropdown,
|
|
1791
|
-
onSelect: function () {
|
|
1857
|
+
onSelect: function (value) {
|
|
1858
|
+
if (keyInput) keyInput.value = _searchKeysMasked[value] || "";
|
|
1859
|
+
_syncKeyVisibility();
|
|
1860
|
+
}
|
|
1792
1861
|
});
|
|
1793
1862
|
}
|
|
1794
1863
|
|
|
@@ -1861,8 +1930,9 @@ const Settings = (() => {
|
|
|
1861
1930
|
`<div class="custom-select-option" data-value="">${I18n.t("settings.search.builtin")}</div>` +
|
|
1862
1931
|
deepseekRow +
|
|
1863
1932
|
rows;
|
|
1933
|
+
_searchKeysMasked = data.keys_masked || {};
|
|
1864
1934
|
if (select) select.setValue(data.provider || "");
|
|
1865
|
-
keyInput.value = data.
|
|
1935
|
+
keyInput.value = _searchKeysMasked[data.provider] || "";
|
|
1866
1936
|
}
|
|
1867
1937
|
} catch (_) { /* non-critical */ }
|
|
1868
1938
|
_syncKeyVisibility();
|
|
@@ -1896,6 +1966,7 @@ const Settings = (() => {
|
|
|
1896
1966
|
});
|
|
1897
1967
|
const data = await res.json();
|
|
1898
1968
|
if (data.ok) {
|
|
1969
|
+
_searchKeysMasked = data.keys_masked || {};
|
|
1899
1970
|
Modal.toast(I18n.t("settings.search.saved"), "success");
|
|
1900
1971
|
} else {
|
|
1901
1972
|
_showStatus(data.error || I18n.t("settings.search.failed"), false);
|
|
@@ -2342,6 +2413,11 @@ const Settings = (() => {
|
|
|
2342
2413
|
btn.classList.toggle("active", btn.dataset.lang === I18n.lang());
|
|
2343
2414
|
btn.addEventListener("click", () => {
|
|
2344
2415
|
I18n.setLang(btn.dataset.lang);
|
|
2416
|
+
// applyAll only rewrites static attributes; the info bar composes its
|
|
2417
|
+
// tooltips in JS, so refresh them once for the new language.
|
|
2418
|
+
if (typeof Sessions !== "undefined" && Sessions._lastSession) {
|
|
2419
|
+
Sessions.updateInfoBar(Sessions._lastSession);
|
|
2420
|
+
}
|
|
2345
2421
|
document.querySelectorAll("#language-section .settings-lang-btn").forEach(b =>
|
|
2346
2422
|
b.classList.toggle("active", b.dataset.lang === I18n.lang())
|
|
2347
2423
|
);
|
|
@@ -2418,6 +2494,42 @@ const Settings = (() => {
|
|
|
2418
2494
|
// { source, configured, model, base_url, api_key_masked, provider, available }
|
|
2419
2495
|
|
|
2420
2496
|
const MEDIA_KINDS = ["image", "video", "audio", "stt", "video_understanding", "ocr"];
|
|
2497
|
+
|
|
2498
|
+
// Capability glyph shown before each row title, so the six rows can be
|
|
2499
|
+
// told apart at a glance. Stroke icons (24×24, currentColor) in the same
|
|
2500
|
+
// line style as the rest of the settings UI.
|
|
2501
|
+
const MEDIA_KIND_ICONS = {
|
|
2502
|
+
image: '<rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/>',
|
|
2503
|
+
video: '<rect x="2" y="6" width="14" height="12" rx="2"/><path d="m22 8-6 4 6 4V8Z"/>',
|
|
2504
|
+
audio: '<path d="M11 5 6 9H2v6h4l5 4V5Z"/><path d="M15.54 8.46a5 5 0 0 1 0 7.07"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14"/>',
|
|
2505
|
+
stt: '<rect x="9" y="2" width="6" height="12" rx="3"/><path d="M19 10v1a7 7 0 0 1-14 0v-1"/><path d="M12 18v4"/><path d="M8 22h8"/>',
|
|
2506
|
+
video_understanding: '<rect x="2" y="4" width="20" height="16" rx="2"/><path d="m10 9 5 3-5 3V9Z"/>',
|
|
2507
|
+
ocr: '<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7S2 12 2 12Z"/><circle cx="12" cy="12" r="3"/>'
|
|
2508
|
+
};
|
|
2509
|
+
|
|
2510
|
+
function _mediaKindIcon(kind) {
|
|
2511
|
+
const el = document.createElement("span");
|
|
2512
|
+
el.className = "media-kind-icon";
|
|
2513
|
+
el.dataset.kind = kind;
|
|
2514
|
+
el.setAttribute("aria-hidden", "true");
|
|
2515
|
+
el.innerHTML = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" ' +
|
|
2516
|
+
'stroke-linecap="round" stroke-linejoin="round">' + (MEDIA_KIND_ICONS[kind] || "") + "</svg>";
|
|
2517
|
+
return el;
|
|
2518
|
+
}
|
|
2519
|
+
|
|
2520
|
+
// "[vendor mark] Friendly Name" — reuses the model list's vendor badge so
|
|
2521
|
+
// a sidecar model looks the same here as it does in the model picker.
|
|
2522
|
+
function _mediaModelChip(modelId, text, extraClass) {
|
|
2523
|
+
const el = document.createElement("span");
|
|
2524
|
+
el.className = "media-model-chip" + (extraClass ? " " + extraClass : "");
|
|
2525
|
+
if (modelId) el.appendChild(ModelPicker.vendorBadge(modelId));
|
|
2526
|
+
const label = document.createElement("span");
|
|
2527
|
+
label.className = "media-model-chip-label";
|
|
2528
|
+
label.textContent = text || modelId || "";
|
|
2529
|
+
el.appendChild(label);
|
|
2530
|
+
return el;
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2421
2533
|
let _mediaState = null;
|
|
2422
2534
|
let _mediaDefaults = null;
|
|
2423
2535
|
const _mediaCustomDraft = {};
|
|
@@ -2443,7 +2555,21 @@ const Settings = (() => {
|
|
|
2443
2555
|
}
|
|
2444
2556
|
}
|
|
2445
2557
|
|
|
2558
|
+
// Promo for OpenClacky AI Keys: one key unlocks every secondary model.
|
|
2559
|
+
// Hidden when the default provider is already openclacky (nothing to sell)
|
|
2560
|
+
// and in white-label builds (third-party brand shouldn't advertise us).
|
|
2561
|
+
function _updateMediaPromo() {
|
|
2562
|
+
const promo = document.getElementById("media-promo");
|
|
2563
|
+
if (!promo) return;
|
|
2564
|
+
const branded = typeof Brand !== "undefined" && Brand.branded;
|
|
2565
|
+
const provider = Object.values(_mediaDefaults || {})
|
|
2566
|
+
.map(d => d && d.provider)
|
|
2567
|
+
.find(Boolean);
|
|
2568
|
+
promo.style.display = (!branded && provider !== "openclacky") ? "" : "none";
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2446
2571
|
function _renderMediaRows() {
|
|
2572
|
+
_updateMediaPromo();
|
|
2447
2573
|
const container = document.getElementById("media-rows");
|
|
2448
2574
|
if (!container) return;
|
|
2449
2575
|
container.innerHTML = "";
|
|
@@ -2480,7 +2606,10 @@ const Settings = (() => {
|
|
|
2480
2606
|
|
|
2481
2607
|
const title = document.createElement("span");
|
|
2482
2608
|
title.className = "media-row-title";
|
|
2483
|
-
title.
|
|
2609
|
+
title.appendChild(_mediaKindIcon(kind));
|
|
2610
|
+
const titleText = document.createElement("span");
|
|
2611
|
+
titleText.textContent = I18n.t(`settings.media.kind.${kind}`);
|
|
2612
|
+
title.appendChild(titleText);
|
|
2484
2613
|
head.appendChild(title);
|
|
2485
2614
|
|
|
2486
2615
|
// When the default chat model already supports vision, the OCR sidecar
|
|
@@ -2494,7 +2623,7 @@ const Settings = (() => {
|
|
|
2494
2623
|
|
|
2495
2624
|
const model = document.createElement("span");
|
|
2496
2625
|
model.className = "media-vision-primary-model";
|
|
2497
|
-
model.
|
|
2626
|
+
if (state.model) model.appendChild(_mediaModelChip(state.model, state.model));
|
|
2498
2627
|
head.appendChild(model);
|
|
2499
2628
|
|
|
2500
2629
|
row.appendChild(head);
|
|
@@ -2521,7 +2650,11 @@ const Settings = (() => {
|
|
|
2521
2650
|
|
|
2522
2651
|
const status = document.createElement("span");
|
|
2523
2652
|
status.className = "media-row-status";
|
|
2524
|
-
|
|
2653
|
+
const statusText = _mediaStatusText(kind, state, def);
|
|
2654
|
+
if (statusText) {
|
|
2655
|
+
status.appendChild(_mediaModelChip(state.model, statusText));
|
|
2656
|
+
status.title = state.model || "";
|
|
2657
|
+
}
|
|
2525
2658
|
head.appendChild(status);
|
|
2526
2659
|
|
|
2527
2660
|
row.appendChild(head);
|
|
@@ -2535,7 +2668,10 @@ const Settings = (() => {
|
|
|
2535
2668
|
function _mediaStatusText(kind, state, def) {
|
|
2536
2669
|
if (state.source === "off") return "";
|
|
2537
2670
|
if (state.source === "auto") {
|
|
2538
|
-
if (state.configured && state.model)
|
|
2671
|
+
if (state.configured && state.model) {
|
|
2672
|
+
const aliases = (state.aliases && typeof state.aliases === "object") ? state.aliases : {};
|
|
2673
|
+
return aliases[state.model] || state.model;
|
|
2674
|
+
}
|
|
2539
2675
|
return "";
|
|
2540
2676
|
}
|
|
2541
2677
|
return "";
|
|
@@ -2564,37 +2700,85 @@ const Settings = (() => {
|
|
|
2564
2700
|
const modelField = _buildField(I18n.t("settings.media.field.model"));
|
|
2565
2701
|
const opts = Array.isArray(state.available) ? state.available : [];
|
|
2566
2702
|
const aliases = (state.aliases && typeof state.aliases === "object") ? state.aliases : {};
|
|
2567
|
-
|
|
2703
|
+
// Friendly label: "Nano Banana 2.1 — 推荐 · 日常出图…". Raw model IDs
|
|
2704
|
+
// mean nothing to end users, so the alias leads and an optional
|
|
2705
|
+
// one-line hint (i18n key settings.media.modelHint.<id>) explains
|
|
2706
|
+
// when to pick it. Falls back to the raw ID when no alias exists.
|
|
2707
|
+
const hintOf = (m) => {
|
|
2708
|
+
const key = `settings.media.modelHint.${m}`;
|
|
2709
|
+
const h = I18n.t(key);
|
|
2710
|
+
return h === key ? "" : h;
|
|
2711
|
+
};
|
|
2712
|
+
const nameOf = (m) => aliases[m] || m;
|
|
2713
|
+
const labelOf = (m) => {
|
|
2714
|
+
const hint = hintOf(m);
|
|
2715
|
+
return hint ? `${nameOf(m)} — ${hint}` : nameOf(m);
|
|
2716
|
+
};
|
|
2568
2717
|
if (opts.length > 1) {
|
|
2569
|
-
|
|
2570
|
-
|
|
2718
|
+
// Custom dropdown instead of a native <select>: native options
|
|
2719
|
+
// cannot render the vendor mark next to each model name.
|
|
2720
|
+
const wrapper = document.createElement("div");
|
|
2721
|
+
wrapper.className = "custom-select-wrapper media-model-select";
|
|
2722
|
+
|
|
2723
|
+
const trigger = document.createElement("div");
|
|
2724
|
+
trigger.className = "custom-select-trigger";
|
|
2725
|
+
trigger.tabIndex = 0;
|
|
2726
|
+
const valueSpan = document.createElement("span");
|
|
2727
|
+
valueSpan.className = "custom-select-value";
|
|
2728
|
+
const renderValue = (m) => {
|
|
2729
|
+
valueSpan.innerHTML = "";
|
|
2730
|
+
valueSpan.appendChild(_mediaModelChip(m, labelOf(m)));
|
|
2731
|
+
trigger.title = m;
|
|
2732
|
+
};
|
|
2733
|
+
renderValue(state.model);
|
|
2734
|
+
trigger.appendChild(valueSpan);
|
|
2735
|
+
trigger.insertAdjacentHTML("beforeend",
|
|
2736
|
+
'<svg class="custom-select-arrow" fill="none" stroke="currentColor" viewBox="0 0 24 24">' +
|
|
2737
|
+
'<path stroke-linecap="round" stroke-linejoin="round" d="M19 9l-7 7-7-7"/></svg>');
|
|
2738
|
+
|
|
2739
|
+
const dropdown = document.createElement("div");
|
|
2740
|
+
dropdown.className = "custom-select-dropdown media-model-dropdown";
|
|
2571
2741
|
opts.forEach(m => {
|
|
2572
|
-
const o = document.createElement("
|
|
2573
|
-
o.
|
|
2574
|
-
o.
|
|
2575
|
-
|
|
2576
|
-
|
|
2742
|
+
const o = document.createElement("div");
|
|
2743
|
+
o.className = "custom-select-option" + (m === state.model ? " selected" : "");
|
|
2744
|
+
o.dataset.value = m;
|
|
2745
|
+
o.title = m;
|
|
2746
|
+
o.appendChild(_mediaModelChip(m, labelOf(m)));
|
|
2747
|
+
dropdown.appendChild(o);
|
|
2577
2748
|
});
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2749
|
+
|
|
2750
|
+
wrapper.appendChild(trigger);
|
|
2751
|
+
wrapper.appendChild(dropdown);
|
|
2752
|
+
|
|
2753
|
+
const cs = CustomSelect.init({
|
|
2754
|
+
trigger,
|
|
2755
|
+
dropdown,
|
|
2756
|
+
portal: true,
|
|
2757
|
+
onSelect: async (picked) => {
|
|
2758
|
+
// CustomSelect.setValue wrote plain text; restore the chip.
|
|
2759
|
+
renderValue(picked);
|
|
2760
|
+
if (picked === state.model) return;
|
|
2761
|
+
const payload = picked === (def && def.model)
|
|
2762
|
+
? { source: "auto" }
|
|
2763
|
+
: { source: "auto", model: picked };
|
|
2764
|
+
wrapper.classList.add("is-disabled");
|
|
2765
|
+
_setMediaResult(kind, "testing", I18n.t("settings.media.action.saving"));
|
|
2766
|
+
try {
|
|
2767
|
+
await _saveMediaConfig(kind, payload);
|
|
2768
|
+
await _reloadKind(kind);
|
|
2769
|
+
} catch (e) {
|
|
2770
|
+
wrapper.classList.remove("is-disabled");
|
|
2771
|
+
cs.setValue(state.model, "");
|
|
2772
|
+
renderValue(state.model);
|
|
2773
|
+
_setMediaResult(kind, "fail", e.message);
|
|
2774
|
+
}
|
|
2591
2775
|
}
|
|
2592
2776
|
});
|
|
2593
|
-
modelField.appendChild(
|
|
2777
|
+
modelField.appendChild(wrapper);
|
|
2594
2778
|
} else {
|
|
2595
2779
|
const ro = document.createElement("div");
|
|
2596
2780
|
ro.className = "media-auto-readonly";
|
|
2597
|
-
ro.
|
|
2781
|
+
ro.appendChild(_mediaModelChip(state.model, labelOf(state.model)));
|
|
2598
2782
|
modelField.appendChild(ro);
|
|
2599
2783
|
}
|
|
2600
2784
|
wrap.appendChild(modelField);
|
|
@@ -2603,8 +2787,8 @@ const Settings = (() => {
|
|
|
2603
2787
|
const warn = document.createElement("div");
|
|
2604
2788
|
warn.className = "media-row-hint is-warning";
|
|
2605
2789
|
warn.textContent = I18n.t("settings.media.auto.stale", {
|
|
2606
|
-
requested:
|
|
2607
|
-
current:
|
|
2790
|
+
requested: nameOf(state.requested_model),
|
|
2791
|
+
current: nameOf(state.model)
|
|
2608
2792
|
});
|
|
2609
2793
|
wrap.appendChild(warn);
|
|
2610
2794
|
} else {
|
|
@@ -2644,7 +2828,11 @@ const Settings = (() => {
|
|
|
2644
2828
|
lbl.textContent = I18n.t(lk);
|
|
2645
2829
|
const val = document.createElement("span");
|
|
2646
2830
|
val.className = "media-custom-readonly-value";
|
|
2647
|
-
|
|
2831
|
+
if (lk === "settings.media.field.model" && v) {
|
|
2832
|
+
val.appendChild(_mediaModelChip(v, v));
|
|
2833
|
+
} else {
|
|
2834
|
+
val.textContent = v || "—";
|
|
2835
|
+
}
|
|
2648
2836
|
row.appendChild(lbl);
|
|
2649
2837
|
row.appendChild(val);
|
|
2650
2838
|
list.appendChild(row);
|
data/lib/clacky/web/skills.js
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
// Depends on: Sessions (sendMessage), Skills (createInSession, toggleImportBar),
|
|
19
19
|
// I18n, global $ helper.
|
|
20
20
|
// ─────────────────────────────────────────────────────────────────────────
|
|
21
|
-
const SKILL_AC_SHOW_SYSTEM_KEY = "skill-ac-show-system";
|
|
22
|
-
const SKILL_AC_MRU_KEY = "skill-ac-mru";
|
|
21
|
+
const SKILL_AC_SHOW_SYSTEM_KEY = "clacky-skill-ac-show-system";
|
|
22
|
+
const SKILL_AC_MRU_KEY = "clacky-skill-ac-mru";
|
|
23
23
|
|
|
24
24
|
const SkillAC = (() => {
|
|
25
25
|
let _initialized = false;
|
data/lib/clacky/web/theme.js
CHANGED
|
@@ -28,6 +28,21 @@ const Theme = (() => {
|
|
|
28
28
|
window.dispatchEvent(new CustomEvent("clacky-theme-change", { detail: { theme } }));
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
// Per-element transitions have different durations, so a live switch would
|
|
32
|
+
// repaint regions out of step; freeze them and cross-fade the page as one.
|
|
33
|
+
function _switchTo(theme) {
|
|
34
|
+
const root = document.documentElement;
|
|
35
|
+
const swap = () => {
|
|
36
|
+
root.classList.add("theme-switching");
|
|
37
|
+
_applyAttr(theme);
|
|
38
|
+
void root.offsetWidth;
|
|
39
|
+
requestAnimationFrame(() => root.classList.remove("theme-switching"));
|
|
40
|
+
};
|
|
41
|
+
const reduceMotion = window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
42
|
+
if (document.startViewTransition && !reduceMotion) document.startViewTransition(swap);
|
|
43
|
+
else swap();
|
|
44
|
+
}
|
|
45
|
+
|
|
31
46
|
// Update active state on all .settings-bg-theme-card buttons.
|
|
32
47
|
function _syncBgCards() {
|
|
33
48
|
const effective = current();
|
|
@@ -45,7 +60,7 @@ const Theme = (() => {
|
|
|
45
60
|
const mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
46
61
|
const onChange = () => {
|
|
47
62
|
if (!localStorage.getItem(STORAGE_KEY)) {
|
|
48
|
-
|
|
63
|
+
_switchTo(_systemTheme());
|
|
49
64
|
}
|
|
50
65
|
};
|
|
51
66
|
if (mq.addEventListener) mq.addEventListener("change", onChange);
|
|
@@ -61,7 +76,7 @@ const Theme = (() => {
|
|
|
61
76
|
} else {
|
|
62
77
|
localStorage.setItem(STORAGE_KEY, theme);
|
|
63
78
|
}
|
|
64
|
-
|
|
79
|
+
_switchTo(theme);
|
|
65
80
|
}
|
|
66
81
|
|
|
67
82
|
// Keep applyBg as alias for backward compat (settings.js calls it)
|