@kitn.ai/ui 0.16.0 → 0.18.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 (493) hide show
  1. package/README.md +55 -17
  2. package/dist/components/artifact.d.ts +39 -1
  3. package/dist/components/attachment-types.d.ts +12 -0
  4. package/dist/components/attachments.d.ts +2 -10
  5. package/dist/components/card.d.ts +27 -0
  6. package/dist/components/chain-of-thought.d.ts +78 -2
  7. package/dist/components/chat-scope-picker.d.ts +7 -0
  8. package/dist/components/chat-thread.d.ts +39 -16
  9. package/dist/components/choice-card.d.ts +27 -0
  10. package/dist/components/coachmark.d.ts +49 -0
  11. package/dist/components/composer-dom.d.ts +35 -0
  12. package/dist/components/composer-highlight.d.ts +48 -0
  13. package/dist/components/composer-history.d.ts +34 -0
  14. package/dist/components/composer.d.ts +86 -0
  15. package/dist/components/confirm-card.d.ts +17 -0
  16. package/dist/components/conversation-item.d.ts +9 -0
  17. package/dist/components/conversation-list.d.ts +36 -1
  18. package/dist/components/dismissed-stub.d.ts +22 -0
  19. package/dist/components/file-tree.d.ts +15 -0
  20. package/dist/components/form.d.ts +34 -0
  21. package/dist/components/markdown.d.ts +3 -0
  22. package/dist/components/message.d.ts +71 -2
  23. package/dist/components/model-switcher.d.ts +7 -0
  24. package/dist/components/prompt-input.d.ts +13 -4
  25. package/dist/components/prompt-suggestion.d.ts +9 -1
  26. package/dist/components/reasoning.d.ts +14 -1
  27. package/dist/components/response-compare-types.d.ts +66 -0
  28. package/dist/components/response-compare.d.ts +65 -0
  29. package/dist/components/screen.d.ts +46 -0
  30. package/dist/components/tasks-card.d.ts +50 -1
  31. package/dist/components/toast.d.ts +58 -0
  32. package/dist/components/tool-types.d.ts +10 -0
  33. package/dist/components/tool.d.ts +8 -8
  34. package/dist/components/use-card-resolution.d.ts +10 -6
  35. package/dist/components/voice-input.d.ts +27 -0
  36. package/dist/components/voice-output.d.ts +33 -0
  37. package/dist/core-C8fzo39E.js +12 -0
  38. package/dist/custom-elements.json +8472 -1691
  39. package/dist/elements/agent-card.d.ts +1 -0
  40. package/dist/elements/agent-card.js +1 -0
  41. package/dist/elements/artifact.js +1 -0
  42. package/dist/elements/attachments.js +1 -0
  43. package/dist/elements/autoloader.d.ts +2 -0
  44. package/dist/elements/autoloader.js +1 -0
  45. package/dist/elements/avatar.d.ts +1 -0
  46. package/dist/elements/avatar.js +1 -0
  47. package/dist/elements/badge.d.ts +1 -0
  48. package/dist/elements/badge.js +1 -0
  49. package/dist/elements/button.d.ts +1 -0
  50. package/dist/elements/button.js +1 -0
  51. package/dist/elements/card.js +1 -0
  52. package/dist/elements/cards.d.ts +1 -0
  53. package/dist/elements/cards.js +1 -0
  54. package/dist/elements/chain-of-thought.d.ts +0 -12
  55. package/dist/elements/chain-of-thought.js +1 -0
  56. package/dist/elements/chat-scope-picker.js +1 -0
  57. package/dist/elements/chat-types.d.ts +8 -2
  58. package/dist/elements/chat-workspace.js +1 -0
  59. package/dist/elements/chat.js +1 -0
  60. package/dist/elements/checkpoint.js +1 -0
  61. package/dist/elements/choice.js +1 -0
  62. package/dist/elements/chunks/Icon-DLLBeLG5.js +1 -0
  63. package/dist/elements/chunks/action-icons-UB4V5FNq.js +1 -0
  64. package/dist/elements/chunks/arrow-left-C-gwlUmx.js +1 -0
  65. package/dist/elements/chunks/attachments-CgbErf1r.js +1 -0
  66. package/dist/elements/chunks/badge-DTQpgB6N.js +1 -0
  67. package/dist/elements/chunks/bash-InADTalH.js +1 -0
  68. package/dist/elements/chunks/button-XDUM6lXs.js +1 -0
  69. package/dist/elements/chunks/card-CBlFZ-7I.js +1 -0
  70. package/dist/elements/chunks/card-routing-C986KuUA.js +1 -0
  71. package/dist/elements/chunks/chat-thread-BIhmqwNL.js +1 -0
  72. package/dist/elements/chunks/check-hGUoVIKb.js +1 -0
  73. package/dist/elements/chunks/chevron-down-DDoaSUtO.js +1 -0
  74. package/dist/elements/chunks/chevron-right-CdGEUakB.js +1 -0
  75. package/dist/elements/chunks/circle-BKAZdmzb.js +1 -0
  76. package/dist/elements/chunks/circle-check-CmYG-y3I.js +1 -0
  77. package/dist/elements/chunks/circle-x-DewgAEym.js +1 -0
  78. package/dist/elements/chunks/cn-CU7UAWzk.js +1 -0
  79. package/dist/elements/chunks/code-block-DedwxwFI.js +1 -0
  80. package/dist/elements/chunks/collapsible-FfgmTHtM.js +1 -0
  81. package/dist/elements/chunks/composer-Cfbw5HKT.js +65 -0
  82. package/dist/elements/chunks/context-DwJmxlRE.js +1 -0
  83. package/dist/elements/chunks/conversation-list-DsCQMfPq.js +1 -0
  84. package/dist/elements/chunks/core-AYMC6_lb.js +12 -0
  85. package/dist/elements/chunks/css-M7EaDHN_.js +1 -0
  86. package/dist/elements/chunks/default-input-BuqsoENC.js +1 -0
  87. package/dist/elements/chunks/define-rGsaWsLL.js +1 -0
  88. package/dist/elements/chunks/disclosure-CwoAkpMH.js +1 -0
  89. package/dist/elements/chunks/download-DJ06G3Bz.js +1 -0
  90. package/dist/elements/chunks/dropdown-BFg8ri_R.js +1 -0
  91. package/dist/elements/chunks/ellipsis-dlN6YvGw.js +1 -0
  92. package/dist/elements/chunks/engine-javascript-vq0WuIJl.js +141 -0
  93. package/dist/elements/chunks/external-link-DBX2lc_R.js +1 -0
  94. package/dist/elements/chunks/file-text-HfwUx4F9.js +1 -0
  95. package/dist/elements/chunks/file-tree-C6Toj71u.js +1 -0
  96. package/dist/elements/chunks/folder-MYuqa9Xp.js +1 -0
  97. package/dist/elements/chunks/github-dark-dimmed-DUshB20C.js +1 -0
  98. package/dist/elements/chunks/github-light-JYsPkUQd.js +1 -0
  99. package/dist/elements/chunks/hover-card-gE7iyXdW.js +1 -0
  100. package/dist/elements/chunks/html-CPZ3oZQ7.js +1 -0
  101. package/dist/elements/chunks/icon-Vqz4ivrY.js +1 -0
  102. package/dist/elements/chunks/index-BCRhi84a.js +1 -0
  103. package/dist/elements/chunks/info-B_toFS0l.js +1 -0
  104. package/dist/elements/chunks/input-gzbHYZvQ.js +1 -0
  105. package/dist/elements/chunks/javascript-C25yR2R2.js +1 -0
  106. package/dist/elements/chunks/json-DxJze_jm.js +1 -0
  107. package/dist/elements/chunks/kbd-n49c4KZm.js +1 -0
  108. package/dist/elements/chunks/link-CKPs9yM0.js +1 -0
  109. package/dist/elements/chunks/loader-q6MamGus.js +1 -0
  110. package/dist/elements/chunks/markdown-DBrcqq4S.js +64 -0
  111. package/dist/elements/chunks/message-CTqaYI0s.js +1 -0
  112. package/dist/elements/chunks/message-feedback-Cvzm03w0.js +1 -0
  113. package/dist/elements/chunks/message-square-CUg9eRCi.js +1 -0
  114. package/dist/elements/chunks/minimize-2-l2klxP6K.js +1 -0
  115. package/dist/elements/chunks/model-switcher-CmyjiHO1.js +1 -0
  116. package/dist/elements/chunks/overlay-C8sOYqjT.js +1 -0
  117. package/dist/elements/chunks/paperclip-42Ia7xHD.js +1 -0
  118. package/dist/elements/chunks/progress-bar-tzKMWAwO.js +1 -0
  119. package/dist/elements/chunks/prompt-suggestion-D3F6vP_A.js +1 -0
  120. package/dist/elements/chunks/reasoning-BJNmmyov.js +1 -0
  121. package/dist/elements/chunks/resizable-BRsk19qI.js +1 -0
  122. package/dist/elements/chunks/rotate-cw-BgcggLHC.js +1 -0
  123. package/dist/elements/chunks/scroll-area-CgGbFFbT.js +1 -0
  124. package/dist/elements/chunks/separator-8hM4GdHE.js +1 -0
  125. package/dist/elements/chunks/settings-CaUIYOg-.js +1 -0
  126. package/dist/elements/chunks/settings-group-CYjOVIZQ.js +1 -0
  127. package/dist/elements/chunks/share-BTYM3Ddt.js +1 -0
  128. package/dist/elements/chunks/skeleton-DsTYrPUe.js +1 -0
  129. package/dist/elements/chunks/slots-DkZ-Cmha.js +1 -0
  130. package/dist/elements/chunks/star-9R3LBQ9n.js +1 -0
  131. package/dist/elements/chunks/store-CYl5Y0_u.js +1 -0
  132. package/dist/elements/chunks/svelte--5p79yCD.js +1 -0
  133. package/dist/elements/chunks/text-shimmer-CaYGv8Se.js +1 -0
  134. package/dist/elements/chunks/textarea-NEr2SLcD.js +1 -0
  135. package/dist/elements/chunks/thumbs-up-DZYZkFfc.js +1 -0
  136. package/dist/elements/chunks/toast-store-ClxVZRcc.js +1 -0
  137. package/dist/elements/chunks/tool-CHZOmoe9.js +1 -0
  138. package/dist/elements/chunks/tooltip-WpHElELC.js +1 -0
  139. package/dist/elements/chunks/triangle-alert-BlS80PUg.js +1 -0
  140. package/dist/elements/chunks/tsx-B8rCNbgL.js +1 -0
  141. package/dist/elements/chunks/typescript-RycA9KXf.js +1 -0
  142. package/dist/elements/chunks/use-card-resolution-VSVoxDeJ.js +1 -0
  143. package/dist/elements/chunks/video-DxTPZqT8.js +1 -0
  144. package/dist/elements/chunks/vue-BmIZj4XD.js +1 -0
  145. package/dist/elements/chunks/x-C1qtndxn.js +1 -0
  146. package/dist/elements/coachmark.d.ts +1 -0
  147. package/dist/elements/coachmark.js +1 -0
  148. package/dist/elements/code-block.js +1 -0
  149. package/dist/elements/command.d.ts +1 -0
  150. package/dist/elements/command.js +1 -0
  151. package/dist/elements/compare.d.ts +1 -0
  152. package/dist/elements/compare.js +1 -0
  153. package/dist/elements/composer.d.ts +1 -0
  154. package/dist/elements/composer.js +1 -0
  155. package/dist/elements/confirm-card.js +1 -0
  156. package/dist/elements/context-meter.js +1 -0
  157. package/dist/elements/conversation-list.d.ts +1 -11
  158. package/dist/elements/conversation-list.js +1 -0
  159. package/dist/elements/default-input.d.ts +20 -9
  160. package/dist/elements/define.d.ts +11 -0
  161. package/dist/elements/dialog.d.ts +1 -0
  162. package/dist/elements/dialog.js +1 -0
  163. package/dist/elements/disclosure.d.ts +37 -0
  164. package/dist/elements/editable-label.d.ts +1 -0
  165. package/dist/elements/editable-label.js +1 -0
  166. package/dist/elements/embed.js +1 -0
  167. package/dist/elements/empty.js +1 -0
  168. package/dist/elements/feedback-bar.js +1 -0
  169. package/dist/elements/file-tree.js +1 -0
  170. package/dist/elements/file-upload.js +1 -0
  171. package/dist/elements/form.js +1 -0
  172. package/dist/elements/hover-card.d.ts +1 -0
  173. package/dist/elements/hover-card.js +1 -0
  174. package/dist/elements/icon.d.ts +1 -0
  175. package/dist/elements/icon.js +1 -0
  176. package/dist/elements/image.js +1 -0
  177. package/dist/elements/input.d.ts +1 -0
  178. package/dist/elements/input.js +1 -0
  179. package/dist/elements/kbd.d.ts +1 -0
  180. package/dist/elements/kbd.js +1 -0
  181. package/dist/elements/link-preview.js +1 -0
  182. package/dist/elements/loader.js +1 -0
  183. package/dist/elements/markdown.js +1 -0
  184. package/dist/elements/menu.d.ts +1 -0
  185. package/dist/elements/menu.js +1 -0
  186. package/dist/elements/message-skills.d.ts +0 -16
  187. package/dist/elements/message-skills.js +1 -0
  188. package/dist/elements/message.js +1 -0
  189. package/dist/elements/model-switcher.d.ts +1 -11
  190. package/dist/elements/model-switcher.js +1 -0
  191. package/dist/elements/nav.d.ts +1 -0
  192. package/dist/elements/nav.js +1 -0
  193. package/dist/elements/notice.d.ts +1 -0
  194. package/dist/elements/notice.js +1 -0
  195. package/dist/elements/pane-group.d.ts +1 -0
  196. package/dist/elements/pane-group.js +1 -0
  197. package/dist/elements/pane.d.ts +1 -0
  198. package/dist/elements/pane.js +1 -0
  199. package/dist/elements/popover.js +1 -0
  200. package/dist/elements/progress-bar.d.ts +1 -0
  201. package/dist/elements/progress-bar.js +1 -0
  202. package/dist/elements/prompt-dock.d.ts +1 -0
  203. package/dist/elements/prompt-dock.js +1 -0
  204. package/dist/elements/prompt-input.d.ts +1 -9
  205. package/dist/elements/prompt-input.js +1 -0
  206. package/dist/elements/prompt-suggestions.d.ts +0 -6
  207. package/dist/elements/prompt-suggestions.js +1 -0
  208. package/dist/elements/reasoning.js +1 -0
  209. package/dist/elements/register.d.ts +10 -0
  210. package/dist/elements/remote.js +1 -0
  211. package/dist/elements/resizable.d.ts +1 -17
  212. package/dist/elements/resizable.js +1 -0
  213. package/dist/elements/response-stream.js +14 -0
  214. package/dist/elements/screen.d.ts +1 -0
  215. package/dist/elements/screen.js +1 -0
  216. package/dist/elements/scroll-area.d.ts +1 -0
  217. package/dist/elements/scroll-area.js +1 -0
  218. package/dist/elements/scroll-button.js +1 -0
  219. package/dist/elements/search.d.ts +1 -0
  220. package/dist/elements/search.js +1 -0
  221. package/dist/elements/segmented.d.ts +1 -0
  222. package/dist/elements/segmented.js +1 -0
  223. package/dist/elements/separator.d.ts +1 -0
  224. package/dist/elements/separator.js +1 -0
  225. package/dist/elements/setting-item.d.ts +1 -0
  226. package/dist/elements/setting-item.js +1 -0
  227. package/dist/elements/settings-group.d.ts +1 -0
  228. package/dist/elements/settings-group.js +1 -0
  229. package/dist/elements/skeleton.d.ts +1 -0
  230. package/dist/elements/skeleton.js +1 -0
  231. package/dist/elements/slots.d.ts +176 -0
  232. package/dist/elements/source.d.ts +0 -17
  233. package/dist/elements/source.js +1 -0
  234. package/dist/elements/status.d.ts +1 -0
  235. package/dist/elements/status.js +1 -0
  236. package/dist/elements/switch.js +1 -0
  237. package/dist/elements/tabs.d.ts +1 -0
  238. package/dist/elements/tabs.js +1 -0
  239. package/dist/elements/tasks.js +1 -0
  240. package/dist/elements/text-shimmer.js +1 -0
  241. package/dist/elements/thinking-bar.js +1 -0
  242. package/dist/elements/toast.d.ts +1 -0
  243. package/dist/elements/toast.js +1 -0
  244. package/dist/elements/tool.js +1 -0
  245. package/dist/elements/tooltip.d.ts +1 -0
  246. package/dist/elements/tooltip.js +1 -0
  247. package/dist/elements/voice-input.js +1 -0
  248. package/dist/elements/voice-output.d.ts +1 -0
  249. package/dist/elements/voice-output.js +1 -0
  250. package/dist/elements.d.ts +772 -61
  251. package/dist/engine-javascript-C1x7zo1_.js +141 -0
  252. package/dist/index.d.ts +15 -2
  253. package/dist/index.js +14405 -9810
  254. package/dist/kai.es.js +1 -0
  255. package/dist/llms/llms-full.txt +1234 -107
  256. package/dist/llms/llms.txt +4 -4
  257. package/dist/mcp.es.js +217 -6
  258. package/dist/primitives/card-contract.d.ts +20 -4
  259. package/dist/primitives/card-recovery.d.ts +55 -0
  260. package/dist/primitives/composer-model.d.ts +22 -0
  261. package/dist/primitives/composer-triggers.d.ts +19 -0
  262. package/dist/primitives/create-kai-chat.d.ts +38 -0
  263. package/dist/primitives/message-feedback.d.ts +35 -0
  264. package/dist/primitives/toast-store.d.ts +118 -0
  265. package/dist/primitives/use-speech-recognition.d.ts +26 -0
  266. package/dist/react/index.d.ts +1166 -98
  267. package/dist/react/runtime.d.ts +9 -2
  268. package/dist/react/use-kai-chat.d.ts +41 -0
  269. package/dist/react.js +575 -186
  270. package/dist/register-impl-CYWGkgbI.js +141 -0
  271. package/dist/schemas/choice.schema.json +5 -0
  272. package/dist/schemas/tasks.schema.json +7 -2
  273. package/dist/state/index.d.ts +4 -0
  274. package/dist/state/messages.d.ts +11 -0
  275. package/dist/state/stream.d.ts +22 -0
  276. package/dist/state/suggestions.d.ts +4 -0
  277. package/dist/state.js +117 -0
  278. package/dist/theme.tokens.css +87 -0
  279. package/dist/types.d.ts +4 -0
  280. package/dist/ui/agent-card.d.ts +61 -0
  281. package/dist/ui/button.d.ts +5 -2
  282. package/dist/ui/card.d.ts +61 -0
  283. package/dist/ui/collapsible.d.ts +15 -1
  284. package/dist/ui/command.d.ts +33 -0
  285. package/dist/ui/dialog.d.ts +42 -0
  286. package/dist/ui/dropdown.d.ts +95 -1
  287. package/dist/ui/editable-label.d.ts +26 -0
  288. package/dist/ui/hover-card.d.ts +13 -1
  289. package/dist/ui/icon.d.ts +18 -0
  290. package/dist/ui/input.d.ts +33 -0
  291. package/dist/ui/kbd.d.ts +21 -0
  292. package/dist/ui/nav.d.ts +62 -0
  293. package/dist/ui/notice.d.ts +31 -0
  294. package/dist/ui/overlay.d.ts +12 -0
  295. package/dist/ui/pane-grid.d.ts +58 -0
  296. package/dist/ui/pane-group.d.ts +75 -0
  297. package/dist/ui/pane.d.ts +78 -0
  298. package/dist/ui/popover.d.ts +11 -1
  299. package/dist/ui/progress-bar.d.ts +23 -0
  300. package/dist/ui/prompt-dock.d.ts +96 -0
  301. package/dist/ui/resizable.d.ts +12 -0
  302. package/dist/ui/scroll-area.d.ts +4 -0
  303. package/dist/ui/segmented.d.ts +28 -0
  304. package/dist/ui/settings-group.d.ts +32 -0
  305. package/dist/ui/skeleton.d.ts +12 -0
  306. package/dist/ui/stat.d.ts +16 -0
  307. package/dist/ui/status.d.ts +13 -0
  308. package/dist/ui/switch.d.ts +8 -1
  309. package/dist/ui/tabs.d.ts +35 -0
  310. package/dist/ui/tooltip.d.ts +20 -1
  311. package/frameworks/react/index.tsx +1100 -163
  312. package/frameworks/react/runtime.tsx +30 -1
  313. package/frameworks/react/use-kai-chat.tsx +87 -0
  314. package/llms-full.txt +1234 -107
  315. package/llms.txt +4 -4
  316. package/package.json +36 -12
  317. package/src/agent-tooling/mcp/manifest.ts +14 -0
  318. package/src/agent-tooling/mcp/tools/debug.ts +194 -6
  319. package/src/agent-tooling/mcp/tools/reference.ts +32 -0
  320. package/src/agent-tooling/mcp/tools/scaffold.ts +162 -1
  321. package/src/components/artifact.tsx +98 -13
  322. package/src/components/attachment-types.ts +13 -0
  323. package/src/components/attachments.tsx +4 -14
  324. package/src/components/card.tsx +109 -15
  325. package/src/components/chain-of-thought.tsx +210 -1
  326. package/src/components/chat-scope-picker.tsx +13 -3
  327. package/src/components/chat-thread.tsx +238 -137
  328. package/src/components/choice-card.tsx +136 -15
  329. package/src/components/coachmark.tsx +245 -0
  330. package/src/components/component-meta.json +921 -108
  331. package/src/components/composer-dom.ts +159 -0
  332. package/src/components/composer-highlight.ts +242 -0
  333. package/src/components/composer-history.ts +82 -0
  334. package/src/components/composer.tsx +979 -0
  335. package/src/components/confirm-card.tsx +69 -2
  336. package/src/components/conversation-item.tsx +69 -7
  337. package/src/components/conversation-list.tsx +134 -37
  338. package/src/components/dismissed-stub.tsx +80 -0
  339. package/src/components/file-tree.tsx +197 -47
  340. package/src/components/form-widgets.tsx +9 -7
  341. package/src/components/form.tsx +161 -20
  342. package/src/components/image.tsx +3 -5
  343. package/src/components/link-preview.tsx +5 -4
  344. package/src/components/markdown.tsx +5 -2
  345. package/src/components/message.tsx +174 -14
  346. package/src/components/model-switcher.tsx +19 -4
  347. package/src/components/prompt-input.tsx +46 -75
  348. package/src/components/prompt-suggestion.tsx +48 -16
  349. package/src/components/reasoning.tsx +29 -6
  350. package/src/components/response-compare-types.ts +127 -0
  351. package/src/components/response-compare.tsx +460 -0
  352. package/src/components/screen.tsx +176 -0
  353. package/src/components/tasks-card.tsx +374 -23
  354. package/src/components/toast.tsx +486 -0
  355. package/src/components/tool-types.ts +10 -0
  356. package/src/components/tool.tsx +22 -16
  357. package/src/components/use-card-resolution.ts +24 -8
  358. package/src/components/voice-input.tsx +102 -19
  359. package/src/components/voice-output.tsx +202 -0
  360. package/src/elements/agent-card.tsx +67 -0
  361. package/src/elements/artifact.tsx +53 -4
  362. package/src/elements/attachments.tsx +1 -0
  363. package/src/elements/autoloader.ts +89 -0
  364. package/src/elements/avatar.tsx +33 -0
  365. package/src/elements/badge.tsx +32 -0
  366. package/src/elements/button.tsx +126 -0
  367. package/src/elements/card-media.jpg +0 -0
  368. package/src/elements/card.tsx +124 -31
  369. package/src/elements/cards.tsx +81 -7
  370. package/src/elements/chain-of-thought.tsx +77 -32
  371. package/src/elements/chat-scope-picker.tsx +35 -8
  372. package/src/elements/chat-types.ts +9 -2
  373. package/src/elements/chat-workspace.tsx +157 -43
  374. package/src/elements/chat.tsx +49 -25
  375. package/src/elements/choice.tsx +71 -19
  376. package/src/elements/coachmark.tsx +90 -0
  377. package/src/elements/command.tsx +209 -0
  378. package/src/elements/compare.tsx +110 -0
  379. package/src/elements/compiled.css +1 -1
  380. package/src/elements/composer.tsx +151 -0
  381. package/src/elements/confirm-card.tsx +36 -11
  382. package/src/elements/conversation-list.tsx +80 -11
  383. package/src/elements/default-input.tsx +75 -53
  384. package/src/elements/define.tsx +47 -6
  385. package/src/elements/dialog.tsx +98 -0
  386. package/src/elements/disclosure.ts +73 -0
  387. package/src/elements/editable-label.tsx +125 -0
  388. package/src/elements/element-manifest.json +310 -0
  389. package/src/elements/element-meta.json +5954 -1605
  390. package/src/elements/element-types.d.ts +771 -60
  391. package/src/elements/file-tree.tsx +12 -2
  392. package/src/elements/file-upload.tsx +1 -1
  393. package/src/elements/form.tsx +54 -11
  394. package/src/elements/hover-card.tsx +80 -0
  395. package/src/elements/icon-names.json +48 -0
  396. package/src/elements/icon.tsx +41 -0
  397. package/src/elements/input.tsx +203 -0
  398. package/src/elements/kbd.tsx +45 -0
  399. package/src/elements/menu.tsx +217 -0
  400. package/src/elements/message.tsx +84 -55
  401. package/src/elements/model-switcher.tsx +27 -1
  402. package/src/elements/nav.tsx +87 -0
  403. package/src/elements/notice.tsx +53 -0
  404. package/src/elements/pane-group.tsx +119 -0
  405. package/src/elements/pane.tsx +129 -0
  406. package/src/elements/popover.tsx +39 -17
  407. package/src/elements/progress-bar.tsx +39 -0
  408. package/src/elements/prompt-dock.tsx +81 -0
  409. package/src/elements/prompt-input.tsx +112 -63
  410. package/src/elements/prompt-suggestions.tsx +25 -9
  411. package/src/elements/reasoning.tsx +30 -9
  412. package/src/elements/register-impl.ts +41 -3
  413. package/src/elements/register.ts +20 -3
  414. package/src/elements/remote.tsx +4 -0
  415. package/src/elements/resizable.tsx +48 -11
  416. package/src/elements/screen.tsx +90 -0
  417. package/src/elements/scroll-area.tsx +33 -0
  418. package/src/elements/search.tsx +180 -0
  419. package/src/elements/segmented.tsx +135 -0
  420. package/src/elements/separator.tsx +36 -0
  421. package/src/elements/setting-item.tsx +50 -0
  422. package/src/elements/settings-group.tsx +37 -0
  423. package/src/elements/skeleton.tsx +45 -0
  424. package/src/elements/slots.ts +607 -0
  425. package/src/elements/source.tsx +13 -6
  426. package/src/elements/status.tsx +42 -0
  427. package/src/elements/styles.css +19 -0
  428. package/src/elements/switch.tsx +89 -14
  429. package/src/elements/tabs.tsx +95 -0
  430. package/src/elements/tasks.tsx +70 -14
  431. package/src/elements/toast.tsx +89 -0
  432. package/src/elements/tool.tsx +43 -9
  433. package/src/elements/tooltip.tsx +85 -0
  434. package/src/elements/video-poster.jpg +0 -0
  435. package/src/elements/voice-input.tsx +66 -16
  436. package/src/elements/voice-output.tsx +69 -0
  437. package/src/index.ts +35 -2
  438. package/src/primitives/card-contract.ts +14 -5
  439. package/src/primitives/card-recovery.ts +149 -0
  440. package/src/primitives/card-routing.ts +3 -0
  441. package/src/primitives/card-schemas/choice.schema.json +5 -0
  442. package/src/primitives/card-schemas/tasks.schema.json +7 -2
  443. package/src/primitives/composer-model.ts +49 -0
  444. package/src/primitives/composer-triggers.ts +35 -0
  445. package/src/primitives/create-kai-chat.ts +66 -0
  446. package/src/primitives/message-feedback.ts +123 -0
  447. package/src/primitives/toast-store.ts +276 -0
  448. package/src/primitives/use-speech-recognition.ts +135 -0
  449. package/src/state/index.ts +6 -0
  450. package/src/state/messages.ts +36 -0
  451. package/src/state/stream.ts +92 -0
  452. package/src/state/suggestions.ts +9 -0
  453. package/src/types.ts +4 -0
  454. package/src/ui/agent-card.tsx +212 -0
  455. package/src/ui/button.tsx +16 -5
  456. package/src/ui/card.tsx +245 -0
  457. package/src/ui/collapsible.tsx +30 -4
  458. package/src/ui/command.tsx +99 -0
  459. package/src/ui/dialog.tsx +217 -0
  460. package/src/ui/dropdown.tsx +375 -13
  461. package/src/ui/editable-label.tsx +112 -0
  462. package/src/ui/hover-card.tsx +28 -5
  463. package/src/ui/icon.tsx +110 -0
  464. package/src/ui/input.tsx +132 -0
  465. package/src/ui/kbd.tsx +118 -0
  466. package/src/ui/nav.tsx +282 -0
  467. package/src/ui/notice.tsx +84 -0
  468. package/src/ui/overlay.tsx +108 -2
  469. package/src/ui/pane-grid.tsx +116 -0
  470. package/src/ui/pane-group.tsx +280 -0
  471. package/src/ui/pane.tsx +193 -0
  472. package/src/ui/popover.tsx +16 -2
  473. package/src/ui/progress-bar.tsx +83 -0
  474. package/src/ui/prompt-dock.tsx +145 -0
  475. package/src/ui/resizable.tsx +69 -1
  476. package/src/ui/scroll-area.tsx +14 -3
  477. package/src/ui/segmented.tsx +109 -0
  478. package/src/ui/settings-group.tsx +67 -0
  479. package/src/ui/skeleton.tsx +62 -5
  480. package/src/ui/stat.tsx +41 -0
  481. package/src/ui/status.tsx +48 -0
  482. package/src/ui/switch.tsx +49 -23
  483. package/src/ui/tabs.tsx +168 -0
  484. package/src/ui/tooltip.tsx +57 -7
  485. package/theme.css +113 -0
  486. package/dist/components/slash-command.d.ts +0 -15
  487. package/dist/kitn-chat.es.js +0 -1
  488. package/dist/register-impl-wCsFPoh9.js +0 -77
  489. package/dist/register-ujhr1nBS.js +0 -1
  490. package/src/components/slash-command.tsx +0 -232
  491. package/src/elements/framework-usage.json +0 -563
  492. /package/dist/{kitn-chat-provider.d.ts → kai-provider.d.ts} +0 -0
  493. /package/dist/{kitn-chat-provider.es.js → kai-provider.es.js} +0 -0
