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,21 +1,8 @@
1
- /**
2
- * 内置定时任务调度(issue #184)。
3
- *
4
- * 面向普通用户的图形化调度器:任务 CRUD + cron/间隔触发 + 无头执行 +
5
- * 执行历史 + 通知。底层 cron 解析复用 plugin-schedule.ts(parseCronSpec /
6
- * nextCronFire),持久化走 <dataDir>/scheduler-tasks.json(全局共享,
7
- * 与 client-state.json 同级),执行经调用方注入的 executor(index.ts 接
8
- * AgentService.chatFromScheduler,无头伪客户端)。
9
- *
10
- * 定时策略:单个 10s ticker 检查到期任务(cron 下次触发 / 间隔毫秒),
11
- * running 集合防重叠;catchUp "once" 在启动时补跑一次漏掉的触发。
12
- */
13
1
  import { readFileSync } from "node:fs";
14
2
  import { join } from "node:path";
15
3
  import { nextCronFire, parseCronSpec } from "./plugin-schedule.js";
16
4
  import { writeJsonAtomicSync } from "./atomic-file.js";
17
5
  export const SCHEDULER_FILE = "scheduler-tasks.json";
18
- /** 持久间隔底线 60s(与 host.schedule 持久任务同口径,防 token 烧穿)。 */
19
6
  export const SCHEDULER_MIN_INTERVAL_MS = 60_000;
20
7
  export const SCHEDULER_MAX_INTERVAL_MS = 30 * 24 * 60 * 60 * 1000;
21
8
  export const SCHEDULER_HISTORY_MAX = 20;
@@ -43,7 +30,6 @@ export class SchedulerValidationError extends Error {
43
30
  this.name = "SchedulerValidationError";
44
31
  }
45
32
  }
