@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,347 @@
1
+ /**
2
+ * 一次调用「要干什么」的中文一句话——审批卡标题下面那行字。
3
+ *
4
+ * 为什么不在界面上现拼:卡上有两类调用,命令类给一段命令行原文,写类给一个路径。
5
+ * 命令原文是给读得懂命令行的人看的;多数人只想知道「它要删我哪个目录」。
6
+ *
7
+ * 这张表是**确定性**的:同一句命令永远得到同一个说法,不调模型、不联网、不加延迟。
8
+ * 认不出来的就直说「运行 xxx 命令」,不猜——用户是拿这句话决定点不点「允许」的,
9
+ * 猜错比不说更糟。
10
+ *
11
+ * 只做「够判断」的解读,不做完整 shell 解析:切段与词元化直接借
12
+ * `core/command-policy` 那一份(与判定危险命令用的是同一套切法),
13
+ * 免得两处对「一段命令」的理解慢慢分叉。
14
+ *
15
+ * @module dsc/core/call-meaning
16
+ */
17
+ import { splitSegments } from './command-policy.js';
18
+ /** 程序名 → 中文动作。键一律小写:去目录前缀、去 `.exe` 之后再查。 */
19
+ const PROGRAM_VERBS = {
20
+ // 文件与目录
21
+ rm: '删除',
22
+ del: '删除',
23
+ erase: '删除',
24
+ 'remove-item': '删除',
25
+ ri: '删除',
26
+ rd: '删除目录',
27
+ rmdir: '删除目录',
28
+ mkdir: '新建目录',
29
+ md: '新建目录',
30
+ 'new-item': '新建',
31
+ ni: '新建',
32
+ touch: '新建空文件',
33
+ cp: '复制',
34
+ copy: '复制',
35
+ 'copy-item': '复制',
36
+ cpi: '复制',
37
+ xcopy: '复制',
38
+ robocopy: '同步目录',
39
+ mv: '移动',
40
+ move: '移动',
41
+ 'move-item': '移动',
42
+ mi: '移动',
43
+ ren: '改名',
44
+ rename: '改名',
45
+ 'rename-item': '改名',
46
+ rn: '改名',
47
+ 'get-content': '读文件内容',
48
+ gc: '读文件内容',
49
+ cat: '读文件内容',
50
+ type: '读文件内容',
51
+ head: '读文件开头几行',
52
+ tail: '读文件结尾几行',
53
+ 'set-content': '写文件内容',
54
+ sc: '写文件内容',
55
+ 'out-file': '写文件内容',
56
+ 'add-content': '往文件追加内容',
57
+ 'clear-content': '清空文件内容',
58
+ 'select-string': '在文件里搜文本',
59
+ sls: '在文件里搜文本',
60
+ grep: '在文件里搜文本',
61
+ findstr: '在文件里搜文本',
62
+ 'get-childitem': '列目录',
63
+ gci: '列目录',
64
+ ls: '列目录',
65
+ dir: '列目录',
66
+ tree: '列出目录树',
67
+ 'set-location': '切换目录',
68
+ cd: '切换目录',
69
+ pushd: '切换目录',
70
+ pwd: '显示当前目录',
71
+ // 网络
72
+ curl: '发网络请求',
73
+ wget: '下载文件',
74
+ 'invoke-webrequest': '发网络请求',
75
+ 'invoke-restmethod': '调接口',
76
+ ssh: '连远程主机',
77
+ scp: '在主机间拷文件',
78
+ // 运行环境与构建
79
+ node: '跑 Node 脚本',
80
+ tsx: '跑 TypeScript 脚本',
81
+ deno: '跑 Deno 脚本',
82
+ bun: '跑 Bun 脚本',
83
+ python: '跑 Python 脚本',
84
+ python3: '跑 Python 脚本',
85
+ py: '跑 Python 脚本',
86
+ npx: '临时装一个包再跑它',
87
+ pip: '装 Python 包',
88
+ pip3: '装 Python 包',
89
+ uv: '装 Python 包',
90
+ tsc: '做类型检查',
91
+ eslint: '检查代码风格',
92
+ prettier: '格式化代码',
93
+ cargo: '跑 Rust 构建',
94
+ go: '跑 Go 构建',
95
+ make: '按 Makefile 构建',
96
+ msbuild: '构建 .NET 项目',
97
+ dotnet: '跑 .NET 命令',
98
+ // 进程与系统
99
+ taskkill: '结束进程',
100
+ 'stop-process': '结束进程',
101
+ 'start-process': '启动程序',
102
+ chmod: '改文件权限',
103
+ chown: '改文件所有者',
104
+ attrib: '改文件属性',
105
+ icacls: '改文件访问权限',
106
+ 'get-process': '列进程',
107
+ ps: '列进程',
108
+ 'get-service': '查服务状态',
109
+ // 压缩
110
+ tar: '打包或解包',
111
+ zip: '压缩',
112
+ unzip: '解压',
113
+ '7z': '压缩或解压',
114
+ 'compress-archive': '压缩',
115
+ 'expand-archive': '解压',
116
+ // 容器与集群
117
+ docker: '操作容器',
118
+ kubectl: '操作 Kubernetes 集群',
119
+ // 输出与杂项
120
+ echo: '输出一行文字',
121
+ 'write-output': '输出文字',
122
+ 'write-host': '输出文字',
123
+ sleep: '等待一会',
124
+ 'start-sleep': '等待一会',
125
+ 'test-path': '判断文件是否存在',
126
+ 'set-environmentvariable': '改环境变量',
127
+ // 再开一层解释器:真正干活的是它后面那段脚本
128
+ pwsh: '用 PowerShell 跑一段脚本',
129
+ powershell: '用 PowerShell 跑一段脚本',
130
+ cmd: '用 cmd 跑一段脚本',
131
+ bash: '用 bash 跑一段脚本',
132
+ sh: '用 sh 跑一段脚本',
133
+ };
134
+ /** 带目标的 git 子命令:只有它们后面那个词元值得写进卡片。 */
135
+ const GIT_TARGET_SUBS = new Set([
136
+ 'add',
137
+ 'checkout',
138
+ 'switch',
139
+ 'restore',
140
+ 'show',
141
+ 'blame',
142
+ 'diff',
143
+ 'rm',
144
+ 'clean',
145
+ 'log',
146
+ 'clone',
147
+ 'worktree',
148
+ ]);
149
+ /** 一次复制 / 移动的两个端点都要说(只报源不说去向,等于什么也没说)。 */
150
+ const TWO_END_VERBS = new Set(['复制', '移动']);
151
+ /** `python -m module`:跑的是模块,不是文件。 */
152
+ const PYTHON_HEADS = new Set(['python', 'python3', 'py']);
153
+ /** `git` 子命令 → 中文。表里没有的退回「用 Git 做版本控制」。 */
154
+ const GIT_VERBS = {
155
+ status: '看 Git 状态',
156
+ diff: '看 Git 改动',
157
+ log: '看提交历史',
158
+ add: '暂存改动',
159
+ commit: '提交改动',
160
+ push: '推送提交',
161
+ pull: '拉取远端改动',
162
+ fetch: '取远端更新',
163
+ clone: '克隆仓库',
164
+ checkout: '切换分支或文件',
165
+ switch: '切换分支',
166
+ branch: '操作分支',
167
+ merge: '合并分支',
168
+ rebase: '变基',
169
+ reset: '回退提交',
170
+ revert: '撤销一次提交',
171
+ stash: '暂存还没提交的改动',
172
+ tag: '操作标签',
173
+ remote: '管理远端',
174
+ show: '查看某一处提交',
175
+ blame: '查每行是谁改的',
176
+ init: '初始化仓库',
177
+ restore: '恢复文件',
178
+ clean: '删掉未跟踪的文件',
179
+ worktree: '操作工作树',
180
+ };
181
+ /** 包管理器子命令(npm / pnpm / yarn 共用同一套说法)。 */
182
+ const PKG_VERBS = {
183
+ install: '装依赖',
184
+ i: '装依赖',
185
+ add: '加依赖',
186
+ ci: '按锁文件装依赖',
187
+ remove: '卸依赖',
188
+ rm: '卸依赖',
189
+ uninstall: '卸依赖',
190
+ update: '升级依赖',
191
+ upgrade: '升级依赖',
192
+ test: '跑测试',
193
+ build: '构建',
194
+ start: '启动项目',
195
+ };
196
+ /** 包装词:真正干活的是它们后面那个程序。 */
197
+ const WRAPPERS = new Set(['sudo', 'doas', 'nohup', 'env', 'command', 'time']);
198
+ /** 一句话最多多长(再长卡片就被撑成两行了)。 */
199
+ const MAX_LENGTH = 60;
200
+ /** 目标路径最长显示多长:超了只留最后两级。 */
201
+ const MAX_TARGET = 42;
202
+ /** 词元 → 程序名:去目录前缀、去 `.exe`、小写。 */
203
+ function programName(token) {
204
+ const base = token.split(/[\\/]/).pop() ?? token;
205
+ return base.toLowerCase().replace(/\.exe$/, '');
206
+ }
207
+ /** 一个词元是不是开关(`-Recurse`、`--force`、Windows 上的 `/f`)。 */
208
+ function isFlag(token) {
209
+ return token.startsWith('-') || /^\/[A-Za-z]{1,3}$/.test(token);
210
+ }
211
+ /** `NAME=value` 形式的环境变量赋值(`env FOO=bar cmd` 里那一截)。 */
212
+ function isAssignment(token) {
213
+ return /^[A-Za-z_][A-Za-z0-9_]*=/.test(token);
214
+ }
215
+ /**
216
+ * 路径缩短:只保留最后两级。
217
+ *
218
+ * 卡上的位置本来就窄,而「D:\dsc\src\plugins\approval.ts」和「…/plugins/approval.ts」
219
+ * 对判断「它要动什么」没有差别。完整路径在参数摘要的悬浮提示里。
220
+ */
221
+ function shortenTarget(value) {
222
+ // URL 不按斜杠切:`…/https:/example.com` 这种切法把协议弄没了,不如原样留着。
223
+ if (/^[a-z][a-z0-9+.-]*:\/\//i.test(value))
224
+ return value;
225
+ if (value.length <= MAX_TARGET)
226
+ return value;
227
+ const parts = value.split(/[\\/]/).filter((part) => part !== '');
228
+ if (parts.length <= 2)
229
+ return value;
230
+ return `…/${parts.slice(-2).join('/')}`;
231
+ }
232
+ /** 取第一个不像开关的操作数(`-Path x` 取到的是 `x`)。 */
233
+ function firstOperand(tokens) {
234
+ for (const token of tokens) {
235
+ if (token === '' || isFlag(token) || isAssignment(token))
236
+ continue;
237
+ return token;
238
+ }
239
+ return null;
240
+ }
241
+ /** 一段命令的中文说法。 */
242
+ function phraseOfSegment(segment) {
243
+ const tokens = segment.tokens;
244
+ let index = 0;
245
+ while (index < tokens.length && WRAPPERS.has(programName(tokens[index])))
246
+ index += 1;
247
+ while (index < tokens.length && isAssignment(tokens[index]))
248
+ index += 1;
249
+ const head = tokens[index];
250
+ if (head === undefined)
251
+ return '空命令';
252
+ const name = programName(head);
253
+ const rest = tokens.slice(index + 1);
254
+ if (name === 'git') {
255
+ const subIndex = rest.findIndex((token) => !isFlag(token));
256
+ const sub = subIndex < 0 ? undefined : rest[subIndex];
257
+ const phrase = sub === undefined ? '用 Git 做版本控制' : (GIT_VERBS[sub] ?? `执行 git ${sub}`);
258
+ // 只有「本来就对着一个路径/分支」的子命令才把操作数写上。
259
+ // `git commit -m "修一处标点"` 的操作数是提交信息,写进卡片只会误导。
260
+ const arg = sub === undefined || !GIT_TARGET_SUBS.has(sub) ? null : firstOperand(rest.slice(subIndex + 1));
261
+ return arg === null ? phrase : `${phrase} ${shortenTarget(arg)}`;
262
+ }
263
+ if (PYTHON_HEADS.has(name) && rest[0] === '-m') {
264
+ const module = rest[1];
265
+ return module === undefined ? '跑 Python 模块' : `跑 Python 模块 ${module}`;
266
+ }
267
+ if (name === 'npm' || name === 'pnpm' || name === 'yarn' || name === 'cnpm') {
268
+ const subIndex = rest.findIndex((token) => !isFlag(token));
269
+ const sub = subIndex < 0 ? undefined : rest[subIndex];
270
+ if (sub === undefined)
271
+ return `跑 ${name} 包管理命令`;
272
+ if (sub === 'run') {
273
+ const script = rest[subIndex + 1];
274
+ return script === undefined ? '跑项目里定义的脚本' : `跑脚本 ${script}`;
275
+ }
276
+ return `${name} ${PKG_VERBS[sub] ?? sub}`;
277
+ }
278
+ const verb = PROGRAM_VERBS[name];
279
+ if (verb === undefined)
280
+ return `运行 ${name} 命令`;
281
+ const operands = operandsOf(rest);
282
+ const first = operands[0];
283
+ if (first === undefined)
284
+ return verb;
285
+ if (TWO_END_VERBS.has(verb) && operands.length >= 2) {
286
+ return `${verb} ${shortenTarget(first)} → ${shortenTarget(operands[1])}`;
287
+ }
288
+ return `${verb} ${shortenTarget(first)}`;
289
+ }
290
+ /** 取所有不像开关的操作数(最多三个:再往后都是边角参数)。 */
291
+ function operandsOf(tokens) {
292
+ const out = [];
293
+ for (const token of tokens) {
294
+ if (token === '' || isFlag(token) || isAssignment(token))
295
+ continue;
296
+ out.push(token);
297
+ if (out.length >= 3)
298
+ break;
299
+ }
300
+ return out;
301
+ }
302
+ /**
303
+ * 一条命令的中文说法。
304
+ *
305
+ * @param command - 命令原文(可以是多行、带管道)
306
+ * @returns 一句中文(可能被截断);空命令给 null
307
+ */
308
+ export function commandMeaning(command) {
309
+ const segments = splitSegments(command).filter((segment) => segment.tokens.length > 0);
310
+ const first = segments[0];
311
+ if (first === undefined)
312
+ return null;
313
+ // 多段只细说第一段,其余报个数:管道里七八段的完整解读会变成一篇小作文,
314
+ // 而用户此刻要判断的是「这一下要不要点允许」。
315
+ const text = segments.length === 1 ? phraseOfSegment(first) : `${phraseOfSegment(first)}(共 ${segments.length} 段命令)`;
316
+ return text.length > MAX_LENGTH ? `${text.slice(0, MAX_LENGTH)}…` : text;
317
+ }
318
+ /** 工具名 → 中文动作(命令类工具走 {@link commandMeaning},不走这张表)。 */
319
+ const TOOL_VERBS = {
320
+ write: '写文件',
321
+ edit: '改文件',
322
+ read: '读文件',
323
+ glob: '按名字找文件',
324
+ grep: '在文件里搜内容',
325
+ run_code: '跑一段脚本',
326
+ tool_call: '转调另一个工具',
327
+ bash: '跑 shell 命令',
328
+ pwsh: '跑 PowerShell 命令',
329
+ };
330
+ /**
331
+ * 一次工具调用的中文说法:命令类解读命令,写类说清动哪个文件。
332
+ *
333
+ * @param input.toolName - 工具真名
334
+ * @param input.command - 这次要跑的命令(命令类工具才有)
335
+ * @param input.target - 这次要动的绝对路径(写类工具才有)
336
+ * @returns 一句话;认不出来给 null(界面就不画那一行)
337
+ */
338
+ export function callMeaning(input) {
339
+ const command = input.command ?? null;
340
+ if (command !== null && command.trim() !== '')
341
+ return commandMeaning(command);
342
+ const verb = TOOL_VERBS[input.toolName];
343
+ if (verb === undefined)
344
+ return null;
345
+ const target = input.target ?? null;
346
+ return target === null || target === '' ? verb : `${verb} ${shortenTarget(target)}`;
347
+ }
@@ -26,6 +26,7 @@
26
26
  import { existsSync } from 'node:fs';
27
27
  import { isAbsolute, resolve } from 'node:path';
28
28
  import { refRecordMatches } from './snapshot.js';
29
+ import { readBlockReason } from '../path-policy.js';
29
30
  /** 鼠标键位掩码(dispatchMouseEvent 的 buttons 字段)。 */
30
31
  const BUTTON_MASK = { left: 1, right: 2, middle: 4 };
31
32
  /** 视口外的点先滚进可视区,再取坐标。 */
@@ -437,6 +438,11 @@ export async function uploadFiles(page, ref, paths, baseDir) {
437
438
  const full = isAbsolute(entry) ? entry : resolve(baseDir, entry);
438
439
  if (!existsSync(full))
439
440
  throw new Error(`要上传的文件不存在:${full}`);
441
+ // 上传等于把文件内容交给网页:与 read 工具同一份读禁,别让模型借浏览器把
442
+ // ~/.ssh/id_rsa、.env 这类文件送出去。审批卡仍会显示路径,但这一道不靠人眼兜底。
443
+ const blocked = readBlockReason(full);
444
+ if (blocked !== null)
445
+ throw new Error(`不能上传这个文件:${blocked}`);
440
446
  return full; // Windows 上用原生反斜杠路径,DOM.setFileInputFiles 就这么收
441
447
  });
