pi-web-ui 0.113.0 → 0.114.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 (228) hide show
  1. package/CHANGELOG.md +69 -1
  2. package/README.md +117 -252
  3. package/README.zh-CN.md +145 -223
  4. package/README.zh-TW.md +145 -223
  5. package/bin/device-hub-cli.mjs +577 -0
  6. package/bin/pi-device-hub.mjs +9 -0
  7. package/bin/pi-web-ui.mjs +145 -20
  8. package/dist/gh-comment-781.md +5 -0
  9. package/dist/server/agent-service-daemon.js +102 -24
  10. package/dist/server/agent-service.js +2296 -1121
  11. package/dist/server/approval-rules.js +29 -3
  12. package/dist/server/ask-user-question-tool.js +8 -8
  13. package/dist/server/atomic-file.js +35 -14
  14. package/dist/server/attachment-store.js +71 -35
  15. package/dist/server/attachments.js +18 -8
  16. package/dist/server/canvas/canvas-agent-tool.js +65 -15
  17. package/dist/server/canvas/canvas-dispatch.js +61 -20
  18. package/dist/server/canvas/canvas-orchestrator.js +516 -199
  19. package/dist/server/canvas/canvas-scheduler.js +99 -0
  20. package/dist/server/canvas/canvas-store.js +107 -54
  21. package/dist/server/canvas/canvas-validation.js +131 -0
  22. package/dist/server/canvas/canvas-workspace.js +284 -0
  23. package/dist/server/client-id-utils.js +8 -0
  24. package/dist/server/client-state.js +104 -22
  25. package/dist/server/communicate-tool.js +76 -0
  26. package/dist/server/compact-context-tool.js +2 -3
  27. package/dist/server/compaction-instructions.js +75 -0
  28. package/dist/server/compaction-markers.js +7 -2
  29. package/dist/server/compaction-state.js +84 -0
  30. package/dist/server/composer-drafts.js +43 -40
  31. package/dist/server/context-evidence.js +346 -0
  32. package/dist/server/control-socket.js +6 -2
  33. package/dist/server/conversation-communication.js +368 -0
  34. package/dist/server/conversation-read-tool.js +3 -4
  35. package/dist/server/conversation-tool-names.js +14 -0
  36. package/dist/server/conversation-tool.js +57 -0
  37. package/dist/server/delegate-mode.js +17 -4
  38. package/dist/server/device-center/bot-catalog.js +88 -0
  39. package/dist/server/device-center/bot-execution.js +106 -0
  40. package/dist/server/device-center/bots.js +170 -0
  41. package/dist/server/device-center/collab-service.js +153 -0
  42. package/dist/server/device-center/collab-tool.js +184 -0
  43. package/dist/server/device-center/connector.js +332 -0
  44. package/dist/server/device-center/desktop-linux.js +372 -0
  45. package/dist/server/device-center/desktop-native.js +413 -0
  46. package/dist/server/device-center/desktop-page.js +232 -0
  47. package/dist/server/device-center/desktop-setup.js +30 -0
  48. package/dist/server/device-center/desktop.js +387 -0
  49. package/dist/server/device-center/device-portals.js +241 -0
  50. package/dist/server/device-center/execution-failure.js +70 -0
  51. package/dist/server/device-center/executor.js +371 -0
  52. package/dist/server/device-center/file-sync.js +493 -0
  53. package/dist/server/device-center/hub-auth.js +69 -0
  54. package/dist/server/device-center/hub-page.js +68 -0
  55. package/dist/server/device-center/hub-setup.js +214 -0
  56. package/dist/server/device-center/hub.js +829 -0
  57. package/dist/server/device-center/local-page.js +17 -0
  58. package/dist/server/device-center/local.js +476 -0
  59. package/dist/server/device-center/main.js +118 -0
  60. package/dist/server/device-center/native-desktop/macos.js +192 -0
  61. package/dist/server/device-center/native-desktop/windows.js +118 -0
  62. package/dist/server/device-center/path-portal.js +120 -0
  63. package/dist/server/device-center/relay.js +959 -0
  64. package/dist/server/device-center/runtime.js +253 -0
  65. package/dist/server/device-center/smoke-preview.js +3 -0
  66. package/dist/server/device-center/store.js +122 -0
  67. package/dist/server/device-center/task-error.js +14 -0
  68. package/dist/server/device-center/transfers.js +293 -0
  69. package/dist/server/device-center/workspaces.js +45 -0
  70. package/dist/server/dispatch-domain-handlers.js +83 -27
  71. package/dist/server/dsh/dsh-agent-service.js +277 -158
  72. package/dist/server/dsh/dsh-client.js +12 -2
  73. package/dist/server/durable/durable-agent-service.js +1 -1
  74. package/dist/server/evidence-tool-hooks.js +49 -0
  75. package/dist/server/file-save.js +95 -0
  76. package/dist/server/file-transfer-routes.js +97 -47
  77. package/dist/server/files-service.js +110 -34
  78. package/dist/server/goal-review-gate.js +16 -6
  79. package/dist/server/goal-service.js +54 -30
  80. package/dist/server/http-proxy.js +120 -0
  81. package/dist/server/index.js +236 -232
  82. package/dist/server/load-timing.js +31 -0
  83. package/dist/server/mcp-bridge.js +219 -94
  84. package/dist/server/mcp-hot-reload.js +31 -5
  85. package/dist/server/mcp-manager.js +192 -93
  86. package/dist/server/mcp-oauth-login.js +169 -0
  87. package/dist/server/mcp-oauth-ui.js +137 -0
  88. package/dist/server/mcp-oauth.js +395 -0
  89. package/dist/server/mcp-project-runtime.js +207 -0
  90. package/dist/server/message-window.js +74 -21
  91. package/dist/server/net-guard.js +122 -20
  92. package/dist/server/payload-limits.js +17 -0
  93. package/dist/server/pending-question.js +82 -0
  94. package/dist/server/plan-mode.js +338 -137
  95. package/dist/server/plugin-assets.js +8 -4
  96. package/dist/server/plugin-chat-attachments.js +48 -0
  97. package/dist/server/plugin-facilities.js +67 -220
  98. package/dist/server/plugin-installer.js +2 -1
  99. package/dist/server/plugin-removal.js +49 -0
  100. package/dist/server/plugin-secrets.js +179 -0
  101. package/dist/server/plugins.js +262 -92
  102. package/dist/server/preset-fields.js +49 -0
  103. package/dist/server/preset-plugin-dependencies.js +57 -0
  104. package/dist/server/preset-share.js +112 -72
  105. package/dist/server/protocol-version.js +1 -1
  106. package/dist/server/queue-modes.js +10 -0
  107. package/dist/server/remote-ssh-service.js +160 -67
  108. package/dist/server/request-context.js +164 -0
  109. package/dist/server/sandbox-data.js +655 -0
  110. package/dist/server/sandbox-engines.js +7 -0
  111. package/dist/server/sandbox-runtime-gate.js +41 -0
  112. package/dist/server/sandbox-service.js +139 -698
  113. package/dist/server/sandbox-tool.js +21 -4
  114. package/dist/server/scheduler-tasks.js +63 -48
  115. package/dist/server/serialize.js +48 -19
  116. package/dist/server/session-branch.js +25 -3
  117. package/dist/server/session-parser.js +28 -18
  118. package/dist/server/session-scan.js +130 -0
  119. package/dist/server/session-search.js +51 -37
  120. package/dist/server/settings-service.js +267 -111
  121. package/dist/server/setup-config.js +58 -0
  122. package/dist/server/skill-maintenance.js +112 -24
  123. package/dist/server/subagent-helpers.js +4 -1
  124. package/dist/server/subagent-notify.js +4 -1
  125. package/dist/server/subagent-security-gate.js +52 -11
  126. package/dist/server/subagent-task.js +27 -0
  127. package/dist/server/subagents.js +217 -46
  128. package/dist/server/tabs.js +9 -1
  129. package/dist/server/terminals.js +467 -363
  130. package/dist/server/tool-guards.js +42 -6
  131. package/dist/server/tool-manager.js +47 -20
  132. package/dist/server/tool-overrides.js +13 -11
  133. package/dist/server/tool-prompt-overrides.js +32 -2
  134. package/dist/server/tool-prompts.js +1 -1
  135. package/dist/server/turn-timing.js +11 -0
  136. package/dist/server/universal/session-store.js +48 -6
  137. package/dist/server/universal/universal-service.js +1 -1
  138. package/dist/server/universal/universal-session.js +334 -231
  139. package/dist/server/uploads.js +64 -5
  140. package/dist/server/webui-context.js +6 -6
  141. package/dist/server/worktree-service.js +32 -24
  142. package/dist/server/ws-pending-queue.js +73 -27
  143. package/dist/test-artifact.md +9 -0
  144. package/dist/test-preview-modal.md +11 -0
  145. package/dist/test-report.html +20 -0
  146. package/docs/device-center.md +142 -0
  147. package/docs/device-desktop.md +48 -0
  148. package/package.json +4 -1
  149. package/plugin-sdk/index.d.ts +45 -9
  150. package/plugin-sdk/ssh-host-trust.mjs +225 -0
  151. package/plugins/catalog.json +1 -1
  152. package/themes/aetheris.css +1 -107
  153. package/themes/ayu-light.css +5 -29
  154. package/themes/bases/flow-base.css +0 -6
  155. package/themes/bases/statusbar-flat-base.css +112 -0
  156. package/themes/bases/zhujian-base.css +1 -0
  157. package/themes/bases/zhupi-base.css +1 -0
  158. package/themes/catppuccin-latte.css +4 -27
  159. package/themes/catppuccin.css +4 -35
  160. package/themes/claude-code-dark.css +1 -0
  161. package/themes/codex.css +4 -28
  162. package/themes/cyberpunk.css +3 -61
  163. package/themes/dark-teal.css +0 -1
  164. package/themes/dazzle.css +3 -73
  165. package/themes/everforest-light.css +4 -27
  166. package/themes/geist.css +4 -28
  167. package/themes/gruvbox-light.css +4 -27
  168. package/themes/kanagawa-lotus.css +4 -27
  169. package/themes/md-preview.css +3 -213
  170. package/themes/mist.css +4 -24
  171. package/themes/nord.css +4 -35
  172. package/themes/one-dark.css +4 -37
  173. package/themes/paper.css +4 -16
  174. package/themes/rose-pine-dawn.css +4 -28
  175. package/themes/sakura.css +4 -24
  176. package/themes/solarized-light.css +4 -27
  177. package/themes/tokyo-night.css +3 -34
  178. package/themes/white.css +4 -26
  179. package/themes/zhujian-dark.css +1 -0
  180. package/themes/zhupi-dark.css +1 -0
  181. package/web/dist/.build-assets.json +1 -0
  182. package/web/dist/assets/BgTasksModal-CS7UNzcw.js +1 -0
  183. package/web/dist/assets/BgTasksModal-Dk-tp78W.js +1 -0
  184. package/web/dist/assets/CanvasStudio-BEJZE5BI.js +1579 -0
  185. package/web/dist/assets/CanvasStudio-CgUNHqos.js +1579 -0
  186. package/web/dist/assets/DeviceCenter-C8_CbxQ3.js +3 -0
  187. package/web/dist/assets/DeviceCenter-CVblvhNX.js +3 -0
  188. package/web/dist/assets/Dropdown-Oug0DDte.js +1 -0
  189. package/web/dist/assets/FilePreview-CvdX6nr6.js +2 -0
  190. package/web/dist/assets/FilePreview-kCZhfBAF.js +2 -0
  191. package/web/dist/assets/GlobalSearchModal-BLH63yYP.js +1 -0
  192. package/web/dist/assets/GlobalSearchModal-DAkvlvp6.js +1 -0
  193. package/web/dist/assets/GroupConversation-Cgo4xbpa.js +1 -0
  194. package/web/dist/assets/GroupConversation-DZ71jEi8.js +1 -0
  195. package/web/dist/assets/ModelConfigModal-BpWdFdQC.js +2 -0
  196. package/web/dist/assets/PiSetupModal-mkWPSxMj.js +1 -0
  197. package/web/dist/assets/ProviderOAuthControls-VK_jqXYS.js +1 -0
  198. package/web/dist/assets/SCMPanel-BP1TUT-V.js +2 -0
  199. package/web/dist/assets/SCMPanel-BscPm9kf.js +2 -0
  200. package/web/dist/assets/SettingsModal-C8UgMjVM.js +20 -0
  201. package/web/dist/assets/SettingsModal-VynB7jNb.js +20 -0
  202. package/web/dist/assets/TerminalPanel-D6cPRFei.js +3 -0
  203. package/web/dist/assets/TerminalPanel-DL20uKgU.js +3 -0
  204. package/web/dist/assets/TuiOverlayModal-Dst3BmT8.js +1 -0
  205. package/web/dist/assets/TuiOverlayModal-NCkpNtTp.js +1 -0
  206. package/web/dist/assets/UniversalPathPicker-CfQFc_c3.js +1 -0
  207. package/web/dist/assets/UniversalPathPicker-DwxwNcFw.js +1 -0
  208. package/web/dist/assets/app-globals-CnO6KlEM.js +325 -0
  209. package/web/dist/assets/desktop-DPyTy4M3.js +1 -0
  210. package/web/dist/assets/es-DWMIuDU2.js +2 -0
  211. package/web/dist/assets/index-CPgAH5q7.js +83 -0
  212. package/web/dist/assets/index-Cje8iugL.js +83 -0
  213. package/web/dist/assets/index-DnKeiDbj.css +1 -0
  214. package/web/dist/assets/markdown-BggnuQ4H.js +40 -0
  215. package/web/dist/assets/markdown-C8LL_u4z.css +1 -0
  216. package/web/dist/assets/math-1uRJCsA9.js +257 -0
  217. package/web/dist/assets/math-BorAY7qD.css +1 -0
  218. package/web/dist/assets/plugin-host-CqA4yW6w.js +1 -0
  219. package/web/dist/assets/shortcut-stack-hhrDyRBn.js +1 -0
  220. package/web/dist/assets/theme-BqdAjEjF.js +1 -0
  221. package/web/dist/assets/uuid-BzDIGCwP.js +1 -0
  222. package/web/dist/index.html +15 -9
  223. package/web/dist/sw.js +1 -1
  224. package/web/dist/assets/TerminalPanel-3wojLfLk.js +0 -3
  225. package/web/dist/assets/index-A8YXwnpZ.js +0 -2008
  226. package/web/dist/assets/index-BwL7qBh6.css +0 -1
  227. package/web/dist/assets/markdown-BJZlfvdP.js +0 -296
  228. package/web/dist/assets/markdown-DSNUiDzp.css +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-web-ui",
