@agi-fans/dsh-tui 0.20.0 → 0.22.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 (319) hide show
  1. package/lib/CHANGELOG.md +249 -3
  2. package/lib/chrome/box.d.ts +47 -16
  3. package/lib/chrome/box.js +172 -130
  4. package/lib/chrome/box.js.map +1 -1
  5. package/lib/chrome/code-highlight.d.ts +15 -0
  6. package/lib/chrome/code-highlight.js +60 -4
  7. package/lib/chrome/code-highlight.js.map +1 -1
  8. package/lib/chrome/command-output.d.ts +29 -2
  9. package/lib/chrome/command-output.js +100 -4
  10. package/lib/chrome/command-output.js.map +1 -1
  11. package/lib/chrome/main-screen-renderer.d.ts +18 -0
  12. package/lib/chrome/main-screen-renderer.js +58 -5
  13. package/lib/chrome/main-screen-renderer.js.map +1 -1
  14. package/lib/chrome/markdown.js +30 -10
  15. package/lib/chrome/markdown.js.map +1 -1
  16. package/lib/chrome/relative-time.d.ts +17 -0
  17. package/lib/chrome/relative-time.js +36 -0
  18. package/lib/chrome/relative-time.js.map +1 -1
  19. package/lib/chrome/renderer.d.ts +9 -0
  20. package/lib/chrome/renderer.js +1 -1
  21. package/lib/chrome/renderer.js.map +1 -1
  22. package/lib/chrome/secret-mask.d.ts +35 -0
  23. package/lib/chrome/secret-mask.js +180 -0
  24. package/lib/chrome/secret-mask.js.map +1 -0
  25. package/lib/chrome/status-config.d.ts +161 -51
  26. package/lib/chrome/status-config.js +237 -126
  27. package/lib/chrome/status-config.js.map +1 -1
  28. package/lib/chrome/status-line.d.ts +3 -2
  29. package/lib/chrome/status-line.js +105 -63
  30. package/lib/chrome/status-line.js.map +1 -1
  31. package/lib/chrome/terminal-colors.d.ts +85 -0
  32. package/lib/chrome/terminal-colors.js +230 -0
  33. package/lib/chrome/terminal-colors.js.map +1 -0
  34. package/lib/chrome/terminal-images.d.ts +9 -1
  35. package/lib/chrome/terminal-images.js +27 -4
  36. package/lib/chrome/terminal-images.js.map +1 -1
  37. package/lib/chrome/theme.d.ts +32 -9
  38. package/lib/chrome/theme.js +616 -520
  39. package/lib/chrome/theme.js.map +1 -1
  40. package/lib/chrome/tool-args.d.ts +1 -1
  41. package/lib/chrome/tool-args.js +3 -1
  42. package/lib/chrome/tool-args.js.map +1 -1
  43. package/lib/chrome/tool-renderers.d.ts +2 -0
  44. package/lib/chrome/tool-renderers.js +69 -3
  45. package/lib/chrome/tool-renderers.js.map +1 -1
  46. package/lib/chrome/tools-list.d.ts +1 -4
  47. package/lib/chrome/tools-list.js +1 -41
  48. package/lib/chrome/tools-list.js.map +1 -1
  49. package/lib/chrome/welcome-tips.d.ts +20 -7
  50. package/lib/chrome/welcome-tips.js +22 -41
  51. package/lib/chrome/welcome-tips.js.map +1 -1
  52. package/lib/commands/auth-ids.d.ts +25 -0
  53. package/lib/commands/auth-ids.js +27 -0
  54. package/lib/commands/auth-ids.js.map +1 -0
  55. package/lib/commands/auth-input.d.ts +34 -0
  56. package/lib/commands/auth-input.js +96 -0
  57. package/lib/commands/auth-input.js.map +1 -0
  58. package/lib/commands/auth-providers.d.ts +39 -0
  59. package/lib/commands/auth-providers.js +125 -0
  60. package/lib/commands/auth-providers.js.map +1 -0
  61. package/lib/commands/auth.d.ts +16 -22
  62. package/lib/commands/auth.js +346 -299
  63. package/lib/commands/auth.js.map +1 -1
  64. package/lib/commands/btw.d.ts +27 -0
  65. package/lib/commands/btw.js +59 -0
  66. package/lib/commands/btw.js.map +1 -0
  67. package/lib/commands/diff.js +30 -5
  68. package/lib/commands/diff.js.map +1 -1
  69. package/lib/commands/export.d.ts +1 -1
  70. package/lib/commands/export.js +5 -3
  71. package/lib/commands/export.js.map +1 -1
  72. package/lib/commands/files.d.ts +17 -1
  73. package/lib/commands/files.js +69 -61
  74. package/lib/commands/files.js.map +1 -1
  75. package/lib/commands/integrations.js +18 -6
  76. package/lib/commands/integrations.js.map +1 -1
  77. package/lib/commands/jobs.d.ts +19 -4
  78. package/lib/commands/jobs.js +50 -7
  79. package/lib/commands/jobs.js.map +1 -1
  80. package/lib/commands/model.js +109 -76
  81. package/lib/commands/model.js.map +1 -1
  82. package/lib/commands/permission.js +46 -13
  83. package/lib/commands/permission.js.map +1 -1
  84. package/lib/commands/plugins.js +196 -42
  85. package/lib/commands/plugins.js.map +1 -1
  86. package/lib/commands/schedule.d.ts +29 -0
  87. package/lib/commands/schedule.js +228 -0
  88. package/lib/commands/schedule.js.map +1 -0
  89. package/lib/commands/session-configuration.d.ts +1 -1
  90. package/lib/commands/session-configuration.js +29 -28
  91. package/lib/commands/session-configuration.js.map +1 -1
  92. package/lib/commands/session.js +75 -80
  93. package/lib/commands/session.js.map +1 -1
  94. package/lib/commands/terminal.d.ts +24 -4
  95. package/lib/commands/terminal.js +38 -94
  96. package/lib/commands/terminal.js.map +1 -1
  97. package/lib/commands/trajectory.js +4 -1
  98. package/lib/commands/trajectory.js.map +1 -1
  99. package/lib/definition.d.ts +150 -11
  100. package/lib/index.d.ts +1 -0
  101. package/lib/index.js +1 -0
  102. package/lib/index.js.map +1 -1
  103. package/lib/input/actions.d.ts +51 -0
  104. package/lib/input/actions.js +120 -0
  105. package/lib/input/actions.js.map +1 -0
  106. package/lib/input/editor-discovery.js +2 -2
  107. package/lib/input/editor-discovery.js.map +1 -1
  108. package/lib/input/editor.d.ts +0 -10
  109. package/lib/input/editor.js +11 -9
  110. package/lib/input/editor.js.map +1 -1
  111. package/lib/input/image-paste.d.ts +19 -1
  112. package/lib/input/image-paste.js +82 -1
  113. package/lib/input/image-paste.js.map +1 -1
  114. package/lib/input/keybindings-config.d.ts +15 -4
  115. package/lib/input/keybindings-config.js +57 -35
  116. package/lib/input/keybindings-config.js.map +1 -1
  117. package/lib/input/keys.d.ts +18 -0
  118. package/lib/input/keys.js +48 -3
  119. package/lib/input/keys.js.map +1 -1
  120. package/lib/input/wheel-scroll.d.ts +46 -0
  121. package/lib/input/wheel-scroll.js +69 -0
  122. package/lib/input/wheel-scroll.js.map +1 -0
  123. package/lib/prompt-intents.d.ts +182 -0
  124. package/lib/prompt-intents.js +127 -0
  125. package/lib/prompt-intents.js.map +1 -0
  126. package/lib/runtime/agent-profile.d.ts +5 -0
  127. package/lib/runtime/agent-profile.js +12 -0
  128. package/lib/runtime/agent-profile.js.map +1 -1
  129. package/lib/runtime/approval-rules.d.ts +59 -0
  130. package/lib/runtime/approval-rules.js +179 -0
  131. package/lib/runtime/approval-rules.js.map +1 -0
  132. package/lib/runtime/btw-policy.d.ts +7 -0
  133. package/lib/runtime/btw-policy.js +18 -0
  134. package/lib/runtime/btw-policy.js.map +1 -0
  135. package/lib/runtime/btw.d.ts +47 -0
  136. package/lib/runtime/btw.js +200 -0
  137. package/lib/runtime/btw.js.map +1 -0
  138. package/lib/runtime/cancellable.d.ts +75 -0
  139. package/lib/runtime/cancellable.js +76 -0
  140. package/lib/runtime/cancellable.js.map +1 -0
  141. package/lib/runtime/composer-images.js +5 -4
  142. package/lib/runtime/composer-images.js.map +1 -1
  143. package/lib/runtime/composer-shell.d.ts +30 -0
  144. package/lib/runtime/composer-shell.js +150 -0
  145. package/lib/runtime/composer-shell.js.map +1 -0
  146. package/lib/runtime/file-recovery-local.d.ts +73 -0
  147. package/lib/runtime/file-recovery-local.js +351 -0
  148. package/lib/runtime/file-recovery-local.js.map +1 -0
  149. package/lib/runtime/file-recovery-recording.d.ts +23 -0
  150. package/lib/runtime/file-recovery-recording.js +131 -0
  151. package/lib/runtime/file-recovery-recording.js.map +1 -0
  152. package/lib/runtime/file-recovery-review.d.ts +3 -0
  153. package/lib/runtime/file-recovery-review.js +130 -0
  154. package/lib/runtime/file-recovery-review.js.map +1 -0
  155. package/lib/runtime/file-recovery-store.d.ts +83 -0
  156. package/lib/runtime/file-recovery-store.js +329 -0
  157. package/lib/runtime/file-recovery-store.js.map +1 -0
  158. package/lib/runtime/file-recovery-worker.d.ts +22 -0
  159. package/lib/runtime/file-recovery-worker.js +153 -0
  160. package/lib/runtime/file-recovery-worker.js.map +1 -0
  161. package/lib/runtime/file-review.d.ts +6 -3
  162. package/lib/runtime/file-review.js +44 -7
  163. package/lib/runtime/file-review.js.map +1 -1
  164. package/lib/runtime/herdr-agent.d.ts +4 -13
  165. package/lib/runtime/herdr-agent.js +19 -63
  166. package/lib/runtime/herdr-agent.js.map +1 -1
  167. package/lib/runtime/plain-tui.d.ts +2 -0
  168. package/lib/runtime/plain-tui.js +7 -1
  169. package/lib/runtime/plain-tui.js.map +1 -1
  170. package/lib/runtime/plugin-settings.d.ts +25 -2
  171. package/lib/runtime/plugin-settings.js +329 -31
  172. package/lib/runtime/plugin-settings.js.map +1 -1
  173. package/lib/runtime/provider-local.d.ts +81 -24
  174. package/lib/runtime/provider-local.js +1807 -608
  175. package/lib/runtime/provider-local.js.map +1 -1
  176. package/lib/runtime/runner.js +52 -12
  177. package/lib/runtime/runner.js.map +1 -1
  178. package/lib/runtime/session-archive.d.ts +6 -0
  179. package/lib/runtime/session-archive.js +129 -3
  180. package/lib/runtime/session-archive.js.map +1 -1
  181. package/lib/runtime/session-runtime.js +1 -1
  182. package/lib/runtime/session-runtime.js.map +1 -1
  183. package/lib/runtime/settings-preferences.d.ts +5 -0
  184. package/lib/runtime/settings-preferences.js +34 -0
  185. package/lib/runtime/settings-preferences.js.map +1 -0
  186. package/lib/runtime/startup-notices.js +2 -0
  187. package/lib/runtime/startup-notices.js.map +1 -1
  188. package/lib/runtime/terminal-modes.d.ts +47 -0
  189. package/lib/runtime/terminal-modes.js +86 -0
  190. package/lib/runtime/terminal-modes.js.map +1 -0
  191. package/lib/runtime/terminal-notifications.d.ts +3 -5
  192. package/lib/runtime/terminal-notifications.js +4 -8
  193. package/lib/runtime/terminal-notifications.js.map +1 -1
  194. package/lib/runtime/terminal-probe.d.ts +36 -0
  195. package/lib/runtime/terminal-probe.js +37 -0
  196. package/lib/runtime/terminal-probe.js.map +1 -0
  197. package/lib/runtime/terminal-session.d.ts +57 -0
  198. package/lib/runtime/terminal-session.js +164 -0
  199. package/lib/runtime/terminal-session.js.map +1 -0
  200. package/lib/runtime/terminal-state.d.ts +29 -0
  201. package/lib/runtime/terminal-state.js +62 -0
  202. package/lib/runtime/terminal-state.js.map +1 -0
  203. package/lib/runtime/tool-presentation.js +50 -14
  204. package/lib/runtime/tool-presentation.js.map +1 -1
  205. package/lib/session/external-agents.d.ts +5 -0
  206. package/lib/session/external-agents.js +27 -0
  207. package/lib/session/external-agents.js.map +1 -0
  208. package/lib/session/feature-toggles.d.ts +1 -1
  209. package/lib/session/feature-toggles.js +1 -1
  210. package/lib/session/interaction-adapter.d.ts +1 -6
  211. package/lib/session/interaction-adapter.js +95 -18
  212. package/lib/session/interaction-adapter.js.map +1 -1
  213. package/lib/session/message-queue.js +1 -1
  214. package/lib/session/message-queue.js.map +1 -1
  215. package/lib/session/model-readiness.d.ts +16 -0
  216. package/lib/session/model-readiness.js +43 -0
  217. package/lib/session/model-readiness.js.map +1 -0
  218. package/lib/session/package-metadata.d.ts +8 -0
  219. package/lib/session/package-metadata.js +8 -0
  220. package/lib/session/package-metadata.js.map +1 -1
  221. package/lib/session/project-context.d.ts +5 -0
  222. package/lib/session/project-context.js +36 -0
  223. package/lib/session/project-context.js.map +1 -1
  224. package/lib/session/session-controller.d.ts +10 -13
  225. package/lib/session/session-controller.js +183 -98
  226. package/lib/session/session-controller.js.map +1 -1
  227. package/lib/session/session-library.js +2 -0
  228. package/lib/session/session-library.js.map +1 -1
  229. package/lib/session/session-tree.d.ts +3 -0
  230. package/lib/session/session-tree.js +3 -1
  231. package/lib/session/session-tree.js.map +1 -1
  232. package/lib/session/subagent-roster.d.ts +2 -1
  233. package/lib/session/subagent-roster.js +24 -3
  234. package/lib/session/subagent-roster.js.map +1 -1
  235. package/lib/session/subagent-tracker.d.ts +6 -2
  236. package/lib/session/subagent-tracker.js +49 -2
  237. package/lib/session/subagent-tracker.js.map +1 -1
  238. package/lib/session/tui-settings.d.ts +47 -13
  239. package/lib/session/tui-settings.js +76 -34
  240. package/lib/session/tui-settings.js.map +1 -1
  241. package/lib/session/working-directory.d.ts +4 -0
  242. package/lib/session/working-directory.js +4 -0
  243. package/lib/session/working-directory.js.map +1 -0
  244. package/lib/session/worktrees.d.ts +13 -0
  245. package/lib/session/worktrees.js +49 -0
  246. package/lib/session/worktrees.js.map +1 -0
  247. package/lib/views/approval-rule.d.ts +3 -0
  248. package/lib/views/approval-rule.js +4 -0
  249. package/lib/views/approval-rule.js.map +1 -0
  250. package/lib/views/at-complete.d.ts +8 -0
  251. package/lib/views/at-complete.js +64 -2
  252. package/lib/views/at-complete.js.map +1 -1
  253. package/lib/views/autocomplete.d.ts +22 -2
  254. package/lib/views/autocomplete.js +70 -40
  255. package/lib/views/autocomplete.js.map +1 -1
  256. package/lib/views/copy-targets.d.ts +13 -14
  257. package/lib/views/copy-targets.js +42 -54
  258. package/lib/views/copy-targets.js.map +1 -1
  259. package/lib/views/document-reader.js +18 -5
  260. package/lib/views/document-reader.js.map +1 -1
  261. package/lib/views/event-views.d.ts +1 -1
  262. package/lib/views/event-views.js +60 -6
  263. package/lib/views/event-views.js.map +1 -1
  264. package/lib/views/file-actions.d.ts +12 -0
  265. package/lib/views/file-actions.js +72 -0
  266. package/lib/views/file-actions.js.map +1 -0
  267. package/lib/views/history-search.js +15 -21
  268. package/lib/views/history-search.js.map +1 -1
  269. package/lib/views/hotkeys.d.ts +8 -1
  270. package/lib/views/hotkeys.js +53 -26
  271. package/lib/views/hotkeys.js.map +1 -1
  272. package/lib/views/list-navigation.d.ts +62 -0
  273. package/lib/views/list-navigation.js +73 -0
  274. package/lib/views/list-navigation.js.map +1 -0
  275. package/lib/views/list-view.d.ts +99 -0
  276. package/lib/views/list-view.js +165 -0
  277. package/lib/views/list-view.js.map +1 -0
  278. package/lib/views/prompt-selector.d.ts +34 -4
  279. package/lib/views/prompt-selector.js +270 -134
  280. package/lib/views/prompt-selector.js.map +1 -1
  281. package/lib/views/session-files.d.ts +1 -2
  282. package/lib/views/session-files.js +1 -11
  283. package/lib/views/session-files.js.map +1 -1
  284. package/lib/views/settings-list.d.ts +51 -10
  285. package/lib/views/settings-list.js +267 -315
  286. package/lib/views/settings-list.js.map +1 -1
  287. package/lib/views/trajectory-timeline.d.ts +72 -0
  288. package/lib/views/trajectory-timeline.js +133 -0
  289. package/lib/views/trajectory-timeline.js.map +1 -0
  290. package/lib/views/trajectory.d.ts +15 -4
  291. package/lib/views/trajectory.js +557 -123
  292. package/lib/views/trajectory.js.map +1 -1
  293. package/lib/views/transcript-export.js +9 -0
  294. package/lib/views/transcript-export.js.map +1 -1
  295. package/lib/views/transcript-render.d.ts +97 -25
  296. package/lib/views/transcript-render.js +542 -170
  297. package/lib/views/transcript-render.js.map +1 -1
  298. package/lib/views/transcript-search.d.ts +39 -6
  299. package/lib/views/transcript-search.js +46 -11
  300. package/lib/views/transcript-search.js.map +1 -1
  301. package/lib/views/transcript-types.d.ts +63 -5
  302. package/lib/views/transcript-types.js +23 -11
  303. package/lib/views/transcript-types.js.map +1 -1
  304. package/package.json +95 -65
  305. package/lib/commands/loop.d.ts +0 -52
  306. package/lib/commands/loop.js +0 -307
  307. package/lib/commands/loop.js.map +0 -1
  308. package/lib/commands/steer.d.ts +0 -5
  309. package/lib/commands/steer.js +0 -24
  310. package/lib/commands/steer.js.map +0 -1
  311. package/lib/runtime/terminal-reader.d.ts +0 -11
  312. package/lib/runtime/terminal-reader.js +0 -87
  313. package/lib/runtime/terminal-reader.js.map +0 -1
  314. package/lib/views/agent-hub.d.ts +0 -32
  315. package/lib/views/agent-hub.js +0 -206
  316. package/lib/views/agent-hub.js.map +0 -1
  317. package/lib/views/copy-selector.d.ts +0 -51
  318. package/lib/views/copy-selector.js +0 -139
  319. package/lib/views/copy-selector.js.map +0 -1
