@assistant-ui/mcp-docs-server 0.1.23 → 0.1.25
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 +5 -3
- package/.docs/organized/code-examples/with-a2a.md +676 -0
- package/.docs/organized/code-examples/with-ag-ui.md +7 -8
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +28 -16
- package/.docs/organized/code-examples/with-artifacts.md +5 -5
- package/.docs/organized/code-examples/with-assistant-transport.md +3 -3
- package/.docs/organized/code-examples/with-chain-of-thought.md +34 -26
- package/.docs/organized/code-examples/with-cloud-standalone.md +10 -8
- package/.docs/organized/code-examples/with-cloud.md +5 -5
- package/.docs/organized/code-examples/with-custom-thread-list.md +7 -7
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +8 -8
- package/.docs/organized/code-examples/with-expo.md +571 -539
- package/.docs/organized/code-examples/with-external-store.md +3 -4
- package/.docs/organized/code-examples/with-ffmpeg.md +5 -5
- package/.docs/organized/code-examples/with-google-adk.md +353 -0
- package/.docs/organized/code-examples/with-heat-graph.md +304 -0
- package/.docs/organized/code-examples/with-langgraph.md +25 -23
- package/.docs/organized/code-examples/with-parent-id-grouping.md +4 -4
- package/.docs/organized/code-examples/with-react-hook-form.md +6 -9
- package/.docs/organized/code-examples/with-react-ink.md +265 -0
- package/.docs/organized/code-examples/with-react-router.md +10 -11
- package/.docs/organized/code-examples/with-store.md +29 -18
- package/.docs/organized/code-examples/with-tanstack.md +7 -7
- package/.docs/organized/code-examples/with-tap-runtime.md +6 -4
- package/.docs/raw/blog/2025-01-31-changelog/index.mdx +1 -1
- package/.docs/raw/blog/2026-03-launch-week/index.mdx +227 -0
- package/.docs/raw/docs/(docs)/architecture.mdx +1 -1
- package/.docs/raw/docs/(docs)/cli.mdx +14 -9
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +8 -3
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +5 -1
- package/.docs/raw/docs/(docs)/copilots/{make-assistant-readable.mdx → make-assistant-visible.mdx} +14 -5
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +11 -11
- package/.docs/raw/docs/(docs)/copilots/motivation.mdx +2 -2
- package/.docs/raw/docs/(docs)/devtools.mdx +3 -2
- package/.docs/raw/docs/(docs)/guides/attachments.mdx +9 -11
- package/.docs/raw/docs/(docs)/guides/branching.mdx +11 -6
- package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +18 -16
- package/.docs/raw/docs/(docs)/guides/context-api.mdx +81 -43
- package/.docs/raw/docs/(docs)/guides/dictation.mdx +5 -5
- package/.docs/raw/docs/(docs)/guides/editing.mdx +16 -7
- package/.docs/raw/docs/(docs)/guides/latex.mdx +3 -0
- package/.docs/raw/docs/(docs)/guides/message-timing.mdx +2 -1
- package/.docs/raw/docs/(docs)/guides/multi-agent.mdx +173 -0
- package/.docs/raw/docs/(docs)/guides/quoting.mdx +55 -206
- package/.docs/raw/docs/(docs)/guides/speech.mdx +1 -4
- package/.docs/raw/docs/(docs)/guides/suggestions.mdx +9 -15
- package/.docs/raw/docs/(docs)/guides/tool-ui.mdx +17 -7
- package/.docs/raw/docs/(docs)/guides/tools.mdx +24 -9
- package/.docs/raw/docs/(docs)/index.mdx +3 -3
- package/.docs/raw/docs/(docs)/installation.mdx +69 -46
- package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +20 -6
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +24 -4
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +20 -19
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +28 -53
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +4 -4
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +7 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +20 -14
- package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +99 -45
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +52 -40
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +343 -23
- package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +4 -6
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +4 -2
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +3 -5
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +169 -22
- package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +14 -4
- package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +15 -26
- package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +39 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +33 -9
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +48 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +36 -7
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +30 -10
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +12 -10
- package/.docs/raw/docs/(reference)/migrations/deprecation-policy.mdx +1 -1
- package/.docs/raw/docs/(reference)/migrations/react-langgraph-v0-7.mdx +9 -4
- package/.docs/raw/docs/(reference)/migrations/v0-11.mdx +7 -5
- package/.docs/raw/docs/(reference)/migrations/v0-12.mdx +9 -7
- package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +159 -0
- package/.docs/raw/docs/(reference)/react-compatibility.mdx +5 -134
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +89 -7
- package/.docs/raw/docs/cloud/ai-sdk.mdx +19 -5
- package/.docs/raw/docs/cloud/langgraph.mdx +13 -3
- package/.docs/raw/docs/ink/adapters.mdx +41 -0
- package/.docs/raw/docs/ink/custom-backend.mdx +203 -0
- package/.docs/raw/docs/ink/hooks.mdx +448 -0
- package/.docs/raw/docs/ink/index.mdx +239 -0
- package/.docs/raw/docs/ink/migration.mdx +140 -0
- package/.docs/raw/docs/ink/primitives.mdx +699 -0
- package/.docs/raw/docs/react-native/adapters.mdx +63 -87
- package/.docs/raw/docs/react-native/custom-backend.mdx +11 -14
- package/.docs/raw/docs/react-native/hooks.mdx +214 -232
- package/.docs/raw/docs/react-native/index.mdx +118 -159
- package/.docs/raw/docs/react-native/migration.mdx +144 -0
- package/.docs/raw/docs/react-native/primitives.mdx +431 -302
- package/.docs/raw/docs/runtimes/a2a/index.mdx +294 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +9 -9
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +14 -3
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +53 -0
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +59 -25
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +13 -6
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +138 -38
- package/.docs/raw/docs/runtimes/custom/local.mdx +184 -42
- package/.docs/raw/docs/runtimes/data-stream.mdx +92 -19
- package/.docs/raw/docs/runtimes/google-adk/index.mdx +624 -0
- package/.docs/raw/docs/runtimes/helicone.mdx +6 -6
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +38 -27
- package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +1 -1
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +15 -20
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +7 -11
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +8 -11
- package/.docs/raw/docs/runtimes/langserve.mdx +6 -7
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +18 -3
- package/.docs/raw/docs/ui/context-display.mdx +147 -0
- package/.docs/raw/docs/ui/file.mdx +5 -4
- package/.docs/raw/docs/ui/image.mdx +5 -4
- package/.docs/raw/docs/ui/markdown.mdx +3 -1
- package/.docs/raw/docs/ui/model-selector.mdx +8 -8
- package/.docs/raw/docs/ui/part-grouping.mdx +7 -10
- package/.docs/raw/docs/ui/quote.mdx +210 -0
- package/.docs/raw/docs/ui/reasoning.mdx +12 -11
- package/.docs/raw/docs/ui/sources.mdx +88 -17
- package/.docs/raw/docs/ui/streamdown.mdx +16 -7
- package/.docs/raw/docs/ui/thread-list.mdx +11 -13
- package/.docs/raw/docs/ui/thread.mdx +28 -33
- package/.docs/raw/docs/ui/tool-fallback.mdx +5 -6
- package/.docs/raw/docs/ui/tool-group.mdx +9 -8
- package/.docs/raw/docs/utilities/heat-graph.mdx +236 -0
- package/.docs/raw/docs/utilities/tw-shimmer.mdx +211 -0
- package/package.json +4 -4
- package/.docs/raw/docs/(reference)/legacy/styled/assistant-modal.mdx +0 -77
- package/.docs/raw/docs/(reference)/legacy/styled/decomposition.mdx +0 -635
- package/.docs/raw/docs/(reference)/legacy/styled/markdown.mdx +0 -77
- package/.docs/raw/docs/(reference)/legacy/styled/scrollbar.mdx +0 -72
- package/.docs/raw/docs/(reference)/legacy/styled/thread-width.mdx +0 -22
- package/.docs/raw/docs/(reference)/legacy/styled/thread.mdx +0 -77
- /package/.docs/raw/docs/cloud/{overview.mdx → index.mdx} +0 -0
|
@@ -3,286 +3,114 @@ title: Hooks
|
|
|
3
3
|
description: Reactive hooks for accessing runtime state in React Native.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
All hooks support an optional **selector** function for fine-grained re-renders. Without a selector, the component re-renders on every state change. With a selector, it only re-renders when the selected value changes (shallow equality).
|
|
7
|
-
|
|
8
|
-
```tsx
|
|
9
|
-
// Re-renders on every thread state change
|
|
10
|
-
const thread = useThread();
|
|
11
|
-
|
|
12
|
-
// Re-renders only when isRunning changes
|
|
13
|
-
const isRunning = useThread((s) => s.isRunning);
|
|
14
|
-
```
|
|
15
|
-
|
|
16
6
|
## State Hooks
|
|
17
7
|
|
|
18
|
-
###
|
|
8
|
+
### useAuiState
|
|
19
9
|
|
|
20
|
-
|
|
10
|
+
The primary hook for accessing reactive state. It accepts a selector function for fine-grained re-renders — the component only re-renders when the selected value changes (shallow equality).
|
|
21
11
|
|
|
22
12
|
```tsx
|
|
23
|
-
import {
|
|
13
|
+
import { useAuiState } from "@assistant-ui/react-native";
|
|
24
14
|
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
15
|
+
// Thread state
|
|
16
|
+
const messages = useAuiState((s) => s.thread.messages);
|
|
17
|
+
const isRunning = useAuiState((s) => s.thread.isRunning);
|
|
18
|
+
const isEmpty = useAuiState((s) => s.thread.isEmpty);
|
|
28
19
|
|
|
29
|
-
|
|
20
|
+
// Composer state
|
|
21
|
+
const text = useAuiState((s) => s.composer.text);
|
|
22
|
+
const composerIsEmpty = useAuiState((s) => s.composer.isEmpty);
|
|
23
|
+
const attachments = useAuiState((s) => s.composer.attachments);
|
|
30
24
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
| `isRunning` | `boolean` | Whether the model is generating |
|
|
35
|
-
| `isDisabled` | `boolean` | Whether the thread is disabled |
|
|
36
|
-
| `capabilities` | `RuntimeCapabilities` | What actions are supported |
|
|
25
|
+
// Message state (inside a message context)
|
|
26
|
+
const role = useAuiState((s) => s.message.role);
|
|
27
|
+
const isLast = useAuiState((s) => s.message.isLast);
|
|
37
28
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
```tsx
|
|
43
|
-
import { useComposer } from "@assistant-ui/react-native";
|
|
44
|
-
|
|
45
|
-
const text = useComposer((s) => s.text);
|
|
46
|
-
const isEmpty = useComposer((s) => s.isEmpty);
|
|
29
|
+
// Thread list item state
|
|
30
|
+
const threadId = useAuiState((s) => s.threadListItem.id);
|
|
31
|
+
const title = useAuiState((s) => s.threadListItem.title);
|
|
47
32
|
```
|
|
48
33
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
| Field | Type | Description |
|
|
52
|
-
|-------|------|-------------|
|
|
53
|
-
| `text` | `string` | Current input text |
|
|
54
|
-
| `isEmpty` | `boolean` | Whether the input is empty |
|
|
55
|
-
| `attachments` | `Attachment[]` | Current attachments |
|
|
56
|
-
| `canCancel` | `boolean` | Whether a run can be cancelled |
|
|
34
|
+
### useAui
|
|
57
35
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
Access the current message state. Must be used inside a `MessageProvider` or a `renderMessage` / `renderItem` callback.
|
|
36
|
+
Access the store methods for imperative actions.
|
|
61
37
|
|
|
62
38
|
```tsx
|
|
63
|
-
import {
|
|
64
|
-
|
|
65
|
-
const role = useMessage((s) => s.role);
|
|
66
|
-
const isLast = useMessage((s) => s.isLast);
|
|
67
|
-
```
|
|
39
|
+
import { useAui } from "@assistant-ui/react-native";
|
|
68
40
|
|
|
69
|
-
|
|
41
|
+
const aui = useAui();
|
|
70
42
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
| `role` | `MessageRole` | `"user"`, `"assistant"`, or `"system"` |
|
|
75
|
-
| `isLast` | `boolean` | Whether this is the last message |
|
|
76
|
-
| `branchNumber` | `number` | Current branch index |
|
|
77
|
-
| `branchCount` | `number` | Total number of branches |
|
|
43
|
+
// Composer actions
|
|
44
|
+
aui.composer().setText("Hello");
|
|
45
|
+
aui.composer().send();
|
|
78
46
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
Access a specific content part by index within a message.
|
|
82
|
-
|
|
83
|
-
```tsx
|
|
84
|
-
import { useContentPart } from "@assistant-ui/react-native";
|
|
85
|
-
|
|
86
|
-
const part = useContentPart(0); // first content part
|
|
47
|
+
// Thread actions
|
|
48
|
+
aui.thread().cancelRun();
|
|
87
49
|
```
|
|
88
50
|
|
|
89
|
-
###
|
|
51
|
+
### useAuiEvent
|
|
90
52
|
|
|
91
|
-
|
|
53
|
+
Subscribe to events without causing re-renders.
|
|
92
54
|
|
|
93
55
|
```tsx
|
|
94
|
-
import {
|
|
95
|
-
|
|
96
|
-
const { threadIds, mainThreadId, threadItems } = useThreadList();
|
|
56
|
+
import { useAuiEvent } from "@assistant-ui/react-native";
|
|
97
57
|
|
|
98
|
-
|
|
99
|
-
|
|
58
|
+
useAuiEvent("thread.runStart", (payload) => {
|
|
59
|
+
console.log("Run started:", payload);
|
|
60
|
+
});
|
|
100
61
|
```
|
|
101
62
|
|
|
102
|
-
**ThreadListState fields:**
|
|
103
|
-
|
|
104
|
-
| Field | Type | Description |
|
|
105
|
-
|-------|------|-------------|
|
|
106
|
-
| `threadIds` | `string[]` | All thread IDs |
|
|
107
|
-
| `mainThreadId` | `string` | Currently active thread ID |
|
|
108
|
-
| `threadItems` | `Record<string, ThreadListItemState>` | Thread metadata (title, etc.) |
|
|
109
|
-
|
|
110
63
|
## Runtime Hooks
|
|
111
64
|
|
|
112
|
-
### useAssistantRuntime
|
|
113
|
-
|
|
114
|
-
Get the `AssistantRuntime` from context. This is the top-level runtime with access to thread management.
|
|
115
|
-
|
|
116
|
-
```tsx
|
|
117
|
-
import { useAssistantRuntime } from "@assistant-ui/react-native";
|
|
118
|
-
|
|
119
|
-
const runtime = useAssistantRuntime();
|
|
120
|
-
|
|
121
|
-
// Switch threads
|
|
122
|
-
runtime.threads.switchToThread(threadId);
|
|
123
|
-
runtime.threads.switchToNewThread();
|
|
124
|
-
|
|
125
|
-
// Thread management
|
|
126
|
-
runtime.threads.rename(threadId, "New Title");
|
|
127
|
-
runtime.threads.delete(threadId);
|
|
128
|
-
|
|
129
|
-
// Access the current thread runtime
|
|
130
|
-
runtime.thread; // ThreadRuntime
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### useThreadRuntime
|
|
134
|
-
|
|
135
|
-
Get the `ThreadRuntime` for the current thread.
|
|
136
|
-
|
|
137
|
-
```tsx
|
|
138
|
-
import { useThreadRuntime } from "@assistant-ui/react-native";
|
|
139
|
-
|
|
140
|
-
const threadRuntime = useThreadRuntime();
|
|
141
|
-
|
|
142
|
-
threadRuntime.cancelRun();
|
|
143
|
-
threadRuntime.appendMessage(message);
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
### useComposerRuntime
|
|
147
|
-
|
|
148
|
-
Get the `ComposerRuntime` for the current composer.
|
|
149
|
-
|
|
150
|
-
```tsx
|
|
151
|
-
import { useComposerRuntime } from "@assistant-ui/react-native";
|
|
152
|
-
|
|
153
|
-
const composerRuntime = useComposerRuntime();
|
|
154
|
-
|
|
155
|
-
composerRuntime.setText("Hello");
|
|
156
|
-
composerRuntime.send();
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
### useMessageRuntime
|
|
160
|
-
|
|
161
|
-
Get the `MessageRuntime` for the current message.
|
|
162
|
-
|
|
163
|
-
```tsx
|
|
164
|
-
import { useMessageRuntime } from "@assistant-ui/react-native";
|
|
165
|
-
|
|
166
|
-
const messageRuntime = useMessageRuntime();
|
|
167
|
-
|
|
168
|
-
messageRuntime.reload();
|
|
169
|
-
messageRuntime.switchToBranch({ position: "next" });
|
|
170
|
-
```
|
|
171
|
-
|
|
172
65
|
### useLocalRuntime
|
|
173
66
|
|
|
174
|
-
Create an `AssistantRuntime` with a `ChatModelAdapter`.
|
|
67
|
+
Create an `AssistantRuntime` with a `ChatModelAdapter`.
|
|
175
68
|
|
|
176
69
|
```tsx
|
|
177
70
|
import { useLocalRuntime } from "@assistant-ui/react-native";
|
|
178
|
-
import AsyncStorage from "@react-native-async-storage/async-storage";
|
|
179
71
|
|
|
180
72
|
const runtime = useLocalRuntime(chatModel, {
|
|
181
|
-
|
|
182
|
-
titleGenerator: createSimpleTitleAdapter(),
|
|
73
|
+
initialMessages: [],
|
|
183
74
|
});
|
|
184
75
|
```
|
|
185
76
|
|
|
186
77
|
| Option | Type | Description |
|
|
187
78
|
|--------|------|-------------|
|
|
188
79
|
| `initialMessages` | `ThreadMessageLike[]` | Messages to pre-populate |
|
|
189
|
-
| `
|
|
190
|
-
| `
|
|
191
|
-
| `
|
|
192
|
-
|
|
193
|
-
## Primitive Hooks
|
|
194
|
-
|
|
195
|
-
Low-level hooks for building custom components.
|
|
196
|
-
|
|
197
|
-
### useThreadMessages
|
|
198
|
-
|
|
199
|
-
```tsx
|
|
200
|
-
import { useThreadMessages } from "@assistant-ui/react-native";
|
|
201
|
-
|
|
202
|
-
const messages = useThreadMessages(); // ThreadMessage[]
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
### useThreadIsRunning
|
|
206
|
-
|
|
207
|
-
```tsx
|
|
208
|
-
import { useThreadIsRunning } from "@assistant-ui/react-native";
|
|
209
|
-
|
|
210
|
-
const isRunning = useThreadIsRunning(); // boolean
|
|
211
|
-
```
|
|
80
|
+
| `maxSteps` | `number` | Maximum tool call steps per run |
|
|
81
|
+
| `cloud` | `AssistantCloud` | Optional cloud instance for persistence |
|
|
82
|
+
| `adapters` | `object` | Optional adapter overrides (see below) |
|
|
83
|
+
| `unstable_humanToolNames` | `string[]` | Tool names that pause the run for human approval |
|
|
212
84
|
|
|
213
|
-
|
|
85
|
+
The `adapters` option accepts the following fields (all optional):
|
|
214
86
|
|
|
215
|
-
|
|
216
|
-
|
|
87
|
+
| Adapter | Type | Description |
|
|
88
|
+
|---------|------|-------------|
|
|
89
|
+
| `history` | `ThreadHistoryAdapter` | Load and save thread message history |
|
|
90
|
+
| `attachments` | `AttachmentAdapter` | Handle file and attachment uploads |
|
|
91
|
+
| `speech` | `SpeechSynthesisAdapter` | Text-to-speech playback |
|
|
92
|
+
| `dictation` | `DictationAdapter` | Speech-to-text input |
|
|
93
|
+
| `feedback` | `FeedbackAdapter` | Thumbs up/down feedback |
|
|
94
|
+
| `suggestion` | `SuggestionAdapter` | Prompt suggestions |
|
|
217
95
|
|
|
218
|
-
|
|
219
|
-
```
|
|
96
|
+
### useRemoteThreadListRuntime
|
|
220
97
|
|
|
221
|
-
|
|
98
|
+
Create an `AssistantRuntime` with a persistent thread list backed by a `RemoteThreadListAdapter`. This wraps any runtime hook (such as one calling `useLocalRuntime` or a custom AI SDK hook) and layers thread-list management on top.
|
|
222
99
|
|
|
223
100
|
```tsx
|
|
224
|
-
import {
|
|
225
|
-
|
|
226
|
-
const { send, canSend } = useComposerSend();
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
### useComposerCancel
|
|
230
|
-
|
|
231
|
-
```tsx
|
|
232
|
-
import { useComposerCancel } from "@assistant-ui/react-native";
|
|
233
|
-
|
|
234
|
-
const { cancel, canCancel } = useComposerCancel();
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
### useComposerAddAttachment
|
|
238
|
-
|
|
239
|
-
Add an attachment to the composer. Returns `{ addAttachment }` — call it with a `File` or `CreateAttachment` object. Pair with your own file picker (e.g. `expo-image-picker`).
|
|
101
|
+
import { useRemoteThreadListRuntime } from "@assistant-ui/react-native";
|
|
240
102
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
// With expo-image-picker
|
|
247
|
-
const pickImage = async () => {
|
|
248
|
-
const result = await ImagePicker.launchImageLibraryAsync({
|
|
249
|
-
base64: true,
|
|
250
|
-
quality: 0.8,
|
|
251
|
-
});
|
|
252
|
-
if (result.canceled) return;
|
|
253
|
-
|
|
254
|
-
for (const asset of result.assets) {
|
|
255
|
-
await addAttachment({
|
|
256
|
-
name: asset.fileName ?? "image.jpg",
|
|
257
|
-
type: "image",
|
|
258
|
-
content: [
|
|
259
|
-
{ type: "image", image: `data:image/jpeg;base64,${asset.base64}` },
|
|
260
|
-
],
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
};
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
<Callout type="info">
|
|
267
|
-
You must configure an `AttachmentAdapter` (e.g. `SimpleImageAttachmentAdapter`) in your runtime options for attachments to work.
|
|
268
|
-
</Callout>
|
|
269
|
-
|
|
270
|
-
### useMessageReload
|
|
271
|
-
|
|
272
|
-
```tsx
|
|
273
|
-
import { useMessageReload } from "@assistant-ui/react-native";
|
|
274
|
-
|
|
275
|
-
const { reload, canReload } = useMessageReload();
|
|
103
|
+
const runtime = useRemoteThreadListRuntime({
|
|
104
|
+
runtimeHook: () => useLocalRuntime(chatModel),
|
|
105
|
+
adapter: myThreadListAdapter,
|
|
106
|
+
});
|
|
276
107
|
```
|
|
277
108
|
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const { branchNumber, branchCount, goToPrev, goToNext } =
|
|
284
|
-
useMessageBranching();
|
|
285
|
-
```
|
|
109
|
+
| Option | Type | Description |
|
|
110
|
+
|--------|------|-------------|
|
|
111
|
+
| `runtimeHook` | `() => AssistantRuntime` | Hook that returns a per-thread runtime |
|
|
112
|
+
| `adapter` | `RemoteThreadListAdapter` | Backend adapter for listing/creating/archiving threads |
|
|
113
|
+
| `allowNesting` | `boolean` | When `true`, silently becomes a no-op if already inside another `useRemoteThreadListRuntime` |
|
|
286
114
|
|
|
287
115
|
## Model Context Hooks
|
|
288
116
|
|
|
@@ -334,6 +162,23 @@ useAssistantToolUI({
|
|
|
334
162
|
});
|
|
335
163
|
```
|
|
336
164
|
|
|
165
|
+
### useAssistantDataUI
|
|
166
|
+
|
|
167
|
+
Register a UI renderer for a named data message part.
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
import { useAssistantDataUI } from "@assistant-ui/react-native";
|
|
171
|
+
|
|
172
|
+
useAssistantDataUI({
|
|
173
|
+
name: "weather_card",
|
|
174
|
+
render: ({ data }) => (
|
|
175
|
+
<View>
|
|
176
|
+
<Text>{data.city}: {data.temperature}°F</Text>
|
|
177
|
+
</View>
|
|
178
|
+
),
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
337
182
|
### useAssistantInstructions
|
|
338
183
|
|
|
339
184
|
Register system instructions in the model context.
|
|
@@ -344,6 +189,20 @@ import { useAssistantInstructions } from "@assistant-ui/react-native";
|
|
|
344
189
|
useAssistantInstructions("You are a helpful weather assistant.");
|
|
345
190
|
```
|
|
346
191
|
|
|
192
|
+
### useInlineRender
|
|
193
|
+
|
|
194
|
+
Wrap a tool UI component so that inline state updates (from a parent component's render) are reflected without remounting. Use this when the render function closes over props that change over time.
|
|
195
|
+
|
|
196
|
+
```tsx
|
|
197
|
+
import { useInlineRender } from "@assistant-ui/react-native";
|
|
198
|
+
|
|
199
|
+
const stableRender = useInlineRender(({ args, result }) => (
|
|
200
|
+
<Text>{someOuterProp}: {result?.value}</Text>
|
|
201
|
+
));
|
|
202
|
+
|
|
203
|
+
useAssistantToolUI({ toolName: "my_tool", render: stableRender });
|
|
204
|
+
```
|
|
205
|
+
|
|
347
206
|
### makeAssistantTool
|
|
348
207
|
|
|
349
208
|
Create a component that registers a tool when mounted. Useful for declarative tool registration.
|
|
@@ -359,6 +218,129 @@ const WeatherTool = makeAssistantTool({
|
|
|
359
218
|
render: ({ args, result }) => <Text>{args.city}: {result?.temperature}°F</Text>,
|
|
360
219
|
});
|
|
361
220
|
|
|
362
|
-
// Mount inside
|
|
221
|
+
// Mount inside AssistantRuntimeProvider to register
|
|
363
222
|
<WeatherTool />
|
|
364
223
|
```
|
|
224
|
+
|
|
225
|
+
### makeAssistantToolUI
|
|
226
|
+
|
|
227
|
+
Create a component that registers only a tool UI renderer when mounted.
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
import { makeAssistantToolUI } from "@assistant-ui/react-native";
|
|
231
|
+
|
|
232
|
+
const WeatherToolUI = makeAssistantToolUI({
|
|
233
|
+
toolName: "get_weather",
|
|
234
|
+
render: ({ args, result }) => <Text>{args.city}: {result?.temperature}°F</Text>,
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
<WeatherToolUI />
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### makeAssistantDataUI
|
|
241
|
+
|
|
242
|
+
Create a component that registers a data UI renderer when mounted.
|
|
243
|
+
|
|
244
|
+
```tsx
|
|
245
|
+
import { makeAssistantDataUI } from "@assistant-ui/react-native";
|
|
246
|
+
|
|
247
|
+
const WeatherCard = makeAssistantDataUI({
|
|
248
|
+
name: "weather_card",
|
|
249
|
+
render: ({ data }) => <Text>{data.city}: {data.temperature}°F</Text>,
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
<WeatherCard />
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Shared Providers
|
|
256
|
+
|
|
257
|
+
These context providers are re-exported from `@assistant-ui/core/react` and are used internally by the primitives to scope the `aui` store to a particular item (message, part, thread list item, etc.). They are available for advanced custom rendering scenarios.
|
|
258
|
+
|
|
259
|
+
### MessageByIndexProvider
|
|
260
|
+
|
|
261
|
+
Scopes the `aui` context to a specific message by its index in the thread.
|
|
262
|
+
|
|
263
|
+
```tsx
|
|
264
|
+
import { MessageByIndexProvider } from "@assistant-ui/react-native";
|
|
265
|
+
|
|
266
|
+
<MessageByIndexProvider index={2}>
|
|
267
|
+
{/* children can read s.message, s.composer */}
|
|
268
|
+
</MessageByIndexProvider>
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### PartByIndexProvider
|
|
272
|
+
|
|
273
|
+
Scopes the `aui` context to a specific message part by its index.
|
|
274
|
+
|
|
275
|
+
```tsx
|
|
276
|
+
import { PartByIndexProvider } from "@assistant-ui/react-native";
|
|
277
|
+
|
|
278
|
+
<PartByIndexProvider index={0}>
|
|
279
|
+
{/* children can read s.part */}
|
|
280
|
+
</PartByIndexProvider>
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### TextMessagePartProvider
|
|
284
|
+
|
|
285
|
+
Provides a synthetic text part context from a plain string. Useful for rendering text outside the normal message-part pipeline.
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
import { TextMessagePartProvider } from "@assistant-ui/react-native";
|
|
289
|
+
|
|
290
|
+
<TextMessagePartProvider text="Hello world" isRunning={false}>
|
|
291
|
+
{/* children can read s.part as a text part */}
|
|
292
|
+
</TextMessagePartProvider>
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
| Prop | Type | Description |
|
|
296
|
+
|------|------|-------------|
|
|
297
|
+
| `text` | `string` | The text content |
|
|
298
|
+
| `isRunning` | `boolean` | Whether the part is still streaming (default `false`) |
|
|
299
|
+
|
|
300
|
+
### ChainOfThoughtByIndicesProvider
|
|
301
|
+
|
|
302
|
+
Scopes the `aui` context to a slice of message parts that form a chain-of-thought block.
|
|
303
|
+
|
|
304
|
+
```tsx
|
|
305
|
+
import { ChainOfThoughtByIndicesProvider } from "@assistant-ui/react-native";
|
|
306
|
+
|
|
307
|
+
<ChainOfThoughtByIndicesProvider startIndex={1} endIndex={3}>
|
|
308
|
+
{/* children can read s.chainOfThought */}
|
|
309
|
+
</ChainOfThoughtByIndicesProvider>
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### ChainOfThoughtPartByIndexProvider
|
|
313
|
+
|
|
314
|
+
Scopes the `aui` context to a specific part within a chain-of-thought block.
|
|
315
|
+
|
|
316
|
+
```tsx
|
|
317
|
+
import { ChainOfThoughtPartByIndexProvider } from "@assistant-ui/react-native";
|
|
318
|
+
|
|
319
|
+
<ChainOfThoughtPartByIndexProvider index={0}>
|
|
320
|
+
{/* children can read s.part */}
|
|
321
|
+
</ChainOfThoughtPartByIndexProvider>
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### ThreadListItemByIndexProvider
|
|
325
|
+
|
|
326
|
+
Scopes the `aui` context to a specific thread list item by its index.
|
|
327
|
+
|
|
328
|
+
```tsx
|
|
329
|
+
import { ThreadListItemByIndexProvider } from "@assistant-ui/react-native";
|
|
330
|
+
|
|
331
|
+
<ThreadListItemByIndexProvider index={0} archived={false}>
|
|
332
|
+
{/* children can read s.threadListItem */}
|
|
333
|
+
</ThreadListItemByIndexProvider>
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
### SuggestionByIndexProvider
|
|
337
|
+
|
|
338
|
+
Scopes the `aui` context to a specific suggestion by its index.
|
|
339
|
+
|
|
340
|
+
```tsx
|
|
341
|
+
import { SuggestionByIndexProvider } from "@assistant-ui/react-native";
|
|
342
|
+
|
|
343
|
+
<SuggestionByIndexProvider index={0}>
|
|
344
|
+
{/* children can read s.suggestion */}
|
|
345
|
+
</SuggestionByIndexProvider>
|
|
346
|
+
```
|