pi-web-ui 0.106.0 → 0.108.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.
Files changed (59) hide show
  1. package/CHANGELOG.md +77 -11
  2. package/README.zh-TW.md +2 -2
  3. package/dist/server/agent-formatters.js +19 -4
  4. package/dist/server/agent-service.js +33 -16
  5. package/dist/server/bg-servers.js +205 -53
  6. package/dist/server/client-state.js +6 -2
  7. package/dist/server/dispatch-domain-handlers.js +2 -0
  8. package/dist/server/dsh/dsh-agent-service.js +24 -10
  9. package/dist/server/durable/durable-agent-service.js +153 -0
  10. package/dist/server/durable/durable-capabilities.js +11 -0
  11. package/dist/server/durable/durable-driver.js +481 -0
  12. package/dist/server/durable/durable-loader.js +38 -0
  13. package/dist/server/durable/durable-models.js +283 -0
  14. package/dist/server/durable/durable-storage.js +42 -0
  15. package/dist/server/durable/durable-tools.js +45 -0
  16. package/dist/server/durable/index.js +8 -0
  17. package/dist/server/engine-capabilities.js +20 -1
  18. package/dist/server/engine-probe.js +156 -8
  19. package/dist/server/files-service.js +15 -1
  20. package/dist/server/global-loader.js +335 -0
  21. package/dist/server/index.js +127 -17
  22. package/dist/server/managed.js +2 -0
  23. package/dist/server/marker-service.js +5 -19
  24. package/dist/server/markers/index.js +1 -3
  25. package/dist/server/model-admin.js +61 -10
  26. package/dist/server/model-resolver.js +91 -3
  27. package/dist/server/plugins.js +18 -1
  28. package/dist/server/preset-fields.js +14 -0
  29. package/dist/server/preset-share.js +2 -0
  30. package/dist/server/process-utils.js +114 -12
  31. package/dist/server/protocol-version.js +1 -1
  32. package/dist/server/sdk-origin.js +2 -2
  33. package/dist/server/serialize.js +1 -1
  34. package/dist/server/settings-service.js +4 -0
  35. package/dist/server/text-sniff.js +2 -0
  36. package/dist/server/tool-manager.js +3 -19
  37. package/dist/server/universal/driver-base.js +4 -0
  38. package/dist/server/universal/drivers/claude-code.js +3 -2
  39. package/dist/server/universal/universal-service.js +19 -2
  40. package/dist/server/universal/universal-session.js +63 -7
  41. package/dist/server/update-check.js +20 -8
  42. package/package.json +2 -1
  43. package/plugins/catalog.json +13 -2
  44. package/themes/dark-teal.css +0 -1
  45. package/themes/flow-light.css +1085 -0
  46. package/themes/flow.css +1094 -0
  47. package/themes/wallpaper-flow.css +1158 -0
  48. package/themes/wallpaper-obsidian.css +50 -0
  49. package/themes/zhujian-dark.css +0 -7
  50. package/themes/zhujian.css +0 -7
  51. package/themes/zhupi-dark.css +0 -7
  52. package/themes/zhupi.css +0 -7
  53. package/web/dist/assets/{TerminalPanel-CfxKLDW9.js → TerminalPanel-CslRhcS7.js} +2 -2
  54. package/web/dist/assets/index-C_2Fl6f6.js +690 -0
  55. package/web/dist/assets/index-D0BtO5dn.css +1 -0
  56. package/web/dist/index.html +2 -2
  57. package/web/dist/sw.js +1 -1
  58. package/web/dist/assets/index-BtcP6BDk.css +0 -1
  59. package/web/dist/assets/index-XVtCzcHR.js +0 -690
@@ -6,6 +6,7 @@
6
6
  * 2. 管理各浏览器客户端(clientId)的 UniversalSession 实例;
7
7
  * 3. 负责安静停机(quiesce)、状态汇总(serviceStatus)与生命周期销毁。
8
8
  */
9
+ import { existsSync } from "node:fs";
9
10
  import { UniversalSessionStore } from "./session-store.js";
10
11
  import { UniversalSession } from "./universal-session.js";
11
12
  import { MockAgentDriver } from "./drivers/mock-driver.js";
