@dsh-cc/tui 0.5.0

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 (363) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +144 -0
  3. package/lib/bash-history.d.ts +31 -0
  4. package/lib/bash-history.d.ts.map +1 -0
  5. package/lib/bash-history.js +94 -0
  6. package/lib/bash-history.js.map +1 -0
  7. package/lib/compact-fold.d.ts +35 -0
  8. package/lib/compact-fold.d.ts.map +1 -0
  9. package/lib/compact-fold.js +60 -0
  10. package/lib/compact-fold.js.map +1 -0
  11. package/lib/components/arg-completers.d.ts +22 -0
  12. package/lib/components/arg-completers.d.ts.map +1 -0
  13. package/lib/components/arg-completers.js +75 -0
  14. package/lib/components/arg-completers.js.map +1 -0
  15. package/lib/components/code-theme.d.ts +25 -0
  16. package/lib/components/code-theme.d.ts.map +1 -0
  17. package/lib/components/code-theme.js +137 -0
  18. package/lib/components/code-theme.js.map +1 -0
  19. package/lib/components/completion.d.ts +50 -0
  20. package/lib/components/completion.d.ts.map +1 -0
  21. package/lib/components/completion.js +279 -0
  22. package/lib/components/completion.js.map +1 -0
  23. package/lib/components/diff-card.d.ts +29 -0
  24. package/lib/components/diff-card.d.ts.map +1 -0
  25. package/lib/components/diff-card.js +175 -0
  26. package/lib/components/diff-card.js.map +1 -0
  27. package/lib/components/diff-hunks.d.ts +44 -0
  28. package/lib/components/diff-hunks.d.ts.map +1 -0
  29. package/lib/components/diff-hunks.js +188 -0
  30. package/lib/components/diff-hunks.js.map +1 -0
  31. package/lib/components/editor-history.d.ts +23 -0
  32. package/lib/components/editor-history.d.ts.map +1 -0
  33. package/lib/components/editor-history.js +29 -0
  34. package/lib/components/editor-history.js.map +1 -0
  35. package/lib/components/markdown-theme.d.ts +11 -0
  36. package/lib/components/markdown-theme.d.ts.map +1 -0
  37. package/lib/components/markdown-theme.js +29 -0
  38. package/lib/components/markdown-theme.js.map +1 -0
  39. package/lib/components/masked-input.d.ts +24 -0
  40. package/lib/components/masked-input.d.ts.map +1 -0
  41. package/lib/components/masked-input.js +168 -0
  42. package/lib/components/masked-input.js.map +1 -0
  43. package/lib/components/overlay-host.d.ts +31 -0
  44. package/lib/components/overlay-host.d.ts.map +1 -0
  45. package/lib/components/overlay-host.js +128 -0
  46. package/lib/components/overlay-host.js.map +1 -0
  47. package/lib/components/overlays.d.ts +94 -0
  48. package/lib/components/overlays.d.ts.map +1 -0
  49. package/lib/components/overlays.js +450 -0
  50. package/lib/components/overlays.js.map +1 -0
  51. package/lib/components/provider-box.d.ts +23 -0
  52. package/lib/components/provider-box.d.ts.map +1 -0
  53. package/lib/components/provider-box.js +164 -0
  54. package/lib/components/provider-box.js.map +1 -0
  55. package/lib/components/read-group.d.ts +51 -0
  56. package/lib/components/read-group.d.ts.map +1 -0
  57. package/lib/components/read-group.js +105 -0
  58. package/lib/components/read-group.js.map +1 -0
  59. package/lib/components/root-bash.d.ts +36 -0
  60. package/lib/components/root-bash.d.ts.map +1 -0
  61. package/lib/components/root-bash.js +112 -0
  62. package/lib/components/root-bash.js.map +1 -0
  63. package/lib/components/root-types.d.ts +42 -0
  64. package/lib/components/root-types.d.ts.map +1 -0
  65. package/lib/components/root-types.js +8 -0
  66. package/lib/components/root-types.js.map +1 -0
  67. package/lib/components/root-utils.d.ts +22 -0
  68. package/lib/components/root-utils.d.ts.map +1 -0
  69. package/lib/components/root-utils.js +45 -0
  70. package/lib/components/root-utils.js.map +1 -0
  71. package/lib/components/root.d.ts +25 -0
  72. package/lib/components/root.d.ts.map +1 -0
  73. package/lib/components/root.js +357 -0
  74. package/lib/components/root.js.map +1 -0
  75. package/lib/components/theme.d.ts +61 -0
  76. package/lib/components/theme.d.ts.map +1 -0
  77. package/lib/components/theme.js +99 -0
  78. package/lib/components/theme.js.map +1 -0
  79. package/lib/components/transcript.d.ts +43 -0
  80. package/lib/components/transcript.d.ts.map +1 -0
  81. package/lib/components/transcript.js +203 -0
  82. package/lib/components/transcript.js.map +1 -0
  83. package/lib/components/working-line.d.ts +35 -0
  84. package/lib/components/working-line.d.ts.map +1 -0
  85. package/lib/components/working-line.js +66 -0
  86. package/lib/components/working-line.js.map +1 -0
  87. package/lib/effort-catalog.d.ts +27 -0
  88. package/lib/effort-catalog.d.ts.map +1 -0
  89. package/lib/effort-catalog.js +36 -0
  90. package/lib/effort-catalog.js.map +1 -0
  91. package/lib/export-markdown.d.ts +18 -0
  92. package/lib/export-markdown.d.ts.map +1 -0
  93. package/lib/export-markdown.js +124 -0
  94. package/lib/export-markdown.js.map +1 -0
  95. package/lib/harness/approval-preview.d.ts +33 -0
  96. package/lib/harness/approval-preview.d.ts.map +1 -0
  97. package/lib/harness/approval-preview.js +179 -0
  98. package/lib/harness/approval-preview.js.map +1 -0
  99. package/lib/harness/boot-banner.d.ts +14 -0
  100. package/lib/harness/boot-banner.d.ts.map +1 -0
  101. package/lib/harness/boot-banner.js +89 -0
  102. package/lib/harness/boot-banner.js.map +1 -0
  103. package/lib/harness/driver-agent.d.ts +78 -0
  104. package/lib/harness/driver-agent.d.ts.map +1 -0
  105. package/lib/harness/driver-agent.js +314 -0
  106. package/lib/harness/driver-agent.js.map +1 -0
  107. package/lib/harness/driver-agents.d.ts +20 -0
  108. package/lib/harness/driver-agents.d.ts.map +1 -0
  109. package/lib/harness/driver-agents.js +123 -0
  110. package/lib/harness/driver-agents.js.map +1 -0
  111. package/lib/harness/driver-approvals.d.ts +38 -0
  112. package/lib/harness/driver-approvals.d.ts.map +1 -0
  113. package/lib/harness/driver-approvals.js +277 -0
  114. package/lib/harness/driver-approvals.js.map +1 -0
  115. package/lib/harness/driver-bash.d.ts +15 -0
  116. package/lib/harness/driver-bash.d.ts.map +1 -0
  117. package/lib/harness/driver-bash.js +73 -0
  118. package/lib/harness/driver-bash.js.map +1 -0
  119. package/lib/harness/driver-catalog.d.ts +84 -0
  120. package/lib/harness/driver-catalog.d.ts.map +1 -0
  121. package/lib/harness/driver-catalog.js +256 -0
  122. package/lib/harness/driver-catalog.js.map +1 -0
  123. package/lib/harness/driver-ctx.d.ts +462 -0
  124. package/lib/harness/driver-ctx.d.ts.map +1 -0
  125. package/lib/harness/driver-ctx.js +11 -0
  126. package/lib/harness/driver-ctx.js.map +1 -0
  127. package/lib/harness/driver-hud.d.ts +31 -0
  128. package/lib/harness/driver-hud.d.ts.map +1 -0
  129. package/lib/harness/driver-hud.js +204 -0
  130. package/lib/harness/driver-hud.js.map +1 -0
  131. package/lib/harness/driver-live.d.ts +36 -0
  132. package/lib/harness/driver-live.d.ts.map +1 -0
  133. package/lib/harness/driver-live.js +44 -0
  134. package/lib/harness/driver-live.js.map +1 -0
  135. package/lib/harness/driver-modal.d.ts +52 -0
  136. package/lib/harness/driver-modal.d.ts.map +1 -0
  137. package/lib/harness/driver-modal.js +78 -0
  138. package/lib/harness/driver-modal.js.map +1 -0
  139. package/lib/harness/driver-mode.d.ts +35 -0
  140. package/lib/harness/driver-mode.d.ts.map +1 -0
  141. package/lib/harness/driver-mode.js +84 -0
  142. package/lib/harness/driver-mode.js.map +1 -0
  143. package/lib/harness/driver-pickers.d.ts +48 -0
  144. package/lib/harness/driver-pickers.d.ts.map +1 -0
  145. package/lib/harness/driver-pickers.js +249 -0
  146. package/lib/harness/driver-pickers.js.map +1 -0
  147. package/lib/harness/driver-promote.d.ts +29 -0
  148. package/lib/harness/driver-promote.d.ts.map +1 -0
  149. package/lib/harness/driver-promote.js +36 -0
  150. package/lib/harness/driver-promote.js.map +1 -0
  151. package/lib/harness/driver-queue.d.ts +19 -0
  152. package/lib/harness/driver-queue.d.ts.map +1 -0
  153. package/lib/harness/driver-queue.js +281 -0
  154. package/lib/harness/driver-queue.js.map +1 -0
  155. package/lib/harness/driver-run-local.d.ts +32 -0
  156. package/lib/harness/driver-run-local.d.ts.map +1 -0
  157. package/lib/harness/driver-run-local.js +366 -0
  158. package/lib/harness/driver-run-local.js.map +1 -0
  159. package/lib/harness/driver-sessions.d.ts +28 -0
  160. package/lib/harness/driver-sessions.d.ts.map +1 -0
  161. package/lib/harness/driver-sessions.js +386 -0
  162. package/lib/harness/driver-sessions.js.map +1 -0
  163. package/lib/harness/driver.d.ts +22 -0
  164. package/lib/harness/driver.d.ts.map +1 -0
  165. package/lib/harness/driver.js +459 -0
  166. package/lib/harness/driver.js.map +1 -0
  167. package/lib/harness/preset.d.ts +32 -0
  168. package/lib/harness/preset.d.ts.map +1 -0
  169. package/lib/harness/preset.js +34 -0
  170. package/lib/harness/preset.js.map +1 -0
  171. package/lib/harness/session-list.d.ts +65 -0
  172. package/lib/harness/session-list.d.ts.map +1 -0
  173. package/lib/harness/session-list.js +91 -0
  174. package/lib/harness/session-list.js.map +1 -0
  175. package/lib/harness/shell-output.d.ts +44 -0
  176. package/lib/harness/shell-output.d.ts.map +1 -0
  177. package/lib/harness/shell-output.js +90 -0
  178. package/lib/harness/shell-output.js.map +1 -0
  179. package/lib/harness/statusline-cc-transcript.d.ts +51 -0
  180. package/lib/harness/statusline-cc-transcript.d.ts.map +1 -0
  181. package/lib/harness/statusline-cc-transcript.js +191 -0
  182. package/lib/harness/statusline-cc-transcript.js.map +1 -0
  183. package/lib/harness/statusline-command.d.ts +54 -0
  184. package/lib/harness/statusline-command.d.ts.map +1 -0
  185. package/lib/harness/statusline-command.js +161 -0
  186. package/lib/harness/statusline-command.js.map +1 -0
  187. package/lib/harness/statusline-payload.d.ts +79 -0
  188. package/lib/harness/statusline-payload.d.ts.map +1 -0
  189. package/lib/harness/statusline-payload.js +93 -0
  190. package/lib/harness/statusline-payload.js.map +1 -0
  191. package/lib/harness/statusline-settings.d.ts +47 -0
  192. package/lib/harness/statusline-settings.d.ts.map +1 -0
  193. package/lib/harness/statusline-settings.js +57 -0
  194. package/lib/harness/statusline-settings.js.map +1 -0
  195. package/lib/harness/statusline-wiring.d.ts +45 -0
  196. package/lib/harness/statusline-wiring.d.ts.map +1 -0
  197. package/lib/harness/statusline-wiring.js +247 -0
  198. package/lib/harness/statusline-wiring.js.map +1 -0
  199. package/lib/harness/usage-view.d.ts +84 -0
  200. package/lib/harness/usage-view.d.ts.map +1 -0
  201. package/lib/harness/usage-view.js +199 -0
  202. package/lib/harness/usage-view.js.map +1 -0
  203. package/lib/harness/worktree-exit.d.ts +105 -0
  204. package/lib/harness/worktree-exit.d.ts.map +1 -0
  205. package/lib/harness/worktree-exit.js +168 -0
  206. package/lib/harness/worktree-exit.js.map +1 -0
  207. package/lib/history.d.ts +50 -0
  208. package/lib/history.d.ts.map +1 -0
  209. package/lib/history.js +139 -0
  210. package/lib/history.js.map +1 -0
  211. package/lib/index.d.ts +63 -0
  212. package/lib/index.d.ts.map +1 -0
  213. package/lib/index.js +54 -0
  214. package/lib/index.js.map +1 -0
  215. package/lib/input.d.ts +158 -0
  216. package/lib/input.d.ts.map +1 -0
  217. package/lib/input.js +400 -0
  218. package/lib/input.js.map +1 -0
  219. package/lib/invariant.d.ts +14 -0
  220. package/lib/invariant.d.ts.map +1 -0
  221. package/lib/invariant.js +20 -0
  222. package/lib/invariant.js.map +1 -0
  223. package/lib/mode-cycle.d.ts +22 -0
  224. package/lib/mode-cycle.d.ts.map +1 -0
  225. package/lib/mode-cycle.js +32 -0
  226. package/lib/mode-cycle.js.map +1 -0
  227. package/lib/model-catalog.d.ts +22 -0
  228. package/lib/model-catalog.d.ts.map +1 -0
  229. package/lib/model-catalog.js +45 -0
  230. package/lib/model-catalog.js.map +1 -0
  231. package/lib/packaged-preset.d.ts +32 -0
  232. package/lib/packaged-preset.d.ts.map +1 -0
  233. package/lib/packaged-preset.js +94 -0
  234. package/lib/packaged-preset.js.map +1 -0
  235. package/lib/plugin.d.ts +11 -0
  236. package/lib/plugin.d.ts.map +1 -0
  237. package/lib/plugin.js +88 -0
  238. package/lib/plugin.js.map +1 -0
  239. package/lib/profile.d.ts +4 -0
  240. package/lib/profile.d.ts.map +1 -0
  241. package/lib/profile.js +7 -0
  242. package/lib/profile.js.map +1 -0
  243. package/lib/project-sessions.d.ts +29 -0
  244. package/lib/project-sessions.d.ts.map +1 -0
  245. package/lib/project-sessions.js +60 -0
  246. package/lib/project-sessions.js.map +1 -0
  247. package/lib/project.d.ts +75 -0
  248. package/lib/project.d.ts.map +1 -0
  249. package/lib/project.js +196 -0
  250. package/lib/project.js.map +1 -0
  251. package/lib/provider-actions.d.ts +37 -0
  252. package/lib/provider-actions.d.ts.map +1 -0
  253. package/lib/provider-actions.js +417 -0
  254. package/lib/provider-actions.js.map +1 -0
  255. package/lib/provider-command.d.ts +109 -0
  256. package/lib/provider-command.d.ts.map +1 -0
  257. package/lib/provider-command.js +220 -0
  258. package/lib/provider-command.js.map +1 -0
  259. package/lib/provider-detail.d.ts +15 -0
  260. package/lib/provider-detail.d.ts.map +1 -0
  261. package/lib/provider-detail.js +201 -0
  262. package/lib/provider-detail.js.map +1 -0
  263. package/lib/provider-flow.d.ts +191 -0
  264. package/lib/provider-flow.d.ts.map +1 -0
  265. package/lib/provider-flow.js +192 -0
  266. package/lib/provider-flow.js.map +1 -0
  267. package/lib/provider-presets.d.ts +32 -0
  268. package/lib/provider-presets.d.ts.map +1 -0
  269. package/lib/provider-presets.js +105 -0
  270. package/lib/provider-presets.js.map +1 -0
  271. package/lib/provider-read.d.ts +63 -0
  272. package/lib/provider-read.d.ts.map +1 -0
  273. package/lib/provider-read.js +115 -0
  274. package/lib/provider-read.js.map +1 -0
  275. package/lib/provider-settings.d.ts +30 -0
  276. package/lib/provider-settings.d.ts.map +1 -0
  277. package/lib/provider-settings.js +65 -0
  278. package/lib/provider-settings.js.map +1 -0
  279. package/lib/resume-target.d.ts +59 -0
  280. package/lib/resume-target.d.ts.map +1 -0
  281. package/lib/resume-target.js +143 -0
  282. package/lib/resume-target.js.map +1 -0
  283. package/lib/slash.d.ts +44 -0
  284. package/lib/slash.d.ts.map +1 -0
  285. package/lib/slash.js +81 -0
  286. package/lib/slash.js.map +1 -0
  287. package/lib/state/driver-types.d.ts +505 -0
  288. package/lib/state/driver-types.d.ts.map +1 -0
  289. package/lib/state/driver-types.js +8 -0
  290. package/lib/state/driver-types.js.map +1 -0
  291. package/lib/state/driver-usage-types.d.ts +59 -0
  292. package/lib/state/driver-usage-types.d.ts.map +1 -0
  293. package/lib/state/driver-usage-types.js +8 -0
  294. package/lib/state/driver-usage-types.js.map +1 -0
  295. package/lib/statusline.d.ts +63 -0
  296. package/lib/statusline.d.ts.map +1 -0
  297. package/lib/statusline.js +97 -0
  298. package/lib/statusline.js.map +1 -0
  299. package/lib/store/pickers.d.ts +34 -0
  300. package/lib/store/pickers.d.ts.map +1 -0
  301. package/lib/store/pickers.js +111 -0
  302. package/lib/store/pickers.js.map +1 -0
  303. package/lib/store/provider-panel.d.ts +107 -0
  304. package/lib/store/provider-panel.d.ts.map +1 -0
  305. package/lib/store/provider-panel.js +151 -0
  306. package/lib/store/provider-panel.js.map +1 -0
  307. package/lib/store/question.d.ts +21 -0
  308. package/lib/store/question.d.ts.map +1 -0
  309. package/lib/store/question.js +59 -0
  310. package/lib/store/question.js.map +1 -0
  311. package/lib/store/queue.d.ts +27 -0
  312. package/lib/store/queue.d.ts.map +1 -0
  313. package/lib/store/queue.js +34 -0
  314. package/lib/store/queue.js.map +1 -0
  315. package/lib/store/session.d.ts +73 -0
  316. package/lib/store/session.d.ts.map +1 -0
  317. package/lib/store/session.js +172 -0
  318. package/lib/store/session.js.map +1 -0
  319. package/lib/store/subagents.d.ts +16 -0
  320. package/lib/store/subagents.d.ts.map +1 -0
  321. package/lib/store/subagents.js +44 -0
  322. package/lib/store/subagents.js.map +1 -0
  323. package/lib/store/todos.d.ts +35 -0
  324. package/lib/store/todos.d.ts.map +1 -0
  325. package/lib/store/todos.js +68 -0
  326. package/lib/store/todos.js.map +1 -0
  327. package/lib/store/usage.d.ts +15 -0
  328. package/lib/store/usage.d.ts.map +1 -0
  329. package/lib/store/usage.js +27 -0
  330. package/lib/store/usage.js.map +1 -0
  331. package/lib/store/views.d.ts +419 -0
  332. package/lib/store/views.d.ts.map +1 -0
  333. package/lib/store/views.js +3 -0
  334. package/lib/store/views.js.map +1 -0
  335. package/lib/store.d.ts +19 -0
  336. package/lib/store.d.ts.map +1 -0
  337. package/lib/store.js +10 -0
  338. package/lib/store.js.map +1 -0
  339. package/lib/terminal/lease.d.ts +33 -0
  340. package/lib/terminal/lease.d.ts.map +1 -0
  341. package/lib/terminal/lease.js +99 -0
  342. package/lib/terminal/lease.js.map +1 -0
  343. package/lib/tool-card.d.ts +75 -0
  344. package/lib/tool-card.d.ts.map +1 -0
  345. package/lib/tool-card.js +109 -0
  346. package/lib/tool-card.js.map +1 -0
  347. package/lib/tool-verbs.d.ts +12 -0
  348. package/lib/tool-verbs.d.ts.map +1 -0
  349. package/lib/tool-verbs.js +29 -0
  350. package/lib/tool-verbs.js.map +1 -0
  351. package/lib/transcript.d.ts +40 -0
  352. package/lib/transcript.d.ts.map +1 -0
  353. package/lib/transcript.js +413 -0
  354. package/lib/transcript.js.map +1 -0
  355. package/lib/working-line.d.ts +44 -0
  356. package/lib/working-line.d.ts.map +1 -0
  357. package/lib/working-line.js +56 -0
  358. package/lib/working-line.js.map +1 -0
  359. package/package.json +72 -0
  360. package/presets/cc/.dsh-cc-managed.json +5 -0
  361. package/presets/cc/agent.cordis.yml +524 -0
  362. package/presets/cc/preset.yml +3 -0
  363. package/scripts/stage-preset.mjs +26 -0
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Approval-prompt preview builders extracted from harness/driver.ts: argument
3
+ * restoration from the session log, structured payload previews, permission
4
+ * rule derivation, and settings-conflict detection. Pure functions over the
5
+ * approval request and store view types — no I/O and no harness state.
6
+ * @module @dsh-cc/tui/harness/approval-preview
7
+ */
8
+ import { canonicalizeHostname, isWebFetchRuleTool, ruleString } from '@dsh-cc/permission-rules';
9
+ /**
10
+ * Character cap for the pretty-printed raw-arguments preview of an approval
11
+ * prompt (non-shell, non-file-edit tools).
12
+ */
13
+ const ARGS_PREVIEW_MAX_CHARS = 500;
14
+ /**
15
+ * Restore the approved call's arguments by scanning the session log backwards
16
+ * for the `tool/call` event carrying the request's callId (`appendToolCall`
17
+ * lands before the pre-execute approval, so the event is always present).
18
+ * Returns undefined when the callId is missing, unpaired, or its arguments
19
+ * are not stored as a string.
20
+ */
21
+ function argsOf(req) {
22
+ if (req.callId === undefined)
23
+ return undefined;
24
+ const events = req.agent.session.events;
25
+ for (let i = events.length - 1; i >= 0; i -= 1) {
26
+ const event = events[i];
27
+ if (event.type !== 'tool/call')
28
+ continue;
29
+ if (String(event.data.callId) !== String(req.callId))
30
+ continue;
31
+ const raw = event.data.arguments;
32
+ if (typeof raw !== 'string')
33
+ return undefined;
34
+ try {
35
+ const parsed = JSON.parse(raw);
36
+ if (parsed !== null && typeof parsed === 'object' && !Array.isArray(parsed)) {
37
+ return { args: parsed };
38
+ }
39
+ }
40
+ catch {
41
+ // Not JSON — fall through to the raw-text preview.
42
+ }
43
+ return { raw };
44
+ }
45
+ return undefined;
46
+ }
47
+ /**
48
+ * Build the approval prompt's structured payload preview from the restored
49
+ * call arguments: shell-style `command` arguments map to the command kind;
50
+ * Edit/MultiEdit/Write arguments map to per-file diffs (rendered with the
51
+ * transcript's multi-hunk diff renderer); anything else pretty-prints the raw
52
+ * arguments, and a failed recovery degrades to tool name + reason only.
53
+ */
54
+ export function payloadOf(req) {
55
+ const restored = argsOf(req);
56
+ if (restored === undefined)
57
+ return { kind: 'none' };
58
+ if ('raw' in restored) {
59
+ return { kind: 'args', json: restored.raw.slice(0, ARGS_PREVIEW_MAX_CHARS) };
60
+ }
61
+ const args = restored.args;
62
+ if (typeof args.command === 'string') {
63
+ return { kind: 'command', command: args.command };
64
+ }
65
+ const diffs = diffsOf(req.toolName.toLowerCase(), args);
66
+ if (diffs !== undefined)
67
+ return { kind: 'diff', diffs };
68
+ return { kind: 'args', json: JSON.stringify(args, null, 2).slice(0, ARGS_PREVIEW_MAX_CHARS) };
69
+ }
70
+ /**
71
+ * Extract per-file diffs from file-edit tool arguments, or undefined when the
72
+ * arguments do not carry the expected shape (the preview then degrades to the
73
+ * raw-arguments kind).
74
+ */
75
+ function diffsOf(name, args) {
76
+ const path = typeof args.file_path === 'string' ? args.file_path : undefined;
77
+ if (name === 'write') {
78
+ if (path === undefined || typeof args.content !== 'string')
79
+ return undefined;
80
+ return [{ path, oldText: null, newText: args.content }];
81
+ }
82
+ if (name === 'edit') {
83
+ if (path === undefined || typeof args.old_string !== 'string' || typeof args.new_string !== 'string')
84
+ return undefined;
85
+ return [{ path, oldText: args.old_string, newText: args.new_string }];
86
+ }
87
+ if (name === 'multiedit' || name === 'multi_edit') {
88
+ if (path === undefined || !Array.isArray(args.edits))
89
+ return undefined;
90
+ const diffs = [];
91
+ for (const edit of args.edits) {
92
+ if (edit === null || typeof edit !== 'object')
93
+ continue;
94
+ const { old_string: oldText, new_string: newText } = edit;
95
+ if (typeof oldText !== 'string' || typeof newText !== 'string')
96
+ continue;
97
+ diffs.push({ path, oldText, newText });
98
+ }
99
+ return diffs.length > 0 ? diffs : undefined;
100
+ }
101
+ return undefined;
102
+ }
103
+ /**
104
+ * Derive the permission rule an "always" answer persists for the approved
105
+ * call. Shell commands get a trailing-space first-word prefix rule
106
+ * (`Bash(npm )` matches `npm install …` but not `npmx …` — the deliberate
107
+ * trailing space replaces the colon-carrying `:*` legacy form, which would
108
+ * otherwise embed the colon in the prefix and never match). Environment
109
+ * variable prefixes (e.g., `FOO=bar`) are stripped before extracting the
110
+ * first word, so `FOO=bar npm install` derives a rule for `npm`, not `FOO=bar`.
111
+ * A WebFetch call derives a `WebFetch(domain:<host>)` rule on the exact host
112
+ * from its `url` argument; every other tool gets a whole-tool rule. Undefined
113
+ * (stay once-only) when nothing usable remains, e.g. a blank command.
114
+ */
115
+ export function allowRuleOf(toolName, preview) {
116
+ const name = toolName.trim();
117
+ if (name === '')
118
+ return undefined;
119
+ if (preview?.kind === 'command') {
120
+ const command = preview.command.trim();
121
+ if (command === '')
122
+ return undefined;
123
+ // Strip environment variable prefixes (FOO=bar, FOO=bar BAZ=qux, etc.)
124
+ // These are assignments that appear before the actual command.
125
+ let remaining = command;
126
+ while (true) {
127
+ const match = remaining.match(/^[A-Z_][A-Z0-9_]*=\S*\s+/);
128
+ if (!match)
129
+ break;
130
+ remaining = remaining.slice(match[0].length);
131
+ }
132
+ // Handle common command prefixes that should be stripped
133
+ // sudo: run as root, but rule should match the actual command
134
+ // npx/yarn: package runners, but rule should match the underlying tool
135
+ const prefixesToStrip = ['sudo ', 'npx ', 'yarn '];
136
+ for (const prefix of prefixesToStrip) {
137
+ if (remaining.startsWith(prefix)) {
138
+ remaining = remaining.slice(prefix.length);
139
+ break; // Only strip one prefix
140
+ }
141
+ }
142
+ // For compound commands (&&, ||, ;), only consider the first segment
143
+ // This is a simplification - the rule will match any command starting
144
+ // with the first segment's command, which is the desired behavior.
145
+ const firstSegment = remaining.split(/&&|\|\||;/)[0]?.trim() ?? '';
146
+ const firstWord = firstSegment.split(/\s+/)[0] ?? '';
147
+ if (firstWord === '')
148
+ return undefined;
149
+ // ruleString escapes parens/backslashes so a subshell-opening first word
150
+ // round-trips through parseRuleString.
151
+ return ruleString(name, `${firstWord} `);
152
+ }
153
+ // WebFetch persists a domain rule on the exact host (not `*.host`): the
154
+ // args preview carries the URL, whose hostname is canonicalized here. An
155
+ // unparsable payload keeps today's whole-tool rule.
156
+ if (isWebFetchRuleTool(name) && preview?.kind === 'args') {
157
+ try {
158
+ const parsed = JSON.parse(preview.json);
159
+ const url = parsed.url;
160
+ if (typeof url === 'string') {
161
+ const hostname = canonicalizeHostname(url);
162
+ if (hostname !== undefined)
163
+ return ruleString('WebFetch', `domain:${hostname}`);
164
+ }
165
+ }
166
+ catch {
167
+ // Malformed JSON or missing url — fall through to the whole-tool rule.
168
+ }
169
+ }
170
+ return name;
171
+ }
172
+ /** Whether an error is the settings provider's revision-conflict rejection. */
173
+ export function isSettingsConflict(error) {
174
+ const candidate = error;
175
+ if (candidate === null || typeof candidate !== 'object')
176
+ return false;
177
+ return candidate.code === 'SETTINGS_CONFLICT' || candidate.name === 'SettingsConflictError';
178
+ }
179
+ //# sourceMappingURL=approval-preview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"approval-preview.js","sourceRoot":"","sources":["../../src/harness/approval-preview.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AAG/F;;;GAGG;AACH,MAAM,sBAAsB,GAAG,GAAG,CAAA;AAUlC;;;;;;GAMG;AACH,SAAS,MAAM,CAAC,GAAoB;IAClC,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS;QAAE,OAAO,SAAS,CAAA;IAC9C,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAA;IACvC,KAAK,IAAI,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAE,CAAA;QACxB,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW;YAAE,SAAQ;QACxC,IAAI,MAAM,CAAE,KAAK,CAAC,IAA6B,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;YAAE,SAAQ;QACxF,MAAM,GAAG,GAAI,KAAK,CAAC,IAAgC,CAAC,SAAS,CAAA;QAC7D,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,OAAO,SAAS,CAAA;QAC7C,IAAI,CAAC;YACH,MAAM,MAAM,GAAY,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YACvC,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC5E,OAAO,EAAE,IAAI,EAAE,MAAiC,EAAE,CAAA;YACpD,CAAC;QACH,CAAC;QAA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 import type { TranscriptRow } from '../store.ts';
2
+ /**
3
+ * Build the 6-line half-block whale art: vertical row pairs compress to one
4
+ * line ('█' both, '▀' upper only, '▄' lower only). Lines are right-trimmed,
5
+ * then the common left indent is trimmed so alignment survives. Every line
6
+ * is wrapped in its fixed blue SGR foreground and closed with `\x1b[0m`
7
+ * (pi-tui's wrap engine carries active codes across lines).
8
+ */
9
+ export declare function whaleBannerArt(): string;
10
+ /** Boot info line under the whale art (em dash + middle dots, as historically). */
11
+ export declare function bootBannerText(modelLabel: string, cwd: string): string;
12
+ /** The two transcript rows emitted at boot: whale art, then the info line. */
13
+ export declare function bootBannerRows(modelLabel: string, cwd: string): TranscriptRow[];
14
+ //# sourceMappingURL=boot-banner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boot-banner.d.ts","sourceRoot":"","sources":["../../src/harness/boot-banner.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAiDhD;;;;;;GAMG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAmBvC;AAED,mFAAmF;AACnF,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,aAAa,EAAE,CAK/E"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Boot banner art + info text for the CC transcript. Brand art is
3
+ * theme-independent: the whale renders through a fixed deep-to-light blue
4
+ * 256-color ramp regardless of the configured palette.
5
+ * @module @dsh-cc/tui/harness/boot-banner
6
+ */
7
+ import { sgr } from "../components/theme.js";
8
+ /**
9
+ * DeepSeek whale source art, "half-block compressed" (半块压缩版): 11 rows of
10
+ * '█' (filled) / '.' (background), embedded verbatim — pristine. The eye is
11
+ * punched at build time (see {@link EYE}), so the source art above stays
12
+ * untouched and the eye intent is documented here rather than edited in.
13
+ */
14
+ const WHALE_BITMAP = [
15
+ '..........................███......█.......',
16
+ '..........................█████..█████.....',
17
+ '..........█████████.......████████████.....',
18
+ '........███████████████.....█████████......',
19
+ '......███████████████████..██████..........',
20
+ '......████████████████████████.██..........',
21
+ '......███████████████████████████..........',
22
+ '......█████.......██████████████...........',
23
+ '.......██.............█████████............',
24
+ '.........███...........█████████...........',
25
+ '............███████████..███████...........',
26
+ ];
27
+ /**
28
+ * Eye hole: bitmap rows 4 and 5, column 27 (0-based). Rows are paired
29
+ * vertically (0,1),(2,3),(4,5),… so punching both rows keeps the eye inside
30
+ * one half-block pair. Applied at build time over the verbatim bitmap.
31
+ */
32
+ const EYE = [
33
+ [4, 27],
34
+ [5, 27],
35
+ ];
36
+ /**
37
+ * Fixed deep→light 256-color SGR foreground ramp, one per output line. The
38
+ * mid rows anchor on 63 (#5f5fff), the nearest 256-color match to the
39
+ * DeepSeek brand blue #4D6BFE; the ramp stays on the blue axis (no cyan
40
+ * drift) and the belly tops out at 75 (#5fafff).
41
+ */
42
+ const BLUE_RAMP = ['38;5;25', '38;5;26', '38;5;27', '38;5;63', '38;5;69', '38;5;75'];
43
+ /** Bitmap with the eye punched in (filled → background) at the EYE points. */
44
+ const PUNCHED = (() => {
45
+ const rows = WHALE_BITMAP.slice();
46
+ for (const [r, c] of EYE) {
47
+ rows[r] = rows[r].slice(0, c) + '.' + rows[r].slice(c + 1);
48
+ }
49
+ return rows;
50
+ })();
51
+ /**
52
+ * Build the 6-line half-block whale art: vertical row pairs compress to one
53
+ * line ('█' both, '▀' upper only, '▄' lower only). Lines are right-trimmed,
54
+ * then the common left indent is trimmed so alignment survives. Every line
55
+ * is wrapped in its fixed blue SGR foreground and closed with `\x1b[0m`
56
+ * (pi-tui's wrap engine carries active codes across lines).
57
+ */
58
+ export function whaleBannerArt() {
59
+ const lines = [];
60
+ for (let pair = 0; pair * 2 < PUNCHED.length; pair++) {
61
+ const upper = PUNCHED[pair * 2];
62
+ const lower = PUNCHED[pair * 2 + 1] ?? '';
63
+ let line = '';
64
+ for (let col = 0; col < upper.length; col++) {
65
+ const up = upper[col] === '█';
66
+ const low = lower[col] === '█';
67
+ line += up && low ? '█' : up ? '▀' : low ? '▄' : ' ';
68
+ }
69
+ lines.push(line);
70
+ }
71
+ const trimmed = lines.map(line => line.replace(/\s+$/, ''));
72
+ const indent = Math.min(...trimmed.map(line => line.length - line.trimStart().length));
73
+ return trimmed
74
+ .map(line => line.slice(indent))
75
+ .map((line, i) => sgr(BLUE_RAMP[i % BLUE_RAMP.length])(line))
76
+ .join('\n');
77
+ }
78
+ /** Boot info line under the whale art (em dash + middle dots, as historically). */
79
+ export function bootBannerText(modelLabel, cwd) {
80
+ return `dsh cc-mode — ${modelLabel} · ${cwd} · /tui-help for keys`;
81
+ }
82
+ /** The two transcript rows emitted at boot: whale art, then the info line. */
83
+ export function bootBannerRows(modelLabel, cwd) {
84
+ return [
85
+ { kind: 'banner', text: whaleBannerArt() },
86
+ { kind: 'status', text: bootBannerText(modelLabel, cwd) },
87
+ ];
88
+ }
89
+ //# sourceMappingURL=boot-banner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"boot-banner.js","sourceRoot":"","sources":["../../src/harness/boot-banner.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAA;AAG5C;;;;;GAKG;AACH,MAAM,YAAY,GAAG;IACnB,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;IAC7C,6CAA6C;CAC9C,CAAA;AAED;;;;GAIG;AACH,MAAM,GAAG,GAAuD;IAC9D,CAAC,CAAC,EAAE,EAAE,CAAC;IACP,CAAC,CAAC,EAAE,EAAE,CAAC;CACR,CAAA;AAED;;;;;GAKG;AACH,MAAM,SAAS,GAAG,CAA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ver factory.
3
+ *
4
+ * createDriver used to hold these locals inline: resolveEfforts / stalePair /
5
+ * seedDefaultModel, the resume marker + prompt/bash histories, the tool
6
+ * presenters, history folding, and the model-command catalog. They only read
7
+ * `ctx`/`current`/`selection`/`liveMode` off `rt` (DriverAgentCtx), so they
8
+ * migrate here as a free-function collaborator to keep the factory under the
9
+ * 500-line budget — the same pattern as the other harness/driver-*.ts leaves.
10
+ *
11
+ * Mutable state the other sections rebind (`markedContent`, `history`,
12
+ * `bashHistory`) is owned HERE and exposed through get/set/append handles so
13
+ * no other module captures a stale copy.
14
+ * @module @dsh-cc/tui/harness/driver-agent
15
+ */
16
+ import { type TuiState } from '../store.ts';
17
+ import { type ToolPresenters } from '../transcript.ts';
18
+ import type { CatalogEntry } from '../model-catalog.ts';
19
+ import type { ShellExecutorLike } from '../state/driver-types.ts';
20
+ import type { DriverAgentCtx, DriverSessionEventsCtx } from './driver-ctx.ts';
21
+ /**
22
+ * The slice of createDriver's model/history cluster that the session/event
23
+ * listener needs: it folds events onto fresh state and presents tool cards for
24
+ * the live agent.
25
+ */
26
+ export declare function attachSessionEvents(rt: DriverSessionEventsCtx): void;
27
+ /**
28
+ * The handle object returned by {@link createAgentSection}. createDriver
29
+ * destructures these into its locals and threads them into the other sections.
30
+ */
31
+ export interface AgentSection {
32
+ resolveEfforts(provider: string, model: string): Promise<readonly {
33
+ id: string;
34
+ name: string;
35
+ }[] | undefined>;
36
+ stalePair(captured: {
37
+ provider: string;
38
+ model: string;
39
+ }): boolean;
40
+ seedDefaultModel(reset?: boolean): Promise<void>;
41
+ /**
42
+ * Await the boot default-model seed (kicked once, shared promise). Model-turn
43
+ * paths must await this before dispatch so a turn never runs with an
44
+ * unresolved selection. Resolves even when the seed failed.
45
+ */
46
+ waitForModel(): Promise<void>;
47
+ /** Bounded boot-frame wait (never blocks on a slow seed). */
48
+ awaitBootFrame(): Promise<void>;
49
+ persistResumeTarget(): void;
50
+ getMarkedContent(): boolean;
51
+ setMarkedContent(value: boolean): void;
52
+ historyDir: string | undefined;
53
+ /**
54
+ * Rebind prompt/bash history to a new data directory and reload both from
55
+ * disk. Used by /resume to re-scope history onto the switched session's
56
+ * project (a no-op caller-side when the project is unchanged).
57
+ */
58
+ bindHistoryDir(dir: string | undefined): void;
59
+ getHistory(): string[];
60
+ setHistory(next: string[]): void;
61
+ getBashHistory(): string[];
62
+ appendBashHistory(command: string): void;
63
+ /** Tool presenters (absent when no tools service mounted). */
64
+ presenters: ToolPresenters | undefined;
65
+ /** Shell executor seam for `!` commands (used by the bash section). */
66
+ shell: ShellExecutorLike | undefined;
67
+ /** Fold the live session's event log onto the current view-model. */
68
+ foldHistory(): TuiState;
69
+ loadCatalog(): Promise<CatalogEntry[]>;
70
+ }
71
+ /**
72
+ * Build the agent-model/history cluster. Returns handles createDriver threads
73
+ * into the picker/session/run-local/queue sections and the Driver API, and
74
+ * exposes the owned `markedContent`/`history`/`bashHistory` state through
75
+ * get/set seams so no other module captures a stale copy.
76
+ */
77
+ export declare function createAgentSection(rt: DriverAgentCtx): AgentSection;
78
+ //# sourceMappingURL=driver-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"driver-agent.d.ts","sourceRoot":"","sources":["../../src/harness/driver-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAQH,OAAO,EAOL,KAAK,QAAQ,EACd,MAAM,aAAa,CAAA;AACpB,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAGV,iBAAiB,EAElB,MAAM,0BAA0B,CAAA;AACjC,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AAE7E;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,sBAAsB,GAAG,IAAI,CAuEpE;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;I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