@kitn.ai/ui 0.17.0 → 0.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (494) hide show
  1. package/README.md +28 -5
  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 +37 -12
  9. package/dist/components/choice-card.d.ts +26 -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/file-tree.d.ts +15 -0
  19. package/dist/components/form.d.ts +34 -0
  20. package/dist/components/markdown.d.ts +3 -0
  21. package/dist/components/message.d.ts +12 -0
  22. package/dist/components/model-switcher.d.ts +7 -0
  23. package/dist/components/prompt-input.d.ts +13 -4
  24. package/dist/components/prompt-suggestion.d.ts +9 -1
  25. package/dist/components/reasoning.d.ts +14 -1
  26. package/dist/components/response-compare.d.ts +14 -0
  27. package/dist/components/screen.d.ts +46 -0
  28. package/dist/components/tasks-card.d.ts +49 -1
  29. package/dist/components/toast.d.ts +12 -2
  30. package/dist/components/tool-types.d.ts +10 -0
  31. package/dist/components/tool.d.ts +8 -8
  32. package/dist/components/voice-input.d.ts +27 -0
  33. package/dist/components/voice-output.d.ts +33 -0
  34. package/dist/core-C8fzo39E.js +12 -0
  35. package/dist/custom-elements.json +8392 -1860
  36. package/dist/elements/agent-card.d.ts +1 -0
  37. package/dist/elements/agent-card.js +1 -0
  38. package/dist/elements/artifact.js +1 -1
  39. package/dist/elements/attachments.js +1 -1
  40. package/dist/elements/autoloader.js +1 -1
  41. package/dist/elements/avatar.d.ts +1 -0
  42. package/dist/elements/avatar.js +1 -0
  43. package/dist/elements/badge.d.ts +1 -0
  44. package/dist/elements/badge.js +1 -0
  45. package/dist/elements/button.d.ts +1 -0
  46. package/dist/elements/button.js +1 -0
  47. package/dist/elements/card.js +1 -1
  48. package/dist/elements/cards.js +1 -1
  49. package/dist/elements/chain-of-thought.js +1 -1
  50. package/dist/elements/chat-scope-picker.js +1 -1
  51. package/dist/elements/chat-types.d.ts +47 -0
  52. package/dist/elements/chat-workspace.js +1 -1
  53. package/dist/elements/chat.js +1 -1
  54. package/dist/elements/checkpoint.js +1 -1
  55. package/dist/elements/choice.js +1 -1
  56. package/dist/elements/chunks/Icon-C2LTALdM.js +1 -0
  57. package/dist/elements/chunks/action-icons-Dtl8Ox5D.js +1 -0
  58. package/dist/elements/chunks/arrow-left-GbBceGBE.js +1 -0
  59. package/dist/elements/chunks/attachments-DLJcWCDV.js +1 -0
  60. package/dist/elements/chunks/badge-BTNZTODL.js +1 -0
  61. package/dist/elements/chunks/button-DBDZebGr.js +1 -0
  62. package/dist/elements/chunks/card-YfCyI4fH.js +1 -0
  63. package/dist/elements/chunks/chat-thread-Dz2qbzvI.js +1 -0
  64. package/dist/elements/chunks/check-fhmRksq_.js +1 -0
  65. package/dist/elements/chunks/chevron-down-DcRg1aRU.js +1 -0
  66. package/dist/elements/chunks/chevron-right-ChzBcNJ-.js +1 -0
  67. package/dist/elements/chunks/circle-B4fTe9v6.js +1 -0
  68. package/dist/elements/chunks/circle-check-CJV-3Rem.js +1 -0
  69. package/dist/elements/chunks/circle-x-pDtzlghQ.js +1 -0
  70. package/dist/elements/chunks/cn-CU7UAWzk.js +1 -0
  71. package/dist/elements/chunks/code-block-DZ6mz6vs.js +1 -0
  72. package/dist/elements/chunks/collapsible-CWUAShMC.js +1 -0
  73. package/dist/elements/chunks/composer-BZyPU6gD.js +65 -0
  74. package/dist/elements/chunks/context-Cx6eQA_G.js +1 -0
  75. package/dist/elements/chunks/conversation-list-C4xTQSpT.js +1 -0
  76. package/dist/elements/chunks/default-input-BZcwyKcP.js +1 -0
  77. package/dist/elements/chunks/define-CNSKFZCd.js +1 -0
  78. package/dist/elements/chunks/disclosure-BcBs--Jf.js +1 -0
  79. package/dist/elements/chunks/download-BDQwcFav.js +1 -0
  80. package/dist/elements/chunks/dropdown-wgs8xCJZ.js +1 -0
  81. package/dist/elements/chunks/ellipsis-CUiEJ6R1.js +1 -0
  82. package/dist/elements/chunks/external-link-DJUmC7g2.js +1 -0
  83. package/dist/elements/chunks/file-text-DOYfYvrh.js +1 -0
  84. package/dist/elements/chunks/file-tree-DQzNQrbr.js +1 -0
  85. package/dist/elements/chunks/folder-DBDUBANz.js +1 -0
  86. package/dist/elements/chunks/hover-card-BQGdGAQ3.js +1 -0
  87. package/dist/elements/chunks/icon-CAyRqVrg.js +1 -0
  88. package/dist/elements/chunks/{index-CTBEJeo6.js → index-BCRhi84a.js} +1 -1
  89. package/dist/elements/chunks/info-DBQl-m6e.js +1 -0
  90. package/dist/elements/chunks/input-DZD67EvW.js +1 -0
  91. package/dist/elements/chunks/kbd-DbyVrlnU.js +1 -0
  92. package/dist/elements/chunks/link-vko7AttA.js +1 -0
  93. package/dist/elements/chunks/loader-Cg6rO8tQ.js +1 -0
  94. package/dist/elements/chunks/{markdown-CMTGx9r8.js → markdown-n3Xbj3PR.js} +9 -9
  95. package/dist/elements/chunks/message-CgKytiSB.js +1 -0
  96. package/dist/elements/chunks/message-feedback-Ds3-US0e.js +1 -0
  97. package/dist/elements/chunks/message-square-MmRkvc-M.js +1 -0
  98. package/dist/elements/chunks/minimize-2-3kCdE0q3.js +1 -0
  99. package/dist/elements/chunks/model-switcher-BMtXGwLU.js +1 -0
  100. package/dist/elements/chunks/overlay-B1-MBI6h.js +1 -0
  101. package/dist/elements/chunks/paperclip-DDEfmkHc.js +1 -0
  102. package/dist/elements/chunks/progress-bar-Dwbiyv3s.js +1 -0
  103. package/dist/elements/chunks/prompt-suggestion-9lvgFcEa.js +1 -0
  104. package/dist/elements/chunks/reasoning-DzHWsdAJ.js +1 -0
  105. package/dist/elements/chunks/resizable-Bq_eHxUm.js +1 -0
  106. package/dist/elements/chunks/rotate-cw-jpisOdOV.js +1 -0
  107. package/dist/elements/chunks/scroll-area-g5Ze3K6f.js +1 -0
  108. package/dist/elements/chunks/separator-Bmjc5XyX.js +1 -0
  109. package/dist/elements/chunks/settings-Cz1bMJP9.js +1 -0
  110. package/dist/elements/chunks/settings-group-9imY3kRA.js +1 -0
  111. package/dist/elements/chunks/share-BdenF0wQ.js +1 -0
  112. package/dist/elements/chunks/skeleton-Pjc5jiaY.js +1 -0
  113. package/dist/elements/chunks/slots-DkZ-Cmha.js +1 -0
  114. package/dist/elements/chunks/star-DY6z1UUH.js +1 -0
  115. package/dist/elements/chunks/store-th4VyJXM.js +1 -0
  116. package/dist/elements/chunks/text-shimmer-CEi-tlXr.js +1 -0
  117. package/dist/elements/chunks/textarea-CboigarR.js +1 -0
  118. package/dist/elements/chunks/thumbs-up-BR33KLfA.js +1 -0
  119. package/dist/elements/chunks/toast-store-BEMda0fv.js +1 -0
  120. package/dist/elements/chunks/tool-TMued3WO.js +1 -0
  121. package/dist/elements/chunks/tooltip-Cft_Rxiw.js +1 -0
  122. package/dist/elements/chunks/triangle-alert-B07fX3Q8.js +1 -0
  123. package/dist/elements/chunks/use-card-resolution-M36zVciB.js +1 -0
  124. package/dist/elements/chunks/video-MKp3LmNT.js +1 -0
  125. package/dist/elements/chunks/x-Ckwicf6g.js +1 -0
  126. package/dist/elements/coachmark.d.ts +1 -0
  127. package/dist/elements/coachmark.js +1 -0
  128. package/dist/elements/code-block.js +1 -1
  129. package/dist/elements/command.d.ts +1 -0
  130. package/dist/elements/command.js +1 -0
  131. package/dist/elements/compare.js +1 -1
  132. package/dist/elements/composer.d.ts +1 -0
  133. package/dist/elements/composer.js +1 -0
  134. package/dist/elements/confirm-card.js +1 -1
  135. package/dist/elements/context-meter.js +1 -1
  136. package/dist/elements/conversation-list.js +1 -1
  137. package/dist/elements/css.d.ts +1 -0
  138. package/dist/elements/default-input.d.ts +51 -0
  139. package/dist/elements/define.d.ts +53 -0
  140. package/dist/elements/dialog.d.ts +1 -0
  141. package/dist/elements/dialog.js +1 -0
  142. package/dist/elements/disclosure.d.ts +37 -0
  143. package/dist/elements/editable-label.d.ts +1 -0
  144. package/dist/elements/editable-label.js +1 -0
  145. package/dist/elements/embed.js +1 -1
  146. package/dist/elements/empty.js +1 -1
  147. package/dist/elements/feedback-bar.js +1 -1
  148. package/dist/elements/file-tree.js +1 -1
  149. package/dist/elements/file-upload.js +1 -1
  150. package/dist/elements/form.js +1 -1
  151. package/dist/elements/hover-card.d.ts +1 -0
  152. package/dist/elements/hover-card.js +1 -0
  153. package/dist/elements/icon.d.ts +1 -0
  154. package/dist/elements/icon.js +1 -0
  155. package/dist/elements/image.js +1 -1
  156. package/dist/elements/input.d.ts +1 -0
  157. package/dist/elements/input.js +1 -0
  158. package/dist/elements/kbd.d.ts +1 -0
  159. package/dist/elements/kbd.js +1 -0
  160. package/dist/elements/link-preview.js +1 -1
  161. package/dist/elements/loader.js +1 -1
  162. package/dist/elements/markdown.js +1 -1
  163. package/dist/elements/menu.d.ts +1 -0
  164. package/dist/elements/menu.js +1 -0
  165. package/dist/elements/message-skills.js +1 -1
  166. package/dist/elements/message.js +1 -1
  167. package/dist/elements/model-switcher.js +1 -1
  168. package/dist/elements/nav.d.ts +1 -0
  169. package/dist/elements/nav.js +1 -0
  170. package/dist/elements/notice.d.ts +1 -0
  171. package/dist/elements/notice.js +1 -0
  172. package/dist/elements/pane-group.d.ts +1 -0
  173. package/dist/elements/pane-group.js +1 -0
  174. package/dist/elements/pane.d.ts +1 -0
  175. package/dist/elements/pane.js +1 -0
  176. package/dist/elements/popover.js +1 -1
  177. package/dist/elements/progress-bar.d.ts +1 -0
  178. package/dist/elements/progress-bar.js +1 -0
  179. package/dist/elements/prompt-dock.d.ts +1 -0
  180. package/dist/elements/prompt-dock.js +1 -0
  181. package/dist/elements/prompt-input.js +1 -1
  182. package/dist/elements/prompt-suggestions.js +1 -1
  183. package/dist/elements/reasoning.js +1 -1
  184. package/dist/elements/register-impl.d.ts +0 -0
  185. package/dist/elements/register.d.ts +13 -0
  186. package/dist/elements/remote.d.ts +1 -0
  187. package/dist/elements/remote.js +1 -0
  188. package/dist/elements/resizable.js +1 -1
  189. package/dist/elements/response-stream.js +2 -2
  190. package/dist/elements/screen.d.ts +1 -0
  191. package/dist/elements/screen.js +1 -0
  192. package/dist/elements/scroll-area.d.ts +1 -0
  193. package/dist/elements/scroll-area.js +1 -0
  194. package/dist/elements/scroll-button.js +1 -1
  195. package/dist/elements/search.d.ts +1 -0
  196. package/dist/elements/search.js +1 -0
  197. package/dist/elements/segmented.d.ts +1 -0
  198. package/dist/elements/segmented.js +1 -0
  199. package/dist/elements/separator.d.ts +1 -0
  200. package/dist/elements/separator.js +1 -0
  201. package/dist/elements/setting-item.d.ts +1 -0
  202. package/dist/elements/setting-item.js +1 -0
  203. package/dist/elements/settings-group.d.ts +1 -0
  204. package/dist/elements/settings-group.js +1 -0
  205. package/dist/elements/skeleton.d.ts +1 -0
  206. package/dist/elements/skeleton.js +1 -0
  207. package/dist/elements/slots.d.ts +176 -0
  208. package/dist/elements/source.js +1 -1
  209. package/dist/elements/status.d.ts +1 -0
  210. package/dist/elements/status.js +1 -0
  211. package/dist/elements/switch.js +1 -1
  212. package/dist/elements/tabs.d.ts +1 -0
  213. package/dist/elements/tabs.js +1 -0
  214. package/dist/elements/tasks.js +1 -1
  215. package/dist/elements/text-shimmer.js +1 -1
  216. package/dist/elements/thinking-bar.js +1 -1
  217. package/dist/elements/toast.js +1 -1
  218. package/dist/elements/tool.js +1 -1
  219. package/dist/elements/tooltip.d.ts +1 -0
  220. package/dist/elements/tooltip.js +1 -0
  221. package/dist/elements/voice-input.js +1 -1
  222. package/dist/elements/voice-output.d.ts +1 -0
  223. package/dist/elements/voice-output.js +1 -0
  224. package/dist/elements.d.ts +733 -58
  225. package/dist/engine-javascript-C1x7zo1_.js +141 -0
  226. package/dist/index.d.ts +3 -2
  227. package/dist/index.js +8255 -5703
  228. package/dist/kai.es.js +1 -0
  229. package/dist/llms/llms-full.txt +1146 -64
  230. package/dist/llms/llms.txt +4 -4
  231. package/dist/mcp.es.js +62 -7
  232. package/dist/primitives/composer-model.d.ts +22 -0
  233. package/dist/primitives/composer-triggers.d.ts +19 -0
  234. package/dist/primitives/create-kai-chat.d.ts +38 -0
  235. package/dist/primitives/toast-store.d.ts +32 -2
  236. package/dist/primitives/use-speech-recognition.d.ts +26 -0
  237. package/dist/react/index.d.ts +1085 -97
  238. package/dist/react/runtime.d.ts +9 -2
  239. package/dist/react/use-kai-chat.d.ts +41 -0
  240. package/dist/react.js +572 -193
  241. package/dist/register-impl-cKscku5m.js +141 -0
  242. package/dist/schemas/tasks.schema.json +2 -2
  243. package/dist/state/index.d.ts +4 -0
  244. package/dist/state/messages.d.ts +11 -0
  245. package/dist/state/stream.d.ts +22 -0
  246. package/dist/state/suggestions.d.ts +4 -0
  247. package/dist/state.js +117 -0
  248. package/dist/theme.tokens.css +87 -0
  249. package/dist/types.d.ts +4 -0
  250. package/dist/ui/agent-card.d.ts +61 -0
  251. package/dist/ui/button.d.ts +5 -2
  252. package/dist/ui/card.d.ts +61 -0
  253. package/dist/ui/collapsible.d.ts +15 -1
  254. package/dist/ui/command.d.ts +33 -0
  255. package/dist/ui/dialog.d.ts +42 -0
  256. package/dist/ui/dropdown.d.ts +95 -1
  257. package/dist/ui/editable-label.d.ts +26 -0
  258. package/dist/ui/hover-card.d.ts +13 -1
  259. package/dist/ui/icon.d.ts +18 -0
  260. package/dist/ui/input.d.ts +33 -0
  261. package/dist/ui/kbd.d.ts +21 -0
  262. package/dist/ui/nav.d.ts +62 -0
  263. package/dist/ui/notice.d.ts +31 -0
  264. package/dist/ui/overlay.d.ts +12 -0
  265. package/dist/ui/pane-grid.d.ts +58 -0
  266. package/dist/ui/pane-group.d.ts +77 -0
  267. package/dist/ui/pane.d.ts +78 -0
  268. package/dist/ui/popover.d.ts +11 -1
  269. package/dist/ui/progress-bar.d.ts +23 -0
  270. package/dist/ui/prompt-dock.d.ts +96 -0
  271. package/dist/ui/resizable.d.ts +12 -0
  272. package/dist/ui/scroll-area.d.ts +4 -0
  273. package/dist/ui/segmented.d.ts +28 -0
  274. package/dist/ui/settings-group.d.ts +32 -0
  275. package/dist/ui/skeleton.d.ts +12 -0
  276. package/dist/ui/stat.d.ts +16 -0
  277. package/dist/ui/status.d.ts +13 -0
  278. package/dist/ui/switch.d.ts +8 -1
  279. package/dist/ui/tabs.d.ts +35 -0
  280. package/dist/ui/tooltip.d.ts +19 -1
  281. package/frameworks/react/index.tsx +1042 -157
  282. package/frameworks/react/runtime.tsx +30 -1
  283. package/frameworks/react/use-kai-chat.tsx +87 -0
  284. package/llms-full.txt +1146 -64
  285. package/llms.txt +4 -4
  286. package/package.json +31 -10
  287. package/src/agent-tooling/mcp/manifest.ts +14 -0
  288. package/src/agent-tooling/mcp/tools/debug.ts +11 -7
  289. package/src/agent-tooling/mcp/tools/reference.ts +32 -0
  290. package/src/agent-tooling/mcp/tools/scaffold.ts +30 -1
  291. package/src/components/artifact.tsx +98 -13
  292. package/src/components/attachment-types.ts +13 -0
  293. package/src/components/attachments.tsx +4 -14
  294. package/src/components/card.tsx +109 -15
  295. package/src/components/chain-of-thought.tsx +210 -1
  296. package/src/components/chat-scope-picker.tsx +13 -3
  297. package/src/components/chat-thread.tsx +225 -116
  298. package/src/components/choice-card.tsx +103 -11
  299. package/src/components/coachmark.tsx +249 -0
  300. package/src/components/component-meta.json +699 -110
  301. package/src/components/composer-dom.ts +159 -0
  302. package/src/components/composer-highlight.ts +242 -0
  303. package/src/components/composer-history.ts +82 -0
  304. package/src/components/composer.tsx +979 -0
  305. package/src/components/confirm-card.tsx +54 -1
  306. package/src/components/conversation-item.tsx +69 -7
  307. package/src/components/conversation-list.tsx +134 -37
  308. package/src/components/file-tree.tsx +197 -47
  309. package/src/components/form-widgets.tsx +9 -7
  310. package/src/components/form.tsx +140 -17
  311. package/src/components/image.tsx +3 -5
  312. package/src/components/link-preview.tsx +5 -4
  313. package/src/components/markdown.tsx +5 -2
  314. package/src/components/message.tsx +23 -4
  315. package/src/components/model-switcher.tsx +19 -4
  316. package/src/components/prompt-input.tsx +46 -75
  317. package/src/components/prompt-suggestion.tsx +48 -16
  318. package/src/components/reasoning.tsx +29 -6
  319. package/src/components/response-compare.tsx +31 -2
  320. package/src/components/screen.tsx +176 -0
  321. package/src/components/tasks-card.tsx +341 -21
  322. package/src/components/toast.tsx +119 -31
  323. package/src/components/tool-types.ts +10 -0
  324. package/src/components/tool.tsx +22 -16
  325. package/src/components/voice-input.tsx +102 -19
  326. package/src/components/voice-output.tsx +202 -0
  327. package/src/elements/agent-card.tsx +67 -0
  328. package/src/elements/artifact.tsx +53 -4
  329. package/src/elements/attachments.tsx +1 -0
  330. package/src/elements/avatar.tsx +33 -0
  331. package/src/elements/badge.tsx +32 -0
  332. package/src/elements/button.tsx +126 -0
  333. package/src/elements/card-media.jpg +0 -0
  334. package/src/elements/card.tsx +124 -31
  335. package/src/elements/cards.tsx +81 -7
  336. package/src/elements/chain-of-thought.tsx +77 -32
  337. package/src/elements/chat-scope-picker.tsx +35 -8
  338. package/src/elements/chat-types.ts +2 -2
  339. package/src/elements/chat-workspace.tsx +153 -41
  340. package/src/elements/chat.tsx +45 -23
  341. package/src/elements/choice.tsx +71 -19
  342. package/src/elements/coachmark.tsx +90 -0
  343. package/src/elements/command.tsx +209 -0
  344. package/src/elements/compare.tsx +24 -2
  345. package/src/elements/compiled.css +2 -2
  346. package/src/elements/composer.tsx +151 -0
  347. package/src/elements/confirm-card.tsx +36 -11
  348. package/src/elements/conversation-list.tsx +80 -11
  349. package/src/elements/default-input.tsx +75 -53
  350. package/src/elements/define.tsx +87 -7
  351. package/src/elements/dialog.tsx +98 -0
  352. package/src/elements/disclosure.ts +73 -0
  353. package/src/elements/editable-label.tsx +125 -0
  354. package/src/elements/element-manifest.json +129 -1
  355. package/src/elements/element-meta.json +5562 -1336
  356. package/src/elements/element-types.d.ts +732 -57
  357. package/src/elements/file-tree.tsx +12 -2
  358. package/src/elements/file-upload.tsx +1 -1
  359. package/src/elements/form.tsx +54 -11
  360. package/src/elements/hover-card.tsx +80 -0
  361. package/src/elements/icon-names.json +48 -0
  362. package/src/elements/icon.tsx +41 -0
  363. package/src/elements/input.tsx +203 -0
  364. package/src/elements/kbd.tsx +45 -0
  365. package/src/elements/menu.tsx +217 -0
  366. package/src/elements/message.tsx +58 -11
  367. package/src/elements/model-switcher.tsx +27 -1
  368. package/src/elements/nav.tsx +87 -0
  369. package/src/elements/notice.tsx +53 -0
  370. package/src/elements/pane-group.tsx +119 -0
  371. package/src/elements/pane.tsx +129 -0
  372. package/src/elements/popover.tsx +39 -17
  373. package/src/elements/progress-bar.tsx +39 -0
  374. package/src/elements/prompt-dock.tsx +81 -0
  375. package/src/elements/prompt-input.tsx +112 -63
  376. package/src/elements/prompt-suggestions.tsx +25 -9
  377. package/src/elements/reasoning.tsx +30 -9
  378. package/src/elements/register-impl.ts +38 -3
  379. package/src/elements/register.ts +11 -3
  380. package/src/elements/resizable.tsx +48 -11
  381. package/src/elements/screen.tsx +90 -0
  382. package/src/elements/scroll-area.tsx +33 -0
  383. package/src/elements/search.tsx +180 -0
  384. package/src/elements/segmented.tsx +135 -0
  385. package/src/elements/separator.tsx +36 -0
  386. package/src/elements/setting-item.tsx +50 -0
  387. package/src/elements/settings-group.tsx +37 -0
  388. package/src/elements/skeleton.tsx +45 -0
  389. package/src/elements/slots.ts +607 -0
  390. package/src/elements/source.tsx +13 -6
  391. package/src/elements/status.tsx +42 -0
  392. package/src/elements/switch.tsx +89 -14
  393. package/src/elements/tabs.tsx +95 -0
  394. package/src/elements/tasks.tsx +70 -14
  395. package/src/elements/toast.tsx +17 -2
  396. package/src/elements/tool.tsx +43 -9
  397. package/src/elements/tooltip.tsx +85 -0
  398. package/src/elements/video-poster.jpg +0 -0
  399. package/src/elements/voice-input.tsx +66 -16
  400. package/src/elements/voice-output.tsx +69 -0
  401. package/src/index.ts +5 -2
  402. package/src/primitives/card-schemas/tasks.schema.json +2 -2
  403. package/src/primitives/composer-model.ts +49 -0
  404. package/src/primitives/composer-triggers.ts +35 -0
  405. package/src/primitives/create-kai-chat.ts +66 -0
  406. package/src/primitives/toast-store.ts +43 -2
  407. package/src/primitives/use-speech-recognition.ts +135 -0
  408. package/src/state/index.ts +6 -0
  409. package/src/state/messages.ts +36 -0
  410. package/src/state/stream.ts +92 -0
  411. package/src/state/suggestions.ts +9 -0
  412. package/src/types.ts +4 -0
  413. package/src/ui/agent-card.tsx +218 -0
  414. package/src/ui/button.tsx +16 -5
  415. package/src/ui/card.tsx +245 -0
  416. package/src/ui/collapsible.tsx +30 -4
  417. package/src/ui/command.tsx +99 -0
  418. package/src/ui/dialog.tsx +217 -0
  419. package/src/ui/dropdown.tsx +375 -13
  420. package/src/ui/editable-label.tsx +112 -0
  421. package/src/ui/hover-card.tsx +28 -5
  422. package/src/ui/icon.tsx +110 -0
  423. package/src/ui/input.tsx +132 -0
  424. package/src/ui/kbd.tsx +118 -0
  425. package/src/ui/nav.tsx +282 -0
  426. package/src/ui/notice.tsx +84 -0
  427. package/src/ui/overlay.tsx +108 -2
  428. package/src/ui/pane-grid.tsx +117 -0
  429. package/src/ui/pane-group.tsx +291 -0
  430. package/src/ui/pane.tsx +193 -0
  431. package/src/ui/popover.tsx +16 -2
  432. package/src/ui/progress-bar.tsx +83 -0
  433. package/src/ui/prompt-dock.tsx +145 -0
  434. package/src/ui/resizable.tsx +69 -1
  435. package/src/ui/scroll-area.tsx +14 -3
  436. package/src/ui/segmented.tsx +109 -0
  437. package/src/ui/settings-group.tsx +67 -0
  438. package/src/ui/skeleton.tsx +62 -5
  439. package/src/ui/stat.tsx +41 -0
  440. package/src/ui/status.tsx +48 -0
  441. package/src/ui/switch.tsx +49 -23
  442. package/src/ui/tabs.tsx +168 -0
  443. package/src/ui/tooltip.tsx +52 -8
  444. package/theme.css +113 -0
  445. package/dist/components/slash-command.d.ts +0 -15
  446. package/dist/elements/chunks/Icon-D_Zmwmwh.js +0 -1
  447. package/dist/elements/chunks/action-icons-PVfIvcuG.js +0 -1
  448. package/dist/elements/chunks/attachments-Dp6vqtrc.js +0 -1
  449. package/dist/elements/chunks/button-CKyYD9G4.js +0 -1
  450. package/dist/elements/chunks/card-Cjho-PYk.js +0 -1
  451. package/dist/elements/chunks/chat-thread-RT808iPf.js +0 -1
  452. package/dist/elements/chunks/check-CDYaMYrM.js +0 -1
  453. package/dist/elements/chunks/chevron-down-3SBiq8HF.js +0 -1
  454. package/dist/elements/chunks/chevron-right-k2UFlIVK.js +0 -1
  455. package/dist/elements/chunks/cn-Dogu6PbV.js +0 -1
  456. package/dist/elements/chunks/code-block-BYUmfFSd.js +0 -1
  457. package/dist/elements/chunks/collapsible-BiNwdOn6.js +0 -1
  458. package/dist/elements/chunks/context-18g6oi4J.js +0 -1
  459. package/dist/elements/chunks/conversation-list-D9Y0NVdo.js +0 -1
  460. package/dist/elements/chunks/default-input-CSAoYYMd.js +0 -1
  461. package/dist/elements/chunks/download-D8K0Je8r.js +0 -1
  462. package/dist/elements/chunks/dropdown-bUs2iTia.js +0 -1
  463. package/dist/elements/chunks/external-link-6mA0wxab.js +0 -1
  464. package/dist/elements/chunks/file-text-DnaYk3Dm.js +0 -1
  465. package/dist/elements/chunks/file-tree-CgtRLlxK.js +0 -1
  466. package/dist/elements/chunks/hover-card-CIGw62gP.js +0 -1
  467. package/dist/elements/chunks/link-BlGSeoPy.js +0 -1
  468. package/dist/elements/chunks/loader-DvhR4qa0.js +0 -1
  469. package/dist/elements/chunks/message-CDZwXjhL.js +0 -1
  470. package/dist/elements/chunks/message-feedback-CYx81QiA.js +0 -1
  471. package/dist/elements/chunks/model-switcher-O_tUhoOT.js +0 -1
  472. package/dist/elements/chunks/overlay-DydXYMQW.js +0 -1
  473. package/dist/elements/chunks/prompt-suggestion-ldlWV5kd.js +0 -1
  474. package/dist/elements/chunks/reasoning-2PUnHlmr.js +0 -1
  475. package/dist/elements/chunks/resizable-B5WNbSeb.js +0 -1
  476. package/dist/elements/chunks/star-t9tI-P0q.js +0 -1
  477. package/dist/elements/chunks/store-C6rIooZz.js +0 -1
  478. package/dist/elements/chunks/text-shimmer-uh9V_KUh.js +0 -1
  479. package/dist/elements/chunks/textarea-3nm6Ia9U.js +0 -1
  480. package/dist/elements/chunks/thumbs-up-BBtguGld.js +0 -1
  481. package/dist/elements/chunks/toast-store-D8cL3fWl.js +0 -1
  482. package/dist/elements/chunks/tool-GJ3vwp1U.js +0 -1
  483. package/dist/elements/chunks/tooltip-DwKAz4XR.js +0 -1
  484. package/dist/elements/chunks/triangle-alert-Ct1zt2JL.js +0 -1
  485. package/dist/elements/chunks/use-card-resolution-D-_0Alzy.js +0 -1
  486. package/dist/elements/chunks/video-mVYiM99-.js +0 -1
  487. package/dist/elements/chunks/x-CzxL27Ch.js +0 -1
  488. package/dist/kitn-chat.es.js +0 -1
  489. package/dist/register-JyTglR6m.js +0 -1
  490. package/dist/register-impl-C6wlSsts.js +0 -77
  491. package/src/components/slash-command.tsx +0 -232
  492. package/src/elements/framework-usage.json +0 -588
  493. /package/dist/{kitn-chat-provider.d.ts → kai-provider.d.ts} +0 -0
  494. /package/dist/{kitn-chat-provider.es.js → kai-provider.es.js} +0 -0