3
- "version": "0.113.0",
3
+ "version": "0.114.0",
4
4
  "description": "Just open your browser to get all your work done — browser cockpit for AI coding agents (chat, code, files, terminal, Git in one tab)",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -29,6 +29,8 @@
29
29
  "plugin-sdk/",
30
30
  "plugins/catalog.json",
31
31
  "docs/dsh-engine.md",
32
+ "docs/device-center.md",
33
+ "docs/device-desktop.md",
32
34
  "CHANGELOG.md",
33
35
  "README.md",
34
36
  "LICENSE"
@@ -99,6 +101,7 @@
99
101
  "dependencies": {
100
102
  "@deepseek-ai/dsh-sdk-jsonrpc-server": "^0.2.1-rc.2",
101
103
  "@deepseek-ai/dsh-sdk-protocol": "^0.2.1-rc.2",
104
+ "@earendil-works/pi-mcp": "^1.4.0",
102
105
  "compression": "^1.8.2",
103
106
  "electron-updater": "^6.8.9",
104
107
  "express": "^5.2.1",
@@ -179,6 +179,26 @@ export type ToolGuardPreDecision =
179
179
  | { decision: "deny"; reason?: string; reasonEn?: string }
180
180
  | { decision: "ask"; reason?: string; reasonEn?: string };
181
181
 
182
+ export interface PluginChatAttachment {
183
+ path: string;
184
+ mode?: "reference" | "inline";
185
+ name?: string;
186
+ mimeType?: string;
187
+ imageData?: string;
188
+ fileData?: string;
189
+ }
190
+
191
+ export interface PluginChatRequest {
192
+ text: string;
193
+ accountId?: string;
194
+ conversationId?: string;
195
+ cwd?: string;
196
+ model?: string;
197
+ thinkingLevel?: string;
198
+ /** Up to 8 attachments, 10 MiB each and 20 MiB total. Images use imageData (base64). */
199
+ attachments?: PluginChatAttachment[];
200
+ }
201
+
182
202
  /** 插件服务端入口拿到的宿主接口(精简:全量见 server/plugins.ts PluginHost)。 */
183
203
  export interface PluginHost {
184
204
  broadcast(payload: unknown): void;
@@ -340,14 +360,16 @@ export interface PluginHost {
340
360
  };
341
361
  /** 无头调用:把外部通道文本投给 agent(要 "chat" 能力;宿主未接 chatProvider
342
362
  * 时 reject(由 chatWait 包成 {ok:false},插件侧用 chatWait 更省心)。 */
343
- chat(req: { text: string; accountId?: string }): Promise<{
344
- ok: boolean;
345
- conversationId?: string;
346
- error?: string;
363
+ chat(req: PluginChatRequest): Promise<{
364
+ /** Present only on mock hosts or older integrations; real failures reject. */
365
+ ok?: boolean;
366
+ conversationId: string;
367
+ clientId: string;
368
+ runId?: string;
347
369
  }>;
348
370
  /** 等待无头调用的运行结束(默认 120s 超时;无注入/超时/失败一律回 {ok:false},绝不抛错)。 */
349
371
  chatWait(
350
- req: { text: string; accountId?: string },
372
+ req: PluginChatRequest,
351
373
  opts?: { timeoutMs?: number },
352
374
  ): Promise<{ ok: boolean; conversationId?: string; error?: string }>;
353
375
  /** 对话读写:无注入时 list/search 回 []、get 回 null,绝不抛错。 */
@@ -366,7 +388,7 @@ export interface PluginHost {
366
388
  ): Promise<{ ok: boolean; error?: string }>;
367
389
  /** 插队指定对话的当前运行(无注入回 {ok:false},绝不抛错)。 */
368
390
  steer(conversationId: string, text: string): Promise<{ ok: boolean; error?: string }>;
369
- /** 中止指定对话的运行(无注入回 {ok:false},绝不抛错)。 */
391
+ /** Abort by stable plugin runId (pr- prefix, survives takeover), or legacy local conversationId. */
370
392
  abortRun(conversationId: string): Promise<{ ok: boolean; error?: string }>;
371
393
  /** 项目组装:在已授权目录里建目录/clone 仓库/写文件(失败回 {ok:false,error},不留半成品)。 */
372
394
  project: {
@@ -589,13 +611,27 @@ export interface MockHostControls {
589
611
 
590
612
  /** 浏览器桥兼容(client 侧逻辑单测也能用同一个 mock):无注入回退语义。 */
591
613
  export interface MockHostDialogs {
592
- select(opts: { title?: string; options?: unknown; [key: string]: unknown }): Promise<{
614
+ select(opts: {
615
+ title?: string;
616
+ options?: unknown;
617
+ code?: { content: string; language?: string; hasRisk?: boolean };
618
+ [key: string]: unknown;
619
+ }): Promise<{
593
620
  ok: boolean;
594
621
  selected?: string[];
595
622
  error?: string;
596
623
  }>;
597
- confirm(opts: { title?: string; text?: string; [key: string]: unknown }): Promise<boolean>;
598
- input(opts: { title?: string; [key: string]: unknown }): Promise<{ ok: boolean; value?: string }>;
624
+ confirm(opts: {
625
+ title?: string;
626
+ text?: string;
627
+ code?: { content: string; language?: string; hasRisk?: boolean };
628
+ [key: string]: unknown;
629
+ }): Promise<boolean>;
630
+ input(opts: {
631
+ title?: string;
632
+ code?: { content: string; language?: string; hasRisk?: boolean };
633
+ [key: string]: unknown;
634
+ }): Promise<{ ok: boolean; value?: string }>;
599
635
  }
600
636
 
601
637
  /** createMockHost 返回的 mock host(PluginHost 全量 + harness 字段 + 桥兼容)。 */
@@ -0,0 +1,225 @@
1
+ /** Shared, fail-closed OpenSSH verification and explicit, fingerprint-confirmed trust persistence. */
2
+ import { createHash, createHmac, randomUUID, timingSafeEqual } from "node:crypto";
3
+ import { chmod, lstat, mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
4
+ import os from "node:os";
5
+ import path from "node:path";
6
+
7
+ function equal(a, b) {
8
+ return a.length === b.length && timingSafeEqual(a, b);
9
+ }
10
+
11
+ function matches(pattern, hostname) {
12
+ if (pattern.startsWith("|")) {
13
+ const parts = pattern.split("|");
14
+ if (parts.length !== 4 || parts[1] !== "1") return false;
15
+ const salt = Buffer.from(parts[2], "base64");
16
+ const digest = Buffer.from(parts[3], "base64");
17
+ return salt.length === 20 && equal(createHmac("sha1", salt).update(hostname).digest(), digest);
18
+ }
19
+ const regex = pattern
20
+ .replace(/[.+^${}()|[\]\\]/g, "\\$&")
21
+ .replace(/\*/g, ".*")
22
+ .replace(/\?/g, ".");
23
+ return new RegExp(`^${regex}$`, "i").test(hostname);
24
+ }
25
+
26
+ function hostMatches(patterns, hostname) {
27
+ let matched = false;
28
+ for (const pattern of patterns.split(",")) {
29
+ if (pattern.startsWith("!")) {
30
+ if (matches(pattern.slice(1), hostname)) return false;
31
+ } else if (matches(pattern, hostname)) matched = true;
32
+ }
33
+ return matched;
34
+ }
35
+
36
+ /** Exact host/port binding; hashed hosts, wildcards, negation and @revoked are supported.
37
+ * @cert-authority is intentionally not accepted: certificate verification is not implemented.
38
+ */
39
+ export function verifyKnownHosts(contents, host, port, key) {
40
+ const hostname = port === 22 ? host.toLowerCase() : `[${host.toLowerCase()}]:${port}`;
41
+ let trusted = false;
42
+ for (const line of contents.split(/\r?\n/)) {
43
+ const fields = line.trim().split(/\s+/);
44
+ if (!fields[0] || fields[0].startsWith("#")) continue;
45
+ const marker = fields[0].startsWith("@") ? fields.shift() : "";
46
+ const [hosts, algorithm, encoded] = fields;
47
+ if (!hosts || !algorithm || !encoded || !hostMatches(hosts, hostname)) continue;
48
+ const stored = Buffer.from(encoded, "base64");
49
+ if (stored.length < 4) continue;
50
+ const length = stored.readUInt32BE(0);
51
+ if (length > stored.length - 4 || stored.subarray(4, 4 + length).toString("ascii") !== algorithm) continue;
52
+ if (!equal(stored, key)) continue;
53
+ if (marker === "@revoked") return false;
54
+ if (!marker) trusted = true;
55
+ }
56
+ return trusted;
57
+ }
58
+
59
+ function knownHostsFile() {
60
+ const configured = process.env.PI_WEB_SSH_KNOWN_HOSTS?.trim();
61
+ return path.resolve(
62
+ configured ? configured.replace(/^~(?=[/\\])/, os.homedir()) : path.join(os.homedir(), ".ssh", "known_hosts"),
63
+ );
64
+ }
65
+
66
+ async function readKnownHosts(file) {
67
+ try {
68
+ return await readFile(file, "utf8");
69
+ } catch (error) {
70
+ if (error.code === "ENOENT") return "";
71
+ throw new Error(`Cannot read SSH known_hosts ${file}: ${error.message}`);
72
+ }
73
+ }
74
+
75
+ function fingerprintOf(key) {
76
+ return `SHA256:${createHash("sha256").update(key).digest("base64").replace(/=+$/, "")}`;
77
+ }
78
+
79
+ function algorithmOf(key) {
80
+ if (!Buffer.isBuffer(key) || key.length < 5) throw new Error("Invalid SSH host key");
81
+ const length = key.readUInt32BE(0);
82
+ if (!length || length > key.length - 4) throw new Error("Invalid SSH host key");
83
+ const algorithm = key.subarray(4, 4 + length).toString("ascii");
84
+ if (!/^[a-zA-Z0-9@._+-]+$/.test(algorithm)) throw new Error("Invalid SSH host key algorithm");
85
+ return algorithm;
86
+ }
87
+
88
+ function hostBinding(host, port) {
89
+ if (typeof host !== "string" || !host || /[\s,*?!|#[\]\\/\x00-\x1f\x7f]/.test(host)) {
90
+ throw new Error("Invalid SSH host");
91
+ }
92
+ if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error("Invalid SSH port");
93
+ return port === 22 ? host.toLowerCase() : `[${host.toLowerCase()}]:${port}`;
94
+ }
95
+
96
+ function matchingRows(contents, hostname) {
97
+ const rows = [];
98
+ for (const line of contents.split(/(?<=\n)/)) {
99
+ const fields = /^(\s*)(?:(@\S+)\s+)?([^\s#]+)(\s+)(\S+)\s+(\S+)/.exec(line);
100
+ if (!fields || !hostMatches(fields[3], hostname)) continue;
101
+ const stored = Buffer.from(fields[6], "base64");
102
+ try {
103
+ if (algorithmOf(stored) !== fields[5]) continue;
104
+ } catch {
105
+ continue;
106
+ }
107
+ rows.push({ line, fields, stored, marker: fields[2] || "", hosts: fields[3] });
108
+ }
109
+ return rows;
110
+ }
111
+
112
+ function trustStatus(contents, hostname, key) {
113
+ const rows = matchingRows(contents, hostname);
114
+ if (rows.some((row) => row.marker === "@revoked" && equal(row.stored, key))) return "revoked";
115
+ return rows.length ? "changed" : "unknown";
116
+ }
117
+
118
+ // Serialize the read/modify/rename transaction, including saves to the same file from different callers.
119
+ let pendingSave = Promise.resolve();
120
+
121
+ /** Persist only a caller-confirmed key. Returns the public trust description; never returns key bytes.
122
+ * replace is required for changed keys. Wildcard/CA/revoked bindings cannot be rewritten here.
123
+ * Serialization is process-local; one service process must own the configured trust file.
124
+ */
125
+ export function saveTrustedHostKey({ host, port = 22, key, fingerprint, replace = false }) {
126
+ const file = knownHostsFile();
127
+ // Capture bytes now: callers cannot change the key while waiting for an earlier save.
128
+ const capturedKey = Buffer.isBuffer(key) ? Buffer.from(key) : key;
129
+ const save = pendingSave.then(async () => {
130
+ const hostname = hostBinding(host, port);
131
+ const algorithm = algorithmOf(capturedKey);
132
+ if (fingerprint !== fingerprintOf(capturedKey)) throw new Error("SSH host key fingerprint mismatch");
133
+ const contents = await readKnownHosts(file);
134
+ const rows = matchingRows(contents, hostname);
135
+ if (rows.some((row) => row.marker === "@revoked")) throw new Error("SSH host key is revoked; cannot save trust");
136
+ const result = { host, port, algorithm, fingerprint, knownHostsFile: file };
137
+ if (verifyKnownHosts(contents, host, port, capturedKey)) return result;
138
+ if (rows.length && !replace) throw new Error("SSH host key changed; explicit replace is required");
139
+ const replacements = new Map();
140
+ for (const row of rows) {
141
+ const bindings = row.hosts.split(",");
142
+ if (
143
+ row.marker ||
144
+ bindings.some((binding) => !binding.startsWith("!") && matches(binding, hostname) && /[*?]/.test(binding))
145
+ ) {
146
+ throw new Error("Cannot safely replace wildcard or marked SSH known_hosts binding");
147
+ }
148
+ const remaining = bindings.filter((binding) => binding.startsWith("!") || !matches(binding, hostname));
149
+ // A list containing only exclusions no longer binds any host.
150
+ if (!remaining.some((binding) => !binding.startsWith("!"))) replacements.set(row.line, "");
151
+ else {
152
+ const start = row.fields[1].length;
153
+ replacements.set(
154
+ row.line,
155
+ row.line.slice(0, start) + remaining.join(",") + row.line.slice(start + row.hosts.length),
156
+ );
157
+ }
158
+ }
159
+ let updated = contents
160
+ .split(/(?<=\n)/)
161
+ .map((line) => replacements.get(line) ?? line)
162
+ .join("");
163
+ if (updated && !updated.endsWith("\n")) updated += "\n";
164
+ updated += `${hostname} ${algorithm} ${capturedKey.toString("base64")}\n`;
165
+ let mode = 0o600;
166
+ try {
167
+ const stat = await lstat(file);
168
+ if (!stat.isFile() || stat.isSymbolicLink()) throw new Error("SSH known_hosts must be a regular file");
169
+ mode = stat.mode & 0o777;
170
+ } catch (error) {
171
+ if (error.code !== "ENOENT") throw error;
172
+ }
173
+ await mkdir(path.dirname(file), { recursive: true, mode: 0o700 });
174
+ const temporary = `${file}.${randomUUID()}.tmp`;
175
+ try {
176
+ await writeFile(temporary, updated, { flag: "wx", mode });
177
+ await chmod(temporary, mode);
178
+ await rename(temporary, file);
179
+ } finally {
180
+ await unlink(temporary).catch((error) => {
181
+ if (error.code !== "ENOENT") throw error;
182
+ });
183
+ }
184
+ return result;
185
+ });
186
+ pendingSave = save.catch(() => {});
187
+ return save;
188
+ }
189
+
190
+ /** Read once per handshake, before any authentication. The override names a single local file. */
191
+ export async function createHostVerifier(host, port = 22) {
192
+ const file = knownHostsFile();
193
+ const contents = await readKnownHosts(file);
194
+ let failure;
195
+ return {
196
+ hostVerifier(key) {
197
+ if (verifyKnownHosts(contents, host, port, key)) return true;
198
+ const fingerprint = fingerprintOf(key);
199
+ failure = new Error(
200
+ `SSH 主机密钥未受信任或已变更 / host key untrusted or changed: ${host}:${port}; presented ${fingerprint}. ` +
201
+ `连接已拒绝,未保存密钥 / Connection refused; no key was saved. ` +
202
+ `请通过服务器控制台或管理员独立核对指纹(服务器上可运行 ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub;按实际密钥类型选文件)。` +
203
+ `核对一致后,用本机 OpenSSH ssh 连接同一主机和端口,设置 StrictHostKeyChecking=ask 和 UserKnownHostsFile 为 ${file},确认提示后重试。` +
204
+ `若密钥已变更,须先由管理员确认轮换,再手动更新对应记录;不要盲目删除旧记录或直接信任 ssh-keyscan 输出。` +
205
+ ` Independently verify the fingerprint with the server console/admin, then use OpenSSH ssh with StrictHostKeyChecking=ask and UserKnownHostsFile=${file} for the same host/port; accept only the verified key. ` +
206
+ `For rotated keys, confirm rotation before replacing the old entry. Do not trust ssh-keyscan output alone. ` +
207
+ `Preprovision verified OpenSSH entries in this file, or set PI_WEB_SSH_KNOWN_HOSTS to a trusted known_hosts file in the server environment. ` +
208
+ `CA-only (@cert-authority) entries are not supported; provision the verified host public key.`,
209
+ );
210
+ failure.hostTrust = {
211
+ host,
212
+ port,
213
+ algorithm: algorithmOf(key),
214
+ fingerprint,
215
+ knownHostsFile: file,
216
+ status: trustStatus(contents, port === 22 ? host.toLowerCase() : `[${host.toLowerCase()}]:${port}`, key),
217
+ };
218
+ Object.defineProperty(failure, "hostKey", { value: Buffer.from(key), enumerable: false });
219
+ return false;
220
+ },
221
+ getError() {
222
+ return failure;
223
+ },
224
+ };
225
+ }
@@ -420,7 +420,7 @@
420
420
  "icon": "📑",
421
421
  "iconSvg": "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z\"/><polyline points=\"14 2 14 8 20 8\"/><line x1=\"16\" y1=\"13\" x2=\"8\" y2=\"13\"/><line x1=\"16\" y1=\"17\" x2=\"8\" y2=\"17\"/><line x1=\"10\" y1=\"9\" x2=\"8\" y2=\"9\"/></svg>",
422
422
  "description": "基于 Univer 引擎的高保真 Office 原生画布预览与编辑:接管工作区 .pptx / .docx / .xlsx 真实渲染,支持 1:1 排版放映与 AI 结构化表格修改写回。",
423
- "descriptionEn": "High-fidelity Office Canvas preview and editing powered by Univer: 1:1 true layouts for .pptx/.docx/.xlsx with AI structured editing and lossless disk save.",
423
+ "descriptionEn": "Office Canvas preview and editing powered by Univer, with structured AI operations and conflict-checked disk export.",
424
424
  "source": "xing-shuyin/pi-web-ui/plugins/office",
425
425
  "homepage": "https://github.com/xing-shuyin/pi-web-ui/tree/main/plugins/office"
426
426
  },
@@ -1,6 +1,7 @@
1
1
  /* theme-name: 以太座舱 */
2
2
  /* theme-name-en: Aetheris HUD */
3
3
  /* theme-group: builtin */
4
+ @import "./bases/statusbar-flat-base.css";
4
5
  :root {
5
6
  color-scheme: dark;
6
7
  --bg: #040507;
@@ -475,115 +476,8 @@ body,
475
476
  .statusbar .bar-item,
476
477
  .statusbar .bar-item.chip,
477
478
  .statusbar .chip {
478
- height: 18px;
479
- min-height: 18px;
480
- padding: 0 4px;
481
- font-size: 11px;
482
- line-height: 18px;
483
- gap: 3px;
484
- color: var(--text-dim);
485
- background: transparent;
486
- border: 1px solid transparent;
487
- border-radius: 2px;
488
- box-shadow: none;
489
- opacity: 1;
490
- filter: none;
491
- text-shadow: none;
492
- cursor: pointer;
493
- transform: none;
494
479
  letter-spacing: normal;
495
480
  }
496
- .statusbar .bar-item:hover,
497
- .statusbar .bar-item.chip:hover,
498
- .statusbar .chip:hover {
499
- background: var(--glow-12);
500
- color: var(--text);
501
- border-color: transparent;
502
- border-radius: 2px;
503
- box-shadow: none;
504
- opacity: 1;
505
- filter: none;
506
- text-shadow: none;
507
- transform: none;
508
- }
509
- .statusbar .bar-item.active,
510
- .statusbar .bar-item.chip.active,
511
- .statusbar .chip.active {
512
- background: var(--bg-elev2);
513
- color: var(--text);
514
- }
515
- .statusbar .bar-item-text {
516
- font-size: 11px;
517
- line-height: 1.2;
518
- color: inherit;
519
- opacity: 1;
520
- text-shadow: none;
521
- }
522
- .statusbar .bar-item-char {
523
- font-size: 11px;
524
- line-height: 1;
525
- font-weight: 600;
526
- color: var(--text-faint);
527
- opacity: 0.85;
528
- text-shadow: none;
529
- }
530
- .statusbar .bar-item.status-cost {
531
- gap: 0;
532
- }
533
- .statusbar .bar-item-icon {
534
- font-size: 11px;
535
- width: 11px;
536
- height: 11px;
537
- min-width: 11px;
538
- opacity: 0.75;
539
- color: inherit;
540
- filter: none;
541
- text-shadow: none;
542
- }
543
- .statusbar .bar-item:hover .bar-item-icon {
544
- opacity: 1;
545
- color: inherit;
546
- filter: none;
547
- }
548
- .statusbar .bar-item-icon svg,
549
- .statusbar .bar-item-glyph {
550
- width: 11px;
551
- height: 11px;
552
- color: inherit;
553
- stroke: currentColor;
554
- filter: none;
555
- text-shadow: none;
556
- }
557
- .statusbar .bar-item-badge {
558
- background: none;
559
- color: var(--accent);
560
- font-size: 10px;
561
- font-weight: 700;
562
- min-width: 0;
563
- height: auto;
564
- padding: 0;
565
- margin-left: 0;
566
- border-radius: 0;
567
- opacity: 1;
568
- text-shadow: none;
569
- box-shadow: none;
570
- }
571
- .statusbar .engine-picker-btn {
572
- background: transparent;
573
- border: 1px solid transparent;
574
- border-radius: 2px;
575
- padding: 0 4px;
576
- color: var(--text-dim);
577
- box-shadow: none;
578
- opacity: 1;
579
- filter: none;
580
- text-shadow: none;
581
- }
582
- .statusbar .engine-picker-btn:hover {
583
- background: var(--glow-12);
584
- border-color: transparent;
585
- color: var(--text);
586
- }
587
481
 
588
482
  /* ---------------- 9. 极客悬浮滚动条 (Quiet Cybernetic Scrollbar) ---------------- */
589
483
  ::-webkit-scrollbar {
@@ -15,14 +15,11 @@
15
15
  --accent-contrast: #0f1419;
16
16
  --accent-soft: rgba(242, 151, 24, 0.14);
17
17
  --green: #587600;
18
- --on-green: #ffffff;
19
18
  --green-soft: rgba(134, 179, 0, 0.12);
20
19
  --red: #da1717;
21
- --on-red: #ffffff;
22
20
  --red-soft: rgba(240, 113, 113, 0.1);
23
21
  --amber: #9f5b16;
24
22
  --blue: #0b63f3;
25
- --blue-soft: rgba(59, 130, 246, 0.12);
26
23
  --term-bg: #fcfcfc;
27
24
  --term-fg: #5c6166;
28
25
  --term-cursor: #f29718;
@@ -43,15 +40,9 @@
43
40
  --term-bright-blue: #22a4e6;
44
41
  --term-bright-magenta: #a37acc;
45
42
  --term-bright-cyan: #4cbf99;
46
- --term-bright-white: #ffffff;
47
- --mono: "SF Mono", "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
48
- --mermaid-font-size: 12px;
49
43
  --tooltip-bg: #f8f9fa;
50
44
  --code-bg: #f0f1f3;
51
45
  --code-text: #5c6166;
52
- --code-border: var(--border-soft);
53
- --code-pad: 8px 10px;
54
- --card-body-pad: 4px 14px 12px;
55
46
  --err-text: #d62222;
56
47
  --red-text: #d62222;
57
48
  --amber-text: #97601b;
@@ -72,32 +63,18 @@
72
63
  --notice-warn-border: var(--amber);
73
64
  --notice-info-border: var(--info-blue);
74
65
  --send-blue: #f29718;
75
- --on-send-blue: #1a1a1a;
76
66
  --send-blue-hover: #e08a0d;
77
- --stop-red: #ef4444;
78
- --stop-red-hover: #dc2626;
79
67
  --brand-grad-a: #f29718;
80
68
  --brand-grad-b: #f07171;
69
+ --on-green: #ffffff;
70
+ --on-red: #ffffff;
81
71
  --on-amber: #ffffff;
82
- --search-active-fg: #1a1d26;
83
- --switch-knob: #ffffff;
84
- --bg-elev3: rgba(255, 255, 255, 0.06);
85
- --sunken-bg: rgba(0, 0, 0, 0.15);
86
- --glow-015: rgba(255, 255, 255, 0.015);
87
- --glow-025: rgba(255, 255, 255, 0.025);
88
- --glow-03: rgba(255, 255, 255, 0.03);
89
- --glow-04: rgba(255, 255, 255, 0.04);
90
- --glow-05: rgba(255, 255, 255, 0.05);
91
- --glow-12: rgba(255, 255, 255, 0.12);
92
- --glow-18: rgba(255, 255, 255, 0.18);
93
- --glow-22: rgba(255, 255, 255, 0.22);
94
- --glow-38: rgba(255, 255, 255, 0.38);
72
+ --on-send-blue: #1a1a1a;
73
+ --on-send-blue-hover: #1a1a1a;
74
+ --on-stop-red-hover: #ffffff;
95
75
  --control-fg: #6b7d8f;
96
76
  --control-bg: #f0f1f3;
97
77
  --control-border: #e0e1e3;
98
- --bg-image: none;
99
- --bg-image-dim: 0.78;
100
- --bg-image-blur: 0px;
101
78
  --wallpaper-panel-alpha: 100%;
102
79
  --topbar-bg: #f8f9fa;
103
80
  --statusbar-bg: #fcfcfc;
@@ -106,7 +83,6 @@
106
83
  --chip-bg: #f0f1f3;
107
84
  --msgs-bg: #fcfcfc;
108
85
  --inputbox-bg: #f0f1f3;
109
- --menu-bg: var(--bg-elev2);
110
86
  }
111
87
 
112
88
  /* ---- syntax highlighting (Ayu Light) ---- */
@@ -1240,12 +1240,6 @@
1240
1240
  color: #000000;
1241
1241
  }
1242
1242
 
1243
- /* 主操作按钮防白底白字:实底按钮前景走 --accent-contrast */
1244
- .btn.primary,
1245
- .cwd-choose-btn.primary {
1246
- color: var(--accent-contrast, #000000);
1247
- }
1248
-
1249
1243
  /* ========================================================
1250
1244
  字级输入流系统(Character-Level Inline Stream)
1251
1245
  --------------------------------------------------------
@@ -0,0 +1,112 @@
1
+ /* Shared flat statusbar controls; palette colors remain inherited. */
2
+ .statusbar .bar-item,
3
+ .statusbar .bar-item.chip,
4
+ .statusbar .chip {
5
+ height: 18px;
6
+ min-height: 18px;
7
+ padding: 0 4px;
8
+ font-size: 11px;
9
+ line-height: 18px;
10
+ gap: 3px;
11
+ color: var(--text-dim);
12
+ background: transparent;
13
+ border: 1px solid transparent;
14
+ border-radius: 2px;
15
+ box-shadow: none;
16
+ opacity: 1;
17
+ filter: none;
18
+ text-shadow: none;
19
+ cursor: pointer;
20
+ transform: none;
21
+ }
22
+ .statusbar .bar-item:hover,
23
+ .statusbar .bar-item.chip:hover,
24
+ .statusbar .chip:hover {
25
+ background: var(--glow-12);
26
+ color: var(--text);
27
+ border-color: transparent;
28
+ border-radius: 2px;
29
+ box-shadow: none;
30
+ opacity: 1;
31
+ filter: none;
32
+ text-shadow: none;
33
+ transform: none;
34
+ }
35
+ .statusbar .bar-item.active,
36
+ .statusbar .bar-item.chip.active,
37
+ .statusbar .chip.active {
38
+ background: var(--bg-elev2);
39
+ color: var(--text);
40
+ }
41
+ .statusbar .bar-item-text {
42
+ font-size: 11px;
43
+ line-height: 1.2;
44
+ color: inherit;
45
+ opacity: 1;
46
+ text-shadow: none;
47
+ }
48
+ .statusbar .bar-item-char {
49
+ font-size: 11px;
50
+ line-height: 1;
51
+ font-weight: 600;
52
+ color: var(--text-faint);
53
+ opacity: 0.85;
54
+ text-shadow: none;
55
+ }
56
+ .statusbar .bar-item.status-cost {
57
+ gap: 0;
58
+ }
59
+ .statusbar .bar-item-icon {
60
+ font-size: 11px;
61
+ width: 11px;
62
+ height: 11px;
63
+ min-width: 11px;
64
+ opacity: 0.75;
65
+ color: inherit;
66
+ filter: none;
67
+ text-shadow: none;
68
+ }
69
+ .statusbar .bar-item:hover .bar-item-icon {
70
+ opacity: 1;
71
+ color: inherit;
72
+ filter: none;
73
+ }
74
+ .statusbar .bar-item-icon svg,
75
+ .statusbar .bar-item-glyph {
76
+ width: 11px;
77
+ height: 11px;
78
+ color: inherit;
79
+ stroke: currentColor;
80
+ filter: none;
81
+ text-shadow: none;
82
+ }
83
+ .statusbar .bar-item-badge {
84
+ background: none;
85
+ color: var(--accent);
86
+ font-size: 10px;
87
+ font-weight: 700;
88
+ min-width: 0;
89
+ height: auto;
90
+ padding: 0;
91
+ margin-left: 0;
92
+ border-radius: 0;
93
+ opacity: 1;
94
+ text-shadow: none;
95
+ box-shadow: none;
96
+ }
97
+ .statusbar .engine-picker-btn {
98
+ background: transparent;
99
+ border: 1px solid transparent;
100
+ border-radius: 2px;
101
+ padding: 0 4px;
102
+ color: var(--text-dim);
103
+ box-shadow: none;
104
+ opacity: 1;
105
+ filter: none;
106
+ text-shadow: none;
107
+ }
108
+ .statusbar .engine-picker-btn:hover {
109
+ background: var(--glow-12);
110
+ border-color: transparent;
111
+ color: var(--text);
112
+ }
@@ -452,6 +452,7 @@ div.chead[role="button"]:hover,
452
452
 
453
453
  .btn.send:hover {
454
454
  background: var(--send-blue-hover);
455
+ color: var(--on-send-blue-hover);
455
456
  }
456
457
 
457
458
  .btn.stop {
@@ -424,6 +424,7 @@ div.chead[role="button"]:hover,
424
424
 
425
425
  .btn.send:hover {
426
426
  background: var(--send-blue-hover);
427
+ color: var(--on-send-blue-hover);
427
428
  }
428
429
 
429
430
  .btn.stop {