pi-web-ui 0.117.0 → 0.118.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 (512) hide show
  1. package/CHANGELOG.md +48 -2
  2. package/README.md +69 -138
  3. package/README.zh-CN.md +70 -179
  4. package/README.zh-TW.md +3 -1
  5. package/bin/device-hub-cli.mjs +147 -43
  6. package/bin/frp-manager.mjs +4 -80
  7. package/bin/hub-upgrade.mjs +561 -0
  8. package/bin/pi-device-hub.mjs +0 -1
  9. package/bin/pi-web-ui.mjs +56 -444
  10. package/deploy/nginx-subpath.conf +0 -33
  11. package/deploy/pi-web-ui.service +0 -20
  12. package/dist/server/agent-formatters.js +4 -38
  13. package/dist/server/agent-service-daemon.js +160 -374
  14. package/dist/server/agent-service.js +875 -2978
  15. package/dist/server/approval-audit.js +2 -23
  16. package/dist/server/approval-default-rules.js +0 -6
  17. package/dist/server/approval-rules.js +7 -105
  18. package/dist/server/ask-user-question-tool.js +1 -12
  19. package/dist/server/atomic-file.js +33 -5
  20. package/dist/server/attachment-store.js +0 -36
  21. package/dist/server/attachments.js +3 -112
  22. package/dist/server/auth-cookie.js +0 -21
  23. package/dist/server/bash-tool.js +1 -32
  24. package/dist/server/bg-servers.js +0 -96
  25. package/dist/server/browser-page-tool.js +11 -62
  26. package/dist/server/builtin-modules.js +7 -0
  27. package/dist/server/canvas/canvas-agent-tool.js +58 -47
  28. package/dist/server/canvas/canvas-cards.js +0 -14
  29. package/dist/server/canvas/canvas-dispatch.js +7 -4
  30. package/dist/server/canvas/canvas-orchestrator.js +167 -181
  31. package/dist/server/canvas/canvas-runtime-messages.js +30 -0
  32. package/dist/server/canvas/canvas-scheduled-task.js +0 -3
  33. package/dist/server/canvas/canvas-scheduler.js +5 -7
  34. package/dist/server/canvas/canvas-store.js +24 -35
  35. package/dist/server/canvas/canvas-validation.js +17 -14
  36. package/dist/server/canvas/canvas-workspace.js +26 -30
  37. package/dist/server/canvas/pstack-skills-data.js +0 -5
  38. package/dist/server/claim-files-tool.js +1 -15
  39. package/dist/server/claim-store.js +5 -49
  40. package/dist/server/client-id-utils.js +0 -16
  41. package/dist/server/client-state.js +6 -213
  42. package/dist/server/communicate-tool.js +0 -3
  43. package/dist/server/compact-context-tool.js +0 -30
  44. package/dist/server/compacted-history.js +0 -35
  45. package/dist/server/compaction-instructions.js +0 -13
  46. package/dist/server/compaction-markers.js +3 -76
  47. package/dist/server/compaction-state.js +0 -21
  48. package/dist/server/composer-drafts.js +0 -34
  49. package/dist/server/context-budget-runner.js +0 -11
  50. package/dist/server/context-budget.js +1 -70
  51. package/dist/server/context-evidence.js +0 -14
  52. package/dist/server/context-usage.js +0 -12
  53. package/dist/server/control-socket.js +4 -48
  54. package/dist/server/conversation-communication.js +0 -10
  55. package/dist/server/conversation-identity.js +0 -1
  56. package/dist/server/conversation-read-tool.js +0 -58
  57. package/dist/server/conversation-tool-names.js +0 -1
  58. package/dist/server/conversation-tool.js +0 -1
  59. package/dist/server/conversation-touches.js +4 -75
  60. package/dist/server/dangling-tools.js +0 -82
  61. package/dist/server/delegate-mode.js +0 -36
  62. package/dist/server/delegate-task.js +2 -28
  63. package/dist/server/device-center/approval-summary.js +0 -1
  64. package/dist/server/device-center/bot-catalog.js +0 -3
  65. package/dist/server/device-center/bot-execution.js +0 -8
  66. package/dist/server/device-center/bot-presets.js +0 -1
  67. package/dist/server/device-center/bots.js +0 -1
  68. package/dist/server/device-center/collab-service.js +1 -3
  69. package/dist/server/device-center/collab-tool.js +0 -10
  70. package/dist/server/device-center/connector.js +21 -11
  71. package/dist/server/device-center/delivery-authority.js +0 -3
  72. package/dist/server/device-center/delivery-subject.js +0 -1
  73. package/dist/server/device-center/desktop-linux.js +3 -15
  74. package/dist/server/device-center/desktop-native.js +1 -10
  75. package/dist/server/device-center/desktop-page.js +2 -3
  76. package/dist/server/device-center/desktop-setup.js +1 -3
  77. package/dist/server/device-center/desktop.js +1 -7
  78. package/dist/server/device-center/device-integration.js +1 -27
  79. package/dist/server/device-center/device-lan-access.js +403 -0
  80. package/dist/server/device-center/device-lan.js +484 -0
  81. package/dist/server/device-center/device-portals.js +0 -3
  82. package/dist/server/device-center/execution-failure.js +0 -2
  83. package/dist/server/device-center/execution-guides.js +0 -1
  84. package/dist/server/device-center/execution-instructions.js +0 -1
  85. package/dist/server/device-center/execution-settings.js +0 -1
  86. package/dist/server/device-center/execution-system-prompt.js +0 -3
  87. package/dist/server/device-center/execution-workspace.js +1 -4
  88. package/dist/server/device-center/executor.js +0 -27
  89. package/dist/server/device-center/file-sync-paths.js +0 -5
  90. package/dist/server/device-center/file-sync.js +0 -10
  91. package/dist/server/device-center/group-context-delta.js +0 -8
  92. package/dist/server/device-center/group-context-message.js +0 -14
  93. package/dist/server/device-center/group-context.js +0 -19
  94. package/dist/server/device-center/group-events.js +0 -2
  95. package/dist/server/device-center/group-plan-guard.js +1 -35
  96. package/dist/server/device-center/group-router-runtime.js +182 -0
  97. package/dist/server/device-center/group-router-worker.js +178 -0
  98. package/dist/server/device-center/group-router.js +359 -0
  99. package/dist/server/device-center/hub-auth.js +24 -2
  100. package/dist/server/device-center/hub-conversations.js +0 -12
  101. package/dist/server/device-center/hub-deliveries.js +0 -1
  102. package/dist/server/device-center/hub-integration.js +0 -8
  103. package/dist/server/device-center/hub-locks.js +1 -5
  104. package/dist/server/device-center/hub-mobile.js +147 -0
  105. package/dist/server/device-center/hub-orchestration.js +400 -0
  106. package/dist/server/device-center/hub-page.js +25 -7
  107. package/dist/server/device-center/hub-setup.js +0 -6
  108. package/dist/server/device-center/hub-transaction-log.js +0 -22
  109. package/dist/server/device-center/hub-upgrade.js +162 -0
  110. package/dist/server/device-center/hub-webhooks.js +1 -3
  111. package/dist/server/device-center/hub.js +210 -86
  112. package/dist/server/device-center/human-interaction.js +1 -4
  113. package/dist/server/device-center/integration-errors.js +0 -2
  114. package/dist/server/device-center/integration-verification.js +0 -2
  115. package/dist/server/device-center/local-hub.js +0 -2
  116. package/dist/server/device-center/local-publication.js +1 -8
  117. package/dist/server/device-center/local-verification-job.js +0 -2
  118. package/dist/server/device-center/local-verification.js +0 -1
  119. package/dist/server/device-center/local.js +267 -39
  120. package/dist/server/device-center/main.js +14 -1
  121. package/dist/server/device-center/mobile-notification-forwarder.js +292 -0
  122. package/dist/server/device-center/native-desktop/macos.js +0 -1
  123. package/dist/server/device-center/native-desktop/windows.js +0 -1
  124. package/dist/server/device-center/partition-log.js +0 -31
  125. package/dist/server/device-center/path-portal.js +42 -12
  126. package/dist/server/device-center/publication-journal.js +0 -7
  127. package/dist/server/device-center/publish-intent.js +0 -5
  128. package/dist/server/device-center/relay.js +85 -30
  129. package/dist/server/device-center/report-upload.js +0 -1
  130. package/dist/server/device-center/runtime.js +1 -18
  131. package/dist/server/device-center/store.js +13 -33
  132. package/dist/server/device-center/task-context-budget.js +0 -3
  133. package/dist/server/device-center/task-error.js +0 -1
  134. package/dist/server/device-center/task-journal.js +6 -23
  135. package/dist/server/device-center/task-outcome.js +0 -13
  136. package/dist/server/device-center/task-plan.js +0 -1
  137. package/dist/server/device-center/task-progress.js +0 -16
  138. package/dist/server/device-center/task-recovery.js +5 -88
  139. package/dist/server/device-center/task-report-outbox.js +0 -4
  140. package/dist/server/device-center/task-report.js +2 -10
  141. package/dist/server/device-center/task-scheduler.js +1 -35
  142. package/dist/server/device-center/task-settlement.js +0 -18
  143. package/dist/server/device-center/task-state.js +0 -12
  144. package/dist/server/device-center/task-workspace.js +0 -50
  145. package/dist/server/device-center/transfer-stream.js +5 -45
  146. package/dist/server/device-center/transfers.js +2 -10
  147. package/dist/server/device-center/verification-limits.js +0 -1
  148. package/dist/server/device-center/work-contract.js +1 -73
  149. package/dist/server/device-center/work-items.js +317 -0
  150. package/dist/server/device-center/workspaces.js +0 -1
  151. package/dist/server/dispatch-domain-handlers.js +190 -32
  152. package/dist/server/dispatch-plugin-handlers.js +2 -19
  153. package/dist/server/dsh/dsh-agent-service.js +69 -599
  154. package/dist/server/dsh/dsh-client.js +7 -111
  155. package/dist/server/dsh/dsh-market-service.js +4 -25
  156. package/dist/server/dsh/dsh-serialize.js +0 -49
  157. package/dist/server/dsh/dsh-sessions.js +0 -37
  158. package/dist/server/dsh/dsh-usage.js +0 -37
  159. package/dist/server/dsh/preset-clones.js +1 -65
  160. package/dist/server/dsh/runtime/custom-prompt.mjs +0 -14
  161. package/dist/server/dsh/runtime/goal-rpc.mjs +7 -176
  162. package/dist/server/dsh/runtime/launcher.mjs +2 -53
  163. package/dist/server/dsh/runtime/override.patch.yml +0 -29
  164. package/dist/server/dsh/runtime/runtime-root.mjs +0 -54
  165. package/dist/server/durable/durable-agent-service.js +5 -23
  166. package/dist/server/durable/durable-driver.js +12 -73
  167. package/dist/server/durable/durable-event-projector.js +1 -50
  168. package/dist/server/durable/durable-loader.js +0 -12
  169. package/dist/server/durable/durable-models.js +11 -80
  170. package/dist/server/durable/durable-storage.js +1 -17
  171. package/dist/server/durable/durable-tools.js +2 -20
  172. package/dist/server/durable/index.js +0 -3
  173. package/dist/server/edit-soft-tool.js +2 -81
  174. package/dist/server/engine-capabilities.js +0 -13
  175. package/dist/server/engine-catalog.js +74 -0
  176. package/dist/server/engine-cli.js +89 -0
  177. package/dist/server/engine-probe.js +35 -217
  178. package/dist/server/ensure-bash.js +2 -28
  179. package/dist/server/eval-tool.js +1 -50
  180. package/dist/server/evidence-tool-hooks.js +0 -2
  181. package/dist/server/file-archives.js +0 -10
  182. package/dist/server/file-save.js +1 -12
  183. package/dist/server/file-transfer-routes.js +0 -11
  184. package/dist/server/files-service.js +18 -271
  185. package/dist/server/global-loader.js +9 -89
  186. package/dist/server/goal-evidence.js +1 -35
  187. package/dist/server/goal-review-gate.js +0 -58
  188. package/dist/server/goal-service.js +19 -422
  189. package/dist/server/hashline-engine.js +8 -112
  190. package/dist/server/host-guard.js +0 -24
  191. package/dist/server/host-metrics.js +0 -6
  192. package/dist/server/http-proxy.js +1 -7
  193. package/dist/server/i18n.js +5 -72
  194. package/dist/server/icon-svg.js +0 -15
  195. package/dist/server/index.js +177 -680
  196. package/dist/server/json-utils.js +0 -12
  197. package/dist/server/launch-origin.js +0 -44
  198. package/dist/server/left-panel-running.js +0 -9
  199. package/dist/server/load-timing.js +1 -4
  200. package/dist/server/load-tools-tool.js +0 -20
  201. package/dist/server/locales.js +1 -46
  202. package/dist/server/lsp-tool.js +13 -126
  203. package/dist/server/managed.js +0 -48
  204. package/dist/server/marker-service.js +1 -22
  205. package/dist/server/markers/builtins/action.js +0 -19
  206. package/dist/server/markers/builtins/notify.js +1 -9
  207. package/dist/server/markers/builtins/rename.js +0 -13
  208. package/dist/server/markers/index.js +0 -3
  209. package/dist/server/markers/marker.js +0 -13
  210. package/dist/server/markers/registry.js +0 -3
  211. package/dist/server/markers/store.js +1 -12
  212. package/dist/server/market-service.js +7 -43
  213. package/dist/server/mcp-agent-tool.js +0 -10
  214. package/dist/server/mcp-bridge.js +6 -138
  215. package/dist/server/mcp-hot-reload.js +0 -25
  216. package/dist/server/mcp-manager.js +2 -44
  217. package/dist/server/mcp-oauth-login.js +0 -2
  218. package/dist/server/mcp-oauth-ui.js +1 -4
  219. package/dist/server/mcp-oauth.js +5 -79
  220. package/dist/server/mcp-project-runtime.js +0 -4
  221. package/dist/server/message-deletion.js +0 -2
  222. package/dist/server/message-entry-resolver.js +0 -8
  223. package/dist/server/message-window.js +0 -71
  224. package/dist/server/mobile-notification-events.js +16 -0
  225. package/dist/server/mobile-origin.js +79 -0
  226. package/dist/server/mobile-push.js +523 -0
  227. package/dist/server/model-admin.js +19 -358
  228. package/dist/server/model-enrich.js +0 -19
  229. package/dist/server/model-resolver.js +2 -61
  230. package/dist/server/native-cli-discovery.js +115 -0
  231. package/dist/server/native-cli-model.js +71 -0
  232. package/dist/server/native-cli-references.js +214 -0
  233. package/dist/server/native-cli-remote-cleanup.js +58 -0
  234. package/dist/server/native-cli-remote-files.js +282 -0
  235. package/dist/server/native-cli-routes.js +68 -0
  236. package/dist/server/native-cli-runtime.js +1 -0
  237. package/dist/server/native-cli-session-hooks.js +170 -0
  238. package/dist/server/native-cli-session.js +585 -0
  239. package/dist/server/native-cli-state.js +82 -0
  240. package/dist/server/native-cli.js +210 -0
  241. package/dist/server/net-guard.js +9 -71
  242. package/dist/server/office-parse.js +0 -50
  243. package/dist/server/orphan-manager.js +0 -18
  244. package/dist/server/patch-bash-process.js +0 -4
  245. package/dist/server/patch-executable-lookup.js +0 -77
  246. package/dist/server/patch-node-pty.js +3 -43
  247. package/dist/server/patch-remote-catalog.js +1 -32
  248. package/dist/server/patch-tool.js +0 -15
  249. package/dist/server/payload-limits.js +0 -5
  250. package/dist/server/pending-question.js +0 -5
  251. package/dist/server/permission-preset.js +4 -33
  252. package/dist/server/persona-chain.js +0 -26
  253. package/dist/server/pkg-info.js +1 -17
  254. package/dist/server/plan-manager.js +2 -49
  255. package/dist/server/plan-mode.js +0 -97
  256. package/dist/server/plan-update-tool.js +1 -15
  257. package/dist/server/plugin-api-catalog.js +6 -4
  258. package/dist/server/plugin-assets.js +1 -35
  259. package/dist/server/plugin-bundled.js +68 -0
  260. package/dist/server/plugin-catalog-sync.js +0 -37
  261. package/dist/server/plugin-catalog.js +13 -67
  262. package/dist/server/plugin-chat-attachments.js +0 -1
  263. package/dist/server/plugin-conversation-view.js +0 -20
  264. package/dist/server/plugin-dom.js +1 -23
  265. package/dist/server/plugin-facilities.js +4 -115
  266. package/dist/server/plugin-grants.js +2 -90
  267. package/dist/server/plugin-install-spec.js +0 -43
  268. package/dist/server/plugin-installer.js +34 -75
  269. package/dist/server/plugin-llm.js +4 -38
  270. package/dist/server/plugin-manifest-validate.js +0 -31
  271. package/dist/server/plugin-permissions.js +1 -24
  272. package/dist/server/plugin-project.js +7 -129
  273. package/dist/server/plugin-removal.js +1 -8
  274. package/dist/server/plugin-schedule.js +1 -38
  275. package/dist/server/plugin-secrets.js +3 -16
  276. package/dist/server/plugin-tool-guard.js +1 -28
  277. package/dist/server/plugin-ui-slots.js +0 -4
  278. package/dist/server/plugin-updater.js +15 -90
  279. package/dist/server/plugins.js +71 -619
  280. package/dist/server/present-files-tool.js +0 -57
  281. package/dist/server/preset-fields.js +9 -62
  282. package/dist/server/preset-plugin-dependencies.js +0 -2
  283. package/dist/server/preset-share.js +3 -172
  284. package/dist/server/process-utils.js +4 -80
  285. package/dist/server/prompt-assembler.js +2 -30
  286. package/dist/server/prompt-base-store.js +0 -47
  287. package/dist/server/prompt-composer.js +21 -98
  288. package/dist/server/prompt-templates.js +0 -2
  289. package/dist/server/protocol-version.js +1 -11
  290. package/dist/server/protocol.js +0 -5
  291. package/dist/server/queue-modes.js +0 -3
  292. package/dist/server/queue-utils.js +0 -40
  293. package/dist/server/quick-ask-context.js +384 -0
  294. package/dist/server/quick-ask-settings.js +34 -1
  295. package/dist/server/quick-ask.js +123 -27
  296. package/dist/server/read-tool.js +0 -65
  297. package/dist/server/reasoning-registry.js +1 -29
  298. package/dist/server/remote-cli-persistence.js +373 -0
  299. package/dist/server/remote-native-cli.js +78 -0
  300. package/dist/server/remote-ssh-service.js +481 -190
  301. package/dist/server/request-context.js +0 -9
  302. package/dist/server/resolve-global-sdk.js +0 -26
  303. package/dist/server/sandbox-data.js +0 -1
  304. package/dist/server/sandbox-engines.js +0 -1
  305. package/dist/server/sandbox-runtime-gate.js +0 -3
  306. package/dist/server/sandbox-service.js +0 -41
  307. package/dist/server/sandbox-tool.js +0 -20
  308. package/dist/server/schedule-agent-tool.js +2 -31
  309. package/dist/server/scheduler-tasks.js +3 -54
  310. package/dist/server/scm-commitmsg.js +0 -53
  311. package/dist/server/scm.js +3 -48
  312. package/dist/server/sdk-builtin-extensions.js +2 -29
  313. package/dist/server/sdk-origin.js +0 -45
  314. package/dist/server/serialize.js +2 -92
  315. package/dist/server/server-config.js +0 -11
  316. package/dist/server/session-branch.js +1 -87
  317. package/dist/server/session-list-scan.js +17 -25
  318. package/dist/server/session-open.js +2 -26
  319. package/dist/server/session-parser.js +1 -55
  320. package/dist/server/session-scan.js +1 -17
  321. package/dist/server/session-search.js +0 -56
  322. package/dist/server/settings-service.js +11 -126
  323. package/dist/server/setup-config.js +0 -2
  324. package/dist/server/setup-page.js +0 -9
  325. package/dist/server/skill-content-filler.js +0 -17
  326. package/dist/server/skill-discovery.js +5 -92
  327. package/dist/server/skill-maintenance.js +1 -28
  328. package/dist/server/skill-tool.js +0 -30
  329. package/dist/server/slash-commands.js +5 -50
  330. package/dist/server/soft-cap.js +0 -42
  331. package/dist/server/startup-banner.js +0 -8
  332. package/dist/server/subagent-handoff.js +0 -11
  333. package/dist/server/subagent-helpers.js +2 -17
  334. package/dist/server/subagent-notify.js +0 -19
  335. package/dist/server/subagent-security-gate.js +0 -50
  336. package/dist/server/subagent-task.js +0 -9
  337. package/dist/server/subagent-templates-hant.js +0 -10
  338. package/dist/server/subagent-templates.js +3 -103
  339. package/dist/server/subagents.js +1 -87
  340. package/dist/server/system-screenshot-windows.js +259 -0
  341. package/dist/server/system-screenshot.js +77 -0
  342. package/dist/server/tabs.js +3 -48
  343. package/dist/server/terminals.js +559 -586
  344. package/dist/server/text-quote.js +0 -12
  345. package/dist/server/text-sniff.js +2 -52
  346. package/dist/server/themes.js +2 -41
  347. package/dist/server/tool-approval.js +0 -47
  348. package/dist/server/tool-guards.js +0 -90
  349. package/dist/server/tool-host-factories.js +1 -16
  350. package/dist/server/tool-info.js +0 -13
  351. package/dist/server/tool-manager.js +1 -229
  352. package/dist/server/tool-overrides.js +1 -46
  353. package/dist/server/tool-prompt-overrides.js +1 -30
  354. package/dist/server/tool-prompts.js +0 -14
  355. package/dist/server/tool-signature.js +0 -25
  356. package/dist/server/transcript-prepare.js +1 -19
  357. package/dist/server/tts-routes.js +58 -0
  358. package/dist/server/tts-service.js +106 -0
  359. package/dist/server/tts-system.js +160 -0
  360. package/dist/server/turn-timing.js +0 -1
  361. package/dist/server/unauthorized-page.js +0 -8
  362. package/dist/server/universal/driver-base.js +2 -31
  363. package/dist/server/universal/drivers/claude-code.js +12 -172
  364. package/dist/server/universal/drivers/codex.js +12 -35
  365. package/dist/server/universal/drivers/mock-driver.js +1 -11
  366. package/dist/server/universal/index.js +0 -3
  367. package/dist/server/universal/session-store.js +4 -21
  368. package/dist/server/universal/universal-attachments.js +2 -36
  369. package/dist/server/universal/universal-service.js +5 -24
  370. package/dist/server/universal/universal-session.js +26 -148
  371. package/dist/server/universal/universal-types.js +0 -3
  372. package/dist/server/update-check.js +6 -182
  373. package/dist/server/uploads.js +4 -43
  374. package/dist/server/virtual-tui.js +2 -27
  375. package/dist/server/vision-bridge.js +0 -27
  376. package/dist/server/wait-subscription-scan.js +13 -115
  377. package/dist/server/webui-context.js +2 -87
  378. package/dist/server/workspace-handle.js +1 -56
  379. package/dist/server/workspace-snapshot.js +7 -113
  380. package/dist/server/worktree-service.js +2 -53
  381. package/dist/server/worktree-tool.js +0 -11
  382. package/dist/server/ws-client-id.js +0 -18
  383. package/dist/server/ws-pending-queue.js +0 -7
  384. package/dist/server/ws-unknown-types.js +0 -17
  385. package/docs/README.md +24 -17
  386. package/docs/architecture-plugins.md +37 -1
  387. package/docs/device-center.md +28 -2
  388. package/docs/device-desktop.md +3 -3
  389. package/docs/group-orchestration.md +142 -0
  390. package/docs/hub-upgrade-release-testing.md +46 -0
  391. package/extensions/webui.ts +3 -74
  392. package/package.json +7 -3
  393. package/plugin-sdk/README.md +6 -0
  394. package/plugin-sdk/client-utils.mjs +0 -7
  395. package/plugin-sdk/client.d.ts +0 -1
  396. package/plugin-sdk/client.mjs +1 -31
  397. package/plugin-sdk/import-check.mjs +4 -51
  398. package/plugin-sdk/index.d.ts +120 -119
  399. package/plugin-sdk/index.mjs +0 -6
  400. package/plugin-sdk/ssh-host-trust.mjs +0 -12
  401. package/plugin-sdk/testing.d.ts +0 -1
  402. package/plugin-sdk/testing.mjs +31 -86
  403. package/plugins/catalog.json +52 -4
  404. package/plugins/superagent/README.md +110 -0
  405. package/plugins/superagent/client/entry.mjs +21 -0
  406. package/plugins/superagent/index.mjs +8 -0
  407. package/plugins/superagent/main.mjs +218 -0
  408. package/plugins/superagent/manifest.json +15 -0
  409. package/plugins/superagent/server.mjs +572 -0
  410. package/plugins/superagent/style.css +167 -0
  411. package/themes/aetheris.css +1 -31
  412. package/themes/ayu-light.css +0 -1
  413. package/themes/bases/flow-base.css +2 -83
  414. package/themes/bases/obsidian-base.css +2 -37
  415. package/themes/bases/statusbar-flat-base.css +0 -1
  416. package/themes/bases/zhujian-base.css +0 -63
  417. package/themes/bases/zhupi-base.css +0 -64
  418. package/themes/catppuccin-latte.css +0 -1
  419. package/themes/catppuccin.css +0 -1
  420. package/themes/claude-code-dark.css +0 -1
  421. package/themes/codex.css +0 -1
  422. package/themes/dark-teal.css +22 -54
  423. package/themes/everforest-light.css +0 -1
  424. package/themes/flow-cristallo.css +1 -9
  425. package/themes/flow-ink.css +1 -10
  426. package/themes/flow-light.css +1 -10
  427. package/themes/flow-obsidian.css +1 -10
  428. package/themes/flow-zurich.css +1 -10
  429. package/themes/flow.css +1 -9
  430. package/themes/geist.css +0 -1
  431. package/themes/gruvbox-light.css +0 -1
  432. package/themes/kanagawa-lotus.css +0 -1
  433. package/themes/md-preview.css +1 -2
  434. package/themes/mist.css +0 -1
  435. package/themes/nord.css +0 -1
  436. package/themes/one-dark.css +0 -1
  437. package/themes/paper.css +0 -1
  438. package/themes/rose-pine-dawn.css +0 -1
  439. package/themes/sakura.css +0 -1
  440. package/themes/solarized-light.css +0 -1
  441. package/themes/tokyo-night.css +0 -1
  442. package/themes/translucent.css +4 -35
  443. package/themes/transparent.css +4 -41
  444. package/themes/vs-code-dark.css +0 -1
  445. package/themes/wallpaper-flow.css +3 -17
  446. package/themes/wallpaper-obsidian.css +1 -4
  447. package/themes/white.css +0 -1
  448. package/web/dist/.build-assets.json +1 -1
  449. package/web/dist/assets/{BgTasksModal-BjNRIUIc.js → BgTasksModal-D-x7kA63.js} +1 -1
  450. package/web/dist/assets/CanvasStudio-CAWcs9tm.js +1579 -0
  451. package/web/dist/assets/DeviceCenter-Dc0whRcu.js +3 -0
  452. package/web/dist/assets/DeviceExecutionSettings-BoX7-0h7.js +1 -0
  453. package/web/dist/assets/DeviceGroups-C_fZMNeK.js +1 -0
  454. package/web/dist/assets/{Dropdown-CQtstPGv.js → Dropdown-CTgVLUbp.js} +1 -1
  455. package/web/dist/assets/FilePreview-C6W0PvaK.js +2 -0
  456. package/web/dist/assets/GlobalSearchModal-HR9LSspC.js +1 -0
  457. package/web/dist/assets/GroupConversation-C81YjF2C.js +61 -0
  458. package/web/dist/assets/GroupWorkItems-BIvZtr10.js +1 -0
  459. package/web/dist/assets/{HintTip-ChTW8o1m.js → HintTip-Da6qc566.js} +1 -1
  460. package/web/dist/assets/ModelConfigModal-DhSyuIuV.js +2 -0
  461. package/web/dist/assets/NativeCliPanel-CU1rZmyu.js +5 -0
  462. package/web/dist/assets/{PiSetupModal-BX5rUuoI.js → PiSetupModal-DZKY5Wiw.js} +1 -1
  463. package/web/dist/assets/ProviderOAuthControls-CIL85nA7.js +1 -0
  464. package/web/dist/assets/{SCMPanel-DPAyY2sW.js → SCMPanel-CuEgzAlO.js} +2 -2
  465. package/web/dist/assets/SettingsModal-Cdu5h29p.js +33 -0
  466. package/web/dist/assets/TermXterm-Bt5WKAxP.js +3 -0
  467. package/web/dist/assets/TerminalPanel-BCIBV8se.js +1 -0
  468. package/web/dist/assets/TuiOverlayModal-3NDd9T97.js +1 -0
  469. package/web/dist/assets/app-globals-CZjFtI4F.js +129 -0
  470. package/web/dist/assets/canvas-client-WkhM55mR.js +1 -0
  471. package/web/dist/assets/composer-bridge-CImnjDHq.js +1 -0
  472. package/web/dist/assets/desktop-B8NZ3KW-.js +1 -0
  473. package/web/dist/assets/index-CQc3VrWa.css +1 -0
  474. package/web/dist/assets/index-D_AGu4Zv.js +404 -0
  475. package/web/dist/assets/plugin-host-uqZGpvCs.js +1 -0
  476. package/web/dist/assets/{remote-ssh-client-Dzi-eEyE.js → remote-ssh-client-Cdf-cTUe.js} +1 -1
  477. package/web/dist/assets/theme-DGL7hLUs.js +1 -0
  478. package/web/dist/index.html +11 -10
  479. package/web/dist/sw.js +15 -61
  480. package/web/public/sw.js +14 -60
  481. package/web/dist/assets/BgTasksModal-C0zuU8FE.js +0 -1
  482. package/web/dist/assets/CanvasStudio-BWvdmJ0M.js +0 -1579
  483. package/web/dist/assets/CanvasStudio-VQFjmTGq.js +0 -1579
  484. package/web/dist/assets/DeviceCenter-DI9_0aBB.js +0 -3
  485. package/web/dist/assets/DeviceCenter-DsNtXqzY.js +0 -3
  486. package/web/dist/assets/DeviceExecutionSettings-BLP1Su5G.js +0 -1
  487. package/web/dist/assets/DeviceGroups-2Pvk0Cds.js +0 -1
  488. package/web/dist/assets/DeviceGroups-CP7CcyPD.js +0 -1
  489. package/web/dist/assets/FilePreview-BMB2tNyT.js +0 -2
  490. package/web/dist/assets/FilePreview-RGFQUbJo.js +0 -2
  491. package/web/dist/assets/GlobalSearchModal-BM5wxiqU.js +0 -1
  492. package/web/dist/assets/GlobalSearchModal-DGv_WINq.js +0 -1
  493. package/web/dist/assets/GroupConversation-B7SnuXj1.js +0 -61
  494. package/web/dist/assets/GroupConversation-Dda69q-2.js +0 -61
  495. package/web/dist/assets/ModelConfigModal-C-0Z4hUZ.js +0 -2
  496. package/web/dist/assets/ModelConfigModal-yqeadyab.js +0 -2
  497. package/web/dist/assets/ProviderOAuthControls-DY4SCfXg.js +0 -1
  498. package/web/dist/assets/SCMPanel-C4KbQvvK.js +0 -2
  499. package/web/dist/assets/SettingsModal-DxZp6D_g.js +0 -32
  500. package/web/dist/assets/SettingsModal-WhQzaOPt.js +0 -32
  501. package/web/dist/assets/TerminalPanel-D4By_RVc.js +0 -3
  502. package/web/dist/assets/TerminalPanel-lZw8-i3j.js +0 -3
  503. package/web/dist/assets/TuiOverlayModal-C3pAVuC8.js +0 -1
  504. package/web/dist/assets/TuiOverlayModal-D7_rEXcJ.js +0 -1
  505. package/web/dist/assets/app-globals-KqOVtmp1.js +0 -123
  506. package/web/dist/assets/canvas-client-BY6ojmle.js +0 -1
  507. package/web/dist/assets/desktop-CV6KKp9R.js +0 -1
  508. package/web/dist/assets/index-BawF7ZP5.js +0 -397
  509. package/web/dist/assets/index-BoGCoq5X.js +0 -397
  510. package/web/dist/assets/index-CVW9FoY2.css +0 -1
  511. package/web/dist/assets/plugin-host-Dn8Dd6SC.js +0 -1
  512. package/web/dist/assets/theme-D_bihpdN.js +0 -1
