@waq666/pneuma 0.0.0-stage → 0.7.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 (708) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +206 -3
  3. package/bin/dsc.js +91 -0
  4. package/bin/headless.cjs +40 -0
  5. package/lib/adapter/core-runtime.d.ts +11 -0
  6. package/lib/adapter/core-runtime.js +259 -0
  7. package/lib/adapter/host.d.ts +18 -0
  8. package/lib/adapter/host.js +14 -0
  9. package/lib/adapter/runtime.d.ts +15 -0
  10. package/lib/adapter/runtime.js +290 -0
  11. package/lib/adapter/transcript.d.ts +184 -0
  12. package/lib/adapter/transcript.js +605 -0
  13. package/lib/app/AgentsOverlay.d.ts +18 -0
  14. package/lib/app/AgentsOverlay.js +63 -0
  15. package/lib/app/App.d.ts +15 -0
  16. package/lib/app/App.js +1650 -0
  17. package/lib/app/App.js.nv-backup +1650 -0
  18. package/lib/app/ApprovalCard.d.ts +12 -0
  19. package/lib/app/ApprovalCard.js +76 -0
  20. package/lib/app/AskCard.d.ts +20 -0
  21. package/lib/app/AskCard.js +45 -0
  22. package/lib/app/ChatView.d.ts +63 -0
  23. package/lib/app/ChatView.js +310 -0
  24. package/lib/app/Composer.d.ts +50 -0
  25. package/lib/app/Composer.js +282 -0
  26. package/lib/app/DiffBlock.d.ts +6 -0
  27. package/lib/app/DiffBlock.js +37 -0
  28. package/lib/app/MarkdownView.d.ts +6 -0
  29. package/lib/app/MarkdownView.js +99 -0
  30. package/lib/app/ModelPicker.d.ts +7 -0
  31. package/lib/app/ModelPicker.js +18 -0
  32. package/lib/app/PlanReviewCard.d.ts +13 -0
  33. package/lib/app/PlanReviewCard.js +54 -0
  34. package/lib/app/PresetPicker.d.ts +11 -0
  35. package/lib/app/PresetPicker.js +19 -0
  36. package/lib/app/PreviewOverlay.d.ts +14 -0
  37. package/lib/app/PreviewOverlay.js +22 -0
  38. package/lib/app/SessionPicker.d.ts +43 -0
  39. package/lib/app/SessionPicker.js +56 -0
  40. package/lib/app/SettingsOverlay.d.ts +32 -0
  41. package/lib/app/SettingsOverlay.js +157 -0
  42. package/lib/app/SkillsPicker.d.ts +7 -0
  43. package/lib/app/SkillsPicker.js +19 -0
  44. package/lib/app/StatusBar.d.ts +22 -0
  45. package/lib/app/StatusBar.js +201 -0
  46. package/lib/app/TaskStrips.d.ts +13 -0
  47. package/lib/app/TaskStrips.js +40 -0
  48. package/lib/app/TimelineRail.d.ts +22 -0
  49. package/lib/app/TimelineRail.js +160 -0
  50. package/lib/app/TimelineRail.js.negbak +98 -0
  51. package/lib/app/TimelineRail.js.nv-backup +160 -0
  52. package/lib/app/ToolCard.d.ts +11 -0
  53. package/lib/app/ToolCard.js +64 -0
  54. package/lib/app/ToolCard.js.nv-backup +64 -0
  55. package/lib/app/TranscriptOverlay.d.ts +27 -0
  56. package/lib/app/TranscriptOverlay.js +36 -0
  57. package/lib/app/TranscriptViewport.d.ts +78 -0
  58. package/lib/app/TranscriptViewport.js +218 -0
  59. package/lib/app/Welcome.d.ts +6 -0
  60. package/lib/app/Welcome.js +71 -0
  61. package/lib/app/attach.d.ts +16 -0
  62. package/lib/app/attach.js +58 -0
  63. package/lib/app/click.d.ts +40 -0
  64. package/lib/app/click.js +103 -0
  65. package/lib/app/clipboard-image.d.ts +11 -0
  66. package/lib/app/clipboard-image.js +66 -0
  67. package/lib/app/cursor.d.ts +4 -0
  68. package/lib/app/cursor.js +24 -0
  69. package/lib/app/hello.d.ts +11 -0
  70. package/lib/app/hello.js +8 -0
  71. package/lib/app/history-store.d.ts +4 -0
  72. package/lib/app/history-store.js +41 -0
  73. package/lib/app/image-blocks.d.ts +12 -0
  74. package/lib/app/image-blocks.js +125 -0
  75. package/lib/app/keymap.d.ts +56 -0
  76. package/lib/app/keymap.js +56 -0
  77. package/lib/app/markdown.d.ts +54 -0
  78. package/lib/app/markdown.js +189 -0
  79. package/lib/app/mouse.d.ts +33 -0
  80. package/lib/app/mouse.js +35 -0
  81. package/lib/app/pointer.d.ts +16 -0
  82. package/lib/app/pointer.js +60 -0
  83. package/lib/app/scroll-model.d.ts +240 -0
  84. package/lib/app/scroll-model.js +347 -0
  85. package/lib/app/settings-model.d.ts +69 -0
  86. package/lib/app/settings-model.js +114 -0
  87. package/lib/app/snapshot-subscribe.d.ts +34 -0
  88. package/lib/app/snapshot-subscribe.js +110 -0
  89. package/lib/app/theme.d.ts +194 -0
  90. package/lib/app/theme.js +186 -0
  91. package/lib/app/ticker.d.ts +7 -0
  92. package/lib/app/ticker.js +53 -0
  93. package/lib/boot.d.ts +1 -0
  94. package/lib/boot.js +34 -0
  95. package/lib/commands.d.ts +49 -0
  96. package/lib/commands.js +115 -0
  97. package/lib/contract.d.ts +1973 -0
  98. package/lib/contract.js +36 -0
  99. package/lib/core/agent-roles.d.ts +52 -0
  100. package/lib/core/agent-roles.js +274 -0
  101. package/lib/core/approval-floor.d.ts +183 -0
  102. package/lib/core/approval-floor.js +679 -0
  103. package/lib/core/approval.d.ts +42 -0
  104. package/lib/core/approval.js +8 -0
  105. package/lib/core/audit.d.ts +61 -0
  106. package/lib/core/audit.js +59 -0
  107. package/lib/core/boot-notices.d.ts +6 -0
  108. package/lib/core/boot-notices.js +61 -0
  109. package/lib/core/cdp/actions.d.ts +182 -0
  110. package/lib/core/cdp/actions.js +649 -0
  111. package/lib/core/cdp/launch.d.ts +192 -0
  112. package/lib/core/cdp/launch.js +491 -0
  113. package/lib/core/cdp/snapshot.d.ts +139 -0
  114. package/lib/core/cdp/snapshot.js +316 -0
  115. package/lib/core/cdp/transport.d.ts +160 -0
  116. package/lib/core/cdp/transport.js +359 -0
  117. package/lib/core/command-policy.d.ts +108 -0
  118. package/lib/core/command-policy.js +580 -0
  119. package/lib/core/commands-completion.d.ts +78 -0
  120. package/lib/core/commands-completion.js +167 -0
  121. package/lib/core/compact-anchors.d.ts +76 -0
  122. package/lib/core/compact-anchors.js +284 -0
  123. package/lib/core/compact.d.ts +110 -0
  124. package/lib/core/compact.js +210 -0
  125. package/lib/core/config-store.d.ts +38 -0
  126. package/lib/core/config-store.js +307 -0
  127. package/lib/core/config.d.ts +36 -0
  128. package/lib/core/config.js +124 -0
  129. package/lib/core/connection-test.d.ts +60 -0
  130. package/lib/core/connection-test.js +84 -0
  131. package/lib/core/desktop-control.d.ts +298 -0
  132. package/lib/core/desktop-control.js +1311 -0
  133. package/lib/core/diff-text.d.ts +74 -0
  134. package/lib/core/diff-text.js +257 -0
  135. package/lib/core/dock-browser.d.ts +137 -0
  136. package/lib/core/dock-browser.js +146 -0
  137. package/lib/core/dock-ops.d.ts +59 -0
  138. package/lib/core/dock-ops.js +104 -0
  139. package/lib/core/dock-session.d.ts +39 -0
  140. package/lib/core/dock-session.js +28 -0
  141. package/lib/core/dsh-compat/hook.d.ts +18 -0
  142. package/lib/core/dsh-compat/hook.js +52 -0
  143. package/lib/core/dsh-compat/resolve-hook.d.ts +5 -0
  144. package/lib/core/dsh-compat/resolve-hook.js +59 -0
  145. package/lib/core/dsh-compat/tools-facade.d.ts +47 -0
  146. package/lib/core/dsh-compat/tools-facade.js +108 -0
  147. package/lib/core/err-text.d.ts +13 -0
  148. package/lib/core/err-text.js +15 -0
  149. package/lib/core/events.d.ts +149 -0
  150. package/lib/core/events.js +1 -0
  151. package/lib/core/git-exec.d.ts +23 -0
  152. package/lib/core/git-exec.js +72 -0
  153. package/lib/core/git-info.d.ts +47 -0
  154. package/lib/core/git-info.js +157 -0
  155. package/lib/core/goal.d.ts +89 -0
  156. package/lib/core/goal.js +189 -0
  157. package/lib/core/hooks.d.ts +272 -0
  158. package/lib/core/hooks.js +818 -0
  159. package/lib/core/host-browser-link.d.ts +59 -0
  160. package/lib/core/host-browser-link.js +9 -0
  161. package/lib/core/host-methods.d.ts +25 -0
  162. package/lib/core/host-methods.js +103 -0
  163. package/lib/core/image-diet.d.ts +77 -0
  164. package/lib/core/image-diet.js +127 -0
  165. package/lib/core/learnings/ledger.d.ts +73 -0
  166. package/lib/core/learnings/ledger.js +273 -0
  167. package/lib/core/learnings/skill-write.d.ts +250 -0
  168. package/lib/core/learnings/skill-write.js +854 -0
  169. package/lib/core/learnings/store.d.ts +102 -0
  170. package/lib/core/learnings/store.js +266 -0
  171. package/lib/core/lifecycle-hooks.d.ts +189 -0
  172. package/lib/core/lifecycle-hooks.js +576 -0
  173. package/lib/core/llm.d.ts +283 -0
  174. package/lib/core/llm.js +565 -0
  175. package/lib/core/lockfile.d.ts +17 -0
  176. package/lib/core/lockfile.js +110 -0
  177. package/lib/core/loop.d.ts +185 -0
  178. package/lib/core/loop.js +587 -0
  179. package/lib/core/lsp/client.d.ts +189 -0
  180. package/lib/core/lsp/client.js +690 -0
  181. package/lib/core/lsp/framing.d.ts +84 -0
  182. package/lib/core/lsp/framing.js +181 -0
  183. package/lib/core/lsp/line-shift.d.ts +28 -0
  184. package/lib/core/lsp/line-shift.js +127 -0
  185. package/lib/core/lsp/manager.d.ts +93 -0
  186. package/lib/core/lsp/manager.js +418 -0
  187. package/lib/core/lsp/normalize.d.ts +32 -0
  188. package/lib/core/lsp/normalize.js +139 -0
  189. package/lib/core/lsp/servers.d.ts +106 -0
  190. package/lib/core/lsp/servers.js +352 -0
  191. package/lib/core/lsp/uri.d.ts +76 -0
  192. package/lib/core/lsp/uri.js +179 -0
  193. package/lib/core/market.d.ts +51 -0
  194. package/lib/core/market.js +358 -0
  195. package/lib/core/mcp.d.ts +201 -0
  196. package/lib/core/mcp.js +836 -0
  197. package/lib/core/memory-eval.d.ts +158 -0
  198. package/lib/core/memory-eval.js +215 -0
  199. package/lib/core/memory.d.ts +266 -0
  200. package/lib/core/memory.js +703 -0
  201. package/lib/core/mention.d.ts +57 -0
  202. package/lib/core/mention.js +129 -0
  203. package/lib/core/microcompact.d.ts +48 -0
  204. package/lib/core/microcompact.js +79 -0
  205. package/lib/core/migrate.d.ts +56 -0
  206. package/lib/core/migrate.js +134 -0
  207. package/lib/core/model-caps.d.ts +83 -0
  208. package/lib/core/model-caps.js +150 -0
  209. package/lib/core/model-discovery.d.ts +19 -0
  210. package/lib/core/model-discovery.js +69 -0
  211. package/lib/core/modes.d.ts +72 -0
  212. package/lib/core/modes.js +152 -0
  213. package/lib/core/native-bridge.d.ts +135 -0
  214. package/lib/core/native-bridge.js +563 -0
  215. package/lib/core/path-policy.d.ts +32 -0
  216. package/lib/core/path-policy.js +248 -0
  217. package/lib/core/permission-presets.d.ts +67 -0
  218. package/lib/core/permission-presets.js +75 -0
  219. package/lib/core/plugin-loader.d.ts +36 -0
  220. package/lib/core/plugin-loader.js +294 -0
  221. package/lib/core/plugin-registry.d.ts +113 -0
  222. package/lib/core/plugin-registry.js +256 -0
  223. package/lib/core/prefs.d.ts +82 -0
  224. package/lib/core/prefs.js +372 -0
  225. package/lib/core/presets.d.ts +80 -0
  226. package/lib/core/presets.js +373 -0
  227. package/lib/core/pricing.d.ts +90 -0
  228. package/lib/core/pricing.js +126 -0
  229. package/lib/core/prompt.d.ts +92 -0
  230. package/lib/core/prompt.js +339 -0
  231. package/lib/core/ptc.d.ts +66 -0
  232. package/lib/core/ptc.js +70 -0
  233. package/lib/core/remote/frames.d.ts +91 -0
  234. package/lib/core/remote/frames.js +174 -0
  235. package/lib/core/remote/notify.d.ts +54 -0
  236. package/lib/core/remote/notify.js +77 -0
  237. package/lib/core/remote/owner.d.ts +32 -0
  238. package/lib/core/remote/owner.js +75 -0
  239. package/lib/core/remote/pairing.d.ts +104 -0
  240. package/lib/core/remote/pairing.js +261 -0
  241. package/lib/core/remote/push.d.ts +80 -0
  242. package/lib/core/remote/push.js +222 -0
  243. package/lib/core/remote/store.d.ts +18 -0
  244. package/lib/core/remote/store.js +59 -0
  245. package/lib/core/remote/tickets.d.ts +20 -0
  246. package/lib/core/remote/tickets.js +49 -0
  247. package/lib/core/remote/uploads.d.ts +63 -0
  248. package/lib/core/remote/uploads.js +161 -0
  249. package/lib/core/request-attribution.d.ts +26 -0
  250. package/lib/core/request-attribution.js +86 -0
  251. package/lib/core/request-invariant.d.ts +61 -0
  252. package/lib/core/request-invariant.js +199 -0
  253. package/lib/core/sandbox/backends.d.ts +64 -0
  254. package/lib/core/sandbox/backends.js +194 -0
  255. package/lib/core/sandbox/execpolicy.d.ts +93 -0
  256. package/lib/core/sandbox/execpolicy.js +452 -0
  257. package/lib/core/sandbox/net-proxy.d.ts +31 -0
  258. package/lib/core/sandbox/net-proxy.js +162 -0
  259. package/lib/core/sandbox/policy.d.ts +211 -0
  260. package/lib/core/sandbox/policy.js +559 -0
  261. package/lib/core/sandbox/win/abi.d.ts +161 -0
  262. package/lib/core/sandbox/win/abi.js +169 -0
  263. package/lib/core/sandbox/win/account.d.ts +71 -0
  264. package/lib/core/sandbox/win/account.js +206 -0
  265. package/lib/core/sandbox/win/acl.d.ts +54 -0
  266. package/lib/core/sandbox/win/acl.js +339 -0
  267. package/lib/core/sandbox/win/backend.d.ts +61 -0
  268. package/lib/core/sandbox/win/backend.js +249 -0
  269. package/lib/core/sandbox/win/doctor.d.ts +24 -0
  270. package/lib/core/sandbox/win/doctor.js +272 -0
  271. package/lib/core/sandbox/win/ffi.d.ts +107 -0
  272. package/lib/core/sandbox/win/ffi.js +166 -0
  273. package/lib/core/sandbox/win/net-abi.d.ts +154 -0
  274. package/lib/core/sandbox/win/net-abi.js +316 -0
  275. package/lib/core/sandbox/win/runner-entry.d.ts +35 -0
  276. package/lib/core/sandbox/win/runner-entry.js +391 -0
  277. package/lib/core/sandbox/win/setup.d.ts +60 -0
  278. package/lib/core/sandbox/win/setup.js +986 -0
  279. package/lib/core/sandbox/win/token.d.ts +35 -0
  280. package/lib/core/sandbox/win/token.js +238 -0
  281. package/lib/core/sandbox/win/wfp.d.ts +41 -0
  282. package/lib/core/sandbox/win/wfp.js +200 -0
  283. package/lib/core/sandbox/win/workspace-sid.d.ts +9 -0
  284. package/lib/core/sandbox/win/workspace-sid.js +45 -0
  285. package/lib/core/schedule/rule.d.ts +184 -0
  286. package/lib/core/schedule/rule.js +745 -0
  287. package/lib/core/schedule/runner.d.ts +185 -0
  288. package/lib/core/schedule/runner.js +678 -0
  289. package/lib/core/schedule/store.d.ts +182 -0
  290. package/lib/core/schedule/store.js +455 -0
  291. package/lib/core/secrets.d.ts +41 -0
  292. package/lib/core/secrets.js +150 -0
  293. package/lib/core/session-export.d.ts +18 -0
  294. package/lib/core/session-export.js +73 -0
  295. package/lib/core/session-index.d.ts +159 -0
  296. package/lib/core/session-index.js +683 -0
  297. package/lib/core/session-meta.d.ts +41 -0
  298. package/lib/core/session-meta.js +97 -0
  299. package/lib/core/session.d.ts +356 -0
  300. package/lib/core/session.js +998 -0
  301. package/lib/core/skills.d.ts +60 -0
  302. package/lib/core/skills.js +171 -0
  303. package/lib/core/spill.d.ts +159 -0
  304. package/lib/core/spill.js +329 -0
  305. package/lib/core/surface-registry.d.ts +45 -0
  306. package/lib/core/surface-registry.js +67 -0
  307. package/lib/core/team-board.d.ts +95 -0
  308. package/lib/core/team-board.js +316 -0
  309. package/lib/core/throughput.d.ts +46 -0
  310. package/lib/core/throughput.js +40 -0
  311. package/lib/core/todo-reminder.d.ts +44 -0
  312. package/lib/core/todo-reminder.js +55 -0
  313. package/lib/core/todo.d.ts +81 -0
  314. package/lib/core/todo.js +222 -0
  315. package/lib/core/token-estimate.d.ts +55 -0
  316. package/lib/core/token-estimate.js +82 -0
  317. package/lib/core/tool-guards.d.ts +103 -0
  318. package/lib/core/tool-guards.js +77 -0
  319. package/lib/core/tool-search.d.ts +152 -0
  320. package/lib/core/tool-search.js +311 -0
  321. package/lib/core/tools/bash.d.ts +281 -0
  322. package/lib/core/tools/bash.js +871 -0
  323. package/lib/core/tools/command-runner.d.ts +84 -0
  324. package/lib/core/tools/command-runner.js +68 -0
  325. package/lib/core/tools/fs-tools.d.ts +23 -0
  326. package/lib/core/tools/fs-tools.js +247 -0
  327. package/lib/core/tools/index.d.ts +8 -0
  328. package/lib/core/tools/index.js +4 -0
  329. package/lib/core/tools/sandbox-args.d.ts +51 -0
  330. package/lib/core/tools/sandbox-args.js +90 -0
  331. package/lib/core/tools/search-tools.d.ts +3 -0
  332. package/lib/core/tools/search-tools.js +153 -0
  333. package/lib/core/tools.d.ts +96 -0
  334. package/lib/core/tools.js +53 -0
  335. package/lib/core/ui-boot-source.d.ts +71 -0
  336. package/lib/core/ui-boot-source.js +121 -0
  337. package/lib/core/ui-bundles.d.ts +249 -0
  338. package/lib/core/ui-bundles.js +830 -0
  339. package/lib/core/ui-combo.d.ts +49 -0
  340. package/lib/core/ui-combo.js +55 -0
  341. package/lib/core/ui-events.d.ts +81 -0
  342. package/lib/core/ui-events.js +364 -0
  343. package/lib/core/ui-hmr.d.ts +36 -0
  344. package/lib/core/ui-hmr.js +128 -0
  345. package/lib/core/ui-methods.d.ts +69 -0
  346. package/lib/core/ui-methods.js +341 -0
  347. package/lib/core/ui-route.d.ts +69 -0
  348. package/lib/core/ui-route.js +122 -0
  349. package/lib/core/ui-server.d.ts +75 -0
  350. package/lib/core/ui-server.js +369 -0
  351. package/lib/core/ui-trust.d.ts +47 -0
  352. package/lib/core/ui-trust.js +164 -0
  353. package/lib/core/untrusted.d.ts +30 -0
  354. package/lib/core/untrusted.js +48 -0
  355. package/lib/core/update-check.d.ts +81 -0
  356. package/lib/core/update-check.js +177 -0
  357. package/lib/core/usage-log.d.ts +82 -0
  358. package/lib/core/usage-log.js +306 -0
  359. package/lib/core/version.d.ts +1 -0
  360. package/lib/core/version.js +37 -0
  361. package/lib/core/web-http.d.ts +57 -0
  362. package/lib/core/web-http.js +137 -0
  363. package/lib/core/web-static.d.ts +31 -0
  364. package/lib/core/web-static.js +75 -0
  365. package/lib/headless.d.ts +1 -0
  366. package/lib/headless.js +31 -0
  367. package/lib/host/kernel.d.ts +33 -0
  368. package/lib/host/kernel.js +451 -0
  369. package/lib/index.d.ts +41 -0
  370. package/lib/index.js +35 -0
  371. package/lib/plugins/agent.d.ts +2 -0
  372. package/lib/plugins/agent.js +274 -0
  373. package/lib/plugins/approval-floor.d.ts +2 -0
  374. package/lib/plugins/approval-floor.js +223 -0
  375. package/lib/plugins/approval.d.ts +16 -0
  376. package/lib/plugins/approval.js +674 -0
  377. package/lib/plugins/ask.d.ts +2 -0
  378. package/lib/plugins/ask.js +245 -0
  379. package/lib/plugins/browser.d.ts +68 -0
  380. package/lib/plugins/browser.js +1341 -0
  381. package/lib/plugins/commands.d.ts +23 -0
  382. package/lib/plugins/commands.js +498 -0
  383. package/lib/plugins/compact.d.ts +21 -0
  384. package/lib/plugins/compact.js +274 -0
  385. package/lib/plugins/computer-use.d.ts +47 -0
  386. package/lib/plugins/computer-use.js +539 -0
  387. package/lib/plugins/desktop-dock.d.ts +2 -0
  388. package/lib/plugins/desktop-dock.js +626 -0
  389. package/lib/plugins/dock-browser.d.ts +34 -0
  390. package/lib/plugins/dock-browser.js +765 -0
  391. package/lib/plugins/dsh-compat.d.ts +25 -0
  392. package/lib/plugins/dsh-compat.js +37 -0
  393. package/lib/plugins/file-review.d.ts +108 -0
  394. package/lib/plugins/file-review.js +393 -0
  395. package/lib/plugins/git.d.ts +26 -0
  396. package/lib/plugins/git.js +132 -0
  397. package/lib/plugins/goal.d.ts +20 -0
  398. package/lib/plugins/goal.js +245 -0
  399. package/lib/plugins/guards.d.ts +14 -0
  400. package/lib/plugins/guards.js +18 -0
  401. package/lib/plugins/hooks.d.ts +19 -0
  402. package/lib/plugins/hooks.js +583 -0
  403. package/lib/plugins/host-stdio.d.ts +88 -0
  404. package/lib/plugins/host-stdio.js +317 -0
  405. package/lib/plugins/image-diet.d.ts +17 -0
  406. package/lib/plugins/image-diet.js +85 -0
  407. package/lib/plugins/lifecycle-hooks.d.ts +26 -0
  408. package/lib/plugins/lifecycle-hooks.js +338 -0
  409. package/lib/plugins/llm.d.ts +13 -0
  410. package/lib/plugins/llm.js +215 -0
  411. package/lib/plugins/lsp.d.ts +54 -0
  412. package/lib/plugins/lsp.js +608 -0
  413. package/lib/plugins/mcp.d.ts +16 -0
  414. package/lib/plugins/mcp.js +673 -0
  415. package/lib/plugins/memory.d.ts +17 -0
  416. package/lib/plugins/memory.js +858 -0
  417. package/lib/plugins/microcompact.d.ts +18 -0
  418. package/lib/plugins/microcompact.js +119 -0
  419. package/lib/plugins/mode.d.ts +18 -0
  420. package/lib/plugins/mode.js +115 -0
  421. package/lib/plugins/permission-presets.d.ts +18 -0
  422. package/lib/plugins/permission-presets.js +135 -0
  423. package/lib/plugins/plan.d.ts +2 -0
  424. package/lib/plugins/plan.js +192 -0
  425. package/lib/plugins/plugin-manager.d.ts +2 -0
  426. package/lib/plugins/plugin-manager.js +165 -0
  427. package/lib/plugins/presets.d.ts +2 -0
  428. package/lib/plugins/presets.js +182 -0
  429. package/lib/plugins/prompt.d.ts +2 -0
  430. package/lib/plugins/prompt.js +264 -0
  431. package/lib/plugins/ptc.d.ts +2 -0
  432. package/lib/plugins/ptc.js +272 -0
  433. package/lib/plugins/remote/http.d.ts +11 -0
  434. package/lib/plugins/remote/http.js +11 -0
  435. package/lib/plugins/remote/routes.d.ts +24 -0
  436. package/lib/plugins/remote/routes.js +384 -0
  437. package/lib/plugins/remote/types.d.ts +135 -0
  438. package/lib/plugins/remote/types.js +87 -0
  439. package/lib/plugins/remote.d.ts +17 -0
  440. package/lib/plugins/remote.js +1028 -0
  441. package/lib/plugins/runtime-api.d.ts +16 -0
  442. package/lib/plugins/runtime-api.js +99 -0
  443. package/lib/plugins/runtime.d.ts +10 -0
  444. package/lib/plugins/runtime.js +451 -0
  445. package/lib/plugins/sandbox.d.ts +2 -0
  446. package/lib/plugins/sandbox.js +761 -0
  447. package/lib/plugins/schedule.d.ts +26 -0
  448. package/lib/plugins/schedule.js +538 -0
  449. package/lib/plugins/self-improve.d.ts +61 -0
  450. package/lib/plugins/self-improve.js +953 -0
  451. package/lib/plugins/session-search.d.ts +16 -0
  452. package/lib/plugins/session-search.js +308 -0
  453. package/lib/plugins/session-title.d.ts +19 -0
  454. package/lib/plugins/session-title.js +109 -0
  455. package/lib/plugins/session.d.ts +7 -0
  456. package/lib/plugins/session.js +296 -0
  457. package/lib/plugins/settings.d.ts +3 -0
  458. package/lib/plugins/settings.js +705 -0
  459. package/lib/plugins/skills.d.ts +2 -0
  460. package/lib/plugins/skills.js +360 -0
  461. package/lib/plugins/spill.d.ts +16 -0
  462. package/lib/plugins/spill.js +200 -0
  463. package/lib/plugins/subagent.d.ts +2 -0
  464. package/lib/plugins/subagent.js +896 -0
  465. package/lib/plugins/surfaces.d.ts +11 -0
  466. package/lib/plugins/surfaces.js +20 -0
  467. package/lib/plugins/team.d.ts +16 -0
  468. package/lib/plugins/team.js +149 -0
  469. package/lib/plugins/todo.d.ts +19 -0
  470. package/lib/plugins/todo.js +188 -0
  471. package/lib/plugins/tool-search.d.ts +2 -0
  472. package/lib/plugins/tool-search.js +434 -0
  473. package/lib/plugins/tool-search.js.nv-backup +434 -0
  474. package/lib/plugins/tools-default.d.ts +12 -0
  475. package/lib/plugins/tools-default.js +275 -0
  476. package/lib/plugins/tools.d.ts +16 -0
  477. package/lib/plugins/tools.js +62 -0
  478. package/lib/plugins/transcript.d.ts +15 -0
  479. package/lib/plugins/transcript.js +311 -0
  480. package/lib/plugins/tui.d.ts +2 -0
  481. package/lib/plugins/tui.js +98 -0
  482. package/lib/plugins/waiting.d.ts +12 -0
  483. package/lib/plugins/waiting.js +34 -0
  484. package/lib/plugins/web-search.d.ts +14 -0
  485. package/lib/plugins/web-search.js +263 -0
  486. package/lib/plugins/webserver.d.ts +48 -0
  487. package/lib/plugins/webserver.js +228 -0
  488. package/lib/remote/assets/app-DAcUCOEn.js +14 -0
  489. package/lib/remote/assets/icon-192.png +0 -0
  490. package/lib/remote/assets/icon-512.png +0 -0
  491. package/lib/remote/assets/index.html +34 -0
  492. package/lib/remote/assets/manifest.json +27 -0
  493. package/lib/remote/assets/style-DIB6729x.css +1 -0
  494. package/lib/remote/assets/sw.js +66 -0
  495. package/lib/services/types.d.ts +1228 -0
  496. package/lib/services/types.js +1 -0
  497. package/lib/tools/config-cli.d.ts +1 -0
  498. package/lib/tools/config-cli.js +89 -0
  499. package/lib/ui/arrival.d.ts +72 -0
  500. package/lib/ui/arrival.js +105 -0
  501. package/lib/ui/assets/app-B70nVIKd.js +69 -0
  502. package/lib/ui/assets/chunk-2UxHyX5q.js +1 -0
  503. package/lib/ui/assets/chunk-B1dDrJ26.js +1 -0
  504. package/lib/ui/assets/chunk-B6aJPvgy.js +1 -0
  505. package/lib/ui/assets/chunk-BEwlwnbL.js +1 -0
  506. package/lib/ui/assets/chunk-BGcgwlCI.js +12 -0
  507. package/lib/ui/assets/chunk-BIGW1oBm.js +1 -0
  508. package/lib/ui/assets/chunk-BPQ3VLAy.js +1 -0
  509. package/lib/ui/assets/chunk-BRH0KZbk.js +141 -0
  510. package/lib/ui/assets/chunk-BX6H_ySx.js +1 -0
  511. package/lib/ui/assets/chunk-B_P3UbPa.js +1 -0
  512. package/lib/ui/assets/chunk-B_TYUkTI.js +1 -0
  513. package/lib/ui/assets/chunk-B_vNuMnf.js +1 -0
  514. package/lib/ui/assets/chunk-BajyYBss.js +10 -0
  515. package/lib/ui/assets/chunk-BdnUsdx6.js +1 -0
  516. package/lib/ui/assets/chunk-Buea-lGh.js +1 -0
  517. package/lib/ui/assets/chunk-C0PvZCCE.js +1 -0
  518. package/lib/ui/assets/chunk-C0m74zRD.js +1 -0
  519. package/lib/ui/assets/chunk-C27-OAKa.js +1 -0
  520. package/lib/ui/assets/chunk-C2oV4EkX.js +1 -0
  521. package/lib/ui/assets/chunk-C7zT0LnQ.js +1 -0
  522. package/lib/ui/assets/chunk-C9GSunVT.js +1 -0
  523. package/lib/ui/assets/chunk-C9tS-k6U.js +1 -0
  524. package/lib/ui/assets/chunk-CHLpvVh8.js +1 -0
  525. package/lib/ui/assets/chunk-CLxacb5B.js +1 -0
  526. package/lib/ui/assets/chunk-COt5Ahok.js +1 -0
  527. package/lib/ui/assets/chunk-CPTIWCL2.js +1 -0
  528. package/lib/ui/assets/chunk-CQLl-L-p.js +1 -0
  529. package/lib/ui/assets/chunk-CUWRgxuq.js +55 -0
  530. package/lib/ui/assets/chunk-CWanVSXC.js +1 -0
  531. package/lib/ui/assets/chunk-Cf5RLm7j.js +1 -0
  532. package/lib/ui/assets/chunk-CickPsom.js +1 -0
  533. package/lib/ui/assets/chunk-Cj5Yp3dK.js +1 -0
  534. package/lib/ui/assets/chunk-Cmh6b_Ma.js +1 -0
  535. package/lib/ui/assets/chunk-Cp-IABpG.js +1 -0
  536. package/lib/ui/assets/chunk-CqE71os6.js +1 -0
  537. package/lib/ui/assets/chunk-CtKP3W-j.js +1 -0
  538. package/lib/ui/assets/chunk-Cvjx9yec.js +1 -0
  539. package/lib/ui/assets/chunk-CxGP3dtY.js +1 -0
  540. package/lib/ui/assets/chunk-CylS5w8V.js +1 -0
  541. package/lib/ui/assets/chunk-D38fbIBN.js +1 -0
  542. package/lib/ui/assets/chunk-D97Zzqfu.js +1 -0
  543. package/lib/ui/assets/chunk-DAi9KRSo.js +1 -0
  544. package/lib/ui/assets/chunk-DHK4yRfg.js +1 -0
  545. package/lib/ui/assets/chunk-DJeabLx-.js +1 -0
  546. package/lib/ui/assets/chunk-DNRxmY5a.js +1 -0
  547. package/lib/ui/assets/chunk-DNSN1z5r.js +1 -0
  548. package/lib/ui/assets/chunk-DNasK_ZG.js +1 -0
  549. package/lib/ui/assets/chunk-DPvrY3IQ.js +1 -0
  550. package/lib/ui/assets/chunk-DXmwc3jG.js +1 -0
  551. package/lib/ui/assets/chunk-Dd0kTxKP.js +1 -0
  552. package/lib/ui/assets/chunk-De0Btta0.js +1 -0
  553. package/lib/ui/assets/chunk-Des-eS-w.js +1 -0
  554. package/lib/ui/assets/chunk-Df6bDoY_.js +1 -0
  555. package/lib/ui/assets/chunk-DijEV5ha.js +1 -0
  556. package/lib/ui/assets/chunk-DkvoVjww.js +1 -0
  557. package/lib/ui/assets/chunk-DlC-OlHO.js +1 -0
  558. package/lib/ui/assets/chunk-DnzrXTVv.js +1 -0
  559. package/lib/ui/assets/chunk-Dualf0xi.js +1 -0
  560. package/lib/ui/assets/chunk-EXT84bkm.js +1 -0
  561. package/lib/ui/assets/chunk-GwR3hkPK.js +1 -0
  562. package/lib/ui/assets/chunk-P80f7IUj.js +1 -0
  563. package/lib/ui/assets/chunk-VOosw3JB.js +1 -0
  564. package/lib/ui/assets/chunk-YQ4lDkt_.js +140 -0
  565. package/lib/ui/assets/chunk-Yzrsuije.js +1 -0
  566. package/lib/ui/assets/chunk-Z72CF80r.js +1 -0
  567. package/lib/ui/assets/chunk-g9-lgVsj.js +1 -0
  568. package/lib/ui/assets/chunk-vGWfd6FD.js +1 -0
  569. package/lib/ui/assets/chunk-wDzz0qaB.js +1 -0
  570. package/lib/ui/assets/chunk-ySF7HWmS.js +1 -0
  571. package/lib/ui/assets/icon.png +0 -0
  572. package/lib/ui/assets/index.html +14 -0
  573. package/lib/ui/assets/pdf.worker.min-CjEcRF4W.mjs +28 -0
  574. package/lib/ui/assets/style-Bq01xH_b.css +1 -0
  575. package/lib/ui/frames.d.ts +67 -0
  576. package/lib/ui/frames.js +146 -0
  577. package/lib/ui/index.d.ts +59 -0
  578. package/lib/ui/index.js +50 -0
  579. package/lib/ui/manifest.d.ts +172 -0
  580. package/lib/ui/manifest.js +158 -0
  581. package/lib/ui/plugin.d.ts +161 -0
  582. package/lib/ui/plugin.js +7 -0
  583. package/lib/ui/plugins/browser/client.js +290 -0
  584. package/lib/ui/plugins/browser/icon.png +0 -0
  585. package/lib/ui/plugins/composer/client.js +1843 -0
  586. package/lib/ui/plugins/composer/icon.png +0 -0
  587. package/lib/ui/plugins/files/client.js +646 -0
  588. package/lib/ui/plugins/files/icon.png +0 -0
  589. package/lib/ui/plugins/manifest.json +107 -0
  590. package/lib/ui/plugins/plugins/client.js +682 -0
  591. package/lib/ui/plugins/plugins/icon.png +0 -0
  592. package/lib/ui/plugins/preview/client.js +197 -0
  593. package/lib/ui/plugins/preview/icon.png +0 -0
  594. package/lib/ui/plugins/prompt/client.js +653 -0
  595. package/lib/ui/plugins/prompt/icon.png +0 -0
  596. package/lib/ui/plugins/sessions/client.js +1577 -0
  597. package/lib/ui/plugins/sessions/icon.png +0 -0
  598. package/lib/ui/plugins/settings/client.js +5470 -0
  599. package/lib/ui/plugins/settings/icon.png +0 -0
  600. package/lib/ui/plugins/skills/client.js +485 -0
  601. package/lib/ui/plugins/skills/icon.png +0 -0
  602. package/lib/ui/plugins/status/client.js +1420 -0
  603. package/lib/ui/plugins/status/icon.png +0 -0
  604. package/lib/ui/plugins/statusbar/client.js +504 -0
  605. package/lib/ui/plugins/statusbar/icon.png +0 -0
  606. package/lib/ui/plugins/tasks/client.js +52 -0
  607. package/lib/ui/plugins/tasks/icon.png +0 -0
  608. package/lib/ui/plugins/team/client.js +527 -0
  609. package/lib/ui/plugins/team/icon.png +0 -0
  610. package/lib/ui/plugins/terminal/client.js +232 -0
  611. package/lib/ui/plugins/terminal/icon.png +0 -0
  612. package/lib/ui/plugins/trace/client.js +1376 -0
  613. package/lib/ui/plugins/trace/icon.png +0 -0
  614. package/lib/ui/plugins/transcript/client.js +2661 -0
  615. package/lib/ui/plugins/transcript/icon.png +0 -0
  616. package/lib/ui/scoped-slots.d.ts +20 -0
  617. package/lib/ui/scoped-slots.js +21 -0
  618. package/lib/ui/sdk/@dsc/ui/index.d.ts +242 -0
  619. package/lib/ui/sdk/@dsc/ui/package.json +16 -0
  620. package/lib/ui/sdk/@dsc/ui-core/contract.d.ts +1973 -0
  621. package/lib/ui/sdk/@dsc/ui-core/core/diff-text.d.ts +74 -0
  622. package/lib/ui/sdk/@dsc/ui-core/core/dock-browser.d.ts +137 -0
  623. package/lib/ui/sdk/@dsc/ui-core/core/dock-ops.d.ts +59 -0
  624. package/lib/ui/sdk/@dsc/ui-core/core/model-caps.d.ts +83 -0
  625. package/lib/ui/sdk/@dsc/ui-core/core/native-bridge.d.ts +135 -0
  626. package/lib/ui/sdk/@dsc/ui-core/core/token-estimate.d.ts +55 -0
  627. package/lib/ui/sdk/@dsc/ui-core/package.json +16 -0
  628. package/lib/ui/sdk/@dsc/ui-core/ui/arrival.d.ts +72 -0
  629. package/lib/ui/sdk/@dsc/ui-core/ui/frames.d.ts +67 -0
  630. package/lib/ui/sdk/@dsc/ui-core/ui/index.d.ts +59 -0
  631. package/lib/ui/sdk/@dsc/ui-core/ui/manifest.d.ts +172 -0
  632. package/lib/ui/sdk/@dsc/ui-core/ui/plugin.d.ts +161 -0
  633. package/lib/ui/sdk/@dsc/ui-core/ui/scoped-slots.d.ts +20 -0
  634. package/lib/ui/sdk/@dsc/ui-core/ui/services-react.d.ts +27 -0
  635. package/lib/ui/sdk/@dsc/ui-core/ui/services.d.ts +63 -0
  636. package/lib/ui/sdk/@dsc/ui-core/ui/slots-react.d.ts +28 -0
  637. package/lib/ui/sdk/@dsc/ui-core/ui/slots.d.ts +481 -0
  638. package/lib/ui/sdk/@dsc/ui-core/ui/store.d.ts +89 -0
  639. package/lib/ui/sdk/@dsc/ui-dockkit/dock-model.d.ts +238 -0
  640. package/lib/ui/sdk/@dsc/ui-dockkit/dock-state.d.ts +163 -0
  641. package/lib/ui/sdk/@dsc/ui-dockkit/dock.d.ts +24 -0
  642. package/lib/ui/sdk/@dsc/ui-dockkit/index.d.ts +15 -0
  643. package/lib/ui/sdk/@dsc/ui-dockkit/package.json +16 -0
  644. package/lib/ui/sdk/@dsc/ui-layout/app.d.ts +74 -0
  645. package/lib/ui/sdk/@dsc/ui-layout/appearance.d.ts +70 -0
  646. package/lib/ui/sdk/@dsc/ui-layout/host-channel.d.ts +112 -0
  647. package/lib/ui/sdk/@dsc/ui-layout/index.d.ts +34 -0
  648. package/lib/ui/sdk/@dsc/ui-layout/package.json +16 -0
  649. package/lib/ui/sdk/@dsc/ui-layout/page-state.d.ts +14 -0
  650. package/lib/ui/sdk/@dsc/ui-layout/review-pane.d.ts +21 -0
  651. package/lib/ui/sdk/@dsc/ui-layout/runtime-context.d.ts +44 -0
  652. package/lib/ui/sdk/@dsc/ui-layout/thread-view.d.ts +28 -0
  653. package/lib/ui/sdk/@dsc/ui-layout/update-button.d.ts +21 -0
  654. package/lib/ui/sdk/@dsc/ui-primitives/code-file-icon-artwork.d.ts +53 -0
  655. package/lib/ui/sdk/@dsc/ui-primitives/code-view.d.ts +15 -0
  656. package/lib/ui/sdk/@dsc/ui-primitives/compat.d.ts +27 -0
  657. package/lib/ui/sdk/@dsc/ui-primitives/completion-sound.d.ts +24 -0
  658. package/lib/ui/sdk/@dsc/ui-primitives/confirm.d.ts +33 -0
  659. package/lib/ui/sdk/@dsc/ui-primitives/css.d.ts +47 -0
  660. package/lib/ui/sdk/@dsc/ui-primitives/diff-rows.d.ts +20 -0
  661. package/lib/ui/sdk/@dsc/ui-primitives/file-icons.d.ts +38 -0
  662. package/lib/ui/sdk/@dsc/ui-primitives/file-type-classify.d.ts +66 -0
  663. package/lib/ui/sdk/@dsc/ui-primitives/file-type-icon.d.ts +57 -0
  664. package/lib/ui/sdk/@dsc/ui-primitives/highlight.d.ts +24 -0
  665. package/lib/ui/sdk/@dsc/ui-primitives/hover-delay.d.ts +17 -0
  666. package/lib/ui/sdk/@dsc/ui-primitives/icons.d.ts +109 -0
  667. package/lib/ui/sdk/@dsc/ui-primitives/index.d.ts +55 -0
  668. package/lib/ui/sdk/@dsc/ui-primitives/lang-table.d.ts +10 -0
  669. package/lib/ui/sdk/@dsc/ui-primitives/markdown.d.ts +20 -0
  670. package/lib/ui/sdk/@dsc/ui-primitives/native.d.ts +41 -0
  671. package/lib/ui/sdk/@dsc/ui-primitives/package.json +16 -0
  672. package/lib/ui/sdk/@dsc/ui-primitives/panels.d.ts +86 -0
  673. package/lib/ui/sdk/@dsc/ui-primitives/paths.d.ts +11 -0
  674. package/lib/ui/sdk/@dsc/ui-primitives/pdf-view.d.ts +13 -0
  675. package/lib/ui/sdk/@dsc/ui-primitives/plugin-text.d.ts +15 -0
  676. package/lib/ui/sdk/@dsc/ui-primitives/select.d.ts +35 -0
  677. package/lib/ui/sdk/@dsc/ui-primitives/table-view.d.ts +23 -0
  678. package/lib/ui/sdk/@dsc/ui-primitives/thread-resizer.d.ts +22 -0
  679. package/lib/ui/sdk/@dsc/ui-primitives/time.d.ts +33 -0
  680. package/lib/ui/sdk/@dsc/ui-primitives/toast.d.ts +16 -0
  681. package/lib/ui/sdk/@dsc/ui-primitives/tokens.d.ts +14 -0
  682. package/lib/ui/sdk/@dsc/ui-primitives/tool-args.d.ts +49 -0
  683. package/lib/ui/sdk/@dsc/ui-primitives/tool-summary.d.ts +64 -0
  684. package/lib/ui/sdk/@dsc/ui-renderer/boot.d.ts +121 -0
  685. package/lib/ui/sdk/@dsc/ui-renderer/hmr.d.ts +43 -0
  686. package/lib/ui/sdk/@dsc/ui-renderer/index.d.ts +20 -0
  687. package/lib/ui/sdk/@dsc/ui-renderer/package.json +16 -0
  688. package/lib/ui/sdk/@dsc/ui-slots/index.d.ts +19 -0
  689. package/lib/ui/sdk/@dsc/ui-slots/package.json +16 -0
  690. package/lib/ui/sdk/@dsc/ui-slots/slots-react.d.ts +48 -0
  691. package/lib/ui/sdk/@dsc/ui-slots/slots.d.ts +102 -0
  692. package/lib/ui/services-react.d.ts +27 -0
  693. package/lib/ui/services-react.js +32 -0
  694. package/lib/ui/services.d.ts +63 -0
  695. package/lib/ui/services.js +121 -0
  696. package/lib/ui/slots-ink.d.ts +26 -0
  697. package/lib/ui/slots-ink.js +78 -0
  698. package/lib/ui/slots-react.d.ts +28 -0
  699. package/lib/ui/slots-react.js +88 -0
  700. package/lib/ui/slots.d.ts +481 -0
  701. package/lib/ui/slots.js +550 -0
  702. package/lib/ui/store.d.ts +89 -0
  703. package/lib/ui/store.js +62 -0
  704. package/lib/ui/tui-plugin-api.d.ts +23 -0
  705. package/lib/ui/tui-plugin-api.js +23 -0
  706. package/lib/ui/tui-plugins.d.ts +47 -0
  707. package/lib/ui/tui-plugins.js +220 -0
  708. package/package.json +58 -6
