@assistant-ui/mcp-docs-server 0.1.38 → 0.2.0
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 +11 -12
- package/.docs/organized/code-examples/with-a2a.md +18 -13
- package/.docs/organized/code-examples/with-ag-ui.md +19 -14
- package/.docs/organized/code-examples/{with-ai-sdk-v6.md → with-ai-sdk-v7.md} +34 -23
- package/.docs/organized/code-examples/with-artifacts.md +473 -141
- package/.docs/organized/code-examples/with-assistant-transport.md +17 -10
- package/.docs/organized/code-examples/with-browser-extension.md +17 -10
- package/.docs/organized/code-examples/with-chain-of-thought.md +21 -14
- package/.docs/organized/code-examples/with-cloud-standalone.md +12 -11
- package/.docs/organized/code-examples/with-cloud.md +20 -15
- package/.docs/organized/code-examples/with-custom-thread-list.md +19 -12
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +22 -15
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +22 -15
- package/.docs/organized/code-examples/with-eve.md +18 -11
- package/.docs/organized/code-examples/with-expo.md +35 -52
- package/.docs/organized/code-examples/with-external-store.md +18 -13
- package/.docs/organized/code-examples/with-ffmpeg.md +20 -15
- package/.docs/organized/code-examples/with-generative-ui.md +22 -17
- package/.docs/organized/code-examples/with-google-adk.md +18 -11
- package/.docs/organized/code-examples/with-heat-graph.md +10 -11
- package/.docs/organized/code-examples/with-image-generation.md +19 -12
- package/.docs/organized/code-examples/with-interactables.md +21 -17
- package/.docs/organized/code-examples/with-langchain.md +19 -12
- package/.docs/organized/code-examples/with-langgraph.md +19 -12
- package/.docs/organized/code-examples/with-livekit.md +23 -16
- package/.docs/organized/code-examples/with-mcp.md +46 -28
- package/.docs/organized/code-examples/with-opencode.md +25 -23
- package/.docs/organized/code-examples/with-pi.md +54 -19
- package/.docs/organized/code-examples/with-react-hook-form.md +21 -16
- package/.docs/organized/code-examples/with-react-ink-web.md +9 -9
- package/.docs/organized/code-examples/with-react-ink.md +4 -4
- package/.docs/organized/code-examples/with-react-router.md +22 -17
- package/.docs/organized/code-examples/with-resumable-stream.md +21 -14
- package/.docs/organized/code-examples/with-store.md +10 -11
- package/.docs/organized/code-examples/with-tanstack.md +19 -13
- package/.docs/organized/code-examples/with-tap-runtime.md +18 -13
- package/.docs/organized/code-examples/with-virtualized-thread.md +19 -14
- package/.docs/raw/docs/(docs)/base-ui.mdx +39 -0
- package/.docs/raw/docs/(docs)/cli.mdx +19 -1
- package/.docs/raw/docs/(docs)/devtools.mdx +7 -2
- package/.docs/raw/docs/(docs)/installation.mdx +15 -1
- package/.docs/raw/docs/(docs)/rtl.mdx +2 -4
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/a2ui.mdx +40 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/actions.mdx +56 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/components.mdx +86 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/index.mdx +22 -1
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/json-generative-ui.mdx +42 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/rendering.mdx +53 -2
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/slack.mdx +81 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/teams.mdx +86 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/tokens.mdx +62 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +19 -420
- package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +4 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +4 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +25 -2
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +37 -0
- package/.docs/raw/docs/(reference)/api-reference/model-context/context.mdx +1 -9
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +1 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +14 -31
- package/.docs/raw/docs/(reference)/api-reference/primitives/composition.mdx +1 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +3 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/selection-toolbar.mdx +2 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/status.mdx +0 -2
- package/.docs/raw/docs/(reference)/api-reference/tools/toolkits.mdx +12 -9
- package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +4 -0
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +7 -1
- package/.docs/raw/docs/cloud/langgraph.mdx +4 -2
- package/.docs/raw/docs/copilots/model-context.mdx +1 -1
- package/.docs/raw/docs/copilots/motivation.mdx +1 -1
- package/.docs/raw/docs/guides/attachments.mdx +3 -3
- package/.docs/raw/docs/guides/branching.mdx +2 -2
- package/.docs/raw/docs/guides/chatgpt-subscription.mdx +108 -0
- package/.docs/raw/docs/guides/context-api.mdx +89 -111
- package/.docs/raw/docs/guides/dictation.mdx +185 -257
- package/.docs/raw/docs/guides/editing.mdx +5 -5
- package/.docs/raw/docs/guides/electron.mdx +369 -0
- package/.docs/raw/docs/guides/index.mdx +20 -0
- package/.docs/raw/docs/guides/mentions.mdx +31 -3
- package/.docs/raw/docs/guides/quoting.mdx +3 -3
- package/.docs/raw/docs/guides/resumable-stream-deployment.mdx +2 -2
- package/.docs/raw/docs/guides/resumable-streams.mdx +12 -1
- package/.docs/raw/docs/guides/speech.mdx +47 -29
- package/.docs/raw/docs/guides/suggestions.mdx +70 -1
- package/.docs/raw/docs/guides/voice.mdx +197 -267
- package/.docs/raw/docs/ink/hooks.mdx +3 -3
- package/.docs/raw/docs/ink/primitives.mdx +49 -8
- package/.docs/raw/docs/integrations/auth/better-auth.mdx +2 -2
- package/.docs/raw/docs/integrations/auth/clerk.mdx +2 -2
- package/.docs/raw/docs/integrations/auth/next-auth.mdx +3 -3
- package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +10 -4
- package/.docs/raw/docs/integrations/frameworks/cloudflare-agents/overview.mdx +3 -3
- package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +1 -1
- package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +3 -3
- package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +1 -1
- package/.docs/raw/docs/integrations/gateways/index.mdx +2 -2
- package/.docs/raw/docs/integrations/observability/helicone.mdx +1 -1
- package/.docs/raw/docs/integrations/observability/langfuse.mdx +1 -1
- package/.docs/raw/docs/integrations/observability/langsmith.mdx +2 -2
- package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +36 -9
- package/.docs/raw/docs/migrations/index.mdx +50 -0
- package/.docs/raw/docs/migrations/toolkit-tools.mdx +4 -2
- package/.docs/raw/docs/migrations/v0-15.mdx +156 -0
- package/.docs/raw/docs/primitives/chain-of-thought.mdx +6 -1
- package/.docs/raw/docs/primitives/composer.mdx +17 -1
- package/.docs/raw/docs/primitives/selection-toolbar.mdx +25 -0
- package/.docs/raw/docs/primitives/thread-list.mdx +2 -2
- package/.docs/raw/docs/react-native/hooks.mdx +3 -3
- package/.docs/raw/docs/react-native/index.mdx +2 -2
- package/.docs/raw/docs/react-native/primitives.mdx +62 -5
- package/.docs/raw/docs/runtimes/ag-ui/agent-state.mdx +124 -0
- package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +10 -1
- package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +14 -5
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +15 -15
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +8 -8
- package/.docs/raw/docs/runtimes/ai-sdk/{v6.mdx → v6-legacy.mdx} +11 -9
- package/.docs/raw/docs/runtimes/ai-sdk/v7.mdx +717 -0
- package/.docs/raw/docs/runtimes/concepts/adapters.mdx +1 -1
- package/.docs/raw/docs/runtimes/concepts/architecture.mdx +1 -1
- package/.docs/raw/docs/runtimes/concepts/threads.mdx +10 -10
- package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +2 -2
- package/.docs/raw/docs/runtimes/custom/data-stream.mdx +10 -19
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +2 -2
- package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +5 -3
- package/.docs/raw/docs/runtimes/eve/overview.mdx +1 -1
- package/.docs/raw/docs/runtimes/langchain.mdx +2 -2
- package/.docs/raw/docs/runtimes/langgraph/agent-state.mdx +181 -0
- package/.docs/raw/docs/runtimes/langgraph/overview.mdx +1 -1
- package/.docs/raw/docs/runtimes/opencode/hooks.mdx +3 -1
- package/.docs/raw/docs/tools/a2ui.mdx +107 -0
- package/.docs/raw/docs/tools/backend.mdx +6 -3
- package/.docs/raw/docs/tools/defining-tools.mdx +7 -1
- package/.docs/raw/docs/tools/generative-ui.mdx +60 -2
- package/.docs/raw/docs/tools/interactables-legacy.mdx +4 -4
- package/.docs/raw/docs/tools/interactables.mdx +3 -3
- package/.docs/raw/docs/tools/mcp-apps.mdx +90 -13
- package/.docs/raw/docs/tools/mcp.mdx +100 -3
- package/.docs/raw/docs/tools/tool-ui.mdx +6 -4
- package/.docs/raw/docs/tools/user-managed-mcp.mdx +77 -9
- package/.docs/raw/docs/ui/accordion.mdx +16 -10
- package/.docs/raw/docs/ui/assistant-modal.mdx +8 -4
- package/.docs/raw/docs/ui/attachment.mdx +5 -1
- package/.docs/raw/docs/ui/badge.mdx +23 -12
- package/.docs/raw/docs/ui/follow-up-suggestions.mdx +4 -2
- package/.docs/raw/docs/ui/model-selector.mdx +33 -3
- package/.docs/raw/docs/ui/part-grouping.mdx +0 -4
- package/.docs/raw/docs/ui/reasoning.mdx +1 -1
- package/.docs/raw/docs/ui/select.mdx +22 -14
- package/.docs/raw/docs/ui/sources.mdx +1 -1
- package/.docs/raw/docs/ui/tabs.mdx +25 -14
- package/.docs/raw/docs/utilities/heat-graph.mdx +2 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +41 -2
- package/dist/index.js.map +1 -1
- package/dist/prepare-docs/code-examples.d.ts.map +1 -1
- package/dist/prepare-docs/code-examples.js.map +1 -1
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -1
- package/dist/prepare-docs/prepare.d.ts +1 -1
- package/dist/prompts/xulux-playground.d.ts +12 -0
- package/dist/prompts/xulux-playground.d.ts.map +1 -0
- package/dist/prompts/xulux-playground.js +33 -0
- package/dist/prompts/xulux-playground.js.map +1 -0
- package/dist/stdio.d.ts +1 -1
- package/dist/tools/docs.d.ts +8 -14
- package/dist/tools/docs.d.ts.map +1 -1
- package/dist/tools/docs.js +26 -10
- package/dist/tools/docs.js.map +1 -1
- package/dist/tools/examples.d.ts +6 -12
- package/dist/tools/examples.d.ts.map +1 -1
- package/dist/tools/examples.js +11 -8
- package/dist/tools/examples.js.map +1 -1
- package/dist/tools/resources.d.ts +1 -2
- package/dist/tools/resources.d.ts.map +1 -1
- package/dist/tools/resources.js +1 -1
- package/dist/tools/resources.js.map +1 -1
- package/dist/tools/search.d.ts +6 -15
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +2 -2
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/tests/mcp-test-client.d.ts +15 -0
- package/dist/tools/tests/mcp-test-client.d.ts.map +1 -0
- package/dist/tools/tests/mcp-test-client.js +68 -0
- package/dist/tools/tests/mcp-test-client.js.map +1 -0
- package/dist/tools/tests/test-setup.d.ts.map +1 -1
- package/dist/tools/tests/test-setup.js +5 -1
- package/dist/tools/tests/test-setup.js.map +1 -1
- package/dist/tools/xulux-templates.d.ts +58 -0
- package/dist/tools/xulux-templates.d.ts.map +1 -0
- package/dist/tools/xulux-templates.js +82 -0
- package/dist/tools/xulux-templates.js.map +1 -0
- package/dist/utils/cache.d.ts +5 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +18 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/mcp-format.d.ts +1 -0
- package/dist/utils/mcp-format.d.ts.map +1 -1
- package/dist/utils/mcp-format.js +7 -4
- package/dist/utils/mcp-format.js.map +1 -1
- package/dist/utils/mdx.d.ts.map +1 -1
- package/dist/utils/paths.d.ts +1 -1
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +3 -1
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/search.d.ts.map +1 -1
- package/dist/utils/security.d.ts.map +1 -1
- package/dist/utils/security.js.map +1 -1
- package/dist/xulux/catalog-client.d.ts +14 -0
- package/dist/xulux/catalog-client.d.ts.map +1 -0
- package/dist/xulux/catalog-client.js +67 -0
- package/dist/xulux/catalog-client.js.map +1 -0
- package/dist/xulux/fallback-catalog.d.ts +7 -0
- package/dist/xulux/fallback-catalog.d.ts.map +1 -0
- package/dist/xulux/fallback-catalog.js +47 -0
- package/dist/xulux/fallback-catalog.js.map +1 -0
- package/dist/xulux/fetch-sandbox.d.ts +5 -0
- package/dist/xulux/fetch-sandbox.d.ts.map +1 -0
- package/dist/xulux/fetch-sandbox.js +40 -0
- package/dist/xulux/fetch-sandbox.js.map +1 -0
- package/dist/xulux/template-service.d.ts +84 -0
- package/dist/xulux/template-service.d.ts.map +1 -0
- package/dist/xulux/template-service.js +223 -0
- package/dist/xulux/template-service.js.map +1 -0
- package/dist/xulux/types.d.ts +55 -0
- package/dist/xulux/types.d.ts.map +1 -0
- package/dist/xulux/types.js +6 -0
- package/dist/xulux/types.js.map +1 -0
- package/package.json +7 -6
- package/src/index.ts +55 -2
- package/src/prompts/xulux-playground.ts +36 -0
- package/src/tools/docs.ts +27 -5
- package/src/tools/examples.ts +17 -12
- package/src/tools/resources.ts +1 -4
- package/src/tools/search.ts +2 -2
- package/src/tools/tests/completions.test.ts +40 -26
- package/src/tools/tests/docs.test.ts +20 -0
- package/src/tools/tests/examples.test.ts +5 -5
- package/src/tools/tests/integration.test.ts +3 -4
- package/src/tools/tests/listings-cache.test.ts +19 -0
- package/src/tools/tests/mcp-protocol.test.ts +173 -108
- package/src/tools/tests/mcp-test-client.ts +111 -0
- package/src/tools/tests/resources.test.ts +97 -66
- package/src/tools/tests/test-setup.ts +8 -0
- package/src/tools/tests/xulux-templates.test.ts +262 -0
- package/src/tools/xulux-templates.ts +141 -0
- package/src/utils/cache.ts +20 -0
- package/src/utils/mcp-format.ts +8 -6
- package/src/utils/paths.ts +4 -1
- package/src/utils/tests/cache.test.ts +51 -0
- package/src/utils/tests/mcp-format.test.ts +22 -0
- package/src/utils/tests/security.test.ts +1 -1
- package/src/xulux/catalog-client.ts +105 -0
- package/src/xulux/fallback-catalog.ts +63 -0
- package/src/xulux/fetch-sandbox.ts +56 -0
- package/src/xulux/template-service.ts +406 -0
- package/src/xulux/types.ts +60 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +0 -464
|
@@ -122,7 +122,7 @@ const content = useAuiState((s) => s.message.content);
|
|
|
122
122
|
|
|
123
123
|
### useAui
|
|
124
124
|
|
|
125
|
-
Access the API instance for imperative operations and actions. Unlike `useAuiState`, this hook
|
|
125
|
+
Access the API instance for imperative operations and actions. Unlike `useAuiState`, this hook does not subscribe to state updates: the client's identity only changes on structural changes (a scope resolving to a different instance), making it well suited for event handlers and imperative operations.
|
|
126
126
|
|
|
127
127
|
```tsx
|
|
128
128
|
import { useAui } from "@assistant-ui/react";
|
|
@@ -132,20 +132,20 @@ function CustomMessageActions() {
|
|
|
132
132
|
|
|
133
133
|
// Perform actions in event handlers
|
|
134
134
|
const handleSend = () => {
|
|
135
|
-
aui.composer
|
|
135
|
+
aui.composer.send();
|
|
136
136
|
};
|
|
137
137
|
|
|
138
138
|
const handleReload = () => {
|
|
139
|
-
aui.message
|
|
139
|
+
aui.message.reload();
|
|
140
140
|
};
|
|
141
141
|
|
|
142
142
|
// Read state imperatively when needed
|
|
143
143
|
const handleConditionalAction = () => {
|
|
144
|
-
const { isRunning } = aui.thread
|
|
145
|
-
const { text } = aui.composer
|
|
144
|
+
const { isRunning } = aui.thread.getState();
|
|
145
|
+
const { text } = aui.composer.getState();
|
|
146
146
|
|
|
147
147
|
if (!isRunning && text.length > 0) {
|
|
148
|
-
aui.composer
|
|
148
|
+
aui.composer.send();
|
|
149
149
|
}
|
|
150
150
|
};
|
|
151
151
|
|
|
@@ -159,7 +159,7 @@ function CustomMessageActions() {
|
|
|
159
159
|
}
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
-
The API object
|
|
162
|
+
The API object doesn't cause re-renders on state updates. Use it for:
|
|
163
163
|
|
|
164
164
|
- **Triggering actions** in event handlers and callbacks
|
|
165
165
|
- **Reading current state** imperatively when you don't need subscriptions
|
|
@@ -170,80 +170,80 @@ The API object is stable and doesn't cause re-renders. Use it for:
|
|
|
170
170
|
|
|
171
171
|
```tsx
|
|
172
172
|
// Thread actions
|
|
173
|
-
aui.thread
|
|
174
|
-
aui.thread
|
|
175
|
-
aui.thread
|
|
176
|
-
aui.thread
|
|
177
|
-
aui.thread
|
|
178
|
-
aui.thread
|
|
179
|
-
aui.thread
|
|
180
|
-
aui.thread
|
|
173
|
+
aui.thread.append(message);
|
|
174
|
+
aui.thread.startRun(config);
|
|
175
|
+
aui.thread.resumeRun(config);
|
|
176
|
+
aui.thread.cancelRun();
|
|
177
|
+
aui.thread.getState();
|
|
178
|
+
aui.thread.message({ index: idx });
|
|
179
|
+
aui.thread.message({ id: messageId });
|
|
180
|
+
aui.thread.composer();
|
|
181
181
|
|
|
182
182
|
// Message actions
|
|
183
|
-
aui.message
|
|
184
|
-
aui.message
|
|
185
|
-
aui.message
|
|
186
|
-
aui.message
|
|
187
|
-
aui.message
|
|
188
|
-
aui.message
|
|
189
|
-
aui.message
|
|
190
|
-
aui.message
|
|
191
|
-
aui.message
|
|
183
|
+
aui.message.reload();
|
|
184
|
+
aui.message.speak();
|
|
185
|
+
aui.message.stopSpeaking();
|
|
186
|
+
aui.message.submitFeedback({ type: "positive" | "negative" });
|
|
187
|
+
aui.message.switchToBranch({ position, branchId });
|
|
188
|
+
aui.message.getState();
|
|
189
|
+
aui.message.part({ index: idx });
|
|
190
|
+
aui.message.part({ toolCallId });
|
|
191
|
+
aui.message.composer();
|
|
192
192
|
|
|
193
193
|
// Part actions
|
|
194
|
-
aui.part
|
|
195
|
-
aui.part
|
|
196
|
-
aui.part
|
|
194
|
+
aui.part.addToolResult(result);
|
|
195
|
+
aui.part.resumeToolCall(result);
|
|
196
|
+
aui.part.getState();
|
|
197
197
|
|
|
198
198
|
// Composer actions
|
|
199
|
-
aui.composer
|
|
200
|
-
aui.composer
|
|
201
|
-
aui.composer
|
|
202
|
-
aui.composer
|
|
203
|
-
aui.composer
|
|
204
|
-
await aui.composer
|
|
205
|
-
await aui.composer
|
|
206
|
-
aui.composer
|
|
199
|
+
aui.composer.send();
|
|
200
|
+
aui.composer.setText(text);
|
|
201
|
+
aui.composer.setRole(role);
|
|
202
|
+
aui.composer.addAttachment(file); // File object
|
|
203
|
+
aui.composer.addAttachment({ name, content }); // external source
|
|
204
|
+
await aui.composer.clearAttachments();
|
|
205
|
+
await aui.composer.reset();
|
|
206
|
+
aui.composer.getState();
|
|
207
207
|
|
|
208
208
|
// Attachment actions
|
|
209
|
-
aui.attachment
|
|
210
|
-
aui.attachment
|
|
209
|
+
aui.attachment.remove();
|
|
210
|
+
aui.attachment.getState();
|
|
211
211
|
|
|
212
212
|
// ThreadList actions
|
|
213
|
-
aui.threads
|
|
214
|
-
aui.threads
|
|
215
|
-
aui.threads
|
|
216
|
-
await aui.threads
|
|
217
|
-
aui.threads
|
|
213
|
+
aui.threads.switchToNewThread();
|
|
214
|
+
aui.threads.switchToThread(threadId);
|
|
215
|
+
aui.threads.reload();
|
|
216
|
+
await aui.threads.getLoadThreadsPromise();
|
|
217
|
+
aui.threads.getState();
|
|
218
218
|
|
|
219
219
|
// ThreadListItem actions
|
|
220
|
-
aui.threadListItem
|
|
221
|
-
aui.threadListItem
|
|
222
|
-
aui.threadListItem
|
|
223
|
-
aui.threadListItem
|
|
224
|
-
aui.threadListItem
|
|
225
|
-
aui.threadListItem
|
|
226
|
-
aui.threadListItem
|
|
220
|
+
aui.threadListItem.switchTo();
|
|
221
|
+
aui.threadListItem.rename(title);
|
|
222
|
+
aui.threadListItem.updateCustom(custom);
|
|
223
|
+
aui.threadListItem.archive();
|
|
224
|
+
aui.threadListItem.unarchive();
|
|
225
|
+
aui.threadListItem.delete();
|
|
226
|
+
aui.threadListItem.getState();
|
|
227
227
|
|
|
228
228
|
// Suggestions actions
|
|
229
|
-
aui.suggestions
|
|
230
|
-
aui.suggestions
|
|
229
|
+
aui.suggestions.getState();
|
|
230
|
+
aui.suggestions.suggestion({ index: 0 });
|
|
231
231
|
|
|
232
232
|
// Suggestion actions
|
|
233
|
-
aui.suggestion
|
|
233
|
+
aui.suggestion.getState();
|
|
234
234
|
|
|
235
235
|
// ChainOfThought actions
|
|
236
|
-
aui.chainOfThought
|
|
237
|
-
aui.chainOfThought
|
|
238
|
-
aui.chainOfThought
|
|
236
|
+
aui.chainOfThought.getState();
|
|
237
|
+
aui.chainOfThought.setCollapsed(collapsed);
|
|
238
|
+
aui.chainOfThought.part({ index: 0 });
|
|
239
239
|
|
|
240
240
|
// ModelContext actions — see /docs/copilots/model-context for full usage
|
|
241
|
-
aui.modelContext
|
|
242
|
-
aui.modelContext
|
|
241
|
+
aui.modelContext.register(provider);
|
|
242
|
+
aui.modelContext.getState();
|
|
243
243
|
|
|
244
244
|
// Tools actions
|
|
245
|
-
aui.tools
|
|
246
|
-
aui.tools
|
|
245
|
+
aui.tools.setToolUI(toolName, render);
|
|
246
|
+
aui.tools.getState();
|
|
247
247
|
```
|
|
248
248
|
|
|
249
249
|
### useAuiEvent
|
|
@@ -320,7 +320,7 @@ function MessageButton() {
|
|
|
320
320
|
|
|
321
321
|
// Automatically uses the current message scope
|
|
322
322
|
const handleReload = () => {
|
|
323
|
-
aui.message
|
|
323
|
+
aui.message.reload();
|
|
324
324
|
};
|
|
325
325
|
|
|
326
326
|
return <button onClick={handleReload}>Reload</button>;
|
|
@@ -329,16 +329,10 @@ function MessageButton() {
|
|
|
329
329
|
|
|
330
330
|
### Checking Scope Availability
|
|
331
331
|
|
|
332
|
-
|
|
332
|
+
Read scopes that may be unavailable through the optional view — they resolve to `undefined` instead of throwing:
|
|
333
333
|
|
|
334
334
|
```tsx
|
|
335
|
-
const
|
|
336
|
-
|
|
337
|
-
// Check if message scope exists
|
|
338
|
-
if (aui.message.source) {
|
|
339
|
-
// Safe to use message scope
|
|
340
|
-
const { role } = aui.message().getState();
|
|
341
|
-
}
|
|
335
|
+
const role = useAuiState((s) => s.optional.message?.role);
|
|
342
336
|
```
|
|
343
337
|
|
|
344
338
|
### Accessing Nested Scopes
|
|
@@ -349,24 +343,24 @@ Navigate through the scope hierarchy programmatically:
|
|
|
349
343
|
const aui = useAui();
|
|
350
344
|
|
|
351
345
|
// Access specific message by ID or index
|
|
352
|
-
const messageById = aui.thread
|
|
353
|
-
const messageByIndex = aui.thread
|
|
346
|
+
const messageById = aui.thread.message({ id: "msg_123" });
|
|
347
|
+
const messageByIndex = aui.thread.message({ index: 0 });
|
|
354
348
|
|
|
355
349
|
// Access part by index or tool call ID
|
|
356
|
-
const partByIndex = aui.message
|
|
357
|
-
const partByToolCall = aui.message
|
|
350
|
+
const partByIndex = aui.message.part({ index: 0 });
|
|
351
|
+
const partByToolCall = aui.message.part({ toolCallId: "call_123" });
|
|
358
352
|
|
|
359
353
|
// Access attachment by index
|
|
360
|
-
const attachment = aui.composer
|
|
354
|
+
const attachment = aui.composer.attachment({ index: 0 }).getState();
|
|
361
355
|
|
|
362
356
|
// Access thread list item by ID, index, or the "main" selector
|
|
363
|
-
const threadItem = aui.threads
|
|
364
|
-
const threadByIndex = aui.threads
|
|
365
|
-
const archivedThread = aui.threads
|
|
357
|
+
const threadItem = aui.threads.item({ id: "thread_123" });
|
|
358
|
+
const threadByIndex = aui.threads.item({ index: 0 });
|
|
359
|
+
const archivedThread = aui.threads.item({ index: 0, archived: true });
|
|
366
360
|
|
|
367
361
|
// Traverse to the main thread directly
|
|
368
|
-
const mainThread = aui.threads
|
|
369
|
-
const message = aui.threads
|
|
362
|
+
const mainThread = aui.threads.thread("main");
|
|
363
|
+
const message = aui.threads.thread("main").message({ id: "msg_123" });
|
|
370
364
|
```
|
|
371
365
|
|
|
372
366
|
## Common Patterns
|
|
@@ -389,7 +383,7 @@ function CopyButton() {
|
|
|
389
383
|
const aui = useAui();
|
|
390
384
|
|
|
391
385
|
const handleCopy = () => {
|
|
392
|
-
navigator.clipboard.writeText(aui.message
|
|
386
|
+
navigator.clipboard.writeText(aui.message.getCopyText());
|
|
393
387
|
};
|
|
394
388
|
|
|
395
389
|
return <button onClick={handleCopy}>Copy</button>;
|
|
@@ -410,10 +404,10 @@ function SmartComposer() {
|
|
|
410
404
|
<div>
|
|
411
405
|
<textarea
|
|
412
406
|
value={text}
|
|
413
|
-
onChange={(e) => aui.composer
|
|
407
|
+
onChange={(e) => aui.composer.setText(e.target.value)}
|
|
414
408
|
disabled={isRunning}
|
|
415
409
|
/>
|
|
416
|
-
<button onClick={() => aui.composer
|
|
410
|
+
<button onClick={() => aui.composer.send()} disabled={!canSend}>
|
|
417
411
|
Send
|
|
418
412
|
</button>
|
|
419
413
|
</div>
|
|
@@ -439,24 +433,18 @@ function MessageCounter() {
|
|
|
439
433
|
|
|
440
434
|
### Resolution Dynamics
|
|
441
435
|
|
|
442
|
-
|
|
436
|
+
Scopes are resolved during render and bound into the client. State updates never change the client's identity; a structural change (for example, switching threads) produces a new client and re-renders consumers through React:
|
|
443
437
|
|
|
444
438
|
```tsx
|
|
445
439
|
const aui = useAui();
|
|
446
440
|
|
|
447
|
-
//
|
|
448
|
-
|
|
449
|
-
thread1.append({ role: "user", content: "Hello" });
|
|
441
|
+
// Bound to the thread current at this render
|
|
442
|
+
aui.thread.append({ role: "user", content: "Hello" });
|
|
450
443
|
|
|
451
|
-
//
|
|
452
|
-
|
|
453
|
-
// This could be a different thread
|
|
454
|
-
const thread2 = aui.thread();
|
|
455
|
-
thread2.cancelRun(); // Cancels the current thread's run, not necessarily thread1's
|
|
444
|
+
// After a thread switch, the component re-renders with a new client.
|
|
445
|
+
// Accessors read from a previous render keep pointing at the old thread.
|
|
456
446
|
```
|
|
457
447
|
|
|
458
|
-
For most use cases, this behavior is intuitive. In advanced scenarios where you need to track specific instances, store the resolved reference.
|
|
459
|
-
|
|
460
448
|
### Performance Optimization
|
|
461
449
|
|
|
462
450
|
**Selector optimization:**
|
|
@@ -570,16 +558,8 @@ These events fire at the same transition you can observe via state. They are kep
|
|
|
570
558
|
// ❌ This will throw if not inside a message component
|
|
571
559
|
const role = useAuiState((s) => s.message.role);
|
|
572
560
|
|
|
573
|
-
// ✅
|
|
574
|
-
|
|
575
|
-
const aui = useAui();
|
|
576
|
-
|
|
577
|
-
const role = useAuiState((s) =>
|
|
578
|
-
aui.message.source !== undefined ? s.message.role : "none",
|
|
579
|
-
);
|
|
580
|
-
|
|
581
|
-
return <div>Role: {role}</div>;
|
|
582
|
-
}
|
|
561
|
+
// ✅ Read through the optional view — unavailable scopes resolve to undefined
|
|
562
|
+
const role = useAuiState((s) => s.optional.message?.role ?? "none");
|
|
583
563
|
```
|
|
584
564
|
|
|
585
565
|
**"Maximum update depth exceeded" / Infinite re-renders**
|
|
@@ -601,7 +581,7 @@ const content = useAuiState((s) => s.message.content);
|
|
|
601
581
|
```tsx
|
|
602
582
|
// ❌ Storing scope references can lead to stale data
|
|
603
583
|
const aui = useAui();
|
|
604
|
-
const thread = aui.thread
|
|
584
|
+
const thread = aui.thread; // This reference might become stale
|
|
605
585
|
|
|
606
586
|
useEffect(() => {
|
|
607
587
|
// This might reference the wrong thread if user switched
|
|
@@ -613,7 +593,7 @@ const aui = useAui();
|
|
|
613
593
|
|
|
614
594
|
useEffect(() => {
|
|
615
595
|
// Always gets the current thread
|
|
616
|
-
aui.thread
|
|
596
|
+
aui.thread.cancelRun();
|
|
617
597
|
}, [aui]);
|
|
618
598
|
```
|
|
619
599
|
|
|
@@ -625,19 +605,17 @@ const value = useAuiState((s) => s.scope.property);
|
|
|
625
605
|
|
|
626
606
|
// Perform action
|
|
627
607
|
const aui = useAui();
|
|
628
|
-
aui.scope
|
|
608
|
+
aui.scope.action();
|
|
629
609
|
|
|
630
610
|
// Listen to events
|
|
631
611
|
useAuiEvent("source.event", (e) => {});
|
|
632
612
|
|
|
633
|
-
//
|
|
634
|
-
|
|
635
|
-
/* scope exists */
|
|
636
|
-
}
|
|
613
|
+
// Read a scope that may be unavailable
|
|
614
|
+
const maybe = useAuiState((s) => s.optional.scope?.property);
|
|
637
615
|
|
|
638
616
|
// Get state imperatively
|
|
639
|
-
const state = aui.scope
|
|
617
|
+
const state = aui.scope.getState();
|
|
640
618
|
|
|
641
619
|
// Navigate scopes
|
|
642
|
-
aui.thread
|
|
620
|
+
aui.thread.message({ id: "..." }).getState();
|
|
643
621
|
```
|