@assistant-ui/react 0.10.22 → 0.10.24

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/dist/cloud/AssistantCloudThreadHistoryAdapter.d.ts +1 -1
  2. package/dist/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
  3. package/dist/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
  4. package/dist/cloud/auiV0.d.ts +1 -1
  5. package/dist/cloud/auiV0.d.ts.map +1 -1
  6. package/dist/cloud/auiV0.js.map +1 -1
  7. package/dist/cloud/index.d.ts +1 -1
  8. package/dist/cloud/index.d.ts.map +1 -1
  9. package/dist/cloud/index.js +1 -1
  10. package/dist/cloud/index.js.map +1 -1
  11. package/dist/cloud/useCloudThreadListRuntime.d.ts +1 -1
  12. package/dist/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
  13. package/dist/cloud/useCloudThreadListRuntime.js.map +1 -1
  14. package/dist/context/react/AssistantContext.d.ts +23 -0
  15. package/dist/context/react/AssistantContext.d.ts.map +1 -1
  16. package/dist/context/react/AssistantContext.js.map +1 -1
  17. package/dist/context/react/ComposerContext.d.ts +64 -0
  18. package/dist/context/react/ComposerContext.d.ts.map +1 -1
  19. package/dist/context/react/ComposerContext.js.map +1 -1
  20. package/dist/context/react/MessageContext.d.ts +56 -0
  21. package/dist/context/react/MessageContext.d.ts.map +1 -1
  22. package/dist/context/react/MessageContext.js.map +1 -1
  23. package/dist/context/react/ThreadContext.d.ts +42 -0
  24. package/dist/context/react/ThreadContext.d.ts.map +1 -1
  25. package/dist/context/react/ThreadContext.js.map +1 -1
  26. package/dist/primitives/actionBar/ActionBarCopy.d.ts +42 -0
  27. package/dist/primitives/actionBar/ActionBarCopy.d.ts.map +1 -1
  28. package/dist/primitives/actionBar/ActionBarCopy.js.map +1 -1
  29. package/dist/primitives/actionBar/ActionBarEdit.d.ts +38 -0
  30. package/dist/primitives/actionBar/ActionBarEdit.d.ts.map +1 -1
  31. package/dist/primitives/actionBar/ActionBarEdit.js.map +1 -1
  32. package/dist/primitives/actionBar/ActionBarReload.d.ts +39 -0
  33. package/dist/primitives/actionBar/ActionBarReload.d.ts.map +1 -1
  34. package/dist/primitives/actionBar/ActionBarReload.js.map +1 -1
  35. package/dist/primitives/actionBar/ActionBarRoot.d.ts +56 -0
  36. package/dist/primitives/actionBar/ActionBarRoot.d.ts.map +1 -1
  37. package/dist/primitives/actionBar/ActionBarRoot.js.map +1 -1
  38. package/dist/primitives/attachment/AttachmentRoot.d.ts +18 -0
  39. package/dist/primitives/attachment/AttachmentRoot.d.ts.map +1 -1
  40. package/dist/primitives/attachment/AttachmentRoot.js.map +1 -1
  41. package/dist/primitives/branchPicker/BranchPickerCount.d.ts +17 -0
  42. package/dist/primitives/branchPicker/BranchPickerCount.d.ts.map +1 -1
  43. package/dist/primitives/branchPicker/BranchPickerCount.js.map +1 -1
  44. package/dist/primitives/branchPicker/BranchPickerNext.d.ts +17 -0
  45. package/dist/primitives/branchPicker/BranchPickerNext.d.ts.map +1 -1
  46. package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
  47. package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts +38 -0
  48. package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts.map +1 -1
  49. package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
  50. package/dist/primitives/branchPicker/BranchPickerRoot.d.ts +27 -0
  51. package/dist/primitives/branchPicker/BranchPickerRoot.d.ts.map +1 -1
  52. package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
  53. package/dist/primitives/composer/ComposerAttachments.d.ts.map +1 -1
  54. package/dist/primitives/composer/ComposerAttachments.js +11 -8
  55. package/dist/primitives/composer/ComposerAttachments.js.map +1 -1
  56. package/dist/primitives/composer/ComposerCancel.d.ts +17 -0
  57. package/dist/primitives/composer/ComposerCancel.d.ts.map +1 -1
  58. package/dist/primitives/composer/ComposerCancel.js.map +1 -1
  59. package/dist/primitives/composer/ComposerInput.d.ts +72 -0
  60. package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
  61. package/dist/primitives/composer/ComposerInput.js.map +1 -1
  62. package/dist/primitives/composer/ComposerRoot.d.ts +19 -0
  63. package/dist/primitives/composer/ComposerRoot.d.ts.map +1 -1
  64. package/dist/primitives/composer/ComposerRoot.js.map +1 -1
  65. package/dist/primitives/composer/ComposerSend.d.ts +18 -0
  66. package/dist/primitives/composer/ComposerSend.d.ts.map +1 -1
  67. package/dist/primitives/composer/ComposerSend.js.map +1 -1
  68. package/dist/primitives/contentPart/ContentPartImage.d.ts +19 -0
  69. package/dist/primitives/contentPart/ContentPartImage.d.ts.map +1 -1
  70. package/dist/primitives/contentPart/ContentPartImage.js.map +1 -1
  71. package/dist/primitives/contentPart/ContentPartText.d.ts +34 -0
  72. package/dist/primitives/contentPart/ContentPartText.d.ts.map +1 -1
  73. package/dist/primitives/contentPart/ContentPartText.js.map +1 -1
  74. package/dist/primitives/message/MessageAttachments.d.ts.map +1 -1
  75. package/dist/primitives/message/MessageAttachments.js +11 -8
  76. package/dist/primitives/message/MessageAttachments.js.map +1 -1
  77. package/dist/primitives/message/MessageContent.d.ts +41 -0
  78. package/dist/primitives/message/MessageContent.d.ts.map +1 -1
  79. package/dist/primitives/message/MessageContent.js +14 -11
  80. package/dist/primitives/message/MessageContent.js.map +1 -1
  81. package/dist/primitives/message/MessageRoot.d.ts +22 -0
  82. package/dist/primitives/message/MessageRoot.d.ts.map +1 -1
  83. package/dist/primitives/message/MessageRoot.js.map +1 -1
  84. package/dist/primitives/thread/ThreadMessages.d.ts +44 -0
  85. package/dist/primitives/thread/ThreadMessages.d.ts.map +1 -1
  86. package/dist/primitives/thread/ThreadMessages.js +5 -2
  87. package/dist/primitives/thread/ThreadMessages.js.map +1 -1
  88. package/dist/primitives/thread/ThreadRoot.d.ts +19 -0
  89. package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
  90. package/dist/primitives/thread/ThreadRoot.js.map +1 -1
  91. package/dist/primitives/thread/ThreadViewport.d.ts +24 -0
  92. package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
  93. package/dist/primitives/thread/ThreadViewport.js.map +1 -1
  94. package/dist/primitives/threadList/ThreadListItems.d.ts.map +1 -1
  95. package/dist/primitives/threadList/ThreadListItems.js +12 -9
  96. package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
  97. package/dist/runtimes/adapters/attachment/AttachmentAdapter.d.ts +54 -0
  98. package/dist/runtimes/adapters/attachment/AttachmentAdapter.d.ts.map +1 -1
  99. package/dist/runtimes/adapters/feedback/FeedbackAdapter.d.ts +33 -0
  100. package/dist/runtimes/adapters/feedback/FeedbackAdapter.d.ts.map +1 -1
  101. package/dist/runtimes/adapters/speech/SpeechAdapterTypes.d.ts +47 -0
  102. package/dist/runtimes/adapters/speech/SpeechAdapterTypes.d.ts.map +1 -1
  103. package/dist/runtimes/local/LocalRuntimeOptions.d.ts +2 -2
  104. package/dist/runtimes/local/LocalRuntimeOptions.d.ts.map +1 -1
  105. package/dist/runtimes/local/LocalRuntimeOptions.js.map +1 -1
  106. package/dist/runtimes/local/index.d.ts +1 -1
  107. package/dist/runtimes/local/index.d.ts.map +1 -1
  108. package/dist/runtimes/local/index.js +3 -2
  109. package/dist/runtimes/local/index.js.map +1 -1
  110. package/dist/runtimes/remote-thread-list/adapter/cloud.d.ts +1 -1
  111. package/dist/runtimes/remote-thread-list/adapter/cloud.d.ts.map +1 -1
  112. package/dist/runtimes/remote-thread-list/adapter/cloud.js +1 -1
  113. package/dist/runtimes/remote-thread-list/adapter/cloud.js.map +1 -1
  114. package/dist/tests/setup.js +8 -8
  115. package/dist/tests/setup.js.map +1 -1
  116. package/package.json +8 -7
  117. package/src/cloud/AssistantCloudThreadHistoryAdapter.tsx +1 -1
  118. package/src/cloud/auiV0.ts +1 -1
  119. package/src/cloud/index.ts +1 -1
  120. package/src/cloud/useCloudThreadListRuntime.tsx +1 -1
  121. package/src/context/react/AssistantContext.ts +23 -0
  122. package/src/context/react/ComposerContext.ts +64 -0
  123. package/src/context/react/MessageContext.ts +56 -0
  124. package/src/context/react/ThreadContext.ts +42 -0
  125. package/src/primitives/actionBar/ActionBarCopy.tsx +42 -0
  126. package/src/primitives/actionBar/ActionBarEdit.tsx +38 -0
  127. package/src/primitives/actionBar/ActionBarReload.tsx +39 -0
  128. package/src/primitives/actionBar/ActionBarRoot.tsx +38 -0
  129. package/src/primitives/attachment/AttachmentRoot.tsx +18 -0
  130. package/src/primitives/branchPicker/BranchPickerCount.tsx +17 -0
  131. package/src/primitives/branchPicker/BranchPickerNext.tsx +17 -0
  132. package/src/primitives/branchPicker/BranchPickerPrevious.tsx +38 -0
  133. package/src/primitives/branchPicker/BranchPickerRoot.tsx +22 -0
  134. package/src/primitives/composer/ComposerAttachments.tsx +11 -7
  135. package/src/primitives/composer/ComposerCancel.tsx +17 -0
  136. package/src/primitives/composer/ComposerInput.tsx +44 -0
  137. package/src/primitives/composer/ComposerRoot.tsx +19 -0
  138. package/src/primitives/composer/ComposerSend.tsx +18 -0
  139. package/src/primitives/contentPart/ContentPartImage.tsx +19 -0
  140. package/src/primitives/contentPart/ContentPartText.tsx +25 -0
  141. package/src/primitives/message/MessageAttachments.tsx +11 -7
  142. package/src/primitives/message/MessageContent.tsx +54 -18
  143. package/src/primitives/message/MessageRoot.tsx +22 -0
  144. package/src/primitives/thread/ThreadMessages.tsx +52 -4
  145. package/src/primitives/thread/ThreadRoot.tsx +19 -0
  146. package/src/primitives/thread/ThreadViewport.tsx +19 -0
  147. package/src/primitives/threadList/ThreadListItems.tsx +12 -8
  148. package/src/runtimes/adapters/attachment/AttachmentAdapter.ts +56 -0
  149. package/src/runtimes/adapters/feedback/FeedbackAdapter.ts +33 -0
  150. package/src/runtimes/adapters/speech/SpeechAdapterTypes.ts +47 -0
  151. package/src/runtimes/local/LocalRuntimeOptions.tsx +1 -1
  152. package/src/runtimes/local/index.ts +1 -1
  153. package/src/runtimes/remote-thread-list/adapter/cloud.tsx +1 -1
  154. package/dist/cloud/AssistantCloud.d.ts +0 -15
  155. package/dist/cloud/AssistantCloud.d.ts.map +0 -1
  156. package/dist/cloud/AssistantCloud.js +0 -25
  157. package/dist/cloud/AssistantCloud.js.map +0 -1
  158. package/dist/cloud/AssistantCloudAPI.d.ts +0 -28
  159. package/dist/cloud/AssistantCloudAPI.d.ts.map +0 -1
  160. package/dist/cloud/AssistantCloudAPI.js +0 -87
  161. package/dist/cloud/AssistantCloudAPI.js.map +0 -1
  162. package/dist/cloud/AssistantCloudAuthStrategy.d.ts +0 -30
  163. package/dist/cloud/AssistantCloudAuthStrategy.d.ts.map +0 -1
  164. package/dist/cloud/AssistantCloudAuthStrategy.js +0 -139
  165. package/dist/cloud/AssistantCloudAuthStrategy.js.map +0 -1
  166. package/dist/cloud/AssistantCloudAuthTokens.d.ts +0 -11
  167. package/dist/cloud/AssistantCloudAuthTokens.d.ts.map +0 -1
  168. package/dist/cloud/AssistantCloudAuthTokens.js +0 -13
  169. package/dist/cloud/AssistantCloudAuthTokens.js.map +0 -1
  170. package/dist/cloud/AssistantCloudFiles.d.ts +0 -27
  171. package/dist/cloud/AssistantCloudFiles.d.ts.map +0 -1
  172. package/dist/cloud/AssistantCloudFiles.js +0 -22
  173. package/dist/cloud/AssistantCloudFiles.js.map +0 -1
  174. package/dist/cloud/AssistantCloudRuns.d.ts +0 -26
  175. package/dist/cloud/AssistantCloudRuns.d.ts.map +0 -1
  176. package/dist/cloud/AssistantCloudRuns.js +0 -39
  177. package/dist/cloud/AssistantCloudRuns.js.map +0 -1
  178. package/dist/cloud/AssistantCloudThreadMessages.d.ts +0 -30
  179. package/dist/cloud/AssistantCloudThreadMessages.d.ts.map +0 -1
  180. package/dist/cloud/AssistantCloudThreadMessages.js +0 -21
  181. package/dist/cloud/AssistantCloudThreadMessages.js.map +0 -1
  182. package/dist/cloud/AssistantCloudThreads.d.ts +0 -48
  183. package/dist/cloud/AssistantCloudThreads.d.ts.map +0 -1
  184. package/dist/cloud/AssistantCloudThreads.js +0 -30
  185. package/dist/cloud/AssistantCloudThreads.js.map +0 -1
  186. package/src/cloud/AssistantCloud.tsx +0 -22
  187. package/src/cloud/AssistantCloudAPI.tsx +0 -121
  188. package/src/cloud/AssistantCloudAuthStrategy.tsx +0 -193
  189. package/src/cloud/AssistantCloudAuthTokens.tsx +0 -13
  190. package/src/cloud/AssistantCloudFiles.tsx +0 -45
  191. package/src/cloud/AssistantCloudRuns.tsx +0 -45
  192. package/src/cloud/AssistantCloudThreadMessages.tsx +0 -48
  193. package/src/cloud/AssistantCloudThreads.tsx +0 -79
  194. package/src/tests/AssistantCloudFiles.test.ts +0 -521
