@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
@@ -0,0 +1,18 @@
1
+ /**
2
+ * 安全序列化(全仓库唯一一份)。
3
+ *
4
+ * `JSON.stringify` 遇到循环引用、BigInt、函数会抛;这条路上抛出来会连累整个
5
+ * 界面帧或原生命令的应答。两处(原生桥、界面方法)此前各包了一个 try/catch,
6
+ * 合并到这里,口径固定成「序列化不了就 null」。
7
+ *
8
+ * @module dsc/core/json-text
9
+ */
10
+ /** 一段 JSON 文本;序列化不了(循环引用、BigInt、函数)给 null。 */
11
+ export function jsonText(value) {
12
+ try {
13
+ return JSON.stringify(value) ?? null;
14
+ }
15
+ catch {
16
+ return null;
17
+ }
18
+ }
@@ -1,4 +1,4 @@
1
- import { type ChatMessage } from '../llm.js';
1
+ import type { ChatMessage } from '../llm.js';
2
2
  import { type LedgerEntry } from './ledger.js';
3
3
  /** 技能主文件名。 */
4
4
  export declare const SKILL_FILE = "SKILL.md";
@@ -163,16 +163,10 @@ export declare function readBeforeWriteCheck(input: ReadBeforeWriteInput): {
163
163
  ok: boolean;
164
164
  error: string;
165
165
  };
166
- /** 从会话消息里取出最后一条用户消息的纯文本(L1 的纠正语气判定用)。 */
167
- export declare function lastUserText(messages: readonly ChatMessage[]): string;
168
- /** 最后一个用户消息之前那条用户消息(L1 记「上一轮用户说了什么」用)。 */
169
- export declare function previousUserText(messages: readonly ChatMessage[]): string;
170
166
  /** 本轮用了多少次工具迭代(从末尾往回数 tool 消息,遇到 user 消息停)。 */
171
167
  export declare function toolIterationsOfTurn(messages: readonly ChatMessage[]): number;
172
168
  /** 本轮用户消息是第几条(0 起算;没有用户消息返回 -1)。 */
173
169
  export declare function userTurnIndex(messages: readonly ChatMessage[]): number;
174
- /** 取最后一条 assistant 消息的正文(L2 复盘结果就是这一条)。 */
175
- export declare function lastAssistantText(messages: readonly ChatMessage[]): string;
176
170
  /** 技能的生命周期档位。 */
177
171
  export type SkillLifecycle = 'active' | 'stale' | 'archived';
178
172
  /** 一个技能的使用记录。 */
@@ -22,8 +22,8 @@
22
22
  */
23
23
  import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmdirSync, statSync, unlinkSync, writeFileSync } from 'node:fs';
24
24
  import { dirname, join, relative, resolve, sep } from 'node:path';
25
- import { contentText } from '../llm.js';
26
25
  import { DSC_SKILLS_DIR, parseSkillMarkdown, scanSkillRoot, splitFrontmatter, writeSkillEnabled } from '../skills.js';
26
+ import { errText } from '../err-text.js';
27
27
  import { appendLedger, copyToBackup, EMPTY_HASH, hashText } from './ledger.js';
28
28
  /** 技能主文件名。 */
29
29
  export const SKILL_FILE = 'SKILL.md';
