@kitn.ai/ui 0.16.0 → 0.17.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 (194) hide show
  1. package/README.md +28 -13
  2. package/dist/components/chat-thread.d.ts +2 -4
  3. package/dist/components/choice-card.d.ts +1 -0
  4. package/dist/components/dismissed-stub.d.ts +22 -0
  5. package/dist/components/message.d.ts +59 -2
  6. package/dist/components/response-compare-types.d.ts +66 -0
  7. package/dist/components/response-compare.d.ts +51 -0
  8. package/dist/components/tasks-card.d.ts +1 -0
  9. package/dist/components/toast.d.ts +48 -0
  10. package/dist/components/use-card-resolution.d.ts +10 -6
  11. package/dist/custom-elements.json +260 -11
  12. package/dist/elements/artifact.js +1 -0
  13. package/dist/elements/attachments.js +1 -0
  14. package/dist/elements/autoloader.d.ts +2 -0
  15. package/dist/elements/autoloader.js +1 -0
  16. package/dist/elements/card.js +1 -0
  17. package/dist/elements/cards.d.ts +1 -0
  18. package/dist/elements/cards.js +1 -0
  19. package/dist/elements/chain-of-thought.d.ts +0 -12
  20. package/dist/elements/chain-of-thought.js +1 -0
  21. package/dist/elements/chat-scope-picker.js +1 -0
  22. package/dist/elements/chat-workspace.js +1 -0
  23. package/dist/elements/chat.js +1 -0
  24. package/dist/elements/checkpoint.js +1 -0
  25. package/dist/elements/choice.js +1 -0
  26. package/dist/elements/chunks/Icon-D_Zmwmwh.js +1 -0
  27. package/dist/elements/chunks/action-icons-PVfIvcuG.js +1 -0
  28. package/dist/elements/chunks/attachments-Dp6vqtrc.js +1 -0
  29. package/dist/elements/chunks/bash-InADTalH.js +1 -0
  30. package/dist/elements/chunks/button-CKyYD9G4.js +1 -0
  31. package/dist/elements/chunks/card-Cjho-PYk.js +1 -0
  32. package/dist/elements/chunks/card-routing-C986KuUA.js +1 -0
  33. package/dist/elements/chunks/chat-thread-RT808iPf.js +1 -0
  34. package/dist/elements/chunks/check-CDYaMYrM.js +1 -0
  35. package/dist/elements/chunks/chevron-down-3SBiq8HF.js +1 -0
  36. package/dist/elements/chunks/chevron-right-k2UFlIVK.js +1 -0
  37. package/dist/elements/chunks/cn-Dogu6PbV.js +1 -0
  38. package/dist/elements/chunks/code-block-BYUmfFSd.js +1 -0
  39. package/dist/elements/chunks/collapsible-BiNwdOn6.js +1 -0
  40. package/dist/elements/chunks/context-18g6oi4J.js +1 -0
  41. package/dist/elements/chunks/conversation-list-D9Y0NVdo.js +1 -0
  42. package/dist/elements/chunks/core-AYMC6_lb.js +12 -0
  43. package/dist/elements/chunks/css-M7EaDHN_.js +1 -0
  44. package/dist/elements/chunks/default-input-CSAoYYMd.js +1 -0
  45. package/dist/elements/chunks/download-D8K0Je8r.js +1 -0
  46. package/dist/elements/chunks/dropdown-bUs2iTia.js +1 -0
  47. package/dist/elements/chunks/engine-javascript-vq0WuIJl.js +141 -0
  48. package/dist/elements/chunks/external-link-6mA0wxab.js +1 -0
  49. package/dist/elements/chunks/file-text-DnaYk3Dm.js +1 -0
  50. package/dist/elements/chunks/file-tree-CgtRLlxK.js +1 -0
  51. package/dist/elements/chunks/github-dark-dimmed-DUshB20C.js +1 -0
  52. package/dist/elements/chunks/github-light-JYsPkUQd.js +1 -0
  53. package/dist/elements/chunks/hover-card-CIGw62gP.js +1 -0
  54. package/dist/elements/chunks/html-CPZ3oZQ7.js +1 -0
  55. package/dist/elements/chunks/index-CTBEJeo6.js +1 -0
  56. package/dist/elements/chunks/javascript-C25yR2R2.js +1 -0
  57. package/dist/elements/chunks/json-DxJze_jm.js +1 -0
  58. package/dist/elements/chunks/link-BlGSeoPy.js +1 -0
  59. package/dist/elements/chunks/loader-DvhR4qa0.js +1 -0
  60. package/dist/elements/chunks/markdown-CMTGx9r8.js +64 -0
  61. package/dist/elements/chunks/message-CDZwXjhL.js +1 -0
  62. package/dist/elements/chunks/message-feedback-CYx81QiA.js +1 -0
  63. package/dist/elements/chunks/model-switcher-O_tUhoOT.js +1 -0
  64. package/dist/elements/chunks/overlay-DydXYMQW.js +1 -0
  65. package/dist/elements/chunks/prompt-suggestion-ldlWV5kd.js +1 -0
  66. package/dist/elements/chunks/reasoning-2PUnHlmr.js +1 -0
  67. package/dist/elements/chunks/resizable-B5WNbSeb.js +1 -0
  68. package/dist/elements/chunks/star-t9tI-P0q.js +1 -0
  69. package/dist/elements/chunks/store-C6rIooZz.js +1 -0
  70. package/dist/elements/chunks/svelte--5p79yCD.js +1 -0
  71. package/dist/elements/chunks/text-shimmer-uh9V_KUh.js +1 -0
  72. package/dist/elements/chunks/textarea-3nm6Ia9U.js +1 -0
  73. package/dist/elements/chunks/thumbs-up-BBtguGld.js +1 -0
  74. package/dist/elements/chunks/toast-store-D8cL3fWl.js +1 -0
  75. package/dist/elements/chunks/tool-GJ3vwp1U.js +1 -0
  76. package/dist/elements/chunks/tooltip-DwKAz4XR.js +1 -0
  77. package/dist/elements/chunks/triangle-alert-Ct1zt2JL.js +1 -0
  78. package/dist/elements/chunks/tsx-B8rCNbgL.js +1 -0
  79. package/dist/elements/chunks/typescript-RycA9KXf.js +1 -0
  80. package/dist/elements/chunks/use-card-resolution-D-_0Alzy.js +1 -0
  81. package/dist/elements/chunks/video-mVYiM99-.js +1 -0
  82. package/dist/elements/chunks/vue-BmIZj4XD.js +1 -0
  83. package/dist/elements/chunks/x-CzxL27Ch.js +1 -0
  84. package/dist/elements/code-block.js +1 -0
  85. package/dist/elements/compare.js +1 -0
  86. package/dist/elements/confirm-card.js +1 -0
  87. package/dist/elements/context-meter.js +1 -0
  88. package/dist/elements/conversation-list.d.ts +1 -11
  89. package/dist/elements/conversation-list.js +1 -0
  90. package/dist/elements/embed.js +1 -0
  91. package/dist/elements/empty.js +1 -0
  92. package/dist/elements/feedback-bar.js +1 -0
  93. package/dist/elements/file-tree.js +1 -0
  94. package/dist/elements/file-upload.js +1 -0
  95. package/dist/elements/form.js +1 -0
  96. package/dist/elements/image.js +1 -0
  97. package/dist/elements/link-preview.js +1 -0
  98. package/dist/elements/loader.js +1 -0
  99. package/dist/elements/markdown.js +1 -0
  100. package/dist/elements/message-skills.d.ts +0 -16
  101. package/dist/elements/message-skills.js +1 -0
  102. package/dist/elements/message.js +1 -0
  103. package/dist/elements/model-switcher.d.ts +1 -11
  104. package/dist/elements/model-switcher.js +1 -0
  105. package/dist/elements/popover.js +1 -0
  106. package/dist/elements/prompt-input.d.ts +1 -9
  107. package/dist/elements/prompt-input.js +1 -0
  108. package/dist/elements/prompt-suggestions.d.ts +0 -6
  109. package/dist/elements/prompt-suggestions.js +1 -0
  110. package/dist/elements/reasoning.js +1 -0
  111. package/dist/elements/resizable.d.ts +1 -17
  112. package/dist/elements/resizable.js +1 -0
  113. package/dist/elements/response-stream.js +14 -0
  114. package/dist/elements/scroll-button.js +1 -0
  115. package/dist/elements/source.d.ts +0 -17
  116. package/dist/elements/source.js +1 -0
  117. package/dist/elements/switch.js +1 -0
  118. package/dist/elements/tasks.js +1 -0
  119. package/dist/elements/text-shimmer.js +1 -0
  120. package/dist/elements/thinking-bar.js +1 -0
  121. package/dist/elements/toast.d.ts +1 -0
  122. package/dist/elements/toast.js +1 -0
  123. package/dist/elements/tool.js +1 -0
  124. package/dist/elements/voice-input.js +1 -0
  125. package/dist/elements.d.ts +41 -5
  126. package/dist/index.d.ts +12 -0
  127. package/dist/index.js +11832 -9790
  128. package/dist/kitn-chat.es.js +1 -1
  129. package/dist/llms/llms-full.txt +57 -12
  130. package/dist/llms/llms.txt +3 -3
  131. package/dist/mcp.es.js +157 -1
  132. package/dist/primitives/card-contract.d.ts +20 -4
  133. package/dist/primitives/card-recovery.d.ts +55 -0
  134. package/dist/primitives/message-feedback.d.ts +35 -0
  135. package/dist/primitives/toast-store.d.ts +88 -0
  136. package/dist/react/index.d.ts +83 -3
  137. package/dist/react.js +90 -80
  138. package/dist/register-JyTglR6m.js +1 -0
  139. package/dist/register-impl-C6wlSsts.js +77 -0
  140. package/dist/schemas/choice.schema.json +5 -0
  141. package/dist/schemas/tasks.schema.json +5 -0
  142. package/dist/ui/tooltip.d.ts +1 -0
  143. package/frameworks/react/index.tsx +63 -11
  144. package/llms-full.txt +57 -12
  145. package/llms.txt +3 -3
  146. package/package.json +15 -6
  147. package/src/agent-tooling/mcp/tools/debug.ts +184 -0
  148. package/src/agent-tooling/mcp/tools/scaffold.ts +133 -1
  149. package/src/components/chat-thread.tsx +27 -35
  150. package/src/components/choice-card.tsx +33 -4
  151. package/src/components/component-meta.json +250 -26
  152. package/src/components/confirm-card.tsx +15 -1
  153. package/src/components/dismissed-stub.tsx +80 -0
  154. package/src/components/form.tsx +21 -3
  155. package/src/components/message.tsx +151 -10
  156. package/src/components/response-compare-types.ts +127 -0
  157. package/src/components/response-compare.tsx +431 -0
  158. package/src/components/tasks-card.tsx +33 -3
  159. package/src/components/toast.tsx +398 -0
  160. package/src/components/use-card-resolution.ts +24 -8
  161. package/src/elements/autoloader.ts +89 -0
  162. package/src/elements/chat-types.ts +7 -0
  163. package/src/elements/chat-workspace.tsx +4 -2
  164. package/src/elements/chat.tsx +4 -2
  165. package/src/elements/compare.tsx +88 -0
  166. package/src/elements/compiled.css +1 -1
  167. package/src/elements/element-manifest.json +182 -0
  168. package/src/elements/element-meta.json +191 -68
  169. package/src/elements/element-types.d.ts +41 -5
  170. package/src/elements/framework-usage.json +25 -0
  171. package/src/elements/message.tsx +27 -45
  172. package/src/elements/register-impl.ts +3 -0
  173. package/src/elements/register.ts +9 -0
  174. package/src/elements/remote.tsx +4 -0
  175. package/src/elements/styles.css +19 -0
  176. package/src/elements/toast.tsx +74 -0
  177. package/src/index.ts +30 -0
  178. package/src/primitives/card-contract.ts +14 -5
  179. package/src/primitives/card-recovery.ts +149 -0
  180. package/src/primitives/card-routing.ts +3 -0
  181. package/src/primitives/card-schemas/choice.schema.json +5 -0
  182. package/src/primitives/card-schemas/tasks.schema.json +5 -0
  183. package/src/primitives/message-feedback.ts +123 -0
  184. package/src/primitives/toast-store.ts +235 -0
  185. package/src/ui/tooltip.tsx +8 -2
  186. package/dist/elements/chat-types.d.ts +0 -41
  187. package/dist/elements/css.d.ts +0 -1
  188. package/dist/elements/default-input.d.ts +0 -40
  189. package/dist/elements/define.d.ts +0 -42
  190. package/dist/elements/register-impl.d.ts +0 -0
  191. package/dist/elements/register.d.ts +0 -3
  192. package/dist/register-impl-wCsFPoh9.js +0 -77
  193. package/dist/register-ujhr1nBS.js +0 -1
  194. /package/dist/elements/{remote.d.ts → compare.d.ts} +0 -0
