@adea-ai/ui 0.140.0 → 0.142.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 (455) hide show
  1. package/dist/components/composites/appearance-editor/appearance-editor.js +2 -2
  2. package/dist/components/composites/appearance-editor/appearance-editor.js.map +1 -1
  3. package/dist/components/composites/catalog-browser/catalog-browser-group.js +1 -1
  4. package/dist/components/composites/chain-of-thought/chain-of-thought.d.ts +56 -0
  5. package/dist/components/composites/chain-of-thought/chain-of-thought.d.ts.map +1 -0
  6. package/dist/components/composites/chain-of-thought/chain-of-thought.js +117 -0
  7. package/dist/components/composites/chain-of-thought/chain-of-thought.js.map +1 -0
  8. package/dist/components/composites/chain-of-thought/index.d.ts +2 -0
  9. package/dist/components/composites/chain-of-thought/index.d.ts.map +1 -0
  10. package/dist/components/composites/chain-of-thought/index.js +2 -0
  11. package/dist/components/composites/chat/chat.d.ts +67 -0
  12. package/dist/components/composites/chat/chat.d.ts.map +1 -0
  13. package/dist/components/composites/chat/chat.js +179 -0
  14. package/dist/components/composites/chat/chat.js.map +1 -0
  15. package/dist/components/composites/chat/index.d.ts +2 -0
  16. package/dist/components/composites/chat/index.d.ts.map +1 -0
  17. package/dist/components/composites/chat/index.js +2 -0
  18. package/dist/components/composites/checkpoint/checkpoint-model.d.ts +34 -0
  19. package/dist/components/composites/checkpoint/checkpoint-model.d.ts.map +1 -0
  20. package/dist/components/composites/checkpoint/checkpoint-model.js +48 -0
  21. package/dist/components/composites/checkpoint/checkpoint-model.js.map +1 -0
  22. package/dist/components/composites/checkpoint/checkpoint.d.ts +48 -0
  23. package/dist/components/composites/checkpoint/checkpoint.d.ts.map +1 -0
  24. package/dist/components/composites/checkpoint/checkpoint.js +160 -0
  25. package/dist/components/composites/checkpoint/checkpoint.js.map +1 -0
  26. package/dist/components/composites/checkpoint/index.d.ts +3 -0
  27. package/dist/components/composites/checkpoint/index.d.ts.map +1 -0
  28. package/dist/components/composites/checkpoint/index.js +3 -0
  29. package/dist/components/composites/confirmation/confirmation-model.d.ts +45 -0
  30. package/dist/components/composites/confirmation/confirmation-model.d.ts.map +1 -0
  31. package/dist/components/composites/confirmation/confirmation-model.js +51 -0
  32. package/dist/components/composites/confirmation/confirmation-model.js.map +1 -0
  33. package/dist/components/composites/confirmation/confirmation.d.ts +72 -0
  34. package/dist/components/composites/confirmation/confirmation.d.ts.map +1 -0
  35. package/dist/components/composites/confirmation/confirmation.js +300 -0
  36. package/dist/components/composites/confirmation/confirmation.js.map +1 -0
  37. package/dist/components/composites/confirmation/index.d.ts +3 -0
  38. package/dist/components/composites/confirmation/index.d.ts.map +1 -0
  39. package/dist/components/composites/confirmation/index.js +3 -0
  40. package/dist/components/composites/context/context-model.d.ts +69 -0
  41. package/dist/components/composites/context/context-model.d.ts.map +1 -0
  42. package/dist/components/composites/context/context-model.js +122 -0
  43. package/dist/components/composites/context/context-model.js.map +1 -0
  44. package/dist/components/composites/context/context.d.ts +38 -0
  45. package/dist/components/composites/context/context.d.ts.map +1 -0
  46. package/dist/components/composites/context/context.js +234 -0
  47. package/dist/components/composites/context/context.js.map +1 -0
  48. package/dist/components/composites/context/index.d.ts +3 -0
  49. package/dist/components/composites/context/index.d.ts.map +1 -0
  50. package/dist/components/composites/context/index.js +3 -0
  51. package/dist/components/composites/file-tree/build-file-tree.d.ts +138 -0
  52. package/dist/components/composites/file-tree/build-file-tree.d.ts.map +1 -0
  53. package/dist/components/composites/file-tree/build-file-tree.js +325 -0
  54. package/dist/components/composites/file-tree/build-file-tree.js.map +1 -0
  55. package/dist/components/composites/file-tree/file-tree.d.ts +74 -0
  56. package/dist/components/composites/file-tree/file-tree.d.ts.map +1 -0
  57. package/dist/components/composites/file-tree/file-tree.js +389 -0
  58. package/dist/components/composites/file-tree/file-tree.js.map +1 -0
  59. package/dist/components/composites/file-tree/index.d.ts +3 -0
  60. package/dist/components/composites/file-tree/index.d.ts.map +1 -0
  61. package/dist/components/composites/file-tree/index.js +3 -0
  62. package/dist/components/composites/inline-citation/citation.d.ts +37 -0
  63. package/dist/components/composites/inline-citation/citation.d.ts.map +1 -0
  64. package/dist/components/composites/inline-citation/citation.js +52 -0
  65. package/dist/components/composites/inline-citation/citation.js.map +1 -0
  66. package/dist/components/composites/inline-citation/index.d.ts +3 -0
  67. package/dist/components/composites/inline-citation/index.d.ts.map +1 -0
  68. package/dist/components/composites/inline-citation/index.js +3 -0
  69. package/dist/components/composites/inline-citation/inline-citation.d.ts +64 -0
  70. package/dist/components/composites/inline-citation/inline-citation.d.ts.map +1 -0
  71. package/dist/components/composites/inline-citation/inline-citation.js +272 -0
  72. package/dist/components/composites/inline-citation/inline-citation.js.map +1 -0
  73. package/dist/components/composites/message-scroller/index.d.ts +3 -0
  74. package/dist/components/composites/message-scroller/index.d.ts.map +1 -0
  75. package/dist/components/composites/message-scroller/index.js +3 -0
  76. package/dist/components/composites/message-scroller/message-scroller.d.ts +55 -0
  77. package/dist/components/composites/message-scroller/message-scroller.d.ts.map +1 -0
  78. package/dist/components/composites/message-scroller/message-scroller.js +201 -0
  79. package/dist/components/composites/message-scroller/message-scroller.js.map +1 -0
  80. package/dist/components/composites/message-scroller/scroll-anchor.d.ts +66 -0
  81. package/dist/components/composites/message-scroller/scroll-anchor.d.ts.map +1 -0
  82. package/dist/components/composites/message-scroller/scroll-anchor.js +122 -0
  83. package/dist/components/composites/message-scroller/scroll-anchor.js.map +1 -0
  84. package/dist/components/composites/model-selector/index.d.ts +3 -0
  85. package/dist/components/composites/model-selector/index.d.ts.map +1 -0
  86. package/dist/components/composites/model-selector/index.js +3 -0
  87. package/dist/components/composites/model-selector/model-selector.d.ts +55 -0
  88. package/dist/components/composites/model-selector/model-selector.d.ts.map +1 -0
  89. package/dist/components/composites/model-selector/model-selector.js +490 -0
  90. package/dist/components/composites/model-selector/model-selector.js.map +1 -0
  91. package/dist/components/composites/model-selector/models.d.ts +51 -0
  92. package/dist/components/composites/model-selector/models.d.ts.map +1 -0
  93. package/dist/components/composites/model-selector/models.js +71 -0
  94. package/dist/components/composites/model-selector/models.js.map +1 -0
  95. package/dist/components/composites/plan/index.d.ts +2 -0
  96. package/dist/components/composites/plan/index.d.ts.map +1 -0
  97. package/dist/components/composites/plan/index.js +2 -0
  98. package/dist/components/composites/plan/plan.d.ts +61 -0
  99. package/dist/components/composites/plan/plan.d.ts.map +1 -0
  100. package/dist/components/composites/plan/plan.js +130 -0
  101. package/dist/components/composites/plan/plan.js.map +1 -0
  102. package/dist/components/composites/queue/index.d.ts +2 -0
  103. package/dist/components/composites/queue/index.d.ts.map +1 -0
  104. package/dist/components/composites/queue/index.js +2 -0
  105. package/dist/components/composites/queue/queue.d.ts +77 -0
  106. package/dist/components/composites/queue/queue.d.ts.map +1 -0
  107. package/dist/components/composites/queue/queue.js +271 -0
  108. package/dist/components/composites/queue/queue.js.map +1 -0
  109. package/dist/components/composites/reasoning/index.d.ts +2 -0
  110. package/dist/components/composites/reasoning/index.d.ts.map +1 -0
  111. package/dist/components/composites/reasoning/index.js +2 -0
  112. package/dist/components/composites/reasoning/reasoning.d.ts +62 -0
  113. package/dist/components/composites/reasoning/reasoning.d.ts.map +1 -0
  114. package/dist/components/composites/reasoning/reasoning.js +156 -0
  115. package/dist/components/composites/reasoning/reasoning.js.map +1 -0
  116. package/dist/components/composites/sources/index.d.ts +3 -0
  117. package/dist/components/composites/sources/index.d.ts.map +1 -0
  118. package/dist/components/composites/sources/index.js +3 -0
  119. package/dist/components/composites/sources/source.d.ts +46 -0
  120. package/dist/components/composites/sources/source.d.ts.map +1 -0
  121. package/dist/components/composites/sources/source.js +74 -0
  122. package/dist/components/composites/sources/source.js.map +1 -0
  123. package/dist/components/composites/sources/sources.d.ts +45 -0
  124. package/dist/components/composites/sources/sources.d.ts.map +1 -0
  125. package/dist/components/composites/sources/sources.js +175 -0
  126. package/dist/components/composites/sources/sources.js.map +1 -0
  127. package/dist/components/composites/stack-trace/index.d.ts +3 -0
  128. package/dist/components/composites/stack-trace/index.d.ts.map +1 -0
  129. package/dist/components/composites/stack-trace/index.js +3 -0
  130. package/dist/components/composites/stack-trace/parse-stack-trace.d.ts +118 -0
  131. package/dist/components/composites/stack-trace/parse-stack-trace.d.ts.map +1 -0
  132. package/dist/components/composites/stack-trace/parse-stack-trace.js +376 -0
  133. package/dist/components/composites/stack-trace/parse-stack-trace.js.map +1 -0
  134. package/dist/components/composites/stack-trace/stack-trace.d.ts +63 -0
  135. package/dist/components/composites/stack-trace/stack-trace.d.ts.map +1 -0
  136. package/dist/components/composites/stack-trace/stack-trace.js +491 -0
  137. package/dist/components/composites/stack-trace/stack-trace.js.map +1 -0
  138. package/dist/components/composites/subagent/index.d.ts +2 -0
  139. package/dist/components/composites/subagent/index.d.ts.map +1 -0
  140. package/dist/components/composites/subagent/index.js +2 -0
  141. package/dist/components/composites/subagent/subagent.d.ts +55 -0
  142. package/dist/components/composites/subagent/subagent.d.ts.map +1 -0
  143. package/dist/components/composites/subagent/subagent.js +138 -0
  144. package/dist/components/composites/subagent/subagent.js.map +1 -0
  145. package/dist/components/composites/suggestion/index.d.ts +2 -0
  146. package/dist/components/composites/suggestion/index.d.ts.map +1 -0
  147. package/dist/components/composites/suggestion/index.js +2 -0
  148. package/dist/components/composites/suggestion/suggestion.d.ts +37 -0
  149. package/dist/components/composites/suggestion/suggestion.d.ts.map +1 -0
  150. package/dist/components/composites/suggestion/suggestion.js +100 -0
  151. package/dist/components/composites/suggestion/suggestion.js.map +1 -0
  152. package/dist/components/composites/task/index.d.ts +2 -0
  153. package/dist/components/composites/task/index.d.ts.map +1 -0
  154. package/dist/components/composites/task/index.js +2 -0
  155. package/dist/components/composites/task/task.d.ts +96 -0
  156. package/dist/components/composites/task/task.d.ts.map +1 -0
  157. package/dist/components/composites/task/task.js +311 -0
  158. package/dist/components/composites/task/task.js.map +1 -0
  159. package/dist/components/composites/terminal/ansi.d.ts +101 -0
  160. package/dist/components/composites/terminal/ansi.d.ts.map +1 -0
  161. package/dist/components/composites/terminal/ansi.js +544 -0
  162. package/dist/components/composites/terminal/ansi.js.map +1 -0
  163. package/dist/components/composites/terminal/index.d.ts +4 -0
  164. package/dist/components/composites/terminal/index.d.ts.map +1 -0
  165. package/dist/components/composites/terminal/index.js +4 -0
  166. package/dist/components/composites/terminal/terminal-model.d.ts +63 -0
  167. package/dist/components/composites/terminal/terminal-model.d.ts.map +1 -0
  168. package/dist/components/composites/terminal/terminal-model.js +69 -0
  169. package/dist/components/composites/terminal/terminal-model.js.map +1 -0
  170. package/dist/components/composites/terminal/terminal.d.ts +88 -0
  171. package/dist/components/composites/terminal/terminal.d.ts.map +1 -0
  172. package/dist/components/composites/terminal/terminal.js +500 -0
  173. package/dist/components/composites/terminal/terminal.js.map +1 -0
  174. package/dist/components/composites/test-results/index.d.ts +3 -0
  175. package/dist/components/composites/test-results/index.d.ts.map +1 -0
  176. package/dist/components/composites/test-results/index.js +3 -0
  177. package/dist/components/composites/test-results/test-results-model.d.ts +154 -0
  178. package/dist/components/composites/test-results/test-results-model.d.ts.map +1 -0
  179. package/dist/components/composites/test-results/test-results-model.js +252 -0
  180. package/dist/components/composites/test-results/test-results-model.js.map +1 -0
  181. package/dist/components/composites/test-results/test-results.d.ts +60 -0
  182. package/dist/components/composites/test-results/test-results.d.ts.map +1 -0
  183. package/dist/components/composites/test-results/test-results.js +631 -0
  184. package/dist/components/composites/test-results/test-results.js.map +1 -0
  185. package/dist/components/composites/tool/format-tool-value.d.ts +37 -0
  186. package/dist/components/composites/tool/format-tool-value.d.ts.map +1 -0
  187. package/dist/components/composites/tool/format-tool-value.js +135 -0
  188. package/dist/components/composites/tool/format-tool-value.js.map +1 -0
  189. package/dist/components/composites/tool/index.d.ts +3 -0
  190. package/dist/components/composites/tool/index.d.ts.map +1 -0
  191. package/dist/components/composites/tool/index.js +3 -0
  192. package/dist/components/composites/tool/tool.d.ts +69 -0
  193. package/dist/components/composites/tool/tool.d.ts.map +1 -0
  194. package/dist/components/composites/tool/tool.js +214 -0
  195. package/dist/components/composites/tool/tool.js.map +1 -0
  196. package/dist/components/composites/update-dialog/update-dialog.js +1 -1
  197. package/dist/components/conversation/conversation-surface.d.ts +7 -0
  198. package/dist/components/conversation/conversation-surface.d.ts.map +1 -1
  199. package/dist/components/conversation/conversation-surface.js +2 -0
  200. package/dist/components/conversation/conversation-surface.js.map +1 -1
  201. package/dist/components/conversation/scroll-follow-core.d.ts +24 -0
  202. package/dist/components/conversation/scroll-follow-core.d.ts.map +1 -1
  203. package/dist/components/conversation/scroll-follow-core.js +23 -1
  204. package/dist/components/conversation/scroll-follow-core.js.map +1 -1
  205. package/dist/components/conversation/scroll-follow.d.ts +3 -0
  206. package/dist/components/conversation/scroll-follow.d.ts.map +1 -1
  207. package/dist/components/conversation/scroll-follow.js +80 -1
  208. package/dist/components/conversation/scroll-follow.js.map +1 -1
  209. package/dist/components/ui/attachment/attachment.d.ts +58 -0
  210. package/dist/components/ui/attachment/attachment.d.ts.map +1 -0
  211. package/dist/components/ui/attachment/attachment.js +279 -0
  212. package/dist/components/ui/attachment/attachment.js.map +1 -0
  213. package/dist/components/ui/attachment/index.d.ts +2 -0
  214. package/dist/components/ui/attachment/index.d.ts.map +1 -0
  215. package/dist/components/ui/attachment/index.js +2 -0
  216. package/dist/components/ui/badge/badge.d.ts +1 -1
  217. package/dist/components/ui/bubble/bubble.d.ts +33 -0
  218. package/dist/components/ui/bubble/bubble.d.ts.map +1 -0
  219. package/dist/components/ui/bubble/bubble.js +95 -0
  220. package/dist/components/ui/bubble/bubble.js.map +1 -0
  221. package/dist/components/ui/bubble/index.d.ts +2 -0
  222. package/dist/components/ui/bubble/index.d.ts.map +1 -0
  223. package/dist/components/ui/bubble/index.js +2 -0
  224. package/dist/components/ui/button/button.d.ts +1 -1
  225. package/dist/components/ui/code-block/code-block.d.ts +56 -3
  226. package/dist/components/ui/code-block/code-block.d.ts.map +1 -1
  227. package/dist/components/ui/code-block/code-block.js +231 -50
  228. package/dist/components/ui/code-block/code-block.js.map +1 -1
  229. package/dist/components/ui/code-block/index.d.ts +1 -1
  230. package/dist/components/ui/code-block/index.d.ts.map +1 -1
  231. package/dist/components/ui/code-block/index.js +2 -2
  232. package/dist/components/ui/field/number-field.d.ts +21 -4
  233. package/dist/components/ui/field/number-field.d.ts.map +1 -1
  234. package/dist/components/ui/field/number-field.js +22 -11
  235. package/dist/components/ui/field/number-field.js.map +1 -1
  236. package/dist/components/ui/marker/index.d.ts +2 -0
  237. package/dist/components/ui/marker/index.d.ts.map +1 -0
  238. package/dist/components/ui/marker/index.js +2 -0
  239. package/dist/components/ui/marker/marker.d.ts +35 -0
  240. package/dist/components/ui/marker/marker.d.ts.map +1 -0
  241. package/dist/components/ui/marker/marker.js +123 -0
  242. package/dist/components/ui/marker/marker.js.map +1 -0
  243. package/dist/components/ui/message/cite-ranges.d.ts +42 -0
  244. package/dist/components/ui/message/cite-ranges.d.ts.map +1 -0
  245. package/dist/components/ui/message/cite-ranges.js +105 -0
  246. package/dist/components/ui/message/cite-ranges.js.map +1 -0
  247. package/dist/components/ui/message/index.d.ts +4 -0
  248. package/dist/components/ui/message/index.d.ts.map +1 -0
  249. package/dist/components/ui/message/index.js +4 -0
  250. package/dist/components/ui/message/message.d.ts +95 -0
  251. package/dist/components/ui/message/message.d.ts.map +1 -0
  252. package/dist/components/ui/message/message.js +443 -0
  253. package/dist/components/ui/message/message.js.map +1 -0
  254. package/dist/components/ui/message/parse-message-text.d.ts +93 -0
  255. package/dist/components/ui/message/parse-message-text.d.ts.map +1 -0
  256. package/dist/components/ui/message/parse-message-text.js +365 -0
  257. package/dist/components/ui/message/parse-message-text.js.map +1 -0
  258. package/dist/components/ui/questionnaire/index.d.ts +2 -0
  259. package/dist/components/ui/questionnaire/index.d.ts.map +1 -0
  260. package/dist/components/ui/questionnaire/index.js +2 -0
  261. package/dist/components/ui/questionnaire/questionnaire.d.ts +83 -0
  262. package/dist/components/ui/questionnaire/questionnaire.d.ts.map +1 -0
  263. package/dist/components/ui/questionnaire/questionnaire.js +470 -0
  264. package/dist/components/ui/questionnaire/questionnaire.js.map +1 -0
  265. package/dist/components/ui/status-chip/status-chip.d.ts +1 -1
  266. package/dist/components/ui/switch/switch.js +11 -11
  267. package/dist/components/ui/switch/switch.js.map +1 -1
  268. package/dist/components/ui/trace/index.d.ts +2 -0
  269. package/dist/components/ui/trace/index.d.ts.map +1 -0
  270. package/dist/components/ui/trace/index.js +2 -0
  271. package/dist/components/ui/trace/trace.d.ts +72 -0
  272. package/dist/components/ui/trace/trace.d.ts.map +1 -0
  273. package/dist/components/ui/trace/trace.js +340 -0
  274. package/dist/components/ui/trace/trace.js.map +1 -0
  275. package/dist/index.d.ts +26 -0
  276. package/dist/index.d.ts.map +1 -1
  277. package/dist/index.js +46 -5
  278. package/dist/r/attachment.json +25 -0
  279. package/dist/r/bubble.json +22 -0
  280. package/dist/r/chain-of-thought.json +26 -0
  281. package/dist/r/chat.json +24 -0
  282. package/dist/r/checkpoint.json +35 -0
  283. package/dist/r/confirmation.json +34 -0
  284. package/dist/r/context.json +33 -0
  285. package/dist/r/file-tree.json +32 -0
  286. package/dist/r/inline-citation.json +35 -0
  287. package/dist/r/marker.json +22 -0
  288. package/dist/r/message-scroller.json +31 -0
  289. package/dist/r/message.json +33 -0
  290. package/dist/r/model-selector.json +34 -0
  291. package/dist/r/plan.json +26 -0
  292. package/dist/r/questionnaire.json +28 -0
  293. package/dist/r/queue.json +26 -0
  294. package/dist/r/reasoning.json +26 -0
  295. package/dist/r/registry.json +811 -52
  296. package/dist/r/sources.json +32 -0
  297. package/dist/r/src/components/composites/chain-of-thought/chain-of-thought.tsx +141 -0
  298. package/dist/r/src/components/composites/chain-of-thought/index.ts +11 -0
  299. package/dist/r/src/components/composites/chat/chat.tsx +190 -0
  300. package/dist/r/src/components/composites/chat/index.ts +11 -0
  301. package/dist/r/src/components/composites/checkpoint/checkpoint-model.ts +71 -0
  302. package/dist/r/src/components/composites/checkpoint/checkpoint.tsx +214 -0
  303. package/dist/r/src/components/composites/checkpoint/index.ts +8 -0
  304. package/dist/r/src/components/composites/confirmation/confirmation-model.ts +83 -0
  305. package/dist/r/src/components/composites/confirmation/confirmation.tsx +311 -0
  306. package/dist/r/src/components/composites/confirmation/index.ts +9 -0
  307. package/dist/r/src/components/composites/context/context-model.ts +168 -0
  308. package/dist/r/src/components/composites/context/context.tsx +187 -0
  309. package/dist/r/src/components/composites/context/index.ts +18 -0
  310. package/dist/r/src/components/composites/file-tree/build-file-tree.ts +456 -0
  311. package/dist/r/src/components/composites/file-tree/file-tree.tsx +405 -0
  312. package/dist/r/src/components/composites/file-tree/index.ts +25 -0
  313. package/dist/r/src/components/composites/inline-citation/citation.ts +78 -0
  314. package/dist/r/src/components/composites/inline-citation/index.ts +9 -0
  315. package/dist/r/src/components/composites/inline-citation/inline-citation.tsx +285 -0
  316. package/dist/r/src/components/composites/message-scroller/index.ts +2 -0
  317. package/dist/r/src/components/composites/message-scroller/message-scroller.tsx +301 -0
  318. package/dist/r/src/components/composites/message-scroller/scroll-anchor.ts +170 -0
  319. package/dist/r/src/components/composites/model-selector/index.ts +14 -0
  320. package/dist/r/src/components/composites/model-selector/model-selector.tsx +420 -0
  321. package/dist/r/src/components/composites/model-selector/models.ts +103 -0
  322. package/dist/r/src/components/composites/plan/index.ts +1 -0
  323. package/dist/r/src/components/composites/plan/plan.tsx +155 -0
  324. package/dist/r/src/components/composites/queue/index.ts +10 -0
  325. package/dist/r/src/components/composites/queue/queue.tsx +264 -0
  326. package/dist/r/src/components/composites/reasoning/index.ts +1 -0
  327. package/dist/r/src/components/composites/reasoning/reasoning.tsx +176 -0
  328. package/dist/r/src/components/composites/sources/index.ts +11 -0
  329. package/dist/r/src/components/composites/sources/source.ts +116 -0
  330. package/dist/r/src/components/composites/sources/sources.tsx +163 -0
  331. package/dist/r/src/components/composites/stack-trace/index.ts +19 -0
  332. package/dist/r/src/components/composites/stack-trace/parse-stack-trace.ts +507 -0
  333. package/dist/r/src/components/composites/stack-trace/stack-trace.tsx +395 -0
  334. package/dist/r/src/components/composites/subagent/index.ts +1 -0
  335. package/dist/r/src/components/composites/subagent/subagent.tsx +159 -0
  336. package/dist/r/src/components/composites/suggestion/index.ts +1 -0
  337. package/dist/r/src/components/composites/suggestion/suggestion.tsx +140 -0
  338. package/dist/r/src/components/composites/task/index.ts +14 -0
  339. package/dist/r/src/components/composites/task/task.tsx +317 -0
  340. package/dist/r/src/components/composites/terminal/ansi.ts +674 -0
  341. package/dist/r/src/components/composites/terminal/index.ts +20 -0
  342. package/dist/r/src/components/composites/terminal/terminal-model.ts +111 -0
  343. package/dist/r/src/components/composites/terminal/terminal.tsx +574 -0
  344. package/dist/r/src/components/composites/test-results/index.ts +20 -0
  345. package/dist/r/src/components/composites/test-results/test-results-model.ts +368 -0
  346. package/dist/r/src/components/composites/test-results/test-results.tsx +586 -0
  347. package/dist/r/src/components/composites/tool/format-tool-value.ts +221 -0
  348. package/dist/r/src/components/composites/tool/index.ts +2 -0
  349. package/dist/r/src/components/composites/tool/tool.tsx +228 -0
  350. package/dist/r/src/components/conversation/conversation-surface.tsx +9 -0
  351. package/dist/r/src/components/conversation/scroll-follow-core.ts +31 -0
  352. package/dist/r/src/components/conversation/scroll-follow.ts +92 -0
  353. package/dist/r/src/components/ui/attachment/attachment.tsx +282 -0
  354. package/dist/r/src/components/ui/attachment/index.ts +10 -0
  355. package/dist/r/src/components/ui/bubble/bubble.tsx +86 -0
  356. package/dist/r/src/components/ui/bubble/index.ts +1 -0
  357. package/dist/r/src/components/ui/code-block/code-block.tsx +256 -26
  358. package/dist/r/src/components/ui/code-block/index.ts +9 -1
  359. package/dist/r/src/components/ui/field/number-field.tsx +51 -14
  360. package/dist/r/src/components/ui/marker/index.ts +1 -0
  361. package/dist/r/src/components/ui/marker/marker.tsx +90 -0
  362. package/dist/r/src/components/ui/message/cite-ranges.ts +144 -0
  363. package/dist/r/src/components/ui/message/index.ts +23 -0
  364. package/dist/r/src/components/ui/message/message.tsx +434 -0
  365. package/dist/r/src/components/ui/message/parse-message-text.ts +450 -0
  366. package/dist/r/src/components/ui/questionnaire/index.ts +10 -0
  367. package/dist/r/src/components/ui/questionnaire/questionnaire.tsx +446 -0
  368. package/dist/r/src/components/ui/trace/index.ts +9 -0
  369. package/dist/r/src/components/ui/trace/trace.tsx +334 -0
  370. package/dist/r/src/styles/base.css +34 -0
  371. package/dist/r/stack-trace.json +32 -0
  372. package/dist/r/subagent.json +27 -0
  373. package/dist/r/suggestion.json +24 -0
  374. package/dist/r/task.json +28 -0
  375. package/dist/r/terminal.json +35 -0
  376. package/dist/r/test-results.json +33 -0
  377. package/dist/r/tool.json +31 -0
  378. package/dist/r/trace.json +25 -0
  379. package/package.json +6 -3
  380. package/registry.json +811 -52
  381. package/src/components/composites/chain-of-thought/chain-of-thought.tsx +141 -0
  382. package/src/components/composites/chain-of-thought/index.ts +11 -0
  383. package/src/components/composites/chat/chat.tsx +190 -0
  384. package/src/components/composites/chat/index.ts +11 -0
  385. package/src/components/composites/checkpoint/checkpoint-model.ts +71 -0
  386. package/src/components/composites/checkpoint/checkpoint.tsx +214 -0
  387. package/src/components/composites/checkpoint/index.ts +8 -0
  388. package/src/components/composites/confirmation/confirmation-model.ts +83 -0
  389. package/src/components/composites/confirmation/confirmation.tsx +311 -0
  390. package/src/components/composites/confirmation/index.ts +9 -0
  391. package/src/components/composites/context/context-model.ts +168 -0
  392. package/src/components/composites/context/context.tsx +187 -0
  393. package/src/components/composites/context/index.ts +18 -0
  394. package/src/components/composites/file-tree/build-file-tree.ts +456 -0
  395. package/src/components/composites/file-tree/file-tree.tsx +405 -0
  396. package/src/components/composites/file-tree/index.ts +25 -0
  397. package/src/components/composites/inline-citation/citation.ts +78 -0
  398. package/src/components/composites/inline-citation/index.ts +9 -0
  399. package/src/components/composites/inline-citation/inline-citation.tsx +285 -0
  400. package/src/components/composites/message-scroller/index.ts +2 -0
  401. package/src/components/composites/message-scroller/message-scroller.tsx +301 -0
  402. package/src/components/composites/message-scroller/scroll-anchor.ts +170 -0
  403. package/src/components/composites/model-selector/index.ts +14 -0
  404. package/src/components/composites/model-selector/model-selector.tsx +420 -0
  405. package/src/components/composites/model-selector/models.ts +103 -0
  406. package/src/components/composites/plan/index.ts +1 -0
  407. package/src/components/composites/plan/plan.tsx +155 -0
  408. package/src/components/composites/queue/index.ts +10 -0
  409. package/src/components/composites/queue/queue.tsx +264 -0
  410. package/src/components/composites/reasoning/index.ts +1 -0
  411. package/src/components/composites/reasoning/reasoning.tsx +176 -0
  412. package/src/components/composites/sources/index.ts +11 -0
  413. package/src/components/composites/sources/source.ts +116 -0
  414. package/src/components/composites/sources/sources.tsx +163 -0
  415. package/src/components/composites/stack-trace/index.ts +19 -0
  416. package/src/components/composites/stack-trace/parse-stack-trace.ts +507 -0
  417. package/src/components/composites/stack-trace/stack-trace.tsx +395 -0
  418. package/src/components/composites/subagent/index.ts +1 -0
  419. package/src/components/composites/subagent/subagent.tsx +159 -0
  420. package/src/components/composites/suggestion/index.ts +1 -0
  421. package/src/components/composites/suggestion/suggestion.tsx +140 -0
  422. package/src/components/composites/task/index.ts +14 -0
  423. package/src/components/composites/task/task.tsx +317 -0
  424. package/src/components/composites/terminal/ansi.ts +674 -0
  425. package/src/components/composites/terminal/index.ts +20 -0
  426. package/src/components/composites/terminal/terminal-model.ts +111 -0
  427. package/src/components/composites/terminal/terminal.tsx +574 -0
  428. package/src/components/composites/test-results/index.ts +20 -0
  429. package/src/components/composites/test-results/test-results-model.ts +368 -0
  430. package/src/components/composites/test-results/test-results.tsx +586 -0
  431. package/src/components/composites/tool/format-tool-value.ts +221 -0
  432. package/src/components/composites/tool/index.ts +2 -0
  433. package/src/components/composites/tool/tool.tsx +228 -0
  434. package/src/components/conversation/conversation-surface.tsx +9 -0
  435. package/src/components/conversation/scroll-follow-core.ts +31 -0
  436. package/src/components/conversation/scroll-follow.ts +92 -0
  437. package/src/components/ui/attachment/attachment.tsx +282 -0
  438. package/src/components/ui/attachment/index.ts +10 -0
  439. package/src/components/ui/bubble/bubble.tsx +86 -0
  440. package/src/components/ui/bubble/index.ts +1 -0
  441. package/src/components/ui/code-block/code-block.tsx +256 -26
  442. package/src/components/ui/code-block/index.ts +9 -1
  443. package/src/components/ui/field/number-field.tsx +51 -14
  444. package/src/components/ui/marker/index.ts +1 -0
  445. package/src/components/ui/marker/marker.tsx +90 -0
  446. package/src/components/ui/message/cite-ranges.ts +144 -0
  447. package/src/components/ui/message/index.ts +23 -0
  448. package/src/components/ui/message/message.tsx +434 -0
  449. package/src/components/ui/message/parse-message-text.ts +450 -0
  450. package/src/components/ui/questionnaire/index.ts +10 -0
  451. package/src/components/ui/questionnaire/questionnaire.tsx +446 -0
  452. package/src/components/ui/trace/index.ts +9 -0
  453. package/src/components/ui/trace/trace.tsx +334 -0
  454. package/src/index.ts +26 -0
  455. package/src/styles/base.css +34 -0
