dsh-agy-link 0.4.53 → 0.4.59

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
@@ -105,6 +105,7 @@ window.__ModuleLoader__.load({
105
105
  "quota.fiveHour": "5 小时额度",
106
106
  "quota.weekly": "周额度",
107
107
  "quota.refreshed": "额度已刷新",
108
+ "quota.windowReset": "已重置 · 可用",
108
109
  "proxy.button": "代理",
109
110
  "proxy.placeholder": "专属代理 URL(如:http://127.0.0.1:7890;留空则使用全局)",
110
111
  "proxy.save": "保存",
@@ -244,6 +245,7 @@ window.__ModuleLoader__.load({
244
245
  "quota.fiveHour": "5-hour quota",
245
246
  "quota.weekly": "Weekly quota",
246
247
  "quota.refreshed": "Quota refreshed",
248
+ "quota.windowReset": "Reset · available",
247
249
  "proxy.button": "Proxy",
248
250
  "proxy.placeholder": "Dedicated proxy URL (for example: http://127.0.0.1:7890; leave blank to use the global proxy)",
249
251
  "proxy.save": "Save",
@@ -383,6 +385,7 @@ window.__ModuleLoader__.load({
383
385
  "quota.fiveHour": "Cota de 5 horas",
384
386
  "quota.weekly": "Cota semanal",
385
387
  "quota.refreshed": "Cota atualizada",
388
+ "quota.windowReset": "Redefinida · disponível",
386
389
  "proxy.button": "Proxy",
387
390
  "proxy.placeholder": "URL do proxy exclusivo (por exemplo: http://127.0.0.1:7890; deixe vazio para usar o proxy global)",
388
391
  "proxy.save": "Salvar",
@@ -522,6 +525,7 @@ window.__ModuleLoader__.load({
522
525
  "quota.fiveHour": "Cuota de 5 horas",
523
526
  "quota.weekly": "Cuota semanal",
524
527
  "quota.refreshed": "Cuota actualizada",
528
+ "quota.windowReset": "Reiniciada · disponible",
525
529
  "proxy.button": "Proxy",
526
530
  "proxy.placeholder": "URL de proxy exclusivo (por ejemplo: http://127.0.0.1:7890; déjelo vacío para usar el proxy global)",
527
531
  "proxy.save": "Guardar",
@@ -2853,22 +2857,58 @@ window.__ModuleLoader__.load({
2853
2857
  //#endregion
2854
2858
  //#region src/client/mermaid.ts
2855
2859
  const MERMAID_CSS = `
2856
- div.md-code-block[data-agy-mermaid="done"] [data-code-block-content] {
2860
+ div.md-code-block[data-agy-mermaid="done"]:not([data-agy-mermaid-view="source"]) [data-code-block-content] {
2861
+ display: none !important;
2862
+ }
2863
+ div.md-code-block[data-agy-mermaid="done"][data-agy-mermaid-view="source"] [data-agy-mermaid-svg] > .agy-mermaid-body {
2857
2864
  display: none !important;
2858
2865
  }
2859
2866
  div.md-code-block[data-agy-mermaid="render"] {
2860
2867
  border-color: var(--dsw-alias-border-l2, #e2e8f0);
2861
2868
  }
2862
2869
  div[data-agy-mermaid-svg] {
2863
- padding: 12px 8px;
2870
+ position: relative;
2871
+ padding: 8px 8px 12px 8px;
2864
2872
  overflow-x: auto;
2865
2873
  text-align: center;
2866
2874
  background: var(--dsw-alias-bg-base, #ffffff);
2867
2875
  }
2868
2876
  div[data-agy-mermaid-svg] svg {
2869
2877
  max-width: 100%;
2878
+ min-width: 280px;
2870
2879
  height: auto;
2871
2880
  }
2881
+ .agy-mermaid-toolbar {
2882
+ display: flex;
2883
+ justify-content: flex-end;
2884
+ padding: 2px 4px 6px 4px;
2885
+ background: transparent;
2886
+ }
2887
+ .agy-mermaid-toggle {
2888
+ font-size: 11px;
2889
+ line-height: 1.4;
2890
+ padding: 2px 8px;
2891
+ border-radius: 4px;
2892
+ border: 1px solid var(--dsw-alias-border-l2, #e2e8f0);
2893
+ background: var(--dsw-alias-bg-surface, #f8fafc);
2894
+ color: var(--dsw-alias-label-secondary, #475569);
2895
+ cursor: pointer;
2896
+ user-select: none;
2897
+ transition: all 0.15s ease;
2898
+ }
2899
+ .agy-mermaid-toggle:hover {
2900
+ background: var(--dsw-alias-bg-hover, #f1f5f9);
2901
+ color: var(--dsw-alias-label-primary, #0f172a);
2902
+ }
2903
+ .agy-mermaid-warn {
2904
+ padding: 6px 10px;
2905
+ margin-bottom: 6px;
2906
+ font-size: 12px;
2907
+ color: #92400e;
2908
+ background: #fef3c7;
2909
+ border-radius: 4px;
2910
+ text-align: left;
2911
+ }
2872
2912
  div[data-agy-mermaid-svg][data-agy-mermaid-error] {
2873
2913
  text-align: left;
2874
2914
  color: var(--dsw-alias-label-tertiary, #64748b);
@@ -2937,12 +2977,17 @@ body > [id^="iagy-mmd"] .error-icon {
2937
2977
  loadPromise = (async () => {
2938
2978
  for (const url of CDN_URLS) if (await loadScript(url) && window.mermaid !== void 0) {
2939
2979
  try {
2980
+ const isDark = typeof document !== "undefined" && (document.documentElement.classList.contains("dark") || document.body.classList.contains("dark") || window.matchMedia?.("(prefers-color-scheme: dark)").matches === true);
2940
2981
  window.mermaid.initialize({
2941
2982
  startOnLoad: false,
2942
2983
  securityLevel: "strict",
2943
- theme: "neutral",
2984
+ theme: isDark ? "dark" : "neutral",
2944
2985
  fontFamily: "inherit",
2945
- suppressErrorRendering: true
2986
+ suppressErrorRendering: true,
2987
+ flowchart: {
2988
+ useMaxWidth: true,
2989
+ htmlLabels: false
2990
+ }
2946
2991
  });
2947
2992
  } catch {}
2948
2993
  return window.mermaid;
@@ -2955,12 +3000,16 @@ body > [id^="iagy-mmd"] .error-icon {
2955
3000
  }
2956
3001
  /** Banner infostring text ("mermaid") identifies the fence language. */
2957
3002
  function fenceLang(block) {
2958
- const text = ((block.querySelector("[data-code-block-banner] [class*=\"infostring\"]") ?? block.querySelector("[data-code-block-banner] [class*=\"language\"]") ?? block.querySelector("[data-code-block-banner]"))?.textContent ?? "").trim().toLowerCase();
2959
- if (text !== "") return text.split(/\s+/)[0] ?? "";
2960
- const code = block.querySelector("[data-code-block-content] code");
3003
+ const code = block.querySelector("[data-code-block-content] code") ?? block.querySelector("[data-code-block-content] pre");
2961
3004
  const m = (code?.getAttribute("class") ?? "").match(/language-([\w-]+)/);
2962
3005
  if (m?.[1]) return m[1].toLowerCase();
2963
- return (code?.getAttribute("data-language") ?? block.getAttribute("data-language") ?? "").toLowerCase();
3006
+ const dataLang = (code?.getAttribute("data-language") ?? block.getAttribute("data-language") ?? "").trim().toLowerCase();
3007
+ if (dataLang !== "") return dataLang;
3008
+ const text = ((block.querySelector("[data-code-block-banner] [class*=\"infostring\"]") ?? block.querySelector("[data-code-block-banner] [class*=\"language\"]"))?.textContent ?? "").trim().toLowerCase();
3009
+ if (text !== "") return text.split(/\s+/)[0] ?? "";
3010
+ const bannerText = (block.querySelector("[data-code-block-banner]")?.textContent ?? "").trim().toLowerCase();
3011
+ if (bannerText !== "" && bannerText !== "代码块" && bannerText !== "code" && bannerText !== "code block") return bannerText.split(/\s+/)[0] ?? "";
3012
+ return "";
2964
3013
  }
2965
3014
  const MERMAID_FIRST_LINE = /^(?:flowchart(?:\s+\w+)?|graph\s+(?:TB|TD|LR|RL|BT)|sequenceDiagram|classDiagram(?:-v2)?|stateDiagram(?:-v2)?|erDiagram|journey|gantt|pie|mindmap|timeline|gitGraph|sankey-beta|xychart-beta|block-beta|quadrantChart|requirementDiagram|radar-beta|C4(?:Context|Container|Component|Dynamic))\b/;
2966
3015
  /** Content sniff: unknown-language fences are the whole reason this module exists. */
@@ -3034,7 +3083,51 @@ body > [id^="iagy-mmd"] .error-icon {
3034
3083
  const stray = document.querySelectorAll("body > [id^=\"dagy-mmd\"], body > [id^=\"iagy-mmd\"], body > [id^=\"d_agy-mmd\"], body > [id^=\"i_agy-mmd\"], body > [id^=\"agy-mmd-\"]");
3035
3084
  for (let i = 0; i < stray.length; i++) stray[i]?.remove();
3036
3085
  }
3037
- async function renderInto(block, source) {
3086
+ function repairMermaidSource(source) {
3087
+ if (!/^\s*(?:flowchart|graph)\b/i.test(source)) return source;
3088
+ return source.split(/\r?\n/).map((line) => {
3089
+ let l = line;
3090
+ const subMatch = l.match(/^(\s*subgraph\s+)([^"[\]\n]+)$/i);
3091
+ if (subMatch && (subMatch[2].includes(":") || subMatch[2].includes(" ") || subMatch[2].includes(":"))) {
3092
+ const title = subMatch[2].trim();
3093
+ l = `${subMatch[1]}"${title}"`;
3094
+ }
3095
+ l = l.replace(/(\b[a-zA-Z0-9_\u4e00-\u9fa5]+)\[([^"\]\n]+)\]/g, (m, id, text) => {
3096
+ if (text.includes(">") || text.includes("<") || text.includes(":") || text.includes(":") || text.includes("(") || text.includes(")")) return `${id}["${text.trim()}"]`;
3097
+ return m;
3098
+ });
3099
+ l = l.replace(/(\b[a-zA-Z0-9_\u4e00-\u9fa5]+)\(([^")\n]+)\)/g, (m, id, text) => {
3100
+ if (text.includes(">") || text.includes("<") || text.includes(":") || text.includes(":") || text.includes("[") || text.includes("]")) return `${id}("${text.trim()}")`;
3101
+ return m;
3102
+ });
3103
+ if (l.includes("-->") || l.includes("---") || l.includes("-.->") || l.includes("==>") || l.includes("<--")) {
3104
+ let inQuote = false;
3105
+ let inBracket = 0;
3106
+ let inPipe = false;
3107
+ let out = "";
3108
+ for (let i = 0; i < l.length; i++) {
3109
+ const ch = l[i];
3110
+ if (ch === "\"" && (i === 0 || l[i - 1] !== "\\")) {
3111
+ inQuote = !inQuote;
3112
+ out += ch;
3113
+ } else if (!inQuote && ch === "|") {
3114
+ inPipe = !inPipe;
3115
+ out += ch;
3116
+ } else if (!inQuote && !inPipe && (ch === "[" || ch === "(" || ch === "{")) {
3117
+ inBracket++;
3118
+ out += ch;
3119
+ } else if (!inQuote && !inPipe && (ch === "]" || ch === ")" || ch === "}")) {
3120
+ if (inBracket > 0) inBracket--;
3121
+ out += ch;
3122
+ } else if (!inQuote && !inPipe && inBracket === 0 && ch === "+") out += "&";
3123
+ else out += ch;
3124
+ }
3125
+ l = out;
3126
+ }
3127
+ return l;
3128
+ }).join("\n");
3129
+ }
3130
+ async function renderInto(block, source, lang = "") {
3038
3131
  block.querySelector("[data-agy-mermaid-svg]")?.remove();
3039
3132
  const mount = document.createElement("div");
3040
3133
  mount.setAttribute("data-agy-mermaid-svg", "1");
@@ -3048,15 +3141,60 @@ body > [id^="iagy-mmd"] .error-icon {
3048
3141
  }
3049
3142
  renderSeq += 1;
3050
3143
  const id = "agy-mmd-" + renderSeq;
3144
+ let targetSource = source;
3051
3145
  try {
3052
- if (typeof api.parse === "function") await api.parse(source);
3053
- const { svg } = await api.render(id, source, mount);
3054
- mount.innerHTML = svg;
3146
+ let parseValidated = false;
3147
+ if (typeof api.parse === "function") try {
3148
+ await api.parse(targetSource);
3149
+ parseValidated = true;
3150
+ } catch (parseErr) {
3151
+ const repaired = repairMermaidSource(targetSource);
3152
+ if (repaired !== targetSource) try {
3153
+ await api.parse(repaired);
3154
+ targetSource = repaired;
3155
+ parseValidated = true;
3156
+ } catch {
3157
+ throw parseErr;
3158
+ }
3159
+ else throw parseErr;
3160
+ }
3161
+ if (!parseValidated && typeof api.parse !== "function") targetSource = repairMermaidSource(targetSource);
3162
+ const { svg } = await api.render(id, targetSource, mount);
3163
+ if (!svg || svg.trim() === "" || svg.includes("class=\"error-icon\"") || svg.includes("class=\"error-text\"") || svg.includes("aria-roledescription=\"error\"")) throw new Error("Mermaid returned an empty or error diagram");
3164
+ mount.innerHTML = "";
3165
+ const toolbar = document.createElement("div");
3166
+ toolbar.className = "agy-mermaid-toolbar";
3167
+ const toggleBtn = document.createElement("button");
3168
+ toggleBtn.type = "button";
3169
+ toggleBtn.className = "agy-mermaid-toggle";
3170
+ toggleBtn.textContent = "查看源码";
3171
+ toggleBtn.title = "切换图表与原始代码";
3172
+ toggleBtn.addEventListener("click", (ev) => {
3173
+ ev.preventDefault();
3174
+ ev.stopPropagation();
3175
+ if (block.getAttribute("data-agy-mermaid-view") === "source") {
3176
+ block.removeAttribute("data-agy-mermaid-view");
3177
+ toggleBtn.textContent = "查看源码";
3178
+ } else {
3179
+ block.setAttribute("data-agy-mermaid-view", "source");
3180
+ toggleBtn.textContent = "查看图表";
3181
+ }
3182
+ });
3183
+ toolbar.appendChild(toggleBtn);
3184
+ mount.appendChild(toolbar);
3185
+ const bodyDiv = document.createElement("div");
3186
+ bodyDiv.className = "agy-mermaid-body";
3187
+ bodyDiv.innerHTML = svg;
3188
+ mount.appendChild(bodyDiv);
3055
3189
  block.setAttribute("data-agy-mermaid", "done");
3056
3190
  } catch (e) {
3057
- block.setAttribute("data-agy-mermaid", "error");
3058
- mount.setAttribute("data-agy-mermaid-error", "1");
3059
- mount.textContent = "Mermaid render failed: " + (e instanceof Error ? e.message : String(e));
3191
+ if (!isMermaidLang(lang)) {
3192
+ mount.remove();
3193
+ block.setAttribute("data-agy-mermaid", "fallback");
3194
+ } else {
3195
+ block.setAttribute("data-agy-mermaid", "error");
3196
+ mount.innerHTML = "<div class=\"agy-mermaid-warn\">⚠️ Mermaid 图表解析失败,已保留原始代码呈现</div>";
3197
+ }
3060
3198
  } finally {
3061
3199
  cleanupTempElements(id);
3062
3200
  }
@@ -3077,13 +3215,13 @@ body > [id^="iagy-mmd"] .error-icon {
3077
3215
  const block = blocks[i];
3078
3216
  if (!block) continue;
3079
3217
  const state = block.getAttribute("data-agy-mermaid");
3080
- if (state === "done" || state === "busy" || state === "error") continue;
3218
+ if (state === "done" || state === "busy" || state === "error" || state === "fallback") continue;
3081
3219
  const lang = fenceLang(block);
3082
3220
  const source = readSource(block);
3083
3221
  if (source === "") continue;
3084
3222
  if (!isMermaidBlock(lang, source)) continue;
3085
3223
  block.setAttribute("data-agy-mermaid", "busy");
3086
- renderInto(block, source);
3224
+ renderInto(block, source, lang);
3087
3225
  }
3088
3226
  }
3089
3227
  let activeObserver$1 = null;
@@ -3458,11 +3596,17 @@ div[data-variant="think"] [class*="thinkBody"] {
3458
3596
  * Format reset timestamp into readable date/time + relative countdown.
3459
3597
  */
3460
3598
  function formatQuotaWindow(t, resetTimeStr) {
3461
- if (!resetTimeStr) return { resetText: "" };
3599
+ if (!resetTimeStr) return {
3600
+ resetText: "",
3601
+ expired: false
3602
+ };
3462
3603
  try {
3463
3604
  const d = new Date(resetTimeStr);
3464
3605
  const diffMs = d.getTime() - Date.now();
3465
- if (diffMs <= 0) return { resetText: "" };
3606
+ if (Number.isNaN(d.getTime()) || diffMs <= 0) return {
3607
+ resetText: "",
3608
+ expired: true
3609
+ };
3466
3610
  const totalMins = Math.ceil(diffMs / 6e4);
3467
3611
  const days = Math.floor(totalMins / 1440);
3468
3612
  const hours = Math.floor(totalMins % 1440 / 60);
@@ -3471,9 +3615,15 @@ div[data-variant="think"] [class*="thinkBody"] {
3471
3615
  const countdown = days > 0 ? `${days}${t("duration.day")} ${hours}${t("duration.hour")}` : hours > 0 ? `${hours}${t("duration.hour")} ${mins}${t("duration.minute")}` : `${mins}${t("duration.minute")}`;
3472
3616
  const hh = d.getHours().toString().padStart(2, "0");
3473
3617
  const mm = d.getMinutes().toString().padStart(2, "0");
3474
- return { resetText: isWeekly ? `${d.getMonth() + 1}/${d.getDate()} ${hh}:${mm} (${countdown})` : `${hh}:${mm} (${countdown})` };
3618
+ return {
3619
+ resetText: isWeekly ? `${d.getMonth() + 1}/${d.getDate()} ${hh}:${mm} (${countdown})` : `${hh}:${mm} (${countdown})`,
3620
+ expired: false
3621
+ };
3475
3622
  } catch {
3476
- return { resetText: "" };
3623
+ return {
3624
+ resetText: "",
3625
+ expired: true
3626
+ };
3477
3627
  }
3478
3628
  }
3479
3629
  /** Inline brand logo (Gemini / Claude / OpenAI) as a crisp SVG mark. */
@@ -3518,6 +3668,7 @@ div[data-variant="think"] [class*="thinkBody"] {
3518
3668
  }
3519
3669
  const FAMILY_BRAND = {
3520
3670
  google: "gemini",
3671
+ argon: "gemini",
3521
3672
  anthropic: "claude",
3522
3673
  openai: "openai"
3523
3674
  };
@@ -4464,11 +4615,15 @@ body.dark,
4464
4615
  const info = acc.quotas[familyKey];
4465
4616
  const cd = acc.cooldowns[familyKey];
4466
4617
  const inCooldown = cd && cd.cooldownUntil > Date.now();
4467
- const pct5h = typeof info?.remainingFraction === "number" && Number.isFinite(info.remainingFraction) ? Math.max(0, Math.min(100, Math.round(info.remainingFraction * 100))) : -1;
4618
+ const has5h = typeof info?.remainingFraction === "number" && Number.isFinite(info.remainingFraction);
4619
+ const pct5h = has5h ? Math.max(0, Math.min(100, Math.round(info.remainingFraction * 100))) : -1;
4468
4620
  const cdNote = inCooldown ? t("account.localCooldown") : "";
4469
4621
  const w5h = formatQuotaWindow(t, info?.resetTime);
4470
- const pctWeekly = typeof info?.weeklyFraction === "number" && Number.isFinite(info.weeklyFraction) ? Math.max(0, Math.min(100, Math.round(info.weeklyFraction * 100))) : -1;
4622
+ const expiredFull5h = w5h.expired && has5h && pct5h >= 100;
4623
+ const hasWeekly = typeof info?.weeklyFraction === "number" && Number.isFinite(info.weeklyFraction);
4624
+ const pctWeekly = hasWeekly ? Math.max(0, Math.min(100, Math.round(info.weeklyFraction * 100))) : -1;
4471
4625
  const wWeekly = formatQuotaWindow(t, info?.weeklyResetTime);
4626
+ const expiredFullWeekly = wWeekly.expired && hasWeekly && pctWeekly >= 100;
4472
4627
  const getColors = (pct) => {
4473
4628
  if (pct < 0) return {
4474
4629
  bar: "var(--agy-quota-none-border)",
@@ -4553,7 +4708,7 @@ body.dark,
4553
4708
  fontSize: "12.5px",
4554
4709
  marginBottom: "5px",
4555
4710
  color: "var(--agy-text-primary)"
4556
- } }, brandIcon(FAMILY_BRAND[familyKey], 14), h("span", null, label)), renderLine(t("quota.fiveHour"), pct5h, c5h, w5h.resetText ? w5h.resetText + cdNote : cdNote.replace(/^ · /, "")), renderLine(t("quota.weekly"), pctWeekly, cWeekly, wWeekly.resetText));
4711
+ } }, brandIcon(FAMILY_BRAND[familyKey], 14), h("span", null, label)), familyKey !== "argon" || has5h ? renderLine(t("quota.fiveHour"), pct5h, c5h, w5h.resetText ? w5h.resetText + cdNote : expiredFull5h ? t("quota.windowReset") + cdNote : cdNote.replace(/^ · /, "")) : null, renderLine(t("quota.weekly"), pctWeekly, cWeekly, wWeekly.resetText ? wWeekly.resetText : expiredFullWeekly ? t("quota.windowReset") : ""));
4557
4712
  };
4558
4713
  const activeAccountId = pool?.activeAccountId ?? pool?.lastActiveAccountId ?? pool?.activeAccountIds?.google ?? pool?.primaryAccountId;
4559
4714
  const renderedAccountCards = accounts.map((acc) => {
@@ -4575,6 +4730,7 @@ body.dark,
4575
4730
  const legacyDefault = acc.defaultAlias === void 0 && acc.systemHome && acc.alias === "主账号 (系统登录)";
4576
4731
  const displayAlias = acc.defaultAlias || legacyDefault ? acc.systemHome ? t("account.defaultAlias") : t("account.aliasDefault", { number: accIndex + 1 }) : acc.alias;
4577
4732
  const googleModels = acc.quotas.google?.models ?? [];
4733
+ const argonModels = acc.quotas.argon?.models ?? [];
4578
4734
  const anthropicModels = acc.quotas.anthropic?.models ?? [];
4579
4735
  const openaiModels = acc.quotas.openai?.models ?? [];
4580
4736
  const allChildModels = [
@@ -4582,6 +4738,10 @@ body.dark,
4582
4738
  family: "Google",
4583
4739
  model: m
4584
4740
  })),
4741
+ ...argonModels.map((m) => ({
4742
+ family: "Argon",
4743
+ model: m
4744
+ })),
4585
4745
  ...anthropicModels.map((m) => ({
4586
4746
  family: "Anthropic",
4587
4747
  model: m
@@ -4810,7 +4970,7 @@ body.dark,
4810
4970
  }, loadingAction === `remove:${acc.id}` ? renderSpinner() : uiIcon("trash", 11, "var(--agy-danger-text)")) : null)), h("div", {
4811
4971
  key: "agy-body",
4812
4972
  style: S.quotaBox
4813
- }, renderQuotaBar("Gemini", "google", acc), h("button", {
4973
+ }, renderQuotaBar("Gemini", "google", acc), acc.quotas.argon ? renderQuotaBar("Argon", "argon", acc) : null, h("button", {
4814
4974
  type: "button",
4815
4975
  className: "agy-btn",
4816
4976
  style: {