@assistant-ui/mcp-docs-server 0.1.19 → 0.1.21

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 (108) hide show
  1. package/.docs/organized/code-examples/with-ag-ui.md +172 -1633
  2. package/.docs/organized/code-examples/with-ai-sdk-v6.md +42 -1640
  3. package/.docs/organized/code-examples/with-assistant-transport.md +40 -1743
  4. package/.docs/organized/code-examples/with-cloud.md +71 -1745
  5. package/.docs/organized/code-examples/with-custom-thread-list.md +87 -1723
  6. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +70 -1637
  7. package/.docs/organized/code-examples/with-external-store.md +67 -1624
  8. package/.docs/organized/code-examples/with-ffmpeg.md +71 -1629
  9. package/.docs/organized/code-examples/with-langgraph.md +95 -1893
  10. package/.docs/organized/code-examples/with-parent-id-grouping.md +57 -1654
  11. package/.docs/organized/code-examples/with-react-hook-form.md +220 -2163
  12. package/.docs/organized/code-examples/with-react-router.md +66 -1318
  13. package/.docs/organized/code-examples/with-store.md +31 -31
  14. package/.docs/organized/code-examples/with-tanstack.md +77 -861
  15. package/.docs/organized/code-examples/with-tap-runtime.md +812 -0
  16. package/.docs/raw/docs/(docs)/cli.mdx +66 -0
  17. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +0 -1
  18. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +0 -1
  19. package/.docs/raw/docs/(docs)/copilots/model-context.mdx +4 -4
  20. package/.docs/raw/docs/(docs)/copilots/motivation.mdx +3 -3
  21. package/.docs/raw/docs/(docs)/devtools.mdx +0 -1
  22. package/.docs/raw/docs/(docs)/guides/attachments.mdx +2 -3
  23. package/.docs/raw/docs/(docs)/guides/context-api.mdx +117 -117
  24. package/.docs/raw/docs/(docs)/guides/suggestions.mdx +296 -0
  25. package/.docs/raw/docs/(docs)/guides/tools.mdx +336 -513
  26. package/.docs/raw/docs/(docs)/index.mdx +33 -410
  27. package/.docs/raw/docs/(docs)/installation.mdx +450 -0
  28. package/.docs/raw/docs/(docs)/llm.mdx +209 -0
  29. package/.docs/raw/docs/(reference)/api-reference/context-providers/assistant-runtime-provider.mdx +0 -1
  30. package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +0 -1
  31. package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +48 -3
  32. package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +0 -1
  33. package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +0 -1
  34. package/.docs/raw/docs/(reference)/api-reference/overview.mdx +9 -3
  35. package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar-more.mdx +20 -52
  36. package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +16 -39
  37. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +49 -50
  38. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +3 -11
  39. package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +0 -3
  40. package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +0 -1
  41. package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +5 -16
  42. package/.docs/raw/docs/(reference)/api-reference/primitives/composition.mdx +0 -1
  43. package/.docs/raw/docs/(reference)/api-reference/primitives/error.mdx +0 -1
  44. package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +1 -2
  45. package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +0 -1
  46. package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +152 -0
  47. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item-more.mdx +0 -1
  48. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +1 -2
  49. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +1 -2
  50. package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +28 -40
  51. package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +0 -1
  52. package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +1 -2
  53. package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +2 -3
  54. package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +1 -2
  55. package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +1 -2
  56. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +0 -1
  57. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +0 -1
  58. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +1 -2
  59. package/.docs/raw/docs/(reference)/legacy/styled/assistant-modal.mdx +0 -1
  60. package/.docs/raw/docs/(reference)/legacy/styled/decomposition.mdx +5 -5
  61. package/.docs/raw/docs/(reference)/legacy/styled/markdown.mdx +0 -1
  62. package/.docs/raw/docs/(reference)/legacy/styled/thread.mdx +0 -1
  63. package/.docs/raw/docs/(reference)/migrations/v0-12.mdx +207 -33
  64. package/.docs/raw/docs/(reference)/react-compatibility.mdx +0 -1
  65. package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +0 -1
  66. package/.docs/raw/docs/cloud/persistence/langgraph.mdx +0 -1
  67. package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +0 -1
  68. package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +118 -0
  69. package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +198 -0
  70. package/.docs/raw/docs/runtimes/assistant-transport.mdx +3 -3
  71. package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +5 -6
  72. package/.docs/raw/docs/runtimes/custom/external-store.mdx +9 -11
  73. package/.docs/raw/docs/runtimes/custom/local.mdx +43 -36
  74. package/.docs/raw/docs/runtimes/data-stream.mdx +35 -3
  75. package/.docs/raw/docs/runtimes/langgraph/index.mdx +1 -2
  76. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +0 -1
  77. package/.docs/raw/docs/runtimes/langserve.mdx +0 -1
  78. package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +0 -1
  79. package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +0 -1
  80. package/.docs/raw/docs/ui/accordion.mdx +259 -0
  81. package/.docs/raw/docs/ui/assistant-modal.mdx +1 -3
  82. package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -3
  83. package/.docs/raw/docs/ui/attachment.mdx +0 -2
  84. package/.docs/raw/docs/ui/badge.mdx +138 -0
  85. package/.docs/raw/docs/ui/diff-viewer.mdx +279 -0
  86. package/.docs/raw/docs/ui/file.mdx +152 -0
  87. package/.docs/raw/docs/ui/image.mdx +100 -0
  88. package/.docs/raw/docs/ui/markdown.mdx +0 -1
  89. package/.docs/raw/docs/ui/mermaid.mdx +0 -1
  90. package/.docs/raw/docs/ui/model-selector.mdx +224 -0
  91. package/.docs/raw/docs/ui/part-grouping.mdx +4 -5
  92. package/.docs/raw/docs/ui/reasoning.mdx +6 -5
  93. package/.docs/raw/docs/ui/scrollbar.mdx +26 -9
  94. package/.docs/raw/docs/ui/select.mdx +245 -0
  95. package/.docs/raw/docs/ui/sources.mdx +6 -5
  96. package/.docs/raw/docs/ui/streamdown.mdx +348 -0
  97. package/.docs/raw/docs/ui/syntax-highlighting.mdx +8 -63
  98. package/.docs/raw/docs/ui/tabs.mdx +259 -0
  99. package/.docs/raw/docs/ui/thread-list.mdx +98 -16
  100. package/.docs/raw/docs/ui/thread.mdx +57 -73
  101. package/.docs/raw/docs/ui/tool-fallback.mdx +0 -1
  102. package/.docs/raw/docs/ui/tool-group.mdx +1 -3
  103. package/README.md +3 -3
  104. package/package.json +4 -4
  105. package/src/tools/tests/examples.test.ts +1 -1
  106. package/.docs/raw/docs/(docs)/about-assistantui.mdx +0 -54
  107. package/.docs/raw/docs/(docs)/mcp-docs-server.mdx +0 -321
  108. package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +0 -219
