@kognitivedev/ui 0.2.11

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 (258) hide show
  1. package/.turbo/turbo-build.log +2 -0
  2. package/CHANGELOG.md +19 -0
  3. package/README.md +264 -0
  4. package/dist/__tests__/context-provider.test.d.ts +1 -0
  5. package/dist/__tests__/context-provider.test.js +38 -0
  6. package/dist/__tests__/event-emitter.test.d.ts +1 -0
  7. package/dist/__tests__/event-emitter.test.js +62 -0
  8. package/dist/__tests__/keyboard-shortcuts.test.d.ts +1 -0
  9. package/dist/__tests__/keyboard-shortcuts.test.js +36 -0
  10. package/dist/__tests__/kognitive-runtime.test.d.ts +1 -0
  11. package/dist/__tests__/kognitive-runtime.test.js +58 -0
  12. package/dist/__tests__/kognitive-transport.test.d.ts +1 -0
  13. package/dist/__tests__/kognitive-transport.test.js +96 -0
  14. package/dist/__tests__/make-tool-ui.test.d.ts +1 -0
  15. package/dist/__tests__/make-tool-ui.test.js +50 -0
  16. package/dist/__tests__/message-helpers.test.d.ts +1 -0
  17. package/dist/__tests__/message-helpers.test.js +80 -0
  18. package/dist/__tests__/thread-manager.test.d.ts +1 -0
  19. package/dist/__tests__/thread-manager.test.js +84 -0
  20. package/dist/__tests__/tool-ui-registry.test.d.ts +1 -0
  21. package/dist/__tests__/tool-ui-registry.test.js +68 -0
  22. package/dist/__tests__/toolkit.test.d.ts +1 -0
  23. package/dist/__tests__/toolkit.test.js +33 -0
  24. package/dist/components/attachment-preview.d.ts +8 -0
  25. package/dist/components/attachment-preview.js +10 -0
  26. package/dist/components/composer.d.ts +6 -0
  27. package/dist/components/composer.js +10 -0
  28. package/dist/components/error-banner.d.ts +6 -0
  29. package/dist/components/error-banner.js +8 -0
  30. package/dist/components/markdown-content.d.ts +13 -0
  31. package/dist/components/markdown-content.js +31 -0
  32. package/dist/components/message.d.ts +7 -0
  33. package/dist/components/message.js +28 -0
  34. package/dist/components/status-indicator.d.ts +6 -0
  35. package/dist/components/status-indicator.js +16 -0
  36. package/dist/components/suggestions.d.ts +4 -0
  37. package/dist/components/suggestions.js +12 -0
  38. package/dist/components/thread-list.d.ts +4 -0
  39. package/dist/components/thread-list.js +20 -0
  40. package/dist/components/thread.d.ts +15 -0
  41. package/dist/components/thread.js +19 -0
  42. package/dist/components/tool-approval.d.ts +7 -0
  43. package/dist/components/tool-approval.js +12 -0
  44. package/dist/components/tool-invocation.d.ts +5 -0
  45. package/dist/components/tool-invocation.js +33 -0
  46. package/dist/context/kognitive-context.d.ts +2 -0
  47. package/dist/context/kognitive-context.js +6 -0
  48. package/dist/context/types.d.ts +44 -0
  49. package/dist/context/types.js +2 -0
  50. package/dist/context/use-kognitive.d.ts +1 -0
  51. package/dist/context/use-kognitive.js +7 -0
  52. package/dist/hooks/use-auto-scroll.d.ts +2 -0
  53. package/dist/hooks/use-auto-scroll.js +18 -0
  54. package/dist/hooks/use-copy-to-clipboard.d.ts +4 -0
  55. package/dist/hooks/use-copy-to-clipboard.js +13 -0
  56. package/dist/hooks/use-keyboard-shortcuts.d.ts +8 -0
  57. package/dist/hooks/use-keyboard-shortcuts.js +24 -0
  58. package/dist/hooks/use-kognitive-chat.d.ts +38 -0
  59. package/dist/hooks/use-kognitive-chat.js +35 -0
  60. package/dist/hooks/use-kognitive-event.d.ts +12 -0
  61. package/dist/hooks/use-kognitive-event.js +47 -0
  62. package/dist/hooks/use-streaming-status.d.ts +2 -0
  63. package/dist/hooks/use-streaming-status.js +8 -0
  64. package/dist/hooks/use-thread-manager.d.ts +20 -0
  65. package/dist/hooks/use-thread-manager.js +83 -0
  66. package/dist/index.d.ts +41 -0
  67. package/dist/index.js +92 -0
  68. package/dist/kognitive-ui.d.ts +48 -0
  69. package/dist/kognitive-ui.js +130 -0
  70. package/dist/primitives/action-bar/action-bar-copy.d.ts +6 -0
  71. package/dist/primitives/action-bar/action-bar-copy.js +16 -0
  72. package/dist/primitives/action-bar/action-bar-edit.d.ts +6 -0
  73. package/dist/primitives/action-bar/action-bar-edit.js +11 -0
  74. package/dist/primitives/action-bar/action-bar-feedback.d.ts +10 -0
  75. package/dist/primitives/action-bar/action-bar-feedback.js +30 -0
  76. package/dist/primitives/action-bar/action-bar-retry.d.ts +6 -0
  77. package/dist/primitives/action-bar/action-bar-retry.js +25 -0
  78. package/dist/primitives/action-bar/action-bar-root.d.ts +6 -0
  79. package/dist/primitives/action-bar/action-bar-root.js +7 -0
  80. package/dist/primitives/action-bar/action-bar-stop.d.ts +6 -0
  81. package/dist/primitives/action-bar/action-bar-stop.js +11 -0
  82. package/dist/primitives/action-bar/index.d.ts +14 -0
  83. package/dist/primitives/action-bar/index.js +17 -0
  84. package/dist/primitives/composer/composer-attachment-trigger.d.ts +7 -0
  85. package/dist/primitives/composer/composer-attachment-trigger.js +33 -0
  86. package/dist/primitives/composer/composer-attachments.d.ts +7 -0
  87. package/dist/primitives/composer/composer-attachments.js +16 -0
  88. package/dist/primitives/composer/composer-input.d.ts +6 -0
  89. package/dist/primitives/composer/composer-input.js +19 -0
  90. package/dist/primitives/composer/composer-root.d.ts +6 -0
  91. package/dist/primitives/composer/composer-root.js +91 -0
  92. package/dist/primitives/composer/composer-send.d.ts +6 -0
  93. package/dist/primitives/composer/composer-send.js +10 -0
  94. package/dist/primitives/composer/edit-composer-root.d.ts +11 -0
  95. package/dist/primitives/composer/edit-composer-root.js +24 -0
  96. package/dist/primitives/composer/index.d.ts +15 -0
  97. package/dist/primitives/composer/index.js +19 -0
  98. package/dist/primitives/composer/use-composer.d.ts +12 -0
  99. package/dist/primitives/composer/use-composer.js +6 -0
  100. package/dist/primitives/message/index.d.ts +9 -0
  101. package/dist/primitives/message/index.js +13 -0
  102. package/dist/primitives/message/message-content.d.ts +25 -0
  103. package/dist/primitives/message/message-content.js +70 -0
  104. package/dist/primitives/message/message-role.d.ts +6 -0
  105. package/dist/primitives/message/message-role.js +11 -0
  106. package/dist/primitives/message/message-root.d.ts +9 -0
  107. package/dist/primitives/message/message-root.js +38 -0
  108. package/dist/primitives/message/use-message.d.ts +10 -0
  109. package/dist/primitives/message/use-message.js +6 -0
  110. package/dist/primitives/thread/index.d.ts +17 -0
  111. package/dist/primitives/thread/index.js +21 -0
  112. package/dist/primitives/thread/thread-empty.d.ts +5 -0
  113. package/dist/primitives/thread/thread-empty.js +11 -0
  114. package/dist/primitives/thread/thread-error.d.ts +6 -0
  115. package/dist/primitives/thread/thread-error.js +11 -0
  116. package/dist/primitives/thread/thread-loading.d.ts +5 -0
  117. package/dist/primitives/thread/thread-loading.js +11 -0
  118. package/dist/primitives/thread/thread-messages.d.ts +6 -0
  119. package/dist/primitives/thread/thread-messages.js +9 -0
  120. package/dist/primitives/thread/thread-root.d.ts +6 -0
  121. package/dist/primitives/thread/thread-root.js +12 -0
  122. package/dist/primitives/thread/thread-scroll-to-bottom.d.ts +6 -0
  123. package/dist/primitives/thread/thread-scroll-to-bottom.js +14 -0
  124. package/dist/primitives/thread/thread-suggestions.d.ts +6 -0
  125. package/dist/primitives/thread/thread-suggestions.js +14 -0
  126. package/dist/primitives/thread/use-thread.d.ts +9 -0
  127. package/dist/primitives/thread/use-thread.js +6 -0
  128. package/dist/primitives/thread-list/index.d.ts +11 -0
  129. package/dist/primitives/thread-list/index.js +15 -0
  130. package/dist/primitives/thread-list/thread-list-item.d.ts +9 -0
  131. package/dist/primitives/thread-list/thread-list-item.js +13 -0
  132. package/dist/primitives/thread-list/thread-list-items.d.ts +6 -0
  133. package/dist/primitives/thread-list/thread-list-items.js +9 -0
  134. package/dist/primitives/thread-list/thread-list-new.d.ts +6 -0
  135. package/dist/primitives/thread-list/thread-list-new.js +13 -0
  136. package/dist/primitives/thread-list/thread-list-root.d.ts +6 -0
  137. package/dist/primitives/thread-list/thread-list-root.js +16 -0
  138. package/dist/primitives/thread-list/use-thread-list.d.ts +9 -0
  139. package/dist/primitives/thread-list/use-thread-list.js +6 -0
  140. package/dist/primitives/tool-ui/index.d.ts +7 -0
  141. package/dist/primitives/tool-ui/index.js +11 -0
  142. package/dist/primitives/tool-ui/tool-ui-fallback.d.ts +5 -0
  143. package/dist/primitives/tool-ui/tool-ui-fallback.js +20 -0
  144. package/dist/primitives/tool-ui/tool-ui-root.d.ts +5 -0
  145. package/dist/primitives/tool-ui/tool-ui-root.js +20 -0
  146. package/dist/primitives/tool-ui/use-tool-ui.d.ts +2 -0
  147. package/dist/primitives/tool-ui/use-tool-ui.js +8 -0
  148. package/dist/runtime/kognitive-runtime.d.ts +30 -0
  149. package/dist/runtime/kognitive-runtime.js +32 -0
  150. package/dist/runtime/kognitive-transport.d.ts +26 -0
  151. package/dist/runtime/kognitive-transport.js +42 -0
  152. package/dist/runtime/thread-manager.d.ts +17 -0
  153. package/dist/runtime/thread-manager.js +62 -0
  154. package/dist/runtime/types.d.ts +58 -0
  155. package/dist/runtime/types.js +2 -0
  156. package/dist/tool-ui/make-tool-ui.d.ts +59 -0
  157. package/dist/tool-ui/make-tool-ui.js +10 -0
  158. package/dist/tool-ui/registry.d.ts +9 -0
  159. package/dist/tool-ui/registry.js +26 -0
  160. package/dist/tool-ui/tool-ui-context.d.ts +2 -0
  161. package/dist/tool-ui/tool-ui-context.js +6 -0
  162. package/dist/tool-ui/toolkit.d.ts +31 -0
  163. package/dist/tool-ui/toolkit.js +33 -0
  164. package/dist/tool-ui/types.d.ts +19 -0
  165. package/dist/tool-ui/types.js +2 -0
  166. package/dist/utils/cn.d.ts +2 -0
  167. package/dist/utils/cn.js +8 -0
  168. package/dist/utils/create-context.d.ts +1 -0
  169. package/dist/utils/create-context.js +16 -0
  170. package/dist/utils/message-helpers.d.ts +6 -0
  171. package/dist/utils/message-helpers.js +46 -0
  172. package/package.json +56 -0
  173. package/src/__tests__/context-provider.test.ts +43 -0
  174. package/src/__tests__/event-emitter.test.ts +69 -0
  175. package/src/__tests__/keyboard-shortcuts.test.ts +55 -0
  176. package/src/__tests__/kognitive-runtime.test.ts +62 -0
  177. package/src/__tests__/kognitive-transport.test.ts +113 -0
  178. package/src/__tests__/make-tool-ui.test.ts +60 -0
  179. package/src/__tests__/message-helpers.test.ts +101 -0
  180. package/src/__tests__/thread-manager.test.ts +118 -0
  181. package/src/__tests__/tool-ui-registry.test.ts +80 -0
  182. package/src/__tests__/toolkit.test.ts +37 -0
  183. package/src/components/attachment-preview.tsx +46 -0
  184. package/src/components/composer.tsx +59 -0
  185. package/src/components/error-banner.tsx +33 -0
  186. package/src/components/markdown-content.tsx +64 -0
  187. package/src/components/message.tsx +145 -0
  188. package/src/components/status-indicator.tsx +26 -0
  189. package/src/components/suggestions.tsx +27 -0
  190. package/src/components/thread-list.tsx +69 -0
  191. package/src/components/thread.tsx +89 -0
  192. package/src/components/tool-approval.tsx +54 -0
  193. package/src/components/tool-invocation.tsx +94 -0
  194. package/src/context/kognitive-context.tsx +8 -0
  195. package/src/context/types.ts +43 -0
  196. package/src/context/use-kognitive.ts +5 -0
  197. package/src/hooks/use-auto-scroll.ts +19 -0
  198. package/src/hooks/use-copy-to-clipboard.ts +16 -0
  199. package/src/hooks/use-keyboard-shortcuts.ts +34 -0
  200. package/src/hooks/use-kognitive-chat.ts +73 -0
  201. package/src/hooks/use-kognitive-event.ts +56 -0
  202. package/src/hooks/use-streaming-status.ts +7 -0
  203. package/src/hooks/use-thread-manager.ts +114 -0
  204. package/src/index.ts +56 -0
  205. package/src/kognitive-ui.tsx +216 -0
  206. package/src/primitives/action-bar/action-bar-copy.tsx +30 -0
  207. package/src/primitives/action-bar/action-bar-edit.tsx +24 -0
  208. package/src/primitives/action-bar/action-bar-feedback.tsx +59 -0
  209. package/src/primitives/action-bar/action-bar-retry.tsx +38 -0
  210. package/src/primitives/action-bar/action-bar-root.tsx +14 -0
  211. package/src/primitives/action-bar/action-bar-stop.tsx +24 -0
  212. package/src/primitives/action-bar/index.ts +15 -0
  213. package/src/primitives/composer/composer-attachment-trigger.tsx +70 -0
  214. package/src/primitives/composer/composer-attachments.tsx +36 -0
  215. package/src/primitives/composer/composer-input.tsx +46 -0
  216. package/src/primitives/composer/composer-root.tsx +130 -0
  217. package/src/primitives/composer/composer-send.tsx +23 -0
  218. package/src/primitives/composer/edit-composer-root.tsx +52 -0
  219. package/src/primitives/composer/index.ts +17 -0
  220. package/src/primitives/composer/use-composer.ts +19 -0
  221. package/src/primitives/message/index.ts +11 -0
  222. package/src/primitives/message/message-content.tsx +117 -0
  223. package/src/primitives/message/message-role.tsx +13 -0
  224. package/src/primitives/message/message-root.tsx +64 -0
  225. package/src/primitives/message/use-message.ts +17 -0
  226. package/src/primitives/thread/index.ts +19 -0
  227. package/src/primitives/thread/thread-empty.tsx +12 -0
  228. package/src/primitives/thread/thread-error.tsx +18 -0
  229. package/src/primitives/thread/thread-loading.tsx +12 -0
  230. package/src/primitives/thread/thread-messages.tsx +12 -0
  231. package/src/primitives/thread/thread-root.tsx +28 -0
  232. package/src/primitives/thread/thread-scroll-to-bottom.tsx +26 -0
  233. package/src/primitives/thread/thread-suggestions.tsx +31 -0
  234. package/src/primitives/thread/use-thread.ts +16 -0
  235. package/src/primitives/thread-list/index.ts +13 -0
  236. package/src/primitives/thread-list/thread-list-item.tsx +37 -0
  237. package/src/primitives/thread-list/thread-list-items.tsx +19 -0
  238. package/src/primitives/thread-list/thread-list-new.tsx +26 -0
  239. package/src/primitives/thread-list/thread-list-root.tsx +29 -0
  240. package/src/primitives/thread-list/use-thread-list.ts +16 -0
  241. package/src/primitives/tool-ui/index.ts +9 -0
  242. package/src/primitives/tool-ui/tool-ui-fallback.tsx +63 -0
  243. package/src/primitives/tool-ui/tool-ui-root.tsx +26 -0
  244. package/src/primitives/tool-ui/use-tool-ui.ts +7 -0
  245. package/src/runtime/kognitive-runtime.ts +56 -0
  246. package/src/runtime/kognitive-transport.ts +56 -0
  247. package/src/runtime/thread-manager.ts +92 -0
  248. package/src/runtime/types.ts +63 -0
  249. package/src/tool-ui/make-tool-ui.ts +71 -0
  250. package/src/tool-ui/registry.ts +27 -0
  251. package/src/tool-ui/tool-ui-context.tsx +8 -0
  252. package/src/tool-ui/toolkit.ts +40 -0
  253. package/src/tool-ui/types.ts +29 -0
  254. package/src/utils/cn.ts +6 -0
  255. package/src/utils/create-context.ts +18 -0
  256. package/src/utils/message-helpers.ts +42 -0
  257. package/tsconfig.json +15 -0
  258. package/vitest.config.ts +8 -0
