@assistant-ui/mcp-docs-server 0.1.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 (109) hide show
  1. package/.docs/organized/code-examples/local-ollama.md +1135 -0
  2. package/.docs/organized/code-examples/search-agent-for-e-commerce.md +1721 -0
  3. package/.docs/organized/code-examples/with-ai-sdk.md +1081 -0
  4. package/.docs/organized/code-examples/with-cloud.md +1164 -0
  5. package/.docs/organized/code-examples/with-external-store.md +1064 -0
  6. package/.docs/organized/code-examples/with-ffmpeg.md +1305 -0
  7. package/.docs/organized/code-examples/with-langgraph.md +1819 -0
  8. package/.docs/organized/code-examples/with-openai-assistants.md +1175 -0
  9. package/.docs/organized/code-examples/with-react-hook-form.md +1727 -0
  10. package/.docs/organized/code-examples/with-vercel-ai-rsc.md +1157 -0
  11. package/.docs/raw/blog/2024-07-29-hello/index.mdx +65 -0
  12. package/.docs/raw/blog/2024-09-11/index.mdx +10 -0
  13. package/.docs/raw/blog/2024-12-15/index.mdx +10 -0
  14. package/.docs/raw/blog/2025-01-31-changelog/index.mdx +129 -0
  15. package/.docs/raw/docs/about-assistantui.mdx +44 -0
  16. package/.docs/raw/docs/api-reference/context-providers/AssistantRuntimeProvider.mdx +30 -0
  17. package/.docs/raw/docs/api-reference/context-providers/TextContentPartProvider.mdx +26 -0
  18. package/.docs/raw/docs/api-reference/integrations/react-hook-form.mdx +103 -0
  19. package/.docs/raw/docs/api-reference/integrations/vercel-ai-sdk.mdx +145 -0
  20. package/.docs/raw/docs/api-reference/overview.mdx +583 -0
  21. package/.docs/raw/docs/api-reference/primitives/ActionBar.mdx +264 -0
  22. package/.docs/raw/docs/api-reference/primitives/AssistantModal.mdx +129 -0
  23. package/.docs/raw/docs/api-reference/primitives/Attachment.mdx +96 -0
  24. package/.docs/raw/docs/api-reference/primitives/BranchPicker.mdx +87 -0
  25. package/.docs/raw/docs/api-reference/primitives/Composer.mdx +204 -0
  26. package/.docs/raw/docs/api-reference/primitives/ContentPart.mdx +173 -0
  27. package/.docs/raw/docs/api-reference/primitives/Error.mdx +70 -0
  28. package/.docs/raw/docs/api-reference/primitives/Message.mdx +181 -0
  29. package/.docs/raw/docs/api-reference/primitives/Thread.mdx +197 -0
  30. package/.docs/raw/docs/api-reference/primitives/composition.mdx +21 -0
  31. package/.docs/raw/docs/api-reference/runtimes/AssistantRuntime.mdx +33 -0
  32. package/.docs/raw/docs/api-reference/runtimes/AttachmentRuntime.mdx +46 -0
  33. package/.docs/raw/docs/api-reference/runtimes/ComposerRuntime.mdx +69 -0
  34. package/.docs/raw/docs/api-reference/runtimes/ContentPartRuntime.mdx +22 -0
  35. package/.docs/raw/docs/api-reference/runtimes/MessageRuntime.mdx +49 -0
  36. package/.docs/raw/docs/api-reference/runtimes/ThreadListItemRuntime.mdx +32 -0
  37. package/.docs/raw/docs/api-reference/runtimes/ThreadListRuntime.mdx +31 -0
  38. package/.docs/raw/docs/api-reference/runtimes/ThreadRuntime.mdx +48 -0
  39. package/.docs/raw/docs/architecture.mdx +92 -0
  40. package/.docs/raw/docs/cloud/authorization.mdx +152 -0
  41. package/.docs/raw/docs/cloud/overview.mdx +55 -0
  42. package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +54 -0
  43. package/.docs/raw/docs/cloud/persistence/langgraph.mdx +123 -0
  44. package/.docs/raw/docs/concepts/architecture.mdx +19 -0
  45. package/.docs/raw/docs/concepts/runtime-layer.mdx +163 -0
  46. package/.docs/raw/docs/concepts/why.mdx +9 -0
  47. package/.docs/raw/docs/copilots/make-assistant-readable.mdx +71 -0
  48. package/.docs/raw/docs/copilots/make-assistant-tool-ui.mdx +76 -0
  49. package/.docs/raw/docs/copilots/make-assistant-tool.mdx +117 -0
  50. package/.docs/raw/docs/copilots/model-context.mdx +135 -0
  51. package/.docs/raw/docs/copilots/motivation.mdx +191 -0
  52. package/.docs/raw/docs/copilots/use-assistant-instructions.mdx +62 -0
  53. package/.docs/raw/docs/getting-started.mdx +1133 -0
  54. package/.docs/raw/docs/guides/Attachments.mdx +640 -0
  55. package/.docs/raw/docs/guides/Branching.mdx +59 -0
  56. package/.docs/raw/docs/guides/Editing.mdx +56 -0
  57. package/.docs/raw/docs/guides/Speech.mdx +43 -0
  58. package/.docs/raw/docs/guides/ToolUI.mdx +663 -0
  59. package/.docs/raw/docs/guides/Tools.mdx +496 -0
  60. package/.docs/raw/docs/index.mdx +7 -0
  61. package/.docs/raw/docs/legacy/styled/AssistantModal.mdx +85 -0
  62. package/.docs/raw/docs/legacy/styled/Decomposition.mdx +633 -0
  63. package/.docs/raw/docs/legacy/styled/Markdown.mdx +86 -0
  64. package/.docs/raw/docs/legacy/styled/Scrollbar.mdx +71 -0
  65. package/.docs/raw/docs/legacy/styled/Thread.mdx +84 -0
  66. package/.docs/raw/docs/legacy/styled/ThreadWidth.mdx +21 -0
  67. package/.docs/raw/docs/mcp-docs-server.mdx +324 -0
  68. package/.docs/raw/docs/migrations/deprecation-policy.mdx +41 -0
  69. package/.docs/raw/docs/migrations/v0-7.mdx +188 -0
  70. package/.docs/raw/docs/migrations/v0-8.mdx +160 -0
  71. package/.docs/raw/docs/migrations/v0-9.mdx +75 -0
  72. package/.docs/raw/docs/react-compatibility.mdx +208 -0
  73. package/.docs/raw/docs/runtimes/ai-sdk/rsc.mdx +226 -0
  74. package/.docs/raw/docs/runtimes/ai-sdk/use-assistant-hook.mdx +195 -0
  75. package/.docs/raw/docs/runtimes/ai-sdk/use-chat-hook.mdx +138 -0
  76. package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +136 -0
  77. package/.docs/raw/docs/runtimes/custom/external-store.mdx +1624 -0
  78. package/.docs/raw/docs/runtimes/custom/local.mdx +1185 -0
  79. package/.docs/raw/docs/runtimes/helicone.mdx +60 -0
  80. package/.docs/raw/docs/runtimes/langgraph/index.mdx +320 -0
  81. package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +11 -0
  82. package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +28 -0
  83. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +120 -0
  84. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +336 -0
  85. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +385 -0
  86. package/.docs/raw/docs/runtimes/langserve.mdx +126 -0
  87. package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +218 -0
  88. package/.docs/raw/docs/runtimes/mastra/overview.mdx +17 -0
  89. package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +196 -0
  90. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +222 -0
  91. package/.docs/raw/docs/ui/AssistantModal.mdx +46 -0
  92. package/.docs/raw/docs/ui/AssistantSidebar.mdx +42 -0
  93. package/.docs/raw/docs/ui/Attachment.mdx +82 -0
  94. package/.docs/raw/docs/ui/Markdown.mdx +72 -0
  95. package/.docs/raw/docs/ui/Mermaid.mdx +79 -0
  96. package/.docs/raw/docs/ui/Scrollbar.mdx +59 -0
  97. package/.docs/raw/docs/ui/SyntaxHighlighting.mdx +253 -0
  98. package/.docs/raw/docs/ui/Thread.mdx +47 -0
  99. package/.docs/raw/docs/ui/ThreadList.mdx +49 -0
  100. package/.docs/raw/docs/ui/ToolFallback.mdx +64 -0
  101. package/.docs/raw/docs/ui/primitives/Thread.mdx +197 -0
  102. package/LICENSE +21 -0
  103. package/README.md +128 -0
  104. package/dist/chunk-C7O7EFKU.js +38 -0
  105. package/dist/chunk-CZCDQ3YH.js +420 -0
  106. package/dist/index.js +1 -0
  107. package/dist/prepare-docs/prepare.js +199 -0
  108. package/dist/stdio.js +8 -0
  109. package/package.json +43 -0