@@ -0,0 +1,300 @@
1
+ import { cn } from "../../../lib/utils.js";
2
+ import { Button } from "../../ui/button/button.js";
3
+ import { CodeBlock } from "../../ui/code-block/code-block.js";
4
+ import { DiffBlock } from "../../ui/diff-block/diff-block.js";
5
+ import { Spinner } from "../../ui/spinner/spinner.js";
6
+ import { boundText } from "../sources/source.js";
7
+ import { confirmationOutcome, decisionReason, isAwaitingAnswer, settleDecision } from "./confirmation-model.js";
8
+ import { createComponent, insert, memo, mergeProps, setAttribute, spread, template, use } from "solid-js/web";
9
+ import { Ban, Check, Clock, Lock, ShieldQuestion } from "lucide-solid";
10
+ import { Show, createEffect, createSignal, createUniqueId, splitProps } from "solid-js";
11
+ //#region src/components/composites/confirmation/confirmation.tsx
12
+ var _tmpl$ = /*#__PURE__*/ template(`<p class="m-0 mt-0.5 text-xs text-muted-foreground [overflow-wrap:anywhere]">`);
13
+ var _tmpl$2 = /*#__PURE__*/ template(`<span class="shrink-0 text-xs text-muted-foreground">`);
14
+ var _tmpl$3 = /*#__PURE__*/ template(`<p role=status class="m-0 text-xs text-muted-foreground">`);
15
+ var _tmpl$4 = /*#__PURE__*/ template(`<p role=alert class="m-0 text-xs text-destructive [overflow-wrap:anywhere]">`);
16
+ var _tmpl$5 = /*#__PURE__*/ template(`<footer class="flex flex-wrap items-center justify-end gap-2"><span role=status class=visually-hidden>`);
17
+ var _tmpl$6 = /*#__PURE__*/ template(`<section data-slot=confirmation><header class="flex items-start gap-2.5"><span aria-hidden=true class="mt-0.5 text-muted-foreground [&amp;_svg]:size-4"></span><div class="min-w-0 flex-1"><h3 class="m-0 text-sm font-semibold [overflow-wrap:anywhere]">`);
18
+ var _tmpl$7 = /*#__PURE__*/ template(`<p tabindex=-1 role=status class="m-0 flex items-center gap-1.5 text-xs text-muted-foreground outline-none">`);
19
+ var _tmpl$8 = /*#__PURE__*/ template(`<div role=region aria-label="Proposed changes"tabindex=0 class="max-h-64 overflow-auto rounded-xl outline-none focus-visible:ring-3 focus-visible:ring-primary-subtle">`);
20
+ function Confirmation(props) {
21
+ const [local, rest] = splitProps(props, [
22
+ "class",
23
+ "state",
24
+ "title",
25
+ "description",
26
+ "details",
27
+ "onApprove",
28
+ "onDeny",
29
+ "approveLabel",
30
+ "denyLabel",
31
+ "disabledReason",
32
+ "error",
33
+ "resolvedBy",
34
+ "resolvedAt",
35
+ "children"
36
+ ]);
37
+ const uid = createUniqueId();
38
+ const titleId = `${uid}-title`;
39
+ const reasonId = `${uid}-reason`;
40
+ const state = () => local.state ?? "requested";
41
+ const awaiting = () => isAwaitingAnswer(state());
42
+ const [pending, setPending] = createSignal(void 0);
43
+ const [failure, setFailure] = createSignal(void 0);
44
+ let inflight = false;
45
+ let root;
46
+ let outcome;
47
+ const reasonFor = (handler, missing) => {
48
+ if (pending() !== void 0) return "Your answer is being sent.";
49
+ return decisionReason({
50
+ state: state(),
51
+ disabledReason: local.disabledReason,
52
+ hasHandler: handler !== void 0,
53
+ unavailableFallback: "This request cannot be answered right now.",
54
+ missingFallback: missing
55
+ });
56
+ };
57
+ const approveReason = () => reasonFor(local.onApprove, "Approving is not available here.");
58
+ const denyReason = () => reasonFor(local.onDeny, "Denying is not available here.");
59
+ const reasons = () => [...new Set([approveReason(), denyReason()].filter(Boolean))].join(" ");
60
+ const error = () => local.error ? boundText(local.error, 240) : failure();
61
+ const choose = async (choice) => {
62
+ const handler = choice === "approve" ? local.onApprove : local.onDeny;
63
+ const blocked = choice === "approve" ? approveReason() : denyReason();
64
+ if (inflight || blocked || !awaiting()) return;
65
+ inflight = true;
66
+ setPending(choice);
67
+ setFailure(void 0);
68
+ const result = await settleDecision(handler);
69
+ inflight = false;
70
+ setPending(void 0);
71
+ if (!result.ok) setFailure(result.message);
72
+ };
73
+ let wasAwaiting = awaiting();
74
+ createEffect(() => {
75
+ const now = awaiting();
76
+ if (wasAwaiting && !now) {
77
+ const active = document.activeElement;
78
+ if (active === null || active === document.body || root?.contains(active)) outcome?.focus();
79
+ }
80
+ wasAwaiting = now;
81
+ });
82
+ const buttonProps = (choice) => {
83
+ const blocked = () => choice === "approve" ? approveReason() : denyReason();
84
+ const disabled = () => pending() !== void 0 || blocked() !== void 0;
85
+ return {
86
+ "aria-disabled": disabled() || void 0,
87
+ "aria-describedby": blocked() ? reasonId : void 0,
88
+ onClick: () => void choose(choice)
89
+ };
90
+ };
91
+ return (() => {
92
+ var _el$ = _tmpl$6(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$5 = _el$4.firstChild;
93
+ use((element) => root = element, _el$);
94
+ setAttribute(_el$, "aria-labelledby", titleId);
95
+ spread(_el$, mergeProps({
96
+ get ["data-state"]() {
97
+ return state();
98
+ },
99
+ get ["class"]() {
100
+ return cn("flex w-full max-w-xl min-w-0 flex-col gap-3 rounded-xl border bg-card p-4", {
101
+ "border-ring": awaiting(),
102
+ "border-border": !awaiting()
103
+ });
104
+ }
105
+ }, rest), false, true);
106
+ insert(_el$3, createComponent(Show, {
107
+ get when() {
108
+ return state() === "approved";
109
+ },
110
+ get children() {
111
+ return createComponent(Check, { "class": "text-success" });
112
+ }
113
+ }), null);
114
+ insert(_el$3, createComponent(Show, {
115
+ get when() {
116
+ return state() === "denied";
117
+ },
118
+ get children() {
119
+ return createComponent(Ban, {});
120
+ }
121
+ }), null);
122
+ insert(_el$3, createComponent(Show, {
123
+ get when() {
124
+ return state() === "expired";
125
+ },
126
+ get children() {
127
+ return createComponent(Clock, {});
128
+ }
129
+ }), null);
130
+ insert(_el$3, createComponent(Show, {
131
+ get when() {
132
+ return state() === "unavailable";
133
+ },
134
+ get children() {
135
+ return createComponent(Lock, {});
136
+ }
137
+ }), null);
138
+ insert(_el$3, createComponent(Show, {
139
+ get when() {
140
+ return state() === "requested";
141
+ },
142
+ get children() {
143
+ return createComponent(ShieldQuestion, {});
144
+ }
145
+ }), null);
146
+ setAttribute(_el$5, "id", titleId);
147
+ insert(_el$5, () => boundText(local.title, 200));
148
+ insert(_el$4, createComponent(Show, {
149
+ get when() {
150
+ return local.description;
151
+ },
152
+ get children() {
153
+ var _el$6 = _tmpl$();
154
+ insert(_el$6, () => boundText(local.description ?? "", 400));
155
+ return _el$6;
156
+ }
157
+ }), null);
158
+ insert(_el$2, createComponent(Show, {
159
+ get when() {
160
+ return awaiting();
161
+ },
162
+ get children() {
163
+ var _el$7 = _tmpl$2();
164
+ insert(_el$7, () => state() === "requested" ? "Needs your answer" : "Cannot be answered now");
165
+ return _el$7;
166
+ }
167
+ }), null);
168
+ insert(_el$, createComponent(Show, {
169
+ get when() {
170
+ return local.details;
171
+ },
172
+ children: (details) => createComponent(Details, { get details() {
173
+ return details();
174
+ } })
175
+ }), null);
176
+ insert(_el$, () => local.children, null);
177
+ insert(_el$, createComponent(Show, {
178
+ get when() {
179
+ return awaiting();
180
+ },
181
+ get fallback() {
182
+ return (() => {
183
+ var _el$10 = _tmpl$7();
184
+ use((element) => outcome = element, _el$10);
185
+ insert(_el$10, () => confirmationOutcome(state(), local.resolvedBy, local.resolvedAt));
186
+ return _el$10;
187
+ })();
188
+ },
189
+ get children() {
190
+ return [
191
+ createComponent(Show, {
192
+ get when() {
193
+ return reasons();
194
+ },
195
+ get children() {
196
+ var _el$8 = _tmpl$3();
197
+ setAttribute(_el$8, "id", reasonId);
198
+ insert(_el$8, reasons);
199
+ return _el$8;
200
+ }
201
+ }),
202
+ createComponent(Show, {
203
+ get when() {
204
+ return error();
205
+ },
206
+ get children() {
207
+ var _el$9 = _tmpl$4();
208
+ insert(_el$9, error);
209
+ return _el$9;
210
+ }
211
+ }),
212
+ (() => {
213
+ var _el$0 = _tmpl$5(), _el$1 = _el$0.firstChild;
214
+ insert(_el$0, createComponent(Button, mergeProps({
215
+ type: "button",
216
+ variant: "outline",
217
+ size: "sm"
218
+ }, () => buttonProps("deny"), { get children() {
219
+ return [createComponent(Show, {
220
+ get when() {
221
+ return pending() === "deny";
222
+ },
223
+ get children() {
224
+ return createComponent(Spinner, {
225
+ size: "sm",
226
+ label: false
227
+ });
228
+ }
229
+ }), memo(() => local.denyLabel ?? "Deny")];
230
+ } })), _el$1);
231
+ insert(_el$0, createComponent(Button, mergeProps({
232
+ type: "button",
233
+ size: "sm"
234
+ }, () => buttonProps("approve"), { get children() {
235
+ return [createComponent(Show, {
236
+ get when() {
237
+ return pending() === "approve";
238
+ },
239
+ get children() {
240
+ return createComponent(Spinner, {
241
+ size: "sm",
242
+ label: false
243
+ });
244
+ }
245
+ }), memo(() => local.approveLabel ?? "Approve")];
246
+ } })), _el$1);
247
+ insert(_el$1, () => pending() !== void 0 ? "Sending your answer" : "");
248
+ return _el$0;
249
+ })()
250
+ ];
251
+ }
252
+ }), null);
253
+ return _el$;
254
+ })();
255
+ }
256
+ /** A name from the host or the model, cleaned and clipped before it reaches a header. */
257
+ function bounded(value, limit) {
258
+ return value ? boundText(value, limit) || void 0 : void 0;
259
+ }
260
+ function Details(props) {
261
+ return createComponent(Show, {
262
+ get when() {
263
+ return memo(() => props.details.kind === "diff")() && props.details;
264
+ },
265
+ get fallback() {
266
+ return createComponent(CodeBlock, {
267
+ size: "sm",
268
+ get code() {
269
+ return props.details.code;
270
+ },
271
+ get language() {
272
+ return bounded(props.details.language, 24);
273
+ },
274
+ get title() {
275
+ return bounded(props.details.title, 80);
276
+ },
277
+ complete: true,
278
+ wrap: true,
279
+ maxHeight: "14rem"
280
+ });
281
+ },
282
+ children: (diff) => (() => {
283
+ var _el$11 = _tmpl$8();
284
+ insert(_el$11, createComponent(DiffBlock, {
285
+ get patch() {
286
+ return diff().patch;
287
+ },
288
+ get title() {
289
+ return bounded(diff().title, 80);
290
+ },
291
+ complete: true
292
+ }));
293
+ return _el$11;
294
+ })()
295
+ });
296
+ }
297
+ //#endregion
298
+ export { Confirmation };
299
+
300
+ //# sourceMappingURL=confirmation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirmation.js","names":["Ban","Check","Clock","Lock","ShieldQuestion","createEffect","createSignal","createUniqueId","Show","splitProps","ComponentProps","JSX","cn","Button","CodeBlock","DiffBlock","Spinner","boundText","confirmationOutcome","decisionReason","isAwaitingAnswer","settleDecision","ConfirmationState","ConfirmationDetails","Readonly","kind","code","language","title","patch","ConfirmationProps","Omit","state","description","details","onApprove","Promise","onDeny","approveLabel","denyLabel","disabledReason","error","resolvedBy","resolvedAt","children","Element","Choice","Confirmation","props","local","rest","uid","titleId","reasonId","awaiting","pending","setPending","undefined","failure","setFailure","inflight","root","HTMLElement","outcome","HTMLParagraphElement","reasonFor","handler","missing","hasHandler","unavailableFallback","missingFallback","approveReason","denyReason","reasons","Set","filter","Boolean","join","choose","choice","blocked","result","ok","message","wasAwaiting","now","active","document","activeElement","body","contains","focus","buttonProps","disabled","onClick","_el$","_tmpl$6","_el$2","firstChild","_el$3","_el$4","nextSibling","_el$5","_$use","element","_$setAttribute","_$spread","_$mergeProps","data-state","class","_$insert","_$createComponent","when","_el$6","_tmpl$","_el$7","_tmpl$2","Details","fallback","_el$10","_tmpl$7","_el$8","_tmpl$3","_el$9","_tmpl$4","_el$0","_tmpl$5","_el$1","type","variant","size","label","_$memo","bounded","value","limit","Extract","complete","wrap","maxHeight","diff","_el$11","_tmpl$8","_$mergeProps","_$createComponent","_$memo"],"sources":["../../../../src/components/composites/confirmation/confirmation.tsx"],"sourcesContent":["import { Ban, Check, Clock, Lock, ShieldQuestion } from 'lucide-solid'\nimport {\n createEffect,\n createSignal,\n createUniqueId,\n Show,\n splitProps,\n type ComponentProps,\n type JSX,\n} from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { Button } from '../../ui/button'\nimport { CodeBlock } from '../../ui/code-block'\nimport { DiffBlock } from '../../ui/diff-block'\nimport { Spinner } from '../../ui/spinner'\nimport { boundText } from '../sources/source'\nimport {\n confirmationOutcome,\n decisionReason,\n isAwaitingAnswer,\n settleDecision,\n type ConfirmationState,\n} from './confirmation-model'\n\n/**\n * Confirmation.\n *\n * The agent has stopped a tool and will not continue until the person approves or\n * denies it. Like `Questionnaire`, this is one of the two elements in a transcript\n * the reader *must* act on, so it is allowed a card surface — and the border is\n * the focus ring's colour only while it is waiting. Once answered it drops to a\n * hairline and a one-line record, because a settled decision should read as\n * history, not as something still asking.\n *\n * ## It shows what is being approved, and nothing else\n *\n * `title` and `description` say what the tool wants to do; `details` is the\n * evidence, rendered as `CodeBlock size=\"sm\"` (a command, a request) or\n * `DiffBlock` (a patch). Details are text: never interpreted, and a long one\n * scrolls inside its block. Approve and Deny exist only while the request is\n * open; afterwards they are replaced by the outcome, with *who* and *when* only if\n * the host supplied them.\n *\n * ## The host owns authority\n *\n * Whether this client may answer is not decided here. No handler, or a host\n * `disabledReason`, or the `unavailable` state, leaves the buttons visible and\n * disabled with the reason beside them in words — never hidden, because a reader\n * who cannot see the choice cannot tell whether the agent is waiting on them.\n *\n * ## Answering is a round trip\n *\n * `onApprove` / `onDeny` may return a promise. While one is pending both buttons\n * refuse input (a synchronous guard as well as the signal, so a double click in\n * one tick cannot submit twice) and the pressed one shows a spinner. A failure\n * shows `error` (or the rejection's own message) and re-enables the buttons. The\n * buttons use `aria-disabled` rather than `disabled`: a native disabled button\n * drops focus, and the reader's place would be lost mid-decision. When the state\n * settles, focus moves to the outcome line if it was in the card, so a keyboard\n * user is not stranded on a control that no longer exists.\n */\nexport type ConfirmationDetails =\n | Readonly<{ kind: 'code'; code: string; language?: string; title?: string }>\n | Readonly<{ kind: 'diff'; patch: string; title?: string }>\n\nexport type ConfirmationProps = Omit<ComponentProps<'section'>, 'title' | 'onError'> & {\n state?: ConfirmationState\n /** What the tool wants to do, as a short sentence. */\n title: string\n description?: string\n details?: ConfirmationDetails\n onApprove?: () => void | Promise<void>\n onDeny?: () => void | Promise<void>\n approveLabel?: string\n denyLabel?: string\n /** Why the choice cannot be made right now; shown in words beside the buttons. */\n disabledReason?: string\n /** A failed answer, in words. Overrides the rejection's own message. */\n error?: string\n /** Who answered, once settled. Omit if unknown; nothing is assumed. */\n resolvedBy?: string\n /** When it was answered, already formatted for the reader. Omit if unknown. */\n resolvedAt?: string\n /** Extra content between the details and the buttons. */\n children?: JSX.Element\n}\n\ntype Choice = 'approve' | 'deny'\n\nexport function Confirmation(props: ConfirmationProps) {\n const [local, rest] = splitProps(props, [\n 'class',\n 'state',\n 'title',\n 'description',\n 'details',\n 'onApprove',\n 'onDeny',\n 'approveLabel',\n 'denyLabel',\n 'disabledReason',\n 'error',\n 'resolvedBy',\n 'resolvedAt',\n 'children',\n ])\n const uid = createUniqueId()\n const titleId = `${uid}-title`\n const reasonId = `${uid}-reason`\n const state = (): ConfirmationState => local.state ?? 'requested'\n const awaiting = () => isAwaitingAnswer(state())\n const [pending, setPending] = createSignal<Choice | undefined>(undefined)\n const [failure, setFailure] = createSignal<string | undefined>(undefined)\n let inflight = false\n let root: HTMLElement | undefined\n let outcome: HTMLParagraphElement | undefined\n\n const reasonFor = (handler: (() => void | Promise<void>) | undefined, missing: string) => {\n if (pending() !== undefined) return 'Your answer is being sent.'\n return decisionReason({\n state: state(),\n disabledReason: local.disabledReason,\n hasHandler: handler !== undefined,\n unavailableFallback: 'This request cannot be answered right now.',\n missingFallback: missing,\n })\n }\n const approveReason = () => reasonFor(local.onApprove, 'Approving is not available here.')\n const denyReason = () => reasonFor(local.onDeny, 'Denying is not available here.')\n // One sentence per distinct reason, so two identical reasons are not read twice.\n const reasons = () => [...new Set([approveReason(), denyReason()].filter(Boolean))].join(' ')\n const error = () => (local.error ? boundText(local.error, 240) : failure())\n\n const choose = async (choice: Choice) => {\n const handler = choice === 'approve' ? local.onApprove : local.onDeny\n const blocked = choice === 'approve' ? approveReason() : denyReason()\n if (inflight || blocked || !awaiting()) return\n inflight = true\n setPending(choice)\n setFailure(undefined)\n const result = await settleDecision(handler)\n inflight = false\n setPending(undefined)\n if (!result.ok) setFailure(result.message)\n }\n\n // The buttons are replaced by the outcome line; keep a keyboard reader in the card.\n // The previous value is kept by hand: `on(..., { defer: true })` does not record the\n // input of its skipped first run, so its \"previous\" is undefined on the first change.\n let wasAwaiting = awaiting()\n createEffect(() => {\n const now = awaiting()\n if (wasAwaiting && !now) {\n const active = document.activeElement\n if (active === null || active === document.body || root?.contains(active)) {\n outcome?.focus()\n }\n }\n wasAwaiting = now\n })\n\n const buttonProps = (choice: Choice) => {\n const blocked = () => (choice === 'approve' ? approveReason() : denyReason())\n const disabled = () => pending() !== undefined || blocked() !== undefined\n return {\n 'aria-disabled': disabled() || undefined,\n 'aria-describedby': blocked() ? reasonId : undefined,\n onClick: () => void choose(choice),\n }\n }\n\n return (\n <section\n ref={(element) => (root = element)}\n data-slot=\"confirmation\"\n data-state={state()}\n aria-labelledby={titleId}\n class={cn('flex w-full max-w-xl min-w-0 flex-col gap-3 rounded-xl border bg-card p-4', {\n 'border-ring': awaiting(),\n 'border-border': !awaiting(),\n })}\n {...rest}\n >\n <header class=\"flex items-start gap-2.5\">\n <span aria-hidden=\"true\" class=\"mt-0.5 text-muted-foreground [&_svg]:size-4\">\n <Show when={state() === 'approved'}>\n <Check class=\"text-success\" />\n </Show>\n <Show when={state() === 'denied'}>\n <Ban />\n </Show>\n <Show when={state() === 'expired'}>\n <Clock />\n </Show>\n <Show when={state() === 'unavailable'}>\n <Lock />\n </Show>\n <Show when={state() === 'requested'}>\n <ShieldQuestion />\n </Show>\n </span>\n <div class=\"min-w-0 flex-1\">\n <h3 id={titleId} class=\"m-0 text-sm font-semibold [overflow-wrap:anywhere]\">\n {boundText(local.title, 200)}\n </h3>\n <Show when={local.description}>\n <p class=\"m-0 mt-0.5 text-xs text-muted-foreground [overflow-wrap:anywhere]\">\n {boundText(local.description ?? '', 400)}\n </p>\n </Show>\n </div>\n <Show when={awaiting()}>\n <span class=\"shrink-0 text-xs text-muted-foreground\">\n {state() === 'requested' ? 'Needs your answer' : 'Cannot be answered now'}\n </span>\n </Show>\n </header>\n\n <Show when={local.details}>{(details) => <Details details={details()} />}</Show>\n\n {local.children}\n\n <Show\n when={awaiting()}\n fallback={\n <p\n ref={(element) => (outcome = element)}\n tabindex=\"-1\"\n role=\"status\"\n class=\"m-0 flex items-center gap-1.5 text-xs text-muted-foreground outline-none\"\n >\n {confirmationOutcome(state(), local.resolvedBy, local.resolvedAt)}\n </p>\n }\n >\n <Show when={reasons()}>\n <p id={reasonId} role=\"status\" class=\"m-0 text-xs text-muted-foreground\">\n {reasons()}\n </p>\n </Show>\n <Show when={error()}>\n <p role=\"alert\" class=\"m-0 text-xs text-destructive [overflow-wrap:anywhere]\">\n {error()}\n </p>\n </Show>\n <footer class=\"flex flex-wrap items-center justify-end gap-2\">\n <Button type=\"button\" variant=\"outline\" size=\"sm\" {...buttonProps('deny')}>\n <Show when={pending() === 'deny'}>\n <Spinner size=\"sm\" label={false} />\n </Show>\n {local.denyLabel ?? 'Deny'}\n </Button>\n <Button type=\"button\" size=\"sm\" {...buttonProps('approve')}>\n <Show when={pending() === 'approve'}>\n <Spinner size=\"sm\" label={false} />\n </Show>\n {local.approveLabel ?? 'Approve'}\n </Button>\n {/* Present from the start: a live region inserted with its text is not reliably announced. */}\n <span role=\"status\" class=\"visually-hidden\">\n {pending() !== undefined ? 'Sending your answer' : ''}\n </span>\n </footer>\n </Show>\n </section>\n )\n}\n\n/** A name from the host or the model, cleaned and clipped before it reaches a header. */\nfunction bounded(value: string | undefined, limit: number): string | undefined {\n return value ? boundText(value, limit) || undefined : undefined\n}\n\nfunction Details(props: { details: ConfirmationDetails }) {\n return (\n <Show\n when={props.details.kind === 'diff' && props.details}\n fallback={\n <CodeBlock\n size=\"sm\"\n code={(props.details as Extract<ConfirmationDetails, { kind: 'code' }>).code}\n language={bounded(\n (props.details as Extract<ConfirmationDetails, { kind: 'code' }>).language,\n 24\n )}\n title={bounded(props.details.title, 80)}\n complete\n wrap\n maxHeight=\"14rem\"\n />\n }\n >\n {(diff) => (\n // The diff block has no height cap of its own, so the cap lives here; a\n // scroller must be focusable, hence the labelled region and tab stop.\n <div\n role=\"region\"\n aria-label=\"Proposed changes\"\n tabindex=\"0\"\n class=\"max-h-64 overflow-auto rounded-xl outline-none focus-visible:ring-3 focus-visible:ring-primary-subtle\"\n >\n <DiffBlock\n patch={(diff() as Extract<ConfirmationDetails, { kind: 'diff' }>).patch}\n title={bounded(diff().title, 80)}\n complete\n />\n </div>\n )}\n </Show>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyFA,SAAgB+C,aAAaC,OAA0B;CACrD,MAAM,CAACC,OAAOC,QAAQzC,WAAWuC,OAAO;EACtC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAAU,CACX;CACD,MAAMG,MAAM5C,eAAe;CAC3B,MAAM6C,UAAU,GAAGD,IAAG;CACtB,MAAME,WAAW,GAAGF,IAAG;CACvB,MAAMnB,cAAiCiB,MAAMjB,SAAS;CACtD,MAAMsB,iBAAiBlC,iBAAiBY,MAAM,CAAC;CAC/C,MAAM,CAACuB,SAASC,cAAclD,aAAiCmD,KAAAA,CAAS;CACxE,MAAM,CAACC,SAASC,cAAcrD,aAAiCmD,KAAAA,CAAS;CACxE,IAAIG,WAAW;CACf,IAAIC;CACJ,IAAIE;CAEJ,MAAME,aAAaC,SAAmDC,YAAoB;EACxF,IAAIZ,QAAQ,MAAME,KAAAA,GAA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K,CAAC,CAAoD/G;IAAK;IAAA,IACvED,QAAK;KAAA,OAAEyG,QAAQO,KAAK,CAAC,CAAChH,OAAO,EAAE;IAAC;IAChC6G,UAAQ;GAAA,CAAA,CAAA;GAAA,OAAAI;EAAA,EAAA,CAAA;CAGb,CAAA;AAGP"}
@@ -0,0 +1,3 @@
1
+ export { Confirmation, type ConfirmationDetails, type ConfirmationProps } from './confirmation';
2
+ export { confirmationOutcome, decisionReason, isAwaitingAnswer, settleDecision, type ConfirmationState, type DecisionResult, } from './confirmation-model';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/confirmation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAC/F,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,KAAK,iBAAiB,EACtB,KAAK,cAAc,GACpB,MAAM,sBAAsB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { confirmationOutcome, decisionReason, isAwaitingAnswer, settleDecision } from "./confirmation-model.js";
2
+ import { Confirmation } from "./confirmation.js";
3
+ export { Confirmation, confirmationOutcome, decisionReason, isAwaitingAnswer, settleDecision };
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The figures a host may know about a context window. Every one is optional and
3
+ * means "the host told us", so absence is never rendered as zero: `used: 0` is a
4
+ * fresh conversation, a missing `used` is an unknown.
5
+ */
6
+ export type ContextBreakdown = Readonly<{
7
+ input?: number;
8
+ output?: number;
9
+ cacheRead?: number;
10
+ cacheWrite?: number;
11
+ reasoning?: number;
12
+ }>;
13
+ export type ContextCost = Readonly<{
14
+ amount: number;
15
+ /** An ISO 4217 code such as `USD`. Without one the amount is shown unlabelled. */
16
+ currency?: string;
17
+ }>;
18
+ export type ContextFigures = Readonly<{
19
+ /** Tokens in the window now. */
20
+ used?: number;
21
+ /** The window's size. */
22
+ total?: number;
23
+ breakdown?: ContextBreakdown;
24
+ cost?: ContextCost;
25
+ }>;
26
+ /** A usable figure: a finite, non-negative number. NaN, Infinity and negatives are "unknown". */
27
+ export declare function isFigure(value: number | undefined): value is number;
28
+ /** The breakdown entries the host actually supplied, in a fixed reading order. */
29
+ export declare function breakdownRows(breakdown: ContextBreakdown | undefined): readonly {
30
+ key: string;
31
+ label: string;
32
+ value: number;
33
+ }[];
34
+ /**
35
+ * Whether there is anything to show. When there is not, the trigger is not
36
+ * rendered at all: an empty gauge or "0%" would assert an empty window.
37
+ */
38
+ export declare function hasContextFigures(figures: ContextFigures): boolean;
39
+ /**
40
+ * Percentage of the window used, rounded. Needs both figures and a non-empty
41
+ * window; it is not clamped, because "112%" is the truth about an overrun and a
42
+ * clamp would hide it (the ring is what saturates, not the number).
43
+ */
44
+ export declare function contextPercent(used: number | undefined, total: number | undefined): number | undefined;
45
+ export type ContextLevel = 'normal' | 'high' | 'critical' | 'full';
46
+ /**
47
+ * How full, in steps. The step changes an icon and a word as well as a colour, so
48
+ * it reads without colour vision and in a screen reader.
49
+ */
50
+ export declare function contextLevel(percent: number | undefined): ContextLevel;
51
+ export declare function contextLevelWord(level: ContextLevel): string | undefined;
52
+ /** Compact token count for the trigger: 950, 1.2K, 48.2K, 1.3M. */
53
+ export declare function formatTokens(value: number, locale?: string): string;
54
+ /** The exact count for the popover. */
55
+ export declare function formatExact(value: number, locale?: string): string;
56
+ /**
57
+ * Money, with its currency symbol when the code is valid. An unrecognised code
58
+ * (`Intl` throws a RangeError) is shown as written, bounded, rather than being
59
+ * swapped for a currency the host never named.
60
+ */
61
+ export declare function formatCost(cost: ContextCost, locale?: string): string;
62
+ /**
63
+ * The trigger's accessible name: the whole claim in words. Percent when both
64
+ * figures are known, else the most informative thing that is.
65
+ */
66
+ export declare function contextLabel(figures: ContextFigures, locale?: string): string | undefined;
67
+ /** The short visible text inside the trigger. Always a prefix-compatible part of `contextLabel`. */
68
+ export declare function contextShort(figures: ContextFigures, locale?: string): string | undefined;
69
+ //# sourceMappingURL=context-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-model.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/context/context-model.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAC,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,kFAAkF;IAClF,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAC,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,gCAAgC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,yBAAyB;IACzB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,IAAI,CAAC,EAAE,WAAW,CAAA;CACnB,CAAC,CAAA;AAEF,iGAAiG;AACjG,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,KAAK,IAAI,MAAM,CAEnE;AAUD,kFAAkF;AAClF,wBAAgB,aAAa,CAC3B,SAAS,EAAE,gBAAgB,GAAG,SAAS,GACtC,SAAS;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAAE,CAQ1D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CAOlE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,GAAG,SAAS,CAGpB;AAED,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAA;AAElE;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,YAAY,CAMtE;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAWxE;AAED,mEAAmE;AACnE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,SAAU,GAAG,MAAM,CAIpE;AAED,uCAAuC;AACvC,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,SAAU,GAAG,MAAM,CAEnE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,SAAU,GAAG,MAAM,CAYtE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAU,GAAG,MAAM,GAAG,SAAS,CAY1F;AAED,oGAAoG;AACpG,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAU,GAAG,MAAM,GAAG,SAAS,CAQ1F"}
@@ -0,0 +1,122 @@
1
+ import { boundText } from "../sources/source.js";
2
+ //#region src/components/composites/context/context-model.ts
3
+ /** A usable figure: a finite, non-negative number. NaN, Infinity and negatives are "unknown". */
4
+ function isFigure(value) {
5
+ return typeof value === "number" && Number.isFinite(value) && value >= 0;
6
+ }
7
+ var BREAKDOWN_ROWS = [
8
+ ["input", "Input"],
9
+ ["output", "Output"],
10
+ ["cacheRead", "Cache read"],
11
+ ["cacheWrite", "Cache write"],
12
+ ["reasoning", "Reasoning"]
13
+ ];
14
+ /** The breakdown entries the host actually supplied, in a fixed reading order. */
15
+ function breakdownRows(breakdown) {
16
+ if (!breakdown) return [];
17
+ const rows = [];
18
+ for (const [key, label] of BREAKDOWN_ROWS) {
19
+ const value = breakdown[key];
20
+ if (isFigure(value)) rows.push({
21
+ key,
22
+ label,
23
+ value
24
+ });
25
+ }
26
+ return rows;
27
+ }
28
+ /**
29
+ * Whether there is anything to show. When there is not, the trigger is not
30
+ * rendered at all: an empty gauge or "0%" would assert an empty window.
31
+ */
32
+ function hasContextFigures(figures) {
33
+ return isFigure(figures.used) || isFigure(figures.total) || breakdownRows(figures.breakdown).length > 0 || figures.cost !== void 0 && isFigure(figures.cost.amount);
34
+ }
35
+ /**
36
+ * Percentage of the window used, rounded. Needs both figures and a non-empty
37
+ * window; it is not clamped, because "112%" is the truth about an overrun and a
38
+ * clamp would hide it (the ring is what saturates, not the number).
39
+ */
40
+ function contextPercent(used, total) {
41
+ if (!isFigure(used) || !isFigure(total) || total <= 0) return void 0;
42
+ return Math.round(used / total * 100);
43
+ }
44
+ /**
45
+ * How full, in steps. The step changes an icon and a word as well as a colour, so
46
+ * it reads without colour vision and in a screen reader.
47
+ */
48
+ function contextLevel(percent) {
49
+ if (percent === void 0) return "normal";
50
+ if (percent >= 100) return "full";
51
+ if (percent >= 90) return "critical";
52
+ if (percent >= 75) return "high";
53
+ return "normal";
54
+ }
55
+ function contextLevelWord(level) {
56
+ switch (level) {
57
+ case "high": return "Getting full";
58
+ case "critical": return "Nearly full";
59
+ case "full": return "Full";
60
+ case "normal": return;
61
+ }
62
+ }
63
+ /** Compact token count for the trigger: 950, 1.2K, 48.2K, 1.3M. */
64
+ function formatTokens(value, locale = "en-US") {
65
+ return new Intl.NumberFormat(locale, {
66
+ notation: "compact",
67
+ maximumFractionDigits: 1
68
+ }).format(value);
69
+ }
70
+ /** The exact count for the popover. */
71
+ function formatExact(value, locale = "en-US") {
72
+ return new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }).format(value);
73
+ }
74
+ /**
75
+ * Money, with its currency symbol when the code is valid. An unrecognised code
76
+ * (`Intl` throws a RangeError) is shown as written, bounded, rather than being
77
+ * swapped for a currency the host never named.
78
+ */
79
+ function formatCost(cost, locale = "en-US") {
80
+ const digits = {
81
+ minimumFractionDigits: 2,
82
+ maximumFractionDigits: cost.amount < 1 ? 4 : 2
83
+ };
84
+ if (!cost.currency) return new Intl.NumberFormat(locale, digits).format(cost.amount);
85
+ try {
86
+ return new Intl.NumberFormat(locale, {
87
+ ...digits,
88
+ style: "currency",
89
+ currency: cost.currency
90
+ }).format(cost.amount);
91
+ } catch {
92
+ return `${new Intl.NumberFormat(locale, digits).format(cost.amount)} ${boundText(cost.currency, 8)}`;
93
+ }
94
+ }
95
+ /**
96
+ * The trigger's accessible name: the whole claim in words. Percent when both
97
+ * figures are known, else the most informative thing that is.
98
+ */
99
+ function contextLabel(figures, locale = "en-US") {
100
+ const percent = contextPercent(figures.used, figures.total);
101
+ if (percent !== void 0) {
102
+ const word = contextLevelWord(contextLevel(percent));
103
+ return `${percent}% of context used${word ? `, ${word.toLowerCase()}` : ""}`;
104
+ }
105
+ if (isFigure(figures.used)) return `${formatTokens(figures.used, locale)} tokens used`;
106
+ if (isFigure(figures.total)) return `${formatTokens(figures.total, locale)} token context window`;
107
+ if (breakdownRows(figures.breakdown).length > 0) return "Token usage";
108
+ if (figures.cost && isFigure(figures.cost.amount)) return `Cost ${formatCost(figures.cost, locale)}`;
109
+ }
110
+ /** The short visible text inside the trigger. Always a prefix-compatible part of `contextLabel`. */
111
+ function contextShort(figures, locale = "en-US") {
112
+ const percent = contextPercent(figures.used, figures.total);
113
+ if (percent !== void 0) return `${percent}%`;
114
+ if (isFigure(figures.used)) return formatTokens(figures.used, locale);
115
+ if (isFigure(figures.total)) return formatTokens(figures.total, locale);
116
+ if (breakdownRows(figures.breakdown).length > 0) return "Usage";
117
+ if (figures.cost && isFigure(figures.cost.amount)) return formatCost(figures.cost, locale);
118
+ }
119
+ //#endregion
120
+ export { breakdownRows, contextLabel, contextLevel, contextLevelWord, contextPercent, contextShort, formatCost, formatExact, formatTokens, hasContextFigures, isFigure };
121
+
122
+ //# sourceMappingURL=context-model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-model.js","names":[],"sources":["../../../../src/components/composites/context/context-model.ts"],"sourcesContent":["import { boundText } from '../sources/source'\n\n/**\n * The figures a host may know about a context window. Every one is optional and\n * means \"the host told us\", so absence is never rendered as zero: `used: 0` is a\n * fresh conversation, a missing `used` is an unknown.\n */\nexport type ContextBreakdown = Readonly<{\n input?: number\n output?: number\n cacheRead?: number\n cacheWrite?: number\n reasoning?: number\n}>\n\nexport type ContextCost = Readonly<{\n amount: number\n /** An ISO 4217 code such as `USD`. Without one the amount is shown unlabelled. */\n currency?: string\n}>\n\nexport type ContextFigures = Readonly<{\n /** Tokens in the window now. */\n used?: number\n /** The window's size. */\n total?: number\n breakdown?: ContextBreakdown\n cost?: ContextCost\n}>\n\n/** A usable figure: a finite, non-negative number. NaN, Infinity and negatives are \"unknown\". */\nexport function isFigure(value: number | undefined): value is number {\n return typeof value === 'number' && Number.isFinite(value) && value >= 0\n}\n\nconst BREAKDOWN_ROWS = [\n ['input', 'Input'],\n ['output', 'Output'],\n ['cacheRead', 'Cache read'],\n ['cacheWrite', 'Cache write'],\n ['reasoning', 'Reasoning'],\n] as const\n\n/** The breakdown entries the host actually supplied, in a fixed reading order. */\nexport function breakdownRows(\n breakdown: ContextBreakdown | undefined\n): readonly { key: string; label: string; value: number }[] {\n if (!breakdown) return []\n const rows: { key: string; label: string; value: number }[] = []\n for (const [key, label] of BREAKDOWN_ROWS) {\n const value = breakdown[key]\n if (isFigure(value)) rows.push({ key, label, value })\n }\n return rows\n}\n\n/**\n * Whether there is anything to show. When there is not, the trigger is not\n * rendered at all: an empty gauge or \"0%\" would assert an empty window.\n */\nexport function hasContextFigures(figures: ContextFigures): boolean {\n return (\n isFigure(figures.used) ||\n isFigure(figures.total) ||\n breakdownRows(figures.breakdown).length > 0 ||\n (figures.cost !== undefined && isFigure(figures.cost.amount))\n )\n}\n\n/**\n * Percentage of the window used, rounded. Needs both figures and a non-empty\n * window; it is not clamped, because \"112%\" is the truth about an overrun and a\n * clamp would hide it (the ring is what saturates, not the number).\n */\nexport function contextPercent(\n used: number | undefined,\n total: number | undefined\n): number | undefined {\n if (!isFigure(used) || !isFigure(total) || total <= 0) return undefined\n return Math.round((used / total) * 100)\n}\n\nexport type ContextLevel = 'normal' | 'high' | 'critical' | 'full'\n\n/**\n * How full, in steps. The step changes an icon and a word as well as a colour, so\n * it reads without colour vision and in a screen reader.\n */\nexport function contextLevel(percent: number | undefined): ContextLevel {\n if (percent === undefined) return 'normal'\n if (percent >= 100) return 'full'\n if (percent >= 90) return 'critical'\n if (percent >= 75) return 'high'\n return 'normal'\n}\n\nexport function contextLevelWord(level: ContextLevel): string | undefined {\n switch (level) {\n case 'high':\n return 'Getting full'\n case 'critical':\n return 'Nearly full'\n case 'full':\n return 'Full'\n case 'normal':\n return undefined\n }\n}\n\n/** Compact token count for the trigger: 950, 1.2K, 48.2K, 1.3M. */\nexport function formatTokens(value: number, locale = 'en-US'): string {\n return new Intl.NumberFormat(locale, { notation: 'compact', maximumFractionDigits: 1 }).format(\n value\n )\n}\n\n/** The exact count for the popover. */\nexport function formatExact(value: number, locale = 'en-US'): string {\n return new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }).format(value)\n}\n\n/**\n * Money, with its currency symbol when the code is valid. An unrecognised code\n * (`Intl` throws a RangeError) is shown as written, bounded, rather than being\n * swapped for a currency the host never named.\n */\nexport function formatCost(cost: ContextCost, locale = 'en-US'): string {\n const digits = { minimumFractionDigits: 2, maximumFractionDigits: cost.amount < 1 ? 4 : 2 }\n if (!cost.currency) return new Intl.NumberFormat(locale, digits).format(cost.amount)\n try {\n return new Intl.NumberFormat(locale, {\n ...digits,\n style: 'currency',\n currency: cost.currency,\n }).format(cost.amount)\n } catch {\n return `${new Intl.NumberFormat(locale, digits).format(cost.amount)} ${boundText(cost.currency, 8)}`\n }\n}\n\n/**\n * The trigger's accessible name: the whole claim in words. Percent when both\n * figures are known, else the most informative thing that is.\n */\nexport function contextLabel(figures: ContextFigures, locale = 'en-US'): string | undefined {\n const percent = contextPercent(figures.used, figures.total)\n if (percent !== undefined) {\n const word = contextLevelWord(contextLevel(percent))\n return `${percent}% of context used${word ? `, ${word.toLowerCase()}` : ''}`\n }\n if (isFigure(figures.used)) return `${formatTokens(figures.used, locale)} tokens used`\n if (isFigure(figures.total)) return `${formatTokens(figures.total, locale)} token context window`\n if (breakdownRows(figures.breakdown).length > 0) return 'Token usage'\n if (figures.cost && isFigure(figures.cost.amount))\n return `Cost ${formatCost(figures.cost, locale)}`\n return undefined\n}\n\n/** The short visible text inside the trigger. Always a prefix-compatible part of `contextLabel`. */\nexport function contextShort(figures: ContextFigures, locale = 'en-US'): string | undefined {\n const percent = contextPercent(figures.used, figures.total)\n if (percent !== undefined) return `${percent}%`\n if (isFigure(figures.used)) return formatTokens(figures.used, locale)\n if (isFigure(figures.total)) return formatTokens(figures.total, locale)\n if (breakdownRows(figures.breakdown).length > 0) return 'Usage'\n if (figures.cost && isFigure(figures.cost.amount)) return formatCost(figures.cost, locale)\n return undefined\n}\n"],"mappings":";;;AA+BA,SAAgB,SAAS,OAA4C;CACnE,OAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,SAAS;AACzE;AAEA,IAAM,iBAAiB;CACrB,CAAC,SAAS,OAAO;CACjB,CAAC,UAAU,QAAQ;CACnB,CAAC,aAAa,YAAY;CAC1B,CAAC,cAAc,aAAa;CAC5B,CAAC,aAAa,WAAW;AAC3B;;AAGA,SAAgB,cACd,WAC0D;CAC1D,IAAI,CAAC,WAAW,OAAO,CAAC;CACxB,MAAM,OAAwD,CAAC;CAC/D,KAAK,MAAM,CAAC,KAAK,UAAU,gBAAgB;EACzC,MAAM,QAAQ,UAAU;EACxB,IAAI,SAAS,KAAK,GAAG,KAAK,KAAK;GAAE;GAAK;GAAO;EAAM,CAAC;CACtD;CACA,OAAO;AACT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-0,0 +1,38 @@
1
+ import { type ComponentProps } from 'solid-js';
2
+ import { Popover } from '../../ui/popover';
3
+ import { type ContextFigures } from './context-model';
4
+ /**
5
+ * Context.
6
+ *
7
+ * How much of the model's context window is in use, as a compact trigger that
8
+ * opens the figures behind it. It sits next to the composer, where the reader
9
+ * decides whether to keep going or start fresh, so the trigger is small and the
10
+ * detail is a press away rather than permanent chrome.
11
+ *
12
+ * ## Every figure is a claim, so every figure is optional
13
+ *
14
+ * A host passes whatever it knows: `used`, `total`, a `breakdown` (input, output,
15
+ * cache read and write, reasoning), a `cost`. A missing value is omitted — never
16
+ * drawn as 0, which would say "empty" about a window nobody measured — and when
17
+ * *nothing* is known the trigger is not rendered at all (`hasContextFigures`).
18
+ * Nothing is estimated here; the one derived row, "Remaining", appears only when
19
+ * both `used` and `total` are known and `used` does not exceed `total`.
20
+ *
21
+ * ## Never colour alone
22
+ *
23
+ * The ring shows the fraction; past 75% the ring gives way to a warning glyph
24
+ * (triangle, then octagon at 90% and above), the popover says "Getting full",
25
+ * "Nearly full" or "Full" in words, and the trigger's accessible name speaks the
26
+ * same. An overrun is reported as it is ("112%"); only the ring saturates.
27
+ *
28
+ * It is a `Popover`, not a hover card: the figures must be reachable by keyboard
29
+ * and by touch, and Escape closes it and returns focus to the trigger.
30
+ */
31
+ export type ContextProps = ContextFigures & {
32
+ /** BCP 47 tag for number formatting. Defaults to `en-US`, so output is stable. */
33
+ locale?: string;
34
+ placement?: ComponentProps<typeof Popover>['placement'];
35
+ class?: string;
36
+ };
37
+ export declare function Context(props: ContextProps): import("solid-js").JSX.Element;
38
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/context/context.tsx"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,UAAU,CAAA;AAGrE,OAAO,EAAE,OAAO,EAAgD,MAAM,kBAAkB,CAAA;AAExF,OAAO,EAWL,KAAK,cAAc,EAEpB,MAAM,iBAAiB,CAAA;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,MAAM,YAAY,GAAG,cAAc,GAAG;IAC1C,kFAAkF;IAClF,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,cAAc,CAAC,OAAO,OAAO,CAAC,CAAC,WAAW,CAAC,CAAA;IACvD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAMD,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,kCAmG1C"}