@assistant-ui/react 0.7.91 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/dist/cloud/auiV0.js.map +1 -1
  2. package/dist/cloud/auiV0.mjs.map +1 -1
  3. package/dist/index.d.ts +0 -1
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1 -3
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +0 -1
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/internal.d.ts +0 -1
  10. package/dist/internal.d.ts.map +1 -1
  11. package/dist/internal.js +0 -3
  12. package/dist/internal.js.map +1 -1
  13. package/dist/internal.mjs +0 -2
  14. package/dist/internal.mjs.map +1 -1
  15. package/dist/model-context/ModelContextTypes.d.ts +11 -0
  16. package/dist/model-context/ModelContextTypes.d.ts.map +1 -1
  17. package/dist/model-context/ModelContextTypes.js.map +1 -1
  18. package/dist/model-context/ModelContextTypes.mjs.map +1 -1
  19. package/dist/model-context/makeAssistantVisible.d.ts.map +1 -1
  20. package/dist/model-context/makeAssistantVisible.js +4 -2
  21. package/dist/model-context/makeAssistantVisible.js.map +1 -1
  22. package/dist/model-context/makeAssistantVisible.mjs +4 -2
  23. package/dist/model-context/makeAssistantVisible.mjs.map +1 -1
  24. package/dist/primitives/contentPart/index.d.ts +0 -1
  25. package/dist/primitives/contentPart/index.d.ts.map +1 -1
  26. package/dist/primitives/contentPart/index.js +0 -3
  27. package/dist/primitives/contentPart/index.js.map +1 -1
  28. package/dist/primitives/contentPart/index.mjs +0 -2
  29. package/dist/primitives/contentPart/index.mjs.map +1 -1
  30. package/dist/primitives/index.d.ts +0 -1
  31. package/dist/primitives/index.d.ts.map +1 -1
  32. package/dist/primitives/index.js +0 -3
  33. package/dist/primitives/index.js.map +1 -1
  34. package/dist/primitives/index.mjs +0 -2
  35. package/dist/primitives/index.mjs.map +1 -1
  36. package/dist/primitives/message/MessageContent.d.ts +1 -2
  37. package/dist/primitives/message/MessageContent.d.ts.map +1 -1
  38. package/dist/primitives/message/MessageContent.js +2 -7
  39. package/dist/primitives/message/MessageContent.js.map +1 -1
  40. package/dist/primitives/message/MessageContent.mjs +2 -7
  41. package/dist/primitives/message/MessageContent.mjs.map +1 -1
  42. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
  43. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +1 -3
  44. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
  45. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs +1 -3
  46. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs.map +1 -1
  47. package/dist/runtimes/edge/converters/toCoreMessages.d.ts.map +1 -1
  48. package/dist/runtimes/edge/converters/toCoreMessages.js +1 -6
  49. package/dist/runtimes/edge/converters/toCoreMessages.js.map +1 -1
  50. package/dist/runtimes/edge/converters/toCoreMessages.mjs +1 -6
  51. package/dist/runtimes/edge/converters/toCoreMessages.mjs.map +1 -1
  52. package/dist/runtimes/edge/converters/toLanguageModelMessages.js.map +1 -1
  53. package/dist/runtimes/edge/converters/toLanguageModelMessages.mjs.map +1 -1
  54. package/dist/runtimes/external-store/ThreadMessageLike.d.ts +2 -2
  55. package/dist/runtimes/external-store/ThreadMessageLike.d.ts.map +1 -1
  56. package/dist/runtimes/external-store/ThreadMessageLike.js +0 -3
  57. package/dist/runtimes/external-store/ThreadMessageLike.js.map +1 -1
  58. package/dist/runtimes/external-store/ThreadMessageLike.mjs +0 -3
  59. package/dist/runtimes/external-store/ThreadMessageLike.mjs.map +1 -1
  60. package/dist/runtimes/remote-thread-list/adapter/cloud.d.ts.map +1 -1
  61. package/dist/runtimes/remote-thread-list/adapter/cloud.js +1 -7
  62. package/dist/runtimes/remote-thread-list/adapter/cloud.js.map +1 -1
  63. package/dist/runtimes/remote-thread-list/adapter/cloud.mjs +1 -7
  64. package/dist/runtimes/remote-thread-list/adapter/cloud.mjs.map +1 -1
  65. package/dist/types/AssistantTypes.d.ts +3 -7
  66. package/dist/types/AssistantTypes.d.ts.map +1 -1
  67. package/dist/types/AssistantTypes.js.map +1 -1
  68. package/dist/types/ContentPartComponentTypes.d.ts +1 -3
  69. package/dist/types/ContentPartComponentTypes.d.ts.map +1 -1
  70. package/dist/types/ContentPartComponentTypes.js.map +1 -1
  71. package/dist/types/index.d.ts +1 -1
  72. package/dist/types/index.d.ts.map +1 -1
  73. package/dist/types/index.js.map +1 -1
  74. package/package.json +1 -21
  75. package/src/cloud/auiV0.ts +1 -1
  76. package/src/index.ts +0 -1
  77. package/src/internal.ts +0 -1
  78. package/src/model-context/ModelContextTypes.ts +19 -0
  79. package/src/model-context/makeAssistantVisible.tsx +4 -2
  80. package/src/primitives/contentPart/index.ts +0 -1
  81. package/src/primitives/index.ts +0 -1
  82. package/src/primitives/message/MessageContent.tsx +0 -9
  83. package/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx +1 -3
  84. package/src/runtimes/edge/converters/toCoreMessages.ts +11 -14
  85. package/src/runtimes/edge/converters/toLanguageModelMessages.ts +2 -2
  86. package/src/runtimes/external-store/ThreadMessageLike.tsx +0 -6
  87. package/src/runtimes/remote-thread-list/adapter/cloud.tsx +4 -13
  88. package/src/types/AssistantTypes.ts +4 -9
  89. package/src/types/ContentPartComponentTypes.tsx +0 -4
  90. package/src/types/index.ts +0 -2
  91. package/dist/primitives/contentPart/ContentPartDisplay.d.ts +0 -9
  92. package/dist/primitives/contentPart/ContentPartDisplay.d.ts.map +0 -1
  93. package/dist/primitives/contentPart/ContentPartDisplay.js +0 -37
  94. package/dist/primitives/contentPart/ContentPartDisplay.js.map +0 -1
  95. package/dist/primitives/contentPart/ContentPartDisplay.mjs +0 -13
  96. package/dist/primitives/contentPart/ContentPartDisplay.mjs.map +0 -1
  97. package/dist/primitives/contentPart/useContentPartDisplay.d.ts +0 -8
  98. package/dist/primitives/contentPart/useContentPartDisplay.d.ts.map +0 -1
  99. package/dist/primitives/contentPart/useContentPartDisplay.js +0 -42
  100. package/dist/primitives/contentPart/useContentPartDisplay.js.map +0 -1
  101. package/dist/primitives/contentPart/useContentPartDisplay.mjs +0 -18
  102. package/dist/primitives/contentPart/useContentPartDisplay.mjs.map +0 -1
  103. package/dist/styles/index.css +0 -1261
  104. package/dist/styles/index.css.map +0 -1
  105. package/dist/styles/modal.css +0 -143
  106. package/dist/styles/modal.css.map +0 -1
  107. package/dist/styles/tailwindcss/base-components.css +0 -69
  108. package/dist/styles/tailwindcss/base-components.css.json +0 -48
  109. package/dist/styles/tailwindcss/modal.css +0 -29
  110. package/dist/styles/tailwindcss/modal.css.json +0 -26
  111. package/dist/styles/tailwindcss/thread.css +0 -262
  112. package/dist/styles/tailwindcss/thread.css.json +0 -183
  113. package/dist/styles/themes/default.css +0 -64
  114. package/dist/styles/themes/default.css.json +0 -46
  115. package/dist/styles/themes/shadcn-extras.css +0 -4
  116. package/dist/styles/themes/shadcn-extras.css.json +0 -5
  117. package/dist/tailwindcss/index.d.ts +0 -49
  118. package/dist/tailwindcss/index.d.ts.map +0 -1
  119. package/dist/tailwindcss/index.js +0 -189
  120. package/dist/tailwindcss/index.js.map +0 -1
  121. package/dist/tailwindcss/index.mjs +0 -181
  122. package/dist/tailwindcss/index.mjs.map +0 -1
  123. package/dist/ui/assistant-action-bar.d.ts +0 -24
  124. package/dist/ui/assistant-action-bar.d.ts.map +0 -1
  125. package/dist/ui/assistant-action-bar.js +0 -193
  126. package/dist/ui/assistant-action-bar.js.map +0 -1
  127. package/dist/ui/assistant-action-bar.mjs +0 -181
  128. package/dist/ui/assistant-action-bar.mjs.map +0 -1
  129. package/dist/ui/assistant-message.d.ts +0 -13
  130. package/dist/ui/assistant-message.d.ts.map +0 -1
  131. package/dist/ui/assistant-message.js +0 -107
  132. package/dist/ui/assistant-message.js.map +0 -1
  133. package/dist/ui/assistant-message.mjs +0 -77
  134. package/dist/ui/assistant-message.mjs.map +0 -1
  135. package/dist/ui/assistant-modal.d.ts +0 -23
  136. package/dist/ui/assistant-modal.d.ts.map +0 -1
  137. package/dist/ui/assistant-modal.js +0 -126
  138. package/dist/ui/assistant-modal.js.map +0 -1
  139. package/dist/ui/assistant-modal.mjs +0 -99
  140. package/dist/ui/assistant-modal.mjs.map +0 -1
  141. package/dist/ui/attachment-ui.d.ts +0 -12
  142. package/dist/ui/attachment-ui.d.ts.map +0 -1
  143. package/dist/ui/attachment-ui.js +0 -170
  144. package/dist/ui/attachment-ui.js.map +0 -1
  145. package/dist/ui/attachment-ui.mjs +0 -160
  146. package/dist/ui/attachment-ui.mjs.map +0 -1
  147. package/dist/ui/base/CircleStopIcon.d.ts +0 -3
  148. package/dist/ui/base/CircleStopIcon.d.ts.map +0 -1
  149. package/dist/ui/base/CircleStopIcon.js +0 -45
  150. package/dist/ui/base/CircleStopIcon.js.map +0 -1
  151. package/dist/ui/base/CircleStopIcon.mjs +0 -20
  152. package/dist/ui/base/CircleStopIcon.mjs.map +0 -1
  153. package/dist/ui/base/avatar.d.ts +0 -12
  154. package/dist/ui/base/avatar.d.ts.map +0 -1
  155. package/dist/ui/base/avatar.js +0 -69
  156. package/dist/ui/base/avatar.js.map +0 -1
  157. package/dist/ui/base/avatar.mjs +0 -31
  158. package/dist/ui/base/avatar.mjs.map +0 -1
  159. package/dist/ui/base/button.d.ts +0 -16
  160. package/dist/ui/base/button.d.ts.map +0 -1
  161. package/dist/ui/base/button.js +0 -66
  162. package/dist/ui/base/button.js.map +0 -1
  163. package/dist/ui/base/button.mjs +0 -40
  164. package/dist/ui/base/button.mjs.map +0 -1
  165. package/dist/ui/base/dialog.d.ts +0 -9
  166. package/dist/ui/base/dialog.d.ts.map +0 -1
  167. package/dist/ui/base/dialog.js +0 -80
  168. package/dist/ui/base/dialog.js.map +0 -1
  169. package/dist/ui/base/dialog.mjs +0 -40
  170. package/dist/ui/base/dialog.mjs.map +0 -1
  171. package/dist/ui/base/index.d.ts +0 -6
  172. package/dist/ui/base/index.d.ts.map +0 -1
  173. package/dist/ui/base/index.js +0 -55
  174. package/dist/ui/base/index.js.map +0 -1
  175. package/dist/ui/base/index.mjs +0 -25
  176. package/dist/ui/base/index.mjs.map +0 -1
  177. package/dist/ui/base/tooltip-icon-button.d.ts +0 -17
  178. package/dist/ui/base/tooltip-icon-button.d.ts.map +0 -1
  179. package/dist/ui/base/tooltip-icon-button.js +0 -44
  180. package/dist/ui/base/tooltip-icon-button.js.map +0 -1
  181. package/dist/ui/base/tooltip-icon-button.mjs +0 -19
  182. package/dist/ui/base/tooltip-icon-button.mjs.map +0 -1
  183. package/dist/ui/base/tooltip.d.ts +0 -6
  184. package/dist/ui/base/tooltip.d.ts.map +0 -1
  185. package/dist/ui/base/tooltip.js +0 -57
  186. package/dist/ui/base/tooltip.js.map +0 -1
  187. package/dist/ui/base/tooltip.mjs +0 -20
  188. package/dist/ui/base/tooltip.mjs.map +0 -1
  189. package/dist/ui/branch-picker.d.ts +0 -15
  190. package/dist/ui/branch-picker.d.ts.map +0 -1
  191. package/dist/ui/branch-picker.js +0 -89
  192. package/dist/ui/branch-picker.js.map +0 -1
  193. package/dist/ui/branch-picker.mjs +0 -69
  194. package/dist/ui/branch-picker.mjs.map +0 -1
  195. package/dist/ui/composer.d.ts +0 -25
  196. package/dist/ui/composer.d.ts.map +0 -1
  197. package/dist/ui/composer.js +0 -168
  198. package/dist/ui/composer.js.map +0 -1
  199. package/dist/ui/composer.mjs +0 -138
  200. package/dist/ui/composer.mjs.map +0 -1
  201. package/dist/ui/content-part.d.ts +0 -7
  202. package/dist/ui/content-part.d.ts.map +0 -1
  203. package/dist/ui/content-part.js +0 -61
  204. package/dist/ui/content-part.js.map +0 -1
  205. package/dist/ui/content-part.mjs +0 -27
  206. package/dist/ui/content-part.mjs.map +0 -1
  207. package/dist/ui/edit-composer.d.ts +0 -22
  208. package/dist/ui/edit-composer.d.ts.map +0 -1
  209. package/dist/ui/edit-composer.js +0 -77
  210. package/dist/ui/edit-composer.js.map +0 -1
  211. package/dist/ui/edit-composer.mjs +0 -57
  212. package/dist/ui/edit-composer.mjs.map +0 -1
  213. package/dist/ui/index.d.ts +0 -75
  214. package/dist/ui/index.d.ts.map +0 -1
  215. package/dist/ui/index.js +0 -86
  216. package/dist/ui/index.js.map +0 -1
  217. package/dist/ui/index.mjs +0 -38
  218. package/dist/ui/index.mjs.map +0 -1
  219. package/dist/ui/thread-config.d.ts +0 -162
  220. package/dist/ui/thread-config.d.ts.map +0 -1
  221. package/dist/ui/thread-config.js +0 -63
  222. package/dist/ui/thread-config.js.map +0 -1
  223. package/dist/ui/thread-config.mjs +0 -41
  224. package/dist/ui/thread-config.mjs.map +0 -1
  225. package/dist/ui/thread-list-item.d.ts +0 -13
  226. package/dist/ui/thread-list-item.d.ts.map +0 -1
  227. package/dist/ui/thread-list-item.js +0 -94
  228. package/dist/ui/thread-list-item.js.map +0 -1
  229. package/dist/ui/thread-list-item.mjs +0 -64
  230. package/dist/ui/thread-list-item.mjs.map +0 -1
  231. package/dist/ui/thread-list.d.ts +0 -27
  232. package/dist/ui/thread-list.d.ts.map +0 -1
  233. package/dist/ui/thread-list.js +0 -91
  234. package/dist/ui/thread-list.js.map +0 -1
  235. package/dist/ui/thread-list.mjs +0 -61
  236. package/dist/ui/thread-list.mjs.map +0 -1
  237. package/dist/ui/thread-welcome.d.ts +0 -21
  238. package/dist/ui/thread-welcome.d.ts.map +0 -1
  239. package/dist/ui/thread-welcome.js +0 -101
  240. package/dist/ui/thread-welcome.js.map +0 -1
  241. package/dist/ui/thread-welcome.mjs +0 -81
  242. package/dist/ui/thread-welcome.mjs.map +0 -1
  243. package/dist/ui/thread.d.ts +0 -30
  244. package/dist/ui/thread.d.ts.map +0 -1
  245. package/dist/ui/thread.js +0 -152
  246. package/dist/ui/thread.js.map +0 -1
  247. package/dist/ui/thread.mjs +0 -125
  248. package/dist/ui/thread.mjs.map +0 -1
  249. package/dist/ui/user-action-bar.d.ts +0 -16
  250. package/dist/ui/user-action-bar.d.ts.map +0 -1
  251. package/dist/ui/user-action-bar.js +0 -63
  252. package/dist/ui/user-action-bar.js.map +0 -1
  253. package/dist/ui/user-action-bar.mjs +0 -43
  254. package/dist/ui/user-action-bar.mjs.map +0 -1
  255. package/dist/ui/user-message.d.ts +0 -13
  256. package/dist/ui/user-message.d.ts.map +0 -1
  257. package/dist/ui/user-message.js +0 -96
  258. package/dist/ui/user-message.js.map +0 -1
  259. package/dist/ui/user-message.mjs +0 -65
  260. package/dist/ui/user-message.mjs.map +0 -1
  261. package/dist/ui/utils/withDefaults.d.ts +0 -7
  262. package/dist/ui/utils/withDefaults.d.ts.map +0 -1
  263. package/dist/ui/utils/withDefaults.js +0 -66
  264. package/dist/ui/utils/withDefaults.js.map +0 -1
  265. package/dist/ui/utils/withDefaults.mjs +0 -30
  266. package/dist/ui/utils/withDefaults.mjs.map +0 -1
  267. package/src/primitives/contentPart/ContentPartDisplay.tsx +0 -20
  268. package/src/primitives/contentPart/useContentPartDisplay.tsx +0 -21
  269. package/src/styles/base.css +0 -37
  270. package/src/styles/index.css +0 -4
  271. package/src/styles/modal.css +0 -1
  272. package/src/styles/tailwindcss/base-components.css +0 -69
  273. package/src/styles/tailwindcss/modal.css +0 -29
  274. package/src/styles/tailwindcss/thread.css +0 -262
  275. package/src/styles/themes/default.css +0 -64
  276. package/src/styles/themes/shadcn-extras.css +0 -4
  277. package/src/tailwindcss/index.ts +0 -149
  278. package/src/ui/assistant-action-bar.tsx +0 -301
  279. package/src/ui/assistant-message.tsx +0 -96
  280. package/src/ui/assistant-modal.tsx +0 -146
  281. package/src/ui/attachment-ui.tsx +0 -211
  282. package/src/ui/base/CircleStopIcon.tsx +0 -17
  283. package/src/ui/base/avatar.tsx +0 -41
  284. package/src/ui/base/button.tsx +0 -42
  285. package/src/ui/base/dialog.tsx +0 -113
  286. package/src/ui/base/index.ts +0 -15
  287. package/src/ui/base/tooltip-icon-button.tsx +0 -29
  288. package/src/ui/base/tooltip.tsx +0 -22
  289. package/src/ui/branch-picker.tsx +0 -117
  290. package/src/ui/composer.tsx +0 -210
  291. package/src/ui/content-part.tsx +0 -23
  292. package/src/ui/edit-composer.tsx +0 -98
  293. package/src/ui/index.ts +0 -98
  294. package/src/ui/thread-config.tsx +0 -246
  295. package/src/ui/thread-list-item.tsx +0 -91
  296. package/src/ui/thread-list.tsx +0 -78
  297. package/src/ui/thread-welcome.tsx +0 -140
  298. package/src/ui/thread.tsx +0 -176
  299. package/src/ui/user-action-bar.tsx +0 -66
  300. package/src/ui/user-message.tsx +0 -92
  301. package/src/ui/utils/withDefaults.tsx +0 -35
  302. package/tailwindcss/README.md +0 -1
  303. package/tailwindcss/package-lock.json +0 -6
  304. package/tailwindcss/package.json +0 -5
