dsh-agy-link 0.4.87 → 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,33 @@
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
+
17
+ ## 0.4.88 (2026-10-29)
18
+
19
+ ### English
20
+
21
+ - **Security(media): add `X-Content-Type-Options: nosniff` and a CSP sandbox to served media/assets.**
22
+ - The media and asset routes serve local image/SVG files from the DSH origin. They now send `X-Content-Type-Options: nosniff` (no MIME sniffing) and `Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox`, so an operator-supplied SVG cannot execute scripts if opened/navigated directly. Adds header assertions to the media test.
23
+
24
+ ### 中文
25
+
26
+ - **安全(media):媒体/静态资源响应增加 `X-Content-Type-Options: nosniff` 与 CSP sandbox。**
27
+ - 媒体与静态资源路由从 DSH 同源提供本地图片/SVG。现附加 `X-Content-Type-Options: nosniff`(禁止 MIME 嗅探)与 `Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox`,使运维提供的 SVG 即使被直接打开/导航也无法执行脚本。为媒体测试补充响应头断言。
28
+
29
+ **Full Changelog**: https://github.com/amlyczz/dsh-agy-link/compare/v0.4.87...v0.4.88
30
+
3
31
  ## 0.4.87 (2026-10-29)
4
32
 
5
33
  ### 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);
@@ -35126,7 +35141,9 @@ function handleMediaRequest(req, res, opts = {}) {
35126
35141
  "Content-Length": st.size,
35127
35142
  "Cache-Control": "public, max-age=3600",
35128
35143
  "Access-Control-Allow-Origin": "*",
35129
- "Content-Disposition": "inline"
35144
+ "Content-Disposition": "inline",
35145
+ "X-Content-Type-Options": "nosniff",
35146
+ "Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; sandbox"
35130
35147
  });
35131
35148
  const stream = createReadStream(filePath);
35132
35149
  stream.on("error", () => {
@@ -35173,7 +35190,9 @@ function handleAssetRequest(req, res, assetDir) {
35173
35190
  "Content-Type": contentType,
35174
35191
  "Content-Length": st.size,
35175
35192
  "Cache-Control": "public, max-age=86400",
35176
- "Access-Control-Allow-Origin": "*"
35193
+ "Access-Control-Allow-Origin": "*",
35194
+ "X-Content-Type-Options": "nosniff",
35195
+ "Content-Security-Policy": "default-src 'none'; style-src 'unsafe-inline'; sandbox"
35177
35196
  });
35178
35197
  const stream = createReadStream(filePath);
35179
35198
  stream.on("error", () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agy-link",
3
- "version": "0.4.87",
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",