pi-web-ui 0.102.0 → 0.103.1

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.
@@ -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))
@@ -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 = 27;
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({