@@ -0,0 +1,9 @@
1
+ import { MessageRoot } from "./message-root";
2
+ import { MessageContent } from "./message-content";
3
+ import { MessageRole } from "./message-role";
4
+ export declare const MessagePrimitive: {
5
+ Root: typeof MessageRoot;
6
+ Content: typeof MessageContent;
7
+ Role: typeof MessageRole;
8
+ };
9
+ export { useMessage } from "./use-message";
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useMessage = exports.MessagePrimitive = void 0;
4
+ const message_root_1 = require("./message-root");
5
+ const message_content_1 = require("./message-content");
6
+ const message_role_1 = require("./message-role");
7
+ exports.MessagePrimitive = {
8
+ Root: message_root_1.MessageRoot,
9
+ Content: message_content_1.MessageContent,
10
+ Role: message_role_1.MessageRole,
11
+ };
12
+ var use_message_1 = require("./use-message");
13
+ Object.defineProperty(exports, "useMessage", { enumerable: true, get: function () { return use_message_1.useMessage; } });
@@ -0,0 +1,25 @@
1
+ import { type ComponentType } from "react";
2
+ import type { FileUIPart } from "ai";
3
+ import type { ToolInvocationState } from "../../tool-ui/types";
4
+ export interface TextComponentProps {
5
+ text: string;
6
+ }
7
+ export interface ToolInvocationComponentProps {
8
+ toolCallId: string;
9
+ toolName: string;
10
+ input: any;
11
+ output: any;
12
+ state: ToolInvocationState;
13
+ }
14
+ export interface FileComponentProps {
15
+ file: FileUIPart;
16
+ }
17
+ export interface MessageContentComponents {
18
+ Text?: ComponentType<TextComponentProps>;
19
+ ToolInvocation?: ComponentType<ToolInvocationComponentProps>;
20
+ File?: ComponentType<FileComponentProps>;
21
+ }
22
+ export interface MessageContentProps {
23
+ components?: MessageContentComponents;
24
+ }
25
+ export declare function MessageContent({ components }: MessageContentProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageContent = MessageContent;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const use_message_1 = require("./use-message");
6
+ const tool_ui_context_1 = require("../../tool-ui/tool-ui-context");
7
+ function DefaultText({ text }) {
8
+ return (0, jsx_runtime_1.jsx)("p", { children: text });
9
+ }
10
+ function DefaultFile({ file }) {
11
+ var _a, _b;
12
+ if (file.mediaType.startsWith("image/")) {
13
+ return (0, jsx_runtime_1.jsx)("img", { src: file.url, alt: (_a = file.filename) !== null && _a !== void 0 ? _a : "attachment" });
14
+ }
15
+ return (0, jsx_runtime_1.jsxs)("div", { "data-file-type": file.mediaType, children: ["File: ", (_b = file.filename) !== null && _b !== void 0 ? _b : file.mediaType] });
16
+ }
17
+ function isToolPart(part) {
18
+ return part.type.startsWith("tool-") || part.type === "dynamic-tool";
19
+ }
20
+ function getToolName(part) {
21
+ if (part.type === "dynamic-tool")
22
+ return part.toolName;
23
+ // For typed tool parts, type is "tool-{name}"
24
+ return part.type.replace(/^tool-/, "");
25
+ }
26
+ function MessageContent({ components }) {
27
+ var _a, _b;
28
+ const { message } = (0, use_message_1.useMessage)();
29
+ let registry;
30
+ try {
31
+ registry = (0, tool_ui_context_1.useToolUIRegistry)();
32
+ }
33
+ catch (_c) {
34
+ // ToolUIRegistry is optional
35
+ }
36
+ const TextComponent = (_a = components === null || components === void 0 ? void 0 : components.Text) !== null && _a !== void 0 ? _a : DefaultText;
37
+ const ToolInvocationComponent = components === null || components === void 0 ? void 0 : components.ToolInvocation;
38
+ const FileComponent = (_b = components === null || components === void 0 ? void 0 : components.File) !== null && _b !== void 0 ? _b : DefaultFile;
39
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: message.parts.map((part, i) => {
40
+ if (part.type === "text") {
41
+ return (0, jsx_runtime_1.jsx)(TextComponent, { text: part.text }, i);
42
+ }
43
+ if (isToolPart(part)) {
44
+ const toolPart = part;
45
+ const toolName = getToolName(toolPart);
46
+ const renderProps = {
47
+ toolCallId: toolPart.toolCallId,
48
+ toolName,
49
+ input: toolPart.input,
50
+ output: toolPart.output,
51
+ state: toolPart.state,
52
+ };
53
+ // Check registry first
54
+ const RegisteredUI = registry === null || registry === void 0 ? void 0 : registry.get(toolName);
55
+ if (RegisteredUI) {
56
+ return (0, jsx_runtime_1.jsx)(RegisteredUI, Object.assign({}, renderProps), i);
57
+ }
58
+ // Then check component override
59
+ if (ToolInvocationComponent) {
60
+ return (0, jsx_runtime_1.jsx)(ToolInvocationComponent, Object.assign({}, renderProps), i);
61
+ }
62
+ // Default: simple JSON display
63
+ return ((0, jsx_runtime_1.jsxs)("div", { "data-tool": toolName, "data-tool-state": toolPart.state, children: [(0, jsx_runtime_1.jsx)("strong", { children: toolName }), (0, jsx_runtime_1.jsx)("pre", { children: JSON.stringify(toolPart.input, null, 2) }), toolPart.output !== undefined && ((0, jsx_runtime_1.jsx)("pre", { children: JSON.stringify(toolPart.output, null, 2) }))] }, i));
64
+ }
65
+ if (part.type === "file") {
66
+ return (0, jsx_runtime_1.jsx)(FileComponent, { file: part }, i);
67
+ }
68
+ return null;
69
+ }) }));
70
+ }
@@ -0,0 +1,6 @@
1
+ import { type ReactNode } from "react";
2
+ export interface MessageRoleProps {
3
+ match: "user" | "assistant" | "system";
4
+ children: ReactNode;
5
+ }
6
+ export declare function MessageRole({ match, children }: MessageRoleProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageRole = MessageRole;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const use_message_1 = require("./use-message");
6
+ function MessageRole({ match, children }) {
7
+ const { message } = (0, use_message_1.useMessage)();
8
+ if (message.role !== match)
9
+ return null;
10
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
11
+ }
@@ -0,0 +1,9 @@
1
+ import { type ReactNode } from "react";
2
+ import type { UIMessage } from "ai";
3
+ export interface MessageRootProps {
4
+ message?: UIMessage;
5
+ index?: number;
6
+ className?: string;
7
+ children: ReactNode;
8
+ }
9
+ export declare function MessageRoot({ message, index, className, children }: MessageRootProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageRoot = MessageRoot;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const use_message_1 = require("./use-message");
7
+ const kognitive_context_1 = require("../../context/kognitive-context");
8
+ function MessageRoot({ message, index, className, children }) {
9
+ if (!message) {
10
+ throw new Error("MessagePrimitive.Root requires a `message` prop or must be used inside ThreadPrimitive.Messages");
11
+ }
12
+ const { messages, setMessages, send } = (0, kognitive_context_1.useKognitiveContext)();
13
+ const [isEditing, setIsEditing] = (0, react_1.useState)(false);
14
+ const startEdit = (0, react_1.useCallback)(() => {
15
+ if (message.role === "user")
16
+ setIsEditing(true);
17
+ }, [message.role]);
18
+ const cancelEdit = (0, react_1.useCallback)(() => {
19
+ setIsEditing(false);
20
+ }, []);
21
+ const submitEdit = (0, react_1.useCallback)((newText) => {
22
+ setIsEditing(false);
23
+ // Trim conversation to before this message and re-send
24
+ const msgIndex = messages.findIndex((m) => m.id === message.id);
25
+ if (msgIndex >= 0) {
26
+ setMessages(messages.slice(0, msgIndex));
27
+ send(newText);
28
+ }
29
+ }, [messages, message.id, setMessages, send]);
30
+ return ((0, jsx_runtime_1.jsx)(use_message_1.MessageContextProvider, { value: {
31
+ message,
32
+ index: index !== null && index !== void 0 ? index : 0,
33
+ isEditing,
34
+ startEdit,
35
+ cancelEdit,
36
+ submitEdit,
37
+ }, children: (0, jsx_runtime_1.jsx)("div", { className: className, "data-role": message.role, "data-message-id": message.id, "data-editing": isEditing || undefined, children: children }) }));
38
+ }
@@ -0,0 +1,10 @@
1
+ import type { UIMessage } from "ai";
2
+ export interface MessageContextValue {
3
+ message: UIMessage;
4
+ index: number;
5
+ isEditing: boolean;
6
+ startEdit: () => void;
7
+ cancelEdit: () => void;
8
+ submitEdit: (newText: string) => void;
9
+ }
10
+ export declare const MessageContextProvider: import("react").Provider<MessageContextValue | null>, useMessage: () => MessageContextValue, MessageContext: import("react").Context<MessageContextValue | null>;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.MessageContext = exports.useMessage = exports.MessageContextProvider = void 0;
5
+ const create_context_1 = require("../../utils/create-context");
6
+ _a = (0, create_context_1.createContext)("Message"), exports.MessageContextProvider = _a[0], exports.useMessage = _a[1], exports.MessageContext = _a[2];
@@ -0,0 +1,17 @@
1
+ import { ThreadRoot } from "./thread-root";
2
+ import { ThreadMessages } from "./thread-messages";
3
+ import { ThreadEmpty } from "./thread-empty";
4
+ import { ThreadLoading } from "./thread-loading";
5
+ import { ThreadScrollToBottom } from "./thread-scroll-to-bottom";
6
+ import { ThreadError } from "./thread-error";
7
+ import { ThreadSuggestions } from "./thread-suggestions";
8
+ export declare const ThreadPrimitive: {
9
+ Root: typeof ThreadRoot;
10
+ Messages: typeof ThreadMessages;
11
+ Empty: typeof ThreadEmpty;
12
+ Loading: typeof ThreadLoading;
13
+ ScrollToBottom: typeof ThreadScrollToBottom;
14
+ Error: typeof ThreadError;
15
+ Suggestions: typeof ThreadSuggestions;
16
+ };
17
+ export { useThread } from "./use-thread";
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useThread = exports.ThreadPrimitive = void 0;
4
+ const thread_root_1 = require("./thread-root");
5
+ const thread_messages_1 = require("./thread-messages");
6
+ const thread_empty_1 = require("./thread-empty");
7
+ const thread_loading_1 = require("./thread-loading");
8
+ const thread_scroll_to_bottom_1 = require("./thread-scroll-to-bottom");
9
+ const thread_error_1 = require("./thread-error");
10
+ const thread_suggestions_1 = require("./thread-suggestions");
11
+ exports.ThreadPrimitive = {
12
+ Root: thread_root_1.ThreadRoot,
13
+ Messages: thread_messages_1.ThreadMessages,
14
+ Empty: thread_empty_1.ThreadEmpty,
15
+ Loading: thread_loading_1.ThreadLoading,
16
+ ScrollToBottom: thread_scroll_to_bottom_1.ThreadScrollToBottom,
17
+ Error: thread_error_1.ThreadError,
18
+ Suggestions: thread_suggestions_1.ThreadSuggestions,
19
+ };
20
+ var use_thread_1 = require("./use-thread");
21
+ Object.defineProperty(exports, "useThread", { enumerable: true, get: function () { return use_thread_1.useThread; } });
@@ -0,0 +1,5 @@
1
+ import { type ReactNode } from "react";
2
+ export interface ThreadEmptyProps {
3
+ children: ReactNode;
4
+ }
5
+ export declare function ThreadEmpty({ children }: ThreadEmptyProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThreadEmpty = ThreadEmpty;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const use_thread_1 = require("./use-thread");
6
+ function ThreadEmpty({ children }) {
7
+ const { messages } = (0, use_thread_1.useThread)();
8
+ if (messages.length > 0)
9
+ return null;
10
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
11
+ }
@@ -0,0 +1,6 @@
1
+ import { type ReactNode } from "react";
2
+ export interface ThreadErrorProps {
3
+ children?: ReactNode | ((error: Error) => ReactNode);
4
+ className?: string;
5
+ }
6
+ export declare function ThreadError({ children, className }: ThreadErrorProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThreadError = ThreadError;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const kognitive_context_1 = require("../../context/kognitive-context");
6
+ function ThreadError({ children, className }) {
7
+ const { error } = (0, kognitive_context_1.useKognitiveContext)();
8
+ if (!error)
9
+ return null;
10
+ return ((0, jsx_runtime_1.jsx)("div", { className: className, role: "alert", "data-error": true, children: typeof children === "function" ? children(error) : children !== null && children !== void 0 ? children : error.message }));
11
+ }
@@ -0,0 +1,5 @@
1
+ import { type ReactNode } from "react";
2
+ export interface ThreadLoadingProps {
3
+ children: ReactNode;
4
+ }
5
+ export declare function ThreadLoading({ children }: ThreadLoadingProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThreadLoading = ThreadLoading;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const use_thread_1 = require("./use-thread");
6
+ function ThreadLoading({ children }) {
7
+ const { isStreaming } = (0, use_thread_1.useThread)();
8
+ if (!isStreaming)
9
+ return null;
10
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children });
11
+ }
@@ -0,0 +1,6 @@
1
+ import { type ReactNode } from "react";
2
+ import type { UIMessage } from "ai";
3
+ export interface ThreadMessagesProps {
4
+ children: (message: UIMessage, index: number) => ReactNode;
5
+ }
6
+ export declare function ThreadMessages({ children }: ThreadMessagesProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThreadMessages = ThreadMessages;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const use_thread_1 = require("./use-thread");
6
+ function ThreadMessages({ children }) {
7
+ const { messages } = (0, use_thread_1.useThread)();
8
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: messages.map((message, index) => children(message, index)) });
9
+ }
@@ -0,0 +1,6 @@
1
+ import { type ReactNode } from "react";
2
+ export interface ThreadRootProps {
3
+ className?: string;
4
+ children: ReactNode;
5
+ }
6
+ export declare function ThreadRoot({ className, children }: ThreadRootProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThreadRoot = ThreadRoot;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const kognitive_context_1 = require("../../context/kognitive-context");
7
+ const use_thread_1 = require("./use-thread");
8
+ function ThreadRoot({ className, children }) {
9
+ const { messages, status, isStreaming, send, stop } = (0, kognitive_context_1.useKognitiveContext)();
10
+ const containerRef = (0, react_1.useRef)(null);
11
+ return ((0, jsx_runtime_1.jsx)(use_thread_1.ThreadContextProvider, { value: { messages, status, isStreaming, send, stop }, children: (0, jsx_runtime_1.jsx)("div", { ref: containerRef, className: className, "data-status": status, "data-streaming": isStreaming || undefined, children: children }) }));
12
+ }
@@ -0,0 +1,6 @@
1
+ import { type ReactNode } from "react";
2
+ export interface ThreadScrollToBottomProps {
3
+ className?: string;
4
+ children?: ReactNode;
5
+ }
6
+ export declare function ThreadScrollToBottom({ className, children }: ThreadScrollToBottomProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThreadScrollToBottom = ThreadScrollToBottom;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ function ThreadScrollToBottom({ className, children }) {
7
+ const scrollToBottom = (0, react_1.useCallback)(() => {
8
+ const container = document.querySelector("[data-kognitive-thread-root]");
9
+ if (container) {
10
+ container.scrollTop = container.scrollHeight;
11
+ }
12
+ }, []);
13
+ return ((0, jsx_runtime_1.jsx)("button", { type: "button", className: className, onClick: scrollToBottom, "aria-label": "Scroll to bottom", children: children !== null && children !== void 0 ? children : "↓" }));
14
+ }
@@ -0,0 +1,6 @@
1
+ import { type ReactNode } from "react";
2
+ export interface ThreadSuggestionsProps {
3
+ className?: string;
4
+ children?: (suggestions: string[], send: (text: string) => void) => ReactNode;
5
+ }
6
+ export declare function ThreadSuggestions({ className, children }: ThreadSuggestionsProps): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThreadSuggestions = ThreadSuggestions;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const kognitive_context_1 = require("../../context/kognitive-context");
6
+ function ThreadSuggestions({ className, children }) {
7
+ const { suggestions, send, isStreaming } = (0, kognitive_context_1.useKognitiveContext)();
8
+ if (suggestions.length === 0 || isStreaming)
9
+ return null;
10
+ if (children) {
11
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: children(suggestions, send) });
12
+ }
13
+ return ((0, jsx_runtime_1.jsx)("div", { className: className, "data-suggestions": true, children: suggestions.map((suggestion, i) => ((0, jsx_runtime_1.jsx)("button", { type: "button", onClick: () => send(suggestion), "data-suggestion": true, children: suggestion }, i))) }));
14
+ }
@@ -0,0 +1,9 @@
1
+ import type { UIMessage, ChatStatus } from "ai";
2
+ export interface ThreadContextValue {
3
+ messages: UIMessage[];
4
+ status: ChatStatus;
5
+ isStreaming: boolean;
6
+ send: (text: string) => void;
7
+ stop: () => void;
8
+ }
9
+ export declare const ThreadContextProvider: import("react").Provider<ThreadContextValue | null>, useThread: () => ThreadContextValue, ThreadContext: import("react").Context<ThreadContextValue | null>;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ThreadContext = exports.useThread = exports.ThreadContextProvider = void 0;
5
+ const create_context_1 = require("../../utils/create-context");
6
+ _a = (0, create_context_1.createContext)("Thread"), exports.ThreadContextProvider = _a[0], exports.useThread = _a[1], exports.ThreadContext = _a[2];
@@ -0,0 +1,11 @@
1
+ import { ThreadListRoot } from "./thread-list-root";
2
+ import { ThreadListItems } from "./thread-list-items";
3
+ import { ThreadListItem } from "./thread-list-item";
4
+ import { ThreadListNew } from "./thread-list-new";
5
+ export declare const ThreadListPrimitive: {
6
+ Root: typeof ThreadListRoot;
7
+ Items: typeof ThreadListItems;
8
+ Item: typeof ThreadListItem;
9
+ New: typeof ThreadListNew;
10
+ };
11
+ export { useThreadList } from "./use-thread-list";
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useThreadList = exports.ThreadListPrimitive = void 0;
4
+ const thread_list_root_1 = require("./thread-list-root");
5
+ const thread_list_items_1 = require("./thread-list-items");
6
+ const thread_list_item_1 = require("./thread-list-item");
7
+ const thread_list_new_1 = require("./thread-list-new");
8
+ exports.ThreadListPrimitive = {
9
+ Root: thread_list_root_1.ThreadListRoot,
10
+ Items: thread_list_items_1.ThreadListItems,
11
+ Item: thread_list_item_1.ThreadListItem,
12
+ New: thread_list_new_1.ThreadListNew,
13
+ };
14
+ var use_thread_list_1 = require("./use-thread-list");
15
+ Object.defineProperty(exports, "useThreadList", { enumerable: true, get: function () { return use_thread_list_1.useThreadList; } });
@@ -0,0 +1,9 @@
1
+ import { type ReactNode } from "react";
2
+ import type { ThreadSummary } from "../../runtime/types";
3
+ export interface ThreadListItemProps {
4
+ thread: ThreadSummary;
5
+ isActive: boolean;
6
+ className?: string;
7
+ children?: ReactNode;
8
+ }
9
+ export declare function ThreadListItem({ thread, isActive, className, children }: ThreadListItemProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThreadListItem = ThreadListItem;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const use_thread_list_1 = require("./use-thread-list");
7
+ function ThreadListItem({ thread, isActive, className, children }) {
8
+ const { setActiveSessionId } = (0, use_thread_list_1.useThreadList)();
9
+ const handleClick = (0, react_1.useCallback)(() => {
10
+ setActiveSessionId(thread.sessionId);
11
+ }, [thread.sessionId, setActiveSessionId]);
12
+ return ((0, jsx_runtime_1.jsx)("button", { type: "button", className: className, onClick: handleClick, "data-active": isActive || undefined, "data-status": thread.status, "data-session-id": thread.sessionId, "aria-current": isActive ? "true" : undefined, children: children !== null && children !== void 0 ? children : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { children: thread.title || thread.lastUserPreview || "New conversation" }), (0, jsx_runtime_1.jsx)("span", { children: thread.lastAssistantPreview })] })) }));
13
+ }
@@ -0,0 +1,6 @@
1
+ import { type ReactNode } from "react";
2
+ import type { ThreadSummary } from "../../runtime/types";
3
+ export interface ThreadListItemsProps {
4
+ children: (thread: ThreadSummary, isActive: boolean) => ReactNode;
5
+ }
6
+ export declare function ThreadListItems({ children }: ThreadListItemsProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThreadListItems = ThreadListItems;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const use_thread_list_1 = require("./use-thread-list");
6
+ function ThreadListItems({ children }) {
7
+ const { threads, activeSessionId } = (0, use_thread_list_1.useThreadList)();
8
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: threads.map((thread) => children(thread, thread.sessionId === activeSessionId)) }));
9
+ }
@@ -0,0 +1,6 @@
1
+ import { type ReactNode } from "react";
2
+ export interface ThreadListNewProps {
3
+ className?: string;
4
+ children?: ReactNode;
5
+ }
6
+ export declare function ThreadListNew({ className, children }: ThreadListNewProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThreadListNew = ThreadListNew;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const use_thread_list_1 = require("./use-thread-list");
7
+ function ThreadListNew({ className, children }) {
8
+ const { createThread } = (0, use_thread_list_1.useThreadList)();
9
+ const handleClick = (0, react_1.useCallback)(() => {
10
+ void createThread();
11
+ }, [createThread]);
12
+ return ((0, jsx_runtime_1.jsx)("button", { type: "button", className: className, onClick: handleClick, "aria-label": "New conversation", children: children !== null && children !== void 0 ? children : "New conversation" }));
13
+ }
@@ -0,0 +1,6 @@
1
+ import { type ReactNode } from "react";
2
+ export interface ThreadListRootProps {
3
+ className?: string;
4
+ children: ReactNode;
5
+ }
6
+ export declare function ThreadListRoot({ className, children }: ThreadListRootProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThreadListRoot = ThreadListRoot;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const kognitive_context_1 = require("../../context/kognitive-context");
6
+ const use_thread_list_1 = require("./use-thread-list");
7
+ function ThreadListRoot({ className, children }) {
8
+ const { threads, activeSessionId, setActiveSessionId, createThread, refreshThreads } = (0, kognitive_context_1.useKognitiveContext)();
9
+ return ((0, jsx_runtime_1.jsx)(use_thread_list_1.ThreadListContextProvider, { value: {
10
+ threads,
11
+ activeSessionId,
12
+ setActiveSessionId,
13
+ createThread,
14
+ refreshThreads,
15
+ }, children: (0, jsx_runtime_1.jsx)("div", { className: className, role: "navigation", "aria-label": "Threads", children: children }) }));
16
+ }
@@ -0,0 +1,9 @@
1
+ import type { ThreadSummary } from "../../runtime/types";
2
+ export interface ThreadListContextValue {
3
+ threads: ThreadSummary[];
4
+ activeSessionId: string | null;
5
+ setActiveSessionId: (sessionId: string | null) => void;
6
+ createThread: () => Promise<void>;
7
+ refreshThreads: () => Promise<void>;
8
+ }
9
+ export declare const ThreadListContextProvider: import("react").Provider<ThreadListContextValue | null>, useThreadList: () => ThreadListContextValue, ThreadListContext: import("react").Context<ThreadListContextValue | null>;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ThreadListContext = exports.useThreadList = exports.ThreadListContextProvider = void 0;
5
+ const create_context_1 = require("../../utils/create-context");
6
+ _a = (0, create_context_1.createContext)("ThreadList"), exports.ThreadListContextProvider = _a[0], exports.useThreadList = _a[1], exports.ThreadListContext = _a[2];
@@ -0,0 +1,7 @@
1
+ import { ToolUIRoot } from "./tool-ui-root";
2
+ import { ToolUIFallback } from "./tool-ui-fallback";
3
+ export declare const ToolUIPrimitive: {
4
+ Root: typeof ToolUIRoot;
5
+ Fallback: typeof ToolUIFallback;
6
+ };
7
+ export { useToolUI } from "./use-tool-ui";
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useToolUI = exports.ToolUIPrimitive = void 0;
4
+ const tool_ui_root_1 = require("./tool-ui-root");
5
+ const tool_ui_fallback_1 = require("./tool-ui-fallback");
6
+ exports.ToolUIPrimitive = {
7
+ Root: tool_ui_root_1.ToolUIRoot,
8
+ Fallback: tool_ui_fallback_1.ToolUIFallback,
9
+ };
10
+ var use_tool_ui_1 = require("./use-tool-ui");
11
+ Object.defineProperty(exports, "useToolUI", { enumerable: true, get: function () { return use_tool_ui_1.useToolUI; } });
@@ -0,0 +1,5 @@
1
+ import type { ToolUIRenderProps } from "../../tool-ui/types";
2
+ export interface ToolUIFallbackProps extends ToolUIRenderProps {
3
+ className?: string;
4
+ }
5
+ export declare function ToolUIFallback({ toolName, toolCallId, input, output, state, className }: ToolUIFallbackProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ToolUIFallback = ToolUIFallback;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ function stateLabel(state) {
7
+ switch (state) {
8
+ case "input-streaming": return "streaming input...";
9
+ case "input-available": return "calling...";
10
+ case "approval-requested": return "awaiting approval";
11
+ case "approval-responded": return "approved";
12
+ case "output-available": return "done";
13
+ case "error": return "error";
14
+ default: return state;
15
+ }
16
+ }
17
+ function ToolUIFallback({ toolName, toolCallId, input, output, state, className }) {
18
+ const [expanded, setExpanded] = (0, react_1.useState)(false);
19
+ return ((0, jsx_runtime_1.jsxs)("div", { className: className, "data-tool": toolName, "data-tool-state": state, "data-tool-call-id": toolCallId, children: [(0, jsx_runtime_1.jsxs)("button", { type: "button", onClick: () => setExpanded(!expanded), "aria-expanded": expanded, style: { display: "flex", alignItems: "center", gap: "0.5rem", cursor: "pointer", background: "none", border: "none", padding: "0.5rem", width: "100%", textAlign: "left" }, children: [(0, jsx_runtime_1.jsx)("span", { children: "\uD83D\uDD27" }), (0, jsx_runtime_1.jsx)("strong", { children: toolName }), (0, jsx_runtime_1.jsx)("span", { "data-tool-state-badge": state, children: stateLabel(state) }), (0, jsx_runtime_1.jsx)("span", { style: { marginLeft: "auto" }, children: expanded ? "\u25BC" : "\u25B6" })] }), expanded && ((0, jsx_runtime_1.jsxs)("div", { style: { padding: "0.5rem" }, children: [input !== undefined && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Arguments:" }), (0, jsx_runtime_1.jsx)("pre", { style: { overflow: "auto", fontSize: "0.85em" }, children: JSON.stringify(input, null, 2) })] })), output !== undefined && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("strong", { children: "Result:" }), (0, jsx_runtime_1.jsx)("pre", { style: { overflow: "auto", fontSize: "0.85em" }, children: JSON.stringify(output, null, 2) })] }))] }))] }));
20
+ }
@@ -0,0 +1,5 @@
1
+ import type { ToolUIRenderProps } from "../../tool-ui/types";
2
+ export interface ToolUIRootProps extends ToolUIRenderProps {
3
+ className?: string;
4
+ }
5
+ export declare function ToolUIRoot(props: ToolUIRootProps): import("react/jsx-runtime").JSX.Element;