442
448
  await verifyRef(page, ref);
@@ -190,8 +190,8 @@ export async function launchBrowser(config, signal, options = {}) {
190
190
  if (exe === null) {
191
191
  const configured = config.executablePath.trim();
192
192
  throw new Error(configured === ''
193
- ? '没找到 Chrome 或 Edge。请在设置「浏览器自动化」里把 executablePath 填成浏览器可执行文件的绝对路径'
194
- : `配置的浏览器路径不存在:${configured}(请在设置「浏览器自动化」里改掉)`);
193
+ ? '没找到 Chrome 或 Edge。请在「受控浏览器」设置里把 executablePath 填成浏览器可执行文件的绝对路径'
194
+ : `配置的浏览器路径不存在:${configured}(请在「受控浏览器」设置里改掉)`);
195
195
  }
196
196
  const ownedProfile = config.profileDir.trim() === '';
197
197
  const profileDir = ownedProfile ? mkdtempSync(join(tmpdir(), 'dsc-browser-')) : resolve(config.profileDir.trim());
@@ -0,0 +1,27 @@
1
+ import type { SnapshotRef } from './snapshot.js';
2
+ /** 一条控制台事件(含异常,异常压在 level='exception' 上)。 */
3
+ export interface ConsoleEntry {
4
+ ts: number;
5
+ level: string;
6
+ text: string;
7
+ }
8
+ /** 一条网络事件:请求发出时建条目,响应/失败时按 requestId 回填。 */
9
+ export interface NetworkEntry {
10
+ ts: number;
11
+ requestId: string;
12
+ method: string;
13
+ url: string;
14
+ status: number;
15
+ mimeType: string;
16
+ failed: string;
17
+ }
18
+ /** 一行人类可读摘要 + 一行结构化 JSON。 */
19
+ export declare function report(summary: string, data: Record<string, unknown>): string;
20
+ /** ref 的人类可读描述(输出与报错里用)。 */
21
+ export declare function describeRef(ref: SnapshotRef): string;
22
+ /** 变量值的兜底字符串化(控制台参数可能是对象或循环引用)。 */
23
+ export declare function safeStringify(value: unknown): string;
24
+ /** 控制台条目 → 一行 `[时间] 级别: 文本`(时间走 `core/clock.ts`,本地时间)。 */
25
+ export declare function consoleLine(entry: ConsoleEntry): string;
26
+ /** 网络条目 → 一行 `[时间] 方法 状态 mime 地址`(地址过 neutralizer 防注入)。 */
27
+ export declare function networkLine(entry: NetworkEntry): string;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * 浏览器两条链共用的输出口径与事件条目。
3
+ *
4
+ * 「两条链」指 `plugins/browser.ts` 那台一次性 Chrome 与 `plugins/dock-browser.ts` 那台
5
+ * 侧栏浏览器。两者的启动、生命周期、信任口径都不一样(见 `docs/dock-browser-control.md`),
6
+ * 所以是两个插件;但**模型读到的输出**必须一样——同一个错误在两处说成两种话,
7
+ * 模型就学不会。
8
+ *
9
+ * 这几个函数原先在两处逐字各写一份(`report` / `describeRef` / `safeStringify` / `clock`),
10
+ * 连注释都写着「照 browser.ts 的」——靠注释维持一致,迟早分叉。合到一处后:
11
+ * (时间戳另有一份 `core/clock.ts`:它原先在这里输出 UTC、而沙箱日志输出本地时间。)
12
+ * - 输出形状只有一份定义;
13
+ * - 控制台、网络两行渲染也只有一份,不会一边改了格式另一边没跟上。
14
+ *
15
+ * 只收**输出形状**,不收业务判断:URL 守卫、ref 代际校验、进程清理都留在各自插件里。
16
+ *
17
+ * @module dsc/core/cdp/report
18
+ */
19
+ import { clockText } from '../clock.js';
20
+ import { neutralizeInline } from '../untrusted.js';
21
+ /** 一行人类可读摘要 + 一行结构化 JSON。 */
22
+ export function report(summary, data) {
23
+ return `${summary}\n${JSON.stringify(data)}`;
24
+ }
25
+ /** ref 的人类可读描述(输出与报错里用)。 */
26
+ export function describeRef(ref) {
27
+ return `${ref.role}${ref.name === '' ? '' : ` "${ref.name}"`}`;
28
+ }
29
+ /** 变量值的兜底字符串化(控制台参数可能是对象或循环引用)。 */
30
+ export function safeStringify(value) {
31
+ if (typeof value === 'string')
32
+ return value;
33
+ try {
34
+ const text = JSON.stringify(value);
35
+ return text === undefined ? String(value) : text;
36
+ }
37
+ catch {
38
+ return String(value);
39
+ }
40
+ }
41
+ /** 控制台条目 → 一行 `[时间] 级别: 文本`(时间走 `core/clock.ts`,本地时间)。 */
42
+ export function consoleLine(entry) {
43
+ return `[${clockText(entry.ts)}] ${entry.level}: ${entry.text}`;
44
+ }
45
+ /** 网络条目 → 一行 `[时间] 方法 状态 mime 地址`(地址过 neutralizer 防注入)。 */
46
+ export function networkLine(entry) {
47
+ const status = entry.failed === '' ? String(entry.status === 0 ? '进行中' : entry.status) : `失败:${entry.failed}`;
48
+ const mime = entry.mimeType === '' ? '' : ` ${entry.mimeType}`;
49
+ return `[${clockText(entry.ts)}] ${entry.method} ${status}${mime} ${neutralizeInline(entry.url, 240)}`;
50
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * 定长环形缓冲:满了丢最旧的,条数上限变了就把内容搬过去。
3
+ *
4
+ * 用在浏览器的控制台与网络事件缓冲上——`plugins/browser.ts` 那台自管 Chrome 两个桶,
5
+ * `plugins/dock-browser.ts` 每台侧栏视图各两个桶。两处原先各抄了一份,抄的那份
6
+ * 少了 `resize`;这里按完整版留住:用户改个设置不该把已经攒下的现状丢光。
7
+ *
8
+ * 只放数据结构,不放「什么算一条事件」——那是 {@link module:dsc/core/cdp/report} 的事。
9
+ *
10
+ * @module dsc/core/cdp/ring-buffer
11
+ */
12
+ export declare class RingBuffer<T> {
13
+ private capacity;
14
+ private items;
15
+ constructor(capacity: number);
16
+ /** 当前条数。 */
17
+ get size(): number;
18
+ push(item: T): void;
19
+ /** 按条件找一条(网络条目要按 requestId 回填状态)。 */
20
+ find(predicate: (item: T) => boolean): T | undefined;
21
+ toArray(): T[];
22
+ clear(): void;
23
+ /** 容量变了:先换上限再截断,已经攒下的内容不会被清掉。 */
24
+ resize(capacity: number): void;
25
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * 定长环形缓冲:满了丢最旧的,条数上限变了就把内容搬过去。
3
+ *
4
+ * 用在浏览器的控制台与网络事件缓冲上——`plugins/browser.ts` 那台自管 Chrome 两个桶,
5
+ * `plugins/dock-browser.ts` 每台侧栏视图各两个桶。两处原先各抄了一份,抄的那份
6
+ * 少了 `resize`;这里按完整版留住:用户改个设置不该把已经攒下的现状丢光。
7
+ *
8
+ * 只放数据结构,不放「什么算一条事件」——那是 {@link module:dsc/core/cdp/report} 的事。
9
+ *
10
+ * @module dsc/core/cdp/ring-buffer
11
+ */
12
+ export class RingBuffer {
13
+ capacity;
14
+ items = [];
15
+ constructor(capacity) {
16
+ this.capacity = capacity;
17
+ }
18
+ /** 当前条数。 */
19
+ get size() {
20
+ return this.items.length;
21
+ }
22
+ push(item) {
23
+ this.items.push(item);
24
+ if (this.capacity > 0 && this.items.length > this.capacity) {
25
+ this.items.splice(0, this.items.length - this.capacity);
26
+ }
27
+ }
28
+ /** 按条件找一条(网络条目要按 requestId 回填状态)。 */
29
+ find(predicate) {
30
+ return this.items.find(predicate);
31
+ }
32
+ toArray() {
33
+ return [...this.items];
34
+ }
35
+ clear() {
36
+ this.items = [];
37
+ }
38
+ /** 容量变了:先换上限再截断,已经攒下的内容不会被清掉。 */
39
+ resize(capacity) {
40
+ this.capacity = capacity;
41
+ if (capacity > 0 && this.items.length > capacity)
42
+ this.items.splice(0, this.items.length - capacity);
43
+ }
44
+ }
@@ -18,6 +18,7 @@
18
18
  *
19
19
  * @module dsc/core/cdp/snapshot
20
20
  */
21
+ import { oneLine } from '../strings.js';
21
22
  /**
22
23
  * 可交互角色白名单(小写比较)。
23
24
  * 这些角色要么能点(button/link/menuitem/tab)、要么能填(textbox/combobox/checkbox/…)、
@@ -69,21 +70,16 @@ function roleLabel(node) {
69
70
  const value = axValue(node.role);
70
71
  return typeof value === 'string' ? value : 'unknown';
71
72
  }
72
- /** 压成一行并截断(快照是一行一个元素,绝不能带换行)。 */
73
- function oneLine(text) {
74
- const flat = text.replace(/\s+/g, ' ').trim();
75
- return flat.length > MAX_INLINE_CHARS ? `${flat.slice(0, MAX_INLINE_CHARS)}…` : flat;
76
- }
77
73
  /** 节点的可访问名(浏览器算好的,直接抄)。 */
78
74
  function nameOf(node) {
79
75
  const value = axValue(node.name);
80
- return typeof value === 'string' ? oneLine(value) : '';
76
+ return typeof value === 'string' ? oneLine(value, MAX_INLINE_CHARS) : '';
81
77
  }
82
78
  /** 节点的当前值(输入框里填的内容)。 */
83
79
  function valueOf(node) {
84
80
  const value = axValue(node.value);
85
81
  if (typeof value === 'string')
86
- return oneLine(value);
82
+ return oneLine(value, MAX_INLINE_CHARS);
87
83
  if (typeof value === 'number' || typeof value === 'boolean')
88
84
  return String(value);
89
85
  return '';
@@ -226,7 +222,7 @@ function collectText(node, children, byId, depth) {
226
222
  if (TEXT_ROLES.has(role)) {
227
223
  const value = axValue(node.name) ?? axValue(node.value);
228
224
  if (typeof value === 'string' && value.trim() !== '')
229
- parts.push(oneLine(value));
225
+ parts.push(oneLine(value, MAX_INLINE_CHARS));
230
226
  }
231
227
  for (const child of children) {
232
228
  const childRole = roleOf(child);
@@ -237,7 +233,7 @@ function collectText(node, children, byId, depth) {
237
233
  if (nested !== '')
238
234
  parts.push(nested);
239
235
  }
240
- return oneLine(parts.join(' '));
236
+ return oneLine(parts.join(' '), MAX_INLINE_CHARS);
241
237
  }
242
238
  /**
243
239
  * 按行截断,**绝不切到元素中间**。
@@ -352,7 +352,7 @@ function builtinWebSocketFactory() {
352
352
  const globalSocket = globalThis.WebSocket;
353
353
  if (typeof globalSocket !== 'function') {
354
354
  return () => {
355
- throw new Error('当前 Node 没有内置 WebSocket(需要 Node ≥ 22.19);请升级 Node 后再用浏览器自动化');
355
+ throw new Error('当前 Node 没有内置 WebSocket(需要 Node ≥ 22.19);请升级 Node 后再用受控浏览器');
356
356
  };
357
357
  }
358
358
  return (url) => new globalSocket(url);
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 数字收敛(全仓库唯一一份)。
3
+ *
4
+ * 为什么单独放一个模块:这段「不是有限数就取缺省,是就四舍五入再夹进区间」的写法
5
+ * 此前在约二十处各抄一遍(各插件的 readConfig、core 的 hooks / spill / image-diet 等),
6
+ * 每处都得同步一遍区间语义。它不依赖任何模块,放 core 谁都能引。
7
+ *
8
+ * 区间以 `{ min, max }` 成对给出时用 {@link clampIntIn},免得调用点把 .min/.max 摊开。
9
+ *
10
+ * @module dsc/core/clamp
11
+ */
12
+ /** 不是有限数就返回缺省;是就四舍五入并夹进 [min, max]。 */
13
+ export declare function clampInt(value: unknown, min: number, max: number, fallback: number): number;
14
+ /** 有限数字才要(NaN、Infinity、非数字都不要);类型守卫版,用在解析外部 JSON 时。 */
15
+ export declare function isFiniteNumber(value: unknown): value is number;
16
+ /** 区间以 `{ min, max }` 成对给出时的写法。 */
17
+ export declare function clampIntIn(value: unknown, bounds: {
18
+ min: number;
19
+ max: number;
20
+ }, fallback: number): number;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 数字收敛(全仓库唯一一份)。
3
+ *
4
+ * 为什么单独放一个模块:这段「不是有限数就取缺省,是就四舍五入再夹进区间」的写法
5
+ * 此前在约二十处各抄一遍(各插件的 readConfig、core 的 hooks / spill / image-diet 等),
6
+ * 每处都得同步一遍区间语义。它不依赖任何模块,放 core 谁都能引。
7
+ *
8
+ * 区间以 `{ min, max }` 成对给出时用 {@link clampIntIn},免得调用点把 .min/.max 摊开。
9
+ *
10
+ * @module dsc/core/clamp
11
+ */
12
+ /** 不是有限数就返回缺省;是就四舍五入并夹进 [min, max]。 */
13
+ export function clampInt(value, min, max, fallback) {
14
+ const num = Number(value);
15
+ return Number.isFinite(num) ? Math.min(Math.max(Math.round(num), min), max) : fallback;
16
+ }
17
+ /** 有限数字才要(NaN、Infinity、非数字都不要);类型守卫版,用在解析外部 JSON 时。 */
18
+ export function isFiniteNumber(value) {
19
+ return typeof value === 'number' && Number.isFinite(value);
20
+ }
21
+ /** 区间以 `{ min, max }` 成对给出时的写法。 */
22
+ export function clampIntIn(value, bounds, fallback) {
23
+ return clampInt(value, bounds.min, bounds.max, fallback);
24
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * 时:分:秒(全仓库唯一一份)。
3
+ *
4
+ * 两处曾经各写一份:浏览器那条链的输出(`core/cdp/report.ts`)与沙箱的拒载日志
5
+ * (`plugins/sandbox.ts`)。两份不只看写法不同,**时区也不一样**——前者走
6
+ * `toISOString()`(UTC),后者取本地时分秒。于是同一个用户在同一个界面里会看到两套时间,
7
+ * 北京时间的用户会以为浏览器的时钟坏了。
8
+ *
9
+ * 现在统一成**本地时间**:日志是给人看的,人按自己墙上的钟读它。要 UTC 的地方
10
+ * (例如按天统计用量,`plugins/commands.ts` 取日期)本来就该走 `toISOString().slice(0, 10)`,
11
+ * 那是另一件事,不在这里。
12
+ *
13
+ * @module dsc/core/clock
14
+ */
15
+ /** 时间戳 → `HH:MM:SS`(本地时间,各段补零)。 */
16
+ export declare function clockText(ts: number): string;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * 时:分:秒(全仓库唯一一份)。
3
+ *
4
+ * 两处曾经各写一份:浏览器那条链的输出(`core/cdp/report.ts`)与沙箱的拒载日志
5
+ * (`plugins/sandbox.ts`)。两份不只看写法不同,**时区也不一样**——前者走
6
+ * `toISOString()`(UTC),后者取本地时分秒。于是同一个用户在同一个界面里会看到两套时间,
7
+ * 北京时间的用户会以为浏览器的时钟坏了。
8
+ *
9
+ * 现在统一成**本地时间**:日志是给人看的,人按自己墙上的钟读它。要 UTC 的地方
10
+ * (例如按天统计用量,`plugins/commands.ts` 取日期)本来就该走 `toISOString().slice(0, 10)`,
11
+ * 那是另一件事,不在这里。
12
+ *
13
+ * @module dsc/core/clock
14
+ */
15
+ /** 时间戳 → `HH:MM:SS`(本地时间,各段补零)。 */
16
+ export function clockText(ts) {
17
+ const date = new Date(ts);
18
+ const pad = (value) => String(value).padStart(2, '0');
19
+ return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
20
+ }