tavern-harness 0.1.32 → 0.1.33

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
@@ -3,6 +3,32 @@
3
3
  > 本文件由 `scripts/changelog.mjs` 从 `changelog/v*.md` 生成,请勿手动编辑。
4
4
  > 版本对比链接见文末;源文件位于仓库 `changelog/` 目录。
5
5
 
6
+ ## [0.1.33] - 2026-11-18
7
+
8
+ ### 中文
9
+
10
+ #### 修复
11
+
12
+ - 修复 0.1.32 的 npm 包遗漏 `voice-server.mjs`、导致本地持久化服务无法启动、对话数据无法加载与保存的问题
13
+ - 持久化与沙箱子进程反复拉起时不再重复注册进程退出监听,消除启动时的 `MaxListenersExceededWarning`
14
+ - 子进程的错误输出会显示在终端,本地服务启动失败时不再静默
15
+
16
+ #### 内部
17
+
18
+ - 新增发布内容校验:`npm pack` / `npm publish` 前会检查 `files` 白名单是否覆盖所有运行时相对导入
19
+
20
+ ### English
21
+
22
+ #### Fixed
23
+
24
+ - Fixed the 0.1.32 npm package missing `voice-server.mjs`, which prevented the local persistence service from starting and blocked loading or saving conversations
25
+ - Stopped re-registering process exit listeners whenever the persistence or sandbox child process is relaunched, removing the startup `MaxListenersExceededWarning`
26
+ - Child-process errors now appear in the terminal instead of failing silently
27
+
28
+ #### Internal
29
+
30
+ - Added a publish-content check that verifies the `files` allowlist covers every runtime relative import before `npm pack` / `npm publish`
31
+
6
32
  ## [0.1.32] - 2026-11-18
7
33
 
8
34
  ### 中文
@@ -956,6 +982,7 @@
956
982
  - Vite + React + Zustand + Dexie stack with browser-side local persistence
957
983
 
958
984
  <!-- 链接定义 -->
985
+ [0.1.33]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.32...v0.1.33
959
986
  [0.1.32]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.31...v0.1.32
960
987
  [0.1.31]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.30...v0.1.31
961
988
  [0.1.30]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.29...v0.1.30
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tavern-harness",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "description": "Tavern Harness — 酒馆模式下的本地 AI Agent 助手(MyAgent-Android 的 Web 复刻)",
5
5
  "private": false,
6
6
  "type": "module",
@@ -15,6 +15,7 @@
15
15
  "vite.config.ts",
16
16
  "sandbox-server.mjs",
17
17
  "persistence-server.mjs",
18
+ "voice-server.mjs",
18
19
  "tsconfig.json",
19
20
  "README.md",
20
21
  "CHANGELOG.md"
@@ -41,6 +42,8 @@
41
42
  "changelog:build": "node scripts/changelog.mjs build",
42
43
  "changelog:check": "node scripts/changelog.mjs check",
43
44
  "changelog:check:release": "node scripts/changelog.mjs check --release",
45
+ "check:package": "node scripts/check-package-files.mjs",
46
+ "prepack": "npm run check:package",
44
47
  "prepublishOnly": "npm run build && npm run changelog:check:release"
45
48
  },
