pi-web-ui 0.101.0 → 0.103.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 (39) hide show
  1. package/CHANGELOG.md +37 -1
  2. package/README.md +1 -1
  3. package/README.zh-CN.md +1 -1
  4. package/bin/pi-web-ui.mjs +13 -9
  5. package/dist/server/agent-service-daemon.js +19 -12
  6. package/dist/server/agent-service.js +255 -58
  7. package/dist/server/ask-user-question-tool.js +12 -2
  8. package/dist/server/bash-tool.js +19 -1
  9. package/dist/server/client-state.js +24 -1
  10. package/dist/server/dispatch-domain-handlers.js +69 -3
  11. package/dist/server/dsh/dsh-agent-service.js +21 -4
  12. package/dist/server/dsh/runtime/goal-rpc.mjs +5 -1
  13. package/dist/server/edit-soft-tool.js +15 -3
  14. package/dist/server/files-service.js +636 -14
  15. package/dist/server/index.js +7 -1
  16. package/dist/server/plugin-installer.js +6 -1
  17. package/dist/server/plugins.js +1 -0
  18. package/dist/server/preset-fields.js +28 -0
  19. package/dist/server/preset-share.js +8 -0
  20. package/dist/server/protocol-version.js +1 -1
  21. package/dist/server/read-tool.js +11 -4
  22. package/dist/server/remote-ssh-service.js +1314 -0
  23. package/dist/server/scm.js +16 -0
  24. package/dist/server/settings-service.js +15 -0
  25. package/dist/server/terminals.js +65 -20
  26. package/dist/server/tool-guards.js +18 -6
  27. package/dist/server/virtual-tui.js +258 -0
  28. package/dist/server/webui-context.js +109 -4
  29. package/package.json +7 -1
  30. package/themes/zhupi-dark.css +3 -14
  31. package/themes/zhupi.css +2 -16
  32. package/web/dist/assets/TerminalPanel-PIx1pMZ0.js +3 -0
  33. package/web/dist/assets/index-CYQdZEbx.css +1 -0
  34. package/web/dist/assets/index-CtaYhpZt.js +680 -0
  35. package/web/dist/index.html +4 -2
  36. package/web/dist/sw.js +1 -1
  37. package/web/dist/assets/TerminalPanel-DD7I5_aC.js +0 -3
  38. package/web/dist/assets/index-CpjA1YdT.css +0 -1
  39. package/web/dist/assets/index-nKn87VuM.js +0 -678
@@ -60,7 +60,8 @@ import { SchedulerStore, SchedulerValidationError } from "./scheduler-tasks.js";
60
60
  import { initHttpProxy } from "./http-proxy.js";
61
61
  import { globalLspPool } from "./lsp-tool.js";
62
62
  import { buildPiWebTokenCookie, decodeCookieToken, isTlsRequest } from "./auth-cookie.js";
63
- import { handleFileMessage, handleScmMessage, handleBgServerMessage, handlePresetAndDshMessage, handleModelAndProviderMessage, handleTerminalMessage, handleSessionLifecycleMessage, handlePlanAndGoalMessage, handleScheduleMessage, handleSettingsMessage, handleInteractiveResponseMessage, } from "./dispatch-domain-handlers.js";
63
+ import { handleFileMessage, handleScmMessage, handleBgServerMessage, handlePresetAndDshMessage, handleModelAndProviderMessage, handleTerminalMessage, handleSessionLifecycleMessage, handlePlanAndGoalMessage, handleScheduleMessage, handleSettingsMessage, handleInteractiveResponseMessage, handleRemoteSshMessage, } from "./dispatch-domain-handlers.js";
64
+ import { RemoteSshService, setGlobalRemoteSshService } from "./remote-ssh-service.js";
64
65
  import { handlePluginMessage } from "./dispatch-plugin-handlers.js";
