@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,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Overview
|
|
3
|
+
description: Four ways to wire assistant-ui to a backend without a framework adapter.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
If no [framework adapter](/docs/runtimes/pick-a-runtime) fits your backend, this section gives you four building blocks. All four are built on one of the two core runtimes; understanding the layering (see [architecture](/docs/runtimes/concepts/architecture)) makes the choice clear.
|
|
7
|
+
|
|
8
|
+
## The four paths
|
|
9
|
+
|
|
10
|
+
| Path | Layered on | Wire shape | Choose when |
|
|
11
|
+
| --- | --- | --- | --- |
|
|
12
|
+
| [`LocalRuntime`](/docs/runtimes/custom/local-runtime) | Core | You write a `ChatModelAdapter.run` function | The simplest case: you have a `fetch` call to make, want assistant-ui to handle state |
|
|
13
|
+
| [`ExternalStoreRuntime`](/docs/runtimes/custom/external-store) | Core | You provide messages + callbacks | You already have state in redux, zustand, tanstack-query, or anywhere |
|
|
14
|
+
| [`DataStream`](/docs/runtimes/custom/data-stream) | LocalRuntime + protocol | Your backend emits the data stream protocol | You want a thin message-stream contract, or you are migrating from AI SDK v4 |
|
|
15
|
+
| [`AssistantTransport`](/docs/runtimes/custom/assistant-transport) | ExternalStoreRuntime + protocol | Your backend streams agent state snapshots | Your agent has rich internal state and you want it surfaced in the UI; or you need bidirectional commands |
|
|
16
|
+
|
|
17
|
+
## Decision tree
|
|
18
|
+
|
|
19
|
+
```text
|
|
20
|
+
do you have an AI SDK / LangGraph / Google ADK / A2A backend?
|
|
21
|
+
└── yes → use that framework adapter; you do not need this section
|
|
22
|
+
└── no → continue
|
|
23
|
+
│
|
|
24
|
+
do you already have message state in redux / zustand / tanstack-query?
|
|
25
|
+
└── yes → ExternalStoreRuntime
|
|
26
|
+
└── no → continue
|
|
27
|
+
│
|
|
28
|
+
do you control the backend wire format?
|
|
29
|
+
└── yes, and i want simple fetch calls → LocalRuntime
|
|
30
|
+
└── yes, and i want to stream a structured agent state → AssistantTransport
|
|
31
|
+
└── no, the backend already speaks data stream protocol → DataStream
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## What each path gives you
|
|
35
|
+
|
|
36
|
+
**`LocalRuntime`** is the lowest-friction path. You implement one method (`run` or `async *run`). Branching, editing, regeneration, multi-thread, and adapter slots all work without extra code.
|
|
37
|
+
|
|
38
|
+
**`ExternalStoreRuntime`** is the inverse: you own the message array and provide callbacks for each interaction. UI features turn on based on which callbacks you provide. Ideal when chat state is a first-class entity in your existing store.
|
|
39
|
+
|
|
40
|
+
**`DataStream`** is `LocalRuntime` plus a wire protocol. You do not write a `ChatModelAdapter`; your backend emits a standardized stream of message parts and the runtime consumes it directly.
|
|
41
|
+
|
|
42
|
+
**`AssistantTransport`** is `ExternalStoreRuntime` plus a state-streaming protocol. Instead of sending message parts, your backend sends snapshots of its full agent state. The UI is a stateless view on top of that state. Supports custom commands beyond the built-in `add-message` and `add-tool-result`.
|
|
43
|
+
|
|
44
|
+
## Common building blocks
|
|
45
|
+
|
|
46
|
+
Regardless of which path you pick, the [adapter](/docs/runtimes/concepts/adapters) and [thread](/docs/runtimes/concepts/threads) interfaces work the same way. Wire attachments, history, speech, feedback, suggestions, and multi-thread support through those shared contracts.
|
|
47
|
+
|
|
48
|
+
## Next
|
|
49
|
+
|
|
50
|
+
<Cards>
|
|
51
|
+
<Card
|
|
52
|
+
title="LocalRuntime"
|
|
53
|
+
description="Write a single ChatModelAdapter.run function."
|
|
54
|
+
href="/docs/runtimes/custom/local-runtime"
|
|
55
|
+
/>
|
|
56
|
+
<Card
|
|
57
|
+
title="ExternalStoreRuntime"
|
|
58
|
+
description="Bring redux, zustand, tanstack-query, or your own state."
|
|
59
|
+
href="/docs/runtimes/custom/external-store"
|
|
60
|
+
/>
|
|
61
|
+
<Card
|
|
62
|
+
title="Data Stream"
|
|
63
|
+
description="Standard message-stream protocol on top of LocalRuntime."
|
|
64
|
+
href="/docs/runtimes/custom/data-stream"
|
|
65
|
+
/>
|
|
66
|
+
<Card
|
|
67
|
+
title="Assistant Transport"
|
|
68
|
+
description="Stream full agent state snapshots and bidirectional commands."
|
|
69
|
+
href="/docs/runtimes/custom/assistant-transport"
|
|
70
|
+
/>
|
|
71
|
+
</Cards>
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: API reference
|
|
3
|
+
description: createAdkStream, server helpers, session adapter, threads, message editing.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Reference for the runtime's wire-up surface. Start with [quickstart](/docs/runtimes/google-adk/quickstart) if you have not already.
|
|
7
|
+
|
|
8
|
+
## createAdkStream
|
|
9
|
+
|
|
10
|
+
Creates an `AdkStreamCallback` that connects to an ADK endpoint via SSE. Supports two modes.
|
|
11
|
+
|
|
12
|
+
**proxy mode** — POST to your own API route:
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { createAdkStream } from "@assistant-ui/react-google-adk";
|
|
16
|
+
|
|
17
|
+
const stream = createAdkStream({ api: "/api/chat" });
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**direct mode** — connect directly to an ADK server:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
const stream = createAdkStream({
|
|
24
|
+
api: "http://localhost:8000",
|
|
25
|
+
appName: "my-app",
|
|
26
|
+
userId: "user-1",
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
| Option | Type | Description |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| `api` | `string` | URL to POST to (proxy route or ADK server base URL). |
|
|
33
|
+
| `appName` | `string?` | ADK app name (enables direct mode when set). |
|
|
34
|
+
| `userId` | `string?` | ADK user ID (required with `appName`). |
|
|
35
|
+
| `headers` | `Record<string, string>` or `() => ...` | Static or dynamic request headers. |
|
|
36
|
+
|
|
37
|
+
## Direct ADK server connection
|
|
38
|
+
|
|
39
|
+
When connecting directly to an ADK server (without a proxy API route), use `createAdkSessionAdapter` to back your thread list with ADK sessions:
|
|
40
|
+
|
|
41
|
+
```tsx
|
|
42
|
+
import {
|
|
43
|
+
useAdkRuntime,
|
|
44
|
+
createAdkStream,
|
|
45
|
+
createAdkSessionAdapter,
|
|
46
|
+
} from "@assistant-ui/react-google-adk";
|
|
47
|
+
|
|
48
|
+
const ADK_URL = "http://localhost:8000";
|
|
49
|
+
|
|
50
|
+
const { adapter, load, artifacts } = createAdkSessionAdapter({
|
|
51
|
+
apiUrl: ADK_URL,
|
|
52
|
+
appName: "my-app",
|
|
53
|
+
userId: "user-1",
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const runtime = useAdkRuntime({
|
|
57
|
+
stream: createAdkStream({
|
|
58
|
+
api: ADK_URL,
|
|
59
|
+
appName: "my-app",
|
|
60
|
+
userId: "user-1",
|
|
61
|
+
}),
|
|
62
|
+
sessionAdapter: adapter,
|
|
63
|
+
load,
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The session adapter maps ADK sessions to assistant-ui threads:
|
|
68
|
+
|
|
69
|
+
- **`adapter`** is a `RemoteThreadListAdapter` that uses ADK's session REST API for thread CRUD.
|
|
70
|
+
- **`load`** reconstructs messages from session events via `AdkEventAccumulator`.
|
|
71
|
+
- **`artifacts`** are functions to fetch, list, and delete session artifacts (see [hooks → artifacts](/docs/runtimes/google-adk/hooks#artifacts)).
|
|
72
|
+
|
|
73
|
+
| Option | Type | Description |
|
|
74
|
+
| --- | --- | --- |
|
|
75
|
+
| `apiUrl` | `string` | ADK server base URL. |
|
|
76
|
+
| `appName` | `string` | ADK app name. |
|
|
77
|
+
| `userId` | `string` | ADK user ID. |
|
|
78
|
+
| `headers` | `Record<string, string>` or `() => ...` | Static or dynamic request headers. |
|
|
79
|
+
|
|
80
|
+
## Server helpers
|
|
81
|
+
|
|
82
|
+
Server helpers live under the `/server` subpath:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
import {
|
|
86
|
+
createAdkApiRoute,
|
|
87
|
+
adkEventStream,
|
|
88
|
+
parseAdkRequest,
|
|
89
|
+
toAdkContent,
|
|
90
|
+
} from "@assistant-ui/react-google-adk/server";
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### createAdkApiRoute
|
|
94
|
+
|
|
95
|
+
One-liner API route handler that combines request parsing and SSE streaming:
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
export const POST = createAdkApiRoute({
|
|
99
|
+
runner,
|
|
100
|
+
userId: "default-user",
|
|
101
|
+
sessionId: (req) =>
|
|
102
|
+
new URL(req.url).searchParams.get("sessionId") ?? "default",
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Both `userId` and `sessionId` accept a static string or a function `(req: Request) => string` for dynamic resolution.
|
|
107
|
+
|
|
108
|
+
### adkEventStream
|
|
109
|
+
|
|
110
|
+
Converts an `AsyncGenerator<Event>` from ADK's `Runner.runAsync()` into an SSE `Response`. Sends an initial `:ok` comment to keep connections alive through proxies.
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
const events = runner.runAsync({ userId, sessionId, newMessage });
|
|
114
|
+
return adkEventStream(events);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### parseAdkRequest and toAdkContent
|
|
118
|
+
|
|
119
|
+
Lower-level helpers for custom API routes. `parseAdkRequest` parses incoming requests; `toAdkContent` converts to ADK's `Content` format. Supports user messages, tool results, `stateDelta`, `checkpointId`, and multimodal content:
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
const parsed = await parseAdkRequest(req);
|
|
123
|
+
// parsed.type is "message" or "tool-result"
|
|
124
|
+
// parsed.config contains runConfig, checkpointId
|
|
125
|
+
// parsed.stateDelta contains session state changes
|
|
126
|
+
|
|
127
|
+
const newMessage = toAdkContent(parsed);
|
|
128
|
+
const events = runner.runAsync({
|
|
129
|
+
userId,
|
|
130
|
+
sessionId,
|
|
131
|
+
newMessage,
|
|
132
|
+
stateDelta: parsed.stateDelta,
|
|
133
|
+
});
|
|
134
|
+
return adkEventStream(events);
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Thread management
|
|
138
|
+
|
|
139
|
+
Three options, picked by what you want to own. See [threads](/docs/runtimes/concepts/threads) for the general model.
|
|
140
|
+
|
|
141
|
+
### ADK session adapter
|
|
142
|
+
|
|
143
|
+
Use `createAdkSessionAdapter` to persist threads via ADK's session API; see [Direct ADK server connection](#direct-adk-server-connection) above.
|
|
144
|
+
|
|
145
|
+
### Custom thread management
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
const runtime = useAdkRuntime({
|
|
149
|
+
stream: createAdkStream({ api: "/api/chat" }),
|
|
150
|
+
create: async () => {
|
|
151
|
+
const sessionId = await createSession();
|
|
152
|
+
return { externalId: sessionId };
|
|
153
|
+
},
|
|
154
|
+
load: async (externalId) => {
|
|
155
|
+
const history = await loadSession(externalId);
|
|
156
|
+
return { messages: history };
|
|
157
|
+
},
|
|
158
|
+
delete: async (externalId) => {
|
|
159
|
+
await deleteSession(externalId);
|
|
160
|
+
},
|
|
161
|
+
});
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Cloud persistence
|
|
165
|
+
|
|
166
|
+
For persistent thread history via assistant-cloud, pass a `cloud` instance:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
const runtime = useAdkRuntime({
|
|
170
|
+
cloud, // see "AssistantCloud" in /docs/runtimes/concepts/threads
|
|
171
|
+
stream: createAdkStream({ api: "/api/chat" }),
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Message editing and regeneration
|
|
176
|
+
|
|
177
|
+
Provide a `getCheckpointId` callback to enable edit and regenerate buttons:
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
const runtime = useAdkRuntime({
|
|
181
|
+
stream: createAdkStream({ api: "/api/chat" }),
|
|
182
|
+
getCheckpointId: async (threadId, parentMessages) => {
|
|
183
|
+
// Resolve checkpoint ID for server-side forking
|
|
184
|
+
return checkpointId;
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
When `getCheckpointId` is provided:
|
|
190
|
+
|
|
191
|
+
- **Edit buttons** appear on user messages.
|
|
192
|
+
- **Regenerate buttons** appear on assistant messages.
|
|
193
|
+
|
|
194
|
+
The resolved `checkpointId` is passed to your `stream` callback via `config.checkpointId`.
|
|
195
|
+
|
|
196
|
+
<Callout type="info">
|
|
197
|
+
Without `getCheckpointId`, edit and regenerate buttons will not appear. This is intentional; truncating client-side messages without forking from the correct server-side checkpoint would produce incorrect state.
|
|
198
|
+
</Callout>
|
|
199
|
+
|
|
200
|
+
## Event handlers
|
|
201
|
+
|
|
202
|
+
Listen to streaming events:
|
|
203
|
+
|
|
204
|
+
```ts
|
|
205
|
+
const runtime = useAdkRuntime({
|
|
206
|
+
stream: createAdkStream({ api: "/api/chat" }),
|
|
207
|
+
eventHandlers: {
|
|
208
|
+
onError: (error) => {
|
|
209
|
+
console.error("Stream error:", error);
|
|
210
|
+
},
|
|
211
|
+
onAgentTransfer: (toAgent) => {
|
|
212
|
+
console.log("Agent transferred to:", toAgent);
|
|
213
|
+
},
|
|
214
|
+
onCustomEvent: (key, value) => {
|
|
215
|
+
// Fired for each entry in event.customMetadata
|
|
216
|
+
console.log("Custom metadata:", key, value);
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## RunConfig and stateDelta
|
|
223
|
+
|
|
224
|
+
Pass `AdkRunConfig` to control agent behavior, and `stateDelta` to mutate session state along with messages:
|
|
225
|
+
|
|
226
|
+
```ts
|
|
227
|
+
import { useAdkSend } from "@assistant-ui/react-google-adk";
|
|
228
|
+
|
|
229
|
+
const send = useAdkSend();
|
|
230
|
+
|
|
231
|
+
send(messages, {
|
|
232
|
+
runConfig: {
|
|
233
|
+
streamingMode: "sse",
|
|
234
|
+
maxLlmCalls: 10,
|
|
235
|
+
pauseOnToolCalls: true,
|
|
236
|
+
},
|
|
237
|
+
stateDelta: { taskId: "abc", mode: "verbose" },
|
|
238
|
+
});
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
`stateDelta` maps to ADK's `stateDelta` parameter on `/run_sse`.
|
|
242
|
+
|
|
243
|
+
## Next
|
|
244
|
+
|
|
245
|
+
<Cards>
|
|
246
|
+
<Card
|
|
247
|
+
title="Hooks"
|
|
248
|
+
description="Tool confirmations, auth, input requests, artifacts, escalation, metadata."
|
|
249
|
+
href="/docs/runtimes/google-adk/hooks"
|
|
250
|
+
/>
|
|
251
|
+
<Card
|
|
252
|
+
title="Threads"
|
|
253
|
+
description="General model for multi-thread support across runtimes."
|
|
254
|
+
href="/docs/runtimes/concepts/threads"
|
|
255
|
+
/>
|
|
256
|
+
</Cards>
|