@@ -0,0 +1,84 @@
1
+ import { type JSX, Show, createSignal } from 'solid-js';
2
+ import { Info, TriangleAlert, CircleAlert, CircleCheck, X } from 'lucide-solid';
3
+ import { cn } from '../utils/cn';
4
+ import { renderIcon } from './icon';
5
+
6
+ export type NoticeSeverity = 'neutral' | 'info' | 'warning' | 'error' | 'success';
7
+
8
+ const SEVERITY_ICON = { neutral: Info, info: Info, warning: TriangleAlert, error: CircleAlert, success: CircleCheck };
9
+
10
+ /** Icon tint per severity. Neutral stays muted; the rest use the kit's tool hues
11
+ * (the same on-brand, AA-checked colors used by tool/status chips). */
12
+ const ICON_TONE: Record<NoticeSeverity, string> = {
13
+ neutral: 'text-muted-foreground',
14
+ info: 'text-tool-blue',
15
+ warning: 'text-tool-amber',
16
+ error: 'text-tool-red',
17
+ success: 'text-tool-green',
18
+ };
19
+
20
+ /** The default leading icon for a notice: `null` when `icon="none"`, the named
21
+ * icon when one is given, else the severity glyph. Exported so the `kai-notice`
22
+ * facade can use it as the fallback inside a `slot="icon"` escape hatch. */
23
+ export function noticeIconNode(severity: NoticeSeverity, icon?: string): JSX.Element {
24
+ if (icon === 'none') return null;
25
+ if (icon) return renderIcon(icon, { class: cn('size-4 shrink-0', ICON_TONE[severity]) });
26
+ const I = SEVERITY_ICON[severity];
27
+ return <I class={cn('size-4 shrink-0', ICON_TONE[severity])} aria-hidden="true" />;
28
+ }
29
+
30
+ export interface NoticeProps {
31
+ severity?: NoticeSeverity;
32
+ /** Leading icon: omit for the severity default, `"none"` to hide it, or a named
33
+ * icon to override. */
34
+ icon?: string;
35
+ /** A custom icon node that replaces the icon region entirely (the `kai-notice`
36
+ * facade passes a `slot="icon"` here, with the default icon as its fallback). */
37
+ iconSlot?: JSX.Element;
38
+ /** Render a dismiss (×) button that hides the notice and calls `onDismiss`. */
39
+ dismissible?: boolean;
40
+ /** Called after the notice is dismissed. */
41
+ onDismiss?: () => void;
42
+ /** The message. */
43
+ children: JSX.Element;
44
+ /** Optional trailing action (e.g. a link). */
45
+ action?: JSX.Element;
46
+ class?: string;
47
+ }
48
+
49
+ /**
50
+ * A self-contained inline notice / alert: a leading severity icon, a message, an
51
+ * optional trailing action, and an optional dismiss. Carries the right a11y role
52
+ * (`alert` for errors, `status` otherwise). Placement is the consumer's — this is
53
+ * just the notice box.
54
+ */
55
+ export function Notice(props: NoticeProps) {
56
+ const [open, setOpen] = createSignal(true);
57
+ const severity = (): NoticeSeverity => props.severity ?? 'neutral';
58
+ const dismiss = () => { setOpen(false); props.onDismiss?.(); };
59
+
60
+ return (
61
+ <Show when={open()}>
62
+ <div
63
+ role={severity() === 'error' ? 'alert' : 'status'}
64
+ class={cn('flex items-center gap-2.5 rounded-lg bg-surface px-3.5 py-2.5 text-sm', props.class)}
65
+ >
66
+ <Show when={props.iconSlot} fallback={noticeIconNode(severity(), props.icon)}>
67
+ {props.iconSlot}
68
+ </Show>
69
+ <div class="flex-1 leading-snug text-muted-foreground">{props.children}</div>
70
+ <Show when={props.action}>{props.action}</Show>
71
+ <Show when={props.dismissible}>
72
+ <button
73
+ type="button"
74
+ aria-label="Dismiss"
75
+ onClick={dismiss}
76
+ class="-my-1 -mr-1.5 shrink-0 rounded p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-foreground"
77
+ >
78
+ <X class="size-3.5" aria-hidden="true" />
79
+ </button>
80
+ </Show>
81
+ </div>
82
+ </Show>
83
+ );
84
+ }
@@ -3,7 +3,8 @@ import {
3
3
  } from 'solid-js';
