@waq666/pneuma 0.7.1 → 0.8.1

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 (416) hide show
  1. package/README.md +242 -206
  2. package/bin/dsc.js +9 -3
  3. package/bin/headless.cjs +1 -1
  4. package/lib/adapter/transcript.d.ts +19 -2
  5. package/lib/adapter/transcript.js +71 -14
  6. package/lib/app/AgentsOverlay.js +7 -6
  7. package/lib/app/App.js +1 -1
  8. package/lib/app/ApprovalCard.js +15 -9
  9. package/lib/app/ChatView.d.ts +3 -1
  10. package/lib/app/ChatView.js +21 -17
  11. package/lib/app/Composer.js +22 -4
  12. package/lib/app/MarkdownView.js +2 -1
  13. package/lib/app/ModelPicker.js +7 -6
  14. package/lib/app/PickerFrame.d.ts +4 -0
  15. package/lib/app/PickerFrame.js +18 -0
  16. package/lib/app/PlanReviewCard.js +2 -1
  17. package/lib/app/PresetPicker.js +8 -7
  18. package/lib/app/SessionPicker.js +21 -20
  19. package/lib/app/SettingsOverlay.js +1 -1
  20. package/lib/app/SkillsPicker.js +7 -6
  21. package/lib/app/StatusBar.js +3 -15
  22. package/lib/app/TaskStrips.js +1 -4
  23. package/lib/app/TimelineRail.js +2 -1
  24. package/lib/app/ToolCard.js +2 -6
  25. package/lib/app/Welcome.d.ts +1 -0
  26. package/lib/app/Welcome.js +1 -4
  27. package/lib/app/click.d.ts +0 -2
  28. package/lib/app/click.js +2 -21
  29. package/lib/app/display-width.d.ts +16 -0
  30. package/lib/app/display-width.js +33 -0
  31. package/lib/app/markdown.d.ts +1 -3
  32. package/lib/app/markdown.js +2 -19
  33. package/lib/app/scroll-model.js +1 -1
  34. package/lib/contract/approval.d.ts +91 -0
  35. package/lib/contract/approval.js +1 -0
  36. package/lib/contract/mode.d.ts +69 -0
  37. package/lib/contract/mode.js +1 -0
  38. package/lib/contract/plugin.d.ts +240 -0
  39. package/lib/contract/plugin.js +1 -0
  40. package/lib/contract/runtime.d.ts +282 -0
  41. package/lib/contract/runtime.js +1 -0
  42. package/lib/contract/session.d.ts +208 -0
  43. package/lib/contract/session.js +36 -0
  44. package/lib/contract/settings.d.ts +242 -0
  45. package/lib/contract/settings.js +1 -0
  46. package/lib/contract/snapshot.d.ts +453 -0
  47. package/lib/contract/snapshot.js +1 -0
  48. package/lib/contract/task.d.ts +189 -0
  49. package/lib/contract/task.js +10 -0
  50. package/lib/contract/transcript.d.ts +358 -0
  51. package/lib/contract/transcript.js +1 -0
  52. package/lib/contract/usage.d.ts +132 -0
  53. package/lib/contract/usage.js +10 -0
  54. package/lib/contract.d.ts +20 -1968
  55. package/lib/contract.js +19 -30
  56. package/lib/core/agent-roles.d.ts +1 -1
  57. package/lib/core/agent-roles.js +6 -5
  58. package/lib/core/approval-floor.d.ts +9 -0
  59. package/lib/core/approval-floor.js +152 -25
  60. package/lib/core/attachments.d.ts +185 -0
  61. package/lib/core/attachments.js +425 -0
  62. package/lib/core/bytes.d.ts +14 -0
  63. package/lib/core/bytes.js +28 -0
  64. package/lib/core/call-meaning.d.ts +20 -0
  65. package/lib/core/call-meaning.js +347 -0
  66. package/lib/core/cdp/actions.js +6 -0
  67. package/lib/core/cdp/launch.js +2 -2
  68. package/lib/core/cdp/report.d.ts +27 -0
  69. package/lib/core/cdp/report.js +50 -0
  70. package/lib/core/cdp/ring-buffer.d.ts +25 -0
  71. package/lib/core/cdp/ring-buffer.js +44 -0
  72. package/lib/core/cdp/snapshot.js +5 -9
  73. package/lib/core/cdp/transport.js +1 -1
  74. package/lib/core/clamp.d.ts +20 -0
  75. package/lib/core/clamp.js +24 -0
  76. package/lib/core/clock.d.ts +16 -0
  77. package/lib/core/clock.js +20 -0
  78. package/lib/core/command-policy.js +33 -1
  79. package/lib/core/commands-completion.d.ts +28 -0
  80. package/lib/core/commands-completion.js +108 -30
  81. package/lib/core/compact.d.ts +36 -6
  82. package/lib/core/compact.js +89 -17
  83. package/lib/core/desktop-control.js +1 -3
  84. package/lib/core/dsh-compat/llm-usage-event.d.ts +78 -0
  85. package/lib/core/dsh-compat/llm-usage-event.js +91 -0
  86. package/lib/core/dsh-compat/presentation.d.ts +84 -0
  87. package/lib/core/dsh-compat/presentation.js +105 -0
  88. package/lib/core/dsh-compat/resolve-hook.d.ts +3 -3
  89. package/lib/core/dsh-compat/resolve-hook.js +41 -13
  90. package/lib/core/dsh-compat/service-map.d.ts +52 -0
  91. package/lib/core/dsh-compat/service-map.js +87 -0
  92. package/lib/core/dsh-compat/session-bridge.d.ts +107 -0
  93. package/lib/core/dsh-compat/session-bridge.js +376 -0
  94. package/lib/core/dsh-compat/session-events.d.ts +54 -0
  95. package/lib/core/dsh-compat/session-events.js +297 -0
  96. package/lib/core/dsh-compat/shims/credentials.d.ts +62 -0
  97. package/lib/core/dsh-compat/shims/credentials.js +86 -0
  98. package/lib/core/dsh-compat/shims/home-paths.d.ts +77 -0
  99. package/lib/core/dsh-compat/shims/home-paths.js +143 -0
  100. package/lib/core/dsh-compat/tools-facade.d.ts +31 -1
  101. package/lib/core/dsh-compat/tools-facade.js +207 -3
  102. package/lib/core/err-text.d.ts +5 -0
  103. package/lib/core/err-text.js +5 -0
  104. package/lib/core/events.d.ts +31 -2
  105. package/lib/core/git-info.d.ts +127 -15
  106. package/lib/core/git-info.js +315 -34
  107. package/lib/core/git-surface.d.ts +17 -0
  108. package/lib/core/git-surface.js +7 -0
  109. package/lib/core/hooks.d.ts +19 -2
  110. package/lib/core/hooks.js +57 -13
  111. package/lib/core/host-methods.d.ts +1 -1
  112. package/lib/core/host-methods.js +4 -0
  113. package/lib/core/image-diet.js +1 -4
  114. package/lib/core/json-text.d.ts +11 -0
  115. package/lib/core/json-text.js +18 -0
  116. package/lib/core/learnings/skill-write.d.ts +1 -7
  117. package/lib/core/learnings/skill-write.js +3 -37
  118. package/lib/core/lifecycle-hooks.d.ts +11 -3
  119. package/lib/core/lifecycle-hooks.js +33 -42
  120. package/lib/core/llm.d.ts +42 -0
  121. package/lib/core/llm.js +40 -25
  122. package/lib/core/loop.d.ts +11 -1
  123. package/lib/core/loop.js +95 -28
  124. package/lib/core/lsp/client.js +30 -17
  125. package/lib/core/lsp/normalize.d.ts +0 -2
  126. package/lib/core/lsp/normalize.js +1 -6
  127. package/lib/core/lsp/servers.js +1 -4
  128. package/lib/core/mcp.d.ts +18 -0
  129. package/lib/core/mcp.js +60 -16
  130. package/lib/core/microcompact.d.ts +45 -0
  131. package/lib/core/microcompact.js +128 -0
  132. package/lib/core/native-bridge.js +2 -10
  133. package/lib/core/path-policy.d.ts +13 -1
  134. package/lib/core/path-policy.js +87 -18
  135. package/lib/core/permission-presets.d.ts +9 -5
  136. package/lib/core/permission-presets.js +14 -7
  137. package/lib/core/permission-scope.d.ts +65 -0
  138. package/lib/core/permission-scope.js +109 -0
  139. package/lib/core/plugin-bundle.d.ts +95 -0
  140. package/lib/core/plugin-bundle.js +137 -0
  141. package/lib/core/plugin-loader.d.ts +36 -1
  142. package/lib/core/plugin-loader.js +336 -12
  143. package/lib/core/plugin-patch.d.ts +64 -0
  144. package/lib/core/plugin-patch.js +146 -0
  145. package/lib/core/plugin-registry.d.ts +14 -0
  146. package/lib/core/plugin-registry.js +2 -0
  147. package/lib/core/prefs.js +40 -2
  148. package/lib/core/presets.d.ts +11 -0
  149. package/lib/core/presets.js +61 -22
  150. package/lib/core/profile-dir.d.ts +5 -0
  151. package/lib/core/profile-dir.js +40 -0
  152. package/lib/core/prompt.js +55 -19
  153. package/lib/core/ptc.d.ts +8 -2
  154. package/lib/core/ptc.js +18 -4
  155. package/lib/core/records.d.ts +16 -0
  156. package/lib/core/records.js +22 -0
  157. package/lib/core/remote/notify.js +1 -3
  158. package/lib/core/remote/push.js +2 -6
  159. package/lib/core/sandbox/execpolicy.js +27 -3
  160. package/lib/core/sandbox/net-proxy.js +2 -2
  161. package/lib/core/sandbox/policy.d.ts +1 -1
  162. package/lib/core/sandbox/policy.js +21 -15
  163. package/lib/core/sandbox/win/account.js +1 -4
  164. package/lib/core/sandbox/win/acl.js +1 -6
  165. package/lib/core/sandbox/win/backend.d.ts +24 -3
  166. package/lib/core/sandbox/win/backend.js +73 -23
  167. package/lib/core/sandbox/win/doctor.js +1 -4
  168. package/lib/core/sandbox/win/runner-entry.js +1 -6
  169. package/lib/core/sandbox/win/setup.js +1 -4
  170. package/lib/core/sandbox/win/utf16.d.ts +11 -0
  171. package/lib/core/sandbox/win/utf16.js +15 -0
  172. package/lib/core/sandbox/win/wfp.js +1 -4
  173. package/lib/core/schedule/rule.d.ts +0 -17
  174. package/lib/core/schedule/rule.js +1 -3
  175. package/lib/core/schedule/runner.d.ts +5 -2
  176. package/lib/core/schedule/runner.js +32 -9
  177. package/lib/core/schedule/store.d.ts +0 -2
  178. package/lib/core/schedule/store.js +2 -9
  179. package/lib/core/session-index.d.ts +50 -0
  180. package/lib/core/session-index.js +169 -3
  181. package/lib/core/session.d.ts +89 -13
  182. package/lib/core/session.js +385 -32
  183. package/lib/core/shell-quote.d.ts +21 -0
  184. package/lib/core/shell-quote.js +24 -0
  185. package/lib/core/side-ask.d.ts +52 -0
  186. package/lib/core/side-ask.js +89 -0
  187. package/lib/core/skills.d.ts +16 -0
  188. package/lib/core/skills.js +45 -8
  189. package/lib/core/snapshot-throttle.d.ts +8 -0
  190. package/lib/core/snapshot-throttle.js +24 -0
  191. package/lib/core/spill.d.ts +11 -5
  192. package/lib/core/spill.js +35 -36
  193. package/lib/core/strings.d.ts +21 -0
  194. package/lib/core/strings.js +33 -0
  195. package/lib/core/terminal-env.d.ts +61 -0
  196. package/lib/core/terminal-env.js +327 -0
  197. package/lib/core/text-format.d.ts +17 -0
  198. package/lib/core/text-format.js +26 -0
  199. package/lib/core/todo-reminder.d.ts +19 -14
  200. package/lib/core/todo-reminder.js +14 -23
  201. package/lib/core/token-estimate.d.ts +18 -2
  202. package/lib/core/token-estimate.js +10 -2
  203. package/lib/core/tool-result-prune.d.ts +42 -0
  204. package/lib/core/tool-result-prune.js +47 -0
  205. package/lib/core/tool-search.d.ts +3 -2
  206. package/lib/core/tool-search.js +3 -2
  207. package/lib/core/tools/bash.d.ts +35 -3
  208. package/lib/core/tools/bash.js +168 -41
  209. package/lib/core/tools/fs-tools.js +18 -17
  210. package/lib/core/tools/image-tool.d.ts +2 -0
  211. package/lib/core/tools/image-tool.js +59 -0
  212. package/lib/core/tools/path-args.d.ts +4 -0
  213. package/lib/core/tools/path-args.js +22 -0
  214. package/lib/core/tools/search-tools.d.ts +30 -0
  215. package/lib/core/tools/search-tools.js +321 -34
  216. package/lib/core/tools.d.ts +82 -0
  217. package/lib/core/tools.js +21 -0
  218. package/lib/core/transcript-text.d.ts +19 -0
  219. package/lib/core/transcript-text.js +44 -0
  220. package/lib/core/ui-boot-source.d.ts +5 -0
  221. package/lib/core/ui-boot-source.js +10 -3
  222. package/lib/core/ui-bundles.d.ts +80 -6
  223. package/lib/core/ui-bundles.js +700 -76
  224. package/lib/core/ui-events.d.ts +10 -0
  225. package/lib/core/ui-events.js +25 -0
  226. package/lib/core/ui-methods.d.ts +1 -1
  227. package/lib/core/ui-methods.js +42 -13
  228. package/lib/core/ui-route.js +11 -7
  229. package/lib/core/ui-server.d.ts +6 -0
  230. package/lib/core/ui-server.js +106 -1
  231. package/lib/core/unified-diff.d.ts +35 -0
  232. package/lib/core/unified-diff.js +86 -0
  233. package/lib/core/usage-log.js +39 -0
  234. package/lib/core/web-http.d.ts +1 -1
  235. package/lib/core/web-http.js +1 -3
  236. package/lib/host/kernel.js +57 -41
  237. package/lib/plugins/agent.js +101 -20
  238. package/lib/plugins/approval-floor.js +12 -8
  239. package/lib/plugins/approval.js +252 -80
  240. package/lib/plugins/ask.js +60 -8
  241. package/lib/plugins/browser.js +32 -84
  242. package/lib/plugins/commands.js +167 -57
  243. package/lib/plugins/compact.d.ts +2 -2
  244. package/lib/plugins/compact.js +200 -30
  245. package/lib/plugins/computer-use.js +34 -18
  246. package/lib/plugins/dock-browser.js +24 -65
  247. package/lib/plugins/dsh-compat.js +7 -0
  248. package/lib/plugins/file-review.js +59 -15
  249. package/lib/plugins/git.js +16 -8
  250. package/lib/plugins/goal.js +9 -8
  251. package/lib/plugins/hooks.js +4 -2
  252. package/lib/plugins/host-stdio.js +14 -16
  253. package/lib/plugins/lifecycle-hooks.d.ts +5 -4
  254. package/lib/plugins/lifecycle-hooks.js +12 -10
  255. package/lib/plugins/llm.js +74 -33
  256. package/lib/plugins/lsp.js +22 -27
  257. package/lib/plugins/mcp.js +16 -17
  258. package/lib/plugins/memory.js +3 -24
  259. package/lib/plugins/microcompact.d.ts +4 -1
  260. package/lib/plugins/microcompact.js +117 -19
  261. package/lib/plugins/mode.js +30 -11
  262. package/lib/plugins/permission-presets.d.ts +2 -1
  263. package/lib/plugins/permission-presets.js +55 -35
  264. package/lib/plugins/plugin-manager.js +4 -6
  265. package/lib/plugins/presets.js +56 -27
  266. package/lib/plugins/prompt.js +54 -11
  267. package/lib/plugins/ptc.d.ts +13 -0
  268. package/lib/plugins/ptc.js +121 -24
  269. package/lib/plugins/remote/types.d.ts +1 -1
  270. package/lib/plugins/remote/types.js +11 -0
  271. package/lib/plugins/remote.js +14 -15
  272. package/lib/plugins/runtime.js +91 -14
  273. package/lib/plugins/sandbox.js +181 -60
  274. package/lib/plugins/schedule.js +12 -11
  275. package/lib/plugins/self-improve.js +28 -18
  276. package/lib/plugins/session-search.js +18 -13
  277. package/lib/plugins/session-title.js +1 -1
  278. package/lib/plugins/session.js +103 -25
  279. package/lib/plugins/settings.js +16 -40
  280. package/lib/plugins/skills.js +18 -1
  281. package/lib/plugins/spill.js +18 -11
  282. package/lib/plugins/subagent.js +208 -42
  283. package/lib/plugins/team.js +11 -5
  284. package/lib/plugins/todo.d.ts +1 -1
  285. package/lib/plugins/todo.js +25 -19
  286. package/lib/plugins/tool-search.js +47 -28
  287. package/lib/plugins/tools-default.js +89 -5
  288. package/lib/plugins/tools.js +3 -3
  289. package/lib/plugins/transcript.js +116 -9
  290. package/lib/plugins/web-search.d.ts +1 -1
  291. package/lib/plugins/web-search.js +25 -16
  292. package/lib/plugins/webserver.js +40 -7
  293. package/lib/remote/assets/app-B3Id1EBq.js +14 -0
  294. package/lib/remote/assets/index.html +2 -2
  295. package/lib/remote/assets/{style-DIB6729x.css → style-NtlpbKOI.css} +1 -1
  296. package/lib/services/types.d.ts +247 -29
  297. package/lib/tools/plugin-cli.d.ts +1 -0
  298. package/lib/tools/plugin-cli.js +209 -0
  299. package/lib/ui/assets/app-B-Jx5dnh.js +90 -0
  300. package/lib/ui/assets/{chunk-BajyYBss.js → chunk-Bfdlo8Me.js} +1 -1
  301. package/lib/ui/assets/chunk-DGX-i4eb.js +12 -0
  302. package/lib/ui/assets/index.html +62 -14
  303. package/lib/ui/assets/style-WzxwEPaE.css +1 -0
  304. package/lib/ui/frames.js +1 -3
  305. package/lib/ui/index.d.ts +30 -1
  306. package/lib/ui/index.js +29 -0
  307. package/lib/ui/manifest.d.ts +24 -6
  308. package/lib/ui/manifest.js +3 -2
  309. package/lib/ui/plugins/actions/bundle.json +8 -0
  310. package/lib/ui/plugins/actions/client.js +43 -0
  311. package/lib/ui/plugins/ask/bundle.json +8 -0
  312. package/lib/ui/plugins/ask/client.js +415 -0
  313. package/lib/ui/plugins/browser/bundle.json +8 -0
  314. package/lib/ui/plugins/composer/bundle.json +9 -0
  315. package/lib/ui/plugins/composer/client.js +1806 -1087
  316. package/lib/ui/plugins/files/bundle.json +8 -0
  317. package/lib/ui/plugins/files/client.js +13 -98
  318. package/lib/ui/plugins/manifest.json +1 -104
  319. package/lib/ui/plugins/palette/bundle.json +8 -0
  320. package/lib/ui/plugins/palette/client.js +360 -0
  321. package/lib/ui/plugins/plugins/bundle.json +8 -0
  322. package/lib/ui/plugins/plugins/client.js +116 -38
  323. package/lib/ui/plugins/preview/bundle.json +8 -0
  324. package/lib/ui/plugins/preview/client.js +6 -16
  325. package/lib/ui/plugins/prompt/bundle.json +8 -0
  326. package/lib/ui/plugins/prompt/client.js +81 -47
  327. package/lib/ui/plugins/sessions/bundle.json +8 -0
  328. package/lib/ui/plugins/sessions/client.js +157 -111
  329. package/lib/ui/plugins/settings/bundle.json +8 -0
  330. package/lib/ui/plugins/settings/client.js +184 -170
  331. package/lib/ui/plugins/skills/bundle.json +8 -0
  332. package/lib/ui/plugins/skills/client.js +161 -79
  333. package/lib/ui/plugins/status/bundle.json +8 -0
  334. package/lib/ui/plugins/status/client.js +165 -26
  335. package/lib/ui/plugins/statusbar/bundle.json +9 -0
  336. package/lib/ui/plugins/statusbar/client.js +100 -144
  337. package/lib/ui/plugins/tasks/bundle.json +8 -0
  338. package/lib/ui/plugins/team/bundle.json +8 -0
  339. package/lib/ui/plugins/team/client.js +60 -58
  340. package/lib/ui/plugins/terminal/bundle.json +8 -0
  341. package/lib/ui/plugins/terminal/client.js +1 -7
  342. package/lib/ui/plugins/trace/bundle.json +11 -0
  343. package/lib/ui/plugins/trace/client.js +86 -179
  344. package/lib/ui/plugins/transcript/bundle.json +8 -0
  345. package/lib/ui/plugins/transcript/client.js +1608 -1243
  346. package/lib/ui/sdk/@dsc/ui/index.d.ts +54 -16
  347. package/lib/ui/sdk/@dsc/ui/package.json +1 -1
  348. package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +20 -1968
  349. package/lib/ui/sdk/@dsc/ui-core/core/attachments.d.ts +185 -0
  350. package/lib/ui/sdk/@dsc/ui-core/core/bytes.d.ts +14 -0
  351. package/lib/ui/sdk/@dsc/ui-core/core/err-text.d.ts +18 -0
  352. package/lib/ui/sdk/@dsc/ui-core/core/git-surface.d.ts +17 -0
  353. package/lib/ui/sdk/@dsc/ui-core/core/json-text.d.ts +11 -0
  354. package/lib/ui/sdk/@dsc/ui-core/core/path-policy.d.ts +44 -0
  355. package/lib/ui/sdk/@dsc/ui-core/core/records.d.ts +16 -0
  356. package/lib/ui/sdk/@dsc/ui-core/core/throughput.d.ts +46 -0
  357. package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +18 -2
  358. package/lib/ui/sdk/@dsc/ui-core/core/unified-diff.d.ts +35 -0
  359. package/lib/ui/sdk/@dsc/ui-core/package.json +1 -1
  360. package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +30 -1
  361. package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +24 -6
  362. package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +19 -8
  363. package/lib/ui/sdk/@dsc/ui-core/ui/signal.d.ts +49 -0
  364. package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +17 -3
  365. package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +1 -1
  366. package/lib/ui/sdk/@dsc/ui-dockkit/package.json +1 -1
  367. package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +4 -0
  368. package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +6 -1
  369. package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +21 -0
  370. package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +1 -0
  371. package/lib/ui/sdk/@dsc/ui-layout/package.json +1 -1
  372. package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +1 -1
  373. package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +10 -1
  374. package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +1 -1
  375. package/lib/ui/sdk/@dsc/ui-layout/usage-today.d.ts +11 -0
  376. package/lib/ui/sdk/@dsc/ui-primitives/dialog-focus.d.ts +30 -0
  377. package/lib/ui/sdk/@dsc/ui-primitives/error-text.d.ts +12 -0
  378. package/lib/ui/sdk/@dsc/ui-primitives/git-surface.d.ts +9 -0
  379. package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +23 -0
  380. package/lib/ui/sdk/@dsc/ui-primitives/humanize-error.d.ts +35 -0
  381. package/lib/ui/sdk/@dsc/ui-primitives/icons-workspace.d.ts +33 -0
  382. package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +21 -3
  383. package/lib/ui/sdk/@dsc/ui-primitives/image-lightbox.d.ts +21 -0
  384. package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +16 -0
  385. package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +10 -14
  386. package/lib/ui/sdk/@dsc/ui-primitives/package.json +1 -1
  387. package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +31 -8
  388. package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +2 -0
  389. package/lib/ui/sdk/@dsc/ui-primitives/review-findings-card.d.ts +25 -0
  390. package/lib/ui/sdk/@dsc/ui-primitives/review-findings.d.ts +64 -0
  391. package/lib/ui/sdk/@dsc/ui-primitives/review-notice-card.d.ts +27 -0
  392. package/lib/ui/sdk/@dsc/ui-primitives/review-notice.d.ts +80 -0
  393. package/lib/ui/sdk/@dsc/ui-primitives/signal.d.ts +9 -0
  394. package/lib/ui/sdk/@dsc/ui-primitives/sizes.d.ts +15 -0
  395. package/lib/ui/sdk/@dsc/ui-primitives/skeleton.d.ts +39 -0
  396. package/lib/ui/sdk/@dsc/ui-primitives/snapshot.d.ts +46 -0
  397. package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +3 -3
  398. package/lib/ui/sdk/@dsc/ui-primitives/throughput.d.ts +13 -0
  399. package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +9 -0
  400. package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +1 -1
  401. package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +30 -6
  402. package/lib/ui/sdk/@dsc/ui-primitives/unified-diff.d.ts +10 -0
  403. package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +10 -1
  404. package/lib/ui/sdk/@dsc/ui-renderer/cordis-host.d.ts +113 -0
  405. package/lib/ui/sdk/@dsc/ui-renderer/package.json +1 -1
  406. package/lib/ui/sdk/@dsc/ui-slots/package.json +1 -1
  407. package/lib/ui/services.d.ts +19 -8
  408. package/lib/ui/services.js +20 -12
  409. package/lib/ui/signal.d.ts +49 -0
  410. package/lib/ui/signal.js +57 -0
  411. package/lib/ui/tui-plugins.js +36 -16
  412. package/package.json +71 -58
  413. package/lib/remote/assets/app-DAcUCOEn.js +0 -14
  414. package/lib/ui/assets/app-B70nVIKd.js +0 -69
  415. package/lib/ui/assets/chunk-BGcgwlCI.js +0 -12
  416. package/lib/ui/assets/style-Bq01xH_b.css +0 -1