46
- /** 归一化 + 校验用户输入;非法抛 SchedulerValidationError。纯函数,可单测。 */
47
33
  export function normalizeSchedulerInput(input, now = Date.now()) {
48
34
  const idRaw = String(input.id ?? "").trim();
49
35
  const id = idRaw || randomTaskId();
@@ -110,8 +96,6 @@ export function normalizeSchedulerInput(input, now = Date.now()) {
110
96
  const conversationId = String(input.conversationId ?? "")
111
97
  .trim()
112
98
  .slice(0, 128);
113
- // 落盘会话文件:稳定身份键(issue #231)。只做归一化(去首尾空白、封顶),
114
- // 不校验存在性 —— 创建时刻文件可能还没落盘,触发时按它匹配不上即回落。
115
99
  const sessionFile = String(input.sessionFile ?? "")
116
100
  .trim()
117
101
  .slice(0, 1024);
@@ -136,7 +120,6 @@ export function normalizeSchedulerInput(input, now = Date.now()) {
136
120
  updatedAt: now,
137
121
  };
138
122
  }
139
- /** 下次触发毫秒时间戳;非法/禁用回 null。纯函数,可单测。 */
140
123
  export function computeNextFire(task, fromMs) {
141
124
  try {
142
125
  if (task.kind === "cron") {
@@ -154,7 +137,6 @@ export function computeNextFire(task, fromMs) {
154
137
  return null;
155
138
  }
156
139
  }
157
- /** 间隔任务的人类可读描述(面板显示用)。纯函数。 */
158
140
  export function describeIntervalMs(ms) {
159
141
  const s = Math.round(ms / 1000);
160
142
  if (s < 60)
@@ -205,9 +187,6 @@ function sanitizeHistory(v) {
205
187
  }
206
188
  return out.sort((a, b) => b.at - a.at).slice(0, SCHEDULER_HISTORY_MAX);
207
189
  }
208
- /** 落盘会话路径是否指向同一会话(纯函数,可单测)。
209
- * Windows 上 `C:\a\b` 与 `C:/a/b`、尾部分隔符差异都算同一文件;
210
- * 空串永不相等(没拿到稳定键的任务不配对)。 */
211
190
  export function sameSessionFile(a, b) {
212
191
  const x = String(a ?? "").trim();
213
192
  const y = String(b ?? "").trim();
@@ -231,7 +210,6 @@ export class SchedulerStore {
231
210
  setExecutor(executor) {
232
211
  this.opts.executor = executor;
233
212
  }
234
- /** 启动 ticker + catchUp 补跑(幂等)。 */
235
213
  start() {
236
214
  this.load();
237
215
  if (this.started)
@@ -246,7 +224,6 @@ export class SchedulerStore {
246
224
  if (next === null)
247
225
  continue;
248
226
  if (next <= now && task.catchUp === "once" && lastAt < now) {
249
- // 重启发现漏跑:补一次,补完按这次重排。
250
227
  this.nextFire.set(task.id, now + 5000);
251
228
  void this.fire(task.id, false).catch((err) => this.reportFailure(err));
252
229
  }
@@ -267,7 +244,6 @@ export class SchedulerStore {
267
244
  }
268
245
  this.started = false;
269
246
  }
270
- /** 读盘;坏文件/形状不对当空表(读路径不回写)。 */
271
247
  load() {
272
248
  try {
273
249
  const parsed = JSON.parse(readFileSync(schedulerFile(this.dataDir), "utf8"));
@@ -309,9 +285,7 @@ export class SchedulerStore {
309
285
  history: sanitizeHistory(r.history),
310
286
  });
311
287
  }
312
- catch {
313
- // 单条坏记录跳过,不影响其他任务
314
- }
288
+ catch { }
315
289
  }
316
290
  this.tasks = next;
317
291
  }
@@ -339,9 +313,7 @@ export class SchedulerStore {
339
313
  try {
340
314
  this.opts.onChange?.();
341
315
  }
342
- catch {
343
- /* 推送失败不影响调度 */
344
- }
316
+ catch { }
345
317
  }
346
318
  list() {
347
319
  const now = Date.now();
@@ -377,10 +349,6 @@ export class SchedulerStore {
377
349
  })
378
350
  .sort((a, b) => a.name.localeCompare(b.name, "zh"));
379
351
  }
380
- /** 新建或全量更新(同名 id 覆盖);返回归一化后的任务。
381
- * issue #231:面板编辑不带绑定字段(conversationId/sessionFile 缺席)时保留旧绑定 ——
382
- * 否则用户在面板改个名字就会把 AI 任务的会话绑定洗掉,下次触发直接变无头。
383
- * 字段显式出现(含空串)仍按全量语义覆盖。 */
384
352
  upsert(input, origin) {
385
353
  if (origin !== undefined && !validOrigin(origin))
386
354
  throw new Error("Invalid scheduled-task creation origin");
@@ -409,12 +377,10 @@ export class SchedulerStore {
409
377
  this.opts.validateTask?.(task);
410
378
  const history = prev?.history ? sanitizeHistory(prev.history) : [];
411
379
  this.save(new Map(this.tasks).set(task.id, { ...task, history }));
412
- // spec/cwd/开关变了 → 按现在重排下次触发
413
380
  this.nextFire.set(task.id, computeNextFire(task, Date.now()) ?? Date.now() + TICK_MS);
414
381
  this.changed();
415
382
  return task;
416
383
  }
417
- /** Commit cancellation before the caller discards transcript evidence. No awaits can race fire(). */
418
384
  cancelUnstartedFromCalls(sessionFile, toolCallIds, commit) {
419
385
  const next = new Map(this.tasks);
420
386
  const removed = [];
@@ -473,9 +439,7 @@ export class SchedulerStore {
473
439
  try {
474
440
  this.opts.onTaskRemoved?.(id);
475
441
  }
476
- catch {
477
- /* 回调失败不影响删除 */
478
- }
442
+ catch { }
479
443
  }
480
444
  return ok;
481
445
  }
@@ -489,9 +453,6 @@ export class SchedulerStore {
489
453
  this.changed();
490
454
  return { ...t };
491
455
  }
492
- /** 会话重绑定(issue #231):触发时按稳定键找到了新的对话句柄,把任务的
493
- * 投递目标迁移过去(只改 conversationId/sessionFile/updatedAt,不碰下次触发
494
- * 与历史)。无变化回 false(调用方免一次落盘+推送);未知任务回 false。 */
495
456
  rebind(id, binding) {
496
457
  const prev = this.tasks.get(id);
497
458
  if (!prev || prev.target === "canvas")
@@ -523,21 +484,29 @@ export class SchedulerStore {
523
484
  this.changed();
524
485
  return true;
525
486
  }
526
- async tick() {
527
- const now = Date.now();
487
+ async tick(now = Date.now()) {
528
488
  for (const task of this.tasks.values()) {
529
- if (!task.enabled || this.running.has(task.id))
489
+ if (!task.enabled)
530
490
  continue;
531
491
  let next = this.nextFire.get(task.id);
532
492
  if (next === undefined) {
533
493
  next = computeNextFire(task, Math.max(now, task.updatedAt)) ?? now + TICK_MS;
534
494
  this.nextFire.set(task.id, next);
535
495
  }
536
- if (next <= now)
537
- await this.fire(task.id, false);
496
+ if (this.running.has(task.id)) {
497
+ if (next <= now) {
498
+ const nextSlot = computeNextFire(task, now) ?? now + TICK_MS;
499
+ this.nextFire.set(task.id, nextSlot);
500
+ this.changed();
501
+ this.notify("info", `定时任务「${task.name}」上一轮仍在执行中,本次定时触发已顺延至下个周期(${new Date(nextSlot).toLocaleTimeString()})。`, `Scheduled task "${task.name}" is still running from previous turn; postponed to next interval (${new Date(nextSlot).toLocaleTimeString()}).`);
502
+ }
503
+ continue;
504
+ }
505
+ if (next <= now) {
506
+ void this.fire(task.id, false, now).catch((err) => this.reportFailure(err));
507
+ }
538
508
  }
539
509
  }
540
- /** 手动立即执行一次(面板 Run Now;调试用,不扰动下次触发)。 */
541
510
  async runNow(id) {
542
511
  const task = this.tasks.get(id);
543
512
  if (!task)
@@ -546,12 +515,11 @@ export class SchedulerStore {
546
515
  return { ok: false, error: "任务正在执行中" };
547
516
  return this.fire(id, true);
548
517
  }
549
- async fire(id, manual) {
518
+ async fire(id, manual, triggerAt) {
550
519
  const task = this.tasks.get(id);
551
520
  if (!task)
552
521
  return { ok: false, error: "任务不存在" };
553
522
  const executor = this.opts.executor;
554
- // Remember the attempt before any external effect, even if run-history persistence later fails.
555
523
  if (task.origin && task.startedAt === undefined) {
556
524
  try {
557
525
  this.save(new Map(this.tasks).set(id, { ...task, startedAt: Date.now() }));
@@ -562,8 +530,12 @@ export class SchedulerStore {
562
530
  }
563
531
  }
564
532
  this.running.add(id);
565
- this.changed();
566
533
  const startedAt = Date.now();
534
+ const scheduleBase = triggerAt !== undefined ? Math.max(triggerAt, startedAt) : startedAt;
535
+ if (!task.oneShot && !manual) {
536
+ this.nextFire.set(id, computeNextFire(task, scheduleBase) ?? scheduleBase + TICK_MS);
537
+ }
538
+ this.changed();
567
539
  let result;
568
540
  try {
569
541
  result = executor
@@ -597,17 +569,21 @@ export class SchedulerStore {
597
569
  this.reportFailure(err);
598
570
  }
599
571
  finally {
600
- // 执行可能已产生外部副作用;记录写失败也不能在每个 tick 立即重试。
601
- // 仅推进内存调度,使用执行期间更新后的配置,不伪造成功历史。
602
- // 进程重启后仍可能补跑:本地记录与外部副作用不保证跨进程 exactly-once。
603
572
  const cur = this.tasks.get(id);
604
573
  if (cur && task.oneShot) {
605
- // A failed history/removal write must not repeat an already attempted one-shot.
606
574
  this.tasks.set(id, { ...cur, enabled: false });
607
575
  this.nextFire.delete(id);
608
576
  }
609
577
  else if (cur && cur.enabled && !manual) {
610
- this.nextFire.set(id, computeNextFire(cur, Date.now()) ?? Date.now() + TICK_MS);
578
+ if (cur.kind === "interval") {
579
+ this.nextFire.set(id, computeNextFire(cur, Date.now()) ?? Date.now() + TICK_MS);
580
+ }
581
+ else {
582
+ const currentNext = this.nextFire.get(id);
583
+ if (currentNext === undefined || currentNext <= Date.now()) {
584
+ this.nextFire.set(id, computeNextFire(cur, Date.now()) ?? Date.now() + TICK_MS);
585
+ }
586
+ }
611
587
  }
612
588
  this.running.delete(id);
613
589
  this.changed();
@@ -1,32 +1,7 @@
1
- /**
2
- * AI commit-message generation — pure prompt assembly + response cleanup.
3
- *
4
- * The git gathering lives in scm.ts (scmCommitContext); the one-off model
5
- * call lives in agent-service (ClientSession.scmGenCommitMessage, same
6
- * completeSimple path as the vision bridge). This module owns everything
7
- * deterministic so it stays unit-testable:
8
- *
9
- * buildCommitMsgInput(ctx, fallbackLang) → user message (null = nothing
10
- * to commit — the caller turns that into a friendly error)
11
- * COMMITMSG_SYSTEM_PROMPT → system prompt
12
- * sanitizeCommitMessage(raw) → the single-line subject that
13
- * ends up in the commit input (models are told to emit exactly that, but
14
- * fences/labels/quotes/newlines are stripped defensively)
15
- *
16
- * Language policy: the generated message follows the repository's own commit
17
- * subjects (style AND language — a repo writing "feat(xxx): 描述" keeps
18
- * getting that). Only a repo with no commits yet falls back to the UI
19
- * language passed as fallbackLang.
20
- */
21
1
  import { isNotRepoError, scmCommitContext } from "./scm.js";
22
2
  import { pick } from "./i18n.js";
23
- /** SCM AI 提交信息生成超时时间(毫秒) */
24
3
  export const SCM_COMMITMSG_TIMEOUT_MS = 60_000;
25
- /** Hard cap for the generated subject — the commit input is single-line and
26
- * this keeps a chatty model from filling the whole header row. */
27
4
  export const MAX_COMMITMSG_LEN = 200;
28
- /** File list cap inside the prompt (porcelain lines); the diffs carry the
29
- * details, the list is orientation only. */
30
5
  const MAX_FILE_LINES = 200;
31
6
  export const COMMITMSG_SYSTEM_PROMPT = `You write git commit messages. You receive the pending changes of a repository and output exactly one commit message: a single subject line.
32
7
 
@@ -39,13 +14,6 @@ Rules:
39
14
  6. If the repository has no commits yet, write the message in the language stated in the request.
40
15
 
41
16
  Output ONLY the subject line.`;
42
- /**
43
- * Assemble the effective system prompt from the settings-panel prefs (same
44
- * contract as the vision bridge's buildVisionBridgePrompt): mode "append"
45
- * puts custom text after the built-in default (empty custom = pure default);
46
- * mode "replace" swaps in the custom text, but an empty custom still falls
47
- * back to the default (never send an empty system prompt).
48
- */
49
17
  export function buildCommitMsgPrompt(mode, custom) {
50
18
  const text = custom?.trim() ?? "";
51
19
  if (mode === "replace" && text)
@@ -54,17 +22,11 @@ export function buildCommitMsgPrompt(mode, custom) {
54
22
  return `${COMMITMSG_SYSTEM_PROMPT}\n\n${text}`;
55
23
  return COMMITMSG_SYSTEM_PROMPT;
56
24
  }
57
- /** "path → [add,del]" map → compact "+12/-3 path" lines (sorted by path). */
58
25
  function formatNumStat(stat) {
59
26
  return Object.keys(stat)
60
27
  .sort()
61
28
  .map((p) => `+${stat[p][0]}/-${stat[p][1]} ${p}`);
62
29
  }
63
- /**
64
- * Assemble the user message from the gathered context. Returns null when
65
- * there is nothing to describe (no staged/unstaged diff and no untracked
66
- * files) — the caller replies "no changes" instead of calling the model.
67
- */
68
30
  export function buildCommitMsgInput(ctx, fallbackLang) {
69
31
  const parts = [];
70
32
  if (ctx.subjects.length > 0) {
@@ -100,8 +62,6 @@ export function buildCommitMsgInput(ctx, fallbackLang) {
100
62
  }
101
63
  const untracked = ctx.files.filter((f) => f.x === "?" && f.y === "?");
102
64
  if (untracked.length > 0 && !ctx.stagedPatch.trim()) {
103
- // Untracked content never appears in `git diff` — name the files so
104
- // the model knows they are part of the change set (commit-all flow).
105
65
  parts.push(`Untracked files (new, content not shown): ${untracked
106
66
  .map((f) => f.path)
107
67
  .join(", ")
@@ -111,26 +71,17 @@ export function buildCommitMsgInput(ctx, fallbackLang) {
111
71
  return null;
112
72
  return parts.join("\n");
113
73
  }
114
- /**
115
- * Normalize whatever the model emitted into the single-line subject that goes
116
- * into the commit input: drop fences, labels and wrapping quotes, keep only
117
- * the first non-empty line, collapse whitespace, cap the length.
118
- */
119
74
  export function sanitizeCommitMessage(raw) {
120
75
  let text = raw.trim();
121
- // ```…``` fences wrapping the whole answer.
122
76
  const fence = text.match(/^```[a-zA-Z]*\s*\n?([\s\S]*?)\n?```$/);
123
77
  if (fence)
124
78
  text = fence[1].trim();
125
- // Leading labels some models add despite the instructions.
126
79
  text = text.replace(/^(commit(\s+message)?|subject|提交信息|提交消息|提交说明)\s*[::]\s*/i, "");
127
- // First non-empty line only — the input field is single-line by design.
128
80
  const firstLine = text
129
81
  .split("\n")
130
82
  .map((l) => l.trim())
131
83
  .find((l) => l.length > 0) ?? "";
132
84
  let out = firstLine.replace(/\s+/g, " ").trim();
133
- // Matching wrapping quotes.
134
85
  if (out.length >= 2) {
135
86
  const a = out[0];
136
87
  const b = out[out.length - 1];
@@ -142,10 +93,6 @@ export function sanitizeCommitMessage(raw) {
142
93
  out = `${out.slice(0, MAX_COMMITMSG_LEN - 1).trimEnd()}…`;
143
94
  return out;
144
95
  }
145
- /**
146
- * 完整的 SCM AI 提交信息生成逻辑封装:
147
- * 提取 git 差异上下文 -> 组装 prompt -> 调用模型 completeSimple -> 结果清洗校验
148
- */
149
96
  export async function generateScmCommitMessage(opts) {
150
97
  const { cwd, model, runtime, lang, promptMode = "append", customPrompt = "", timeoutMs = SCM_COMMITMSG_TIMEOUT_MS, } = opts;
151
98
  try {
@@ -1,20 +1,10 @@
1
- /**
2
- * Read-only git queries backing the source-control panel.
3
- *
4
- * Replaces the old hidden-PTY + text-scraping approach: every query is a
5
- * plain `execFile("git", …)` — no shell, no prompts, no echo, no sentinel
6
- * parsing. Output is parsed into structured JSON on the server; the client
7
- * just renders it.
8
- */
9
1
  import { execFile } from "node:child_process";
10
2
  import { promisify } from "node:util";
11
3
  import { pick } from "./i18n.js";
12
4
  import { getGlobalRemoteSshService, isRemoteWorkspaceUri, shellQuotePosix } from "./remote-ssh-service.js";
13
5
  const exec = promisify(execFile);
14
- /** Per-command timeout / output cap — a stuck repo must not hang the panel. */
15
6
  const GIT_TIMEOUT_MS = 15_000;
16
7
  const MAX_GIT_OUTPUT = 16 * 1024 * 1024;
17
- /** Run one git command; throws Error with a readable message on failure. */
18
8
  async function git(cwd, args, lang) {
19
9
  const l = lang?.() ?? "en";
20
10
  if (isRemoteWorkspaceUri(cwd)) {
@@ -49,8 +39,6 @@ async function git(cwd, args, lang) {
49
39
  throw new Error(detail || pick(l, "git 命令失败", "git command failed", "scm.git.failed"));
50
40
  }
51
41
  }
52
- /** Absolute path of the repo's git dir (handles worktrees/submodules), or
53
- * null when cwd isn't inside a repository. */
54
42
  export async function gitDirOf(cwd) {
55
43
  if (isRemoteWorkspaceUri(cwd))
56
44
  return null;
@@ -66,15 +54,9 @@ export async function gitDirOf(cwd) {
66
54
  return null;
67
55
  }
68
56
  }
69
- /** True when the error is "this directory isn't a git repository". */
70
57
  export function isNotRepoError(err) {
71
58
  return /not a git repository/i.test(err instanceof Error ? err.message : String(err));
72
59
  }
73
- /* ------------------------------------------------------------------ */
74
- /* parsers */
75
- /* ------------------------------------------------------------------ */
76
- /** Undo git's C-style quoting for unusual file names ("a\tb" → a<TAB>b).
77
- * core.quotepath=false already handles non-ASCII; this covers control chars. */
78
60
  function unquotePath(s) {
79
61
  if (!s.startsWith('"'))
80
62
  return s;
@@ -163,7 +145,7 @@ function parseStatusFiles(text) {
163
145
  continue;
164
146
  if (line.length >= 3) {
165
147
  let path = line.slice(3);
166
- const arrow = path.indexOf(" -> "); // rename: "R old -> new"
148
+ const arrow = path.indexOf(" -> ");
167
149
  if (arrow >= 0)
168
150
  path = path.slice(arrow + 4);
169
151
  out.push({ path: unquotePath(path), x: line[0], y: line[1] });
@@ -184,7 +166,6 @@ function parseBranches(text) {
184
166
  }
185
167
  else if (ref.startsWith("refs/remotes/")) {
186
168
  const short = ref.slice("refs/remotes/".length);
187
- // Skip the "origin/HEAD -> origin/main" symlink.
188
169
  if (short.endsWith("/HEAD"))
189
170
  continue;
190
171
  const slash = short.indexOf("/");
@@ -197,20 +178,17 @@ function parseBranches(text) {
197
178
  }
198
179
  return out;
199
180
  }
200
- /** Parse `git log --graph --pretty=format:%H%x09…` preserving graph prefixes. */
201
181
  function parseCommitHistory(text) {
202
182
  const out = [];
203
183
  for (const line of text.split("\n")) {
204
184
  const tab = line.indexOf("\t");
205
185
  if (tab < 0)
206
- continue; // connector-only graph line
186
+ continue;
207
187
  const prefixAndHash = line.slice(0, tab);
208
188
  const match = prefixAndHash.match(/([0-9a-f]{7,40})$/i);
209
189
  if (!match || match.index === undefined)
210
190
  continue;
211
191
  const fields = line.slice(tab + 1).split("\t");
212
- // An empty decoration field removes the final tab — four fields is a
213
- // valid undecorated commit.
214
192
  if (fields.length < 4)
215
193
  continue;
216
194
  out.push({
@@ -225,7 +203,6 @@ function parseCommitHistory(text) {
225
203
  }
226
204
  return out;
227
205
  }
228
- /** Parse `git diff --numstat` output: "12\t3\tpath" → { path: [add, del] }. */
229
206
  function parseNumStat(text) {
230
207
  const stats = {};
231
208
  for (const line of text.split("\n")) {
@@ -238,7 +215,7 @@ function parseNumStat(text) {
238
215
  let add = Number(line.slice(0, tab1));
239
216
  let del = Number(line.slice(tab1 + 1, tab2));
240
217
  if (!Number.isFinite(add))
241
- add = 0; // binary file → "-"
218
+ add = 0;
242
219
  if (!Number.isFinite(del))
243
220
  del = 0;
244
221
  const path = unquotePath(line.slice(tab2 + 1).trim());
@@ -247,9 +224,6 @@ function parseNumStat(text) {
247
224
  }
248
225
  return stats;
249
226
  }
250
- /* ------------------------------------------------------------------ */
251
- /* queries */
252
- /* ------------------------------------------------------------------ */
253
227
  const HISTORY_ARGS = [
254
228
  "log",
255
229
  "--all",
@@ -260,12 +234,9 @@ const HISTORY_ARGS = [
260
234
  "-n",
261
235
  "120",
262
236
  ];
263
- /** Commit graph for the history tab — fetched lazily so the common
264
- * "changes" view never pays for it on huge repos. */
265
237
  export async function scmHistory(cwd, lang) {
266
238
  return parseCommitHistory(await git(cwd, HISTORY_ARGS, lang));
267
239
  }
268
- /** Status refresh payload (status + branches + numstat) — parallel. */
269
240
  export async function scmStatus(cwd, lang) {
270
241
  const [statusText, branchText, statText, cachedStatText] = await Promise.all([
271
242
  git(cwd, ["status", "--porcelain=v1", "-b", "--find-renames"], lang),
@@ -277,7 +248,6 @@ export async function scmStatus(cwd, lang) {
277
248
  .split("\n")
278
249
  .find((l) => l.startsWith("## "))
279
250
  ?.slice(3) ?? "");
280
- // Worktree + staged line counts, merged per path.
281
251
  const merged = {};
282
252
  for (const [path, pair] of Object.entries(parseNumStat(statText))) {
283
253
  merged[path] = pair;
@@ -299,7 +269,6 @@ export async function scmStatus(cwd, lang) {
299
269
  stats: merged,
300
270
  };
301
271
  }
302
- /** Staged + worktree diffs for one file (empty strings when no diff). */
303
272
  export async function scmFileDiff(cwd, path, lang) {
304
273
  const [staged, worktree] = await Promise.all([
305
274
  git(cwd, ["diff", "--cached", "--no-color", "--no-ext-diff", "--", path], lang).catch(() => ""),
@@ -307,27 +276,15 @@ export async function scmFileDiff(cwd, path, lang) {
307
276
  ]);
308
277
  return { staged, worktree };
309
278
  }
310
- /** Full patch of one commit (`git show`). */
311
279
  export async function scmCommitDetail(cwd, hash, lang) {
312
280
  return git(cwd, ["show", "--no-color", "--no-ext-diff", "--find-renames", "--format=fuller", "--stat", "--patch", hash], lang);
313
281
  }
314
- /* ------------------------------------------------------------------ */
315
- /* AI commit-message context */
316
- /* ------------------------------------------------------------------ */
317
- /** Cap per patch (staged / worktree) fed to the commit-message prompt —
318
- * enough for the model to see what most commits are about without letting
319
- * one huge repo blow up the one-off completion request. */
320
282
  const MAX_COMMITMSG_PATCH_CHARS = 12_000;
321
- /** Cap one patch at MAX_COMMITMSG_PATCH_CHARS, keeping the head (early files
322
- * matter most for a commit message) and marking the cut. */
323
283
  function capPatch(text) {
324
284
  if (text.length <= MAX_COMMITMSG_PATCH_CHARS)
325
285
  return text;
326
286
  return `${text.slice(0, MAX_COMMITMSG_PATCH_CHARS)}\n… (diff truncated)`;
327
287
  }
328
- /** Gather staged/worktree patches, numstats, status and recent subjects for
329
- * the AI commit-message generator. Throws the usual git errors (including
330
- * "not a git repository") — the caller maps them to friendly replies. */
331
288
  export async function scmCommitContext(cwd, lang) {
332
289
  const [stagedPatch, worktreePatch, stagedStatText, worktreeStatText, statusText, subjectText] = await Promise.all([
333
290
  git(cwd, ["diff", "--cached", "--no-color", "--no-ext-diff", "--find-renames"], lang).catch(() => ""),
@@ -335,8 +292,6 @@ export async function scmCommitContext(cwd, lang) {
335
292
  git(cwd, ["diff", "--cached", "--numstat"], lang).catch(() => ""),
336
293
  git(cwd, ["diff", "--numstat"], lang).catch(() => ""),
337
294
  git(cwd, ["status", "--porcelain=v1", "--find-renames"], lang),
338
- // Empty repos (no commits yet) make `git log` fail — that's a valid
339
- // "no style reference" answer, not an error worth failing the request.
340
295
  git(cwd, ["log", "-n", "15", "--pretty=format:%s"], lang).then((s) => s, () => ""),
341
296
  ]);
342
297
  const subjects = subjectText
@@ -1,21 +1,8 @@
1
- /**
2
- * sdk-builtin-extensions.ts — 动态装配与筛选 @earendil-works/pi-coding-agent SDK 内置扩展。
3
- *
4
- * 职责:
5
- * 1. 继承 SDK 原生内置扩展(如 builtin:llama.cpp、builtin:codemode、builtin:tool-search);
6
- * 2. 精准隔离 SDK 内置 MCP 扩展(pi-web-ui 统一使用专属 McpBridge 管理,防止 MCP 进程双重派生);
7
- * 3. 严格保留 builtin: true 与 replaceable 等元数据,确保 SDK DefaultResourceLoader 正确建立
8
- * builtin:<name> 字典索引(解决 Issue #755:GUI 无法发现和使用 llama.cpp 本地模型的问题);
9
- * 4. 遵循与 resolve-global-sdk / patch-remote-catalog 相同的事实源,兼容全局 SDK 与自带副本。
10
- */
11
1
  import { existsSync } from "node:fs";
12
2
  import { dirname, join } from "node:path";
13
3
  import { fileURLToPath, pathToFileURL } from "node:url";
14
4
  import { createCodemodeExtension, createToolSearchExtension } from "@earendil-works/pi-coding-agent";
15
5
  let cachedEntries = null;
16
- /**
17
- * 解析当前生效 SDK 的 extensions/index.js 文件绝对路径。
18
- */
19
6
  export function resolveSdkExtensionsIndexPath() {
20
7
  try {
21
8
  const entry = fileURLToPath(import.meta.resolve("@earendil-works/pi-coding-agent"));
@@ -23,16 +10,9 @@ export function resolveSdkExtensionsIndexPath() {
23
10
  if (existsSync(candidate))
24
11
  return candidate;
25
12
  }
26
- catch {
27
- /* ignore resolve failure */
28
- }
13
+ catch { }
29
14
  return null;
30
15
  }
31
- /**
32
- * 获取经过宿主门禁过滤后的 SDK 内置扩展工厂列表(带内存缓存)。
33
- * - 包含:llama.cpp、codemode、tool-search(以及未来 SDK 官方新增的提供商扩展)
34
- * - 剔除:mcp(由 WebUI 独立 McpBridge 接管)
35
- */
36
16
  export async function getSdkBuiltinExtensionFactories() {
37
17
  if (cachedEntries)
38
18
  return cachedEntries;
@@ -43,7 +23,6 @@ export async function getSdkBuiltinExtensionFactories() {
43
23
  const mod = (await import(pathToFileURL(indexPath).href));
44
24
  if (Array.isArray(mod.builtInExtensions)) {
45
25
  for (const ext of mod.builtInExtensions) {
46
- // 严格屏蔽 SDK 内置 mcp:避免与宿主 McpBridge 重复连接和拉起 stdio 进程
47
26
  if (ext.name === "mcp")
48
27
  continue;
49
28
  factories.push({
@@ -56,11 +35,8 @@ export async function getSdkBuiltinExtensionFactories() {
56
35
  }
57
36
  }
58
37
  }
59
- catch {
60
- /* dynamic load failed, fall back below */
61
- }
38
+ catch { }
62
39
  }
63
- // 兜底回退:若未成功加载任何工厂,保证核心基础设施扩展可用
64
40
  if (factories.length === 0) {
65
41
  factories.push({
66
42
  name: "codemode",
@@ -79,7 +55,4 @@ export async function getSdkBuiltinExtensionFactories() {
79
55
  cachedEntries = factories;
80
56
  return factories;
81
57
  }
82
- /**
83
- * 宿主层需禁用的 SDK 内置扩展名称清单(双保险,传给 disabledBuiltinExtensions)。
84
- */
85
58
  export const SDK_DISABLED_BUILTIN_EXTENSIONS = ["mcp"];