@@ -0,0 +1,74 @@
1
+ /**
2
+ * 文本差异:把「改之前的行」与「改之后的行」算成标准 unified diff 的几段 hunk。
3
+ *
4
+ * 为什么自己写而不是引第三方包:这个仓库零额外运行时依赖(package.json 的 dependencies
5
+ * 只有 cordis / ink / react / koffi / yaml 五样),为了一个几十行的差异算法再拉一个包,
6
+ * 换来的是供应链上一个新的信任面与一份要跟着升的版本。算法本身是教科书写法。
7
+ *
8
+ * 为什么先削公共前后缀再上 LCS:DP 表的空间是 `(m+1) × (n+1)` 个格子。改一个 3000 行文件
9
+ * 里的一行、或在一个大文件末尾追加一段,公共前后缀一削,真正进表的往往只有几行,
10
+ * 于是「大文件小改动」这个最常见的场景根本不碰内存上限。只有中部就大改时才需要兜底:
11
+ * 超过 {@link MAX_DIFF_CELLS} 就退回「摘要 + 第一处分歧的位置」,宁可少给信息也不把宿主拖死。
12
+ *
13
+ * 为什么超长行要按字符切:minified 的 js、单行几万字的 json 会让一条 diff 就撑爆上下文。
14
+ * 截断处写清「已截断、原本多少字符」,用户和模型都知道那不是完整内容。
15
+ *
16
+ * @module dsc/core/diff-text
17
+ */
18
+ /** 单行超过这么多字符就切掉(切完在行尾写明原本多少字符)。 */
19
+ export declare const DIFF_LINE_CHAR_LIMIT = 400;
20
+ /**
21
+ * 差异矩阵的格子数上限。超过就走摘要兜底。
22
+ * 取 400 万格 ≈ 一张 2000×2000 的表:这个规模在毫秒级算完,内存也可控;
23
+ * 再往上(整篇重写一万行的文件)摘要其实比逐行 diff 更可读。
24
+ */
25
+ export declare const MAX_DIFF_CELLS = 4000000;
26
+ /** 一段 diff 行(` ` 上下文 / `-` 删 / `+` 增)及其新旧行号。 */
27
+ export interface DiffLine {
28
+ kind: 'context' | 'remove' | 'add';
29
+ text: string;
30
+ /** 这一行在旧文件里的行号;`add` 行为 null。 */
31
+ oldLine: number | null;
32
+ /** 这一行在新文件里的行号;`remove` 行为 null。 */
33
+ newLine: number | null;
34
+ }
35
+ /** 一段 hunk:`@@ -oldStart,oldCount +newStart,newCount @@` 加上它包含的行。 */
36
+ export interface DiffHunk {
37
+ oldStart: number;
38
+ oldCount: number;
39
+ newStart: number;
40
+ newCount: number;
41
+ lines: DiffLine[];
42
+ }
43
+ /** 一次 diff 的结果。`ok` 为 false 时给的是摘要(算不动或没有变化)。 */
44
+ export interface DiffResult {
45
+ /** true = 逐行 diff 算出来了(哪怕只有一段)。 */
46
+ ok: boolean;
47
+ hunks: DiffHunk[];
48
+ added: number;
49
+ removed: number;
50
+ /** ok=false / 内容相同时的中文说明(一行内说清原因)。 */
51
+ note?: string;
52
+ /** true = 新旧文本完全相同。 */
53
+ identical: boolean;
54
+ /** true = 因为超出 {@link MAX_DIFF_CELLS} 走了摘要兜底。 */
55
+ oversize: boolean;
56
+ }
57
+ /** 按 `\n` 切行;CRLF 的 `\r` 与 BOM 一并抹掉,免得每行都被判成「改过」。 */
58
+ export declare function splitLines(text: string): string[];
59
+ /**
60
+ * 算一次 diff。
61
+ *
62
+ * @param before - 改动前的完整文本。
63
+ * @param after - 改动后的完整文本。
64
+ * @param contextLines - 每个 hunk 前后各留几行上下文(0 = 只给改动的行)。
65
+ * @returns 逐行 diff;算不动或没有变化时给摘要。
66
+ */
67
+ export declare function diffLines(before: string, after: string, contextLines: number): DiffResult;
68
+ /** 把一段 hunk 铺成文本行(超长行在这里切,见 {@link clipLine})。 */
69
+ export declare function renderHunk(hunk: DiffHunk): string[];
70
+ /**
71
+ * 整份 diff 的文本(把所有 hunk 拼起来)。
72
+ * 只用来落日志或测试;给用户看的那份一律走 `plugins/file-review.ts` 的行数上限渲染。
73
+ */
74
+ export declare function renderDiff(result: DiffResult): string;
@@ -0,0 +1,257 @@
1
+ /**
2
+ * 文本差异:把「改之前的行」与「改之后的行」算成标准 unified diff 的几段 hunk。
3
+ *
4
+ * 为什么自己写而不是引第三方包:这个仓库零额外运行时依赖(package.json 的 dependencies
5
+ * 只有 cordis / ink / react / koffi / yaml 五样),为了一个几十行的差异算法再拉一个包,
6
+ * 换来的是供应链上一个新的信任面与一份要跟着升的版本。算法本身是教科书写法。
7
+ *
8
+ * 为什么先削公共前后缀再上 LCS:DP 表的空间是 `(m+1) × (n+1)` 个格子。改一个 3000 行文件
9
+ * 里的一行、或在一个大文件末尾追加一段,公共前后缀一削,真正进表的往往只有几行,
10
+ * 于是「大文件小改动」这个最常见的场景根本不碰内存上限。只有中部就大改时才需要兜底:
11
+ * 超过 {@link MAX_DIFF_CELLS} 就退回「摘要 + 第一处分歧的位置」,宁可少给信息也不把宿主拖死。
12
+ *
13
+ * 为什么超长行要按字符切:minified 的 js、单行几万字的 json 会让一条 diff 就撑爆上下文。
14
+ * 截断处写清「已截断、原本多少字符」,用户和模型都知道那不是完整内容。
15
+ *
16
+ * @module dsc/core/diff-text
17
+ */
18
+ /** 单行超过这么多字符就切掉(切完在行尾写明原本多少字符)。 */
19
+ export const DIFF_LINE_CHAR_LIMIT = 400;
20
+ /**
21
+ * 差异矩阵的格子数上限。超过就走摘要兜底。
22
+ * 取 400 万格 ≈ 一张 2000×2000 的表:这个规模在毫秒级算完,内存也可控;
23
+ * 再往上(整篇重写一万行的文件)摘要其实比逐行 diff 更可读。
24
+ */
25
+ export const MAX_DIFF_CELLS = 4_000_000;
26
+ /** 按 `\n` 切行;CRLF 的 `\r` 与 BOM 一并抹掉,免得每行都被判成「改过」。 */
27
+ export function splitLines(text) {
28
+ const body = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
29
+ if (body === '')
30
+ return [];
31
+ const normalized = body.endsWith('\n') ? body.slice(0, -1) : body;
32
+ return normalized.split('\n').map((line) => (line.endsWith('\r') ? line.slice(0, -1) : line));
33
+ }
34
+ /** 新旧文本的换行风格是否不同(改了行尾风格要说一句,不然「整篇看起来没变」)。 */
35
+ function newlineStyleChanged(before, after) {
36
+ const style = (text) => text === '' ? 'none' : text.includes('\r\n') ? 'crlf' : 'lf';
37
+ const left = style(before);
38
+ const right = style(after);
39
+ return left !== 'none' && right !== 'none' && left !== right;
40
+ }
41
+ /** 超长行切一刀,行尾写明原本多少字符(决策理由见模块注释)。 */
42
+ function clipLine(line) {
43
+ return line.length <= DIFF_LINE_CHAR_LIMIT
44
+ ? line
45
+ : `${line.slice(0, DIFF_LINE_CHAR_LIMIT)}…(本行原 ${String(line.length)} 字符,预览已截断)`;
46
+ }
47
+ /** 摘要兜底:说清「变了多少行」与「第一处不一样在第几行」。 */
48
+ function summarize(before, after, reason) {
49
+ let head = 0;
50
+ const shared = Math.min(before.length, after.length);
51
+ while (head < shared && before[head] === after[head])
52
+ head += 1;
53
+ let tail = 0;
54
+ while (tail < shared - head &&
55
+ before[before.length - 1 - tail] === after[after.length - 1 - tail]) {
56
+ tail += 1;
57
+ }
58
+ const removed = before.length - head - tail;
59
+ const added = after.length - head - tail;
60
+ const where = head < shared || removed > 0 ? `第 ${String(head + 1)} 行起` : '文件末尾';
61
+ return {
62
+ ok: false,
63
+ hunks: [],
64
+ added: Math.max(0, added),
65
+ removed: Math.max(0, removed),
66
+ note: `${reason};从${where}开始不一样:删 ${String(Math.max(0, removed))} 行、加 ${String(Math.max(0, added))} 行`,
67
+ identical: false,
68
+ oversize: true,
69
+ };
70
+ }
71
+ /**
72
+ * 算一次 diff。
73
+ *
74
+ * @param before - 改动前的完整文本。
75
+ * @param after - 改动后的完整文本。
76
+ * @param contextLines - 每个 hunk 前后各留几行上下文(0 = 只给改动的行)。
77
+ * @returns 逐行 diff;算不动或没有变化时给摘要。
78
+ */
79
+ export function diffLines(before, after, contextLines) {
80
+ const oldLines = splitLines(before);
81
+ const newLines = splitLines(after);
82
+ const context = Math.max(0, Math.min(Math.round(contextLines), 50));
83
+ if (before === after) {
84
+ return { ok: true, hunks: [], added: 0, removed: 0, identical: true, oversize: false };
85
+ }
86
+ const suffixNote = newlineStyleChanged(before, after) ? '(顺带改了换行风格:CRLF ↔ LF)' : '';
87
+ const shared = Math.min(oldLines.length, newLines.length);
88
+ let head = 0;
89
+ while (head < shared && oldLines[head] === newLines[head])
90
+ head += 1;
91
+ let tail = 0;
92
+ while (tail < shared - head &&
93
+ oldLines[oldLines.length - 1 - tail] === newLines[newLines.length - 1 - tail]) {
94
+ tail += 1;
95
+ }
96
+ const oldMiddle = oldLines.slice(head, oldLines.length - tail);
97
+ const newMiddle = newLines.slice(head, newLines.length - tail);
98
+ // 两侧中部任意一边为空 = 纯插入或纯删除,不必跑矩阵
99
+ const cells = (oldMiddle.length + 1) * (newMiddle.length + 1);
100
+ if (oldMiddle.length > 0 && newMiddle.length > 0 && cells > MAX_DIFF_CELLS) {
101
+ return summarize(oldLines, newLines, `改动区间过大(约 ${String(oldMiddle.length)} 行 vs ${String(newMiddle.length)} 行),只给摘要`);
102
+ }
103
+ const ops = lcsOps(oldMiddle, newMiddle);
104
+ /**
105
+ * 中部逐行结果。
106
+ * 注意下标:`oldMiddle`/`newMiddle` 是削掉公共前后缀之后的数组,
107
+ * 而 oldCursor/newCursor 走的是**文件里的行号**,两者差一个 head,
108
+ * 所以取文本要写 `oldMiddle[oldCursor - head]`,行号则是 `oldCursor + 1`(行号从 1 起)。
109
+ */
110
+ const middle = [];
111
+ let oldCursor = head;
112
+ let newCursor = head;
113
+ for (const op of ops) {
114
+ if (op === 'context') {
115
+ middle.push({ kind: 'context', text: oldMiddle[oldCursor - head] ?? '', oldLine: oldCursor + 1, newLine: newCursor + 1 });
116
+ oldCursor += 1;
117
+ newCursor += 1;
118
+ }
119
+ else if (op === 'remove') {
120
+ middle.push({ kind: 'remove', text: oldMiddle[oldCursor - head] ?? '', oldLine: oldCursor + 1, newLine: null });
121
+ oldCursor += 1;
122
+ }
123
+ else {
124
+ middle.push({ kind: 'add', text: newMiddle[newCursor - head] ?? '', oldLine: null, newLine: newCursor + 1 });
125
+ newCursor += 1;
126
+ }
127
+ }
128
+ /**
129
+ * 上下文行必须自己补回 rows 里:公共前后缀在 LCS 之前就被削掉了,
130
+ * 那几行压根不在 `middle` 里。少了它们,hunk 就只剩光秃秃的改动行
131
+ * (`@@ -2 +2 @@` 而不是 diff -u 的 `@@ -1,3 +1,3 @@`),
132
+ * 用户看不出改在哪个函数、哪一段里。
133
+ */
134
+ const rows = [
135
+ ...oldLines.slice(0, head).map((text, index) => ({
136
+ kind: 'context',
137
+ text,
138
+ oldLine: index + 1,
139
+ newLine: index + 1,
140
+ })),
141
+ ...middle,
142
+ ...oldLines.slice(oldLines.length - tail).map((text, index) => ({
143
+ kind: 'context',
144
+ text,
145
+ oldLine: oldLines.length - tail + index + 1,
146
+ newLine: newLines.length - tail + index + 1,
147
+ })),
148
+ ];
149
+ const hunks = groupHunks(rows, context);
150
+ const added = middle.reduce((sum, row) => sum + (row.kind === 'add' ? 1 : 0), 0);
151
+ const removed = middle.reduce((sum, row) => sum + (row.kind === 'remove' ? 1 : 0), 0);
152
+ const note = suffixNote === '' ? undefined : `${suffixNote}(逐行差异已忽略行尾风格)`;
153
+ return { ok: true, hunks, added, removed, identical: false, oversize: false, ...(note !== undefined ? { note } : {}) };
154
+ }
155
+ /**
156
+ * 只对「中部」求最长公共子序列,再回溯成操作序列。
157
+ * 删与插在同一位置时先删后插(与 `diff -u` 的写法一致,读起来是「这段被替换成那段」)。
158
+ */
159
+ function lcsOps(oldMiddle, newMiddle) {
160
+ const m = oldMiddle.length;
161
+ const n = newMiddle.length;
162
+ if (m === 0)
163
+ return new Array(n).fill('add');
164
+ if (n === 0)
165
+ return new Array(m).fill('remove');
166
+ // table[i][j] = oldMiddle[i..] 与 newMiddle[j..] 的最长公共子序列长度
167
+ const width = n + 1;
168
+ const table = new Int32Array((m + 1) * width);
169
+ for (let i = m - 1; i >= 0; i -= 1) {
170
+ for (let j = n - 1; j >= 0; j -= 1) {
171
+ table[i * width + j] =
172
+ oldMiddle[i] === newMiddle[j]
173
+ ? (table[(i + 1) * width + j + 1] ?? 0) + 1
174
+ : Math.max(table[(i + 1) * width + j] ?? 0, table[i * width + j + 1] ?? 0);
175
+ }
176
+ }
177
+ const ops = [];
178
+ let i = 0;
179
+ let j = 0;
180
+ while (i < m && j < n) {
181
+ if (oldMiddle[i] === newMiddle[j]) {
182
+ ops.push('context');
183
+ i += 1;
184
+ j += 1;
185
+ }
186
+ else if ((table[(i + 1) * width + j] ?? 0) >= (table[i * width + j + 1] ?? 0)) {
187
+ ops.push('remove');
188
+ i += 1;
189
+ }
190
+ else {
191
+ ops.push('add');
192
+ j += 1;
193
+ }
194
+ }
195
+ while (i < m) {
196
+ ops.push('remove');
197
+ i += 1;
198
+ }
199
+ while (j < n) {
200
+ ops.push('add');
201
+ j += 1;
202
+ }
203
+ return ops;
204
+ }
205
+ /**
206
+ * 把逐行结果切成 hunk:改动行连同前后各 {@link contextLines} 行算一段,
207
+ * 两段之间相隔不超过 `2 × context` 行就并成一段(跟 `diff -u` 的合并规则一样),
208
+ * 否则中间那段没改的内容就不重复贴出来了。
209
+ */
210
+ function groupHunks(rows, context) {
211
+ const changed = rows
212
+ .map((row, index) => (row.kind === 'context' ? -1 : index))
213
+ .filter((index) => index >= 0);
214
+ if (changed.length === 0)
215
+ return [];
216
+ const ranges = [];
217
+ for (const index of changed) {
218
+ const from = Math.max(0, index - context);
219
+ const to = Math.min(rows.length - 1, index + context);
220
+ const last = ranges[ranges.length - 1];
221
+ if (last !== undefined && from <= last.to + 1)
222
+ last.to = Math.max(last.to, to);
223
+ else
224
+ ranges.push({ from, to });
225
+ }
226
+ return ranges.map((range) => {
227
+ const slice = rows.slice(range.from, range.to + 1);
228
+ const first = slice[0];
229
+ // 起点行号:hunk 第一行有这一侧的行号就用它;没有(开头就是新增/删除行)就退到
230
+ // 「本该显示的上一行」,两侧都没有(空文件长出来的第一段)才落到 0
231
+ // —— 这样 @@ -0,0 @@ 只在真的从空文件新增时出现
232
+ return {
233
+ oldStart: first.oldLine ?? rows[range.from - 1]?.oldLine ?? 0,
234
+ oldCount: slice.reduce((sum, row) => sum + (row.kind === 'add' ? 0 : 1), 0),
235
+ newStart: first.newLine ?? rows[range.from - 1]?.newLine ?? 0,
236
+ newCount: slice.reduce((sum, row) => sum + (row.kind === 'remove' ? 0 : 1), 0),
237
+ lines: slice,
238
+ };
239
+ });
240
+ }
241
+ /** hunk 头 `@@ -1,3 +1,4 @@`(行数为 1 时省掉 `,1`,与 `diff -u` 的写法一致)。 */
242
+ function hunkHeader(hunk) {
243
+ const range = (start, count) => count === 1 ? `${String(start)}` : `${String(start)},${String(count)}`;
244
+ return `@@ -${range(hunk.oldStart, hunk.oldCount)} +${range(hunk.newStart, hunk.newCount)} @@`;
245
+ }
246
+ /** 把一段 hunk 铺成文本行(超长行在这里切,见 {@link clipLine})。 */
247
+ export function renderHunk(hunk) {
248
+ const body = hunk.lines.map((line) => `${line.kind === 'context' ? ' ' : line.kind === 'add' ? '+' : '-'}${clipLine(line.text)}`);
249
+ return [hunkHeader(hunk), ...body];
250
+ }
251
+ /**
252
+ * 整份 diff 的文本(把所有 hunk 拼起来)。
253
+ * 只用来落日志或测试;给用户看的那份一律走 `plugins/file-review.ts` 的行数上限渲染。
254
+ */
255
+ export function renderDiff(result) {
256
+ return result.hunks.flatMap((hunk) => renderHunk(hunk)).join('\n');
257
+ }
@@ -0,0 +1,137 @@
1
+ /**
2
+ * dock 浏览器控制的**契约纯模块**:宿主进程(agent 所在)与桌面壳主进程共用这一份。
3
+ *
4
+ * 为什么单独落一个模块:这两侧在两个进程、两套编译产物里(`src/**` → `lib/`,
5
+ * 桌面端 → `out/`),线上跑的是消息而不是函数调用。方法白名单、动作枚举、消息形状、
6
+ * 超时预算放在一处,两侧 import 同一个常量——加一条命令时不可能只改一边。
7
+ *
8
+ * **这一份不许 import electron,也不许 import 任何有副作用的东西**:宿主侧那个
9
+ * `node lib/headless.js` 的进程也要引用它,探针还要用类型擦除直读它。
10
+ *
11
+ * 信任模型(为什么白名单是硬性的):dock 视图跑在 `persist:dsc-browser` 这个**持久**
12
+ * 分区里,带着用户自己的登录态。裸 CDP 里能读 cookie、能 `Runtime.evaluate`、
13
+ * 能导航到 `file://`——所以桌面侧对每一条命令都做白名单校验,导航参数还要重过一遍
14
+ * 与壳相同的 http/https 闸门(见 {@link dockNavigateTarget})。
15
+ *
16
+ * @module dsc/core/dock-browser
17
+ */
18
+ /** 宿主协议版本(破坏性变更时递增)。两侧都从这里取,不再各写一份。 */
19
+ export declare const HOST_PROTOCOL_VERSION = 3;
20
+ /**
21
+ * 允许转发到 dock 视图的 CDP 方法。
22
+ *
23
+ * 收口原则:**只放 `src/core/cdp/` 那套动作与快照真正用得到的域**(Page / DOM /
24
+ * Accessibility / Runtime / Network / Input / Emulation)。故意不放的几类:
25
+ * - `Target.*` / `Browser.*`:那是浏览器级命令,会打到别的 target 上(dock 视图的
26
+ * debugger 本来就只作用于这一页,放开它们等于越出这台视图);
27
+ * - `Storage.*` / `Network.getAllCookies` 之类:直接读用户登录态;
28
+ * - `DOM.setFileInputFiles`:ZCode 的内嵌浏览器也明确不支持上传,这里不放。
29
+ */
30
+ export declare const DOCK_CDP_COMMANDS: readonly string[];
31
+ /** 命令白名单判定(桌面侧每条命令都过它;不在名单里直接拒,不做「尽量执行」)。 */
32
+ export declare function isAllowedDockCommand(method: string): boolean;
33
+ /**
34
+ * 允许推给宿主的 CDP 事件。
35
+ *
36
+ * 与命令白名单同一条收口逻辑:只放那套动作订阅的事件(控制台 / 异常 / 对话框 /
37
+ * 跳转 / 网络),`Target.*` 与渲染相关的高频事件一概不推。
38
+ * 事件是**推**的,跨进程成本按条算——宿主只在真的要看了才 `*.enable`,桌面侧也只
39
+ * 对已经挂上 debugger 的视图转发。
40
+ */
41
+ export declare const DOCK_CDP_EVENTS: readonly string[];
42
+ /** 事件白名单判定。 */
43
+ export declare function shouldForwardDockEvent(method: string): boolean;
44
+ /**
45
+ * 从一条命令里抽出「这条命令其实在导航到某个地址」那个地址,没有就返回 null。
46
+ *
47
+ * 为什么必须有这一步:壳那条 `browserNav` 走的是 `navigateDockBrowser`,只有 http/https
48
+ * 能进。而 `Page.navigate` 是**绕开那道闸门**的直通车——不在这儿补一刀,agent 就能
49
+ * 把用户那台带登录态的浏览器导到 `file://` 上去。桌面侧收到这两个方法时,
50
+ * 一律用这个函数的返回值再过一次 {@link isHttpUrl} 同款判定。
51
+ */
52
+ export declare function dockNavigateTarget(method: string, params: Record<string, unknown> | undefined): string | null;
53
+ /** 一台 dock 视图现在的样子(`views` 动作与 `browser-views` 的回执)。 */
54
+ export interface DockViewInfo {
55
+ /** 视图 id(壳那边就是页签 id;agent 自己开的那几张是 `agent-N`)。 */
56
+ id: string;
57
+ url: string;
58
+ title: string;
59
+ loading: boolean;
60
+ /** 现在挂在窗口上(= 侧栏展开且这张页签是激活的那张)。藏起来的视图截不了图。 */
61
+ visible: boolean;
62
+ }
63
+ /** 一条命令的默认超时:跨进程 + 可能等页面,给得比 CDP 那层(20s)宽一点。 */
64
+ export declare const DOCK_CALL_TIMEOUT_MS = 25000;
65
+ /** 开一张页签(要等壳把页签建出来、把原生视图挂上)的超时。 */
66
+ export declare const DOCK_OPEN_TIMEOUT_MS = 8000;
67
+ /** `views`/`snapshot`/`screenshot`/`console`/`network`/`wait_for`:只看不动。 */
68
+ export declare const DOCK_LOOK_ACTIONS: readonly string[];
69
+ /** `open`/`navigate`/`click`/`hover`/`type`/`press`/`scroll`/`evaluate`/`close`:会改页面。 */
70
+ export declare const DOCK_ACTIONS: readonly string[];
71
+ /**
72
+ * agent 自己开的那几张页签的 id 前缀。
73
+ *
74
+ * 为什么要有前缀:`views` 会把用户自己开的页签一起列出来(那些是同一台持久分区,
75
+ * 地址栏里可能是他登录着的后台)。前缀让「这是 agent 开的」这件事在 id 上就看得出,
76
+ * 审批卡与工具输出里都能直接标出来。
77
+ */
78
+ export declare const DOCK_AGENT_VIEW_PREFIX = "agent-";
79
+ /** 这张视图是不是 agent 自己开的。 */
80
+ export declare function isAgentView(viewId: string): boolean;
81
+ /** runtime → host:宿主请桌面壳办事的四条请求(都带 id,等同一条应答)。 */
82
+ export type DockBrowserRequest =
83
+ /** 在某台视图上执行一条 CDP 命令(method 过 {@link isAllowedDockCommand})。 */
84
+ {
85
+ type: 'browser-call';
86
+ id: number;
87
+ viewId: string;
88
+ method: string;
89
+ params?: Record<string, unknown>;
90
+ }
91
+ /** 开一张浏览器页签(并聚焦它)——`viewId` 不给时由桌面侧发号 `agent-N`。 */
92
+ | {
93
+ type: 'browser-open';
94
+ id: number;
95
+ url: string;
96
+ viewId?: string;
97
+ }
98
+ /** 关掉一台(连带壳里那张页签一起关)。 */
99
+ | {
100
+ type: 'browser-close';
101
+ id: number;
102
+ viewId: string;
103
+ }
104
+ /** 列出现在活着的视图。 */
105
+ | {
106
+ type: 'browser-views';
107
+ id: number;
108
+ };
109
+ /** host → runtime:请求的应答(ok 为假时 error 是一句能给用户看的人话)。 */
110
+ export type DockBrowserReply = {
111
+ type: 'browser-result';
112
+ id: number;
113
+ ok: true;
114
+ value: unknown;
115
+ } | {
116
+ type: 'browser-result';
117
+ id: number;
118
+ ok: false;
119
+ error: string;
120
+ };
121
+ /** host → runtime:CDP 事件推送(只推 {@link DOCK_CDP_EVENTS} 里的)。 */
122
+ export interface DockBrowserEventPush {
123
+ type: 'browser-event';
124
+ viewId: string;
125
+ method: string;
126
+ params: Record<string, unknown>;
127
+ }
128
+ /**
129
+ * 请壳开一张浏览器页签并聚焦(`id` 由桌面侧指定,壳必须照用,否则宿主对不上号)。
130
+ *
131
+ * 为什么要绕渲染层:原生视图的矩形与页签的激活态都在壳里(`dockBrowser` 的 rect 由
132
+ * 组件量出来),桌面主进程不知道侧栏现在在哪儿。ZCode 同样是「建页签顺手把右侧栏
133
+ * 打开并激活」——我们这条走同一形状。
134
+ */
135
+ export declare const DOCK_TAB_OPEN_EVENT = "browser-tab-open-request";
136
+ /** 请壳关掉某张浏览器页签(`browser-close` 走它,免得留下一个点不开的空页签)。 */
137
+ export declare const DOCK_TAB_CLOSE_EVENT = "browser-tab-close-request";
@@ -0,0 +1,146 @@
1
+ /**
2
+ * dock 浏览器控制的**契约纯模块**:宿主进程(agent 所在)与桌面壳主进程共用这一份。
3
+ *
4
+ * 为什么单独落一个模块:这两侧在两个进程、两套编译产物里(`src/**` → `lib/`,
5
+ * 桌面端 → `out/`),线上跑的是消息而不是函数调用。方法白名单、动作枚举、消息形状、
6
+ * 超时预算放在一处,两侧 import 同一个常量——加一条命令时不可能只改一边。
7
+ *
8
+ * **这一份不许 import electron,也不许 import 任何有副作用的东西**:宿主侧那个
9
+ * `node lib/headless.js` 的进程也要引用它,探针还要用类型擦除直读它。
10
+ *
11
+ * 信任模型(为什么白名单是硬性的):dock 视图跑在 `persist:dsc-browser` 这个**持久**
12
+ * 分区里,带着用户自己的登录态。裸 CDP 里能读 cookie、能 `Runtime.evaluate`、
13
+ * 能导航到 `file://`——所以桌面侧对每一条命令都做白名单校验,导航参数还要重过一遍
14
+ * 与壳相同的 http/https 闸门(见 {@link dockNavigateTarget})。
15
+ *
16
+ * @module dsc/core/dock-browser
17
+ */
18
+ /** 宿主协议版本(破坏性变更时递增)。两侧都从这里取,不再各写一份。 */
19
+ export const HOST_PROTOCOL_VERSION = 3;
20
+ /**
21
+ * 允许转发到 dock 视图的 CDP 方法。
22
+ *
23
+ * 收口原则:**只放 `src/core/cdp/` 那套动作与快照真正用得到的域**(Page / DOM /
24
+ * Accessibility / Runtime / Network / Input / Emulation)。故意不放的几类:
25
+ * - `Target.*` / `Browser.*`:那是浏览器级命令,会打到别的 target 上(dock 视图的
26
+ * debugger 本来就只作用于这一页,放开它们等于越出这台视图);
27
+ * - `Storage.*` / `Network.getAllCookies` 之类:直接读用户登录态;
28
+ * - `DOM.setFileInputFiles`:ZCode 的内嵌浏览器也明确不支持上传,这里不放。
29
+ */
30
+ export const DOCK_CDP_COMMANDS = [
31
+ 'Page.enable',
32
+ 'Page.navigate',
33
+ 'Page.reload',
34
+ 'Page.captureScreenshot',
35
+ 'Page.getLayoutMetrics',
36
+ 'Page.getFrameTree',
37
+ 'Page.handleJavaScriptDialog',
38
+ 'DOM.enable',
39
+ 'DOM.getDocument',
40
+ 'DOM.describeNode',
41
+ 'DOM.resolveNode',
42
+ 'DOM.getBoxModel',
43
+ 'DOM.scrollIntoViewIfNeeded',
44
+ 'DOM.focus',
45
+ 'Accessibility.enable',
46
+ 'Accessibility.getFullAXTree',
47
+ 'Accessibility.getPartialAXTree',
48
+ 'Runtime.enable',
49
+ 'Runtime.evaluate',
50
+ 'Runtime.callFunctionOn',
51
+ 'Network.enable',
52
+ 'Input.dispatchMouseEvent',
53
+ 'Input.dispatchKeyEvent',
54
+ 'Input.insertText',
55
+ 'Emulation.setDeviceMetricsOverride',
56
+ 'Emulation.clearDeviceMetricsOverride',
57
+ ];
58
+ /** 命令白名单判定(桌面侧每条命令都过它;不在名单里直接拒,不做「尽量执行」)。 */
59
+ export function isAllowedDockCommand(method) {
60
+ return DOCK_CDP_COMMANDS.includes(method);
61
+ }
62
+ /**
63
+ * 允许推给宿主的 CDP 事件。
64
+ *
65
+ * 与命令白名单同一条收口逻辑:只放那套动作订阅的事件(控制台 / 异常 / 对话框 /
66
+ * 跳转 / 网络),`Target.*` 与渲染相关的高频事件一概不推。
67
+ * 事件是**推**的,跨进程成本按条算——宿主只在真的要看了才 `*.enable`,桌面侧也只
68
+ * 对已经挂上 debugger 的视图转发。
69
+ */
70
+ export const DOCK_CDP_EVENTS = [
71
+ 'Page.frameNavigated',
72
+ 'Page.javascriptDialogOpening',
73
+ 'Page.javascriptDialogClosed',
74
+ 'Runtime.consoleAPICalled',
75
+ 'Runtime.exceptionThrown',
76
+ 'Runtime.executionContextsCleared',
77
+ 'Network.requestWillBeSent',
78
+ 'Network.responseReceived',
79
+ 'Network.loadingFailed',
80
+ ];
81
+ /** 事件白名单判定。 */
82
+ export function shouldForwardDockEvent(method) {
83
+ return DOCK_CDP_EVENTS.includes(method);
84
+ }
85
+ /**
86
+ * 从一条命令里抽出「这条命令其实在导航到某个地址」那个地址,没有就返回 null。
87
+ *
88
+ * 为什么必须有这一步:壳那条 `browserNav` 走的是 `navigateDockBrowser`,只有 http/https
89
+ * 能进。而 `Page.navigate` 是**绕开那道闸门**的直通车——不在这儿补一刀,agent 就能
90
+ * 把用户那台带登录态的浏览器导到 `file://` 上去。桌面侧收到这两个方法时,
91
+ * 一律用这个函数的返回值再过一次 {@link isHttpUrl} 同款判定。
92
+ */
93
+ export function dockNavigateTarget(method, params) {
94
+ if (method !== 'Page.navigate')
95
+ return null;
96
+ const url = params === undefined ? undefined : params['url'];
97
+ return typeof url === 'string' ? url : null;
98
+ }
99
+ /** 一条命令的默认超时:跨进程 + 可能等页面,给得比 CDP 那层(20s)宽一点。 */
100
+ export const DOCK_CALL_TIMEOUT_MS = 25_000;
101
+ /** 开一张页签(要等壳把页签建出来、把原生视图挂上)的超时。 */
102
+ export const DOCK_OPEN_TIMEOUT_MS = 8_000;
103
+ /** `views`/`snapshot`/`screenshot`/`console`/`network`/`wait_for`:只看不动。 */
104
+ export const DOCK_LOOK_ACTIONS = [
105
+ 'views',
106
+ 'snapshot',
107
+ 'screenshot',
108
+ 'console',
109
+ 'network',
110
+ 'wait_for',
111
+ ];
112
+ /** `open`/`navigate`/`click`/`hover`/`type`/`press`/`scroll`/`evaluate`/`close`:会改页面。 */
113
+ export const DOCK_ACTIONS = [
114
+ 'open',
115
+ 'navigate',
116
+ 'click',
117
+ 'hover',
118
+ 'type',
119
+ 'press',
120
+ 'scroll',
121
+ 'evaluate',
122
+ 'close',
123
+ ];
124
+ /**
125
+ * agent 自己开的那几张页签的 id 前缀。
126
+ *
127
+ * 为什么要有前缀:`views` 会把用户自己开的页签一起列出来(那些是同一台持久分区,
128
+ * 地址栏里可能是他登录着的后台)。前缀让「这是 agent 开的」这件事在 id 上就看得出,
129
+ * 审批卡与工具输出里都能直接标出来。
130
+ */
131
+ export const DOCK_AGENT_VIEW_PREFIX = 'agent-';
132
+ /** 这张视图是不是 agent 自己开的。 */
133
+ export function isAgentView(viewId) {
134
+ return viewId.startsWith(DOCK_AGENT_VIEW_PREFIX);
135
+ }
136
+ // ── 桌面壳 → 界面(壳里的页签归渲染层管,这两条走原生桥的事件面) ─────────────
137
+ /**
138
+ * 请壳开一张浏览器页签并聚焦(`id` 由桌面侧指定,壳必须照用,否则宿主对不上号)。
139
+ *
140
+ * 为什么要绕渲染层:原生视图的矩形与页签的激活态都在壳里(`dockBrowser` 的 rect 由
141
+ * 组件量出来),桌面主进程不知道侧栏现在在哪儿。ZCode 同样是「建页签顺手把右侧栏
142
+ * 打开并激活」——我们这条走同一形状。
143
+ */
144
+ export const DOCK_TAB_OPEN_EVENT = 'browser-tab-open-request';
145
+ /** 请壳关掉某张浏览器页签(`browser-close` 走它,免得留下一个点不开的空页签)。 */
146
+ export const DOCK_TAB_CLOSE_EVENT = 'browser-tab-close-request';
@@ -0,0 +1,59 @@
1
+ /**
2
+ * dock 通道的分档规格:读类 / 写类 / 终端。
3
+ *
4
+ * ## 为什么要分档
5
+ *
6
+ * `dock` 原来是**整条**被界面通道排除的,理由是它里面混着 `term-spawn`(起 pwsh/cmd/bash/node)——
7
+ * 那与「在用户机器上执行任意命令」同级,不该交给页面。但这条通道里另外十一个 op 是界面真正要用的:
8
+ * 工作区文件树、文件内容、git 状态与分支清单、差异(读),以及暂存 / 取消暂存 / 提交 /
9
+ * 切分支 / 建分支(写)。
10
+ * 一锅端掉等于「文件面板」永远搬不进壳;整条放行又等于把 spawn 交出去。所以按**动作落在谁手里**拆三档:
11
+ *
12
+ * | 档 | op | 走哪条路 | 为什么 |
13
+ * | --- | --- | --- | --- |
14
+ * | 读 | `fs-list` `fs-read` `git-status` `git-branches` `git-log` `git-diff` | 界面 HTTP 通道**直接放行** | 只读,且宿主侧已经限定在 cwd 内 |
15
+ * | 写 | `git-stage` `git-unstage` `git-commit` `git-checkout` `git-branch-create` | 界面 HTTP 通道,但**过审批** | 会改仓库状态,交给权限模式那套裁决(与工具调用同一口径) |
16
+ * | 终端 | `term-spawn` `term-input` `term-kill` | **只走桌面窗口的原生桥**,不进 HTTP 面 | 起进程 = 任意命令执行;浏览器里拿到 Cookie 的页面不该有这个能力 |
17
+ *
18
+ * 「只走原生桥」是**真的**只走那条路:`DOCK_UI_OPS` 里没有 term op,所以 HTTP 的
19
+ * `/api/invoke { method: 'dock' }` 拿着 `term-spawn` 会被实参校验当场拒(枚举不在表里)。
20
+ * 而原生桥只对主窗口的文档开放(`event.sender === mainWindow.webContents`),
21
+ * 于是"桌面窗口有效"这件事由**传输**保证,而不是靠 payload 里一个可伪造的标记位。
22
+ *
23
+ * 这一份零依赖、浏览器安全,所以三处共用:宿主插件(分档与审批)、界面通道(放行面)、
24
+ * 桌面主进程与壳(终端那条路)。
25
+ *
26
+ * @module dsc/core/dock-ops
27
+ */
28
+ /** 读类:只读取工作区现状,宿主侧限定在 cwd 内。 */
29
+ export declare const DOCK_READ_OPS: readonly ["fs-list", "fs-read", "git-status", "git-branches", "git-log", "git-diff"];
30
+ /** 写类:会改 git 状态,走审批。 */
31
+ export declare const DOCK_WRITE_OPS: readonly ["git-stage", "git-unstage", "git-commit", "git-checkout", "git-branch-create"];
32
+ /** 终端:起进程,只走桌面窗口的原生桥。 */
33
+ export declare const DOCK_TERM_OPS: readonly ["term-spawn", "term-input", "term-kill"];
34
+ /** 全部 op(宿主插件按它认人)。 */
35
+ export declare const DOCK_OPS: readonly ["fs-list", "fs-read", "git-status", "git-branches", "git-log", "git-diff", "git-stage", "git-unstage", "git-commit", "git-checkout", "git-branch-create", "term-spawn", "term-input", "term-kill"];
36
+ /** 界面 HTTP 通道放行的 op:读 + 写,**没有**终端。 */
37
+ export declare const DOCK_UI_OPS: readonly ["fs-list", "fs-read", "git-status", "git-branches", "git-log", "git-diff", "git-stage", "git-unstage", "git-commit", "git-checkout", "git-branch-create"];
38
+ export type DockReadOp = (typeof DOCK_READ_OPS)[number];
39
+ export type DockWriteOp = (typeof DOCK_WRITE_OPS)[number];
40
+ export type DockTermOp = (typeof DOCK_TERM_OPS)[number];
41
+ export type DockOp = (typeof DOCK_OPS)[number];
42
+ /** 查表用的集合。 */
43
+ export declare const DOCK_TERM_OP_SET: ReadonlySet<string>;
44
+ export declare const DOCK_WRITE_OP_SET: ReadonlySet<string>;
45
+ /** 是不是终端 op(决定它能不能进界面 HTTP 面)。 */
46
+ export declare function isDockTermOp(op: string): op is DockTermOp;
47
+ /** 是不是写类 op(决定要不要过审批)。 */
48
+ export declare function isDockWriteOp(op: string): op is DockWriteOp;
49
+ /**
50
+ * 写类 op 的审批卡文案。
51
+ *
52
+ * `toolName` 用 `git:` 前缀,一眼能跟工具调用区分开(审批卡上会显示这一栏);
53
+ * `summary` 只放**这次要动什么**(文件清单 / 提交信息首行),不放整段 payload——
54
+ * 卡片是单行的,塞不下。
55
+ */
56
+ export declare const DOCK_WRITE_LABEL: Readonly<Record<DockWriteOp, {
57
+ toolName: string;
58
+ summary: (payload: Record<string, unknown>) => string;
59
+ }>>;