dsh-agy-link 0.4.94 → 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,39 @@
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
+
21
+ ## 0.4.95 (2026-10-30)
22
+
23
+ ### English
24
+
25
+ - **Fix(runner): stop Linux pool accounts from reading the desktop Secret Service (primary token) — isolate D-Bus per account.** (thanks @superwiboy, #62)
26
+ - On Linux with a desktop session, agy's credential reader queries the OS Secret Service (gnome-keyring/secret-tool) before the isolated token file, so pooled sub-accounts silently used the primary account's token (primary quota drained, sub-accounts at 0 usage). `isolatedHomeEnv()` now sets `DBUS_SESSION_BUS_ADDRESS` to a nonexistent, **per-account private** path (`<home>/.no-dbus-session`), forcing agy to read only its slot token.
27
+ - Hardening over the original patch: the dummy bus path is private to each isolated home instead of a shared world-writable `/tmp` path (which a local user could hijack by binding a fake bus socket). Adds `linuxDbusDisabledEnv()` + tests.
28
+
29
+ ### 中文
30
+
31
+ - **修复(runner):Linux 池账号不再穿透到桌面 Secret Service(读到主账号 token)——按账号隔离 D-Bus。**(感谢 @superwiboy,#62)
32
+ - Linux 桌面会话下,agy 读取凭据时会先查系统 Secret Service(gnome-keyring/secret-tool),导致池内子账号静默使用主账号 token(主账号额度被耗、子账号 0 用量)。`isolatedHomeEnv()` 现在把 `DBUS_SESSION_BUS_ADDRESS` 指向一个不存在、且**每账号私有**的路径(`<home>/.no-dbus-session`),强制 agy 只读自己 slot 的 token。
33
+ - 相较原补丁的加固:临时 bus 路径使用各账号私有 home,而非共享可写的 `/tmp` 路径(后者可能被本机其他用户伪造 bus socket 劫持)。新增 `linuxDbusDisabledEnv()` 及测试。
34
+
35
+ **Full Changelog**: https://github.com/amlyczz/dsh-agy-link/compare/v0.4.94...v0.4.95
36
+
3
37
  ## 0.4.94 (2026-10-29)
4
38
 
5
39
  ### 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
@@ -3113,6 +3113,16 @@ function windowsQuote(arg) {
3113
3113
  * the real user profile). GEMINI_CLI_HOME is honored by the agy CLI on all
3114
3114
  * platforms for its .gemini dir.
3115
3115
  */
3116
+ /**
3117
+ * Linux/Unix: env that points D-Bus at a nonexistent, per-account PRIVATE path
3118
+ * so agy cannot fall through to the desktop Secret Service (gnome-keyring) and
3119
+ * read the primary account's token. The path lives INSIDE the isolated home:
3120
+ * a shared world-writable path (e.g. /tmp/…) could be hijacked by another local
3121
+ * user binding a fake bus socket there and MITM-ing the Secret Service lookup.
3122
+ */
3123
+ function linuxDbusDisabledEnv(dir) {
3124
+ return { DBUS_SESSION_BUS_ADDRESS: "unix:path=" + join(dir, ".no-dbus-session") };
3125
+ }
3116
3126
  function isolatedHomeEnv(dir) {
3117
3127
  const geminiDir = join(dir, ".gemini");
3118
3128
  const env = {
@@ -3128,7 +3138,7 @@ function isolatedHomeEnv(dir) {
3128
3138
  env.HOMEDRIVE = m[1];
3129
3139
  env.HOMEPATH = m[2];
3130
3140
  }
3131
- }
3141
+ } else if (process.platform === "linux") Object.assign(env, linuxDbusDisabledEnv(dir));
3132
3142
  return env;
3133
3143
  }
3134
3144
  /**
@@ -30841,7 +30851,8 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
30841
30851
  const bin = this.deps.bin();
30842
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);
30843
30853
  const isReview = typeof options.system === "string" && options.system.includes("REVIEW_POLICY");
30844
- 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;
30845
30856
  if (isAux && !isReview && !cfg.allowAuxiliary) throw new LlmError("auxiliary calls are disabled for the antigravity route (allowAuxiliary: false)", Err.AUX_DISABLED);
30846
30857
  const toolNames = new Set((options.tools ?? []).map((t) => t.name));
30847
30858
  const isCodeMode = toolNames.has("run_code") && !toolNames.has("agy_tool");
@@ -31106,7 +31117,7 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
31106
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;
31107
31118
  }
31108
31119
  }
31109
- if (cfg.forwardSystemPrompt || isReview) {
31120
+ if (cfg.forwardSystemPrompt || isReview || isTitle) {
31110
31121
  const sysInstruction = options.system || (() => {
31111
31122
  const sm = messages.find((m) => m.role === "system");
31112
31123
  return sm ? textOf(sm).trim() : "";
@@ -31256,7 +31267,7 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
31256
31267
  model: activeModelForArgs,
31257
31268
  effort,
31258
31269
  conversationId: !isAux && binding !== void 0 ? binding.conversationId : void 0,
31259
- permissionMode: isAux ? "plan" : cfg.permissionMode,
31270
+ permissionMode: isAux && !isTitle ? "plan" : cfg.permissionMode,
31260
31271
  timeoutMs: cfg.timeoutMs,
31261
31272
  printTimeoutMinutes,
31262
31273
  extraArgs: cfg.extraArgs,
@@ -31268,7 +31279,7 @@ var AgyAdapter = class AgyAdapter extends LlmAdapter {
31268
31279
  model: activeModelForArgs,
31269
31280
  effort,
31270
31281
  conversationId: !isAux && binding !== void 0 ? binding.conversationId : void 0,
31271
- permissionMode: isAux ? "plan" : cfg.permissionMode,
31282
+ permissionMode: isAux && !isTitle ? "plan" : cfg.permissionMode,
31272
31283
  timeoutMs: cfg.timeoutMs,
31273
31284
  printTimeoutMinutes,
31274
31285
  extraArgs: cfg.extraArgs,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agy-link",
3
- "version": "0.4.94",
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",