@assistant-ui/mcp-docs-server 0.1.34 → 0.1.36
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 +4 -4
- package/.docs/organized/code-examples/with-a2a.md +5 -5
- package/.docs/organized/code-examples/with-ag-ui.md +6 -6
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +7 -7
- package/.docs/organized/code-examples/with-artifacts.md +7 -7
- package/.docs/organized/code-examples/with-assistant-transport.md +73 -57
- package/.docs/organized/code-examples/with-browser-extension.md +7 -7
- package/.docs/organized/code-examples/with-chain-of-thought.md +44 -93
- package/.docs/organized/code-examples/with-cloud-standalone.md +7 -7
- package/.docs/organized/code-examples/with-cloud.md +7 -7
- package/.docs/organized/code-examples/with-custom-thread-list.md +7 -7
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +9 -9
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +9 -9
- package/.docs/organized/code-examples/with-eve.md +343 -0
- package/.docs/organized/code-examples/with-expo.md +943 -940
- package/.docs/organized/code-examples/with-external-store.md +5 -5
- package/.docs/organized/code-examples/with-ffmpeg.md +8 -11
- package/.docs/organized/code-examples/with-generative-ui.md +33 -309
- package/.docs/organized/code-examples/with-google-adk.md +5 -5
- package/.docs/organized/code-examples/with-heat-graph.md +4 -4
- package/.docs/organized/code-examples/with-image-generation.md +7 -7
- package/.docs/organized/code-examples/with-interactables.md +169 -341
- package/.docs/organized/code-examples/with-langchain.md +7 -7
- package/.docs/organized/code-examples/with-langgraph.md +23 -160
- package/.docs/organized/code-examples/with-livekit.md +10 -10
- package/.docs/organized/code-examples/with-mcp.md +7 -7
- package/.docs/organized/code-examples/with-opencode.md +106 -580
- package/.docs/organized/code-examples/with-pi.md +2046 -0
- package/.docs/organized/code-examples/with-react-hook-form.md +16 -9
- package/.docs/organized/code-examples/with-react-ink-web.md +691 -0
- package/.docs/organized/code-examples/with-react-ink.md +29 -17
- package/.docs/organized/code-examples/with-react-router.md +12 -12
- package/.docs/organized/code-examples/with-resumable-stream.md +8 -8
- package/.docs/organized/code-examples/with-store.md +14 -10
- package/.docs/organized/code-examples/with-tanstack.md +21 -7
- package/.docs/organized/code-examples/with-tap-runtime.md +5 -5
- package/.docs/organized/code-examples/with-virtualized-thread.md +676 -0
- package/.docs/raw/docs/(docs)/architecture.mdx +13 -12
- package/.docs/raw/docs/(docs)/cli.mdx +4 -2
- package/.docs/raw/docs/(docs)/devtools.mdx +25 -2
- package/.docs/raw/docs/(docs)/index.mdx +5 -2
- package/.docs/raw/docs/(docs)/installation.mdx +5 -2
- package/.docs/raw/docs/(reference)/api-reference/external-store/message-conversion.mdx +16 -16
- package/.docs/raw/docs/(reference)/api-reference/hooks/composer-triggers.mdx +73 -42
- package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +3 -20
- package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +234 -123
- package/.docs/raw/docs/(reference)/api-reference/integrations/eve.mdx +51 -0
- package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +4 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +70 -38
- package/.docs/raw/docs/(reference)/api-reference/model-context/context.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +30 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +7 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +26 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/chain-of-thought.mdx +15 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +103 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +16 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +56 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/queue-item.mdx +12 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/selection-toolbar.mdx +12 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +14 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +57 -1
- package/.docs/raw/docs/(reference)/api-reference/tools/index.mdx +6 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/interactables-legacy.mdx +55 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/interactables.mdx +151 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/rendering.mdx +17 -38
- package/.docs/raw/docs/(reference)/api-reference/tools/status.mdx +22 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/toolkits.mdx +20 -27
- package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +40 -25
- package/.docs/raw/docs/guides/chain-of-thought.mdx +1 -1
- package/.docs/raw/docs/guides/headless-composer-input.mdx +113 -0
- package/.docs/raw/docs/guides/index.mdx +3 -0
- package/.docs/raw/docs/guides/input-history.mdx +55 -0
- package/.docs/raw/docs/guides/latex.mdx +28 -22
- package/.docs/raw/docs/guides/mentions.mdx +32 -7
- package/.docs/raw/docs/guides/slash-commands.mdx +3 -6
- package/.docs/raw/docs/guides/speech.mdx +5 -7
- package/.docs/raw/docs/guides/virtualization.mdx +133 -0
- package/.docs/raw/docs/guides/voice.mdx +3 -2
- package/.docs/raw/docs/ink/hooks.mdx +2 -2
- package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +4 -12
- package/.docs/raw/docs/integrations/auth/better-auth.mdx +7 -10
- package/.docs/raw/docs/integrations/auth/clerk.mdx +3 -9
- package/.docs/raw/docs/integrations/auth/next-auth.mdx +3 -8
- package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +8 -5
- package/.docs/raw/docs/integrations/index.mdx +5 -12
- package/.docs/raw/docs/integrations/observability/helicone.mdx +3 -4
- package/.docs/raw/docs/integrations/observability/langfuse.mdx +3 -5
- package/.docs/raw/docs/integrations/observability/langsmith.mdx +3 -2
- package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +4 -3
- package/.docs/raw/docs/primitives/composer.mdx +8 -0
- package/.docs/raw/docs/primitives/thread.mdx +24 -0
- package/.docs/raw/docs/react-native/hooks.mdx +1 -1
- package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +22 -3
- package/.docs/raw/docs/runtimes/concepts/stability.mdx +1 -1
- package/.docs/raw/docs/runtimes/custom/data-stream.mdx +1 -1
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +54 -0
- package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +108 -4
- package/.docs/raw/docs/runtimes/eve/overview.mdx +100 -0
- package/.docs/raw/docs/runtimes/eve/quickstart.mdx +143 -0
- package/.docs/raw/docs/runtimes/langchain.mdx +386 -18
- package/.docs/raw/docs/runtimes/langgraph/quickstart.mdx +1 -1
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +1 -1
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +12 -6
- package/.docs/raw/docs/tools/defining-tools.mdx +4 -0
- package/.docs/raw/docs/tools/interactables-legacy.mdx +410 -0
- package/.docs/raw/docs/tools/interactables.mdx +892 -223
- package/.docs/raw/docs/tools/mcp.mdx +4 -4
- package/.docs/raw/docs/tools/multi-agent.mdx +5 -0
- package/.docs/raw/docs/tools/tool-ui.mdx +37 -1
- package/.docs/raw/docs/ui/composer-trigger-popover.mdx +2 -0
- package/.docs/raw/docs/ui/dot-matrix.mdx +133 -0
- package/.docs/raw/docs/ui/file.mdx +1 -1
- package/.docs/raw/docs/ui/model-selector.mdx +219 -52
- package/.docs/raw/docs/ui/number-roll.mdx +154 -0
- package/.docs/raw/docs/ui/part-grouping.mdx +38 -0
- package/.docs/raw/docs/ui/reasoning.mdx +3 -3
- package/.docs/raw/docs/ui/streamdown.mdx +2 -0
- package/.docs/raw/docs/ui/syntax-highlighting.mdx +1 -1
- package/.docs/raw/docs/ui/thread.mdx +52 -0
- package/.docs/raw/docs/ui/tool-fallback.mdx +2 -2
- package/.docs/raw/docs/utilities/react-o11y.mdx +92 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +14 -6
- package/src/tools/tests/mcp-protocol.test.ts +9 -0
|
@@ -11,16 +11,16 @@ import { LangGraphIcon } from "@/components/icons/langgraph";
|
|
|
11
11
|
|
|
12
12
|
Pick `react-langchain` over `react-langgraph` when:
|
|
13
13
|
|
|
14
|
+
- You are scaffolding via `npx create-assistant-ui -t langchain` (the official template uses it).
|
|
14
15
|
- Your app already depends on `@langchain/react` and uses `useStream` elsewhere.
|
|
15
16
|
- You want to read custom state keys (`todos`, `files`, plans) reactively with `useLangChainState<T>(key)`.
|
|
16
17
|
- You prefer a thin wrapper that stays pinned to upstream behavior.
|
|
17
18
|
|
|
18
19
|
Pick `react-langgraph` instead when:
|
|
19
20
|
|
|
20
|
-
- You
|
|
21
|
-
- You need subgraph events, generative UI messages, message metadata, or end-to-end cancellation today.
|
|
21
|
+
- You need a fully custom/bespoke backend stream (your own async generator) rather than `useStream`'s transport, or you're maintaining an existing `react-langgraph` app.
|
|
22
22
|
|
|
23
|
-
Both adapters are first-class
|
|
23
|
+
Both adapters are first-class and now at feature parity (the [comparison](#comparison-with-react-langgraph) below has the full table); `react-langchain` is the newer, thinner wrapper pinned to upstream `useStream`.
|
|
24
24
|
|
|
25
25
|
## Architecture
|
|
26
26
|
|
|
@@ -28,6 +28,8 @@ Both adapters are first-class. `react-langchain` is newer and thinner; some feat
|
|
|
28
28
|
|
|
29
29
|
Shared adapters (attachments, speech, feedback) work the same way described in [adapters](/docs/runtimes/concepts/adapters). Cloud thread persistence is built in.
|
|
30
30
|
|
|
31
|
+
`thread.isLoading` reflects `useStream`'s `isThreadLoading` (initial history hydration), separate from `isRunning` (a run being in-flight).
|
|
32
|
+
|
|
31
33
|
## Requirements
|
|
32
34
|
|
|
33
35
|
- A LangGraph Cloud API server (locally via [LangGraph Studio](https://github.com/langchain-ai/langgraph-studio) or hosted via [LangSmith](https://www.langchain.com/langsmith)).
|
|
@@ -249,13 +251,18 @@ Follow the [Ink setup](/docs/ink).
|
|
|
249
251
|
|
|
250
252
|
## `useStreamRuntime` options
|
|
251
253
|
|
|
252
|
-
`useStreamRuntime` accepts every option upstream `useStream` does, plus
|
|
254
|
+
`useStreamRuntime` accepts every option upstream `useStream` does, plus these assistant-ui-specific fields:
|
|
253
255
|
|
|
254
256
|
| Option | Type | Description |
|
|
255
257
|
| --- | --- | --- |
|
|
256
258
|
| `cloud` | `AssistantCloud` | Optional. Persists threads via assistant-cloud. |
|
|
257
259
|
| `adapters` | `{ attachments?, speech?, feedback? }` | Optional. Attachment, speech, and feedback adapters. |
|
|
258
260
|
| `messagesKey` | `string` | The state key that holds messages. Defaults to `"messages"`. |
|
|
261
|
+
| `uiStateKey` | `string` | The state key that holds generative `UIMessage`s. Defaults to `"ui"`. |
|
|
262
|
+
|
|
263
|
+
### Forwarding per-run config
|
|
264
|
+
|
|
265
|
+
When a message is sent, its `runConfig.custom` (for example a selected mode or model) is forwarded on the underlying `useStream().submit` call as `config.configurable`. Read it in the graph from `config["configurable"]`; on LangGraph v1 the same values are also reachable through the Runtime `context`, which `config.configurable` is aliased to. This lets per-run app config reach the graph without extra wiring.
|
|
259
266
|
|
|
260
267
|
## Reading custom state keys
|
|
261
268
|
|
|
@@ -347,7 +354,108 @@ Added in v0.0.2 — see issue [#3862](https://github.com/assistant-ui/assistant-
|
|
|
347
354
|
|
|
348
355
|
## Interrupts
|
|
349
356
|
|
|
350
|
-
LangGraph interrupts pause the graph and wait for client input. `useLangChainInterruptState` exposes the current interrupt; `useLangChainSubmit` resumes the graph with a raw state update.
|
|
357
|
+
LangGraph interrupts pause the graph and wait for client input. `useLangChainInterruptState` exposes the current interrupt; `useLangChainRespond` resumes it with a response payload, while `useLangChainSubmit` resumes the graph with a raw state update.
|
|
358
|
+
|
|
359
|
+
`useLangChainRespond` is the cleaner resume path; it carries the response payload via `useStream().respond` and handles interrupt namespaces, so you don't have to construct a `Command`.
|
|
360
|
+
|
|
361
|
+
<PlatformTabs>
|
|
362
|
+
<Tab value="React">
|
|
363
|
+
|
|
364
|
+
```tsx
|
|
365
|
+
import {
|
|
366
|
+
useLangChainInterruptState,
|
|
367
|
+
useLangChainRespond,
|
|
368
|
+
} from "@assistant-ui/react-langchain";
|
|
369
|
+
|
|
370
|
+
function InterruptPrompt() {
|
|
371
|
+
const interrupt = useLangChainInterruptState();
|
|
372
|
+
const respond = useLangChainRespond();
|
|
373
|
+
if (!interrupt) return null;
|
|
374
|
+
return (
|
|
375
|
+
<div>
|
|
376
|
+
<pre>{JSON.stringify(interrupt.value, null, 2)}</pre>
|
|
377
|
+
<button onClick={() => respond({ approved: true })}>Approve</button>
|
|
378
|
+
</div>
|
|
379
|
+
);
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
</Tab>
|
|
384
|
+
<Tab value="React Native">
|
|
385
|
+
|
|
386
|
+
```tsx
|
|
387
|
+
import {
|
|
388
|
+
useLangChainInterruptState,
|
|
389
|
+
useLangChainRespond,
|
|
390
|
+
} from "@assistant-ui/react-langchain";
|
|
391
|
+
import { Pressable, Text, View } from "react-native";
|
|
392
|
+
|
|
393
|
+
function InterruptPrompt() {
|
|
394
|
+
const interrupt = useLangChainInterruptState();
|
|
395
|
+
const respond = useLangChainRespond();
|
|
396
|
+
if (!interrupt) return null;
|
|
397
|
+
return (
|
|
398
|
+
<View>
|
|
399
|
+
<Text>{JSON.stringify(interrupt.value, null, 2)}</Text>
|
|
400
|
+
<Pressable onPress={() => respond({ approved: true })}>
|
|
401
|
+
<Text>Approve</Text>
|
|
402
|
+
</Pressable>
|
|
403
|
+
</View>
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
</Tab>
|
|
409
|
+
<Tab value="React Ink">
|
|
410
|
+
|
|
411
|
+
```tsx
|
|
412
|
+
import {
|
|
413
|
+
useLangChainInterruptState,
|
|
414
|
+
useLangChainRespond,
|
|
415
|
+
} from "@assistant-ui/react-langchain";
|
|
416
|
+
import { Box, Text, useInput } from "ink";
|
|
417
|
+
|
|
418
|
+
function InterruptPrompt() {
|
|
419
|
+
const interrupt = useLangChainInterruptState();
|
|
420
|
+
const respond = useLangChainRespond();
|
|
421
|
+
|
|
422
|
+
useInput((input) => {
|
|
423
|
+
if (!interrupt || input !== "a") return;
|
|
424
|
+
respond({ approved: true });
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
if (!interrupt) return null;
|
|
428
|
+
return (
|
|
429
|
+
<Box flexDirection="column">
|
|
430
|
+
<Text>{JSON.stringify(interrupt.value, null, 2)}</Text>
|
|
431
|
+
<Text>Press a to approve.</Text>
|
|
432
|
+
</Box>
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
</Tab>
|
|
438
|
+
</PlatformTabs>
|
|
439
|
+
|
|
440
|
+
When several interrupts are pending at once (e.g. parallel approvals), use `useLangChainRespondAll()` to resume them all in one run. Sequential `useLangChainRespond` calls can't, since the first resume starts a run and strands the rest.
|
|
441
|
+
|
|
442
|
+
```tsx
|
|
443
|
+
import {
|
|
444
|
+
useLangChainInterrupts,
|
|
445
|
+
useLangChainRespondAll,
|
|
446
|
+
} from "@assistant-ui/react-langchain";
|
|
447
|
+
|
|
448
|
+
const interrupts = useLangChainInterrupts();
|
|
449
|
+
const respondAll = useLangChainRespondAll();
|
|
450
|
+
// resume every pending interrupt with the same payload:
|
|
451
|
+
await respondAll(
|
|
452
|
+
Object.fromEntries(
|
|
453
|
+
interrupts.flatMap((i) => (i.id ? [[i.id, { approved: true }]] : [])),
|
|
454
|
+
),
|
|
455
|
+
);
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
You can also resume with a raw `Command` via `useLangChainSubmit`:
|
|
351
459
|
|
|
352
460
|
<PlatformTabs>
|
|
353
461
|
<Tab value="React">
|
|
@@ -441,6 +549,243 @@ function InterruptPrompt() {
|
|
|
441
549
|
</Tab>
|
|
442
550
|
</PlatformTabs>
|
|
443
551
|
|
|
552
|
+
## Tool calls
|
|
553
|
+
|
|
554
|
+
`useLangChainToolCalls` exposes the root tool calls `useStream` assembles from the `tools` channel — each entry carries a `name`, `args`, and `id`. Use it to render pending or streamed tool calls and approval UIs. It defaults to an empty array, so you can `.map` without a guard.
|
|
555
|
+
|
|
556
|
+
<PlatformTabs>
|
|
557
|
+
<Tab value="React">
|
|
558
|
+
|
|
559
|
+
```tsx
|
|
560
|
+
import { useLangChainToolCalls } from "@assistant-ui/react-langchain";
|
|
561
|
+
|
|
562
|
+
function PendingToolCalls() {
|
|
563
|
+
const toolCalls = useLangChainToolCalls();
|
|
564
|
+
return (
|
|
565
|
+
<ul>
|
|
566
|
+
{toolCalls.map((tc) => (
|
|
567
|
+
<li key={tc.id}>
|
|
568
|
+
{tc.name}: <code>{JSON.stringify(tc.args)}</code>
|
|
569
|
+
</li>
|
|
570
|
+
))}
|
|
571
|
+
</ul>
|
|
572
|
+
);
|
|
573
|
+
}
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
</Tab>
|
|
577
|
+
<Tab value="React Native">
|
|
578
|
+
|
|
579
|
+
```tsx
|
|
580
|
+
import { useLangChainToolCalls } from "@assistant-ui/react-langchain";
|
|
581
|
+
import { Text, View } from "react-native";
|
|
582
|
+
|
|
583
|
+
function PendingToolCalls() {
|
|
584
|
+
const toolCalls = useLangChainToolCalls();
|
|
585
|
+
return (
|
|
586
|
+
<View>
|
|
587
|
+
{toolCalls.map((tc) => (
|
|
588
|
+
<Text key={tc.id}>
|
|
589
|
+
{tc.name}: {JSON.stringify(tc.args)}
|
|
590
|
+
</Text>
|
|
591
|
+
))}
|
|
592
|
+
</View>
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
</Tab>
|
|
598
|
+
<Tab value="React Ink">
|
|
599
|
+
|
|
600
|
+
```tsx
|
|
601
|
+
import { useLangChainToolCalls } from "@assistant-ui/react-langchain";
|
|
602
|
+
import { Box, Text } from "ink";
|
|
603
|
+
|
|
604
|
+
function PendingToolCalls() {
|
|
605
|
+
const toolCalls = useLangChainToolCalls();
|
|
606
|
+
return (
|
|
607
|
+
<Box flexDirection="column">
|
|
608
|
+
{toolCalls.map((tc) => (
|
|
609
|
+
<Text key={tc.id}>
|
|
610
|
+
{tc.name}: {JSON.stringify(tc.args)}
|
|
611
|
+
</Text>
|
|
612
|
+
))}
|
|
613
|
+
</Box>
|
|
614
|
+
);
|
|
615
|
+
}
|
|
616
|
+
```
|
|
617
|
+
|
|
618
|
+
</Tab>
|
|
619
|
+
</PlatformTabs>
|
|
620
|
+
|
|
621
|
+
## Subagent and subgraph discovery
|
|
622
|
+
|
|
623
|
+
For multi-agent graphs, `useStream` tracks which subagents and subgraphs it has seen on the current run as cheap discovery maps. `useLangChainSubagents` and `useLangChainSubgraphs` surface those maps — keyed by namespace, each value a `SubagentDiscoverySnapshot` / `SubgraphDiscoverySnapshot`. Both default to a stable empty map, so you can iterate without a guard.
|
|
624
|
+
|
|
625
|
+
These replace `react-langgraph`'s subgraph `eventHandlers`: v1 surfaces discovery as maps you read reactively rather than per-event callbacks.
|
|
626
|
+
|
|
627
|
+
```tsx
|
|
628
|
+
import {
|
|
629
|
+
useLangChainSubagents,
|
|
630
|
+
useLangChainSubgraphs,
|
|
631
|
+
} from "@assistant-ui/react-langchain";
|
|
632
|
+
|
|
633
|
+
function Discovered() {
|
|
634
|
+
const subagents = useLangChainSubagents();
|
|
635
|
+
const subgraphs = useLangChainSubgraphs();
|
|
636
|
+
return (
|
|
637
|
+
<ul>
|
|
638
|
+
{[...subagents.keys()].map((ns) => (
|
|
639
|
+
<li key={ns}>subagent: {ns}</li>
|
|
640
|
+
))}
|
|
641
|
+
{[...subgraphs.keys()].map((ns) => (
|
|
642
|
+
<li key={ns}>subgraph: {ns}</li>
|
|
643
|
+
))}
|
|
644
|
+
</ul>
|
|
645
|
+
);
|
|
646
|
+
}
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
## Subagent and subgraph views
|
|
650
|
+
|
|
651
|
+
The discovery maps above pair with v1's scoped selector hooks to render a subagent's or subgraph's own messages and tool calls. `useLangChainStream` exposes the underlying `useStream` handle; feed it to `useMessages(stream, target)` / `useToolCalls(stream, target)` from `@langchain/react`, with a `SubagentDiscoverySnapshot` / `SubgraphDiscoverySnapshot` from `useLangChainSubagents` / `useLangChainSubgraphs` as the target. `useLangChainStream` returns `undefined` outside the runtime provider.
|
|
652
|
+
|
|
653
|
+
```tsx
|
|
654
|
+
import {
|
|
655
|
+
useLangChainStream,
|
|
656
|
+
useLangChainSubagents,
|
|
657
|
+
} from "@assistant-ui/react-langchain";
|
|
658
|
+
import { useMessages, useToolCalls } from "@langchain/react";
|
|
659
|
+
|
|
660
|
+
function SubagentCard({ stream, subagent }) {
|
|
661
|
+
const messages = useMessages(stream, subagent);
|
|
662
|
+
const toolCalls = useToolCalls(stream, subagent);
|
|
663
|
+
return (
|
|
664
|
+
<div>
|
|
665
|
+
<strong>{subagent.namespace.join("/")}</strong>
|
|
666
|
+
<pre>{messages.map((m) => m.content).join("\n")}</pre>
|
|
667
|
+
<ul>
|
|
668
|
+
{toolCalls.map((tc) => (
|
|
669
|
+
<li key={tc.id}>{tc.name}</li>
|
|
670
|
+
))}
|
|
671
|
+
</ul>
|
|
672
|
+
</div>
|
|
673
|
+
);
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
function Subagents() {
|
|
677
|
+
const stream = useLangChainStream();
|
|
678
|
+
const subagents = useLangChainSubagents();
|
|
679
|
+
if (!stream) return null;
|
|
680
|
+
return [...subagents.values()].map((s) => (
|
|
681
|
+
<SubagentCard key={s.namespace.join("/")} stream={stream} subagent={s} />
|
|
682
|
+
));
|
|
683
|
+
}
|
|
684
|
+
```
|
|
685
|
+
|
|
686
|
+
## Per-message metadata
|
|
687
|
+
|
|
688
|
+
`useMessageMetadata` (from `@langchain/react`) reads per-message metadata (e.g. `parentCheckpointId`) for a given message id. Pair it with `useLangChainStream`, which returns `undefined` outside the runtime provider; guard the stream before calling the selector, since `useMessageMetadata` throws on an undefined stream.
|
|
689
|
+
|
|
690
|
+
```tsx
|
|
691
|
+
import { useLangChainStream } from "@assistant-ui/react-langchain";
|
|
692
|
+
import { useMessageMetadata } from "@langchain/react";
|
|
693
|
+
|
|
694
|
+
function MessageInfoView({
|
|
695
|
+
stream,
|
|
696
|
+
messageId,
|
|
697
|
+
}: {
|
|
698
|
+
stream: NonNullable<ReturnType<typeof useLangChainStream>>;
|
|
699
|
+
messageId: string;
|
|
700
|
+
}) {
|
|
701
|
+
const { parentCheckpointId } = useMessageMetadata(stream, messageId) ?? {};
|
|
702
|
+
// …render per-message metadata…
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
function MessageInfo({ messageId }: { messageId: string }) {
|
|
706
|
+
const stream = useLangChainStream();
|
|
707
|
+
if (!stream) return null;
|
|
708
|
+
return <MessageInfoView stream={stream} messageId={messageId} />;
|
|
709
|
+
}
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
## Media
|
|
713
|
+
|
|
714
|
+
The v1 media hooks surface multimodal media streamed by the agent. Feed the `useLangChainStream` handle to them — the same pattern as the views and metadata sections above.
|
|
715
|
+
|
|
716
|
+
```tsx
|
|
717
|
+
import { useLangChainStream } from "@assistant-ui/react-langchain";
|
|
718
|
+
import { useImages, useAudio } from "@langchain/react";
|
|
719
|
+
|
|
720
|
+
function MediaView({
|
|
721
|
+
stream,
|
|
722
|
+
}: {
|
|
723
|
+
stream: NonNullable<ReturnType<typeof useLangChainStream>>;
|
|
724
|
+
}) {
|
|
725
|
+
const images = useImages(stream);
|
|
726
|
+
// useAudio / useVideo / useFiles likewise
|
|
727
|
+
return <>{/* …render media… */}</>;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
function Media() {
|
|
731
|
+
const stream = useLangChainStream();
|
|
732
|
+
if (!stream) return null;
|
|
733
|
+
return <MediaView stream={stream} />;
|
|
734
|
+
}
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
## Generative UI
|
|
738
|
+
|
|
739
|
+
Graphs can accumulate UI components in their state and attach each one to the assistant message that produced it. The runtime reads these from `stream.values[uiStateKey]` (default `"ui"`) and, for every `UIMessage` whose parent id matches an assistant message, emits a `data` part on that message. The parent id is read from `metadata.message_id` (Python SDK) or `metadata.id` (JS SDK). Pass `uiStateKey` if your graph stores them elsewhere.
|
|
740
|
+
|
|
741
|
+
Register the components with `makeAssistantDataUI`, keyed by the `UIMessage`'s `name`, and mount the returned element once inside the runtime provider:
|
|
742
|
+
|
|
743
|
+
```tsx
|
|
744
|
+
import {
|
|
745
|
+
AssistantRuntimeProvider,
|
|
746
|
+
makeAssistantDataUI,
|
|
747
|
+
Thread,
|
|
748
|
+
} from "@assistant-ui/react";
|
|
749
|
+
import { useStreamRuntime } from "@assistant-ui/react-langchain";
|
|
750
|
+
|
|
751
|
+
const ChartUI = makeAssistantDataUI({
|
|
752
|
+
name: "chart",
|
|
753
|
+
render: ({ data }) => <Chart points={data.points} />,
|
|
754
|
+
});
|
|
755
|
+
|
|
756
|
+
function App() {
|
|
757
|
+
const runtime = useStreamRuntime({
|
|
758
|
+
assistantId: "agent",
|
|
759
|
+
apiUrl: "http://localhost:2024",
|
|
760
|
+
});
|
|
761
|
+
|
|
762
|
+
return (
|
|
763
|
+
<AssistantRuntimeProvider runtime={runtime}>
|
|
764
|
+
<ChartUI />
|
|
765
|
+
<Thread />
|
|
766
|
+
</AssistantRuntimeProvider>
|
|
767
|
+
);
|
|
768
|
+
}
|
|
769
|
+
```
|
|
770
|
+
|
|
771
|
+
This covers two paths transparently. The **state-snapshot** path renders whatever UI the graph has committed to its state. The **live** path renders UI streamed over the `custom` channel by `push_ui_message` / `remove_ui_message` before (or instead of) it lands in state, so components appear as the graph emits them. The runtime accumulates the live events and merges them with the state snapshot, with the snapshot authoritative once a UI lands in state. Both feed the same `makeAssistantDataUI` renderers.
|
|
772
|
+
|
|
773
|
+
The live path requires the graph's `streamMode` to include `"custom"` so the UI events reach the client.
|
|
774
|
+
|
|
775
|
+
## Errors
|
|
776
|
+
|
|
777
|
+
`useLangChainError` exposes the last run or hydration error from upstream `useStream().error`. It is untyped (`unknown`), so narrow it at the use site before rendering.
|
|
778
|
+
|
|
779
|
+
```tsx
|
|
780
|
+
import { useLangChainError } from "@assistant-ui/react-langchain";
|
|
781
|
+
|
|
782
|
+
function ErrorBanner() {
|
|
783
|
+
const error = useLangChainError();
|
|
784
|
+
if (!error) return null;
|
|
785
|
+
return <div role="alert">{error instanceof Error ? error.message : String(error)}</div>;
|
|
786
|
+
}
|
|
787
|
+
```
|
|
788
|
+
|
|
444
789
|
## Message conversion
|
|
445
790
|
|
|
446
791
|
`convertLangChainBaseMessage` transforms a LangChain `BaseMessage` into an assistant-ui message. Use it when building a custom `ExternalStoreAdapter` that consumes LangChain messages outside `useStreamRuntime`.
|
|
@@ -476,7 +821,7 @@ const runtime = useStreamRuntime({
|
|
|
476
821
|
|
|
477
822
|
## Comparison with `react-langgraph`
|
|
478
823
|
|
|
479
|
-
Both packages connect assistant-ui to LangGraph backends. They are independent adapters for different upstream libraries; one is not a successor to the other.
|
|
824
|
+
Both packages connect assistant-ui to LangGraph backends. They are independent adapters for different upstream libraries; one is not a successor to the other. The official `create-assistant-ui` template (`-t langchain`) ships `react-langchain`. The two are now at feature parity; `react-langgraph` remains the choice for a fully custom backend stream or an existing `react-langgraph` app.
|
|
480
825
|
|
|
481
826
|
| Aspect | `react-langgraph` | `react-langchain` |
|
|
482
827
|
| --- | --- | --- |
|
|
@@ -485,7 +830,7 @@ Both packages connect assistant-ui to LangGraph backends. They are independent a
|
|
|
485
830
|
| Version | `0.13.x` | `0.0.x` |
|
|
486
831
|
| Lines of source | ~7,500 | ~600 |
|
|
487
832
|
| Built on | `useExternalStoreRuntime` | `useExternalStoreRuntime` |
|
|
488
|
-
| `create-assistant-ui` template |
|
|
833
|
+
| `create-assistant-ui` template | No template | `-t langchain` |
|
|
489
834
|
|
|
490
835
|
### Feature coverage
|
|
491
836
|
|
|
@@ -493,16 +838,32 @@ Both packages connect assistant-ui to LangGraph backends. They are independent a
|
|
|
493
838
|
| --- | --- | --- |
|
|
494
839
|
| Stream messages | Yes (`useLangGraphRuntime`) | Yes (`useStreamRuntime`) |
|
|
495
840
|
| Interrupt state | Yes | Yes |
|
|
496
|
-
|
|
|
841
|
+
| Thread history loading state (`thread.isLoading`) | Yes | Yes |
|
|
842
|
+
| Send raw state update / resume command | Yes | Yes (`useLangChainSubmit`; `useLangChainRespond` for payload resume) |
|
|
843
|
+
| Forward per-run `runConfig` | Yes (whole object → `config`) | Yes (`custom` → `config.configurable`) |
|
|
497
844
|
| Read arbitrary custom state key | No | Yes (`useLangChainState<T>(key)`) |
|
|
498
|
-
|
|
|
499
|
-
|
|
|
500
|
-
|
|
|
501
|
-
|
|
|
502
|
-
|
|
|
845
|
+
| Root tool-calls projection | Via message parts | Yes (`useLangChainToolCalls`) |
|
|
846
|
+
| File content parts in messages | Yes | Yes |
|
|
847
|
+
| Regenerate (checkpoint fork) | Yes (`getCheckpointId`) | Yes (auto-resolved) |
|
|
848
|
+
| Edit message (checkpoint fork) | Yes | Yes (auto-resolved) |
|
|
849
|
+
| Per-message metadata (`messages-tuple`) | Yes | Yes (`useMessageMetadata` via `useLangChainStream`) |
|
|
850
|
+
| Multimodal media (audio/image/video/file) | Via parts | Yes (v1 media hooks via `useLangChainStream`) |
|
|
851
|
+
| Generative UI (state snapshot) | Yes | Yes (`uiStateKey`) |
|
|
852
|
+
| Generative UI (live `push_ui_message`) | Yes | Yes (`streamMode: ["custom"]`) |
|
|
853
|
+
| Subgraph / namespaced stream events | Yes (via `eventHandlers`) | Replaced by `useLangChainSubagents` / `useLangChainSubgraphs` + views |
|
|
854
|
+
| Subagent discovery | Via `eventHandlers` | Yes (`useLangChainSubagents`) |
|
|
855
|
+
| Subgraph discovery | Via `eventHandlers` | Yes (`useLangChainSubgraphs`) |
|
|
856
|
+
| Subagent/subgraph message views | Via `eventHandlers` | Yes (via `useLangChainStream` + v1 selector hooks) |
|
|
857
|
+
| End-to-end cancellation primitive | Yes (`unstable_createLangGraphStream`) | n/a — cancellation via `useStream().stop()` (Cancel button on by default) |
|
|
858
|
+
| Message accumulator utility | Yes (`LangGraphMessageAccumulator`) | n/a — `useStream` owns accumulation |
|
|
859
|
+
| Streaming timing (per-message) | Yes | Yes |
|
|
503
860
|
| Cloud thread persistence | Yes | Yes |
|
|
504
861
|
|
|
505
|
-
|
|
862
|
+
Per-message streaming timing is attached automatically to `message.metadata.timing` (no setup), matching `react-langgraph`. It captures time-to-first-token, total stream time, chunk count, and tokens/sec, computed from message growth while the run is in flight.
|
|
863
|
+
|
|
864
|
+
`react-langchain` is the newer, thinner wrapper. It delegates to upstream `useStream` rather than re-implementing the stream plumbing, which is why its footprint is smaller.
|
|
865
|
+
|
|
866
|
+
Regenerate works without configuration. Clicking regenerate resolves the server checkpoint to fork from (the checkpoint each message records as it streams in, falling back to a `stream.client.threads.getHistory(threadId)` id match for older turns), then re-runs with `submit(null, { forkFrom })`. It works on checkpoint-enabled backends (for example LangGraph Cloud) and degrades gracefully; when no checkpoint resolves the regenerate is a no-op. `react-langgraph` instead requires a user-supplied `getCheckpointId` callback. Editing a message forks from the same checkpoint and submits the edited human content instead of re-running the prior turn; editing the first message forks from the thread's initial checkpoint to restart it.
|
|
506
867
|
|
|
507
868
|
### Hook name mapping
|
|
508
869
|
|
|
@@ -510,11 +871,18 @@ Both packages connect assistant-ui to LangGraph backends. They are independent a
|
|
|
510
871
|
| --- | --- | --- |
|
|
511
872
|
| `useLangGraphRuntime` | `useStreamRuntime` | Options extend upstream `UseStreamOptions`; no `stream` / `create` / `load` to write. |
|
|
512
873
|
| `useLangGraphInterruptState` | `useLangChainInterruptState` | Same return shape. |
|
|
513
|
-
| `useLangGraphSendCommand` | `
|
|
874
|
+
| `useLangGraphSendCommand` | `useLangChainRespond` | Preferred resume; carries a payload via `stream.respond`. For a raw `Command`, use `useLangChainSubmit(null, { command })`. |
|
|
514
875
|
| `useLangGraphSend` | _(use `runtime.thread.append`)_ | No direct equivalent; send turns through the runtime. |
|
|
515
|
-
| `useLangGraphMessageMetadata` | _(
|
|
516
|
-
| `useLangGraphUIMessages` | _(
|
|
876
|
+
| `useLangGraphMessageMetadata` | _(use `useMessageMetadata(useLangChainStream(), id)`)_ | Per-message metadata via the upstream selector hook. |
|
|
877
|
+
| `useLangGraphUIMessages` | _(UI renders as data parts; register with `makeAssistantDataUI`)_ | See [Generative UI](#generative-ui). |
|
|
517
878
|
| _(none)_ | `useLangChainState<T>(key)` | New — reads any custom state key reactively. |
|
|
879
|
+
| _(none)_ | `useLangChainToolCalls` | New — root tool calls assembled by `useStream`. |
|
|
880
|
+
| _(none)_ | `useLangChainError()` | New — reads the last run/hydration error reactively. |
|
|
881
|
+
| _(none)_ | `useLangChainRespondAll` | Resume multiple interrupts at one checkpoint (`stream.respondAll`). |
|
|
882
|
+
| _(none)_ | `useLangChainInterrupts` | New — every interrupt pending at the checkpoint, each with `id` and `value`. |
|
|
883
|
+
| _(via `eventHandlers`)_ | `useLangChainSubagents` | New — subagents discovered on the current run; replaces subgraph event handlers. |
|
|
884
|
+
| _(via `eventHandlers`)_ | `useLangChainSubgraphs` | New — subgraphs discovered on the current run; replaces subgraph event handlers. |
|
|
885
|
+
| _(none)_ | `useLangChainStream` | New — the raw `useStream` handle for v1's scoped `useMessages` / `useToolCalls` selector hooks. |
|
|
518
886
|
|
|
519
887
|
## Related
|
|
520
888
|
|
|
@@ -522,7 +890,7 @@ Both packages connect assistant-ui to LangGraph backends. They are independent a
|
|
|
522
890
|
<Card
|
|
523
891
|
icon={<LangGraphIcon width={20} height={20} className="text-[#1C3C3C] dark:text-[#5b9595]" />}
|
|
524
892
|
title="LangGraph"
|
|
525
|
-
description="The
|
|
893
|
+
description="The original LangGraph adapter, built on the raw SDK."
|
|
526
894
|
href="/docs/runtimes/langgraph"
|
|
527
895
|
/>
|
|
528
896
|
<Card
|
|
@@ -8,7 +8,7 @@ description: Create a Next.js project with the LangGraph assistant-ui template.
|
|
|
8
8
|
Run the following command to create a new Next.js project with the LangGraph assistant-ui template:
|
|
9
9
|
|
|
10
10
|
```sh
|
|
11
|
-
npx create-assistant-ui@latest -t
|
|
11
|
+
npx create-assistant-ui@latest -t langchain my-app
|
|
12
12
|
cd my-app
|
|
13
13
|
```
|
|
14
14
|
|
|
@@ -28,13 +28,19 @@ assistant-ui ships React adapter packages for these. Pick the matching card and
|
|
|
28
28
|
icon={<VercelIcon width={20} height={20} />}
|
|
29
29
|
title="Vercel AI SDK"
|
|
30
30
|
description="useChat hook, streaming, tools, attachments, multi-step. v6 current; v5 / v4 legacy."
|
|
31
|
-
href="/docs/runtimes/ai-sdk"
|
|
31
|
+
href="/docs/runtimes/ai-sdk/overview"
|
|
32
|
+
/>
|
|
33
|
+
<Card
|
|
34
|
+
icon={<VercelIcon width={20} height={20} />}
|
|
35
|
+
title="Eve"
|
|
36
|
+
description="Filesystem-first durable agents with eve/next, sessions, NDJSON streaming, and HITL."
|
|
37
|
+
href="/docs/runtimes/eve/overview"
|
|
32
38
|
/>
|
|
33
39
|
<Card
|
|
34
40
|
icon={<LangGraphIcon width={20} height={20} className="text-[#1C3C3C] dark:text-[#5b9595]" />}
|
|
35
41
|
title="LangGraph"
|
|
36
42
|
description="Direct integration with @langchain/langgraph-sdk. Subgraph events, UI messages, message metadata."
|
|
37
|
-
href="/docs/runtimes/langgraph"
|
|
43
|
+
href="/docs/runtimes/langgraph/overview"
|
|
38
44
|
/>
|
|
39
45
|
<Card
|
|
40
46
|
icon={<LangChainIcon width={20} height={20} className="text-[#7FC8FF]" />}
|
|
@@ -46,7 +52,7 @@ assistant-ui ships React adapter packages for these. Pick the matching card and
|
|
|
46
52
|
icon={<AdkIcon width={20} height={20} />}
|
|
47
53
|
title="Google ADK"
|
|
48
54
|
description="ADK JS or Python agents. Tool confirmations, auth flows, multi-agent, code execution."
|
|
49
|
-
href="/docs/runtimes/google-adk"
|
|
55
|
+
href="/docs/runtimes/google-adk/overview"
|
|
50
56
|
/>
|
|
51
57
|
<Card
|
|
52
58
|
icon={<A2AIcon width={20} height={20} />}
|
|
@@ -58,14 +64,14 @@ assistant-ui ships React adapter packages for these. Pick the matching card and
|
|
|
58
64
|
icon={<AguiIcon width={20} height={20} />}
|
|
59
65
|
title="AG-UI Protocol"
|
|
60
66
|
description="AG-UI agents (CopilotKit, custom servers). Streaming text, thinking, tool calls, state snapshots."
|
|
61
|
-
href="/docs/runtimes/ag-ui"
|
|
67
|
+
href="/docs/runtimes/ag-ui/overview"
|
|
62
68
|
/>
|
|
63
69
|
<PlatformOnly platforms={["react"]}>
|
|
64
70
|
<Card
|
|
65
71
|
icon={<OpenCodeIcon width={20} height={20} />}
|
|
66
72
|
title="OpenCode"
|
|
67
73
|
description="OpenCode coding-agent server. Permission flows, questions, fork / revert. Experimental."
|
|
68
|
-
href="/docs/runtimes/opencode"
|
|
74
|
+
href="/docs/runtimes/opencode/overview"
|
|
69
75
|
/>
|
|
70
76
|
</PlatformOnly>
|
|
71
77
|
</Cards>
|
|
@@ -104,7 +110,7 @@ If you do not know your framework yet, or your backend is custom, pick by what y
|
|
|
104
110
|
| Backend that already speaks the data stream protocol | [DataStream](/docs/runtimes/custom/data-stream) |
|
|
105
111
|
| Stream full agent state snapshots (not just messages) | [AssistantTransport](/docs/runtimes/custom/assistant-transport) |
|
|
106
112
|
|
|
107
|
-
If none of the framework adapters fits, start at [custom backend](/docs/runtimes/custom).
|
|
113
|
+
If none of the framework adapters fits, start at [custom backend](/docs/runtimes/custom/overview).
|
|
108
114
|
|
|
109
115
|
## Shared concepts
|
|
110
116
|
|
|
@@ -423,6 +423,10 @@ The compiler splits each file across the client/server boundary on its own, then
|
|
|
423
423
|
- **Spread a default import** (`import weatherTools from "./tools/weather"`). Relative paths and `tsconfig` path aliases like `@/tools/weather` both resolve. Only the default export crosses the generative-module boundary, so a named import (or any opaque, non-generative import) is rejected.
|
|
424
424
|
- You can also spread a local `defineToolkit(...)` or `defineMcpToolkit(...)` binding declared in the same file.
|
|
425
425
|
|
|
426
|
+
The compiler checks static tool names across inline entries and compiler-visible
|
|
427
|
+
spreads. If two fragments define the same tool name, the build warns that
|
|
428
|
+
JavaScript object spread will keep the later tool definition.
|
|
429
|
+
|
|
426
430
|
### Add MCP server tools
|
|
427
431
|
|
|
428
432
|
`defineMcpToolkit` exposes tools from an MCP server. For an MCP-only toolkit, export it directly:
|