@@ -0,0 +1 @@
1
+ import{d as p,s as g,i as n,c as r,z as i,S as u,h as b,k as m,j as f,t as l,q as h}from"./chunks/cn-Dogu6PbV.js";import{T as c}from"./chunks/text-shimmer-uh9V_KUh.js";import{c as x}from"./chunks/chevron-right-k2UFlIVK.js";var k=l('<button type=button class="flex items-center gap-1 text-sm transition-opacity hover:opacity-80">'),v=l('<button type=button class="text-muted-foreground hover:text-foreground border-muted-foreground/50 hover:border-foreground border-b border-dotted text-sm transition-colors">'),w=l("<div>");function y(o){const[t]=g(o,["class","text","onStop","stopLabel","onClick"]),s=()=>t.text??"Thinking",d=()=>t.stopLabel??"Answer now";return(()=>{var a=w();return n(a,r(u,{get when(){return t.onClick},get fallback(){return r(c,{class:"cursor-default text-sm font-medium",get children(){return s()}})},get children(){var e=k();return i(e,"click",t.onClick,!0),n(e,r(c,{class:"text-sm font-medium",get children(){return s()}}),null),n(e,r(x,{class:"text-muted-foreground size-4"}),null),e}}),null),n(a,r(u,{get when(){return t.onStop},get children(){var e=v();return i(e,"click",t.onStop,!0),n(e,d),e}}),null),b(()=>m(a,f("flex w-full items-center justify-between",t.class))),a})()}p(["click"]),h("kai-thinking-bar",{text:"Thinking",stoppable:!1,stopLabel:"Answer now"},(o,{dispatch:t,flag:s})=>r(y,{get text(){return o.text},get stopLabel(){return o.stopLabel},get onStop(){return s("stoppable")?()=>t("kai-stop"):void 0}}));
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ import{d as nt,a as z,e as Q,b as W,p as Y,c as v,i as w,F as U,u as V,h as B,j as C,g as G,k as X,A as H,G as Z,S as M,t as E,o as _,q as it}from"./chunks/cn-Dogu6PbV.js";import{c as at}from"./chunks/overlay-DydXYMQW.js";import{r as tt,t as st}from"./chunks/toast-store-D8cL3fWl.js";import{c as dt}from"./chunks/check-CDYaMYrM.js";import{x as lt}from"./chunks/x-CzxL27Ch.js";var ct=E('<button type=button aria-label=Dismiss class="text-muted-foreground hover:text-foreground -mr-1 flex size-5 shrink-0 items-center justify-center rounded-md transition-colors">'),ut=E('<div role=status><span class="min-w-0 flex-1 truncate">'),mt=E('<button type=button class="text-primary hover:text-primary/80 shrink-0 rounded-md text-sm font-medium underline-offset-2 hover:underline">'),pt=E('<div role=region aria-label=Notifications aria-live=polite data-stack=collapsed><div class="pointer-events-auto relative transition-[height] duration-200 ease-out"style="min-width:16rem;max-width:min(28rem, calc(100vw - 2rem))">'),ft=E("<div role=region aria-label=Notifications aria-live=polite data-stack=expanded>"),vt=E("<div>");function ht(){var t,s;const[d,u]=z(typeof window<"u"&&((t=window.matchMedia)==null?void 0:t.call(window,"(prefers-reduced-motion: reduce)").matches)===!0);if(typeof window<"u"&&window.matchMedia){const o=window.matchMedia("(prefers-reduced-motion: reduce)"),l=()=>u(o.matches);(s=o.addEventListener)==null||s.call(o,"change",l),Y(()=>{var p;return(p=o.removeEventListener)==null?void 0:p.call(o,"change",l)})}return d}function et(t){const[s,d]=z(!0),u=at(s),o=()=>t.item.variant??"neutral",l=()=>t.item.dismissible!==!1;let p=tt(t.item),f=0,y,k="timeout";const h=()=>{y!==void 0&&(clearTimeout(y),y=void 0)},L=()=>{h(),!(p<=0)&&(f=Date.now(),y=setTimeout(()=>{k="timeout",d(!1)},p))},q=()=>{y!==void 0&&(h(),p-=Date.now()-f)},[F,j]=z(!1),R=()=>t.paused===!0||F();W(_(()=>tt(t.item),a=>{p=a,R()?h():L()})),W(_(R,a=>{a?q():L()},{defer:!0})),Y(h),W(()=>{!u.present()&&!s()&&t.onDismiss(k)});const S=()=>{h(),k="close",d(!1)},N=()=>{var a;const b=t.item.action;b&&((a=t.onAction)==null||a.call(t,b.label),b.onAction()===!1||(h(),k="action",d(!1)))};return v(M,{get when(){return u.present()},get children(){var a=ut(),b=a.firstChild;a.addEventListener("pointerleave",()=>j(!1)),a.addEventListener("pointerenter",()=>j(!0));var T=u.setRef;return typeof T=="function"?V(T,a):u.setRef=a,w(a,v(M,{get when(){return o()==="success"},get children(){return v(dt,{class:"size-4 shrink-0 text-emerald-500"})}}),b),w(b,()=>t.item.message),w(a,v(M,{get when(){return t.item.action},children:m=>(()=>{var $=mt();return $.$$click=N,w($,()=>m().label),$})()}),null),w(a,v(M,{get when(){return l()},get children(){var m=ct();return m.$$click=S,w(m,v(lt,{class:"size-3.5"})),m}}),null),B(m=>{var $=u.state()==="closed"?"":void 0,A=C("pointer-events-auto flex items-center gap-3 rounded-full border px-4 py-2.5 text-sm shadow-lg","bg-popover text-popover-foreground border-border","animate-in fade-in-0 slide-in-from-top-4","data-[closed]:animate-out data-[closed]:fade-out-0 data-[closed]:slide-out-to-top-2");return $!==m.e&&G(a,"data-closed",m.e=$),A!==m.t&&X(a,m.t=A),m},{e:void 0,t:void 0}),a}})}const rt={"top-center":"top-4 left-1/2 -translate-x-1/2 items-center","top-right":"top-4 right-4 items-end","top-left":"top-4 left-4 items-start","bottom-center":"bottom-4 left-1/2 -translate-x-1/2 items-center flex-col-reverse","bottom-right":"bottom-4 right-4 items-end flex-col-reverse","bottom-left":"bottom-4 left-4 items-start flex-col-reverse"},xt={"top-center":"items-center","top-left":"items-start","top-right":"items-end","bottom-center":"items-center flex-col-reverse","bottom-left":"items-start flex-col-reverse","bottom-right":"items-end flex-col-reverse"},O=12;function ot(t,s){const d=s.left+s.width/2,u=s.top+O,o=s.bottom-O,l=s.left+O,p=s.right-O,f=`${Math.max(0,s.width-O*2)}px`;switch(t){case"top-left":return{top:`${u}px`,left:`${l}px`,transform:"none","max-width":f};case"top-right":return{top:`${u}px`,left:`${p}px`,transform:"translateX(-100%)","max-width":f};case"bottom-center":return{top:`${o}px`,left:`${d}px`,transform:"translate(-50%, -100%)","max-width":f};case"bottom-left":return{top:`${o}px`,left:`${l}px`,transform:"translateY(-100%)","max-width":f};case"bottom-right":return{top:`${o}px`,left:`${p}px`,transform:"translate(-100%, -100%)","max-width":f};default:return{top:`${u}px`,left:`${d}px`,transform:"translateX(-50%)","max-width":f}}}function gt(t){const s=()=>t.max??3,d=()=>t.position??"top-center",u=()=>t.stack??"expanded",o=ht(),l=()=>u()==="collapsed"&&!o(),[p,f]=z(!1),[y,k]=z(!1),h=()=>p()||y(),L=20,q=.05,F=48,j=8,R=()=>d().startsWith("bottom"),S=()=>R()?-1:1,[N,a]=z(F),b=e=>{if(!e||typeof window>"u")return;const i=()=>{const n=e.offsetHeight;n&&a(n)};if(i(),typeof ResizeObserver>"u")return;const r=new ResizeObserver(i);r.observe(e),Y(()=>r.disconnect())},T=e=>h()?`translateY(${S()*(N()+j)*e}px) scale(1)`:`translateY(${S()*L*e}px) scale(${1-q*e})`,m=()=>{const e=A().length;return e?h()?e*N()+(e-1)*j:N()+(e-1)*L:0},$=Q(()=>[...(t.toasts??[]).filter(e=>(e.target??void 0)===t.target)].reverse()),A=Q(()=>$().slice(0,s())),[D,I]=z(null);return W(()=>{const e=t.target;if(!e||typeof window>"u"){I(null);return}const i=()=>{const n=e.getBoundingClientRect();I({top:n.top,left:n.left,right:n.right,bottom:n.bottom,width:n.width})};i();const r=new ResizeObserver(i);r.observe(e),window.addEventListener("scroll",i,!0),window.addEventListener("resize",i),Y(()=>{r.disconnect(),window.removeEventListener("scroll",i,!0),window.removeEventListener("resize",i)})}),v(M,{get when(){return l()},get fallback(){return(()=>{var e=ft();return w(e,v(U,{get each(){return A()},children:i=>v(et,{item:i,onDismiss:r=>{var n;return(n=t.onDismiss)==null?void 0:n.call(t,i.id,r)},onAction:r=>{var n;return(n=t.onAction)==null?void 0:n.call(t,i.id,r)}})})),B(i=>{var r=C("pointer-events-none fixed z-[100] flex flex-col gap-2",D()?xt[d()]:C("max-w-[min(28rem,calc(100vw-2rem))]",rt[d()])),n=D()?ot(d(),D()):void 0;return r!==i.e&&X(e,i.e=r),i.t=Z(e,n,i.t),i},{e:void 0,t:void 0}),e})()},get children(){var e=pt(),i=e.firstChild;return e.$$focusout=()=>k(!1),e.$$focusin=()=>k(!0),e.addEventListener("pointerleave",()=>f(!1)),e.addEventListener("pointerenter",()=>f(!0)),w(i,v(U,{get each(){return A()},children:(r,n)=>(()=>{var g=vt();return V(c=>{n()===0&&b(c)},g),w(g,v(et,{item:r,get paused(){return h()},onDismiss:c=>{var x;return(x=t.onDismiss)==null?void 0:x.call(t,r.id,c)},onAction:c=>{var x;return(x=t.onAction)==null?void 0:x.call(t,r.id,c)}})),B(c=>{var x=n(),J=C("absolute inset-x-0 flex transition-[transform,opacity] duration-200 ease-out",R()?"bottom-0 origin-bottom":"top-0 origin-top",d().endsWith("right")?"justify-end":d().endsWith("left")?"justify-start":"justify-center"),K=String(s()-n()),P=T(n());return x!==c.e&&G(g,"data-depth",c.e=x),J!==c.t&&X(g,c.t=J),K!==c.a&&H(g,"z-index",c.a=K),P!==c.o&&H(g,"transform",c.o=P),c},{e:void 0,t:void 0,a:void 0,o:void 0}),g})()})),B(r=>{var n=h()?"":void 0,g=C("pointer-events-none fixed z-[100]",!D()&&rt[d()]),c=D()?ot(d(),D()):void 0,x=`${m()}px`;return n!==r.e&&G(e,"data-expanded",r.e=n),g!==r.t&&X(e,r.t=g),r.a=Z(e,c,r.a),x!==r.o&&H(i,"height",r.o=x),r},{e:void 0,t:void 0,a:void 0,o:void 0}),e}})}nt(["click","focusin","focusout"]),it("kai-toast-region",{toasts:[],position:"top-center",max:3,stack:"expanded",target:void 0},(t,{dispatch:s})=>{const d=()=>{const o=t.max,l=typeof o=="string"?parseInt(o,10):o;return typeof l=="number"&&!Number.isNaN(l)?l:3},u=o=>{st.dismiss(o)};return v(gt,{get toasts(){return t.toasts??[]},get position(){return t.position},get max(){return d()},get stack(){return t.stack},get target(){return t.target},onDismiss:(o,l)=>{u(o),s("kai-dismiss",{id:o,reason:l})},onAction:(o,l)=>s("kai-action",{id:o,label:l})})});
@@ -0,0 +1 @@
1
+ import{q as r,c as o,S as n}from"./chunks/cn-Dogu6PbV.js";import{T as a}from"./chunks/tool-GJ3vwp1U.js";r("kai-tool",{tool:void 0,open:!1},(t,{flag:e})=>o(n,{get when(){return t.tool},get children(){return o(a,{get toolPart(){return t.tool},get defaultOpen(){return e("open")}})}}));
@@ -0,0 +1 @@
1
+ import{a as m,p as x,s as T,i as f,c as r,F as M,A as B,S as p,n as y,j as k,h as z,k as C,t as h,q as j}from"./chunks/cn-Dogu6PbV.js";import{B as R}from"./chunks/button-CKyYD9G4.js";import{T as E}from"./chunks/tooltip-DwKAz4XR.js";function S(c={}){const n=c.mimeType??"audio/webm;codecs=opus",[i,a]=m(!1),[v,s]=m(null);let t,l=[],u;async function b(){s(null),l=[];try{const o=await navigator.mediaDevices.getUserMedia({audio:!0});return t=new MediaRecorder(o,{mimeType:n}),t.ondataavailable=e=>{e.data.size>0&&l.push(e.data)},t.onstop=()=>{const e=new Blob(l,{type:n});o.getTracks().forEach(d=>d.stop()),a(!1),u?.(e)},t.start(),a(!0),new Promise(e=>{u=e})}catch(o){throw s(o instanceof Error?o.message:"Microphone access denied"),a(!1),o}}function g(){t&&t.state==="recording"&&t.stop()}return x(()=>g()),{isRecording:i,error:v,start:b,stop:g}}var V=h('<svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><path d="M12 1a3 3 0 00-3 3v8a3 3 0 006 0V4a3 3 0 00-3-3z"></path><path d="M19 10v2a7 7 0 01-14 0v-2"></path><line x1=12 y1=19 x2=12 y2=23></line><line x1=8 y1=23 x2=16 y2=23>'),F=h('<svg width=14 height=14 viewBox="0 0 24 24"fill=currentColor><rect x=4 y=4 width=16 height=16 rx=2>'),P=h('<svg width=16 height=16 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=2 class=animate-spin><path d="M21 12a9 9 0 11-6.219-8.56">'),$=h("<div>"),q=h('<div class="absolute inset-0 animate-ping rounded-full border-2 border-red-400/30"style=animation-duration:2s>');function A(c){const[n]=T(c,["onTranscribe","onTranscription","disabled","class"]),{isRecording:i,start:a,stop:v}=S(),[s,t]=m(!1),l=()=>s()?"Transcribing...":i()?"Stop recording":"Voice input";async function u(){if(i())v();else try{const e=await a();t(!0);try{const d=await n.onTranscribe(e);d.trim()&&n.onTranscription(d.trim())}finally{t(!1)}}catch{t(!1)}}const b=()=>V(),g=()=>F(),o=()=>P();return(()=>{var e=$();return f(e,r(p,{get when(){return i()},get children(){return r(M,{each:[0,1,2],children:d=>(()=>{var w=q();return B(w,"animation-delay",`${d*.3}s`),w})()})}}),null),f(e,r(E,{get content(){return l()},get children(){return r(R,{variant:"ghost",size:"icon-sm",get"aria-label"(){return l()},onClick:u,get disabled(){return n.disabled||s()},get class(){return k("relative z-10 rounded-full transition-all duration-300",i()&&"bg-destructive text-white hover:bg-destructive/80")},get children(){return[r(p,{get when(){return s()},get children(){return r(o,{})}}),r(p,{get when(){return y(()=>!s())()&&i()},get children(){return r(g,{})}}),r(p,{get when(){return y(()=>!s())()&&!i()},get children(){return r(b,{})}})]}})}}),null),z(()=>C(e,k("relative inline-flex items-center justify-center",n.class))),e})()}j("kai-voice-input",{transcribe:void 0,disabled:!1},(c,{dispatch:n,flag:i})=>r(A,{get disabled(){return i("disabled")},onTranscribe:async a=>(n("kai-audio-captured",{blob:a}),c.transcribe?c.transcribe(a):""),onTranscription:a=>n("kai-transcription",{text:a})}));
@@ -101,11 +101,11 @@ export interface KaiCardsElement extends HTMLElement {
101
101
  /** Color mode (`auto` follows prefers-color-scheme). */
102
102
  theme?: 'light' | 'dark' | 'auto';
103
103
  /** The stream of card envelopes to render. Set as a JS PROPERTY: `el.cards = [...]`. */
104
- cards?: { type: string; id: string; data: unknown; title?: string; resolution?: { kind: "action"; action: string; payload?: unknown; at?: string } | { kind: "submit"; data: unknown; at?: string } }[];
104
+ cards?: { type: string; id: string; data: unknown; title?: string; resolution?: { kind: "action"; action: string; payload?: unknown; at?: string } | { kind: "submit"; data: unknown; at?: string } | { kind: "dismissed"; at?: string } | { kind: "expired"; reason?: string; at?: string } }[];
105
105
  /** Optional type→tag overrides/additions (merged over the built-ins). Property: `el.types`. Typed as a plain string map (not the `CardTagMap` alias) so the generated React wrapper inlines it instead of emitting an unresolved named type. */
106
106
  types?: Record<string, string>;
107
107
  /** Optional CardPolicy handling child events. Property: `el.policy`. */
108
- policy?: { onSubmit?: (cardId: string, data: unknown) => void; onAction?: (cardId: string, action: string, payload?: unknown) => void; onSendPrompt?: (text: string, opts: { mode: "compose" | "send"; context?: unknown; }) => void; onOpen?: (url: string, target: "tab" | "artifact") => void; onState?: (cardId: string, patch: unknown) => void; onDismiss?: (cardId: string) => void; onError?: (cardId: string, message: string) => void; maxSendPromptMode?: "compose" | "send" };
108
+ policy?: { onSubmit?: (cardId: string, data: unknown) => void; onAction?: (cardId: string, action: string, payload?: unknown) => void; onSendPrompt?: (text: string, opts: { mode: "compose" | "send"; context?: unknown; }) => void; onOpen?: (url: string, target: "tab" | "artifact") => void; onState?: (cardId: string, patch: unknown) => void; onDismiss?: (cardId: string) => void; onReopen?: (cardId: string) => void; onError?: (cardId: string, message: string) => void; maxSendPromptMode?: "compose" | "send" };
109
109
  }
