@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
package/README.md CHANGED
@@ -11,7 +11,7 @@ It can be consumed two ways:
11
11
 
12
12
  - **~50 composable components** across three layers: headless primitives → accessible UI primitives (built in-house, WCAG 2.1 AA — no third-party UI dependency) → AI feature components.
13
13
  - **Shadow-DOM web components** — zero CSS conflicts in any host. The host's styles can't leak in; the kit's Tailwind can't leak out.
14
- - **Lightweight by design** — a markdown-only `<kai-chat>` is **~110 KB gzip** (one file). Syntax highlighting (Shiki) is loaded **on demand, per-language, with no WASM** and never loads at all if you don't render code.
14
+ - **Load it your way** — register every element in one import, cherry-pick per-element with a bundler, or drop in a CDN autoloader that loads each on demand. Syntax highlighting loads lazily, per language, only when you render code.
15
15
  - **Tailwind v4** design tokens — rebrand by overriding `--color-*` custom properties.
16
16
 
17
17
  ## Install
@@ -43,6 +43,10 @@ npm run build # emits dist/kitn-chat.es.js
43
43
  <script type="module">
44
44
  import '@kitn.ai/ui/elements';
45
45
 
46
+ // Registration is async (SSR-safe) — wait for the element to be defined
47
+ // before setting properties, or the upgrade clobbers them.
48
+ await customElements.whenDefined('kai-chat');
49
+
46
50
  const chat = document.querySelector('kai-chat');
47
51
 
48
52
  // Rich data is set as JS properties (not HTML attributes)
@@ -50,8 +54,8 @@ npm run build # emits dist/kitn-chat.es.js
50
54
  { id: '1', role: 'assistant', content: 'Hello! How can I help?' },
51
55
  ];
52
56
 
