pi-web-ui 0.116.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 (529) hide show
  1. package/CHANGELOG.md +83 -3
  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 +163 -36
  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 +184 -504
  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 +203 -371
  14. package/dist/server/agent-service.js +1281 -3030
  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 +42 -114
  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 +36 -214
  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 +38 -92
  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 +142 -68
  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 +48 -9
  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 +27 -11
  69. package/dist/server/device-center/collab-tool.js +393 -27
  70. package/dist/server/device-center/connector.js +128 -48
  71. package/dist/server/device-center/delivery-authority.js +95 -0
  72. package/dist/server/device-center/delivery-subject.js +29 -0
  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 +452 -208
  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 +15 -6
  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 +46 -31
  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 +13 -15
  101. package/dist/server/device-center/hub-deliveries.js +119 -15
  102. package/dist/server/device-center/hub-integration.js +647 -334
  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 +28 -9
  107. package/dist/server/device-center/hub-setup.js +23 -7
  108. package/dist/server/device-center/hub-transaction-log.js +175 -0
  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 +946 -404
  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 +111 -0
  115. package/dist/server/device-center/local-hub.js +6 -4
  116. package/dist/server/device-center/local-publication.js +416 -0
  117. package/dist/server/device-center/local-verification-job.js +95 -0
  118. package/dist/server/device-center/local-verification.js +273 -0
  119. package/dist/server/device-center/local.js +341 -18
  120. package/dist/server/device-center/main.js +18 -2
  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 +52 -46
  125. package/dist/server/device-center/path-portal.js +42 -12
  126. package/dist/server/device-center/publication-journal.js +305 -0
  127. package/dist/server/device-center/publish-intent.js +374 -0
  128. package/dist/server/device-center/relay.js +217 -52
  129. package/dist/server/device-center/report-upload.js +0 -1
  130. package/dist/server/device-center/runtime.js +419 -52
  131. package/dist/server/device-center/store.js +223 -65
  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 +68 -0
  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 +569 -227
  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 +335 -0
  143. package/dist/server/device-center/task-state.js +0 -12
  144. package/dist/server/device-center/task-workspace.js +393 -0
  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 +9 -0
  148. package/dist/server/device-center/work-contract.js +923 -0
  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 +202 -29
  152. package/dist/server/dispatch-plugin-handlers.js +2 -19
  153. package/dist/server/dsh/dsh-agent-service.js +78 -601
  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 +199 -677
  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 +6 -45
  247. package/dist/server/patch-remote-catalog.js +4 -34
  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 +24 -61
  282. package/dist/server/preset-plugin-dependencies.js +0 -2
  283. package/dist/server/preset-share.js +4 -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 +61 -0
  295. package/dist/server/quick-ask.js +260 -0
  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 +55 -31
  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 +32 -56
  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 +215 -0
  318. package/dist/server/session-open.js +69 -0
  319. package/dist/server/session-parser.js +4 -54
  320. package/dist/server/session-scan.js +81 -45
  321. package/dist/server/session-search.js +0 -56
  322. package/dist/server/settings-service.js +19 -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 +3 -40
  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 +55 -0
  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 +98 -194
  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 +30 -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 +373 -0
  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 +55 -6
  387. package/docs/device-center.md +57 -23
  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 +9 -6
  393. package/plugin-sdk/README.md +22 -8
  394. package/plugin-sdk/client-utils.mjs +0 -7
  395. package/plugin-sdk/client.d.ts +26 -0
  396. package/plugin-sdk/client.mjs +52 -0
  397. package/plugin-sdk/import-check.mjs +4 -51
  398. package/plugin-sdk/index.d.ts +128 -117
  399. package/plugin-sdk/index.mjs +2 -687
  400. package/plugin-sdk/package.json +15 -4
  401. package/plugin-sdk/ssh-host-trust.mjs +0 -12
  402. package/plugin-sdk/testing.d.ts +9 -0
  403. package/plugin-sdk/testing.mjs +511 -0
  404. package/plugins/catalog.json +52 -4
  405. package/plugins/superagent/README.md +110 -0
  406. package/plugins/superagent/client/entry.mjs +21 -0
  407. package/plugins/superagent/index.mjs +8 -0
  408. package/plugins/superagent/main.mjs +218 -0
  409. package/plugins/superagent/manifest.json +15 -0
  410. package/plugins/superagent/server.mjs +572 -0
  411. package/plugins/superagent/style.css +167 -0
  412. package/themes/aetheris.css +1 -31
  413. package/themes/ayu-light.css +0 -1
  414. package/themes/bases/flow-base.css +2 -83
  415. package/themes/bases/obsidian-base.css +2 -37
  416. package/themes/bases/statusbar-flat-base.css +0 -1
  417. package/themes/bases/zhujian-base.css +0 -63
  418. package/themes/bases/zhupi-base.css +0 -64
  419. package/themes/catppuccin-latte.css +0 -1
  420. package/themes/catppuccin.css +0 -1
  421. package/themes/claude-code-dark.css +0 -1
  422. package/themes/codex.css +0 -1
  423. package/themes/dark-teal.css +22 -54
  424. package/themes/everforest-light.css +0 -1
  425. package/themes/flow-cristallo.css +160 -0
  426. package/themes/flow-ink.css +160 -0
  427. package/themes/flow-light.css +1 -10
  428. package/themes/flow-obsidian.css +160 -0
  429. package/themes/flow-zurich.css +160 -0
  430. package/themes/flow.css +1 -9
  431. package/themes/geist.css +0 -1
  432. package/themes/gruvbox-light.css +0 -1
  433. package/themes/kanagawa-lotus.css +0 -1
  434. package/themes/md-preview.css +1 -2
  435. package/themes/mist.css +0 -1
  436. package/themes/nord.css +0 -1
  437. package/themes/one-dark.css +0 -1
  438. package/themes/paper.css +0 -1
  439. package/themes/rose-pine-dawn.css +0 -1
  440. package/themes/sakura.css +0 -1
  441. package/themes/solarized-light.css +0 -1
  442. package/themes/tokyo-night.css +0 -1
  443. package/themes/translucent.css +4 -35
  444. package/themes/transparent.css +4 -41
  445. package/themes/vs-code-dark.css +0 -1
  446. package/themes/wallpaper-flow.css +3 -17
  447. package/themes/wallpaper-obsidian.css +1 -4
  448. package/themes/white.css +0 -1
  449. package/web/dist/.build-assets.json +1 -1
  450. package/web/dist/assets/{BgTasksModal-BDoOpj-F.js → BgTasksModal-D-x7kA63.js} +1 -1
  451. package/web/dist/assets/CanvasStudio-CAWcs9tm.js +1579 -0
  452. package/web/dist/assets/DeviceCenter-Dc0whRcu.js +3 -0
  453. package/web/dist/assets/DeviceExecutionSettings-BoX7-0h7.js +1 -0
  454. package/web/dist/assets/DeviceGroups-C_fZMNeK.js +1 -0
  455. package/web/dist/assets/{Dropdown-C4LIhshN.js → Dropdown-CTgVLUbp.js} +1 -1
  456. package/web/dist/assets/FilePreview-C6W0PvaK.js +2 -0
  457. package/web/dist/assets/GlobalSearchModal-HR9LSspC.js +1 -0
  458. package/web/dist/assets/GroupConversation-C81YjF2C.js +61 -0
  459. package/web/dist/assets/GroupWorkItems-BIvZtr10.js +1 -0
  460. package/web/dist/assets/{HintTip-c6d0TJoh.js → HintTip-Da6qc566.js} +1 -1
  461. package/web/dist/assets/ModelConfigModal-DhSyuIuV.js +2 -0
  462. package/web/dist/assets/NativeCliPanel-CU1rZmyu.js +5 -0
  463. package/web/dist/assets/{PiSetupModal-BmMrrgB9.js → PiSetupModal-DZKY5Wiw.js} +1 -1
  464. package/web/dist/assets/ProviderOAuthControls-CIL85nA7.js +1 -0
  465. package/web/dist/assets/SCMPanel-CuEgzAlO.js +2 -0
  466. package/web/dist/assets/SettingsModal-Cdu5h29p.js +33 -0
  467. package/web/dist/assets/TermXterm-Bt5WKAxP.js +3 -0
  468. package/web/dist/assets/TerminalPanel-BCIBV8se.js +1 -0
  469. package/web/dist/assets/TuiOverlayModal-3NDd9T97.js +1 -0
  470. package/web/dist/assets/app-globals-CZjFtI4F.js +129 -0
  471. package/web/dist/assets/canvas-client-WkhM55mR.js +1 -0
  472. package/web/dist/assets/composer-bridge-CImnjDHq.js +1 -0
  473. package/web/dist/assets/desktop-B8NZ3KW-.js +1 -0
  474. package/web/dist/assets/index-CQc3VrWa.css +1 -0
  475. package/web/dist/assets/index-D_AGu4Zv.js +404 -0
  476. package/web/dist/assets/plugin-host-uqZGpvCs.js +1 -0
  477. package/web/dist/assets/{remote-ssh-client-CfYSMEZg.js → remote-ssh-client-Cdf-cTUe.js} +1 -1
  478. package/web/dist/assets/theme-DGL7hLUs.js +1 -0
  479. package/web/dist/index.html +12 -11
  480. package/web/dist/sw.js +15 -61
  481. package/web/public/sw.js +14 -60
  482. package/dist/gh-comment-781.md +0 -5
  483. package/dist/server/device-center/local-page.js +0 -17
  484. package/dist/server/device-center/smoke-preview.js +0 -3
  485. package/dist/server/durable/durable-capabilities.js +0 -11
  486. package/dist/server/markers/builtins/services.js +0 -123
  487. package/dist/server/markers/builtins/todo.js +0 -189
  488. package/dist/server/markers-list-tool.js +0 -34
  489. package/dist/server/orchestrator.js +0 -109
  490. package/dist/server/patch-turn-end-boundary.js +0 -77
  491. package/dist/server/system-prompt-soul.js +0 -41
  492. package/dist/server/univer-service.js +0 -448
  493. package/dist/server/universal/drivers/dsh-driver.js +0 -379
  494. package/dist/test-artifact.md +0 -9
  495. package/dist/test-preview-modal.md +0 -11
  496. package/dist/test-report.html +0 -20
  497. package/web/dist/assets/BgTasksModal-C0i3O1FT.js +0 -1
  498. package/web/dist/assets/CanvasStudio-B8thymBN.js +0 -1579
  499. package/web/dist/assets/CanvasStudio-zSxyIx1R.js +0 -1579
  500. package/web/dist/assets/DeviceCenter-DfAHKcid.js +0 -3
  501. package/web/dist/assets/DeviceCenter-ydvOTlzE.js +0 -3
  502. package/web/dist/assets/DeviceExecutionSettings-q5Ik8oXg.js +0 -1
  503. package/web/dist/assets/DeviceGroups-CI14_SRb.js +0 -1
  504. package/web/dist/assets/DeviceGroups-DvsB5IEU.js +0 -1
  505. package/web/dist/assets/FilePreview-BgGongmv.js +0 -2
  506. package/web/dist/assets/FilePreview-D4NrhF-U.js +0 -2
  507. package/web/dist/assets/GlobalSearchModal-BWgU8yPd.js +0 -1
  508. package/web/dist/assets/GlobalSearchModal-F7fNimKk.js +0 -1
  509. package/web/dist/assets/GroupConversation-Dh71Pdb-.js +0 -17
  510. package/web/dist/assets/GroupConversation-ZK3nRmNm.js +0 -17
  511. package/web/dist/assets/ModelConfigModal-YVEgyy34.js +0 -2
  512. package/web/dist/assets/ModelConfigModal-vWtg3srp.js +0 -2
  513. package/web/dist/assets/ProviderOAuthControls-BGSBIKD7.js +0 -1
  514. package/web/dist/assets/SCMPanel-B8_EDxNr.js +0 -2
  515. package/web/dist/assets/SCMPanel-BU58qk3T.js +0 -2
  516. package/web/dist/assets/SettingsModal-CMUybq3J.js +0 -32
  517. package/web/dist/assets/SettingsModal-OBmGTh-5.js +0 -32
  518. package/web/dist/assets/TerminalPanel-0CYvD72B.js +0 -3
  519. package/web/dist/assets/TerminalPanel-DDavKvFr.js +0 -3
  520. package/web/dist/assets/TuiOverlayModal-BsA-QTvN.js +0 -1
  521. package/web/dist/assets/TuiOverlayModal-DzoVQBuG.js +0 -1
  522. package/web/dist/assets/app-globals-CZxzGvIo.js +0 -123
  523. package/web/dist/assets/canvas-client-CUnXlQYX.js +0 -1
  524. package/web/dist/assets/desktop-aAKpvKJV.js +0 -1
  525. package/web/dist/assets/index-C6DwztqE.css +0 -1
  526. package/web/dist/assets/index-CuN802Sj.js +0 -93
  527. package/web/dist/assets/index-EH5Fw9fa.js +0 -93
  528. package/web/dist/assets/plugin-host-BRWib9DF.js +0 -1
  529. package/web/dist/assets/theme-D2l_mLNo.js +0 -1