4
4
  import { Dynamic } from 'solid-js/web';
5
5
  import {
6
- computePosition, autoUpdate, offset, flip, shift, arrow, hide, type Placement,
6
+ computePosition, autoUpdate, offset, flip, shift, arrow, hide,
7
+ getOverflowAncestors, type Placement,
7
8
  } from '@floating-ui/dom';
8
9
 
9
10
  /**
@@ -72,6 +73,84 @@ export interface UsePositionOptions {
72
73
  placement?: Placement;
73
74
  gutter?: number;
74
75
  arrowEl?: Accessor<HTMLElement | undefined>;
76
+ /**
77
+ * Fired ONCE when the reference (anchor) "goes away" — either removed from the
78
+ * document OR hidden behind an `inert` ancestor (e.g. a modal/takeover that
79
+ * inert-s the background while open). In both cases the anchor is no longer a
80
+ * valid, interactive target, so the caller should close the overlay and unmount
81
+ * its portal instead of leaving it orphaned (floating over an inert background or
82
+ * anchored to a node that no longer exists). Anchored overlays portal OUT of the
83
+ * trigger's subtree, so Solid's onCleanup does not catch an anchor that is
84
+ * removed/inerted independently of the overlay component. Wire this to set the
85
+ * overlay's open state to false.
86
+ */
87
+ onDisconnect?: () => void;
88
+ }
89
+
90
+ /**
91
+ * True if `node` sits inside an `inert` subtree. Climbs ACROSS shadow boundaries:
92
+ * an anchor often lives inside a web component's shadow root (kai-coachmark renders
93
+ * its anchor span in its own shadow) while `inert` lands on a LIGHT-DOM ancestor of
94
+ * the host (kai-screen inert-s its siblings, e.g. kai-workspace). `closest('[inert]')`
95
+ * alone cannot see that because it halts at the shadow root, so after each tree we
96
+ * hop to the host of the containing ShadowRoot and keep climbing.
97
+ */
98
+ function inInertSubtree(node: Node | null): boolean {
99
+ let n: Node | null = node;
100
+ while (n) {
101
+ if (n instanceof Element && n.closest('[inert]')) return true;
102
+ const root = n.getRootNode();
103
+ n = root instanceof ShadowRoot ? root.host : null;
104
+ }
105
+ return false;
106
+ }
107
+
108
+ /**
109
+ * Watch for the reference element "going away" and fire `onDisconnect` exactly
110
+ * once. The anchor is gone when it is either removed from the document OR hidden
111
+ * behind an `inert` ancestor (`inInertSubtree(reference)`, which crosses shadow
112
+ * boundaries) — the latter is how a modal/takeover (e.g. kai-screen) makes the
113
+ * background non-interactive while leaving it in the DOM. Either way the anchor is
114
+ * no longer a valid target and the overlay must close.
115
+ *
116
+ * Uses a MutationObserver on BOTH the document and the anchor's root node: the
117
+ * document catches the anchor's host being removed and any ancestor gaining
118
+ * `inert` (and light-DOM removals), while the anchor's root node — a ShadowRoot
119
+ * for kai-* elements — catches removals INSIDE the shadow tree, which a
120
+ * document-level observer can't see through encapsulation. We observe childList
121
+ * (DOM removals) AND the `inert` attribute, then re-check the anchor after any
122
+ * mutation. Guarded for environments without MutationObserver. Returns a teardown
123
+ * that disconnects the observer.
124
+ */
125
+ function watchAnchorGone(ref: HTMLElement, onDisconnect: () => void): () => void {
126
+ if (typeof MutationObserver !== 'function') return () => {};
127
+ let fired = false;
128
+ // "Live" = connected AND not buried under an inert ancestor (across shadow roots).
129
+ const isLive = () => ref.isConnected && !inInertSubtree(ref);
130
+ // Only fire after the anchor has actually been live, so a one-off setup while
131
+ // detached/inert can never trigger a false disconnect.
132
+ let everLive = isLive();
133
+ const check = () => {
134
+ if (fired) return;
135
+ if (isLive()) { everLive = true; return; }
136
+ if (!everLive) return;
137
+ fired = true;
138
+ obs.disconnect();
139
+ onDisconnect();
140
+ };
141
+ const obs = new MutationObserver(check);
142
+ const roots = new Set<Node>();
143
+ if (typeof document !== 'undefined') roots.add(document);
144
+ const rootNode = ref.getRootNode();
145
+ if (rootNode) roots.add(rootNode);
146
+ for (const root of roots) {
147
+ try {
148
+ obs.observe(root, {
149
+ childList: true, subtree: true, attributes: true, attributeFilter: ['inert'],
150
+ });
151
+ } catch { /* unobservable root */ }
152
+ }
153
+ return () => obs.disconnect();
75
154
  }