65
66
  /** Strip npm-injected env (`npm start` exports `npm_config_*` / `npm_package_*` /
66
67
  * `npm_lifecycle_*` into every child). Anything this server spawns — shells,
@@ -1184,6 +1185,9 @@ async function confirmPluginInstallHelper(items) {
1184
1185
  onGrantsChanged: pushPluginPermissions,
1185
1186
  });
1186
1187
  }
1188
+ // 远程 SSH 连接管理、环境探针与目录浏览服务
1189
+ const remoteSshService = new RemoteSshService(DATA_DIR);
1190
+ setGlobalRemoteSshService(remoteSshService);
1187
1191
  // 内置定时任务(issue #184):全局 <dataDir>/scheduler-tasks.json,TTL 与
1188
1192
  // client-state 同级;Agent 工具建的任务优先唤醒发起对话(issue #193:
1189
1193
  // wakeConversation steer 投递,不切用户当前对话),原对话不在先回落同项目
@@ -1718,6 +1722,8 @@ wss.on("connection", (ws) => {
1718
1722
  return;
1719
1723
  if (handleScheduleMessage(msg, scheduler, send))
1720
1724
  return;
1725
+ if (handleRemoteSshMessage(msg, remoteSshService, send))
1726
+ return;
1721
1727
  if (handleSettingsMessage(msg, cs))
1722
1728
  return;
1723
1729
  if (handleInteractiveResponseMessage(msg, cs, service, clientId, send))
@@ -182,7 +182,12 @@ export class PluginInstaller {
182
182
  // 上 kill(-pid) 指向不存在的组而静默失败,作业杀不掉、锁一直占着
183
183
  // (CI 的 busy 单测在 Linux 上 5 秒超时,Windows 走 taskkill 不受影响)。
184
184
  detached: process.platform !== "win32",
185
- env: { ...process.env, PI_WEB_DATA_DIR: this.deps.dataDir, NO_COLOR: "1" },
185
+ env: {
186
+ ...process.env,
187
+ ...(process.versions.electron ? { ELECTRON_RUN_AS_NODE: "1" } : {}),
188
+ PI_WEB_DATA_DIR: this.deps.dataDir,
189
+ NO_COLOR: "1",
190
+ },
186
191
  stdio: ["ignore", "pipe", "pipe"],
187
192
  });
188
193
  this.child = child;
@@ -2308,6 +2308,7 @@ export class PluginManager {
2308
2308
  name: typeof m.name === "string" && m.name ? m.name : name,
2309
2309
  version: typeof m.version === "string" ? m.version : undefined,
2310
2310
  description: typeof m.description === "string" ? m.description : undefined,
2311
+ homepage: typeof m.homepage === "string" && m.homepage.trim() ? m.homepage.trim() : undefined,
2311
2312
  icon: typeof m.icon === "string" && m.icon.trim() ? m.icon.trim() : undefined,
2312
2313
  iconSvg: normalizeIconSvg(m.iconSvg),
2313
2314
  hasClient: existsSync(join(dir, "client", "entry.mjs")),
@@ -39,6 +39,8 @@ export const PRESET_FIELD_GROUPS = {
39
39
  "disabledPluginTools",
40
40
  "toolPromptOverrides",
41
41
  "toolLazyLoading",
42
+ "codemodeMode",
43
+ "codemodeInlineBudget",
42
44
  "readDirEnabled",
43
45
  "toolApprovalEnabled",
44
46
  "toolWatchdogTimeoutMs",
@@ -183,6 +185,18 @@ export const PRESET_FIELD_META = {
183
185
  hintZh: "仅常驻核心工具,其余工具通过 load_tools 按需动态引入(节省上下文)",
184
186
  hintEn: "Keep only core tools active; load others on demand (saves context)",
185
187
  },
188
+ codemodeMode: {
189
+ labelZh: "codemode 运行模式",
190
+ labelEn: "Codemode Execution Mode",
191
+ hintZh: "常规模式(on)或纯代码模式(only,仅通过沙箱脚本调用工具)",
192
+ hintEn: "Regular mode (on) or strict code mode (only, all tool calls run via sandbox script)",
193
+ },
194
+ codemodeInlineBudget: {
195
+ labelZh: "codemode 工具声明预算",
196
+ labelEn: "Codemode Inline Budget",
197
+ hintZh: "直接嵌入在 codemode 系统提示词中的工具声明 Token 预算(默认 3000)",
198
+ hintEn: "Token budget for tool declarations directly embedded in the codemode prompt (default: 3000)",
199
+ },
186
200
  readDirEnabled: {
187
201
  labelZh: "read 工具列目录",
188
202
  labelEn: "Directory Listing in read",
@@ -589,6 +603,17 @@ export function formatPresetFieldValue(field, value, lang = "zh") {
589
603
  };
590
604
  }
591
605
  // 8. 模式类字段
606
+ if (field === "codemodeMode") {
607
+ return {
608
+ summary: value === "only"
609
+ ? isZh
610
+ ? "纯代码模式 (only,仅通过沙箱脚本调用工具)"
611
+ : "Strict code mode (only, sandbox scripts only)"
612
+ : isZh
613
+ ? "常规模式 (on,常规可用,支持脚本批处理)"
614
+ : "Standard mode (on, direct & scripts)",
615
+ };
616
+ }
592
617
  if (field === "promptMode" ||
593
618
  field === "visionBridgePromptMode" ||
594
619
  field === "scmCommitMsgPromptMode" ||
@@ -662,6 +687,9 @@ export function formatPresetFieldValue(field, value, lang = "zh") {
662
687
  }
663
688
  // 11. 数字配置
664
689
  if (typeof value === "number") {
690
+ if (field === "codemodeInlineBudget") {
691
+ return { summary: `${value} tokens` };
692
+ }
665
693
  if (field === "softCapTokens") {
666
694
  return { summary: value > 0 ? `${value} tokens` : isZh ? "跟随默认 (16384 tokens)" : "Default (16384 tokens)" };
667
695
  }
@@ -241,6 +241,8 @@ const PRESET_FIELD_KINDS = {
241
241
  disabledPluginTools: "list",
242
242
  toolPromptOverrides: "toolPromptOverrides",
243
243
  toolLazyLoading: "bool",
244
+ codemodeMode: "codemodeMode",
245
+ codemodeInlineBudget: "number",
244
246
  readDirEnabled: "bool",
245
247
  bgAutoCleanupMin: "number",
246
248
  toolApprovalEnabled: "bool",
@@ -373,6 +375,12 @@ export function sanitizePresetSettings(input, opts) {
373
375
  else
374
376
  rejected.push(key);
375
377
  break;
378
+ case "codemodeMode":
379
+ if (raw === "on" || raw === "only")
380
+ settings[key] = raw;
381
+ else
382
+ rejected.push(key);
383
+ break;
376
384
  case "number":
377
385
  if (typeof raw === "number" && Number.isFinite(raw) && raw >= 0)
378
386
  settings[key] = Math.floor(raw);
@@ -8,4 +8,4 @@
8
8
  * its own copy in web/src/protocol-version.ts; scripts/check-protocol-sync.mjs
9
9
  * verifies the two never drift.
10
10
  */
