dsh-agy-link 0.4.95 → 0.4.96

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.96 (2026-10-30)
4
+
5
+ ### English
6
+
7
+ - **Fix(client/mermaid): serialize diagram rendering so multiple charts don't clobber each other and silently degrade to code blocks.**
8
+ - `mermaid.render()` is not reentrant: it injects shared temporary nodes into `document.body`, and `renderInto()`'s post-render `cleanupTempElements()` sweeps all of them. When one scan pass found two or more diagrams at once (a long answer with several charts, or the first lazy load resolving for every already-pending block), concurrent renders removed each other's in-flight temp DOM — the losers threw and auto-sniffed blocks silently set `data-agy-mermaid="fallback"`, i.e. the diagram simply stayed a plain `代码块`. All renders now go through a single `enqueueMermaidRender()` promise chain so exactly one diagram is drawn at a time; a failing task never breaks the chain. Adds serialization regression tests (verified live: 4 concurrent generic fences now all render).
9
+ - **Fix(adapter): session-title calls keep their format constraints (forward the system prompt) and don't force plan mode.**
10
+ - When DSH generates a session title (`options.purpose === 'session-title'`), the length/single-line/no-prefix constraints live in `options.system`, which was dropped (forwardSystemPrompt off, only review whitelisted), and aux calls were forced into `--mode plan` — chatty models then emitted conversational preambles that DSH stored verbatim as the title. Title calls now forward `options.system` and use `cfg.permissionMode` (no forced plan). Corrected from #63 (which used an invalid `'default'` mode); adds a regression test.
11
+
12
+ ### 中文
13
+
14
+ - **修复(client/mermaid):串行化图表渲染,避免一次扫描内的多个图表相互踩踏、静默降级成代码块。**
15
+ - `mermaid.render()` 不是可重入的:它会向 `document.body` 注入共享的临时节点,而 `renderInto()` 渲染后的 `cleanupTempElements()` 会清扫全部这类节点。当一次扫描同时命中两个及以上图表(长回答里有多个图表,或首次懒加载对所有待渲染块同时 resolve)时,并发渲染会互相删掉对方正在用的临时 DOM——败者抛错,自动嗅探的块静默进入 `data-agy-mermaid="fallback"`,也就是图表没渲染、仍显示成普通「代码块」。现在所有渲染都经过单一 `enqueueMermaidRender()` promise 链串行执行,单个任务失败也不会中断整条链。新增串行化回归测试(已在真实客户端实测:4 个并发通用代码围栏全部渲染成功)。
16
+ - **修复(adapter):会话标题调用保留格式约束(转发系统提示词)且不强制 plan 模式。**
17
+ - 生成会话标题时,单行/无前缀等格式约束位于 `options.system`,此前被丢弃且 aux 调用被强加 `--mode plan`,导致模型输出客套前缀被原样当作标题。现标题调用转发 `options.system` 并使用 `cfg.permissionMode`(不再强制 plan)。实现修正自 #63(其使用了无效的 `'default'` 模式);补充回归测试。
18
+
19
+ **Full Changelog**: https://github.com/amlyczz/dsh-agy-link/compare/v0.4.95...v0.4.96
20
+
3
21
  ## 0.4.95 (2026-10-30)
4
22
 
5
23
  ### English
package/dist/client.js CHANGED
@@ -3339,77 +3339,86 @@ body > [id^="iagy-mmd"] .error-icon {
3339
3339
  if (svg.includes("viewBox=\"0 0 0 0\"") || svg.includes("viewBox=\"-8 -8 16 16\"") || svg.includes("max-width: 16px") || svg.includes("max-width: 0px")) return true;
3340
3340
  return false;
3341
3341
  }
