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,14 +1,6 @@
1
- /**
2
- * universal-session.ts — 通用 Agent 会话控制器(实现 DispatchSession)。
3
- *
4
- * 职责:
5
- * 1. 桥接 BaseAgentDriver 与 Web 前端 Wire 协议;
6
- * 2. 自动维护严格线性的 UiMessage[] 历史与流式 streamingMessage;
7
- * 3. 60ms 节流下发 snapshot / message_delta,实现高帧率低开销的前端流式渲染;
8
- * 4. 无缝复用宿主 FilesService(文件树/预览/SCM/上传)、TerminalManager(终端)与 BgServerTracker(后台服务)。
9
- */
10
1
  import { startTurnTiming, finishTurnTiming } from "../turn-timing.js";
11
2
  import { normalizeQuickAskSettings } from "../quick-ask-settings.js";
3
+ import { captureQuickAskConversation } from "../quick-ask-context.js";
12
4
  import { randomUUID } from "node:crypto";
13
5
  import { existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
14
6
  import { homedir } from "node:os";
@@ -89,8 +81,6 @@ export class UniversalSession {
89
81
  activeConvId;
90
82
  conversations = new Map();
91
83
  isStreaming = false;
92
- /** 在途回合归属的会话 id(#700/#701):prompt 开始时锚定,finalizeTurn 收尾时消费并清空。
93
- * 会话切换/回滚不再让流式回写与回合收尾锚错会话,避免跨对话内容污染落盘。 */
94
84
  turnConvId = null;
95
85
  turn = null;
96
86
  projectGeneration = 0;
@@ -293,13 +283,11 @@ export class UniversalSession {
293
283
  else {
294
284
  this.currentModel = opts.driver.currentModel ?? "default";
295
285
  }
296
- // 恢复上次使用的模型(按引擎独立记录:项目记忆优先 > 全局默认)
297
286
  const savedModel = opts.stateStore?.getProjectModel(opts.clientId, opts.cwd, this.engine) ??
298
287
  opts.stateStore?.getDefaultModel(this.engine);
299
288
  if (savedModel) {
300
289
  this.currentModel = savedModel;
301
290
  }
302
- // 恢复思考强度记忆:模型专属记忆 > 全局默认 > 既有默认
303
291
  const rememberedThinking = getModelThinkingLevelFromSettings(this.currentModel, this.agentDir);
304
292
  if (rememberedThinking) {
305
293
  this.thinkingLevel = rememberedThinking;
@@ -336,7 +324,6 @@ export class UniversalSession {
336
324
  cleanupMinutes: () => 0,
337
325
  workspaceCwd: () => this.cwd,
338
326
  });
339
- // 加载现有会话或创建初始会话
340
327
  const existing = this.store.listConversations(this.cwd);
341
328
  if (existing.length > 0) {
342
329
  for (const conv of existing) {
@@ -350,7 +337,6 @@ export class UniversalSession {
350
337
  this.conversations.set(initialConv.id, initialConv);
351
338
  this.store.saveConversation(this.cwd, initialConv);
352
339
  }
353
- // 记录当前客户端访问的工作区
354
340
  if (typeof this.stateStore?.remember === "function" && this.cwd) {
355
341
  this.stateStore.remember(this.clientId, this.cwd);
356
342
  }
@@ -362,7 +348,6 @@ export class UniversalSession {
362
348
  })
363
349
  .catch(() => { });
364
350
  }
365
- // 若驱动为 Claude Code,异步探测环境并下发安装指引
366
351
  if (this.driver instanceof ClaudeCodeDriver) {
367
352
  void probeClaudeCode().then((probe) => {
368
353
  if (!probe.installed && !this.disposed) {
@@ -502,9 +487,7 @@ export class UniversalSession {
502
487
  try {
503
488
  sink(msg);
504
489
  }
505
- catch {
506
- /* ignore send error on broken pipe */
507
- }
490
+ catch { }
508
491
  }
509
492
  }
510
493
  flushSnapshot(_forceFull = false) {
@@ -537,7 +520,6 @@ export class UniversalSession {
537
520
  messages: this.turnConvId === conv.id && this.pendingToolResults.length > 0
538
521
  ? [...conv.messages, ...this.pendingToolResults]
539
522
  : conv.messages,
540
- // 回合归属会话才携带流式态:切走后的前台会话快照不再混入后台回合内容(#701)
541
523
  streamingMessage: !this.turnConvId || this.turnConvId === conv.id ? this.streamingMessage : null,
542
524
  isStreaming: !this.turnConvId || this.turnConvId === conv.id ? this.isStreaming : false,
543
525
  turnTiming: conv.turnTiming ?? null,
@@ -591,9 +573,6 @@ export class UniversalSession {
591
573
  this.flushSnapshot();
592
574
  }, SNAPSHOT_INTERVAL_MS);
593
575
  }
594
- // ---------------------------------------------------------------------------
595
- // 核心 Prompt 流程
596
- // ---------------------------------------------------------------------------
597
576
  static isDefaultTitle(title) {
598
577
  const t = (title ?? "").trim();
599
578
  return !t || t === "新对话" || t === "New chat" || t === "New Chat" || t === "对话" || t === "Chat";
@@ -614,11 +593,9 @@ export class UniversalSession {
614
593
  this.emitNotice("info", "已加入排队,将在当前回复生成完成后自动发送", "Queued — will send after current response settles");
615
594
  return;
616
595
  }
617
- // 插队(steer):中断当前轮次并提交新问题
618
596
  this.emitNotice("info", "正在插队,中断当前生成并提交新问题...", "Steering: aborting current turn and submitting prompt...");
619
597
  await this.abort();
620
598
  }
621
- // 1. 拦截与执行斜杠命令(内置 / 插件 / 驱动扩展 / 技能指令 / 子代理命令)
622
599
  const slash = parseSlash(text);
623
600
  if (slash) {
624
601
  if (slash.name === "subagent" || slash.name.startsWith("subagent:")) {
@@ -667,7 +644,6 @@ export class UniversalSession {
667
644
  const isCurrent = () => this.turn === turn && !this.disposed;
668
645
  this.turnConvId = conv.id;
669
646
  const now = Date.now();
670
- // 2. 扫描用户文本中的 @ 提及(文件路径与技能指令)
671
647
  try {
672
648
  const availableSkills = await this.collectUniversalSkills();
673
649
  if (!isCurrent())
@@ -675,7 +651,6 @@ export class UniversalSession {
675
651
  const scanResult = scanAtMentions(text, turn.cwd, availableSkills, attachments ?? []);
676
652
  const effectiveAttachments = [...(attachments ?? []), ...scanResult.detectedAttachments];
677
653
  const finalPrompt = formatPromptWithSkills(text, scanResult.detectedSkills);
678
- // 3. 自动根据首条提问为新会话命名(首条提问立即刷新左侧栏运行与历史列表)
679
654
  const hasNoUserMessages = !conv.messages.some((m) => m.role === "user");
680
655
  if (UniversalSession.isDefaultTitle(conv.title) && hasNoUserMessages && text.trim()) {
681
656
  const trimmed = text.trim().replace(/\s+/g, " ");
@@ -689,7 +664,6 @@ export class UniversalSession {
689
664
  }
690
665
  void this.refreshSessions();
691
666
  }
692
- // 4. 插入用户消息以及附件卡片(保证 Web UI 附件卡片折叠呈现与历史复原)
693
667
  const userMsg = {
694
668
  id: `u-${now}-${randomUUID().slice(0, 6)}`,
695
669
  role: "user",
@@ -707,9 +681,7 @@ export class UniversalSession {
707
681
  if (!conv.isEphemeral) {
708
682
  this.store.saveConversation(this.cwd, conv);
709
683
  }
710
- // 用户发送了提示词,消费并清除当前会话的草稿
711
684
  this.sessionDrafts.delete(conv.id);
712
- // 确保底层驱动与当前对话的 driverSessionId 上下文同步(保证多轮对话连续且新建对话隔离)
713
685
  if (conv.driverSessionId) {
714
686
  await this.driver.resumeSession(conv.driverSessionId);
715
687
  if (!isCurrent())
@@ -724,7 +696,6 @@ export class UniversalSession {
724
696
  this.store.saveConversation(turn.cwd, conv);
725
697
  }
726
698
  }
727
- // 3. 准备助手流式消息
728
699
  const assistantMsgId = `a-${now}-${randomUUID().slice(0, 6)}`;
729
700
  this.streamingThinking = "";
730
701
  this.streamingText = "";
@@ -736,7 +707,6 @@ export class UniversalSession {
736
707
  model: this.currentModel,
737
708
  };
738
709
  this.flushSnapshot();
739
- // 4. 构建 AgentEventSink(时序保真:思考 -> 前置正文 -> 工具调用 -> 总结正文)
740
710
  const sink = {
741
711
  onSessionStarted: (sessionId) => {
742
712
  conv.driverSessionId = sessionId;
@@ -779,8 +749,6 @@ export class UniversalSession {
779
749
  argumentsText: JSON.stringify(args, null, 2),
780
750
  };
781
751
  this.streamingMessage.content.push(toolBlock);
782
- // Publish the structural boundary before a following text/thinking delta.
783
- // Otherwise the reducer can merge it into the block preceding this tool.
784
752
  this.flushSnapshot();
785
753
  },
786
754
  onToolEnd: (callId, result) => {
@@ -838,7 +806,6 @@ export class UniversalSession {
838
806
  if (this.streamingText) {
839
807
  content.push({ type: "text", text: this.streamingText });
840
808
  }
841
- // 保留之前追加的 toolCall blocks
842
809
  for (const b of this.streamingMessage.content) {
843
810
  if (b.type === "toolCall") {
844
811
  content.push(b);
@@ -877,7 +844,6 @@ export class UniversalSession {
877
844
  conv.messages.push(...this.pendingToolResults);
878
845
  this.pendingToolResults = [];
879
846
  }
880
- // 累计会话统计与上下文占用(底座统一驱动底栏上下文环、Token 计数、缓存命中率与累计成本)
881
847
  if (!conv.stats) {
882
848
  conv.stats = {
883
849
  tokens: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
@@ -904,7 +870,6 @@ export class UniversalSession {
904
870
  percent: totalCtx !== null && win > 0 ? Math.min(100, Math.round((totalCtx / win) * 100)) : null,
905
871
  };
906
872
  }
907
- // 回写 Claude 分配的 session ID(保证多轮上下文连续)
908
873
  if (typeof this.driver.getActiveSessionId === "function") {
909
874
  const activeSid = this.driver.getActiveSessionId();
910
875
  if (activeSid && conv.driverSessionId !== activeSid) {
@@ -914,23 +879,18 @@ export class UniversalSession {
914
879
  finishTurnTiming(conv);
915
880
  this.isStreaming = false;
916
881
  this.streamingThinking = "";
917
- // 先取本轮全文再清空:内联标记解析在清空之后读 streamingText,
918
- // 条件恒为 false,[[conv:rename]]/[[action:suggest]] 在 universal
919
- // 引擎(claude/durable 等驱动)下从不被解析。
920
882
  const finalText = this.streamingText;
921
883
  this.streamingText = "";
922
884
  conv.updatedAt = Date.now();
923
885
  if (!conv.isEphemeral) {
924
886
  this.store.saveConversation(turn.cwd, conv);
925
887
  }
926
- // 解析本轮生成的内联标记(如 [[conv:rename:...]] / [[action:suggest:...]])
927
888
  if (finalText && finalText.includes("[[")) {
928
889
  this.markerOrigins.set(conv.id, turn);
929
890
  void this.markerSvc.handleAssistantText(conv.id, finalText);
930
891
  }
931
892
  this.flushSnapshot();
932
893
  void this.refreshSessions();
933
- // 检查排队消息并自动处理
934
894
  if (!this.switchingProject && !this.disposed && this.followUpQueue.length > 0) {
935
895
  const next = this.followUpQueue.shift();
936
896
  this.flushSnapshot(true);
@@ -942,7 +902,6 @@ export class UniversalSession {
942
902
  return this.abortPromise;
943
903
  if (!this.isStreaming)
944
904
  return;
945
- // Install the gate before finalizeTurn can dispatch a queued prompt.
946
905
  this.abortPromise = Promise.resolve().then(async () => {
947
906
  this.finalizeTurn();
948
907
  await this.driver.abort();
@@ -960,7 +919,6 @@ export class UniversalSession {
960
919
  }
961
920
  async retryLast() {
962
921
  const conv = this.activeConv;
963
- // 找到最后一条 user 消息重新发送
964
922
  for (let i = conv.messages.length - 1; i >= 0; i--) {
965
923
  const m = conv.messages[i];
966
924
  if (m.role === "user") {
@@ -981,9 +939,6 @@ export class UniversalSession {
981
939
  }
982
940
  }
983
941
  }
984
- // ---------------------------------------------------------------------------
985
- // 对话生命周期
986
- // ---------------------------------------------------------------------------
987
942
  async newChat(_preset, ephemeral = false, onReady) {
988
943
  const newConv = this.createEmptyConversation("新对话", Boolean(ephemeral));
989
944
  this.conversations.set(newConv.id, newConv);
@@ -996,6 +951,16 @@ export class UniversalSession {
996
951
  onReady?.(newConv.id);
997
952
  return true;
998
953
  }
954
+ async readQuickAskConversation(source, signal) {
955
+ signal.throwIfAborted();
956
+ const id = source.conversationId ?? source.sessionFile;
957
+ if (!id ||
958
+ !/^[a-zA-Z0-9_-]+$/.test(id) ||
959
+ (source.conversationId && source.sessionFile && source.conversationId !== source.sessionFile))
960
+ return undefined;
961
+ const conv = this.conversations.get(id) ?? this.store.loadConversation(this.cwd, id);
962
+ return conv ? captureQuickAskConversation(conv.title, conv.id, conv.messages, this.cwd) : undefined;
963
+ }
999
964
  async switchConversation(id) {
1000
965
  assertEngineWorkspaceSupported(this.sandboxes, this.cwd, this.engine);
1001
966
  let conv = this.conversations.get(id);
@@ -1006,7 +971,6 @@ export class UniversalSession {
1006
971
  }
1007
972
  if (conv) {
1008
973
  this.activeConvId = conv.id;
1009
- // 同步底层驱动会话上下文(若存在)
1010
974
  if (conv.driverSessionId) {
1011
975
  await this.driver.resumeSession(conv.driverSessionId).catch(() => { });
1012
976
  }
@@ -1071,9 +1035,7 @@ export class UniversalSession {
1071
1035
  }
1072
1036
  async deleteSession(path) {
1073
1037
  const targetId = path.trim() || this.activeConvId;
1074
- // 1. 从磁盘删除持久化会话记录
1075
1038
  this.store.deleteConversation(this.cwd, targetId);
1076
- // 2. 若内存中存在该会话,将其从内存中移除
1077
1039
  if (this.conversations.has(targetId)) {
1078
1040
  await this.dismissConversation(targetId, true, true);
1079
1041
  }
@@ -1086,18 +1048,15 @@ export class UniversalSession {
1086
1048
  const conv = this.conversations.get(id);
1087
1049
  if (!conv)
1088
1050
  return;
1089
- // 若指定 withFinishedSubagents,级联清理该父会话下的已结束子代理
1090
1051
  if (withFinishedSubagents) {
1091
1052
  const kids = Array.from(this.conversations.values()).filter((c) => c.isSubagent && c.subagentParentId === id && !c.subagentStreaming);
1092
1053
  for (const kid of kids) {
1093
1054
  await this.dismissConversation(kid.id, false, force);
1094
1055
  }
1095
1056
  }
1096
- // 若清理的本身是运行中的子代理,立即中止并清理其驱动
1097
1057
  if (conv.isSubagent && conv.subagentStreaming) {
1098
1058
  await this.stopSubagent(id);
1099
1059
  }
1100
- // 仅从运行中会话映射与草稿中移除,保留磁盘持久化记录(供历史面板随时回溯打开)
1101
1060
  this.conversations.delete(id);
1102
1061
  this.sessionDrafts.delete(id);
1103
1062
  if (this.activeConvId === id) {
@@ -1158,7 +1117,6 @@ export class UniversalSession {
1158
1117
  if (!targetConv) {
1159
1118
  targetConv = this.activeConv;
1160
1119
  }
1161
- // 回滚与在途回合互斥:先落定在途回合再截断,否则 finalize 与 slice 交错导致截断/错位(#700)
1162
1120
  if (targetConv.id === this.activeConvId && (this.isStreaming || this.streamingMessage)) {
1163
1121
  await this.abort();
1164
1122
  targetConv = this.activeConv;
@@ -1169,7 +1127,6 @@ export class UniversalSession {
1169
1127
  this.flushSnapshot();
1170
1128
  return;
1171
1129
  }
1172
- // 回滚截断到该消息之前
1173
1130
  targetConv.messages = targetConv.messages.slice(0, idx);
1174
1131
  targetConv.updatedAt = Date.now();
1175
1132
  if (!targetConv.isEphemeral) {
@@ -1216,7 +1173,6 @@ export class UniversalSession {
1216
1173
  if (forkedMessages.length > 0) {
1217
1174
  forkedConv.updatedAt = Date.now();
1218
1175
  }
1219
- // 若底层驱动支持原生会话分叉(如 Durable 引擎的原生 CoW 分叉),保持事务级上下文关联
1220
1176
  if (targetConv.driverSessionId && typeof this.driver.forkSession === "function") {
1221
1177
  try {
1222
1178
  const forkedSid = await this.driver.forkSession(targetConv.driverSessionId);
@@ -1224,9 +1180,7 @@ export class UniversalSession {
1224
1180
  forkedConv.driverSessionId = forkedSid;
1225
1181
  }
1226
1182
  }
1227
- catch {
1228
- /* fallback */
1229
- }
1183
+ catch { }
1230
1184
  }
1231
1185
  this.conversations.set(forkedConv.id, forkedConv);
1232
1186
  if (!forkedConv.isEphemeral) {
@@ -1256,7 +1210,6 @@ export class UniversalSession {
1256
1210
  this.flushSnapshot();
1257
1211
  return;
1258
1212
  }
1259
- // Remove the question, its file asides and the abandoned suffix in place.
1260
1213
  let cutIdx = idx;
1261
1214
  while (cutIdx > 0 &&
1262
1215
  conv.messages[cutIdx - 1]?.role === "custom" &&
@@ -1264,8 +1217,6 @@ export class UniversalSession {
1264
1217
  cutIdx--;
1265
1218
  }
1266
1219
  conv.messages.splice(cutIdx);
1267
- // Drivers expose no in-place history replacement. A fresh backend handle
1268
- // prevents resume from restoring the discarded suffix; the UI identity stays.
1269
1220
  conv.driverSessionId = undefined;
1270
1221
  const context = conv.messages.map((m) => `[${m.role}] ${messageTextWithQuotes(m)}`).join("\n");
1271
1222
  conv.updatedAt = Date.now();
@@ -1275,7 +1226,6 @@ export class UniversalSession {
1275
1226
  }
1276
1227
  this.flushSnapshot(true);
1277
1228
  void this.refreshSessions();
1278
- // Capture the destination before any asynchronous slash/skill lookup.
1279
1229
  await this.prompt(text, attachments, undefined, conv, context ? `Previous conversation context:\n${context}` : "");
1280
1230
  }
1281
1231
  async refreshSessions() {
@@ -1316,7 +1266,6 @@ export class UniversalSession {
1316
1266
  isEphemeral: Boolean(c.isEphemeral),
1317
1267
  }));
1318
1268
  this.send({ type: "conversations", conversations: convs, activeId: this.activeConvId });
1319
- // 左侧栏历史对话读取的是 sessions 消息(轻量临时子代理不污染长期历史列表):
1320
1269
  const sessionSummaries = allList
1321
1270
  .filter((c) => !c.isSubagent || !c.isEphemeral)
1322
1271
  .map((c) => {
@@ -1339,7 +1288,6 @@ export class UniversalSession {
1339
1288
  });
1340
1289
  this.send({ type: "sessions", sessions: sessionSummaries });
1341
1290
  }
1342
- /** 引擎自属的会话展示名解析回调(定制 Universal/Claude 的首条截断 + 自定义命名策略) */
1343
1291
  resolveSessionDisplayName(conv, firstMsg) {
1344
1292
  if (conv.title && !UniversalSession.isDefaultTitle(conv.title)) {
1345
1293
  return conv.title;
@@ -1432,9 +1380,6 @@ export class UniversalSession {
1432
1380
  this.send({ type: "session_search_results", reqId, query, ok: false, results: [] });
1433
1381
  }
1434
1382
  }
1435
- // ---------------------------------------------------------------------------
1436
- // 文件、终端与 Git SCM 委托
1437
- // ---------------------------------------------------------------------------
1438
1383
  async listFiles(path) {
1439
1384
  await this.files.listFiles(path);
1440
1385
  }
@@ -1485,9 +1430,6 @@ export class UniversalSession {
1485
1430
  getTerminalCwd() {
1486
1431
  return this.cwd;
1487
1432
  }
1488
- // ---------------------------------------------------------------------------
1489
- // 后台服务生命周期委托
1490
- // ---------------------------------------------------------------------------
1491
1433
  async killBackgroundServer(port, _taskId) {
1492
1434
  if (port === undefined)
1493
1435
  return false;
@@ -1512,9 +1454,6 @@ export class UniversalSession {
1512
1454
  const minutes = Number.isFinite(override) && override > 0 ? override : 30;
1513
1455
  return this.bg.cleanStale(minutes * 60_000, { manual: true });
1514
1456
  }
1515
- // ---------------------------------------------------------------------------
1516
- // 模型与偏好控制
1517
- // ---------------------------------------------------------------------------
1518
1457
  async listModels() {
1519
1458
  if (this.driver.listModels) {
1520
1459
  const models = await this.driver.listModels();
@@ -1554,12 +1493,10 @@ export class UniversalSession {
1554
1493
  if (this.driver.setModel) {
1555
1494
  await this.driver.setModel(modelId);
1556
1495
  }
1557
- // 优先恢复该模型的全局思考强度记忆或全局默认强度
1558
1496
  const remembered = getModelThinkingLevelFromSettings(modelId, this.agentDir);
1559
1497
  if (remembered) {
1560
1498
  this.thinkingLevel = remembered;
1561
1499
  }
1562
- // 校验并平滑适应新模型支持的思考强度
1563
1500
  if (typeof this.driver.getSupportedThinkingLevels === "function") {
1564
1501
  const supported = this.driver.getSupportedThinkingLevels(modelId);
1565
1502
  if (supported.length > 0 && !supported.includes(this.thinkingLevel)) {
@@ -1595,7 +1532,6 @@ export class UniversalSession {
1595
1532
  if (typeof this.driver.setThinkingLevel === "function") {
1596
1533
  this.driver.setThinkingLevel(level);
1597
1534
  }
1598
- // 同步持久化至全局 settings.json 的 modelThinkingLevels
1599
1535
  if (this.currentModel) {
1600
1536
  saveModelThinkingLevelToSettings(this.currentModel, level, this.agentDir);
1601
1537
  }
@@ -1607,7 +1543,6 @@ export class UniversalSession {
1607
1543
  throw new Error("Workspace switch already in progress");
1608
1544
  this.switchingProject = true;
1609
1545
  try {
1610
- // Finish the captured old turn before replacing the driver's workspace.
1611
1546
  this.followUpQueue = [];
1612
1547
  await this.abort();
1613
1548
  for (const id of this.subagentDrivers.keys())
@@ -1615,7 +1550,6 @@ export class UniversalSession {
1615
1550
  this.projectGeneration++;
1616
1551
  this.cwd = path;
1617
1552
  this.driver.setCwd(path);
1618
- // 切换工作区 CWD:清空旧目录会话缓存与草稿,并加载属于新目录的会话
1619
1553
  this.conversations.clear();
1620
1554
  this.sessionDrafts.clear();
1621
1555
  const existing = this.store.listConversations(this.cwd);
@@ -1637,7 +1571,6 @@ export class UniversalSession {
1637
1571
  this.stateStore.remember(this.clientId, path);
1638
1572
  }
1639
1573
  void this.pushProjects();
1640
- // 切换目录后恢复该目录按引擎隔离的项目记忆模型
1641
1574
  const savedModel = this.stateStore?.getProjectModel(this.clientId, path, this.engine) ??
1642
1575
  this.stateStore?.getDefaultModel(this.engine);
1643
1576
  if (savedModel && savedModel !== this.currentModel) {
@@ -1663,11 +1596,9 @@ export class UniversalSession {
1663
1596
  this.worktreeInfo = info;
1664
1597
  this.flushSnapshot();
1665
1598
  }
1666
- /** 获取通用底座持有的持久终端交互工具集 */
1667
1599
  getTerminalTools() {
1668
1600
  return makePersistentTerminalTools(this.terminals, this.cwd, () => this.lang);
1669
1601
  }
1670
- /** 执行通用底座持久终端工具(供外部驱动或模型调用) */
1671
1602
  async execTerminalTool(name, args, signal) {
1672
1603
  const tools = this.getTerminalTools();
1673
1604
  const tool = tools.find((t) => t.name === name);
@@ -1882,9 +1813,6 @@ export class UniversalSession {
1882
1813
  async makeDir(path) {
1883
1814
  await this.files.makeDir(path);
1884
1815
  }
1885
- // ---------------------------------------------------------------------------
1886
- // 辅助方法与空实现
1887
- // ---------------------------------------------------------------------------
1888
1816
  emitNotice(level, text, textEn) {
1889
1817
  this.send({ type: "notice", level, text, textEn });
1890
1818
  }
@@ -1919,9 +1847,7 @@ export class UniversalSession {
1919
1847
  }
1920
1848
  }
1921
1849
  }
1922
- catch {
1923
- /* ignore driver model query error */
1924
- }
1850
+ catch { }
1925
1851
  }
1926
1852
  return out;
1927
1853
  }
@@ -1942,9 +1868,7 @@ export class UniversalSession {
1942
1868
  }
1943
1869
  }
1944
1870
  }
1945
- catch {
1946
- /* ignore driver skills query error */
1947
- }
1871
+ catch { }
1948
1872
  }
1949
1873
  this.skillsCache = out;
1950
1874
  return out;
@@ -1985,9 +1909,7 @@ export class UniversalSession {
1985
1909
  async listCommands() {
1986
1910
  this.send({ type: "commands", commands: [], path: "" });
1987
1911
  }
1988
- async saveCommands(_commands) {
1989
- /* no-op */
1990
- }
1912
+ async saveCommands(_commands) { }
1991
1913
  refreshSettings() {
1992
1914
  this.pushSettings();
1993
1915
  }
@@ -2003,6 +1925,7 @@ export class UniversalSession {
2003
1925
  disabledExtensions: s?.disabledExtensions ?? [],
2004
1926
  disabledAgentTools: [],
2005
1927
  disabledPluginTools: [],
1928
+ nativeCliInheritModel: { ...s?.nativeCliInheritModel },
2006
1929
  terminalToolsEnabled: s?.terminalToolsEnabled ?? true,
2007
1930
  terminalBash: s?.terminalBash ?? true,
2008
1931
  terminalBashIdleMs: s?.terminalBashIdleMs ?? 3000,
@@ -2010,7 +1933,6 @@ export class UniversalSession {
2010
1933
  toolWatchdogTimeoutMs: s?.toolWatchdogTimeoutMs ?? 1200000,
2011
1934
  readDirEnabled: true,
2012
1935
  bgAutoCleanupMin: s?.bgAutoCleanupMin ?? 0,
2013
- // 同一字段的含义在本引擎不适用(无 pi 工具注册面):恒为 false 占位,保协议完整。
2014
1936
  toolLazyLoading: false,
2015
1937
  codemodeMode: "on",
2016
1938
  codemodeInlineBudget: 3000,
@@ -2093,15 +2015,9 @@ export class UniversalSession {
2093
2015
  }
2094
2016
  this.pushSettings();
2095
2017
  }
2096
- async reloadExtensions() {
2097
- /* no-op */
2098
- }
2099
- async checkUpdate() {
2100
- /* no-op */
2101
- }
2102
- async checkUpdatesAll() {
2103
- /* no-op */
2104
- }
2018
+ async reloadExtensions() { }
2019
+ async checkUpdate() { }
2020
+ async checkUpdatesAll() { }
2105
2021
  resolveDialog(id, value) {
2106
2022
  this.webUi.resolveDialog(id, value);
2107
2023
  }
@@ -2115,7 +2031,6 @@ export class UniversalSession {
2115
2031
  this.webUi.handleTuiOverlayCancel(id);
2116
2032
  }
2117
2033
  installPiAgent() {
2118
- /* no-op */
2119
2034
  return Promise.resolve();
2120
2035
  }
2121
2036
  setProviderApiKey(provider, apiKey) {
@@ -2195,15 +2110,12 @@ export class UniversalSession {
2195
2110
  return Promise.resolve();
2196
2111
  }
2197
2112
  clearGoal() {
2198
- /* no-op */
2199
2113
  return Promise.resolve();
2200
2114
  }
2201
2115
  startGoalWizard() {
2202
- /* no-op */
2203
2116
  return Promise.resolve();
2204
2117
  }
2205
2118
  setGoalPrefs() {
2206
- /* no-op */
2207
2119
  return Promise.resolve();
2208
2120
  }
2209
2121
  async savePreset(name) {
@@ -2241,7 +2153,6 @@ export class UniversalSession {
2241
2153
  this.emitNotice("error", `未找到名为「${name}」的设置预设`, `Settings preset "${name}" not found`);
2242
2154
  return;
2243
2155
  }
2244
- // Missing settings retain their current values; metadata never enters settings.
2245
2156
  const { settings } = sanitizePresetSettings(found);
2246
2157
  this.stateStore.saveSettings(this.clientId, settings);
2247
2158
  this.pushSettings();
@@ -2441,10 +2352,6 @@ export class UniversalSession {
2441
2352
  error: res.error,
2442
2353
  });
2443
2354
  }
2444
- // ---------------------------------------------------------------------------
2445
- // 通用底座第一方子代理(Subagent)生命周期与调度管理
2446
- // ---------------------------------------------------------------------------
2447
- /** 统计当前活跃(流式运行中)的子代理数量 */
2448
2355
  getLiveSubagentsCount() {
2449
2356
  let count = 0;
2450
2357
  for (const conv of this.conversations.values()) {
@@ -2454,7 +2361,6 @@ export class UniversalSession {
2454
2361
  }
2455
2362
  return count;
2456
2363
  }
2457
- /** 创建并启动一个子代理会话 */
2458
2364
  async spawnSubagent(prompt, type, cwd, templateName, model, parentId, persist = false, title, _thinking, _notifyOnDone) {
2459
2365
  if (_notifyOnDone === "manual") {
2460
2366
  throw new Error("notifyOnDone=manual is only supported by the pi engine.");
@@ -2468,7 +2374,6 @@ export class UniversalSession {
2468
2374
  if (liveCount >= maxSubagents) {
2469
2375
  throw new Error(pick(this.lang, `同时运行的子代理数量已达上限(${maxSubagents} 个),请先用 wait 等一部分完成、或用 stop 停掉不需要的再派发`, `Active subagent limit reached (${maxSubagents} live). Wait for some with wait_all or stop unneeded ones with stop before spawning more`));
2470
2376
  }
2471
- // 检查并解析模板
2472
2377
  let template;
2473
2378
  let effectivePrompt = prompt;
2474
2379
  if (templateName) {
@@ -2525,7 +2430,6 @@ export class UniversalSession {
2525
2430
  }
2526
2431
  this.flushSnapshot();
2527
2432
  void this.refreshSessions();
2528
- // 为该子代理创建独立的 Driver 实例
2529
2433
  let subDriver;
2530
2434
  if (this.driverFactory) {
2531
2435
  subDriver = this.driverFactory(targetCwd);
@@ -2542,22 +2446,17 @@ export class UniversalSession {
2542
2446
  subDriver = this.driver;
2543
2447
  }
2544
2448
  this.subagentDrivers.set(convId, subDriver);
2545
- // 若驱动支持 setModel,应用子代理指定的模型
2546
2449
  if (effectiveModel && subDriver.setModel) {
2547
2450
  try {
2548
2451
  await subDriver.setModel(effectiveModel);
2549
2452
  }
2550
- catch {
2551
- // 驱动不支持或模型设置失败时平滑降级
2552
- }
2453
+ catch { }
2553
2454
  }
2554
2455
  if (this.disposed || generation !== this.projectGeneration || this.subagentDrivers.get(convId) !== subDriver)
2555
2456
  return { convId };
2556
- // 异步启动子代理执行流程
2557
2457
  void this.runSubagent(convId, subDriver, effectivePrompt, targetCwd);
2558
2458
  return { convId };
2559
2459
  }
2560
- /** 后台异步执行子代理 Prompt */
2561
2460
  async runSubagent(convId, subDriver, prompt, cwd) {
2562
2461
  const conv = this.conversations.get(convId);
2563
2462
  if (!conv)
@@ -2590,7 +2489,6 @@ export class UniversalSession {
2590
2489
  assistantMsg.content.push({ type: "thinking", thinking: delta });
2591
2490
  }
2592
2491
  if (this.activeConvId === convId) {
2593
- // Subagents stream through conv.messages snapshots, not the main turn's message.
2594
2492
  this.scheduleThrottledSnapshot();
2595
2493
  }
2596
2494
  },
@@ -2654,9 +2552,7 @@ export class UniversalSession {
2654
2552
  try {
2655
2553
  void subDriver.dispose();
2656
2554
  }
2657
- catch {
2658
- // 忽略 dispose 异常
2659
- }
2555
+ catch { }
2660
2556
  this.notifySubagentWaitListeners();
2661
2557
  this.flushSnapshot();
2662
2558
  void this.refreshSessions();
@@ -2674,9 +2570,7 @@ export class UniversalSession {
2674
2570
  try {
2675
2571
  void subDriver.dispose();
2676
2572
  }
2677
- catch {
2678
- // 忽略 dispose 异常
2679
- }
2573
+ catch { }
2680
2574
  this.notifySubagentWaitListeners();
2681
2575
  this.flushSnapshot();
2682
2576
  void this.refreshSessions();
@@ -2705,7 +2599,6 @@ export class UniversalSession {
2705
2599
  sink.onError(msg);
2706
2600
  }
2707
2601
  }
2708
- /** 获取单个子代理运行态快照结果 */
2709
2602
  async getSubagentResult(convId) {
2710
2603
  const conv = this.conversations.get(convId);
2711
2604
  if (!conv || !conv.isSubagent) {
@@ -2713,7 +2606,6 @@ export class UniversalSession {
2713
2606
  }
2714
2607
  return this.subagentToSnapshot(conv);
2715
2608
  }
2716
- /** 提取子代理会话的最终 assistant 正文输出 */
2717
2609
  extractSubagentOutput(conv) {
2718
2610
  const assistantMsgs = conv.messages.filter((m) => m.role === "assistant");
2719
2611
  const pieces = [];
@@ -2726,7 +2618,6 @@ export class UniversalSession {
2726
2618
  }
2727
2619
  return pieces.join("\n").trim();
2728
2620
  }
2729
- /** 将 UniversalConversation 转换成标准 SubagentSnapshot */
2730
2621
  subagentToSnapshot(conv) {
2731
2622
  const output = this.extractSubagentOutput(conv);
2732
2623
  const state = conv.subagentState ?? (conv.subagentStreaming ? "running" : conv.subagentCanceled ? "canceled" : "done");
@@ -2748,7 +2639,6 @@ export class UniversalSession {
2748
2639
  handoffFrom: conv.subagentHandoffFrom ? [...conv.subagentHandoffFrom] : undefined,
2749
2640
  };
2750
2641
  }
2751
- /** 停止指定的子代理运行 */
2752
2642
  async stopSubagent(convId) {
2753
2643
  const conv = this.conversations.get(convId);
2754
2644
  if (!conv)
@@ -2764,15 +2654,12 @@ export class UniversalSession {
2764
2654
  await driver.abort();
2765
2655
  void driver.dispose();
2766
2656
  }
2767
- catch {
2768
- // 忽略驱动中止失败
2769
- }
2657
+ catch { }
2770
2658
  }
2771
2659
  this.notifySubagentWaitListeners();
2772
2660
  this.flushSnapshot();
2773
2661
  void this.refreshSessions();
2774
2662
  }
2775
- /** 等待指定的子代理到达终态 */
2776
2663
  async waitSubagents(timeoutSeconds, runIds, callerId) {
2777
2664
  const waitCapMs = computeWaitCapMs();
2778
2665
  const requestedMs = typeof timeoutSeconds === "number" && timeoutSeconds > 0 ? Math.floor(timeoutSeconds * 1000) : waitCapMs;
@@ -2825,18 +2712,14 @@ export class UniversalSession {
2825
2712
  this.subagentWaitListeners.add(onUpdate);
2826
2713
  });
2827
2714
  }
2828
- /** 唤醒所有等待中的子代理监听者 */
2829
2715
  notifySubagentWaitListeners() {
2830
2716
  for (const listener of this.subagentWaitListeners) {
2831
2717
  try {
2832
2718
  listener();
2833
2719
  }
2834
- catch {
2835
- // 忽略监听者异常
2836
- }
2720
+ catch { }
2837
2721
  }
2838
2722
  }
2839
- /** 列出子代理快照列表 */
2840
2723
  listSubagents(scope = "all") {
2841
2724
  const snaps = [];
2842
2725
  for (const conv of this.conversations.values()) {
@@ -2850,7 +2733,6 @@ export class UniversalSession {
2850
2733
  }
2851
2734
  return snaps;
2852
2735
  }
2853
- /** 向指定子代理发送引导/追加消息 */
2854
2736
  async steerSubagent(convId, message) {
2855
2737
  const conv = this.conversations.get(convId);
2856
2738
  if (!conv || !conv.isSubagent) {
@@ -2865,7 +2747,6 @@ export class UniversalSession {
2865
2747
  conv.updatedAt = Date.now();
2866
2748
  this.flushSnapshot();
2867
2749
  }
2868
- /** 跨代理协作交接 */
2869
2750
  async handoffSubagent(fromRunId, toRunId, payload) {
2870
2751
  const fromConv = this.conversations.get(fromRunId);
2871
2752
  const toConv = this.conversations.get(toRunId);
@@ -2882,7 +2763,6 @@ export class UniversalSession {
2882
2763
  timestamp: Date.now(),
2883
2764
  };
2884
2765
  this.subagentHandoffs = recordSubagentHandoff(this.subagentHandoffs, record, 50);
2885
- // 向目标子代理注入交接卡片消息
2886
2766
  const now = Date.now();
2887
2767
  const fromType = fromConv?.subagentType ?? "peer";
2888
2768
  toConv.messages.push({
@@ -2907,9 +2787,7 @@ export class UniversalSession {
2907
2787
  void driver.abort();
2908
2788
  void driver.dispose();
2909
2789
  }
2910
- catch {
2911
- // 忽略驱动释放异常
2912
- }
2790
+ catch { }
2913
2791
  }
2914
2792
  this.subagentDrivers.clear();
2915
2793
  this.subagentWaitListeners.clear();