@@ -50,10 +50,10 @@ assistant-ui organizes state into **scopes** - logical boundaries that provide a
50
50
  // Inside a message component
51
51
  function MessageButton() {
52
52
  // ✅ Available: message scope (current message)
53
- const role = useAssistantState(({ message }) => message.role);
53
+ const role = useAuiState(({ message }) => message.role);
54
54
 
55
55
  // ✅ Available: thread scope (parent)
56
- const isRunning = useAssistantState(({ thread }) => thread.isRunning);
56
+ const isRunning = useAuiState(({ thread }) => thread.isRunning);
57
57
  }
58
58
  ```
59
59
 
@@ -68,22 +68,22 @@ The Context API follows a predictable state management pattern:
68
68
 
69
69
  ## Essential Hooks
70
70
 
71
- ### useAssistantState
71
+ ### useAuiState
72
72
 
73
73
  Read state reactively with automatic re-renders when values change. This hook works like Zustand's selector pattern - you provide a function that extracts the specific data you need, and your component only re-renders when that data changes.
74
74
 
75
75
  ```tsx
76
- import { useAssistantState } from "@assistant-ui/react";
76
+ import { useAuiState } from "@assistant-ui/react";
77
77
 
78
78
  // Basic usage - extract a single property
79
- const role = useAssistantState(({ message }) => message.role); // "user" | "assistant"
80
- const isRunning = useAssistantState(({ thread }) => thread.isRunning); // boolean
79
+ const role = useAuiState(({ message }) => message.role); // "user" | "assistant"
80
+ const isRunning = useAuiState(({ thread }) => thread.isRunning); // boolean
81
81
 