3342
+ let renderChain = Promise.resolve();
3343
+ /** Queue a render task behind the previous one. Failures never break the chain. */
3344
+ function enqueueMermaidRender(task) {
3345
+ const run = renderChain.then(task, task);
3346
+ renderChain = run.then(() => void 0, () => void 0);
3347
+ return run;
3348
+ }
3342
3349
  async function renderInto(block, source, lang = "") {
3343
3350
  block.querySelector("[data-agy-mermaid-svg]")?.remove();
3344
3351
  const mount = document.createElement("div");
3345
3352
  mount.setAttribute("data-agy-mermaid-svg", "1");
3346
3353
  block.appendChild(mount);
3347
- const api = await loadMermaid();
3348
- if (api === null) {
3349
- block.setAttribute("data-agy-mermaid", "error");
3350
- mount.setAttribute("data-agy-mermaid-error", "1");
3351
- mount.textContent = "Mermaid renderer unavailable (offline). Diagram source stays below.";
3352
- return;
3353
- }
3354
- renderSeq += 1;
3355
- const id = "agy-mmd-" + renderSeq;
3356
- let targetSource = source;
3357
- try {
3358
- let parseValidated = false;
3359
- if (typeof api.parse === "function") try {
3360
- await api.parse(targetSource);
3361
- parseValidated = true;
3362
- } catch (parseErr) {
3363
- const repaired = repairMermaidSource(targetSource);
3364
- if (repaired !== targetSource) try {
3365
- await api.parse(repaired);
3366
- targetSource = repaired;
3354
+ await enqueueMermaidRender(async () => {
3355
+ const api = await loadMermaid();
3356
+ if (api === null) {
3357
+ block.setAttribute("data-agy-mermaid", "error");
3358
+ mount.setAttribute("data-agy-mermaid-error", "1");
3359
+ mount.textContent = "Mermaid renderer unavailable (offline). Diagram source stays below.";
3360
+ return;
3361
+ }
3362
+ renderSeq += 1;
3363
+ const id = "agy-mmd-" + renderSeq;
3364
+ let targetSource = source;
3365
+ try {
3366
+ let parseValidated = false;
3367
+ if (typeof api.parse === "function") try {
3368
+ await api.parse(targetSource);
3367
3369
  parseValidated = true;
3368
- } catch {
3369
- throw parseErr;
3370
+ } catch (parseErr) {
3371
+ const repaired = repairMermaidSource(targetSource);
3372
+ if (repaired !== targetSource) try {
3373
+ await api.parse(repaired);
3374
+ targetSource = repaired;
3375
+ parseValidated = true;
3376
+ } catch {
3377
+ throw parseErr;
3378
+ }
3379
+ else throw parseErr;
3370
3380
  }
3371
- else throw parseErr;
3372
- }
3373
- if (!parseValidated && typeof api.parse !== "function") targetSource = repairMermaidSource(targetSource);
3374
- const { svg } = await api.render(id, targetSource);
3375
- if (isInvalidOrCollapsedSvg(svg)) throw new Error("Mermaid returned an empty or invalid diagram");
3376
- mount.innerHTML = "";
3377
- const toolbar = document.createElement("div");
3378
- toolbar.className = "agy-mermaid-toolbar";
3379
- const toggleBtn = document.createElement("button");
3380
- toggleBtn.type = "button";
3381
- toggleBtn.className = "agy-mermaid-toggle";
3382
- toggleBtn.textContent = "查看源码";
3383
- toggleBtn.title = "切换图表与原始代码";
3384
- toggleBtn.addEventListener("click", (ev) => {
3385
- ev.preventDefault();
3386
- ev.stopPropagation();
3387
- if (block.getAttribute("data-agy-mermaid-view") === "source") {
3388
- block.removeAttribute("data-agy-mermaid-view");
3389
- toggleBtn.textContent = "查看源码";
3381
+ if (!parseValidated && typeof api.parse !== "function") targetSource = repairMermaidSource(targetSource);
3382
+ const { svg } = await api.render(id, targetSource);
3383
+ if (isInvalidOrCollapsedSvg(svg)) throw new Error("Mermaid returned an empty or invalid diagram");
3384
+ mount.innerHTML = "";
3385
+ const toolbar = document.createElement("div");
3386
+ toolbar.className = "agy-mermaid-toolbar";
3387
+ const toggleBtn = document.createElement("button");
3388
+ toggleBtn.type = "button";
3389
+ toggleBtn.className = "agy-mermaid-toggle";
3390
+ toggleBtn.textContent = "查看源码";
3391
+ toggleBtn.title = "切换图表与原始代码";
3392
+ toggleBtn.addEventListener("click", (ev) => {
3393
+ ev.preventDefault();
3394
+ ev.stopPropagation();
3395
+ if (block.getAttribute("data-agy-mermaid-view") === "source") {
3396
+ block.removeAttribute("data-agy-mermaid-view");
3397
+ toggleBtn.textContent = "查看源码";
3398
+ } else {
3399
+ block.setAttribute("data-agy-mermaid-view", "source");
3400
+ toggleBtn.textContent = "查看图表";
3401
+ }
3402
+ });
3403
+ toolbar.appendChild(toggleBtn);
3404
+ mount.appendChild(toolbar);
3405
+ const bodyDiv = document.createElement("div");
3406
+ bodyDiv.className = "agy-mermaid-body";
3407
+ bodyDiv.innerHTML = svg;
3408
+ mount.appendChild(bodyDiv);
3409
+ block.setAttribute("data-agy-mermaid", "done");
3410
+ } catch (e) {
3411
+ if (!isMermaidLang(lang)) {
3412
+ mount.remove();
3413
+ block.setAttribute("data-agy-mermaid", "fallback");
3390
3414
  } else {
3391
- block.setAttribute("data-agy-mermaid-view", "source");
3392
- toggleBtn.textContent = "查看图表";
3415
+ block.setAttribute("data-agy-mermaid", "error");
3416
+ mount.innerHTML = "<div class=\"agy-mermaid-warn\">⚠️ Mermaid 图表解析失败,已保留原始代码呈现</div>";
3393
3417
  }
3394
- });
3395
- toolbar.appendChild(toggleBtn);
3396
- mount.appendChild(toolbar);
3397
- const bodyDiv = document.createElement("div");
3398
- bodyDiv.className = "agy-mermaid-body";
3399
- bodyDiv.innerHTML = svg;
3400
- mount.appendChild(bodyDiv);
3401
- block.setAttribute("data-agy-mermaid", "done");
3402
- } catch (e) {
3403
- if (!isMermaidLang(lang)) {
3404
- mount.remove();
3405
- block.setAttribute("data-agy-mermaid", "fallback");
3406
- } else {
3407
- block.setAttribute("data-agy-mermaid", "error");
3408
- mount.innerHTML = "<div class=\"agy-mermaid-warn\">⚠️ Mermaid 图表解析失败,已保留原始代码呈现</div>";
3418
+ } finally {
3419
+ cleanupTempElements(id);
3409
3420
  }
3410
- } finally {
3411
- cleanupTempElements(id);
3412
- }
3421
+ });
3413
3422
  }
3414
3423
  let scanTimer$1 = null;
3415
3424
  function scheduleScan$1() {
package/dist/index.js CHANGED
@@ -30851,7 +30851,8 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
30851
30851
  const bin = this.deps.bin();
30852
30852
  if (!bin) throw new LlmError("agy binary not found on PATH — install it via https://antigravity.google/docs/cli/install", Err.AGY_NOT_INSTALLED);
30853
30853
  const isReview = typeof options.system === "string" && options.system.includes("REVIEW_POLICY");
30854
- const isAux = options.purpose === "compaction" || options.purpose === "session-title" || isReview;
30854
+ const isTitle = options.purpose === "session-title";
30855
+ const isAux = options.purpose === "compaction" || isTitle || isReview;
30855
30856
  if (isAux && !isReview && !cfg.allowAuxiliary) throw new LlmError("auxiliary calls are disabled for the antigravity route (allowAuxiliary: false)", Err.AUX_DISABLED);
30856
30857
  const toolNames = new Set((options.tools ?? []).map((t) => t.name));
30857
30858
  const isCodeMode = toolNames.has("run_code") && !toolNames.has("agy_tool");
@@ -31116,7 +31117,7 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
31116
31117
  if (binding.interrupted === true) prompt = "[the previous turn was interrupted before it finished — do not continue or answer that unfinished work; respond only to the newest request below]\n\n" + prompt;
31117
31118
  }
31118
31119
  }
31119
- if (cfg.forwardSystemPrompt || isReview) {
31120
+ if (cfg.forwardSystemPrompt || isReview || isTitle) {
31120
31121
  const sysInstruction = options.system || (() => {
31121
31122
  const sm = messages.find((m) => m.role === "system");
31122
31123
  return sm ? textOf(sm).trim() : "";
@@ -31266,7 +31267,7 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
31266
31267
  model: activeModelForArgs,
31267
31268
  effort,
31268
31269
  conversationId: !isAux && binding !== void 0 ? binding.conversationId : void 0,
31269
- permissionMode: isAux ? "plan" : cfg.permissionMode,
31270
+ permissionMode: isAux && !isTitle ? "plan" : cfg.permissionMode,
31270
31271
  timeoutMs: cfg.timeoutMs,
31271
31272
  printTimeoutMinutes,
31272
31273
  extraArgs: cfg.extraArgs,
@@ -31278,7 +31279,7 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
31278
31279
  model: activeModelForArgs,
31279
31280
  effort,
31280
31281
  conversationId: !isAux && binding !== void 0 ? binding.conversationId : void 0,
31281
- permissionMode: isAux ? "plan" : cfg.permissionMode,
31282
+ permissionMode: isAux && !isTitle ? "plan" : cfg.permissionMode,
31282
31283
  timeoutMs: cfg.timeoutMs,
31283
31284
  printTimeoutMinutes,
31284
31285
  extraArgs: cfg.extraArgs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agy-link",
3
- "version": "0.4.95",
3
+ "version": "0.4.96",
4
4
  "description": "Google Antigravity (agy CLI) models for DeepSeek Harness — stream Gemini/Claude/GPT-OSS subscriptions into DSH with thinking, tool activity, token usage and in-GUI Google OAuth login.",
5
5
  "type": "module",
6
6
  "license": "MIT",