@assistant-ui/mcp-docs-server 0.1.30 → 0.1.31
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 +1 -1
- package/.docs/organized/code-examples/with-a2a.md +2 -2
- package/.docs/organized/code-examples/with-ag-ui.md +3 -3
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +5 -5
- 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 +79 -50
- package/.docs/organized/code-examples/with-cloud-standalone.md +4 -4
- package/.docs/organized/code-examples/with-cloud.md +4 -4
- package/.docs/organized/code-examples/with-custom-thread-list.md +56 -11
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +7 -7
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +7 -7
- package/.docs/organized/code-examples/with-expo.md +16 -16
- package/.docs/organized/code-examples/with-external-store.md +2 -2
- package/.docs/organized/code-examples/with-ffmpeg.md +5 -5
- package/.docs/organized/code-examples/with-generative-ui.md +5 -5
- package/.docs/organized/code-examples/with-google-adk.md +4 -4
- package/.docs/organized/code-examples/with-heat-graph.md +1 -1
- package/.docs/organized/code-examples/with-interactables.md +5 -5
- package/.docs/organized/code-examples/with-langchain.md +3 -3
- package/.docs/organized/code-examples/with-langgraph.md +3 -3
- package/.docs/organized/code-examples/with-livekit.md +8 -8
- package/.docs/organized/code-examples/with-opencode.md +99 -54
- package/.docs/organized/code-examples/with-parent-id-grouping.md +4 -4
- package/.docs/organized/code-examples/with-react-hook-form.md +5 -5
- package/.docs/organized/code-examples/with-react-ink.md +1 -1
- package/.docs/organized/code-examples/with-react-router.md +8 -8
- package/.docs/organized/code-examples/with-store.md +1 -1
- package/.docs/organized/code-examples/with-tanstack.md +5 -5
- package/.docs/organized/code-examples/with-tap-runtime.md +2 -2
- package/.docs/raw/docs/(docs)/cli.mdx +2 -1
- package/.docs/raw/docs/(docs)/copilots/assistant-frame.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +10 -3
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +8 -3
- package/.docs/raw/docs/(docs)/copilots/make-assistant-visible.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/motivation.mdx +1 -0
- package/.docs/raw/docs/(docs)/copilots/use-assistant-instructions.mdx +1 -0
- package/.docs/raw/docs/(docs)/devtools.mdx +1 -0
- package/.docs/raw/docs/(docs)/index.mdx +1 -0
- package/.docs/raw/docs/(docs)/installation.mdx +1 -0
- package/.docs/raw/docs/(docs)/rtl.mdx +1 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/attachments.mdx +34 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/feedback-speech.mdx +41 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/index.mdx +26 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/persistence.mdx +34 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/runtime.mdx +31 -0
- package/.docs/raw/docs/(reference)/api-reference/context-providers/index.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/index.mdx +26 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +72 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/runtimes.mdx +41 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +48 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +30 -0
- package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +23 -0
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +21 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +7 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +65 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +50 -6
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +15 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +36 -1
- package/.docs/raw/docs/(reference)/api-reference/runtimes/index.mdx +38 -0
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +5 -0
- package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +144 -6
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +230 -2
- package/.docs/raw/docs/cloud/ai-sdk.mdx +221 -3
- package/.docs/raw/docs/cloud/langgraph.mdx +274 -2
- package/.docs/raw/docs/{(docs)/guides → guides}/attachments.mdx +41 -36
- package/.docs/raw/docs/guides/branching.mdx +76 -0
- package/.docs/raw/docs/guides/chain-of-thought.mdx +166 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/context-api.mdx +50 -22
- package/.docs/raw/docs/{(docs)/guides → guides}/dictation.mdx +2 -0
- package/.docs/raw/docs/guides/editing.mdx +102 -0
- package/.docs/raw/docs/guides/index.mdx +103 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/interactables.mdx +49 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/latex.mdx +51 -8
- package/.docs/raw/docs/{(docs)/guides → guides}/mentions.mdx +61 -86
- package/.docs/raw/docs/{(docs)/guides → guides}/message-timing.mdx +8 -2
- package/.docs/raw/docs/{(docs)/guides → guides}/multi-agent.mdx +64 -4
- package/.docs/raw/docs/{(docs)/guides → guides}/quoting.mdx +10 -17
- package/.docs/raw/docs/{(docs)/guides → guides}/slash-commands.mdx +103 -37
- package/.docs/raw/docs/guides/speech.mdx +156 -0
- package/.docs/raw/docs/{(docs)/guides → guides}/suggestions.mdx +21 -83
- package/.docs/raw/docs/{(docs)/guides → guides}/tool-ui.mdx +108 -36
- package/.docs/raw/docs/{(docs)/guides → guides}/tools.mdx +131 -35
- package/.docs/raw/docs/{(docs)/guides → guides}/voice.mdx +39 -0
- package/.docs/raw/docs/ink/index.mdx +1 -3
- package/.docs/raw/docs/ink/migration.mdx +1 -3
- package/.docs/raw/docs/ink/primitives.mdx +37 -1
- package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +520 -0
- package/.docs/raw/docs/integrations/auth/better-auth.mdx +191 -0
- package/.docs/raw/docs/integrations/auth/clerk.mdx +172 -0
- package/.docs/raw/docs/integrations/auth/next-auth.mdx +196 -0
- package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +79 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +188 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +57 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +201 -0
- package/.docs/raw/docs/integrations/gateways/index.mdx +157 -0
- package/.docs/raw/docs/integrations/index.mdx +173 -0
- package/.docs/raw/docs/integrations/observability/helicone.mdx +130 -0
- package/.docs/raw/docs/integrations/observability/langfuse.mdx +156 -0
- package/.docs/raw/docs/integrations/observability/langsmith.mdx +146 -0
- package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +712 -0
- package/.docs/raw/docs/integrations/tools/mcp.mdx +267 -0
- package/.docs/raw/docs/primitives/action-bar.mdx +1 -0
- package/.docs/raw/docs/primitives/assistant-modal.mdx +1 -0
- package/.docs/raw/docs/primitives/attachment.mdx +1 -0
- package/.docs/raw/docs/primitives/branch-picker.mdx +1 -0
- package/.docs/raw/docs/primitives/chain-of-thought.mdx +90 -85
- package/.docs/raw/docs/primitives/composer.mdx +2 -1
- package/.docs/raw/docs/primitives/error.mdx +1 -0
- package/.docs/raw/docs/primitives/index.mdx +2 -1
- package/.docs/raw/docs/primitives/message.mdx +68 -5
- package/.docs/raw/docs/primitives/selection-toolbar.mdx +1 -0
- package/.docs/raw/docs/primitives/suggestion.mdx +1 -0
- package/.docs/raw/docs/primitives/thread-list.mdx +39 -0
- package/.docs/raw/docs/primitives/thread.mdx +16 -13
- package/.docs/raw/docs/react-native/index.mdx +1 -3
- package/.docs/raw/docs/react-native/migration.mdx +1 -3
- package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +396 -0
- package/.docs/raw/docs/runtimes/a2a/overview.mdx +60 -0
- package/.docs/raw/docs/runtimes/a2a/quickstart.mdx +216 -0
- package/.docs/raw/docs/runtimes/ag-ui/overview.mdx +70 -0
- package/.docs/raw/docs/runtimes/ag-ui/quickstart.mdx +243 -0
- package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +123 -0
- package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +52 -0
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +71 -131
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +69 -63
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +330 -123
- package/.docs/raw/docs/runtimes/concepts/adapters.mdx +265 -0
- package/.docs/raw/docs/runtimes/concepts/architecture.mdx +125 -0
- package/.docs/raw/docs/runtimes/concepts/stability.mdx +67 -0
- package/.docs/raw/docs/runtimes/concepts/threads.mdx +428 -0
- package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +703 -0
- package/.docs/raw/docs/runtimes/custom/data-stream.mdx +323 -0
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +253 -1236
- package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +746 -0
- package/.docs/raw/docs/runtimes/custom/overview.mdx +71 -0
- package/.docs/raw/docs/runtimes/google-adk/api.mdx +256 -0
- package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +717 -0
- package/.docs/raw/docs/runtimes/google-adk/overview.mdx +69 -0
- package/.docs/raw/docs/runtimes/google-adk/quickstart.mdx +229 -0
- package/.docs/raw/docs/runtimes/langchain.mdx +533 -0
- package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +305 -0
- package/.docs/raw/docs/runtimes/langgraph/interrupts.mdx +104 -0
- package/.docs/raw/docs/runtimes/langgraph/overview.mdx +84 -0
- package/.docs/raw/docs/runtimes/langgraph/quickstart.mdx +496 -0
- package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +127 -0
- package/.docs/raw/docs/runtimes/langgraph/threads.mdx +113 -0
- package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +3 -3
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +0 -23
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +1 -1
- package/.docs/raw/docs/runtimes/opencode/hooks.mdx +191 -0
- package/.docs/raw/docs/runtimes/opencode/overview.mdx +48 -0
- package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +119 -0
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +71 -203
- package/.docs/raw/docs/ui/accordion.mdx +1 -0
- package/.docs/raw/docs/ui/assistant-modal.mdx +1 -0
- package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -0
- package/.docs/raw/docs/ui/attachment.mdx +1 -0
- package/.docs/raw/docs/ui/badge.mdx +1 -0
- package/.docs/raw/docs/ui/composer-trigger-popover.mdx +1 -0
- package/.docs/raw/docs/ui/context-display.mdx +1 -0
- package/.docs/raw/docs/ui/diff-viewer.mdx +1 -0
- package/.docs/raw/docs/ui/directive-text.mdx +1 -0
- package/.docs/raw/docs/ui/file.mdx +1 -0
- package/.docs/raw/docs/ui/image.mdx +1 -0
- package/.docs/raw/docs/ui/markdown.mdx +2 -14
- package/.docs/raw/docs/ui/mermaid.mdx +1 -0
- package/.docs/raw/docs/ui/message-timing.mdx +3 -2
- package/.docs/raw/docs/ui/model-selector.mdx +1 -0
- package/.docs/raw/docs/ui/part-grouping.mdx +325 -313
- package/.docs/raw/docs/ui/quote.mdx +1 -0
- package/.docs/raw/docs/ui/reasoning.mdx +66 -33
- package/.docs/raw/docs/ui/scrollbar.mdx +1 -0
- package/.docs/raw/docs/ui/select.mdx +1 -0
- package/.docs/raw/docs/ui/sources.mdx +1 -0
- package/.docs/raw/docs/ui/streamdown.mdx +1 -0
- package/.docs/raw/docs/ui/syntax-highlighting.mdx +1 -0
- package/.docs/raw/docs/ui/tabs.mdx +1 -0
- package/.docs/raw/docs/ui/thread-list.mdx +17 -0
- package/.docs/raw/docs/ui/thread.mdx +56 -1
- package/.docs/raw/docs/ui/tool-fallback.mdx +1 -0
- package/.docs/raw/docs/ui/tool-group.mdx +39 -11
- package/.docs/raw/docs/ui/voice.mdx +1 -0
- package/.docs/raw/docs/utilities/heat-graph.mdx +1 -0
- package/.docs/raw/docs/utilities/react-o11y.mdx +278 -0
- package/.docs/raw/docs/utilities/tw-shimmer.mdx +1 -0
- package/package.json +3 -3
- package/src/tools/tests/path-traversal.test.ts +1 -1
- package/.docs/raw/docs/(docs)/guides/branching.mdx +0 -65
- package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +0 -164
- package/.docs/raw/docs/(docs)/guides/editing.mdx +0 -66
- package/.docs/raw/docs/(docs)/guides/speech.mdx +0 -38
- package/.docs/raw/docs/runtimes/a2a/index.mdx +0 -298
- package/.docs/raw/docs/runtimes/assistant-transport.mdx +0 -1033
- package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +0 -314
- package/.docs/raw/docs/runtimes/custom/local.mdx +0 -1464
- package/.docs/raw/docs/runtimes/data-stream.mdx +0 -422
- package/.docs/raw/docs/runtimes/google-adk/index.mdx +0 -686
- package/.docs/raw/docs/runtimes/helicone.mdx +0 -61
- package/.docs/raw/docs/runtimes/langchain/comparison.mdx +0 -60
- package/.docs/raw/docs/runtimes/langchain/index.mdx +0 -210
- package/.docs/raw/docs/runtimes/langgraph/index.mdx +0 -699
- package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +0 -12
- package/.docs/raw/docs/runtimes/langserve.mdx +0 -116
- package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +0 -218
- package/.docs/raw/docs/runtimes/mastra/overview.mdx +0 -18
- package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +0 -217
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: react-o11y
|
|
3
|
+
description: Headless primitives for visualizing observability spans (traces, waterfalls).
|
|
4
|
+
platforms: ["react"]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
<Callout type="warn">
|
|
8
|
+
`@assistant-ui/react-o11y` is currently v0.0.11 and experimental. The API may change without notice.
|
|
9
|
+
</Callout>
|
|
10
|
+
|
|
11
|
+
`@assistant-ui/react-o11y` provides headless, Radix-style primitives for rendering observability spans as collapsible, indented hierarchical UIs. Use it to build trace inspectors, waterfall debug panels, or LLM call timelines on top of your own span data source.
|
|
12
|
+
|
|
13
|
+
- **Headless** — Zero styling opinions, bring your own CSS / Tailwind.
|
|
14
|
+
- **Composable** — Radix-style primitive parts you fully control.
|
|
15
|
+
- **Tree-aware** — Automatic depth, parent / child collapse, time range computation.
|
|
16
|
+
- **Tap-powered** — Built on the same `@assistant-ui/tap` reactive primitives as the runtimes.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
<InstallCommand npm={["@assistant-ui/react-o11y"]} />
|
|
21
|
+
|
|
22
|
+
## Quick start
|
|
23
|
+
|
|
24
|
+
Mount `SpanResource` with your span data, then render primitives that read from the resource's state:
|
|
25
|
+
|
|
26
|
+
```tsx title="components/trace-view.tsx"
|
|
27
|
+
"use client";
|
|
28
|
+
|
|
29
|
+
import {
|
|
30
|
+
SpanPrimitive,
|
|
31
|
+
SpanResource,
|
|
32
|
+
type SpanData,
|
|
33
|
+
} from "@assistant-ui/react-o11y";
|
|
34
|
+
import { useAui, AuiProvider } from "@assistant-ui/store";
|
|
35
|
+
|
|
36
|
+
function SpanRow() {
|
|
37
|
+
return (
|
|
38
|
+
<SpanPrimitive.Root className="flex items-center gap-2 py-1">
|
|
39
|
+
<SpanPrimitive.Indent />
|
|
40
|
+
<SpanPrimitive.CollapseToggle className="size-4 cursor-pointer">
|
|
41
|
+
▸
|
|
42
|
+
</SpanPrimitive.CollapseToggle>
|
|
43
|
+
<SpanPrimitive.StatusIndicator className="size-2 rounded-full data-[span-status=running]:bg-yellow-500 data-[span-status=completed]:bg-green-500 data-[span-status=failed]:bg-red-500" />
|
|
44
|
+
<SpanPrimitive.TypeBadge className="rounded bg-muted px-1.5 text-xs" />
|
|
45
|
+
<SpanPrimitive.Name className="text-sm" />
|
|
46
|
+
<SpanPrimitive.Children components={{ Span: SpanRow }} />
|
|
47
|
+
</SpanPrimitive.Root>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function TraceView({ spans }: { spans: SpanData[] }) {
|
|
52
|
+
const aui = useAui({ resource: SpanResource({ spans }) });
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<AuiProvider value={aui}>
|
|
56
|
+
<SpanPrimitive.Children components={{ Span: SpanRow }} />
|
|
57
|
+
</AuiProvider>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
`SpanData` is the input shape your code produces (see [SpanData](#spandata)). `SpanResource` enriches it with depth, child counts, time range, and collapse state.
|
|
63
|
+
|
|
64
|
+
## Anatomy
|
|
65
|
+
|
|
66
|
+
```tsx
|
|
67
|
+
import {
|
|
68
|
+
SpanPrimitive,
|
|
69
|
+
SpanResource,
|
|
70
|
+
SpanByIndexProvider,
|
|
71
|
+
} from "@assistant-ui/react-o11y";
|
|
72
|
+
|
|
73
|
+
// Top-level: mount SpanResource via useAui
|
|
74
|
+
const aui = useAui({ resource: SpanResource({ spans }) });
|
|
75
|
+
|
|
76
|
+
<AuiProvider value={aui}>
|
|
77
|
+
{/* Render visible spans (flat-list output respecting collapsed state) */}
|
|
78
|
+
<SpanPrimitive.Children components={{ Span: SpanRow }} />
|
|
79
|
+
</AuiProvider>;
|
|
80
|
+
|
|
81
|
+
// Each <SpanRow /> sits inside its own SpanByIndexProvider context and reads via primitives
|
|
82
|
+
function SpanRow() {
|
|
83
|
+
return (
|
|
84
|
+
<SpanPrimitive.Root>
|
|
85
|
+
<SpanPrimitive.Indent />
|
|
86
|
+
<SpanPrimitive.CollapseToggle />
|
|
87
|
+
<SpanPrimitive.StatusIndicator />
|
|
88
|
+
<SpanPrimitive.TypeBadge />
|
|
89
|
+
<SpanPrimitive.Name />
|
|
90
|
+
</SpanPrimitive.Root>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
`SpanPrimitive.Children` produces a flat list of visible spans (collapsed subtrees are excluded). Each rendered child is wrapped in a `SpanByIndexProvider` so its primitives resolve to that specific span's state.
|
|
96
|
+
|
|
97
|
+
## API reference
|
|
98
|
+
|
|
99
|
+
### SpanResource
|
|
100
|
+
|
|
101
|
+
Tap resource that ingests raw span data and exposes a tree-aware reactive state to primitives.
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
SpanResource({ spans }: { spans: SpanData[] }): ClientOutput<"span">;
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Mount through `useAui({ resource: SpanResource({ spans }) })`.
|
|
108
|
+
|
|
109
|
+
The resource computes:
|
|
110
|
+
|
|
111
|
+
- **depth** of each span based on parent chain.
|
|
112
|
+
- **hasChildren** flag.
|
|
113
|
+
- **timeRange** (`min` / `max` across all spans).
|
|
114
|
+
- **collapse state** managed internally; toggles through primitives.
|
|
115
|
+
|
|
116
|
+
### SpanData
|
|
117
|
+
|
|
118
|
+
Input shape you provide to `SpanResource`:
|
|
119
|
+
|
|
120
|
+
| Field | Type | Description |
|
|
121
|
+
| --- | --- | --- |
|
|
122
|
+
| `id` | `string` | Unique span identifier. |
|
|
123
|
+
| `parentSpanId` | `string \| null` | Parent span id, or `null` for root spans. |
|
|
124
|
+
| `name` | `string` | Display name. |
|
|
125
|
+
| `type` | `string` | Span category (e.g. `llm`, `tool`, `http`). Used by `TypeBadge`. |
|
|
126
|
+
| `status` | `"running" \| "completed" \| "failed" \| "skipped"` | Lifecycle state. Used by `StatusIndicator`. |
|
|
127
|
+
| `startedAt` | `number` | Start timestamp (ms). |
|
|
128
|
+
| `endedAt` | `number \| null` | End timestamp (ms), or `null` if still running. |
|
|
129
|
+
| `latencyMs` | `number \| null` | Pre-computed latency, or `null` if running. |
|
|
130
|
+
|
|
131
|
+
### SpanState
|
|
132
|
+
|
|
133
|
+
Returned by `useAuiState((s) => s.span)` inside any span-scoped subtree:
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
type SpanState = {
|
|
137
|
+
id: string;
|
|
138
|
+
parentSpanId: string | null;
|
|
139
|
+
name: string;
|
|
140
|
+
type: string;
|
|
141
|
+
status: "running" | "completed" | "failed" | "skipped";
|
|
142
|
+
startedAt: number;
|
|
143
|
+
endedAt: number | null;
|
|
144
|
+
latencyMs: number | null;
|
|
145
|
+
depth: number;
|
|
146
|
+
hasChildren: boolean;
|
|
147
|
+
isCollapsed: boolean;
|
|
148
|
+
children: SpanItemState[];
|
|
149
|
+
timeRange: { min: number; max: number };
|
|
150
|
+
};
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### SpanPrimitive.Root
|
|
154
|
+
|
|
155
|
+
Container `<div>` exposing span state via data attributes for styling:
|
|
156
|
+
|
|
157
|
+
| Attribute | Source |
|
|
158
|
+
| --- | --- |
|
|
159
|
+
| `data-span-id` | `span.id` |
|
|
160
|
+
| `data-span-status` | `span.status` |
|
|
161
|
+
| `data-span-type` | `span.type` |
|
|
162
|
+
| `data-span-depth` | `span.depth` |
|
|
163
|
+
| `data-collapsed` | `span.isCollapsed` |
|
|
164
|
+
|
|
165
|
+
Accepts all standard `<div>` props.
|
|
166
|
+
|
|
167
|
+
### SpanPrimitive.Indent
|
|
168
|
+
|
|
169
|
+
A `<div>` that adds horizontal padding proportional to span depth.
|
|
170
|
+
|
|
171
|
+
| Prop | Type | Default | Description |
|
|
172
|
+
| --- | --- | --- | --- |
|
|
173
|
+
| `baseIndent` | `number` | `8` | Base padding in pixels. |
|
|
174
|
+
| `indentPerLevel` | `number` | `12` | Additional padding per depth level. |
|
|
175
|
+
|
|
176
|
+
Final `paddingLeft = baseIndent + depth * indentPerLevel`.
|
|
177
|
+
|
|
178
|
+
### SpanPrimitive.CollapseToggle
|
|
179
|
+
|
|
180
|
+
A `<button>` that toggles the current span's collapsed state. Renders only when the span has children. Stops click propagation so it can be nested inside a clickable row.
|
|
181
|
+
|
|
182
|
+
Exposes `data-collapsed` for styling. Accepts all standard `<button>` props.
|
|
183
|
+
|
|
184
|
+
### SpanPrimitive.StatusIndicator
|
|
185
|
+
|
|
186
|
+
A `<span>` that exposes `data-span-status` for status-based styling (color, icon swap, etc.). Renders no built-in glyph; you provide the visual.
|
|
187
|
+
|
|
188
|
+
```tsx
|
|
189
|
+
<SpanPrimitive.StatusIndicator className="size-2 rounded-full data-[span-status=running]:bg-yellow-500 data-[span-status=completed]:bg-green-500 data-[span-status=failed]:bg-red-500 data-[span-status=skipped]:bg-gray-400" />
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### SpanPrimitive.TypeBadge
|
|
193
|
+
|
|
194
|
+
A `<span>` that defaults its children to `span.type` (override by passing custom children). Exposes `data-span-type`.
|
|
195
|
+
|
|
196
|
+
### SpanPrimitive.Name
|
|
197
|
+
|
|
198
|
+
A `<span>` that defaults its children to `span.name`. Override by passing custom children.
|
|
199
|
+
|
|
200
|
+
### SpanPrimitive.Children
|
|
201
|
+
|
|
202
|
+
Iterates over visible child spans and renders each.
|
|
203
|
+
|
|
204
|
+
Two usage modes:
|
|
205
|
+
|
|
206
|
+
**Render-prop:**
|
|
207
|
+
|
|
208
|
+
```tsx
|
|
209
|
+
<SpanPrimitive.Children>
|
|
210
|
+
{({ span }) => <CustomRow span={span} />}
|
|
211
|
+
</SpanPrimitive.Children>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Component prop (recommended for performance):**
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
<SpanPrimitive.Children components={{ Span: SpanRow }} />
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The `components.Span` form is memoized; pass a stable component reference to avoid re-renders on unrelated state changes.
|
|
221
|
+
|
|
222
|
+
Each child is wrapped in `SpanByIndexProvider` automatically, so primitives inside `SpanRow` read that child's state.
|
|
223
|
+
|
|
224
|
+
### SpanByIndexProvider
|
|
225
|
+
|
|
226
|
+
Lower-level escape hatch. Selects one span by index and provides its scope to descendants:
|
|
227
|
+
|
|
228
|
+
```tsx
|
|
229
|
+
<SpanByIndexProvider index={0}>
|
|
230
|
+
<SpanPrimitive.Root>{/* reads span at index 0 */}</SpanPrimitive.Root>
|
|
231
|
+
</SpanByIndexProvider>
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Most users do not need to use this directly; `SpanPrimitive.Children` wires it up automatically.
|
|
235
|
+
|
|
236
|
+
### SpanPrimitive.ChildByIndex
|
|
237
|
+
|
|
238
|
+
Convenience component that pairs `SpanByIndexProvider` with a render component:
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
<SpanPrimitive.ChildByIndex index={0} components={{ Span: SpanRow }} />
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
Useful when you want explicit control over which child indices to render (e.g. for virtualization).
|
|
245
|
+
|
|
246
|
+
## Styling
|
|
247
|
+
|
|
248
|
+
All primitives forward refs and accept standard DOM props (`className`, `style`, etc.). Use the data attributes for state-based styling:
|
|
249
|
+
|
|
250
|
+
```css
|
|
251
|
+
[data-span-status="running"] {
|
|
252
|
+
/* yellow indicator */
|
|
253
|
+
}
|
|
254
|
+
[data-span-status="failed"] {
|
|
255
|
+
/* red indicator */
|
|
256
|
+
}
|
|
257
|
+
[data-collapsed="true"] svg {
|
|
258
|
+
transform: rotate(0deg);
|
|
259
|
+
}
|
|
260
|
+
[data-collapsed="false"] svg {
|
|
261
|
+
transform: rotate(90deg);
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
## Related
|
|
266
|
+
|
|
267
|
+
<Cards>
|
|
268
|
+
<Card
|
|
269
|
+
title="heat-graph"
|
|
270
|
+
description="Activity heatmap primitives in the same Radix-style headless pattern."
|
|
271
|
+
href="/docs/utilities/heat-graph"
|
|
272
|
+
/>
|
|
273
|
+
<Card
|
|
274
|
+
title="Primitives overview"
|
|
275
|
+
description="The broader assistant-ui primitive system."
|
|
276
|
+
href="/docs/primitives"
|
|
277
|
+
/>
|
|
278
|
+
</Cards>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: tw-shimmer
|
|
3
3
|
description: Tailwind CSS v4 plugin for shimmer effects.
|
|
4
|
+
platforms: ["react"]
|
|
4
5
|
---
|
|
5
6
|
|
|
6
7
|
`tw-shimmer` is a zero-dependency Tailwind CSS v4 plugin that provides polished shimmer animations for both text and skeleton loaders. It uses sine-eased gradients with 17 carefully calculated stops and OKLCH color mixing for smooth, banding-free effects.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@assistant-ui/mcp-docs-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"description": "MCP server for assistant-ui documentation and examples",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|
|
@@ -34,13 +34,13 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
36
36
|
"gray-matter": "^4.0.3",
|
|
37
|
-
"zod": "^4.3
|
|
37
|
+
"zod": "^4.4.3"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/node": "^25.6.0",
|
|
41
41
|
"tsx": "^4.21.0",
|
|
42
42
|
"vitest": "^4.1.5",
|
|
43
|
-
"@assistant-ui/x-buildutils": "0.0.
|
|
43
|
+
"@assistant-ui/x-buildutils": "0.0.7"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public",
|
|
@@ -26,7 +26,7 @@ describe("Path Traversal Security", () => {
|
|
|
26
26
|
|
|
27
27
|
it("should handle multiple paths with one malicious", async () => {
|
|
28
28
|
const result = await testContext.callTool("assistantUIDocs", {
|
|
29
|
-
paths: ["(docs)/index", "../../../../etc/passwd", "
|
|
29
|
+
paths: ["(docs)/index", "../../../../etc/passwd", "guides"],
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
expect(result.results).toBeDefined();
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Message Branching
|
|
3
|
-
description: Navigate between different conversation branches when editing or reloading messages.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
import { BranchingSample } from "@/components/docs/samples/branching";
|
|
7
|
-
|
|
8
|
-
Switch between different conversation branches.
|
|
9
|
-
|
|
10
|
-
<BranchingSample />
|
|
11
|
-
|
|
12
|
-
A new branch is created when:
|
|
13
|
-
|
|
14
|
-
- a user message is edited
|
|
15
|
-
- an assistant message is reloaded
|
|
16
|
-
|
|
17
|
-
Branches are automatically tracked by assistant-ui by observing changes to the `messages` array.
|
|
18
|
-
|
|
19
|
-
## Enabling branch support
|
|
20
|
-
|
|
21
|
-
You can show a branch picker by using `BranchPickerPrimitive`.
|
|
22
|
-
|
|
23
|
-
```tsx {1, 8, 15-30}
|
|
24
|
-
import { BranchPickerPrimitive } from "@assistant-ui/react";
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const Message = () => {
|
|
28
|
-
return (
|
|
29
|
-
<MessagePrimitive.Root>
|
|
30
|
-
...
|
|
31
|
-
<BranchPicker /> {/* <-- show the branch picker */}
|
|
32
|
-
...
|
|
33
|
-
</MessagePrimitive.Root>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const BranchPicker = () => {
|
|
39
|
-
return (
|
|
40
|
-
<BranchPickerPrimitive.Root hideWhenSingleBranch>
|
|
41
|
-
<BranchPickerPrimitive.Previous />
|
|
42
|
-
<BranchPickerPrimitive.Number /> / <BranchPickerPrimitive.Count />
|
|
43
|
-
<BranchPickerPrimitive.Next />
|
|
44
|
-
</BranchPickerPrimitive.Root>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## API
|
|
50
|
-
|
|
51
|
-
You can access the current branch state or navigate via the API as well.
|
|
52
|
-
These APIs rely on the message scope and may only be called inside a message component.
|
|
53
|
-
|
|
54
|
-
```tsx
|
|
55
|
-
import { useAui, useAuiState } from "@assistant-ui/react";
|
|
56
|
-
|
|
57
|
-
// read branch state
|
|
58
|
-
const { branchNumber, branchCount } = useAuiState((s) => s.message);
|
|
59
|
-
|
|
60
|
-
// navigation
|
|
61
|
-
const aui = useAui();
|
|
62
|
-
aui.message().switchToBranch({ position: "next" });
|
|
63
|
-
aui.message().switchToBranch({ position: "previous" });
|
|
64
|
-
aui.message().switchToBranch({ branchId: "some-id" });
|
|
65
|
-
```
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Chain of Thought
|
|
3
|
-
description: Group reasoning and tool calls into a collapsible accordion UI.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
LLMs often produce reasoning steps and tool calls in succession. Chain of Thought lets you visually group these consecutive parts into a single collapsible accordion, giving users a clean "thinking" UI.
|
|
7
|
-
|
|
8
|
-
## Overview
|
|
9
|
-
|
|
10
|
-
When a model like OpenAI's `o4-mini` responds, it may emit a sequence of reasoning tokens and tool calls before producing its final text answer. By default, these parts render individually. `ChainOfThoughtPrimitive` groups consecutive reasoning + tool-call parts together and renders them through a single component.
|
|
11
|
-
|
|
12
|
-
Key benefits:
|
|
13
|
-
|
|
14
|
-
- **Cleaner UI** — Collapse intermediate steps behind a "Thinking" toggle
|
|
15
|
-
- **Better context** — Users see that reasoning and tool calls are related
|
|
16
|
-
- **Built-in accordion** — Expand/collapse with a single click; collapsed by default
|
|
17
|
-
|
|
18
|
-
## Quick Start
|
|
19
|
-
|
|
20
|
-
<Steps>
|
|
21
|
-
<Step>
|
|
22
|
-
|
|
23
|
-
### Pass a ChainOfThought component to MessagePrimitive.Parts
|
|
24
|
-
|
|
25
|
-
`MessagePrimitive.Parts` accepts a `ChainOfThought` component. When provided, consecutive reasoning and tool-call parts are automatically grouped and rendered through it.
|
|
26
|
-
|
|
27
|
-
```tsx
|
|
28
|
-
import {
|
|
29
|
-
AuiIf,
|
|
30
|
-
ChainOfThoughtPrimitive,
|
|
31
|
-
MessagePrimitive,
|
|
32
|
-
} from "@assistant-ui/react";
|
|
33
|
-
import type { FC } from "react";
|
|
34
|
-
|
|
35
|
-
const Reasoning: FC<{ text: string }> = ({ text }) => {
|
|
36
|
-
return (
|
|
37
|
-
<p className="whitespace-pre-wrap px-4 py-2 text-muted-foreground text-sm italic">
|
|
38
|
-
{text}
|
|
39
|
-
</p>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const ChainOfThought: FC = () => {
|
|
44
|
-
return (
|
|
45
|
-
<ChainOfThoughtPrimitive.Root className="my-2 rounded-lg border">
|
|
46
|
-
<ChainOfThoughtPrimitive.AccordionTrigger className="flex w-full cursor-pointer items-center gap-2 px-4 py-2 font-medium text-sm hover:bg-muted/50">
|
|
47
|
-
Thinking
|
|
48
|
-
</ChainOfThoughtPrimitive.AccordionTrigger>
|
|
49
|
-
<AuiIf condition={(s) => !s.chainOfThought.collapsed}>
|
|
50
|
-
<ChainOfThoughtPrimitive.Parts>
|
|
51
|
-
{({ part }) => {
|
|
52
|
-
if (part.type === "reasoning") return <Reasoning {...part} />;
|
|
53
|
-
if (part.type === "tool-call") return <ToolFallback {...part} />;
|
|
54
|
-
return null;
|
|
55
|
-
}}
|
|
56
|
-
</ChainOfThoughtPrimitive.Parts>
|
|
57
|
-
</AuiIf>
|
|
58
|
-
</ChainOfThoughtPrimitive.Root>
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const AssistantMessage: FC = () => {
|
|
63
|
-
return (
|
|
64
|
-
<MessagePrimitive.Root>
|
|
65
|
-
<MessagePrimitive.Parts>
|
|
66
|
-
{({ part }) => {
|
|
67
|
-
if (part.type === "text") return <MarkdownText />;
|
|
68
|
-
return null;
|
|
69
|
-
}}
|
|
70
|
-
</MessagePrimitive.Parts>
|
|
71
|
-
</MessagePrimitive.Root>
|
|
72
|
-
);
|
|
73
|
-
};
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
</Step>
|
|
77
|
-
<Step>
|
|
78
|
-
|
|
79
|
-
### Use a reasoning model
|
|
80
|
-
|
|
81
|
-
Chain of Thought is most useful with models that produce reasoning tokens (e.g. OpenAI `o4-mini`). Here's an example backend route using the Vercel AI SDK:
|
|
82
|
-
|
|
83
|
-
```tsx title="app/api/chat/route.ts"
|
|
84
|
-
import { openai } from "@ai-sdk/openai";
|
|
85
|
-
import { streamText, convertToModelMessages } from "ai";
|
|
86
|
-
|
|
87
|
-
export async function POST(req: Request) {
|
|
88
|
-
const { messages } = await req.json();
|
|
89
|
-
|
|
90
|
-
const result = streamText({
|
|
91
|
-
model: openai("o4-mini"),
|
|
92
|
-
messages: await convertToModelMessages(messages),
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
return result.toUIMessageStreamResponse();
|
|
96
|
-
}
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
</Step>
|
|
100
|
-
</Steps>
|
|
101
|
-
|
|
102
|
-
## API Reference
|
|
103
|
-
|
|
104
|
-
### ChainOfThoughtPrimitive.Root
|
|
105
|
-
|
|
106
|
-
Container element for the chain of thought group. Renders a `<div>`.
|
|
107
|
-
|
|
108
|
-
### ChainOfThoughtPrimitive.AccordionTrigger
|
|
109
|
-
|
|
110
|
-
A button that toggles the collapsed/expanded state. Collapsed by default.
|
|
111
|
-
|
|
112
|
-
### ChainOfThoughtPrimitive.Parts
|
|
113
|
-
|
|
114
|
-
Renders the grouped parts when expanded (nothing when collapsed).
|
|
115
|
-
|
|
116
|
-
```tsx
|
|
117
|
-
<AuiIf condition={(s) => !s.chainOfThought.collapsed}>
|
|
118
|
-
<ChainOfThoughtPrimitive.Parts>
|
|
119
|
-
{({ part }) => {
|
|
120
|
-
if (part.type === "reasoning") return <Reasoning {...part} />;
|
|
121
|
-
if (part.type === "tool-call") return <ToolFallback {...part} />;
|
|
122
|
-
return null;
|
|
123
|
-
}}
|
|
124
|
-
</ChainOfThoughtPrimitive.Parts>
|
|
125
|
-
</AuiIf>
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
| Prop | Type | Description |
|
|
129
|
-
| --- | --- | --- |
|
|
130
|
-
| `components.Reasoning` | `FC<{ text: string }>` | Component to render reasoning parts |
|
|
131
|
-
| `components.tools.Fallback` | `ToolCallMessagePartComponent` | Fallback component for tool-call parts |
|
|
132
|
-
| `components.Layout` | `ComponentType<PropsWithChildren>` | Wrapper component around each rendered part when expanded |
|
|
133
|
-
|
|
134
|
-
## Reading Collapsed State
|
|
135
|
-
|
|
136
|
-
Use `AuiIf` to conditionally render based on the accordion state:
|
|
137
|
-
|
|
138
|
-
```tsx
|
|
139
|
-
import { AuiIf, ChainOfThoughtPrimitive } from "@assistant-ui/react";
|
|
140
|
-
import { ChevronDownIcon, ChevronRightIcon } from "lucide-react";
|
|
141
|
-
|
|
142
|
-
const ChainOfThoughtAccordionTrigger = () => {
|
|
143
|
-
return (
|
|
144
|
-
<ChainOfThoughtPrimitive.AccordionTrigger className="flex w-full cursor-pointer items-center gap-2 px-4 py-2 text-sm">
|
|
145
|
-
<AuiIf condition={(s) => s.chainOfThought.collapsed}>
|
|
146
|
-
<ChevronRightIcon className="size-4" />
|
|
147
|
-
</AuiIf>
|
|
148
|
-
<AuiIf condition={(s) => !s.chainOfThought.collapsed}>
|
|
149
|
-
<ChevronDownIcon className="size-4" />
|
|
150
|
-
</AuiIf>
|
|
151
|
-
Thinking
|
|
152
|
-
</ChainOfThoughtPrimitive.AccordionTrigger>
|
|
153
|
-
);
|
|
154
|
-
};
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## Full Example
|
|
158
|
-
|
|
159
|
-
See the complete [with-chain-of-thought example](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-chain-of-thought) for a working implementation with tool calls and reasoning.
|
|
160
|
-
|
|
161
|
-
## Related Guides
|
|
162
|
-
|
|
163
|
-
- [Generative UI](/docs/guides/tool-ui) — Custom UI for tool calls
|
|
164
|
-
- [Tools](/docs/guides/tools) — Defining and using tools
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Message Editing
|
|
3
|
-
description: Allow users to edit their messages with custom editor interfaces.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
Give the user the ability to edit their message.
|
|
7
|
-
|
|
8
|
-
## Enabling edit support
|
|
9
|
-
|
|
10
|
-
You can show an editor interface by using `ComposerPrimitive`.
|
|
11
|
-
|
|
12
|
-
```tsx {1-2,11,25,31-52}
|
|
13
|
-
import { ComposerPrimitive, useAuiState } from "@assistant-ui/react";
|
|
14
|
-
...
|
|
15
|
-
|
|
16
|
-
const Thread = () => {
|
|
17
|
-
return (
|
|
18
|
-
<ThreadPrimitive.Root>
|
|
19
|
-
<ThreadPrimitive.Viewport>
|
|
20
|
-
...
|
|
21
|
-
<ThreadPrimitive.Messages>
|
|
22
|
-
{({ message }) => {
|
|
23
|
-
// Show our new component during edit mode
|
|
24
|
-
return <MessageWithEditComposer />;
|
|
25
|
-
}}
|
|
26
|
-
</ThreadPrimitive.Messages>
|
|
27
|
-
</ThreadPrimitive.Viewport>
|
|
28
|
-
...
|
|
29
|
-
</ThreadPrimitive.Root>
|
|
30
|
-
);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const UserMessage = () => {
|
|
34
|
-
return (
|
|
35
|
-
<MessagePrimitive.Root>
|
|
36
|
-
...
|
|
37
|
-
<ActionBarPrimitive.Root>
|
|
38
|
-
...
|
|
39
|
-
<ActionBarPrimitive.Edit /> {/* <-- add a button to enable edit mode */}
|
|
40
|
-
</ActionBarPrimitive.Root>
|
|
41
|
-
</MessagePrimitive.Root>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// define a wrapper component that handles both display and edit mode
|
|
46
|
-
const MessageWithEditComposer = () => {
|
|
47
|
-
const isEditing = useAuiState((s) => s.composer.isEditing);
|
|
48
|
-
if (isEditing) return <EditComposer />;
|
|
49
|
-
return <UserMessage />;
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// define the edit composer component
|
|
53
|
-
const EditComposer = () => {
|
|
54
|
-
return (
|
|
55
|
-
// you can return a MessagePrimitive including a ComposerPrimitive, or only a ComposerPrimitive
|
|
56
|
-
<MessagePrimitive.Root>
|
|
57
|
-
...
|
|
58
|
-
<ComposerPrimitive.Root>
|
|
59
|
-
<ComposerPrimitive.Input />
|
|
60
|
-
<ComposerPrimitive.Cancel />
|
|
61
|
-
<ComposerPrimitive.Send />
|
|
62
|
-
</ComposerPrimitive.Root>
|
|
63
|
-
</MessagePrimitive.Root>
|
|
64
|
-
);
|
|
65
|
-
};
|
|
66
|
-
```
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Text-to-Speech (Speech Synthesis)
|
|
3
|
-
description: Read messages aloud with Web Speech API or custom TTS.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
import { SpeechSample } from "@/components/docs/samples/speech";
|
|
7
|
-
|
|
8
|
-
assistant-ui supports text-to-speech via the `SpeechSynthesisAdapter` interface.
|
|
9
|
-
|
|
10
|
-
<SpeechSample />
|
|
11
|
-
|
|
12
|
-
## SpeechSynthesisAdapter
|
|
13
|
-
|
|
14
|
-
Currently, the following speech synthesis adapters are supported:
|
|
15
|
-
|
|
16
|
-
- `WebSpeechSynthesisAdapter`: Uses the browser's `Web Speech API`
|
|
17
|
-
|
|
18
|
-
Support for other speech synthesis adapters is planned for the future.
|
|
19
|
-
|
|
20
|
-
Passing a `SpeechSynthesisAdapter` to the runtime will enable text-to-speech support.
|
|
21
|
-
|
|
22
|
-
## UI
|
|
23
|
-
|
|
24
|
-
The default action bar does not include a speech button. You need to add `ActionBarPrimitive.Speak` and `ActionBarPrimitive.StopSpeaking` to your assistant message action bar manually. See the example above for a complete implementation.
|
|
25
|
-
|
|
26
|
-
## Example
|
|
27
|
-
|
|
28
|
-
The following example uses the `WebSpeechSynthesisAdapter`.
|
|
29
|
-
|
|
30
|
-
```tsx
|
|
31
|
-
import { WebSpeechSynthesisAdapter } from "@assistant-ui/react";
|
|
32
|
-
|
|
33
|
-
const runtime = useChatRuntime({
|
|
34
|
-
adapters: {
|
|
35
|
-
speech: new WebSpeechSynthesisAdapter(),
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
```
|