@assistant-ui/mcp-docs-server 0.1.35 → 0.1.36

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 (107) hide show
  1. package/.docs/organized/code-examples/waterfall.md +1 -1
  2. package/.docs/organized/code-examples/with-a2a.md +2 -2
  3. package/.docs/organized/code-examples/with-ag-ui.md +2 -2
  4. package/.docs/organized/code-examples/with-ai-sdk-v6.md +4 -4
  5. package/.docs/organized/code-examples/with-artifacts.md +4 -4
  6. package/.docs/organized/code-examples/with-assistant-transport.md +70 -54
  7. package/.docs/organized/code-examples/with-browser-extension.md +4 -4
  8. package/.docs/organized/code-examples/with-chain-of-thought.md +40 -89
  9. package/.docs/organized/code-examples/with-cloud-standalone.md +4 -4
  10. package/.docs/organized/code-examples/with-cloud.md +4 -4
  11. package/.docs/organized/code-examples/with-custom-thread-list.md +4 -4
  12. package/.docs/organized/code-examples/with-elevenlabs-conversational.md +6 -6
  13. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +6 -6
  14. package/.docs/organized/code-examples/with-eve.md +343 -0
  15. package/.docs/organized/code-examples/with-expo.md +909 -932
  16. package/.docs/organized/code-examples/with-external-store.md +2 -2
  17. package/.docs/organized/code-examples/with-ffmpeg.md +5 -8
  18. package/.docs/organized/code-examples/with-generative-ui.md +5 -5
  19. package/.docs/organized/code-examples/with-google-adk.md +2 -2
  20. package/.docs/organized/code-examples/with-heat-graph.md +1 -1
  21. package/.docs/organized/code-examples/with-image-generation.md +4 -4
  22. package/.docs/organized/code-examples/with-interactables.md +166 -338
  23. package/.docs/organized/code-examples/with-langchain.md +4 -4
  24. package/.docs/organized/code-examples/with-langgraph.md +20 -157
  25. package/.docs/organized/code-examples/with-livekit.md +6 -6
  26. package/.docs/organized/code-examples/with-mcp.md +4 -4
  27. package/.docs/organized/code-examples/with-opencode.md +3 -3
  28. package/.docs/organized/code-examples/with-pi.md +9 -7
  29. package/.docs/organized/code-examples/with-react-hook-form.md +13 -6
  30. package/.docs/organized/code-examples/with-react-ink-web.md +5 -5
  31. package/.docs/organized/code-examples/with-react-ink.md +1 -1
  32. package/.docs/organized/code-examples/with-react-router.md +10 -10
  33. package/.docs/organized/code-examples/with-resumable-stream.md +5 -5
  34. package/.docs/organized/code-examples/with-store.md +1 -1
  35. package/.docs/organized/code-examples/with-tanstack.md +5 -5
  36. package/.docs/organized/code-examples/with-tap-runtime.md +2 -2
  37. package/.docs/organized/code-examples/with-virtualized-thread.md +44 -24
  38. package/.docs/raw/docs/(docs)/cli.mdx +4 -2
  39. package/.docs/raw/docs/(docs)/devtools.mdx +25 -2
  40. package/.docs/raw/docs/(docs)/index.mdx +5 -2
  41. package/.docs/raw/docs/(docs)/installation.mdx +5 -2
  42. package/.docs/raw/docs/(reference)/api-reference/external-store/message-conversion.mdx +16 -16
  43. package/.docs/raw/docs/(reference)/api-reference/hooks/composer-triggers.mdx +73 -42
  44. package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +3 -20
  45. package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +234 -166
  46. package/.docs/raw/docs/(reference)/api-reference/integrations/eve.mdx +51 -0
  47. package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +4 -1
  48. package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +70 -38
  49. package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +30 -0
  50. package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +7 -0
  51. package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +26 -0
  52. package/.docs/raw/docs/(reference)/api-reference/primitives/chain-of-thought.mdx +15 -0
  53. package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +103 -0
  54. package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +16 -0
  55. package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +56 -0
  56. package/.docs/raw/docs/(reference)/api-reference/primitives/queue-item.mdx +12 -0
  57. package/.docs/raw/docs/(reference)/api-reference/primitives/selection-toolbar.mdx +12 -0
  58. package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +14 -0
  59. package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +57 -1
  60. package/.docs/raw/docs/(reference)/api-reference/tools/index.mdx +6 -0
  61. package/.docs/raw/docs/(reference)/api-reference/tools/interactables-legacy.mdx +55 -0
  62. package/.docs/raw/docs/(reference)/api-reference/tools/interactables.mdx +151 -0
  63. package/.docs/raw/docs/(reference)/api-reference/tools/rendering.mdx +15 -15
  64. package/.docs/raw/docs/(reference)/api-reference/tools/toolkits.mdx +20 -20
  65. package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +25 -9
  66. package/.docs/raw/docs/guides/headless-composer-input.mdx +113 -0
  67. package/.docs/raw/docs/guides/latex.mdx +28 -22
  68. package/.docs/raw/docs/guides/mentions.mdx +32 -7
  69. package/.docs/raw/docs/guides/slash-commands.mdx +3 -6
  70. package/.docs/raw/docs/guides/speech.mdx +5 -7
  71. package/.docs/raw/docs/guides/virtualization.mdx +77 -7
  72. package/.docs/raw/docs/guides/voice.mdx +3 -2
  73. package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +4 -12
  74. package/.docs/raw/docs/integrations/auth/better-auth.mdx +7 -10
  75. package/.docs/raw/docs/integrations/auth/clerk.mdx +3 -9
  76. package/.docs/raw/docs/integrations/auth/next-auth.mdx +3 -8
  77. package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +8 -5
  78. package/.docs/raw/docs/integrations/index.mdx +5 -12
  79. package/.docs/raw/docs/integrations/observability/helicone.mdx +3 -4
  80. package/.docs/raw/docs/integrations/observability/langfuse.mdx +3 -5
  81. package/.docs/raw/docs/integrations/observability/langsmith.mdx +3 -2
  82. package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +4 -3
  83. package/.docs/raw/docs/primitives/composer.mdx +8 -0
  84. package/.docs/raw/docs/primitives/thread.mdx +24 -0
  85. package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +21 -0
  86. package/.docs/raw/docs/runtimes/custom/external-store.mdx +54 -0
  87. package/.docs/raw/docs/runtimes/eve/overview.mdx +100 -0
  88. package/.docs/raw/docs/runtimes/eve/quickstart.mdx +143 -0
  89. package/.docs/raw/docs/runtimes/langchain.mdx +386 -18
  90. package/.docs/raw/docs/runtimes/langgraph/quickstart.mdx +1 -1
  91. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +1 -1
  92. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +6 -0
  93. package/.docs/raw/docs/tools/defining-tools.mdx +4 -0
  94. package/.docs/raw/docs/tools/interactables-legacy.mdx +410 -0
  95. package/.docs/raw/docs/tools/interactables.mdx +892 -223
  96. package/.docs/raw/docs/tools/mcp.mdx +4 -4
  97. package/.docs/raw/docs/tools/multi-agent.mdx +5 -0
  98. package/.docs/raw/docs/ui/composer-trigger-popover.mdx +2 -0
  99. package/.docs/raw/docs/ui/file.mdx +1 -1
  100. package/.docs/raw/docs/ui/part-grouping.mdx +38 -0
  101. package/.docs/raw/docs/utilities/react-o11y.mdx +92 -6
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js +18 -2
  104. package/dist/index.js.map +1 -1
  105. package/package.json +4 -4
  106. package/src/index.ts +14 -6
  107. package/src/tools/tests/mcp-protocol.test.ts +9 -0
