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,23 +1,5 @@
1
- /**
2
- * server/delegate-mode.ts
3
- *
4
- * 审查者模式(自动委派 / delegate mode):主对话**只审阅不施工**,活由服务端
5
- * 派给一个**常驻落盘执行对话**(每会话一个,跨轮复用)。
6
- *
7
- * 形态:会话级开关(`set_delegate_mode`)→ 开启后:
8
- * 1. 自动路由:用户在主对话发的每条 prompt,服务端直接转给执行对话执行
9
- * (`ClientSession.dispatchToDelegate`),主对话这一轮**不跑模型**;
10
- * 2. 纯委派闸门:主对话的写类工具 / 非常规 bash / 派发类工具一律拒
11
- * —— 即便模型自己想动手也过不去(与计划模式同一套 `withXGate` 骨架)。
12
- *
13
- * 与计划模式的关系:**互斥优先级**。计划模式开着的时候不自动派活(计划模式已经
14
- * 把 spawn/旁路工具全拒了,再自动派活就是死锁),由计划模式那一轮说了算。
15
- *
16
- * 判定全部是纯函数(无 IO),单测见 tests/unit/delegate-mode.test.ts。
17
- */
18
1
  import { bashCommandIsReadOnly, readOnlyToolCallAllowed, SESSION_DISPATCH_TOOLS } from "./plan-mode.js";
19
2
  import { isReadOnlyConversationAction, CONVERSATION_TOOL_NAMES } from "./conversation-tool-names.js";
