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.
Files changed (64) hide show
  1. package/bin/frp-manager.mjs +85 -7
  2. package/dist/server/agent-formatters.js +10 -6
  3. package/dist/server/agent-service-daemon.js +27 -9
  4. package/dist/server/agent-service.js +140 -24
  5. package/dist/server/attachments.js +114 -31
  6. package/dist/server/canvas/canvas-agent-tool.js +587 -0
  7. package/dist/server/canvas/canvas-cards.js +144 -0
  8. package/dist/server/canvas/canvas-dispatch.js +155 -0
  9. package/dist/server/canvas/canvas-orchestrator.js +1027 -0
  10. package/dist/server/canvas/canvas-store.js +260 -0
  11. package/dist/server/client-id-utils.js +2 -2
  12. package/dist/server/client-state.js +24 -0
  13. package/dist/server/context-budget.js +6 -3
  14. package/dist/server/dsh/dsh-agent-service.js +115 -9
  15. package/dist/server/dsh/dsh-client.js +10 -1
  16. package/dist/server/dsh/runtime/goal-rpc.mjs +128 -3
  17. package/dist/server/dsh/runtime/launcher.mjs +59 -5
  18. package/dist/server/dsh/runtime/runtime-root.mjs +353 -40
  19. package/dist/server/durable/durable-agent-service.js +3 -0
  20. package/dist/server/file-transfer-routes.js +8 -2
  21. package/dist/server/files-service.js +10 -2
  22. package/dist/server/index.js +137 -4
  23. package/dist/server/marker-service.js +3 -1
  24. package/dist/server/markers/marker.js +45 -4
  25. package/dist/server/markers/registry.js +31 -0
  26. package/dist/server/message-window.js +6 -3
  27. package/dist/server/office-parse.js +394 -7
  28. package/dist/server/plugin-api-catalog.js +6 -0
  29. package/dist/server/plugins.js +97 -20
  30. package/dist/server/preset-fields.js +35 -1
  31. package/dist/server/preset-share.js +3 -0
  32. package/dist/server/prompt-assembler.js +7 -1
  33. package/dist/server/prompt-composer.js +66 -36
  34. package/dist/server/protocol-version.js +1 -1
  35. package/dist/server/remote-ssh-service.js +16 -4
  36. package/dist/server/settings-service.js +19 -3
  37. package/dist/server/tool-manager.js +30 -0
  38. package/dist/server/univer-service.js +448 -0
  39. package/dist/server/universal/drivers/claude-code.js +19 -2
  40. package/dist/server/universal/universal-attachments.js +5 -0
  41. package/dist/server/universal/universal-service.js +5 -0
  42. package/dist/server/universal/universal-session.js +28 -12
  43. package/dist/server/update-check.js +90 -5
  44. package/dist/server/workspace-snapshot.js +33 -2
  45. package/docs/dsh-engine.md +497 -0
  46. package/package.json +5 -4
  47. package/plugin-sdk/index.d.ts +17 -0
  48. package/plugin-sdk/index.mjs +5 -0
  49. package/plugins/catalog.json +22 -0
  50. package/themes/aetheris.css +114 -0
  51. package/themes/bases/obsidian-base.css +216 -0
  52. package/themes/md-preview.css +113 -0
  53. package/themes/wallpaper-flow.css +182 -0
  54. package/web/dist/assets/{TerminalPanel-BHjM6pzY.js → TerminalPanel-BiUNySMA.js} +2 -2
  55. package/web/dist/assets/index-B0ajS__T.js +697 -0
  56. package/web/dist/assets/index-BHik5WGG.css +1 -0
  57. package/web/dist/assets/{markdown-DXwnfD9T.js → markdown-BJZlfvdP.js} +24 -24
  58. package/web/dist/assets/markdown-DSNUiDzp.css +1 -0
  59. package/web/dist/index.html +4 -4
  60. package/web/dist/sw.js +1 -1
  61. package/web/dist/assets/es-DIDZppIF.js +0 -2
  62. package/web/dist/assets/index-DwInT7-a.css +0 -1
  63. package/web/dist/assets/index-GfVFIgIL.js +0 -693
  64. 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 root = resolve(ctx.cwd);
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
- // 机器浏览的绝对路径(盘符 / posix "/")允许在工作区之外。
115
- const absPath = isAbsoluteWirePath(att.path);
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
- try {
122
- st = await fs.stat(abs);
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
- catch {
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
- if (!st.isFile() || st.size === 0 || st.size > MAX_PATH_IMAGE_BYTES) {
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 absPath = isAbsoluteWirePath(att.path);
512
- const abs = absPath ? wireToAbs(att.path) : resolve(root, att.path);
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
- // Normalize to forward slashes (relative() returns "\\" on Windows);
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
- try {
529
- stat = await fs.stat(abs);
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
- catch {
532
- ctx.emit({
533
- type: "notice",
534
- level: "error",
535
- text: `附件不存在:${att.path}`,
536
- textEn: `Attachment does not exist: ${att.path}`,
537
- });
538
- continue;
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
- const data = await fs.readFile(abs, "base64");
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",