@assistant-ui/mcp-docs-server 0.1.25 → 0.1.27
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.
- package/.docs/organized/code-examples/waterfall.md +4 -4
- package/.docs/organized/code-examples/with-a2a.md +5 -5
- package/.docs/organized/code-examples/with-ag-ui.md +6 -6
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +7 -7
- package/.docs/organized/code-examples/with-artifacts.md +7 -7
- package/.docs/organized/code-examples/with-assistant-transport.md +5 -5
- package/.docs/organized/code-examples/with-chain-of-thought.md +7 -7
- package/.docs/organized/code-examples/with-cloud-standalone.md +8 -8
- package/.docs/organized/code-examples/with-cloud.md +7 -7
- package/.docs/organized/code-examples/with-custom-thread-list.md +7 -7
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +511 -0
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +10 -10
- package/.docs/organized/code-examples/with-expo.md +18 -18
- package/.docs/organized/code-examples/with-external-store.md +5 -5
- package/.docs/organized/code-examples/with-ffmpeg.md +220 -66
- package/.docs/organized/code-examples/with-google-adk.md +6 -6
- package/.docs/organized/code-examples/with-heat-graph.md +4 -4
- package/.docs/organized/code-examples/with-interactables.md +836 -0
- package/.docs/organized/code-examples/with-langgraph.md +6 -6
- package/.docs/organized/code-examples/with-livekit.md +591 -0
- package/.docs/organized/code-examples/with-parent-id-grouping.md +6 -6
- package/.docs/organized/code-examples/with-react-hook-form.md +8 -8
- package/.docs/organized/code-examples/with-react-ink.md +3 -3
- package/.docs/organized/code-examples/with-react-router.md +11 -11
- package/.docs/organized/code-examples/with-store.md +11 -6
- package/.docs/organized/code-examples/with-tanstack.md +8 -8
- package/.docs/organized/code-examples/with-tap-runtime.md +8 -8
- package/.docs/raw/blog/2026-03-launch-week/index.mdx +31 -0
- package/.docs/raw/docs/(docs)/cli.mdx +60 -0
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +9 -1
- package/.docs/raw/docs/(docs)/guides/attachments.mdx +65 -4
- package/.docs/raw/docs/(docs)/guides/interactables.mdx +354 -0
- package/.docs/raw/docs/(docs)/guides/message-timing.mdx +3 -3
- package/.docs/raw/docs/(docs)/guides/multi-agent.mdx +1 -0
- package/.docs/raw/docs/(docs)/guides/tool-ui.mdx +29 -0
- package/.docs/raw/docs/(docs)/guides/voice.mdx +333 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +128 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +23 -0
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +6 -0
- package/.docs/raw/docs/cloud/ai-sdk.mdx +81 -1
- package/.docs/raw/docs/ink/primitives.mdx +141 -0
- package/.docs/raw/docs/primitives/action-bar.mdx +351 -0
- package/.docs/raw/docs/primitives/assistant-modal.mdx +215 -0
- package/.docs/raw/docs/primitives/attachment.mdx +216 -0
- package/.docs/raw/docs/primitives/branch-picker.mdx +221 -0
- package/.docs/raw/docs/primitives/chain-of-thought.mdx +311 -0
- package/.docs/raw/docs/primitives/composer.mdx +526 -0
- package/.docs/raw/docs/primitives/error.mdx +141 -0
- package/.docs/raw/docs/primitives/index.mdx +98 -0
- package/.docs/raw/docs/primitives/message.mdx +524 -0
- package/.docs/raw/docs/primitives/selection-toolbar.mdx +165 -0
- package/.docs/raw/docs/primitives/suggestion.mdx +242 -0
- package/.docs/raw/docs/primitives/thread-list.mdx +404 -0
- package/.docs/raw/docs/primitives/thread.mdx +482 -0
- package/.docs/raw/docs/runtimes/a2a/index.mdx +4 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +2 -2
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +6 -2
- package/.docs/raw/docs/ui/context-display.mdx +2 -2
- package/.docs/raw/docs/ui/mention.mdx +168 -0
- package/.docs/raw/docs/ui/model-selector.mdx +1 -1
- package/.docs/raw/docs/ui/voice.mdx +172 -0
- package/package.json +3 -4
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Interactables
|
|
3
|
+
description: Persistent UI whose state can be read and updated by the AI assistant.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { InteractableSample } from "@/components/docs/samples/interactable";
|
|
7
|
+
|
|
8
|
+
Interactables are React components that live outside the chat message flow and have state that both the user and the AI can read and write. This enables AI-driven UI patterns where the assistant controls parts of your application beyond the chat window.
|
|
9
|
+
|
|
10
|
+
<InteractableSample />
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Unlike regular tool UIs that appear inline within messages, interactables:
|
|
15
|
+
|
|
16
|
+
- **Persist across messages** — they live outside the chat thread
|
|
17
|
+
- **Have shared state** — both the user (via React) and the AI (via auto-generated tools) can update them
|
|
18
|
+
- **Support partial updates** — the AI only needs to send the fields it wants to change
|
|
19
|
+
- **Are developer-placed** — you decide where they render in your app
|
|
20
|
+
- **Auto-register tools** — the AI automatically gets a tool to update each interactable's state
|
|
21
|
+
|
|
22
|
+
Common use cases:
|
|
23
|
+
|
|
24
|
+
- Task boards that the AI can add items to
|
|
25
|
+
- Data dashboards that update based on conversation
|
|
26
|
+
- Forms that the AI pre-fills
|
|
27
|
+
- Canvas/editor components that the AI can manipulate
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
### 1. Register the Interactables scope
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { useAui, Interactables, AssistantRuntimeProvider } from "@assistant-ui/react";
|
|
35
|
+
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
36
|
+
|
|
37
|
+
function MyRuntimeProvider({ children }: { children: React.ReactNode }) {
|
|
38
|
+
const runtime = useChatRuntime();
|
|
39
|
+
|
|
40
|
+
const aui = useAui({
|
|
41
|
+
interactables: Interactables(),
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<AssistantRuntimeProvider aui={aui} runtime={runtime}>
|
|
46
|
+
{children}
|
|
47
|
+
</AssistantRuntimeProvider>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. Create an interactable
|
|
53
|
+
|
|
54
|
+
<Callout type="warn">
|
|
55
|
+
Define the `stateSchema` and `initialState` **outside** the component (or
|
|
56
|
+
memoize them). Creating a new schema on every render will cause the
|
|
57
|
+
interactable to re-register and reset its state.
|
|
58
|
+
</Callout>
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
import { useAssistantInteractable, useInteractableState } from "@assistant-ui/react";
|
|
62
|
+
import { z } from "zod";
|
|
63
|
+
|
|
64
|
+
const taskBoardSchema = z.object({
|
|
65
|
+
tasks: z.array(
|
|
66
|
+
z.object({
|
|
67
|
+
id: z.string(),
|
|
68
|
+
title: z.string(),
|
|
69
|
+
done: z.boolean(),
|
|
70
|
+
}),
|
|
71
|
+
),
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const taskBoardInitialState = { tasks: [] };
|
|
75
|
+
|
|
76
|
+
function TaskBoard() {
|
|
77
|
+
const id = useAssistantInteractable("taskBoard", {
|
|
78
|
+
description: "A task board showing the user's tasks",
|
|
79
|
+
stateSchema: taskBoardSchema,
|
|
80
|
+
initialState: taskBoardInitialState,
|
|
81
|
+
});
|
|
82
|
+
const [state, { setState }] = useInteractableState(id, taskBoardInitialState);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div>
|
|
86
|
+
<h2>Tasks</h2>
|
|
87
|
+
<ul>
|
|
88
|
+
{state.tasks.map((task) => (
|
|
89
|
+
<li key={task.id}>
|
|
90
|
+
<label>
|
|
91
|
+
<input
|
|
92
|
+
type="checkbox"
|
|
93
|
+
checked={task.done}
|
|
94
|
+
onChange={() =>
|
|
95
|
+
setState((prev) => ({
|
|
96
|
+
tasks: prev.tasks.map((t) =>
|
|
97
|
+
t.id === task.id ? { ...t, done: !t.done } : t,
|
|
98
|
+
),
|
|
99
|
+
}))
|
|
100
|
+
}
|
|
101
|
+
/>
|
|
102
|
+
{task.title}
|
|
103
|
+
</label>
|
|
104
|
+
</li>
|
|
105
|
+
))}
|
|
106
|
+
</ul>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### 3. Place it in your layout
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
function App() {
|
|
116
|
+
return (
|
|
117
|
+
<MyRuntimeProvider>
|
|
118
|
+
<div className="flex">
|
|
119
|
+
<Thread className="flex-1" />
|
|
120
|
+
<TaskBoard /> {/* Lives outside the chat */}
|
|
121
|
+
</div>
|
|
122
|
+
</MyRuntimeProvider>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Now when the user says _"Add a task called 'Buy groceries'"_, the AI will automatically call the `update_taskBoard` tool to update the state. Thanks to partial updates, the AI only needs to send the fields it wants to change.
|
|
128
|
+
|
|
129
|
+
## Partial Updates
|
|
130
|
+
|
|
131
|
+
Auto-generated tools use a partial schema — all fields become optional. The AI only sends the fields it wants to change; omitted fields keep their current values.
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
// If the state is { title: "My Note", content: "Hello", color: "yellow" }
|
|
135
|
+
// The AI can call: update_note({ color: "blue" })
|
|
136
|
+
// Result: { title: "My Note", content: "Hello", color: "blue" }
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
This is especially useful for large state objects where regenerating the entire state would be expensive and error-prone.
|
|
140
|
+
|
|
141
|
+
<Callout type="info">
|
|
142
|
+
Merge is shallow (one level deep). If the AI sends a nested object, it replaces
|
|
143
|
+
that entire field rather than deep-merging into it.
|
|
144
|
+
</Callout>
|
|
145
|
+
|
|
146
|
+
## Multiple Instances
|
|
147
|
+
|
|
148
|
+
You can render multiple interactables with the same `name` but different `id`s. Each gets its own update tool:
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
import { useAssistantInteractable, useInteractableState } from "@assistant-ui/react";
|
|
152
|
+
import { z } from "zod";
|
|
153
|
+
|
|
154
|
+
const noteSchema = z.object({
|
|
155
|
+
title: z.string(),
|
|
156
|
+
content: z.string(),
|
|
157
|
+
color: z.enum(["yellow", "blue", "green", "pink"]),
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const noteInitialState = { title: "New Note", content: "", color: "yellow" as const };
|
|
161
|
+
|
|
162
|
+
function NoteCard({ noteId }: { noteId: string }) {
|
|
163
|
+
useAssistantInteractable("note", {
|
|
164
|
+
id: noteId,
|
|
165
|
+
description: "A sticky note",
|
|
166
|
+
stateSchema: noteSchema,
|
|
167
|
+
initialState: noteInitialState,
|
|
168
|
+
});
|
|
169
|
+
const [state] = useInteractableState(noteId, noteInitialState);
|
|
170
|
+
|
|
171
|
+
return <div>{state.title}</div>;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function App() {
|
|
175
|
+
return (
|
|
176
|
+
<>
|
|
177
|
+
<NoteCard noteId="note-1" /> {/* → update_note_note-1 tool */}
|
|
178
|
+
<NoteCard noteId="note-2" /> {/* → update_note_note-2 tool */}
|
|
179
|
+
</>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
When only one instance of a name exists, the tool is named `update_{name}` (e.g., `update_note`). When multiple instances exist, tools are named `update_{name}_{id}` (e.g., `update_note_note-1`).
|
|
185
|
+
|
|
186
|
+
## Selection
|
|
187
|
+
|
|
188
|
+
When multiple interactables are present, you can mark one as "selected" to tell the AI which one the user is focused on:
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
function NoteCard({ noteId }: { noteId: string }) {
|
|
192
|
+
useAssistantInteractable("note", {
|
|
193
|
+
id: noteId,
|
|
194
|
+
description: "A sticky note",
|
|
195
|
+
stateSchema: noteSchema,
|
|
196
|
+
initialState: noteInitialState,
|
|
197
|
+
});
|
|
198
|
+
const [state, { setSelected }] = useInteractableState(noteId, noteInitialState);
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
<div onClick={() => setSelected(true)}>
|
|
202
|
+
{state.title}
|
|
203
|
+
</div>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
The AI sees `(SELECTED)` in the system prompt for the focused interactable, allowing it to prioritize that one in responses. For example, the user can say _"Change the color to blue"_ and the AI knows which note to update.
|
|
209
|
+
|
|
210
|
+
## API Reference
|
|
211
|
+
|
|
212
|
+
### `useAssistantInteractable`
|
|
213
|
+
|
|
214
|
+
Registers an interactable with the AI assistant. Returns the instance id.
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
const id = useAssistantInteractable(name, config);
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
**Parameters:**
|
|
221
|
+
|
|
222
|
+
| Parameter | Type | Description |
|
|
223
|
+
| --- | --- | --- |
|
|
224
|
+
| `name` | `string` | Name for the interactable (used in tool names) |
|
|
225
|
+
| `config.description` | `string` | Description shown to the AI |
|
|
226
|
+
| `config.stateSchema` | `StandardSchemaV1 \| JSONSchema7` | Schema for the state (e.g., a Zod schema) |
|
|
227
|
+
| `config.initialState` | `unknown` | Initial state value |
|
|
228
|
+
| `config.id` | `string?` | Optional unique instance ID (auto-generated if omitted) |
|
|
229
|
+
| `config.selected` | `boolean?` | Whether this interactable is selected |
|
|
230
|
+
|
|
231
|
+
**Returns:** `string` — the instance id (auto-generated or provided).
|
|
232
|
+
|
|
233
|
+
### `useInteractableState`
|
|
234
|
+
|
|
235
|
+
Reads and writes the state of a registered interactable.
|
|
236
|
+
|
|
237
|
+
```tsx
|
|
238
|
+
const [state, { setState, setSelected, isPending, error, flush }] = useInteractableState<TState>(id, fallback?);
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Parameters:**
|
|
242
|
+
|
|
243
|
+
| Parameter | Type | Description |
|
|
244
|
+
| --- | --- | --- |
|
|
245
|
+
| `id` | `string` | The interactable instance id (from `useAssistantInteractable`) |
|
|
246
|
+
| `fallback` | `TState?` | Fallback value before the interactable is registered |
|
|
247
|
+
|
|
248
|
+
**Returns:** `[state, methods]`
|
|
249
|
+
|
|
250
|
+
| Return | Type | Description |
|
|
251
|
+
| --- | --- | --- |
|
|
252
|
+
| `state` | `TState` | Current state |
|
|
253
|
+
| `setState` | `(updater: TState \| (prev: TState) => TState) => void` | State setter (like `useState`) |
|
|
254
|
+
| `setSelected` | `(selected: boolean) => void` | Mark this interactable as selected |
|
|
255
|
+
| `isPending` | `boolean` | Whether a persistence save is in-flight |
|
|
256
|
+
| `error` | `unknown` | Error from the last failed save |
|
|
257
|
+
| `flush` | `() => Promise<void>` | Force an immediate persistence save |
|
|
258
|
+
|
|
259
|
+
### `Interactables`
|
|
260
|
+
|
|
261
|
+
The scope resource that manages all interactables. Register it via `useAui`:
|
|
262
|
+
|
|
263
|
+
```tsx
|
|
264
|
+
const aui = useAui({
|
|
265
|
+
interactables: Interactables(),
|
|
266
|
+
});
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## How It Works
|
|
270
|
+
|
|
271
|
+
When you call `useAssistantInteractable("taskBoard", config)`:
|
|
272
|
+
|
|
273
|
+
1. **Registration** — the interactable is registered in the `interactables` scope with its name, description, schema, and initial state.
|
|
274
|
+
2. **Tool generation** — an `update_taskBoard` frontend tool is automatically created with a partial schema (all fields optional). For multiple instances, tools are named `update_{name}_{id}`.
|
|
275
|
+
3. **System prompt** — the AI receives a system message describing the interactable, its current state, and whether it is selected.
|
|
276
|
+
4. **Streaming updates** — as the AI generates the tool arguments, the interactable's state updates progressively rather than waiting for complete arguments. This gives users immediate visual feedback.
|
|
277
|
+
5. **Partial merge** — only the fields the AI sends are updated; the rest are preserved.
|
|
278
|
+
6. **Bidirectional updates** — when the AI calls the tool, the state updates and React re-renders. When the user updates state via `setState`, the model context is notified so the AI sees the latest state on the next turn.
|
|
279
|
+
|
|
280
|
+
## Persistence
|
|
281
|
+
|
|
282
|
+
By default, interactable state is in-memory and lost on page refresh. You can add persistence by providing a save callback:
|
|
283
|
+
|
|
284
|
+
```tsx
|
|
285
|
+
import { useEffect } from "react";
|
|
286
|
+
import { useAui, Interactables } from "@assistant-ui/react";
|
|
287
|
+
|
|
288
|
+
function MyRuntimeProvider({ children }) {
|
|
289
|
+
const aui = useAui({ interactables: Interactables() });
|
|
290
|
+
|
|
291
|
+
useEffect(() => {
|
|
292
|
+
// Set up persistence adapter
|
|
293
|
+
aui.interactables().setPersistenceAdapter({
|
|
294
|
+
save: async (state) => {
|
|
295
|
+
localStorage.setItem("interactables", JSON.stringify(state));
|
|
296
|
+
},
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
// Restore saved state on mount
|
|
300
|
+
const saved = localStorage.getItem("interactables");
|
|
301
|
+
if (saved) {
|
|
302
|
+
aui.interactables().importState(JSON.parse(saved));
|
|
303
|
+
}
|
|
304
|
+
}, [aui]);
|
|
305
|
+
|
|
306
|
+
return /* ... */;
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### Sync Status
|
|
311
|
+
|
|
312
|
+
When a persistence adapter is set, `useInteractableState` exposes sync metadata:
|
|
313
|
+
|
|
314
|
+
```tsx
|
|
315
|
+
const [state, { setState, isPending, error, flush }] = useInteractableState(id, fallback);
|
|
316
|
+
|
|
317
|
+
// isPending — true while a save is in-flight
|
|
318
|
+
// error — the error from the last failed save, if any
|
|
319
|
+
// flush() — force an immediate save (useful before navigation)
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
State changes are automatically debounced (500ms) before saving. When a component unregisters, any pending save is flushed immediately.
|
|
323
|
+
|
|
324
|
+
### Export / Import
|
|
325
|
+
|
|
326
|
+
For custom persistence strategies, use `exportState` and `importState` directly:
|
|
327
|
+
|
|
328
|
+
```tsx
|
|
329
|
+
const snapshot = aui.interactables().exportState();
|
|
330
|
+
// => { "note-1": { name: "note", state: { title: "Hello" } }, ... }
|
|
331
|
+
|
|
332
|
+
aui.interactables().importState(snapshot);
|
|
333
|
+
// Imported state is picked up when components next register
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## Combining with Tools
|
|
337
|
+
|
|
338
|
+
You can use `Interactables` alongside `Tools`:
|
|
339
|
+
|
|
340
|
+
```tsx
|
|
341
|
+
const aui = useAui({
|
|
342
|
+
tools: Tools({ toolkit: myToolkit }),
|
|
343
|
+
interactables: Interactables(),
|
|
344
|
+
});
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
## Full Example
|
|
348
|
+
|
|
349
|
+
See the complete [with-interactables example](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-interactables) for a working implementation featuring:
|
|
350
|
+
|
|
351
|
+
- **Task Board** — single-instance interactable with a custom `manage_tasks` tool
|
|
352
|
+
- **Sticky Notes** — multi-instance interactables with selection and partial updates
|
|
353
|
+
- **localStorage persistence** — state survives page refresh via `setPersistenceAdapter`
|
|
354
|
+
- **Sync indicator** — spinning icon while a save is in-flight (`isPending`)
|
|
@@ -58,8 +58,8 @@ const AssistantMessage: FC = () => {
|
|
|
58
58
|
| `streamStartTime` | `number` | Unix timestamp when stream started |
|
|
59
59
|
| `firstTokenTime` | `number?` | Time to first text token (ms) |
|
|
60
60
|
| `totalStreamTime` | `number?` | Total stream duration (ms) |
|
|
61
|
-
| `tokenCount` | `number?` |
|
|
62
|
-
| `tokensPerSecond` | `number?` | Throughput (tokens/sec)
|
|
61
|
+
| `tokenCount` | `number?` | Output token count from message metadata usage |
|
|
62
|
+
| `tokensPerSecond` | `number?` | Throughput (tokens/sec), when token usage is available |
|
|
63
63
|
| `totalChunks` | `number` | Total stream chunks received |
|
|
64
64
|
| `toolCallCount` | `number` | Number of tool calls |
|
|
65
65
|
|
|
@@ -90,7 +90,7 @@ const runtime = useDataStreamRuntime({ api: "/api/chat" });
|
|
|
90
90
|
Timing is tracked automatically on the client side by observing streaming state transitions and content changes. Timing is finalized when each stream completes.
|
|
91
91
|
|
|
92
92
|
<Callout type="warn">
|
|
93
|
-
`tokenCount` and `tokensPerSecond`
|
|
93
|
+
`tokenCount` and `tokensPerSecond` require usage metadata from `finish` or `finish-step` in your AI SDK route. If usage metadata is not emitted, duration and TTFT metrics still work, but token-based metrics are omitted.
|
|
94
94
|
</Callout>
|
|
95
95
|
|
|
96
96
|
```tsx
|
|
@@ -171,3 +171,4 @@ function SubConversation({
|
|
|
171
171
|
|
|
172
172
|
- [Generative UI](/docs/guides/tool-ui) — Creating tool call UIs
|
|
173
173
|
- [MessagePartPrimitive](/docs/api-reference/primitives/message-part) — API reference for message part primitives
|
|
174
|
+
- [Sub-Agent Model Tracking](/docs/cloud/ai-sdk#sub-agent-model-tracking) — Track delegated model usage and costs in the Cloud dashboard
|
|
@@ -748,6 +748,35 @@ useAssistantToolUI({
|
|
|
748
748
|
server.
|
|
749
749
|
</Callout>
|
|
750
750
|
|
|
751
|
+
## Per-Property Streaming Status
|
|
752
|
+
|
|
753
|
+
When rendering a tool UI, you can track which arguments have finished streaming using `useToolArgsStatus`. This must be used inside a tool-call message part context.
|
|
754
|
+
|
|
755
|
+
```tsx
|
|
756
|
+
import { useToolArgsStatus } from "@assistant-ui/react";
|
|
757
|
+
|
|
758
|
+
const WeatherUI = makeAssistantToolUI({
|
|
759
|
+
toolName: "weather",
|
|
760
|
+
render: ({ args }) => {
|
|
761
|
+
const { status, propStatus } = useToolArgsStatus<{
|
|
762
|
+
location: string;
|
|
763
|
+
unit: string;
|
|
764
|
+
}>();
|
|
765
|
+
|
|
766
|
+
return (
|
|
767
|
+
<div>
|
|
768
|
+
<span className={propStatus.location === "streaming" ? "animate-pulse" : ""}>
|
|
769
|
+
{args.location ?? "..."}
|
|
770
|
+
</span>
|
|
771
|
+
{status === "complete" && <WeatherChart data={args} />}
|
|
772
|
+
</div>
|
|
773
|
+
);
|
|
774
|
+
},
|
|
775
|
+
});
|
|
776
|
+
```
|
|
777
|
+
|
|
778
|
+
`propStatus` maps each key to `"streaming"` | `"complete"` once the key appears in the partial JSON. Keys not yet present in the stream are absent from `propStatus`.
|
|
779
|
+
|
|
751
780
|
## Related Guides
|
|
752
781
|
|
|
753
782
|
- [Tools Guide](/docs/guides/tools) - Learn how to create and use tools with AI models
|