@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.
Files changed (208) hide show
  1. package/.docs/organized/code-examples/waterfall.md +1 -1
  2. package/.docs/organized/code-examples/with-a2a.md +2 -2
  3. package/.docs/organized/code-examples/with-ag-ui.md +3 -3
  4. package/.docs/organized/code-examples/with-ai-sdk-v6.md +5 -5
  5. package/.docs/organized/code-examples/with-artifacts.md +5 -5
  6. package/.docs/organized/code-examples/with-assistant-transport.md +3 -3
  7. package/.docs/organized/code-examples/with-chain-of-thought.md +79 -50
  8. package/.docs/organized/code-examples/with-cloud-standalone.md +4 -4
  9. package/.docs/organized/code-examples/with-cloud.md +4 -4
  10. package/.docs/organized/code-examples/with-custom-thread-list.md +56 -11
  11. package/.docs/organized/code-examples/with-elevenlabs-conversational.md +7 -7
  12. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +7 -7
  13. package/.docs/organized/code-examples/with-expo.md +16 -16
  14. package/.docs/organized/code-examples/with-external-store.md +2 -2
  15. package/.docs/organized/code-examples/with-ffmpeg.md +5 -5
  16. package/.docs/organized/code-examples/with-generative-ui.md +5 -5
  17. package/.docs/organized/code-examples/with-google-adk.md +4 -4
  18. package/.docs/organized/code-examples/with-heat-graph.md +1 -1
  19. package/.docs/organized/code-examples/with-interactables.md +5 -5
  20. package/.docs/organized/code-examples/with-langchain.md +3 -3
  21. package/.docs/organized/code-examples/with-langgraph.md +3 -3
  22. package/.docs/organized/code-examples/with-livekit.md +8 -8
  23. package/.docs/organized/code-examples/with-opencode.md +99 -54
  24. package/.docs/organized/code-examples/with-parent-id-grouping.md +4 -4
  25. package/.docs/organized/code-examples/with-react-hook-form.md +5 -5
  26. package/.docs/organized/code-examples/with-react-ink.md +1 -1
  27. package/.docs/organized/code-examples/with-react-router.md +8 -8
  28. package/.docs/organized/code-examples/with-store.md +1 -1
  29. package/.docs/organized/code-examples/with-tanstack.md +5 -5
  30. package/.docs/organized/code-examples/with-tap-runtime.md +2 -2
  31. package/.docs/raw/docs/(docs)/cli.mdx +2 -1
  32. package/.docs/raw/docs/(docs)/copilots/assistant-frame.mdx +1 -0
  33. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +10 -3
  34. package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +8 -3
  35. package/.docs/raw/docs/(docs)/copilots/make-assistant-visible.mdx +1 -0
  36. package/.docs/raw/docs/(docs)/copilots/model-context.mdx +1 -0
  37. package/.docs/raw/docs/(docs)/copilots/motivation.mdx +1 -0
  38. package/.docs/raw/docs/(docs)/copilots/use-assistant-instructions.mdx +1 -0
  39. package/.docs/raw/docs/(docs)/devtools.mdx +1 -0
  40. package/.docs/raw/docs/(docs)/index.mdx +1 -0
  41. package/.docs/raw/docs/(docs)/installation.mdx +1 -0
  42. package/.docs/raw/docs/(docs)/rtl.mdx +1 -0
  43. package/.docs/raw/docs/(reference)/api-reference/adapters/attachments.mdx +34 -0
  44. package/.docs/raw/docs/(reference)/api-reference/adapters/feedback-speech.mdx +41 -0
  45. package/.docs/raw/docs/(reference)/api-reference/adapters/index.mdx +26 -0
  46. package/.docs/raw/docs/(reference)/api-reference/adapters/persistence.mdx +34 -0
  47. package/.docs/raw/docs/(reference)/api-reference/adapters/runtime.mdx +31 -0
  48. package/.docs/raw/docs/(reference)/api-reference/context-providers/index.mdx +20 -0
  49. package/.docs/raw/docs/(reference)/api-reference/hooks/index.mdx +26 -0
  50. package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +72 -0
  51. package/.docs/raw/docs/(reference)/api-reference/hooks/runtimes.mdx +41 -0
  52. package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +48 -0
  53. package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +30 -0
  54. package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +23 -0
  55. package/.docs/raw/docs/(reference)/api-reference/overview.mdx +21 -0
  56. package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +7 -0
  57. package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +65 -0
  58. package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +50 -6
  59. package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +15 -0
  60. package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +36 -1
  61. package/.docs/raw/docs/(reference)/api-reference/runtimes/index.mdx +38 -0
  62. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +5 -0
  63. package/.docs/raw/docs/(reference)/migrations/v0-14.mdx +144 -6
  64. package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +230 -2
  65. package/.docs/raw/docs/cloud/ai-sdk.mdx +221 -3
  66. package/.docs/raw/docs/cloud/langgraph.mdx +274 -2
  67. package/.docs/raw/docs/{(docs)/guides → guides}/attachments.mdx +41 -36
  68. package/.docs/raw/docs/guides/branching.mdx +76 -0
  69. package/.docs/raw/docs/guides/chain-of-thought.mdx +166 -0
  70. package/.docs/raw/docs/{(docs)/guides → guides}/context-api.mdx +50 -22
  71. package/.docs/raw/docs/{(docs)/guides → guides}/dictation.mdx +2 -0
  72. package/.docs/raw/docs/guides/editing.mdx +102 -0
  73. package/.docs/raw/docs/guides/index.mdx +103 -0
  74. package/.docs/raw/docs/{(docs)/guides → guides}/interactables.mdx +49 -0
  75. package/.docs/raw/docs/{(docs)/guides → guides}/latex.mdx +51 -8
  76. package/.docs/raw/docs/{(docs)/guides → guides}/mentions.mdx +61 -86
  77. package/.docs/raw/docs/{(docs)/guides → guides}/message-timing.mdx +8 -2
  78. package/.docs/raw/docs/{(docs)/guides → guides}/multi-agent.mdx +64 -4
  79. package/.docs/raw/docs/{(docs)/guides → guides}/quoting.mdx +10 -17
  80. package/.docs/raw/docs/{(docs)/guides → guides}/slash-commands.mdx +103 -37
  81. package/.docs/raw/docs/guides/speech.mdx +156 -0
  82. package/.docs/raw/docs/{(docs)/guides → guides}/suggestions.mdx +21 -83
  83. package/.docs/raw/docs/{(docs)/guides → guides}/tool-ui.mdx +108 -36
  84. package/.docs/raw/docs/{(docs)/guides → guides}/tools.mdx +131 -35
  85. package/.docs/raw/docs/{(docs)/guides → guides}/voice.mdx +39 -0
  86. package/.docs/raw/docs/ink/index.mdx +1 -3
  87. package/.docs/raw/docs/ink/migration.mdx +1 -3
  88. package/.docs/raw/docs/ink/primitives.mdx +37 -1
  89. package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +520 -0
  90. package/.docs/raw/docs/integrations/auth/better-auth.mdx +191 -0
  91. package/.docs/raw/docs/integrations/auth/clerk.mdx +172 -0
  92. package/.docs/raw/docs/integrations/auth/next-auth.mdx +196 -0
  93. package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +79 -0
  94. package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +188 -0
  95. package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +57 -0
  96. package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +201 -0
  97. package/.docs/raw/docs/integrations/gateways/index.mdx +157 -0
  98. package/.docs/raw/docs/integrations/index.mdx +173 -0
  99. package/.docs/raw/docs/integrations/observability/helicone.mdx +130 -0
  100. package/.docs/raw/docs/integrations/observability/langfuse.mdx +156 -0
  101. package/.docs/raw/docs/integrations/observability/langsmith.mdx +146 -0
  102. package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +712 -0
  103. package/.docs/raw/docs/integrations/tools/mcp.mdx +267 -0
  104. package/.docs/raw/docs/primitives/action-bar.mdx +1 -0
  105. package/.docs/raw/docs/primitives/assistant-modal.mdx +1 -0
  106. package/.docs/raw/docs/primitives/attachment.mdx +1 -0
  107. package/.docs/raw/docs/primitives/branch-picker.mdx +1 -0
  108. package/.docs/raw/docs/primitives/chain-of-thought.mdx +90 -85
  109. package/.docs/raw/docs/primitives/composer.mdx +2 -1
  110. package/.docs/raw/docs/primitives/error.mdx +1 -0
  111. package/.docs/raw/docs/primitives/index.mdx +2 -1
  112. package/.docs/raw/docs/primitives/message.mdx +68 -5
  113. package/.docs/raw/docs/primitives/selection-toolbar.mdx +1 -0
  114. package/.docs/raw/docs/primitives/suggestion.mdx +1 -0
  115. package/.docs/raw/docs/primitives/thread-list.mdx +39 -0
  116. package/.docs/raw/docs/primitives/thread.mdx +16 -13
  117. package/.docs/raw/docs/react-native/index.mdx +1 -3
  118. package/.docs/raw/docs/react-native/migration.mdx +1 -3
  119. package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +396 -0
  120. package/.docs/raw/docs/runtimes/a2a/overview.mdx +60 -0
  121. package/.docs/raw/docs/runtimes/a2a/quickstart.mdx +216 -0
  122. package/.docs/raw/docs/runtimes/ag-ui/overview.mdx +70 -0
  123. package/.docs/raw/docs/runtimes/ag-ui/quickstart.mdx +243 -0
  124. package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +123 -0
  125. package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +52 -0
  126. package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +71 -131
  127. package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +69 -63
  128. package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +330 -123
  129. package/.docs/raw/docs/runtimes/concepts/adapters.mdx +265 -0
  130. package/.docs/raw/docs/runtimes/concepts/architecture.mdx +125 -0
  131. package/.docs/raw/docs/runtimes/concepts/stability.mdx +67 -0
  132. package/.docs/raw/docs/runtimes/concepts/threads.mdx +428 -0
  133. package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +703 -0
  134. package/.docs/raw/docs/runtimes/custom/data-stream.mdx +323 -0
  135. package/.docs/raw/docs/runtimes/custom/external-store.mdx +253 -1236
  136. package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +746 -0
  137. package/.docs/raw/docs/runtimes/custom/overview.mdx +71 -0
  138. package/.docs/raw/docs/runtimes/google-adk/api.mdx +256 -0
  139. package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +717 -0
  140. package/.docs/raw/docs/runtimes/google-adk/overview.mdx +69 -0
  141. package/.docs/raw/docs/runtimes/google-adk/quickstart.mdx +229 -0
  142. package/.docs/raw/docs/runtimes/langchain.mdx +533 -0
  143. package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +305 -0
  144. package/.docs/raw/docs/runtimes/langgraph/interrupts.mdx +104 -0
  145. package/.docs/raw/docs/runtimes/langgraph/overview.mdx +84 -0
  146. package/.docs/raw/docs/runtimes/langgraph/quickstart.mdx +496 -0
  147. package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +127 -0
  148. package/.docs/raw/docs/runtimes/langgraph/threads.mdx +113 -0
  149. package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +3 -3
  150. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +0 -23
  151. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +1 -1
  152. package/.docs/raw/docs/runtimes/opencode/hooks.mdx +191 -0
  153. package/.docs/raw/docs/runtimes/opencode/overview.mdx +48 -0
  154. package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +119 -0
  155. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +71 -203
  156. package/.docs/raw/docs/ui/accordion.mdx +1 -0
  157. package/.docs/raw/docs/ui/assistant-modal.mdx +1 -0
  158. package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -0
  159. package/.docs/raw/docs/ui/attachment.mdx +1 -0
  160. package/.docs/raw/docs/ui/badge.mdx +1 -0
  161. package/.docs/raw/docs/ui/composer-trigger-popover.mdx +1 -0
  162. package/.docs/raw/docs/ui/context-display.mdx +1 -0
  163. package/.docs/raw/docs/ui/diff-viewer.mdx +1 -0
  164. package/.docs/raw/docs/ui/directive-text.mdx +1 -0
  165. package/.docs/raw/docs/ui/file.mdx +1 -0
  166. package/.docs/raw/docs/ui/image.mdx +1 -0
  167. package/.docs/raw/docs/ui/markdown.mdx +2 -14
  168. package/.docs/raw/docs/ui/mermaid.mdx +1 -0
  169. package/.docs/raw/docs/ui/message-timing.mdx +3 -2
  170. package/.docs/raw/docs/ui/model-selector.mdx +1 -0
  171. package/.docs/raw/docs/ui/part-grouping.mdx +325 -313
  172. package/.docs/raw/docs/ui/quote.mdx +1 -0
  173. package/.docs/raw/docs/ui/reasoning.mdx +66 -33
  174. package/.docs/raw/docs/ui/scrollbar.mdx +1 -0
  175. package/.docs/raw/docs/ui/select.mdx +1 -0
  176. package/.docs/raw/docs/ui/sources.mdx +1 -0
  177. package/.docs/raw/docs/ui/streamdown.mdx +1 -0
  178. package/.docs/raw/docs/ui/syntax-highlighting.mdx +1 -0
  179. package/.docs/raw/docs/ui/tabs.mdx +1 -0
  180. package/.docs/raw/docs/ui/thread-list.mdx +17 -0
  181. package/.docs/raw/docs/ui/thread.mdx +56 -1
  182. package/.docs/raw/docs/ui/tool-fallback.mdx +1 -0
  183. package/.docs/raw/docs/ui/tool-group.mdx +39 -11
  184. package/.docs/raw/docs/ui/voice.mdx +1 -0
  185. package/.docs/raw/docs/utilities/heat-graph.mdx +1 -0
  186. package/.docs/raw/docs/utilities/react-o11y.mdx +278 -0
  187. package/.docs/raw/docs/utilities/tw-shimmer.mdx +1 -0
  188. package/package.json +3 -3
  189. package/src/tools/tests/path-traversal.test.ts +1 -1
  190. package/.docs/raw/docs/(docs)/guides/branching.mdx +0 -65
  191. package/.docs/raw/docs/(docs)/guides/chain-of-thought.mdx +0 -164
  192. package/.docs/raw/docs/(docs)/guides/editing.mdx +0 -66
  193. package/.docs/raw/docs/(docs)/guides/speech.mdx +0 -38
  194. package/.docs/raw/docs/runtimes/a2a/index.mdx +0 -298
  195. package/.docs/raw/docs/runtimes/assistant-transport.mdx +0 -1033
  196. package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +0 -314
  197. package/.docs/raw/docs/runtimes/custom/local.mdx +0 -1464
  198. package/.docs/raw/docs/runtimes/data-stream.mdx +0 -422
  199. package/.docs/raw/docs/runtimes/google-adk/index.mdx +0 -686
  200. package/.docs/raw/docs/runtimes/helicone.mdx +0 -61
  201. package/.docs/raw/docs/runtimes/langchain/comparison.mdx +0 -60
  202. package/.docs/raw/docs/runtimes/langchain/index.mdx +0 -210
  203. package/.docs/raw/docs/runtimes/langgraph/index.mdx +0 -699
  204. package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +0 -12
  205. package/.docs/raw/docs/runtimes/langserve.mdx +0 -116
  206. package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +0 -218
  207. package/.docs/raw/docs/runtimes/mastra/overview.mdx +0 -18
  208. package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +0 -217