46
49
  "dependencies": {
@@ -1,7 +1,47 @@
1
1
  {
2
- "latest": "0.1.32",
2
+ "latest": "0.1.33",
3
3
  "repo": "https://github.com/Rannichan/Tavern-Harness",
4
4
  "entries": [
5
+ {
6
+ "version": "0.1.33",
7
+ "date": "2026-11-18",
8
+ "breaking": false,
9
+ "compare": "v0.1.32...v0.1.33",
10
+ "groups": {
11
+ "zh-CN": [
12
+ {
13
+ "kind": "fixed",
14
+ "items": [
15
+ "修复 0.1.32 的 npm 包遗漏 `voice-server.mjs`、导致本地持久化服务无法启动、对话数据无法加载与保存的问题",
16
+ "持久化与沙箱子进程反复拉起时不再重复注册进程退出监听,消除启动时的 `MaxListenersExceededWarning`",
17
+ "子进程的错误输出会显示在终端,本地服务启动失败时不再静默"
18
+ ]
19
+ },
20
+ {
21
+ "kind": "internal",
22
+ "items": [
23
+ "新增发布内容校验:`npm pack` / `npm publish` 前会检查 `files` 白名单是否覆盖所有运行时相对导入"
24
+ ]
25
+ }
26
+ ],
27
+ "en": [
28
+ {
29
+ "kind": "fixed",
30
+ "items": [
31
+ "Fixed the 0.1.32 npm package missing `voice-server.mjs`, which prevented the local persistence service from starting and blocked loading or saving conversations",
32
+ "Stopped re-registering process exit listeners whenever the persistence or sandbox child process is relaunched, removing the startup `MaxListenersExceededWarning`",
33
+ "Child-process errors now appear in the terminal instead of failing silently"
34
+ ]
35
+ },
36
+ {
37
+ "kind": "internal",
38
+ "items": [
39
+ "Added a publish-content check that verifies the `files` allowlist covers every runtime relative import before `npm pack` / `npm publish`"
40
+ ]
41
+ }
42
+ ]
43
+ }
44
+ },
5
45
  {
6
46
  "version": "0.1.32",
7
47
  "date": "2026-11-18",
package/vite.config.ts CHANGED
@@ -16,6 +16,40 @@ const projectRoot = dirname(fileURLToPath(import.meta.url));
16
16
  // 运行时版本号只在构建时从 package.json 注入,避免应用读文件或请求 npm registry
17
17
  const pkg = JSON.parse(readFileSync(join(projectRoot, 'package.json'), 'utf8')) as { version: string };
18
18
 
19
+ /**
20
+ * 子进程统一登记:持久化服务、沙箱服务共用同一个进程退出监听。
21
+ * 以前每次 spawn 都 process.once('exit', ...),子进程反复拉起时监听器只增不减,
22
+ * 累计 11 个就会触发 MaxListenersExceededWarning(持久化服务启动失败时尤其明显)。
23
+ */
24
+ interface ChildProcessRegistry {
25
+ children: Set<ChildProcess>;
26
+ exitHookInstalled: boolean;
27
+ }
28
+
29
+ const globalWithChildRegistry = globalThis as typeof globalThis & {
30
+ __tavernChildRegistry?: ChildProcessRegistry;
31
+ };
32
+ const childRegistry = (globalWithChildRegistry.__tavernChildRegistry ??= {
33
+ children: new Set<ChildProcess>(),
34
+ exitHookInstalled: false,
35
+ });
36
+
37
+ function trackChildProcess(child: ChildProcess): void {
38
+ childRegistry.children.add(child);
39
+ child.once('exit', () => childRegistry.children.delete(child));
40
+ if (childRegistry.exitHookInstalled) return;
41
+ childRegistry.exitHookInstalled = true;
42
+ process.once('exit', () => {
43
+ for (const tracked of childRegistry.children) {
44
+ try {
45
+ tracked.kill();
46
+ } catch {
47
+ /* ignore */
48
+ }
49
+ }
50
+ });
51
+ }
52
+
19
53
  /**
20
54
  * 浏览器同源校验:Origin 必须存在且与请求的 Host 一致;`Sec-Fetch-Site` 若存在
21
55
  * 必须是 same-origin(部分手机浏览器访问局域网地址时不发 fetch metadata,
@@ -188,9 +222,15 @@ function persistenceProxyPlugin(): Plugin {
188
222
  childPort = port;
189
223
  const child = spawn(process.execPath, [persistenceScript, String(port)], {
190
224
  cwd: projectRoot,
191
- stdio: 'ignore',
225
+ // stdout 交给服务自己保持安静;stderr 透传,启动失败时能在终端直接看到原因
226
+ stdio: ['ignore', 'ignore', 'inherit'],
192
227
  windowsHide: true,
193
- env: { ...process.env, PERSISTENCE_SERVICE_TOKEN: serviceToken },
228
+ env: {
229
+ ...process.env,
230
+ PERSISTENCE_SERVICE_TOKEN: serviceToken,
231
+ // node:sqlite 在 Node 22 会打印 ExperimentalWarning;这是预期用法,不需要打扰用户
232
+ NODE_NO_WARNINGS: '1',
233
+ },
194
234
  });
195
235
  persistenceChild = child;
196
236
  child.on('exit', () => {
@@ -199,7 +239,7 @@ function persistenceProxyPlugin(): Plugin {
199
239
  childPort = null;
200
240
  }
201
241
  });
202
- process.once('exit', () => child.kill());
242
+ trackChildProcess(child);
203
243
  for (let attempt = 0; attempt < 30; attempt++) {
204
244
  await new Promise((resolve) => setTimeout(resolve, 100));
205
245
  if (await serviceReady(port)) return port;
@@ -433,7 +473,8 @@ function sandboxProxyPlugin(): Plugin {
433
473
  childPort = availablePort;
434
474
  const child = spawn(process.execPath, [SANDBOX_SCRIPT, String(availablePort)], {
435
475
  cwd: projectRoot,
436
- stdio: 'ignore',
476
+ // stdout 保持安静;stderr 透传,方便定位沙箱服务启动失败
477
+ stdio: ['ignore', 'ignore', 'inherit'],
437
478
  windowsHide: true,
438
479
  env: {
439
480
  ...process.env,
@@ -448,13 +489,7 @@ function sandboxProxyPlugin(): Plugin {
448
489
  childPort = null;
449
490
  });
450
491
  child.unref();
451
- process.once('exit', () => {
452
- try {
453
- child.kill();
454
- } catch {
455
- /* ignore */
456
- }
457
- });
492
+ trackChildProcess(child);
458
493
  }
459
494
  if (!sandboxChild) return null;
460
495
  // 3) 等待就绪(最多 3s)
@@ -0,0 +1,21 @@
1
+ export function normalizeBailianAudioUrl(value) {
2
+ if (typeof value !== 'string' || !value.trim()) return null;
3
+
4
+ let url;
5
+ try {
6
+ url = new URL(value.trim());
7
+ } catch {
8
+ return null;
9
+ }
10
+
11
+ if (url.username || url.password) return null;
12
+ if (
13
+ url.protocol === 'http:'
14
+ && !url.port
15
+ && /^(?:[a-z0-9][a-z0-9-]*\.)?oss-[a-z0-9-]+\.aliyuncs\.com$/i.test(url.hostname)
16
+ ) {
17
+ url.protocol = 'https:';
18
+ }
19
+
20
+ return url.protocol === 'https:' ? url.href : null;
21
+ }