@@ -1,210 +0,0 @@
1
- "use client";
2
-
3
- import { ComponentPropsWithoutRef, forwardRef, type FC } from "react";
4
-
5
- import { PaperclipIcon, SendHorizontalIcon } from "lucide-react";
6
- import { withDefaults } from "./utils/withDefaults";
7
- import { useThreadConfig } from "./thread-config";
8
- import { TooltipIconButton } from "./base/tooltip-icon-button";
9
- import { CircleStopIcon } from "./base/CircleStopIcon";
10
- import { ComposerPrimitive, ThreadPrimitive } from "../primitives";
11
- import { useThread } from "../context/react/ThreadContext";
12
- import Attachment from "./attachment-ui";
13
-
14
- const useAllowAttachments = (ensureCapability = false) => {
15
- const { composer: { allowAttachments = true } = {} } = useThreadConfig();
16
- const attachmentsSupported = useThread((t) => t.capabilities.attachments);
17
- return allowAttachments && (!ensureCapability || attachmentsSupported);
18
- };
19
-
20
- const Composer: FC = () => {
21
- const allowAttachments = useAllowAttachments(true);
22
- return (
23
- <ComposerRoot>
24
- {allowAttachments && <ComposerAttachments />}
25
- {allowAttachments && <ComposerAddAttachment />}
26
- <ComposerInput autoFocus />
27
- <ComposerAction />
28
- </ComposerRoot>
29
- );
30
- };
31
-
32
- Composer.displayName = "Composer";
33
-
34
- const ComposerRoot = withDefaults(ComposerPrimitive.Root, {
35
- className: "aui-composer-root",
36
- });
37
-
38
- ComposerRoot.displayName = "ComposerRoot";
39
-
40
- const ComposerInputStyled = withDefaults(ComposerPrimitive.Input, {
41
- rows: 1,
42
- autoFocus: true,
43
- className: "aui-composer-input",
44
- });
45
-
46
- namespace ComposerInput {
47
- export type Element = HTMLTextAreaElement;
48
- export type Props = ComponentPropsWithoutRef<typeof ComposerInputStyled>;
49
- }
50
-
51
- const ComposerInput = forwardRef<ComposerInput.Element, ComposerInput.Props>(
52
- (props, ref) => {
53
- const {
54
- strings: {
55
- composer: { input: { placeholder = "Write a message..." } = {} } = {},
56
- } = {},
57
- } = useThreadConfig();
58
- return (
59
- <ComposerInputStyled placeholder={placeholder} {...props} ref={ref} />
60
- );
61
- },
62
- );
63
-
64
- ComposerInput.displayName = "ComposerInput";
65
-
66
- const ComposerAttachmentsContainer = withDefaults("div", {
67
- className: "aui-composer-attachments",
68
- });
69
-
70
- namespace ComposerAttachments {
71
- export type Props = Partial<ComposerPrimitive.Attachments.Props>;
72
- }
73
-
74
- const ComposerAttachments: FC<ComposerAttachments.Props> = ({ components }) => {
75
- return (
76
- <ComposerAttachmentsContainer>
77
- <ComposerPrimitive.Attachments
78
- components={{
79
- ...components,
80
- Attachment: components?.Attachment ?? Attachment,
81
- }}
82
- />
83
- </ComposerAttachmentsContainer>
84
- );
85
- };
86
-
87
- const ComposerAttachButton = withDefaults(TooltipIconButton, {
88
- variant: "default",
89
- className: "aui-composer-attach",
90
- });
91
-
92
- namespace ComposerAddAttachment {
93
- export type Element = HTMLButtonElement;
94
- export type Props = Partial<TooltipIconButton.Props>;
95
- }
96
-
97
- const ComposerAddAttachment = forwardRef<
98
- ComposerAddAttachment.Element,
99
- ComposerAddAttachment.Props
100
- >((props, ref) => {
101
- const {
102
- strings: {
103
- composer: { addAttachment: { tooltip = "Attach file" } = {} } = {},
104
- } = {},
105
- } = useThreadConfig();
106
- const allowAttachments = useAllowAttachments();
107
- return (
108
- <ComposerPrimitive.AddAttachment disabled={!allowAttachments} asChild>
109
- <ComposerAttachButton
110
- tooltip={tooltip}
111
- variant={"ghost"}
112
- {...props}
113
- ref={ref}
114
- >
115
- {props.children ?? <PaperclipIcon />}
116
- </ComposerAttachButton>
117
- </ComposerPrimitive.AddAttachment>
118
- );
119
- });
120
-
121
- ComposerAddAttachment.displayName = "ComposerAddAttachment";
122
-
123
- const useAllowCancel = () => {
124
- const cancelSupported = useThread((t) => t.capabilities.cancel);
125
- return cancelSupported;
126
- };
127
-
128
- const ComposerAction: FC = () => {
129
- const allowCancel = useAllowCancel();
130
- if (!allowCancel) return <ComposerSend />;
131
- return (
132
- <>
133
- <ThreadPrimitive.If running={false}>
134
- <ComposerSend />
135
- </ThreadPrimitive.If>
136
- <ThreadPrimitive.If running>
137
- <ComposerCancel />
138
- </ThreadPrimitive.If>
139
- </>
140
- );
141
- };
142
-
143
- ComposerAction.displayName = "ComposerAction";
144
-
145
- const ComposerSendButton = withDefaults(TooltipIconButton, {
146
- variant: "default",
147
- className: "aui-composer-send",
148
- });
149
-
150
- namespace ComposerSend {
151
- export type Element = HTMLButtonElement;
152
- export type Props = Partial<TooltipIconButton.Props>;
153
- }
154
-
155
- const ComposerSend = forwardRef<ComposerSend.Element, ComposerSend.Props>(
156
- (props, ref) => {
157
- const {
158
- strings: { composer: { send: { tooltip = "Send" } = {} } = {} } = {},
159
- } = useThreadConfig();
160
- return (
161
- <ComposerPrimitive.Send asChild>
162
- <ComposerSendButton tooltip={tooltip} {...props} ref={ref}>
163
- {props.children ?? <SendHorizontalIcon />}
164
- </ComposerSendButton>
165
- </ComposerPrimitive.Send>
166
- );
167
- },
168
- );
169
-
170
- ComposerSend.displayName = "ComposerSend";
171
-
172
- const ComposerCancelButton = withDefaults(TooltipIconButton, {
173
- variant: "default",
174
- className: "aui-composer-cancel",
175
- });
176
-
177
- namespace ComposerCancel {
178
- export type Element = HTMLButtonElement;
179
- export type Props = Partial<TooltipIconButton.Props>;
180
- }
181
-
182
- const ComposerCancel = forwardRef<ComposerCancel.Element, ComposerCancel.Props>(
183
- (props, ref) => {
184
- const {
185
- strings: { composer: { cancel: { tooltip = "Cancel" } = {} } = {} } = {},
186
- } = useThreadConfig();
187
- return (
188
- <ComposerPrimitive.Cancel asChild>
189
- <ComposerCancelButton tooltip={tooltip} {...props} ref={ref}>
190
- {props.children ?? <CircleStopIcon />}
191
- </ComposerCancelButton>
192
- </ComposerPrimitive.Cancel>
193
- );
194
- },
195
- );
196
-
197
- ComposerCancel.displayName = "ComposerCancel";
198
-
199
- const exports = {
200
- Root: ComposerRoot,
201
- Input: ComposerInput,
202
- Action: ComposerAction,
203
- Send: ComposerSend,
204
- Cancel: ComposerCancel,
205
- AddAttachment: ComposerAddAttachment,
206
- Attachments: ComposerAttachments,
207
- };
208
-
209
- export default Object.assign(Composer, exports) as typeof Composer &
210
- typeof exports;
@@ -1,23 +0,0 @@
1
- "use client";
2
-
3
- import { FC } from "react";
4
- import { ContentPartPrimitive } from "../primitives";
5
- import { useSmoothStatus, withSmoothContextProvider } from "../utils/smooth";
6
- import classNames from "classnames";
7
-
8
- export const Text: FC = () => {
9
- const status = useSmoothStatus();
10
- return (
11
- <ContentPartPrimitive.Text
12
- className={classNames(
13
- "aui-text",
14
- status.type === "running" && "aui-text-running",
15
- )}
16
- component="p"
17
- />
18
- );
19
- };
20
-
21
- const exports = { Text: withSmoothContextProvider(Text) };
22
-
23
- export default exports;
@@ -1,98 +0,0 @@
1
- "use client";
2
-
3
- import { forwardRef, type FC } from "react";
4
-
5
- import { Button, ButtonProps } from "./base/button";
6
- import { withDefaults } from "./utils/withDefaults";
7
- import { useThreadConfig } from "./thread-config";
8
- import { ComposerPrimitive } from "../primitives";
9
-
10
- const EditComposer: FC = () => {
11
- return (
12
- <EditComposerRoot>
13
- <EditComposerInput />
14
-
15
- <EditComposerFooter>
16
- <EditComposerCancel />
17
- <EditComposerSend />
18
- </EditComposerFooter>
19
- </EditComposerRoot>
20
- );
21
- };
22
-
23
- EditComposer.displayName = "EditComposer";
24
-
25
- const EditComposerRoot = withDefaults(ComposerPrimitive.Root, {
26
- className: "aui-edit-composer-root",
27
- });
28
-
29
- EditComposerRoot.displayName = "EditComposerRoot";
30
-
31
- const EditComposerInput = withDefaults(ComposerPrimitive.Input, {
32
- className: "aui-edit-composer-input",
33
- });
34
-
35
- EditComposerInput.displayName = "EditComposerInput";
36
-
37
- const EditComposerFooter = withDefaults("div", {
38
- className: "aui-edit-composer-footer",
39
- });
40
-
41
- EditComposerFooter.displayName = "EditComposerFooter";
42
-
43
- namespace EditComposerCancel {
44
- export type Element = HTMLButtonElement;
45
- export type Props = Partial<ButtonProps>;
46
- }
47
-
48
- const EditComposerCancel = forwardRef<
49
- EditComposerCancel.Element,
50
- EditComposerCancel.Props
51
- >((props, ref) => {
52
- const {
53
- strings: { editComposer: { cancel: { label = "Cancel" } = {} } = {} } = {},
54
- } = useThreadConfig();
55
- return (
56
- <ComposerPrimitive.Cancel asChild>
57
- <Button variant="ghost" {...props} ref={ref}>
58
- {props.children ?? label}
59
- </Button>
60
- </ComposerPrimitive.Cancel>
61
- );
62
- });
63
-
64
- EditComposerCancel.displayName = "EditComposerCancel";
65
-
66
- namespace EditComposerSend {
67
- export type Element = HTMLButtonElement;
68
- export type Props = Partial<ButtonProps>;
69
- }
70
-
71
- const EditComposerSend = forwardRef<
72
- EditComposerSend.Element,
73
- EditComposerSend.Props
74
- >((props, ref) => {
75
- const {
76
- strings: { editComposer: { send: { label = "Send" } = {} } = {} } = {},
77
- } = useThreadConfig();
78
- return (
79
- <ComposerPrimitive.Send asChild>
80
- <Button {...props} ref={ref}>
81
- {props.children ?? label}
82
- </Button>
83
- </ComposerPrimitive.Send>
84
- );
85
- });
86
-
87
- EditComposerSend.displayName = "EditComposerSend";
88
-
89
- const exports = {
90
- Root: EditComposerRoot,
91
- Input: EditComposerInput,
92
- Footer: EditComposerFooter,
93
- Cancel: EditComposerCancel,
94
- Send: EditComposerSend,
95
- };
96
-
97
- export default Object.assign(EditComposer, exports) as typeof EditComposer &
98
- typeof exports;
package/src/ui/index.ts DELETED
@@ -1,98 +0,0 @@
1
- /** @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`. */
2
- export { ThreadConfigProvider } from "./thread-config";
3
-
4
- /** @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`. */
5
- export { useThreadConfig } from "./thread-config";
6
-
7
- /** @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`. */
8
- export type { ThreadConfig } from "./thread-config";
9
-
10
- /** @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`. */
11
- export type { ThreadWelcomeConfig } from "./thread-config";
12
-
13
- /** @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`. */
14
- export type { UserMessageConfig } from "./thread-config";
15
-
16
- /** @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`. */
17
- export type { AssistantMessageConfig } from "./thread-config";
18
-
19
- /** @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`. */
20
- export type { StringsConfig } from "./thread-config";
21
-
22
- /** @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`. */
23
- export type { SuggestionConfig } from "./thread-config";
24
-
25
- /** @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`. */
26
- export type { ThreadConfigProviderProps } from "./thread-config";
27
-
28
- /**
29
- * @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`.
30
- */
31
- export { default as AssistantActionBar } from "./assistant-action-bar";
32
-
33
- /**
34
- * @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`.
35
- */
36
- export { default as AssistantMessage } from "./assistant-message";
37
-
38
- /**
39
- * @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`.
40
- */
41
- export { default as AssistantModal } from "./assistant-modal";
42
-
43
- /**
44
- * @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`.
45
- */
46
- export { default as BranchPicker } from "./branch-picker";
47
-
48
- /**
49
- * @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`.
50
- */
51
- export { default as Composer } from "./composer";
52
-
53
- /**
54
- * @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`.
55
- */
56
- export { default as ContentPart } from "./content-part";
57
-
58
- /**
59
- * @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`.
60
- */
61
- export {
62
- default as AttachmentUI, // TODO name collision with Attachment
63
- } from "./attachment-ui";
64
-
65
- /**
66
- * @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`.
67
- */
68
- export { default as EditComposer } from "./edit-composer";
69
-
70
- /**
71
- * @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`.
72
- */
73
- export { default as Thread } from "./thread";
74
-
75
- /**
76
- * @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`.
77
- */
78
- export { default as ThreadList } from "./thread-list";
79
-
80
- /**
81
- * @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`.
82
- */
83
- export { default as ThreadListItem } from "./thread-list-item";
84
-
85
- /**
86
- * @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`.
87
- */
88
- export { default as ThreadWelcome } from "./thread-welcome";
89
-
90
- /**
91
- * @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`.
92
- */
93
- export { default as UserMessage } from "./user-message";
94
-
95
- /**
96
- * @deprecated This export was moved to `@assistant-ui/react-ui`. Use the migration codemod to update your code, by running `npx assistant-ui upgrade`.
97
- */
98
- export { default as UserActionBar } from "./user-action-bar";
@@ -1,246 +0,0 @@
1
- "use client";
2
-
3
- import {
4
- ComponentType,
5
- FC,
6
- PropsWithChildren,
7
- ReactNode,
8
- createContext,
9
- useContext,
10
- } from "react";
11
-
12
- import { AssistantRuntime } from "../api/AssistantRuntime";
13
- import { AvatarProps } from "./base/avatar";
14
- import {
15
- EmptyContentPartComponent,
16
- TextContentPartComponent,
17
- ToolCallContentPartProps,
18
- } from "../types";
19
- import { AssistantRuntimeProvider } from "../context";
20
- import { AssistantToolUI } from "../model-context";
21
- import { useAssistantRuntime } from "../context/react/AssistantContext";
22
-
23
- export type SuggestionConfig = {
24
- text?: ReactNode | undefined;
25
- prompt: string;
26
- };
27
-
28
- export type ThreadWelcomeConfig = {
29
- message?: string | null | undefined;
30
- suggestions?: SuggestionConfig[] | undefined;
31
- };
32
-
33
- export type UserMessageConfig = {
34
- allowEdit?: boolean | undefined;
35
- };
36
-
37
- export type AssistantMessageConfig = {
38
- allowReload?: boolean | undefined;
39
- allowCopy?: boolean | undefined;
40
- allowSpeak?: boolean | undefined;
41
- allowFeedbackPositive?: boolean | undefined;
42
- allowFeedbackNegative?: boolean | undefined;
43
- components?:
44
- | {
45
- Text?: TextContentPartComponent | undefined;
46
- Empty?: EmptyContentPartComponent | undefined;
47
- ToolFallback?: ComponentType<ToolCallContentPartProps> | undefined;
48
- Footer?: ComponentType | undefined;
49
- }
50
- | undefined;
51
- };
52
-
53
- export type BranchPickerConfig = {
54
- allowBranchPicker?: boolean | undefined;
55
- };
56
-
57
- export type ComposerConfig = {
58
- allowAttachments?: boolean | undefined;
59
- };
60
-
61
- export type StringsConfig = {
62
- assistantModal?: {
63
- open: {
64
- button: {
65
- tooltip?: string | undefined;
66
- };
67
- };
68
- closed: {
69
- button: {
70
- tooltip?: string | undefined;
71
- };
72
- };
73
- };
74
- threadList?: {
75
- new?: {
76
- label?: string | undefined;
77
- };
78
- item?: {
79
- title?: {
80
- fallback?: string | undefined;
81
- };
82
- archive?: {
83
- tooltip?: string | undefined;
84
- };
85
- };
86
- };
87
- thread?: {
88
- scrollToBottom?: {
89
- tooltip?: string | undefined;
90
- };
91
- };
92
- welcome?: {
93
- message?: string | undefined;
94
- };
95
- userMessage?: {
96
- edit?: {
97
- tooltip?: string | undefined;
98
- };
99
- };
100
- assistantMessage?: {
101
- reload?: {
102
- tooltip?: string | undefined;
103
- };
104
- copy?: {
105
- tooltip?: string | undefined;
106
- };
107
- speak?: {
108
- tooltip?: string | undefined;
109
- stop?: {
110
- tooltip?: string | undefined;
111
- };
112
- };
113
- feedback?: {
114
- positive?: {
115
- tooltip?: string | undefined;
116
- };
117
- negative?: {
118
- tooltip?: string | undefined;
119
- };
120
- };
121
- };
122
- branchPicker?: {
123
- previous?: {
124
- tooltip?: string | undefined;
125
- };
126
- next?: {
127
- tooltip?: string | undefined;
128
- };
129
- };
130
- composer?: {
131
- send?:
132
- | {
133
- tooltip?: string | undefined;
134
- }
135
- | undefined;
136
- cancel?:
137
- | {
138
- tooltip?: string | undefined;
139
- }
140
- | undefined;
141
- addAttachment?:
142
- | {
143
- tooltip?: string | undefined;
144
- }
145
- | undefined;
146
- removeAttachment?: {
147
- tooltip?: string | undefined;
148
- };
149
- input?: {
150
- placeholder?: string | undefined;
151
- };
152
- };
153
- editComposer?: {
154
- send?: {
155
- label?: string | undefined;
156
- };
157
- cancel?: {
158
- label?: string | undefined;
159
- };
160
- };
161
- code?: {
162
- header?: {
163
- copy?: {
164
- tooltip?: string | undefined;
165
- };
166
- };
167
- };
168
- };
169
-
170
- const ThreadConfigContext = createContext<ThreadConfig>({});
171
-
172
- export type ThreadConfig = {
173
- runtime?: AssistantRuntime | undefined;
174
-
175
- assistantAvatar?: AvatarProps | undefined;
176
-
177
- welcome?: ThreadWelcomeConfig | undefined;
178
- assistantMessage?: AssistantMessageConfig | undefined;
179
- userMessage?: UserMessageConfig | undefined;
180
-
181
- branchPicker?: BranchPickerConfig | undefined;
182
-
183
- composer?: ComposerConfig | undefined;
184
-
185
- strings?: StringsConfig | undefined;
186
-
187
- tools?: AssistantToolUI[] | undefined; // TODO add AssistantTool support
188
-
189
- components?:
190
- | {
191
- UserMessage?: ComponentType | undefined;
192
- AssistantMessage?: ComponentType | undefined;
193
- EditComposer?: ComponentType | undefined;
194
- Composer?: ComponentType | undefined;
195
- ThreadWelcome?: ComponentType | undefined;
196
- MessagesFooter?: ComponentType | undefined;
197
- }
198
- | undefined;
199
- };
200
-
201
- export const useThreadConfig = (): Omit<ThreadConfig, "runtime"> => {
202
- return useContext(ThreadConfigContext);
203
- };
204
-
205
- export type ThreadConfigProviderProps = PropsWithChildren<{
206
- config?: ThreadConfig | undefined;
207
- }>;
208
-
209
- export const ThreadConfigProvider: FC<ThreadConfigProviderProps> = ({
210
- children,
211
- config,
212
- }) => {
213
- const hasAssistant = !!useAssistantRuntime({ optional: true });
214
-
215
- const hasConfig = config && Object.keys(config).length > 0;
216
- const outerConfig = useThreadConfig();
217
-
218
- if (hasConfig && Object.keys(outerConfig).length > 0) {
219
- throw new Error(
220
- "You are providing ThreadConfig to several nested components. Please provide all configuration to the same component.",
221
- );
222
- }
223
-
224
- const configProvider = hasConfig ? (
225
- <ThreadConfigContext.Provider value={config}>
226
- {children}
227
- </ThreadConfigContext.Provider>
228
- ) : (
229
- <>{children}</>
230
- );
231
-
232
- if (!config?.runtime) return configProvider;
233
-
234
- if (hasAssistant) {
235
- throw new Error(
236
- "You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed.",
237
- );
238
- }
239
- return (
240
- <AssistantRuntimeProvider runtime={config.runtime}>
241
- {configProvider}
242
- </AssistantRuntimeProvider>
243
- );
244
- };
245
-
246
- ThreadConfigProvider.displayName = "ThreadConfigProvider";