@@ -21,11 +21,12 @@
21
21
  * @module dsc/plugins/ptc
22
22
  */
23
23
  import vm from 'node:vm';
24
- import { argsSummary, callFacts } from '../core/tools.js';
24
+ import { argsSummary, callFacts, gateIdentity } from '../core/tools.js';
25
25
  import { PTC_LIMITS, PTC_SDK_SIGNATURE, ptcDescribe, ptcResultBody, } from '../core/ptc.js';
26
+ import { resolvePluginConfig } from '../core/plugin-registry.js';
26
27
  /** PTC 的模式名(与 core/presets.ts 的 PTC_PRESET 同一个值)。 */
27
28
  const PTC_PRESET = 'ptc';
28
- const RUN_CODE_DESCRIPTION = `用一段 JavaScript 批量调用工具,在代码里筛选汇总,只把结论交回来。
29
+ const RUN_CODE_DESCRIPTION = (deadlineMs) => `用一段 JavaScript 批量调用工具,在代码里筛选汇总,只把结论交回来。
29
30
 
30
31
  怎么写:code 是一段 JavaScript 的**函数体**(可以直接 await、可以 return)。里面用 sdk 调工具:
31
32
  ${PTC_SDK_SIGNATURE}
@@ -40,13 +41,92 @@ const RUN_CODE_DESCRIPTION = `用一段 JavaScript 批量调用工具,在代
40
41
  规矩:
41
42
  - 每次 sdk.xxx() 都照旧过审批与安全钩子,被拒的那条返回“【被拒绝】原因”,脚本接着跑。
42
43
  - console.log 的输出会随结果一起交回来(只留最后 ${PTC_LIMITS.consoleLines} 行)。
43
- - 一段脚本最多调 ${PTC_LIMITS.maxCalls} 次工具,最多跑 ${Math.round(PTC_LIMITS.deadlineMs / 1000)} 秒。
44
+ - 一段脚本最多调 ${PTC_LIMITS.maxCalls} 次工具,最多跑 ${Math.round(deadlineMs / 1000)} 秒。
44
45
  - 交回的内容超过 ${PTC_LIMITS.resultMax} 字符会被截断:先在代码里把结果压小,再 return 摘要。
45
46
  - 同进程 vm 里跑:拿不到 process / require / 文件系统,唯一的出口就是 sdk。`;