@@ -0,0 +1,230 @@
1
+ /**
2
+ * Colors the terminal reports about itself (OSC 10 foreground, OSC 11
3
+ * background, OSC 4 palette entries, CSI ?997 color scheme) and the perceptual
4
+ * math used to adapt a palette to them.
5
+ *
6
+ * A terminal only answers these when it is interactive and willing; every
7
+ * helper here is pure so a caller can probe once, keep whatever arrived, and
8
+ * fall back to the shipped palettes when nothing did.
9
+ * @module @agi-fans/dsh-tui/terminal-colors
10
+ */
11
+ /**
12
+ * Query the default foreground, background and all sixteen palette entries.
13
+ * `ST` terminates instead of `BEL` because a query is written before the
14
+ * terminal has proven it understands either form.
15
+ */
16
+ export const COLOR_QUERY = '\x1b]10;?\x1b\\\x1b]11;?\x1b\\'
17
+ + Array.from({ length: 16 }, (_, index) => `\x1b]4;${index};?\x1b\\`).join('');
18
+ /** Query whether the terminal considers itself dark or light (CSI ?997). */
19
+ export const COLOR_SCHEME_QUERY = '\x1b[?997;?n';
20
+ const OSC_COLOR_REPLY = /^(?:1([01])|4;(\d{1,3}));(.+)$/u;
21
+ const HEX6 = /^#([0-9a-f]{6})$/iu;
22
+ const HEX12 = /^#([0-9a-f]{12})$/iu;
23
+ const RGB_SPEC = /^rgba?:([0-9a-f]{1,4})\/([0-9a-f]{1,4})\/([0-9a-f]{1,4})$/iu;
24
+ function channel(hex) {
25
+ return Math.round((Number.parseInt(hex, 16) / (16 ** hex.length - 1)) * 255);
26
+ }
27
+ /** Parse one OSC 10/11/4 reply body (the text between the introducer and the terminator). */
28
+ export function parseOscColorReply(body) {
29
+ const match = OSC_COLOR_REPLY.exec(body);
30
+ if (match === null)
31
+ return undefined;
32
+ const target = match[1] === '0' ? 'foreground'
33
+ : match[1] === '1' ? 'background'
34
+ : Number.parseInt(match[2] ?? '', 10);
35
+ if (typeof target === 'number' && !(target >= 0 && target <= 15))
36
+ return undefined;
37
+ const color = parseColorSpec(match[3] ?? '');
38
+ return color === undefined ? { target } : { target, color };
39
+ }
40
+ /** Parse the color spec a terminal uses in a color reply (`#rrggbb`, `#rrrrggggbbbb`, `rgb:r/g/b`). */
41
+ export function parseColorSpec(spec) {
42
+ const value = spec.trim();
43
+ const hex6 = HEX6.exec(value);
44
+ if (hex6 !== null) {
45
+ const hex = hex6[1];
46
+ return { r: Number.parseInt(hex.slice(0, 2), 16), g: Number.parseInt(hex.slice(2, 4), 16), b: Number.parseInt(hex.slice(4, 6), 16) };
47
+ }
48
+ const hex12 = HEX12.exec(value);
49
+ if (hex12 !== null) {
50
+ const hex = hex12[1];
51
+ return { r: channel(hex.slice(0, 4)), g: channel(hex.slice(4, 8)), b: channel(hex.slice(8, 12)) };
52
+ }
53
+ const rgb = RGB_SPEC.exec(value);
54
+ if (rgb !== null)
55
+ return { r: channel(rgb[1]), g: channel(rgb[2]), b: channel(rgb[3]) };
56
+ return undefined;
57
+ }
58
+ /** Parse a CSI ?997 report; `2` means the terminal describes itself as light. */
59
+ export function parseSchemeReply(data) {
60
+ const match = /^\x1b\[\?997;([12])n$/u.exec(data);
61
+ if (match === null)
62
+ return undefined;
63
+ return match[1] === '2' ? 'light' : 'dark';
64
+ }
65
+ /** Fold one reply into the accumulated description, keeping earlier fields the reply does not answer. */
66
+ export function mergeColorReply(colors, reply) {
67
+ if (reply.target === 'foreground')
68
+ return reply.color === undefined ? colors : { ...colors, foreground: reply.color };
69
+ if (reply.target === 'background')
70
+ return reply.color === undefined ? colors : { ...colors, background: reply.color };
71
+ if (reply.color === undefined)
72
+ return colors;
73
+ const entries = Array.from({ length: 16 }, (_, index) => colors.entries?.[index] ?? colors.palette?.[index]);
74
+ entries[reply.target] = reply.color;
75
+ // Publishing needs every index present; the accumulator keeps the partial
76
+ // report until then.
77
+ return entries.every((entry) => entry !== undefined)
78
+ ? { ...colors, entries, palette: entries }
79
+ : { ...colors, entries };
80
+ }
81
+ /**
82
+ * Stable key for everything reported colors can change; two reports with the
83
+ * same colors produce the same key, so caches never stale-hit across a
84
+ * light/dark switch.
85
+ */
86
+ export function terminalColorsKey(colors) {
87
+ if (colors === undefined)
88
+ return '';
89
+ // Every frame asks once per cached block; a new report is a new object.
90
+ const known = terminalColorsKeys.get(colors);
91
+ if (known !== undefined)
92
+ return known;
93
+ const rgb = (color) => color === undefined ? '' : `${color.r},${color.g},${color.b}`;
94
+ const key = [rgb(colors.foreground), rgb(colors.background), colors.scheme ?? '', (colors.palette ?? []).map(rgb).join(';')].join('|');
95
+ terminalColorsKeys.set(colors, key);
96
+ return key;
97
+ }
98
+ const terminalColorsKeys = new WeakMap();
99
+ /** Convert one 8-bit sRGB color to Oklab (Björn Ottosson's transform). */
100
+ export function toOklab(color) {
101
+ const linear = (value) => {
102
+ const channelValue = value / 255;
103
+ return channelValue <= 0.04045 ? channelValue / 12.92 : ((channelValue + 0.055) / 1.055) ** 2.4;
104
+ };
105
+ const r = linear(color.r);
106
+ const g = linear(color.g);
107
+ const b = linear(color.b);
108
+ const l = Math.cbrt(0.412_221_470_8 * r + 0.536_332_536_3 * g + 0.051_445_992_9 * b);
109
+ const m = Math.cbrt(0.211_903_498_2 * r + 0.680_699_545_1 * g + 0.107_396_956_6 * b);
110
+ const s = Math.cbrt(0.088_302_461_9 * r + 0.281_718_837_6 * g + 0.629_978_700_5 * b);
111
+ return [
112
+ 0.210_454_255_3 * l + 0.793_617_785 * m - 0.004_072_046_8 * s,
113
+ 1.977_998_495_1 * l - 2.428_592_205 * m + 0.450_593_709_9 * s,
114
+ 0.025_904_037_1 * l + 0.782_771_766_2 * m - 0.808_675_766 * s,
115
+ ];
116
+ }
117
+ /** Squared Oklab distance; ordering is all that matters for nearest-color picks. */
118
+ export function labDistance(left, right) {
119
+ const dl = left[0] - right[0];
120
+ const da = left[1] - right[1];
121
+ const db = left[2] - right[2];
122
+ return dl * dl + da * da + db * db;
123
+ }
124
+ /**
125
+ * Index of the palette entry closest to `color` in Oklab, which is what a
126
+ * 16-color terminal can actually show. Returns undefined for an empty palette.
127
+ */
128
+ export function nearestPaletteIndex(color, palette) {
129
+ if (palette.length === 0)
130
+ return undefined;
131
+ const target = toOklab(color);
132
+ let best;
133
+ let bestDistance = Number.POSITIVE_INFINITY;
134
+ for (let index = 0; index < palette.length; index += 1) {
135
+ const entry = palette[index];
136
+ // A caller may hand us a partial report; a missing entry is not a color.
137
+ if (entry === undefined)
138
+ continue;
139
+ const distance = labDistance(target, toOklab(entry));
140
+ if (distance < bestDistance) {
141
+ bestDistance = distance;
142
+ best = index;
143
+ }
144
+ }
145
+ return best;
146
+ }
147
+ /** WCAG relative luminance of one color. */
148
+ export function relativeLuminance(color) {
149
+ const channelLuminance = (value) => {
150
+ const channelValue = value / 255;
151
+ return channelValue <= 0.039_28 ? channelValue / 12.92 : ((channelValue + 0.055) / 1.055) ** 2.4;
152
+ };
153
+ return 0.2126 * channelLuminance(color.r) + 0.7152 * channelLuminance(color.g) + 0.0722 * channelLuminance(color.b);
154
+ }
155
+ /** WCAG contrast ratio; 1 means identical colors. */
156
+ export function contrastRatio(left, right) {
157
+ const a = relativeLuminance(left);
158
+ const b = relativeLuminance(right);
159
+ return (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);
160
+ }
161
+ /** The xterm 256-color entries above the sixteen the user configures: the 6×6×6 cube and the gray ramp. */
162
+ const XTERM_256 = (() => {
163
+ const levels = [0, 95, 135, 175, 215, 255];
164
+ const entries = [];
165
+ for (let index = 16; index < 232; index += 1) {
166
+ const offset = index - 16;
167
+ entries.push({ index, lab: toOklab({ r: levels[Math.floor(offset / 36)], g: levels[Math.floor(offset / 6) % 6], b: levels[offset % 6] }) });
168
+ }
169
+ for (let index = 232; index < 256; index += 1) {
170
+ const value = 8 + (index - 232) * 10;
171
+ entries.push({ index, lab: toOklab({ r: value, g: value, b: value }) });
172
+ }
173
+ return entries;
174
+ })();
175
+ const xterm256Cache = new Map();
176
+ /**
177
+ * The xterm-256 entry closest to `color` in Oklab, from the fixed cube and
178
+ * gray ramp only: indices 0-15 follow the user's palette and would make the
179
+ * result depend on a terminal theme we cannot see.
180
+ */
181
+ /** First xterm-256 index of the 24-step neutral ramp. */
182
+ const GREY_RAMP_START = 232;
183
+ /**
184
+ * Nearest xterm-256 entry, restricted to the 24-step neutral ramp.
185
+ *
186
+ * The ramp is `232..255`, and it exists because a *surface* swatch is usually a
187
+ * near-neutral. Left to the whole palette, three swatches that differ by a few
188
+ * units of warmth all land on one entry, which is why a pending, a successful,
189
+ * and a failed tool card used to share a single fill on a 256-color terminal.
190
+ * `hueSteps` keeps that from happening: see {@link surfaceXterm256}.
191
+ */
192
+ export function nearestXterm256Grey(color) {
193
+ const key = `g:${color.r},${color.g},${color.b}`;
194
+ const known = xterm256Cache.get(key);
195
+ if (known !== undefined)
196
+ return known;
197
+ const target = toOklab(color);
198
+ let best = GREY_RAMP_START;
199
+ let bestDistance = Number.POSITIVE_INFINITY;
200
+ for (const entry of XTERM_256) {
201
+ if (entry.index < GREY_RAMP_START)
202
+ continue;
203
+ const distance = labDistance(target, entry.lab);
204
+ if (distance < bestDistance) {
205
+ bestDistance = distance;
206
+ best = entry.index;
207
+ }
208
+ }
209
+ xterm256Cache.set(key, best);
210
+ return best;
211
+ }
212
+ export function nearestXterm256(color) {
213
+ const key = `${color.r},${color.g},${color.b}`;
214
+ const known = xterm256Cache.get(key);
215
+ if (known !== undefined)
216
+ return known;
217
+ const target = toOklab(color);
218
+ let best = 16;
219
+ let bestDistance = Number.POSITIVE_INFINITY;
220
+ for (const entry of XTERM_256) {
221
+ const distance = labDistance(target, entry.lab);
222
+ if (distance < bestDistance) {
223
+ bestDistance = distance;
224
+ best = entry.index;
225
+ }
226
+ }
227
+ xterm256Cache.set(key, best);
228
+ return best;
229
+ }
230
+ //# sourceMappingURL=terminal-colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal-colors.js","sourceRoot":"","sources":["../../src/chrome/terminal-colors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA4BH;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,gCAAgC;MACvD,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;AAEhF,4EAA4E;AAC5E,MAAM,CAAC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Q;QAC3C,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;QAC/C,IAAI,QAAQ,GAAG,YAAY,EAAE,CAAC;YAC5B,YAAY,GAAG,QAAQ,CAAA;YACvB,IAAI,GAAG,KAAK,CAAC,KAAK,CAAA;QACpB,CAAC;IACH,CAAC;IACD,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC5B,OAAO,IAAI,CAAA;AACb,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAU;IACxC,MAAM,GAAG,GAAG,GAAG,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAA;IAC9C,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACpC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAA;IACrC,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAA;IAC7B,IAAI,IAAI,GAAG,EAAE,CAAA;IACb,IAAI,YAAY,GAAG,MAAM,CAAC,iBAAiB,CAAA;IAC3C,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE,CAAC;QAC9B,MAAM,QAAQ,GAAG,WAAW,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;QAC/C,IAAI,QAAQ,GAAG,YAAY,EAAE,CAAC;YAC5B,YAAY,GAAG,QAAQ,CAAA;YACvB,IAAI,GAAG,KAAK,CAAC,KAAK,CAAA;QACpB,CAAC;IACH,CAAC;IACD,aAAa,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;IAC5B,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -15,7 +15,15 @@ export interface ImagePlacement {
15
15
  columns: number;
16
16
  rows: number;
17
17
  }