@@ -1,17 +1,3 @@
1
- /**
2
- * lsp-tool.ts — 导出给 AI Agent 的原生 LSP 语言服务器工具(Native Opt-in LSP Tool)。
3
- *
4
- * 核心设计:
5
- * - 零重型外部依赖:基于 Node.js 标准流与原生 JSON-RPC 2.0 实现轻量级 LSP 客户端。
6
- * - 多会话共享池(Project-level Pool):同项目多会话与并发子代理复用同一个后台语言服务器实例,
7
- * 避免多子代理重复拉起语言服务器导致内存爆炸(参考 omp 的 lspmux 理念)。
8
- * - 支持 4 大核心语义动作:
9
- * 1. definition:跳转到符号定义位置(支持展示定义代码片段);
10
- * 2. references:列出工作区内所有引用/调用处;
11
- * 3. hover:获取类型签名与文档说明(Docstring/Markdown);
12
- * 4. diagnostics:获取文件或项目的实时编译与类型检查错误。
13
- * - 闲置自动回收:15 分钟无请求自动休眠退出,释放系统内存。
14
- */
15
1
  import { spawn } from "node:child_process";
16
2
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
17
3
  import { homedir } from "node:os";
@@ -132,12 +118,10 @@ function getLanguageForPath(filePath) {
132
118
  return { langKey: "cpp", config: LANGUAGE_SERVER_CATALOG.cpp };
133
119
  return null;
134
120
  }