76
155
 
77
156
  /**
@@ -116,8 +195,35 @@ export function usePosition(
116
195
  setHidden(!!middlewareData.hide?.referenceHidden);
117
196
  });
118
197
  };
198
+ // autoUpdate tracks scroll, window resize, reference/floating ResizeObserver,
199
+ // and reference layout-shifts (IntersectionObserver). But its `ancestorResize`
200
+ // only listens for DOM `resize` events (which ONLY `window` fires), so an
201
+ // ANCESTOR element resizing (e.g. a sibling resizable sidebar reflowing the
202
+ // anchor's container without resizing the anchor itself) is caught only by the
203
+ // threshold-based layoutShift, which lags during a continuous drag. Add a
204
+ // ResizeObserver across the reference and its overflow ancestors so the
205
+ // floating node follows the anchor on any layout resize. Both are torn down
206
+ // on unmount via onCleanup.
119
207
  const cleanup = autoUpdate(ref, float, update);
120
- onCleanup(cleanup);
208
+ let ro: ResizeObserver | undefined;
209
+ if (typeof ResizeObserver === 'function') {
210
+ ro = new ResizeObserver(update);
211
+ ro.observe(ref);
212
+ for (const ancestor of getOverflowAncestors(ref)) {
213
+ if (ancestor instanceof Element) ro.observe(ancestor);
214
+ }
215
+ }
216
+ // When the anchor goes away (removed from the DOM or buried under an inert
217
+ // ancestor), close the overlay so its portal unmounts instead of floating
218
+ // orphaned. Independent of autoUpdate/ResizeObserver.
219
+ const disconnectWatch = options.onDisconnect
220
+ ? watchAnchorGone(ref, options.onDisconnect)
221
+ : undefined;
222
+ onCleanup(() => {
223
+ cleanup();
224
+ ro?.disconnect();
225
+ disconnectWatch?.();
226
+ });
121
227
  });
122
228
 
123
229
  return { pos, arrowPos, hidden };
@@ -0,0 +1,117 @@
1
+ import { type JSX, For, children as resolveChildren } from 'solid-js';
2
+ import { cn } from '../utils/cn';
3
+
4
+ export interface PaneGridProps {
5
+ /** The panes - arbitrary N. Each top-level child is one tile in the grid. */
6
+ children: JSX.Element;
7
+ /** Minimum width of every pane, in px, before columns drop / the grid scrolls.
8
+ * Defaults to `280`. */
9
+ minPaneWidth?: number;
10
+ /** Minimum height of every pane, in px, before the grid scrolls vertically.
11
+ * Defaults to `200`. */
12
+ minPaneHeight?: number;
13
+ /** Column cap when the container is wide. Columns fill up to this many, then drop
14
+ * to fewer as the container narrows. Defaults to `3`. */
15
+ maxColumns?: number;
16
+ /** Gap between panes - any CSS length. Defaults to the kit gap
17
+ * (`var(--kai-pane-grid-gap, 0.5rem)`). */
18
+ gap?: string;
19
+ /** When set to a valid child index, render ONLY that pane full-bleed (a single
20
+ * filling cell) - a simple maximize hook the consumer drives. `null`/`undefined`
21
+ * (or an out-of-range index) shows the full tiled grid. */
22
+ maximizedIndex?: number | null;
23
+ /** Extra classes for the grid container. */
24
+ class?: string;
25
+ }
26
+
27
+ /**
28
+ * PaneGrid - an N-pane responsive tiling grid with a min-size + scroll floor.
29
+ *
30
+ * Lays an arbitrary number of panes out in a CSS grid that fills up to
31
+ * `maxColumns` columns when wide, then DROPS columns (maxColumns -> ... -> 1) as
32
+ * the container narrows - so panes never squish below their minimums. Once even one
33
+ * column can't hold a pane at `minPaneWidth`, the grid SCROLLS instead of shrinking
34
+ * the panes; rows are kept at least `minPaneHeight` tall the same way. Because new
35
+ * rows stack downward, the overflow is preferentially VERTICAL - horizontal scroll
36
+ * only appears when the container is narrower than a single pane's minimum.
37
+ *
38
+ * This generalizes the hand-rolled center grid from the Split Workspace demo, where
39
+ * `kai-resizable` (capped at 3 panes) couldn't express an arbitrary-N tiled grid.
40
+ *
41
+ * Column track (computed from the props):
42
+ *
43
+ * repeat(auto-fit, minmax(max(<minPaneWidth>px, (100% - <gaps>) / <maxColumns>), 1fr))
44
+ *
45
+ * where `<gaps>` is the total inter-column gap at the cap, `(maxColumns - 1) * gap`.
46
+ * The inner `max()` is the floor: each track is at least `minPaneWidth`, and at most
47
+ * `1fr`; the `(100% - gaps) / maxColumns` term is the per-column width WHEN the cap is
48
+ * filled, so `auto-fit` never packs in more than `maxColumns` columns. As the
49
+ * container shrinks past the point where a column can be `minPaneWidth` wide, a column
50
+ * drops; below one pane's minimum, the `overflow:auto` + `min-w-0`/`min-h-0` container
51
+ * scrolls.
52
+ *
53
+ * Maximize: when `maximizedIndex` points at a child, only that pane renders, in a
54
+ * single `1fr` x `1fr` cell that fills the grid. Restore by clearing the prop.
55
+ *
56
+ * The gap default reads `--kai-pane-grid-gap` (fallback `0.5rem`), so a consumer can
57
+ * retune spacing from outside without passing the prop. Everything is tokenized
58
+ * (surface/border come from whatever the panes use) - no hardcoded colors, so it
59
+ * reads correctly in light and dark.
60
+ */
61
+ export function PaneGrid(props: PaneGridProps) {
62
+ const minPaneWidth = () => props.minPaneWidth ?? 280;
63
+ const minPaneHeight = () => props.minPaneHeight ?? 200;
64
+ const maxColumns = () => Math.max(1, props.maxColumns ?? 3);
65
+ const gap = () => props.gap ?? 'var(--kai-pane-grid-gap, 0.5rem)';
66
+
67
+ // Resolve children to their rendered nodes so a single pane can be picked out for
68
+ // the maximize hook (mirrors how Resizable reads its panels).
69
+ const resolved = resolveChildren(() => props.children);
70
+ const items = (): JSX.Element[] => resolved.toArray() as JSX.Element[];
71
+
72
+ // A valid maximize target, or null for the full grid.
73
+ const maxIndex = (): number | null => {
74
+ const m = props.maximizedIndex;
75
+ if (m == null) return null;
76
+ return m >= 0 && m < items().length ? m : null;
77
+ };
78
+
79
+ const shown = (): JSX.Element[] => {
80
+ const m = maxIndex();
81
+ return m == null ? items() : [items()[m]];
82
+ };
83
+
84
+ const gridStyle = (): JSX.CSSProperties => {
85
+ const g = gap();
86
+ if (maxIndex() != null) {
87
+ // One filling cell.
88
+ return {
89
+ 'grid-template-columns': '1fr',
90
+ 'grid-auto-rows': '1fr',
91
+ gap: g,
92
+ };
93
+ }
94
+ const cols = maxColumns();
95
+ // The per-column width when the cap is filled: (container - all gaps) / cols.
96
+ // Inside max() this is a math sub-expression, so the var/number arithmetic is valid.
97
+ const capped = `(100% - ${cols - 1} * ${g}) / ${cols}`;
98
+ return {
99
+ 'grid-template-columns': `repeat(auto-fit, minmax(max(${minPaneWidth()}px, ${capped}), 1fr))`,
100
+ 'grid-auto-rows': `minmax(${minPaneHeight()}px, 1fr)`,
101
+ gap: g,
102
+ };
103
+ };
104
+
105
+ return (
106
+ <div
107
+ data-pane-grid
108
+ // min-w-0 / min-h-0 let the grid shrink inside a flex/grid parent so its own
109
+ // overflow:auto (not the parent) takes over once panes hit their minimums.
110
+ class={cn('grid h-full w-full min-h-0 min-w-0 overflow-auto', props.class)}
111
+ tabindex={0}
112
+ style={gridStyle()}
113
+ >
114
+ <For each={shown()}>{(pane) => pane}</For>
115
+ </div>
116
+ );
117
+ }
@@ -0,0 +1,291 @@
1
+ import { type JSX, For, Show } from 'solid-js';
2
+ import { MoreHorizontal, X } from 'lucide-solid';
3
+ import { type PaneStatusTone } from './pane';
4
+ import { cn } from '../utils/cn';
5
+
6
+ /** The work state of a tab's agent/process, mapped to the kit's tool / status
7
+ * hues — the SAME vocabulary as {@link './pane'.PaneStatus} and the AgentCard:
8
+ * working = blue, idle = muted, done = green, error = red, blocked = amber. */
9
+ export interface PaneTabStatus {
10
+ /** Which hue the numbered badge takes. */
11
+ tone: PaneStatusTone;
12
+ /** Optional status word shown on the active tab, on hover, and always for a
13
+ * needs-attention / error tab. Without it only the badge color carries state. */
14
+ label?: string;
15
+ /** Animate a ping ring around the badge — for the live `working` state.
16
+ * Respects prefers-reduced-motion. */
17
+ pulse?: boolean;
18
+ }
19
+
20
+ /** One tab in a {@link PaneGroup}: an agent/window shown in the strip. */
21
+ export interface PaneTab {
22
+ /** Stable id, emitted as the selected value throughout. */
23
+ id: string;
24
+ /** The tab name (the agent / window title). */
25
+ name: string;
26
+ /** Run status — drives the numbered badge color + the status word. Defaults to
27
+ * an `idle` (muted) badge with no word. */
28
+ status?: PaneTabStatus;
29
+ /** Raise the attention treatment: an amber ring + the status word always shown.
30
+ * The "this one wants you" signal. */
31
+ needsAttention?: boolean;
32
+ /** The keyboard NUMBER shown inside the badge (the ⌥-jump hint). Defaults to the
33
+ * tab's 1-based position in the strip. */
34
+ number?: number;
35
+ }
36
+
37
+ export interface PaneGroupProps {
38
+ /** The tabs, left → right. Each is one agent/window in the group. */
39
+ tabs: PaneTab[];
40
+ /** The active tab id. Defaults to the first tab. Drive it from `onTabChange`. */
41
+ active?: string;
42
+ /** A tab was selected (click, Enter/Space, or arrow-key move). */
43
+ onTabChange?: (id: string) => void;
44
+ /** A tab's close (×) was clicked. The consumer drops the tab from `tabs`. */
45
+ onTabClose?: (id: string) => void;
46
+ /** A tab's "…" overflow was clicked. The consumer wires the actual menu; the
47
+ * group only surfaces the affordance. Omit to hide the "…" button. */
48
+ onTabMenu?: (id: string) => void;
49
+ /** Highlight the frame with a ring/border to mark this as the ACTIVE group in a
50
+ * multi-group layout. */
51
+ focused?: boolean;
52
+ /** The active pane's body — the consumer owns it and swaps it on `onTabChange`. */
53
+ children?: JSX.Element;
54
+ /** Extra classes for the outer frame. */
55
+ class?: string;
56
+ }
57
+
58
+ /** tone → numbered-badge background (the kit's tool hues + muted for idle). */
59
+ const TONE_BG: Record<PaneStatusTone, string> = {
60
+ working: 'bg-tool-blue',
61
+ idle: 'bg-muted-foreground',
62
+ done: 'bg-tool-green',
63
+ error: 'bg-tool-red',
64
+ blocked: 'bg-tool-amber',
65
+ };
66
+
67
+ /** tone → badge digit color (contrasts the solid badge fill). */
68
+ const TONE_BADGE_FG: Record<PaneStatusTone, string> = {
69
+ working: 'text-white',
70
+ idle: 'text-background',
71
+ done: 'text-white',
72
+ error: 'text-white',
73
+ blocked: 'text-white',
74
+ };
75
+
76
+ /** tone → matching text color for the inline status word. */
77
+ const TONE_TEXT: Record<PaneStatusTone, string> = {
78
+ working: 'text-tool-blue',
79
+ idle: 'text-muted-foreground',
80
+ done: 'text-tool-green',
81
+ error: 'text-tool-red',
82
+ blocked: 'text-tool-amber',
83
+ };
84
+
85
+ /**
86
+ * PaneGroup — an editor group: a TAB STRIP (numbered-status-badge tabs) over a
87
+ * single CONTENT area showing the active tab's pane body. The reusable "one column
88
+ * = a group of agents shown as tabs" primitive from the Multi-Agent Workspace,
89
+ * extracted from the hand-rolled group in the Split Workspace demo.
90
+ *
91
+ * Each tab leads with a small TONE-COLORED NUMBERED BADGE — the color encodes the
92
+ * agent's run status, the digit is its keyboard (⌥-jump) number, unifying status +
93
+ * hint into one element — then the name, then the status WORD (shown on the active
94
+ * tab, on hover, and always for a needs-attention / error tab), an optional "…"
95
+ * overflow, and a close "×". The active tab is highlighted; a needs-attention tab
96
+ * carries an amber ring even when inactive.
97
+ *
98
+ * Composition: the group owns the tab UX; the CONSUMER owns the pane content. It
99
+ * renders `children` as the active pane's body and swaps it in response to
100
+ * `onTabChange`. Selection-only — it never routes content itself.
101
+ *
102
+ * Accessibility: a `role="group"` ("Open panes") strip of real `<button>` tab
103
+ * activators (NOT `role="tab"`, so the strip can legally own the per-tab menu/close
104
+ * buttons) with roving tabindex + Arrow/Home/End navigation; the active activator is
105
+ * marked `aria-current="true"`, and the body is the `role="tabpanel"`. Colors are all
106
+ * token-backed (surface / border / ring / tool-*), so it reads in light and dark.
107
+ * The strip, each tab, and the body are exposed via `::part(tabs|tab|body)` for
108
+ * the `kai-pane-group` facade. Give the group a bounded height for the body scroll.
109
+ */
110
+ export function PaneGroup(props: PaneGroupProps) {
111
+ const tabs = () => props.tabs ?? [];
112
+ const activeId = () => props.active ?? tabs()[0]?.id;
113
+
114
+ // Roving tabindex needs exactly one tab in the tab order: the active tab gets it,
115
+ // else the first, so the strip is always reachable by Tab.
116
+ const rovingId = () => {
117
+ const a = activeId();
118
+ if (a !== undefined && tabs().some((t) => t.id === a)) return a;
119
+ return tabs()[0]?.id;
120
+ };
121
+
122
+ const tabEls: Record<string, HTMLElement> = {};
123
+ const select = (id: string) => props.onTabChange?.(id);
124
+
125
+ // Arrow/Home/End move + select (activate on focus move); Enter/Space select.
126
+ // Only handled from the tab itself, never from its nested ×/… buttons.
127
+ const onKeyDown = (e: KeyboardEvent, tab: PaneTab) => {
128
+ if (e.currentTarget !== e.target) return;
129
+ const list = tabs();
130
+ if (list.length === 0) return;
131
+ const i = list.findIndex((t) => t.id === tab.id);
132
+ let next: PaneTab | undefined;
133
+ switch (e.key) {
134
+ case 'ArrowRight':
135
+ case 'ArrowDown':
136
+ next = list[(i + 1) % list.length];
137
+ break;
138
+ case 'ArrowLeft':
139
+ case 'ArrowUp':
140
+ next = list[(i - 1 + list.length) % list.length];
141
+ break;
142
+ case 'Home':
143
+ next = list[0];
144
+ break;
145
+ case 'End':
146
+ next = list[list.length - 1];
147
+ break;
148
+ case 'Enter':
149
+ case ' ':
150
+ e.preventDefault();
151
+ select(tab.id);
152
+ return;
153
+ default:
154
+ return;
155
+ }
156
+ if (next) {
157
+ e.preventDefault();
158
+ select(next.id);
159
+ tabEls[next.id]?.focus();
160
+ }
161
+ };
162
+
163
+ const TabItem = (p: { tab: PaneTab; index: number }) => {
164
+ const tab = () => p.tab;
165
+ const tone = (): PaneStatusTone => tab().status?.tone ?? 'idle';
166
+ const isActive = () => tab().id === activeId();
167
+ const num = () => tab().number ?? p.index + 1;
168
+ // The status word shows on the active tab, on hover, and always when the tab
169
+ // needs attention or has errored.
170
+ const alwaysWord = () => isActive() || !!tab().needsAttention || tone() === 'error';
171
+ // Outer wrapper is a plain div (no ARIA role) so the activator button and
172
+ // the menu/close buttons are siblings -- no nested-interactive violation.
173
+ return (
174
+ <div
175
+ class={cn(
176
+ 'group/tab relative flex shrink-0 items-center rounded-md text-xs',
177
+ isActive()
178
+ ? 'bg-background text-foreground shadow-sm ring-1 ring-border'
179
+ : 'text-muted-foreground hover:bg-hover hover:text-foreground',
180
+ tab().needsAttention && !isActive() && 'ring-1 ring-tool-amber/50',
181
+ )}
182
+ data-active={isActive() ? '' : undefined}
183
+ data-needs-attention={tab().needsAttention ? '' : undefined}
184
+ >
185
+ {/* Button-group activator (NOT role="tab") so the strip can legally own the
186
+ sibling menu/close buttons. aria-current marks the active pane. */}
187
+ <button
188
+ ref={(el) => { tabEls[tab().id] = el; }}
189
+ type="button"
190
+ part="tab"
191
+ tabindex={tab().id === rovingId() ? 0 : -1}
192
+ aria-current={isActive() ? 'true' : undefined}
193
+ onClick={() => select(tab().id)}
194
+ onKeyDown={(e) => onKeyDown(e, tab())}
195
+ class="flex cursor-pointer items-center gap-1.5 py-1 pl-1.5 outline-none transition-colors focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
196
+ >
197
+ {/* Numbered status badge: color = status, digit = the ⌥-jump number. */}
198
+ <span class="relative flex size-[18px] shrink-0" aria-hidden="true">
199
+ <Show when={tab().status?.pulse}>
200
+ <span class={cn('absolute inset-0 animate-ping rounded opacity-60 motion-reduce:hidden', TONE_BG[tone()])} />
201
+ </Show>
202
+ <span
203
+ class={cn(
204
+ 'relative flex size-[18px] items-center justify-center rounded text-[11px] font-bold leading-none tabular-nums',
205
+ TONE_BG[tone()],
206
+ TONE_BADGE_FG[tone()],
207
+ )}
208
+ >
209
+ {num()}
210
+ </span>
211
+ </span>
212
+
213
+ <span class="max-w-[8rem] truncate font-medium">{tab().name}</span>
214
+
215
+ <Show when={tab().status?.label}>
216
+ <span
217
+ class={cn(
218
+ 'truncate text-[10px] font-medium',
219
+ TONE_TEXT[tone()],
220
+ alwaysWord() ? 'inline' : 'hidden group-hover/tab:inline',
221
+ )}
222
+ >
223
+ {tab().status!.label}
224
+ </span>
225
+ </Show>
226
+ </button>
227
+
228
+ {/* menu/close are siblings to the activator, not descendants -- no nested-interactive. */}
229
+ <span class="ml-0.5 flex shrink-0 items-center pr-1">
230
+ <Show when={props.onTabMenu}>
231
+ <button
232
+ type="button"
233
+ part="menu"
234
+ aria-label={`${tab().name} tab actions`}
235
+ aria-haspopup="menu"
236
+ onClick={(e) => { e.stopPropagation(); props.onTabMenu?.(tab().id); }}
237
+ class={cn(
238
+ 'flex size-5 items-center justify-center rounded text-muted-foreground transition-colors',
239
+ 'hover:bg-surface-sunken hover:text-foreground',
240
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring',
241
+ isActive() ? 'opacity-100' : 'opacity-0 group-hover/tab:opacity-100',
242
+ )}
243
+ >
244
+ <MoreHorizontal class="size-3.5" aria-hidden="true" />
245
+ </button>
246
+ </Show>
247
+ <Show when={props.onTabClose}>
248
+ <button
249
+ type="button"
250
+ part="close"
251
+ aria-label={`Close ${tab().name}`}
252
+ onClick={(e) => { e.stopPropagation(); props.onTabClose?.(tab().id); }}
253
+ class={cn(
254
+ 'flex size-5 items-center justify-center rounded text-muted-foreground transition-colors',
255
+ 'hover:bg-surface-sunken hover:text-foreground',
256
+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring',
257
+ isActive() ? 'opacity-100' : 'opacity-0 group-hover/tab:opacity-100',
258
+ )}
259
+ >
260
+ <X class="size-3.5" aria-hidden="true" />
261
+ </button>
262
+ </Show>
263
+ </span>
264
+ </div>
265
+ );
266
+ };
267
+
268
+ return (
269
+ <div
270
+ data-pane-group
271
+ class={cn(
272
+ 'flex h-full min-h-0 flex-col overflow-hidden rounded-xl border bg-surface',
273
+ props.focused ? 'border-ring ring-2 ring-inset ring-ring/35' : 'border-border',
274
+ props.class,
275
+ )}
276
+ >
277
+ <div
278
+ part="tabs"
279
+ role="group"
280
+ aria-label="Open panes"
281
+ class="flex shrink-0 items-center gap-1 overflow-x-auto border-b border-border px-1.5 py-1"
282
+ >
283
+ <For each={tabs()}>{(tab, i) => <TabItem tab={tab} index={i()} />}</For>
284
+ </div>
285
+
286
+ <div part="body" role="tabpanel" class="min-h-0 flex-1 overflow-y-auto">
287
+ {props.children}
288
+ </div>
289
+ </div>
290
+ );
291
+ }