@@ -0,0 +1,188 @@
1
+ ---
2
+ title: Migration to v0.7
3
+ ---
4
+
5
+ import { Callout } from "fumadocs-ui/components/callout";
6
+
7
+ This guide serves as a reference for users facing breaking changes during upgrade to v0.7. You do not need to read this guide to upgrade to v0.7.
8
+
9
+ All breaking changes in v0.7 are renames or removals of existing APIs. Therefore, all breaking changes should cause a Typescript error, so you can simply check for errors after upgrading.
10
+
11
+ ### Component Property Types moved to `Component.Props`
12
+
13
+ Component property types are now neatly organized under the component itself.
14
+
15
+ ```diff
16
+ -import { ThreadPrimitiveMessagesProps } from "@assistant-ui/react";
17
+ +import { ThreadPrimitive } from "@assistant-ui/react";
18
+
19
+ -type Props = ThreadPrimitiveMessagesProps;
20
+ +type Props = ThreadPrimitive.Messages.Props;
21
+ ```
22
+
23
+ ## Context API simplifications
24
+
25
+ ### `useThreadContext`, `useMessageContext`, ... replaced with direct imports of stores
26
+
27
+ `useAssistantContext`, `useThreadContext`, `useMessageContext` and `useContentPartContext` have been removed in favor of direct exports from `@assistant-ui/react`;
28
+
29
+ ```diff
30
+ -const { useThread } = useThreadContext();
31
+
32
+ +import { useThread } from "@assistant-ui/react";
33
+ ```
34
+
35
+ # Assistant Context API simplifications
36
+
37
+ ### `useAssistantActions` replaced with `useAssistantRuntime`
38
+
39
+ `useAssistantActions` has been removed in favor of `useAssistantRuntime`.
40
+
41
+ ```diff
42
+ -const switchToNewThread = useAssistantActions(a => a.switchToNewThread);
43
+ +const runtime = useAssistantRuntime();
44
+ +runtime.switchToNewThread();
45
+ ```
46
+
47
+ ### `switchToThread(null)` replaced with `switchToNewThread()`
48
+
49
+ ```diff
50
+ -useThreadRuntime().switchToThread(null);
51
+ +useThreadRuntime().switchToNewThread();
52
+ ```
53
+
54
+ ### useSwtichToNewThread() moved to useAssistantRuntime().switchToNewThread()
55
+
56
+ ```diff
57
+ -useSwitchToNewThread();
58
+ +const runtime = useAssistantRuntime()
59
+ +runtime.switchToNewThread();
60
+ ```
61
+
62
+ ### `runtime.subscribe` removed, `subscribeToMainThread` removed
63
+
64
+ Previously, you needed to subscribe to the runtime to receive updates whenever the main thread changed and resubscribe to the main thread whenever you switched to a new thread. The `runtime.thread` value now always refers to the current main thread, there is no need to subscribe to the runtime anymore.
65
+
66
+ ## ThreadRuntime API simplifications
67
+
68
+ ### `useAppendMessage` moved to `useThreadRuntime().append()`
69
+
70
+ ```diff
71
+ -const append = useAppendMessage();
72
+ +const threadRuntime = useThreadRuntime();
73
+ -append("hello world");
74
+ +threadRuntime.append("hello world");
75
+ ```
76
+
77
+ ### `useThreadActions` replaced with `useThreadRuntime`
78
+
79
+ `useThreadActions` has been removed in favor of `useThreadRuntime`.
80
+
81
+ ```diff
82
+ -const reload = useThreadActions(a => a.reload);
83
+ +const threadRuntime = useThreadRuntime();
84
+ +threadRuntime.reload();
85
+ ```
86
+
87
+ ### State values moved to `threadRuntime.getState()`
88
+
89
+ In order to make it clear that accessing the state only provides a snapshot of the current state and will not cause a re-render on changes, the state values of `useThreadRuntime` have been moved to `threadRuntime.getState()`.
90
+
91
+ ```diff
92
+ -const isRunning = useThreadRuntime().isRunning; // anti-pattern, your code will not update on change
93
+ +const isRunning = useThread(t => t.isRunning);
94
+ ```
95
+
96
+ ### `useThreadStore` replaced with `useThreadRuntime().getState()`
97
+
98
+ `useThreadStore` has been removed in favor of `useThreadRuntime().getState()`.
99
+
100
+ ### `threadRuntime.getBranches()` replaced with `useThreadRuntime().getMessageByIndex(idx).getState().branchNumber/Count`
101
+
102
+ The branch IDs are an internal implementation detail. The new Message Runtime API provides `branchNumber` and `branchCount` state fields that can be used instead.
103
+
104
+ ### New Message Runtime API replaces several methods from `useThreadRuntime`
105
+
106
+ A few methods from `useThreadRuntime` have been moved to `useMessageRuntime()`.
107
+
108
+ - `threadRuntime.switchToBranch()` has been removed in favor of `useThreadRuntime().getMessageByIndex(idx).switchToBranch()`.
109
+ - `threadRuntime.addToolResult()` has been removed in favor of `useThreadRuntime().getMessageByIndex(idx).getContentPartByToolCallId(toolCallId).addToolResult()`.
110
+ - `threadRuntime.speak()` has been removed in favor of `useThreadRuntime().getMessageByIndex(idx).speak()`.
111
+ - `threadRuntime.submitFeedback()` has been removed in favor of `useThreadRuntime().getMessageByIndex(idx).submitFeedback()`.
112
+ - `threadRuntime.getEditComposer()` has been removed in favor of `useThreadRuntime().getMessageById(id).getMessageByIndex(idx).composer`.
113
+ - `threadRuntime.beginEdit()` has been removed in favor of `useThreadRuntime().getMessageById(id).getMessageByIndex(idx).composer.beginEdit()`.
114
+
115
+ ## Composer Runtime API simplifications
116
+
117
+ ### Methods inside `useComposer` moved to `useComposerRuntime`
118
+
119
+ `useComposer()` used to provide several methods such as `setText`, `addAttachment`, `send`, `edit`, `cancel`, ...
120
+ These methods have been moved to `useComposerRuntime()`.
121
+
122
+ ### `useComposerStore` replaced with `useComposerRuntime().getState()`
123
+
124
+ `useComposerStore` has been removed in favor of `useComposerRuntime().getState()`.
125
+
126
+ ### `value` `setValue` replaced with `text` `setText`
127
+
128
+ ```diff
129
+ -useComposer(c => c.value);
130
+ +useComposer(c => c.text);
131
+ ```
132
+
133
+ ### `focus`, `onFocus` methods removed
134
+
135
+ These methods have been removed.
136
+
137
+ ## Message Context API simplifications
138
+
139
+ ### Flattened context values `useMessage().message` -> `useMessage()`
140
+
141
+ `MessageState` is now itself a message, so you no longer need to access the nested `useMessage().message` field.
142
+
143
+ ```diff
144
+ -useMessage(m => m.message.content);
145
+ +useMessage(m => m.content);
146
+ ```
147
+
148
+ ### `useMessageStore` replaced with `useMessageRuntime().getState()`
149
+
150
+ `useMessageStore` has been removed in favor of `useMessageRuntime().getState()`.
151
+
152
+ ## Content Part Context API simplifications
153
+
154
+ ### Flattened context values `useContentPart().part` -> `useContentPart()`
155
+
156
+ `ContentPartState` is now itself a content part, so you no longer need to access the nested `useContentPart().part` field.
157
+
158
+ ```diff
159
+ -useContentPart(c => c.part.type);
160
+ +useContentPart(c => c.type);
161
+ ```
162
+
163
+ This also applies to tool UI render functions:
164
+
165
+ ```diff
166
+ makeAssistantToolUI({
167
+ ...
168
+ - render: ({ part: { args } }) => <>{args}</>,
169
+ + render: ({ args }) => <>{args}</>,
170
+ });
171
+ ```
172
+
173
+ ## Attachment Context API simplifications
174
+
175
+ ### Flattened context values `useAttachment().attachment` -> `useAttachment()`
176
+
177
+ `AttachmentState` is now itself an attachment, so you no longer need to access the nested `useAttachment().attachment` field.
178
+
179
+ ```diff
180
+ -useAttachment(a => a.attachment.type);
181
+ +useAttachment(a => a.type);
182
+ ```
183
+
184
+ ## Roundtrips renamed to steps
185
+
186
+ `AssistantMessage.roundtrips` was renamed to `AssistantMessage.metadata.steps`.
187
+
188
+ Edge runtime's `maxToolRoundtrips` was replaced with `maxSteps` (which is `maxToolRoundtrips` + 1; if you had `maxToolRoundtrips` at 2, set `maxSteps` to 3).
@@ -0,0 +1,160 @@
1
+ ---
2
+ title: Migration to v0.8
3
+ ---
4
+
5
+ ## Styled Components moved to @assistant-ui/react-ui
6
+
7
+ All styled components (Thread, ThreadList, AssistantModal, makeMarkdownText, etc.) have been moved to a new package, `@assistant-ui/react-ui`.
8
+
9
+ To migrate, use the migration codemod:
10
+
11
+ ```sh
12
+ # IMPORTANT: make sure to commit all changes to git / creating a backup before running the codemod
13
+ npx assistant-ui upgrade
14
+ ```
15
+
16
+ ## Vercel AI SDK RSC requires additional setup
17
+
18
+ Built-in RSC support in assistant-ui has been removed, so an additional setup step is required.
19
+ The RSC runtime now requires additional setup to display React Server Components.
20
+
21
+ ```ts
22
+ import { RSCDisplay } from "@assistant-ui/react-ai-sdk";
23
+
24
+ // if you are using the default Thread component
25
+ // add RSCDisplay to assistantMessage.components.Text
26
+ <Thread assistantMessage={{ components: { Text: RSCDisplay } }} />
27
+
28
+
29
+ // if you are using unstyled primitives, update MyThread.tsx
30
+ <MessagePrimitive.Content components={{ Text: RSCDisplay }} />
31
+ ```
32
+
33
+ ## Migrate away from UIContentPart
34
+
35
+ For instructions on migrating for Vercel AI SDK RSC, see section above.
36
+ This migration guide is for users of `useExternalStoreRuntime`.
37
+
38
+ ### Recommended Approach: Use ToolUI
39
+
40
+ First, reconsider your approach.
41
+
42
+ Creating UI components in the `convertMessage` callback is considered an anti-pattern.
43
+ The recommended alternative approach is to pass tool-call content parts, and use `makeAssistantToolUI` to map these tool calls to UI components.
44
+
45
+ This ensures that the data layer is separate and decoupled from the UI layer.
46
+
47
+ #### Example
48
+
49
+ Consider the following example, where you are using a UIContentPart to show a loading indicator.
50
+
51
+ ```ts title="bad.ts"
52
+ // THIS IS BAD
53
+ const convertMessage = (message: MyMessage): ThreadMessageLike => {
54
+ if (message.isLoading) {
55
+ return { content: [{ type: "ui", display:< MyLoader /> }] };
56
+ }
57
+ // ...
58
+ };
59
+ ```
60
+
61
+ ```ts title="good.ts"
62
+ const convertMessage = (message: MyMessage): ThreadMessageLike => {
63
+ if (message.isLoading) {
64
+ return { content: [] };
65
+ }
66
+ // ...
67
+ };
68
+
69
+ // use the empty content part to show the loading indicator
70
+ <Thread assistantMessage={{ components: { Empty: MyLoader } }} />;
71
+ ```
72
+
73
+ (if you are using unstyled primitives, update MyThread.tsx, and pass the component to MessagePrimitive.Content)
74
+
75
+ #### Example 2
76
+
77
+ Consider the following example, where you are displaying a custom chart based on data received from an external source.
78
+
79
+ ```ts title="bad.ts"
80
+ // THIS IS BAD
81
+ const convertMessage = (message: MyMessage): ThreadMessageLike => {
82
+ return { content: [{ type: "ui", display: <MyChart data={message.chartData} /> }] };
83
+ };
84
+ ```
85
+
86
+ ```ts title="good.ts"
87
+ const convertMessage = (message: MyMessage): ThreadMessageLike => {
88
+ return {
89
+ content: [
90
+ {
91
+ type: "tool-call",
92
+ toolName: "chart",
93
+ args: message.chartData,
94
+ },
95
+ ],
96
+ };
97
+ };
98
+
99
+ const ChartToolUI = makeAssistantToolUI({
100
+ toolName: "chart",
101
+ render: ({ args }) => <MyChart data={args} />,
102
+ });
103
+
104
+ // use tool UI to display the chart
105
+ <Thread tools={[ChartToolUI]} />;
106
+ ```
107
+
108
+ (if you are using unstyled primitives, render the `<ChartToolUI />` component anywhere inside your AssistantRuntimeProvider)
109
+
110
+ ### Fallback Approach: Override ContentPartText
111
+
112
+ However, sometimes you receive UI components from an external source.
113
+
114
+ The example below assumes that your custom `MyMessage` type has a `display` field.
115
+
116
+ First, we define a dummy `UI_PLACEHOLDER` content part, which we will replace with the UI component later:
117
+
118
+ ```ts
119
+ const UI_PLACEHOLDER = Object.freeze({
120
+ type: "text",
121
+ text: "UI content placeholder",
122
+ });
123
+ const convertMessage = (message: MyMessage): ThreadMessageLike => ({
124
+ content: [
125
+ // other content parts,
126
+ UI_PLACEHOLDER,
127
+ ],
128
+ });
129
+ ```
130
+
131
+ Then, we define a custom `TextContentPartComponent`:
132
+
133
+ ```tsx
134
+ const MyText: TextContentPartComponent = () => {
135
+ const isUIPlaceholder = useContentPart((p) => p === UI_PLACEHOLDER);
136
+
137
+ // this assumes that you have a `display` field on your original message objects before conversion.
138
+ const ui = useMessage((m) =>
139
+ isUIPlaceholder ? getExternalStoreMessage(m).display : undefined,
140
+ );
141
+ if (ui) {
142
+ return ui;
143
+ }
144
+
145
+ return <MarkdownText />; // your default text component
146
+ };
147
+ ```
148
+
149
+ We pass this component to our Thread:
150
+
151
+ ```tsx
152
+ <Thread
153
+ assistantMessage={{ components: { Text: MyText } }}
154
+ userMessage={{ components: { Text: MyText } }}
155
+ />
156
+ ```
157
+
158
+ (if you are using unstyled primitives, update MyThread.tsx, and pass the component to MessagePrimitive.Content)
159
+
160
+ Now, the `UI_PLACEHOLDER` content part is replaced with the UI component we defined earlier.
@@ -0,0 +1,75 @@
1
+ ---
2
+ title: Migration to v0.9
3
+ ---
4
+
5
+ ## Edge Runtime moved to @assistant-ui/react-edge
6
+
7
+ The edge runtime, as well as the `CoreMessage` type, moved to `@assistant-ui/react-edge`.
8
+
9
+ The following components and types have been moved to `@assistant-ui/react-edge`:
10
+
11
+ - Edge Runtime
12
+
13
+ - `useEdgeRuntime`
14
+ - `EdgeRuntimeOptions`
15
+ - `EdgeModelAdapter`
16
+ - `EdgeChatAdapter`
17
+ - `EdgeRuntimeRequestOptions`
18
+ - `createEdgeRuntimeAPI`
19
+ - `getEdgeRuntimeResponse`
20
+
21
+ - Core Types
22
+ - `CoreMessage`
23
+ - `CoreUserMessage`
24
+ - `CoreAssistantMessage`
25
+ - `CoreSystemMessage`
26
+ - `CoreUserContentPart`
27
+ - `CoreAssistantContentPart`
28
+ - `CoreToolCallContentPart`
29
+ - Core message converters
30
+ - `fromCoreMessages`
31
+ - `fromCoreMessage`
32
+ - `toCoreMessages`
33
+ - `toCoreMessage`
34
+
35
+ To migrate, use the migration codemod:
36
+
37
+ ```sh
38
+ # IMPORTANT: make sure to commit all changes to git / creating a backup before running the codemod
39
+ npx assistant-ui upgrade
40
+ ```
41
+
42
+ ## Language Model converters and useDangerousInBrowserRuntime moved to @assistant-ui/react-ai-sdk
43
+
44
+ The following methods have been moved to `@assistant-ui/react-ai-sdk`:
45
+
46
+ - Language Model converters
47
+ - `toLanguageModelMessages`
48
+ - `toLanguageModelTools`
49
+ - `fromLanguageModelMessages`
50
+ - `fromLanguageModelTools`
51
+ - Dangerous in Browser Runtime
52
+ - `useDangerousInBrowserRuntime`
53
+
54
+ To migrate, use the migration codemod:
55
+
56
+ ```sh
57
+ # IMPORTANT: make sure to commit all changes to git / creating a backup before running the codemod
58
+ npx assistant-ui upgrade
59
+ ```
60
+
61
+ ## LangGraph `unstable_allowImageAttachments` removed
62
+
63
+ The `unstable_allowImageAttachments` option has been removed. Use the `adapters` option instead.
64
+
65
+ ```ts
66
+ useLangGraphRuntime({
67
+ adapters: {
68
+ attachments: new SimpleImageAttachmentAdapter(),
69
+ },
70
+ });
71
+ ```
72
+
73
+ ## Markdown `components.by_language` removed
74
+
75
+ The `components.by_language` option has been removed. Use the `componentsByLanguage` option instead.
@@ -0,0 +1,208 @@
1
+ ---
2
+ title: Using old React versions
3
+ description: Guide for using assistant-ui with older React versions (18, 17, 16)
4
+ ---
5
+
6
+ import { Callout } from "fumadocs-ui/components/callout";
7
+
8
+ <Callout type="warning" title="Older React Versions">
9
+ Older React versions are not continuously tested. If you encounter any issues
10
+ with integration, please contact us for help by joining our
11
+ [Discord](https://discord.gg/S9dwgCNEFs).
12
+ </Callout>
13
+
14
+ This guide provides instructions for configuring assistant-ui to work with React 18 or older versions.
15
+
16
+ ## React 18
17
+
18
+ If you're using React 18, you need to update the shadcn/ui components to work with `forwardRef`. Specifically, you need to modify the Button component.
19
+
20
+ ### Updating the Button Component
21
+
22
+ Navigate to your button component file (typically `/components/ui/button.tsx`) and wrap the Button component with `forwardRef`:
23
+
24
+ ```tsx
25
+ // Before
26
+ function Button({
27
+ className,
28
+ variant,
29
+ size,
30
+ asChild = false,
31
+ ...props
32
+ }: React.ComponentProps<"button"> &
33
+ VariantProps<typeof buttonVariants> & {
34
+ asChild?: boolean;
35
+ }) {
36
+ const Comp = asChild ? Slot : "button";
37
+
38
+ return (
39
+ <Comp
40
+ data-slot="button"
41
+ className={cn(buttonVariants({ variant, size, className }))}
42
+ {...props}
43
+ />
44
+ );
45
+ }
46
+
47
+ // After
48
+ const Button = React.forwardRef<
49
+ HTMLButtonElement,
50
+ React.ComponentProps<"button"> &
51
+ VariantProps<typeof buttonVariants> & {
52
+ asChild?: boolean;
53
+ }
54
+ >(({ className, variant, size, asChild = false, ...props }, ref) => {
55
+ const Comp = asChild ? Slot : "button";
56
+
57
+ return (
58
+ <Comp
59
+ data-slot="button"
60
+ className={cn(buttonVariants({ variant, size, className }))}
61
+ ref={ref}
62
+ {...props}
63
+ />
64
+ );
65
+ });
66
+ Button.displayName = "Button";
67
+ ```
68
+
69
+ **Note:** If you're using a lower React version (17 or 16), you'll also need to follow the instructions for that version.
70
+
71
+ ## React 17
72
+
73
+ For React 17 compatibility, in addition to the modifications outlined for React 18, you must also include a polyfill for the `useSyncExternalStore` hook (utilized by zustand).
74
+
75
+ ### Patching Zustand with patch-package
76
+
77
+ Since the assistant-ui uses zustand internally, which depends on `useSyncExternalStore`, you'll need to patch the zustand package directly:
78
+
79
+ 1. Install the required packages:
80
+
81
+ ```bash
82
+ npm install use-sync-external-store patch-package
83
+ # or
84
+ yarn add use-sync-external-store patch-package
85
+ ```
86
+
87
+ 2. Add a postinstall script to your package.json:
88
+
89
+ ```json
90
+ {
91
+ "scripts": {
92
+ "postinstall": "patch-package"
93
+ }
94
+ }
95
+ ```
96
+
97
+ 3. You'll want to follow the instructions in [patch-package](https://github.com/ds300/patch-package), by first making changes to the files of a particular package in your node_modules folder, then running either `yarn patch-package package-name` or `npx patch-package package-name`. You'll need a patch for zustand - within `node_modules/zustand`, open `zustand/react.js` and make the following code changes:
98
+
99
+ ```diff
100
+ diff --git a/node_modules/zustand/react.js b/node_modules/zustand/react.js
101
+ index 7599cfb..64530a8 100644
102
+ --- a/node_modules/zustand/react.js
103
+ +++ b/node_modules/zustand/react.js
104
+ @@ -1,6 +1,6 @@
105
+ 'use strict';
106
+
107
+ -var React = require('react');
108
+ +var React = require('use-sync-external-store/shim');
109
+ var vanilla = require('zustand/vanilla');
110
+
111
+ const identity = (arg) => arg;
112
+ @@ -10,7 +10,7 @@ function useStore(api, selector = identity) {
113
+ () => selector(api.getState()),
114
+ () => selector(api.getInitialState())
115
+ );
116
+ - React.useDebugValue(slice);
117
+ + //React.useDebugValue(slice);
118
+ return slice;
119
+ }
120
+ const createImpl = (createState) => {
121
+
122
+ This patch replaces the React import in zustand with the polyfill from `use-sync-external-store/shim` and comments out the `useDebugValue` call which isn't needed.
123
+
124
+ You should then run the patch-package command `yarn patch-package zustand` or `npx patch-package zustand` which should create a `patches` folder with a zustand patch file similar looking to this:
125
+
126
+ ```diff
127
+ diff --git a/node_modules/zustand/react.js b/node_modules/zustand/react.js
128
+ index 7599cfb..64530a8 100644
129
+ --- a/node_modules/zustand/react.js
130
+ +++ b/node_modules/zustand/react.js
131
+ @@ -1,6 +1,6 @@
132
+ 'use strict';
133
+
134
+ -var React = require('react');
135
+ +var React = require('use-sync-external-store/shim');
136
+ var vanilla = require('zustand/vanilla');
137
+
138
+ const identity = (arg) => arg;
139
+ @@ -10,7 +10,7 @@ function useStore(api, selector = identity) {
140
+ () => selector(api.getState()),
141
+ () => selector(api.getInitialState())
142
+ );
143
+ - React.useDebugValue(slice);
144
+ + //React.useDebugValue(slice);
145
+ return slice;
146
+ }
147
+ const createImpl = (createState) => {
148
+ ```
149
+
150
+ 4. You may also need to apply the same patches within `node_modules/@assistant-ui/react/` and possibly a nested dependency patch for `node_modules/@assistant-ui/react/node_modules/zustand`. Look for instances of `React.useSyncExternalStore` and replace with `{ useSyncExternalStore } from "use-sync-external-store/shim";` and comment out any `useDebugValue` calls. Finally, you may need to patch `useId` from React, so within `node_modules/@assistant-ui/react/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js`, change the following:
151
+
152
+ ```diff
153
+ -import { Fragment, useEffect, useId } from "react";
154
+ +import { Fragment, useEffect, useRef } from "react";
155
+ import { create } from "zustand";
156
+ import { AssistantMessageStream } from "assistant-stream";
157
+ import { RuntimeAdapterProvider } from "../adapters/RuntimeAdapterProvider.js";
158
+ import { jsx } from "react/jsx-runtime";
159
+ +
160
+ +// PATCH-PACKAGE: Polyfill for useId if not available in React 16
161
+ +let useId;
162
+ +try {
163
+ + // Try to use React's useId if available
164
+ + useId = require("react").useId;
165
+ +} catch (e) {}
166
+ +if (!useId) {
167
+ + // Fallback polyfill
168
+ + let globalId = 0;
169
+ + useId = function() {
170
+ + const idRef = useRef();
171
+ + if (!idRef.current) {
172
+ + globalId++;
173
+ + idRef.current = `uid-${globalId}`;
174
+ + }
175
+ + return idRef.current;
176
+ + };
177
+ +}
178
+ ```
179
+
180
+ 5. Run the postinstall script to apply the patches:
181
+
182
+ ```bash
183
+ npm run postinstall
184
+ # or
185
+ yarn postinstall
186
+ ```
187
+
188
+ This patch replaces the React import in zustand with the polyfill from `use-sync-external-store/shim` and comments out the `useDebugValue` call which isn't needed.
189
+
190
+ **Note:** If you're using React 16, you'll also need to follow the instructions for that version.
191
+
192
+ ## React 16
193
+
194
+ <Callout type="info" title="Incomplete Section">
195
+ This section is incomplete and contributions are welcome. If you're using
196
+ React 16 and have successfully integrated assistant-ui, please consider
197
+ contributing to this documentation.
198
+ </Callout>
199
+
200
+ For React 16 compatibility, you need to apply all the steps for **React 18** and **React 17** above.
201
+
202
+ ## Additional Resources
203
+
204
+ If you encounter any issues with React compatibility, please:
205
+
206
+ 1. Check that all required dependencies are installed
207
+ 2. Ensure your component modifications are correctly implemented
208
+ 3. Join our [Discord](https://discord.gg/S9dwgCNEFs) community for direct support