135
- /** 二进制探测结果的内存缓存(cwd + cmd 为 key;用户态安装成功后按包失效) */
136
121
  const resolveBinaryCache = new Map();
137
122
  export function clearResolveBinaryCache() {
138
123
  resolveBinaryCache.clear();
139
124
  }
140
- /** 探测二进制是否可在当前系统执行(优先项目本地、Pi 生态共享目录、用户态托管目录、系统 PATH) */
141
125
  export function resolveBinary(cmd, cwd) {
142
126
  const cacheKey = `${cwd}::${cmd}`;
143
127
  const cached = resolveBinaryCache.get(cacheKey);
@@ -161,14 +145,12 @@ function resolveBinaryUncached(cmd, cwd) {
161
145
  }
162
146
  return null;
163
147
  }
164
- // 1. 本地 workspace node_modules/.bin 优先
165
148
  const localBinDir = resolve(cwd, "node_modules", ".bin");
166
149
  for (const ext of exts) {
167
150
  const target = join(localBinDir, cmd + ext);
168
151
  if (existsSync(target))
169
152
  return target;
170
153
  }
171
- // 2. Pi 生态工具与用户态目录(pi-lens / pi-web 用户态托管,零权限直接复用)
172
154
  const home = homedir();
173
155
  const sharedDirs = [
174
156
  join(home, ".pi-lens", "tools", "node_modules", ".bin"),
@@ -182,7 +164,6 @@ function resolveBinaryUncached(cmd, cwd) {
182
164
  return target;
183
165
  }
184
166
  }
185
- // 3. 遍历系统 PATH 目录(纯文件系统检查,零子进程开销、杜绝 Windows cmd.exe 引号卡死)
186
167
  const pathDirs = (process.env.PATH || "").split(delimiter);
