tavern-harness 0.1.11 → 0.1.13

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.
Files changed (48) hide show
  1. package/CHANGELOG.md +345 -0
  2. package/README.md +18 -6
  3. package/README.zh.md +16 -4
  4. package/bin/cli.js +16 -2
  5. package/index.html +3 -1
  6. package/package.json +18 -5
  7. package/persistence-server.mjs +303 -0
  8. package/public/sillytavern-logo.png +0 -0
  9. package/src/App.tsx +72 -8
  10. package/src/components/CharactersView.tsx +221 -68
  11. package/src/components/ChatView.tsx +98 -69
  12. package/src/components/FileDisplayModal.tsx +28 -17
  13. package/src/components/NewSessionMenu.tsx +2 -9
  14. package/src/components/PopoverMenu.tsx +54 -0
  15. package/src/components/SettingsView.tsx +21 -1
  16. package/src/components/Sidebar.tsx +133 -53
  17. package/src/components/VersionHistoryModal.tsx +114 -0
  18. package/src/components/shared.tsx +12 -3
  19. package/src/core/browserPreferences.ts +45 -0
  20. package/src/core/changelog.ts +43 -0
  21. package/src/core/characterBook.ts +32 -0
  22. package/src/core/clipboard.ts +32 -0
  23. package/src/core/editable.ts +26 -0
  24. package/src/core/gameplay.ts +2 -0
  25. package/src/core/i18n.ts +141 -10
  26. package/src/core/longPress.ts +209 -0
  27. package/src/core/longPressGesture.ts +110 -0
  28. package/src/core/mobileViewport.ts +362 -0
  29. package/src/core/openai.ts +39 -7
  30. package/src/core/proxy.ts +8 -7
  31. package/src/core/sillyTavernWorldInfo.ts +159 -0
  32. package/src/core/sortableSensors.ts +21 -0
  33. package/src/core/stickyBottom.ts +45 -0
  34. package/src/core/tools/generatedSkillExecutor.ts +4 -20
  35. package/src/core/version.ts +46 -0
  36. package/src/core/viewport.ts +81 -0
  37. package/src/core/wechatTouch.ts +145 -0
  38. package/src/db/database.ts +313 -2
  39. package/src/generated/changelog.json +510 -0
  40. package/src/main.tsx +18 -2
  41. package/src/store/store.ts +99 -33
  42. package/src/theme/chat.css +174 -49
  43. package/src/theme/global.css +391 -10
  44. package/src/theme/theme.ts +9 -2
  45. package/src/theme/views.css +341 -8
  46. package/src/types/models.ts +9 -0
  47. package/src/vite-env.d.ts +4 -1
  48. package/vite.config.ts +195 -23
