dsh-agy-link 0.6.21 → 0.6.22
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/CHANGELOG.md +73 -0
- package/README.md +1 -1
- package/dist/cli-image.mjs +545 -86
- package/dist/client.js +587 -225
- package/dist/index.js +874 -184
- package/docs/CONFIGURATION.md +11 -2
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -70,6 +70,7 @@ window.__ModuleLoader__.load({
|
|
|
70
70
|
"quota.fiveHour": "5 小时额度",
|
|
71
71
|
"quota.weekly": "周额度",
|
|
72
72
|
"quota.refreshed": "额度已刷新",
|
|
73
|
+
"quota.refreshStarted": "正在同步额度,稍后自动更新",
|
|
73
74
|
"quota.windowReset": "已重置 · 可用",
|
|
74
75
|
"proxy.button": "代理",
|
|
75
76
|
"proxy.placeholder": "专属代理 URL(如:http://127.0.0.1:7890;留空则使用全局)",
|
|
@@ -125,6 +126,8 @@ window.__ModuleLoader__.load({
|
|
|
125
126
|
"effort.low": "low",
|
|
126
127
|
"effort.medium": "medium",
|
|
127
128
|
"effort.high": "high",
|
|
129
|
+
"effort.xhigh": "extra",
|
|
130
|
+
"effort.max": "max",
|
|
128
131
|
"pool.label": "号池调度:",
|
|
129
132
|
"pool.sequential": "顺次耗尽",
|
|
130
133
|
"pool.roundRobin": "轮询均衡",
|
|
@@ -183,6 +186,10 @@ window.__ModuleLoader__.load({
|
|
|
183
186
|
"config.imageCopy": "复制命令",
|
|
184
187
|
"config.imageCopied": "命令已复制",
|
|
185
188
|
"config.imageCopyFailed": "复制失败,请手动选择命令",
|
|
189
|
+
"config.showHeaderBadge": "会话状态徽标",
|
|
190
|
+
"config.showHeaderBadgeDesc": "在会话头部工具栏显示 Antigravity 状态与账号徽标(窄屏/手机端会自动隐藏文字标签)",
|
|
191
|
+
"config.showTranslateAction": "单条翻译按钮",
|
|
192
|
+
"config.showTranslateActionDesc": "在助理消息下方操作栏显示「译成人话」按钮",
|
|
186
193
|
"config.on": "开启",
|
|
187
194
|
"config.off": "关闭",
|
|
188
195
|
"config.runtimeTitle": "运行方式",
|
|
@@ -269,6 +276,7 @@ window.__ModuleLoader__.load({
|
|
|
269
276
|
"quota.fiveHour": "5-hour quota",
|
|
270
277
|
"quota.weekly": "Weekly quota",
|
|
271
278
|
"quota.refreshed": "Quota refreshed",
|
|
279
|
+
"quota.refreshStarted": "Syncing quota — figures update shortly",
|
|
272
280
|
"quota.windowReset": "Reset · available",
|
|
273
281
|
"proxy.button": "Proxy",
|
|
274
282
|
"proxy.placeholder": "Dedicated proxy URL (for example: http://127.0.0.1:7890; leave blank to use the global proxy)",
|
|
@@ -324,6 +332,8 @@ window.__ModuleLoader__.load({
|
|
|
324
332
|
"effort.low": "low",
|
|
325
333
|
"effort.medium": "medium",
|
|
326
334
|
"effort.high": "high",
|
|
335
|
+
"effort.xhigh": "extra",
|
|
336
|
+
"effort.max": "max",
|
|
327
337
|
"pool.label": "Account-pool scheduling:",
|
|
328
338
|
"pool.sequential": "Use sequentially",
|
|
329
339
|
"pool.roundRobin": "Round-robin",
|
|
@@ -382,6 +392,10 @@ window.__ModuleLoader__.load({
|
|
|
382
392
|
"config.imageCopy": "Copy command",
|
|
383
393
|
"config.imageCopied": "Command copied",
|
|
384
394
|
"config.imageCopyFailed": "Copy failed — select the command manually",
|
|
395
|
+
"config.showHeaderBadge": "Header status badge",
|
|
396
|
+
"config.showHeaderBadgeDesc": "Show the Antigravity status badge in the conversation header toolbar (text hidden on small screens)",
|
|
397
|
+
"config.showTranslateAction": "Translate button",
|
|
398
|
+
"config.showTranslateActionDesc": "Show the \"Translate to plain text\" button under assistant messages",
|
|
385
399
|
"config.on": "On",
|
|
386
400
|
"config.off": "Off",
|
|
387
401
|
"config.runtimeTitle": "Runtime",
|
|
@@ -468,6 +482,7 @@ window.__ModuleLoader__.load({
|
|
|
468
482
|
"quota.fiveHour": "Cota de 5 horas",
|
|
469
483
|
"quota.weekly": "Cota semanal",
|
|
470
484
|
"quota.refreshed": "Cota atualizada",
|
|
485
|
+
"quota.refreshStarted": "Sincronizando a cota — os números atualizam em breve",
|
|
471
486
|
"quota.windowReset": "Redefinida · disponível",
|
|
472
487
|
"proxy.button": "Proxy",
|
|
473
488
|
"proxy.placeholder": "URL do proxy exclusivo (por exemplo: http://127.0.0.1:7890; deixe vazio para usar o proxy global)",
|
|
@@ -523,6 +538,8 @@ window.__ModuleLoader__.load({
|
|
|
523
538
|
"effort.low": "low",
|
|
524
539
|
"effort.medium": "medium",
|
|
525
540
|
"effort.high": "high",
|
|
541
|
+
"effort.xhigh": "extra",
|
|
542
|
+
"effort.max": "max",
|
|
526
543
|
"pool.label": "Agendamento do pool de contas:",
|
|
527
544
|
"pool.sequential": "Usar em sequência",
|
|
528
545
|
"pool.roundRobin": "Rodízio",
|
|
@@ -581,6 +598,10 @@ window.__ModuleLoader__.load({
|
|
|
581
598
|
"config.imageCopy": "Copiar comando",
|
|
582
599
|
"config.imageCopied": "Comando copiado",
|
|
583
600
|
"config.imageCopyFailed": "Falha ao copiar — selecione o comando manualmente",
|
|
601
|
+
"config.showHeaderBadge": "Ícone de status no cabeçalho",
|
|
602
|
+
"config.showHeaderBadgeDesc": "Exibe o emblema de status do Antigravity na barra de ferramentas do cabeçalho da conversa",
|
|
603
|
+
"config.showTranslateAction": "Botão de tradução",
|
|
604
|
+
"config.showTranslateActionDesc": "Exibe o botão de tradução sob as mensagens do assistente",
|
|
584
605
|
"config.on": "Ativado",
|
|
585
606
|
"config.off": "Desativado",
|
|
586
607
|
"config.runtimeTitle": "Execução",
|
|
@@ -667,6 +688,7 @@ window.__ModuleLoader__.load({
|
|
|
667
688
|
"quota.fiveHour": "Cuota de 5 horas",
|
|
668
689
|
"quota.weekly": "Cuota semanal",
|
|
669
690
|
"quota.refreshed": "Cuota actualizada",
|
|
691
|
+
"quota.refreshStarted": "Sincronizando la cuota — las cifras se actualizarán en breve",
|
|
670
692
|
"quota.windowReset": "Reiniciada · disponible",
|
|
671
693
|
"proxy.button": "Proxy",
|
|
672
694
|
"proxy.placeholder": "URL de proxy exclusivo (por ejemplo: http://127.0.0.1:7890; déjelo vacío para usar el proxy global)",
|
|
@@ -722,6 +744,8 @@ window.__ModuleLoader__.load({
|
|
|
722
744
|
"effort.low": "low",
|
|
723
745
|
"effort.medium": "medium",
|
|
724
746
|
"effort.high": "high",
|
|
747
|
+
"effort.xhigh": "extra",
|
|
748
|
+
"effort.max": "max",
|
|
725
749
|
"pool.label": "Programación del pool de cuentas:",
|
|
726
750
|
"pool.sequential": "Usar en secuencia",
|
|
727
751
|
"pool.roundRobin": "Turno rotativo",
|
|
@@ -780,6 +804,10 @@ window.__ModuleLoader__.load({
|
|
|
780
804
|
"config.imageCopy": "Copiar comando",
|
|
781
805
|
"config.imageCopied": "Comando copiado",
|
|
782
806
|
"config.imageCopyFailed": "Error al copiar — selecciona el comando manualmente",
|
|
807
|
+
"config.showHeaderBadge": "Insignia de estado en la cabecera",
|
|
808
|
+
"config.showHeaderBadgeDesc": "Muestra la insignia de estado de Antigravity en la barra de la cabecera de la conversación (el texto se oculta en pantallas pequeñas)",
|
|
809
|
+
"config.showTranslateAction": "Botón de traducción",
|
|
810
|
+
"config.showTranslateActionDesc": "Muestra el botón «Traducir a lenguaje sencillo» bajo los mensajes del asistente",
|
|
783
811
|
"config.on": "Activado",
|
|
784
812
|
"config.off": "Desactivado",
|
|
785
813
|
"config.runtimeTitle": "Ejecución",
|
|
@@ -1837,18 +1865,6 @@ window.__ModuleLoader__.load({
|
|
|
1837
1865
|
box-shadow: 0 2px 10px rgba(168, 85, 247, 0.25);
|
|
1838
1866
|
}
|
|
1839
1867
|
|
|
1840
|
-
.agy-chip-file {
|
|
1841
|
-
color: #34d399;
|
|
1842
|
-
background: rgba(52, 211, 153, 0.1);
|
|
1843
|
-
border-color: rgba(52, 211, 153, 0.28);
|
|
1844
|
-
}
|
|
1845
|
-
.agy-chip-file:hover {
|
|
1846
|
-
background: rgba(52, 211, 153, 0.22);
|
|
1847
|
-
border-color: rgba(52, 211, 153, 0.5);
|
|
1848
|
-
color: #6ee7b7;
|
|
1849
|
-
box-shadow: 0 2px 10px rgba(52, 211, 153, 0.25);
|
|
1850
|
-
}
|
|
1851
|
-
|
|
1852
1868
|
.agy-image-chip-icon {
|
|
1853
1869
|
display: inline-flex;
|
|
1854
1870
|
align-items: center;
|
|
@@ -2467,6 +2483,129 @@ window.__ModuleLoader__.load({
|
|
|
2467
2483
|
}
|
|
2468
2484
|
//#endregion
|
|
2469
2485
|
//#region src/client/images/scanner.ts
|
|
2486
|
+
/**
|
|
2487
|
+
* Cached client context. `installImageEnhancer` receives it from `apply(ctx)` so
|
|
2488
|
+
* the click handler — which runs long after apply returned — can still reach
|
|
2489
|
+
* `ctx.get('sidebarRight')`. Never dereferenced eagerly: Cordis throws on a
|
|
2490
|
+
* non-injected service, so every read stays inside a guard.
|
|
2491
|
+
*/
|
|
2492
|
+
let clientContext = null;
|
|
2493
|
+
function setClientContext(ctx) {
|
|
2494
|
+
clientContext = ctx;
|
|
2495
|
+
}
|
|
2496
|
+
/** The tab type that previews a session file in the right Sidebar (documentpreview's fallback). */
|
|
2497
|
+
const DOCUMENT_PREVIEW_TAB = "@deepseek-ai/dsh-client-ui-sidebar-documentpreview";
|
|
2498
|
+
/**
|
|
2499
|
+
* Resolve one Cordis service without an injection declaration.
|
|
2500
|
+
*
|
|
2501
|
+
* Kept local (not imported from translate-context) on purpose: this module is
|
|
2502
|
+
* also loaded by SSR/toolview tests under plain ESM, and translate-context pulls
|
|
2503
|
+
* React in through `require`. A guarded `get()` plus a guarded property read is
|
|
2504
|
+
* enough here — Cordis throws on a non-injected service property, hence the try.
|
|
2505
|
+
*/
|
|
2506
|
+
function service$1(ctx, name) {
|
|
2507
|
+
const c = ctx;
|
|
2508
|
+
try {
|
|
2509
|
+
const fromGet = c.get?.(name);
|
|
2510
|
+
if (fromGet !== void 0 && fromGet !== null) return fromGet;
|
|
2511
|
+
} catch {}
|
|
2512
|
+
try {
|
|
2513
|
+
const direct = c[name];
|
|
2514
|
+
return direct === void 0 || direct === null ? void 0 : direct;
|
|
2515
|
+
} catch {
|
|
2516
|
+
return;
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
/** The Session the visible conversation belongs to; `''` when unknown. */
|
|
2520
|
+
function currentSessionId$1(ctx) {
|
|
2521
|
+
const value = service$1(ctx, "uiSession")?.current?.value;
|
|
2522
|
+
if (value !== void 0 && value !== null) for (const key of [
|
|
2523
|
+
"key",
|
|
2524
|
+
"sessionId",
|
|
2525
|
+
"id"
|
|
2526
|
+
]) {
|
|
2527
|
+
const id = value[key];
|
|
2528
|
+
if (typeof id === "string" && id !== "") return id;
|
|
2529
|
+
}
|
|
2530
|
+
const byId = service$1(ctx, "sessions")?.list?.getSnapshot?.()?.byId;
|
|
2531
|
+
if (byId !== void 0 && byId !== null) {
|
|
2532
|
+
const ids = Object.keys(byId);
|
|
2533
|
+
if (ids.length === 1 && ids[0] !== void 0) return ids[0];
|
|
2534
|
+
}
|
|
2535
|
+
return "";
|
|
2536
|
+
}
|
|
2537
|
+
function encodeSegment(segment) {
|
|
2538
|
+
return encodeURIComponent(segment).replace(/%3A/gi, ":");
|
|
2539
|
+
}
|
|
2540
|
+
/** `dsh-resource://file/session/<sessionId>/<path>`, mirroring DSH's `sessionFileAddress`. */
|
|
2541
|
+
function sessionFileAddress(sessionId, filePath) {
|
|
2542
|
+
const normalized = filePath.replace(/\\/g, "/").replace(/^(?:\.\/)+/, "");
|
|
2543
|
+
return `dsh-resource://file/session/${encodeSegment(sessionId)}/${normalized.split("/").map(encodeSegment).join("/")}`;
|
|
2544
|
+
}
|
|
2545
|
+
/** `file:///C:/x` | `file://C:/x` | `C:\x` → `C:/x`, dropping a `#L12` / `?v=1` suffix. */
|
|
2546
|
+
function normalizeLocalPath(raw) {
|
|
2547
|
+
let p = raw.trim();
|
|
2548
|
+
if (p.startsWith("file://")) {
|
|
2549
|
+
p = p.slice(7);
|
|
2550
|
+
if (/^\/[A-Za-z]:/.test(p)) p = p.slice(1);
|
|
2551
|
+
}
|
|
2552
|
+
const [pathPart] = p.replace(/\\/g, "/").split(/[?#]/);
|
|
2553
|
+
return (pathPart ?? "").replace(/^(?:\.\/)+/, "");
|
|
2554
|
+
}
|
|
2555
|
+
function sidebarRightOf(ctx) {
|
|
2556
|
+
const sidebarRight = service$1(ctx, "sidebarRight");
|
|
2557
|
+
return typeof sidebarRight?.openResource === "function" ? sidebarRight : void 0;
|
|
2558
|
+
}
|
|
2559
|
+
/**
|
|
2560
|
+
* Whether a tab type can follow a session file address. Web/headless profiles
|
|
2561
|
+
* omit `ui-sidebar-documentpreview`; opening there would silently do nothing, so
|
|
2562
|
+
* the caller must fall back to the OS opener instead of reporting success.
|
|
2563
|
+
*/
|
|
2564
|
+
function canPreviewFiles(ctx) {
|
|
2565
|
+
const tabs = service$1(ctx, "sidebarRightTabs");
|
|
2566
|
+
return tabs?.get?.(DOCUMENT_PREVIEW_TAB) !== void 0 && tabs?.get?.(DOCUMENT_PREVIEW_TAB) !== null;
|
|
2567
|
+
}
|
|
2568
|
+
function mountedSessionId(sidebarRight) {
|
|
2569
|
+
const mounted = sidebarRight.mounted?.getSnapshot?.();
|
|
2570
|
+
return typeof mounted === "string" ? mounted : "";
|
|
2571
|
+
}
|
|
2572
|
+
/** The on-screen Session's workspace root, normalized to forward slashes. */
|
|
2573
|
+
function sessionWorkspace(ctx, sessionId) {
|
|
2574
|
+
const cwd = service$1(ctx, "sessions")?.list?.getSnapshot?.()?.byId?.[sessionId]?.cwd;
|
|
2575
|
+
return typeof cwd === "string" ? cwd.replace(/\\/g, "/").replace(/\/+$/, "") : "";
|
|
2576
|
+
}
|
|
2577
|
+
/**
|
|
2578
|
+
* Open a local file in DSH's native right Sidebar (the `ui-sidebar-documentpreview`
|
|
2579
|
+
* tab), exactly like the native `fileMention` chip does.
|
|
2580
|
+
*
|
|
2581
|
+
* The address is built the way `fileAddressFor` builds it: a path inside the
|
|
2582
|
+
* Session workspace travels relative, anything else keeps its absolute spelling.
|
|
2583
|
+
* Returns `false` when no Sidebar can take it, so callers can fall back.
|
|
2584
|
+
*/
|
|
2585
|
+
function openInRightSidebar(rawPath) {
|
|
2586
|
+
if (clientContext === null) return false;
|
|
2587
|
+
const sidebarRight = sidebarRightOf(clientContext);
|
|
2588
|
+
if (sidebarRight === void 0) return false;
|
|
2589
|
+
if (!canPreviewFiles(clientContext)) return false;
|
|
2590
|
+
const sessionId = mountedSessionId(sidebarRight) || currentSessionId$1(clientContext);
|
|
2591
|
+
if (sessionId === "") return false;
|
|
2592
|
+
const target = normalizeLocalPath(rawPath);
|
|
2593
|
+
if (target === "") return false;
|
|
2594
|
+
const cwd = sessionWorkspace(clientContext, sessionId);
|
|
2595
|
+
let addressPath = target;
|
|
2596
|
+
if (cwd !== "") {
|
|
2597
|
+
const lowerCwd = cwd.toLowerCase();
|
|
2598
|
+
if (target.toLowerCase() === lowerCwd) addressPath = "";
|
|
2599
|
+
else if (target.toLowerCase().startsWith(`${lowerCwd}/`)) addressPath = target.slice(cwd.length + 1);
|
|
2600
|
+
}
|
|
2601
|
+
const line = /#L(\d+)/.exec(rawPath);
|
|
2602
|
+
try {
|
|
2603
|
+
sidebarRight.openResource(sessionFileAddress(sessionId, addressPath), line === null ? void 0 : { params: { line: Number(line[1]) } });
|
|
2604
|
+
return true;
|
|
2605
|
+
} catch {
|
|
2606
|
+
return false;
|
|
2607
|
+
}
|
|
2608
|
+
}
|
|
2470
2609
|
/** Get React props of a DOM element */
|
|
2471
2610
|
function getReactProps(el) {
|
|
2472
2611
|
const key = Object.keys(el).find((k) => k.startsWith("__reactProps"));
|
|
@@ -2621,6 +2760,31 @@ window.__ModuleLoader__.load({
|
|
|
2621
2760
|
}
|
|
2622
2761
|
}
|
|
2623
2762
|
}
|
|
2763
|
+
function enhanceFileLinks(links) {
|
|
2764
|
+
for (let i = 0; i < links.length; i++) {
|
|
2765
|
+
const link = links[i];
|
|
2766
|
+
if (!link || link.dataset.agyFileEnhanced === "true" || link.dataset.agyLinkEnhanced === "true" || link.dataset.agyVideoEnhanced === "true") continue;
|
|
2767
|
+
const rawHref = link.getAttribute("href") ?? "";
|
|
2768
|
+
const resolvedHref = link.href ?? "";
|
|
2769
|
+
if (isImageFile(rawHref) || isImageFile(resolvedHref) || isVideoFile(rawHref) || isVideoFile(resolvedHref)) continue;
|
|
2770
|
+
if (!rawHref.startsWith("file://") && !resolvedHref.startsWith("file://") && !isLocalFilePath(rawHref)) continue;
|
|
2771
|
+
link.dataset.agyFileEnhanced = "true";
|
|
2772
|
+
const pathToUse = rawHref.startsWith("file://") ? rawHref : resolvedHref.startsWith("file://") ? resolvedHref : rawHref || resolvedHref;
|
|
2773
|
+
link.addEventListener("click", (e) => {
|
|
2774
|
+
if (e.target?.closest?.(".agy-image-link-chip")) return;
|
|
2775
|
+
e.preventDefault();
|
|
2776
|
+
e.stopPropagation();
|
|
2777
|
+
const fileName = pathToUse.split(/[/\\]/).pop() || pathToUse;
|
|
2778
|
+
if (openInRightSidebar(pathToUse)) {
|
|
2779
|
+
showToast(`已在原生边栏打开: ${fileName}`);
|
|
2780
|
+
return;
|
|
2781
|
+
}
|
|
2782
|
+
openInSystem(pathToUse, false).then((res) => {
|
|
2783
|
+
showToast(res.ok ? `已在系统程序中打开: ${fileName}` : `打开失败: ${res.error || "未找到文件"}`);
|
|
2784
|
+
});
|
|
2785
|
+
});
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2624
2788
|
/**
|
|
2625
2789
|
* Scan DOM for imageAlt spans and enhance them with live rendered images
|
|
2626
2790
|
*/
|
|
@@ -2632,6 +2796,7 @@ window.__ModuleLoader__.load({
|
|
|
2632
2796
|
const links = document.querySelectorAll("a[href]");
|
|
2633
2797
|
enhanceImageLinks(links);
|
|
2634
2798
|
enhanceVideoLinks(links);
|
|
2799
|
+
enhanceFileLinks(links);
|
|
2635
2800
|
}
|
|
2636
2801
|
let imageEnhancerDispose = null;
|
|
2637
2802
|
let imageScanTimer = null;
|
|
@@ -2650,7 +2815,7 @@ window.__ModuleLoader__.load({
|
|
|
2650
2815
|
const target = e.target;
|
|
2651
2816
|
const a = target?.closest("a");
|
|
2652
2817
|
if (!a) return;
|
|
2653
|
-
if (a.dataset.agyLinkEnhanced === "true" || a.dataset.agyVideoEnhanced === "true") return;
|
|
2818
|
+
if (a.dataset.agyLinkEnhanced === "true" || a.dataset.agyVideoEnhanced === "true" || a.dataset.agyFileEnhanced === "true") return;
|
|
2654
2819
|
if (target?.closest?.(".agy-image-link-chip")) return;
|
|
2655
2820
|
const rawHref = a.getAttribute("href") ?? "";
|
|
2656
2821
|
const resolvedHref = a.href ?? "";
|
|
@@ -2659,13 +2824,18 @@ window.__ModuleLoader__.load({
|
|
|
2659
2824
|
if (/^https?:\/\//i.test(pathToUse) && !pathToUse.includes("/plugins/agy-link/")) return;
|
|
2660
2825
|
e.preventDefault();
|
|
2661
2826
|
e.stopPropagation();
|
|
2827
|
+
const fileName = pathToUse.split(/[/\\]/).pop() || pathToUse;
|
|
2828
|
+
if (openInRightSidebar(pathToUse)) {
|
|
2829
|
+
showToast(`已在原生边栏打开: ${fileName}`);
|
|
2830
|
+
return;
|
|
2831
|
+
}
|
|
2662
2832
|
openInSystem(pathToUse, false).then((res) => {
|
|
2663
|
-
|
|
2664
|
-
showToast(res.ok ? `已在系统默认程序中打开: ${fileName}` : `打开失败: ${res.error || "未找到文件"}`);
|
|
2833
|
+
showToast(res.ok ? `已在系统程序中打开: ${fileName}` : `打开失败: ${res.error || "未找到文件"}`);
|
|
2665
2834
|
});
|
|
2666
2835
|
}
|
|
2667
2836
|
}
|
|
2668
|
-
function installImageEnhancer() {
|
|
2837
|
+
function installImageEnhancer(ctx) {
|
|
2838
|
+
if (ctx) setClientContext(ctx);
|
|
2669
2839
|
if (typeof window === "undefined" || typeof document === "undefined") return () => {};
|
|
2670
2840
|
imageEnhancerDispose?.();
|
|
2671
2841
|
injectStyles$5();
|
|
@@ -2981,6 +3151,21 @@ window.__ModuleLoader__.load({
|
|
|
2981
3151
|
};
|
|
2982
3152
|
const { tool, input } = info;
|
|
2983
3153
|
const desc = pick(input, "Description", "description", "toolAction", "toolSummary", "Instruction", "instruction");
|
|
3154
|
+
if (tool === "invoke_subagent") {
|
|
3155
|
+
const directRole = pick(input, "Role", "role");
|
|
3156
|
+
const directTypeName = pick(input, "TypeName", "typeName");
|
|
3157
|
+
const effRole = directRole && directTypeName ? `${directRole} (${directTypeName})` : directRole ?? directTypeName;
|
|
3158
|
+
const prompt = pick(input, "Prompt", "prompt");
|
|
3159
|
+
return {
|
|
3160
|
+
kind: "generic",
|
|
3161
|
+
tool,
|
|
3162
|
+
server: info.server,
|
|
3163
|
+
title: desc ?? (effRole ? `Subagent · ${effRole}` : "Invoke Subagent"),
|
|
3164
|
+
command: prompt,
|
|
3165
|
+
output: out,
|
|
3166
|
+
raw: parsedArgsRaw(block)
|
|
3167
|
+
};
|
|
3168
|
+
}
|
|
2984
3169
|
if (QUESTION_TOOLS.has(tool)) {
|
|
2985
3170
|
const questionsRaw = input.questions ?? input.Questions;
|
|
2986
3171
|
const questions = Array.isArray(questionsRaw) ? questionsRaw : [];
|
|
@@ -4941,6 +5126,178 @@ body.dark .agy-tsl-card,
|
|
|
4941
5126
|
}, meta.join(" · ")), h$1("span", { className: "agy-tsl-actions" }, original === "" ? null : action("original", showOriginal ? t("tsl.hideOriginal", "Hide original") : t("tsl.showOriginal", "Show original"), () => setShowOriginal(!showOriginal), showOriginal), action("copy", copied ? t("tsl.copied", "Copied") : t("tsl.copy", "Copy"), copy), action("collapse", open ? t("tsl.collapse", "Collapse") : t("tsl.expand", "Expand"), () => setOpen(!open)))), open ? h$1("div", { className: "agy-tsl-body" }, renderMarkdown(text)) : null, showOriginal && original !== "" ? h$1("pre", { className: "agy-tsl-original" }, original) : null);
|
|
4942
5127
|
};
|
|
4943
5128
|
//#endregion
|
|
5129
|
+
//#region src/common/timeouts.ts
|
|
5130
|
+
/** Status poll: keep the console responsive, never stack polls. */
|
|
5131
|
+
const STATUS_TIMEOUT_MS = 5e3;
|
|
5132
|
+
/** A write (sync / warmup / config / auth): the busy flag must always clear. */
|
|
5133
|
+
const WRITE_TIMEOUT_MS = 2e4;
|
|
5134
|
+
//#endregion
|
|
5135
|
+
//#region src/client/api.ts
|
|
5136
|
+
const win = globalThis;
|
|
5137
|
+
const base = win.location?.origin ?? "";
|
|
5138
|
+
const PLUGIN_BASE = "/plugins/agy-link";
|
|
5139
|
+
/** One AbortSignal.timeout helper, shared by writes and the status poll. */
|
|
5140
|
+
function timedSignal(ms) {
|
|
5141
|
+
if (typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function") return AbortSignal.timeout(ms);
|
|
5142
|
+
}
|
|
5143
|
+
async function postJson(path, body) {
|
|
5144
|
+
try {
|
|
5145
|
+
const init = {
|
|
5146
|
+
method: "POST",
|
|
5147
|
+
headers: { "Content-Type": "application/json" },
|
|
5148
|
+
body: JSON.stringify(body)
|
|
5149
|
+
};
|
|
5150
|
+
const signal = timedSignal(WRITE_TIMEOUT_MS);
|
|
5151
|
+
if (signal !== void 0) init.signal = signal;
|
|
5152
|
+
const res = await win.fetch?.(base + path, init);
|
|
5153
|
+
if (!res) return null;
|
|
5154
|
+
try {
|
|
5155
|
+
const payload = await res.json();
|
|
5156
|
+
if (!res.ok && payload !== null && typeof payload === "object") return {
|
|
5157
|
+
ok: false,
|
|
5158
|
+
...payload
|
|
5159
|
+
};
|
|
5160
|
+
return payload;
|
|
5161
|
+
} catch {
|
|
5162
|
+
return { ok: res.ok };
|
|
5163
|
+
}
|
|
5164
|
+
} catch {
|
|
5165
|
+
return null;
|
|
5166
|
+
}
|
|
5167
|
+
}
|
|
5168
|
+
/** Small typed endpoint helper for the account-pool actions. */
|
|
5169
|
+
function postPool(action, body = {}) {
|
|
5170
|
+
return postJson(`${PLUGIN_BASE}/pool/${action}`, body);
|
|
5171
|
+
}
|
|
5172
|
+
/** The shared config-write helper (same /config endpoint the toggles use). */
|
|
5173
|
+
function postConfig(key, value) {
|
|
5174
|
+
return postJson(`${PLUGIN_BASE}/config`, {
|
|
5175
|
+
key,
|
|
5176
|
+
value
|
|
5177
|
+
});
|
|
5178
|
+
}
|
|
5179
|
+
const { createElement: h, useState, useEffect, useRef } = require("react");
|
|
5180
|
+
const reactDom = require("react-dom");
|
|
5181
|
+
//#endregion
|
|
5182
|
+
//#region src/client/status.ts
|
|
5183
|
+
const STATUS_CACHE_KEY = "dsh_agy_status_cache";
|
|
5184
|
+
function loadInitialStatusCache() {
|
|
5185
|
+
try {
|
|
5186
|
+
const raw = win.localStorage?.getItem(STATUS_CACHE_KEY);
|
|
5187
|
+
if (raw) {
|
|
5188
|
+
const parsed = JSON.parse(raw);
|
|
5189
|
+
if (parsed && typeof parsed === "object") return parsed;
|
|
5190
|
+
}
|
|
5191
|
+
} catch {}
|
|
5192
|
+
return null;
|
|
5193
|
+
}
|
|
5194
|
+
let statusCache = loadInitialStatusCache();
|
|
5195
|
+
async function getStatus() {
|
|
5196
|
+
try {
|
|
5197
|
+
const init = {};
|
|
5198
|
+
const signal = timedSignal(STATUS_TIMEOUT_MS);
|
|
5199
|
+
if (signal !== void 0) init.signal = signal;
|
|
5200
|
+
const res = await win.fetch?.(base + "/plugins/agy-link/status", init);
|
|
5201
|
+
if (!res || !res.ok) return null;
|
|
5202
|
+
return await res.json();
|
|
5203
|
+
} catch {
|
|
5204
|
+
return null;
|
|
5205
|
+
}
|
|
5206
|
+
}
|
|
5207
|
+
const statusListeners = /* @__PURE__ */ new Set();
|
|
5208
|
+
let statusPollTimer = null;
|
|
5209
|
+
let statusPollInterval = 3e3;
|
|
5210
|
+
let statusFetchSeq = 0;
|
|
5211
|
+
function isStatusEqual(a, b) {
|
|
5212
|
+
if (a === b) return true;
|
|
5213
|
+
if (a === null || b === null) return false;
|
|
5214
|
+
try {
|
|
5215
|
+
return JSON.stringify(a) === JSON.stringify(b);
|
|
5216
|
+
} catch {
|
|
5217
|
+
return false;
|
|
5218
|
+
}
|
|
5219
|
+
}
|
|
5220
|
+
/**
|
|
5221
|
+
* UI visibility switches are opt-out: a missing/undefined flag means the
|
|
5222
|
+
* affordance stays visible (older hosts, a not-yet-polled status, or a status
|
|
5223
|
+
* payload fetched before this version shipped). Only an explicit `false`
|
|
5224
|
+
* hides it.
|
|
5225
|
+
*/
|
|
5226
|
+
function isUiVisible(status, key) {
|
|
5227
|
+
return status?.[key] !== false;
|
|
5228
|
+
}
|
|
5229
|
+
/** Single writer for the shared status snapshot (poll loop, refresh, tests). */
|
|
5230
|
+
function publishStatus(st) {
|
|
5231
|
+
statusCache = st;
|
|
5232
|
+
try {
|
|
5233
|
+
win.localStorage?.setItem(STATUS_CACHE_KEY, JSON.stringify(st));
|
|
5234
|
+
} catch {}
|
|
5235
|
+
for (const fn of [...statusListeners]) try {
|
|
5236
|
+
fn(st);
|
|
5237
|
+
} catch {}
|
|
5238
|
+
}
|
|
5239
|
+
async function statusPollTick() {
|
|
5240
|
+
const seq = ++statusFetchSeq;
|
|
5241
|
+
const st = await getStatus();
|
|
5242
|
+
if (st !== null && seq === statusFetchSeq) {
|
|
5243
|
+
if (!isStatusEqual(statusCache, st)) publishStatus(st);
|
|
5244
|
+
}
|
|
5245
|
+
}
|
|
5246
|
+
function ensureStatusPolling() {
|
|
5247
|
+
if (statusPollTimer !== null) {
|
|
5248
|
+
if (statusPollInterval !== 3e3) {
|
|
5249
|
+
clearInterval(statusPollTimer);
|
|
5250
|
+
statusPollTimer = null;
|
|
5251
|
+
} else return;
|
|
5252
|
+
}
|
|
5253
|
+
statusPollInterval = 3e3;
|
|
5254
|
+
statusPollTick();
|
|
5255
|
+
statusPollTimer = setInterval(() => {
|
|
5256
|
+
statusPollTick();
|
|
5257
|
+
}, 3e3);
|
|
5258
|
+
}
|
|
5259
|
+
function stopStatusPollingIfIdle() {
|
|
5260
|
+
if (statusListeners.size === 0 && statusPollTimer !== null && statusPollInterval === 3e3) {
|
|
5261
|
+
clearInterval(statusPollTimer);
|
|
5262
|
+
statusPollInterval = 15e3;
|
|
5263
|
+
statusPollTimer = setInterval(() => {
|
|
5264
|
+
statusPollTick();
|
|
5265
|
+
}, 15e3);
|
|
5266
|
+
}
|
|
5267
|
+
}
|
|
5268
|
+
/** Stop the shared poll loop (plugin teardown / reload). */
|
|
5269
|
+
function disposeStatusPolling() {
|
|
5270
|
+
if (statusPollTimer !== null) {
|
|
5271
|
+
clearInterval(statusPollTimer);
|
|
5272
|
+
statusPollTimer = null;
|
|
5273
|
+
}
|
|
5274
|
+
}
|
|
5275
|
+
/**
|
|
5276
|
+
* Subscribe a component to the shared status poll. Returns the latest
|
|
5277
|
+
* snapshot plus a manual refresh that keeps the last good snapshot on a
|
|
5278
|
+
* transient failure (a failed refresh used to flip the whole panel back to
|
|
5279
|
+
* its loading state).
|
|
5280
|
+
*/
|
|
5281
|
+
function useAgyStatus() {
|
|
5282
|
+
const [status, setStatus] = useState(statusCache);
|
|
5283
|
+
useEffect(() => {
|
|
5284
|
+
statusListeners.add(setStatus);
|
|
5285
|
+
ensureStatusPolling();
|
|
5286
|
+
return () => {
|
|
5287
|
+
statusListeners.delete(setStatus);
|
|
5288
|
+
stopStatusPollingIfIdle();
|
|
5289
|
+
};
|
|
5290
|
+
}, []);
|
|
5291
|
+
const refresh = async () => {
|
|
5292
|
+
const st = await getStatus();
|
|
5293
|
+
if (st !== null && !isStatusEqual(statusCache, st)) publishStatus(st);
|
|
5294
|
+
};
|
|
5295
|
+
return {
|
|
5296
|
+
status,
|
|
5297
|
+
refresh
|
|
5298
|
+
};
|
|
5299
|
+
}
|
|
5300
|
+
//#endregion
|
|
4944
5301
|
//#region src/client/translate-state.ts
|
|
4945
5302
|
async function postTranslate(body) {
|
|
4946
5303
|
try {
|
|
@@ -5222,6 +5579,8 @@ body.dark .agy-tsl-card,
|
|
|
5222
5579
|
messageId,
|
|
5223
5580
|
sessionId
|
|
5224
5581
|
]);
|
|
5582
|
+
const { status } = useAgyStatus();
|
|
5583
|
+
if (!isUiVisible(status, "showTranslateAction")) return null;
|
|
5225
5584
|
if (messageId === "" || sessionId === "") return null;
|
|
5226
5585
|
const apply = (next) => {
|
|
5227
5586
|
setActionState(key, next);
|
|
@@ -5745,8 +6104,6 @@ body.dark .agy-tsl-card,
|
|
|
5745
6104
|
compactionDispose = dispose;
|
|
5746
6105
|
return dispose;
|
|
5747
6106
|
}
|
|
5748
|
-
const { createElement: h, useState, useEffect, useRef } = require("react");
|
|
5749
|
-
const reactDom = require("react-dom");
|
|
5750
6107
|
//#endregion
|
|
5751
6108
|
//#region src/client/icons.ts
|
|
5752
6109
|
/** Inline brand logo (Gemini / Claude / OpenAI) as a crisp SVG mark. */
|
|
@@ -6017,152 +6374,6 @@ body.dark .agy-tsl-card,
|
|
|
6017
6374
|
};
|
|
6018
6375
|
}
|
|
6019
6376
|
//#endregion
|
|
6020
|
-
//#region src/client/api.ts
|
|
6021
|
-
const win = globalThis;
|
|
6022
|
-
const base = win.location?.origin ?? "";
|
|
6023
|
-
const PLUGIN_BASE = "/plugins/agy-link";
|
|
6024
|
-
async function postJson(path, body) {
|
|
6025
|
-
try {
|
|
6026
|
-
const res = await win.fetch?.(base + path, {
|
|
6027
|
-
method: "POST",
|
|
6028
|
-
headers: { "Content-Type": "application/json" },
|
|
6029
|
-
body: JSON.stringify(body)
|
|
6030
|
-
});
|
|
6031
|
-
if (!res) return null;
|
|
6032
|
-
try {
|
|
6033
|
-
const payload = await res.json();
|
|
6034
|
-
if (!res.ok && payload !== null && typeof payload === "object") return {
|
|
6035
|
-
ok: false,
|
|
6036
|
-
...payload
|
|
6037
|
-
};
|
|
6038
|
-
return payload;
|
|
6039
|
-
} catch {
|
|
6040
|
-
return { ok: res.ok };
|
|
6041
|
-
}
|
|
6042
|
-
} catch {
|
|
6043
|
-
return null;
|
|
6044
|
-
}
|
|
6045
|
-
}
|
|
6046
|
-
/** Small typed endpoint helper for the account-pool actions. */
|
|
6047
|
-
function postPool(action, body = {}) {
|
|
6048
|
-
return postJson(`${PLUGIN_BASE}/pool/${action}`, body);
|
|
6049
|
-
}
|
|
6050
|
-
/** The shared config-write helper (same /config endpoint the toggles use). */
|
|
6051
|
-
function postConfig(key, value) {
|
|
6052
|
-
return postJson(`${PLUGIN_BASE}/config`, {
|
|
6053
|
-
key,
|
|
6054
|
-
value
|
|
6055
|
-
});
|
|
6056
|
-
}
|
|
6057
|
-
//#endregion
|
|
6058
|
-
//#region src/client/status.ts
|
|
6059
|
-
const STATUS_CACHE_KEY = "dsh_agy_status_cache";
|
|
6060
|
-
function loadInitialStatusCache() {
|
|
6061
|
-
try {
|
|
6062
|
-
const raw = win.localStorage?.getItem(STATUS_CACHE_KEY);
|
|
6063
|
-
if (raw) {
|
|
6064
|
-
const parsed = JSON.parse(raw);
|
|
6065
|
-
if (parsed && typeof parsed === "object") return parsed;
|
|
6066
|
-
}
|
|
6067
|
-
} catch {}
|
|
6068
|
-
return null;
|
|
6069
|
-
}
|
|
6070
|
-
let statusCache = loadInitialStatusCache();
|
|
6071
|
-
async function getStatus() {
|
|
6072
|
-
try {
|
|
6073
|
-
const init = {};
|
|
6074
|
-
if (typeof AbortSignal !== "undefined" && typeof AbortSignal.timeout === "function") init.signal = AbortSignal.timeout(5e3);
|
|
6075
|
-
const res = await win.fetch?.(base + "/plugins/agy-link/status", init);
|
|
6076
|
-
if (!res || !res.ok) return null;
|
|
6077
|
-
return await res.json();
|
|
6078
|
-
} catch {
|
|
6079
|
-
return null;
|
|
6080
|
-
}
|
|
6081
|
-
}
|
|
6082
|
-
const statusListeners = /* @__PURE__ */ new Set();
|
|
6083
|
-
let statusPollTimer = null;
|
|
6084
|
-
let statusPollInterval = 3e3;
|
|
6085
|
-
let statusFetchSeq = 0;
|
|
6086
|
-
function isStatusEqual(a, b) {
|
|
6087
|
-
if (a === b) return true;
|
|
6088
|
-
if (a === null || b === null) return false;
|
|
6089
|
-
try {
|
|
6090
|
-
return JSON.stringify(a) === JSON.stringify(b);
|
|
6091
|
-
} catch {
|
|
6092
|
-
return false;
|
|
6093
|
-
}
|
|
6094
|
-
}
|
|
6095
|
-
function notifyStatus(st) {
|
|
6096
|
-
statusCache = st;
|
|
6097
|
-
try {
|
|
6098
|
-
win.localStorage?.setItem(STATUS_CACHE_KEY, JSON.stringify(st));
|
|
6099
|
-
} catch {}
|
|
6100
|
-
for (const fn of [...statusListeners]) try {
|
|
6101
|
-
fn(st);
|
|
6102
|
-
} catch {}
|
|
6103
|
-
}
|
|
6104
|
-
async function statusPollTick() {
|
|
6105
|
-
const seq = ++statusFetchSeq;
|
|
6106
|
-
const st = await getStatus();
|
|
6107
|
-
if (st !== null && seq === statusFetchSeq) {
|
|
6108
|
-
if (!isStatusEqual(statusCache, st)) notifyStatus(st);
|
|
6109
|
-
}
|
|
6110
|
-
}
|
|
6111
|
-
function ensureStatusPolling() {
|
|
6112
|
-
if (statusPollTimer !== null) {
|
|
6113
|
-
if (statusPollInterval !== 3e3) {
|
|
6114
|
-
clearInterval(statusPollTimer);
|
|
6115
|
-
statusPollTimer = null;
|
|
6116
|
-
} else return;
|
|
6117
|
-
}
|
|
6118
|
-
statusPollInterval = 3e3;
|
|
6119
|
-
statusPollTick();
|
|
6120
|
-
statusPollTimer = setInterval(() => {
|
|
6121
|
-
statusPollTick();
|
|
6122
|
-
}, 3e3);
|
|
6123
|
-
}
|
|
6124
|
-
function stopStatusPollingIfIdle() {
|
|
6125
|
-
if (statusListeners.size === 0 && statusPollTimer !== null && statusPollInterval === 3e3) {
|
|
6126
|
-
clearInterval(statusPollTimer);
|
|
6127
|
-
statusPollInterval = 15e3;
|
|
6128
|
-
statusPollTimer = setInterval(() => {
|
|
6129
|
-
statusPollTick();
|
|
6130
|
-
}, 15e3);
|
|
6131
|
-
}
|
|
6132
|
-
}
|
|
6133
|
-
/** Stop the shared poll loop (plugin teardown / reload). */
|
|
6134
|
-
function disposeStatusPolling() {
|
|
6135
|
-
if (statusPollTimer !== null) {
|
|
6136
|
-
clearInterval(statusPollTimer);
|
|
6137
|
-
statusPollTimer = null;
|
|
6138
|
-
}
|
|
6139
|
-
}
|
|
6140
|
-
/**
|
|
6141
|
-
* Subscribe a component to the shared status poll. Returns the latest
|
|
6142
|
-
* snapshot plus a manual refresh that keeps the last good snapshot on a
|
|
6143
|
-
* transient failure (a failed refresh used to flip the whole panel back to
|
|
6144
|
-
* its loading state).
|
|
6145
|
-
*/
|
|
6146
|
-
function useAgyStatus() {
|
|
6147
|
-
const [status, setStatus] = useState(statusCache);
|
|
6148
|
-
useEffect(() => {
|
|
6149
|
-
statusListeners.add(setStatus);
|
|
6150
|
-
ensureStatusPolling();
|
|
6151
|
-
return () => {
|
|
6152
|
-
statusListeners.delete(setStatus);
|
|
6153
|
-
stopStatusPollingIfIdle();
|
|
6154
|
-
};
|
|
6155
|
-
}, []);
|
|
6156
|
-
const refresh = async () => {
|
|
6157
|
-
const st = await getStatus();
|
|
6158
|
-
if (st !== null && !isStatusEqual(statusCache, st)) notifyStatus(st);
|
|
6159
|
-
};
|
|
6160
|
-
return {
|
|
6161
|
-
status,
|
|
6162
|
-
refresh
|
|
6163
|
-
};
|
|
6164
|
-
}
|
|
6165
|
-
//#endregion
|
|
6166
6377
|
//#region src/client/global-css.ts
|
|
6167
6378
|
const GLOBAL_CSS = `
|
|
6168
6379
|
@keyframes agy-spin {
|
|
@@ -6588,6 +6799,13 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
6588
6799
|
overrides here are deliberately blunt.
|
|
6589
6800
|
------------------------------------------------------------------ */
|
|
6590
6801
|
@media (max-width: 680px) {
|
|
6802
|
+
.agy-session-status-label {
|
|
6803
|
+
display: none !important;
|
|
6804
|
+
}
|
|
6805
|
+
.agy-session-status-btn {
|
|
6806
|
+
padding: 4px 6px !important;
|
|
6807
|
+
min-width: 0 !important;
|
|
6808
|
+
}
|
|
6591
6809
|
.agy-modal-backdrop {
|
|
6592
6810
|
padding: 0 !important;
|
|
6593
6811
|
align-items: stretch !important;
|
|
@@ -7160,13 +7378,37 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
7160
7378
|
}, children)));
|
|
7161
7379
|
}
|
|
7162
7380
|
//#endregion
|
|
7381
|
+
//#region src/common/model-lineup.ts
|
|
7382
|
+
/** Models the plugin treats as the Gemini family for UI filtering. */
|
|
7383
|
+
function isGeminiFamilyModel(id) {
|
|
7384
|
+
return /gemini/i.test(typeof id === "string" ? id : "");
|
|
7385
|
+
}
|
|
7386
|
+
//#endregion
|
|
7163
7387
|
//#region src/client/config-options.ts
|
|
7164
|
-
/**
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7169
|
-
|
|
7388
|
+
/** Effort ids carried by a catalog entry (order preserved, deduped). */
|
|
7389
|
+
function modelEfforts(model) {
|
|
7390
|
+
if (model === void 0 || model === null) return [];
|
|
7391
|
+
const raw = model.efforts;
|
|
7392
|
+
if (!Array.isArray(raw)) return [];
|
|
7393
|
+
const out = [];
|
|
7394
|
+
for (const item of raw) {
|
|
7395
|
+
if (typeof item !== "string") continue;
|
|
7396
|
+
const id = item.trim().toLowerCase();
|
|
7397
|
+
if (id !== "" && !out.includes(id)) out.push(id);
|
|
7398
|
+
}
|
|
7399
|
+
return out;
|
|
7400
|
+
}
|
|
7401
|
+
/** Effort ids supported anywhere in the catalog (fallback when no model is chosen). */
|
|
7402
|
+
function catalogEfforts(models) {
|
|
7403
|
+
const out = [];
|
|
7404
|
+
for (const model of models) for (const id of modelEfforts(model)) if (!out.includes(id)) out.push(id);
|
|
7405
|
+
return out;
|
|
7406
|
+
}
|
|
7407
|
+
function findCatalogModel(modelId, models) {
|
|
7408
|
+
const wanted = typeof modelId === "string" ? modelId.trim() : "";
|
|
7409
|
+
if (wanted === "") return void 0;
|
|
7410
|
+
return models.find((model) => typeof model?.id === "string" && model.id.trim() === wanted);
|
|
7411
|
+
}
|
|
7170
7412
|
/**
|
|
7171
7413
|
* Translation-model dropdown: `''` (host fallback chain: gemini-3.8-flash →
|
|
7172
7414
|
* newest gemini-*-flash → conversation default) plus every catalog model.
|
|
@@ -7200,30 +7442,65 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
7200
7442
|
* hand is still appended by `translateModelOptions`, so the state stays honest.
|
|
7201
7443
|
*/
|
|
7202
7444
|
function geminiCatalogModels(models) {
|
|
7203
|
-
return models.filter((model) => typeof model?.id === "string" &&
|
|
7445
|
+
return models.filter((model) => typeof model?.id === "string" && isGeminiFamilyModel(model.id));
|
|
7204
7446
|
}
|
|
7205
7447
|
/**
|
|
7206
|
-
* Thinking-effort dropdown: `''` (follow the
|
|
7207
|
-
*
|
|
7208
|
-
*
|
|
7448
|
+
* Thinking-effort dropdown for a specific model: `''` (follow the model's
|
|
7449
|
+
* default) plus exactly the levels THAT model supports, in the catalog's own
|
|
7450
|
+
* order.
|
|
7451
|
+
*
|
|
7452
|
+
* Deriving from the catalog instead of a local low/medium/high list is what
|
|
7453
|
+
* keeps this control honest: a model with no `--effort` support gets no levels
|
|
7454
|
+
* at all, and a model with an extra level (agy 1.5.7's `xhigh` → "Extra") gets
|
|
7455
|
+
* it without any code change. An unrecognised configured level is still
|
|
7456
|
+
* appended verbatim so the select can display the real state.
|
|
7209
7457
|
*/
|
|
7210
|
-
function translateEffortOptions(current, labels) {
|
|
7458
|
+
function translateEffortOptions(current, labels, modelId = "", models = []) {
|
|
7211
7459
|
const options = [{
|
|
7212
7460
|
value: "",
|
|
7213
7461
|
label: labels.auto
|
|
7214
7462
|
}];
|
|
7215
|
-
|
|
7463
|
+
const chosen = findCatalogModel(modelId, models);
|
|
7464
|
+
const supported = chosen === void 0 ? catalogEfforts(models) : modelEfforts(chosen);
|
|
7465
|
+
for (const level of supported) options.push({
|
|
7216
7466
|
value: level,
|
|
7217
|
-
label: labels
|
|
7467
|
+
label: labels.level(level)
|
|
7218
7468
|
});
|
|
7219
7469
|
const wanted = typeof current === "string" ? current.trim().toLowerCase() : "";
|
|
7220
7470
|
if (wanted !== "" && !options.some((option) => option.value === wanted)) options.push({
|
|
7221
7471
|
value: wanted,
|
|
7222
|
-
label: wanted
|
|
7472
|
+
label: labels.level(wanted)
|
|
7223
7473
|
});
|
|
7224
7474
|
return options;
|
|
7225
7475
|
}
|
|
7226
7476
|
//#endregion
|
|
7477
|
+
//#region src/common/reasoning.ts
|
|
7478
|
+
/** Every effort id agy accepts, in ascending intensity order. */
|
|
7479
|
+
const REASONING_EFFORTS = [
|
|
7480
|
+
"low",
|
|
7481
|
+
"medium",
|
|
7482
|
+
"high",
|
|
7483
|
+
"xhigh",
|
|
7484
|
+
"max"
|
|
7485
|
+
];
|
|
7486
|
+
/**
|
|
7487
|
+
* Display names, matching agy's own model picker ("Extra" is `xhigh`, which is
|
|
7488
|
+
* how the GUI labels it while `agy --help` spells it `xhigh`).
|
|
7489
|
+
*/
|
|
7490
|
+
const EFFORT_LABELS = {
|
|
7491
|
+
low: "Low",
|
|
7492
|
+
medium: "Medium",
|
|
7493
|
+
high: "High",
|
|
7494
|
+
xhigh: "Extra",
|
|
7495
|
+
max: "Max"
|
|
7496
|
+
};
|
|
7497
|
+
/** Display name for an effort id; unknown ids are shown verbatim. */
|
|
7498
|
+
function effortLabel(id) {
|
|
7499
|
+
const key = typeof id === "string" ? id.trim().toLowerCase() : "";
|
|
7500
|
+
return EFFORT_LABELS[key] ?? (typeof id === "string" ? id.trim() : "");
|
|
7501
|
+
}
|
|
7502
|
+
[...REASONING_EFFORTS].sort((a, b) => b.length - a.length || a.localeCompare(b));
|
|
7503
|
+
//#endregion
|
|
7227
7504
|
//#region src/client/hooks/useTranslation.ts
|
|
7228
7505
|
function useAgyTranslation(locale) {
|
|
7229
7506
|
const [, rerender] = useState(0);
|
|
@@ -7337,7 +7614,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
7337
7614
|
return;
|
|
7338
7615
|
}
|
|
7339
7616
|
await refresh();
|
|
7340
|
-
showToast(t("quota.refreshed"), "success");
|
|
7617
|
+
showToast(res?.pending === true ? t("quota.refreshStarted") : t("quota.refreshed"), res?.pending === true ? "info" : "success");
|
|
7341
7618
|
} finally {
|
|
7342
7619
|
setLoadingAction(null);
|
|
7343
7620
|
}
|
|
@@ -7663,6 +7940,11 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
7663
7940
|
} }, left, right);
|
|
7664
7941
|
}
|
|
7665
7942
|
//#endregion
|
|
7943
|
+
//#region src/client/ui/SegGroup.ts
|
|
7944
|
+
function segGroup(children) {
|
|
7945
|
+
return h("div", { style: S.segGroup }, children);
|
|
7946
|
+
}
|
|
7947
|
+
//#endregion
|
|
7666
7948
|
//#region src/client/ui/Select.ts
|
|
7667
7949
|
function Select({ value, options, onChange, ariaLabel, title, disabled, style }) {
|
|
7668
7950
|
return h("select", {
|
|
@@ -8401,10 +8683,12 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8401
8683
|
gap: "6px"
|
|
8402
8684
|
} }, catalogModels.map((m) => {
|
|
8403
8685
|
const isHidden = hiddenModelSet.has(m.id);
|
|
8686
|
+
const efforts = (m.efforts ?? []).map((id) => effortLabel(id));
|
|
8687
|
+
const title = efforts.length > 0 ? m.id + " · " + efforts.join(" / ") : m.id;
|
|
8404
8688
|
return h(Button, {
|
|
8405
8689
|
key: m.id,
|
|
8406
8690
|
variant: isHidden ? "seg" : "segActive",
|
|
8407
|
-
title
|
|
8691
|
+
title,
|
|
8408
8692
|
disabled: loadingAction === "config:hiddenModels",
|
|
8409
8693
|
style: isHidden ? {
|
|
8410
8694
|
opacity: .45,
|
|
@@ -8415,8 +8699,77 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8415
8699
|
})), h("span", { style: S.muted }, t("models.hint")));
|
|
8416
8700
|
}
|
|
8417
8701
|
//#endregion
|
|
8702
|
+
//#region src/client/sections/VisibilityRows.ts
|
|
8703
|
+
function visibilityRow(o) {
|
|
8704
|
+
return h(Row, {
|
|
8705
|
+
left: h("div", { style: {
|
|
8706
|
+
display: "flex",
|
|
8707
|
+
flexDirection: "column"
|
|
8708
|
+
} }, h("span", { style: {
|
|
8709
|
+
color: "var(--agy-text-primary)",
|
|
8710
|
+
fontWeight: 600,
|
|
8711
|
+
fontSize: "12.5px"
|
|
8712
|
+
} }, o.t(o.label)), h("span", { style: S.muted }, o.t(o.desc))),
|
|
8713
|
+
right: segGroup([h(Button, {
|
|
8714
|
+
variant: o.visible ? "segActive" : "seg",
|
|
8715
|
+
disabled: o.loadingAction === "config:" + o.key,
|
|
8716
|
+
onClick: () => void o.setCfg(o.key, true)
|
|
8717
|
+
}, o.t("config.on")), h(Button, {
|
|
8718
|
+
variant: !o.visible ? "segActive" : "seg",
|
|
8719
|
+
disabled: o.loadingAction === "config:" + o.key,
|
|
8720
|
+
onClick: () => void o.setCfg(o.key, false)
|
|
8721
|
+
}, o.t("config.off"))])
|
|
8722
|
+
});
|
|
8723
|
+
}
|
|
8724
|
+
/** Returns two rows; React flattens the array inside the parent's children. */
|
|
8725
|
+
function renderVisibilityRows(args) {
|
|
8726
|
+
const common = {
|
|
8727
|
+
t: args.t,
|
|
8728
|
+
loadingAction: args.loadingAction,
|
|
8729
|
+
setCfg: args.setCfg
|
|
8730
|
+
};
|
|
8731
|
+
return [visibilityRow({
|
|
8732
|
+
...common,
|
|
8733
|
+
label: "config.showHeaderBadge",
|
|
8734
|
+
desc: "config.showHeaderBadgeDesc",
|
|
8735
|
+
key: "showHeaderBadge",
|
|
8736
|
+
visible: args.status.showHeaderBadge !== false
|
|
8737
|
+
}), visibilityRow({
|
|
8738
|
+
...common,
|
|
8739
|
+
label: "config.showTranslateAction",
|
|
8740
|
+
desc: "config.showTranslateActionDesc",
|
|
8741
|
+
key: "showTranslateAction",
|
|
8742
|
+
visible: args.status.showTranslateAction !== false
|
|
8743
|
+
})];
|
|
8744
|
+
}
|
|
8745
|
+
//#endregion
|
|
8418
8746
|
//#region src/client/sections/SettingsSection.ts
|
|
8747
|
+
/**
|
|
8748
|
+
* BUSY-STATE WATCHDOG. Every action sets a busy flag and clears it when its
|
|
8749
|
+
* request settles. A host route with no .catch, a 20s `agy /usage` spawn, or a
|
|
8750
|
+
* browser fetch with no timeout each used to leave "同步中" spinning forever.
|
|
8751
|
+
* The request layer now bounds those; this is the final invariant — no busy
|
|
8752
|
+
* flag may outlive BUSY_TIMEOUT_MS.
|
|
8753
|
+
*/
|
|
8754
|
+
function useBusyAction() {
|
|
8755
|
+
const [loadingAction, setLoadingAction] = useState(null);
|
|
8756
|
+
const timerRef = useRef(null);
|
|
8757
|
+
const set = (value) => {
|
|
8758
|
+
setLoadingAction(value);
|
|
8759
|
+
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
8760
|
+
timerRef.current = value === null ? null : setTimeout(() => {
|
|
8761
|
+
timerRef.current = null;
|
|
8762
|
+
setLoadingAction(null);
|
|
8763
|
+
}, BUSY_TIMEOUT_MS);
|
|
8764
|
+
};
|
|
8765
|
+
useEffect(() => () => {
|
|
8766
|
+
if (timerRef.current !== null) clearTimeout(timerRef.current);
|
|
8767
|
+
}, []);
|
|
8768
|
+
return [loadingAction, set];
|
|
8769
|
+
}
|
|
8419
8770
|
const IMAGE_CLI_SAMPLE = "dsh-agy-image -p \"…\" -a 16:9 -o ./image.jpg";
|
|
8771
|
+
/** Slightly longer than a bounded write, so a normal failure still shows its own toast. */
|
|
8772
|
+
const BUSY_TIMEOUT_MS = 25e3;
|
|
8420
8773
|
function createSettingsSection(locale) {
|
|
8421
8774
|
return function AgySettingsSection(_props) {
|
|
8422
8775
|
const t = useAgyTranslation(locale);
|
|
@@ -8438,7 +8791,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8438
8791
|
setToast((prev) => prev !== null && prev.text === text ? null : prev);
|
|
8439
8792
|
}, 6e3);
|
|
8440
8793
|
};
|
|
8441
|
-
const [loadingAction, setLoadingAction] =
|
|
8794
|
+
const [loadingAction, setLoadingAction] = useBusyAction();
|
|
8442
8795
|
const [proxyInputs, setProxyInputs] = useState({});
|
|
8443
8796
|
const [editingProxyId, setEditingProxyId] = useState(null);
|
|
8444
8797
|
const [expandedModels, setExpandedModels] = useState({});
|
|
@@ -8779,8 +9132,20 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8779
9132
|
onClick: () => auth.setImportMode(true)
|
|
8780
9133
|
}, t("auth.tokenTab"))) : null), !flowActive ? auth.importMode ? renderTokenImportForm(t, auth, pool, isBusy, loadingAction) : renderBrowserOAuthForm(t, auth, pool, isBusy, loadingAction) : renderWaitingCodeForm(t, auth, isBusy, loadingAction));
|
|
8781
9134
|
}
|
|
8782
|
-
|
|
8783
|
-
|
|
9135
|
+
/**
|
|
9136
|
+
* Effort labels for the dropdowns. Localised when the locale defines the id,
|
|
9137
|
+
* otherwise agy's own English name (Low/Medium/High/Extra/Max) — the same
|
|
9138
|
+
* names the host's model menu shows, so both surfaces read identically.
|
|
9139
|
+
*/
|
|
9140
|
+
function effortLabels(t) {
|
|
9141
|
+
return {
|
|
9142
|
+
auto: t("config.translateEffortAuto"),
|
|
9143
|
+
level: (id) => {
|
|
9144
|
+
const key = "effort." + id;
|
|
9145
|
+
const localised = t(key);
|
|
9146
|
+
return localised === key ? effortLabel(id) : localised;
|
|
9147
|
+
}
|
|
9148
|
+
};
|
|
8784
9149
|
}
|
|
8785
9150
|
function renderRuntimeConfig(t, status, pool, catalogModels, hiddenModelSet, loadingAction, actions) {
|
|
8786
9151
|
const { setCfg, setMode, toggleModelHidden, copyImageCommand } = actions;
|
|
@@ -8869,14 +9234,14 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8869
9234
|
},
|
|
8870
9235
|
disabled: loadingAction === "config:translateEffort",
|
|
8871
9236
|
onChange: (e) => void setCfg("translateEffort", e?.target?.value ?? ""),
|
|
8872
|
-
options: translateEffortOptions(status.translateEffort ?? "",
|
|
8873
|
-
auto: t("config.translateEffortAuto"),
|
|
8874
|
-
low: t("effort.low"),
|
|
8875
|
-
medium: t("effort.medium"),
|
|
8876
|
-
high: t("effort.high")
|
|
8877
|
-
})
|
|
9237
|
+
options: translateEffortOptions(status.translateEffort ?? "", effortLabels(t), status.translateModel ?? "", catalogModels)
|
|
8878
9238
|
}))
|
|
8879
|
-
}), renderImageRow(t, status, catalogModels, loadingAction, setCfg, copyImageCommand),
|
|
9239
|
+
}), renderImageRow(t, status, catalogModels, loadingAction, setCfg, copyImageCommand), renderVisibilityRows({
|
|
9240
|
+
t,
|
|
9241
|
+
status,
|
|
9242
|
+
loadingAction,
|
|
9243
|
+
setCfg
|
|
9244
|
+
}), renderDefaultEffortRow(t, status, catalogModels, loadingAction, setCfg), h(ModelsPanel, {
|
|
8880
9245
|
t,
|
|
8881
9246
|
catalogModels,
|
|
8882
9247
|
hiddenModelSet,
|
|
@@ -8884,8 +9249,18 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8884
9249
|
toggleModelHidden
|
|
8885
9250
|
})));
|
|
8886
9251
|
}
|
|
8887
|
-
|
|
9252
|
+
/**
|
|
9253
|
+
* Default thinking effort. The buttons come from the LIVE catalog, not a local
|
|
9254
|
+
* low/medium/high list: when agy ships a new level (1.5.7 added `xhigh`) the
|
|
9255
|
+
* row gains it with no code change, and it can never offer a level no model
|
|
9256
|
+
* supports.
|
|
9257
|
+
*/
|
|
9258
|
+
function renderDefaultEffortRow(t, status, catalogModels, loadingAction, setCfg) {
|
|
8888
9259
|
const value = status.defaultEffort;
|
|
9260
|
+
const labels = effortLabels(t);
|
|
9261
|
+
const levels = catalogEfforts(catalogModels);
|
|
9262
|
+
const configured = (value ?? "").trim().toLowerCase();
|
|
9263
|
+
const shown = configured !== "" && !levels.includes(configured) ? [...levels, configured] : levels;
|
|
8889
9264
|
return h(Row, {
|
|
8890
9265
|
left: h("div", { style: {
|
|
8891
9266
|
display: "flex",
|
|
@@ -8895,28 +9270,16 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8895
9270
|
fontWeight: 600,
|
|
8896
9271
|
fontSize: "12.5px"
|
|
8897
9272
|
} }, t("config.defaultEffort")), h("span", { style: S.muted }, t("config.defaultEffortDesc"))),
|
|
8898
|
-
right: segGroup([
|
|
8899
|
-
|
|
8900
|
-
|
|
8901
|
-
|
|
8902
|
-
|
|
8903
|
-
|
|
8904
|
-
|
|
8905
|
-
|
|
8906
|
-
|
|
8907
|
-
|
|
8908
|
-
}, t("effort.low")),
|
|
8909
|
-
h(Button, {
|
|
8910
|
-
variant: value === "medium" ? "segActive" : "seg",
|
|
8911
|
-
disabled: loadingAction === "config:defaultEffort",
|
|
8912
|
-
onClick: () => void setCfg("defaultEffort", "medium")
|
|
8913
|
-
}, t("effort.medium")),
|
|
8914
|
-
h(Button, {
|
|
8915
|
-
variant: value === "high" ? "segActive" : "seg",
|
|
8916
|
-
disabled: loadingAction === "config:defaultEffort",
|
|
8917
|
-
onClick: () => void setCfg("defaultEffort", "high")
|
|
8918
|
-
}, t("effort.high"))
|
|
8919
|
-
])
|
|
9273
|
+
right: segGroup([h(Button, {
|
|
9274
|
+
variant: value === "" ? "segActive" : "seg",
|
|
9275
|
+
disabled: loadingAction === "config:defaultEffort",
|
|
9276
|
+
onClick: () => void setCfg("defaultEffort", "")
|
|
9277
|
+
}, t("effort.auto")), ...shown.map((level) => h(Button, {
|
|
9278
|
+
key: level,
|
|
9279
|
+
variant: value === level ? "segActive" : "seg",
|
|
9280
|
+
disabled: loadingAction === "config:defaultEffort",
|
|
9281
|
+
onClick: () => void setCfg("defaultEffort", level)
|
|
9282
|
+
}, labels.level(level)))])
|
|
8920
9283
|
});
|
|
8921
9284
|
}
|
|
8922
9285
|
function renderImageRow(t, status, catalogModels, loadingAction, setCfg, copyImageCommand) {
|
|
@@ -8955,12 +9318,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
8955
9318
|
},
|
|
8956
9319
|
disabled: loadingAction === "config:imageEffort",
|
|
8957
9320
|
onChange: (e) => void setCfg("imageEffort", e?.target?.value ?? ""),
|
|
8958
|
-
options: translateEffortOptions(status.imageEffort ?? "",
|
|
8959
|
-
auto: t("config.translateEffortAuto"),
|
|
8960
|
-
low: t("effort.low"),
|
|
8961
|
-
medium: t("effort.medium"),
|
|
8962
|
-
high: t("effort.high")
|
|
8963
|
-
})
|
|
9321
|
+
options: translateEffortOptions(status.imageEffort ?? "", effortLabels(t), status.imageModel ?? "", catalogModels)
|
|
8964
9322
|
}))), h("div", { style: {
|
|
8965
9323
|
display: "flex",
|
|
8966
9324
|
alignItems: "center",
|
|
@@ -9038,7 +9396,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
9038
9396
|
const badge = h(Button, {
|
|
9039
9397
|
variant: "pill",
|
|
9040
9398
|
title: badgeTitle,
|
|
9041
|
-
className: "agy-btn",
|
|
9399
|
+
className: "agy-btn agy-session-status-btn",
|
|
9042
9400
|
onClick: () => {
|
|
9043
9401
|
modalHostManager.claim(hostId);
|
|
9044
9402
|
agyModalStore.setOpen(true);
|
|
@@ -9048,12 +9406,15 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
9048
9406
|
width: "7px",
|
|
9049
9407
|
height: "7px",
|
|
9050
9408
|
borderRadius: "50%",
|
|
9051
|
-
background: color
|
|
9052
|
-
|
|
9053
|
-
|
|
9409
|
+
background: color,
|
|
9410
|
+
flexShrink: 0
|
|
9411
|
+
} }), h("span", { className: "agy-session-status-label" }, buttonLabel));
|
|
9412
|
+
const modalPortal = isPrimaryHost && isModalOpen ? portalToBody(h(ConsoleDialog, {
|
|
9054
9413
|
t,
|
|
9055
9414
|
SettingsSection
|
|
9056
|
-
})) : null
|
|
9415
|
+
})) : null;
|
|
9416
|
+
if (!isUiVisible(status, "showHeaderBadge")) return modalPortal;
|
|
9417
|
+
return h("div", { style: { display: "inline-block" } }, badge, modalPortal);
|
|
9057
9418
|
};
|
|
9058
9419
|
}
|
|
9059
9420
|
function ConsoleDialog({ t, SettingsSection }) {
|
|
@@ -9084,6 +9445,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
9084
9445
|
const name = "dsh-agy-link-client";
|
|
9085
9446
|
const inject = ["slots", "locale"];
|
|
9086
9447
|
function apply(ctx) {
|
|
9448
|
+
setClientContext(ctx);
|
|
9087
9449
|
injectGlobalStyles();
|
|
9088
9450
|
ctx.effect(() => {
|
|
9089
9451
|
ensureStatusPolling();
|
|
@@ -9193,7 +9555,7 @@ body[data-ds-dark-theme] select.agy-select { color-scheme: dark; }
|
|
|
9193
9555
|
}
|
|
9194
9556
|
ctx.effect(() => installAutoExpandReasoning());
|
|
9195
9557
|
ctx.effect(() => installMermaidRendering());
|
|
9196
|
-
ctx.effect(() => installImageEnhancer());
|
|
9558
|
+
ctx.effect(() => installImageEnhancer(ctx));
|
|
9197
9559
|
ctx.effect(() => installDecisionChips());
|
|
9198
9560
|
ctx.effect(() => installCompactionCard());
|
|
9199
9561
|
ctx.effect(() => {
|