@@ -3,7 +3,7 @@ title: "@assistant-ui/react-ai-sdk"
3
3
  description: Vercel AI SDK runtime hooks, chat transports, and message conversion utilities for assistant-ui React applications.
4
4
  ---
5
5
 
6
- import { reactAiSdk_AISDKToolkit, reactAiSdk_AssistantChatTransport, reactAiSdk_createResumableSessionStorage, reactAiSdk_getThreadMessageTokenUsage, reactAiSdk_injectQuoteContext, reactAiSdk_useAISDKRuntime, reactAiSdk_useChatRuntime } from "@/generated/integrationTypeDocs";
6
+ import { reactAiSdk_AISDKToolkit, reactAiSdk_AssistantChatTransport, reactAiSdk_createResumableSessionStorage, reactAiSdk_getThreadMessageTokenUsage, reactAiSdk_injectQuoteContext, reactAiSdk_unstable_injectInteractableContext, reactAiSdk_useAISDKRuntime, reactAiSdk_useChatRuntime } from "@/generated/integrationTypeDocs";
7
7
 
8
8
  {/* AUTO-GENERATED PAGE by scripts/generate-api-reference.mts */}
9
9
  {/* Do not edit manually. */}
@@ -34,43 +34,6 @@ import { reactAiSdk_AISDKToolkit, reactAiSdk_AssistantChatTransport, reactAiSdk_
34
34
  const frontendTools: (tools: Record<string, ToolJSONSchema>) => ToolSet;
35
35
  ```
36
36
 
37
- ### generativeTools
38
-
39
- <Callout type="warn">
40
- <strong>Deprecated.</strong> Use [AISDKToolkit](/docs/api-reference/integrations/react-ai-sdk#aisdktoolkit) instead:
41
- `new AISDKToolkit({ toolkit }).tools({ frontend })`. It is a strict superset
42
- (it also opens MCP server connections), so it replaces `generativeTools`
43
- everywhere. The `frontendTools` option is named `frontend` on `.tools()`, and
44
- `.tools()` is async. `generativeTools` will be removed in a future version.
45
- </Callout>
46
-
47
- Builds an AI SDK `ToolSet` for server-side use with `streamText` /
48
- `generateText` from a generative `toolkit` and the frontend-uploaded tools.
49
-
50
- Each toolkit tool's `execute` runs on the server. Pair this with the
51
- `"use generative"` compiler: import the toolkit in a server route (where it
52
- resolves to the server build — schema + `execute`, with `render` stripped) and
53
- pass it here. Tools without an `execute` are still exposed to the model but
54
- left for the client to fulfill. `frontendTools` lets the client contribute
55
- tools that aren't in the static toolkit.
56
-
57
- ```ts
58
- // Define once at module scope so any MCP connections pool across requests.
59
- const aiToolkit = new AISDKToolkit({ toolkit: docsToolkit });
60
-
61
- // In your route handler:
62
- const { tools } = await req.json();
63
- streamText({
64
- model,
65
- messages,
66
- tools: await aiToolkit.tools({ frontend: tools }),
67
- });
68
- ```
69
-
70
- ```ts
71
- const generativeTools: (options: GenerativeToolsOptions) => ToolSet;
72
- ```
73
-
74
37
  ### getThreadMessageTokenUsage
75
38
 
76
39
  <ParametersTable {...reactAiSdk_getThreadMessageTokenUsage} />
@@ -104,6 +67,38 @@ export async function POST(req: Request) {
104
67
  const RESUMABLE_STREAM_ID_HEADER: "x-resumable-stream-id";
105
68
  ```
106
69
 
70
+ ### unstable_injectInteractableContext
71
+
72
+ Injects interactable state snapshots into messages as model-visible text.
73
+
74
+ Mirrors [injectQuoteContext](/docs/api-reference/integrations/react-ai-sdk#injectquotecontext): reads the frozen snapshot stamped on a user
75
+ message's `metadata.custom.interactables` (by the interactables scope at send
76
+ time) and prepends a text part. Run this in your route handler before
77
+ `convertToModelMessages`, which otherwise ignores `metadata.custom`.
78
+
79
+ Wording is consumer-owned — pass `format` to control how each snapshot reads.
80
+ A snapshot may originate from a user edit or an agent `update_*` call, so the
81
+ default phrasing is neutral. Keep the instance id visible in custom wording:
82
+ the model needs it to address the `update_*` tool's `id` parameter. A custom
83
+ `format` must also handle entries with `partial: true`, whose `state` carries
84
+ only the fields that changed since the model's last known state.
85
+
86
+ ```ts
87
+ import { convertToModelMessages, streamText } from "ai";
88
+ import { unstable_injectInteractableContext } from "@assistant-ui/react-ai-sdk";
89
+
90
+ export async function POST(req: Request) {
91
+ const { messages } = await req.json();
92
+ const result = streamText({
93
+ model: myModel,
94
+ messages: await convertToModelMessages(unstable_injectInteractableContext(messages)),
95
+ });
96
+ return result.toUIMessageStreamResponse();
97
+ }
98
+ ```
99
+
100
+ <ParametersTable {...reactAiSdk_unstable_injectInteractableContext} />
101
+
107
102
  ### useAISDKRuntime
108
103
 
109
104
  <ParametersTable {...reactAiSdk_useAISDKRuntime} />
@@ -117,4 +112,41 @@ const RESUMABLE_STREAM_ID_HEADER: "x-resumable-stream-id";
117
112
  ```ts
118
113
  function useThreadTokenUsage(): ThreadTokenUsage;
119
114
  ```
115
+
116
+ ### generativeTools
117
+
118
+ <Callout type="warn">
119
+ <strong>Deprecated.</strong> Use [AISDKToolkit](/docs/api-reference/integrations/react-ai-sdk#aisdktoolkit) instead:
120
+ `new AISDKToolkit({ toolkit }).tools({ frontend })`. It is a strict superset
121
+ (it also opens MCP server connections), so it replaces `generativeTools`
122
+ everywhere. The `frontendTools` option is named `frontend` on `.tools()`, and
123
+ `.tools()` is async. `generativeTools` will be removed in a future version.
124
+ </Callout>
125
+
126
+ Builds an AI SDK `ToolSet` for server-side use with `streamText` /
127
+ `generateText` from a generative `toolkit` and the frontend-uploaded tools.
128
+
129
+ Each toolkit tool's `execute` runs on the server. Pair this with the
130
+ `"use generative"` compiler: import the toolkit in a server route (where it
131
+ resolves to the server build — schema + `execute`, with `render` stripped) and
132
+ pass it here. Tools without an `execute` are still exposed to the model but
133
+ left for the client to fulfill. `frontendTools` lets the client contribute
134
+ tools that aren't in the static toolkit.
135
+
136
+ ```ts
137
+ // Define once at module scope so any MCP connections pool across requests.
138
+ const aiToolkit = new AISDKToolkit({ toolkit: docsToolkit });
139
+
140
+ // In your route handler:
141
+ const { tools } = await req.json();
142
+ streamText({
143
+ model,
144
+ messages,
145
+ tools: await aiToolkit.tools({ frontend: tools }),
146
+ });
147
+ ```
148
+
149
+ ```ts
150
+ const generativeTools: (options: GenerativeToolsOptions) => ToolSet;
151
+ ```
120
152
  {/* api-reference:end */}
@@ -53,6 +53,18 @@ const AssistantMessageBar = () => (
53
53
  <p>This primitive renders a <code>{`<${ActionBarPrimitiveDocs.Root?.element}>`}</code> element unless <code>asChild</code> is set.</p>
54
54
  )}
55
55
 
56
+ ```tsx
57
+ <ActionBarPrimitive.Root
58
+ hideWhenRunning={true}
59
+ autohide="not-last"
60
+ autohideFloat="single-branch"
61
+ >
62
+ <ActionBarPrimitive.Copy />
63
+ <ActionBarPrimitive.Edit />
64
+ <ActionBarPrimitive.Reload />
65
+ </ActionBarPrimitive.Root>
66
+ ```
67
+
56
68
  <ParametersTable {...ActionBarPrimitiveRootProps} />
57
69
 
58
70
  {/* api-manual:ActionBarPrimitive.Root:start */}
@@ -75,6 +87,12 @@ const AssistantMessageBar = () => (
75
87
  <p>This primitive renders a <code>{`<${ActionBarPrimitiveDocs.Copy?.element}>`}</code> element unless <code>asChild</code> is set.</p>
76
88
  )}