package/CHANGELOG.md ADDED
@@ -0,0 +1,345 @@
1
+ # Changelog
2
+
3
+ > 本文件由 `scripts/changelog.mjs` 从 `changelog/v*.md` 生成,请勿手动编辑。
4
+ > 版本对比链接见文末;源文件位于仓库 `changelog/` 目录。
5
+
6
+ ## [0.1.13] - 2026-10-21
7
+
8
+ ### 中文
9
+
10
+ #### 新增
11
+
12
+ - 设置 → 关于新增「版本记录」:内置 v0.1.1 以来的完整更新历史,有新版本时侧栏与设置入口会显示未读圆点;运行 `tavern-harness --version` 可直接查看当前版本号
13
+ - 世界书新增「角色卡知识库」:可为角色卡维护独立知识条目并合并进每回合召回,同时支持导入 SillyTavern 世界书 JSON
14
+ - 支持 DeepSeek 思考模式:可设置 `reasoning_effort`,并在多轮对话中回放 `reasoning_content`
15
+ - 局域网访问:服务默认监听局域网,新增 `--host` 绑定与侧栏二维码,手机扫码即可继续对话
16
+ - 移动端交互增强:长按菜单、触摸拖拽排序、键盘弹出时保持布局稳定,初始化失败可重试
17
+
18
+ #### 改进
19
+
20
+ - 酒馆数据改为保存在主机本地(默认 `~/.tavern-harness`),访问同一实例的浏览器共享数据;首次启动会自动迁移浏览器中的旧数据,界面语言与主题仍按浏览器分别保存
21
+ - 用户气泡、思考面板与工具卡改用不同底色和左侧色条区分,消息操作栏与内联编辑器更紧凑
22
+
23
+ #### 修复
24
+
25
+ - 角色工坊调整技能顺序后会先保存顺序再刷新列表
26
+ - 修复移动端长弹窗内容超出屏幕后无法滚动
27
+
28
+ #### 内部
29
+
30
+ - 新增宿主端持久化服务与共享数据层,拆分持久化请求体限制并复用同源校验
31
+ - 版本记录改由 `changelog/v*.md` 生成 JSON 与 `CHANGELOG.md`,并加入文件、tag、版本号一致性测试
32
+
33
+ ### English
34
+
35
+ #### Added
36
+
37
+ - Version history in Settings → About, covering every release since v0.1.1; an unseen dot marks new notes in the sidebar and settings, and `tavern-harness --version` prints the current version
38
+ - Character Book knowledge tab in the world book editor: keep per-character knowledge entries, merge them into each turn's recall, and import SillyTavern world info JSON
39
+ - DeepSeek thinking support: set `reasoning_effort` and replay `reasoning_content` across turns
40
+ - LAN access: the server listens on the LAN by default, with `--host` binding and a sidebar QR code for continuing on a phone
41
+ - Mobile interaction upgrades: long-press menus, touch drag sorting, a stable layout while the keyboard opens, and retryable initialization failures
42
+
43
+ #### Changed
44
+
45
+ - Tavern data is now stored on the host (default `~/.tavern-harness`) and shared by browsers using the same instance; existing browser data is migrated automatically on first launch, while language and theme remain per browser
46
+ - User bubbles, thinking panels and tool cards now use distinct surfaces and left rails; message actions and the inline editor are more compact
47
+
48
+ #### Fixed
49
+
50
+ - Skill order is saved before the character workshop refreshes its list
51
+ - Long modals can scroll again on mobile
52
+
53
+ #### Internal
54
+
55
+ - Added the host persistence service and shared data layer, split persistence body limits, and reused same-origin validation
56
+ - Release notes are generated from `changelog/v*.md` into JSON and `CHANGELOG.md`, with tests for file/tag/version consistency
57
+
58
+ ## [0.1.12] - 2026-10-16
59
+
60
+ ### 中文
61
+
62
+ #### 修复
63
+
64
+ - 为外部 HTTPS 模型服务补充代理转发,修复浏览器 CORS 导致的连接失败
65
+
66
+ #### 内部
67
+
68
+ - README 增加中英文切换链接
69
+
70
+ ### English
71
+
72
+ #### Fixed
73
+
74
+ - Added proxy forwarding for external HTTPS model providers, fixing connection failures caused by browser CORS
75
+
76
+ #### Internal
77
+
78
+ - Added language links between the English and Chinese READMEs
79
+
80
+ ## [0.1.11] - 2026-10-15
81
+
82
+ ### 中文
83
+
84
+ #### 新增
85
+
86
+ - 角色书(Character Book):支持编辑、导入与按关键词召回
87
+ - 导入深度提示词并作为附加指令生效
88
+ - 人物设定占位符在对话中正确替换为用户人设
89
+ - 编辑器支持 Markdown 预览,聊天消息支持强调样式
90
+ - 仪表盘新增 GitHub 入口
91
+
92
+ #### 改进
93
+
94
+ - 工作坊编辑器改用 Portal 渲染,避免弹窗被父容器裁剪
95
+ - 改进原始响应日志查看器
96
+ - 保留导入角色的完整开场白,并归一化角色卡提示词
97
+
98
+ #### 修复
99
+
100
+ - 修复仪表盘操作按钮边框不一致
101
+
102
+ ### English
103
+
104
+ #### Added
105
+
106
+ - Character Book: edit, import, and keyword-based recall
107
+ - Import depth prompts and apply them as additional instructions
108
+ - Persona placeholders are now replaced with the user's persona in conversations
109
+ - Markdown previews in editors, plus emphasis rendering in chat messages
110
+ - GitHub link on the dashboard
111
+
112
+ #### Changed
113
+
114
+ - Workshop editors now render in a portal so modals are no longer clipped by their parent
115
+ - Improved the raw response log viewer
116
+ - Preserved full imported greetings and normalized imported character-card prompts
117
+
118
+ #### Fixed
119
+
120
+ - Fixed inconsistent borders on dashboard action buttons
121
+
122
+ ## [0.1.10] - 2026-10-12
123
+
124
+ ### 中文
125
+
126
+ #### 新增
127
+
128
+ - YOLO 模式:可在设置中选择自动批准工具修改与 Shell 执行,减少逐次确认
129
+ - 沙箱工作区持久化到包目录之外,升级或重装 npm 包不再丢失技能文件
130
+
131
+ #### 修复
132
+
133
+ - 校验并保留流式返回的工具调用参数,修复参数被截断或解析失败
134
+ - 修复设置卡片、文档标题与仪表盘按钮的样式问题
135
+
136
+ #### 内部
137
+
138
+ - 新增贡献指南(CONTRIBUTING),补充测试与提交流程
139
+
140
+ ### English
141
+
142
+ #### Added
143
+
144
+ - YOLO mode: optionally auto-approve tool edits and shell execution from Settings
145
+ - Sandbox workspace now persists outside the package directory, so skill files survive upgrades and reinstalls
146
+
147
+ #### Fixed
148
+
149
+ - Validate and preserve streamed tool-call arguments, fixing truncated or unparsable arguments
150
+ - Fixed styling issues in settings cards, documentation headings, and dashboard buttons
151
+
152
+ #### Internal
153
+
154
+ - Added CONTRIBUTING with testing and pull-request guidelines
155
+
156
+ ## [0.1.9] - 2026-10-09
157
+
158
+ ### 中文
159
+
160
+ #### 改进
161
+
162
+ - 统一应用各处背景,减少页面切换时的色差
163
+ - 更新浏览器标签页标题,显示当前所在页面
164
+
165
+ ### English
166
+
167
+ #### Changed
168
+
169
+ - Unified application backgrounds to remove color jumps between views
170
+ - Updated browser tab titles to reflect the current page
171
+
172
+ ## [0.1.8] - 2026-10-09
173
+
174
+ ### 中文
175
+
176
+ #### 修复
177
+
178
+ - 修复编辑器预览与提示词区域的尺寸异常
179
+ - 本地化「新话题」标记,切换语言后不再显示原始键值
180
+
181
+ #### 新增
182
+
183
+ - 补充 MIT 许可证
184
+
185
+ #### 内部
186
+
187
+ - 更新文档与演示视频链接,README 增加玩法展示入口
188
+
189
+ ### English
190
+
191
+ #### Fixed
192
+
193
+ - Fixed incorrect sizing in the editor preview and prompt area
194
+ - Localized the "new topic" marker so it no longer shows a raw key after switching languages
195
+
196
+ #### Added
197
+
198
+ - Added the MIT license
199
+
200
+ #### Internal
201
+
202
+ - Refreshed documentation and demo links, and added gameplay showcases to the README
203
+
204
+ ## [0.1.7] - 2026-10-07
205
+
206
+ ### 中文
207
+
208
+ #### 修复
209
+
210
+ - 修复导入游戏后参与者座位顺序错乱的问题
211
+
212
+ ### English
213
+
214
+ #### Fixed
215
+
216
+ - Fixed participant seat order being scrambled after importing a game
217
+
218
+ ## [0.1.6] - 2026-10-07
219
+
220
+ ### 中文
221
+
222
+ #### 改进
223
+
224
+ - 对齐「仅提及」群聊模式下的系统提示词,减少角色误发言
225
+
226
+ #### 内部
227
+
228
+ - 文档更新:首页导航、Wiki 启动指南、README 安装说明,并补充开放生态介绍
229
+
230
+ ### English
231
+
232
+ #### Changed
233
+
234
+ - Aligned system prompts in mention-only group chats to reduce characters speaking out of turn
235
+
236
+ #### Internal
237
+
238
+ - Documentation refresh: homepage navigation, Wiki quick start, README setup, and an open-ecosystem section
239
+
240
+ ## [0.1.5] - 2026-10-07
241
+
242
+ ### 中文
243
+
244
+ #### 修复
245
+
246
+ - 修复沙箱服务在 npm 安装场景下无法从包根目录解析的问题
247
+
248
+ ### English
249
+
250
+ #### Fixed
251
+
252
+ - Fixed the sandbox server failing to resolve from the package root when installed from npm
253
+
254
+ ## [0.1.4] - 2026-10-07
255
+
256
+ ### 中文
257
+
258
+ #### 修复
259
+
260
+ - 补齐 React 子路径依赖的预打包,修复 `npx` 启动时解析失败
261
+
262
+ ### English
263
+
264
+ #### Fixed
265
+
266
+ - Prebundled React subpath dependencies to fix resolution failures when starting via `npx`
267
+
268
+ ## [0.1.3] - 2026-10-07
269
+
270
+ ### 中文
271
+
272
+ #### 修复
273
+
274
+ - 修复 React DOM 具名导入在预打包后不可用导致的页面白屏
275
+
276
+ ### English
277
+
278
+ #### Fixed
279
+
280
+ - Fixed a blank page caused by named React DOM imports breaking after prebundling
281
+
282
+ ## [0.1.2] - 2026-10-07
283
+
284
+ ### 中文
285
+
286
+ #### 修复
287
+
288
+ - 修复通过 npm 全局安装或 `npx` 启动时,运行时依赖未预打包导致的启动失败
289
+
290
+ ### English
291
+
292
+ #### Fixed
293
+
294
+ - Fixed startup failures after installing from npm or running via `npx` caused by unbundled runtime dependencies
295
+
296
+ ## [0.1.1] - 2026-10-07
297
+
298
+ ### 中文
299
+
300
+ #### 新增
301
+
302
+ - 首个公开版本:`npx tavern-harness` 一键启动,自动打开浏览器并支持局域网访问
303
+ - 流式对话与工具调用,支持实时思考过程预览
304
+ - 角色工坊:角色卡、世界书(Lorebook)、SillyTavern v2/v3 角色卡与 PNG 导入
305
+ - 多人群聊与回合队列,支持角色互相 @ 与发言顺序编排
306
+ - 内置技能与沙箱执行:文件读写、Shell 白名单命令、代码执行
307
+ - 成就系统、统计面板、主题切换与简体中文 / 繁體中文 / English 三语界面
308
+ - 游戏完整导出与导入、定时消息
309
+ - 本地优先:所有数据保存在本机,不经过第三方服务
310
+
311
+ #### 内部
312
+
313
+ - Vite + React + Zustand + Dexie 技术栈,浏览器端本地持久化
314
+
315
+ ### English
316
+
317
+ #### Added
318
+
319
+ - First public release: one-command startup with `npx tavern-harness`, auto-opens the browser, and serves the LAN
320
+ - Streaming chat with tool calls and live thinking preview
321
+ - Character workshop: character cards, lorebooks, SillyTavern v2/v3 cards, and PNG import
322
+ - Group chats with a turn queue, character @-mentions, and reorderable speaking order
323
+ - Built-in skills and sandboxed execution: file reads/writes, allowlisted shell commands, code execution
324
+ - Achievements, stats, themes, and Simplified Chinese / Traditional Chinese / English UI
325
+ - Full gameplay export and import, plus scheduled messages
326
+ - Local-first: all data stays on your machine and never passes through a third-party service
327
+
328
+ #### Internal
329
+
330
+ - Vite + React + Zustand + Dexie stack with browser-side local persistence
331
+
332
+ <!-- 链接定义 -->
333
+ [0.1.13]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.12...v0.1.13
334
+ [0.1.12]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.11...v0.1.12
335
+ [0.1.11]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.10...v0.1.11
336
+ [0.1.10]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.9...v0.1.10
337
+ [0.1.9]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.8...v0.1.9
338
+ [0.1.8]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.7...v0.1.8
339
+ [0.1.7]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.6...v0.1.7
340
+ [0.1.6]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.5...v0.1.6
341
+ [0.1.5]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.4...v0.1.5
342
+ [0.1.4]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.3...v0.1.4
343
+ [0.1.3]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.2...v0.1.3
344
+ [0.1.2]: https://github.com/Rannichan/Tavern-Harness/compare/v0.1.1...v0.1.2
345
+ [0.1.1]: https://github.com/Rannichan/Tavern-Harness/releases/tag/v0.1.1
package/README.md CHANGED
@@ -10,6 +10,10 @@
10
10
  <a href="https://www.npmjs.com/package/tavern-harness"><img alt="npm" src="https://img.shields.io/npm/v/tavern-harness?style=flat-square" /></a>