20
- /** 审查者模式下确定禁止的工具名单(写 / 改 / 增删 / git 写 / 派发类)。 */
21
3
  export const DELEGATE_MODE_BLOCKED_TOOL_NAMES = [
22
4
  "write",
23
5
  "create",
@@ -48,7 +30,6 @@ export const DELEGATE_MODE_BLOCKED_TOOL_NAMES = [
48
30
  "truncate",
49
31
  "rename",
50
32
  "git",
51
- // 代码求值(eval 沙箱可写真实文件系统 —— 主对话只审阅不施工,#436)
52
33
  "eval",
53
34
  "codemode",
54
35
  "mcp_manage",
@@ -62,18 +43,8 @@ export const DELEGATE_MODE_BLOCKED_TOOL_NAMES = [
62
43
  ...SESSION_DISPATCH_TOOLS,
63
44
  ];
64
45
  const BLOCKED_TOOLS = new Set(DELEGATE_MODE_BLOCKED_TOOL_NAMES);
65
- /**
66
- * 审查者模式下也禁掉的「派发类」工具:派活是**服务端**的活(自动路由),
67
- * 模型再自己 spawn 一个只会绕开「一个常驻执行对话」这条语义线(多份上下文、
68
- * 多份配额、左栏一堆对话),而且落盘对话占项目会话名额。
69
- * 与计划模式禁它的理由不同:那边是「别绕开只读约束」,这边是「别绕开统一派活」。
70
- * 名单 = 三闸门共用的真实注册派发工具(SESSION_DISPATCH_TOOLS,#436 前是一堆
71
- * 幽灵名)+ subagent 整工具(这里不分 action,审查者对话一概不派不问)。
72
- */
73
46
  const DISPATCH_TOOLS = new Set([...SESSION_DISPATCH_TOOLS, ...CONVERSATION_TOOL_NAMES]);
74
- /** bash 家族(要逐条判命令是否只读)。 */
75
47
  const BASH_TOOLS = new Set(["bash", "shell", "sh", "zsh", "terminal_bash", "run_command", "exec"]);
76
- /** 从工具参数里取命令文本(各工具字段名不同)。 */
77
48
  function commandOf(params) {
78
49
  if (!params || typeof params !== "object")
79
50
  return "";
@@ -85,11 +56,6 @@ function commandOf(params) {
85
56
  }
86
57
  return "";
87
58
  }
88
- /**
89
- * 审查者模式闸门(纯函数):命中即拒绝,并把「该干什么」告诉模型 ——
90
- * 提示词已经说明规则,这里再把可操作的下一步重复一遍(长任务里模型最容易
91
- * 「顺手改一下」,拒绝理由就是它唯一的纠偏机会)。
92
- */
93
59
  export function delegationDenial(toolName, params) {
94
60
  const name = (toolName ?? "").trim();
95
61
  if (!name)
@@ -138,7 +104,6 @@ export function delegationDenial(toolName, params) {
138
104
  }
139
105
  return undefined;
140
106
  }
141
- /** 审查者模式系统提示词段(英文:进入模型上下文,按工具提示词卫生口径只写英文)。 */
142
107
  export const DELEGATION_SYSTEM_PROMPT = [
143
108
  "# Reviewer mode (you review; a server-side executor does the work)",
144
109
  "Reviewer mode is on for this conversation. The server forwards every user request to ONE persistent executor conversation, and that conversation is the only one allowed to change anything.",
@@ -148,7 +113,6 @@ export const DELEGATION_SYSTEM_PROMPT = [
148
113
  "- Keep your own messages short and decision-oriented. The executor keeps the working context; you are the reviewer, not the worker.",
149
114
  "- If plan mode is also on, plan mode wins: no dispatch happens and you produce the plan yourself.",
150
115
  ].join("\n");
151
- /** 拒给用户的界面文案(notice,zh + en 成对)。 */
152
116
  export function delegateNoticeText(enabled) {
153
117
  return enabled
154
118
  ? {
@@ -1,36 +1,16 @@
1
- /**
2
- * delegate_task —— 结构化派单工具(oh-my-pi 委派协议的代码级硬化)。
3
- *
4
- * 背景:单纯靠提示词要求模型“派单写详细”是没有强制力的——模型糊弄也不会有
5
- * 任何后果。本工具把六段式派单格式写进参数 schema + 服务端校验:缺段/太短/
6
- * 模板不可用直接报错打回(错误文本留在上下文里,模型补全后重试)。
7
- *
8
- * 与 subagent_spawn 的关系:并存。subagent_spawn 是通用自由派单;delegate_task
9
- * 是走 specialist 模板的结构化派单(agent 必填且必须是启用的模板)。执行体复用
10
- * 同一条 spawn 通道(SubagentToolHost.spawnSubagent):真子代理会话、白名单、
11
- * 模型优先级、左栏徽标、等待/改向/停止全套机制都不用重写。
12
- *
13
- * 纯函数(validateDelegation / buildDelegationPrompt)可单测;语言按 ServerLang
14
- * 切中英(section 头固定英文——子代理侧各模板早已习惯英文段头;面向派单者的
15
- * 错误文本走 pick,key 缺失时自动回落英文,见 server/i18n.ts)。
16
- */
17
1
  import { Type } from "typebox";
18
2
  import { defineTool } from "@earendil-works/pi-coding-agent";
19
3
  import { pick } from "./i18n.js";
20
4
  import { DELEGATE_TASK_TOOL_NAME } from "./tool-manager.js";
21
5
  import { subagentTitle } from "./subagents.js";
22
6
  import { parseRequiredTools, resolveSecurityMode } from "./subagent-security-gate.js";
23
- /** 工具名(唯一值在 tool-manager.ts;本别名保留:前端派单卡片与旧导入沿用它)。 */
24
7
  export const DELEGATE_TOOL_NAME = DELEGATE_TASK_TOOL_NAME;
25
- /** 各段最小长度(trim 后字符数):TASK 必须具体,OUTCOME 必须可验收,其余段不许空着。 */
26
8
  const MIN_TASK = 20;
27
9
  const MIN_OUTCOME = 10;
28
- /** 六段的固定英文名(校验报错与拼装 prompt 共用,子代理侧无需翻译)。 */
29
10
  const SECTIONS = ["TASK", "EXPECTED OUTCOME", "REQUIRED TOOLS", "MUST DO", "MUST NOT DO", "CONTEXT"];
30
11
  function str(v) {
31
12
  return typeof v === "string" ? v : "";
32
13
  }
33
- /** 把模型传进来的脏参数归一化(缺字段/错类型不抛错,交给校验报错)。 */
34
14
  export function normalizeDelegation(params) {
35
15
  const p = (params && typeof params === "object" ? params : {});
36
16
  return {
@@ -45,10 +25,6 @@ export function normalizeDelegation(params) {
45
25
  persist: typeof p.persist === "boolean" ? p.persist : undefined,
46
26
  };
47
27
  }
48
- /**
49
- * 校验派单输入;通过返回 null,否则返回直接回给模型的错误文本(已按 lang 选好语言)。
50
- * `usableNames` = 当前可用模板名(host.listTemplates(),只含 enabled 的)。
51
- */
52
28
  export function validateDelegation(input, usableNames, lang = "en") {
53
29
  if (!input.agent || !usableNames.includes(input.agent)) {
54
30
  const shown = usableNames.slice(0, 12).join(" · ") + (usableNames.length > 12 ? " · …" : "");
@@ -69,7 +45,6 @@ export function validateDelegation(input, usableNames, lang = "en") {
69
45
  }
70
46
  return null;
71
47
  }
72
- /** 拼装发给子代理的标准六段 prompt(段头固定英文;收尾一行为汇报纪律)。 */
73
48
  export function buildDelegationPrompt(input, lang = "en") {
74
49
  const firstLine = input.task.split("\n")[0]?.trim().slice(0, 80) || input.agent;
75
50
  const closer = lang === "zh"
@@ -132,7 +107,6 @@ const delegateSchema = Type.Object({
132
107
  "use for tasks needing long-term retention.",
133
108
  })),
134
109
  });
135
- /** 结构化派单工具:校验六段 → 拼装标准 prompt → 走 host.spawnSubagent 真子代理。 */
136
110
  export function makeDelegateTaskTool(host, lang) {
137
111
  const getLang = lang ?? host.lang ?? (() => "en");
138
112
  const text = (t, details = {}) => ({
@@ -170,8 +144,6 @@ export function makeDelegateTaskTool(host, lang) {
170
144
  allowedTools: parsedTools.allowedTools,
171
145
  securityMode,
172
146
  };
173
- // 与 subagent_spawn 同理:spawn 通道是唯一的失败面(数量上限 / runtime
174
- // 创建失败都经由 host 抛错),转成返回文本让 AI 能读到原因并修正重试。
175
147
  let convId;
176
148
  try {
177
149
  convId = await host.spawnSubagent(prompt, "delegate", ctx.cwd, input.agent, input.model, undefined, input.persist, undefined, undefined, undefined, extra);
@@ -202,6 +174,8 @@ export function makeDelegateTaskTool(host, lang) {
202
174
  modelLine: modelLineEn,
203
175
  modelLineZh,
204
176
  modelLineEn,
177
+ toolsLineEn,
178
+ securityLineEn,
205
179
  }), { convId, agent: input.agent, template: input.agent, model: input.model });
206
180
  },
207
181
  });
@@ -1,5 +1,4 @@
1
1
  import { Buffer } from "node:buffer";
2
- /** Public facts only: never include parameter values, paths, command text or rule reasons. */
3
2
  export function approvalOperationSummary(toolName, params) {
4
3
  const input = params && typeof params === "object" && !Array.isArray(params) ? params : {};
5
4
  const lines = [];
@@ -7,7 +7,6 @@ import { listAllMcpServers } from "../mcp-manager.js";
7
7
  import { getMcpToolServer } from "../mcp-bridge.js";
8
8
  import { isBotToolHighPrivilege } from "./bot-execution.js";
9
9
  import { DeviceWorkspaceError } from "./workspaces.js";
10
- /** Captures the requested project once; only public metadata is returned. */
11
10
  export async function getLocalBotOptions(sources, requestedCwd, signal) {
12
11
  signal.throwIfAborted();
13
12
  if (requestedCwd !== undefined && (typeof requestedCwd !== "string" || !isAbsolute(requestedCwd)))
@@ -19,8 +18,6 @@ export async function getLocalBotOptions(sources, requestedCwd, signal) {
19
18
  const defaultTools = [...(sources.defaultTools?.() ?? [])];
20
19
  const agentDir = sources.agentDir ?? getAgentDir();
21
20
  const settings = SettingsManager.create(cwd, agentDir);
22
- // Match ResourceLoader package/path resolution, but skip missing packages rather than installing.
23
- // No extensions are imported and no MCP transport is initialized.
24
21
  const resources = await new DefaultPackageManager({ cwd, agentDir, settingsManager: settings }).resolve(async () => {
25
22
  signal.throwIfAborted();
26
23
  return "skip";
@@ -4,9 +4,7 @@ import { isAbsolute, resolve } from "node:path";
4
4
  import { getBotExecutionInstructions } from "./execution-instructions.js";
5
5
  import { checkGroupTaskPlanGuard, isGroupToolForbiddenInPlanCatalog } from "./group-plan-guard.js";
6
6
  const bindings = new Map();
7
- // Exact locally constructed frames, scoped to one task capability and consumed by the WS gate.
8
7
  const interactionReplies = new Map();
9
- // Advisory only: these tools can create execution contexts or mutate host policy.
10
8
  const highPrivilegeTools = new Set([
11
9
  "bash",
12
10
  "powershell",
@@ -27,11 +25,9 @@ const highPrivilegeTools = new Set([
27
25
  "team",
28
26
  "tool_search",
29
27
  ]);
30
- /** Catalog warning; authorization is determined solely by the configured whitelist. */
31
28
  export function isBotToolHighPrivilege(name) {
32
29
  return highPrivilegeTools.has(name) || name.startsWith("subagent_") || name.startsWith("team_");
33
30
  }
34
- /** Compute tools that must be stripped due to capability attenuation when a task is dispatched cross-bot. */
35
31
  export function computeAttenuatedTools(sourceTools, targetTools) {
36
32
  const sourceSet = new Set(sourceTools);
37
33
  return targetTools.filter((tool) => isBotToolHighPrivilege(tool) && !sourceSet.has(tool));
@@ -201,18 +197,15 @@ export function registerBotExecution(bot, authorizedResumePath, context) {
201
197
  },
202
198
  };
203
199
  }
204
- /** A binding is removed only after the executor confirms its task has stopped. */
205
200
  export function isBotExecutionRegistered(clientId) {
206
201
  return bindings.has(clientId);
207
202
  }
208
- /** Unregistered private IDs fail closed, including after a server restart. */
209
203
  export function getBotExecution(clientId) {
210
204
  const binding = bindings.get(clientId);
211
205
  if (!binding && clientId.startsWith("device-task-"))
212
206
  throw new Error("Unregistered Bot execution client");
213
207
  return binding;
214
208
  }
215
- /** Executor uses only this control surface; all other public WS commands are denied. */
216
209
  export function botExecutionMessageAllowed(clientId, type, message) {
217
210
  const capability = getBotExecution(clientId);
218
211
  if (!capability)
@@ -227,7 +220,6 @@ export function botExecutionMessageAllowed(clientId, type, message) {
227
220
  }
228
221
  if (type === "question_answer" || type === "tool_approval_response") {
229
222
  const expected = interactionReplies.get(clientId);
230
- // A rejected frame cannot consume the grant for the legitimate reply.
231
223
  if (!expected || JSON.stringify(message) !== expected)
232
224
  return false;
233
225
  interactionReplies.delete(clientId);
@@ -1,5 +1,4 @@
1
1
  import { DeviceWorkspaceError } from "./workspaces.js";
2
- /** Partial Bot presets never carry workspace, identity, credentials or host runtime settings. */
3
2
  export function applyLocalBotPreset(bot, raw, catalog) {
4
3
  const fail = (message) => {
5
4
  throw new DeviceWorkspaceError(400, "BOT_PRESET_INVALID", message);
@@ -49,7 +49,6 @@ function validate(input) {
49
49
  revision: input.revision,
50
50
  };
51
51
  }
52
- /** One instance per service data directory. Mutations and lease admission share one serial queue. */
53
52
  export async function createLocalBotRegistry(dataDir) {
54
53
  await mkdir(dataDir, { recursive: true });
55
54
  const directory = join(dataDir, "device-bots");
@@ -15,7 +15,6 @@ export function createDeviceCollabService(options) {
15
15
  if (!context)
16
16
  throw new Error("Invalid workspace");
17
17
  const bound = options.getExecutionContext?.(context);
18
- // Resolve authority before workspace acquisition; never mutate caller arguments.
19
18
  if ([
20
19
  "task_state",
21
20
  "task_update",
@@ -401,7 +400,7 @@ export function createDeviceCollabService(options) {
401
400
  signal?.throwIfAborted();
402
401
  const chunkIndex = file.firstChunkIndex + c;
403
402
  if (receivedSet.has(chunkIndex))
404
- continue; // Resume skip
403
+ continue;
405
404
  const chunkOffset = c * manifest.chunkSize;
406
405
  const chunkSize = Math.min(manifest.chunkSize, file.size - chunkOffset);
407
406
  const { buffer, sha256 } = await files.readChunk({
@@ -497,7 +496,6 @@ export function createDeviceCollabService(options) {
497
496
  }
498
497
  }
499
498
  catch {
500
- // Remote errors, URLs, fetch errors and local file errors may contain secrets.
501
499
  throw new Error(signal?.aborted ? "Device collaboration cancelled." : "Device collaboration request failed.");
502
500
  }
503
501
  finally {
@@ -317,7 +317,6 @@ export function validateDeviceCollabInput(input) {
317
317
  "content",
318
318
  "title",
319
319
  ].includes(key)) {
320
- // Validated together below, including required revision and at least one report field.
321
320
  continue;
322
321
  }
323
322
  if (key === "criteriaResults") {
@@ -502,8 +501,6 @@ export function validateDeviceCollabInput(input) {
502
501
  throw new Error(`Missing device_collab argument: ${key}.`);
503
502
  }
504
503
  }
505
- // Except for explicit conversation/history projections below, only structural identifiers/status/counts leave the service boundary. No raw replies,
506
- // file contents, credentials, endpoints, or arbitrary service error strings are exposed.
507
504
  const summaryKeys = new Set([
508
505
  "id",
509
506
  "deviceId",
@@ -597,7 +594,6 @@ function projectArtifactMetadata(value) {
597
594
  ...(source.baseline ? { baseline: evidenceFields(source.baseline, ["repositoryId", "commit"]) } : {}),
598
595
  };
599
596
  }
600
- /** Public immutable evidence identities; raw context and patch payloads require explicit reads. */
601
597
  export function projectExecutionEvidence(value) {
602
598
  const source = evidenceRecord(value);
603
599
  const contract = evidenceRecord(source.contract);
@@ -676,7 +672,6 @@ export function projectBlackboard(value) {
676
672
  },
677
673
  };
678
674
  }
679
- // Explicit schema projection prevents arbitrary Hub fields from leaking into tool results.
680
675
  export function projectTaskState(value) {
681
676
  const record = (v) => v && typeof v === "object" && !Array.isArray(v) ? v : {};
682
677
  let truncated = false;
@@ -751,7 +746,6 @@ export function projectTaskState(value) {
751
746
  }
752
747
  result.reported = projected;
753
748
  }
754
- // Keep the state usable even when multibyte reports exceed the wire budget.
755
749
  const lists = [
756
750
  result.decisions,
757
751
  result.artifacts,
@@ -877,7 +871,6 @@ export function projectTaskState(value) {
877
871
  out.truncated = true;
878
872
  return out;
879
873
  }
880
- // Project only public conversation context; private roots, fingerprints and credentials never pass through.
881
874
  function projectConversations(value) {
882
875
  const object = (item) => item && typeof item === "object" && !Array.isArray(item) ? item : {};
883
876
  const source = object(value);
@@ -1192,7 +1185,6 @@ function projectConversations(value) {
1192
1185
  const items = source[key];
1193
1186
  const projected = [];
1194
1187
  out[key] = projected;
1195
- // Reserve space for each collection and prioritize recent context.
1196
1188
  const selected = key === "conversations" ? items.slice(0, 100) : items.slice(-100).reverse();
1197
1189
  for (const item of selected) {
1198
1190
  projected.push(projectItem(item, fields, texts));
@@ -1224,7 +1216,6 @@ function projectConversations(value) {
1224
1216
  }
1225
1217
  return out;
1226
1218
  }
1227
- // Only numeric measurements and fixed mode values may leave the metrics boundary.
1228
1219
  function projectContextMetrics(value) {
1229
1220
  const record = (item) => item && typeof item === "object" && !Array.isArray(item) ? item : {};
1230
1221
  const numeric = (source, keys) => {
@@ -1263,7 +1254,6 @@ function projectContextMetrics(value) {
1263
1254
  samples: Array.isArray(source.samples) ? source.samples.slice(-10).map(sample) : [],
1264
1255
  };
1265
1256
  }
1266
- // History deliberately exposes bounded message text, never arbitrary response fields.
1267
1257
  function projectHistory(value) {
1268
1258
  const object = (item) => item && typeof item === "object" && !Array.isArray(item) ? item : {};
1269
1259
  const string = (item, limit = 256) => (typeof item === "string" ? item.slice(0, limit) : "");
@@ -2,6 +2,7 @@ import http, {} from "node:http";
2
2
  import { projectTaskActivity } from "./task-progress.js";
3
3
  import https from "node:https";
4
4
  import { WebSocket } from "ws";
5
+ import { createDeviceLanServer } from "./device-lan.js";
5
6
  import { deviceTaskFailure } from "./task-error.js";
6
7
  import { uploadTaskReport } from "./report-upload.js";
7
8
  import { reportUploadMetadata } from "./report-metadata.js";
@@ -26,6 +27,7 @@ export function createDeviceConnector(options) {
26
27
  const endpoint = new URL("/device-connect", hub);
27
28
  endpoint.protocol = hub.protocol === "https:" || hub.protocol === "wss:" ? "wss:" : "ws:";
28
29
  endpoint.searchParams.set("deviceId", options.deviceId);
30
+ const deviceLan = createDeviceLanServer({ localOrigin: local.origin, localAuthToken: options.localAuthToken });
29
31
  let closed = false;
30
32
  let tasksDisabled = false;
31
33
  const waitingForHumanTaskIds = new Set();
@@ -59,8 +61,6 @@ export function createDeviceConnector(options) {
59
61
  task.controller.abort();
60
62
  }
61
63
  else {
62
- // Passive network disconnect: ONLY retain tasks that have an active lease and recovery enabled!
63
- // Tasks without leaseToken or without recovery cannot be claimed on reconnect; abort them.
64
64
  for (const task of runningTasks.values()) {
65
65
  if (!options.recovery || !task.leaseToken) {
66
66
  task.controller.abort();
@@ -159,7 +159,22 @@ export function createDeviceConnector(options) {
159
159
  handshakeTimeout: 10_000,
160
160
  });
161
161
  socket = ws;
162
- const rpc = createCommandChannel(ws, options.onCommand);
162
+ const rpc = createCommandChannel(ws, async (action, payload, signal) => {
163
+ if (action !== "device_lan") {
164
+ if (!options.onCommand)
165
+ throw new Error("Device command unavailable");
166
+ return options.onCommand(action, payload, signal);
167
+ }
168
+ if (signal.aborted)
169
+ throw new Error("Device access cancelled");
170
+ const grant = await deviceLan.issueGrant();
171
+ if (signal.aborted || closed || socket !== ws || ws.readyState !== WebSocket.OPEN) {
172
+ if (grant)
173
+ deviceLan.revoke(grant.identity);
174
+ throw new Error("Device connection changed");
175
+ }
176
+ return grant;
177
+ });
163
178
  const messages = createWsMessageChannel(ws);
164
179
  const cancellations = new Set();
165
180
  const steerings = new Set();
@@ -172,7 +187,6 @@ export function createDeviceConnector(options) {
172
187
  tasksDisabled = false;
173
188
  lastPong = Date.now();
174
189
  retryReports();
175
- // === Task Recovery / Reconnect Claim / Outbox Replay ===
176
190
  const claimsToSend = new Map();
177
191
  if (options.recovery) {
178
192
  for (const claim of options.recovery.prepareClaims()) {
@@ -204,7 +218,6 @@ export function createDeviceConnector(options) {
204
218
  for (const item of options.recovery.getPendingOutbox())
205
219
  sendOutboxEntry(ws, item);
206
220
  }
207
- // =======================================================
208
221
  void Promise.resolve()
209
222
  .then(() => options.onConnect?.())
210
223
  .catch(() => ws.close(1011, "Bot sync failed"));
@@ -219,7 +232,6 @@ export function createDeviceConnector(options) {
219
232
  const frame = parseFrame(Buffer.from(raw));
220
233
  if (rpc.handle(frame))
221
234
  return;
222
- // === Task Recovery / Reconnect Results ===
223
235
  if (frame.type === "task_claim_result") {
224
236
  if (typeof frame.taskId === "string" && typeof frame.attemptId === "string" && frame.accepted === false) {
225
237
  const task = runningTasks.get(frame.taskId);
@@ -278,7 +290,6 @@ export function createDeviceConnector(options) {
278
290
  }
279
291
  return;
280
292
  }
281
- // =========================================
282
293
  if (frame.type === "task_cancel") {
283
294
  if (typeof frame.id !== "string" ||
284
295
  !frame.id ||
@@ -600,7 +611,6 @@ export function createDeviceConnector(options) {
600
611
  void (async () => {
601
612
  let bytes = 0;
602
613
  try {
603
- // Pull only as fast as the relay socket drains, instead of aborting bursts.
604
614
  for await (const data of res) {
605
615
  const chunk = Buffer.from(data);
606
616
  bytes += chunk.length;
@@ -706,7 +716,8 @@ export function createDeviceConnector(options) {
706
716
  if (socket !== ws)
707
717
  return;
708
718
  socket = undefined;
709
- stopTasks(false); // Retain running tasks locally across disconnects
719
+ deviceLan.close();
720
+ stopTasks(false);
710
721
  for (const id of streams.keys())
711
722
  dispose(id);
712
723
  if (!closed) {
@@ -723,7 +734,6 @@ export function createDeviceConnector(options) {
723
734
  else
724
735
  socket.ping();
725
736
  retryReports();
726
- // === Heartbeat Lease Renewal ===
727
737
  if (options.recovery) {
728
738
  const renews = options.recovery.prepareLeaseRenews({ waitingForHumanTaskIds });
729
739
  for (const renew of renews) {
@@ -736,7 +746,6 @@ export function createDeviceConnector(options) {
736
746
  }
737
747
  }
738
748
  }
739
- // ===============================
740
749
  }
741
750
  }, 15_000);
742
751
  heartbeat.unref();
@@ -745,6 +754,7 @@ export function createDeviceConnector(options) {
745
754
  isOnline: () => socket?.readyState === WebSocket.OPEN,
746
755
  close() {
747
756
  closed = true;
757
+ deviceLan.close();
748
758
  reportAbort.abort();
749
759
  stopTasks(true);
750
760
  clearInterval(heartbeat);
@@ -3,7 +3,6 @@ import { validateCodeArtifactOutcome, validateContextManifest, validateWorkContr
3
3
  function conflict(message) {
4
4
  throw Object.assign(new Error(message), { status: 409 });
5
5
  }
6
- /** Contract authority spans conversations within its owning account and room. */
7
6
  export function assertLatestContract(state, task) {
8
7
  const contract = task.contract;
9
8
  if (!contract)
@@ -76,12 +75,10 @@ export function assertDeliveryAuthority(state, delivery) {
76
75
  conflict("Delivery artifact subject changed");
77
76
  return task;
78
77
  }
79
- /** Legacy records have no durable CAS identity: preserve their uncertainty for manual recovery. */
80
78
  export function isLegacyPublicationUnknown(integration) {
81
79
  return (!integration.publishIntent &&
82
80
  (integration.status === "applying" || !!integration.error?.startsWith("Apply failed; check target outcome:")));
83
81
  }
84
- /** Effect receipts do not prove a previously started Git child has stopped. */
85
82
  export function hasOpenPublication(integration) {
86
83
  return (!!integration.publishIntent &&
87
84
  ((!!integration.publishStop && !integration.publishStop.stopConfirmed) ||
@@ -1,4 +1,3 @@
1
- /** Artifact identity is the complete immutable subject, never an absent commit. */
2
1
  export function artifactRefsMatch(a, b) {
3
2
  return (!!a &&
4
3
  !!b &&
@@ -14,9 +14,7 @@ function executable(name) {
14
14
  if (statSync(candidate).isFile())
15
15
  return candidate;
16
16
  }
17
- catch {
18
- /* Missing or inaccessible PATH entry. */
19
- }
17
+ catch { }
20
18
  }
21
19
  return undefined;
22
20
  }
@@ -24,7 +22,6 @@ export function linuxDesktopStatus() {
24
22
  const unsupported = (reason) => ({ supported: false, backend: "x11", reason });
25
23
  if (process.platform !== "linux")
26
24
  return unsupported("Linux X11 desktop capture requires Linux.");
27
- // XWayland only captures X11 windows, not the full Wayland desktop.
28
25
  if (process.env.XDG_SESSION_TYPE?.toLowerCase() === "wayland" || process.env.WAYLAND_DISPLAY)
29
26
  return unsupported("Wayland desktop capture requires Portal/PipeWire and is not supported yet.");
30
27
  if (!process.env.DISPLAY)
@@ -51,9 +48,7 @@ function screenSize() {
51
48
  if (match && +match[1] > 0 && +match[2] > 0)
52
49
  return [+match[1], +match[2]];
53
50
  }
54
- catch {
55
- /* Try xrandr when xdpyinfo cannot query this display. */
56
- }
51
+ catch { }
57
52
  }
58
53
  const randr = executable("xrandr");
59
54
  if (randr) {
@@ -63,9 +58,7 @@ function screenSize() {
63
58
  if (match && +match[1] > 0 && +match[2] > 0)
64
59
  return [+match[1], +match[2]];
65
60
  }
66
- catch {
67
- /* Report a useful dependency/display error below. */
68
- }
61
+ catch { }
69
62
  }
70
63
  throw new Error("Cannot determine X11 screen dimensions; install xdpyinfo or xrandr and check DISPLAY/XAUTHORITY.");
71
64
  }
@@ -145,7 +138,6 @@ export function startLinuxDesktop(options) {
145
138
  buttons.clear();
146
139
  if (!control || !args.length)
147
140
  return;
148
- // One bounded, directly spawned cleanup command; never starts a shell.
149
141
  execFile(control, args, { timeout: 2000, killSignal: "SIGKILL", maxBuffer: 16384, shell: false }, () => { });
150
142
  };
151
143
  const close = () => {
@@ -159,7 +151,6 @@ export function startLinuxDesktop(options) {
159
151
  killTimer = setTimeout(() => capture?.kill("SIGKILL"), 1000);
160
152
  killTimer.unref();
161
153
  }
162
- // Wait for the active command's callback before releasing, avoiding a late keydown.
163
154
  if (command)
164
155
  command.kill("SIGKILL");
165
156
  else
@@ -180,7 +171,6 @@ export function startLinuxDesktop(options) {
180
171
  if (closed || command || !queue.length || !control)
181
172
  return;
182
173
  const args = queue.shift();
183
- // Track attempted downs too: an interrupted xdotool can already have injected them.
184
174
  for (let i = 0; i < args.length - 1; i++) {
185
175
  if (args[i] === "keydown")
186
176
  keys.add(args[i + 1]);
@@ -318,7 +308,6 @@ export function startLinuxDesktop(options) {
318
308
  capture.stdout.on("data", (chunk) => {
319
309
  if (closed)
320
310
  return;
321
- // Slice large writes so a single producer chunk cannot grow retained memory unboundedly.
322
311
  for (let offset = 0; offset < chunk.length && !closed; offset += 65536) {
323
312
  pending = Buffer.concat([pending, chunk.subarray(offset, offset + 65536)]);
324
313
  while (pending.length && !closed) {
@@ -365,7 +354,6 @@ export function startLinuxDesktop(options) {
365
354
  });
366
355
  }
367
356
  catch (error) {
368
- // Defer setup failures so callers can store the returned handle before onClose.
369
357
  queueMicrotask(() => fail(String(error)));
370
358
  }
371
359
  return { input, close };
@@ -43,7 +43,6 @@ const specialKeys = new Set([
43
43
  "Period",
44
44
  "Slash",
45
45
  ]);
46
- // Rebuild a bounded wire object: never forward untrusted extra fields to the helper.
47
46
  function validatedInput(value) {
48
47
  if (!value || typeof value !== "object")
49
48
  return;
@@ -82,7 +81,6 @@ function validatedInput(value) {
82
81
  function powershellPath() {
83
82
  return join(process.env.SystemRoot || "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe");
84
83
  }
85
- /** Availability of the capture runtime; OS permissions are checked by the helper at startup. */
86
84
  export function nativeDesktopStatus() {
87
85
  if (process.platform === "win32") {
88
86
  return existsSync(powershellPath())
@@ -109,9 +107,7 @@ export function nativeDesktopStatus() {
109
107
  stdio: ["ignore", "pipe", "ignore"],
110
108
  }).trim());
111
109
  }
112
- catch {
113
- /* Missing/unselected developer tools or a stalled xcrun. */
114
- }
110
+ catch { }
115
111
  return swiftAvailable
116
112
  ? { supported: true, backend: "macos-screencapturekit" }
117
113
  : {
@@ -126,7 +122,6 @@ export function nativeDesktopStatus() {
126
122
  reason: "Native desktop capture is unavailable on this platform; Linux requires a separate X11/Wayland backend.",
127
123
  };
128
124
  }
129
- /** Explicit local permission action; callers must enforce local-device access. */
130
125
  export async function requestNativeDesktopPermissions(kind, signal) {
131
126
  if (signal?.aborted)
132
127
  throw new Error("Native desktop permission request aborted.");
@@ -151,7 +146,6 @@ export async function requestNativeDesktopPermissions(kind, signal) {
151
146
  clearTimeout(timeout);
152
147
  clearTimeout(killTimer);
153
148
  signal?.removeEventListener("abort", abort);
154
- // Never remove a running helper's script, or block the event loop on retries.
155
149
  if (directory)
156
150
  rm(directory, { recursive: true, force: true, maxRetries: 2 }, () => { });
157
151
  }
@@ -236,7 +230,6 @@ export async function requestNativeDesktopPermissions(kind, signal) {
236
230
  }
237
231
  });
238
232
  }
239
- /** Main-display JPEG stream. Read-only is immutable per handle and defaults to true. */
240
233
  export function startNativeDesktop(options) {
241
234
  const status = nativeDesktopStatus();
242
235
  const readOnly = options.readOnly !== false;
@@ -273,8 +266,6 @@ export function startNativeDesktop(options) {
273
266
  finish();
274
267
  return;
275
268
  }
276
- // EOF/close is processed on a dedicated input thread: held keys/buttons are
277
- // released before exit, even when capture is waiting for frame acknowledgment.
278
269
  if (!child.stdin.destroyed)
279
270
  child.stdin.end('{"type":"close"}\n');
280
271
  timer = setTimeout(() => {
@@ -1,4 +1,3 @@
1
- /** Self-contained native JPEG desktop client. All URLs stay relative to the mounted page. */
2
1
  export function desktopPage() {
3
2
  return `<!doctype html>
4
3
  <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Remote desktop</title>
@@ -126,8 +125,8 @@ function connect() {
126
125
  pendingFrame = {blob:event.data, generation:currentGeneration, socket:current}; void decodeFrames();
127
126
  }
128
127
  };
129
- current.onerror = () => { if (isCurrent()) fail(t('connectionError')); };
130
- current.onclose = event => { if (isCurrent()) { stop(); status(t('closed') + ' (' + event.code + ')' + (event.reason ? ': ' + event.reason : ''), true); } };
128
+ current.onerror = () => { if (isCurrent()) { fail(t('connectionError')); parent.postMessage({type:'device-portal-disconnected'}, '*'); } };
129
+ current.onclose = event => { if (isCurrent()) { stop(); status(t('closed') + ' (' + event.code + ')' + (event.reason ? ': ' + event.reason : ''), true); parent.postMessage({type:'device-portal-disconnected'}, '*'); } };
131
130
  }
132
131
  async function request(path, options = {}) {
133
132
  const response = await fetch(appUrl(path), {...options, credentials:'same-origin', cache:'no-store'});
@@ -9,9 +9,7 @@ export function createDesktopSetup(options) {
9
9
  try {
10
10
  storedEnabled = JSON.parse(readFileSync(settingsFile, "utf8"))?.enabled === true;
11
11
  }
12
- catch {
13
- // Missing or unreadable settings leave desktop access disabled by default.
14
- }
12
+ catch { }
15
13
  let closed = false;
16
14
  return {
17
15
  get enabled() {