11
- export const PROTOCOL_VERSION = 26;
11
+ export const PROTOCOL_VERSION = 29;
@@ -32,6 +32,7 @@ import { isAbsolute, join, resolve as nodeResolve } from "node:path";
32
32
  import { createLsToolDefinition, createReadToolDefinition, defineTool, } from "@earendil-works/pi-coding-agent";
33
33
  import { Type } from "typebox";
34
34
  import { pick } from "./i18n.js";
35
+ import { createRemoteSdkOperations } from "./remote-ssh-service.js";
35
36
  const UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;
36
37
  /**
37
38
  * 目录判定用的路径归一:~ / @ 前缀、Unicode 空格、相对 → 绝对(对齐 SDK
@@ -106,7 +107,11 @@ async function dirAwareExecute(base, ls, fallbackCwd, dirEnabled, getLang, norma
106
107
  const path = typeof rawPath === "string" ? rawPath : "";
107
108
  if (path && dirEnabled()) {
108
109
  const cwd = typeof ctx?.cwd === "string" ? ctx.cwd : fallbackCwd;
109
- if (await isDirectoryPath(resolvePathForDirCheck(path, cwd))) {
110
+ const remoteOps = createRemoteSdkOperations(cwd);
111
+ const isDir = remoteOps
112
+ ? await remoteOps.isDirectory(resolvePathForDirCheck(path, cwd))
113
+ : await isDirectoryPath(resolvePathForDirCheck(path, cwd));
114
+ if (isDir) {
110
115
  const limit = typeof input.limit === "number" && input.limit > 0 ? Math.floor(input.limit) : undefined;
111
116
  // 列目录本体完全复用 SDK 的 ls。
112
117
  const listed = (await ls.execute(toolCallId, { path, ...(limit !== undefined ? { limit } : {}) }, signal, onUpdate, ctx));
@@ -127,7 +132,8 @@ async function dirAwareExecute(base, ls, fallbackCwd, dirEnabled, getLang, norma
127
132
  export function withReadDirSupport(base, fallbackCwd, options = {}) {
128
133
  const dirEnabled = options.dirEnabled ?? (() => true);
129
134
  const getLang = options.getLang ?? (() => "en");
130
- const ls = createLsToolDefinition(fallbackCwd);
135
+ const remoteOps = createRemoteSdkOperations(fallbackCwd);
136
+ const ls = createLsToolDefinition(fallbackCwd, remoteOps ? { operations: remoteOps.ls } : undefined);
131
137
  return defineTool({
132
138
  ...base,
133
139
  description: `${base.description} ${DIR_DESCRIPTION_NOTE}`,
@@ -143,8 +149,9 @@ export function withReadDirSupport(base, fallbackCwd, options = {}) {
143
149
  * 有扩展同名工具时改用 `withReadDirSupport` 组合它的实现(见 tool-overrides.ts)。
144
150
  */
145
151
  export function makeReadDirTool(fallbackCwd, options = {}) {
146
- const base = createReadToolDefinition(fallbackCwd);
147
- const ls = createLsToolDefinition(fallbackCwd);
152
+ const remoteOps = createRemoteSdkOperations(fallbackCwd);
153
+ const base = createReadToolDefinition(fallbackCwd, remoteOps ? { operations: remoteOps.read } : undefined);
154
+ const ls = createLsToolDefinition(fallbackCwd, remoteOps ? { operations: remoteOps.ls } : undefined);
148
155
  const dirEnabled = options.dirEnabled ?? (() => true);
149
156
  const getLang = options.getLang ?? (() => "en");
150
157
  return defineTool({