77
89
 
90
+ ```tsx
91
+ <ActionBarPrimitive.Copy copiedDuration={2000}>
92
+ Copy Message
93
+ </ActionBarPrimitive.Copy>
94
+ ```
95
+
78
96
  <ParametersTable {...ActionBarPrimitiveCopyProps} />
79
97
 
80
98
  {/* api-manual:ActionBarPrimitive.Copy:start */}
@@ -97,6 +115,12 @@ const AssistantMessageBar = () => (
97
115
  <p>This primitive renders a <code>{`<${ActionBarPrimitiveDocs.Reload?.element}>`}</code> element unless <code>asChild</code> is set.</p>
98
116
  )}
99
117
 
118
+ ```tsx
119
+ <ActionBarPrimitive.Reload>
120
+ Reload Message
121
+ </ActionBarPrimitive.Reload>
122
+ ```
123
+
100
124
  <ParametersTable {...ActionBarPrimitiveReloadProps} />
101
125
 
102
126
  ### Edit
@@ -113,6 +137,12 @@ const AssistantMessageBar = () => (
113
137
  <p>This primitive renders a <code>{`<${ActionBarPrimitiveDocs.Edit?.element}>`}</code> element unless <code>asChild</code> is set.</p>
114
138
  )}
115
139
 
140
+ ```tsx
141
+ <ActionBarPrimitive.Edit>
142
+ Edit Message
143
+ </ActionBarPrimitive.Edit>
144
+ ```
145
+
116
146
  <ParametersTable {...ActionBarPrimitiveEditProps} />