18
- /** Only known direct terminals opt in. Outer-terminal hints do not prove passthrough. */
18
+ /**
19
+ * Which inline-image protocol this terminal speaks, if any.
20
+ *
21
+ * Every hint here is one a terminal actually sets: the Kitty flags, the
22
+ * Ghostty/WezTerm/Warp markers, and the multiplexers that forward the protocol
23
+ * (Herdr and Rex, whose panes leak the outer terminal's variables, so they are
24
+ * decided first). `OMDSH_IMAGE_PROTOCOL` forces an answer when detection is
25
+ * wrong: `kitty`, `iterm2`, or `none`.
26
+ */
19
27
  export declare function imageProtocol(env: NodeJS.ProcessEnv): ImageProtocol | undefined;
20
28
  /** Fit in display cells while preserving the source's pixel aspect ratio. */
21
29
  export declare function imageSize(image: PreviewImage, columns: number, rows: number, cell?: {
@@ -1,11 +1,34 @@
1
- /** Only known direct terminals opt in. Outer-terminal hints do not prove passthrough. */
1
+ /**
2
+ * Which inline-image protocol this terminal speaks, if any.
3
+ *
4
+ * Every hint here is one a terminal actually sets: the Kitty flags, the
5
+ * Ghostty/WezTerm/Warp markers, and the multiplexers that forward the protocol
6
+ * (Herdr and Rex, whose panes leak the outer terminal's variables, so they are
7
+ * decided first). `OMDSH_IMAGE_PROTOCOL` forces an answer when detection is
8
+ * wrong: `kitty`, `iterm2`, or `none`.
9
+ */
2
10
  export function imageProtocol(env) {
3
- if (env.TMUX || env.STY || env.ZELLIJ || env.HERDR_ENV === '1' || /^(?:tmux|screen)/u.test(env.TERM ?? ''))
11
+ const forced = (env.OMDSH_IMAGE_PROTOCOL ?? '').trim().toLowerCase();
12
+ if (forced === 'none')
13
+ return undefined;
14
+ if (forced === 'kitty' || forced === 'iterm2')
15
+ return forced;
16
+ // Multiplexers that do not carry graphics through to the outer terminal.
17
+ if (env.TMUX || env.STY || env.ZELLIJ || /^(?:tmux|screen)/u.test(env.TERM ?? ''))
4
18
  return undefined;
5
19
  const program = (env.TERM_PROGRAM ?? '').toLowerCase();
6
- if (env.KITTY_WINDOW_ID || env.TERM === 'xterm-kitty' || ['ghostty', 'wezterm'].includes(program))
20
+ const term = env.TERM ?? '';
21
+ if (program === 'herdr' || program === 'rex' || env.HERDR_ENV === '1')
22
+ return 'kitty';
23
+ if (env.KITTY_WINDOW_ID || term === 'xterm-kitty' || program === 'kitty')
24
+ return 'kitty';
25
+ if (program === 'ghostty' || term.includes('ghostty') || env.GHOSTTY_RESOURCES_DIR)
26
+ return 'kitty';
27
+ if (env.WEZTERM_PANE || program === 'wezterm')
28
+ return 'kitty';
29
+ if (program === 'warpterminal' || env.WARP_SESSION_ID || env.WARP_TERMINAL_SESSION_UUID)
7
30
  return 'kitty';
8
- if (program === 'iterm.app' || env.LC_TERMINAL === 'iTerm2')
31
+ if (program === 'iterm.app' || env.ITERM_SESSION_ID || env.LC_TERMINAL === 'iTerm2')
9
32
  return 'iterm2';
10
33
  return undefined;
11
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"terminal-images.js","sourceRoot":"","sources":["../../src/chrome/terminal-images.ts"],"names":[],"mappings":"AAoBA,yFAAyF;AACzF,MAAM,UAAU,aAAa,CAAC,GAAsB;IAClD,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,SAAS,KAAK,GAAG,IAAI,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;QAAE,OAAO,SAAS,CAAA;IAC5H,MAAM,OAAO,GAAG,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;IACtD,IAAI,GAAG,CAAC,eAAe,IAAI,GAAG,CAAC,IAAI,KAAK,aAAa,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,OAAO,CAAA;IACjH,IAAI,OAAO,KAAK,WAAW,IAAI,GAAG,CAAC,WAAW,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAA;IAC5E,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,SAAS,CAAC,KAAmB,EAAE,OAAe,EAAE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C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAA;IACxE,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,WAAW,CAAC,EAAU,IAAY,OAAO,mBAAmB,EAAE,YAAY,CAAA,CAAC,CAAC"}
@@ -3,6 +3,7 @@
3
3
  * glyphs used by terminal views.
4
4
  * @module @agi-fans/dsh-tui
5
5
  */
6
+ import { type TerminalColors } from './terminal-colors.ts';
6
7
  /** Rounded-box drawing characters (OMP unicode preset). */
7
8
  export declare const BOX: {
8
9
  readonly topLeft: "╭";
@@ -50,9 +51,17 @@ export declare const SYMBOL: {
50
51
  /** Braille activity spinner (OMP unicode activity frames). */
51
52
  export declare const SPINNER: readonly ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"];
52
53
  /** Semantic colors the view addresses. */
53
- export type ThemeColor = 'accent' | 'border' | 'borderAccent' | 'borderMuted' | 'success' | 'error' | 'warning' | 'muted' | 'dim' | 'text' | 'userMessageText' | 'userMessageBg' | 'toolPendingBg' | 'toolSuccessBg' | 'toolErrorBg' | 'toolTitle' | 'toolOutput' | 'toolDiffAdded' | 'toolDiffRemoved' | 'toolDiffContext' | 'mdHeading' | 'mdLink' | 'mdLinkUrl' | 'mdCode' | 'mdCodeBlock' | 'mdCodeBlockBorder' | 'mdKeyword' | 'syntaxString' | 'syntaxNumber' | 'syntaxFunction' | 'syntaxType' | 'mdQuote' | 'mdListBullet' | 'thinkingText' | 'customMessageLabel';
54
+ export type ThemeColor = 'accent' | 'border' | 'borderAccent' | 'borderMuted' | 'success' | 'error' | 'warning' | 'muted' | 'dim' | 'text' | 'userMessageText' | 'userMessageBg' | 'toolPendingBg' | 'toolSuccessBg' | 'toolAltBg' | 'toolErrorBg' | 'toolTitle' | 'toolOutput' | 'toolDiffAdded' | 'toolDiffRemoved' | 'toolDiffContext' | 'mdHeading' | 'mdLink' | 'mdLinkUrl' | 'mdCode' | 'mdCodeBlock' | 'mdCodeBlockBorder' | 'mdKeyword' | 'syntaxString' | 'syntaxNumber' | 'syntaxFunction' | 'syntaxType' | 'mdQuote' | 'mdQuoteBorder' | 'mdHr' | 'mdListBullet' | 'shellMode' | 'thinkingText' | 'customMessageLabel';
54
55
  /** Built-in palettes, including a few well-known oh-my-pi coding themes. */
55
- export declare const THEME_NAMES: readonly ["dark", "light", "midnight", "solarized", "catppuccin", "dracula", "nord", "gruvbox", "rose-pine", "mono"];
56
+ /**
57
+ * Shipped palettes: one dark, one light, and the one that follows the terminal.
58
+ *
59
+ * A theme is a contract the whole TUI is read through — every card, diff, and
60
+ * syntax token has to stay legible on it — so the set stays small enough to hold
61
+ * to that standard. `system` is not a third design: it derives its surfaces from
62
+ * the colours the terminal reports and then follows the same rules.
63
+ */
64
+ export declare const THEME_NAMES: readonly ["dark", "light", "system"];
56
65
  /** One shipped palette name. */
57
66
  export type ThemeName = (typeof THEME_NAMES)[number];
58
67
  /** True when `value` is a shipped palette name. */
@@ -65,8 +74,12 @@ export interface Theme {
65
74
  readonly name: ThemeName;
66
75
  /** Whether SGR is emitted. */
67
76
  readonly colors: boolean;
68
- /** Whether hex colors become 24-bit SGR (else 16-color). */
77
+ /** Whether hex colors become 24-bit SGR. */
69
78
  readonly trueColor: boolean;
79
+ /** How swatches are encoded; meaningful only when {@link Theme.colors} is true. */
80
+ readonly depth: ColorDepth;
81
+ /** Cache fingerprint covering the palette, SGR flag, depth, and reported terminal colors. */
82
+ readonly key: string;
70
83
  fg(color: ThemeColor, text: string): string;
71
84
  bg(color: ThemeColor, text: string): string;
72
85
  getFgAnsi(color: ThemeColor): string;
@@ -81,6 +94,12 @@ export interface Theme {
81
94
  }
82
95
  /** Paint a fixed surface, restoring its paired ink and fill after nested resets. */
83
96
  export declare function paintSurface(theme: Theme, background: ThemeColor, foreground: ThemeColor, text: string): string;
97
+ /**
98
+ * How many colors the terminal can show, which decides how a swatch is
99
+ * encoded. It is independent of what the terminal reports about its palette:
100
+ * a report changes the target values, never the encoding.
101
+ */
102
+ export type ColorDepth = 'ansi16' | 'ansi256' | 'truecolor';
84
103
  /**
85
104
  * True when the environment asks for no color at all: a non-empty `NO_COLOR`
86
105
  * (https://no-color.org) or `FORCE_COLOR=0`. An empty `NO_COLOR` counts as
@@ -88,18 +107,22 @@ export declare function paintSurface(theme: Theme, background: ThemeColor, foreg
88
107
  */
89
108
  export declare function colorDisabledByEnv(env?: NodeJS.ProcessEnv): boolean;
90
109
  /**
91
- * Detect 24-bit color. `NO_COLOR` (any non-empty value) and `FORCE_COLOR=0`
92
- * suppress 24-bit color and outrank every capability hint; `COLORTERM` and
93
- * Windows Terminal enable it, and only known 16-color hosts disqualify it.
110
+ * Detect the color depth. `NO_COLOR` (any non-empty value) and `FORCE_COLOR=0`
111
+ * outrank every capability hint and leave 16 colors; `COLORTERM` and Windows
112
+ * Terminal prove 24-bit color. Apple Terminal advertises `xterm-256color` but
113
+ * misdraws 24-bit sequences on the releases still in use, so it gets the
114
+ * 256-color cube. Known 16-color hosts stay at 16, and every other terminal is
115
+ * assumed to be a modern 24-bit one.
94
116
  */
95
- export declare function detectTrueColor(env?: NodeJS.ProcessEnv): boolean;
117
+ export declare function detectColorDepth(env?: NodeJS.ProcessEnv): ColorDepth;
96
118
  /**
97
119
  * Build a theme.
98
120
  * @param colors - emit SGR when true.
99
- * @param trueColor - 24-bit hex; ignored when colors is false.
121
+ * @param depth - color depth, or a boolean for 24-bit versus 16 colors; ignored when colors is false.
100
122
  * @param name - shipped palette (`dark` default).
123
+ * @param terminal - what the terminal reported about itself, when a probe answered.
101
124
  */
102
- export declare function createTheme(colors: boolean, trueColor?: boolean, name?: ThemeName): Theme;
125
+ export declare function createTheme(colors: boolean, depth?: ColorDepth | boolean, name?: ThemeName, terminal?: TerminalColors): Theme;
103
126
  /** DeepSeek mark adapted from the official SVG for a 20×6 terminal cell. */
104
127
  export declare const DEEPSEEK_LOGO: readonly [" ⢀⣀ ⢀⡀ ", "⢀⣤⣶⣿⣿⣿⣿⣿⣿⣿⣧⣄⡀⢻⣿⣷⣶⣶⣶⡿", "⣿⡟⠛⠛⠛⠿⢿⣿⣿⣿⣿⡿⢿⣷⣾⣿⣿⠉⠉ ", "⢻⣿⣄⡀ ⢀⠈⠛⢿⣿⣿⣶⣿⣿⡿⠃ ", " ⠙⠻⢿⣶⣦⣼⣿⣷⣦⣭⣿⠿⣿⣷⠦ ", " ⠉⠉⠉⠉⠉⠁ "];
105
128
  /**