@@ -259,9 +259,6 @@ export function skillDirOf(name) {
259
259
  export function skillFileOf(name) {
260
260
  return join(skillDirOf(name), SKILL_FILE);
261
261
  }
262
- function errText(error) {
263
- return error instanceof Error ? error.message : String(error);
264
- }
265
262
  function fail(error) {
266
263
  return { ok: false, error, notice: '', entry: null, backup: '' };
267
264
  }
@@ -542,28 +539,6 @@ export function readBeforeWriteCheck(input) {
542
539
  return { ok: true, error: '' };
543
540
  return { ok: false, error: `改 ${input.name} 之前得先读它:本会话还没用 skill 工具读过这个技能,先读一遍再改` };
544
541
  }
545
- /** 从会话消息里取出最后一条用户消息的纯文本(L1 的纠正语气判定用)。 */
546
- export function lastUserText(messages) {
547
- for (let index = messages.length - 1; index >= 0; index -= 1) {
548
- const message = messages[index];
549
- if (message !== undefined && message.role === 'user')
550
- return contentText(message.content).trim();
551
- }
552
- return '';
553
- }
554
- /** 最后一个用户消息之前那条用户消息(L1 记「上一轮用户说了什么」用)。 */
555
- export function previousUserText(messages) {
556
- let seen = 0;
557
- for (let index = messages.length - 1; index >= 0; index -= 1) {
558
- const message = messages[index];
559
- if (message === undefined || message.role !== 'user')
560
- continue;
561
- seen += 1;
562
- if (seen === 2)
563
- return contentText(message.content).trim();
564
- }
565
- return '';
566
- }
567
542
  /** 本轮用了多少次工具迭代(从末尾往回数 tool 消息,遇到 user 消息停)。 */
568
543
  export function toolIterationsOfTurn(messages) {
569
544
  let count = 0;
@@ -586,15 +561,6 @@ export function userTurnIndex(messages) {
586
561
  count += 1;
587
562
  return count - 1;
588
563
  }
589
- /** 取最后一条 assistant 消息的正文(L2 复盘结果就是这一条)。 */
590
- export function lastAssistantText(messages) {
591
- for (let index = messages.length - 1; index >= 0; index -= 1) {
592
- const message = messages[index];
593
- if (message !== undefined && message.role === 'assistant')
594
- return contentText(message.content).trim();
595
- }
596
- return '';
597
- }
598
564
  /** 读使用台账;文件缺失或坏了都当空台账(它只是遥测,不该让技能功能瘫掉)。 */
599
565
  export function readUsage() {
600
566
  const file = usageFile();
@@ -763,7 +729,7 @@ export function curateSkills(now = Date.now(), options = DEFAULT_AGING) {
763
729
  const doc = readUsage();
764
730
  let local = [];
765
731
  try {
766
- local = scanSkillRoot({ dir: skillsRoot(), source: 'user-dsc', rank: 400 }).map((item) => item.name);
732
+ local = scanSkillRoot({ dir: skillsRoot(), source: 'user-dsc', rank: 400, scope: 'global' }).map((item) => item.name);
767
733
  }
768
734
  catch {
769
735
  local = [];
@@ -835,7 +801,7 @@ export function curateSkills(now = Date.now(), options = DEFAULT_AGING) {
835
801
  /** 技能目录里有哪些本地技能(整理与设置页显示用)。 */
836
802
  export function localSkillNames() {
837
803
  try {
838
- return scanSkillRoot({ dir: skillsRoot(), source: 'user-dsc', rank: 400 })
804
+ return scanSkillRoot({ dir: skillsRoot(), source: 'user-dsc', rank: 400, scope: 'global' })
839
805
  .map((item) => item.name)
840
806
  .sort((a, b) => a.localeCompare(b));
841
807
  }
@@ -1,9 +1,11 @@
1
1
  import type { HookJudgement, HookRun } from './hooks.js';
2
2
  /**
3
- * codex 的十二个生命周期事件名,照抄 `codex/codex-rs/hooks/src/lib.rs:23-36`。
3
+ * codex 的十四个生命周期事件名,照抄 `codex/codex-rs/hooks/src/lib.rs:32-47`。
4
4
  * 名字保持 codex 原样(大驼峰),用户手上的 hooks.json 不用改一个字。
5
+ * 其中 PreModelRequest / PostModelRequest 在 Pneuma 没有可阻塞的模型请求挂点,
6
+ * 认作「未接通」:配置里写了不会静默失效,会进 problems 说明原因。
5
7
  */
6
- export declare const LIFECYCLE_EVENTS: readonly ["PreToolUse", "PermissionRequest", "PostToolUse", "PreCompact", "PostCompact", "SessionStart", "SessionEnd", "UserPromptSubmit", "SubagentStart", "SubagentStop", "Stop", "Interrupt"];
8
+ export declare const LIFECYCLE_EVENTS: readonly ["PreModelRequest", "PostModelRequest", "PreToolUse", "PermissionRequest", "PostToolUse", "PreCompact", "PostCompact", "SessionStart", "SessionEnd", "UserPromptSubmit", "SubagentStart", "SubagentStop", "Stop", "Interrupt"];
7
9
  export type LifecycleEvent = (typeof LIFECYCLE_EVENTS)[number];
8
10
  /** 接通档位:wired = 完整接通;partial = 接上了但做不到 codex 的全部能力;unwired = 没有扩展点,不执行。 */
9
11
  export type LifecycleTier = 'wired' | 'partial' | 'unwired';
@@ -43,7 +45,13 @@ export interface LifecycleHooksConfig {
43
45
  configPath: string;
44
46
  /** 钩子自己没写超时时给多少毫秒。 */
45
47
  timeoutMs: number;
46
- /** 钩子没跑成(超时、命令起不来、输出看不懂、退出码非 0)时按拒处理;false 才转放行。 */
48
+ /**
49
+ * 钩子没跑成(超时、命令起不来、输出看不懂、退出码非 0)时按拒处理;false 则只留一条提示。
50
+ *
51
+ * 默认 false,与 codex 同一口径:codex 把非 2 的退出码记成 Failed,`should_block` 仍为 false
52
+ * (`codex-rs/hooks/src/engine/mod.rs` 的 pre_tool_use 用例)。钩子坏掉是钩子自己的事,
53
+ * 不该把所有工具调用一起掐死;想要「没跑成也算拦」的人自己打开。
54
+ */
47
55
  failClosed: boolean;
48
56
  /** 命令白名单:逗号或空格分隔的入口(例如 `node, uv`);空串 = 不限制。 */
49
57
  commandAllowlist: string;
@@ -2,11 +2,11 @@
2
2
  * 生命周期钩子引擎:按 codex 的事件名读一份外部配置,跑外部命令,把结论交回插件落位。
3
3
  *
4
4
  * 与 `core/hooks.ts`(安全钩子)的分工:那个管 dsc 自己的四个事件、配置在
5
- * `~/.dsc/hooks.json`;这一份管 codex 那十二个事件名、配置在
5
+ * `~/.dsc/hooks.json`;这一份管 codex 那十四个事件名、配置在
6
6
  * `~/.dsc/lifecycle-hooks.json`。**两份配置各读各的**,不共用文件,免得两个插件抢同一份配置。
7
7
  *
8
8
  * 三件事在这里定死,插件那边只负责挂扩展点:
9
- * 1. 十二个事件各自的档位(wired / partial / unwired)与不能接通的理由,见
9
+ * 1. 十四个事件各自的档位(wired / partial / unwired)与不能接通的理由,见
10
10
  * {@link LIFECYCLE_CAPABILITIES}——`unwired` 的事件配了钩子也不执行,只进 `problems`;
11
11
  * 2. 外部命令怎么跑、跑不成怎么算(默认按拒,`failClosed: false` 才转放行),
12
12
  * 执行器自带一份,因为 codex 的载荷契约(snake_case、无结尾换行)与
@@ -20,19 +20,26 @@
20
20
  */
21
21
  import { spawn } from 'node:child_process';
22
22
  import { existsSync, readFileSync } from 'node:fs';
23
- import { homedir } from 'node:os';
24
- import { join } from 'node:path';
25
23
  import { HOOK_STDERR_MAX, HOOK_STDOUT_MAX, HOOK_TIMEOUT_DEFAULT, HOOK_TIMEOUT_MAX, HOOK_TIMEOUT_MIN, judgeScriptRun, matcherHits, } from './hooks.js';
24
+ import { errText } from './err-text.js';
26
25
  import { resolvePluginConfig } from './plugin-registry.js';
27
26
  import { scrubChildEnv, redact } from './secrets.js';
28
27
  import { wrapUntrusted } from './untrusted.js';
29
- import { dscPath } from './path-policy.js';
30
- // ── 十二个事件与它们的档位 ───────────────────────────────────────────────────
28
+ import { dscPath, expandHome } from './path-policy.js';
29
+ import { clampInt as clampNumber } from './clamp.js';
30
+ import { isRecord } from './records.js';
31
+ import { shellOf } from './shell-quote.js';
32
+ import { splitList } from './strings.js';
33
+ // ── 十四个事件与它们的档位 ───────────────────────────────────────────────────
31
34
  /**
32
- * codex 的十二个生命周期事件名,照抄 `codex/codex-rs/hooks/src/lib.rs:23-36`。
35
+ * codex 的十四个生命周期事件名,照抄 `codex/codex-rs/hooks/src/lib.rs:32-47`。
33
36
  * 名字保持 codex 原样(大驼峰),用户手上的 hooks.json 不用改一个字。
37
+ * 其中 PreModelRequest / PostModelRequest 在 Pneuma 没有可阻塞的模型请求挂点,
38
+ * 认作「未接通」:配置里写了不会静默失效,会进 problems 说明原因。
34
39
  */
35
40
  export const LIFECYCLE_EVENTS = [
41
+ 'PreModelRequest',
42
+ 'PostModelRequest',
36
43
  'PreToolUse',
37
44
  'PermissionRequest',
38
45
  'PostToolUse',
@@ -51,6 +58,18 @@ export const LIFECYCLE_EVENTS = [
51
58
  * 档位是按 dsc 现有扩展点核实过的,改扩展点就要连带改这张表。
52
59
  */
53
60
  export const LIFECYCLE_CAPABILITIES = [
61
+ {
62
+ event: 'PreModelRequest',
63
+ tier: 'unwired',
64
+ extension: '无',
65
+ note: 'Pneuma 的请求组装是同步点,等不了外部命令,也没有「在模型请求之前可阻塞」的扩展点;配了也不会执行。',
66
+ },
67
+ {
68
+ event: 'PostModelRequest',
69
+ tier: 'unwired',
70
+ extension: '无',
71
+ note: 'Pneuma 没有「每次模型请求之后」的挂点(回合结束的 dsc/turn-end 是另一层语义);配了也不会执行。',
72
+ },
54
73
  {
55
74
  event: 'PreToolUse',
56
75
  tier: 'wired',
@@ -143,21 +162,10 @@ export const LIFECYCLE_DEFAULTS = {
143
162
  enabled: true,
144
163
  configPath: dscPath('lifecycle-hooks.json'),
145
164
  timeoutMs: HOOK_TIMEOUT_DEFAULT,
146
- failClosed: true,
165
+ // 默认真不拦:只有钩子明确用退出码 2(或写了 failClosed: true)才挡工具
166
+ failClosed: false,
147
167
  commandAllowlist: '',
148
168
  };
149
- /** `~` 展开成用户目录;相对路径原样返回(交给 spawn 的 cwd 去解析)。 */
150
- function expandPath(text) {
151
- if (text === '~')
152
- return homedir();
153
- if (text.startsWith('~/') || text.startsWith('~\\'))
154
- return join(homedir(), text.slice(2));
155
- return text;
156
- }
157
- function clampNumber(value, min, max, fallback) {
158
- const num = Number(value);
159
- return Number.isFinite(num) ? Math.min(Math.max(Math.round(num), min), max) : fallback;
160
- }
161
169
  function asText(value, fallback) {
162
170
  return typeof value === 'string' && value.trim() !== '' ? value.trim() : fallback;
163
171
  }
@@ -171,15 +179,13 @@ export function resolveLifecycleConfig(passed) {
171
179
  const raw = resolvePluginConfig('lifecycle-hooks', passed);
172
180
  return {
173
181
  enabled: raw.enabled !== false && raw.enabled !== 'false',
174
- configPath: expandPath(asText(raw.configPath, LIFECYCLE_DEFAULTS.configPath)),
182
+ configPath: expandHome(asText(raw.configPath, LIFECYCLE_DEFAULTS.configPath)),
175
183
  timeoutMs: clampNumber(raw.timeoutMs, HOOK_TIMEOUT_MIN, HOOK_TIMEOUT_MAX, LIFECYCLE_DEFAULTS.timeoutMs),
176
- failClosed: raw.failClosed !== false && raw.failClosed !== 'false',
184
+ // 默认不拦(与 codex 一致):只有明确写 true 才把「钩子没跑成」当成拦
185
+ failClosed: raw.failClosed === true || raw.failClosed === 'true',
177
186
  commandAllowlist: typeof raw.commandAllowlist === 'string' ? raw.commandAllowlist : LIFECYCLE_DEFAULTS.commandAllowlist,
178
187
  };
179
188
  }
180
- function isRecord(value) {
181
- return value !== null && typeof value === 'object' && !Array.isArray(value);
182
- }
183
189
  /**
184
190
  * 把磁盘上的内容按 codex 的形态读成钩子表。
185
191
  *
@@ -223,7 +229,7 @@ export function readLifecycleDoc(configPath) {
223
229
  if (name === 'hooks' && isRecord(raw.hooks))
224
230
  continue;
225
231
  if (!LIFECYCLE_EVENTS.includes(name)) {
226
- doc.problems.push(`不认识的事件名 ${name},已跳过(可用的是 codex 的十二个:${LIFECYCLE_EVENTS.join(' / ')})`);
232
+ doc.problems.push(`不认识的事件名 ${name},已跳过(可用的是 codex 的十四个:${LIFECYCLE_EVENTS.join(' / ')})`);
227
233
  continue;
228
234
  }
229
235
  recognized = true;
@@ -280,7 +286,7 @@ export function readLifecycleDoc(configPath) {
280
286
  }
281
287
  }
282
288
  if (!recognized && doc.hooks.length === 0 && doc.problems.length === 0) {
283
- doc.problems.push('这份钩子配置里没有任何事件(键应该是 codex 的十二个事件名之一)');
289
+ doc.problems.push('这份钩子配置里没有任何事件(键应该是 codex 的十四个事件名之一)');
284
290
  }
285
291
  if (doc.hooks.length > LIFECYCLE_MAX_HOOKS) {
286
292
  doc.problems.push(`钩子超过 ${LIFECYCLE_MAX_HOOKS} 条,多出来的忽略`);
@@ -323,13 +329,6 @@ function countByEvent(hooks) {
323
329
  return counts;
324
330
  }
325
331
  // ── 命令白名单 ───────────────────────────────────────────────────────────────
326
- /** 拆逗号/空格分隔的清单(中英文逗号都认)。 */
327
- function splitList(text) {
328
- return text
329
- .split(/[,,\s]+/)
330
- .map((entry) => entry.trim())
331
- .filter((entry) => entry !== '');
332
- }
333
332
  /**
334
333
  * 命令是否被白名单放行。
335
334
  *
@@ -353,14 +352,6 @@ export function commandAllowed(command, allowlist) {
353
352
  });
354
353
  }
355
354
  // ── 跑一条外部命令 ───────────────────────────────────────────────────────────
356
- function shellOf() {
357
- return process.platform === 'win32'
358
- ? { file: 'cmd.exe', args: ['/d', '/s', '/c'] }
359
- : { file: '/bin/sh', args: ['-c'] };
360
- }
361
- function errText(error) {
362
- return error instanceof Error ? error.message : String(error);
363
- }
364
355
  /**
365
356
  * 跑一条钩子命令。
366
357
  *
package/lib/core/llm.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { UserFileAttachment } from './attachments.js';
1
2
  export interface ToolCall {
2
3
  id: string;
3
4
  name: string;
@@ -43,6 +44,23 @@ export interface ChatMessage {
43
44
  * 不显示时间,不猜一个。
44
45
  */
45
46
  ts?: number;
47
+ /**
48
+ * 这条用户消息带的视频 / 通用文件(图片走 content 里的 image 块)。
49
+ *
50
+ * 与 `ts` 同一条纪律:只在内存与 jsonl 里活着,协议里没有这一项,
51
+ * {@link serializeMessages} 发请求前会剥掉;模型看到的是拼进正文的路径句柄
52
+ * (见 `core/attachments.ts` 的 `fileHandleText`)。
53
+ */
54
+ files?: UserFileAttachment[];
55
+ /**
56
+ * 这条 user 消息是谁发起的:人打的字(缺省)还是机器投递的唤醒(`'notice'`:
57
+ * 后台作业完成、定时补投、目标续跑、记忆复盘……)。
58
+ *
59
+ * 与 `ts` / `files` 同一条纪律:只在内存与 jsonl 里活着,协议里没有这一项,
60
+ * {@link serializeMessages} 发请求前会剥掉。它存在的唯一理由是**重放也要认得出机器消息**——
61
+ * 界面据此把这类消息画成一行内部触发行,而不是一个可编辑的用户气泡(见 adapter/transcript)。
62
+ */
63
+ origin?: 'user' | 'notice';
46
64
  }
47
65
  /**
48
66
  * 一次模型请求的路由:端点连接信息 + 协议字段。
@@ -250,6 +268,30 @@ export declare class StreamInterruptedError extends LlmError {
250
268
  readonly partial: StreamResult;
251
269
  constructor(message: string, partial: StreamResult);
252
270
  }
271
+ /** 一条流式工具调用增量:除了 `index`,其余字段网关都可能不给,甚至给成 `null`。 */
272
+ export interface ToolCallDelta {
273
+ index: number;
274
+ id?: string | null;
275
+ function?: {
276
+ name?: string | null;
277
+ arguments?: string | null;
278
+ } | null;
279
+ }
280
+ /**
281
+ * 把一条流式工具调用增量并进「按 index 累积」的调用表。
282
+ *
283
+ * 为什么逐字段判 `typeof === 'string'` 而不是判「有没有值」(2026-10-30 白屏事故):
284
+ * 网关在后续分片里把 `id` / `function.name` 回成 `null` 时,`x !== undefined && x !== ''`
285
+ * 两道门都放行,`null` 就覆盖掉了前面已经收到的好名字。于是一条本该叫 `run_code` 的调用
286
+ * 落成 `name: null`,日志里写着「未知工具:null」,界面再对 `call.name` 调 `.toLowerCase()`
287
+ * 就整块渲染崩掉(对话页白屏)。`null` 不是「给了个空值」,是「这次这片没带名字」,
288
+ * 所以只接受字符串,其余一律当没给。
289
+ *
290
+ * @param calls - 这次请求的调用表(键是流里的 index,同一个 index 会分多片到齐)
291
+ * @param call - 这一片的增量
292
+ * @param onName - 第一次拿到名字时的回调(界面据此先画一张「准备中」的卡)
293
+ */
294
+ export declare function applyToolCallDelta(calls: Map<number, ToolCall>, call: ToolCallDelta, onName?: (name: string) => void): void;
253
295
  /** 发起一次流式对话(openai-completions 适配器的实现;经 LlmService.stream 派发)。 */
254
296
  export declare function streamChat(request: StreamRequest, handlers: StreamHandlers): Promise<StreamResult>;
255
297
  /** assistant 消息重放:reasoning_content 回传保持模型思路连贯(dsh 同款)。 */
package/lib/core/llm.js CHANGED
@@ -223,6 +223,43 @@ export class StreamInterruptedError extends LlmError {
223
223
  }
224
224
  }
225
225
  const MAX_ATTEMPTS = 3;
226
+ /**
227
+ * 把一条流式工具调用增量并进「按 index 累积」的调用表。
228
+ *
229
+ * 为什么逐字段判 `typeof === 'string'` 而不是判「有没有值」(2026-10-30 白屏事故):
230
+ * 网关在后续分片里把 `id` / `function.name` 回成 `null` 时,`x !== undefined && x !== ''`
231
+ * 两道门都放行,`null` 就覆盖掉了前面已经收到的好名字。于是一条本该叫 `run_code` 的调用
232
+ * 落成 `name: null`,日志里写着「未知工具:null」,界面再对 `call.name` 调 `.toLowerCase()`
233
+ * 就整块渲染崩掉(对话页白屏)。`null` 不是「给了个空值」,是「这次这片没带名字」,
234
+ * 所以只接受字符串,其余一律当没给。
235
+ *
236
+ * @param calls - 这次请求的调用表(键是流里的 index,同一个 index 会分多片到齐)
237
+ * @param call - 这一片的增量
238
+ * @param onName - 第一次拿到名字时的回调(界面据此先画一张「准备中」的卡)
239
+ */
240
+ export function applyToolCallDelta(calls, call, onName) {
241
+ const id = typeof call.id === 'string' ? call.id : '';
242
+ const name = typeof call.function?.name === 'string' ? call.function.name : '';
243
+ const args = typeof call.function?.arguments === 'string' ? call.function.arguments : '';
244
+ const existing = calls.get(call.index);
245
+ if (existing === undefined) {
246
+ calls.set(call.index, { id, name, arguments: args });
247
+ // 首次拿到工具名就报一声「准备中」——参数这会儿多半还没开始到
248
+ if (name !== '')
249
+ onName?.(name);
250
+ return;
251
+ }
252
+ if (id !== '')
253
+ existing.id = id;
254
+ if (name !== '') {
255
+ // 名字也可能被分片切开:只在「从没有名字变成有名字」那一次报
256
+ if (existing.name === '')
257
+ onName?.(name);
258
+ existing.name = name;
259
+ }
260
+ if (args !== '')
261
+ existing.arguments += args;
262
+ }
226
263
  /** 发起一次流式对话(openai-completions 适配器的实现;经 LlmService.stream 派发)。 */
227
264
  export async function streamChat(request, handlers) {
228
265
  let attempt = 0;
@@ -345,31 +382,7 @@ async function streamOnce(request, handlers) {
345
382
  handlers.onDelta('text', delta.content);
346
383
  }
347
384
  for (const call of delta?.tool_calls ?? []) {
348
- const existing = callsByIndex.get(call.index);
349
- if (existing === undefined) {
350
- const name = call.function?.name ?? '';
351
- callsByIndex.set(call.index, {
352
- id: call.id ?? '',
353
- name,
354
- arguments: call.function?.arguments ?? '',
355
- });
356
- // 首次拿到工具名就报一声「准备中」——参数这会儿多半还没开始到
357
- if (name !== '')
358
- handlers.onToolPrepare?.(name);
359
- }
360
- else {
361
- if (call.id !== undefined && call.id !== '')
362
- existing.id = call.id;
363
- const name = call.function?.name;
364
- if (name !== undefined && name !== '') {
365
- // 名字也可能被分片切开:只在「从没有名字变成有名字」那一次报
366
- if (existing.name === '')
367
- handlers.onToolPrepare?.(name);
368
- existing.name = name;
369
- }
370
- if (call.function?.arguments !== undefined)
371
- existing.arguments += call.function.arguments;
372
- }
385
+ applyToolCallDelta(callsByIndex, call, handlers.onToolPrepare);
373
386
  }
374
387
  if (choice?.finish_reason != null)
375
388
  result.finishReason = choice.finish_reason;
@@ -421,6 +434,8 @@ export function serializeMessages(messages) {
421
434
  // 不动别的插件往消息上挂的东西。
422
435
  const wire = { ...message };
423
436
  delete wire.ts;
437
+ delete wire.files;
438
+ delete wire.origin;
424
439
  if (wire.role !== 'assistant')
425
440
  return wire;
426
441
  return {
@@ -23,6 +23,7 @@ import type { ChatMessage, LlmRoute, StreamHandlers, StreamRequest, StreamResult
23
23
  import { LlmError } from './llm.js';
24
24
  import type { CoreEvent } from './events.js';
25
25
  import type { Session, InboxOrigin } from './session.js';
26
+ import type { UserFileAttachment } from './attachments.js';
26
27
  import type { ToolGuardChain } from './tool-guards.js';
27
28
  import { type ToolEntry } from './tools.js';
28
29
  export interface AgentDeps {
@@ -92,6 +93,15 @@ export declare class MiniAgent {
92
93
  * 而这个 agent 从生到死只认一个会话,一个字段就是「按会话去重」。
93
94
  */
94
95
  private lastInvariantDigest;
96
+ /**
97
+ * 本轮请求发给模型的那份工具目录(requestOnce 现取、executeToolCalls 用它解析)。
98
+ *
99
+ * 为什么执行不重新取一次:模型是照着**发出去的那份 schema** 喊名字的。取两次的话,
100
+ * 请求与执行之间只要注册表变过(换模式、插件热插拔),模型明明喊的是它刚被告诉的
101
+ * 工具,也会落到「未知工具」——2026-10-28 用户报的那一串就是这么来的。
102
+ * 换模式的影响因此从**下一轮请求**起生效,同一轮里模型面前与手上是同一份。
103
+ */
104
+ private requestTools;
95
105
  constructor(deps: AgentDeps, session: Session);
96
106
  get sessionId(): string;
97
107
  get cwd(): string;
@@ -111,7 +121,7 @@ export declare class MiniAgent {
111
121
  * 回合跑动中入箱时,`'notice'` 会记进收件箱条目,界面据此把它画在输入框上方的
112
122
  * 只读通知条(而不是输入框下方的队列条);出账落库后两者都是同一条 user 消息。
113
123
  */
114
- followup(text: string, images?: string[], origin?: InboxOrigin): void;
124
+ followup(text: string, images?: string[], origin?: InboxOrigin, files?: UserFileAttachment[]): void;
115
125
  /**
116
126
  * 改一条排队中的输入(回合跑动中提交、还没出账的那些)。
117
127
  * @returns 是否真的改了;越界(等到出账了)返回 false,界面据此提示。