@@ -1,30 +1,3 @@
1
- /**
2
- * Fork-free executable lookup for Android/Termux.
3
- *
4
- * Background: on POSIX the SDK resolves host executables with `spawnSync("which", …)`
5
- * (`dist/utils/shell.js`) and probes availability with `spawnSync(cmd, ["--version"])`
6
- * (`dist/utils/tools-manager.js`). On Android/Termux forking a child process can stall
7
- * before it ever execs, so those probes never return and the first tool call hangs the
8
- * server instead of failing fast. Both are pure lookups, so this patch answers them from
9
- * PATH — no child process involved.
10
- *
11
- * The SDK sources are transformed in memory before compilation, never on disk (same seam
12
- * as `server/patch-bash-process.ts`). The patch therefore survives every
13
- * `npm i -g @earendil-works/pi-coding-agent` and applies to whichever copy
14
- * `resolve-global-sdk.ts` picks. Drop this module once the SDK resolves executables from
15
- * PATH itself.
16
- *
17
- * Two properties matter more than brevity here:
18
- *
19
- * 1. The replacement never relies on a binding that happens to exist in the SDK version
20
- * at hand — it carries its own imports (`PREAMBLE`). Otherwise a version whose module
21
- * header differs (SDK 1.1.0 has no `shellPathExists`) throws a ReferenceError that the
22
- * surrounding `catch` swallows, and the hook reports `patched` while shell discovery
23
- * silently falls back to `sh`.
24
- * 2. It keeps the *semantics* of executable lookup: an entry only counts when it is a
25
- * real file we may execute — not a directory and not an inert file. Existence alone
26
- * made `ensureTool` claim a tool it could not spawn (`ENOENT` right after).
27
- */
28
1
  import { registerHooks } from "node:module";