@@ -38,10 +39,25 @@ export class UniversalAgentService {
38
39
  async attach(clientId, send) {
39
40
  let session = this.sessions.get(clientId);
40
41
  if (!session) {
41
- const driver = this.driverFactory(this.cwd);
42
+ let effectiveCwd = this.cwd;
43
+ const saved = this.stateStore?.get(clientId);
44
+ if (saved?.lastCwd && saved.lastCwd !== this.cwd) {
45
+ try {
46
+ if (existsSync(saved.lastCwd)) {
47
+ effectiveCwd = saved.lastCwd;
48
+ }
49
+ }
50
+ catch {
51
+ /* fallback */
52
+ }
53
+ }
54
+ if (typeof this.stateStore?.remember === "function") {
55
+ this.stateStore.remember(clientId, effectiveCwd);
56
+ }
57
+ const driver = this.driverFactory(effectiveCwd);
42
58
  session = new UniversalSession({
43
59
  clientId,
44
- cwd: this.cwd,
60
+ cwd: effectiveCwd,
45
61
  dataDir: this.dataDir,
46
62
  agentDir: this.agentDir,
47
63
  send,
@@ -54,6 +70,7 @@ export class UniversalAgentService {
54
70
  onQuit: () => this.onQuit?.() ?? false,
55
71
  });
56
72
  this.sessions.set(clientId, session);
73
+ session.attachSink(send);
57
74
  }
58
75
  else {
59
76
  session.attachSink(send);
@@ -259,6 +259,7 @@ export class UniversalSession {
259
259
  isDisposed: () => this.disposed,
260
260
  pluginTasks: () => [],
261
261
  cleanupMinutes: () => 0,
262
+ workspaceCwd: () => this.cwd,
262
263
  });
263
264
  // 加载现有会话或创建初始会话
264
265
  const existing = this.store.listConversations(this.cwd);
@@ -274,6 +275,10 @@ export class UniversalSession {
274
275
  this.conversations.set(initialConv.id, initialConv);
275
276
  this.store.saveConversation(this.cwd, initialConv);
276
277
  }
278
+ // 记录当前客户端访问的工作区
279
+ if (typeof this.stateStore?.remember === "function" && this.cwd) {
280
+ this.stateStore.remember(this.clientId, this.cwd);
281
+ }
277
282
  // 若驱动为 Claude Code,异步探测环境并下发安装指引
278
283
  if (this.driver instanceof ClaudeCodeDriver) {
279
284
  void probeClaudeCode().then((probe) => {
@@ -392,6 +397,8 @@ export class UniversalSession {
392
397
  }
393
398
  this.bg.push();
394
399
  void this.refreshSessions();
400
+ void this.pushProjects();
401
+ this.flushSnapshot(true);
395
402
  }
396
403
  detachSink(send) {
397
404
  this.sinks.delete(send);
@@ -823,11 +830,16 @@ export class UniversalSession {
823
830
  }
824
831
  if (conv) {
825
832
  this.activeConvId = conv.id;
833
+ // 同步底层驱动会话上下文(若存在)
834
+ if (conv.driverSessionId) {
835
+ await this.driver.resumeSession(conv.driverSessionId).catch(() => { });
836
+ }
826
837
  }
827
838
  else {
828
839
  this.emitNotice("warning", "未能找到目标会话,已保持在当前对话", "Target conversation not found, staying on current conversation");
829
840
  }
830
841
  this.flushSnapshot(true);
842
+ void this.refreshSessions();
831
843
  }
832
844
  async switchSession(path, sessionId) {
833
845
  const targetId = sessionId || path;
@@ -882,7 +894,17 @@ export class UniversalSession {
882
894
  }
883
895
  }
884
896
  async deleteSession(path) {
885
- await this.dismissConversation(path);
897
+ const targetId = path.trim() || this.activeConvId;
898
+ // 1. 从磁盘删除持久化会话记录
899
+ this.store.deleteConversation(this.cwd, targetId);
900
+ // 2. 若内存中存在该会话,将其从内存中移除
901
+ if (this.conversations.has(targetId)) {
902
+ await this.dismissConversation(targetId, true, true);
903
+ }
904
+ else {
905
+ void this.refreshSessions();
906
+ this.flushSnapshot();
907
+ }
886
908
  }
887
909
  async dismissConversation(id, withFinishedSubagents = false, force = false) {
888
910
  const conv = this.conversations.get(id);
@@ -899,9 +921,7 @@ export class UniversalSession {
899
921
  if (conv.isSubagent && conv.subagentStreaming) {
900
922
  await this.stopSubagent(id);
901
923
  }
902
- if (!conv.isEphemeral) {
903
- this.store.deleteConversation(this.cwd, id);
904
- }
924
+ // 仅从运行中会话映射与草稿中移除,保留磁盘持久化记录(供历史面板随时回溯打开)
905
925
  this.conversations.delete(id);
906
926
  this.sessionDrafts.delete(id);
907
927
  if (this.activeConvId === id) {
@@ -1015,6 +1035,18 @@ export class UniversalSession {
1015
1035
  if (forkedMessages.length > 0) {
1016
1036
  forkedConv.updatedAt = Date.now();
1017
1037
  }
1038
+ // 若底层驱动支持原生会话分叉(如 Durable 引擎的原生 CoW 分叉),保持事务级上下文关联
1039
+ if (targetConv.driverSessionId && typeof this.driver.forkSession === "function") {
1040
+ try {
1041
+ const forkedSid = await this.driver.forkSession(targetConv.driverSessionId);
1042
+ if (forkedSid) {
1043
+ forkedConv.driverSessionId = forkedSid;
1044
+ }
1045
+ }
1046
+ catch {
1047
+ /* fallback */
1048
+ }
1049
+ }
1018
1050
  this.conversations.set(forkedConv.id, forkedConv);
1019
1051
  if (!forkedConv.isEphemeral) {
1020
1052
  this.store.saveConversation(this.cwd, forkedConv);
@@ -1050,6 +1082,18 @@ export class UniversalSession {
1050
1082
  if (headMessages.length > 0) {
1051
1083
  forkedConv.updatedAt = Date.now();
1052
1084
  }
1085
+ // 若底层驱动支持原生会话分叉(如 Durable 引擎),继承前序不可变记录
1086
+ if (conv.driverSessionId && typeof this.driver.forkSession === "function") {
1087
+ try {
1088
+ const forkedSid = await this.driver.forkSession(conv.driverSessionId);
1089
+ if (forkedSid) {
1090
+ forkedConv.driverSessionId = forkedSid;
1091
+ }
1092
+ }
1093
+ catch {
1094
+ /* fallback */
1095
+ }
1096
+ }
1053
1097
  this.conversations.set(forkedConv.id, forkedConv);
1054
1098
  if (!forkedConv.isEphemeral) {
1055
1099
  this.store.saveConversation(this.cwd, forkedConv);
@@ -1133,10 +1177,16 @@ export class UniversalSession {
1133
1177
  return conv.title || (this.lang === "zh" ? "新对话" : "New chat");
1134
1178
  }
1135
1179
  async pushProjects() {
1136
- /* 由外层统一处理 */
1180
+ if (typeof this.stateStore?.getRecentProjects !== "function")
1181
+ return;
1182
+ const projects = await this.stateStore.getRecentProjects(this.clientId);
1183
+ this.send({ type: "projects", projects });
1137
1184
  }
1138
- async removeProject() {
1139
- /* 由外层统一处理 */
1185
+ async removeProject(path) {
1186
+ if (typeof this.stateStore?.removeProject !== "function")
1187
+ return;
1188
+ this.stateStore.removeProject(this.clientId, path);
1189
+ await this.pushProjects();
1140
1190
  }
1141
1191
  async searchSessions(query, reqId) {
1142
1192
  const q = query.trim().toLowerCase();
@@ -1184,6 +1234,7 @@ export class UniversalSession {
1184
1234
  path: conv.id,
1185
1235
  sessionId: conv.id,
1186
1236
  name: conv.title,
1237
+ displayName: this.resolveSessionDisplayName(conv, firstMsg),
1187
1238
  firstMessage: firstMsg,
1188
1239
  messageCount: conv.messages.length,
1189
1240
  modified: conv.updatedAt,
@@ -1366,6 +1417,10 @@ export class UniversalSession {
1366
1417
  }
1367
1418
  await this.refreshSessions();
1368
1419
  await this.refreshWorktreeInfo();
1420
+ if (typeof this.stateStore?.remember === "function") {
1421
+ this.stateStore.remember(this.clientId, path);
1422
+ }
1423
+ void this.pushProjects();
1369
1424
  // 切换目录后恢复该目录按引擎隔离的项目记忆模型
1370
1425
  const savedModel = this.stateStore?.getProjectModel(this.clientId, path, this.engine) ??
1371
1426
  this.stateStore?.getDefaultModel(this.engine);
@@ -1791,6 +1846,7 @@ export class UniversalSession {
1791
1846
  quickPhrases: s?.quickPhrases ?? [],
1792
1847
  quickPhrasesEnabled: s?.quickPhrasesEnabled ?? true,
1793
1848
  minimalNewChat: s?.minimalNewChat ?? false,
1849
+ preserveDraftAcrossConversations: s?.preserveDraftAcrossConversations ?? false,
1794
1850
  quickPhrasesSeeded: this.stateStore?.getQuickPhrasesSeeded() ?? true,
1795
1851
  };
1796
1852
  this.send({ type: "settings_state", settings });
@@ -450,11 +450,19 @@ function versionFromCandidate(bin) {
450
450
  return null;
451
451
  }
452
452
  /**
453
- * Read the pi core version from disk: resolve the `pi` bin on PATH (traversing all
454
- * matches until a valid version is found), then falling back to standard global
455
- * prefix directories.
453
+ * Read the pi core version from disk: resolve the `pi` bin on PATH and check standard
454
+ * global prefix directories, selecting the highest valid version found to avoid
455
+ * local/ancestor node_modules shadowing an updated global installation.
456
456
  */
457
457
  export function readPiCoreVersionFromDisk(env = process.env) {
458
+ let bestVersion = null;
459
+ const updateBest = (v) => {
460
+ if (!v)
461
+ return;
462
+ if (!bestVersion || compareVersions(v, bestVersion) > 0) {
463
+ bestVersion = v;
464
+ }
465
+ };
458
466
  const rawPath = env.PATH ?? "";
459
467
  const dirs = rawPath.split(delimiter).filter(Boolean);
460
468
  const isWin = process.platform === "win32";
@@ -465,10 +473,14 @@ export function readPiCoreVersionFromDisk(env = process.env) {
465
473
  if (!existsSync(candidate))
466
474
  continue;
467
475
  const version = versionFromCandidate(candidate);
468
- if (version)
469
- return version;
476
+ if (version) {
477
+ updateBest(version);
478
+ break;
479
+ }
470
480
  }
471
481
  }
482
+ if (bestVersion)
483
+ return bestVersion;
472
484
  // Fallback to global prefix directories (npm global prefix, pnpm, etc.)
473
485
  const home = env.HOME || env.USERPROFILE || "";
474
486
  const prefix = env.npm_config_prefix || env.PREFIX;
@@ -486,12 +498,12 @@ export function readPiCoreVersionFromDisk(env = process.env) {
486
498
  for (const p of prefixDirs) {
487
499
  const v1 = readPiCoreVersionAt(join(p, "node_modules", ...PI_CORE_PACKAGE.split("/"), "package.json"));
488
500
  if (v1)
489
- return v1;
501
+ updateBest(v1);
490
502
  const v2 = readPiCoreVersionAt(join(p, "lib", "node_modules", ...PI_CORE_PACKAGE.split("/"), "package.json"));
491
503
  if (v2)
492
- return v2;
504
+ updateBest(v2);
493
505
  }
494
- return null;
506
+ return bestVersion;
495
507
  }
496
508
  /**
497
509
  * Default pi core probe: run the globally installed `pi --version`, memoized
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-web-ui",
3
- "version": "0.106.0",
3
+ "version": "0.108.0",
4
4
  "description": "Just open your browser to get all your work done — browser cockpit for AI coding agents (chat, code, files, terminal, Git in one tab)",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -75,6 +75,7 @@
75
75
  "test:smoke:core": "node tests/run-smoke.mjs --core",
76
76
  "check:protocol": "node scripts/check-protocol-sync.mjs",
77
77
  "i18n:diff": "node scripts/i18n-diff.mjs",
78
+ "i18n:check": "node scripts/i18n-diff.mjs --check-packs",
78
79
  "release:notes": "node scripts/release-notes.mjs",
79
80
  "changelog:i18n": "node scripts/release-notes.mjs --unreleased",
80
81
  "test:freeze": "node tests/freeze-test.mjs",
@@ -217,8 +217,8 @@
217
217
  "nameEn": "Image Studio & Toolkit",
218
218
  "icon": "🎨",
219
219
  "iconSvg": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M12 3l1.9 4.6L18.5 9.5l-4.6 1.9L12 16l-1.9-4.6L5.5 9.5l4.6-1.9z\"/><path d=\"M18 15l.9 2.1L21 18l-2.1.9L18 21l-.9-2.1L15 18l2.1-.9z\"/><path d=\"M4.5 19.5l2.5-2.5\"/></svg>",
220
- "description": "一体化 AI 生图与图像处理工作台:一套配置同时接入通义万相、FLUX、OpenAI、Google Imagen/Gemini、智谱 CogView、火山豆包、Stability 与 ComfyUI 等主流生图服务;集成压缩(目标体积二分逼近)、裁剪、缩放、格式转换、水印、滤镜调色与 EXIF 分析;生图与处理在同一工作台内无缝流转。提供 7 个 AI 工具,让 agent 自己生图、配置供应商、分析并加工工作区图片。",
221
- "descriptionEn": "All-in-one AI image generation & processing studio: configure DashScope (Wanx), FLUX, OpenAI, Google Imagen/Gemini, Zhipu CogView, Volcengine Seedream, Stability & ComfyUI side by side; compress (with binary search target size), crop, resize, format conversion, watermark, filters & EXIF analysis. Seamlessly flow between generation and editing in one unified workbench. Ships 7 AI tools for generation, provider configuration, analysis, and processing.",
220
+ "description": "一体化 AI 生图与图像处理工作台:一套配置同时接入通义万相、FLUX、OpenAI、Google Imagen/Gemini、智谱 CogView、火山豆包、Stability 与 ComfyUI 等主流生图服务;集成压缩(目标体积二分逼近)、裁剪、缩放、格式转换、水印、滤镜调色与 EXIF 分析;生图与处理在同一工作台内无缝流转。提供 8 个 AI 工具,让 agent 自己生图、配置供应商、分析并加工工作区图片与精准像素取色(附带位置截图)。",
221
+ "descriptionEn": "All-in-one AI image generation & processing studio: configure DashScope (Wanx), FLUX, OpenAI, Google Imagen/Gemini, Zhipu CogView, Volcengine Seedream, Stability & ComfyUI side by side; compress (with binary search target size), crop, resize, format conversion, watermark, filters & EXIF analysis. Seamlessly flow between generation and editing in one unified workbench. Ships 8 AI tools for generation, provider configuration, analysis, processing, and exact pixel color picking with context screenshot crops.",
222
222
  "source": "xing-shuyin/pi-web-ui/plugins/image-toolkit",
223
223
  "homepage": "https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/image-toolkit"
224
224
  },
@@ -360,5 +360,16 @@
360
360
  "descriptionEn": "Persistent Chrome automation: launches or attaches to a persistent Chrome instance, supports tab management, human-visible element snapshots, smart clicks and inputs, and anti-bot resilience across tasks.",
361
361
  "source": "xing-shuyin/pi-web-ui/plugins/browser-use",
362
362
  "homepage": "https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/browser-use"
363
+ },
364
+ {
365
+ "id": "tts",
366
+ "name": "语音合成 (TTS)",
367
+ "nameEn": "TTS Voice Engine",
368
+ "icon": "🔊",
369
+ "iconSvg": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><polygon points=\"11 5 6 9 2 9 2 15 6 15 11 19 11 5\"/><path d=\"M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07\"/></svg>",
370
+ "description": "多源通用语音合成插件,聚合豆包大模型语音与 DeepSeek 官方音色,支持浏览器扩展一键同步登录凭据并支持消息朗读与实时边打字边流式发声。",
371
+ "descriptionEn": "Multi-engine TTS plugin aggregating Doubao and DeepSeek official voices, supporting one-click browser credential sync, message narration, and real-time streaming speech playback.",
372
+ "source": "xing-shuyin/pi-web-ui/plugins/tts",
373
+ "homepage": "https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/tts"
363
374
  }
364
375
  ]
@@ -149,7 +149,6 @@
149
149
  .dialog-submit,
150
150
  .goalbar-btn,
151
151
  .template-btn.send,
152
- .brand-logo,
153
152
  .goalbar-chip.reviewing,
154
153
  .goalbar-chip.pass,
155
154
  .goalbar-chip.fail,