@@ -0,0 +1,486 @@
1
+ import {
2
+ createSignal, createEffect, onCleanup, on, For, Show, createMemo,
3
+ } from 'solid-js';
4
+ import { X, Check, AlertTriangle, XCircle, Info } from 'lucide-solid';
5
+ import { cn } from '../utils/cn';
6
+ import { createPresence } from '../ui/overlay';
7
+ import {
8
+ type ToastItem, type ToastVariant, type ToastAppearance, resolveDuration,
9
+ } from '../primitives/toast-store';
10
+
11
+ export type { ToastItem, ToastVariant, ToastAppearance };
12
+
13
+ /** Why a toast went away — surfaced to `onDismiss` (and the facade event). */
14
+ export type ToastDismissReason = 'timeout' | 'close' | 'action';
15
+
16
+ export type ToastPosition = 'top-center' | 'top-right' | 'top-left' | 'bottom-center' | 'bottom-right' | 'bottom-left';
17
+
18
+ export interface ToastRegionProps {
19
+ /** The toasts to render. Newest is shown on top. Set as a JS property on the
20
+ * element; mutate by passing a new array reference. */
21
+ toasts: ToastItem[];
22
+ /** Where the stack anchors. Defaults to `'top-center'`. */
23
+ position?: ToastPosition;
24
+ /** Max simultaneously-visible toasts; the rest queue and promote as slots
25
+ * free up. Defaults to `3`. */
26
+ max?: number;
27
+ /** Stacking: 'expanded' (default, full column) | 'collapsed' (Sonner-style
28
+ * pile that expands on hover/focus). Attribute: stack. */
29
+ stack?: 'expanded' | 'collapsed';
30
+ /** Region-level default appearance for toasts that don't set their own. A
31
+ * per-toast `appearance` always wins. Defaults to `'pill'`. */
32
+ appearance?: ToastAppearance;
33
+ /** Region-level default inverse treatment for toasts that don't set their own.
34
+ * A per-toast `inverse` always wins. Defaults to `false`. */
35
+ inverse?: boolean;
36
+ /** When set, this region renders only the toasts scoped to that element and
37
+ * anchors over its bounds (top-center), following it on scroll/resize. Unset =
38
+ * the global, viewport-anchored region. */
39
+ target?: HTMLElement;
40
+ /** Fired when a toast leaves, with the reason. */
41
+ onDismiss?: (id: string, reason: ToastDismissReason) => void;
42
+ /** Fired when a toast's action button is pressed. */
43
+ onAction?: (id: string, label: string) => void;
44
+ }
45
+
46
+ /** Reactive `prefers-reduced-motion`. SSR-safe (returns false when no window). */
47
+ function usePrefersReducedMotion() {
48
+ const [reduced, setReduced] = createSignal(
49
+ typeof window !== 'undefined' && window.matchMedia?.('(prefers-reduced-motion: reduce)').matches === true,
50
+ );
51
+ if (typeof window !== 'undefined' && window.matchMedia) {
52
+ const mq = window.matchMedia('(prefers-reduced-motion: reduce)');
53
+ const on = () => setReduced(mq.matches);
54
+ mq.addEventListener?.('change', on);
55
+ onCleanup(() => mq.removeEventListener?.('change', on));
56
+ }
57
+ return reduced;
58
+ }
59
+
60
+ // ── Single toast pill ────────────────────────────────────────────────────────
61
+
62
+ interface ToastProps {
63
+ item: ToastItem;
64
+ onDismiss: (reason: ToastDismissReason) => void;
65
+ onAction?: (label: string) => void;
66
+ /** Hold the auto-dismiss timer (the region sets this true while the whole stack
67
+ * is hovered/expanded, so peers don't dismiss out from under the cursor). */
68
+ paused?: boolean;
69
+ /** Region-level default appearance, used when the item doesn't set its own. */
70
+ appearance?: ToastAppearance;
71
+ /** Region-level default inverse, used when the item doesn't set its own. */
72
+ inverse?: boolean;
73
+ }
74
+
75
+ /**
76
+ * A single toast pill. Auto-dismisses after its (action-floored) duration, holds
77
+ * the timer while hovered (this pill) OR while `paused` (the whole stack is
78
+ * hovered), and animates in/out via `createPresence`. Pure + prop-driven — the
79
+ * parent `ToastRegion` owns the list + queue.
80
+ */
81
+ export function Toast(props: ToastProps) {
82
+ const [open, setOpen] = createSignal(true);
83
+ const presence = createPresence(open);
84
+ const variant = () => props.item.variant ?? 'neutral';
85
+ const dismissible = () => props.item.dismissible !== false;
86
+ // Item-level value wins, then the region-level default, then the built-in default.
87
+ const appearance = (): ToastAppearance => props.item.appearance ?? props.appearance ?? 'pill';
88
+ const inverse = (): boolean => props.item.inverse ?? props.inverse ?? false;
89
+
90
+ // Surface + accent colors, swapped for the high-contrast inverse treatment so the
91
+ // toast pops on EITHER appearance, in light AND dark. The inverse surface is the
92
+ // foreground color, so action/close/muted text switch to the background color.
93
+ const surfaceClass = () =>
94
+ inverse() ? 'bg-foreground text-background border-transparent' : 'bg-popover text-popover-foreground border-border';
95
+ const mutedClass = () => (inverse() ? 'text-background/70' : 'text-muted-foreground');
96
+ const actionClass = () => (inverse() ? 'text-background hover:text-background/80' : 'text-primary hover:text-primary/80');
97
+ const closeClass = () => (inverse() ? 'text-background/70 hover:text-background' : 'text-muted-foreground hover:text-foreground');
98
+
99
+ let remaining = resolveDuration(props.item);
100
+ let startedAt = 0;
101
+ let timer: ReturnType<typeof setTimeout> | undefined;
102
+ let reason: ToastDismissReason = 'timeout';
103
+
104
+ const clear = () => { if (timer !== undefined) { clearTimeout(timer); timer = undefined; } };
105
+
106
+ const begin = () => {
107
+ clear();
108
+ if (remaining <= 0) return; // sticky (duration 0)
109
+ startedAt = Date.now();
110
+ timer = setTimeout(() => { reason = 'timeout'; setOpen(false); }, remaining);
111
+ };
112
+ const pause = () => {
113
+ if (timer === undefined) return;
114
+ clear();
115
+ remaining -= Date.now() - startedAt;
116
+ };
117
+
118
+ const [hovered, setHovered] = createSignal(false);
119
+ // Held = this pill is hovered, OR the region says the whole stack is hovered.
120
+ const held = (): boolean => props.paused === true || hovered();
121
+
122
+ // (Re)start the timer whenever the resolved duration changes (mount + update());
123
+ // resets the remaining time to full. Holds instead of running if currently held.
124
+ createEffect(on(() => resolveDuration(props.item), (d) => {
125
+ remaining = d;
126
+ if (held()) clear();
127
+ else begin();
128
+ }));
129
+ // Pause/resume on hover (this pill or the whole stack) WITHOUT resetting remaining,
130
+ // so the countdown continues from where it left off. Deferred — the duration
131
+ // effect already armed it on mount.
132
+ createEffect(on(held, (isHeld) => {
133
+ if (isHeld) pause();
134
+ else begin();
135
+ }, { defer: true }));
136
+ onCleanup(clear);
137
+
138
+ // When presence has fully exited, notify the parent so it drops the item.
139
+ createEffect(() => {
140
+ if (!presence.present() && !open()) props.onDismiss(reason);
141
+ });
142
+
143
+ const close = () => { clear(); reason = 'close'; setOpen(false); };
144
+
145
+ const act = () => {
146
+ const action = props.item.action;
147
+ if (!action) return;
148
+ props.onAction?.(action.label);
149
+ const keepOpen = action.onAction() === false;
150
+ if (!keepOpen) { clear(); reason = 'action'; setOpen(false); }
151
+ };
152
+
153
+ // Leading variant icon — shared by both appearances. In the card it sits at the
154
+ // top, so nudge it down to align with the title's cap height.
155
+ const iconAlign = () => (appearance() === 'card' ? 'mt-0.5' : undefined);
156
+ const VariantIcon = () => (
157
+ <>
158
+ <Show when={variant() === 'success'}>
159
+ <Check class={cn('size-4 shrink-0 text-emerald-500', iconAlign())} />
160
+ </Show>
161
+ <Show when={variant() === 'warning'}>
162
+ <AlertTriangle class={cn('size-4 shrink-0 text-warning', iconAlign())} />
163
+ </Show>
164
+ <Show when={variant() === 'error'}>
165
+ <XCircle class={cn('size-4 shrink-0 text-destructive', iconAlign())} />
166
+ </Show>
167
+ <Show when={variant() === 'info'}>
168
+ <Info class={cn('size-4 shrink-0 text-info', iconAlign())} />
169
+ </Show>
170
+ </>
171
+ );
172
+
173
+ const ActionButton = (p: { class?: string }) => (
174
+ <Show when={props.item.action}>
175
+ {(action) => (
176
+ <button
177
+ type="button"
178
+ onClick={act}
179
+ class={cn(
180
+ appearance() === 'card'
181
+ ? cn(
182
+ 'inline-flex shrink-0 items-center rounded-md border px-2.5 py-1 text-xs font-medium transition-colors',
183
+ inverse()
184
+ ? 'border-background/30 text-background hover:bg-background/10'
185
+ : 'border-border text-foreground hover:bg-accent',
186
+ )
187
+ : cn('shrink-0 rounded-md text-sm font-medium underline-offset-2 hover:underline', actionClass()),
188
+ p.class,
189
+ )}
190
+ >
191
+ {action().label}
192
+ </button>
193
+ )}
194
+ </Show>
195
+ );
196
+
197
+ const CloseButton = () => (
198
+ <Show when={dismissible()}>
199
+ <button
200
+ type="button"
201
+ onClick={close}
202
+ aria-label="Dismiss"
203
+ class={cn(
204
+ '-mr-1 flex size-5 shrink-0 items-center justify-center rounded-md transition-colors',
205
+ closeClass(),
206
+ )}
207
+ >
208
+ <X class="size-3.5" />
209
+ </button>
210
+ </Show>
211
+ );
212
+
213
+ return (
214
+ <Show when={presence.present()}>
215
+ <div
216
+ ref={presence.setRef}
217
+ role="status"
218
+ data-appearance={appearance()}
219
+ data-inverse={inverse() ? '' : undefined}
220
+ data-closed={presence.state() === 'closed' ? '' : undefined}
221
+ onPointerEnter={() => setHovered(true)}
222
+ onPointerLeave={() => setHovered(false)}
223
+ class={cn(
224
+ 'pointer-events-auto border text-sm shadow-lg',
225
+ surfaceClass(),
226
+ 'animate-in fade-in-0 slide-in-from-top-4',
227
+ 'data-[closed]:animate-out data-[closed]:fade-out-0 data-[closed]:slide-out-to-top-2',
228
+ appearance() === 'card'
229
+ ? 'flex min-w-[24rem] items-start gap-3 rounded-xl p-4 shadow-xl'
230
+ : 'flex items-center gap-3 rounded-full px-4 py-2.5',
231
+ )}
232
+ >
233
+ <VariantIcon />
234
+ <Show
235
+ when={appearance() === 'card'}
236
+ fallback={
237
+ <>
238
+ <span class="min-w-0 flex-1 truncate">{props.item.message}</span>
239
+ <ActionButton />
240
+ <CloseButton />
241
+ </>
242
+ }
243
+ >
244
+ <div class="min-w-0 flex-1">
245
+ <div class="font-medium leading-snug">{props.item.message}</div>
246
+ <Show when={props.item.description}>
247
+ <div class={cn('mt-1 line-clamp-2 text-xs leading-snug', mutedClass())}>
248
+ {props.item.description}
249
+ </div>
250
+ </Show>
251
+ <ActionButton class="mt-2" />
252
+ </div>
253
+ <CloseButton />
254
+ </Show>
255
+ </div>
256
+ </Show>
257
+ );
258
+ }
259
+
260
+ // ── Region (stack + queue) ───────────────────────────────────────────────────
261
+
262
+ const POSITION_CLASSES: Record<ToastPosition, string> = {
263
+ 'top-center': 'top-4 left-1/2 -translate-x-1/2 items-center',
264
+ 'top-right': 'top-4 right-4 items-end',
265
+ 'top-left': 'top-4 left-4 items-start',
266
+ 'bottom-center': 'bottom-4 left-1/2 -translate-x-1/2 items-center flex-col-reverse',
267
+ 'bottom-right': 'bottom-4 right-4 items-end flex-col-reverse',
268
+ 'bottom-left': 'bottom-4 left-4 items-start flex-col-reverse',
269
+ };
270
+
271
+ // Flex alignment + stack direction per position, for a TARGET-anchored region (the
272
+ // stack hugs the chosen corner; bottom rows grow upward so the newest sits at the
273
+ // anchored edge). Mirrors POSITION_CLASSES minus the viewport-edge offsets.
274
+ const ANCHOR_FLEX: Record<ToastPosition, string> = {
275
+ 'top-center': 'items-center',
276
+ 'top-left': 'items-start',
277
+ 'top-right': 'items-end',
278
+ 'bottom-center': 'items-center flex-col-reverse',
279
+ 'bottom-left': 'items-start flex-col-reverse',
280
+ 'bottom-right': 'items-end flex-col-reverse',
281
+ };
282
+
283
+ /** Inset from the target's edges, in px. */
284
+ const ANCHOR_PAD = 12;
285
+
286
+ interface TargetRect { top: number; left: number; right: number; bottom: number; width: number }
287
+
288
+ /**
289
+ * The fixed-position style pinning a target-anchored stack to the corner named by
290
+ * `position`, computed from the target's rect. The region is `position: fixed`, so
291
+ * we resolve absolute top/left + a transform that grows the stack inward from that
292
+ * edge. (Rect-based, like the popover's anchor math — no collision flipping needed.)
293
+ */
294
+ function anchorStyle(position: ToastPosition, r: TargetRect): Record<string, string> {
295
+ const cx = r.left + r.width / 2;
296
+ const top = r.top + ANCHOR_PAD;
297
+ const bottom = r.bottom - ANCHOR_PAD;
298
+ const left = r.left + ANCHOR_PAD;
299
+ const right = r.right - ANCHOR_PAD;
300
+ const maxWidth = `${Math.max(0, r.width - ANCHOR_PAD * 2)}px`;
301
+ switch (position) {
302
+ case 'top-left':
303
+ return { top: `${top}px`, left: `${left}px`, transform: 'none', 'max-width': maxWidth };
304
+ case 'top-right':
305
+ return { top: `${top}px`, left: `${right}px`, transform: 'translateX(-100%)', 'max-width': maxWidth };
306
+ case 'bottom-center':
307
+ return { top: `${bottom}px`, left: `${cx}px`, transform: 'translate(-50%, -100%)', 'max-width': maxWidth };
308
+ case 'bottom-left':
309
+ return { top: `${bottom}px`, left: `${left}px`, transform: 'translateY(-100%)', 'max-width': maxWidth };
310
+ case 'bottom-right':
311
+ return { top: `${bottom}px`, left: `${right}px`, transform: 'translate(-100%, -100%)', 'max-width': maxWidth };
312
+ case 'top-center':
313
+ default:
314
+ return { top: `${top}px`, left: `${cx}px`, transform: 'translateX(-50%)', 'max-width': maxWidth };
315
+ }
316
+ }
317
+
318
+ /**
319
+ * Renders a stack of toasts at a viewport edge. Caps the visible count at `max`
320
+ * (newest on top); overflow waits in a queue and is promoted as visible toasts
321
+ * leave. `aria-live=polite` / `role=region` so screen readers announce new
322
+ * toasts without stealing focus.
323
+ */
324
+ export function ToastRegion(props: ToastRegionProps) {
325
+ const max = () => props.max ?? 3;
326
+ const position = () => props.position ?? 'top-center';
327
+
328
+ const stack = () => props.stack ?? 'expanded';
329
+ const reduced = usePrefersReducedMotion();
330
+ const collapsed = () => stack() === 'collapsed' && !reduced();
331
+ // Expanded while the stack is hovered OR holds focus (collapsed mode). These are
332
+ // tracked SEPARATELY and OR'd: dismissing a toast (clicking its ×) removes the
333
+ // focused button → a focusout — but if the pointer is still over the stack we must
334
+ // stay expanded (and paused), so focusout alone must not collapse it.
335
+ const [hovered, setHovered] = createSignal(false);
336
+ const [focused, setFocused] = createSignal(false);
337
+ const open = () => hovered() || focused();
338
+
339
+ // Tunable look (IVP). Resting peek + per-depth shrink; uniform expanded row height.
340
+ const OFFSET = 20; // px each deeper toast peeks past the one in front
341
+ const SCALE_STEP = 0.05; // each deeper toast is 5% smaller
342
+ const ROW_FALLBACK = 48; // px; used until the front pill is measured
343
+ const GAP = 8; // matches gap-2 in the expanded column
344
+
345
+ const isBottom = () => position().startsWith('bottom');
346
+ const dir = () => (isBottom() ? -1 : 1);
347
+
348
+ // Measure ONE pill (all are single-line/uniform) to size the expanded spacing.
349
+ const [rowH, setRowH] = createSignal(ROW_FALLBACK);
350
+ const measure = (el: HTMLElement | undefined) => {
351
+ if (!el || typeof window === 'undefined') return;
352
+ const set = () => { const h = el.offsetHeight; if (h) setRowH(h); };
353
+ set();
354
+ // jsdom (and SSR) lack ResizeObserver; the fallback height is fine there.
355
+ if (typeof ResizeObserver === 'undefined') return;
356
+ const ro = new ResizeObserver(set);
357
+ ro.observe(el);
358
+ onCleanup(() => ro.disconnect());
359
+ };
360
+
361
+ // The transform for the wrapper at depth i, given the current open/resting state.
362
+ const depthTransform = (i: number): string => {
363
+ if (open()) return `translateY(${dir() * (rowH() + GAP) * i}px) scale(1)`;
364
+ return `translateY(${dir() * OFFSET * i}px) scale(${1 - SCALE_STEP * i})`;
365
+ };
366
+ // The collapsed stage gets an explicit height covering the whole stack extent —
367
+ // resting (the pile) vs expanded (the full column) — so the region is ONE
368
+ // continuous hover surface. Without it the cursor falls into the gaps between
369
+ // expanded pills (or the spot a just-dismissed pill vacated) and the region
370
+ // flickers collapsed→expanded. Grows away from the anchored edge in both modes.
371
+ const stageHeight = (): number => {
372
+ const n = visible().length;
373
+ if (!n) return 0;
374
+ return open() ? n * rowH() + (n - 1) * GAP : rowH() + (n - 1) * OFFSET;
375
+ };
376
+
377
+ // Only the toasts for THIS region's target (undefined target = the global one).
378
+ // Newest-first so the freshest toast sits at the top; the queue (past `max`)
379
+ // stays mounted-but-hidden until a slot frees up.
380
+ const ordered = createMemo(() =>
381
+ [...(props.toasts ?? []).filter((t) => (t.target ?? undefined) === props.target)].reverse(),
382
+ );
383
+ const visible = createMemo(() => ordered().slice(0, max()));
384
+
385
+ // Scoped to a target → anchor the stack to the `position` corner of the target,
386
+ // following it on scroll/resize. Otherwise it's a viewport-fixed corner/center.
387
+ const [anchor, setAnchor] = createSignal<TargetRect | null>(null);
388
+ createEffect(() => {
389
+ const t = props.target;
390
+ if (!t || typeof window === 'undefined') { setAnchor(null); return; }
391
+ const update = () => {
392
+ const r = t.getBoundingClientRect();
393
+ setAnchor({ top: r.top, left: r.left, right: r.right, bottom: r.bottom, width: r.width });
394
+ };
395
+ update();
396
+ const ro = new ResizeObserver(update);
397
+ ro.observe(t);
398
+ window.addEventListener('scroll', update, true);
399
+ window.addEventListener('resize', update);
400
+ onCleanup(() => {
401
+ ro.disconnect();
402
+ window.removeEventListener('scroll', update, true);
403
+ window.removeEventListener('resize', update);
404
+ });
405
+ });
406
+
407
+ return (
408
+ <Show
409
+ when={collapsed()}
410
+ fallback={
411
+ <div
412
+ role="region"
413
+ aria-label="Notifications"
414
+ aria-live="polite"
415
+ data-stack="expanded"
416
+ class={cn(
417
+ 'pointer-events-none fixed z-[100] flex flex-col gap-2',
418
+ anchor()
419
+ ? ANCHOR_FLEX[position()]
420
+ : cn('max-w-[min(30rem,calc(100vw-2rem))]', POSITION_CLASSES[position()]),
421
+ )}
422
+ style={anchor() ? anchorStyle(position(), anchor()!) : undefined}
423
+ >
424
+ <For each={visible()}>
425
+ {(item) => (
426
+ <Toast
427
+ item={item}
428
+ appearance={props.appearance}
429
+ inverse={props.inverse}
430
+ onDismiss={(reason) => props.onDismiss?.(item.id, reason)}
431
+ onAction={(label) => props.onAction?.(item.id, label)}
432
+ />
433
+ )}
434
+ </For>
435
+ </div>
436
+ }
437
+ >
438
+ <div
439
+ role="region"
440
+ aria-label="Notifications"
441
+ aria-live="polite"
442
+ data-stack="collapsed"
443
+ data-expanded={open() ? '' : undefined}
444
+ onPointerEnter={() => setHovered(true)}
445
+ onPointerLeave={() => setHovered(false)}
446
+ onFocusIn={() => setFocused(true)}
447
+ onFocusOut={() => setFocused(false)}
448
+ class={cn('pointer-events-none fixed z-[100]', !anchor() && POSITION_CLASSES[position()])}
449
+ style={anchor() ? anchorStyle(position(), anchor()!) : undefined}
450
+ >
451
+ {/* Relative stage with an explicit height so it's ONE continuous hover
452
+ surface (pointer-events-auto) — no flicker when the cursor crosses gaps
453
+ or a dismissed pill's vacated spot. Pills are absolutely stacked from the
454
+ anchored edge. */}
455
+ <div
456
+ class="pointer-events-auto relative transition-[height] duration-200 ease-out"
457
+ style={{ 'min-width': '16rem', 'max-width': 'min(30rem, calc(100vw - 2rem))', height: `${stageHeight()}px` }}
458
+ >
459
+ <For each={visible()}>
460
+ {(item, i) => (
461
+ <div
462
+ data-depth={i()}
463
+ ref={(el) => { if (i() === 0) measure(el); }}
464
+ class={cn(
465
+ 'absolute inset-x-0 flex transition-[transform,opacity] duration-200 ease-out',
466
+ isBottom() ? 'bottom-0 origin-bottom' : 'top-0 origin-top',
467
+ position().endsWith('right') ? 'justify-end' : position().endsWith('left') ? 'justify-start' : 'justify-center',
468
+ )}
469
+ style={{ 'z-index': String(max() - i()), transform: depthTransform(i()) }}
470
+ >
471
+ <Toast
472
+ item={item}
473
+ paused={open()}
474
+ appearance={props.appearance}
475
+ inverse={props.inverse}
476
+ onDismiss={(reason) => props.onDismiss?.(item.id, reason)}
477
+ onAction={(label) => props.onAction?.(item.id, label)}
478
+ />
479
+ </div>
480
+ )}
481
+ </For>
482
+ </div>
483
+ </div>
484
+ </Show>
485
+ );
486
+ }
@@ -0,0 +1,10 @@
1
+ /** A tool-call part rendered by <Tool>. Pure type — kept JSX-free so it can be
2
+ * imported by the framework-neutral state core and the React typecheck pass. */
3
+ export interface ToolPart {
4
+ type: string;
5
+ state: 'input-streaming' | 'input-available' | 'output-available' | 'output-error';
6
+ input?: Record<string, unknown>;
7
+ output?: Record<string, unknown>;
8
+ toolCallId?: string;
9
+ errorText?: string;
10
+ }
@@ -1,21 +1,19 @@
1
1
  import { type JSX, splitProps, createSignal, Show, For } from 'solid-js';