package/package.json CHANGED
@@ -28,7 +28,7 @@
28
28
  "conversational-ui",
29
29
  "conversational-ai"
30
30
  ],
31
- "version": "0.10.22",
31
+ "version": "0.10.24",
32
32
  "license": "MIT",
33
33
  "type": "module",
34
34
  "exports": {
@@ -57,12 +57,13 @@
57
57
  "@radix-ui/react-use-callback-ref": "^1.1.1",
58
58
  "@radix-ui/react-use-escape-keydown": "^1.1.1",
59
59
  "@standard-schema/spec": "^1.0.0",
60
- "assistant-stream": "^0.2.15",
60
+ "assistant-stream": "^0.2.17",
61
61
  "json-schema": "^0.4.0",
62
62
  "nanoid": "5.1.5",
63
63
  "react-textarea-autosize": "^8.5.9",
64
- "zod": "^3.25.49",
65
- "zustand": "^5.0.5"
64
+ "zod": "^3.25.64",
65
+ "zustand": "^5.0.5",
66
+ "assistant-cloud": "0.0.2"
66
67
  },
67
68
  "peerDependencies": {
68
69
  "@types/react": "*",
@@ -82,11 +83,11 @@
82
83
  "@stryker-mutator/core": "^9.0.1",
83
84
  "@stryker-mutator/vitest-runner": "^9.0.1",
84
85
  "@types/json-schema": "^7.0.15",
85
- "@types/node": "^22.15.29",
86
+ "@types/node": "^24.0.1",
86
87
  "eslint": "^9",
87
88
  "eslint-config-next": "15.3.3",
88
- "tsx": "^4.19.4",
89
- "vitest": "^3.2.0",
89
+ "tsx": "^4.20.3",
90
+ "vitest": "^3.2.3",
90
91
  "@assistant-ui/x-buildutils": "0.0.1"
91
92
  },