117
147
 
118
148
  ### Speak
@@ -54,6 +54,13 @@ const MyComposerAttachment = () => (
54
54
  <p>This primitive renders a <code>{`<${AttachmentPrimitiveDocs.Root?.element}>`}</code> element unless <code>asChild</code> is set.</p>
55
55
  )}
56
56
 
57
+ ```tsx
58
+ <AttachmentPrimitive.Root>
59
+ <AttachmentPrimitive.Name />
60
+ <AttachmentPrimitive.Remove />
61
+ </AttachmentPrimitive.Root>
62
+ ```
63
+
57
64
  <ParametersTable {...AttachmentPrimitiveRootProps} />
58
65
 
59
66
  ### Name
@@ -47,6 +47,14 @@ const BranchPicker = () => (
47
47
  <p>This primitive renders a <code>{`<${BranchPickerPrimitiveDocs.Root?.element}>`}</code> element unless <code>asChild</code> is set.</p>
48
48
  )}
49
49
 
50
+ ```tsx
51
+ <BranchPickerPrimitive.Root hideWhenSingleBranch={true}>
52
+ <BranchPickerPrimitive.Previous />
53
+ <BranchPickerPrimitive.Count />
54
+ <BranchPickerPrimitive.Next />
55
+ </BranchPickerPrimitive.Root>
56
+ ```
57
+
50
58
  <ParametersTable {...BranchPickerPrimitiveRootProps} />
51
59
 
52
60
  ### Next
@@ -63,6 +71,12 @@ const BranchPicker = () => (
63
71
  <p>This primitive renders a <code>{`<${BranchPickerPrimitiveDocs.Next?.element}>`}</code> element unless <code>asChild</code> is set.</p>
64
72
  )}
65
73
 
74
+ ```tsx
75
+ <BranchPickerPrimitive.Next>
76
+ Next →
77
+ </BranchPickerPrimitive.Next>
78
+ ```
79
+
66
80
  <ParametersTable {...BranchPickerPrimitiveNextProps} />
67
81
 
68
82
  ### Previous
@@ -79,6 +93,12 @@ const BranchPicker = () => (
79
93
  <p>This primitive renders a <code>{`<${BranchPickerPrimitiveDocs.Previous?.element}>`}</code> element unless <code>asChild</code> is set.</p>
80
94
  )}
81
95
 
96
+ ```tsx
97
+ <BranchPickerPrimitive.Previous>
98
+ ← Previous
99
+ </BranchPickerPrimitive.Previous>
100
+ ```
101
+
82
102
  <ParametersTable {...BranchPickerPrimitivePreviousProps} />
83
103
 
84
104
  ### Count
@@ -95,6 +115,12 @@ const BranchPicker = () => (
95
115
  <p>This primitive renders a <code>{`<${BranchPickerPrimitiveDocs.Count?.element}>`}</code> element unless <code>asChild</code> is set.</p>
96
116
  )}
97
117
 
118
+ ```tsx
119
+ <div>
120
+ Branch <BranchPickerPrimitive.Count /> of {totalBranches}
121
+ </div>
122
+ ```
123
+
98
124
  {BranchPickerPrimitiveDocs.Count?.props && (
99
125
  <ParametersTable type={BranchPickerPrimitiveDocs.Count?.element} parameters={BranchPickerPrimitiveDocs.Count.props} />
100
126
  )}