53
- // Events are CustomEvents dispatched on the element (they do not bubble)
54
- chat.addEventListener('submit', (e) => {
57
+ // Events are non-bubbling kai-* CustomEvents dispatched on the element
58
+ chat.addEventListener('kai-submit', (e) => {
55
59
  console.log('user sent:', e.detail.value);
56
60
  });
57
61
  </script>
@@ -73,7 +77,7 @@ The element bundle is a self-contained ES module — load it directly from [jsDe
73
77
  <kai-chat></kai-chat>
74
78
  ```
75
79
 
76
- The URLs above track the **latest** release — handy for trying things out. **For production, pin an exact version** (e.g. `@kitn.ai/ui@0.4.0/dist/kitn-chat.es.js`): pinned URLs are immutable and cached far more aggressively, and — since this package is pre-1.0 — pinning shields you from breaking changes in a future minor release. SolidJS and the kit's CSS are bundled in, and the lazy code-highlighting chunks load from the same CDN on demand. To override design tokens, also include `theme.css`:
80
+ The URLs above track the **latest** release — handy for trying things out. **For production, pin an exact version** (e.g. `@kitn.ai/ui@0.16.0/dist/kitn-chat.es.js`): pinned URLs are immutable and cached far more aggressively, and — since this package is pre-1.0 — pinning shields you from breaking changes in a future minor release. SolidJS and the kit's CSS are bundled in, and the lazy code-highlighting chunks load from the same CDN on demand. To override design tokens, also include `theme.css`:
77
81
 
78
82
  ```html
79
83
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@kitn.ai/ui/theme.css">
@@ -109,7 +113,7 @@ function App() {
109
113
  }
110
114
  ```
111
115
 
112
- The SolidJS entry (`.`) is the kit's raw source (`src/index.ts`) — your bundler compiles it, so it tree-shakes to just what you import.
116
+ The SolidJS entry (`.`) ships compiled — your bundler tree-shakes it to just the components you import.
113
117
 
114
118
  ## Integrations
115
119
 
@@ -127,10 +131,13 @@ The components are deliberately **transport-agnostic**: `<kai-chat>` just render
127
131
  <script type="module">
128
132
  import '@kitn.ai/ui/elements';
129
133
 
134
+ // Registration is async (SSR-safe) — wait for the element before using it.
135
+ await customElements.whenDefined('kai-chat');
136
+
130
137
  const chat = document.getElementById('chat');
131
138
  chat.messages = [];
132
139
 
133
- chat.addEventListener('submit', async (e) => {
140
+ chat.addEventListener('kai-submit', async (e) => {
134
141
  const text = e.detail.value.trim();
135
142
  if (!text) return;
136
143
 
@@ -392,12 +399,20 @@ cd examples/vue && npm install && npm run dev
392
399
  - **[docs/web-components.md](docs/web-components.md)** — full element API: every property, event, and the `ChatMessage` schema.
393
400
  - **[llms.txt](llms.txt)** / **[llms-full.txt](llms-full.txt)** — dense machine-readable references for AI coding agents.
394
401
 
395
- ## Bundle size
402
+ ## Loading
403
+
404
+ Three ways to load the elements — register all (the simple default), cherry-pick per-element, or a CDN autoloader:
405
+
406
+ | How you load | What it does |
407
+ |---|---|
408
+ | `import '@kitn.ai/ui/elements'` | registers every element — the simple default |
409
+ | `import '@kitn.ai/ui/elements/chat'` | one element, bundler tree-shakes |
410
+ | `import '@kitn.ai/ui/autoloader'` (opt-in **DOM autoloader**) | loads each element's module **on demand** as `<kai-*>` appears |
396
411
 
397
- | Scenario | Loaded |
398
- |---|--:|
399
- | `<kai-chat>`, markdown only (no code blocks) | **~110 KB gzip** (~413 KB raw), one file |
400
- | + a code block | adds Shiki core + JS engine + that language + theme, lazily |
401
- | Highlighting disabled | Shiki never loads |
412
+ The autoloader watches the DOM (initial scan + `MutationObserver`) and dynamically imports only the
413
+ elements actually present — so a page with just `<kai-chat>` never downloads the others. It's additive:
414
+ the register-all bundle stays the default. (Direct per-element imports and the autoloader are client-side;
415
+ SSR apps use the register-all `@kitn.ai/ui/elements` or render client-only.)
402
416
 
403
- The build is ES-module onlya UMD/IIFE build can't code-split and would inline every lazy chunk into one multi-MB file, so it's intentionally omitted.
417
+ Code highlighting (Shiki) is always lazyloaded per-language on first code block, with no WASM, and never
418
+ at all if you don't render code. The build is ES-module only (a UMD/IIFE build can't code-split).
@@ -1,4 +1,5 @@
1
1
  import { AttachmentData } from './attachments';
2
+ import { MessageActionDetail } from '../primitives/message-feedback';
2
3
  import { SlashCommandItem } from './slash-command';
3
4
  import { ChatMessage } from '../elements/chat-types';
4
5
  import { ProseSize } from '../primitives/chat-config';
@@ -82,10 +83,7 @@ export interface ChatThreadProps {
82
83
  }) => void;
83
84
  onSuggestionClick?: (value: string) => void;
84
85
  onModelChange?: (modelId: string) => void;
85
- onMessageAction?: (detail: {
86
- messageId: string;
87
- action: string;
88
- }) => void;
86
+ onMessageAction?: (detail: MessageActionDetail) => void;
89
87
  onSearch?: () => void;
90
88
  onVoice?: () => void;
91
89
  onSlashSelect?: (command: SlashCommandItem) => void;
@@ -24,6 +24,7 @@ export interface ChoiceCardData {
24
24
  options: ChoiceOption[];
25
25
  allowOther?: ChoiceAllowOther;
26
26
  submitLabel?: string;
27
+ dismissible?: boolean;
27
28
  }
28
29
  export type ChoiceCardEnvelope = CardEnvelope<'choice', ChoiceCardData>;
29
30
  export declare const CHOICE_CARD_TYPE: "choice";
@@ -0,0 +1,22 @@
1
+ import { JSX } from 'solid-js';
2
+ /** The card types that render a dismissed stub, mapped to their intent verb. */
3
+ export type DismissedCardType = 'confirm' | 'choice' | 'form' | 'tasks';
4
+ /** Map a card `type` to its dismissed-stub intent label ("Proposed:", "Choose:",
5
+ * "Form:", "Tasks:"). Falls back to a capitalized type for unknown card types. */
6
+ export declare function stubIntent(type: string): string;
7
+ export interface DismissedStubProps {
8
+ /** The card type, used to derive the intent label ("Proposed:" etc.). */
9
+ type: string;
10
+ /** The card's title/heading; shown after the intent label. Falls back gracefully. */
11
+ title?: string;
12
+ /** Re-open handler. The owning card emits `{ kind:'reopen', cardId }`. */
13
+ onReopen: () => void;
14
+ /** The Reopen button label. Default 'Reopen'. */
15
+ reopenLabel?: string;
16
+ class?: string;
17
+ }
18
+ /**
19
+ * `DismissedStub` — the compact stub a card collapses to after it's been dismissed.
20
+ * Group-labelled for a11y; the Reopen affordance is a ghost button.
21
+ */
22
+ export declare function DismissedStub(props: DismissedStubProps): JSX.Element;
@@ -1,5 +1,7 @@
1
1
  import { JSX } from 'solid-js';
2
- import { ChatMessageAction, CustomAction } from '../elements/chat-types';
2
+ import { ChatMessageAction, CustomAction, FeedbackVote } from '../elements/chat-types';
3
+ import { ToolPart } from './tool';
4
+ import { AttachmentData } from './attachments';
3
5
  export interface MessageProps extends JSX.HTMLAttributes<HTMLDivElement> {
4
6
  children: JSX.Element;
5
7
  }
@@ -28,6 +30,13 @@ export interface MessageActionBarProps {
28
30
  reveal?: 'always' | 'hover';
29
31
  /** Fired with the built-in name or the custom action id when a button is clicked. */
30
32
  onAction: (id: string) => void;
33
+ /** The active feedback vote. When `'like'`/`'dislike'` is set, that button is
34
+ * marked pressed (filled) and the OTHER vote button animates out. `undefined`
35
+ * shows both. Pure/prop-driven so the bar survives re-renders. */
36
+ activeFeedback?: FeedbackVote;
37
+ /** When true, the `copy` button shows its emerald check icon instead of the
38
+ * copy glyph (cleared by the owner after ~2s). */
39
+ copied?: boolean;
31
40
  class?: string;
32
41
  }
33
42
  /**
@@ -36,8 +45,56 @@ export interface MessageActionBarProps {
36
45
  * descriptors use their `label` plus `actionIcon(icon)` (label-only when the
37
46
  * icon is unknown or absent). `reveal="hover"` makes the bar fade in on the
38
47
  * parent `.group`'s hover.
48
+ *
49
+ * Pure/prop-driven: feedback (`activeFeedback`) and copy (`copied`) state are
50
+ * owned by the parent facade and passed in — the bar holds no internal signals,
51
+ * so it survives the new-array-per-chunk re-renders of a streaming thread. With
52
+ * a vote active, the chosen `like`/`dislike` button is marked `aria-pressed` +
53
+ * filled and the other vote button collapses its width (sliding the active thumb
54
+ * into its place) via a 0fr↔1fr grid transition. The
55
+ * `copy` button swaps to an emerald check while `copied`.
39
56
  */
40
57
  declare function MessageActionBar(props: MessageActionBarProps): JSX.Element;
58
+ export interface MessageBodyProps {
59
+ /** The message text/markdown. */
60
+ content: string;
61
+ /** Optional collapsible reasoning block, rendered above the content. */
62
+ reasoning?: {
63
+ text: string;
64
+ label?: string;
65
+ };
66
+ /** Tool-call parts, rendered above the content. */
67
+ tools?: ToolPart[];
68
+ /** Inline attachment previews, rendered above the content. */
69
+ attachments?: AttachmentData[];
70
+ /** Whether this is a user message (right-aligned bubble) vs an assistant
71
+ * message (full-width transparent). */
72
+ isUser: boolean;
73
+ /** Whether the content renders as markdown. */
74
+ markdown: boolean;
75
+ /** Action-bar entries — built-in names and/or custom descriptors. When empty
76
+ * the bar is not rendered. */
77
+ actions?: (ChatMessageAction | CustomAction)[];
78
+ /** `'always'` (default) keeps the bar visible; `'hover'` reveals it on parent
79
+ * `.group` hover. */
80
+ actionsReveal?: 'always' | 'hover';
81
+ /** Fired with the built-in name or custom id when an action is clicked. */
82
+ onAction?: (id: string) => void;
83
+ /** The currently-active feedback vote, so the bar can mark like/dislike and
84
+ * hide the other. */
85
+ activeFeedback?: FeedbackVote;
86
+ /** When true, the copy button shows its "copied" check icon. */
87
+ copied?: boolean;
88
+ }
89
+ /**
90
+ * The shared message body: an optional reasoning block, tool calls, inline
91
+ * attachments, the content bubble, and the action bar — in that order. This is
92
+ * the single source of truth for how a message renders, consumed by `ChatThread`
93
+ * (the `<For>` over `messages`), the standalone `<kai-message>` facade, and (in
94
+ * future) `kai-compare` for each candidate. Pure/prop-driven: all interaction
95
+ * state (copied, feedback vote) is owned above and passed in.
96
+ */
97
+ declare function MessageBody(props: MessageBodyProps): JSX.Element;
41
98
  export interface MessageActionProps {
42
99
  tooltip: string;
43
100
  children: JSX.Element;
@@ -51,4 +108,4 @@ export interface MessageCopyButtonProps {
51
108
  class?: string;
52
109
  }
53
110
  declare function MessageCopyButton(props: MessageCopyButtonProps): JSX.Element;
54
- export { Message, MessageAvatar, MessageContent, MessageActions, MessageActionBar, MessageAction, MessageCopyButton };
111
+ export { Message, MessageAvatar, MessageContent, MessageActions, MessageActionBar, MessageBody, MessageAction, MessageCopyButton };
@@ -0,0 +1,66 @@
1
+ import { ToolPart } from './tool';
2
+ import { AttachmentData } from './attachments';
3
+ /** One assistant response in a comparison. Rendered identically to an assistant
4
+ * message (reasoning + tools + attachments + markdown content) via `MessageBody`. */
5
+ export interface CompareCandidate {
6
+ /** Stable id, unique within the pair; echoed back in the selection. */
7
+ id: string;
8
+ /** The response text/markdown. */
9
+ content: string;
10
+ /** Optional collapsible reasoning block. */
11
+ reasoning?: {
12
+ text: string;
13
+ label?: string;
14
+ };
15
+ /** Tool-call parts rendered above the content. */
16
+ tools?: ToolPart[];
17
+ /** Inline attachment previews rendered above the content. */
18
+ attachments?: AttachmentData[];
19
+ /** Optional short column label (e.g. "A" / "B" / "Concise"). */
20
+ label?: string;
21
+ /** Optional model name shown as a sub-label. */
22
+ model?: string;
23
+ /** When true this candidate is still streaming — its pick control is disabled
24
+ * and a per-column shimmer shows until it (and its sibling) settle. */
25
+ streaming?: boolean;
26
+ }
27
+ /** The two-candidate tuple. Enforced at the type level; validated at runtime by
28
+ * `normalizeCandidates`. */
29
+ export type ComparePair = [CompareCandidate, CompareCandidate];
30
+ /** How the card collapses once the user picks. `'winner'` (default) shows just the
31
+ * chosen candidate's body; `'none'` keeps both columns but marks the choice. */
32
+ export type CompareCollapse = 'winner' | 'none';
33
+ /** The compare definition (set as the `data` JS property on `<kai-compare>`). */
34
+ export interface ResponseCompareData {
35
+ /** Optional prompt/question shown above the two columns. */
36
+ prompt?: string;
37
+ /** Exactly two candidates: [A, B]. */
38
+ candidates: ComparePair;
39
+ /** Collapse behaviour after a pick. Default `'winner'`. */
40
+ collapse?: CompareCollapse;
41
+ }
42
+ /** Emitted (and re-hydratable) when the user picks. The consumer pairs
43
+ * `(prompt, chosenId, rejectedIds)` for preference capture / RLHF. */
44
+ export interface CompareSelection {
45
+ /** The id of the chosen candidate. */
46
+ chosenId: string;
47
+ /** The id(s) of the rejected candidate(s) — for a pair, the other one. */
48
+ rejectedIds: string[];
49
+ /** Epoch ms when the pick was made. */
50
+ at?: number;
51
+ }
52
+ /**
53
+ * Validate + normalize the candidate list. A compare requires EXACTLY two
54
+ * candidates with unique, non-empty string ids. Returns the usable pair, or an
55
+ * error message when the definition is unusable (rendered as an inline error /
56
+ * emitted as a `kai-error`). Modeled on `normalizeOptions`.
57
+ */
58
+ export declare function normalizeCandidates(candidates: unknown): {
59
+ candidates: ComparePair | null;
60
+ error?: string;
61
+ };
62
+ /** Build the selection payload for choosing `chosenId` out of the pair (the other
63
+ * candidate is the rejected one). Stamps `at` with the current time. */
64
+ export declare function buildSelection(pair: ComparePair, chosenId: string): CompareSelection;
65
+ /** Whether any candidate in the pair is still streaming (pick stays disabled). */
66
+ export declare function isAnyStreaming(pair: ComparePair | null): boolean;
@@ -0,0 +1,51 @@
1
+ import { JSX, Accessor } from 'solid-js';
2
+ import { CompareSelection, ResponseCompareData } from './response-compare-types';
3
+ export type { CompareCandidate, ComparePair, CompareCollapse, ResponseCompareData, CompareSelection, } from './response-compare-types';
4
+ export { normalizeCandidates, buildSelection, isAnyStreaming } from './response-compare-types';
5
+ export type CompareLayout = 'auto' | 'columns' | 'tabs';
6
+ export interface ResolvedController<T> {
7
+ value: Accessor<T | undefined>;
8
+ isResolved: Accessor<boolean>;
9
+ isOptimistic: Accessor<boolean>;
10
+ setLocal: (v: T) => void;
11
+ }
12
+ export declare function useResolved<T>(opts: {
13
+ prop: Accessor<T | undefined>;
14
+ data: Accessor<unknown>;
15
+ }): ResolvedController<T>;
16
+ export interface ResponseCompareProps {
17
+ /** The compare definition (prompt + the two candidates). */
18
+ data?: ResponseCompareData;
19
+ /** Stable id correlating every emitted event. */
20
+ compareId?: string;
21
+ /** Re-hydrate / control the selection. Renders the collapsed winner. Set as a
22
+ * JS property: `el.selection = { chosenId, rejectedIds }`. */
23
+ selection?: CompareSelection;
24
+ /** Layout. `'columns'` = side-by-side; `'tabs'` = one candidate at a time with
25
+ * pills to switch; `'auto'` (default) uses a CONTAINER query — columns when the
26
+ * component is ≥640px wide, tabs when narrower (e.g. on a phone). */
27
+ layout?: CompareLayout;
28
+ class?: string;
29
+ /** Fired when the user commits a pick. */
30
+ onSelect?: (sel: CompareSelection) => void;
31
+ /** Fired once both candidates have settled (stopped streaming) and a valid
32
+ * definition is shown. */
33
+ onReady?: () => void;
34
+ /** Fired for an unusable definition (inline error state). */
35
+ onError?: (message: string) => void;
36
+ }
37
+ /**
38
+ * `ResponseCompare` — a dual-response comparison. Two assistant candidates for the
39
+ * same prompt render side-by-side (or as tabs), each via `MessageBody` so a
40
+ * candidate reads exactly like an assistant message (reasoning + tools +
41
+ * attachments + markdown). The pick is a COMMIT, not a Submit: clicking "Pick this"
42
+ * (or Enter on the focused column) computes `{ chosenId, rejectedIds:[other], at }`,
43
+ * optimistically collapses to the chosen candidate's body, and calls `onSelect` for
44
+ * the consumer to send a `(prompt, chosen, rejected)` preference pair. Single-shot.
45
+ *
46
+ * While EITHER candidate is `streaming`, both pick controls are disabled and the
47
+ * streaming column shows a `TextShimmer`; `onReady` fires once both settle. The two
48
+ * columns are a WAI-ARIA radiogroup with roving tabindex (Arrow keys move A↔B,
49
+ * Enter/Space picks). Emits `onError` for a malformed definition.
50
+ */
51
+ export declare function ResponseCompare(props: ResponseCompareProps): JSX.Element;
@@ -16,6 +16,7 @@ export interface TasksCardData {
16
16
  allowEmpty?: boolean;
17
17
  min?: number;
18
18
  max?: number;
19
+ dismissible?: boolean;
19
20
  }
20
21
  export interface TasksCardResult {
21
22
  selected: string[];
@@ -0,0 +1,48 @@
1
+ import { ToastItem, ToastVariant } from '../primitives/toast-store';
2
+ export type { ToastItem, ToastVariant };
3
+ /** Why a toast went away — surfaced to `onDismiss` (and the facade event). */
4
+ export type ToastDismissReason = 'timeout' | 'close' | 'action';
5
+ export type ToastPosition = 'top-center' | 'top-right' | 'top-left' | 'bottom-center' | 'bottom-right' | 'bottom-left';
6
+ export interface ToastRegionProps {
7
+ /** The toasts to render. Newest is shown on top. Set as a JS property on the
8
+ * element; mutate by passing a new array reference. */
9
+ toasts: ToastItem[];
10
+ /** Where the stack anchors. Defaults to `'top-center'`. */
11
+ position?: ToastPosition;
12
+ /** Max simultaneously-visible toasts; the rest queue and promote as slots
13
+ * free up. Defaults to `3`. */
14
+ max?: number;
15
+ /** Stacking: 'expanded' (default, full column) | 'collapsed' (Sonner-style
16
+ * pile that expands on hover/focus). Attribute: stack. */
17
+ stack?: 'expanded' | 'collapsed';
18
+ /** When set, this region renders only the toasts scoped to that element and
19
+ * anchors over its bounds (top-center), following it on scroll/resize. Unset =
20
+ * the global, viewport-anchored region. */
21
+ target?: HTMLElement;
22
+ /** Fired when a toast leaves, with the reason. */
23
+ onDismiss?: (id: string, reason: ToastDismissReason) => void;
24
+ /** Fired when a toast's action button is pressed. */
25
+ onAction?: (id: string, label: string) => void;
26
+ }
27
+ interface ToastProps {
28
+ item: ToastItem;
29
+ onDismiss: (reason: ToastDismissReason) => void;
30
+ onAction?: (label: string) => void;
31
+ /** Hold the auto-dismiss timer (the region sets this true while the whole stack
32
+ * is hovered/expanded, so peers don't dismiss out from under the cursor). */
33
+ paused?: boolean;
34
+ }
35
+ /**
36
+ * A single toast pill. Auto-dismisses after its (action-floored) duration, holds
37
+ * the timer while hovered (this pill) OR while `paused` (the whole stack is
38
+ * hovered), and animates in/out via `createPresence`. Pure + prop-driven — the
39
+ * parent `ToastRegion` owns the list + queue.
40
+ */
41
+ export declare function Toast(props: ToastProps): import("solid-js").JSX.Element;
42
+ /**
43
+ * Renders a stack of toasts at a viewport edge. Caps the visible count at `max`
44
+ * (newest on top); overflow waits in a queue and is promoted as visible toasts
45
+ * leave. `aria-live=polite` / `role=region` so screen readers announce new
46
+ * toasts without stealing focus.
47
+ */
48
+ export declare function ToastRegion(props: ToastRegionProps): import("solid-js").JSX.Element;
@@ -1,12 +1,16 @@
1
1
  import { Accessor } from 'solid-js';
2
2
  import { CardResolution } from '../primitives/card-contract';
3
- export interface ResolutionController {
4
- resolution: Accessor<CardResolution | undefined>;
3
+ export interface ResolutionController<R extends CardResolution = CardResolution> {
4
+ resolution: Accessor<R | undefined>;
5
5
  isResolved: Accessor<boolean>;
6
+ /** A finished resolution the user can't take back here (action | submit | expired). */
7
+ isTerminal: Accessor<boolean>;
8
+ /** A deferred resolution (`dismissed`) — set aside, still re-openable. */
9
+ isDeferred: Accessor<boolean>;
6
10
  isOptimistic: Accessor<boolean>;
7
- setLocal: (r: CardResolution) => void;
11
+ setLocal: (r: R) => void;
8
12
  }
9
- export declare function useCardResolution(opts: {
10
- prop: Accessor<CardResolution | undefined>;
13
+ export declare function useCardResolution<R extends CardResolution = CardResolution>(opts: {
14
+ prop: Accessor<R | undefined>;
11
15
  data: Accessor<unknown>;
12
- }): ResolutionController;
16
+ }): ResolutionController<R>;