82
82
  // Access nested data
83
- const attachmentCount = useAssistantState(
83
+ const attachmentCount = useAuiState(
84
84
  ({ composer }) => composer.attachments.length,
85
85
  );
86
- const lastMessage = useAssistantState(({ thread }) => thread.messages.at(-1));
86
+ const lastMessage = useAuiState(({ thread }) => thread.messages.at(-1));
87
87
  ```
88
88
 
89
89
  The selector function receives all available scopes for your component's location and should return a specific value. The component re-renders only when that returned value changes.
@@ -92,54 +92,54 @@ The selector function receives all available scopes for your component's locatio
92
92
 
93
93
  ```tsx
94
94
  // Access multiple scopes
95
- const canSend = useAssistantState(
95
+ const canSend = useAuiState(
96
96
  ({ thread, composer }) => !thread.isRunning && composer.text.length > 0,
97
97
  );
98
98
 
99
99
  // Compute derived state
100
- const messageCount = useAssistantState(({ thread }) => thread.messages.length);
100
+ const messageCount = useAuiState(({ thread }) => thread.messages.length);
101
101
  ```
102
102
 
103
103
  **Important:** Never create new objects in selectors. Return primitive values or stable references to avoid infinite re-renders.
104
104
 
105
105
  ```tsx
106
106
  // ❌ Bad - creates new object every time
107
- const data = useAssistantState(({ message }) => ({
107
+ const data = useAuiState(({ message }) => ({
108
108
  role: message.role,
109
109
  content: message.content,
110
110
  }));
111
111
 
112
112
  // ✅ Good - returns stable values
113
- const role = useAssistantState(({ message }) => message.role);
114
- const content = useAssistantState(({ message }) => message.content);
113
+ const role = useAuiState(({ message }) => message.role);
114
+ const content = useAuiState(({ message }) => message.content);
115
115
  ```
116
116
 
117
- ### useAssistantApi
117
+ ### useAui
118
118
 
119
- Access the API instance for imperative operations and actions. Unlike `useAssistantState`, this hook returns a stable object that never changes, making it perfect for event handlers and imperative operations.
119
+ Access the API instance for imperative operations and actions. Unlike `useAuiState`, this hook returns a stable object that never changes, making it perfect for event handlers and imperative operations.
120
120
 
121
121
  ```tsx
122
- import { useAssistantApi } from "@assistant-ui/react";
122
+ import { useAui } from "@assistant-ui/react";
123
123
 
124
124
  function CustomMessageActions() {
125
- const api = useAssistantApi();
125
+ const aui = useAui();
126
126
 
127
127
  // Perform actions in event handlers
128
128
  const handleSend = () => {
129
- api.composer().send();
129
+ aui.composer().send();
130
130
  };
131
131
 
132
132
  const handleReload = () => {
133
- api.message().reload();
133
+ aui.message().reload();
134
134
  };
135
135
 
136
136
  // Read state imperatively when needed
137
137
  const handleConditionalAction = () => {
138
- const { isRunning } = api.thread().getState();
139
- const { text } = api.composer().getState();
138
+ const { isRunning } = aui.thread().getState();
139
+ const { text } = aui.composer().getState();
140
140
 
141
141
  if (!isRunning && text.length > 0) {
142
- api.composer().send();
142
+ aui.composer().send();
143
143
  }
144
144
  };
145
145
 
@@ -164,86 +164,86 @@ The API object is stable and doesn't cause re-renders. Use it for:
164
164
 
165
165
  ```tsx
166
166
  // Thread actions
167
- api.thread().append(message);
168
- api.thread().startRun(config);
169
- api.thread().cancelRun();
170
- api.thread().switchToNewThread();
171
- api.thread().switchToThread(threadId);
172
- api.thread().getState();
173
- api.thread().message(idOrIndex);
174
- api.thread().composer;
167
+ aui.thread().append(message);
168
+ aui.thread().startRun(config);
169
+ aui.thread().cancelRun();
170
+ aui.thread().switchToNewThread();
171
+ aui.thread().switchToThread(threadId);
172
+ aui.thread().getState();
173
+ aui.thread().message(idOrIndex);
174
+ aui.thread().composer;
175
175
 
176
176
  // Message actions
177
- api.message().reload();
178
- api.message().speak();
179
- api.message().stopSpeaking();
180
- api.message().submitFeedback({ type: "positive" | "negative" });
181
- api.message().switchToBranch({ position, branchId });
182
- api.message().getState();
183
- api.message().part(indexOrToolCallId);
184
- api.message().composer;
177
+ aui.message().reload();
178
+ aui.message().speak();
179
+ aui.message().stopSpeaking();
180
+ aui.message().submitFeedback({ type: "positive" | "negative" });
181
+ aui.message().switchToBranch({ position, branchId });
182
+ aui.message().getState();
183
+ aui.message().part(indexOrToolCallId);
184
+ aui.message().composer;
185
185
 
186
186
  // Part actions
187
187
  api.part().addResult(result);
188
188
  api.part().getState();
189
189
 
190
190
  // Composer actions
191
- api.composer().send();
192
- api.composer().setText(text);
193
- api.composer().setRole(role);
194
- api.composer().addAttachment(file);
195
- api.composer().clearAttachments();
196
- api.composer().reset();
197
- api.composer().getState();
191
+ aui.composer().send();
192
+ aui.composer().setText(text);
193
+ aui.composer().setRole(role);
194
+ aui.composer().addAttachment(file);
195
+ aui.composer().clearAttachments();
196
+ aui.composer().reset();
197
+ aui.composer().getState();
198
198
 
199
199
  // Attachment actions
200
- api.attachment().remove();
201
- api.attachment().getState();
200
+ aui.attachment().remove();
201
+ aui.attachment().getState();
202
202
 
203
203
  // ThreadList actions
204
- api.threads().switchToNewThread();
205
- api.threads().switchToThread(threadId);
206
- api.threads().getState();
204
+ aui.threads().switchToNewThread();
205
+ aui.threads().switchToThread(threadId);
206
+ aui.threads().getState();
207
207
 
208
208
  // ThreadListItem actions
209
- api.threadListItem().switchTo();
210
- api.threadListItem().rename(title);
211
- api.threadListItem().archive();
212
- api.threadListItem().unarchive();
213
- api.threadListItem().delete();
214
- api.threads().getState();
209
+ aui.threadListItem().switchTo();
210
+ aui.threadListItem().rename(title);
211
+ aui.threadListItem().archive();
212
+ aui.threadListItem().unarchive();
213
+ aui.threadListItem().delete();
214
+ aui.threads().getState();
215
215
 
216
216
  // Tools actions
217
- api.tools().setToolUI(toolName, render);
218
- api.tools().getState();
217
+ aui.tools().setToolUI(toolName, render);
218
+ aui.tools().getState();
219
219
  ```
220
220
 
221
- ### useAssistantEvent
221
+ ### useAuiEvent
222
222
 
223
223
  Subscribe to events with automatic cleanup on unmount. This hook is perfect for reacting to user interactions, system events, or integrating with external analytics.
224
224
 
225
225
  ```tsx
226
- import { useAssistantEvent } from "@assistant-ui/react";
226
+ import { useAuiEvent } from "@assistant-ui/react";
227
227
 
228
228
  // Listen to current scope events (most common)
229
- useAssistantEvent("composer.send", (event) => {
229
+ useAuiEvent("composer.send", (event) => {
230
230
  console.log("Current composer sent message:", event.message);
231
231
  });
232
232
 
233
233
  // Listen to all events of a type across all scopes
234
- useAssistantEvent({ event: "composer.send", scope: "*" }, (event) => {
234
+ useAuiEvent({ event: "composer.send", scope: "*" }, (event) => {
235
235
  console.log("Any composer sent a message:", event);
236
236
  });
237
237
 
238
238
  // Listen to ALL events (useful for debugging or analytics)
239
- useAssistantEvent("*", (event) => {
239
+ useAuiEvent("*", (event) => {
240
240
  console.log("Event occurred:", event.type, "from:", event.source);
241
241
  // Send to analytics, logging, etc.
242
242
  });
243
243
 
244
244
  // Practical example: Track user interactions
245
245
  function AnalyticsTracker() {
246
- useAssistantEvent("composer.send", (event) => {
246
+ useAuiEvent("composer.send", (event) => {
247
247
  analytics.track("message_sent", {
248
248
  messageLength: event.message.content.length,
249
249
  hasAttachments: event.message.attachments.length > 0,
@@ -256,7 +256,7 @@ function AnalyticsTracker() {
256
256
 
257
257
  **Event name patterns:**
258
258
 
259
- - Event names follow `source.action` format (e.g., `composer.send`, `thread.run-start`)
259
+ - Event names follow `source.action` format in camelCase (e.g., `composer.send`, `thread.runStart`)
260
260
  - Use `"*"` as the event name to listen to all events
261
261
  - The `scope` parameter controls which instances trigger the event
262
262
 
@@ -281,11 +281,11 @@ The Context API automatically resolves the current scope based on component loca
281
281
 
282
282
  ```tsx
283
283
  function MessageButton() {
284
- const api = useAssistantApi();
284
+ const aui = useAui();
285
285
 
286
286
  // Automatically uses the current message scope
287
287
  const handleReload = () => {
288
- api.message().reload();
288
+ aui.message().reload();
289
289
  };
290
290
 
291
291
  return <button onClick={handleReload}>Reload</button>;
@@ -297,12 +297,12 @@ function MessageButton() {
297
297
  Before accessing a scope, check if it's available:
298
298
 
299
299
  ```tsx
300
- const api = useAssistantApi();
300
+ const aui = useAui();
301
301
 
302
302
  // Check if message scope exists
303
303
  if (api.message.source) {
304
304
  // Safe to use message scope
305
- const { role } = api.message().getState();
305
+ const { role } = aui.message().getState();
306
306
  }
307
307
  ```
308
308
 
@@ -311,22 +311,22 @@ if (api.message.source) {
311
311
  Navigate through the scope hierarchy programmatically:
312
312
 
313
313
  ```tsx
314
- const api = useAssistantApi();
314
+ const aui = useAui();
315
315
 
316
316
  // Access specific message by ID or index
317
- const messageById = api.thread().message({ id: "msg_123" });
318
- const messageByIndex = api.thread().message({ index: 0 });
317
+ const messageById = aui.thread().message({ id: "msg_123" });
318
+ const messageByIndex = aui.thread().message({ index: 0 });
319
319
 
320
320
  // Access part by index or tool call ID
321
- const partByIndex = api.message().part({ index: 0 });
322
- const partByToolCall = api.message().part({ toolCallId: "call_123" });
321
+ const partByIndex = aui.message().part({ index: 0 });
322
+ const partByToolCall = aui.message().part({ toolCallId: "call_123" });
323
323
 
324
324
  // Access attachment by index
325
- const attachment = api.composer().attachment({ index: 0 }).getState();
325
+ const attachment = aui.composer().attachment({ index: 0 }).getState();
326
326
 
327
327
  // Access thread from thread list
328
- const thread = api.threads().thread("main");
329
- const threadItem = api.threads().item({ id: "thread_123" });
328
+ const thread = aui.threads().thread("main");
329
+ const threadItem = aui.threads().item({ id: "thread_123" });
330
330
  ```
331
331
 
332
332
  ## Common Patterns
@@ -335,7 +335,7 @@ const threadItem = api.threads().item({ id: "thread_123" });
335
335
 
336
336
  ```tsx
337
337
  function RunIndicator() {
338
- const isRunning = useAssistantState(({ thread }) => thread.isRunning);
338
+ const isRunning = useAuiState(({ thread }) => thread.isRunning);
339
339
 
340
340
  if (!isRunning) return null;
341
341
  return <div>Assistant is thinking...</div>;
@@ -346,10 +346,10 @@ function RunIndicator() {
346
346
 
347
347
  ```tsx
348
348
  function CopyButton() {
349
- const api = useAssistantApi();
349
+ const aui = useAui();
350
350
 
351
351
  const handleCopy = () => {
352
- navigator.clipboard.writeText(api.message().getCopyText());
352
+ navigator.clipboard.writeText(aui.message().getCopyText());
353
353
  };
354
354
 
355
355
  return <button onClick={handleCopy}>Copy</button>;
@@ -360,9 +360,9 @@ function CopyButton() {
360
360
 
361
361
  ```tsx
362
362
  function SmartComposer() {
363
- const api = useAssistantApi();
364
- const isRunning = useAssistantState(({ thread }) => thread.isRunning);
365
- const text = useAssistantState(({ composer }) => composer.text);
363
+ const aui = useAui();
364
+ const isRunning = useAuiState(({ thread }) => thread.isRunning);
365
+ const text = useAuiState(({ composer }) => composer.text);
366
366
 
367
367
  const canSend = !isRunning && text.length > 0;
368
368
 
@@ -370,10 +370,10 @@ function SmartComposer() {
370
370
  <div>
371
371
  <textarea
372
372
  value={text}
373
- onChange={(e) => api.composer().setText(e.target.value)}
373
+ onChange={(e) => aui.composer().setText(e.target.value)}
374
374
  disabled={isRunning}
375
375
  />
376
- <button onClick={() => api.composer().send()} disabled={!canSend}>
376
+ <button onClick={() => aui.composer().send()} disabled={!canSend}>
377
377
  Send
378
378
  </button>
379
379
  </div>
@@ -387,7 +387,7 @@ function SmartComposer() {
387
387
  function MessageCounter() {
388
388
  const [sendCount, setSendCount] = useState(0);
389
389
 
390
- useAssistantEvent("composer.send", () => {
390
+ useAuiEvent("composer.send", () => {
391
391
  setSendCount((c) => c + 1);
392
392
  });
393
393
 
@@ -402,16 +402,16 @@ function MessageCounter() {
402
402
  When you call `api.scope()`, the API resolves the current scope at that moment. This resolution happens each time you call the function, which matters when dealing with changing contexts:
403
403
 
404
404
  ```tsx
405
- const api = useAssistantApi();
405
+ const aui = useAui();
406
406
 
407
407
  // Get current thread
408
- const thread1 = api.thread();
408
+ const thread1 = aui.thread();
409
409
  thread1.append({ role: "user", content: "Hello" });
410
410
 
411
411
  // User might switch threads here
412
412
 
413
413
  // This could be a different thread
414
- const thread2 = api.thread();
414
+ const thread2 = aui.thread();
415
415
  thread2.cancelRun(); // Cancels the current thread's run, not necessarily thread1's
416
416
  ```
417
417
 
@@ -423,12 +423,12 @@ For most use cases, this behavior is intuitive. In advanced scenarios where you
423
423
 
424
424
  ```tsx
425
425
  // ❌ Expensive computation in selector (runs on every store update)
426
- const result = useAssistantState(
426
+ const result = useAuiState(
427
427
  ({ thread }) => thread.messages.filter((m) => m.role === "user").length,
428
428
  );
429
429
 
430
430
  // ✅ Memoize expensive computations
431
- const messages = useAssistantState(({ thread }) => thread.messages);
431
+ const messages = useAuiState(({ thread }) => thread.messages);
432
432
  const userCount = useMemo(
433
433
  () => messages.filter((m) => m.role === "user").length,
434
434
  [messages],
@@ -439,10 +439,10 @@ const userCount = useMemo(
439
439
 
440
440
  ```tsx
441
441
  // ❌ Subscribes to entire thread state
442
- const thread = useAssistantState(({ thread }) => thread);
442
+ const thread = useAuiState(({ thread }) => thread);
443
443
 
444
444
  // ✅ Subscribe only to needed values
445
- const isRunning = useAssistantState(({ thread }) => thread.isRunning);
445
+ const isRunning = useAuiState(({ thread }) => thread.isRunning);
446
446
  ```
447
447
 
448
448
  ## API Reference
@@ -451,9 +451,9 @@ const isRunning = useAssistantState(({ thread }) => thread.isRunning);
451
451
 
452
452
  | Hook | Purpose | Returns |
453
453
  | ----------------------------------- | -------------------------- | -------------- |
454
- | `useAssistantState(selector)` | Subscribe to state changes | Selected value |
455
- | `useAssistantApi()` | Get API instance | API object |
456
- | `useAssistantEvent(event, handler)` | Subscribe to events | void |
454
+ | `useAuiState(selector)` | Subscribe to state changes | Selected value |
455
+ | `useAui()` | Get API instance | API object |
456
+ | `useAuiEvent(event, handler)` | Subscribe to events | void |
457
457
 
458
458
  ### Scope States
459
459
 
@@ -483,14 +483,14 @@ const isRunning = useAssistantState(({ thread }) => thread.isRunning);
483
483
 
484
484
  | Event | Description |
485
485
  | -------------------------------- | ----------------------------- |
486
- | `thread.run-start` | Assistant starts generating |
487
- | `thread.run-end` | Assistant finishes generating |
486
+ | `thread.runStart` | Assistant starts generating |
487
+ | `thread.runEnd` | Assistant finishes generating |
488
488
  | `thread.initialize` | Thread is initialized |
489
- | `thread.model-context-update` | Model context is updated |
489
+ | `thread.modelContextUpdate` | Model context is updated |
490
490
  | `composer.send` | Message is sent |
491
- | `composer.attachment-add` | Attachment added to composer |
492
- | `thread-list-item.switched-to` | Switched to a thread |
493
- | `thread-list-item.switched-away` | Switched away from a thread |
491
+ | `composer.attachmentAdd` | Attachment added to composer |
492
+ | `threadListItem.switchedTo` | Switched to a thread |
493
+ | `threadListItem.switchedAway` | Switched away from a thread |
494
494
 
495
495
  ## Troubleshooting
496
496
 
@@ -500,13 +500,13 @@ const isRunning = useAssistantState(({ thread }) => thread.isRunning);
500
500
 
501
501
  ```tsx
502
502
  // ❌ This will throw if not inside a message component
503
- const role = useAssistantState(({ message }) => message.role);
503
+ const role = useAuiState(({ message }) => message.role);
504
504
 
505
505
  // ✅ Check scope availability first
506
506
  function SafeMessageButton() {
507
- const api = useAssistantApi();
507
+ const aui = useAui();
508
508
 
509
- const role = useAssistantState(({ message }) =>
509
+ const role = useAuiState(({ message }) =>
510
510
  api.message.source !== undefined ? message.role : "none",
511
511
  );
512
512
 
@@ -518,22 +518,22 @@ function SafeMessageButton() {
518
518
 
519
519
  ```tsx
520
520
  // ❌ Creating new objects in selectors causes infinite re-renders
521
- const data = useAssistantState(({ message }) => ({
521
+ const data = useAuiState(({ message }) => ({
522
522
  role: message.role,
523
523
  content: message.content, // New object every time!
524
524
  }));
525
525
 
526
526
  // ✅ Return primitive values or use separate selectors
527
- const role = useAssistantState(({ message }) => message.role);
528
- const content = useAssistantState(({ message }) => message.content);
527
+ const role = useAuiState(({ message }) => message.role);
528
+ const content = useAuiState(({ message }) => message.content);
529
529
  ```
530
530
 
531
531
  **"Scope resolution failed" / Stale scope references**
532
532
 
533
533
  ```tsx
534
534
  // ❌ Storing scope references can lead to stale data
535
- const api = useAssistantApi();
536
- const thread = api.thread(); // This reference might become stale
535
+ const aui = useAui();
536
+ const thread = aui.thread(); // This reference might become stale
537
537
 
538
538
  useEffect(() => {
539
539
  // This might reference the wrong thread if user switched
@@ -541,26 +541,26 @@ useEffect(() => {
541
541
  }, [thread]);
542
542
 
543
543
  // ✅ Resolve scopes fresh each time
544
- const api = useAssistantApi();
544
+ const aui = useAui();
545
545
 
546
546
  useEffect(() => {
547
547
  // Always gets the current thread
548
- api.thread().cancelRun();
549
- }, [api]);
548
+ aui.thread().cancelRun();
549
+ }, [aui]);
550
550
  ```
551
551
 
552
552
  ## Quick Reference
553
553
 
554
554
  ```tsx
555
555
  // Read state
556
- const value = useAssistantState(({ scope }) => scope.property);
556
+ const value = useAuiState(({ scope }) => scope.property);
557
557
 
558
558
  // Perform action
559
- const api = useAssistantApi();
559
+ const aui = useAui();
560
560
  api.scope().action();
561
561
 
562
562
  // Listen to events
563
- useAssistantEvent("source.event", (e) => {});
563
+ useAuiEvent("source.event", (e) => {});
564
564
 
565
565
  // Check scope availability
566
566
  if (api.scope.source) {
@@ -571,5 +571,5 @@ if (api.scope.source) {
571
571
  const state = api.scope().getState();
572
572
 
573
573
  // Navigate scopes
574
- api.thread().message({ id: "..." }).getState();
574
+ aui.thread().message({ id: "..." }).getState();
575
575
  ```