@@ -31,6 +31,15 @@ For examples and usage patterns, see [ChainOfThought](/docs/primitives/chain-of-
31
31
  <p>This primitive renders a <code>{`<${ChainOfThoughtPrimitiveDocs.Root?.element}>`}</code> element unless <code>asChild</code> is set.</p>
32
32
  )}
33
33
 
34
+ ```tsx
35
+ <ChainOfThoughtPrimitive.Root>
36
+ <ChainOfThoughtPrimitive.AccordionTrigger>
37
+ Toggle reasoning
38
+ </ChainOfThoughtPrimitive.AccordionTrigger>
39
+ <ChainOfThoughtPrimitive.Parts />
40
+ </ChainOfThoughtPrimitive.Root>
41
+ ```
42
+
34
43
  <ParametersTable {...ChainOfThoughtPrimitiveRootProps} />
35
44
 
36
45
  ### AccordionTrigger
@@ -47,6 +56,12 @@ For examples and usage patterns, see [ChainOfThought](/docs/primitives/chain-of-
47
56
  <p>This primitive renders a <code>{`<${ChainOfThoughtPrimitiveDocs.AccordionTrigger?.element}>`}</code> element unless <code>asChild</code> is set.</p>
48
57
  )}
49
58
 
59
+ ```tsx
60
+ <ChainOfThoughtPrimitive.AccordionTrigger>
61
+ Toggle Reasoning
62
+ </ChainOfThoughtPrimitive.AccordionTrigger>
63
+ ```
64
+
50
65
  <ParametersTable {...ChainOfThoughtPrimitiveAccordionTriggerProps} />
51
66
 
52
67
  ### Parts
@@ -78,6 +78,13 @@ const ComposerWithDictation = () => (
78
78
  <p>This primitive renders a <code>{`<${ComposerPrimitiveDocs.Root?.element}>`}</code> element unless <code>asChild</code> is set.</p>
79
79
  )}
80
80
 
81
+ ```tsx
82
+ <ComposerPrimitive.Root>
83
+ <ComposerPrimitive.Input placeholder="Type your message..." />
84
+ <ComposerPrimitive.Send>Send</ComposerPrimitive.Send>
85
+ </ComposerPrimitive.Root>
86
+ ```
87
+
81
88
  <ParametersTable {...ComposerPrimitiveRootProps} />
82
89
 
83
90
  ### Input
@@ -94,6 +101,26 @@ const ComposerWithDictation = () => (
94
101
  <p>This primitive renders a <code>{`<${ComposerPrimitiveDocs.Input?.element}>`}</code> element unless <code>asChild</code> is set.</p>
95
102
  )}
96
103
 
104
+ ```tsx
105
+ // Ctrl/Cmd+Enter to submit (plain Enter inserts newline)
106
+ <ComposerPrimitive.Input
107
+ placeholder="Type your message..."
108
+ submitMode="ctrlEnter"
109
+ />
110
+
111
+ // Insert a newline on Enter on touch-primary devices.
112
+ <ComposerPrimitive.Input
113
+ placeholder="Type your message..."
114
+ unstable_insertNewlineOnTouchEnter
115
+ />
116
+
117
+ // Old API (deprecated, still supported)
118
+ <ComposerPrimitive.Input
119
+ placeholder="Type your message..."
120
+ submitOnEnter={true}
121
+ />
122
+ ```
123
+
97
124
  <ParametersTable {...ComposerPrimitiveInputProps} />
98
125
 
99
126
  {/* api-manual:ComposerPrimitive.Input:start */}
@@ -150,6 +177,12 @@ Only takes effect when `submitMode` resolves to `"enter"` (the default); `"ctrlE
150
177
  <p>This primitive renders a <code>{`<${ComposerPrimitiveDocs.Send?.element}>`}</code> element unless <code>asChild</code> is set.</p>
151
178
  )}
152
179
 
180
+ ```tsx
181
+ <ComposerPrimitive.Send>
182
+ Send Message
183
+ </ComposerPrimitive.Send>
184
+ ```
185
+
153
186
  <ParametersTable {...ComposerPrimitiveSendProps} />
154
187
 
155
188
  ### Cancel
@@ -166,6 +199,12 @@ Only takes effect when `submitMode` resolves to `"enter"` (the default); `"ctrlE
166
199
  <p>This primitive renders a <code>{`<${ComposerPrimitiveDocs.Cancel?.element}>`}</code> element unless <code>asChild</code> is set.</p>
167
200
  )}
168
201
 
202
+ ```tsx
203
+ <ComposerPrimitive.Cancel>
204
+ Cancel
205
+ </ComposerPrimitive.Cancel>
206
+ ```
207
+
169
208
  <ParametersTable {...ComposerPrimitiveCancelProps} />
170
209
 
171
210
  ### AddAttachment
@@ -252,6 +291,12 @@ Only takes effect when `submitMode` resolves to `"enter"` (the default); `"ctrlE
252
291
  <p>This primitive renders a <code>{`<${ComposerPrimitiveDocs.Dictate?.element}>`}</code> element unless <code>asChild</code> is set.</p>
253
292
  )}
254
293
 
294
+ ```tsx
295
+ <ComposerPrimitive.Dictate>
296
+ <MicIcon />
297
+ </ComposerPrimitive.Dictate>
298
+ ```
299
+
255
300
  <ParametersTable {...ComposerPrimitiveDictateProps} />
256
301
 
257
302
  ### StopDictation
@@ -268,6 +313,12 @@ Only takes effect when `submitMode` resolves to `"enter"` (the default); `"ctrlE
268
313
  <p>This primitive renders a <code>{`<${ComposerPrimitiveDocs.StopDictation?.element}>`}</code> element unless <code>asChild</code> is set.</p>