2
2
  import { cn } from '../utils/cn';
3
- import { Collapsible, CollapsibleTrigger, CollapsibleContent } from '../ui/collapsible';
3
+ import { Collapsible, CollapsibleTrigger, CollapsibleContent, type CollapsibleController } from '../ui/collapsible';
4
4
  import { Button } from '../ui/button';
5
5
  import { CheckCircle, ChevronDown, Loader2, Settings, XCircle } from 'lucide-solid';
6
-
7
- export interface ToolPart {
8
- type: string;
9
- state: 'input-streaming' | 'input-available' | 'output-available' | 'output-error';
10
- input?: Record<string, unknown>;
11
- output?: Record<string, unknown>;
12
- toolCallId?: string;
13
- errorText?: string;
14
- }
6
+ import type { ToolPart } from './tool-types';
7
+ export type { ToolPart } from './tool-types';
15
8
 
16
9
  export interface ToolProps {
17
10
  toolPart: ToolPart;
18
11
  defaultOpen?: boolean;
12
+ /** Gate the disclosure trigger (programmatic control still works). */
13
+ disabled?: boolean;
14
+ /** Receive the open controller once mounted (forwarded from the Collapsible),
15
+ * so a parent (the kai-tool facade) can drive/observe open state. */
16
+ controllerRef?: (api: CollapsibleController) => void;
19
17
  class?: string;
20
18
  }
