@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
@@ -30,11 +30,14 @@
30
30
  */
31
31
  import { mkdirSync } from 'node:fs';
32
32
  import { resolve } from 'node:path';
33
+ import { clockText } from '../core/clock.js';
34
+ import { errText } from '../core/err-text.js';
33
35
  import { DSC_HOME } from '../core/path-policy.js';
34
36
  import { bootNoticeOnce } from '../core/boot-notices.js';
35
37
  import { resolvePluginConfig, writePluginConfig } from '../core/plugin-registry.js';
36
38
  import { registerCommandRunner } from '../core/tools/command-runner.js';
37
39
  import { readSandboxRequest } from '../core/tools/sandbox-args.js';
40
+ import { permissionOf, writePermissions } from '../core/permission-scope.js';
38
41
  import { createDockerRunner, probeDocker } from '../core/sandbox/backends.js';
39
42
  import { createWindowsTokenRunner, probeWindowsToken } from '../core/sandbox/win/backend.js';
40
43
  import { readSetupState } from '../core/sandbox/win/account.js';
@@ -51,14 +54,18 @@ const SECTION_ORDER = 31;
51
54
  /** 内存里留最近几次拒绝给 `/sandbox` 看。 */
52
55
  const DENY_BUFFER = 3;
53
56
  const PASS = { allowed: true, rule: 'allowed', why: '', how: '' };