@@ -1,686 +0,0 @@
1
- ---
2
- title: Google ADK
3
- description: Connect to Google ADK (Agent Development Kit) agents with streaming, tool calls, and multi-agent support.
4
- ---
5
-
6
- The `@assistant-ui/react-google-adk` package provides integration with [Google ADK JS](https://github.com/google/adk-js), Google's official agent framework for TypeScript. It supports streaming text, tool calls, multi-agent orchestration, code execution, session state, tool confirmations, auth flows, and more.
7
-
8
- ## Requirements
9
-
10
- You need a Google ADK agent running on a server. ADK supports `LlmAgent` with Gemini models, tool use, multi-agent orchestration (sequential, parallel, loop agents), and session management.
11
-
12
- ## Installation
13
-
14
- <InstallCommand npm={["@assistant-ui/react", "@assistant-ui/react-google-adk", "@google/adk"]} />
15
-
16
- <Callout type="info">
17
- `@google/adk` is only needed on the server side. The client-side runtime has no dependency on it.
18
- </Callout>
19
-
20
- ## Getting Started
21
-
22
- <Steps>
23
- <Step>
24
-
25
- ### Create a backend API endpoint
26
-
27
- Use `createAdkApiRoute` to create an API route in one line:
28
-
29
- ```typescript title="app/api/chat/route.ts"
30
- import { createAdkApiRoute } from "@assistant-ui/react-google-adk/server";
31
- import { InMemoryRunner, LlmAgent } from "@google/adk";
32
-
33
- const agent = new LlmAgent({
34
- name: "my_agent",
35
- model: "gemini-2.5-flash",
36
- instruction: "You are a helpful assistant.",
37
- });
38
-
39
- const runner = new InMemoryRunner({ agent, appName: "my-app" });
40
-
41
- export const POST = createAdkApiRoute({
42
- runner,
43
- userId: "user_1",
44
- sessionId: (req) =>
45
- new URL(req.url).searchParams.get("sessionId") ?? "default",
46
- });
47
- ```
48
-
49
- </Step>
50
- <Step>
51
-
52
- ### Set up the client runtime
53
-
54
- Use `createAdkStream` to connect to your API route — no manual SSE parsing needed:
55
-
56
- ```tsx title="components/MyAssistant.tsx"
57
- "use client";
58
-
59
- import { AssistantRuntimeProvider } from "@assistant-ui/react";
60
- import {
61
- useAdkRuntime,
62
- createAdkStream,
63
- } from "@assistant-ui/react-google-adk";
64
- import { Thread } from "@/components/assistant-ui/thread";
65
-
66
- export function MyAssistant() {
67
- const runtime = useAdkRuntime({
68
- stream: createAdkStream({ api: "/api/chat" }),
69
- });
70
-
71
- return (
72
- <AssistantRuntimeProvider runtime={runtime}>
73
- <Thread />
74
- </AssistantRuntimeProvider>
75
- );
76
- }
77
- ```
78
-
79
- </Step>
80
- <Step>
81
-
82
- ### Use the component
83
-
84
- ```tsx title="app/page.tsx"
85
- import { MyAssistant } from "@/components/MyAssistant";
86
-
87
- export default function Home() {
88
- return (
89
- <main className="h-dvh">
90
- <MyAssistant />
91
- </main>
92
- );
93
- }
94
- ```
95
-
96
- </Step>
97
- <Step>
98
-
99
- ### Setup UI components
100
-
101
- Follow the [UI Components](/docs/ui/thread) guide to setup the Thread and other UI components.
102
-
103
- </Step>
104
- </Steps>
105
-
106
- ## `createAdkStream`
107
-
108
- Creates an `AdkStreamCallback` that connects to an ADK endpoint via SSE. Supports two modes:
109
-
110
- **Proxy mode** — POST to your own API route:
111
-
112
- ```typescript
113
- import { createAdkStream } from "@assistant-ui/react-google-adk";
114
-
115
- const stream = createAdkStream({ api: "/api/chat" });
116
- ```
117
-
118
- **Direct mode** — connect directly to an ADK server:
119
-
120
- ```typescript
121
- const stream = createAdkStream({
122
- api: "http://localhost:8000",
123
- appName: "my-app",
124
- userId: "user-1",
125
- });
126
- ```
127
-
128
- | Option | Type | Description |
129
- |--------|------|-------------|
130
- | `api` | `string` | URL to POST to (proxy route or ADK server base URL) |
131
- | `appName` | `string?` | ADK app name (enables direct mode when set) |
132
- | `userId` | `string?` | ADK user ID (required with `appName`) |
133
- | `headers` | `Record<string, string> \| (() => ...)` | Static or dynamic request headers |
134
-
135
- ## Direct ADK Server Connection
136
-
137
- When connecting directly to an ADK server (without a proxy API route), use `createAdkSessionAdapter` to back your thread list with ADK sessions:
138
-
139
- ```tsx
140
- import {
141
- useAdkRuntime,
142
- createAdkStream,
143
- createAdkSessionAdapter,
144
- } from "@assistant-ui/react-google-adk";
145
-
146
- const ADK_URL = "http://localhost:8000";
147
-
148
- const { adapter, load, artifacts } = createAdkSessionAdapter({
149
- apiUrl: ADK_URL,
150
- appName: "my-app",
151
- userId: "user-1",
152
- });
153
-
154
- const runtime = useAdkRuntime({
155
- stream: createAdkStream({
156
- api: ADK_URL,
157
- appName: "my-app",
158
- userId: "user-1",
159
- }),
160
- sessionAdapter: adapter,
161
- load,
162
- });
163
- ```
164
-
165
- The session adapter maps ADK sessions to assistant-ui threads:
166
-
167
- - **`adapter`** — a `RemoteThreadListAdapter` that uses ADK's session REST API for thread CRUD
168
- - **`load`** — reconstructs messages from session events via `AdkEventAccumulator`
169
- - **`artifacts`** — functions to fetch, list, and delete session artifacts (see [Artifact Fetching](#artifact-fetching))
170
-
171
- | Option | Type | Description |
172
- |--------|------|-------------|
173
- | `apiUrl` | `string` | ADK server base URL |
174
- | `appName` | `string` | ADK app name |
175
- | `userId` | `string` | ADK user ID |
176
- | `headers` | `Record<string, string> \| (() => ...)` | Static or dynamic request headers |
177
-
178
- ## Server Helpers
179
-
180
- ### `createAdkApiRoute`
181
-
182
- One-liner API route handler that combines request parsing and SSE streaming:
183
-
184
- ```typescript
185
- import { createAdkApiRoute } from "@assistant-ui/react-google-adk/server";
186
-
187
- export const POST = createAdkApiRoute({
188
- runner,
189
- userId: "default-user",
190
- sessionId: (req) =>
191
- new URL(req.url).searchParams.get("sessionId") ?? "default",
192
- });
193
- ```
194
-
195
- Both `userId` and `sessionId` accept a static string or a function `(req: Request) => string` for dynamic resolution (e.g. from cookies, headers, or query params).
196
-
197
- ### `adkEventStream`
198
-
199
- Converts an `AsyncGenerator<Event>` from ADK's `Runner.runAsync()` into an SSE `Response`. Sends an initial `:ok` comment to keep connections alive through proxies.
200
-
201
- ```typescript
202
- import { adkEventStream } from "@assistant-ui/react-google-adk/server";
203
-
204
- const events = runner.runAsync({ userId, sessionId, newMessage });
205
- return adkEventStream(events);
206
- ```
207
-
208
- ### `parseAdkRequest` / `toAdkContent`
209
-
210
- Lower-level helpers for custom API routes. Parse incoming requests and convert to ADK's `Content` format. Supports user messages, tool results, `stateDelta`, `checkpointId`, and multimodal content:
211
-
212
- ```typescript
213
- import { parseAdkRequest, toAdkContent } from "@assistant-ui/react-google-adk/server";
214
-
215
- const parsed = await parseAdkRequest(req);
216
- // parsed.type is "message" or "tool-result"
217
- // parsed.config contains runConfig, checkpointId
218
- // parsed.stateDelta contains session state changes
219
-
220
- const newMessage = toAdkContent(parsed);
221
- const events = runner.runAsync({
222
- userId,
223
- sessionId,
224
- newMessage,
225
- stateDelta: parsed.stateDelta,
226
- });
227
- return adkEventStream(events);
228
- ```
229
-
230
- ## Hooks
231
-
232
- ### Agent & Session State
233
-
234
- ```typescript
235
- import {
236
- useAdkAgentInfo,
237
- useAdkSessionState,
238
- useAdkSend,
239
- } from "@assistant-ui/react-google-adk";
240
-
241
- function MyComponent() {
242
- // Current active agent name and branch path (multi-agent)
243
- const agentInfo = useAdkAgentInfo();
244
- // agentInfo?.name = "search_agent"
245
- // agentInfo?.branch = "root.search_agent"
246
-
247
- // Accumulated session state delta
248
- const state = useAdkSessionState();
249
-
250
- // Send raw ADK messages programmatically
251
- const send = useAdkSend();
252
- }
253
- ```
254
-
255
- ### Tool Confirmations
256
-
257
- When ADK's `SecurityPlugin` or tool callbacks request user confirmation before executing a tool, use `useAdkToolConfirmations` to read pending requests and `useAdkConfirmTool` to respond:
258
-
259
- ```typescript
260
- import {
261
- useAdkToolConfirmations,
262
- useAdkConfirmTool,
263
- } from "@assistant-ui/react-google-adk";
264
-
265
- function ToolConfirmationUI() {
266
- const confirmations = useAdkToolConfirmations();
267
- const confirmTool = useAdkConfirmTool();
268
-
269
- if (confirmations.length === 0) return null;
270
-
271
- return confirmations.map((conf) => (
272
- <div key={conf.toolCallId}>
273
- <p>Tool "{conf.toolName}" wants to run. {conf.hint}</p>
274
- <button onClick={() => confirmTool(conf.toolCallId, true)}>
275
- Approve
276
- </button>
277
- <button onClick={() => confirmTool(conf.toolCallId, false)}>
278
- Deny
279
- </button>
280
- </div>
281
- ));
282
- }
283
- ```
284
-
285
- ### Auth Requests
286
-
287
- When a tool requires OAuth or other authentication, use `useAdkAuthRequests` to read pending requests and `useAdkSubmitAuth` to submit credentials:
288
-
289
- ```typescript
290
- import {
291
- useAdkAuthRequests,
292
- useAdkSubmitAuth,
293
- type AdkAuthCredential,
294
- } from "@assistant-ui/react-google-adk";
295
-
296
- function AuthUI() {
297
- const authRequests = useAdkAuthRequests();
298
- const submitAuth = useAdkSubmitAuth();
299
-
300
- if (authRequests.length === 0) return null;
301
-
302
- return authRequests.map((req) => (
303
- <div key={req.toolCallId}>
304
- <button onClick={() => {
305
- const credential: AdkAuthCredential = {
306
- authType: "oauth2",
307
- oauth2: { accessToken: "..." },
308
- };
309
- submitAuth(req.toolCallId, credential);
310
- }}>
311
- Authenticate
312
- </button>
313
- </div>
314
- ));
315
- }
316
- ```
317
-
318
- `AdkAuthCredential` supports all ADK auth types: `apiKey`, `http`, `oauth2`, `openIdConnect`, `serviceAccount`.
319
-
320
- ### Input Requests
321
-
322
- When an ADK Python 2.0+ Workflow's `RequestInput` node pauses execution to ask the user a question, ADK emits an `adk_request_input` function call marked as long-running. Respond with `useAdkSubmitInput` inside a tool UI — the helper wraps the answer as `{ result }` to match ADK's `unwrap_response` contract, so the Workflow node resumes with the unwrapped value:
323
-
324
- ```tsx
325
- import { makeAssistantToolUI } from "@assistant-ui/react";
326
- import { useAdkSubmitInput } from "@assistant-ui/react-google-adk";
327
-
328
- type RequestInputArgs = {
329
- interrupt_id?: string;
330
- message?: string;
331
- payload?: unknown;
332
- response_schema?: unknown;
333
- };
334
-
335
- export const RequestInputToolUI = makeAssistantToolUI<RequestInputArgs, unknown>({
336
- toolName: "adk_request_input",
337
- render: function RequestInputUI({ toolCallId, args, result }) {
338
- const submitInput = useAdkSubmitInput();
339
-
340
- if (result !== undefined) {
341
- return <p>Answered: {String(result)}</p>;
342
- }
343
-
344
- return (
345
- <form
346
- onSubmit={(e) => {
347
- e.preventDefault();
348
- const value = (
349
- e.currentTarget.elements.namedItem("answer") as HTMLInputElement
350
- ).value;
351
- submitInput(toolCallId, value);
352
- }}
353
- >
354
- <p>{args.message ?? "Please provide input:"}</p>
355
- <input name="answer" autoFocus />
356
- <button type="submit">Submit</button>
357
- </form>
358
- );
359
- },
360
- });
361
- ```
362
-
363
- Register the tool UI inside `AssistantRuntimeProvider`:
364
-
365
- ```tsx
366
- <AssistantRuntimeProvider runtime={runtime}>
367
- <RequestInputToolUI />
368
- <Thread />
369
- </AssistantRuntimeProvider>
370
- ```
371
-
372
- <Callout type="info">
373
- `adk_request_input` is emitted only by ADK Python 2.0+ Workflow `RequestInput` nodes — ADK JS has no equivalent. Always respond via a tool UI with `useAdkSubmitInput`; HITL interrupts are automatically exempt from `autoCancelPendingToolCalls`, so typing a normal message in the composer will not overwrite the pending interrupt.
374
- </Callout>
375
-
376
- `useAdkSubmitInput` is sugar over the generic `addResult` — if you prefer, you can call `addResult({ result: value })` from inside the render function directly. The `{ result }` wrapper is required either way: the adapter JSON-stringifies the value before sending, and ADK's `unwrap_response` unwraps it on the backend before the Workflow node resumes.
377
-
378
- ### Artifacts
379
-
380
- Track file artifacts created or modified by the agent:
381
-
382
- ```typescript
383
- import { useAdkArtifacts } from "@assistant-ui/react-google-adk";
384
-
385
- function ArtifactList() {
386
- const artifacts = useAdkArtifacts();
387
- // Record<string, number> — filename to version number
388
- }
389
- ```
390
-
391
- #### Artifact Fetching
392
-
393
- When using `createAdkSessionAdapter`, the returned `artifacts` object provides functions to fetch artifact content from the ADK server:
394
-
395
- ```typescript
396
- const { artifacts } = createAdkSessionAdapter({ apiUrl, appName, userId });
397
-
398
- // List all artifact filenames in a session
399
- const filenames = await artifacts.list(sessionId);
400
-
401
- // Load artifact content (latest version)
402
- const data = await artifacts.load(sessionId, "document.pdf");
403
- // data.inlineData?.data — base64 content
404
- // data.inlineData?.mimeType — MIME type
405
- // data.text — text content (if text artifact)
406
-
407
- // Load a specific version
408
- const v1 = await artifacts.load(sessionId, "document.pdf", 1);
409
-
410
- // List all versions
411
- const versions = await artifacts.listVersions(sessionId, "document.pdf");
412
-
413
- // Delete an artifact
414
- await artifacts.delete(sessionId, "document.pdf");
415
- ```
416
-
417
- ### Escalation
418
-
419
- Detect when an agent requests escalation to a human operator:
420
-
421
- ```typescript
422
- import { useAdkEscalation } from "@assistant-ui/react-google-adk";
423
-
424
- function EscalationBanner() {
425
- const escalated = useAdkEscalation();
426
- if (!escalated) return null;
427
- return <div>Agent has requested human assistance.</div>;
428
- }
429
- ```
430
-
431
- ### Long-Running Tools
432
-
433
- Track tools that are executing asynchronously and awaiting external input:
434
-
435
- ```typescript
436
- import { useAdkLongRunningToolIds } from "@assistant-ui/react-google-adk";
437
-
438
- function PendingToolsIndicator() {
439
- const pendingToolIds = useAdkLongRunningToolIds();
440
- if (pendingToolIds.length === 0) return null;
441
- return <div>{pendingToolIds.length} tool(s) awaiting input</div>;
442
- }
443
- ```
444
-
445
- This hook reports every tool call ADK marked via `long_running_tool_ids`, including HITL interrupts. To respond to a specific HITL type, see [Tool Confirmations](#tool-confirmations), [Auth Requests](#auth-requests), or [Input Requests](#input-requests).
446
-
447
- ### Per-Message Metadata
448
-
449
- Access grounding, citation, and token usage metadata per message:
450
-
451
- ```typescript
452
- import { useAdkMessageMetadata } from "@assistant-ui/react-google-adk";
453
-
454
- function MessageMetadata({ messageId }: { messageId: string }) {
455
- const metadataMap = useAdkMessageMetadata();
456
- const meta = metadataMap.get(messageId);
457
- // meta?.groundingMetadata — Google Search grounding sources
458
- // meta?.citationMetadata — citation references
459
- // meta?.usageMetadata — token counts
460
- }
461
- ```
462
-
463
- ### Session State by Scope
464
-
465
- ADK uses key prefixes to scope state. These helpers filter and strip the prefix:
466
-
467
- ```typescript
468
- import {
469
- useAdkAppState,
470
- useAdkUserState,
471
- useAdkTempState,
472
- } from "@assistant-ui/react-google-adk";
473
-
474
- function StateDebug() {
475
- const appState = useAdkAppState(); // app:* keys (app-level, shared)
476
- const userState = useAdkUserState(); // user:* keys (user-level)
477
- const tempState = useAdkTempState(); // temp:* keys (not persisted)
478
- }
479
- ```
480
-
481
- Use `useAdkSessionState()` for the full unfiltered state delta.
482
-
483
- ## Structured Events
484
-
485
- Convert raw ADK events into typed, structured events for custom renderers:
486
-
487
- ```typescript
488
- import {
489
- toAdkStructuredEvents,
490
- AdkEventType,
491
- type AdkStructuredEvent,
492
- } from "@assistant-ui/react-google-adk";
493
-
494
- const structured = toAdkStructuredEvents(event);
495
- for (const e of structured) {
496
- switch (e.type) {
497
- case AdkEventType.CONTENT:
498
- console.log("Text:", e.content);
499
- break;
500
- case AdkEventType.THOUGHT:
501
- console.log("Reasoning:", e.content);
502
- break;
503
- case AdkEventType.TOOL_CALL:
504
- console.log("Tool:", e.call.name, e.call.args);
505
- break;
506
- case AdkEventType.ERROR:
507
- console.error(e.errorMessage);
508
- break;
509
- }
510
- }
511
- ```
512
-
513
- ## State Delta
514
-
515
- Send session state mutations along with messages using `stateDelta`:
516
-
517
- ```typescript
518
- const send = useAdkSend();
519
-
520
- // Pre-populate session state before the agent runs
521
- send(
522
- [{ id: "1", type: "human", content: "Start task" }],
523
- { stateDelta: { taskId: "abc", mode: "verbose" } },
524
- );
525
- ```
526
-
527
- This maps to ADK's `stateDelta` parameter on `/run_sse`.
528
-
529
- ## RunConfig
530
-
531
- Pass `AdkRunConfig` to control agent behavior:
532
-
533
- ```typescript
534
- const send = useAdkSend();
535
-
536
- send(messages, {
537
- runConfig: {
538
- streamingMode: "sse",
539
- maxLlmCalls: 10,
540
- pauseOnToolCalls: true, // pause for client-side tool execution
541
- },
542
- });
543
- ```
544
-
545
- ## Event Handlers
546
-
547
- Listen to streaming events:
548
-
549
- ```typescript
550
- const runtime = useAdkRuntime({
551
- stream: createAdkStream({ api: "/api/chat" }),
552
- eventHandlers: {
553
- onError: (error) => {
554
- console.error("Stream error:", error);
555
- },
556
- onAgentTransfer: (toAgent) => {
557
- console.log("Agent transferred to:", toAgent);
558
- },
559
- onCustomEvent: (key, value) => {
560
- // Fired for each entry in event.customMetadata
561
- console.log("Custom metadata:", key, value);
562
- },
563
- },
564
- });
565
- ```
566
-
567
- ## Thread Management
568
-
569
- ### ADK Session Adapter
570
-
571
- Use `createAdkSessionAdapter` to persist threads via ADK's session API (see [Direct ADK Server Connection](#direct-adk-server-connection) above).
572
-
573
- ### Custom Thread Management
574
-
575
- ```typescript
576
- const runtime = useAdkRuntime({
577
- stream: createAdkStream({ api: "/api/chat" }),
578
- create: async () => {
579
- const sessionId = await createSession();
580
- return { externalId: sessionId };
581
- },
582
- load: async (externalId) => {
583
- const history = await loadSession(externalId);
584
- return { messages: history };
585
- },
586
- delete: async (externalId) => {
587
- await deleteSession(externalId);
588
- },
589
- });
590
- ```
591
-
592
- ### Cloud Persistence
593
-
594
- For persistent thread history via assistant-cloud:
595
-
596
- ```typescript
597
- import { AssistantCloud } from "assistant-cloud";
598
-
599
- const runtime = useAdkRuntime({
600
- cloud: new AssistantCloud({
601
- baseUrl: process.env.NEXT_PUBLIC_ASSISTANT_BASE_URL,
602
- anonymous: true,
603
- }),
604
- stream: createAdkStream({ api: "/api/chat" }),
605
- });
606
- ```
607
-
608
- ## Message Editing & Regeneration
609
-
610
- Provide a `getCheckpointId` callback to enable edit and regenerate buttons:
611
-
612
- ```typescript
613
- const runtime = useAdkRuntime({
614
- stream: createAdkStream({ api: "/api/chat" }),
615
- getCheckpointId: async (threadId, parentMessages) => {
616
- // Resolve checkpoint ID for server-side forking
617
- return checkpointId;
618
- },
619
- });
620
- ```
621
-
622
- When `getCheckpointId` is provided:
623
- - **Edit buttons** appear on user messages
624
- - **Regenerate buttons** appear on assistant messages
625
-
626
- The resolved `checkpointId` is passed to your `stream` callback via `config.checkpointId`.
627
-
628
- <Callout type="info">
629
- Without `getCheckpointId`, edit and regenerate buttons will not appear.
630
- </Callout>
631
-
632
- ## Hooks Reference
633
-
634
- | Hook | Description |
635
- |------|-------------|
636
- | `useAdkAgentInfo()` | Current agent name and branch path |
637
- | `useAdkSessionState()` | Full accumulated session state delta |
638
- | `useAdkAppState()` | App-level state (`app:*` prefix, stripped) |
639
- | `useAdkUserState()` | User-level state (`user:*` prefix, stripped) |
640
- | `useAdkTempState()` | Temp state (`temp:*` prefix, stripped, not persisted) |
641
- | `useAdkSend()` | Send raw ADK messages |
642
- | `useAdkConfirmTool()` | Confirm or deny a pending tool confirmation |
643
- | `useAdkSubmitAuth()` | Submit auth credentials for a pending auth request |
644
- | `useAdkSubmitInput()` | Submit the user's answer for a pending `adk_request_input` HITL interrupt |
645
- | `useAdkToolConfirmations()` | Pending tool confirmation requests |
646
- | `useAdkAuthRequests()` | Pending auth credential requests |
647
- | `useAdkLongRunningToolIds()` | IDs of long-running tools awaiting input |
648
- | `useAdkArtifacts()` | Artifact delta (filename → version) |
649
- | `useAdkEscalation()` | Whether escalation was requested |
650
- | `useAdkMessageMetadata()` | Per-message grounding/citation/usage metadata |
651
-
652
- ## Features
653
-
654
- | Feature | Status |
655
- |---|---|
656
- | Streaming text (SSE) | Supported |
657
- | Tool calls & results | Supported |
658
- | Tool confirmations (`useAdkConfirmTool`) | Supported |
659
- | Auth credential flow (`useAdkSubmitAuth`) | Supported |
660
- | Workflow input requests (`useAdkSubmitInput`, ADK Python 2.0+) | Supported |
661
- | Multi-agent (author/branch tracking) | Supported |
662
- | Agent transfer events | Supported |
663
- | Escalation detection | Supported |
664
- | Chain-of-thought / reasoning | Supported |
665
- | Code execution (executableCode + result) | Supported |
666
- | Inline images & file data | Supported |
667
- | Session state delta + scoped state | Supported |
668
- | Artifact delta tracking + fetching | Supported |
669
- | Long-running tools (HITL) | Supported |
670
- | Grounding / citation / usage metadata | Supported |
671
- | Structured events (`toAdkStructuredEvents`) | Supported |
672
- | Typed `AdkRunConfig` | Supported |
673
- | Client → server `stateDelta` | Supported |
674
- | `finishReason` mapping (17 values) | Supported |
675
- | `interrupted` event handling | Supported |
676
- | Snake\_case events (Python ADK) | Supported |
677
- | Cloud thread persistence | Supported |
678
- | ADK session-backed thread persistence | Supported |
679
- | Direct ADK server connection (no proxy) | Supported |
680
- | One-liner API route (`createAdkApiRoute`) | Supported |
681
- | Message editing & regeneration | Supported |
682
- | Automatic tool invocations | Supported |
683
-
684
- ### ADK Python Backend
685
-
686
- The package automatically normalizes snake\_case event fields from ADK Python backends to camelCase. No configuration needed — connect to either ADK JS or ADK Python servers. This includes all nested fields: `function_call` → `functionCall`, `requested_tool_confirmations` → `requestedToolConfirmations`, etc.