11
11
  </p>
12
12
 
13
+ <p align="center">
14
+ <strong>English</strong> | <a href="README.zh.md">简体中文</a>
15
+ </p>
16
+
13
17
  # Tavern Harness · An AI-Native Role-Playing Sandbox
14
18
 
15
19
  <a id="demo"></a>
@@ -28,11 +32,12 @@ No repository clone or global installation is required:
28
32
  npx tavern-harness
29
33
  ```
30
34
 
31
- The first run downloads the package, starts the local service, and opens your browser automatically. Optional arguments:
35
+ The first run downloads the package, starts a service accessible on your LAN, and opens your browser automatically. Optional arguments:
32
36
 
33
37
  ```bash
34
38
  npx tavern-harness --no-open
35
39
  npx tavern-harness --port 5273
40
+ npx tavern-harness --host 127.0.0.1 # Restrict access to this computer
36
41
  npx tavern-harness --workspace /absolute/path/to/workspace
37
42
  ```
38
43
 
@@ -74,16 +79,15 @@ After starting the app, open **Settings → Model Service Provider**:
74
79
  2. **Test the connection**: the app fetches the model list automatically. If the target service does not expose CORS headers, requests are forwarded through the built-in same-origin proxy for private-network or LAN addresses. On success, the Base URL is rewritten to its proxy form and saved.
75
80
  3. **Select a model**: click the model name at the top of the chat page, then return to the conversation and start chatting.
76
81
 
77
- ### Import a Game and Start Playing
82
+ ### Import a Gameplay and Start Playing
78
83
 
79
- Download the game file below. Click **Import** in the upper-left corner, then import the file you downloaded to create a complete game environment—including characters, lorebooks, skills, and more—and start playing right away:
84
+ Download the gameplay file below. Click **Import** in the upper-left corner, then import the file you downloaded to create a complete game environment—including characters, lorebooks, skills, and more—and start playing right away:
80
85
 
81
86
  [th-demo-affinity-gameplay-en.json](./docs/assets/gameplay/th-demo-affinity-gameplay-en.json)
82
87
 
83
- ### Data Privacy
88
+ ### Data Storage
84
89
 
85
- - **All data is stored in browser IndexedDB**: conversations, character cards, lorebooks, skills, statistics, and API keys are not uploaded to any server.
86
- - Data is tied to the browser, port, and site origin. Switching browsers, opening a private window, or using a different port will not show existing data. This is expected browser security behavior; use the same browser and port each time.
90
+ Tavern data is stored locally on the host and shared by browsers that open the same Tavern Harness instance. Language and theme remain browser-specific.
87
91
 
88
92
  <a id="features"></a>
89
93
  ## 3 · Features
@@ -130,6 +134,14 @@ Tavern Harness has no external harness dependency, and its UI is designed for a
130
134
 
131
135
  > The tavern is open 24 hours a day, and the Keeper is always here to help.
132
136
 
137
+ ## 5 · Changelog
138
+
139
+ Every npm release is recorded in [`changelog/`](changelog/): one file per version, matched one-to-one with a git tag.
140
+
141
+ - Read the full history: [CHANGELOG.md](https://github.com/Rannichan/Tavern-Harness/blob/main/CHANGELOG.md)
142
+ - In the app: **Settings → About → View version history**
143
+ - Maintainers: follow the release steps in [CONTRIBUTING](CONTRIBUTING.md#releases-and-changelog).
144
+
133
145
  ## License
134
146
 
135
147
  This project is licensed under the [MIT License](LICENSE).
package/README.zh.md CHANGED
@@ -10,6 +10,10 @@
10
10
  <a href="https://www.npmjs.com/package/tavern-harness"><img alt="npm" src="https://img.shields.io/npm/v/tavern-harness?style=flat-square" /></a>
11
11
  </p>
12
12
 
13
+ <p align="center">
14
+ <a href="README.md">English</a> | <strong>简体中文</strong>
15
+ </p>
16
+
13
17
  # Tavern Harness · AI 原生的角色扮演沙盒
14
18
 
15
19
  <a id="demo"></a>
@@ -28,11 +32,12 @@
28
32
  npx tavern-harness
29
33
  ```
