@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
@@ -6,7 +6,7 @@
6
6
  * 2. 命令 `/todo [clear]`;
7
7
  * 3. 界面快照里的 `todos` 那片投影(注册进 surfaces 注册表);
8
8
  * 4. 会话状态条目 `todos`(恢复历史会话时清单跟着回来)与压缩后要原样带过去的清单文本;
9
- * 5. 「todo-reminder」节流提醒投影(order 800,默认关):距上次写清单过了 N 个用户回合、
9
+ * 5. 「todo-reminder」节流提醒投影(order 800,默认开):距上次写清单过了 N 轮、
10
10
  * 且还有未完成项时,往请求末尾补一条 user 提醒。逻辑在 `core/todo-reminder.ts`(纯函数,
11
11
  * 可被探针直读),配置走本插件的设置分区。
12
12
  *
@@ -3,17 +3,23 @@ import { appendTodoReminder } from '../core/todo-reminder.js';
3
3
  import { TodoStore } from '../core/todo.js';
4
4
  /** 配置键(`~/.dsc/plugins.json` 条目树里 `file` 等于这个名字那一项的 `config`)。 */
5
5
  const CONFIG_KEY = 'todo';
6
- /** 节流提醒的默认值:默认关(不给所有会话凭空加 token),每 10 个用户回合提醒一次。 */
7
- const REMINDER_DEFAULTS = { enabled: false, everyTurns: 10 };
8
- /** 从插件配置读节流提醒的开关与间隔,并把间隔夹回 1..100。 */
6
+ /** 节流提醒的默认值:默认开,每 8 轮提醒一次(口径与理由见 `core/todo-reminder.ts` 的文件头)。 */
7
+ const REMINDER_DEFAULTS = { enabled: true, everyRounds: 8 };
8
+ /**
9
+ * 从插件配置读节流提醒的开关与间隔,并把间隔夹回 1..100。
10
+ *
11
+ * 2026-10-27 起按「轮」数(一轮 = 一次模型请求),默认开、8 轮一次。
12
+ * 老配置里可能还留着 `everyTurns`,读一次当回退——不迁移、不写盘,等用户下次保存时自然换成新键。
13
+ * `enabled` 只有显式写了 false 才算关:默认开,缺省不该被读成"用户关掉了"。
14
+ */
9
15
  function readReminderConfig() {
10
16
  const raw = resolvePluginConfig(CONFIG_KEY);
11
- const num = Number(raw.everyTurns);
17
+ const num = Number(raw.everyRounds ?? raw.everyTurns);
12
18
  return {
13
- enabled: raw.enabled === true || raw.enabled === 'true',
14
- everyTurns: Number.isFinite(num)
19
+ enabled: raw.enabled !== false && raw.enabled !== 'false',
20
+ everyRounds: Number.isFinite(num)
15
21
  ? Math.min(Math.max(Math.round(num), 1), 100)
16
- : REMINDER_DEFAULTS.everyTurns,
22
+ : REMINDER_DEFAULTS.everyRounds,
17
23
  };
18
24
  }
19
25
  /** 任务清单工具:写入即回显整表,模型看到的和用户看到的是同一份。 */