269
314
  )}
270
315
 
316
+ ```tsx
317
+ <ComposerPrimitive.StopDictation>
318
+ <StopIcon />
319
+ </ComposerPrimitive.StopDictation>
320
+ ```
321
+
271
322
  <ParametersTable {...ComposerPrimitiveStopDictationProps} />
272
323
 
273
324
  ### DictationTranscript
@@ -284,6 +335,14 @@ Only takes effect when `submitMode` resolves to `"enter"` (the default); `"ctrlE
284
335
  <p>This primitive renders a <code>{`<${ComposerPrimitiveDocs.DictationTranscript?.element}>`}</code> element unless <code>asChild</code> is set.</p>
285
336
  )}
286
337
 
338
+ ```tsx
339
+ <ComposerPrimitive.If dictation>
340
+ <div className="dictation-preview">
341
+ <ComposerPrimitive.DictationTranscript />
342
+ </div>
343
+ </ComposerPrimitive.If>
344
+ ```
345
+
287
346
  <ParametersTable {...ComposerPrimitiveDictationTranscriptProps} />
288
347
 
289
348
  ### If
@@ -316,6 +375,13 @@ Only takes effect when `submitMode` resolves to `"enter"` (the default); `"ctrlE
316
375
  <p>This primitive renders a <code>{`<${ComposerPrimitiveDocs.Quote?.element}>`}</code> element unless <code>asChild</code> is set.</p>
317
376
  )}
318
377
 
378
+ ```tsx
379
+ <ComposerPrimitive.Quote>
380
+ <ComposerPrimitive.QuoteText />
381
+ <ComposerPrimitive.QuoteDismiss>×</ComposerPrimitive.QuoteDismiss>
382
+ </ComposerPrimitive.Quote>
383
+ ```
384
+
319
385
  <ParametersTable {...ComposerPrimitiveQuoteProps} />
320
386
 
321
387
  ### QuoteText
@@ -332,6 +398,10 @@ Only takes effect when `submitMode` resolves to `"enter"` (the default); `"ctrlE
332
398
  <p>This primitive renders a <code>{`<${ComposerPrimitiveDocs.QuoteText?.element}>`}</code> element unless <code>asChild</code> is set.</p>
333
399
  )}
334
400
 
401
+ ```tsx
402
+ <ComposerPrimitive.QuoteText />
403
+ ```
404
+
335
405
  <ParametersTable {...ComposerPrimitiveQuoteTextProps} />
336
406
 
337
407
  ### QuoteDismiss
@@ -348,6 +418,10 @@ Only takes effect when `submitMode` resolves to `"enter"` (the default); `"ctrlE
348
418
  <p>This primitive renders a <code>{`<${ComposerPrimitiveDocs.QuoteDismiss?.element}>`}</code> element unless <code>asChild</code> is set.</p>
349
419
  )}
350
420
 
421
+ ```tsx
422
+ <ComposerPrimitive.QuoteDismiss>×</ComposerPrimitive.QuoteDismiss>
423
+ ```
424
+
351
425
  <ParametersTable {...ComposerPrimitiveQuoteDismissProps} />
352
426
 
353
427
  ### Queue
@@ -364,6 +438,17 @@ Only takes effect when `submitMode` resolves to `"enter"` (the default); `"ctrlE
364
438
  <p>This primitive renders a <code>{`<${ComposerPrimitiveDocs.Queue?.element}>`}</code> element unless <code>asChild</code> is set.</p>
365
439
  )}
366
440
 
441
+ ```tsx
442
+ <ComposerPrimitive.Queue>
443
+ {({ queueItem }) => (
444
+ <div>
445
+ <QueueItemPrimitive.Text />
446
+ <QueueItemPrimitive.Steer>Run Now</QueueItemPrimitive.Steer>
447
+ </div>
448
+ )}
449
+ </ComposerPrimitive.Queue>
450
+ ```
451
+
367
452
  <ParametersTable {...ComposerPrimitiveQueueProps} />
368
453
 
369
454
  ### Unstable_TriggerPopover
@@ -402,6 +487,24 @@ Only takes effect when `submitMode` resolves to `"enter"` (the default); `"ctrlE
402
487
  <p>This primitive renders a <code>{`<${ComposerPrimitiveDocs.Unstable_TriggerPopoverRoot?.element}>`}</code> element unless <code>asChild</code> is set.</p>
403
488
  )}
404
489
 
490
+ ```tsx
491
+ <ComposerPrimitive.Unstable_TriggerPopoverRoot>
492
+ <ComposerPrimitive.Unstable_TriggerPopover char="@" adapter={mentionAdapter}>
493
+ <ComposerPrimitive.Unstable_TriggerPopover.Directive formatter={formatter} />
494
+ ...
495
+ </ComposerPrimitive.Unstable_TriggerPopover>
496
+
497
+ <ComposerPrimitive.Unstable_TriggerPopover char="/" adapter={slashAdapter}>
498
+ <ComposerPrimitive.Unstable_TriggerPopover.Action onExecute={handler} />
499
+ ...
500
+ </ComposerPrimitive.Unstable_TriggerPopover>
501
+
502
+ <ComposerPrimitive.Root>
503
+ <ComposerPrimitive.Input />
504
+ </ComposerPrimitive.Root>
505
+ </ComposerPrimitive.Unstable_TriggerPopoverRoot>
506
+ ```
507
+
405
508
  <ParametersTable {...ComposerPrimitiveUnstable_TriggerPopoverRootProps} />