30
34
 
31
- 首次运行会下载包、启动本地服务,并自动打开浏览器。可选参数:
35
+ 首次运行会下载包、启动可从局域网访问的服务,并自动打开浏览器。可选参数:
32
36
 
33
37
  ```bash
34
38
  npx tavern-harness --no-open
35
39
  npx tavern-harness --port 5273
40
+ npx tavern-harness --host 127.0.0.1 # 仅允许本机访问
36
41
  npx tavern-harness --workspace /absolute/path/to/workspace
37
42
  ```
38
43
 
@@ -81,10 +86,9 @@ npm run dev # 开发服务器默认端口 5173,被占用时自动顺延
81
86
 
82
87
  [小咕嘎-gameplay.json](./docs/assets/gameplay/小咕嘎-gameplay.json)
83
88
 
84
- ### 数据隐私须知
89
+ ### 数据存储
85
90
 
86
- - **全部数据存在浏览器 IndexedDB 里**:会话、角色卡、世界书、技能、统计、API Key,均**不上传任何服务器**。
87
- - 数据与浏览器、端口、站点绑定:换浏览器 / 开隐身窗 / 换端口看不到旧数据——这是浏览器安全机制,属正常现象。请确保每次在同一个端口启动、并在同一个浏览器打开。
91
+ 酒馆数据保存在主机本地;访问同一 Tavern Harness 实例的浏览器可共享这些数据。界面语言和主题仍随各自浏览器保存。
88
92
 
