dsh-agy-link 0.4.100 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.js CHANGED
@@ -192,7 +192,33 @@ window.__ModuleLoader__.load({
192
192
  "warmup.allSuccess": "一键预热任务已完成",
193
193
  "warmup.skipped": "当前账号或模型处于冷却中,无需预热",
194
194
  "config.autoWarmup": "7天周配额自动预热",
195
- "config.autoWarmupDesc": "周配额到达重置时间或冷启动时自动唤醒 1 次启动新周期"
195
+ "config.autoWarmupDesc": "周配额到达重置时间或冷启动时自动唤醒 1 次启动新周期",
196
+ "config.autoTranslate": "自动翻译",
197
+ "config.autoTranslateDesc": "每个回合结束后,用 Gemini 把最后的回复翻成大白话,显示在该回复下方",
198
+ "config.on": "开启",
199
+ "config.off": "关闭",
200
+ "config.runtimeTitle": "运行方式",
201
+ "config.runtimeDesc": "权限模式固定 skip(静默执行,AGY 内置保护仍然生效);推理强度由下面的「默认思考强度」决定模型下拉框的初始档位,也可在该下拉框里按模型单独切换。",
202
+ "config.defaultEffort": "默认思考强度",
203
+ "config.defaultEffortDesc": "auto = 各模型用自身默认档;选定后作为会话模型下拉框的初始档位,仍可按模型覆盖",
204
+ "tsl.badge": "Gemini 译文",
205
+ "tsl.plain": "人话版",
206
+ "tsl.byGemini": "由 Gemini 翻译",
207
+ "tsl.translate": "译成人话",
208
+ "tsl.actionTip": "用 Gemini 把这条回复译成人话",
209
+ "tsl.translating": "翻译中…",
210
+ "tsl.done": "已生成译文",
211
+ "tsl.pending": "Gemini 正在翻译…",
212
+ "tsl.copy": "复制",
213
+ "tsl.copied": "已复制",
214
+ "tsl.original": "原文",
215
+ "tsl.showOriginal": "查看原文",
216
+ "tsl.hideOriginal": "收起原文",
217
+ "tsl.failed": "翻译失败",
218
+ "tsl.retry": "重试",
219
+ "tsl.empty": "没有可翻译的内容",
220
+ "tsl.collapse": "收起",
221
+ "tsl.expand": "展开"
196
222
  };
197
223
  const en = {
198
224
  "section.label": "Antigravity",
@@ -342,7 +368,33 @@ window.__ModuleLoader__.load({
342
368
  "warmup.allSuccess": "Warmup completed for all accounts",
343
369
  "warmup.skipped": "Account or model is in cooldown, no warmup needed",
344
370
  "config.autoWarmup": "7-Day Quota Auto-Warmup",
345
- "config.autoWarmupDesc": "Automatically trigger a 1-token probe when weekly reset time is reached"
371
+ "config.autoWarmupDesc": "Automatically trigger a 1-token probe when weekly reset time is reached",
372
+ "config.autoTranslate": "Auto translate",
373
+ "config.autoTranslateDesc": "After each turn, Gemini rewrites the final answer in plain language and shows it under that reply",
374
+ "config.on": "On",
375
+ "config.off": "Off",
376
+ "config.runtimeTitle": "Runtime",
377
+ "config.runtimeDesc": "Permission mode is fixed to skip (unattended; AGY's internal protections still apply). The reasoning effort is set by “Default thinking effort” below, which seeds the session model menu — you can still switch it per model there.",
378
+ "config.defaultEffort": "Default thinking effort",
379
+ "config.defaultEffortDesc": "auto = each model keeps its own default; a fixed level seeds the session model menu and can still be overridden per model",
380
+ "tsl.badge": "Gemini translation",
381
+ "tsl.plain": "Plain language",
382
+ "tsl.byGemini": "Translated by Gemini",
383
+ "tsl.translate": "Translate to plain language",
384
+ "tsl.actionTip": "Rewrite this reply in plain language with Gemini",
385
+ "tsl.translating": "Translating…",
386
+ "tsl.done": "Translation ready",
387
+ "tsl.pending": "Gemini is translating…",
388
+ "tsl.copy": "Copy",
389
+ "tsl.copied": "Copied",
390
+ "tsl.original": "Original",
391
+ "tsl.showOriginal": "Show original",
392
+ "tsl.hideOriginal": "Hide original",
393
+ "tsl.failed": "Translation failed",
394
+ "tsl.retry": "Retry",
395
+ "tsl.empty": "Nothing to translate",
396
+ "tsl.collapse": "Collapse",
397
+ "tsl.expand": "Expand"
346
398
  };
347
399
  const ptBR = {
348
400
  "section.label": "Antigravity",
@@ -492,7 +544,33 @@ window.__ModuleLoader__.load({
492
544
  "warmup.allSuccess": "Pré-aquecimento concluído",
493
545
  "warmup.skipped": "Conta em espera, sem necessidade de aquecimento",
494
546
  "config.autoWarmup": "Pré-aquecimento automático de 7 dias",
495
- "config.autoWarmupDesc": "Ativa automaticamente um ciclo quando o tempo de redefinição semanal é atingido"
547
+ "config.autoWarmupDesc": "Ativa automaticamente um ciclo quando o tempo de redefinição semanal é atingido",
548
+ "config.autoTranslate": "Tradução automática",
549
+ "config.autoTranslateDesc": "Ao fim de cada turno, o Gemini reescreve a resposta final em linguagem simples e mostra abaixo dela",
550
+ "config.on": "Ativado",
551
+ "config.off": "Desativado",
552
+ "config.runtimeTitle": "Execução",
553
+ "config.runtimeDesc": "O modo de permissão é fixo em skip (execução sem supervisão; as proteções internas do AGY continuam ativas). A intensidade de raciocínio é definida em “Intensidade de raciocínio padrão” abaixo, que serve de valor inicial no menu de modelos da sessão — ainda pode ser trocada por modelo lá.",
554
+ "config.defaultEffort": "Intensidade de raciocínio padrão",
555
+ "config.defaultEffortDesc": "auto = cada modelo mantém o próprio padrão; um nível fixo define o valor inicial do menu de modelos da sessão e ainda pode ser substituído por modelo",
556
+ "tsl.badge": "Tradução do Gemini",
557
+ "tsl.plain": "Linguagem simples",
558
+ "tsl.byGemini": "Traduzido pelo Gemini",
559
+ "tsl.translate": "Traduzir para linguagem simples",
560
+ "tsl.actionTip": "Reescrever esta resposta em linguagem simples com o Gemini",
561
+ "tsl.translating": "Traduzindo…",
562
+ "tsl.done": "Tradução concluída",
563
+ "tsl.pending": "O Gemini está traduzindo…",
564
+ "tsl.copy": "Copiar",
565
+ "tsl.copied": "Copiado",
566
+ "tsl.original": "Original",
567
+ "tsl.showOriginal": "Ver original",
568
+ "tsl.hideOriginal": "Ocultar original",
569
+ "tsl.failed": "Falha na tradução",
570
+ "tsl.retry": "Tentar novamente",
571
+ "tsl.empty": "Nada para traduzir",
572
+ "tsl.collapse": "Recolher",
573
+ "tsl.expand": "Expandir"
496
574
  };
497
575
  const es = {
498
576
  "section.label": "Antigravity",
@@ -642,7 +720,33 @@ window.__ModuleLoader__.load({
642
720
  "warmup.allSuccess": "Precalentamiento completado",
643
721
  "warmup.skipped": "Cuenta en espera, sin necesidad de calentar",
644
722
  "config.autoWarmup": "Precalentamiento automático de 7 días",
645
- "config.autoWarmupDesc": "Activa automáticamente un ciclo cuando se alcanza el tiempo de reinicio semanal"
723
+ "config.autoWarmupDesc": "Activa automáticamente un ciclo cuando se alcanza el tiempo de reinicio semanal",
724
+ "config.autoTranslate": "Traducción automática",
725
+ "config.autoTranslateDesc": "Al terminar cada turno, Gemini reescribe la respuesta final en lenguaje sencillo y la muestra debajo de esa respuesta",
726
+ "config.on": "Activado",
727
+ "config.off": "Desactivado",
728
+ "config.runtimeTitle": "Ejecución",
729
+ "config.runtimeDesc": "El modo de permisos está fijo en skip (ejecución desatendida; las protecciones internas de AGY siguen activas). La intensidad de razonamiento la define “Intensidad de razonamiento predeterminada” abajo, que fija el valor inicial del menú de modelos de la sesión — allí todavía puedes cambiarla por modelo.",
730
+ "config.defaultEffort": "Intensidad de razonamiento predeterminada",
731
+ "config.defaultEffortDesc": "auto = cada modelo usa su propio valor por defecto; un nivel fijo fija el valor inicial del menú de modelos de la sesión y aún puede sobrescribirse por modelo",
732
+ "tsl.badge": "Traducción de Gemini",
733
+ "tsl.plain": "Lenguaje sencillo",
734
+ "tsl.byGemini": "Traducido por Gemini",
735
+ "tsl.translate": "Traducir a lenguaje sencillo",
736
+ "tsl.actionTip": "Reescribir esta respuesta en lenguaje sencillo con Gemini",
737
+ "tsl.translating": "Traduciendo…",
738
+ "tsl.done": "Traducción completada",
739
+ "tsl.pending": "Gemini está traduciendo…",
740
+ "tsl.copy": "Copiar",
741
+ "tsl.copied": "Copiado",
742
+ "tsl.original": "Original",
743
+ "tsl.showOriginal": "Ver original",
744
+ "tsl.hideOriginal": "Ocultar original",
745
+ "tsl.failed": "Fallo en la traducción",
746
+ "tsl.retry": "Reintentar",
747
+ "tsl.empty": "Nada que traducir",
748
+ "tsl.collapse": "Contraer",
749
+ "tsl.expand": "Expandir"
646
750
  };
647
751
  //#endregion
648
752
  //#region src/client/scroll-guard.ts
@@ -793,7 +897,7 @@ window.__ModuleLoader__.load({
793
897
  white-space: nowrap;
794
898
  }
795
899
  `;
796
- function injectStyles$3() {
900
+ function injectStyles$4() {
797
901
  if (typeof document === "undefined") return;
798
902
  const styleId = "dsh-agy-link-decisions-css";
799
903
  if (document.getElementById(styleId) === null) {
@@ -954,7 +1058,7 @@ window.__ModuleLoader__.load({
954
1058
  function installDecisionChips() {
955
1059
  if (typeof window === "undefined" || typeof document === "undefined") return () => {};
956
1060
  decisionChipsDispose?.();
957
- injectStyles$3();
1061
+ injectStyles$4();
958
1062
  const observer = new MutationObserver(() => {
959
1063
  scheduleDecisionScan();
960
1064
  });
@@ -1179,7 +1283,7 @@ window.__ModuleLoader__.load({
1179
1283
  pointer-events: none;
1180
1284
  }
1181
1285
  `;
1182
- function injectStyles$2() {
1286
+ function injectStyles$3() {
1183
1287
  if (typeof document === "undefined") return;
1184
1288
  const styleId = "dsh-agy-link-images-css";
1185
1289
  if (document.getElementById(styleId) === null) {
@@ -1203,7 +1307,7 @@ window.__ModuleLoader__.load({
1203
1307
  */
1204
1308
  function openLightbox(src, title = "Image Preview", rawPath) {
1205
1309
  if (typeof document === "undefined") return;
1206
- injectStyles$2();
1310
+ injectStyles$3();
1207
1311
  if (lightboxOverlay) {
1208
1312
  lightboxOverlay.remove();
1209
1313
  lightboxOverlay = null;
@@ -1458,7 +1562,7 @@ window.__ModuleLoader__.load({
1458
1562
  function installImageEnhancer() {
1459
1563
  if (typeof window === "undefined" || typeof document === "undefined") return () => {};
1460
1564
  imageEnhancerDispose?.();
1461
- injectStyles$2();
1565
+ injectStyles$3();
1462
1566
  const observer = new MutationObserver(() => {
1463
1567
  scheduleImageScan();
1464
1568
  });
@@ -3227,7 +3331,7 @@ body > [id^="iagy-mmd"] .error-icon {
3227
3331
  let loadFailedAt = 0;
3228
3332
  const LOAD_RETRY_MS = 6e4;
3229
3333
  let renderSeq = 0;
3230
- function injectStyles$1() {
3334
+ function injectStyles$2() {
3231
3335
  if (typeof document === "undefined") return;
3232
3336
  if (document.getElementById("agy-mermaid-css")) return;
3233
3337
  const st = document.createElement("style");
@@ -3587,7 +3691,7 @@ body > [id^="iagy-mmd"] .error-icon {
3587
3691
  function installMermaidRendering() {
3588
3692
  if (typeof window === "undefined" || typeof document === "undefined") return () => {};
3589
3693
  disposeMermaidRendering();
3590
- injectStyles$1();
3694
+ injectStyles$2();
3591
3695
  cleanupTempElements();
3592
3696
  const observer = new MutationObserver(() => {
3593
3697
  scheduleScan$1();
@@ -3676,7 +3780,7 @@ div[data-variant="think"] [class*="thinkBody"] {
3676
3780
  font-family: inherit;
3677
3781
  }
3678
3782
  `;
3679
- function injectStyles() {
3783
+ function injectStyles$1() {
3680
3784
  if (typeof document === "undefined") return;
3681
3785
  const styleId = "dsh-agy-link-reasoning-css";
3682
3786
  if (document.getElementById(styleId) === null) {
@@ -3766,7 +3870,7 @@ div[data-variant="think"] [class*="thinkBody"] {
3766
3870
  function installAutoExpandReasoning() {
3767
3871
  if (typeof window === "undefined" || typeof document === "undefined") return () => {};
3768
3872
  disposeAutoExpandReasoning();
3769
- injectStyles();
3873
+ injectStyles$1();
3770
3874
  const observer = new MutationObserver(() => {
3771
3875
  scheduleScan();
3772
3876
  });
@@ -3809,6 +3913,652 @@ div[data-variant="think"] [class*="thinkBody"] {
3809
3913
  }
3810
3914
  }
3811
3915
  //#endregion
3916
+ //#region src/client/translate.ts
3917
+ const { createElement: h$1, useState: useState$1, useEffect: useEffect$1 } = require("react");
3918
+ const win$1 = globalThis;
3919
+ const base$1 = win$1.location?.origin ?? "";
3920
+ const STYLE_ID = "dsh-agy-link-tsl-css-v2";
3921
+ const TRANSLATION_KIND = "agy-translation";
3922
+ const CSS = `
3923
+ .agy-tsl-card {
3924
+ margin: 8px 0 2px 0;
3925
+ border-radius: 10px;
3926
+ border: 1px solid var(--dsw-alias-border-l2, rgba(127,127,127,.28));
3927
+ border-left: 3px solid #8b5cf6;
3928
+ background: linear-gradient(180deg, rgba(99,102,241,.09), rgba(139,92,246,.04));
3929
+ overflow: hidden;
3930
+ }
3931
+ .agy-tsl-head {
3932
+ display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
3933
+ padding: 7px 10px; font-size: 12px; color: var(--dsw-alias-label-secondary, #aaa);
3934
+ border-bottom: 1px solid var(--dsw-alias-border-l1, rgba(127,127,127,.18));
3935
+ }
3936
+ .agy-tsl-badge {
3937
+ display: inline-flex; align-items: center; gap: 5px;
3938
+ font-weight: 700; font-size: 12px; color: #a78bfa;
3939
+ background: rgba(139,92,246,.14); border: 1px solid rgba(139,92,246,.35);
3940
+ padding: 2px 8px; border-radius: 999px;
3941
+ }
3942
+ .agy-tsl-meta { opacity: .85; font-variant-numeric: tabular-nums; }
3943
+ .agy-tsl-spacer { flex: 1 1 auto; }
3944
+ .agy-tsl-btn {
3945
+ background: transparent; border: 1px solid transparent; color: var(--dsw-alias-label-secondary, #aaa);
3946
+ border-radius: 6px; cursor: pointer; font-size: 12px; padding: 2px 7px;
3947
+ }
3948
+ .agy-tsl-btn:hover { background: var(--dsw-alias-interactive-bg-hover-solid, rgba(127,127,127,.16)); color: var(--dsw-alias-label-primary, #eee); }
3949
+ .agy-tsl-body { padding: 9px 12px; font-size: 13.5px; line-height: 1.65; color: var(--dsw-alias-label-primary, #eee); }
3950
+ .agy-tsl-body p { margin: 0 0 7px 0; }
3951
+ .agy-tsl-body p:last-child { margin-bottom: 0; }
3952
+ .agy-tsl-body ul, .agy-tsl-body ol { margin: 0 0 7px 0; padding-left: 20px; }
3953
+ .agy-tsl-body li { margin: 2px 0; }
3954
+ .agy-tsl-body h4, .agy-tsl-body h5 { margin: 8px 0 5px 0; font-size: 13.5px; }
3955
+ .agy-tsl-body code { background: rgba(127,127,127,.18); border-radius: 4px; padding: 1px 4px; font-size: 12.5px; }
3956
+ .agy-tsl-body pre { background: rgba(127,127,127,.14); border-radius: 8px; padding: 8px 10px; overflow-x: auto; margin: 0 0 7px 0; }
3957
+ .agy-tsl-body pre code { background: transparent; padding: 0; }
3958
+ .agy-tsl-original {
3959
+ margin: 0; padding: 8px 12px; border-top: 1px dashed var(--dsw-alias-border-l2, rgba(127,127,127,.28));
3960
+ font-size: 12.5px; color: var(--dsw-alias-label-secondary, #aaa); white-space: pre-wrap; max-height: 260px; overflow: auto;
3961
+ }
3962
+ /* Icon-only action that sits in the same strip as copy / thumbs / link, with
3963
+ the same neutral tint so it reads as part of that group. */
3964
+ .agy-tsl-icon {
3965
+ display: inline-flex; align-items: center; justify-content: center;
3966
+ width: 24px; height: 24px; padding: 0; border: 0; border-radius: 6px;
3967
+ background: transparent; color: var(--dsw-alias-label-tertiary, #8a8f98);
3968
+ cursor: pointer; transition: background .15s ease, color .15s ease;
3969
+ }
3970
+ .agy-tsl-icon:hover:not(:disabled) {
3971
+ background: var(--dsw-alias-interactive-bg-hover-solid, rgba(127,127,127,.14));
3972
+ color: var(--dsw-alias-label-primary, #eee);
3973
+ }
3974
+ .agy-tsl-icon:disabled { cursor: default; }
3975
+ .agy-tsl-icon[data-state="working"] { color: var(--dsw-alias-state-business-primary, #2563eb); cursor: wait; }
3976
+ .agy-tsl-icon[data-state="done"] { color: #10b981; }
3977
+ .agy-tsl-icon[data-state="error"] { color: #ef4444; }
3978
+ .agy-tsl-icon svg { width: 15px; height: 15px; display: block; }
3979
+ @keyframes agy-tsl-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
3980
+ /* Own tooltip: the native title bubble never showed inside the desktop shell,
3981
+ and DSH's Tooltip primitive is not exposed to plugin bundles. It mirrors that
3982
+ primitive: same tokens (--dsw-alias-tooltip-bg / --dsw-static-neutral-bluish-00
3983
+ / 13px-20px / 3px 7px / --dsw-radius-sm), no caret, BELOW the anchor, and — like
3984
+ the primitive's portal — a body-level fixed node, so the transcript
3985
+ scroller can neither clip it nor let the composer cover it. */
3986
+ .agy-tsl-wrap { position: relative; display: inline-flex; align-items: center; }
3987
+ .agy-tsl-tip {
3988
+ position: fixed; z-index: 1100;
3989
+ padding: 3px 7px; border-radius: var(--dsw-radius-sm, 8px);
3990
+ background: var(--dsw-alias-tooltip-bg, #1f2229);
3991
+ color: var(--dsw-static-neutral-bluish-00, #fff);
3992
+ font-size: 13px; line-height: 20px; font-weight: 400; letter-spacing: normal;
3993
+ white-space: pre-line; overflow-wrap: break-word; text-align: center;
3994
+ box-sizing: border-box; width: max-content;
3995
+ max-width: min(50vw, calc(100vw - 24px));
3996
+ pointer-events: none;
3997
+ animation: agy-tsl-tip-in .15s var(--ds-ease-in-out, ease-in-out);
3998
+ }
3999
+ @keyframes agy-tsl-tip-in { 0% { opacity: 0; } 100% { opacity: 1; } }
4000
+ @media (prefers-reduced-motion: reduce) {
4001
+ .agy-tsl-tip { animation: none; }
4002
+ }
4003
+ `;
4004
+ function injectStyles() {
4005
+ if (typeof document === "undefined") return;
4006
+ const doc = win$1.document;
4007
+ if (doc === null || doc === void 0) return;
4008
+ const existing = doc.getElementById(STYLE_ID);
4009
+ if (existing !== null && existing !== void 0) {
4010
+ if (existing.textContent !== CSS) existing.textContent = CSS;
4011
+ return;
4012
+ }
4013
+ const st = doc.createElement("style");
4014
+ st.id = STYLE_ID;
4015
+ st.textContent = CSS;
4016
+ const host = doc.head ?? doc.documentElement;
4017
+ if (host) host.appendChild(st);
4018
+ }
4019
+ function service(ctx, name) {
4020
+ try {
4021
+ const fromGet = ctx.get?.(name);
4022
+ if (fromGet !== void 0 && fromGet !== null) return fromGet;
4023
+ } catch {}
4024
+ try {
4025
+ const direct = ctx[name];
4026
+ return direct === void 0 || direct === null ? void 0 : direct;
4027
+ } catch {
4028
+ return;
4029
+ }
4030
+ }
4031
+ /** The session the visible conversation belongs to. */
4032
+ function currentSessionId(ctx) {
4033
+ const value = service(ctx, "uiSession")?.current?.value;
4034
+ if (value !== void 0 && value !== null) for (const key of [
4035
+ "key",
4036
+ "sessionId",
4037
+ "id"
4038
+ ]) {
4039
+ const id = value[key];
4040
+ if (typeof id === "string" && id !== "") return id;
4041
+ }
4042
+ const byId = service(ctx, "sessions")?.list?.getSnapshot?.()?.byId;
4043
+ if (byId !== void 0 && byId !== null) {
4044
+ const ids = Object.keys(byId);
4045
+ if (ids.length === 1 && ids[0] !== void 0) return ids[0];
4046
+ }
4047
+ return "";
4048
+ }
4049
+ async function postTranslate(body) {
4050
+ try {
4051
+ const res = await win$1.fetch?.(base$1 + "/plugins/agy-link/translate", {
4052
+ method: "POST",
4053
+ headers: { "Content-Type": "application/json" },
4054
+ body: JSON.stringify(body)
4055
+ });
4056
+ if (!res) return null;
4057
+ return await res.json();
4058
+ } catch {
4059
+ return null;
4060
+ }
4061
+ }
4062
+ /** Ask the host whether this reply already owns a durable translation. */
4063
+ async function getMessageState(sessionId, messageId) {
4064
+ try {
4065
+ const url = base$1 + "/plugins/agy-link/translate/state?session=" + encodeURIComponent(sessionId) + "&message=" + encodeURIComponent(messageId);
4066
+ const res = await win$1.fetch?.(url);
4067
+ if (!res) return null;
4068
+ return await res.json();
4069
+ } catch {
4070
+ return null;
4071
+ }
4072
+ }
4073
+ function inline(text) {
4074
+ const out = [];
4075
+ const re = /(\*\*[^*]+\*\*|`[^`]+`)/g;
4076
+ let last = 0;
4077
+ let m;
4078
+ let i = 0;
4079
+ while ((m = re.exec(text)) !== null) {
4080
+ if (m.index > last) out.push(text.slice(last, m.index));
4081
+ const token = m[1] ?? "";
4082
+ if (token.startsWith("**")) out.push(h$1("strong", { key: "b" + i }, token.slice(2, -2)));
4083
+ else out.push(h$1("code", { key: "c" + i }, token.slice(1, -1)));
4084
+ last = m.index + token.length;
4085
+ i++;
4086
+ }
4087
+ if (last < text.length) out.push(text.slice(last));
4088
+ return out;
4089
+ }
4090
+ function renderMarkdown(text) {
4091
+ const lines = text.replace(/\r\n?/g, "\n").split("\n");
4092
+ const blocks = [];
4093
+ let i = 0;
4094
+ let key = 0;
4095
+ while (i < lines.length) {
4096
+ const line = lines[i] ?? "";
4097
+ if (line.trim() === "") {
4098
+ i++;
4099
+ continue;
4100
+ }
4101
+ if (/^```/.test(line.trim())) {
4102
+ const lang = line.trim().slice(3).trim();
4103
+ const body = [];
4104
+ i++;
4105
+ while (i < lines.length && !/^```/.test((lines[i] ?? "").trim())) {
4106
+ body.push(lines[i] ?? "");
4107
+ i++;
4108
+ }
4109
+ i++;
4110
+ blocks.push(h$1("pre", { key: "p" + key++ }, h$1("code", lang === "" ? null : { "data-lang": lang }, body.join("\n"))));
4111
+ continue;
4112
+ }
4113
+ if (/^#{1,4}\s+/.test(line)) {
4114
+ const label = line.replace(/^#{1,4}\s+/, "");
4115
+ blocks.push(h$1("h4", { key: "h" + key++ }, inline(label)));
4116
+ i++;
4117
+ continue;
4118
+ }
4119
+ if (/^\s*[-*]\s+/.test(line)) {
4120
+ const items = [];
4121
+ while (i < lines.length && /^\s*[-*]\s+/.test(lines[i] ?? "")) {
4122
+ items.push(h$1("li", { key: "l" + key++ }, inline((lines[i] ?? "").replace(/^\s*[-*]\s+/, ""))));
4123
+ i++;
4124
+ }
4125
+ blocks.push(h$1("ul", { key: "u" + key++ }, items));
4126
+ continue;
4127
+ }
4128
+ if (/^\s*\d+[.)]\s+/.test(line)) {
4129
+ const items = [];
4130
+ while (i < lines.length && /^\s*\d+[.)]\s+/.test(lines[i] ?? "")) {
4131
+ items.push(h$1("li", { key: "n" + key++ }, inline((lines[i] ?? "").replace(/^\s*\d+[.)]\s+/, ""))));
4132
+ i++;
4133
+ }
4134
+ blocks.push(h$1("ol", { key: "o" + key++ }, items));
4135
+ continue;
4136
+ }
4137
+ const para = [];
4138
+ while (i < lines.length) {
4139
+ const cur = lines[i] ?? "";
4140
+ if (cur.trim() === "" || /^```/.test(cur.trim()) || /^#{1,4}\s+/.test(cur) || /^\s*[-*]\s+/.test(cur) || /^\s*\d+[.)]\s+/.test(cur)) break;
4141
+ para.push(cur);
4142
+ i++;
4143
+ }
4144
+ blocks.push(h$1("p", { key: "t" + key++ }, inline(para.join("\n"))));
4145
+ }
4146
+ return h$1("div", null, blocks);
4147
+ }
4148
+ const TranslationCard = (props) => {
4149
+ const data = (props?.node ?? {}).data ?? {};
4150
+ const t = (key, fallback) => {
4151
+ const fn = props?.t;
4152
+ if (typeof fn !== "function") return fallback ?? key;
4153
+ try {
4154
+ const value = fn(key);
4155
+ return value === key && fallback !== void 0 ? fallback : value;
4156
+ } catch {
4157
+ return fallback ?? key;
4158
+ }
4159
+ };
4160
+ const [open, setOpen] = useState$1(true);
4161
+ const [showOriginal, setShowOriginal] = useState$1(false);
4162
+ const [copied, setCopied] = useState$1(false);
4163
+ const text = typeof data.text === "string" ? data.text : "";
4164
+ const original = typeof data.original === "string" ? data.original : "";
4165
+ if (text.trim() === "") return null;
4166
+ const meta = [];
4167
+ if (typeof data.model === "string" && data.model !== "") meta.push(data.model);
4168
+ if (typeof data.effort === "string" && data.effort !== "") meta.push(data.effort);
4169
+ if (typeof data.accountId === "string" && data.accountId !== "") meta.push(data.accountId);
4170
+ const copy = () => {
4171
+ win$1.navigator?.clipboard?.writeText(text).then(() => {
4172
+ setCopied(true);
4173
+ setTimeout(() => setCopied(false), 1500);
4174
+ }).catch(() => void 0);
4175
+ };
4176
+ return h$1("div", {
4177
+ className: "agy-tsl-card",
4178
+ "data-agy-translation": "gemini",
4179
+ "aria-label": t("tsl.badge", "Gemini translation")
4180
+ }, h$1("div", { className: "agy-tsl-head" }, h$1("span", { className: "agy-tsl-badge" }, "✨ " + t("tsl.badge", "Gemini translation")), h$1("span", { className: "agy-tsl-meta" }, meta.join(" · ")), h$1("span", { className: "agy-tsl-spacer" }), h$1("button", {
4181
+ type: "button",
4182
+ className: "agy-tsl-btn",
4183
+ onClick: copy
4184
+ }, copied ? t("tsl.copied", "Copied") : t("tsl.copy", "Copy")), h$1("button", {
4185
+ type: "button",
4186
+ className: "agy-tsl-btn",
4187
+ onClick: () => setOpen(!open)
4188
+ }, open ? t("tsl.collapse", "收起") : t("tsl.expand", "展开"))), open ? h$1("div", { className: "agy-tsl-body" }, renderMarkdown(text)) : null, original !== "" ? h$1("div", {
4189
+ className: "agy-tsl-head",
4190
+ style: {
4191
+ borderBottom: "none",
4192
+ paddingTop: "0",
4193
+ paddingBottom: "6px"
4194
+ }
4195
+ }, h$1("button", {
4196
+ type: "button",
4197
+ className: "agy-tsl-btn",
4198
+ onClick: () => setShowOriginal(!showOriginal)
4199
+ }, showOriginal ? t("tsl.hideOriginal", "Hide original") : t("tsl.showOriginal", "Show original"))) : null, showOriginal && original !== "" ? h$1("pre", { className: "agy-tsl-original" }, original) : null);
4200
+ };
4201
+ /** Four-point Gemini spark, filled with `currentColor` so it inherits the icon
4202
+ * tint of DSH's action strip and looks native next to copy/thumbs/link. */
4203
+ const GEMINI_STAR = "M12 2 Q13.1 9.2 22 12 Q13.1 14.8 12 22 Q10.9 14.8 2 12 Q10.9 9.2 12 2 Z";
4204
+ function geminiGlyph() {
4205
+ return h$1("svg", {
4206
+ viewBox: "0 0 24 24",
4207
+ fill: "currentColor",
4208
+ "aria-hidden": "true",
4209
+ style: {
4210
+ width: "15px",
4211
+ height: "15px",
4212
+ display: "block"
4213
+ }
4214
+ }, h$1("path", { d: GEMINI_STAR }));
4215
+ }
4216
+ function spinnerGlyph() {
4217
+ return h$1("svg", {
4218
+ viewBox: "0 0 24 24",
4219
+ fill: "none",
4220
+ className: "agy-tsl-spinner",
4221
+ "aria-hidden": "true",
4222
+ style: {
4223
+ width: "15px",
4224
+ height: "15px",
4225
+ display: "block",
4226
+ animation: "agy-tsl-spin 0.85s linear infinite",
4227
+ transformOrigin: "center center"
4228
+ }
4229
+ }, h$1("circle", {
4230
+ cx: "12",
4231
+ cy: "12",
4232
+ r: "9",
4233
+ stroke: "currentColor",
4234
+ strokeWidth: "2.5",
4235
+ strokeDasharray: "38 18",
4236
+ strokeLinecap: "round",
4237
+ opacity: "0.85"
4238
+ }));
4239
+ }
4240
+ function checkGlyph() {
4241
+ return h$1("svg", {
4242
+ viewBox: "0 0 24 24",
4243
+ fill: "none",
4244
+ stroke: "currentColor",
4245
+ strokeWidth: "2.5",
4246
+ strokeLinecap: "round",
4247
+ strokeLinejoin: "round",
4248
+ "aria-hidden": "true",
4249
+ style: {
4250
+ width: "15px",
4251
+ height: "15px",
4252
+ display: "block"
4253
+ }
4254
+ }, h$1("polyline", { points: "20 6 9 17 4 12" }));
4255
+ }
4256
+ function errorGlyph() {
4257
+ return h$1("svg", {
4258
+ viewBox: "0 0 24 24",
4259
+ fill: "none",
4260
+ stroke: "currentColor",
4261
+ strokeWidth: "2.2",
4262
+ strokeLinecap: "round",
4263
+ strokeLinejoin: "round",
4264
+ "aria-hidden": "true",
4265
+ style: {
4266
+ width: "15px",
4267
+ height: "15px",
4268
+ display: "block"
4269
+ }
4270
+ }, h$1("circle", {
4271
+ cx: "12",
4272
+ cy: "12",
4273
+ r: "10"
4274
+ }), h$1("line", {
4275
+ x1: "12",
4276
+ y1: "8",
4277
+ x2: "12",
4278
+ y2: "12"
4279
+ }), h$1("line", {
4280
+ x1: "12",
4281
+ y1: "16",
4282
+ x2: "12.01",
4283
+ y2: "16"
4284
+ }));
4285
+ }
4286
+ /**
4287
+ * The hint lives in one body-level node, like DSH's own tooltip portal.
4288
+ *
4289
+ * Two reasons it is not a pseudo-element on the row any more:
4290
+ * 1. the transcript scroller clips its children, so a bubble anchored below the
4291
+ * LAST reply (the row right above the composer) was cut off, and anchoring
4292
+ * it above instead broke alignment with every other tooltip in the strip;
4293
+ * 2. `position: fixed` on the row cannot escape a transformed ancestor, so the
4294
+ * node is appended to <body> where nothing can clip it.
4295
+ * Inline styles keep it hidden and positioned even if our stylesheet is missing,
4296
+ * so a stale sheet can never leak the label into the action row.
4297
+ */
4298
+ const TIP_ID = "dsh-agy-link-tsl-tip";
4299
+ const TIP_GAP_PX = 6;
4300
+ const TIP_MARGIN_PX = 8;
4301
+ const TIP_MAX_WIDTH_VW = .5;
4302
+ /** Viewport size, guarded for a headless/test document. */
4303
+ function viewport() {
4304
+ const w = win$1;
4305
+ return {
4306
+ width: typeof w.innerWidth === "number" ? w.innerWidth : 0,
4307
+ height: typeof w.innerHeight === "number" ? w.innerHeight : 0
4308
+ };
4309
+ }
4310
+ /** Hidden by default through INLINE styles — not through the stylesheet. */
4311
+ function tipNode() {
4312
+ if (typeof document === "undefined") return null;
4313
+ const doc = win$1.document;
4314
+ if (doc === null || doc === void 0 || typeof doc.createElement !== "function") return null;
4315
+ const found = typeof doc.getElementById === "function" ? doc.getElementById(TIP_ID) : null;
4316
+ if (found !== null && found !== void 0 && found.isConnected !== false) return found;
4317
+ const created = doc.createElement("div");
4318
+ created?.setAttribute?.("id", TIP_ID);
4319
+ created?.setAttribute?.("role", "tooltip");
4320
+ if (created !== void 0 && created !== null) {
4321
+ created.style.cssText = "position:fixed;display:none;pointer-events:none;z-index:1100";
4322
+ created.isConnected = true;
4323
+ }
4324
+ doc.body?.appendChild?.(created);
4325
+ return created ?? null;
4326
+ }
4327
+ /**
4328
+ * Anchor box of the element the pointer is on (or `null` when it cannot be read).
4329
+ */
4330
+ function anchorBox(el) {
4331
+ const rect = el?.getBoundingClientRect?.();
4332
+ if (rect === void 0 || rect === null || typeof rect.top !== "number" || typeof rect.left !== "number") return null;
4333
+ return {
4334
+ left: rect.left,
4335
+ width: typeof rect.width === "number" ? rect.width : 0,
4336
+ top: rect.top,
4337
+ bottom: typeof rect.bottom === "number" ? rect.bottom : rect.top
4338
+ };
4339
+ }
4340
+ /** Show the shared bubble under `el`, clamped to the viewport. */
4341
+ function showTip(el, text) {
4342
+ const node = tipNode();
4343
+ const box = anchorBox(el);
4344
+ if (node === null || node === void 0 || box === null) return;
4345
+ node.textContent = text;
4346
+ node.style.display = "inline-flex";
4347
+ const size = node.getBoundingClientRect?.() ?? {
4348
+ width: 0,
4349
+ height: 26
4350
+ };
4351
+ const vp = viewport();
4352
+ const maxWidth = vp.width > 0 ? Math.max(80, vp.width * TIP_MAX_WIDTH_VW) : 0;
4353
+ const width = maxWidth > 0 ? Math.min(size.width, maxWidth) : size.width;
4354
+ let left = box.left + box.width / 2 - width / 2;
4355
+ if (vp.width > 0) left = Math.min(Math.max(TIP_MARGIN_PX, left), Math.max(TIP_MARGIN_PX, vp.width - width - TIP_MARGIN_PX));
4356
+ const below = box.bottom + TIP_GAP_PX;
4357
+ const above = box.top - size.height - TIP_GAP_PX;
4358
+ const top = vp.height > 0 && below + size.height > vp.height - TIP_MARGIN_PX ? Math.max(TIP_MARGIN_PX, above) : below;
4359
+ node.style.left = Math.round(left) + "px";
4360
+ node.style.top = Math.round(top) + "px";
4361
+ }
4362
+ /** Hide the shared bubble (leave/scroll/click). */
4363
+ function hideTip() {
4364
+ const node = tipNode();
4365
+ if (node !== null && node !== void 0) node.style.display = "none";
4366
+ }
4367
+ function tooltipText(props, key, fallback) {
4368
+ const fn = props?.t;
4369
+ if (typeof fn !== "function") return fallback;
4370
+ try {
4371
+ const value = fn(key);
4372
+ return value === key ? fallback : value;
4373
+ } catch {
4374
+ return fallback;
4375
+ }
4376
+ }
4377
+ /**
4378
+ * Per-reply action state, kept outside React so it survives a remount: the chat
4379
+ * timeline virtualises nodes and DSH re-creates the whole panel when the window
4380
+ * regains focus, which used to reset the button to `idle` mid-flight. The map is
4381
+ * the in-page truth; the host's durable record is the truth across page loads.
4382
+ */
4383
+ const ACTION_STATE = /* @__PURE__ */ new Map();
4384
+ const ACTION_INFLIGHT = /* @__PURE__ */ new Set();
4385
+ /**
4386
+ * Icon-only "translate with Gemini" action rendered into the assistant action
4387
+ * strip (`conversation.chat.assistant-actions`), so it lines up with copy,
4388
+ * thumbs, link and usage. The label lives in the hover tooltip only.
4389
+ */
4390
+ const TranslateAction = (props) => {
4391
+ const messageId = typeof props?.messageId === "string" ? props.messageId : "";
4392
+ const injectedSession = typeof props?.sessionId === "string" ? props.sessionId : "";
4393
+ const ctx = props?.ctx;
4394
+ const sessionId = injectedSession !== "" ? injectedSession : ctx === void 0 ? "" : currentSessionId(ctx);
4395
+ const key = sessionId + "\0" + messageId;
4396
+ const [state, setState] = useState$1(() => ACTION_INFLIGHT.has(key) ? "working" : ACTION_STATE.get(key) ?? "idle");
4397
+ useEffect$1(() => {
4398
+ if (messageId === "" || sessionId === "") return;
4399
+ let alive = true;
4400
+ getMessageState(sessionId, messageId).then((res) => {
4401
+ if (!alive || res === null) return;
4402
+ const next = res.state === "ready" ? "done" : res.state === "busy" ? "working" : null;
4403
+ if (next === null) return;
4404
+ ACTION_STATE.set(key, next);
4405
+ if (next === "working") ACTION_INFLIGHT.add(key);
4406
+ setState((prev) => prev === next ? prev : next);
4407
+ });
4408
+ return () => {
4409
+ alive = false;
4410
+ };
4411
+ }, [
4412
+ key,
4413
+ messageId,
4414
+ sessionId
4415
+ ]);
4416
+ if (messageId === "" || sessionId === "") return null;
4417
+ const apply = (next) => {
4418
+ ACTION_STATE.set(key, next);
4419
+ setState(next);
4420
+ };
4421
+ const run = (e) => {
4422
+ e?.stopPropagation?.();
4423
+ e?.preventDefault?.();
4424
+ hideTip();
4425
+ if (state === "working") return;
4426
+ ACTION_INFLIGHT.add(key);
4427
+ apply("working");
4428
+ postTranslate({
4429
+ sessionId,
4430
+ messageId,
4431
+ persist: true
4432
+ }).then((res) => {
4433
+ ACTION_INFLIGHT.delete(key);
4434
+ if (res?.ok === true) {
4435
+ apply("done");
4436
+ return;
4437
+ }
4438
+ apply("error");
4439
+ setTimeout(() => {
4440
+ if (!ACTION_INFLIGHT.has(key)) apply("idle");
4441
+ }, 3e3);
4442
+ }).catch(() => {
4443
+ ACTION_INFLIGHT.delete(key);
4444
+ apply("error");
4445
+ setTimeout(() => {
4446
+ if (!ACTION_INFLIGHT.has(key)) apply("idle");
4447
+ }, 3e3);
4448
+ });
4449
+ };
4450
+ const title = state === "working" ? tooltipText(props, "tsl.translating", "翻译中…") : state === "error" ? tooltipText(props, "tsl.retry", "重试") : state === "done" ? tooltipText(props, "tsl.done", "已生成译文") : tooltipText(props, "tsl.actionTip", "用 Gemini 把这条回复译成人话");
4451
+ const glyph = state === "working" ? spinnerGlyph() : state === "done" ? checkGlyph() : state === "error" ? errorGlyph() : geminiGlyph();
4452
+ return h$1("span", {
4453
+ className: "agy-tsl-wrap",
4454
+ onMouseEnter: (e) => showTip(e?.currentTarget, title),
4455
+ onFocus: (e) => showTip(e?.currentTarget, title),
4456
+ onMouseLeave: () => hideTip(),
4457
+ onBlur: () => hideTip()
4458
+ }, h$1("button", {
4459
+ type: "button",
4460
+ className: "agy-tsl-icon",
4461
+ "data-state": state,
4462
+ disabled: state === "working",
4463
+ onClick: run,
4464
+ "aria-label": title,
4465
+ style: {
4466
+ display: "inline-flex",
4467
+ alignItems: "center",
4468
+ justifyContent: "center",
4469
+ width: "24px",
4470
+ height: "24px",
4471
+ padding: "0",
4472
+ border: "none",
4473
+ borderRadius: "6px",
4474
+ background: "transparent",
4475
+ color: state === "working" ? "var(--dsw-alias-state-business-primary, #2563eb)" : state === "done" ? "#10b981" : state === "error" ? "#ef4444" : "var(--dsw-alias-label-tertiary, #8a8f98)",
4476
+ cursor: state === "working" ? "wait" : "pointer"
4477
+ }
4478
+ }, glyph));
4479
+ };
4480
+ function translationDefinition() {
4481
+ return {
4482
+ kind: TRANSLATION_KIND,
4483
+ target: "chat",
4484
+ match: (event) => event !== null && event.type === "plugin:agy-link/translation" ? {
4485
+ id: String(event.seq ?? 0),
4486
+ role: "start"
4487
+ } : null,
4488
+ start: (_context, match) => {
4489
+ const ev = match.event ?? {};
4490
+ const data = ev.data ?? {};
4491
+ return {
4492
+ seq: typeof ev.seq === "number" ? ev.seq : 0,
4493
+ turn: typeof data.turn === "number" ? data.turn : 0,
4494
+ anchorSeq: typeof data.anchorSeq === "number" ? data.anchorSeq : typeof ev.seq === "number" ? ev.seq : 0,
4495
+ text: typeof data.text === "string" ? data.text : "",
4496
+ model: typeof data.model === "string" ? data.model : "",
4497
+ effort: typeof data.effort === "string" ? data.effort : "",
4498
+ accountId: typeof data.accountId === "string" ? data.accountId : "",
4499
+ createdAt: typeof data.createdAt === "number" ? data.createdAt : 0
4500
+ };
4501
+ },
4502
+ update: (context) => context.state,
4503
+ buildViewNode: (context) => {
4504
+ const state = context.state;
4505
+ if (state === void 0 || typeof state.text !== "string" || state.text.trim() === "") return null;
4506
+ const anchorSeq = typeof state.anchorSeq === "number" ? state.anchorSeq : 0;
4507
+ return {
4508
+ key: context.key,
4509
+ kind: TRANSLATION_KIND,
4510
+ id: context.id,
4511
+ target: "chat",
4512
+ anchorSeq: anchorSeq + .1,
4513
+ location: context.start?.location ?? { kind: "unresolved" },
4514
+ visibility: "visible",
4515
+ data: state
4516
+ };
4517
+ }
4518
+ };
4519
+ }
4520
+ /** Mount the card renderer, the event Definition and both affordances. */
4521
+ function installTranslationUi(ctx, localeNs) {
4522
+ injectStyles();
4523
+ const disposers = [];
4524
+ const conversation = service(ctx, "uiConversation");
4525
+ if (conversation?.events !== void 0 && typeof conversation.events.register === "function") try {
4526
+ const dispose = conversation.events.register(translationDefinition());
4527
+ if (typeof dispose === "function") disposers.push(dispose);
4528
+ } catch (e) {
4529
+ console.warn("[dsh-agy-link] translation definition registration failed:", e);
4530
+ }
4531
+ try {
4532
+ ctx.slots.inject("conversation.chat.node", () => ctx.slots.register({
4533
+ name: "conversation.chat.node",
4534
+ key: TRANSLATION_KIND,
4535
+ locale: localeNs
4536
+ }, TranslationCard));
4537
+ ctx.slots.inject("conversation.chat.assistant-actions", () => ctx.slots.register({
4538
+ name: "conversation.chat.assistant-actions",
4539
+ id: "agy-tsl-message",
4540
+ order: 20,
4541
+ locale: localeNs,
4542
+ inject: (sessionId) => ({ sessionId })
4543
+ }, ((props) => TranslateAction({
4544
+ ...props ?? {},
4545
+ ctx
4546
+ }))));
4547
+ } catch (e) {
4548
+ console.warn("[dsh-agy-link] translation slots unavailable:", e);
4549
+ }
4550
+ return () => {
4551
+ for (const dispose of disposers) try {
4552
+ dispose();
4553
+ } catch {}
4554
+ try {
4555
+ const doc = win$1.document;
4556
+ doc?.getElementById?.(TIP_ID)?.remove?.();
4557
+ doc?.getElementById?.(STYLE_ID)?.remove?.();
4558
+ } catch {}
4559
+ };
4560
+ }
4561
+ //#endregion
3812
4562
  //#region src/client/index.ts
3813
4563
  const { createElement: h, useState, useEffect, useRef } = require("react");
3814
4564
  const reactDom = require("react-dom");
@@ -4680,6 +5430,42 @@ body.dark,
4680
5430
  .agy-btn:active:not(:disabled) {
4681
5431
  transform: translateY(0.5px);
4682
5432
  }
5433
+
5434
+ /* Standalone enable/disable toggle (rows without a segment group). Class-based
5435
+ so both states carry a real border, a hover affordance and a visible
5436
+ clickable area — the old inline segBtn left the OFF state invisible. */
5437
+ .agy-toggle {
5438
+ display: inline-flex;
5439
+ align-items: center;
5440
+ justify-content: center;
5441
+ min-width: 58px;
5442
+ padding: 4px 12px;
5443
+ border-radius: 999px;
5444
+ border: 1px solid var(--dsw-alias-border-l3, #94a3b8);
5445
+ background: var(--dsw-alias-bg-layer-1, #f8fafc);
5446
+ color: var(--dsw-alias-label-primary, #0f172a);
5447
+ font-size: 11.5px;
5448
+ font-weight: 600;
5449
+ line-height: 1.5;
5450
+ cursor: pointer;
5451
+ transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, filter 0.15s ease;
5452
+ }
5453
+ .agy-toggle:hover:not(:disabled) {
5454
+ border-color: var(--dsw-alias-border-l4, #64748b);
5455
+ background: var(--dsw-alias-interactive-bg-hover-solid, #e2e8f0);
5456
+ }
5457
+ .agy-toggle:disabled {
5458
+ opacity: 0.55;
5459
+ cursor: default;
5460
+ }
5461
+ .agy-toggle[data-on="true"] {
5462
+ border-color: var(--dsw-alias-state-business-primary, #2563eb);
5463
+ background: var(--dsw-alias-state-business-primary, #2563eb);
5464
+ color: #ffffff;
5465
+ }
5466
+ .agy-toggle[data-on="true"]:hover:not(:disabled) {
5467
+ filter: brightness(1.08);
5468
+ }
4683
5469
  .agy-progress-fill {
4684
5470
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
4685
5471
  }
@@ -5962,6 +6748,14 @@ html.agy-modal-open [data-conversation-scroll] {
5962
6748
  flexDirection: "column",
5963
6749
  gap: "10px"
5964
6750
  } }, h("div", { style: {
6751
+ display: "flex",
6752
+ flexDirection: "column",
6753
+ gap: "2px"
6754
+ } }, h("span", { style: {
6755
+ color: "var(--agy-text-primary)",
6756
+ fontWeight: 600,
6757
+ fontSize: "12.5px"
6758
+ } }, t("config.runtimeTitle")), h("span", { style: S.muted }, t("config.runtimeDesc"))), h("div", { style: {
5965
6759
  display: "flex",
5966
6760
  alignItems: "center",
5967
6761
  justifyContent: "space-between"
@@ -5969,64 +6763,57 @@ html.agy-modal-open [data-conversation-scroll] {
5969
6763
  color: "var(--agy-text-primary)",
5970
6764
  fontWeight: 600,
5971
6765
  fontSize: "12.5px"
5972
- } }, t("permission.label")), h("div", { style: S.segGroup }, h("button", {
5973
- type: "button",
5974
- style: status?.permissionMode === "plan" ? S.segBtnActive : S.segBtn,
5975
- onClick: () => void setCfg("permissionMode", "plan")
5976
- }, t("permission.plan")), h("button", {
6766
+ } }, t("pool.label")), h("div", { style: S.segGroup }, h("button", {
5977
6767
  type: "button",
5978
- style: status?.permissionMode === "accept-edits" ? S.segBtnActive : S.segBtn,
5979
- onClick: () => void setCfg("permissionMode", "accept-edits")
5980
- }, t("permission.acceptEdits")), h("button", {
6768
+ style: pool?.mode === "sequential" || !pool?.mode ? S.segBtnActive : S.segBtn,
6769
+ onClick: () => void setMode("sequential")
6770
+ }, t("pool.sequential")), h("button", {
5981
6771
  type: "button",
5982
- style: status?.permissionMode === "skip" ? {
5983
- ...S.segBtnActive,
5984
- color: "var(--agy-seg-danger-text)",
5985
- background: "var(--agy-seg-danger-bg)",
5986
- border: "1px solid var(--agy-seg-danger-border)"
5987
- } : S.segBtn,
5988
- onClick: () => void setCfg("permissionMode", "skip")
5989
- }, t("permission.skip")))), h("div", { style: {
6772
+ style: pool?.mode === "round-robin" ? S.segBtnActive : S.segBtn,
6773
+ onClick: () => void setMode("round-robin")
6774
+ }, t("pool.roundRobin")))), h("div", { style: {
5990
6775
  display: "flex",
5991
6776
  alignItems: "center",
5992
6777
  justifyContent: "space-between"
6778
+ } }, h("div", { style: {
6779
+ display: "flex",
6780
+ flexDirection: "column"
5993
6781
  } }, h("span", { style: {
5994
6782
  color: "var(--agy-text-primary)",
5995
6783
  fontWeight: 600,
5996
6784
  fontSize: "12.5px"
5997
- } }, t("effort.label")), h("div", { style: S.segGroup }, h("button", {
6785
+ } }, t("config.autoWarmup")), h("span", { style: S.muted }, t("config.autoWarmupDesc"))), h("div", { style: S.segGroup }, h("button", {
5998
6786
  type: "button",
5999
- style: status?.defaultEffort === "" ? S.segBtnActive : S.segBtn,
6000
- onClick: () => void setCfg("defaultEffort", "")
6001
- }, t("effort.auto")), h("button", {
6002
- type: "button",
6003
- style: status?.defaultEffort === "low" ? S.segBtnActive : S.segBtn,
6004
- onClick: () => void setCfg("defaultEffort", "low")
6005
- }, t("effort.low")), h("button", {
6006
- type: "button",
6007
- style: status?.defaultEffort === "medium" ? S.segBtnActive : S.segBtn,
6008
- onClick: () => void setCfg("defaultEffort", "medium")
6009
- }, t("effort.medium")), h("button", {
6787
+ style: status?.autoWarmup === true ? S.segBtnActive : S.segBtn,
6788
+ disabled: loadingAction === "config:autoWarmup",
6789
+ onClick: () => void setCfg("autoWarmup", true)
6790
+ }, t("config.on")), h("button", {
6010
6791
  type: "button",
6011
- style: status?.defaultEffort === "high" ? S.segBtnActive : S.segBtn,
6012
- onClick: () => void setCfg("defaultEffort", "high")
6013
- }, t("effort.high")))), h("div", { style: {
6792
+ style: status?.autoWarmup !== true ? S.segBtnActive : S.segBtn,
6793
+ disabled: loadingAction === "config:autoWarmup",
6794
+ onClick: () => void setCfg("autoWarmup", false)
6795
+ }, t("config.off")))), h("div", { style: {
6014
6796
  display: "flex",
6015
6797
  alignItems: "center",
6016
6798
  justifyContent: "space-between"
6799
+ } }, h("div", { style: {
6800
+ display: "flex",
6801
+ flexDirection: "column"
6017
6802
  } }, h("span", { style: {
6018
6803
  color: "var(--agy-text-primary)",
6019
6804
  fontWeight: 600,
6020
6805
  fontSize: "12.5px"
6021
- } }, t("pool.label")), h("div", { style: S.segGroup }, h("button", {
6806
+ } }, t("config.autoTranslate")), h("span", { style: S.muted }, t("config.autoTranslateDesc"))), h("div", { style: S.segGroup }, h("button", {
6022
6807
  type: "button",
6023
- style: pool?.mode === "sequential" || !pool?.mode ? S.segBtnActive : S.segBtn,
6024
- onClick: () => void setMode("sequential")
6025
- }, t("pool.sequential")), h("button", {
6808
+ style: status?.autoTranslate === true ? S.segBtnActive : S.segBtn,
6809
+ disabled: loadingAction === "config:autoTranslate",
6810
+ onClick: () => void setCfg("autoTranslate", true)
6811
+ }, t("config.on")), h("button", {
6026
6812
  type: "button",
6027
- style: pool?.mode === "round-robin" ? S.segBtnActive : S.segBtn,
6028
- onClick: () => void setMode("round-robin")
6029
- }, t("pool.roundRobin")))), h("div", { style: {
6813
+ style: status?.autoTranslate !== true ? S.segBtnActive : S.segBtn,
6814
+ disabled: loadingAction === "config:autoTranslate",
6815
+ onClick: () => void setCfg("autoTranslate", false)
6816
+ }, t("config.off")))), h("div", { style: {
6030
6817
  display: "flex",
6031
6818
  alignItems: "center",
6032
6819
  justifyContent: "space-between"
@@ -6037,12 +6824,27 @@ html.agy-modal-open [data-conversation-scroll] {
6037
6824
  color: "var(--agy-text-primary)",
6038
6825
  fontWeight: 600,
6039
6826
  fontSize: "12.5px"
6040
- } }, t("config.autoWarmup")), h("span", { style: S.muted }, t("config.autoWarmupDesc"))), h("button", {
6827
+ } }, t("config.defaultEffort")), h("span", { style: S.muted }, t("config.defaultEffortDesc"))), h("div", { style: S.segGroup }, h("button", {
6041
6828
  type: "button",
6042
- style: status?.autoWarmup !== false ? S.segBtnActive : S.segBtn,
6043
- disabled: loadingAction === "config:autoWarmup",
6044
- onClick: () => void setCfg("autoWarmup", status?.autoWarmup === false)
6045
- }, status?.autoWarmup !== false ? t("account.disable") : t("account.enable"))), h("div", { style: {
6829
+ style: status?.defaultEffort === "" ? S.segBtnActive : S.segBtn,
6830
+ disabled: loadingAction === "config:defaultEffort",
6831
+ onClick: () => void setCfg("defaultEffort", "")
6832
+ }, t("effort.auto")), h("button", {
6833
+ type: "button",
6834
+ style: status?.defaultEffort === "low" ? S.segBtnActive : S.segBtn,
6835
+ disabled: loadingAction === "config:defaultEffort",
6836
+ onClick: () => void setCfg("defaultEffort", "low")
6837
+ }, t("effort.low")), h("button", {
6838
+ type: "button",
6839
+ style: status?.defaultEffort === "medium" ? S.segBtnActive : S.segBtn,
6840
+ disabled: loadingAction === "config:defaultEffort",
6841
+ onClick: () => void setCfg("defaultEffort", "medium")
6842
+ }, t("effort.medium")), h("button", {
6843
+ type: "button",
6844
+ style: status?.defaultEffort === "high" ? S.segBtnActive : S.segBtn,
6845
+ disabled: loadingAction === "config:defaultEffort",
6846
+ onClick: () => void setCfg("defaultEffort", "high")
6847
+ }, t("effort.high")))), h("div", { style: {
6046
6848
  display: "flex",
6047
6849
  flexDirection: "column",
6048
6850
  gap: "6px"
@@ -6267,6 +7069,14 @@ html.agy-modal-open [data-conversation-scroll] {
6267
7069
  ctx.effect(() => installMermaidRendering());
6268
7070
  ctx.effect(() => installImageEnhancer());
6269
7071
  ctx.effect(() => installDecisionChips());
7072
+ ctx.effect(() => {
7073
+ try {
7074
+ return installTranslationUi(ctx, NS);
7075
+ } catch (e) {
7076
+ console.warn("[dsh-agy-link] translation UI unavailable:", e);
7077
+ return () => {};
7078
+ }
7079
+ });
6270
7080
  ctx.effect(() => installSettingsNavIcon(ctx, () => locale.bind(NS)("section.label")));
6271
7081
  }
6272
7082
  //#endregion