406
509
 
407
510
  ### Unstable_TriggerPopoverCategories
@@ -41,6 +41,14 @@ const TextMessagePart = () => {
41
41
  <p>This primitive renders a <code>{`<${MessagePartPrimitiveDocs.Text?.element}>`}</code> element unless <code>asChild</code> is set.</p>
42
42
  )}
43
43
 
44
+ ```tsx
45
+ <MessagePartPrimitive.Text
46
+ smooth={true}
47
+ component="p"
48
+ className="message-text"
49
+ />
50
+ ```
51
+
44
52
  <ParametersTable {...MessagePartPrimitiveTextProps} />
45
53
 
46
54
  {/* api-manual:MessagePartPrimitive.Text:start */}
@@ -63,6 +71,14 @@ const TextMessagePart = () => {
63
71
  <p>This primitive renders a <code>{`<${MessagePartPrimitiveDocs.Image?.element}>`}</code> element unless <code>asChild</code> is set.</p>
64
72
  )}
65
73
 
74
+ ```tsx
75
+ <MessagePartPrimitive.Image
76
+ alt="Generated image"
77
+ className="message-image"
78
+ style={{ maxWidth: '100%' }}
79
+ />
80
+ ```
81
+
66
82
  <ParametersTable {...MessagePartPrimitiveImageProps} />
67
83
 
68
84
  ### InProgress
@@ -55,6 +55,16 @@ const AssistantMessage = () => (
55
55
  <p>This primitive renders a <code>{`<${MessagePrimitiveDocs.Root?.element}>`}</code> element unless <code>asChild</code> is set.</p>
56
56
  )}
57
57
 
58
+ ```tsx
59
+ <MessagePrimitive.Root>
60
+ <MessagePrimitive.Content />
61
+ <ActionBarPrimitive.Root>
62
+ <ActionBarPrimitive.Copy />
63
+ <ActionBarPrimitive.Edit />
64
+ </ActionBarPrimitive.Root>
65
+ </MessagePrimitive.Root>
66
+ ```
67
+
58
68
  <ParametersTable {...MessagePrimitiveRootProps} />
59
69
 
60
70
  ### Parts
@@ -201,6 +211,27 @@ const AssistantMessage = () => (
201
211
  <p>This primitive renders a <code>{`<${MessagePrimitiveDocs.GroupedParts?.element}>`}</code> element unless <code>asChild</code> is set.</p>
202
212
  )}
203
213
 
214
+ ```tsx
215
+ <MessagePrimitive.GroupedParts
216
+ groupBy={groupPartByType({
217
+ reasoning: ["group-thought", "group-reasoning"],
218
+ "tool-call": ["group-thought", "group-tool"],
219
+ })}
220
+ >
221
+ {({ part, children }) => {
222
+ switch (part.type) {
223
+ case "group-thought": return <Thought>{children}</Thought>;
224
+ case "group-reasoning": return <Reasoning>{children}</Reasoning>;
225
+ case "group-tool": return <ToolStack>{children}</ToolStack>;
226
+ case "text": return <MarkdownText />;
227
+ case "tool-call": return part.toolUI ?? <ToolFallback {...part} />;
228
+ case "indicator": return <LoadingDots />;
229
+ default: return null;
230
+ }
231
+ }}
232
+ </MessagePrimitive.GroupedParts>
233
+ ```
234
+
204
235
  <ParametersTable {...MessagePrimitiveGroupedPartsProps} />
205
236
 
206
237
  ### GenerativeUI
@@ -217,6 +248,12 @@ const AssistantMessage = () => (
217
248
  <p>This primitive renders a <code>{`<${MessagePrimitiveDocs.GenerativeUI?.element}>`}</code> element unless <code>asChild</code> is set.</p>
218
249
  )}
219
250
 
251
+ ```tsx
252
+ <MessagePrimitive.GenerativeUI
253
+ components={{ Card: MyCard, Button: MyButton }}
254
+ />
255
+ ```
256
+
220
257
  <ParametersTable {...MessagePrimitiveGenerativeUIProps} />
221
258
 
222
259
  ### Unstable_PartsGrouped
@@ -233,6 +270,25 @@ const AssistantMessage = () => (
233
270
  <p>This primitive renders a <code>{`<${MessagePrimitiveDocs.Unstable_PartsGrouped?.element}>`}</code> element unless <code>asChild</code> is set.</p>
234
271
  )}
235
272
 
273
+ ```tsx
274
+ // Group by parent ID (default behavior)
275
+ <MessagePrimitive.Unstable_PartsGrouped
276
+ components={{
277
+ Text: ({ text }) => <p className="message-text">{text}</p>,
278
+ Image: ({ image }) => <img src={image} alt="Message image" />,
279
+ Group: ({ groupKey, indices, children }) => {
280
+ if (!groupKey) return <>{children}</>;
281
+ return (
282
+ <div className="parent-group border rounded p-4">
283
+ <h4>Parent ID: {groupKey}</h4>
284
+ {children}
285
+ </div>
286
+ );
287
+ }
288
+ }}
289
+ />
290
+ ```
291
+
236
292
  <ParametersTable {...MessagePrimitiveUnstable_PartsGroupedProps} />
