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.
- package/CHANGELOG.md +29 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/server/agent-service-daemon.js +17 -10
- package/dist/server/agent-service.js +125 -49
- package/dist/server/bash-tool.js +19 -1
- package/dist/server/client-state.js +9 -1
- package/dist/server/dispatch-domain-handlers.js +66 -0
- package/dist/server/edit-soft-tool.js +15 -3
- package/dist/server/files-service.js +636 -14
- package/dist/server/index.js +7 -1
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/read-tool.js +11 -4
- package/dist/server/remote-ssh-service.js +1314 -0
- package/dist/server/scm.js +16 -0
- package/dist/server/terminals.js +65 -21
- package/dist/server/tool-guards.js +18 -6
- package/dist/server/virtual-tui.js +258 -0
- package/dist/server/webui-context.js +109 -4
- package/package.json +7 -1
- package/web/dist/assets/TerminalPanel-Dk8E4DaC.js +3 -0
- package/web/dist/assets/index-CYQdZEbx.css +1 -0
- package/web/dist/assets/index-Pl0V0tEL.js +680 -0
- package/web/dist/index.html +4 -2
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/TerminalPanel-CYGOzbPT.js +0 -3
- package/web/dist/assets/index-CP71PHb6.js +0 -680
- package/web/dist/assets/index-ytRwL6j0.css +0 -1
|
@@ -591,6 +591,15 @@ export function handleInteractiveResponseMessage(msg, cs, service, clientId, sen
|
|
|
591
591
|
case "dialog_response":
|
|
592
592
|
cs.resolveDialog(msg.id, msg.value);
|
|
593
593
|
return true;
|
|
594
|
+
case "tui_overlay_input":
|
|
595
|
+
cs.handleTuiOverlayInput?.(msg.id, msg.data);
|
|
596
|
+
return true;
|
|
597
|
+
case "tui_overlay_resize":
|
|
598
|
+
cs.handleTuiOverlayResize?.(msg.id, msg.cols, msg.rows);
|
|
599
|
+
return true;
|
|
600
|
+
case "tui_overlay_cancel":
|
|
601
|
+
cs.handleTuiOverlayCancel?.(msg.id);
|
|
602
|
+
return true;
|
|
594
603
|
case "question_answer":
|
|
595
604
|
if (msg.owner) {
|
|
596
605
|
// 跨页作答:答案转交持有方会话(本页不持有该问卷)。
|
|
@@ -629,3 +638,60 @@ export function handleInteractiveResponseMessage(msg, cs, service, clientId, sen
|
|
|
629
638
|
return false;
|
|
630
639
|
}
|
|
631
640
|
}
|
|
641
|
+
/** 远程 SSH 连接、探针与目录浏览处理 */
|
|
642
|
+
export function handleRemoteSshMessage(msg, remoteSshSvc, send) {
|
|
643
|
+
switch (msg.type) {
|
|
644
|
+
case "remote_ssh_probe":
|
|
645
|
+
void (async () => {
|
|
646
|
+
const res = await remoteSshSvc.probe(msg.params);
|
|
647
|
+
send({
|
|
648
|
+
type: "remote_ssh_probe_result",
|
|
649
|
+
reqId: msg.reqId,
|
|
650
|
+
...res,
|
|
651
|
+
});
|
|
652
|
+
})();
|
|
653
|
+
return true;
|
|
654
|
+
case "remote_ssh_list_dir":
|
|
655
|
+
void (async () => {
|
|
656
|
+
const res = await remoteSshSvc.listDir(msg.connectionId, msg.path);
|
|
657
|
+
send({
|
|
658
|
+
type: "remote_ssh_list_dir_result",
|
|
659
|
+
reqId: msg.reqId,
|
|
660
|
+
...res,
|
|
661
|
+
});
|
|
662
|
+
})();
|
|
663
|
+
return true;
|
|
664
|
+
case "remote_ssh_install_tools":
|
|
665
|
+
void (async () => {
|
|
666
|
+
const res = await remoteSshSvc.installTools(msg.connectionId, msg.tools);
|
|
667
|
+
send({
|
|
668
|
+
type: "remote_ssh_install_result",
|
|
669
|
+
reqId: msg.reqId,
|
|
670
|
+
...res,
|
|
671
|
+
});
|
|
672
|
+
})();
|
|
673
|
+
return true;
|
|
674
|
+
case "remote_ssh_list_profiles":
|
|
675
|
+
void (async () => {
|
|
676
|
+
const profiles = await remoteSshSvc.listProfiles();
|
|
677
|
+
send({
|
|
678
|
+
type: "remote_ssh_profiles_result",
|
|
679
|
+
reqId: msg.reqId,
|
|
680
|
+
profiles,
|
|
681
|
+
});
|
|
682
|
+
})();
|
|
683
|
+
return true;
|
|
684
|
+
case "remote_ssh_delete_profile":
|
|
685
|
+
void (async () => {
|
|
686
|
+
await remoteSshSvc.deleteProfile(msg.name);
|
|
687
|
+
const profiles = await remoteSshSvc.listProfiles();
|
|
688
|
+
send({
|
|
689
|
+
type: "remote_ssh_profiles_result",
|
|
690
|
+
profiles,
|
|
691
|
+
});
|
|
692
|
+
})();
|
|
693
|
+
return true;
|
|
694
|
+
default:
|
|
695
|
+
return false;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
import { constants } from "node:fs";
|
|
24
24
|
import { access, readFile, writeFile } from "node:fs/promises";
|
|
25
25
|
import { homedir } from "node:os";
|
|
26
|
+
import { createRemoteSdkOperations } from "./remote-ssh-service.js";
|
|
26
27
|
import { isAbsolute, join, resolve as nodeResolve } from "node:path";
|
|
27
28
|
import { Type } from "typebox";
|
|
28
29
|
import { defineTool, generateDiffString, generateUnifiedPatch, withFileMutationQueue, } from "@earendil-works/pi-coding-agent";
|
|
@@ -321,6 +322,7 @@ export function makeEditSoftTool(fallbackCwd, getLang) {
|
|
|
321
322
|
}
|
|
322
323
|
const cwd = typeof ctx?.cwd === "string" ? ctx.cwd : fallbackCwd;
|
|
323
324
|
const absolutePath = resolveToCwd(path, cwd);
|
|
325
|
+
const remoteOps = createRemoteSdkOperations(cwd);
|
|
324
326
|
return withFileMutationQueue(absolutePath, async () => {
|
|
325
327
|
const throwIfAborted = () => {
|
|
326
328
|
if (signal?.aborted)
|
|
@@ -328,7 +330,12 @@ export function makeEditSoftTool(fallbackCwd, getLang) {
|
|
|
328
330
|
};
|
|
329
331
|
throwIfAborted();
|
|
330
332
|
try {
|
|
331
|
-
|
|
333
|
+
if (remoteOps) {
|
|
334
|
+
await remoteOps.edit.access(absolutePath);
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
await access(absolutePath, constants.R_OK | constants.W_OK);
|
|
338
|
+
}
|
|
332
339
|
}
|
|
333
340
|
catch (error) {
|
|
334
341
|
throwIfAborted();
|
|
@@ -336,7 +343,7 @@ export function makeEditSoftTool(fallbackCwd, getLang) {
|
|
|
336
343
|
throw new Error(pick(lang, `无法编辑文件:${path}。${errorMessage}。`, `Could not edit file: ${path}. ${errorMessage}.`, "editsoft.file.access.failed", { path, errorMessage }));
|
|
337
344
|
}
|
|
338
345
|
throwIfAborted();
|
|
339
|
-
const buffer = await readFile(absolutePath);
|
|
346
|
+
const buffer = remoteOps ? await remoteOps.edit.readFile(absolutePath) : await readFile(absolutePath);
|
|
340
347
|
const rawContent = buffer.toString("utf-8");
|
|
341
348
|
throwIfAborted();
|
|
342
349
|
const { bom, text: content } = splitBom(rawContent);
|
|
@@ -345,7 +352,12 @@ export function makeEditSoftTool(fallbackCwd, getLang) {
|
|
|
345
352
|
const { baseContent, newContent } = applySoftEdits(normalizedContent, edits, path, lang);
|
|
346
353
|
throwIfAborted();
|
|
347
354
|
const finalContent = bom + restoreLineEndings(newContent, originalEnding);
|
|
348
|
-
|
|
355
|
+
if (remoteOps) {
|
|
356
|
+
await remoteOps.edit.writeFile(absolutePath, finalContent);
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
await writeFile(absolutePath, finalContent, "utf-8");
|
|
360
|
+
}
|
|
349
361
|
throwIfAborted();
|
|
350
362
|
const diffResult = generateDiffString(baseContent, newContent);
|
|
351
363
|
const patch = generateUnifiedPatch(path, baseContent, newContent);
|