187
168
  for (const dir of pathDirs) {
188
169
  if (!dir)
@@ -196,13 +177,8 @@ function resolveBinaryUncached(cmd, cwd) {
196
177
  return null;
197
178
  }
198
179
  const installTasks = new Map();
199
- /** 安装失败的负缓存(pkg -> 失败时间戳):失败后 5 分钟内不再重复执行 120s 的 npm install */
200
180
  const installFailedAt = new Map();
201
181
  const INSTALL_FAIL_NEGATIVE_CACHE_MS = 5 * 60 * 1000;
202
- /**
203
- * 在用户专属目录(~/.pi-web/lsp-servers)执行无侵入、免 sudo/root 的语言服务包按需安装。
204
- * 注意:必须经用户显式授权(lsp 工具的 allowInstall 参数)后才能调用,不得静默触发。
205
- */
206
182
  export async function autoInstallLanguageServer(pkg) {
207
183
  const existing = installTasks.get(pkg);
208
184
  if (existing)
@@ -237,7 +213,6 @@ export async function autoInstallLanguageServer(pkg) {
237
213
  });
238
214
  const timer = setTimeout(() => {
239
215
  if (isWin) {
240
- // win32 下 taskkill /T 连整棵子进程树强杀,避免 npm/node 残留。
241
216
  if (typeof proc.pid === "number") {
242
217
  const killer = spawn("taskkill", ["/PID", String(proc.pid), "/T", "/F"], {
243
218
  stdio: "ignore",
@@ -247,9 +222,6 @@ export async function autoInstallLanguageServer(pkg) {
247
222
  }
248
223
  }
249
224
  else {
250
- // POSIX:npm 由非 shell 直接 spawn,kill 其主进程即可让安装流程终止
251
- //(取 SIGKILL 而非 detached 进程组方案:不改变子进程组语义,安装
252
- // 超时本身是罕见路径,残余 node 子进程随 npm 主进程退出被回收)。
253
225
  try {
254
226
  proc.kill("SIGKILL");
255
227
  }
@@ -273,7 +245,6 @@ export async function autoInstallLanguageServer(pkg) {
273
245
  });
274
246
  });
275
247
  console.warn(`[LSP] Language server [${pkg}] installed, resolving binaries…`);
276
- // 新二进制落盘,探测缓存失效
277
248
  clearResolveBinaryCache();
278
249
  installFailedAt.delete(pkg);
279
250
  return true;
@@ -290,9 +261,6 @@ export async function autoInstallLanguageServer(pkg) {
290
261
  installTasks.set(pkg, task);
291
262
  return task;
292
263
  }
293
- // ----------------------------------------------------------------------------
294
- // JSON-RPC 2.0 传输层与单项目 LSP 客户端
295
- // ----------------------------------------------------------------------------
296
264
  export class LspClient {
297
265
  projectCwd;
298
266
  langKey;
@@ -303,16 +271,14 @@ export class LspClient {
303
271
  proc = null;
304
272
  nextId = 1;
305
273
  pendingRequests = new Map();
306
- diagnosticsCache = new Map(); // fileUri -> diagnostics
307
- openFiles = new Set(); // fileUri
308
- docVersions = new Map(); // fileUri -> version
274
+ diagnosticsCache = new Map();
275
+ openFiles = new Set();
276
+ docVersions = new Map();
309
277
  buffer = Buffer.alloc(0);
310
278
  idleTimer = null;
311
279
  initialized = false;
312
280
  isShuttingDown = false;
313
- constructor(projectCwd, langKey, binPath, binArgs, languageId,
314
- /** 客户端不可用(空闲回收 / 进程退出 / spawn 失败)时从池移除的回调 */
315
- onEvict) {
281
+ constructor(projectCwd, langKey, binPath, binArgs, languageId, onEvict) {
316
282
  this.projectCwd = projectCwd;
317
283
  this.langKey = langKey;
318
284
  this.binPath = binPath;
@@ -332,18 +298,12 @@ export class LspClient {
332
298
  windowsHide: true,
333
299
  });
334
300
  this.proc.stdout?.on("data", (chunk) => this.handleData(chunk));
335
- this.proc.stderr?.on("data", (_d) => {
336
- // 可选记录 debug 日志,不干扰输出
337
- });
338
- // spawn 失败(ENOENT/EACCES 等)只触发 'error',进程从未启动时不会触发
339
- // 'exit'——不监听会让 initialize 等请求挂到超时,客户端还留在池里被误判存活。
301
+ this.proc.stderr?.on("data", (_d) => { });
340
302
  this.proc.on("error", (err) => {
341
303
  this.proc = null;
342
304
  this.rejectAllPending(new Error(`Language server failed to start: ${err.message}`));
343
305
  this.onEvict();
344
306
  });
345
- // stdin 写错误(对端退出后的 EPIPE 等)在 stream 上异步 emit,不监听会以
346
- // uncaughtException 崩掉整个服务进程。这里统一兜底:标记死亡 + 清理挂起请求。
347
307
  this.proc.stdin?.on("error", (err) => {
348
308
  this.proc = null;
349
309
  this.rejectAllPending(new Error(`Language server stdin error: ${err.message}`));
@@ -352,11 +312,9 @@ export class LspClient {
352
312
  this.proc.on("exit", (code) => {
353
313
  this.proc = null;
354
314
  this.rejectAllPending(new Error(`Language server exited with code ${code}`));
355
- // 进程退出即从池移除,防止后续请求命中死客户端
356
315
  this.onEvict();
357
316
  });
358
317
  try {
359
- // 发送 initialize 握手
360
318
  await this.request("initialize", {
361
319
  processId: process.pid,
362
320
  rootUri: pathToFileURL(this.projectCwd).toString(),
@@ -404,7 +362,6 @@ export class LspClient {
404
362
  return;
405
363
  if (this.idleTimer)
406
364
  clearTimeout(this.idleTimer);
407
- // 15 分钟无调用自动回收
408
365
  this.idleTimer = setTimeout(() => {
409
366
  this.shutdown().catch(() => { });
410
367
  this.onEvict();
@@ -439,8 +396,6 @@ export class LspClient {
439
396
  handleMessage(msg) {
440
397
  if (msg.id !== undefined) {
441
398
  if (msg.method) {
442
- // 服务端向客户端发起的请求(如 window/workDoneProgress/create, client/registerCapability)
443
- // 标准 JSON-RPC 必须回复 result: null,防止上游语言服务器挂起等待
444
399
  const reply = JSON.stringify({ jsonrpc: "2.0", id: msg.id, result: null });
445
400
  const wire = `Content-Length: ${Buffer.byteLength(reply, "utf8")}\r\n\r\n${reply}`;
446
401
  try {
@@ -486,8 +441,6 @@ export class LspClient {
486
441
  this.proc.stdin.write(wire);
487
442
  }
488
443
  catch (err) {
489
- // 同步写失败(stream 已销毁等):撤销挂起请求;异步 EPIPE 由 start() 里的
490
- // stdin 'error' 监听兜底,这里只需保证 promise 被 reject 而非向上抛。
491
444
  clearTimeout(timer);
492
445
  this.pendingRequests.delete(id);
493
446
  rej(new Error(`Language server stdin write failed: ${err.message}`));
@@ -503,9 +456,7 @@ export class LspClient {
503
456
  try {
504
457
  this.proc.stdin.write(wire);
505
458
  }
506
- catch {
507
- // 通知写失败只影响状态同步,不值得打断调用链;异步 EPIPE 由 stdin 'error' 监听兜底
508
- }
459
+ catch { }
509
460
  }
510
461
  async syncDocument(absPath) {
511
462
  const uri = pathToFileURL(absPath).toString();
@@ -582,11 +533,8 @@ export class LspClient {
582
533
  this.rejectAllPending(new Error("LSP client shut down"));
583
534
  }
584
535
  }
585
- // ----------------------------------------------------------------------------
586
- // 全局项目级语言服务器管理池(Project-Level LSP Pool)
587
- // ----------------------------------------------------------------------------
588
536
  class LspServerPool {
589
- pool = new Map(); // key: `${cwd}::${langKey}`
537
+ pool = new Map();
590
538
  inFlight = new Map();
591
539
  shuttingDown = false;
592
540
  hasAliveClient(projectCwd, filePath) {
@@ -608,8 +556,6 @@ class LspServerPool {
608
556
  const poolKey = `${projectCwd}::${langInfo.langKey}`;
609
557
  const client = this.pool.get(poolKey);
610
558
  if (client) {
611
- // 池命中必须复检存活:进程退出事件与请求之间有竞态窗口(exit 回调排队、
612
- // spawn error 未触发 exit),死客户端留在池里会让所有请求挂到超时。
613
559
  if (client.isAlive()) {
614
560
  client.touch();
615
561
  return { client };
@@ -621,7 +567,6 @@ class LspServerPool {
621
567
  return pending;
622
568
  }
623
569
  const task = (async () => {
624
- // 寻找可用命令
625
570
  let resolvedBin = null;
626
571
  let resolvedArgs = [];
627
572
  let hint = "";
@@ -637,7 +582,6 @@ class LspServerPool {
637
582
  if (!autoPkg && cmd.npmPackage)
638
583
  autoPkg = cmd.npmPackage;
639
584
  }
640
- // 用户态按需安装必须经用户显式授权(allowInstall),避免在工具调用链里无提示联网 npm install
641
585
  if (!resolvedBin && autoPkg && opts?.allowInstall === true) {
642
586
  const ok = await autoInstallLanguageServer(autoPkg);
643
587
  if (ok) {
@@ -664,8 +608,6 @@ class LspServerPool {
664
608
  this.pool.delete(poolKey);
665
609
  }
666
610
  });
667
- // 启动失败时客户端尚在 start() 内部、池里没有它,onEvict 是空操作;
668
- // 成功后再退出/回收才会真正从池移除。
669
611
  try {
670
612
  await newClient.start();
671
613
  if (this.shuttingDown) {
@@ -696,9 +638,6 @@ class LspServerPool {
696
638
  }
697
639
  }
698
640
  export const globalLspPool = new LspServerPool();
699
- /**
700
- * 辅助函数:在文件改动后,若已有存活的语言服务器,获取即时编译报错(Writethrough Diagnostics)
701
- */
702
641
  export async function getLiveLspDiagnostics(absPath, cwd) {
703
642
  if (!globalLspPool.hasAliveClient(cwd, absPath)) {
704
643
  return null;
@@ -708,7 +647,6 @@ export async function getLiveLspDiagnostics(absPath, cwd) {
708
647
  return null;
709
648
  const { client } = res;
710
649
  const uri = await client.syncDocument(absPath);
711
- // 稍等 80ms 让后台增量分析返回
712
650
  await new Promise((r) => setTimeout(r, 80));
713
651
  const diags = client.getDiagnostics(uri);
714
652
  const errors = diags.filter((d) => d.severity === 1 || !d.severity);
@@ -723,18 +661,8 @@ export async function getLiveLspDiagnostics(absPath, cwd) {
723
661
  });
724
662
  return `⚠️ Post-edit Diagnostics (${errors.length} error${errors.length > 1 ? "s" : ""}):\n${lines.join("\n")}`;
725
663
  }
726
- /** 文本大纲与 details.symbols 共用的展平符号数上限(顶层与子级一并计数)。 */
727
664
  const DOCUMENT_SYMBOL_OUTLINE_CAP = 300;
728
- /**
729
- * details.symbols 的序列化体积预算(字符数)。details 随会话持久且整体 ≤64KB,
730
- * 超限会被整条丢弃(见 serialize.ts 的 TOOL_DETAILS_CAP);符号名/签名极长的
731
- * 极端文件(生成的 .d.ts、protobuf 产物)下 300 个符号也可能撑爆,故按实际
732
- * 序列化体积逐步收紧上限(预算留足余量给 count/truncated 等包装字段)。
733
- */
734
665
  const DOCUMENT_SYMBOL_DETAILS_CHAR_BUDGET = 60_000;
735
- /**
736
- * 递归格式化 DocumentSymbol 列表为缩进的符号大纲树(做条数上限保护)
737
- */
738
666
  function formatDocumentSymbols(symbols, indent = "", lines = []) {
739
667
  for (const sym of symbols) {
740
668
  if (lines.length >= DOCUMENT_SYMBOL_OUTLINE_CAP) {
@@ -754,12 +682,6 @@ function formatDocumentSymbols(symbols, indent = "", lines = []) {
754
682
  }
755
683
  return lines;
756
684
  }
757
- /**
758
- * 与 formatDocumentSymbols 同口径的结构化裁剪:按展平后的符号数(先序遍历,
759
- * 顶层与子级一并计数)截断到 cap 个。只在展平序列的边界上裁剪,保留符号的
760
- * 父子结构保持一致 —— 父被裁掉则整棵子树不再出现;有符号被裁时 truncated 置真。
761
- * 未触发截断时原样返回(不拷贝,避免大对象无谓重建)。
762
- */
763
685
  function capDocumentSymbolTree(symbols, cap) {
764
686
  let count = 0;
765
687
  let truncated = false;
@@ -787,12 +709,6 @@ function capDocumentSymbolTree(symbols, cap) {
787
709
  const { kept } = walk(symbols);
788
710
  return { capped: truncated ? kept : symbols, truncated };
789
711
  }
790
- /**
791
- * details.symbols 的最终裁剪:先与文本大纲同口径按展平计数截到 300;再用实际
792
- * 序列化体积校验 —— details 随会话持久且整体 ≤64KB,超限整条丢弃(见
793
- * serialize.ts 的 TOOL_DETAILS_CAP),符号名/签名极长的极端文件下按半数逐步
794
- * 收紧展平上限,保证结构化大纲真的能进快照而不是被整条丢掉。
795
- */
796
712
  function capDocumentSymbolsForDetails(symbols) {
797
713
  let cap = DOCUMENT_SYMBOL_OUTLINE_CAP;
798
714
  let res = capDocumentSymbolTree(symbols, cap);
@@ -804,9 +720,6 @@ function capDocumentSymbolsForDetails(symbols) {
804
720
  }
805
721
  return res;
806
722
  }
807
- /**
808
- * 递归单趟查找符号(两遍扫描:先严格精确匹配,未命中再执行大小写忽略回退,避免遮蔽后续精确符号;支持 containerName 点分路径)
809
- */
810
723
  function findSymbolPass(symbols, target, mode, parentName = "") {
811
724
  const targetLower = target.toLowerCase();
812
725
  for (const sym of symbols) {
@@ -836,9 +749,6 @@ function findSymbolPass(symbols, target, mode, parentName = "") {
836
749
  function findSymbol(symbols, target) {
837
750
  return findSymbolPass(symbols, target, "exact") ?? findSymbolPass(symbols, target, "ci");
838
751
  }
839
- /**
840
- * 收集文件内可用的顶层符号全名清单(最多收集 50 条,供找不到符号时提供备选提示)
841
- */
842
752
  function collectSymbolNames(symbols, prefix = "", names = []) {
843
753
  for (const sym of symbols) {
844
754
  if (names.length >= 50)
@@ -856,9 +766,6 @@ function collectSymbolNames(symbols, prefix = "", names = []) {
856
766
  }
857
767
  return names;
858
768
  }
859
- /**
860
- * 当未传 path 且执行工作区级操作(如 workspaceSymbol)时,寻找工作区默认主文件以定位语言服务
861
- */
862
769
  function findDefaultSourceFileForLsp(cwd) {
863
770
  const candidates = [
864
771
  "src/index.ts",
@@ -1020,7 +927,6 @@ export function makeLspTool(options) {
1020
927
  }
1021
928
  const client = clientRes.client;
1022
929
  const uri = await client.syncDocument(absPath);
1023
- // 0-indexed positions for LSP protocol
1024
930
  const position = {
1025
931
  line: line - 1,
1026
932
  character: character - 1,
@@ -1035,8 +941,6 @@ export function makeLspTool(options) {
1035
941
  details: { ok: true, locations: [] },
1036
942
  };
1037
943
  }
1038
- // 与 references(:25) 同口径:每个位置都要整读一次目标文件拼 snippet,
1039
- // 无上限的 definition 列表会放大成几十次同步 IO 拖死请求。
1040
944
  const MAX_DEFS = 25;
1041
945
  const formatted = locs.slice(0, MAX_DEFS).map((loc) => {
1042
946
  const targetUri = loc.targetUri || loc.uri || "";
@@ -1130,7 +1034,6 @@ export function makeLspTool(options) {
1130
1034
  };
1131
1035
  }
1132
1036
  if (action === "diagnostics") {
1133
- // 给予极短缓冲以确保 publishDiagnostics 缓存已收到
1134
1037
  await new Promise((r) => setTimeout(r, 120));
1135
1038
  const diags = client.getDiagnostics(uri);
1136
1039
  if (diags.length === 0) {
@@ -1166,9 +1069,6 @@ export function makeLspTool(options) {
1166
1069
  };
1167
1070
  }
1168
1071
  const lines = formatDocumentSymbols(symbols);
1169
- // details 随会话持久且整体 ≤64KB(超限整条丢弃):symbols 与文本大纲同口径
1170
- // 截断 —— 按展平后的符号数(先序遍历,顶层与子级一并计数)截到 300,保留
1171
- // 符号维持父子结构;再按序列化体积兜底收紧,极端文件下保证 details 进得了快照。
1172
1072
  const { capped: detailsSymbols, truncated: symbolsTruncated } = capDocumentSymbolsForDetails(symbols);
1173
1073
  return {
1174
1074
  content: [
@@ -1226,9 +1126,8 @@ export function makeLspTool(options) {
1226
1126
  details: { ok: false, error: "Missing range" },
1227
1127
  };
1228
1128
  }
1229
- let startLine = range.start.line; // 0-indexed
1230
- let endLine = range.end.line; // 0-indexed
1231
- // 针对行尾排他边界(end.character === 0 且跨行时)避免多读末尾空行
1129
+ let startLine = range.start.line;
1130
+ let endLine = range.end.line;
1232
1131
  if (range.end.character === 0 && endLine > startLine) {
1233
1132
  endLine -= 1;
1234
1133
  }
@@ -1313,16 +1212,12 @@ export function makeLspTool(options) {
1313
1212
  };
1314
1213
  }
1315
1214
  if (action === "cascade") {
1316
- // 影响级联(Impact Cascade):找出引用本文件(或本文件某个符号)的工作区文件,
1317
- // 聚合它们的实时诊断——让"改了签名/导出,下游编译炸了"在编辑当轮就暴露,
1318
- // 而不是等到构建或提交时才发现。
1319
1215
  const MAX_SEEDS = 20;
1320
1216
  const MAX_DEPENDENTS = 25;
1321
1217
  const DIAGS_BUDGET_MS = 1500;
1322
1218
  const normalizePath = (p) => (process.platform === "win32" ? p.toLowerCase() : p);
1323
- // 1. 收集种子位置:给了 line/character 就只查那个符号;否则查全部顶层符号。
1324
1219
  const seeds = [];
1325
- let seedTotal = 0; // 顶层符号总数(截断前),超出 MAX_SEEDS 时在输出尾部标明
1220
+ let seedTotal = 0;
1326
1221
  if (typeof params.line === "number") {
1327
1222
  seeds.push({ line: line - 1, character: character - 1 });
1328
1223
  }
@@ -1343,7 +1238,6 @@ export function makeLspTool(options) {
1343
1238
  details: { ok: true, impacted: [], clean: [], notReported: [], referencedFiles: [] },
1344
1239
  };
1345
1240
  }
1346
- // 2. 对每个种子查 references(不含声明处),汇总工作区内的引用方文件。
1347
1241
  const selfNorm = normalizePath(absPath);
1348
1242
  const depPaths = new Set();
1349
1243
  const seedResults = await Promise.allSettled(seeds.map((pos) => client.request("textDocument/references", { textDocument: { uri }, position: pos, context: { includeDeclaration: false } }, timeoutMs)));
@@ -1362,19 +1256,16 @@ export function makeLspTool(options) {
1362
1256
  continue;
1363
1257
  }
1364
1258
  if (normalizePath(refPath) === selfNorm)
1365
- continue; // 排除自身
1259
+ continue;
1366
1260
  const relRef = relative(cwd, refPath);
1367
1261
  if (relRef === ".." || relRef.startsWith(".." + sep) || relRef.startsWith("../") || isAbsolute(relRef)) {
1368
- continue; // 只看工作区内
1262
+ continue;
1369
1263
  }
1370
1264
  if (relRef.split(sep).includes("node_modules"))
1371
1265
  continue;
1372
1266
  depPaths.add(refPath);
1373
1267
  }
1374
1268
  }
1375
- // 只分析排序后的前 MAX_DEPENDENTS 个引用方,但计数必须如实上报:文本与
1376
- // details 都带截断前的真实总数,超出部分用尾注标明(对照 references 动作
1377
- // 的 "... and N more references" 口径),避免模型误以为清单是完整的。
1378
1269
  const totalReferencing = depPaths.size;
1379
1270
  const dependents = [...depPaths].sort().slice(0, MAX_DEPENDENTS);
1380
1271
  if (dependents.length === 0) {
@@ -1388,7 +1279,6 @@ export function makeLspTool(options) {
1388
1279
  details: { ok: true, impacted: [], clean: [], notReported: [], referencedFiles: [] },
1389
1280
  };
1390
1281
  }
1391
- // 3. 逐个 didOpen/didChange 触发服务器分析,轮询等待 publishDiagnostics 回流。
1392
1282
  const depUris = [];
1393
1283
  for (const dep of dependents) {
1394
1284
  try {
@@ -1408,7 +1298,6 @@ export function makeLspTool(options) {
1408
1298
  pending.delete(u);
1409
1299
  }
1410
1300
  }
1411
- // 4. 聚合输出:有错误的排前面,其次警告,clean 与未上报的折叠列出。
1412
1301
  const impacted = [];
1413
1302
  const clean = [];
1414
1303
  const notReported = [];
@@ -1428,7 +1317,7 @@ export function makeLspTool(options) {
1428
1317
  impacted.push({ path: depRel, errors, warnings, diagnostics: diags.slice(0, 10) });
1429
1318
  }
1430
1319
  else if (diags.length === 0 && !knownFinal.has(depUri)) {
1431
- notReported.push(depRel); // 预算内服务器未上报(可能仍在分析)
1320
+ notReported.push(depRel);
1432
1321
  }
1433
1322
  else {
1434
1323
  clean.push(depRel);
@@ -1456,8 +1345,6 @@ export function makeLspTool(options) {
1456
1345
  if (notReported.length > 0) {
1457
1346
  out.push(`Diagnostics not reported in time (${notReported.length}, server may still be analyzing): ${notReported.slice(0, 5).join(", ")}${notReported.length > 5 ? ", ..." : ""}`);
1458
1347
  }
1459
- // 截断尾注:与 references 动作的 "... and N more references" 同口径,
1460
- // 让模型知道被丢弃的引用方/种子符号既不在 clean 也不在 notReported 里。
1461
1348
  if (totalReferencing > dependents.length) {
1462
1349
  out.push(`... and ${totalReferencing - dependents.length} more not analyzed`);
1463
1350
  }
@@ -1,65 +1,17 @@
1
- /**
2
- * managed — instances whose updates come from outside.
3
- *
4
- * pi-web-ui can update itself: the top bar shows an updates badge and a panel
5
- * whose buttons run `npm i -g pi-web-ui@latest` in a visible terminal and
6
- * restart the server. The plugin market installs plugins from the network the
7
- * same way. On a developer's laptop both are conveniences.
8
- *
9
- * Behind a deploy pipeline they are not. A Docker image, a distribution
10
- * package, or a release script that also checks the reverse proxy, the service
11
- * unit and the environment variables a new version needs — for all of those,
12
- * an in-app self-update leaves the machine in a state nothing describes, until
13
- * the next real deploy silently undoes it. `PI_WEB_MANAGED=1` says "this
14
- * instance is managed from outside": the update paths refuse, and the client
15
- * stops offering them.
16
- *
17
- * Two rules kept this small:
18
- *
19
- * - **The server refuses, the client only hides.** Hiding a button while the
20
- * socket still accepts the message is hiding, not disabling: anything that
21
- * can open the WebSocket can still send it.
22
- * - **Nothing else changes.** Chatting, plugins already installed, git,
23
- * terminal, settings are untouched — this switch is about who installs
24
- * software on the machine, not about what the interface can do.
25
- */
26
- /** The client messages that install or replace software on the machine. */
27
1
  export const MANAGED_MESSAGES = [
28
- /** Update check behind the top-bar badge. */
29
2
  "check_update",
30
- /** "Re-check all" in the UPDATE panel (app + components). */
31
3
  "check_updates_all",
32
- /** Installs the pi agent itself. */
33
4
  "install_pi_agent",
34
- /** Updates an agent engine package via background process. */
35
5
  "update_engine",
36
- /** Uninstalls an agent engine package via background process. */
37
6
  "uninstall_engine",
38
- /** Plugin market: fetches and installs a plugin from the network. */
39
7
  "plugin_catalog_add",
40
- /** Plugin install/update/uninstall run as a background job (issue #152). */
41
8
  "plugin_job",
42
- /** Catalog sync can install/update entries too (issue #148). */
43
9
  "plugin_catalog_sync",
44
10
  ];
45
- /**
46
- * Whether this instance is managed from outside.
47
- *
48
- * Accepts the spellings people actually put in a systemd unit or a
49
- * docker-compose file; anything else — including an empty variable — means no,
50
- * so the default stays exactly what it is today.
51
- */
52
11
  export function isManaged(env = process.env) {
53
12
  const v = (env.PI_WEB_MANAGED ?? "").trim().toLowerCase();
54
13
  return v === "1" || v === "true" || v === "yes" || v === "on";
55
14
  }
56
- /**
57
- * The reason to send back, or null when the message may proceed.
58
- *
59
- * Returning the text rather than a boolean keeps the caller a single line and
60
- * puts the explanation next to the rule it comes from — the user gets a
61
- * sentence, not a silently dropped message.
62
- */
63
15
  export function managedRefusal(type, managed) {
64
16
  if (!managed)
65
17
  return null;
@@ -1,6 +1,3 @@
1
- /**
2
- * marker-service.ts — 标记服务(内置版 pi-marker-tools)。
3
- */
4
1
  import { pick } from "./i18n.js";
5
2
  import { ensureMarkersRegistered, parseMarkers, getMarker, allMarkers, collectGuidance, listMarkerNames, } from "./markers/index.js";
6
3
  import { loadStateFromBranch, appendSnapshot } from "./markers/store.js";
@@ -35,7 +32,6 @@ export class MarkerService {
35
32
  return false;
36
33
  return !this.settings.disabledMarkers.includes(name);
37
34
  }
38
- /** 当前服务端语言(英文默认,未接线前保持原有英文行为)。 */
39
35
  lang() {
40
36
  return this.host.lang?.() ?? "en";
41
37
  }
@@ -43,7 +39,6 @@ export class MarkerService {
43
39
  if (!this.settings.markersEnabled)
44
40
  return "";
45
41
  const disabled = new Set(this.settings.disabledMarkers);
46
- // AI guidance is strictly in concise English matching tool prompt guidelines.
47
42
  const lines = collectGuidance(disabled, "en");
48
43
  if (lines.length === 0)
49
44
  return "";
@@ -84,7 +79,6 @@ export class MarkerService {
84
79
  }
85
80
  this.host.stateStore.saveMarkerSettings(this.host.clientId, this.settings);
86
81
  }
87
- // -- state helpers --
88
82
  memFor(convId, ns) {
89
83
  return this.memStore.get(convId)?.get(ns);
90
84
  }
@@ -107,9 +101,7 @@ export class MarkerService {
107
101
  return structuredClone(fromBranch);
108
102
  }
109
103
  }
110
- catch {
111
- // best-effort:分支不可读 → 回落 mem/init(快照损坏不阻断对话)。
112
- }
104
+ catch { }
113
105
  }
114
106
  const mem = this.memFor(convId, namespace);
115
107
  if (mem !== undefined)
@@ -121,14 +113,6 @@ export class MarkerService {
121
113
  const mgr = this.host.getSessionManager(convId);
122
114
  appendSnapshot(mgr, namespace, state);
123
115
  }
124
- // -- parse & execute --
125
- /**
126
- * 解析执行一条 assistant 终稿文本中的内联标记。
127
- *
128
- * 多个气泡(同一轮内前一段文本 + 后一段文本)的 message_end 事件会先后到达,
129
- * 而 apply 是异步的——若并发执行会同时读到旧快照、分配重叠 id、后存覆盖前存。
130
- * 因此按会话串行化:每个 conv 的处理链式排队,保证状态严格按文本顺序累积。
131
- */
132
116
  chains = new Map();
133
117
  handleAssistantText(conversationId, text) {
134
118
  const prev = this.chains.get(conversationId) ?? Promise.resolve();
@@ -199,7 +183,6 @@ export class MarkerService {
199
183
  };
200
184
  }
201
185
  if (result.applied) {
202
- // action 落库;notify/conv 即时生效(通知已发 / 对话已重命名),无需快照。
203
186
  const canonicalTool = token.tool === "suggest" ? ACTION_NAMESPACE : token.tool;
204
187
  if (canonicalTool !== "notify" && canonicalTool !== "conv") {
205
188
  dirty.add(canonicalTool);
@@ -232,10 +215,8 @@ export class MarkerService {
232
215
  if (prev && prev.join("\n") === next.join("\n"))
233
216
  return;
234
217
  this.overlayCache.set(key, next);
235
- // 通过宿主的 widget 合并(跟随当前活动会话,不覆盖扩展 widget)。
236
218
  this.host.refreshMarkers();
237
219
  }
238
- /** 计算某个会话的标记 overlay 行(供 UI widget 动态渲染当前活动会话)。 */
239
220
  overlayLines(conversationId) {
240
221
  const lines = [];
241
222
  for (const m of allMarkers()) {
@@ -289,8 +270,6 @@ export class MarkerService {
289
270
  this.host.onActionsChange?.(conversationId);
290
271
  }
291
272
  }
292
- /** 供设置面板展示的 marker 目录(含启用状态)。 */
293
- /** UI 过滤:rename/title 是 conv 的别名,suggest 是 action 的别名,不单独展示。 */
294
273
  listForUi() {
295
274
  const seen = new Set();
296
275
  const out = [];
@@ -1,16 +1,3 @@
1
- /**
2
- * builtins/action.ts — 建议操作标记(期待用户操作)。
3
- *
4
- * 语法:
5
- * [[action:suggest:<按钮文字>]] 添加快捷操作建议(点击发送该文字)
6
- * [[action:suggest:<按钮显示>,prompt=<实际发送文本>]] 区分展示标签与实际发送内容
7
- * [[action:suggest:label=<按钮显示>,prompt=<发送文本>]] kwargs 风格
8
- * [[action:clear:all]] 清空当前建议操作
9
- *
10
- * 兼容操作别名:
11
- * tool 兼容 action 与 suggest
12
- * op 兼容 suggest / add / next / reply / choice / option / clear
13
- */
14
1
  import { getServerBlock, pick } from "../../i18n.js";
15
2
  export const ACTION_NAMESPACE = "action";
16
3
  export function initActionState() {
@@ -22,7 +9,6 @@ const ACTION_GUIDANCE_ZH = [
22
9
  const ACTION_GUIDANCE_EN = [
23
10
  "- Suggest action buttons: [[action:suggest:<label>]] (one marker per button; for multiple choices output separate markers: [[action:suggest:A]] [[action:suggest:B]], NEVER join options in one marker). Separate prompt: [[action:suggest:<label>,prompt=<text>]]. Clear: [[action:clear:all]].",
24
11
  ];
25
- /** 语言感知的 action guidance:en 用英译、zh 用中文,默认英文。 */
26
12
  export function getActionGuidance(lang = "en") {
27
13
  return getServerBlock(lang, "markers.action.guidance", ACTION_GUIDANCE_ZH, ACTION_GUIDANCE_EN);
28
14
  }
@@ -46,8 +32,6 @@ export const actionMarker = {
46
32
  error: pick(lang, `action 未知操作: ${token.op}(支持 suggest/next/add/clear)`, `action unknown operation: ${token.op} (supports suggest/next/add/clear)`, "markers.action.unknown.operation", { "token.op": token.op }),
47
33
  };
48
34
  }
49
- // 提取 label 与 prompt:
50
- // args: token.args.join(",").trim() (兼容含逗号的正文,如 "是,继续执行")
51
35
  const argsText = token.args.join(",").trim();
52
36
  const kwLabel = token.kwargs["label"]?.trim() || "";
53
37
  const kwPrompt = token.kwargs["prompt"]?.trim() || "";
@@ -64,12 +48,10 @@ export const actionMarker = {
64
48
  prompt = label;
65
49
  if (!label)
66
50
  label = prompt;
67
- // 字符长度封顶保护
68
51
  if (label.length > 80)
69
52
  label = label.slice(0, 80);
70
53
  if (prompt.length > 2000)
71
54
  prompt = prompt.slice(0, 2000);
72
- // 去重
73
55
  const existing = state.actions.find((a) => a.label === label && a.prompt === prompt);
74
56
  if (existing) {
75
57
  return {
@@ -77,7 +59,6 @@ export const actionMarker = {
77
59
  feedback: pick(lang, `建议操作已存在: ${label}`, `Suggested action already exists: ${label}`, "markers.action.already.exists", { label }),
78
60
  };
79
61
  }
80
- // 数量上限 8 个,超限剔除最早的一项
81
62
  if (state.actions.length >= 8) {
82
63
  state.actions.shift();
83
64
  }
@@ -1,16 +1,8 @@
1
- /**
2
- * builtins/notify.ts — 纯提醒标记。
3
- */
4
1
  import { getServerBlock, pick } from "../../i18n.js";
5
- const NOTIFY_GUIDANCE_ZH = [
6
- // #499:guidance 只能承诺协议真实支持的级别——success 从未存在于 notice 协议
7
- // (protocol.ts 仅 info|warning|error),按指引用 success 会被静默降级成 info。
8
- "- 浮动通知:[[notify:<级别>:<内容>]](级别:info|warning|error,不进入正文)。",
9
- ];
2
+ const NOTIFY_GUIDANCE_ZH = ["- 浮动通知:[[notify:<级别>:<内容>]](级别:info|warning|error,不进入正文)。"];
10
3
  const NOTIFY_GUIDANCE_EN = [
11
4
  "- Non-interruptive toast: [[notify:<level>:<message>]] (level: info|warning|error; omitted from reply).",
12
5
  ];
13
- /** 语言感知的 notify guidance(issue #91):en 用英译、zh 用中文,默认英文。 */
14
6
  export function getNotifyGuidance(lang = "en") {
15
7
  return getServerBlock(lang, "markers.notify.guidance", NOTIFY_GUIDANCE_ZH, NOTIFY_GUIDANCE_EN);
16
8
  }