110
110
 
111
111
  export interface KaiChainOfThoughtElement extends HTMLElement {
@@ -119,7 +119,7 @@ export interface KaiChatElement extends HTMLElement {
119
119
  /** Color mode (`auto` follows prefers-color-scheme). */
120
120
  theme?: 'light' | 'dark' | 'auto';
121
121
  /** The full message thread to render, newest last. Each entry carries its role, content, and optional reasoning/tools/attachments/actions. Set as a JS property (`el.messages = [...]`). */
122
- messages: { id: string; role: "user" | "assistant"; content: string; reasoning?: undefined | { text: string; label?: undefined | string }; tools?: undefined | { type: string; state: "input-streaming" | "input-available" | "output-available" | "output-error"; input?: undefined | Record<string, unknown>; output?: undefined | Record<string, unknown>; toolCallId?: undefined | string; errorText?: undefined | string }[]; attachments?: undefined | { id: string; type: "file" | "source-document"; filename?: undefined | string; mediaType?: undefined | string; url?: undefined | string; title?: undefined | string }[]; actions?: undefined | ("copy" | "like" | "dislike" | "regenerate" | "edit" | { id: string; label: string; icon?: undefined | string; tooltip?: undefined | string })[]; avatar?: undefined | { src?: undefined | string; fallback?: undefined | string; alt?: undefined | string } }[];
122
+ messages: { id: string; role: "user" | "assistant"; content: string; reasoning?: undefined | { text: string; label?: undefined | string }; tools?: undefined | { type: string; state: "input-streaming" | "input-available" | "output-available" | "output-error"; input?: undefined | Record<string, unknown>; output?: undefined | Record<string, unknown>; toolCallId?: undefined | string; errorText?: undefined | string }[]; attachments?: undefined | { id: string; type: "file" | "source-document"; filename?: undefined | string; mediaType?: undefined | string; url?: undefined | string; title?: undefined | string }[]; actions?: undefined | ("copy" | "like" | "dislike" | "regenerate" | "edit" | { id: string; label: string; icon?: undefined | string; tooltip?: undefined | string })[]; avatar?: undefined | { src?: undefined | string; fallback?: undefined | string; alt?: undefined | string }; feedback?: undefined | "like" | "dislike" }[];
123
123
  /** Controlled value of the input. When set, the host owns the input text and must update it on `kai-value-change`; leave unset for uncontrolled behavior. */
124
124
  value?: string;
125
125
  /** Placeholder text shown in the empty input. */
@@ -207,6 +207,25 @@ export interface KaiCodeBlockElement extends HTMLElement {
207
207
  proseSize?: "xs" | "sm" | "base" | "lg";
208
208
  }
209
209
 
210
+ export interface KaiCompareElement extends HTMLElement {
211
+ /** Color mode (`auto` follows prefers-color-scheme). */
212
+ theme?: 'light' | 'dark' | 'auto';
213
+ /** The compare definition (prompt + the two candidates). Set as a JS PROPERTY: `el.data = { prompt, candidates: [A, B], collapse? }`. Import `ResponseCompareData` from `@kitn.ai/ui` for the full shape. */
214
+ data?: Record<string, unknown>;
215
+ /** Stable id correlating every emitted event. Attribute: `compare-id`. */
216
+ compareId?: string;
217
+ /** Re-hydrate / control the user's pick. Set as a JS PROPERTY: `el.selection = { chosenId, rejectedIds }`. Renders the collapsed winner. */
218
+ selection?: Record<string, unknown>;
219
+ /** Layout: `'auto'` (default — columns when wide, tabs when narrow, by CONTAINER width) | `'columns'` (side-by-side) | `'tabs'` (pills to switch). Attribute: `layout`. */
220
+ layout?: "auto" | "columns" | "tabs";
221
+ /** Prose/text size for the rendered candidates. Attribute: `prose-size`. */
222
+ proseSize?: "xs" | "sm" | "base" | "lg";
223
+ /** Shiki theme for code blocks in the candidates. Attribute: `code-theme`. */
224
+ codeTheme?: string;
225
+ /** Whether code blocks are syntax-highlighted. Attribute: `code-highlight`. */
226
+ codeHighlight?: boolean;
227
+ }
228
+
210
229
  export interface KaiConfirmElement extends HTMLElement {
211
230
  /** Color mode (`auto` follows prefers-color-scheme). */
212
231
  theme?: 'light' | 'dark' | 'auto';
@@ -368,7 +387,7 @@ export interface KaiMessageElement extends HTMLElement {
368
387
  /** Color mode (`auto` follows prefers-color-scheme). */
369
388
  theme?: 'light' | 'dark' | 'auto';
370
389
  /** The full message object. Set as a JS property. */
371
- message?: { id: string; role: "user" | "assistant"; content: string; reasoning?: { text: string; label?: string }; tools?: { type: string; state: "input-streaming" | "input-available" | "output-available" | "output-error"; input?: Record<string, unknown>; output?: Record<string, unknown>; toolCallId?: string; errorText?: string }[]; attachments?: { id: string; type: "file" | "source-document"; filename?: string; mediaType?: string; url?: string; title?: string }[]; actions?: ("copy" | "like" | "dislike" | "regenerate" | "edit" | { id: string; label: string; icon?: string; tooltip?: string })[]; avatar?: { src?: string; fallback?: string; alt?: string } };
390
+ message?: { id: string; role: "user" | "assistant"; content: string; reasoning?: { text: string; label?: string }; tools?: { type: string; state: "input-streaming" | "input-available" | "output-available" | "output-error"; input?: Record<string, unknown>; output?: Record<string, unknown>; toolCallId?: string; errorText?: string }[]; attachments?: { id: string; type: "file" | "source-document"; filename?: string; mediaType?: string; url?: string; title?: string }[]; actions?: ("copy" | "like" | "dislike" | "regenerate" | "edit" | { id: string; label: string; icon?: string; tooltip?: string })[]; avatar?: { src?: string; fallback?: string; alt?: string }; feedback?: "like" | "dislike" };
372
391
  /** Convenience for simple cases when not passing a `message` object. */
373
392
  role?: "user" | "assistant";
374
393
  /** Convenience content (used when `message` is not set). */
@@ -623,6 +642,21 @@ export interface KaiThinkingBarElement extends HTMLElement {
623
642
  stopLabel?: string;
624
643
  }
625
644
 
645
+ export interface KaiToastRegionElement extends HTMLElement {
646
+ /** Color mode (`auto` follows prefers-color-scheme). */
647
+ theme?: 'light' | 'dark' | 'auto';
648
+ /** The toasts to render. Newest is shown on top. Set as a JS property (array); pass a new array reference to update. */
649
+ toasts: { id: string; message: string; variant?: undefined | "neutral" | "success"; action?: undefined | { label: string; onAction: () => void | false }; duration?: undefined | number; dismissible?: undefined | boolean; target?: undefined | HTMLElement }[];
650
+ /** Stack anchor: `'top-center'` (default), `'top-right'`, `'bottom-center'`, … */
651
+ position?: "top-center" | "top-right" | "top-left" | "bottom-center" | "bottom-right" | "bottom-left";
652
+ /** Max simultaneously-visible toasts; the rest queue. Defaults to `3`. */
653
+ max?: number;
654
+ /** Stacking: 'expanded' (default, full column) | 'collapsed' (Sonner-style pile that expands on hover/focus). Attribute: stack. */
655
+ stack?: "expanded" | "collapsed";
656
+ /** Container element to anchor this region to (JS property). Set by the store for a scoped region; unset = the global viewport region. */
657
+ target?: HTMLElement;
658
+ }
659
+
626
660
  export interface KaiToolElement extends HTMLElement {
627
661
  /** Color mode (`auto` follows prefers-color-scheme). */
628
662
  theme?: 'light' | 'dark' | 'auto';
@@ -651,7 +685,7 @@ export interface KaiWorkspaceElement extends HTMLElement {
651
685
  /** Id of the open conversation, highlighted in the sidebar. */
652
686
  activeId?: string;
653
687
  /** The active conversation's message thread, newest last. Set as a JS property. */
654
- messages: { id: string; role: "user" | "assistant"; content: string; reasoning?: undefined | { text: string; label?: undefined | string }; tools?: undefined | { type: string; state: "input-streaming" | "input-available" | "output-available" | "output-error"; input?: undefined | Record<string, unknown>; output?: undefined | Record<string, unknown>; toolCallId?: undefined | string; errorText?: undefined | string }[]; attachments?: undefined | { id: string; type: "file" | "source-document"; filename?: undefined | string; mediaType?: undefined | string; url?: undefined | string; title?: undefined | string }[]; actions?: undefined | ("copy" | "like" | "dislike" | "regenerate" | "edit" | { id: string; label: string; icon?: undefined | string; tooltip?: undefined | string })[]; avatar?: undefined | { src?: undefined | string; fallback?: undefined | string; alt?: undefined | string } }[];
688
+ messages: { id: string; role: "user" | "assistant"; content: string; reasoning?: undefined | { text: string; label?: undefined | string }; tools?: undefined | { type: string; state: "input-streaming" | "input-available" | "output-available" | "output-error"; input?: undefined | Record<string, unknown>; output?: undefined | Record<string, unknown>; toolCallId?: undefined | string; errorText?: undefined | string }[]; attachments?: undefined | { id: string; type: "file" | "source-document"; filename?: undefined | string; mediaType?: undefined | string; url?: undefined | string; title?: undefined | string }[]; actions?: undefined | ("copy" | "like" | "dislike" | "regenerate" | "edit" | { id: string; label: string; icon?: undefined | string; tooltip?: undefined | string })[]; avatar?: undefined | { src?: undefined | string; fallback?: undefined | string; alt?: undefined | string }; feedback?: undefined | "like" | "dislike" }[];
655
689
  value?: string;
656
690
  placeholder?: string;
657
691
  loading?: boolean;
@@ -693,6 +727,7 @@ declare global {
693
727
  'kai-checkpoint': KaiCheckpointElement;
694
728
  'kai-choice': KaiChoiceElement;
695
729
  'kai-code-block': KaiCodeBlockElement;
730
+ 'kai-compare': KaiCompareElement;
696
731
  'kai-confirm': KaiConfirmElement;
697
732
  'kai-context': KaiContextElement;
698
733
  'kai-conversations': KaiConversationsElement;
@@ -725,6 +760,7 @@ declare global {
725
760
  'kai-tasks': KaiTasksElement;
726
761
  'kai-text-shimmer': KaiTextShimmerElement;
727
762
  'kai-thinking-bar': KaiThinkingBarElement;
763
+ 'kai-toast-region': KaiToastRegionElement;
728
764
  'kai-tool': KaiToolElement;
729
765
  'kai-voice-input': KaiVoiceInputElement;
730
766
  'kai-workspace': KaiWorkspaceElement;
package/dist/index.d.ts CHANGED
@@ -12,12 +12,18 @@ export { configureCodeHighlighting, isCodeHighlightingEnabled } from './primitiv
12
12
  export type { CodeHighlightingOptions } from './primitives/highlighter';
13
13
  export { configurePdfPreview, isPdfPreviewEnabled } from './primitives/pdf-preview';
14
14
  export type { PdfPreviewOptions } from './primitives/pdf-preview';
15
+ export { toast, configureToasts, ensureMounted as ensureToastRegion, getToasts } from './primitives/toast-store';
16
+ export type { ToastItem, ToastVariant, ToastAction, ToastOptions, ToastHandle, ToastFn, ToastConfig, } from './primitives/toast-store';
17
+ export { Toast, ToastRegion } from './components/toast';
18
+ export type { ToastRegionProps, ToastDismissReason, ToastPosition, } from './components/toast';
15
19
  export { CARD_CONTRACT_VERSION } from './primitives/card-contract';
16
20
  export type { CardEnvelope, CardContext, CardEvent, CardEventKind, CardResolution, CardHost, CardPolicy, } from './primitives/card-contract';
17
21
  export { applyResolution, resolutionFromEvent } from './primitives/card-resolution';
18
22
  export { CardProvider, useCardHost } from './primitives/card-host';
19
23
  export type { CardProviderProps } from './primitives/card-host';
20
24
  export { CARD_EVENT_NAME, emitCardEvent, routeCardEvent, listenForCardEvents } from './primitives/card-routing';
25
+ export { dismissRecovery, defaultIsReopenable } from './primitives/card-recovery';
26
+ export type { RecoveryToast, ReopenEnv, DismissRecoveryOptions, } from './primitives/card-recovery';
21
27
  export { validateAgainstSchema } from './primitives/card-validate';
22
28
  export type { JsonSchema, ValidationResult } from './primitives/card-validate';
23
29
  export { mountRemoteCard } from './remote/host-embed';
@@ -30,6 +36,8 @@ export { BUILTIN_CARD_TAGS, BUILTIN_CARD_COMPONENTS, mergeCardTags, mergeCardCom
30
36
  export type { CardComponent, CardComponentMap, CardTagMap } from './primitives/card-registry';
31
37
  export { Card } from './components/card';
32
38
  export type { CardProps } from './components/card';
39
+ export { DismissedStub, stubIntent } from './components/dismissed-stub';
40
+ export type { DismissedStubProps, DismissedCardType } from './components/dismissed-stub';
33
41
  export { Form, validateForm, buildResult, widgetFor, orderedKeys, coerceValue } from './components/form';
34
42
  export type { FormProps, FormField, FormDefinition, FormCardEnvelope, FormValidation, WidgetKind, } from './components/form';
35
43
  export { ConfirmCard, CONFIRM_CARD_TYPE, buttonVariantForStyle, normalizeActions, defaultActionId, } from './components/confirm-card';
@@ -70,6 +78,10 @@ export type { ArtifactProps, ArtifactFile, ArtifactTab } from './components/arti
70
78
  export { ChatContainer, ChatContainerRoot, ChatContainerContent, ChatContainerScrollAnchor, useChatContainer, } from './components/chat-container';
71
79
  export { Message, MessageAvatar, MessageContent, MessageActions, MessageAction, MessageCopyButton } from './components/message';
72
80
  export type { MessageCopyButtonProps } from './components/message';
81
+ export { ResponseCompare, useResolved } from './components/response-compare';
82
+ export type { ResponseCompareProps, CompareLayout, ResolvedController } from './components/response-compare';
83
+ export { normalizeCandidates, buildSelection, isAnyStreaming, } from './components/response-compare';
84
+ export type { CompareCandidate, ComparePair, CompareCollapse, ResponseCompareData, CompareSelection, } from './components/response-compare';
73
85
  export { MessageSkills } from './components/message-skills';
74
86
  export type { Skill as MessageSkill } from './components/message-skills';
75
87
  export { PromptInput, PromptInputTextarea, PromptInputActions, PromptInputAction, usePromptInput, } from './components/prompt-input';