dsh-agy-link 0.4.88 → 0.4.89

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,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.89 (2026-10-29)
4
+
5
+ ### English
6
+
7
+ - **Fix(sessions): use a unique temp file for the atomic store write (multi-process safety).**
8
+ - `SessionStore.persist()` wrote through a deterministic `".sessions.json.tmp"`. Web + headless host processes share one store, so two concurrent persists could interleave into the same temp file and race the rename — corrupting the store or failing a writer with `ENOENT`. Extracted `src/common/atomic-write.ts` (`writeFileAtomicSync`) which uses a per-write unique temp name (`<file>.<pid>.<seq>.<rand>.tmp`) and cleans it up on failure; sessions now uses it. Adds unit tests for uniqueness, no-residue, and failure cleanup.
9
+
10
+ ### 中文
11
+
12
+ - **修复(sessions):原子写改用每次唯一的临时文件(多进程安全)。**
13
+ - `SessionStore.persist()` 之前用固定的 `".sessions.json.tmp"`。Web 与 headless 宿主进程共享同一个 store,并发写会写进同一个临时文件并竞争 rename——导致文件损坏或某个写入者 `ENOENT`。抽出 `src/common/atomic-write.ts`(`writeFileAtomicSync`),临时名每次唯一(`<file>.<pid>.<seq>.<rand>.tmp`),失败时清理;sessions 改用它。补充单测:唯一性、无残留、失败清理。
14
+
15
+ **Full Changelog**: https://github.com/amlyczz/dsh-agy-link/compare/v0.4.88...v0.4.89
16
+
3
17
  ## 0.4.88 (2026-10-29)
4
18
 
5
19
  ### English
package/dist/index.js CHANGED
@@ -29454,6 +29454,27 @@ function readAgyRunLogText(homeDir, before) {
29454
29454
  return parts.join("\n");
29455
29455
  }
29456
29456
  //#endregion
29457
+ //#region src/common/atomic-write.ts
29458
+ let seq = 0;
29459
+ /** Unique temp path beside `file` (same directory, so rename stays atomic). */
29460
+ function atomicTmpPath(file) {
29461
+ const rand = Math.random().toString(36).slice(2, 8);
29462
+ return file + "." + process.pid + "." + (seq++).toString(36) + "." + rand + ".tmp";
29463
+ }
29464
+ /** Write `data` to `file` atomically; on any failure remove the temp file. */
29465
+ function writeFileAtomicSync(file, data) {
29466
+ const tmp = atomicTmpPath(file);
29467
+ try {
29468
+ writeFileSync(tmp, data, "utf8");
29469
+ renameSync(tmp, file);
29470
+ } catch (err) {
29471
+ try {
29472
+ if (existsSync(tmp)) unlinkSync(tmp);
29473
+ } catch {}
29474
+ throw err;
29475
+ }
29476
+ }
29477
+ //#endregion
29457
29478
  //#region src/host/sessions.ts
29458
29479
  var SessionStore = class {
29459
29480
  file;
@@ -29540,19 +29561,13 @@ var SessionStore = class {
29540
29561
  const b = this.data[key];
29541
29562
  if (b !== void 0) merged[key] = b;
29542
29563
  }
29543
- const tmp = join(dirname(this.file), "." + require$$basename(this.file) + ".tmp");
29544
- writeFileSync(tmp, JSON.stringify(merged, null, 2), "utf8");
29545
- renameSync(tmp, this.file);
29564
+ writeFileAtomicSync(this.file, JSON.stringify(merged, null, 2));
29546
29565
  this.data = merged;
29547
29566
  this.dirty.clear();
29548
29567
  this.removed.clear();
29549
29568
  } catch {}
29550
29569
  }
29551
29570
  };
29552
- function require$$basename(p) {
29553
- const i = Math.max(p.lastIndexOf("/"), p.lastIndexOf("\\"));
29554
- return i >= 0 ? p.slice(i + 1) : p;
29555
- }
29556
29571
  //#endregion
29557
29572
  //#region src/host/agy-db.ts
29558
29573
  const execFileAsync = promisify(execFile);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agy-link",
3
- "version": "0.4.88",
3
+ "version": "0.4.89",
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",