47
+ /**
48
+ * 可暂停的脚本时限。
49
+ *
50
+ * 为什么不能只用一个 `setTimeout`:脚本里 `await sdk.ask_user(...)`、等待审批卡的时候,
51
+ * 那是在**等人**,不该算进「脚本跑了多久」。用户在一张卡上想三分钟,120 秒的表先响,
52
+ * 脚本被掐死;他把答案点完,交回来的答案已经没有人在接了——2026-10-29 报障的形状。
53
+ *
54
+ * 停表是协作式的:只有认得出来的等待(工具声明了 `waitsForHuman`、守卫链弹审批卡)
55
+ * 才走 `hold()`;脚本自己 `await sleep(60000)` 照样计入时限,跑飞了还是会被掐断。
56
+ * @param ms - 脚本的总时限(毫秒)。
57
+ */
58
+ function createDeadline(ms) {
59
+ let expire = () => { };
60
+ const promise = new Promise((_resolve, reject) => {
61
+ expire = reject;
62
+ });
63
+ /** 还剩多少毫秒。停表时扣掉已经走过的部分,续表时按它重新上表。 */
64
+ let remaining = ms;
65
+ /** 当前嵌了几层等待(守卫链与工具本体可能同时停表)。 */
66
+ let waiting = 0;
67
+ /** 本次上表的起点(算「已经走了多久」用)。 */
68
+ let startedAt = 0;
69
+ let timer;
70
+ let closed = false;
71
+ const arm = () => {
72
+ startedAt = Date.now();
73
+ timer = setTimeout(() => {
74
+ timer = undefined;
75
+ expire(new Error(`脚本跑了超过 ${Math.round(ms / 1000)} 秒,被掐断了`));
76
+ }, Math.max(0, remaining));
77
+ };
78
+ arm();
79
+ return {
80
+ promise,
81
+ async hold(fn) {
82
+ waiting += 1;
83
+ if (waiting === 1 && timer !== undefined) {
84
+ clearTimeout(timer);
85
+ timer = undefined;
86
+ remaining = Math.max(0, remaining - (Date.now() - startedAt));
87
+ }
88
+ try {
89
+ return await fn();
90
+ }
91
+ finally {
92
+ waiting -= 1;
93
+ if (waiting === 0 && !closed && timer === undefined)
94
+ arm();
95
+ }
96
+ },
97
+ stop() {
98
+ closed = true;
99
+ if (timer !== undefined)
100
+ clearTimeout(timer);
101
+ timer = undefined;
102
+ },
103
+ };
104
+ }
105
+ /** 插件在条目树(`~/.dsc/plugins.json`)里的键,也是 `deadlineMs` 的归属。 */
106
+ const CONFIG_KEY = 'ptc';
107
+ /** 脚本总时限的可调区间(毫秒):低于 30 秒连装个依赖都不够,高于 15 分钟等于没有时限。 */
108
+ export const PTC_DEADLINE_RANGE = { min: 30_000, max: 900_000 };
109
+ /**
110
+ * 取脚本总时限:插件配置里的 `deadlineMs`,没有就用 {@link PTC_LIMITS.deadlineMs}。
111
+ *
112
+ * 为什么可配(2026-10-29 报障):默认 120 秒时,一条 `npm install` 或一次 12 秒的 pytest
113
+ * 加上前后几步就把额度用光,脚本被掐断后只能跨轮轮询,每轮都在烧额度。
114
+ * @param passed - 装配时传进来的配置(内核挂载时的第二参数)。
115
+ */
116
+ export function readDeadlineMs(passed) {
117
+ const raw = resolvePluginConfig(CONFIG_KEY, passed);
118
+ const num = Number(raw.deadlineMs);
119
+ // 没配置就用常量,不再夹一次:常量是代码里的决定,夹取只用来约束用户填进来的数。
120
+ if (!Number.isFinite(num))
121
+ return PTC_LIMITS.deadlineMs;
122
+ return Math.min(Math.max(Math.round(num), PTC_DEADLINE_RANGE.min), PTC_DEADLINE_RANGE.max);
123
+ }
46
124
  export const ptcPlugin = {
47
125
  name: 'ptc',
48
126
  inject: ['tools', 'guards', 'transcript'],
49
- apply(ctx) {
127
+ apply(ctx, passed) {
128
+ /** 每次跑脚本现读:改完配置不必重启宿主。 */
129
+ const deadlineMs = () => readDeadlineMs(passed);
50
130
  /**
51
131
  * 跑一段脚本。
52
132
  * @param code - 函数体源码。
@@ -61,9 +141,13 @@ export const ptcPlugin = {
61
141
  .filter((entry) => entry.name !== 'run_code')
62
142
  .map((entry) => [entry.name, entry]));
63
143
  const records = [];
144
+ // 这一段脚本动过的文件(按调用先后;同一文件多次改交给循环按路径去重)
145
+ const changesList = [];
64
146
  const logs = [];
65
147
  let calls = 0;
66
148
  let trouble;
149
+ // 整段脚本的时限(等人时停表,见 createDeadline 的注释)
150
+ const deadline = createDeadline(deadlineMs());
67
151
  /**
68
152
  * T38 读写闸(对齐 dsh 的「mutating calls run alone」):写/执行调用独占——
69
153
  * 跑的时候读也得等,排队写也挡着新读(不让写饿死);读调用互相并发。
@@ -135,27 +219,43 @@ export const ptcPlugin = {
135
219
  const callId = `ptc-${Date.now().toString(36)}-${seq}`;
136
220
  const started = Date.now();
137
221
  // 界面上的实时卡片:让用户看见脚本正在调什么(这一条不进会话日志,
138
- // 原因见文件头第 2 条;日志靠结果正文里的调用清单留底)
139
- ctx.transcript.emit({ type: 'tool/call', callId, name, args: JSON.stringify(args) });
140
- const verdict = await ctx.guards.gate({
141
- toolName: name,
142
- risk: entry.risk,
222
+ // 原因见文件头第 2 条;日志靠结果正文里的调用清单留底)。
223
+ // 带归属:脚本可能是后台会话在跑,卡片只能落在它自己的视图里(切走了就不画)。
224
+ ctx.transcript.emit({ type: 'tool/call', callId, name, args: JSON.stringify(args) }, session.id);
225
+ // 守卫链可能弹审批卡:等人点卡的时间同样不算脚本时间。
226
+ // 桥接工具(tool_call)在这里同样交出被调工具的真名与真实风险,免得脚本里多弹一张卡。
227
+ const gateInput = gateIdentity(entry, args, cwd);
228
+ const verdict = await deadline.hold(() => ctx.guards.gate({
229
+ toolName: gateInput.name,
230
+ risk: gateInput.risk,
143
231
  cwd,
144
- args,
232
+ args: gateInput.args,
145
233
  signal,
146
234
  sessionId: session.id,
147
235
  sessionPath: session.path,
148
- ...callFacts(args, cwd),
149
- });
236
+ ...callFacts(gateInput.args, cwd),
237
+ }));
150
238
  if (verdict.action === 'deny') {
151
239
  records.push({ name, args: argsSummary(args), ms: Date.now() - started, ok: false, note: verdict.reason });
152
- ctx.transcript.emit({ type: 'tool/result', callId, text: `【被拒绝】${verdict.reason}`, error: 'rejected' });
240
+ ctx.transcript.emit({ type: 'tool/result', callId, text: `【被拒绝】${verdict.reason}`, error: 'rejected' }, session.id);
153
241
  return `【被拒绝】${verdict.reason}`;
154
242
  }
155
243
  try {
156
244
  // T38:写/执行走独占闸,只读走并发闸(闸的规矩见上面的注释)
157
- const execute = () => entry.run(args, { cwd, signal, sessionId: session.id, sessionPath: session.path });
245
+ const run = () => entry.run(args, { cwd, signal, sessionId: session.id, sessionPath: session.path });
246
+ // 声明了 waitsForHuman 的工具(提问卡)整段等待停表:用户想多久都不算脚本时间
247
+ const execute = () => entry.waitsForHuman === true ? deadline.hold(run) : run();
158
248
  const output = entry.risk === 'read' ? await gate.read(execute) : await gate.write(execute);
249
+ // 这一步真的动了文件就记下来(2026-10-30 报障):write / edit 除了文本还回一份
250
+ // 「改了哪个文件、增删几行、改前全文」。以前这里只取 text,改动与回合基线一起丢了,
251
+ // 于是 PTC 模式改了十几个文件、会话底部一张「文件已更改」卡都没有。
252
+ // 带 baseline 原样交回循环:回合基线记账要用「本回合第一次改之前」的全文。
253
+ if (typeof output !== 'string') {
254
+ if (output.changes !== undefined)
255
+ changesList.push(output.changes);
256
+ if (output.changesList !== undefined)
257
+ changesList.push(...output.changesList);
258
+ }
159
259
  const raw = typeof output === 'string' ? output : output.text;
160
260
  // 工具结果里的密钥形状字符串不进脚本、不进日志(遮红挂在观察者链上)
161
261
  const text = ctx.guards.observe(name, raw);
@@ -167,13 +267,13 @@ export const ptcPlugin = {
167
267
  ok: true,
168
268
  ...(images > 0 ? { note: `返回了 ${images} 张图,脚本里拿不到图(本轮已忽略)` } : {}),
169
269
  });
170
- ctx.transcript.emit({ type: 'tool/result', callId, text });
270
+ ctx.transcript.emit({ type: 'tool/result', callId, text }, session.id);
171
271
  return text;
172
272
  }
173
273
  catch (error) {
174
274
  const message = error instanceof Error ? error.message : String(error);
175
275
  records.push({ name, args: argsSummary(args), ms: Date.now() - started, ok: false, note: message });
176
- ctx.transcript.emit({ type: 'tool/result', callId, text: message, error: 'tool-error' });
276
+ ctx.transcript.emit({ type: 'tool/result', callId, text: message, error: 'tool-error' }, session.id);
177
277
  return `【执行失败】${message}`;
178
278
  }
179
279
  };
@@ -208,7 +308,6 @@ export const ptcPlugin = {
208
308
  };
209
309
  const context = vm.createContext(sandbox, { name: 'dsc-ptc' });
210
310
  let value;
211
- let deadline;
212
311
  try {
213
312
  // 脚本就是一段函数体,套一层异步立即执行函数之后顶层可以直接 await
214
313
  const script = new vm.Script(`(async () => {\n${code}\n})()`, { filename: 'dsc-ptc.js' });
@@ -216,9 +315,7 @@ export const ptcPlugin = {
216
315
  // runInContext 的 timeout 只管同步段;await 之后的时间靠这条总时限兜住
217
316
  value = await Promise.race([
218
317
  Promise.resolve(started),
219
- new Promise((_resolve, reject) => {
220
- deadline = setTimeout(() => reject(new Error(`脚本跑了超过 ${Math.round(PTC_LIMITS.deadlineMs / 1000)} 秒,被掐断了`)), PTC_LIMITS.deadlineMs);
221
- }),
318
+ deadline.promise,
222
319
  new Promise((_resolve, reject) => {
223
320
  const abort = () => reject(new Error('用户打断了这一轮,脚本停止'));
224
321
  if (signal.aborted)
@@ -232,14 +329,14 @@ export const ptcPlugin = {
232
329
  trouble = error instanceof Error ? error.message : String(error);
233
330
  }
234
331
  finally {
235
- if (deadline !== undefined)
236
- clearTimeout(deadline);
332
+ deadline.stop();
237
333
  }
238
- return ptcResultBody({ value, calls: records, logs, ...(trouble !== undefined ? { trouble } : {}) });
334
+ const text = ptcResultBody({ value, calls: records, logs, ...(trouble !== undefined ? { trouble } : {}) });
335
+ return changesList.length === 0 ? { text } : { text, changesList };
239
336
  };
240
337
  ctx.tools.register({
241
338
  name: 'run_code',
242
- description: RUN_CODE_DESCRIPTION,
339
+ description: RUN_CODE_DESCRIPTION(deadlineMs()),
243
340
  parameters: {
244
341
  type: 'object',
245
342
  properties: {
@@ -53,7 +53,7 @@ export declare const REMOTE_METHODS: readonly ["submit", "interrupt", "openSessi
53
53
  * 每条都必须是界面通道白名单(`core/ui-methods.ts`)的成员:实参校验直接复用
54
54
  * `validateUiArgs`,不另立一份规格——多出来的口子也必须过同一道形校验。
55
55
  */
56
- export declare const REMOTE_SHELL_METHODS: readonly ["submit", "interrupt", "openSession", "compact", "setModel", "setEffort", "refreshSessions", "listModels", "listSkills", "listPlugins", "getUiPrefs", "getSettingsSections", "getSectionValues", "usageStats", "listArchivedSessions", "archiveSessions", "renameSession", "setSessionPinned", "answerApproval", "answerPlan", "answerQuestion", "setMode", "clearTodos", "peekTranscript", "listUserMessages", "setUiPrefs", "restoreSessions", "listUiCommands", "runUiCommand"];
56
+ export declare const REMOTE_SHELL_METHODS: readonly ["submit", "interrupt", "openSession", "compact", "setModel", "setEffort", "refreshSessions", "listModels", "listSkills", "listPlugins", "getUiPrefs", "getSettingsSections", "getSectionValues", "usageStats", "listArchivedSessions", "archiveSessions", "renameSession", "setSessionPinned", "answerApproval", "answerPlan", "answerQuestion", "setMode", "clearTodos", "peekTranscript", "listUserMessages", "setUiPrefs", "restoreSessions", "listUiCommands", "runUiCommand", "getModelConfig", "listPresets", "readPreset", "usePreset"];
57
57
  /** 查表用的集合。 */
58
58
  export declare const REMOTE_SET: ReadonlySet<string>;
59
59
  /** 壳方法表的查表集合。 */
@@ -78,6 +78,17 @@ export const REMOTE_SHELL_METHODS = [
78
78
  'restoreSessions',
79
79
  'listUiCommands',
80
80
  'runUiCommand',
81
+ // 设置页的两块**读**:模型(端点、模型清单、key 在不在)与模式(预设清单与正文)。
82
+ // 它们是只读投影,不含 key 值(见 ModelConfigView:只有 keyConfigured 布尔),
83
+ // 与 getSettingsSections / getSectionValues 同一档;不放开的话手机上点开这两页
84
+ // 只会看到「协议不允许调用的方法」(2026-10-27 报障第 5 条)。写入那批
85
+ // (saveProvider / setProviderKey / setDefaultModel / setSettingValue)继续挡着。
86
+ 'getModelConfig',
87
+ 'listPresets',
88
+ 'readPreset',
89
+ // 切模式(预设):换的是这一条会话的提示词与工具白名单,不碰凭据与安全闸门本身,
90
+ // 与输入区那颗「模式」chip 同一件事——不开的话手机上那颗 chip 点下去必报错。
91
+ 'usePreset',
81
92
  ];
82
93
  const REMOTE_SHELL_COVERAGE = true;
83
94
  void REMOTE_SHELL_COVERAGE;
@@ -53,6 +53,7 @@ import { bootNoticeOnce } from '../core/boot-notices.js';
53
53
  import { errText } from '../core/err-text.js';
54
54
  import { REMOTE_PORT_MAX, REMOTE_PORT_MIN } from '../core/prefs.js';
55
55
  import { resolvePluginConfig } from '../core/plugin-registry.js';
56
+ import { snapshotThrottleMs } from '../core/snapshot-throttle.js';
56
57
  import { RemoteFrameHub } from '../core/remote/frames.js';
57
58
  import { isHttpUrl, sendWebhook, webhookHasPlaceholder } from '../core/remote/notify.js';
58
59
  import { RemoteOwnerLock } from '../core/remote/owner.js';
@@ -60,6 +61,7 @@ import { RemotePairing } from '../core/remote/pairing.js';
60
61
  import { RemotePush } from '../core/remote/push.js';
61
62
  import { TicketStore } from '../core/remote/tickets.js';
62
63
  import { RemoteUploads } from '../core/remote/uploads.js';
64
+ import { activeProfileDir } from '../core/profile-dir.js';
63
65
  import { uiAssetsDir, uiPluginsDir } from '../core/ui-bundles.js';
64
66
  import { createUiBootSource } from '../core/ui-boot-source.js';
65
67
  import { createUiEvents } from '../core/ui-events.js';
@@ -72,8 +74,6 @@ import { REMOTE_COOKIE, REMOTE_METHODS, REMOTE_PROTOCOL_VERSION, REMOTE_SET, REM
72
74
  import { UI_EVENTS_PROTOCOL_VERSION } from './webserver.js';
73
75
  /** 配置键(`~/.dsc/plugins.json` 条目树里 `file` 等于这个名字那一项的 `config`)。 */
74
76
  const CONFIG_KEY = 'remote';
75
- /** 快照推送节流间隔的缺省值(与 host-stdio 同一个口径)。 */
76
- const DEFAULT_SNAPSHOT_THROTTLE_MS = 80;
77
77
  /** 休眠时回头看一眼主控位的间隔。 */
78
78
  const OWNER_RETRY_MS = 30_000;
79
79
  /** 同类推送的节流窗口:审批卡连着弹、轮结束连着来的时候,手机上别炸一串。 */
@@ -84,17 +84,6 @@ const ESCALATE_WAIT_MS = 120_000;
84
84
  const ESCALATE_MAX = 3;
85
85
  /** 多短的一轮不值得通报(用过 15 秒以上,或者这一轮出现过审批卡,才发「轮完成」)。 */
86
86
  const TURN_NOTIFY_MIN_MS = 15_000;
87
- /**
88
- * 取快照推送节流间隔:夹在 16 毫秒到 1 秒之间(与 host-stdio 同一条理由:再小是白烧 CPU,
89
- * 再大是点完按钮半天没反应)。
90
- */
91
- function readThrottle(passed) {
92
- const raw = resolvePluginConfig(CONFIG_KEY, passed);
93
- const num = Number(raw.snapshotThrottleMs);
94
- if (!Number.isFinite(num))
95
- return DEFAULT_SNAPSHOT_THROTTLE_MS;
96
- return Math.min(Math.max(Math.round(num), 16), 1_000);
97
- }
98
87
  /**
99
88
  * 静态资源目录:编译产物是 `lib/plugins/remote.js`,界面产物在 `lib/remote/assets`
100
89
  * (由 remote-web 的 vite 配置直接写进去)。
@@ -167,6 +156,8 @@ export function createRemoteServer(deps) {
167
156
  const hub = new RemoteFrameHub();
168
157
  let frameTimer = null;
169
158
  let framePending = false;
159
+ /** 上一帧推出去的时刻(0 = 还没推过):节流按 leading-edge 走,见 scheduleFrame。 */
160
+ let lastFrameAt = 0;
170
161
  /**
171
162
  * 一条连接都没有的时候发生的会话变化:帧流那时不前进(没人看,白算),
172
163
  * 所以下一条连接补完缓冲里的帧之后,必须再补一帧全量把这段时间的变化对上。
@@ -211,17 +202,21 @@ export function createRemoteServer(deps) {
211
202
  framePending = true;
212
203
  if (frameTimer !== null)
213
204
  return;
205
+ // leading-edge(2026-11-03,与 host-stdio 同一口径):距上一帧已经超过窗口就立刻推,
206
+ // 窗口内的连续变化才合并。旧写法每次都要等满一个窗口,用户点完会话要干等 60–80ms。
207
+ const wait = Math.max(0, deps.throttleMs - (Date.now() - lastFrameAt));
214
208
  frameTimer = setTimeout(() => {
215
209
  frameTimer = null;
216
210
  if (!framePending)
217
211
  return;
218
212
  framePending = false;
213
+ lastFrameAt = Date.now();
219
214
  if (sockets.size === 0) {
220
215
  missedWhileIdle = true;
221
216
  return;
222
217
  }
223
218
  emitFrame(false);
224
- }, deps.throttleMs);
219
+ }, wait);
225
220
  };
226
221
  const stopFrames = () => {
227
222
  if (frameTimer !== null)
@@ -398,7 +393,8 @@ export const remotePlugin = {
398
393
  inject: ['session', 'transcript', 'agent', 'ui', 'approval', 'settings'],
399
394
  apply(ctx, passed) {
400
395
  const runtime = ctx.ui;
401
- const throttleMs = readThrottle(passed);
396
+ // 快照推送节流:与 host-stdio 同一份口径(见 `core/snapshot-throttle.ts`)。
397
+ const throttleMs = snapshotThrottleMs(resolvePluginConfig(CONFIG_KEY, passed).snapshotThrottleMs);
402
398
  const pairing = new RemotePairing();
403
399
  const owner = new RemoteOwnerLock();
404
400
  const tickets = new TicketStore();
@@ -522,6 +518,9 @@ export const remotePlugin = {
522
518
  const bootSource = createUiBootSource({
523
519
  host: { name: 'Pneuma', version: DSC_VERSION },
524
520
  builtinDir: uiPluginsDir(),
521
+ // profile 里装的组合包界面半也进手机端那张图:手机跑的是同一份壳产物,本机与手机
522
+ // 看同一张图才不会「桌面有、手机没有」。写出来而不是靠缺省,是为了这行能被人看见。
523
+ packageDir: activeProfileDir(),
525
524
  });
526
525
  const freshGraph = () => {
527
526
  bootSource.refresh();
@@ -1,8 +1,9 @@
1
1
  import { errText } from '../adapter/transcript.js';
2
2
  import { listPluginInfos, writePluginEnabled } from '../core/plugin-registry.js';
3
3
  import { setPluginEnabledHot } from '../core/plugin-loader.js';
4
- import { readUiPluginManifestReport, isThirdPartyUiEntry, scanThirdPartyUiTrusts, trustThirdPartyUiPlugin } from '../core/ui-bundles.js';
4
+ import { discoverThirdPartyUiArtifacts, isPackageUiEntry, isThirdPartyUiEntry, readUiPluginManifestReport, scanPackageUiTrusts, scanThirdPartyUiTrusts, trustThirdPartyUiPlugin, } from '../core/ui-bundles.js';
5
5
  import { buildUsageStats } from '../core/usage-log.js';
6
+ import { sideAskOnce } from '../core/side-ask.js';
6
7
  import { shellCommandRejection, shellCommands } from '../core/commands-completion.js';
7
8
  export const runtimePlugin = {
8
9
  name: 'ui-runtime',
@@ -50,13 +51,25 @@ export const runtimePlugin = {
50
51
  * openPicker / openModels 只是事件——终端壳与旧桌面渲染层各有一条转发链
51
52
  * (host-stdio / remote → 各自界面)。壳自己的那批命令不依赖这两个回调。
52
53
  */
53
- function commandUi() {
54
+ function commandUi(shell = false) {
54
55
  return {
55
- notice: (text) => ctx.transcript.system(text),
56
+ // 壳那条通道只放行 `shell: true` 的命令,/help 据此只列能跑的那批
57
+ ...(shell ? { shell: true } : {}),
58
+ // 命令输出标一条 command:壳的空会话欢迎态会把首屏 system 条目整批不画,
59
+ // 不标的话新会话里打第一条命令什么也看不到(2026-10-27 查账)
60
+ notice: (text) => ctx.transcript.system(text, undefined, true),
56
61
  openPicker: () => ctx.emit('dsc/open-picker'),
57
62
  openModels: () => ctx.emit('dsc/open-models'),
58
63
  };
59
64
  }
65
+ /**
66
+ * 进行中的旁问:票据 → 取消信号。
67
+ *
68
+ * 为什么要一张表:
69
+ * - 界面要能「停止」(一张票据换一个 AbortController);
70
+ * - 同一张票据重复发(双击)时先掐掉旧的,不留两条同时烧 token。
71
+ */
72
+ const sideAsks = new Map();
60
73
  const runtime = {
61
74
  subscribe(listener) {
62
75
  return ctx.transcript.subscribe(listener);
@@ -64,8 +77,8 @@ export const runtimePlugin = {
64
77
  getSnapshot() {
65
78
  return ctx.transcript.getSnapshot();
66
79
  },
67
- submit(text, images) {
68
- ctx.agent.followup(text, images);
80
+ submit(text, images, files) {
81
+ ctx.agent.followup(text, images, undefined, 'user', files);
69
82
  },
70
83
  interrupt() {
71
84
  ctx.agent.interrupt();
@@ -103,7 +116,7 @@ export const runtimePlugin = {
103
116
  }
104
117
  ctx.transcript.touch();
105
118
  },
106
- async setEffort(effort) {
119
+ async setEffort(effort, quiet = false) {
107
120
  try {
108
121
  ctx.llm.setEffort(effort);
109
122
  }
@@ -112,12 +125,17 @@ export const runtimePlugin = {
112
125
  ctx.transcript.touch();
113
126
  return;
114
127
  }
115
- const label = effort === 'default'
116
- ? '默认(不声明思考)'
117
- : effort === 'off'
118
- ? '关闭'
119
- : { low: '低', high: '高', max: '最大' }[effort];
120
- ctx.transcript.system(`思考强度设为「${label}」(下一次请求生效)`);
128
+ // quiet:输入区滑杆调档不写这一行(2026-10-26)。写的话每换一档就往正文里塞一行,
129
+ // 还要跟着多推一帧;档位在 chip 上读得到,不需要回执。快照仍要 touch 一次:
130
+ // status.effort 变了,界面得靠它把乐观值换成真实值。
131
+ if (!quiet) {
132
+ const label = effort === 'default'
133
+ ? '默认(不声明思考)'
134
+ : effort === 'off'
135
+ ? '关闭'
136
+ : { low: '低', high: '高', max: '最大' }[effort];
137
+ ctx.transcript.system(`思考强度设为「${label}」(下一次请求生效)`);
138
+ }
121
139
  ctx.transcript.touch();
122
140
  },
123
141
  listPlugins() {
@@ -137,6 +155,13 @@ export const runtimePlugin = {
137
155
  ctx.transcript.touch();
138
156
  return;
139
157
  }
158
+ // 组合包的界面半边(<包名>/client)同一条理由:没有宿主半边可热挂。
159
+ if (isPackageUiEntry(file)) {
160
+ const name = file.slice(0, -'/client'.length);
161
+ ctx.transcript.system(`已${enabled ? '启用' : '停用'}组合包的界面半「${name}」,刷新页面(或重启宿主)后生效`);
162
+ ctx.transcript.touch();
163
+ return;
164
+ }
140
165
  const shown = listPluginInfos().find((item) => item.file === file)?.name ?? file;
141
166
  // 热启停:即时挂载/卸载,写盘持久化;失败回滚(挂载失败自动停用)
142
167
  const outcome = await setPluginEnabledHot(file, enabled);
@@ -150,7 +175,13 @@ export const runtimePlugin = {
150
175
  },
151
176
  listUiTrust() {
152
177
  const report = readUiPluginManifestReport();
153
- return scanThirdPartyUiTrusts(report.apiVersion, new Set(report.entries.map((entry) => entry.id)));
178
+ const builtinIds = new Set(report.entries.map((entry) => entry.id));
179
+ const third = scanThirdPartyUiTrusts(report.apiVersion, builtinIds);
180
+ // 组合包的撞名要和发现层一个口径:内置 + 第三方里**真进了启动图**的那些
181
+ //(被停用或没信任的第三方不占 id,不能拿来判别人撞名)。
182
+ const accepted = discoverThirdPartyUiArtifacts(report.apiVersion, builtinIds);
183
+ const taken = new Set([...builtinIds, ...accepted.entries.map((entry) => entry.id)]);
184
+ return [...third, ...scanPackageUiTrusts(report.apiVersion, taken)];
154
185
  },
155
186
  setUiTrust(name) {
156
187
  const report = readUiPluginManifestReport();
@@ -279,6 +310,9 @@ export const runtimePlugin = {
279
310
  name: spec.name,
280
311
  args: spec.args,
281
312
  description: spec.description,
313
+ ...(spec.label === undefined ? {} : { label: spec.label }),
314
+ // 要收输入的命令(/review):壳据此把回车改成「先补全、不执行」。
315
+ ...(spec.input === undefined ? {} : { input: spec.input }),
282
316
  duringTask: spec.duringTask ?? 'allow',
283
317
  }));
284
318
  },
@@ -289,7 +323,7 @@ export const runtimePlugin = {
289
323
  const rejection = shellCommandRejection(input);
290
324
  if (rejection !== null)
291
325
  throw new Error(rejection);
292
- return ctx.commands.run(input, runtime, commandUi());
326
+ return ctx.commands.run(input, runtime, commandUi(true));
293
327
  },
294
328
  listModels() {
295
329
  return ctx.llm.listModels();
@@ -364,6 +398,42 @@ export const runtimePlugin = {
364
398
  usageStats() {
365
399
  return Promise.resolve(buildUsageStats());
366
400
  },
401
+ // ── 旁问(只读一次性问答,支持流式与指定模型) ──
402
+ async sideAsk(question, quote, requestId, provider, model) {
403
+ sideAsks.get(requestId)?.abort();
404
+ const controller = new AbortController();
405
+ sideAsks.set(requestId, controller);
406
+ // 空串 = 跟随主会话当前路由;两个都给了才切到指定模型(界面传的就是一对)。
407
+ const route = provider !== '' && model !== '' ? ctx.llm.routeTo(provider, model, 'default') : ctx.llm.route();
408
+ try {
409
+ const outcome = await sideAskOnce({
410
+ route,
411
+ stream: (api, request, handlers) => ctx.llm.stream(api, request, handlers),
412
+ question,
413
+ quote,
414
+ signal: controller.signal,
415
+ // 增量经 cordis 事件转给界面通道(webserver 订阅后广播 `event: ask`)。
416
+ onText: (delta) => {
417
+ ctx.emit('dsc/side-ask-chunk', { id: requestId, delta });
418
+ },
419
+ });
420
+ return outcome;
421
+ }
422
+ finally {
423
+ // 收尾信号:界面据此把「正在回答」收掉(结果本身由 invoke 的返回值补齐)。
424
+ ctx.emit('dsc/side-ask-chunk', { id: requestId, delta: '', done: true });
425
+ // 只清自己的那张:同一票据被后一次覆盖时,别把新的那条删了。
426
+ if (sideAsks.get(requestId) === controller)
427
+ sideAsks.delete(requestId);
428
+ }
429
+ },
430
+ sideAskCancel(requestId) {
431
+ const controller = sideAsks.get(requestId);
432
+ if (controller === undefined)
433
+ return Promise.resolve(false);
434
+ controller.abort();
435
+ return Promise.resolve(true);
436
+ },
367
437
  async restoreSessions(paths) {
368
438
  return ctx.session.restore(paths);
369
439
  },
@@ -382,6 +452,9 @@ export const runtimePlugin = {
382
452
  forkSession(path, index) {
383
453
  return Promise.resolve(ctx.session.fork(path, index));
384
454
  },
455
+ rewindSession(path, keep, text) {
456
+ return Promise.resolve(ctx.session.rewind(path, keep, text));
457
+ },
385
458
  getUiPrefs() {
386
459
  return ctx.settings.prefs().ui;
387
460
  },
@@ -390,9 +463,13 @@ export const runtimePlugin = {
390
463
  ctx.settings.setPrefs({ ui: { ...current, ...patch } });
391
464
  // 分组展开态与会话拖拽顺序是点一下/拖一下就写一次的高频静默写入,
392
465
  // 弹回执反而吵:这两类补丁直接返回,不进下面的文案链。
466
+ // 面板几何同理(拖完松手一次),而且它只可能是壳发的——用户看不见任何回执才好。
393
467
  if (patch.sessionExpansion !== undefined || patch.sessionOrder !== undefined) {
394
468
  return Promise.resolve({ ok: true });
395
469
  }
470
+ if (patch.panelWidths !== undefined && Object.keys(patch).length === 1) {
471
+ return Promise.resolve({ ok: true });
472
+ }
396
473
  const notice = patch.sessionSort !== undefined
397
474
  ? patch.sessionSort === 'recent'
398
475
  ? '会话改为按最近更新排序(置顶的仍排最前)'