92
93
  "publishConfig": {
@@ -2,7 +2,7 @@ import { RefObject, useState } from "react";
2
2
  import { useThreadListItemRuntime } from "../context";
3
3
  import { ThreadHistoryAdapter } from "../runtimes/adapters/thread-history/ThreadHistoryAdapter";
4
4
  import { ExportedMessageRepositoryItem } from "../runtimes/utils/MessageRepository";
5
- import { AssistantCloud } from "./AssistantCloud";
5
+ import { AssistantCloud } from "assistant-cloud";
6
6
  import { auiV0Decode, auiV0Encode } from "./auiV0";
7
7
  import { ThreadListItemRuntime } from "../api";
8
8
 
@@ -1,7 +1,7 @@
1
1
  import { ThreadMessage } from "../types";
2
2
  import { MessageStatus } from "../types/AssistantTypes";
3
3
  import { fromThreadMessageLike } from "../runtimes/external-store/ThreadMessageLike";
4
- import { CloudMessage } from "./AssistantCloudThreadMessages";
4
+ import { CloudMessage } from "assistant-cloud";
5
5
  import { isJSONValue } from "../utils/json/is-json";
6
6
  import { ReadonlyJSONObject, ReadonlyJSONValue } from "assistant-stream/utils";
7
7
  import { ExportedMessageRepositoryItem } from "../runtimes/utils/MessageRepository";
@@ -1,2 +1,2 @@
1
1
  export { useCloudThreadListRuntime } from "./useCloudThreadListRuntime";
2
- export { AssistantCloud } from "./AssistantCloud";
2
+ export { AssistantCloud } from "assistant-cloud";
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { AssistantCloud } from "./AssistantCloud";
3
+ import { AssistantCloud } from "assistant-cloud";
4
4
  import { AssistantRuntime } from "../api";
5
5
  import { useRemoteThreadListRuntime } from "../runtimes/remote-thread-list/useRemoteThreadListRuntime";
6
6
  import { useCloudThreadListAdapter } from "../runtimes/remote-thread-list/adapter/cloud";
@@ -24,6 +24,29 @@ export const useAssistantContext = createContextHook(
24
24
  "AssistantRuntimeProvider",
25
25
  );
26
26
 
27
+ /**
28
+ * Hook to access the AssistantRuntime from the current context.
29
+ *
30
+ * The AssistantRuntime provides access to the top-level assistant state and actions,
31
+ * including thread management, tool registration, and configuration.
32
+ *
33
+ * @param options Configuration options
34
+ * @param options.optional Whether the hook should return null if no context is found
35
+ * @returns The AssistantRuntime instance, or null if optional is true and no context exists
36
+ *
37
+ * @example
38
+ * ```tsx
39
+ * function MyComponent() {
40
+ * const runtime = useAssistantRuntime();
41
+ *
42
+ * const handleNewThread = () => {
43
+ * runtime.switchToNewThread();
44
+ * };
45
+ *
46
+ * return <button onClick={handleNewThread}>New Thread</button>;
47
+ * }
48
+ * ```
49
+ */
27
50
  export function useAssistantRuntime(options?: {
28
51
  optional?: false | undefined;
29
52
  }): AssistantRuntime;
@@ -5,6 +5,44 @@ import { useThreadRuntime } from "./ThreadContext";
5
5
  import { ComposerRuntime } from "../../api/ComposerRuntime";
6
6
  import { createStateHookForRuntime } from "./utils/createStateHookForRuntime";
7
7
 
8
+ /**
9
+ * Hook to access the ComposerRuntime from the current context.
10
+ *
11
+ * The ComposerRuntime provides access to composer state and actions for message
12
+ * composition, including text input, attachments, and sending functionality.
13
+ * This hook automatically resolves to either the message's edit composer or
14
+ * the thread's main composer depending on the context.
15
+ *
16
+ * @param options Configuration options
17
+ * @param options.optional Whether the hook should return null if no context is found
18
+ * @returns The ComposerRuntime instance, or null if optional is true and no context exists
19
+ *
20
+ * @example
21
+ * ```tsx
22
+ * function ComposerActions() {
23
+ * const runtime = useComposerRuntime();
24
+ *
25
+ * const handleSend = () => {
26
+ * if (runtime.getState().canSend) {
27
+ * runtime.send();
28
+ * }
29
+ * };
30
+ *
31
+ * const handleCancel = () => {
32
+ * if (runtime.getState().canCancel) {
33
+ * runtime.cancel();
34
+ * }
35
+ * };
36
+ *
37
+ * return (
38
+ * <div>
39
+ * <button onClick={handleSend}>Send</button>
40
+ * <button onClick={handleCancel}>Cancel</button>
41
+ * </div>
42
+ * );
43
+ * }
44
+ * ```
45
+ */
8
46
  export function useComposerRuntime(options?: {
9
47
  optional?: false | undefined;
10
48
  }): ComposerRuntime;
@@ -21,4 +59,30 @@ export function useComposerRuntime(options?: {
21
59
  : (threadRuntime?.composer ?? null);
22
60
  }
23
61
 
62
+ /**
63
+ * Hook to access the current composer state.
64
+ *
65
+ * This hook provides reactive access to the composer's state, including text content,
66
+ * attachments, editing status, and send/cancel capabilities.
67
+ *
68
+ * @param selector Optional selector function to pick specific state properties
69
+ * @returns The selected composer state or the entire composer state if no selector provided
70
+ *
71
+ * @example
72
+ * ```tsx
73
+ * function ComposerStatus() {
74
+ * const text = useComposer((state) => state.text);
75
+ * const canSend = useComposer((state) => state.canSend);
76
+ * const attachmentCount = useComposer((state) => state.attachments.length);
77
+ *
78
+ * return (
79
+ * <div>
80
+ * Text: {text.length} chars,
81
+ * Attachments: {attachmentCount},
82
+ * Can send: {canSend}
83
+ * </div>
84
+ * );
85
+ * }
86
+ * ```
87
+ */
24
88
  export const useComposer = createStateHookForRuntime(useComposerRuntime);
@@ -22,6 +22,38 @@ const useMessageContext = createContextHook(
22
22
  "a component passed to <ThreadPrimitive.Messages components={...} />",
23
23
  );
24
24
 
25
+ /**
26
+ * Hook to access the MessageRuntime from the current context.
27
+ *
28
+ * The MessageRuntime provides access to message-level state and actions,
29
+ * including message content, status, editing capabilities, and branching.
30
+ *
31
+ * @param options Configuration options
32
+ * @param options.optional Whether the hook should return null if no context is found
33
+ * @returns The MessageRuntime instance, or null if optional is true and no context exists
34
+ *
35
+ * @example
36
+ * ```tsx
37
+ * function MessageActions() {
38
+ * const runtime = useMessageRuntime();
39
+ *
40
+ * const handleReload = () => {
41
+ * runtime.reload();
42
+ * };
43
+ *
44
+ * const handleEdit = () => {
45
+ * runtime.startEdit();
46
+ * };
47
+ *
48
+ * return (
49
+ * <div>
50
+ * <button onClick={handleReload}>Reload</button>
51
+ * <button onClick={handleEdit}>Edit</button>
52
+ * </div>
53
+ * );
54
+ * }
55
+ * ```
56
+ */
25
57
  export function useMessageRuntime(options?: {
26
58
  optional?: false | undefined;
27
59
  }): MessageRuntime;
@@ -36,6 +68,30 @@ export function useMessageRuntime(options?: {
36
68
  return context.useMessageRuntime();
37
69
  }
38
70
 
71
+ /**
72
+ * Hook to access the current message state.
73
+ *
74
+ * This hook provides reactive access to the message's state, including content,
75
+ * role, status, and other message-level properties.
76
+ *
77
+ * @param selector Optional selector function to pick specific state properties
78
+ * @returns The selected message state or the entire message state if no selector provided
79
+ *
80
+ * @example
81
+ * ```tsx
82
+ * function MessageContent() {
83
+ * const role = useMessage((state) => state.role);
84
+ * const content = useMessage((state) => state.content);
85
+ * const isLoading = useMessage((state) => state.status.type === "running");
86
+ *
87
+ * return (
88
+ * <div className={`message-${role}`}>
89
+ * {isLoading ? "Loading..." : content.map(part => part.text).join("")}
90
+ * </div>
91
+ * );
92
+ * }
93
+ * ```
94
+ */
39
95
  export const useMessage = createStateHookForRuntime(useMessageRuntime);
40
96
 
41
97
  const useEditComposerRuntime = (opt: {
@@ -20,6 +20,29 @@ const useThreadContext = createContextHook(
20
20
  "AssistantRuntimeProvider",
21
21
  );
22
22
 
23
+ /**
24
+ * Hook to access the ThreadRuntime from the current context.
25
+ *
26
+ * The ThreadRuntime provides access to thread-level state and actions,
27
+ * including message management, thread state, and composer functionality.
28
+ *
29
+ * @param options Configuration options
30
+ * @param options.optional Whether the hook should return null if no context is found
31
+ * @returns The ThreadRuntime instance, or null if optional is true and no context exists
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * function MyComponent() {
36
+ * const runtime = useThreadRuntime();
37
+ *
38
+ * const handleSendMessage = (text: string) => {
39
+ * runtime.append({ role: "user", content: [{ type: "text", text }] });
40
+ * };
41
+ *
42
+ * return <button onClick={() => handleSendMessage("Hello!")}>Send</button>;
43
+ * }
44
+ * ```
45
+ */
23
46
  export function useThreadRuntime(options?: {
24
47
  optional?: false | undefined;
25
48
  }): ThreadRuntime;
@@ -32,6 +55,25 @@ export function useThreadRuntime(options?: { optional?: boolean | undefined }) {
32
55
  return context.useThreadRuntime();
33
56
  }
34
57
 
58
+ /**
59
+ * Hook to access the current thread state.
60
+ *
61
+ * This hook provides reactive access to the thread's state, including messages,
62
+ * running status, capabilities, and other thread-level properties.
63
+ *
64
+ * @param selector Optional selector function to pick specific state properties
65
+ * @returns The selected thread state or the entire thread state if no selector provided
66
+ *
67
+ * @example
68
+ * ```tsx
69
+ * function ThreadStatus() {
70
+ * const isRunning = useThread((state) => state.isRunning);
71
+ * const messageCount = useThread((state) => state.messages.length);
72
+ *
73
+ * return <div>Running: {isRunning}, Messages: {messageCount}</div>;
74
+ * }
75
+ * ```
76
+ */
35
77
  export const useThread = createStateHookForRuntime(useThreadRuntime);
36
78
 
37
79
  const useThreadComposerRuntime = (opt: {
@@ -12,6 +12,30 @@ import {
12
12
  } from "../../context/react/MessageContext";
13
13
  import { useComposerRuntime } from "../../context";
14
14
 
15
+ /**
16
+ * Hook that provides copy functionality for action bar buttons.
17
+ *
18
+ * This hook returns a callback function that copies message content to the clipboard,
19
+ * or null if copying is not available. It handles both regular message content and
20
+ * composer text when in editing mode.
21
+ *
22
+ * @param options Configuration options
23
+ * @param options.copiedDuration Duration in milliseconds to show the copied state
24
+ * @returns A copy callback function, or null if copying is disabled
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * function CustomCopyButton() {
29
+ * const copy = useActionBarPrimitiveCopy({ copiedDuration: 2000 });
30
+ *
31
+ * return (
32
+ * <button onClick={copy} disabled={!copy}>
33
+ * {copy ? "Copy" : "Cannot Copy"}
34
+ * </button>
35
+ * );
36
+ * }
37
+ * ```
38
+ */
15
39
  const useActionBarPrimitiveCopy = ({
16
40
  copiedDuration = 3000,
17
41
  }: { copiedDuration?: number | undefined } = {}) => {
@@ -44,9 +68,27 @@ const useActionBarPrimitiveCopy = ({
44
68
 
45
69
  export namespace ActionBarPrimitiveCopy {
46
70
  export type Element = HTMLButtonElement;
71
+ /**
72
+ * Props for the ActionBarPrimitive.Copy component.
73
+ * Inherits all button element props and action button functionality.
74
+ */
47
75
  export type Props = ActionButtonProps<typeof useActionBarPrimitiveCopy>;
48
76
  }
49
77
 
78
+ /**
79
+ * A button component that copies message content to the clipboard.
80
+ *
81
+ * This component automatically handles copying message text to the clipboard
82
+ * and provides visual feedback through the data-copied attribute. It's disabled
83
+ * when there's no copyable content available.
84
+ *
85
+ * @example
86
+ * ```tsx
87
+ * <ActionBarPrimitive.Copy copiedDuration={2000}>
88
+ * Copy Message
89
+ * </ActionBarPrimitive.Copy>
90
+ * ```
91
+ */
50
92
  export const ActionBarPrimitiveCopy = forwardRef<
51
93
  ActionBarPrimitiveCopy.Element,
52
94
  ActionBarPrimitiveCopy.Props
@@ -8,6 +8,27 @@ import {
8
8
  import { useCallback } from "react";
9
9
  import { useEditComposer, useMessageRuntime } from "../../context";
10
10
 
11
+ /**
12
+ * Hook that provides edit functionality for action bar buttons.
13
+ *
14
+ * This hook returns a callback function that starts editing the current message,
15
+ * or null if editing is not available (e.g., already in editing mode).
16
+ *
17
+ * @returns An edit callback function, or null if editing is disabled
18
+ *
19
+ * @example
20
+ * ```tsx
21
+ * function CustomEditButton() {
22
+ * const edit = useActionBarEdit();
23
+ *
24
+ * return (
25
+ * <button onClick={edit} disabled={!edit}>
26
+ * {edit ? "Edit Message" : "Cannot Edit"}
27
+ * </button>
28
+ * );
29
+ * }
30
+ * ```
31
+ */
11
32
  const useActionBarEdit = () => {
12
33
  const messageRuntime = useMessageRuntime();
13
34
  const disabled = useEditComposer((c) => c.isEditing);
@@ -22,9 +43,26 @@ const useActionBarEdit = () => {
22
43
 
23
44
  export namespace ActionBarPrimitiveEdit {
24
45
  export type Element = ActionButtonElement;
46
+ /**
47
+ * Props for the ActionBarPrimitive.Edit component.
48
+ * Inherits all button element props and action button functionality.
49
+ */
25
50
  export type Props = ActionButtonProps<typeof useActionBarEdit>;
26
51
  }
27
52
 
53
+ /**
54
+ * A button component that starts editing the current message.
55
+ *
56
+ * This component automatically handles starting the edit mode for the current message
57
+ * and is disabled when editing is not available (e.g., already in editing mode).
58
+ *
59
+ * @example
60
+ * ```tsx
61
+ * <ActionBarPrimitive.Edit>
62
+ * Edit Message
63
+ * </ActionBarPrimitive.Edit>
64
+ * ```
65
+ */
28
66
  export const ActionBarPrimitiveEdit = createActionButton(
29
67
  "ActionBarPrimitive.Edit",
30
68
  useActionBarEdit,
@@ -10,6 +10,27 @@ import { useMessageRuntime } from "../../context";
10
10
  import { useThreadRuntime } from "../../context/react/ThreadContext";
11
11
  import { useCombinedStore } from "../../utils/combined/useCombinedStore";
12
12
 
13
+ /**
14
+ * Hook that provides reload functionality for action bar buttons.
15
+ *
16
+ * This hook returns a callback function that reloads/regenerates the current assistant message,
17
+ * or null if reloading is not available (e.g., thread is running, disabled, or message is not from assistant).
18
+ *
19
+ * @returns A reload callback function, or null if reloading is disabled
20
+ *
21
+ * @example
22
+ * ```tsx
23
+ * function CustomReloadButton() {
24
+ * const reload = useActionBarReload();
25
+ *
26
+ * return (
27
+ * <button onClick={reload} disabled={!reload}>
28
+ * {reload ? "Reload Message" : "Cannot Reload"}
29
+ * </button>
30
+ * );
31
+ * }
32
+ * ```
33
+ */
13
34
  const useActionBarReload = () => {
14
35
  const messageRuntime = useMessageRuntime();
15
36
  const threadRuntime = useThreadRuntime();
@@ -29,9 +50,27 @@ const useActionBarReload = () => {
29
50
 
30
51
  export namespace ActionBarPrimitiveReload {
31
52
  export type Element = ActionButtonElement;
53
+ /**
54
+ * Props for the ActionBarPrimitive.Reload component.
55
+ * Inherits all button element props and action button functionality.
56
+ */
32
57
  export type Props = ActionButtonProps<typeof useActionBarReload>;
33
58
  }
34
59
 
60
+ /**
61
+ * A button component that reloads/regenerates the current assistant message.
62
+ *
63
+ * This component automatically handles reloading the current assistant message
64
+ * and is disabled when reloading is not available (e.g., thread is running,
65
+ * disabled, or message is not from assistant).
66
+ *
67
+ * @example
68
+ * ```tsx
69
+ * <ActionBarPrimitive.Reload>
70
+ * Reload Message
71
+ * </ActionBarPrimitive.Reload>
72
+ * ```
73
+ */
35
74
  export const ActionBarPrimitiveReload = createActionButton(
36
75
  "ActionBarPrimitive.Reload",
37
76
  useActionBarReload,
@@ -12,12 +12,50 @@ type PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;
12
12
  export namespace ActionBarPrimitiveRoot {
13
13
  export type Element = ComponentRef<typeof Primitive.div>;
14
14
  export type Props = PrimitiveDivProps & {
15
+ /**
16
+ * Whether to hide the action bar when the thread is running.
17
+ * @default false
18
+ */
15
19
  hideWhenRunning?: boolean | undefined;
20
+ /**
21
+ * Controls when the action bar should automatically hide.
22
+ * - "always": Always hide unless hovered
23
+ * - "not-last": Hide unless this is the last message
24
+ * - "never": Never auto-hide
25
+ * @default "never"
26
+ */
16
27
  autohide?: "always" | "not-last" | "never" | undefined;
28
+ /**
29
+ * Controls floating behavior when auto-hidden.
30
+ * - "always": Always float when hidden
31
+ * - "single-branch": Float only for single-branch messages
32
+ * - "never": Never float
33
+ * @default "never"
34
+ */
17
35
  autohideFloat?: "always" | "single-branch" | "never" | undefined;
18
36
  };
19
37
  }
20
38
 
39
+ /**
40
+ * The root container for action bar components.
41
+ *
42
+ * This component provides intelligent visibility and floating behavior for action bars,
43
+ * automatically hiding and showing based on message state, hover status, and configuration.
44
+ * It supports floating mode for better UX when space is limited.
45
+ *
46
+ * @example
47
+ * ```tsx
48
+ * <ActionBarPrimitive.Root
49
+ * hideWhenRunning={true}
50
+ * autohide="not-last"
51
+ * autohideFloat="single-branch"
52
+ * >
53
+ * <ActionBarPrimitive.Copy />
54
+ * <ActionBarPrimitive.Edit />
55
+ * <ActionBarPrimitive.Reload />
56
+ * </ActionBarPrimitive.Root>
57
+ * ```
58
+ */
21
59
  export const ActionBarPrimitiveRoot = forwardRef<
22
60
  ActionBarPrimitiveRoot.Element,
23
61
  ActionBarPrimitiveRoot.Props
@@ -7,9 +7,27 @@ type PrimitiveDivProps = ComponentPropsWithoutRef<typeof Primitive.div>;
7
7
 
8
8
  export namespace AttachmentPrimitiveRoot {
9
9
  export type Element = ComponentRef<typeof Primitive.div>;
10
+ /**
11
+ * Props for the AttachmentPrimitive.Root component.
12
+ * Accepts all standard div element props.
13
+ */
10
14
  export type Props = PrimitiveDivProps;
11
15
  }
12
16
 
17
+ /**
18
+ * The root container component for an attachment.
19
+ *
20
+ * This component provides the foundational wrapper for attachment-related components
21
+ * and content. It serves as the context provider for attachment state and actions.
22
+ *
23
+ * @example
24
+ * ```tsx
25
+ * <AttachmentPrimitive.Root>
26
+ * <AttachmentPrimitive.Name />
27
+ * <AttachmentPrimitive.Remove />
28
+ * </AttachmentPrimitive.Root>
29
+ * ```
30
+ */
13
31
  export const AttachmentPrimitiveRoot = forwardRef<
14
32
  AttachmentPrimitiveRoot.Element,
15
33
  AttachmentPrimitiveRoot.Props
@@ -9,9 +9,26 @@ const useBranchPickerCount = () => {
9
9
  };
10
10
 
11
11
  export namespace BranchPickerPrimitiveCount {
12
+ /**
13
+ * Props for the BranchPickerPrimitive.Count component.
14
+ * This component takes no props.
15
+ */
12
16
  export type Props = Record<string, never>;
13
17
  }
14
18
 
19
+ /**
20
+ * A component that displays the total number of branches for the current message.
21
+ *
22
+ * This component renders the branch count as plain text, useful for showing
23
+ * users how many alternative responses are available.
24
+ *
25
+ * @example
26
+ * ```tsx
27
+ * <div>
28
+ * Branch <BranchPickerPrimitive.Count /> of {totalBranches}
29
+ * </div>
30
+ * ```
31
+ */
15
32
  export const BranchPickerPrimitiveCount: FC<
16
33
  BranchPickerPrimitiveCount.Props
17
34
  > = () => {
@@ -25,9 +25,26 @@ const useBranchPickerNext = () => {
25
25
 
26
26
  export namespace BranchPickerPrimitiveNext {
27
27
  export type Element = ActionButtonElement;
28
+ /**
29
+ * Props for the BranchPickerPrimitive.Next component.
30
+ * Inherits all button element props and action button functionality.
31
+ */
28
32
  export type Props = ActionButtonProps<typeof useBranchPickerNext>;
29
33
  }
30
34
 
35
+ /**
36
+ * A button component that navigates to the next branch in the message tree.
37
+ *
38
+ * This component automatically handles switching to the next available branch
39
+ * and is disabled when there are no more branches to navigate to.
40
+ *
41
+ * @example
42
+ * ```tsx
43
+ * <BranchPickerPrimitive.Next>
44
+ * Next →
45
+ * </BranchPickerPrimitive.Next>
46
+ * ```
47
+ */
31
48
  export const BranchPickerPrimitiveNext = createActionButton(
32
49
  "BranchPickerPrimitive.Next",
33
50
  useBranchPickerNext,
@@ -11,6 +11,27 @@ import {
11
11
  useMessageRuntime,
12
12
  } from "../../context/react/MessageContext";
13
13
 
14
+ /**
15
+ * Hook that provides navigation to the previous branch functionality.
16
+ *
17
+ * This hook returns a callback function that switches to the previous branch
18
+ * in the message branch tree, or null if there is no previous branch available.
19
+ *
20
+ * @returns A previous branch callback function, or null if navigation is disabled
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * function CustomPreviousButton() {
25
+ * const previous = useBranchPickerPrevious();
26
+ *
27
+ * return (
28
+ * <button onClick={previous} disabled={!previous}>
29
+ * {previous ? "Previous Branch" : "No Previous Branch"}
30
+ * </button>
31
+ * );
32
+ * }
33
+ * ```
34
+ */
14
35
  const useBranchPickerPrevious = () => {
15
36
  const messageRuntime = useMessageRuntime();
16
37
  const disabled = useMessage((m) => m.branchNumber <= 1);
@@ -25,9 +46,26 @@ const useBranchPickerPrevious = () => {
25
46
 
26
47
  export namespace BranchPickerPrimitivePrevious {
27
48
  export type Element = ActionButtonElement;
49
+ /**
50
+ * Props for the BranchPickerPrimitive.Previous component.
51
+ * Inherits all button element props and action button functionality.
52
+ */
28
53
  export type Props = ActionButtonProps<typeof useBranchPickerPrevious>;
29
54
  }
30
55
 
56
+ /**
57
+ * A button component that navigates to the previous branch in the message tree.
58
+ *
59
+ * This component automatically handles switching to the previous available branch
60
+ * and is disabled when there are no previous branches to navigate to.
61
+ *
62
+ * @example
63
+ * ```tsx
64
+ * <BranchPickerPrimitive.Previous>
65
+ * ← Previous
66
+ * </BranchPickerPrimitive.Previous>
67
+ * ```
68
+ */
31
69
  export const BranchPickerPrimitivePrevious = createActionButton(
32
70
  "BranchPickerPrimitive.Previous",
33
71
  useBranchPickerPrevious,