pi-web-ui 0.110.0 → 0.111.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.
- package/bin/frp-manager.mjs +85 -7
- package/dist/server/agent-formatters.js +10 -6
- package/dist/server/agent-service-daemon.js +27 -9
- package/dist/server/agent-service.js +140 -24
- package/dist/server/attachments.js +114 -31
- package/dist/server/canvas/canvas-agent-tool.js +587 -0
- package/dist/server/canvas/canvas-cards.js +144 -0
- package/dist/server/canvas/canvas-dispatch.js +155 -0
- package/dist/server/canvas/canvas-orchestrator.js +1027 -0
- package/dist/server/canvas/canvas-store.js +260 -0
- package/dist/server/client-id-utils.js +2 -2
- package/dist/server/client-state.js +24 -0
- package/dist/server/context-budget.js +6 -3
- package/dist/server/dsh/dsh-agent-service.js +115 -9
- package/dist/server/dsh/dsh-client.js +10 -1
- package/dist/server/dsh/runtime/goal-rpc.mjs +128 -3
- package/dist/server/dsh/runtime/launcher.mjs +59 -5
- package/dist/server/dsh/runtime/runtime-root.mjs +353 -40
- package/dist/server/durable/durable-agent-service.js +3 -0
- package/dist/server/file-transfer-routes.js +8 -2
- package/dist/server/files-service.js +10 -2
- package/dist/server/index.js +137 -4
- package/dist/server/marker-service.js +3 -1
- package/dist/server/markers/marker.js +45 -4
- package/dist/server/markers/registry.js +31 -0
- package/dist/server/message-window.js +6 -3
- package/dist/server/office-parse.js +394 -7
- package/dist/server/plugin-api-catalog.js +6 -0
- package/dist/server/plugins.js +97 -20
- package/dist/server/preset-fields.js +35 -1
- package/dist/server/preset-share.js +3 -0
- package/dist/server/prompt-assembler.js +7 -1
- package/dist/server/prompt-composer.js +66 -36
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/remote-ssh-service.js +16 -4
- package/dist/server/settings-service.js +19 -3
- package/dist/server/tool-manager.js +30 -0
- package/dist/server/univer-service.js +448 -0
- package/dist/server/universal/drivers/claude-code.js +19 -2
- package/dist/server/universal/universal-attachments.js +5 -0
- package/dist/server/universal/universal-service.js +5 -0
- package/dist/server/universal/universal-session.js +28 -12
- package/dist/server/update-check.js +90 -5
- package/dist/server/workspace-snapshot.js +33 -2
- package/docs/dsh-engine.md +497 -0
- package/package.json +5 -4
- package/plugin-sdk/index.d.ts +17 -0
- package/plugin-sdk/index.mjs +5 -0
- package/plugins/catalog.json +22 -0
- package/themes/aetheris.css +114 -0
- package/themes/bases/obsidian-base.css +216 -0
- package/themes/md-preview.css +113 -0
- package/themes/wallpaper-flow.css +182 -0
- package/web/dist/assets/{TerminalPanel-BHjM6pzY.js → TerminalPanel-BiUNySMA.js} +2 -2
- package/web/dist/assets/index-B0ajS__T.js +697 -0
- package/web/dist/assets/index-BHik5WGG.css +1 -0
- package/web/dist/assets/{markdown-DXwnfD9T.js → markdown-BJZlfvdP.js} +24 -24
- package/web/dist/assets/markdown-DSNUiDzp.css +1 -0
- package/web/dist/index.html +4 -4
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/es-DIDZppIF.js +0 -2
- package/web/dist/assets/index-DwInT7-a.css +0 -1
- package/web/dist/assets/index-GfVFIgIL.js +0 -693
- package/web/dist/assets/markdown-CCeVCbci.css +0 -1
|
@@ -4,6 +4,7 @@ import { saveUpload, uploadsRoot } from "./uploads.js";
|
|
|
4
4
|
import { isAbsoluteWirePath, wireToAbs } from "./files-service.js";
|
|
5
5
|
import { buildVisionBridgePrompt, findVisionModels, transcribeImages } from "./vision-bridge.js";
|
|
6
6
|
import { saveAttachment } from "./attachment-store.js";
|
|
7
|
+
import { getGlobalRemoteSshService, isRemoteWorkspaceUri, parseRemoteWorkspaceUri, resolveRemoteWorkspacePath, } from "./remote-ssh-service.js";
|
|
7
8
|
/** 跨快照的视觉转写缓存:批次 hash(名称 + base64 头 + 提示词)→ 转写文本。
|
|
8
9
|
* 编辑重问重发相同图片不再重复耗视觉 token。进程级共享即可。
|
|
9
10
|
* 长驻进程下无界 Map 会随图片种类缓慢吃内存(单条转写可达数十 KB),
|
|
@@ -36,8 +37,38 @@ export async function buildAttachmentMessages(ctx, attachments) {
|
|
|
36
37
|
if (!attachments || attachments.length === 0)
|
|
37
38
|
return [];
|
|
38
39
|
const fs = await import("node:fs/promises");
|
|
39
|
-
const { resolve, sep, relative, extname, basename } = await import("node:path");
|
|
40
|
-
const
|
|
40
|
+
const { resolve, sep, relative, extname, basename, posix } = await import("node:path");
|
|
41
|
+
const isRemote = isRemoteWorkspaceUri(ctx.cwd);
|
|
42
|
+
const remoteParsed = isRemote ? parseRemoteWorkspaceUri(ctx.cwd) : null;
|
|
43
|
+
const remoteRoot = remoteParsed ? remoteParsed.remotePath : "/";
|
|
44
|
+
const sshSvc = isRemote ? getGlobalRemoteSshService() : null;
|
|
45
|
+
const root = isRemote ? "" : resolve(ctx.cwd);
|
|
46
|
+
const resolveTarget = (attPath) => {
|
|
47
|
+
if (isRemote) {
|
|
48
|
+
let clean = attPath.trim();
|
|
49
|
+
if (isRemoteWorkspaceUri(clean)) {
|
|
50
|
+
const p = parseRemoteWorkspaceUri(clean);
|
|
51
|
+
if (p)
|
|
52
|
+
clean = p.remotePath;
|
|
53
|
+
}
|
|
54
|
+
if (clean.startsWith("/")) {
|
|
55
|
+
const abs = posix.normalize(clean);
|
|
56
|
+
const rawRel = posix.relative(remoteRoot, abs);
|
|
57
|
+
const isOutside = rawRel.startsWith("..") || rawRel.includes("/..");
|
|
58
|
+
return { abs, rel: isOutside ? abs : rawRel || ".", isOutside: false };
|
|
59
|
+
}
|
|
60
|
+
const w = resolveRemoteWorkspacePath(remoteRoot, clean);
|
|
61
|
+
if (!w)
|
|
62
|
+
return null;
|
|
63
|
+
return { abs: w.abs, rel: w.rel || ".", isOutside: false };
|
|
64
|
+
}
|
|
65
|
+
const absPath = isAbsoluteWirePath(attPath);
|
|
66
|
+
const abs = absPath ? wireToAbs(attPath) : resolve(root, attPath);
|
|
67
|
+
const rawRel = absPath ? null : relative(root, abs);
|
|
68
|
+
const isOutside = !absPath && (rawRel.startsWith("..") || rawRel.includes(`${sep}..`));
|
|
69
|
+
const rel = absPath ? abs.split(sep).join("/") : rawRel.split(sep).join("/");
|
|
70
|
+
return { abs, rel, isOutside };
|
|
71
|
+
};
|
|
41
72
|
const MAX_ATTACHMENT_BYTES = 200 * 1024;
|
|
42
73
|
const IMAGE_EXT = new Set([".png", ".jpg", ".jpeg", ".gif", ".webp", ".bmp", ".svg"]);
|
|
43
74
|
const MIME = {
|
|
@@ -111,23 +142,42 @@ export async function buildAttachmentMessages(ctx, attachments) {
|
|
|
111
142
|
const ext = extname(att.path).toLowerCase();
|
|
112
143
|
if (!IMAGE_EXT.has(ext) || ext === ".svg")
|
|
113
144
|
continue;
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
const abs = absPath ? wireToAbs(att.path) : resolve(root, att.path);
|
|
117
|
-
const rawRel = absPath ? null : relative(root, abs);
|
|
118
|
-
if (!absPath && (rawRel.startsWith("..") || rawRel.includes(`${sep}..`)))
|
|
145
|
+
const target = resolveTarget(att.path);
|
|
146
|
+
if (!target || target.isOutside)
|
|
119
147
|
continue;
|
|
120
148
|
let st;
|
|
121
|
-
|
|
122
|
-
|
|
149
|
+
if (isRemote) {
|
|
150
|
+
if (!sshSvc)
|
|
151
|
+
continue;
|
|
152
|
+
try {
|
|
153
|
+
const s = await sshSvc.sftpStat(ctx.cwd, target.abs);
|
|
154
|
+
st = { size: s.size, isFile: s.isFile };
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
123
159
|
}
|
|
124
|
-
|
|
160
|
+
else {
|
|
161
|
+
try {
|
|
162
|
+
const s = await fs.stat(target.abs);
|
|
163
|
+
st = { size: s.size, isFile: s.isFile() };
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
if (!st.isFile || st.size === 0 || st.size > MAX_PATH_IMAGE_BYTES) {
|
|
125
170
|
continue;
|
|
126
171
|
}
|
|
127
|
-
|
|
172
|
+
let buf;
|
|
173
|
+
try {
|
|
174
|
+
buf = isRemote
|
|
175
|
+
? (await sshSvc.sftpReadFile(ctx.cwd, target.abs, MAX_PATH_IMAGE_BYTES)).data
|
|
176
|
+
: await fs.readFile(target.abs);
|
|
177
|
+
}
|
|
178
|
+
catch {
|
|
128
179
|
continue;
|
|
129
180
|
}
|
|
130
|
-
const buf = await fs.readFile(abs);
|
|
131
181
|
const mime = sniffImageMime(buf, ext);
|
|
132
182
|
if (!mime)
|
|
133
183
|
continue;
|
|
@@ -508,10 +558,8 @@ export async function buildAttachmentMessages(ctx, attachments) {
|
|
|
508
558
|
pushUploadAside(att.name ?? basename(abs), abs.split(sep).join("/"), buf);
|
|
509
559
|
continue;
|
|
510
560
|
}
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
const rawRel = absPath ? null : relative(root, abs);
|
|
514
|
-
if (!absPath && (rawRel.startsWith("..") || rawRel.includes(`${sep}..`))) {
|
|
561
|
+
const target = resolveTarget(att.path);
|
|
562
|
+
if (!target || target.isOutside) {
|
|
515
563
|
ctx.emit({
|
|
516
564
|
type: "notice",
|
|
517
565
|
level: "warning",
|
|
@@ -520,22 +568,49 @@ export async function buildAttachmentMessages(ctx, attachments) {
|
|
|
520
568
|
});
|
|
521
569
|
continue;
|
|
522
570
|
}
|
|
523
|
-
|
|
524
|
-
// <file path> and details.path must use the wire format. 机器浏览的绝对
|
|
525
|
-
// 路径直接按绝对路径引用(SDK 读文件工具接受绝对路径,与上传文件一致)。
|
|
526
|
-
const rel = absPath ? abs.split(sep).join("/") : rawRel.split(sep).join("/");
|
|
571
|
+
const { abs, rel } = target;
|
|
527
572
|
let stat;
|
|
528
|
-
|
|
529
|
-
|
|
573
|
+
if (isRemote) {
|
|
574
|
+
if (!sshSvc) {
|
|
575
|
+
ctx.emit({
|
|
576
|
+
type: "notice",
|
|
577
|
+
level: "error",
|
|
578
|
+
text: `远程 SSH 服务不可用:${att.path}`,
|
|
579
|
+
textEn: `Remote SSH service not available: ${att.path}`,
|
|
580
|
+
});
|
|
581
|
+
continue;
|
|
582
|
+
}
|
|
583
|
+
try {
|
|
584
|
+
const s = await sshSvc.sftpStat(ctx.cwd, abs);
|
|
585
|
+
stat = {
|
|
586
|
+
size: s.size,
|
|
587
|
+
isFile: () => s.isFile,
|
|
588
|
+
isDirectory: () => s.isDirectory,
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
catch {
|
|
592
|
+
ctx.emit({
|
|
593
|
+
type: "notice",
|
|
594
|
+
level: "error",
|
|
595
|
+
text: `附件不存在:${att.path}`,
|
|
596
|
+
textEn: `Attachment does not exist: ${att.path}`,
|
|
597
|
+
});
|
|
598
|
+
continue;
|
|
599
|
+
}
|
|
530
600
|
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
601
|
+
else {
|
|
602
|
+
try {
|
|
603
|
+
stat = await fs.stat(abs);
|
|
604
|
+
}
|
|
605
|
+
catch {
|
|
606
|
+
ctx.emit({
|
|
607
|
+
type: "notice",
|
|
608
|
+
level: "error",
|
|
609
|
+
text: `附件不存在:${att.path}`,
|
|
610
|
+
textEn: `Attachment does not exist: ${att.path}`,
|
|
611
|
+
});
|
|
612
|
+
continue;
|
|
613
|
+
}
|
|
539
614
|
}
|
|
540
615
|
const name = att.path.split(/[\\/]/).pop() ?? att.path;
|
|
541
616
|
// Folders can't be inlined — always a path reference the model browses
|
|
@@ -634,7 +709,15 @@ ${transcript}
|
|
|
634
709
|
});
|
|
635
710
|
continue;
|
|
636
711
|
}
|
|
637
|
-
|
|
712
|
+
let data;
|
|
713
|
+
try {
|
|
714
|
+
data = isRemote
|
|
715
|
+
? (await sshSvc.sftpReadFile(ctx.cwd, abs, MAX_ATTACHMENT_BYTES)).data.toString("base64")
|
|
716
|
+
: await fs.readFile(abs, "base64");
|
|
717
|
+
}
|
|
718
|
+
catch {
|
|
719
|
+
continue;
|
|
720
|
+
}
|
|
638
721
|
out.push({
|
|
639
722
|
message: {
|
|
640
723
|
customType: "file",
|