21
19
 
@@ -101,16 +99,24 @@ function ToolStateBadge(props: { state: ToolPart['state'] }) {
101
99
  }
102
100
 
103
101
  function Tool(props: ToolProps) {
104
- const [local, rest] = splitProps(props, ['toolPart', 'defaultOpen', 'class']);
105
- const [isOpen, setIsOpen] = createSignal(local.defaultOpen ?? false);
102
+ const [local, rest] = splitProps(props, ['toolPart', 'defaultOpen', 'disabled', 'controllerRef', 'class']);
103
+ // Drive the Collapsible UNCONTROLLED (seed from defaultOpen) and read its open
104
+ // state via the controller it hands up — that same controller is forwarded to
105
+ // the facade so wireDisclosure can drive show/hide/toggle.
106
+ const [api, setApi] = createSignal<CollapsibleController>();
107
+ const isOpen = () => api()?.open() ?? (local.defaultOpen ?? false);
106
108
 
107
109
  const state = () => local.toolPart.state;
108
110
  const input = () => local.toolPart.input;
109
111
  const output = () => local.toolPart.output;
110
112
 
111
113
  return (
112
- <div class={cn('mt-3 overflow-hidden rounded-lg bg-muted/30', local.class)}>
113
- <Collapsible open={isOpen()} onOpenChange={setIsOpen}>
114
+ <div class={cn('mt-3 overflow-hidden rounded-lg bg-surface', local.class)}>
115
+ <Collapsible
116
+ defaultOpen={local.defaultOpen}
117
+ disabled={local.disabled}
118
+ controllerRef={(a) => { setApi(a); local.controllerRef?.(a); }}
119
+ >
114
120
  <CollapsibleTrigger
115
121
  as={(triggerProps: JSX.HTMLAttributes<HTMLButtonElement>) => (
116
122
  <Button
@@ -134,7 +140,7 @@ function Tool(props: ToolProps) {
134
140
  <Show when={input() && Object.keys(input()!).length > 0}>
135
141
  <div>
136
142
  <h4 class="text-muted-foreground mb-2 text-sm font-medium">Input</h4>
137
- <div class="rounded bg-muted/50 p-2 font-mono text-sm">
143
+ <div class="rounded bg-surface-strong p-2 font-mono text-sm">
138
144
  <For each={Object.entries(input()!)}>
139
145
  {([key, value]) => (
140
146
  <div class="mb-1">
@@ -150,7 +156,7 @@ function Tool(props: ToolProps) {
150
156
  <Show when={output()}>
151
157
  <div>
152
158
  <h4 class="text-muted-foreground mb-2 text-sm font-medium">Output</h4>
153
- <div tabindex={0} class="max-h-60 overflow-auto rounded bg-muted/50 p-2 font-mono text-sm">
159
+ <div tabindex={0} class="max-h-60 overflow-auto rounded bg-surface-strong p-2 font-mono text-sm">
154
160
  <pre class="whitespace-pre-wrap">{formatValue(output())}</pre>
155
161
  </div>
156
162
  </div>
@@ -3,26 +3,42 @@
3
3
  // A new `data` identity clears the local flip (a fresh card definition is interactive
4
4
  // again), but an explicit prop keeps it resolved. `isOptimistic` is true only for a
5
5
  // flip made this session (used to announce via role="status"; silent on re-hydrate).
6
+ //
7
+ // A resolution is `isResolved` when present at all; `isTerminal` for the finished
8
+ // states (action | submit | expired) and `isDeferred` for `dismissed` — a set-aside
9
+ // card that still offers a Reopen affordance.
6
10
  import { createSignal, createMemo, createEffect, on, type Accessor } from 'solid-js';
7
11
  import type { CardResolution } from '../primitives/card-contract';
8
12
 
9
- export interface ResolutionController {
10
- resolution: Accessor<CardResolution | undefined>;
13
+ export interface ResolutionController<R extends CardResolution = CardResolution> {
14
+ resolution: Accessor<R | undefined>;
11
15
  isResolved: Accessor<boolean>;
16
+ /** A finished resolution the user can't take back here (action | submit | expired). */
17
+ isTerminal: Accessor<boolean>;
18
+ /** A deferred resolution (`dismissed`) — set aside, still re-openable. */
19
+ isDeferred: Accessor<boolean>;
12
20
  isOptimistic: Accessor<boolean>;
13
- setLocal: (r: CardResolution) => void;
21
+ setLocal: (r: R) => void;
14
22
  }
15
23
 
16
- export function useCardResolution(opts: {
17
- prop: Accessor<CardResolution | undefined>;
24
+ /** The resolution kinds that are finished and not re-openable from the card. */
25
+ const TERMINAL_KINDS = new Set<CardResolution['kind']>(['action', 'submit', 'expired']);
26
+
27
+ export function useCardResolution<R extends CardResolution = CardResolution>(opts: {
28
+ prop: Accessor<R | undefined>;
18
29
  data: Accessor<unknown>;
19
- }): ResolutionController {
20
- const [local, setLocal] = createSignal<CardResolution | undefined>(undefined);
30
+ }): ResolutionController<R> {
31
+ const [local, setLocal] = createSignal<R | undefined>(undefined);
21
32
  // Reset the optimistic flip when a NEW data identity arrives (deferred so mount
22
33
  // doesn't clobber an initial prop). The prop still wins via the memo below.
23
34
  createEffect(on(opts.data, () => setLocal(undefined), { defer: true }));
24
35
  const resolution = createMemo(() => opts.prop() ?? local());
25
36
  const isResolved = createMemo(() => resolution() !== undefined);
37
+ const isTerminal = createMemo(() => {
38
+ const r = resolution();
39
+ return r !== undefined && TERMINAL_KINDS.has(r.kind);
40
+ });
41
+ const isDeferred = createMemo(() => resolution()?.kind === 'dismissed');
26
42
  const isOptimistic = createMemo(() => opts.prop() === undefined && local() !== undefined);
27
- return { resolution, isResolved, isOptimistic, setLocal };
43
+ return { resolution, isResolved, isTerminal, isDeferred, isOptimistic, setLocal };
28
44
  }