54
- /** 时间戳 → `/sandbox` 里那行 `[12:03:44]`。 */
55
- function clockOf(ts) {
56
- const date = new Date(ts);
57
- const pad = (value) => String(value).padStart(2, '0');
58
- return `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
59
- }
60
- function errText(error) {
61
- return error instanceof Error ? error.message : String(error);
57
+ /**
58
+ * 越界之后**可以问用户一次**的规则(参考实现只读档的形态:沙箱拦下 → 审批卡问
59
+ * 「这一次要不要破例」)。其余规则保持硬拒:
60
+ * read-only-subpath 用户亲手标的只读子树,点一次允许就等于把那个开关作废;
61
+ * protected-metadata .git/.ssh/.env 与 dsc 自己的配置,改它等于换掉安全边界;
62
+ * network-off 显式关掉的网络开关,不该被一张卡绕过去;
63
+ * nt-namespace / ads-stream / short-name / unresolvable 是形状或解析失败,没有「这一次」可言。
64
+ */
65
+ const ASKABLE_RULES = new Set(['outside-writable-roots', 'mode-read-only']);
66
+ /** 规则名(可能带 `write-target:` 前缀)能不能交审批卡问一次。 */
67
+ function askableRule(rule) {
68
+ return ASKABLE_RULES.has(rule.replace(/^write-target:/, ''));
62
69
  }
63
70
  export const sandboxPlugin = {
64
71
  name: 'sandbox',
@@ -89,6 +96,26 @@ export const sandboxPlugin = {
89
96
  const currentCwd = () => ctx.session.current().meta.cwd;
90
97
  const currentSessionId = () => ctx.session.current().meta.id;
91
98
  const currentSessionPath = () => ctx.session.current().filePath;
99
+ /**
100
+ * 沙箱档位**按会话**读(2026-10-28):会话里有就用会话的,没有就把默认值钉进去。
101
+ * 默认值来自 plugins.json 的沙箱配置——它只对「还没钉过的会话」与新会话生效。
102
+ */
103
+ const defaultMode = () => readConfig().config.mode;
104
+ /** 这次判定属于哪个会话:优先按会话 id 找常驻实例,其次按路径,最后看当前查看的。 */
105
+ const sessionOf = (sessionId, sessionPath) => {
106
+ const agent = ctx.get('agent');
107
+ const byId = sessionId !== undefined && sessionId !== '' ? agent?.sessionById(sessionId) : undefined;
108
+ if (byId !== undefined)
109
+ return byId;
110
+ if (sessionPath !== undefined && sessionPath !== '') {
111
+ const byPath = agent?.sessionFor(sessionPath);
112
+ if (byPath !== undefined)
113
+ return byPath;
114
+ }
115
+ return ctx.session.current();
116
+ };
117
+ /** 某个会话现在生效的沙箱档位。 */
118
+ const modeOf = (session) => permissionOf(session, 'sandbox', defaultMode());
92
119
  /**
93
120
  * 组一份当前策略快照:设置与会话状态都现读,所以设置页改完立刻生效,不用重启宿主。
94
121
  * 沙箱私有临时目录顺手建出来(建不出来也不抛:策略会把它当普通路径判)。
@@ -105,9 +132,10 @@ export const sandboxPlugin = {
105
132
  * 键是会话路径:一个会话放宽了,别的会话照旧被拦。
106
133
  */
107
134
  const sessionRoots = new Map();
108
- const snapshot = (cwdOverride, sessionPath) => {
135
+ const snapshot = (cwdOverride, sessionPath, modeOverride) => {
109
136
  const { config, problems } = readConfig();
110
137
  const cwd = cwdOverride ?? currentCwd();
138
+ const mode = modeOverride ?? modeOf(ctx.session.current());
111
139
  const granted = sessionPath === undefined ? [] : (sessionRoots.get(sessionPath) ?? []);
112
140
  const tmpDir = sandboxTmpDir(DSC_HOME, cwd, currentSessionId());
113
141
  try {
@@ -117,7 +145,7 @@ export const sandboxPlugin = {
117
145
  // 目录建不出来时写它就是失败的,不必在这里报错(工具自己会拿到真实错误)
118
146
  }
119
147
  const policy = createPolicy({
120
- mode: config.mode,
148
+ mode,
121
149
  cwd,
122
150
  tmpDir,
123
151
  extraWritableRoots: [...config.extraWritableRoots, ...granted],
@@ -132,19 +160,19 @@ export const sandboxPlugin = {
132
160
  if (rule.startsWith('write-target:'))
133
161
  return legalWay(rule.slice('write-target:'.length));
134
162
  if (rule === 'network-off')
135
- return '在「设置 → 沙箱」打开网络开关,或换成不需要联网的做法';
163
+ return '在「插件中心 → 文件与命令围栏」打开网络开关,或换成不需要联网的做法';
136
164
  if (rule === 'malformed-request')
137
165
  return '两个升权参数要么都给(sandbox_permissions + justification),要么都不给';
138
166
  return '换一个不需要改机器配置的做法;确需执行这条命令请让用户手工跑';
139
167
  };
140
168
  /** 记一次拒绝 + 拼给模型看的那句话(带档位、可写根、命中规则、下一步怎么走)。 */
141
- const refuse = (config, policy, tool, verdict) => {
169
+ const refuse = (config, policy, mode, tool, verdict) => {
142
170
  denials.push({ at: Date.now(), tool, rule: verdict.rule, why: verdict.why });
143
171
  if (denials.length > DENY_BUFFER)
144
172
  denials.shift();
145
173
  const roots = policy.roots.length === 0 ? '(无)' : policy.roots.join('、');
146
174
  const reason = `沙箱拒绝这次 ${tool}:${verdict.why}。` +
147
- `当前档位 ${config.mode}(可写根:${roots};网络:${config.networkAccess ? '开' : '关'}),` +
175
+ `当前档位 ${mode}(可写根:${roots};网络:${config.networkAccess ? '开' : '关'}),` +
148
176
  `命中规则「${verdict.rule}」。${verdict.how}`;
149
177
  return { action: 'deny', reason };
150
178
  };
@@ -176,9 +204,10 @@ export const sandboxPlugin = {
176
204
  decide(input) {
177
205
  // 按这次调用的工作目录算可写根:input.cwd 就是循环传进来的会话目录,
178
206
  // 显式优先于会话状态,同进程多工作目录时才不会拿错根。
179
- const { config, policy } = snapshot(input.cwd, input.sessionPath);
207
+ const mode = modeOf(sessionOf(input.sessionId, input.sessionPath));
208
+ const { config, policy } = snapshot(input.cwd, input.sessionPath, mode);
180
209
  // 不设围栏的档位:整档交出去(审批与权限模式照常管)
181
- if (config.mode === 'danger-full-access')
210
+ if (mode === 'danger-full-access')
182
211
  return { action: 'defer' };
183
212
  // 读限制不在本插件职责内:内核 path-policy 已经管凭据读取,这里再拒一次只会给两条理由
184
213
  if (input.risk === 'read')
@@ -191,9 +220,9 @@ export const sandboxPlugin = {
191
220
  allowed: false,
192
221
  rule: 'backend-unavailable',
193
222
  why: '你要的隔离后端(docker / Windows 受限令牌)没建起来,配置又选了「建不起来就拒」',
194
- how: '两条路:在「设置 → 沙箱」把后端换成策略围栏(进程内那个,接受 partial),或把「后端建不起来时」改回 degrade;也可以先修好后端(docker 起得来 / 提权 setup 成功)',
223
+ how: '两条路:在「插件中心 → 文件与命令围栏」把后端换成策略围栏(进程内那个,接受 partial),或把「后端建不起来时」改回 degrade;也可以先修好后端(docker 起得来 / 提权 setup 成功)',
195
224
  };
196
- return refuse(config, policy, input.toolName, verdict);
225
+ return refuse(config, policy, mode, input.toolName, verdict);
197
226
  }
198
227
  const request = readSandboxRequest(input.args);
199
228
  // 半截的升权请求一律拒:单独一个 sandbox_permissions(想偷偷放宽)
@@ -205,7 +234,7 @@ export const sandboxPlugin = {
205
234
  why: `升权参数不完整:${request.reason}`,
206
235
  how: howTo('malformed-request'),
207
236
  };
208
- return refuse(config, policy, input.toolName, verdict);
237
+ return refuse(config, policy, mode, input.toolName, verdict);
209
238
  }
210
239
  const verdict = input.risk === 'write'
211
240
  ? writeVerdict(policy, input.target)
@@ -231,36 +260,62 @@ export const sandboxPlugin = {
231
260
  return { action: 'defer' };
232
261
  if (widened.allowed)
233
262
  return { action: 'defer' };
234
- return refuse(config, policy, input.toolName, {
263
+ return refuse(config, policy, mode, input.toolName, {
235
264
  allowed: false,
236
265
  rule: widened.rule,
237
266
  why: `${widened.reason}(模型请求的是「留在沙箱内放宽写边界」,可写根放宽到这一次的目标后**仍然**不合法)`,
238
267
  how: legalWay(widened.rule),
239
268
  });
240
269
  }
241
- return refuse(config, policy, input.toolName, verdict);
270
+ // 越界但这件事可以问用户一次(参考实现只读档的语义):沙箱只 defer,
271
+ // 审批卡是最后一道。审批插件不在场时不能 defer——那等于无人把关地放行。
272
+ if (askableRule(verdict.rule) && ctx.get('approval') !== undefined)
273
+ return { action: 'defer' };
274
+ return refuse(config, policy, mode, input.toolName, verdict);
242
275
  },
243
276
  };
244
277
  const offGuard = ctx.guards.register(guard);
245
278
  // ── 系统提示段(降级必须可见)─────────────────────────────────────────────
246
- /** 强制等级 → 一句人话。 */
247
- const enforcementText = () => {
248
- switch (enforcement) {
279
+ /**
280
+ * 强制等级 → 一句人话。
281
+ *
282
+ * 等级从参数进来,不读全局 `enforcement`:全局值记的是「进程级后端建到哪一步」,
283
+ * 与会话实际生效的等级可能不是一回事(见 {@link effectiveEnforcement})。
284
+ * 读全局会让提示词出现「partial(none:当前档位不设围栏)」这种自相矛盾的话。
285
+ */
286
+ const enforcementText = (level) => {
287
+ switch (level) {
249
288
  case 'full':
250
- return 'full:命令的执行体被换成了容器(网络与文件系统由容器隔离)';
289
+ return '命令的执行体被换成了容器(网络与文件系统由容器隔离)';
251
290
  case 'partial':
252
- return 'partial:进程内策略围栏(拦得住 dsc 自己发起的工具调用,拦不住命令内部的任意写)';
291
+ return '进程内策略围栏(拦得住自己发起的工具调用,拦不住命令内部的任意写)';
253
292
  default:
254
- return 'none:当前档位不设围栏';
293
+ return '当前档位不设围栏';
255
294
  }
256
295
  };
257
- const promptText = () => {
258
- const { config, policy, problems } = snapshot();
259
- if (config.mode === 'danger-full-access') {
296
+ /**
297
+ * 某个会话实际生效的强制等级。
298
+ *
299
+ * 全局 `enforcement` 记的是「进程级后端建到哪一步」:默认档是 danger-full-access 时
300
+ * refreshBackend 会提前返回,全局值停在 none;但另一个会话切到 workspace-write 时,
301
+ * 守卫仍按进程内策略围栏拦越界写——所以对非 danger 会话,实际等级至少是 partial。
302
+ * 直接把全局值写进设置页/系统提示就会谎报「none:不设围栏」。
303
+ */
304
+ const effectiveEnforcement = (mode) => mode === 'danger-full-access' ? 'none' : enforcement === 'none' ? 'partial' : enforcement;
305
+ /** 「等级 + 一句解释」连在一起写,两半永远取同一档。 */
306
+ const enforcementNote = (mode) => {
307
+ const level = effectiveEnforcement(mode);
308
+ return `${level} —— ${enforcementText(level)}`;
309
+ };
310
+ const promptText = (scope) => {
311
+ // 这个 agent 自己的档位(后台会话不该拿「你此刻点开的会话」的沙箱说明)。
312
+ const mode = modeOf(sessionOf(scope?.sessionId));
313
+ const { config, policy, problems } = snapshot(scope?.cwd, undefined, mode);
314
+ if (mode === 'danger-full-access') {
260
315
  return '【沙箱】档位 danger-full-access:沙箱不设围栏,写盘与命令只受权限模式与审批卡约束。';
261
316
  }
262
317
  const lines = [];
263
- lines.push(`【沙箱】档位 ${config.mode}|强制执行 ${enforcement}(${enforcementText()})`);
318
+ lines.push(`【沙箱】档位 ${mode}|强制执行 ${enforcementNote(mode)}`);
264
319
  lines.push(`可写根:${policy.roots.length === 0 ? '(无,只读档不许写盘)' : policy.roots.join('、')};` +
265
320
  `只读子路径:${policy.readOnlySubpaths.length === 0 ? '(无)' : policy.readOnlySubpaths.join('、')};` +
266
321
  `网络:${config.networkAccess ? '开' : '关(要联网的命令会被直接拒)'}`);
@@ -268,17 +323,21 @@ export const sandboxPlugin = {
268
323
  lines.push(`当前后端是 Windows 受限令牌:命令内部的越界写(脚本里的 fs.writeFile 这类)会被系统层直接拒绝;读不受限;网络第二级体检 ${networkTier}(明细见 /sandbox)。`);
269
324
  }
270
325
  else {
271
- lines.push('策略围栏拦得住 dsc 自己发起的工具调用,拦不住命令内部的任意写(脚本里的 fs.writeFile 这类);要真隔离,请在「设置 → 沙箱」把后端换成 Windows 受限令牌(本机即可,无需 docker)或容器。');
326
+ lines.push('策略围栏拦得住 dsc 自己发起的工具调用,拦不住命令内部的任意写(脚本里的 fs.writeFile 这类);要真隔离,请在「插件中心 → 文件与命令围栏」把后端换成 Windows 受限令牌(本机即可,无需 docker)或容器。');
272
327
  }
273
328
  lines.push('要写到可写根之外(例如另一个盘的项目目录),只能在这一次调用里同时给 sandbox_permissions 与 justification,且照常会弹审批卡让用户点。');
274
329
  if (degradedFailClosed) {
275
- lines.push('⚠ 你要的隔离后端没建起来,且配置选了「后端建不起来就拒」:写与执行类工具现在会被沙箱直接拒(读照常)。修法见「设置 → 沙箱」。');
330
+ lines.push('⚠ 你要的隔离后端没建起来,且配置选了「后端建不起来就拒」:写与执行类工具现在会被沙箱直接拒(读照常)。修法见「插件中心 → 文件与命令围栏」。');
276
331
  }
277
332
  if (problems.length > 0)
278
333
  lines.push(`⚠ 沙箱配置有问题(已按默认值兜底):${problems.join(';')}`);
279
334
  return lines.join('\n');
280
335
  };
281
- const offPrompt = ctx.prompt.register('sandbox', promptText, { order: PROMPT_ORDER });
336
+ // 沙箱说明挂在**请求末尾的环境快照**里,不进系统提示词(2026-10-30 报障):
337
+ // 档位一改系统提示词就变,服务端前缀缓存从那一行起全失效(实测切一次权限,
338
+ // 下一次请求 59K 未命中、只命中 4K)。挪到快照之后前缀稳定,模型每轮照样看到最新档位。
339
+ // 子代理不受影响:它本来就不拿系统提示词里的这段(见 subagent 插件自己的提示词)。
340
+ const offPrompt = ctx.prompt.registerEnvFacts('sandbox', (session) => promptText({ sessionId: session?.meta.id, cwd: session?.meta.cwd }));
282
341
  // ── 后端探测与降级 ────────────────────────────────────────────────────────
283
342
  /**
284
343
  * 按当前设置重新决定后端与强制执行等级。
@@ -298,7 +357,12 @@ export const sandboxPlugin = {
298
357
  const { config } = readConfig();
299
358
  if (config.mode === 'danger-full-access') {
300
359
  enforcement = 'none';
301
- backendDetail = '档位 danger-full-access:不设围栏';
360
+ // 这一档不设围栏,后端与「建不起来就拒」都不参与判定。说清楚,
361
+ // 免得用户以为选了 fail-closed 就一定拒——那和「完全访问」的语义相抵。
362
+ backendDetail =
363
+ config.backend !== 'policy' && config.onUnavailable === 'fail-closed'
364
+ ? '档位 danger-full-access:不设围栏;后端与「建不起来就拒」在这一档不生效'
365
+ : '档位 danger-full-access:不设围栏';
302
366
  ctx.emit('dsc/changed');
303
367
  return backendDetail;
304
368
  }
@@ -327,8 +391,8 @@ export const sandboxPlugin = {
327
391
  : undefined;
328
392
  const handle = createWindowsTokenRunner({
329
393
  mode: config.mode === 'read-only' ? 'read-only' : 'workspace-write',
394
+ // 这里只是「挂载时所在会话」的起点;之后每次调用按 run.cwd 现算可写根(常驻多会话)
330
395
  cwd: currentCwd(),
331
- tmpDir: sandboxTmpDir(DSC_HOME, currentCwd(), currentSessionId()),
332
396
  extraRoots: config.extraWritableRoots,
333
397
  networkAccess: () => readConfig().config.networkAccess,
334
398
  networkAllowlist: () => readConfig().config.networkAllowlist,
@@ -378,11 +442,12 @@ export const sandboxPlugin = {
378
442
  /** 挂载时那条可见说明:只讲档位、强制等级与网络,明细(后端、可写根)在 /sandbox 与设置里。 */
379
443
  const mountLine = () => {
380
444
  const { config, problems } = snapshot();
381
- const head = `沙箱已就绪:档位 ${config.mode}|强制执行 ${enforcement}|网络 ${config.networkAccess ? '开' : '关'}`;
382
- const tail = enforcement === 'partial'
445
+ const effective = effectiveEnforcement(modeOf(ctx.session.current()));
446
+ const head = `沙箱已就绪:档位 ${modeOf(ctx.session.current())}|强制执行 ${effective}|网络 ${config.networkAccess ? '开' : '关'}`;
447
+ const tail = effective === 'partial'
383
448
  ? (config.backend === 'windows-token'
384
449
  ? '。越界写已被系统层拦截;明细见 /sandbox。'
385
- : '。策略围栏拦得住工具调用,拦不住命令内部的任意写,要真隔离请在「设置 → 沙箱」换后端。')
450
+ : '。策略围栏拦得住工具调用,拦不住命令内部的任意写,要真隔离请在「插件中心 → 文件与命令围栏」换后端。')
386
451
  : '。';
387
452
  const warn = problems.length === 0 ? '' : ` ⚠ 配置有问题(已按默认值兜底):${problems.join(';')}`;
388
453
  return `${head}${tail}${warn}`;
@@ -410,7 +475,7 @@ export const sandboxPlugin = {
410
475
  const report = () => {
411
476
  const { config, policy, problems } = snapshot();
412
477
  const lines = [];
413
- lines.push(`沙箱现状:档位 ${config.mode}|强制执行 ${enforcement}`);
478
+ lines.push(`沙箱现状:当前会话档位 ${modeOf(ctx.session.current())}|新会话默认 ${config.mode}|强制执行 ${effectiveEnforcement(modeOf(ctx.session.current()))}`);
414
479
  lines.push(`后端:${config.backend} —— ${backendDetail}`);
415
480
  lines.push(`可写根(${String(policy.roots.length)}):`);
416
481
  if (policy.roots.length === 0)
@@ -435,15 +500,15 @@ export const sandboxPlugin = {
435
500
  if (denials.length === 0)
436
501
  lines.push(' (还没有)');
437
502
  for (const one of denials)
438
- lines.push(` [${clockOf(one.at)}] ${one.tool} · ${one.rule} —— ${one.why}`);
503
+ lines.push(` [${clockText(one.at)}] ${one.tool} · ${one.rule} —— ${one.why}`);
439
504
  if (problems.length > 0)
440
505
  lines.push(`⚠ 配置有问题(已按默认值兜底):${problems.join(';')}`);
441
506
  return lines.join('\n');
442
507
  };
443
508
  const section = {
444
509
  id: SANDBOX_CONFIG_KEY,
445
- title: '沙箱',
446
- subtitle: '档位、可写根、网络开关与强制后端:拦「能不能写」,不拦「要不要问」',
510
+ title: '文件与命令围栏',
511
+ subtitle: '限定能写哪里:可写目录、受保护路径、联网开关与强制执行后端',
447
512
  order: SECTION_ORDER,
448
513
  fields() {
449
514
  const { config, policy, problems } = snapshot();
@@ -451,13 +516,24 @@ export const sandboxPlugin = {
451
516
  {
452
517
  type: 'select',
453
518
  key: 'mode',
454
- label: '档位',
519
+ label: '这个会话允许写哪里',
520
+ options: [
521
+ { value: 'read-only', label: '只读(任何写盘都拒)' },
522
+ { value: 'workspace-write', label: '工作区可写(默认)' },
523
+ { value: 'danger-full-access', label: '不设围栏(等同关掉这层保护)' },
524
+ ],
525
+ help: '只改当前打开的会话,换会话各用各的档位。平时保持这一档就行:正常的工作区读写与命令不会被拦,只有越界写、改受保护文件、关网时联网会被拒。',
526
+ },
527
+ {
528
+ type: 'select',
529
+ key: 'defaultMode',
530
+ label: '以后新开的会话默认写哪里',
455
531
  options: [
456
532
  { value: 'read-only', label: '只读(任何写盘都拒)' },
457
533
  { value: 'workspace-write', label: '工作区可写(默认)' },
458
- { value: 'danger-full-access', label: '不设围栏(等同关掉沙箱)' },
534
+ { value: 'danger-full-access', label: '不设围栏(等同关掉这层保护)' },
459
535
  ],
460
- help: '默认档不挡正常的工作区读写与命令:只有越界写、受保护名与「网络关时的联网命令」会被拒。',
536
+ help: '只影响之后新建的会话;已经打开的会话保留自己的档位。',
461
537
  },
462
538
  {
463
539
  type: 'select',
@@ -467,7 +543,7 @@ export const sandboxPlugin = {
467
543
  { value: 'degrade', label: '降级为策略围栏(照常干,审批卡兜底)' },
468
544
  { value: 'fail-closed', label: '拒绝:写与执行类一律拒(读照常)' },
469
545
  ],
470
- help: '只对 docker / windows-token 这两个「要真隔离」的后端生效:它们建不起来时按哪种姿态收场。策略围栏后端的 partial 是预期状态,不受这一项影响。',
546
+ help: '只对 docker 与 Windows 受限令牌这两个真隔离后端生效:它们建不起来时,是降级为进程内策略围栏照常干,还是拒绝写与执行。进程内策略围栏的 partial 是预期状态,不受这一项影响。',
471
547
  },
472
548
  {
473
549
  type: 'switch',
@@ -521,14 +597,14 @@ export const sandboxPlugin = {
521
597
  placeholder: DEFAULT_SANDBOX_IMAGE,
522
598
  help: `容器后端用的镜像,默认 ${DEFAULT_SANDBOX_IMAGE}。镜像里得有你那条命令要用的工具(例如 node:20-alpine)。`,
523
599
  },
524
- { type: 'info', label: '强制执行等级', text: `${enforcement} —— ${enforcementText()}` },
600
+ { type: 'info', label: '当前会话强制执行等级', text: enforcementNote(modeOf(ctx.session.current())) },
525
601
  { type: 'info', label: '后端现状', text: backendDetail },
526
602
  { type: 'info', label: '沙箱私有临时目录', mono: true, copyable: true, text: policy.tmpDir },
527
603
  { type: 'info', label: '当前生效', text: describePolicy(policy) },
528
604
  {
529
605
  type: 'info',
530
606
  label: '最近 3 次拒绝',
531
- text: denials.length === 0 ? '(还没有)' : denials.map((one) => `[${clockOf(one.at)}] ${one.tool} · ${one.rule} —— ${one.why}`).join('\n'),
607
+ text: denials.length === 0 ? '(还没有)' : denials.map((one) => `[${clockText(one.at)}] ${one.tool} · ${one.rule} —— ${one.why}`).join('\n'),
532
608
  },
533
609
  {
534
610
  type: 'button',
@@ -566,7 +642,8 @@ export const sandboxPlugin = {
566
642
  values() {
567
643
  const { config } = readConfig();
568
644
  return {
569
- mode: config.mode,
645
+ mode: modeOf(ctx.session.current()),
646
+ defaultMode: config.mode,
570
647
  networkAccess: config.networkAccess,
571
648
  networkAllowlist: formatPathList(config.networkAllowlist),
572
649
  extraWritableRoots: formatPathList(config.extraWritableRoots),
@@ -579,6 +656,13 @@ export const sandboxPlugin = {
579
656
  async save(key, value) {
580
657
  switch (key) {
581
658
  case 'mode': {
659
+ const mode = String(value);
660
+ if (!SANDBOX_MODES.includes(mode))
661
+ return `档位只能是 ${SANDBOX_MODES.join(' / ')}`;
662
+ writePermissions(ctx.session.current(), { sandbox: mode });
663
+ break;
664
+ }
665
+ case 'defaultMode': {
582
666
  const mode = String(value);
583
667
  if (!SANDBOX_MODES.includes(mode))
584
668
  return `档位只能是 ${SANDBOX_MODES.join(' / ')}`;
@@ -658,10 +742,10 @@ export const sandboxPlugin = {
658
742
  // ── 对外服务 ─────────────────────────────────────────────────────────────
659
743
  const service = {
660
744
  get mode() {
661
- return readConfig().config.mode;
745
+ return modeOf(ctx.session.current());
662
746
  },
663
747
  get enforcement() {
664
- return enforcement;
748
+ return effectiveEnforcement(modeOf(ctx.session.current()));
665
749
  },
666
750
  get writableRoots() {
667
751
  return snapshot().policy.roots;
@@ -672,24 +756,45 @@ export const sandboxPlugin = {
672
756
  get tmpDir() {
673
757
  return snapshot().policy.tmpDir;
674
758
  },
675
- canWrite(path, cwd) {
759
+ canWrite(path, cwd, sessionPath) {
676
760
  // cwd 省略时退回会话工作目录(接口约定见 src/services/types.ts 的 SandboxService)。
677
- const { policy } = snapshot(cwd);
761
+ const { policy } = snapshot(cwd, sessionPath, modeOf(sessionOf(undefined, sessionPath)));
678
762
  const check = checkWrite(policy, path);
679
763
  const out = { allowed: check.allowed, reason: check.reason };
680
764
  if (check.root !== undefined)
681
765
  out.root = check.root;
682
766
  return out;
683
767
  },
684
- describe() {
685
- const { config, policy } = snapshot();
686
- return `沙箱 ${config.mode}(强制执行 ${enforcement}):${describePolicy(policy)}`;
687
- },
688
768
  /**
689
- * 切档位(打包权限预设的写入口;设置页那一格走的也是同一份写盘 + 重算)。
690
- * 只写配置值并立刻广播,重算后端在后台跑——档位值当拍就对,强制等级下一拍跟上。
691
- * @param next - 三档之一;写错当场抛错(预设表是常量,正常到不了这里)。
769
+ * 审批用:这次调用越界了没有、越界之后能不能问用户。
770
+ * 守卫里同一条判定已经做过一遍(order 8),这里再做一遍是刻意的——审批是
771
+ * 自动放行的最后一道,它不能假设「沙箱一定已经判过」。
692
772
  */
773
+ check(target, command, cwd, sessionPath) {
774
+ const mode = modeOf(sessionOf(undefined, sessionPath));
775
+ const { config, policy } = snapshot(cwd, sessionPath, mode);
776
+ if (mode === 'danger-full-access')
777
+ return { allowed: true, requestable: false };
778
+ const verdict = target !== undefined && target.trim() !== ''
779
+ ? writeVerdict(policy, target)
780
+ : command !== undefined && command.trim() !== ''
781
+ ? execVerdict(config, policy, command)
782
+ : PASS;
783
+ if (verdict.allowed)
784
+ return { allowed: true, requestable: false };
785
+ const rule = verdict.rule.replace(/^write-target:/, '');
786
+ return {
787
+ allowed: false,
788
+ requestable: askableRule(verdict.rule),
789
+ reason: verdict.why,
790
+ rule,
791
+ };
792
+ },
793
+ describe() {
794
+ const { policy } = snapshot();
795
+ const mode = modeOf(ctx.session.current());
796
+ return `沙箱 ${mode}(强制执行 ${effectiveEnforcement(mode)}):${describePolicy(policy)}`;
797
+ },
693
798
  /**
694
799
  * 记一条**本会话**的放宽:把几个绝对路径并进这个会话的可写根。
695
800
  * 只有审批卡上「本会话允许」那一按会调它(调用方是 approval 插件)。
@@ -708,7 +813,23 @@ export const sandboxPlugin = {
708
813
  sessionGrants(sessionPath) {
709
814
  return sessionRoots.get(sessionPath) ?? [];
710
815
  },
816
+ /**
817
+ * 切**当前会话**的档位(打包权限预设与设置页走同一条写口)。
818
+ * 只写会话状态,不动 plugins.json——那一份是「新会话默认」,换它要走 setDefaultMode。
819
+ * @param next - 三档之一;写错当场抛错(预设表是常量,正常到不了这里)。
820
+ */
711
821
  setMode(next) {
822
+ if (!SANDBOX_MODES.includes(next)) {
823
+ throw new Error(`沙箱档位只能是 ${SANDBOX_MODES.join(' / ')},收到「${next}」`);
824
+ }
825
+ writePermissions(ctx.session.current(), { sandbox: next });
826
+ ctx.emit('dsc/changed');
827
+ },
828
+ /**
829
+ * 设「新会话默认档位」:写 plugins.json 并重算进程级后端。
830
+ * 只影响之后新建的会话;已有会话的档位不受影响。
831
+ */
832
+ setDefaultMode(next) {
712
833
  if (!SANDBOX_MODES.includes(next)) {
713
834
  throw new Error(`沙箱档位只能是 ${SANDBOX_MODES.join(' / ')},收到「${next}」`);
714
835
  }
@@ -1,16 +1,13 @@
1
1
  import { resolvePluginConfig, writePluginConfig } from '../core/plugin-registry.js';
2
2
  import { describeNext, describeRule, isValidTimeZone, isOneShot, nextRunAt, parseRule, systemTimeZone, SCHEDULE_RULE_KINDS, } from '../core/schedule/rule.js';
3
3
  import { ScheduleRunner, scheduleLimitsNote } from '../core/schedule/runner.js';
4
- import { errorText, ScheduleStore } from '../core/schedule/store.js';
4
+ import { ScheduleStore } from '../core/schedule/store.js';
5
+ import { errText as errorText } from '../core/err-text.js';
6
+ import { clampInt as clampNumber } from '../core/clamp.js';
5
7
  /** 配置键(`~/.dsc/plugins.json` 条目树里 `file` 等于这个名字那一项的 `config`)。 */
6
8
  const CONFIG_KEY = 'schedule';
7
9
  /** 缺省值:时区取系统时区,单次最长 10 分钟,历史 200 条。 */
8
10
  const DEFAULTS = { enabled: true, maxRunSeconds: 600, historyLimit: 200 };
9
- /** 数值夹取:不是数字就回落,越界就夹。 */
10
- function clampNumber(value, min, max, fallback) {
11
- const num = Number(value);
12
- return Number.isFinite(num) ? Math.min(Math.max(Math.round(num), min), max) : fallback;
13
- }
14
11
  /**
15
12
  * 从插件配置里取可调项并夹到合理区间。
16
13
  * @param passed - 装配时直接传进来的配置(内核挂载时的第二参数)
@@ -145,9 +142,12 @@ export const schedulePlugin = {
145
142
  const route = ctx.llm.route();
146
143
  return { baseUrl: route.baseUrl, apiKey: route.apiKey, model: route.model };
147
144
  },
148
- deliver: (text) => {
145
+ deliver: (text, task) => {
149
146
  // 定点任务是机器发起的投递:跑动中入箱时标 notice,画在输入框上方的只读通知条。
150
- ctx.agent.followup(text, undefined, undefined, 'notice');
147
+ // 目标会话用**建这条任务的那个会话**(task.sessionId),不是当前正在看的会话:
148
+ // 用户切走之后,提醒仍该回到原来的对话里。老任务没存 sessionId 时才回落当前会话。
149
+ const target = task.sessionId === '' ? undefined : task.sessionId;
150
+ ctx.agent.followup(text, undefined, target, 'notice');
151
151
  },
152
152
  waiting: () => ctx.waiting.any,
153
153
  sessionId: () => ctx.session.current().meta.id,
@@ -405,14 +405,15 @@ export const schedulePlugin = {
405
405
  '宿主不常驻(桌面端/终端关着)时不会触发,错过的排期至多补一次、不补积压。');
406
406
  }, { order: 41 });
407
407
  // ── 会话结束对账:把「投出去了但回合失败」接回到重试策略上 ───────────────────
408
- const turnEndDisposer = ctx.on('dsc/turn-end', (reason) => {
409
- runner.noteTurnEnd(reason);
408
+ const turnEndDisposer = ctx.on('dsc/turn-end', (reason, signal) => {
409
+ // 带上会话归属:后台会话的回合结束不能把队首那条投递记成「成功了」。
410
+ runner.noteTurnEnd(reason, signal.sessionId);
410
411
  });
411
412
  // ── 设置分区 ──────────────────────────────────────────────────────────────
412
413
  const section = {
413
414
  id: 'schedule',
414
415
  title: '定时任务',
415
- subtitle: '六种选择器 + 显式时区;到点把任务描述投回会话',
416
+ subtitle: '六种时间选择器 + 时区;到点把任务投回建它的会话',
416
417
  order: 32,
417
418
  fields() {
418
419
  const current = readConfig(passed);