29
2
  export const SENTINEL = "// pi-web-ui #810: fork-free executable lookup v1";
30
3
  export const PREAMBLE_START = "/* pi-web-ui #810: fork-free executable lookup v1 (preamble) */";
@@ -33,11 +6,6 @@ const TARGETS = {
33
6
  shell: "/@earendil-works/pi-coding-agent/dist/utils/shell.js",
34
7
  "tools-manager": "/@earendil-works/pi-coding-agent/dist/utils/tools-manager.js",
35
8
  };
36
- /**
37
- * Self-contained definitions the replacement uses, injected ahead of the SDK source.
38
- * Aliased names cannot collide with the SDK's own imports, so this works for every
39
- * module header — including the shapes that predate `shellPathExists`.
40
- */
41
9
  export const PREAMBLE = `${PREAMBLE_START}
42
10
  import {
43
11
  accessSync as __piWebExecAccess,
@@ -75,7 +43,6 @@ function __piWebExecProgram(candidate) {
75
43
  }
76
44
  }
77
45
  ${PREAMBLE_END}`;
78
- /** SDK 1.4.0 shape: `which` child process in the POSIX branch of findExecutableOnPath. */
79
46
  const SHELL_LOOKUP_OLD = ` // Unix: Use 'which' and trust its output (handles Termux and special filesystems)
80
47
  try {
81
48
  const result = spawnSync("which", [executable], { encoding: "utf-8", timeout: 5000 });
@@ -89,7 +56,6 @@ const SHELL_LOOKUP_OLD = ` // Unix: Use 'which' and trust its output (handles
89
56
  catch {
90
57
  // Ignore errors
91
58
  }`;
92
- /** SDK 1.4.0 shape: `--version` child process probe in commandExists. */
93
59
  const TOOLS_LOOKUP_OLD = `function commandExists(cmd) {
94
60
  try {
95
61
  const result = spawnSync(cmd, ["--version"], { stdio: "pipe" });
@@ -132,7 +98,6 @@ const TOOLS_LOOKUP_NEW = `function commandExists(cmd) {
132
98
  return false;
133
99
  }
134
100
  }`;
135
- /** Which target a loaded module URL belongs to, or null when it is not ours to touch. */
136
101
  export function executableLookupTarget(url) {
137
102
  const normalized = url.replaceAll("\\\\", "/");
138
103
  for (const [target, suffix] of Object.entries(TARGETS)) {
@@ -145,11 +110,8 @@ const ANCHORS = {
145
110
  shell: "function findExecutableOnPath",
146
111
  "tools-manager": "function commandExists",
147
112
  };
148
- /** Any child process a lookup could still be forking through, however it is spelled. */
149
113
  const FORKING_CALL = /\b(?:spawnSync|execSync|execFileSync)\s*\(/;
150
- /** 在这些字符之后出现的 `/` 是正则字面量的开头,而不是除号。 */
151
114
  const REGEX_PREFIX_CHARS = new Set("(,=:[!&|?{};+-*%<>~^".split(""));
152
- /** 这些关键字之后同理(`return /…/` vs `a / b`)。 */
153
115
  const REGEX_PREFIX_WORDS = new Set([
154
116
  "return",
155
117
  "typeof",
@@ -166,7 +128,6 @@ const REGEX_PREFIX_WORDS = new Set([
166
128
  "yield",
167
129
  "await",
168
130
  ]);
169
- /** `/` 在这里是正则字面量而不是除号(只看前一个 token)。 */
170
131
  function isRegexStart(source, i) {
171
132
  let j = i - 1;
172
133
  while (j >= 0 && /\s/.test(source[j]))
@@ -182,13 +143,6 @@ function isRegexStart(source, i) {
182
143
  k--;
183
144
  return REGEX_PREFIX_WORDS.has(source.slice(k + 1, j + 1));
184
145
  }
185
- /**
186
- * `}` / `{` 在正则字面量里不是括号。不认正则的话,`/^}$/` 这种只带一个右花括号的
187
- * 字面量会把深度算错:接着那个嵌套块自己的 `}` 就被当成「函数结束」,于是后面的
188
- * `spawnSync` 落在被截断的 body 之外,已经打过叉的源码会被判成 `already` —— 正是
189
- * 上游改写后最危险的那种误判(Android 上依然会卡死,却不报警)。
190
- * 解析错方向的代价很低:误把代码当成字符串只会让 body 取不出来 → `unsupported`。
191
- */
192
146
  function skipRegex(source, i) {
193
147
  let inClass = false;
194
148
  for (let j = i + 1; j < source.length; j++) {
@@ -197,7 +151,6 @@ function skipRegex(source, i) {
197
151
  j++;
198
152
  continue;
199
153
  }
200
- // 正则字面量不跨行:跑到行尾说明这是个除号,交给调用方按代码处理。
201
154
  if (char === "\n")
202
155
  return null;
203
156
  if (inClass) {
@@ -212,7 +165,6 @@ function skipRegex(source, i) {
212
165
  }
213
166
  return null;
214
167
  }
215
- /** Index just past the comment or quoted literal starting at `i`, or null when it is code. */
216
168
  function skipNonCode(source, i) {
217
169
  const char = source[i];
218
170
  if (char === "/" && source[i + 1] === "/") {
@@ -236,10 +188,6 @@ function skipNonCode(source, i) {
236
188
  }
237
189
  return null;
238
190
  }
239
- /**
240
- * Body of the function starting at `anchor`, or null when it is not there.
241
- * Skips comments and string/template contents so braces inside them cannot unbalance it.
242
- */
243
191
  export function functionBody(source, anchor) {
244
192
  const start = source.indexOf(anchor);
245
193
  if (start < 0)
@@ -258,9 +206,6 @@ export function functionBody(source, anchor) {
258
206
  if (char === "{")
259
207
  depth++;
260
208
  else if (char === "}") {
261
- // Only a brace that ends the line can close the function. A `}` inside a regex
262
- // literal sits mid-statement, and treating it as the end would truncate the body —
263
- // hiding a child process that comes later and reporting the lookup as fixed.
264
209
  if (depth === 1) {
265
210
  if (isStatementEnd(source, i + 1))
266
211
  return source.slice(open, i + 1);
@@ -271,7 +216,6 @@ export function functionBody(source, anchor) {
271
216
  }
272
217
  return null;
273
218
  }
274
- /** Index of the `}` matching the `{` at `open`, or null when the block is unbalanced. */
275
219
  function bracedBlockEnd(source, open) {
276
220
  let depth = 0;
277
221
  for (let i = open; i < source.length; i++) {
@@ -287,12 +231,6 @@ function bracedBlockEnd(source, open) {
287
231
  }
288
232
  return null;
289
233
  }
290
- /**
291
- * What actually runs on POSIX: the body without the `if (process.platform === "win32")`
292
- * early return. The shell lookup keeps a `where` child process in that branch on every SDK
293
- * version, and it never runs on Android/Termux — counting it as a fork would report a
294
- * fork-free POSIX lookup as unrecognized and warn on every start.
295
- */
296
234
  export function posixPortion(body) {
297
235
  const guard = body.search(/if \(process\.platform === "win32"\)\s*\{/);
298
236
  if (guard < 0)
@@ -303,16 +241,9 @@ export function posixPortion(body) {
303
241
  return body;
304
242
  return body.slice(0, guard) + body.slice(close + 1).replace(/^\s*return null;\s*/, "");
305
243
  }
306
- /** Whitespace (and an optional `;`) up to the end of the line — a statement boundary. */
307
244
  function isStatementEnd(source, at) {
308
245
  return /^[ \t]*;?[ \t]*(?:\r?\n|$)/.test(source.slice(at, at + 8));
309
246
  }
310
- /**
311
- * A lookup counts as already fork-free only when that is positively identifiable:
312
- * the function is still there, it scans `process.env.PATH`, and it forks nothing.
313
- * Anything else — a reformatted probe, an unknown rewrite — stays `unsupported`, so an
314
- * unrecognized SDK never gets reported as fixed while the probe is still in the way.
315
- */
316
247
  function isForkFreeLookup(source, anchor) {
317
248
  const body = functionBody(source, anchor);
318
249
  if (body === null)
@@ -325,8 +256,6 @@ export function patchExecutableLookupSource(source, target) {
325
256
  return { code: source, status: "already" };
326
257
  const old = target === "shell" ? SHELL_LOOKUP_OLD : TOOLS_LOOKUP_OLD;
327
258
  const replacement = target === "shell" ? SHELL_LOOKUP_NEW : TOOLS_LOOKUP_NEW;
328
- // Exact, single occurrence: a moved or rewritten lookup must fail loudly, never
329
- // half-apply, because the alternative is a silently hanging server.
330
259
  if (source.split(old).length !== 2) {
331
260
  return { code: source, status: isForkFreeLookup(source, ANCHORS[target]) ? "already" : "unsupported" };
332
261
  }
@@ -335,7 +264,6 @@ export function patchExecutableLookupSource(source, target) {
335
264
  const LOG_PREFIX = "[executable-lookup]";
336
265
  const OPT_OUT = new Set(["off", "0", "false", "no"]);
337
266
  const OPT_IN = new Set(["on", "1", "true", "yes"]);
338
- /** Android/Termux only by default; `PI_WEB_EXEC_LOOKUP=off` opts out, `=on` forces. */
339
267
  export function shouldPatchExecutableLookup(platform = process.platform, env = process.env) {
340
268
  const flag = (env.PI_WEB_EXEC_LOOKUP ?? "").trim().toLowerCase();
341
269
  if (OPT_OUT.has(flag))
@@ -344,7 +272,6 @@ export function shouldPatchExecutableLookup(platform = process.platform, env = p
344
272
  return true;
345
273
  return platform === "android" || Boolean(env.TERMUX_VERSION);
346
274
  }
347
- /** Logged once per target, so every restart states whether the patch is really in place. */
348
275
  export function describeLookupResult(target, status, url) {
349
276
  if (status === "unsupported")
350
277
  return {
@@ -361,11 +288,9 @@ function report(target, status, url) {
361
288
  else
362
289
  console.log(message);
363
290
  }
364
- /** Only ES modules can take the preamble; everything else keeps the SDK's own lookup. */
365
291
  export function isPatchableFormat(format) {
366
292
  return format === "module" || format === "module-typescript";
367
293
  }
368
- /* SDK sources are transformed in memory before compilation, never on disk. */
369
294
  export function registerExecutableLookupPatch(platform = process.platform, env = process.env) {
370
295
  if (!shouldPatchExecutableLookup(platform, env))
371
296
  return;
@@ -380,8 +305,6 @@ export function registerExecutableLookupPatch(platform = process.platform, env =
380
305
  const loaded = nextLoad(url, context);
381
306
  if (loaded.source == null)
382
307
  return loaded;
383
- // The preamble is an ES module head; injecting it into CommonJS would break the
384
- // load instead of falling back to the lookup we were trying to improve.
385
308
  if (!isPatchableFormat(loaded.format)) {
386
309
  console.warn(`${LOG_PREFIX} ${target}: NOT patched — loaded as ${loaded.format ?? "an unknown format"}, ` +
387
310
  `the patch only rewrites ES modules (${url})`);
@@ -1,48 +1,16 @@
1
- /**
2
- * node-pty × Node `--watch` compatibility patches (dev-server noise).
3
- *
4
- * Node's `--watch` mode (the dev script runs `node --watch --import tsx`)
5
- * pushes `watch:require` / `watch:import` messages over the IPC channels of
6
- * spawned worker threads AND forked child processes to track module
7
- * dependencies. node-pty 1.1.0 does not recognize these and mishandles them in
8
- * two places:
9
- *
10
- * · windowsConoutConnection.js — logs every unknown worker message via
11
- * `console.warn`, producing hundreds of "Unexpected ConoutWorkerMessage"
12
- * lines per terminal (the SCM panel's hidden query PTY triggers it on every
13
- * git-view open).
14
- * · windowsPtyAgent.js — the kill path's `_getConsoleProcessList()` treats ANY
15
- * message from the forked console-list agent as its reply; a watch message
16
- * has no `consoleProcessList` property, so `message.consoleProcessList` is
17
- * undefined and the `.forEach` on it crashes the server.
18
- *
19
- * Both are benign protocol noise: the ConPTY worker only ever sends its READY
20
- * sentinel and the agent only sends `{ consoleProcessList }` — both of which
21
- * node-pty handles. These patches make node-pty ignore unrelated IPC traffic.
22
- *
23
- * IMPORTANT: this module MUST be imported before node-pty (see terminals.ts) —
24
- * it rewrites the installed copies on disk so the subsequently-compiled
25
- * node-pty modules contain the fixed handlers. Best-effort and idempotent
26
- * (checks before rewriting), mirroring the spawn-helper chmod self-heal; a
27
- * read-only node_modules or a different node-pty version just skips the patch
28
- * (the runtime console.warn filter in terminals.ts still guards the flood).
29
- */
30
1
  import { existsSync, readFileSync } from "node:fs";
31
2
  import { writeAtomicSync } from "./atomic-file.js";
32
3
  import { createRequire } from "node:module";
33
4
  import { dirname, join } from "node:path";
34
5
  const require = createRequire(import.meta.url);
35
- /** Absolute path of the installed node-pty package root, or null. */
36
6
  function ptyPackageDir() {
37
7
  try {
38
- // require.resolve("node-pty") → <pkg>/lib/index.js → package root is two up.
39
8
  return dirname(dirname(require.resolve("node-pty")));
40
9
  }
41
10
  catch {
42
11
  return null;
43
12
  }
44
13
  }
45
- /** Idempotently replace one code fragment in a node-pty source file. */
46
14
  function patchFile(pkgDir, rel, find, replace) {
47
15
  try {
48
16
  const file = join(pkgDir, rel);
@@ -50,24 +18,18 @@ function patchFile(pkgDir, rel, find, replace) {
50
18
  return;
51
19
  const src = readFileSync(file, "utf8");
52
20
  if (src.includes(replace))
53
- return; // already patched
21
+ return;
54
22
  if (!src.includes(find))
55
- return; // unexpected content — leave alone
23
+ return;
56
24
  writeAtomicSync(file, src.replace(find, replace));
57
25
  }
58
- catch {
59
- // best-effort — the runtime console.warn filter still guards the flood
60
- }
26
+ catch { }
61
27
  }
62
28
  function applyPatches() {
63
29
  const pkgDir = ptyPackageDir();
64
30
  if (!pkgDir)
65
31
  return;
66
- // 1. ConoutConnection: ignore unknown worker messages instead of warning.
67
32
  patchFile(pkgDir, "lib/windowsConoutConnection.js", "console.warn('Unexpected ConoutWorkerMessage', message);", "break; // pi-web-ui: ignore Node --watch worker messages");
68
- // 2. windowsPtyAgent kill path: only accept a real console-list reply
69
- // (watch messages arrive first on the fork channel and carry no
70
- // consoleProcessList — previously resolved undefined and crashed).
71
33
  patchFile(pkgDir, "lib/windowsPtyAgent.js", "agent.on('message', function (message) {\n clearTimeout(timeout);\n resolve(message.consoleProcessList);\n });", [
72
34
  " agent.on('message', function (message) {",
73
35
  " // pi-web-ui: ignore Node --watch messages on the fork channel",
@@ -77,8 +39,6 @@ function applyPatches() {
77
39
  " }",
78
40
  " });",
79
41
  ].join("\n"));
80
- // 3. conpty_console_list_agent: tolerate dead shell PID (AttachConsole failed)
81
- // when process already exited or was killed — return [] instead of crashing.
82
42
  patchFile(pkgDir, "lib/conpty_console_list_agent.js", "var consoleProcessList = getConsoleProcessList(shellPid);\nprocess.send({ consoleProcessList: consoleProcessList });\nprocess.exit(0);", [
83
43
  "try {",
84
44
  " var consoleProcessList = getConsoleProcessList(shellPid);",
@@ -1,38 +1,12 @@
1
- /**
2
- * Remote-catalog merge patch for @earendil-works/pi-coding-agent.
3
- *
4
- * The SDK composes each built-in provider's model list as
5
- * mergeModels(builtinStaticCatalog, pi.devRemoteCatalog)
6
- * which is a UNION: same-id entries get replaced by the newer pi.dev row, new
7
- * ids are appended, but stale built-in models are kept forever (and the UI
8
- * reports "新增 N 个模型" when the overlay grows).
9
- *
10
- * pi-web-ui wants the picker to mirror the OFFICIAL remote catalog exactly —
11
- * an "ensure latest, no merge, no 'new N' noise" behavior. This module rewrites
12
- * the installed copy of remote-catalog-provider.js so the remote overlay
13
- * REPLACES the built-in catalog entirely whenever pi.dev data is present:
14
- * getModels: () => (dynamicModels.length > 0 ? dynamicModels : provider.getModels())
15
- * (the built-in catalog only serves as fallback while no remote data has been
16
- * received yet, so the list can never be empty).
17
- *
18
- * Same pattern as patch-node-pty.ts: idempotent (checks before rewriting),
19
- * best-effort (a read-only node_modules or an SDK version whose source no
20
- * longer matches the search strings just skips the patch and keeps the SDK's
21
- * default union semantics — never a crash). MUST be imported before the SDK
22
- * modules are first loaded (agent-service.ts imports this first).
23
- */
24
1
  import { existsSync, readFileSync } from "node:fs";
25
2
  import { writeAtomicSync } from "./atomic-file.js";
26
3
  import { fileURLToPath } from "node:url";
27
4
  import { dirname, join } from "node:path";
28
- /** Supported patch pairs across SDK versions (0.87.x, 1.1.0+). */
29
5
  const PATCH_PAIRS = [
30
- // SDK 0.87.x
31
6
  {
32
7
  old: "getModels: () => mergeModels(provider.getModels(), dynamicModels),",
33
8
  new: "getModels: () => (dynamicModels.length > 0 ? dynamicModels : provider.getModels()),",
34
9
  },
35
- // SDK 1.1.0+ (typed model shards: chat, image, classifier)
36
10
  {
37
11
  old: 'getModels: () => mergeModels(provider.getModels(), dynamicModels.filter((model) => isModelType(model, "chat"))),',
38
12
  new: 'getModels: () => (dynamicModels.length > 0 ? dynamicModels.filter((model) => isModelType(model, "chat")) : provider.getModels()),',
@@ -42,11 +16,8 @@ const PATCH_PAIRS = [
42
16
  new: "getAllModels: () => (dynamicModels.length > 0 ? dynamicModels : (provider.getAllModels?.() ?? provider.getModels())),",
43
17
  },
44
18
  ];
45
- /** Absolute path of the installed remote-catalog-provider.js, or null. */
46
19
  function remoteCatalogFile() {
47
20
  try {
48
- // import.meta.resolve honors the package "exports" (import condition) → dist/index.js;
49
- // remote-catalog-provider.js lives next to it in dist/core/.
50
21
  const entry = fileURLToPath(import.meta.resolve("@earendil-works/pi-coding-agent"));
51
22
  return join(dirname(entry), "core", "remote-catalog-provider.js");
52
23
  }
@@ -71,8 +42,6 @@ function applyPatch() {
71
42
  writeAtomicSync(file, src);
72
43
  }
73
44
  }
74
- catch {
75
- // best-effort — without the patch the SDK keeps its default union merge
76
- }
45
+ catch { }
77
46
  }
78
47
  applyPatch();
@@ -1,13 +1,3 @@
1
- /**
2
- * patch-tool.ts — 导出给 AI Agent 的结构化补丁工具(Hashline Patch Tool)。
3
- *
4
- * 核心设计:
5
- * - 解决标准 edit 工具容易因缩进幻觉、空白字符或行号漂移导致编辑失败的问题。
6
- * - 补丁语言基于 [path#TAG] 内容哈希锚点,支持精确行替换(PUT N.=M:)、
7
- * 语法块级替换(PUT N*:,自动匹配闭合括号/缩进)、行前/后插入(PUT <N: / PUT >N:)、
8
- * 剪切与寄存器粘贴(CUT / PUT @reg)、文件删除(REM)与重命名(MV)。
9
- * - 当文件被外部改动导致哈希不一致时,自动尝试 3-Way Merge 冲突自愈。
10
- */
11
1
  import { resolve } from "node:path";
12
2
  import { defineTool } from "@earendil-works/pi-coding-agent";
13
3
  import { Type } from "typebox";
@@ -62,10 +52,6 @@ Success returns the next anchor tag and live LSP diagnostics.`,
62
52
  details: emptyReport,
63
53
  };
64
54
  }
65
- // timeout 此前是死参数:schema 声明了 1-300 秒,execute 从未读取,大补丁
66
- // 卡住只能等 20 分钟看门狗(issue #462)。这里用 Promise.race 实现真实
67
- // 超时,覆盖 await 长尾(实时 LSP 诊断等);applyHashlinePatch 是同步
68
- // 本地文件操作,同步段无法被中断,race 只能兜异步部分。
69
55
  const timeoutSec = params.timeout ? Math.min(Math.max(1, params.timeout), 300) : null;
70
56
  const finish = async () => {
71
57
  const report = applyHashlinePatch(patchText, {
@@ -84,7 +70,6 @@ Success returns the next anchor tag and live LSP diagnostics.`,
84
70
  };
85
71
  }
86
72
  const textOutput = [report.summary];
87
- // 为成功修改的文件输出最新的头部标签,方便 Agent 连续进行下一步修改
88
73
  for (const r of report.results) {
89
74
  if (r.op !== "deleted" && r.newHash) {
90
75
  const targetPath = r.newPath || r.filePath;
@@ -1,6 +1,4 @@
1
- /** Shared upload and WebSocket limits. Keep this module free of runtime dependencies. */
2
1
  export const MAX_UPLOAD_BYTES = 100 * 1024 * 1024;
3
- /** Authenticated report chunks: 16 KiB UTF-8, worst-case JSON escaping plus envelope. */
4
2
  export const TASK_REPORT_UPLOAD_JSON_BYTES = 128 * 1024;
5
3
  export function normalizeUploadMaxMb(value, fallback) {
6
4
  return typeof value === "number" && Number.isFinite(value) ? Math.max(1, Math.min(100, Math.floor(value))) : fallback;
@@ -9,11 +7,8 @@ export function uploadLimitBytes(settings, kind) {
9
7
  const defaults = { chat: 20, workspace: 100, folder: 32 };
10
8
  return normalizeUploadMaxMb(settings[`${kind}UploadMaxMb`], defaults[kind]) * 1024 * 1024;
11
9
  }
12
- /** Base64 expands each group of up to three bytes into four characters. */
13
10
  export const MAX_UPLOAD_BASE64_CHARS = Math.ceil(MAX_UPLOAD_BYTES / 3) * 4;
14
- /** Base64 payload plus 1MiB for the JSON envelope (paths, names and attachment metadata). */
15
11
  export const WS_MAX_PAYLOAD_BYTES = MAX_UPLOAD_BASE64_CHARS + 1024 * 1024;
16
- /** Reject definitely oversized base64 text before allocating a decoded Buffer. */
17
12
  export function isUploadDataTooLong(dataLength, capBytes = MAX_UPLOAD_BYTES) {
18
13
  return dataLength > Math.ceil(capBytes / 3) * 4;
19
14
  }
@@ -1,5 +1,4 @@
1
1
  import { randomUUID } from "node:crypto";
2
- /** A request owns its clock and cancellation; holders may change during takeover. */
3
2
  export class PendingQuestion {
4
3
  questions;
5
4
  id = `q-${randomUUID()}`;
@@ -34,8 +33,6 @@ export class PendingQuestion {
34
33
  abort();
35
34
  }
36
35
  }
37
- /** Independent of legacy onSettled, so holder migration cannot erase other owners' cleanup.
38
- * Late subscribers run immediately. Returned cleanup only unsubscribes this listener. */
39
36
  subscribeSettled(listener) {
40
37
  if (this.settled) {
41
38
  listener();
@@ -46,7 +43,6 @@ export class PendingQuestion {
46
43
  this.settledListeners.delete(listener);
47
44
  };
48
45
  }
49
- /** Compatibility alias for integrations using listener naming. */
50
46
  addSettledListener(listener) {
51
47
  return this.subscribeSettled(listener);
52
48
  }
@@ -62,7 +58,6 @@ export class PendingQuestion {
62
58
  this.onSettled = undefined;
63
59
  const listeners = [...this.settledListeners];
64
60
  this.settledListeners.clear();
65
- // Every owner gets cleanup even if another subscriber throws. Preserve the first error.
66
61
  let firstError;
67
62
  let failed = false;
68
63
  for (const listener of [...listeners, ...(onSettled ? [onSettled] : [])]) {
@@ -1,10 +1,3 @@
1
- /**
2
- * 权限预设相关辅助逻辑与会话回放。
3
- */
4
- /**
5
- * 从会话 sessionManager entries 回放恢复最后设定的**计划模式**状态(同 permission/preset
6
- * 的落盘口径:切会话/重载不丢)。从未设定或非布尔 → false。
7
- */
8
1
  export function readPlanModeFromSession(sm) {
9
2
  try {
10
3
  const mgr = sm;
@@ -17,17 +10,9 @@ export function readPlanModeFromSession(sm) {
17
10
  return e.data.enabled;
18
11
  }
19
12
  }
20
- catch {
21
- // ignore
22
- }
13
+ catch { }
23
14
  return false;
24
15
  }
25
- /**
26
- * 从会话 sessionManager entries 回放恢复最后设定的**审查者模式**状态(同 plan/mode
27
- * 口径:customType "delegate/mode")。从未设定或非布尔 → false。
28
- * ⚠️ 执行对话 id **不回放**:常驻执行对话是本进程内的活对象,重启后
29
- * 首条请求会重新建一个(宁可多一个执行对话,也别指向一个不存在的 id)。
30
- */
31
16
  export function readDelegateModeFromSession(sm) {
32
17
  try {
33
18
  const mgr = sm;
@@ -40,15 +25,9 @@ export function readDelegateModeFromSession(sm) {
40
25
  return e.data.enabled;
41
26
  }
42
27
  }
43
- catch {
44
- // ignore
45
- }
28
+ catch { }
46
29
  return false;
47
30
  }
48
- /**
49
- * 从会话 sessionManager entries 回放恢复最后设定的权限预设(若从未设定则返回 undefined)。
50
- * customType 为 "permission/preset",载荷结构为 { preset: string }。
51
- */
52
31
  export function readPermissionFromSession(sm) {
53
32
  try {
54
33
  const mgr = sm;
@@ -62,15 +41,9 @@ export function readPermissionFromSession(sm) {
62
41
  }
63
42
  }
64
43
  }
65
- catch {
66
- // ignore
67
- }
44
+ catch { }
68
45
  return undefined;
69
46
  }
70
- /**
71
- * 从会话 sessionManager entries 回放恢复最后保存的结构化计划状态。
72
- * customType 为 "plan/update" 或 "pi-web-ui/plan",载荷结构为 { plan: PlanState }。
73
- */
74
47
  export function readPlanFromSession(sm) {
75
48
  try {
76
49
  const mgr = sm;
@@ -87,8 +60,6 @@ export function readPlanFromSession(sm) {
87
60
  }
88
61
  }
89
62
  }
90
- catch {
91
- // ignore
92
- }
63
+ catch { }
93
64
  return null;
94
65
  }
@@ -1,25 +1,7 @@
1
- /**
2
- * persona-chain — 内联人设注入、扩展提示词包裹剥离与平台人设补丁。
3
- *
4
- * 负责:
5
- * - INLINE_PERSONA_EXT: 自家内联扩展名标识
6
- * - splitAgentStartPrompt: 剥离先前扩展对 SDK 原始系统提示词的首尾增补
7
- * - PI_DOC_PATHS: 本地 pi SDK 文档路径发现
8
- * - WINDOWS_PERSONA: Windows 平台特有人设补丁(超时/非交互 TTY/GBK 编码)
9
- *
10
- * 从 agent-service.ts 抽出为独立模块。
11
- */
12
1
  import { createRequire } from "node:module";
13
2
  import { dirname, join } from "node:path";
14
3
  import { splitExtensionWrap } from "./prompt-composer.js";
15
- /** 自家内联扩展名(组合模板渲染,见 prompt-composer.ts)。SDK 以其
16
- * "<inline:<name>>" 作为 path;扩展白名单/禁用过滤必须放行它。 */
17
4
  export const INLINE_PERSONA_EXT = "<inline:pi-webui-persona>";
18
- /** 本次 run 的 SDK 原始提示词 + 早前扩展的首尾增补(见 splitExtensionWrap)。
19
- * 导出仅为单测(tests/unit/persona-prompt-chain.test.ts)可达。
20
- * systemPromptOptions 就是 runner 里那个共享可变对象,forceSystemPrompt 有值即
21
- * 说明前面有扩展替换过提示词;临时清掉再读 event.systemPrompt 就拿到原始基线
22
- * (公开字段,不碰 SDK 内部)。没人动过时零开销,直接返回当前文本。 */
23
5
  export function splitAgentStartPrompt(event) {
24
6
  const current = event.systemPrompt;
25
7
  const opts = event.systemPromptOptions;
@@ -34,7 +16,6 @@ export function splitAgentStartPrompt(event) {
34
16
  opts.forceSystemPrompt = forced;
35
17
  }
36
18
  }
37
- /** Pi 包文档路径(composer 的 {{pi_docs}} 自动内容用)。随安装位置解析一次。 */
38
19
  export const PI_DOC_PATHS = (() => {
39
20
  try {
40
21
  const requireLocal = createRequire(import.meta.url);
@@ -45,13 +26,6 @@ export const PI_DOC_PATHS = (() => {
45
26
  return { readme: "", docs: "", examples: "" };
46
27
  }
47
28
  })();
48
- /** Windows persona appendix — appended to the SDK system prompt on win32 only.
49
- * Two failure modes it guards against: (1) the SDK bash tool has NO default
50
- * timeout, so a long-running command hangs the whole conversation forever;
51
- * (2) the in-app terminal is an interactive TTY where heredocs / interactive
52
- * programs wait for input that never comes. Legacy Chinese files are often
53
- * GBK/GB2312 — read them with the right encoding, never paste mojibake into
54
- * reasoning/answers. */
55
29
  export const WINDOWS_PERSONA = `You are a coding agent running on Windows. The bash tool runs Git Bash (bash.exe), not PowerShell. Follow these rules to avoid hanging the session:
56
30
 
57
31
 
@@ -3,15 +3,6 @@ import { dirname, join, resolve } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  let cachedPkgRoot = null;
5
5
  let cachedAppVersion = null;
6
- /**
7
- * 解析 pi-web-ui 包的根目录。
8
- * 兼容:
9
- * - 源码开发模式:server/ (tsx)
10
- * - 源码子模块:server/dsh/ (tsx)
11
- * - 生产构建模式:dist/server/
12
- * - 生产构建子模块:dist/server/dsh/
13
- * - 环境变量显式指定:process.env.PI_WEB_PKG_ROOT
14
- */
15
6
  export function getPkgRoot(fromUrl = import.meta.url) {
16
7
  if (process.env.PI_WEB_PKG_ROOT && existsSync(join(process.env.PI_WEB_PKG_ROOT, "package.json"))) {
17
8
  return process.env.PI_WEB_PKG_ROOT;
@@ -29,16 +20,13 @@ export function getPkgRoot(fromUrl = import.meta.url) {
29
20
  return dir;
30
21
  }
31
22
  }
32
- catch {
33
- /* ignore */
34
- }
23
+ catch { }
35
24
  }
36
25
  const parent = dirname(dir);
37
26
  if (parent === dir)
38
27
  break;
39
28
  dir = parent;
40
29
  }
41
- // Fallback 策略:尝试向上找任意 package.json
42
30
  dir = dirname(fileURLToPath(fromUrl));
43
31
  const candidates = [resolve(dir, ".."), resolve(dir, "..", ".."), resolve(dir, "..", "..", "..")];
44
32
  for (const c of candidates) {
@@ -50,10 +38,6 @@ export function getPkgRoot(fromUrl = import.meta.url) {
50
38
  cachedPkgRoot = candidates[0] ?? dir;
51
39
  return cachedPkgRoot;
52
40
  }
53
- /**
54
- * 获取 pi-web-ui 宿主运行时的真实版本号。
55
- * 若读取失败则 fallback 为 ""。
56
- */
57
41
  export function getAppVersion(fromUrl = import.meta.url) {
58
42
  if (cachedAppVersion !== null)
59
43
  return cachedAppVersion;