237
293
 
238
294
  ### Unstable_PartsGroupedByParentId
@@ -29,6 +29,10 @@ import { QueueItemPrimitive as QueueItemPrimitiveDocs } from "@/generated/primit
29
29
  <p>This primitive renders a <code>{`<${QueueItemPrimitiveDocs.Text?.element}>`}</code> element unless <code>asChild</code> is set.</p>
30
30
  )}
31
31
 
32
+ ```tsx
33
+ <QueueItemPrimitive.Text />
34
+ ```
35
+
32
36
  <ParametersTable {...QueueItemPrimitiveTextProps} />
33
37
 
34
38
  ### Steer
@@ -45,6 +49,10 @@ import { QueueItemPrimitive as QueueItemPrimitiveDocs } from "@/generated/primit
45
49
  <p>This primitive renders a <code>{`<${QueueItemPrimitiveDocs.Steer?.element}>`}</code> element unless <code>asChild</code> is set.</p>
46
50
  )}
47
51
 
52
+ ```tsx
53
+ <QueueItemPrimitive.Steer>Run Now</QueueItemPrimitive.Steer>
54
+ ```
55
+
48
56
  <ParametersTable {...QueueItemPrimitiveSteerProps} />
49
57
 
50
58
  ### Remove
@@ -61,5 +69,9 @@ import { QueueItemPrimitive as QueueItemPrimitiveDocs } from "@/generated/primit
61
69
  <p>This primitive renders a <code>{`<${QueueItemPrimitiveDocs.Remove?.element}>`}</code> element unless <code>asChild</code> is set.</p>
62
70
  )}
63
71
 
72
+ ```tsx
73
+ <QueueItemPrimitive.Remove>×</QueueItemPrimitive.Remove>
74
+ ```
75
+
64
76
  <ParametersTable {...QueueItemPrimitiveRemoveProps} />
65
77
  {/* api-reference:end */}
@@ -54,6 +54,12 @@ Place this component inside `ThreadPrimitive.Root`:
54
54
  <p>This primitive renders a <code>{`<${SelectionToolbarPrimitiveDocs.Root?.element}>`}</code> element unless <code>asChild</code> is set.</p>
55
55
  )}
56
56
 
57
+ ```tsx
58
+ <SelectionToolbarPrimitive.Root>
59
+ <SelectionToolbarPrimitive.Quote>Quote</SelectionToolbarPrimitive.Quote>
60
+ </SelectionToolbarPrimitive.Root>
61
+ ```
62
+
57
63
  <ParametersTable {...SelectionToolbarPrimitiveRootProps} />
58
64
 
59
65
  ### Quote
@@ -70,5 +76,11 @@ Place this component inside `ThreadPrimitive.Root`:
70
76
  <p>This primitive renders a <code>{`<${SelectionToolbarPrimitiveDocs.Quote?.element}>`}</code> element unless <code>asChild</code> is set.</p>
71
77
  )}
72
78
 
79
+ ```tsx
80
+ <SelectionToolbarPrimitive.Quote>
81
+ <QuoteIcon /> Quote
82
+ </SelectionToolbarPrimitive.Quote>
83
+ ```
84
+
73
85
  <ParametersTable {...SelectionToolbarPrimitiveQuoteProps} />
74
86
  {/* api-reference:end */}
@@ -31,6 +31,10 @@ For examples and usage patterns, see [Suggestion](/docs/primitives/suggestion).
31
31
  <p>This primitive renders a <code>{`<${SuggestionPrimitiveDocs.Title?.element}>`}</code> element unless <code>asChild</code> is set.</p>
32
32
  )}
33
33
 
34
+ ```tsx
35
+ <SuggestionPrimitive.Title />
36
+ ```
37
+
34
38
  <ParametersTable {...SuggestionPrimitiveTitleProps} />
35
39
 
36
40
  ### Description
@@ -47,6 +51,10 @@ For examples and usage patterns, see [Suggestion](/docs/primitives/suggestion).
47
51
  <p>This primitive renders a <code>{`<${SuggestionPrimitiveDocs.Description?.element}>`}</code> element unless <code>asChild</code> is set.</p>
48
52
  )}
49
53
 
54
+ ```tsx
55
+ <SuggestionPrimitive.Description />
56
+ ```
57
+
50
58
  <ParametersTable {...SuggestionPrimitiveDescriptionProps} />
51
59
 
52
60
  ### Trigger
@@ -63,5 +71,11 @@ For examples and usage patterns, see [Suggestion](/docs/primitives/suggestion).
63
71
  <p>This primitive renders a <code>{`<${SuggestionPrimitiveDocs.Trigger?.element}>`}</code> element unless <code>asChild</code> is set.</p>
64
72
  )}
65
73
 
74
+ ```tsx
75
+ <SuggestionPrimitive.Trigger send>
76
+ Click me
77
+ </SuggestionPrimitive.Trigger>
78
+ ```
79
+
66
80
  <ParametersTable {...SuggestionPrimitiveTriggerProps} />
67
81
  {/* api-reference:end */}