tavern-harness 0.1.32 → 0.2.0

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.
@@ -312,11 +312,11 @@
312
312
  overflow-y: auto;
313
313
  padding: 22px 28px;
314
314
  }
315
- .workshop-page {
316
- /* Safari 尚未稳定支持 scrollbar-gutter;始终保留纵向滚动条槽,
317
- 防止切换内容高度不同的 Tab 时居中的标题和导航横向跳动。 */
315
+ .workshop-page,
316
+ .settings-page {
317
+ /* 始终保留纵向滚动能力:原生滚动条已被隐藏(见 global.css),
318
+ 不会占用宽度,因此内容高度变化时标题也不会横向跳动。 */
318
319
  overflow-y: scroll;
319
- scrollbar-gutter: stable;
320
320
  }
321
321
  .view-col {
322
322
  max-width: 900px;
@@ -344,6 +344,10 @@
344
344
  font-size: var(--font-size-label);
345
345
  margin: 2px 0 0;
346
346
  }
347
+ .side-nav.view-tabs {
348
+ margin: -14px;
349
+ padding: 14px;
350
+ }
347
351
 
348
352
  /* ---------- 卡片多列瀑布流(角色) ---------- */
349
353
  .char-grid {
@@ -637,11 +641,14 @@
637
641
  }
638
642
 
639
643
  /* ---------- 设置分组 ---------- */
640
- .set-grid {
641
- display: grid;
642
- grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
644
+ .settings-tab-panel {
645
+ display: flex;
646
+ flex-direction: column;
643
647
  gap: 16px;
644
648
  }
649
+ .settings-tab-panel[data-active='false'] {
650
+ display: none;
651
+ }
645
652
  .set-section {
646
653
  border: 1px solid var(--border);
647
654
  border-radius: var(--radius);
@@ -650,8 +657,7 @@
650
657
  display: flex;
651
658
  flex-direction: column;
652
659
  gap: 12px;
653
- box-shadow: var(--shadow);
654
- transition: border-color 0.32s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.32s cubic-bezier(0.16, 1, 0.3, 1);
660
+ transition: border-color 0.32s cubic-bezier(0.16, 1, 0.3, 1);
655
661
  }
656
662
  .set-section:hover {
657
663
  border-color: color-mix(in srgb, var(--primary) 24%, transparent);
@@ -674,6 +680,64 @@
674
680
  .settings-gen-reset {
675
681
  flex-shrink: 0;
676
682
  }
683
+ .theme-palette-grid {
684
+ display: grid;
685
+ grid-template-columns: repeat(4, minmax(0, 1fr));
686
+ gap: 10px;
687
+ }
688
+ .theme-palette-option {
689
+ --palette-main: #d9a673;
690
+ --palette-soft: #f3e7d5;
691
+ --palette-deep: #9a5b17;
692
+ appearance: none;
693
+ border: 1px solid var(--border);
694
+ border-radius: var(--radius-sm);
695
+ background: var(--surface-2);
696
+ color: var(--text-secondary);
697
+ padding: 9px;
698
+ display: grid;
699
+ gap: 7px;
700
+ font: inherit;
701
+ font-size: var(--font-size-body-sm);
702
+ cursor: pointer;
703
+ transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
704
+ }
705
+ .theme-palette-option:hover {
706
+ transform: translateY(-1px);
707
+ border-color: color-mix(in srgb, var(--palette-main) 65%, var(--border));
708
+ }
709
+ .theme-palette-option.active {
710
+ color: var(--text-primary);
711
+ border-color: var(--palette-main);
712
+ background: color-mix(in srgb, var(--palette-main) 12%, var(--surface));
713
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--palette-main) 18%, transparent);
714
+ }
715
+ .theme-palette-jade { --palette-main: #55a982; --palette-soft: #eef1ef; --palette-deep: #59635e; }
716
+ .theme-palette-rose { --palette-main: #c97088; --palette-soft: #ebd9de; --palette-deep: #9b405a; }
717
+ .theme-palette-indigo { --palette-main: #7889d5; --palette-soft: #dcdff0; --palette-deep: #4d5fa8; }
718
+ .theme-palette-preview {
719
+ height: 30px;
720
+ border-radius: 7px;
721
+ overflow: hidden;
722
+ display: grid;
723
+ grid-template-columns: 1fr 1fr 1fr;
724
+ border: 1px solid color-mix(in srgb, var(--palette-deep) 20%, transparent);
725
+ }
726
+ .theme-palette-preview i:nth-child(1) { background: var(--palette-soft); }
727
+ .theme-palette-preview i:nth-child(2) { background: var(--palette-main); }
728
+ .theme-palette-preview i:nth-child(3) { background: var(--palette-deep); }
729
+ .theme-mode-row {
730
+ display: grid;
731
+ grid-template-columns: minmax(0, 1fr) minmax(150px, 240px);
732
+ align-items: center;
733
+ gap: 12px;
734
+ color: var(--text-secondary);
735
+ font-size: var(--font-size-body-sm);
736
+ }
737
+ @media (max-width: 620px) {
738
+ .theme-palette-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
739
+ .theme-mode-row { grid-template-columns: 1fr; }
740
+ }
677
741
  .settings-reset-section {
678
742
  flex-direction: row;
679
743
  align-items: center;
@@ -727,12 +791,6 @@
727
791
  opacity: 1;
728
792
  border-color: color-mix(in srgb, var(--primary) 45%, transparent);
729
793
  background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface));
730
- box-shadow:
731
- inset 0 0 0 1px color-mix(in srgb, var(--primary) 14%, transparent),
732
- inset 0 0 12px color-mix(in srgb, var(--glow) 22%, transparent),
733
- 0 0 0 1px color-mix(in srgb, var(--primary) 22%, transparent),
734
- 0 0 8px color-mix(in srgb, var(--glow) 40%, transparent),
735
- 0 0 16px color-mix(in srgb, var(--glow) 18%, transparent);
736
794
  }
737
795
  .ach-card-head {
738
796
  display: flex;
@@ -815,10 +873,11 @@
815
873
  .character-book-icon { font-size: var(--font-size-title-sm); }
816
874
  .tool-type-icon { font-size: var(--font-size-title-md); }
817
875
  .provider-inline-detail {
818
- max-height: 60px;
819
- overflow: auto;
876
+ overflow: hidden;
820
877
  font-size: var(--font-size-body-sm);
821
878
  color: var(--text-muted);
879
+ text-overflow: ellipsis;
880
+ white-space: nowrap;
822
881
  }
823
882
 
824
883
  .stats-reset-card h3 {
@@ -896,10 +955,17 @@
896
955
  gap: 10px;
897
956
  }
898
957
  .provider-card .p-name {
958
+ min-width: 0;
959
+ flex: 0 1 auto;
960
+ overflow: hidden;
961
+ white-space: nowrap;
899
962
  font-weight: var(--font-weight-bold);
900
963
  font-family: var(--font-family-display);
901
964
  font-size: var(--font-size-title-sm);
902
965
  }
966
+ .provider-card .p-name .card-name-scroll-text {
967
+ white-space: nowrap;
968
+ }
903
969
  .provider-card .p-url {
904
970
  font-size: var(--font-size-sm);
905
971
  color: var(--text-muted);
@@ -1478,10 +1544,6 @@
1478
1544
  padding: 16px 12px;
1479
1545
  }
1480
1546
 
1481
- .workshop-page {
1482
- scrollbar-gutter: auto;
1483
- }
1484
-
1485
1547
  .view-col {
1486
1548
  gap: 14px;
1487
1549
  }
@@ -1777,9 +1839,7 @@
1777
1839
  overflow: hidden;
1778
1840
  display: grid;
1779
1841
  place-items: center;
1780
- background:
1781
- radial-gradient(circle at 1px 1px, color-mix(in srgb, var(--border) 55%, transparent) 1px, transparent 0) 0 0 / 22px 22px,
1782
- var(--surface-2);
1842
+ background: var(--surface-2);
1783
1843
  user-select: none;
1784
1844
  touch-action: none;
1785
1845
  }
@@ -7,6 +7,7 @@ export type ParticipantKind = 'PLAYER' | 'NPC';
7
7
  export type TurnOrderMode = 'PRESET' | 'RANDOM';
8
8
  export type Role = 'system' | 'user' | 'assistant' | 'tool';
9
9
  export type ThemeModeId = 'system' | 'light' | 'dark';
10
+ export type ThemePaletteId = 'amber' | 'jade' | 'rose' | 'indigo';
10
11
  export type ReasoningEffort = 'auto' | 'off' | 'low' | 'medium' | 'xhigh';
11
12
  export type ContextCompressionThreshold = 'off' | number;
12
13
  /** 界面语言:null = 跟随浏览器语言 */
@@ -36,6 +37,7 @@ export interface AppSettings {
36
37
  defaultModel: string;
37
38
  defaultProviderId: number | null;
38
39
  themeMode: ThemeModeId;
40
+ themePalette: ThemePaletteId;
39
41
  /** 界面语言;null = 跟随浏览器语言 */
40
42
  language: AppLanguage;
41
43
  temperature: number;
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
+ }