@@ -103,10 +109,10 @@ export const todoPlugin = {
103
109
  ctx.surfaces.register('todos', () => service.todoView());
104
110
  // 压缩摘要会把清单改写走样,所以整表要原样带过去(压缩插件只问注册表要文本)。
105
111
  ctx.compact.registerCarry(() => service.todoPrompt());
106
- // ── 节流提醒投影(默认关)──────────────────────────────────────────────
112
+ // ── 节流提醒投影(默认开)──────────────────────────────────────────────
107
113
  // 长会话里模型会把「做完一步就改状态」忘掉,光靠工具说明里的静态叮嘱拉不回来。
108
- // 这条投影每 N 个用户回合往请求末尾补一条 user 提醒(ZCode 的节流注入思路),
109
- // 代价是多一条 user 消息的 token,所以默认关、用户自己开。
114
+ // 这条投影每 N 轮往请求末尾补一条 user 提醒(ZCode 的节流注入思路),
115
+ // 代价是每轮多一条 user 消息的 token,所以只在清单确实有未完成项时才发(默认 8 轮一次)。
110
116
  let reminder = readReminderConfig();
111
117
  const applyReminder = (patch) => {
112
118
  writePluginConfig(CONFIG_KEY, patch);
@@ -114,7 +120,7 @@ export const todoPlugin = {
114
120
  };
115
121
  const offReminder = ctx.prompt.registerProjection('todo-reminder', (messages) => appendTodoReminder(messages, {
116
122
  enabled: reminder.enabled,
117
- everyTurns: reminder.everyTurns,
123
+ everyRounds: reminder.everyRounds,
118
124
  hasOpenTodos: todos.read().some((item) => item.status === 'pending' || item.status === 'in_progress'),
119
125
  }),
120
126
  // order 800:排在 env-facts(600) 之后(提醒要落在环境快照之后,也在 drop-images(900) 之前)
@@ -123,17 +129,17 @@ export const todoPlugin = {
123
129
  {
124
130
  type: 'switch',
125
131
  key: 'enabled',
126
- label: '每过若干回合提醒一次未完成任务',
127
- help: '开启后,距上次更新任务清单超过设定回合数且清单里还有未完成项时,往下一轮请求末尾补一条提醒。默认关(省 token)。',
132
+ label: '每过若干轮提醒一次未完成任务',
133
+ help: '开启后,距上次更新任务清单超过设定轮数、且清单里还有未完成项时,往请求末尾补一条提醒。默认开(长任务里模型最容易忘掉这一步)。',
128
134
  },
129
135
  {
130
136
  type: 'number',
131
- key: 'everyTurns',
132
- label: '每隔几个用户回合提醒一次',
137
+ key: 'everyRounds',
138
+ label: '每隔几轮提醒一次',
133
139
  min: 1,
134
140
  max: 100,
135
141
  step: 1,
136
- help: '数值越小提醒越勤、token 花得越多;只在上面那条开着时生效。',
142
+ help: '一轮 = 一次模型请求。数值越小提醒越勤、token 花得越多;只在上面那条开着时生效。',
137
143
  },
138
144
  ];
139
145
  const reminderSection = {
@@ -145,20 +151,20 @@ export const todoPlugin = {
145
151
  // 每次打开都现读磁盘:手改 plugins.json 也能看到真值。
146
152
  values: () => {
147
153
  reminder = readReminderConfig();
148
- return { enabled: reminder.enabled, everyTurns: reminder.everyTurns };
154
+ return { enabled: reminder.enabled, everyRounds: reminder.everyRounds };
149
155
  },
150
156
  save: (key, value) => {
151
157
  if (key === 'enabled') {
152
158
  applyReminder({ enabled: value === true || value === 'true' });
153
159
  return;
154
160
  }
155
- if (key === 'everyTurns') {
161
+ if (key === 'everyRounds') {
156
162
  const num = Number(value);
157
163
  if (!Number.isFinite(num))
158
164
  return '这里要填一个数字';
159
165
  if (num < 1 || num > 100)
160
166
  return '间隔要在 1 到 100 之间';
161
- applyReminder({ everyTurns: Math.round(num) });
167
+ applyReminder({ everyRounds: Math.round(num) });
162
168
  return;
163
169
  }
164
170
  return `这个分区没有这项:${key}`;
@@ -1,5 +1,4 @@
1
1
  import { resolvePluginConfig, writePluginConfig } from '../core/plugin-registry.js';
2
- import { callFacts } from '../core/tools.js';
3
2
  import { ToolSearchIndex, TOOL_SEARCH_CONFIG_KEY, TOOL_SEARCH_LIMITS, parseNameListText, resolveToolSearchConfig, shouldDeferTool, summarizeToolDescription, } from '../core/tool-search.js';
4
3
  import { dscPath } from '../core/path-policy.js';
5
4
  /** 三个桥接工具的固定名字(它们自己不许被撤下,也不许再经 tool_call 包一层)。 */
@@ -8,7 +7,7 @@ const BRIDGE_TOOL_NAMES = new Set(['tool_search', 'tool_describe', 'tool_call'])
8
7
  const PLUGINS_FILE = dscPath('plugins.json');
9
8
  export const toolSearchPlugin = {
10
9
  name: 'tool-search',
11
- inject: ['tools', 'guards', 'settings'],
10
+ inject: ['tools', 'settings'],
12
11
  apply(ctx, passed) {
13
12
  // 先把配置校验一遍:写错了插件就挂不上(错在哪、去哪儿改由 readConfig 的消息说清),
14
13
  // 别带着一份坏配置跑起来、等模型调工具时才炸。
@@ -17,6 +16,8 @@ export const toolSearchPlugin = {
17
16
  const held = new Map();
18
17
  /** 注册过的东西都留退订函数,插件卸载时原样撤掉。 */
19
18
  const disposers = [];
19
+ /** 当前是不是本插件把 MCP 的动手类 schema 撤下了:卸载与关开关要按它收回。 */
20
+ let mcpDeferred = false;
20
21
  /** 取 MCP 客户端。它是可选服务(插件没开时不存在),所以必须走 ctx.get,不能写 ctx.mcp。 */
21
22
  const mcpService = () => ctx.get('mcp');
22
23
  function readConfig() {
@@ -63,8 +64,15 @@ export const toolSearchPlugin = {
63
64
  }
64
65
  }
65
66
  const mcp = mcpService();
66
- if (config.deferMcpSchemas && mcp !== undefined)
67
+ if (config.deferMcpSchemas && mcp !== undefined) {
67
68
  mcp.deferSchemas();
69
+ mcpDeferred = true;
70
+ }
71
+ else if (mcpDeferred) {
72
+ // 关掉开关要当场把动手类工具挂回台面:撤下是单向变量,不收回就只能重启宿主。
73
+ mcp?.restoreSchemas();
74
+ mcpDeferred = false;
75
+ }
68
76
  }
69
77
  /** 现在能检索、能调用的目录:MCP 工具(`mcp.tools()`)+ 本插件撤下的注册表工具。 */
70
78
  function catalogItems() {
@@ -118,7 +126,7 @@ export const toolSearchPlugin = {
118
126
  description: live.description,
119
127
  parameters: live.parameters,
120
128
  risk: live.risk,
121
- where: '就在台面上,可以直接调用(经 tool_call 走等于多过一道审批)',
129
+ where: '就在台面上,直接调用即可(经 tool_call 转调也是同一条工具、同一道审批)',
122
130
  invoke: (callArgs, runCtx) => live.run(callArgs, {
123
131
  cwd: runCtx.cwd,
124
132
  signal: runCtx.signal,
@@ -231,7 +239,7 @@ export const toolSearchPlugin = {
231
239
  const callTool = {
232
240
  name: 'tool_call',
233
241
  description: '按真名调用一条工具(撤下的工具只能这样调)。真名与参数照 tool_search / tool_describe 给出的填,别自己猜。' +
234
- '执行前会按真实工具名重走一遍审批与安全钩子,所以被撤下的写操作照样会弹卡、也照样能被规则拦下。',
242
+ '审批与安全钩子按被调工具的真名判定:撤下的写操作照样会弹卡(只弹一张)、也照样能被规则拦下。',
235
243
  parameters: {
236
244
  type: 'object',
237
245
  properties: {
@@ -244,6 +252,26 @@ export const toolSearchPlugin = {
244
252
  required: ['name'],
245
253
  },
246
254
  risk: 'exec',
255
+ /**
256
+ * 交出被调工具的身份:循环按它过守卫链,桥自己不再判一遍(那是两张卡的来源)。
257
+ * 名字拼错、参数坏掉时返回 undefined——循环退回按 tool_call 判定,错误留给 run 原样报给模型。
258
+ */
259
+ gateAs(gateArgs) {
260
+ const name = String(gateArgs.name ?? '').trim();
261
+ if (name === '' || BRIDGE_TOOL_NAMES.has(name))
262
+ return undefined;
263
+ const target = resolveTool(name);
264
+ if (target === undefined)
265
+ return undefined;
266
+ let callArgs = {};
267
+ try {
268
+ callArgs = readCallArgs(gateArgs.arguments);
269
+ }
270
+ catch {
271
+ // 参数不是合法 JSON:run 里会原样报错,这里按真名与真实风险问一遍,别让一张卡都没有
272
+ }
273
+ return { name: target.name, risk: target.risk, args: callArgs };
274
+ },
247
275
  async run(args, runCtx) {
248
276
  const name = String(args.name ?? '').trim();
249
277
  if (name === '')
@@ -256,21 +284,7 @@ export const toolSearchPlugin = {
256
284
  throw new Error(`没有这个工具:${name}。先用 tool_search 搜名字(例如「创建工单」或 github issue)。`);
257
285
  }
258
286
  const callArgs = readCallArgs(args.arguments);
259
- // 关键一条:工具是被撤下之后经桥接层执行的,但守卫链必须按真实工具名与真实风险判定——
260
- // 否则模式闸门、安全钩子、审批卡看到的都是 tool_call,会话日志里也记不出到底批准了谁。
261
- const verdict = await ctx.guards.gate({
262
- toolName: name,
263
- risk: target.risk,
264
- cwd: runCtx.cwd,
265
- args: callArgs,
266
- signal: runCtx.signal,
267
- sessionId: runCtx.sessionId,
268
- sessionPath: runCtx.sessionPath,
269
- ...callFacts(callArgs, runCtx.cwd),
270
- });
271
- // 守卫说拒:理由原文回给模型(由循环记成这次工具失败),不静默、也不改写成别的话
272
- if (verdict.action === 'deny')
273
- throw new Error(verdict.reason);
287
+ // 审批与安全钩子已经在循环里按真名判过了(见 gateAs):这里只执行,不再问第二遍。
274
288
  return target.invoke(callArgs, runCtx);
275
289
  },
276
290
  };
@@ -295,13 +309,13 @@ export const toolSearchPlugin = {
295
309
  lines.push('MCP 工具的 schema 没撤(开关关着)');
296
310
  }
297
311
  lines.push(`注册表工具 ${String(heldNames.length)} 条${heldNames.length === 0 ? '' : `:${heldNames.join('、')}`}`);
298
- lines.push('read 工具不会出现在这两行里:它们必须留在台面上,否则每次只读都要过一张审批卡。');
312
+ lines.push('read 工具不会出现在这两行里:撤了每次读都要先搜再调、多两次往返,省不下多少 token。');
299
313
  return lines.join('\n');
300
314
  }
301
315
  const section = {
302
316
  id: TOOL_SEARCH_CONFIG_KEY,
303
- title: '工具渐进披露',
304
- subtitle: '每轮只为用得上的工具付 schema:撤下的工具用 tool_search / tool_describe / tool_call 找回来',
317
+ title: '工具按需加载',
318
+ subtitle: '只为用得上的工具付说明文字:动手类与 MCP 工具撤下,read 工具仍常驻',
305
319
  order: 47,
306
320
  fields() {
307
321
  const config = readConfig();
@@ -311,18 +325,18 @@ export const toolSearchPlugin = {
311
325
  label: '常驻台面的三个工具',
312
326
  text: 'tool_search:按关键词(中文按相邻两字切,英文按单词)在撤下的目录里检索;\n' +
313
327
  'tool_describe:取某条工具的完整参数 JSON Schema;\n' +
314
- 'tool_call:按真名调用它,调用前按真名重走审批与安全钩子。',
328
+ 'tool_call:按真名调用它;审批与安全钩子按真名的真实风险判定,一次调用只弹一张卡。',
315
329
  },
316
330
  {
317
331
  type: 'switch',
318
332
  key: 'deferMcpSchemas',
319
- label: '撤下 MCP 工具的 schema',
320
- help: 'MCP 一接进来就是几十个工具的参数表,撤下收益最大。撤下由 MCP 客户端一次性执行,关掉要重启宿主才恢复。',
333
+ label: '把 MCP 工具也收进按需加载',
334
+ help: 'MCP 一接进来就是几十个工具的参数表,收进来收益最大。关掉后动手类工具会立刻挂回台面,不用重启宿主。',
321
335
  },
322
336
  {
323
337
  type: 'select',
324
338
  key: 'tier',
325
- label: '渐进披露档位',
339
+ label: '按需加载档位',
326
340
  options: [
327
341
  { value: '1', label: '1:只撤 MCP 工具' },
328
342
  { value: '2', label: '2:再撤下面规则命中的工具(缺省)' },
@@ -336,7 +350,7 @@ export const toolSearchPlugin = {
336
350
  label: '延后规则(一行一条,支持 *)',
337
351
  placeholder: 'mcp__github__*\nedit',
338
352
  mono: true,
339
- help: '只在档位 2 生效。命中的工具被撤下后要用 tool_call 调,每次调用都会过审批卡。',
353
+ help: '只在档位 2 生效。命中的工具被撤下后要用 tool_call 调,每次调用都按那条工具的真名问一次审批。',
340
354
  },
341
355
  {
342
356
  type: 'text',
@@ -429,6 +443,11 @@ export const toolSearchPlugin = {
429
443
  off();
430
444
  // 卸载时把撤下的工具放回注册表:撤下只是替宿主省 token,卸载了就不该再扣着别人的工具
431
445
  restoreHeld();
446
+ // MCP 那边同样要收口:本插件停用后,动手类 MCP 工具必须回到台面。
447
+ if (mcpDeferred) {
448
+ mcpService()?.restoreSchemas();
449
+ mcpDeferred = false;
450
+ }
432
451
  };
433
452
  },
434
453
  };
@@ -1,7 +1,10 @@
1
1
  import { createBashTool, BASH_DEFAULT_BUDGETS, createJobTools, createTerminalTool, JobTable, stopAllBackgroundChildren, stopBackgroundChild, TerminalTable } from '../core/tools/bash.js';
2
2
  import { createReadTool, editTool, READ_DEFAULT_LINE_LIMIT, writeTool } from '../core/tools/fs-tools.js';
3
+ import { readImageTool } from '../core/tools/image-tool.js';
3
4
  import { globTool, grepTool } from '../core/tools/search-tools.js';
4
5
  import { resolvePluginConfig, writePluginConfig } from '../core/plugin-registry.js';
6
+ import { clampInt as clamp } from '../core/clamp.js';
7
+ import { detectShells, forgetShellDetection, parseShellChoice, readShellChoice, shellChoiceLabel, SHELL_CHOICES, } from '../core/terminal-env.js';
5
8
  /** 配置键(`~/.dsc/plugins.json` 条目树里 `file` 等于这个名字那一项的 `config`)。 */
6
9
  const CONFIG_KEY = 'tools-default';
7
10
  /** 可调值的取值区间:超时太小等于没跑,太大等于占着一轮不放。 */
@@ -12,10 +15,6 @@ const LINE_RANGE = { min: 100, max: 10_000 };
12
15
  /** 从插件配置取预算,区间外的值夹回来(配置写错不至于把工具夹死)。 */
13
16
  function readBudgets(passed) {
14
17
  const raw = resolvePluginConfig(CONFIG_KEY, passed);
15
- const clamp = (value, min, max, fallback) => {
16
- const num = Number(value);
17
- return Number.isFinite(num) ? Math.min(Math.max(Math.round(num), min), max) : fallback;
18
- };
19
18
  return {
20
19
  timeoutMs: clamp(raw.bashTimeoutMs, TIMEOUT_RANGE.min, TIMEOUT_RANGE.max, BASH_DEFAULT_BUDGETS.timeoutMs),
21
20
  maxTimeoutMs: clamp(raw.bashMaxTimeoutMs, TIMEOUT_RANGE.min, TIMEOUT_RANGE.max, BASH_DEFAULT_BUDGETS.maxTimeoutMs),
@@ -176,6 +175,7 @@ export const toolsDefaultPlugin = {
176
175
  ...createJobTools(table).map((entry) => ctx.tools.register(entry)),
177
176
  ctx.tools.register(createTerminalTool(terminals)),
178
177
  ctx.tools.register(createReadTool(budgets.readLineLimit)),
178
+ ctx.tools.register(readImageTool),
179
179
  ctx.tools.register(writeTool),
180
180
  ctx.tools.register(editTool),
181
181
  ctx.tools.register(globTool),
@@ -214,7 +214,7 @@ export const toolsDefaultPlugin = {
214
214
  min: OUTPUT_RANGE.min,
215
215
  max: OUTPUT_RANGE.max,
216
216
  step: 1000,
217
- help: '超出就截断并注明。大输出溢出插件开着时,超过它的阈值会先落盘只回前几行,这条是没开插件时的兜底。',
217
+ help: '超出就截断并注明。长输出转存插件开着时,超过它的阈值会先落盘只回头尾几行,这条是没开插件时的兜底。',
218
218
  },
219
219
  {
220
220
  type: 'number',
@@ -260,6 +260,88 @@ export const toolsDefaultPlugin = {
260
260
  },
261
261
  };
262
262
  const offSection = ctx.settings.registerSection(section);
263
+ // ---- 终端环境(2026-10-30):探出这台机器上有哪几个 shell,让用户选默认执行器 ----
264
+ //
265
+ // 为什么单开一个分区、而不是塞进「工具预算」:这一项改的不是预算而是**命令怎么写**。
266
+ // 选了 Git Bash,模型该写 `ls -la`;选了 PowerShell,该写 `Get-ChildItem`。
267
+ // 界面上挨着预算摆,用户会以为是同一类旋钮。
268
+ const shellSection = {
269
+ id: 'terminal-env',
270
+ title: '终端环境',
271
+ subtitle: '这台机器上有哪些 shell 能执行命令,以及 bash 工具默认用哪一个',
272
+ order: 6,
273
+ fields() {
274
+ // 每次打开分区都现探一次(10 秒缓存):刚装好 PowerShell 7 再打开就能看见。
275
+ const detected = detectShells();
276
+ const current = readShellChoice();
277
+ const options = detected
278
+ .filter((item) => item.value === 'auto' || item.available)
279
+ .map((item) => ({ value: item.value, label: item.label }));
280
+ // 选过但现在已经不可用(卸载了 Git / 关掉了 WSL):仍要能显示当前值,
281
+ // 否则下拉会显示成第一项,用户以为已经跟着改了。
282
+ if (!options.some((option) => option.value === current)) {
283
+ options.push({ value: current, label: `${current}(当前不可用,实际回落平台默认)` });
284
+ }
285
+ const summary = detected
286
+ .map((item) => `${item.available ? '✓' : '✗'} ${item.label}`)
287
+ .join(' ');
288
+ return [
289
+ {
290
+ type: 'select',
291
+ key: 'bashShell',
292
+ label: '默认终端',
293
+ options,
294
+ help: 'bash 工具与终端会话都从这里起进程。切了之后模型看到的工具说明也会跟着改,' +
295
+ '它会按新终端的语法写命令。只列出这台机器上真检测到的;没检测到的不会出现在选项里。',
296
+ },
297
+ { type: 'info', label: '检测结果', text: summary },
298
+ {
299
+ type: 'button',
300
+ action: 'redetect',
301
+ label: '重新检测',
302
+ style: 'ghost',
303
+ help: '刚装完 PowerShell 7 / Git / WSL 时点一下,不用重启。',
304
+ },
305
+ ];
306
+ },
307
+ values: () => ({ bashShell: readShellChoice() }),
308
+ // 契约:save 返回字符串 = 失败原因,返回对象 = 成功(`notice` 是给用户看的回执)。
309
+ // 这里成功必须走对象——返回字符串会被当成「失败原因」摆到界面上(2026-10-30 自查发现)。
310
+ save: (key, value) => {
311
+ if (key !== 'bashShell')
312
+ return `这个分区没有这项:${key}`;
313
+ if (typeof value !== 'string' || !SHELL_CHOICES.includes(value)) {
314
+ return `不认识的终端:${String(value)}`;
315
+ }
316
+ const choice = parseShellChoice(value);
317
+ const detected = detectShells();
318
+ const hit = detected.find((item) => item.value === choice);
319
+ if (choice !== 'auto' && hit !== undefined && !hit.available) {
320
+ return `这台机器上没检测到 ${hit.label},先装好(或点「重新检测」)再选`;
321
+ }
322
+ // 走 applyConfig:写 plugins.json 之后重注册工具——工具说明里的终端名要跟着换。
323
+ applyConfig({ bashShell: choice });
324
+ forgetShellDetection();
325
+ return { notice: `已切到 ${shellChoiceLabel(choice)};下一条命令起生效` };
326
+ },
327
+ action: (name) => {
328
+ // 动作的契约与 save 不同:字符串是**成功**的提示文案,失败要抛错。
329
+ if (name !== 'redetect')
330
+ throw new Error(`不认识的按钮:${name}`);
331
+ forgetShellDetection();
332
+ const detected = detectShells(true);
333
+ const available = detected.filter((item) => item.available).map((item) => item.label);
334
+ return `重新检测完成:${available.join('、')}`;
335
+ },
336
+ };
337
+ const offShellSection = ctx.settings.registerSection(shellSection, { inSettings: true });
338
+ // 后台预热一次探测(挂载 50ms 之后,不占启动关键路径):设置页第一次打开时下拉里就该
339
+ // 已经有选项。不预热的话,`sections()` 会同步跑一次冷探测(四个子进程约 2.5 秒),
340
+ // 用户点开设置就是一阵卡。
341
+ const primeTimer = setTimeout(() => {
342
+ detectShells(true);
343
+ }, 50);
344
+ primeTimer.unref?.();
263
345
  return () => {
264
346
  for (const off of disposers)
265
347
  off();
@@ -269,7 +351,9 @@ export const toolsDefaultPlugin = {
269
351
  clearTimeout(timer);
270
352
  noticeTimers.clear();
271
353
  stopAllBackgroundChildren();
354
+ clearTimeout(primeTimer);
272
355
  offSection();
356
+ offShellSection();
273
357
  };
274
358
  },
275
359
  };
@@ -21,7 +21,7 @@ export const toolsPlugin = {
21
21
  provide: 'tools',
22
22
  apply(ctx) {
23
23
  const entries = new Map();
24
- /** 主会话目录的投影表(按注册顺序应用)。 */
24
+ /** 主会话目录的投影表(按注册顺序应用)。第二个入参是「谁在问」,见 AgentScope。 */
25
25
  const projections = new Map();
26
26
  const service = {
27
27
  register(entry) {
@@ -42,11 +42,11 @@ export const toolsPlugin = {
42
42
  projections.delete(id);
43
43
  };
44
44
  },
45
- visible() {
45
+ visible(scope) {
46
46
  let out = [...entries.values()];
47
47
  for (const [id, fn] of projections) {
48
48
  try {
49
- out = fn(out);
49
+ out = fn(out, scope);
50
50
  }
51
51
  catch (error) {
52
52
  // 一个投影崩了不该让这一轮请求整个失败:跳过它,模型这一轮看到的是未裁剪的
@@ -1,11 +1,30 @@
1
1
  import { Transcript } from '../adapter/transcript.js';
2
2
  import { estimateSessionCostCny, isDeepseekProvider, isPeakHour } from '../core/pricing.js';
3
+ import { readSessionUsage } from '../core/usage-log.js';
3
4
  import { emptySegments } from '../core/token-estimate.js';
5
+ import { contentText } from '../core/llm.js';
6
+ import { SUMMARY_BANNER } from '../core/compact-anchors.js';
4
7
  /**
5
8
  * 收件箱按来源拆两个面:用户来源 → `queued`(输入框下方队列条),机器来源 →
6
9
  * `notices`(输入框上方只读通知条)。`index` 一律保留它在收件箱里的原始位置
7
10
  * (不重新发号)——队列条的动作(编辑 / 撤掉 / 插话)就是按这个下标打到收件箱上的。
8
11
  */
12
+ /**
13
+ * 这一轮从哪一刻开始:取最后一条**非插话**的用户消息 ts(与界面 timing.turnStartedAt 同口径)。
14
+ *
15
+ * 为什么同口径两处写:界面那份算的是「含直播条目」的流,宿主这份算的是已落库的条目——
16
+ * 两者应当是同一时刻(用户消息先落库再进回合)。取不到(老日志没有 ts)就不带这个字段,
17
+ * 状态栏那边整段不画,不编一个 0。
18
+ */
19
+ function turnStartOf(entries) {
20
+ for (let index = entries.length - 1; index >= 0; index -= 1) {
21
+ const entry = entries[index];
22
+ if (entry !== undefined && entry.kind === 'user' && entry.steering !== true) {
23
+ return typeof entry.ts === 'number' ? entry.ts : undefined;
24
+ }
25
+ }
26
+ return undefined;
27
+ }
9
28
  function splitInbox(items) {
10
29
  const queued = [];
11
30
  const notices = [];
@@ -18,10 +37,34 @@ function splitInbox(items) {
18
37
  index,
19
38
  text: item.text,
20
39
  ...(item.images !== undefined && item.images.length > 0 ? { images: item.images } : {}),
40
+ ...(item.files !== undefined && item.files.length > 0 ? { files: item.files } : {}),
21
41
  });
22
42
  });
23
43
  return { queued, notices };
24
44
  }
45
+ /**
46
+ * 会话进度:轮数 = 用户消息数(压缩摘要那一行不算),步数 = 助手消息数。
47
+ *
48
+ * 口径对照 dsh 的 `sessionStats`(turns = 有回复的轮、steps = 助手节点数)。这里不数
49
+ * 渲染条目——同一次模型调用可能拆成思考 + 正文两条,数条目会把步数算多;会话消息是
50
+ * 协议的原始形状,一问一答各一条,最接近 dsh 的持久投影。
51
+ */
52
+ function sessionProgress(messages) {
53
+ let turns = 0;
54
+ let steps = 0;
55
+ for (const message of messages) {
56
+ if (message.role === 'assistant') {
57
+ steps += 1;
58
+ continue;
59
+ }
60
+ if (message.role !== 'user')
61
+ continue;
62
+ if (contentText(message.content).startsWith(SUMMARY_BANNER))
63
+ continue;
64
+ turns += 1;
65
+ }
66
+ return { turns, steps };
67
+ }
25
68
  export const transcriptPlugin = {
26
69
  name: 'transcript',
27
70
  inject: ['session', 'llm', 'surfaces'],
@@ -58,6 +101,31 @@ export const transcriptPlugin = {
58
101
  invalidate();
59
102
  });
60
103
  ctx.on('dsc/changed', () => invalidate());
104
+ /**
105
+ * 正在压缩的会话(0.7.2):键 = 会话 jsonl 路径,值 = 开始时刻。
106
+ *
107
+ * 为什么不并进 turnState:压缩是命令驱动的,外面没有回合,turnState 仍是 idle;
108
+ * 而且压缩与回合互斥(compact 插件自己挡),单独一张表最直白。
109
+ */
110
+ const compactingSince = new Map();
111
+ ctx.on('dsc/compacting', (running, sessionPath) => {
112
+ const path = sessionPath ?? ctx.session.current().filePath;
113
+ if (running)
114
+ compactingSince.set(path, Date.now());
115
+ else
116
+ compactingSince.delete(path);
117
+ invalidate();
118
+ });
119
+ /**
120
+ * 压缩完成后的估算读数(0.7.2):权威值要等下一次真实请求,这期间底部不能停着不动。
121
+ * 只认当前会话——后台会话的读数属于它自己,不该改别人状态栏上的数字。
122
+ */
123
+ ctx.on('dsc/context-used', (tokens, sessionPath) => {
124
+ if (sessionPath !== undefined && sessionPath !== ctx.session.current().filePath)
125
+ return;
126
+ transcript.seedContextUsage(tokens);
127
+ invalidate();
128
+ });
61
129
  // 第二个参数是通知的类别:'compaction' = 「历史刚被压缩」的落点(compact 插件发)。
62
130
  // 本插件认这个类别给条目打压缩标记;不认识的类别按普通通知处理。
63
131
  // 事件可带会话归属(0.6.49):后台会话发的通知/计划卡不进当前查看会话的转录,
@@ -91,7 +159,7 @@ export const transcriptPlugin = {
91
159
  if (current.messages.length === 0)
92
160
  return false;
93
161
  const probe = new Transcript();
94
- probe.replayHistory(current.messages, current.toolErrors, current.fileChanges);
162
+ probe.replayHistory(current.messages, current.toolErrors, current.fileChanges, current.presentations);
95
163
  return sameEntries(probe.entries.filter((entry) => entry.kind !== 'system' && entry.kind !== 'subagent'), transcript.entries.filter((entry) => entry.kind !== 'system' && entry.kind !== 'subagent'));
96
164
  };
97
165
  ctx.on('dsc/session-open', ({ filePath }) => {
@@ -140,8 +208,16 @@ export const transcriptPlugin = {
140
208
  transcript.clear();
141
209
  if (filePath !== undefined) {
142
210
  // 恢复会话:历史消息重放进条目(桌面端/TUI 点历史会话能回看内容)
143
- transcript.replayHistory(current.messages, current.toolErrors, current.fileChanges);
144
- transcript.system(`已恢复会话 ${current.meta.id.slice(0, 8)}`);
211
+ transcript.replayHistory(current.messages, current.toolErrors, current.fileChanges, current.presentations);
212
+ // clear() 会把 contextUsed 归零,而重放不重放 usage;不从这里补回来,
213
+ // 每切一次会话状态栏的上下文就掉成 0%。用量日志按会话记着最后一条请求的
214
+ // 输入 token,它才是「此刻真实占用」。这条会话一行用量都没有时不填:
215
+ // 0% 是个读数,不能拿来冒充「还没数」。
216
+ const usage = readSessionUsage(current.meta.id);
217
+ if (usage !== null)
218
+ transcript.seedContextUsage(usage.lastInputTokens);
219
+ // 不再往转录里写「已恢复会话 xxx」:它落在最后,看着像一句常驻的尾巴,
220
+ // 用户 2026-10-28 要求去掉。恢复这件事本身在侧边栏的选中态里已经说清楚了。
145
221
  }
146
222
  else {
147
223
  transcript.system(`新会话 ${current.meta.id.slice(0, 8)}(模型 ${ctx.llm.provider}/${ctx.llm.model})`);
@@ -150,21 +226,40 @@ export const transcriptPlugin = {
150
226
  seedSubagents();
151
227
  invalidate();
152
228
  });
229
+ /**
230
+ * 这条写入是不是属于「此刻正被查看的会话」。
231
+ *
232
+ * 不带归属(undefined)= 全局提示,放行;带了别的会话 id = 串台,丢掉。
233
+ * 为什么丢的是写入而不是记到别处:每份会话都有自己的 jsonl,切回去时由重放补出,
234
+ * 转录只是「当前视图」的缓存,往别人的视图里塞东西没有任何去处。
235
+ */
236
+ const owned = (owner) => owner === undefined || owner === ctx.session.current().meta.id;
237
+ /**
238
+ * 对外服务面额外带一个回填入口。为什么不写进 TranscriptService 契约:它只服务
239
+ * 宿主启动恢复这一条路径(会话打开走的是上面直接操作 adapter),把恢复细节
240
+ * 摊进所有消费者看到的接口,等于让每个插件都以为自己该管上下文读数。
241
+ */
153
242
  const service = {
154
- emit(event) {
243
+ emit(event, owner) {
244
+ if (!owned(owner))
245
+ return;
155
246
  if (transcript.reduce(event))
156
247
  invalidate();
157
248
  },
158
- system(text) {
159
- transcript.system(text);
249
+ system(text, level, command, owner) {
250
+ if (!owned(owner))
251
+ return;
252
+ transcript.system(text, false, level, command === true);
160
253
  invalidate();
161
254
  },
162
- plan(view) {
255
+ plan(view, owner) {
256
+ if (!owned(owner))
257
+ return;
163
258
  transcript.plan(view);
164
259
  invalidate();
165
260
  },
166
- replayHistory(messages, toolErrors, fileChanges) {
167
- const changed = transcript.replayHistory(messages, toolErrors, fileChanges);
261
+ replayHistory(messages, toolErrors, fileChanges, presentations) {
262
+ const changed = transcript.replayHistory(messages, toolErrors, fileChanges, presentations);
168
263
  if (changed)
169
264
  invalidate();
170
265
  return changed;
@@ -178,6 +273,10 @@ export const transcriptPlugin = {
178
273
  touch() {
179
274
  invalidate();
180
275
  },
276
+ seedContextUsage(used) {
277
+ transcript.seedContextUsage(used);
278
+ invalidate();
279
+ },
181
280
  getSnapshot() {
182
281
  const cached = snapshot;
183
282
  if (cached !== null)
@@ -239,10 +338,18 @@ export const transcriptPlugin = {
239
338
  contextWindow: ctx.llm.contextWindow,
240
339
  contextUsed: transcript.contextUsed,
241
340
  contextSegments: transcript.contextSegments ?? emptySegments(),
341
+ progress: sessionProgress(ctx.session.current().messages),
342
+ // 本轮开始时刻(底面状态栏显示「用时」用):回合在跑才给,跑完就没有这一项——
343
+ // 结束后的用时是轮尾那行的事(RoundFoot 的 title),两处各管一端。
344
+ ...(turnState === 'idle' ? {} : { turnStartedAt: turnStartOf(transcript.entries) }),
242
345
  ...(costEstimate === undefined
243
346
  ? {}
244
347
  : { cost: { total: costEstimate.total, peakNow: isPeakHour() } }),
245
348
  cwd: ctx.session.current().meta.cwd,
349
+ // 正在压缩时给界面一个开始时刻,它据此画活动行(0.7.2);没在压就不带这个字段。
350
+ ...(compactingSince.get(ctx.session.current().filePath) === undefined
351
+ ? {}
352
+ : { compactingSince: compactingSince.get(ctx.session.current().filePath) }),
246
353
  // jsonl 绝对路径:sessionId 是 uuid,落盘类命令(/fork)得用这个
247
354
  sessionPath: ctx.session.current().filePath,
248
355
  // 一条消息都没发过 = 还没落盘:界面据此把输入框草稿记在工作区名下(见 contract 的说明)
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * 提供方走纯 HTTP API(fetch,不经 shell),key 的取值顺序:
6
6
  * plugins.json 条目树里的 `apiKey`(明文,图省事)→ `apiKeyEnv` 指向的环境变量。
7
- * 没配 key 时调用会得到一句「去设置 → 网页搜索配置」的报错,模型能转述给用户。
7
+ * 没配 key 时调用会得到一句「去插件中心 → 联网搜索」的报错,模型能转述给用户。
8
8
  *
9
9
  * 风险等级 read:只查不写,只读权限模式下也能用。
10
10
  *