89
93
  <a id="features"></a>
90
94
  ## 3 · 产品特色
@@ -131,6 +135,14 @@ Tavern Harness 针对提高缓存命中率进行了优化,显著降低了 Toke
131
135
 
132
136
  > 酒馆24小时营业,老板随时为您服务!
133
137
 
138
+ ## 5 · 版本记录
139
+
140
+ 每一次 npm 发布都会记录在 [`changelog/`](changelog/) 目录中:一个版本一个文件,并与 git tag 一一对应。
141
+
142
+ - 查看完整记录:[CHANGELOG.md](https://github.com/Rannichan/Tavern-Harness/blob/main/CHANGELOG.md)
143
+ - 应用内查看:**设置 → 关于 → 查看版本记录**
144
+ - 维护者:发布步骤见 [CONTRIBUTING](CONTRIBUTING.md#releases-and-changelog)。
145
+
134
146
  ## 开源协议
135
147
 
136
148
  本项目采用 [MIT License](LICENSE) 开源协议。
package/bin/cli.js CHANGED
@@ -1,23 +1,34 @@
1
1
  #!/usr/bin/env node
2
2
  // bin/cli.js — npx tavern-harness 一键启动,默认自动打开浏览器
3
3
  // 用法:
4
- // tavern-harness 启动并按实际端口自动打开浏览器(默认)
4
+ // tavern-harness 启动并按实际端口自动打开浏览器,默认允许局域网访问
5
5
  // tavern-harness --no-open 只启动,不打开浏览器
6
6
  // tavern-harness --port 5273 指定端口(5173 被占用时 vite 会自动顺延,
7
7
  // 会打开顺延后的实际端口)
8
+ // tavern-harness --host 127.0.0.1 仅监听本机
8
9
  // tavern-harness --workspace /path 指定生成技能文件工作区
10
+ // tavern-harness --version 输出当前 npm 包版本
11
+ //
12
+ // Requires Node.js 22.5+ because server-side data is stored with node:sqlite.
9
13
  import { fileURLToPath } from 'node:url';
10
14
  import { dirname, join } from 'node:path';
15
+ import { readFileSync } from 'node:fs';
11
16
  import { createServer } from 'vite';
12
17
 
13
18
  const __dirname = dirname(fileURLToPath(import.meta.url));
14
19
  const root = join(__dirname, '..'); // 包根目录
15
20
  const configFile = join(root, 'vite.config.ts'); // 复用现有配置(cors 代理 / sandbox 懒启动都在里面)
21
+ const pkg = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8'));
16
22
 
17
23
  // ---- 解析命令行参数 ----
18
24
  const args = process.argv.slice(2);
25
+ if (args.includes('--version') || args.includes('-v')) {
26
+ console.log(pkg.version);
27
+ process.exit(0);
28
+ }
19
29
  let open = true; // 默认自动打开浏览器
20
30
  let port;
31
+ let host = '0.0.0.0';
21
32
  let workspace;
22
33
  for (let i = 0; i < args.length; i++) {
23
34
  const a = args[i];
@@ -25,11 +36,14 @@ for (let i = 0; i < args.length; i++) {
25
36
  else if (a === '--open') open = true;
26
37
  else if (a === '--port') port = Number(args[++i]);
27
38
  else if (a.startsWith('--port=')) port = Number(a.slice('--port='.length));
39
+ else if (a === '--host') host = args[++i];
40
+ else if (a.startsWith('--host=')) host = a.slice('--host='.length);
28
41
  else if (a === '--workspace') workspace = args[++i];
29
42
  else if (a.startsWith('--workspace=')) workspace = a.slice('--workspace='.length);
30
43
  }
31
44
  const serverOptions = { open };
32
45
  if (Number.isInteger(port) && port > 0 && port < 65536) serverOptions.port = port;
46
+ if (host) serverOptions.host = host;
33
47
  if (workspace) process.env.TAVERN_HARNESS_WORKSPACE = workspace;
34
48
 
35
49
  try {
@@ -41,7 +55,7 @@ try {
41
55
  });
42
56
  await server.listen();
43
57
  server.printUrls();
44
- console.log('\nTavern Harness 已启动,浏览器应已自动打开(未打开可手动访问上面 Local 地址)。按 Ctrl+C 停止。');
58
+ console.log(`\nTavern Harness v${pkg.version} 已启动,浏览器应已自动打开(未打开可手动访问上面 Local 地址)。按 Ctrl+C 停止。`);
45
59
 
46
60
  process.on('SIGINT', async () => {
47
61
  await server.close();
package/index.html CHANGED
@@ -3,7 +3,9 @@
3
3
  <head>
4
4
  <meta charset="UTF-8" />
5
5
  <link rel="icon" type="image/png" href="/favicon.png" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <!-- Edge Android 只有在显式声明 interactive-widget=resizes-content 时才随软键盘
7
+ 收缩布局视口;否则 position: fixed 的 app-shell 不收缩,输入框会被键盘盖住。 -->
8
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, interactive-widget=resizes-content" />
7
9
  <meta name="theme-color" content="#17120A" />
8
10
  <script>
9
11
  (() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tavern-harness",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Tavern Harness — 酒馆模式下的本地 AI Agent 助手(MyAgent-Android 的 Web 复刻)",
5
5
  "private": false,
6
6
  "type": "module",
@@ -14,22 +14,34 @@
14
14
  "index.html",
15
15
  "vite.config.ts",
16
16
  "sandbox-server.mjs",
17
+ "persistence-server.mjs",
17
18
  "tsconfig.json",
18
- "README.md"
19
+ "README.md",
20
+ "CHANGELOG.md"
19
21
  ],
20
22
  "engines": {
21
- "node": ">=18.0.0"
23
+ "node": ">=22.6.0"
22
24
  },
23
25
  "scripts": {
24
26
  "start": "vite",
25
27
  "dev": "vite",
26
- "test": "node --test *.test.mjs",
28
+ "test": "node --experimental-strip-types --test *.test.mjs",
27
29
  "test:character-book": "node --test character-book.test.mjs",
30
+ "test:silly-tavern-world-info": "node --test silly-tavern-world-info.test.mjs",
31
+ "test:openai-request": "node --test openai-request.test.mjs",
28
32
  "test:command-service": "node sandbox-server.test.mjs",
33
+ "test:persistence-service": "node persistence-server.test.mjs",
29
34
  "test:yolo-mode": "node yolo-mode.test.mjs",
30
35
  "test:tool-arguments": "node tool-arguments.test.mjs",
36
+ "test:long-press": "node --experimental-strip-types --test long-press.test.mjs",
31
37
  "build": "tsc --noEmit && vite build",
32
- "preview": "vite preview"
38
+ "preview": "vite preview",
39
+ "test:preview-persistence": "node preview-persistence.test.mjs",
40
+ "changelog:new": "node scripts/changelog.mjs new",
41
+ "changelog:build": "node scripts/changelog.mjs build",
42
+ "changelog:check": "node scripts/changelog.mjs check",
43
+ "changelog:check:release": "node scripts/changelog.mjs check --release",
44
+ "prepublishOnly": "npm run build && npm run changelog:check:release"
33
45
  },
34
46
  "dependencies": {
35
47
  "@codemirror/lang-json": "^6.0.2",
@@ -45,6 +57,7 @@
45
57
  "marked": "^12.0.2",
46
58
  "react": "^18.3.1",
47
59
  "react-dom": "^18.3.1",
60
+ "qrcode.react": "^4.2.0",
48
61
  "vite": "^5.4.21",
49
62
  "zustand": "^4.5.5"
50
63
  },