@assistant-ui/mcp-docs-server 0.1.1

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 (109) hide show
  1. package/.docs/organized/code-examples/local-ollama.md +1135 -0
  2. package/.docs/organized/code-examples/search-agent-for-e-commerce.md +1721 -0
  3. package/.docs/organized/code-examples/with-ai-sdk.md +1081 -0
  4. package/.docs/organized/code-examples/with-cloud.md +1164 -0
  5. package/.docs/organized/code-examples/with-external-store.md +1064 -0
  6. package/.docs/organized/code-examples/with-ffmpeg.md +1305 -0
  7. package/.docs/organized/code-examples/with-langgraph.md +1819 -0
  8. package/.docs/organized/code-examples/with-openai-assistants.md +1175 -0
  9. package/.docs/organized/code-examples/with-react-hook-form.md +1727 -0
  10. package/.docs/organized/code-examples/with-vercel-ai-rsc.md +1157 -0
  11. package/.docs/raw/blog/2024-07-29-hello/index.mdx +65 -0
  12. package/.docs/raw/blog/2024-09-11/index.mdx +10 -0
  13. package/.docs/raw/blog/2024-12-15/index.mdx +10 -0
  14. package/.docs/raw/blog/2025-01-31-changelog/index.mdx +129 -0
  15. package/.docs/raw/docs/about-assistantui.mdx +44 -0
  16. package/.docs/raw/docs/api-reference/context-providers/AssistantRuntimeProvider.mdx +30 -0
  17. package/.docs/raw/docs/api-reference/context-providers/TextContentPartProvider.mdx +26 -0
  18. package/.docs/raw/docs/api-reference/integrations/react-hook-form.mdx +103 -0
  19. package/.docs/raw/docs/api-reference/integrations/vercel-ai-sdk.mdx +145 -0
  20. package/.docs/raw/docs/api-reference/overview.mdx +583 -0
  21. package/.docs/raw/docs/api-reference/primitives/ActionBar.mdx +264 -0
  22. package/.docs/raw/docs/api-reference/primitives/AssistantModal.mdx +129 -0
  23. package/.docs/raw/docs/api-reference/primitives/Attachment.mdx +96 -0
  24. package/.docs/raw/docs/api-reference/primitives/BranchPicker.mdx +87 -0
  25. package/.docs/raw/docs/api-reference/primitives/Composer.mdx +204 -0
  26. package/.docs/raw/docs/api-reference/primitives/ContentPart.mdx +173 -0
  27. package/.docs/raw/docs/api-reference/primitives/Error.mdx +70 -0
  28. package/.docs/raw/docs/api-reference/primitives/Message.mdx +181 -0
  29. package/.docs/raw/docs/api-reference/primitives/Thread.mdx +197 -0
  30. package/.docs/raw/docs/api-reference/primitives/composition.mdx +21 -0
  31. package/.docs/raw/docs/api-reference/runtimes/AssistantRuntime.mdx +33 -0
  32. package/.docs/raw/docs/api-reference/runtimes/AttachmentRuntime.mdx +46 -0
  33. package/.docs/raw/docs/api-reference/runtimes/ComposerRuntime.mdx +69 -0
  34. package/.docs/raw/docs/api-reference/runtimes/ContentPartRuntime.mdx +22 -0
  35. package/.docs/raw/docs/api-reference/runtimes/MessageRuntime.mdx +49 -0
  36. package/.docs/raw/docs/api-reference/runtimes/ThreadListItemRuntime.mdx +32 -0
  37. package/.docs/raw/docs/api-reference/runtimes/ThreadListRuntime.mdx +31 -0
  38. package/.docs/raw/docs/api-reference/runtimes/ThreadRuntime.mdx +48 -0
  39. package/.docs/raw/docs/architecture.mdx +92 -0
  40. package/.docs/raw/docs/cloud/authorization.mdx +152 -0
  41. package/.docs/raw/docs/cloud/overview.mdx +55 -0
  42. package/.docs/raw/docs/cloud/persistence/ai-sdk.mdx +54 -0
  43. package/.docs/raw/docs/cloud/persistence/langgraph.mdx +123 -0
  44. package/.docs/raw/docs/concepts/architecture.mdx +19 -0
  45. package/.docs/raw/docs/concepts/runtime-layer.mdx +163 -0
  46. package/.docs/raw/docs/concepts/why.mdx +9 -0
  47. package/.docs/raw/docs/copilots/make-assistant-readable.mdx +71 -0
  48. package/.docs/raw/docs/copilots/make-assistant-tool-ui.mdx +76 -0
  49. package/.docs/raw/docs/copilots/make-assistant-tool.mdx +117 -0
  50. package/.docs/raw/docs/copilots/model-context.mdx +135 -0
  51. package/.docs/raw/docs/copilots/motivation.mdx +191 -0
  52. package/.docs/raw/docs/copilots/use-assistant-instructions.mdx +62 -0
  53. package/.docs/raw/docs/getting-started.mdx +1133 -0
  54. package/.docs/raw/docs/guides/Attachments.mdx +640 -0
  55. package/.docs/raw/docs/guides/Branching.mdx +59 -0
  56. package/.docs/raw/docs/guides/Editing.mdx +56 -0
  57. package/.docs/raw/docs/guides/Speech.mdx +43 -0
  58. package/.docs/raw/docs/guides/ToolUI.mdx +663 -0
  59. package/.docs/raw/docs/guides/Tools.mdx +496 -0
  60. package/.docs/raw/docs/index.mdx +7 -0
  61. package/.docs/raw/docs/legacy/styled/AssistantModal.mdx +85 -0
  62. package/.docs/raw/docs/legacy/styled/Decomposition.mdx +633 -0
  63. package/.docs/raw/docs/legacy/styled/Markdown.mdx +86 -0
  64. package/.docs/raw/docs/legacy/styled/Scrollbar.mdx +71 -0
  65. package/.docs/raw/docs/legacy/styled/Thread.mdx +84 -0
  66. package/.docs/raw/docs/legacy/styled/ThreadWidth.mdx +21 -0
  67. package/.docs/raw/docs/mcp-docs-server.mdx +324 -0
  68. package/.docs/raw/docs/migrations/deprecation-policy.mdx +41 -0
  69. package/.docs/raw/docs/migrations/v0-7.mdx +188 -0
  70. package/.docs/raw/docs/migrations/v0-8.mdx +160 -0
  71. package/.docs/raw/docs/migrations/v0-9.mdx +75 -0
  72. package/.docs/raw/docs/react-compatibility.mdx +208 -0
  73. package/.docs/raw/docs/runtimes/ai-sdk/rsc.mdx +226 -0
  74. package/.docs/raw/docs/runtimes/ai-sdk/use-assistant-hook.mdx +195 -0
  75. package/.docs/raw/docs/runtimes/ai-sdk/use-chat-hook.mdx +138 -0
  76. package/.docs/raw/docs/runtimes/ai-sdk/use-chat.mdx +136 -0
  77. package/.docs/raw/docs/runtimes/custom/external-store.mdx +1624 -0
  78. package/.docs/raw/docs/runtimes/custom/local.mdx +1185 -0
  79. package/.docs/raw/docs/runtimes/helicone.mdx +60 -0
  80. package/.docs/raw/docs/runtimes/langgraph/index.mdx +320 -0
  81. package/.docs/raw/docs/runtimes/langgraph/tutorial/index.mdx +11 -0
  82. package/.docs/raw/docs/runtimes/langgraph/tutorial/introduction.mdx +28 -0
  83. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +120 -0
  84. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +336 -0
  85. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +385 -0
  86. package/.docs/raw/docs/runtimes/langserve.mdx +126 -0
  87. package/.docs/raw/docs/runtimes/mastra/full-stack-integration.mdx +218 -0
  88. package/.docs/raw/docs/runtimes/mastra/overview.mdx +17 -0
  89. package/.docs/raw/docs/runtimes/mastra/separate-server-integration.mdx +196 -0
  90. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +222 -0
  91. package/.docs/raw/docs/ui/AssistantModal.mdx +46 -0
  92. package/.docs/raw/docs/ui/AssistantSidebar.mdx +42 -0
  93. package/.docs/raw/docs/ui/Attachment.mdx +82 -0
  94. package/.docs/raw/docs/ui/Markdown.mdx +72 -0
  95. package/.docs/raw/docs/ui/Mermaid.mdx +79 -0
  96. package/.docs/raw/docs/ui/Scrollbar.mdx +59 -0
  97. package/.docs/raw/docs/ui/SyntaxHighlighting.mdx +253 -0
  98. package/.docs/raw/docs/ui/Thread.mdx +47 -0
  99. package/.docs/raw/docs/ui/ThreadList.mdx +49 -0
  100. package/.docs/raw/docs/ui/ToolFallback.mdx +64 -0
  101. package/.docs/raw/docs/ui/primitives/Thread.mdx +197 -0
  102. package/LICENSE +21 -0
  103. package/README.md +128 -0
  104. package/dist/chunk-C7O7EFKU.js +38 -0
  105. package/dist/chunk-CZCDQ3YH.js +420 -0
  106. package/dist/index.js +1 -0
  107. package/dist/prepare-docs/prepare.js +199 -0
  108. package/dist/stdio.js +8 -0
  109. package/package.json +43 -0
@@ -0,0 +1,152 @@
1
+ ---
2
+ title: User Authorization
3
+ ---
4
+
5
+ The assistant-ui API can be directly accessed by your frontend. This elliminates the need for a backend server from your side, except for authorization of your users.
6
+
7
+ This document explains how you can setup your server to authorize users to access the assistant-ui API.
8
+
9
+ ## Workspaces
10
+
11
+ Authorization is granted to a workspace. Depending on the structure of your app, you might want to use user_ids as the workspace_id, or you might want to use a more complex structure.
12
+ For example, if your app supports multiple "projects", you might want to use the project_id + user_id as the workspace id (thread history scoped to user+project pairs).
13
+
14
+ ## Workspace Auth Tokens
15
+
16
+ assistant-ui issues workspace auth tokens. These tokens give access to the assistant-ui API for a specific workspace.
17
+ Tokens are short lived (5 minutes), so the client needs to periodically request a new token (handled by assistant-ui).
18
+
19
+ There are two supported approaches to obtain a workspace auth token:
20
+
21
+ - Direct integration with your auth provider
22
+ - From a backend server / serverless function
23
+
24
+ ### Choosing the right approach
25
+
26
+ Direct integration with your auth provider:
27
+
28
+ - simpler to setup and maintain
29
+ - assigns a workspace_id to every user (by using the user_id as the workspace_id)
30
+ - requires a supported auth provider (Clerk, Auth0, Supabase, Firebase, Stytch, Kinde, ...)
31
+
32
+ Backend server:
33
+
34
+ - more complex to setup
35
+ - more flexible workspace structure (multi-user workspaces, workspaces per project, etc.)
36
+ - supports self hosted auth solutions, e.g. Auth.js
37
+ - requires a backend server / serverless function
38
+
39
+ You can always switch between the two approaches without any downtime or necessary database migrations.
40
+ Choose direct integration with your auth provider if you can. Otherwise, use a backend server.
41
+
42
+ ### Auth Provider Integration
43
+ In the AssistantUI dashboard, go to the "Auth Integrations" tab and add a new integration.
44
+ Follow the steps to add your auth provider. (See the auth providers we have guides for at the bottom of this page.)
45
+
46
+ Then, pass in a function to `authToken` that returns an ID token from your auth provider.
47
+
48
+ ```ts
49
+ import { AssistantCloud } from "@assistant-ui/react";
50
+
51
+ const assistantCloud = new AssistantCloud({
52
+ authToken: () => JWT_TOKEN
53
+ });
54
+ ```
55
+
56
+ ### Integration with an Auth Provider
57
+
58
+ #### Backend API Endpoint
59
+
60
+ The following is an api route example to create an auth token based on an authenticated user's orgId and userId.
61
+
62
+ In the Assistant Cloud dashboard, go to the "API Keys" tab and add a new API key, add the key the environment variable `ASSISTANT_API_KEY=[KEY]`
63
+
64
+ ```ts title="/app/api/assistant-ui-token/route.ts"
65
+ import { AssistantCloud } from "@assistant-ui/react";
66
+ import { auth } from "@clerk/nextjs/server";
67
+
68
+ export const POST = async (req: Request) => {
69
+ const { userId, orgId } = await auth();
70
+
71
+ if (!userId) throw new Error("User not authenticated");
72
+
73
+ const workspaceId = orgId ? `${orgId}:${userId}` : userId;
74
+ const assistantCloud = new AssistantCloud({
75
+ apiKey: process.env["ASSISTANT_API_KEY"]!,
76
+ userId,
77
+ workspaceId,
78
+ });
79
+ const {token} = await assistantCloud.auth.tokens.create();
80
+
81
+ return new Response(token);
82
+ };
83
+ ```
84
+
85
+ #### Frontend Implementation
86
+
87
+ The following is an api route example to create an auth token based on an authenticated user's orgId and userId.
88
+
89
+ ```ts title="client.ts"
90
+ const cloud = new AssistantCloud({
91
+ baseUrl: process.env["NEXT_PUBLIC_ASSISTANT_BASE_URL"]!,
92
+ authToken: () =>
93
+ fetch("/api/assistant-ui-token", { method: "POST" }).then((r) =>
94
+ r.json().then((data) => data.token)
95
+ ),
96
+ });
97
+
98
+ const runtime = useChatRuntime({
99
+ api: "/api/chat",
100
+ cloud,
101
+ });
102
+ ```
103
+
104
+ ### Anonymous (without auth provider) Frontend Implementation
105
+
106
+ The following is a example to get auth tokens for Clerk based on the org_id and user_id:
107
+
108
+ ```ts title="/app/api/assistant-ui-token/route.ts"
109
+ import { AssistantCloud } from "@assistant-ui/react";
110
+
111
+ const cloud = new AssistantCloud({
112
+ baseUrl: process.env["NEXT_PUBLIC_ASSISTANT_BASE_URL"]!,
113
+ anonymous: true,
114
+ });
115
+
116
+ const runtime = useChatRuntime({
117
+ api: "/api/chat",
118
+ cloud,
119
+ });
120
+
121
+ return (
122
+ <AssistantRuntimeProvider runtime={runtime}>
123
+ <div className="grid h-dvh grid-cols-[200px_1fr] gap-x-2 px-4 py-4">
124
+ <ThreadList />
125
+ <MyThread />
126
+ </div>
127
+ </AssistantRuntimeProvider>
128
+ );
129
+
130
+ ```
131
+
132
+
133
+ ### Setting up the Clerk Auth Provider
134
+
135
+ First, go to the Clerk dashboard and under "Configure" tab, "JWT Templates" section, create a new template. Choose a blank template and name it "assistant-ui".
136
+
137
+ As the "Claims" field, enter the following:
138
+
139
+ ```json
140
+ {
141
+ "aud": "assistant-ui"
142
+ }
143
+ ```
144
+
145
+ <Callout emoji="⚠️">
146
+ <b>Note:</b> The aud claim ensures that the JWT is only valid for the
147
+ assistant-ui API.
148
+ </Callout>
149
+
150
+ You can leave everything else as default. Take note of the "Issuer" and "JWKS Endpoint" fields.
151
+
152
+ Then, In the assistant-cloud dashboard, navigate to the "Auth Rules" tab and create a new rule. Choose "Clerk" and enter the Issuer and JWKS Endpoint from the previous step. As the "Audience" field, enter "assistant-ui".
@@ -0,0 +1,55 @@
1
+ ---
2
+ title: Overview
3
+ ---
4
+
5
+ Assistant Cloud is a hosted service built for assistant-ui frontends that offers comprehensive thread management and message history. It automatically persists threads, supports human-in-the-loop workflows, and integrates with common auth providers to seamlessly allow users to resume conversations at any point.
6
+
7
+
8
+ ## Features
9
+
10
+ ### Thread management
11
+
12
+ Using our `<ThreadList />` component, show the users a list of conversations. Allow the users to seamlessly switch between conversations and even let long running tasks run in the background.
13
+
14
+ Assistant Cloud automatically persists a list of threads and corresponding metadata. It also automatically generates a title for conversations based on the initial messages.
15
+
16
+ Supported backends:
17
+
18
+ - AI SDK
19
+ - LangGraph
20
+ - Custom
21
+
22
+ ### Chat history
23
+
24
+ For every conversation, Assistant Cloud can store the history of messages, allowing the user to resume the conversation at any point in time.
25
+ This supports human in the loop workflows, where the execution of an agent is interrupted until user feedback is collected.
26
+
27
+ Supported backends:
28
+
29
+ - AI SDK
30
+ - LangGraph
31
+ - Custom (currently only Local Runtime)
32
+
33
+ ### Authorization
34
+
35
+ Assistant Cloud integrates with your auth provider (Clerk, Auth0, Supabase, Firebase, ...) to identify your users and authorize them to access just the conversations they are allowed to see.
36
+
37
+ Supported auth providers:
38
+
39
+ - Clerk
40
+ - Auth0
41
+ - Supabase
42
+ - Firebase
43
+ - Your own
44
+
45
+ ## Getting Started
46
+
47
+ To get started, create an account at [Assistant Cloud Dashboard](https://cloud.assistant-ui.com/) and follow one of the walkthroughs for your preferred backend:
48
+
49
+ - [AI SDK](/docs/cloud/persistence/ai-sdk)
50
+ - [LangGraph](/docs/cloud/persistence/langgraph)
51
+
52
+ You can also check out our example repositories to see how to integrate Assistant Cloud with your frontend:
53
+
54
+ - [With AI SDK](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-cloud)
55
+ - [With LangGraph](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-langgraph)
@@ -0,0 +1,54 @@
1
+ ---
2
+ title: Chat History for AI SDK
3
+ ---
4
+
5
+ ## Overview
6
+
7
+ With the help of assistant-cloud, you can add thread management and thread history capabilities to assistant-ui. This guide will walk you through the process of integrating assistant-cloud with the AI SDK by Vercel.
8
+
9
+ ### Prerequisites
10
+
11
+ You need an assistant-cloud account to follow this guide. You can sign up here: [https://cloud.assistant-ui.com/](https://cloud.assistant-ui.com/)
12
+
13
+ ### Setting up assistant-cloud project in your react project:
14
+
15
+ 1. Create a new project on the assistant-cloud dashboard and copy the Frontend API URL (`https://proj-[ID].assistant-api.com`) from the settings page.
16
+ 2. Add the url as an environment variable `NEXT_PUBLIC_ASSISTANT_BASE_URL`
17
+
18
+ ```bash
19
+ NEXT_PUBLIC_ASSISTANT_BASE_URL=[YOUR_FRONTEND_API_URL]
20
+ ```
21
+ 3. Create a client side AssistantCloud instance. Note: this will create an anonymous user id that is tied to the user's browser session. For connecting to an auth provider to persist threads for a user based on a workspace and/or user id, look at [Cloud Authorization Docs](/docs/cloud/authorization).
22
+
23
+ ```typescript
24
+ "use client";
25
+ import {
26
+ AssistantCloud,
27
+ AssistantRuntimeProvider,
28
+ ThreadList,
29
+ Thread
30
+ } from "@assistant-ui/react";
31
+ import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
32
+
33
+
34
+ const cloud = new AssistantCloud({
35
+ baseUrl: process.env["NEXT_PUBLIC_ASSISTANT_BASE_URL"]!,
36
+ anonymous: true,
37
+ });
38
+
39
+
40
+ const runtime = useChatRuntime({
41
+ api: "/api/chat",
42
+ cloud,
43
+ });
44
+
45
+ return (
46
+ <AssistantRuntimeProvider runtime={runtime}>
47
+ <div className="grid h-dvh grid-cols-[200px_1fr] gap-x-2 px-4 py-4">
48
+ <ThreadList />
49
+ <Thread />
50
+ </div>
51
+ </AssistantRuntimeProvider>
52
+ );
53
+
54
+ ```
@@ -0,0 +1,123 @@
1
+ ---
2
+ title: Chat History for LangGraph Cloud
3
+ ---
4
+
5
+ ## Overview
6
+
7
+ With the help of assistant-cloud, you can add thread management and thread history capabilities to assistant-ui.
8
+ This guide will walk you through the process of integrating assistant-cloud with LangGraph Cloud.
9
+
10
+ ### Prerequisites
11
+
12
+ You need an assistant-cloud account to follow this guide.
13
+ You can sign up here: https://cloud.assistant-ui.com/
14
+
15
+ ### Setting up an assistant-cloud project
16
+
17
+ To get started, follow the steps below:
18
+
19
+ - Create a new project on the assistant-cloud dashboard.
20
+ - Navigate to the "Settings" tab and copy the Frontend API URL.
21
+ - Add this URL to your .env file
22
+
23
+ ```bash
24
+ NEXT_PUBLIC_ASSISTANT_BASE_URL=https://<your-frontend-api-url>
25
+ ```
26
+
27
+ ### Connecting the runtime provider
28
+
29
+ Now that we have everything set up, let's write the code for the runtime provider.
30
+
31
+ The code below is a simple LangGraph runtime provider that uses the assistant-cloud API to create and manage threads.
32
+
33
+ ```tsx twoslash {1-2,5-6,19,27,29-36,38-45}
34
+ // @errors: 2307
35
+
36
+ "use client";
37
+
38
+ import {
39
+ AssistantCloud,
40
+ AssistantRuntimeProvider,
41
+ useCloudThreadListRuntime,
42
+ useThreadListItemRuntime,
43
+ } from "@assistant-ui/react";
44
+ import { useLangGraphRuntime } from "@assistant-ui/react-langgraph";
45
+ import { createThread, getThreadState, sendMessage } from "@/lib/chatApi";
46
+ import { LangChainMessage } from "@assistant-ui/react-langgraph";
47
+ import { useAuth } from "@clerk/nextjs";
48
+ import { useMemo } from "react";
49
+
50
+ // ---cut---
51
+ const useMyLangGraphRuntime = () => {
52
+ const threadListItemRuntime = useThreadListItemRuntime();
53
+ const runtime = useLangGraphRuntime({
54
+ stream: async function* (messages) {
55
+ const { externalId } = await threadListItemRuntime.initialize();
56
+ if (!externalId) throw new Error("Thread not found");
57
+
58
+ return sendMessage({ threadId: externalId, messages });
59
+ },
60
+ onSwitchToThread: async (externalId) => {
61
+ const state = await getThreadState(externalId);
62
+ return {
63
+ messages:
64
+ (state.values as { messages?: LangChainMessage[] }).messages ?? [],
65
+ };
66
+ },
67
+ });
68
+
69
+ return runtime;
70
+ };
71
+
72
+ export function MyRuntimeProvider({
73
+ children,
74
+ }: Readonly<{
75
+ children: React.ReactNode;
76
+ }>) {
77
+ const { getToken } = useAuth();
78
+
79
+ const cloud = useMemo(
80
+ () =>
81
+ new AssistantCloud({
82
+ baseUrl: process.env["NEXT_PUBLIC_ASSISTANT_BASE_URL"]!,
83
+ authToken: async () => getToken({ template: "assistant-ui" }),
84
+ }),
85
+ [getToken],
86
+ );
87
+
88
+ const runtime = useCloudThreadListRuntime({
89
+ cloud,
90
+ runtimeHook: useMyLangGraphRuntime,
91
+ create: async () => {
92
+ const { thread_id } = await createThread();
93
+ return { externalId: thread_id };
94
+ },
95
+ });
96
+
97
+ return (
98
+ <AssistantRuntimeProvider runtime={runtime}>
99
+ {children}
100
+ </AssistantRuntimeProvider>
101
+ );
102
+ }
103
+ ```
104
+
105
+ <Callout emoji="💡">
106
+ Observe that the `useMyLangGraphRuntime` hook is extracted into a separate
107
+ function. This hook will be mounted multiple times, once per active thread.
108
+ </Callout>
109
+
110
+ ### Displaying a ThreadList component
111
+
112
+ Now, you can add a ThreadList component to your application. This component will display a list of threads and allow users to switch between them.
113
+
114
+ ```sh
115
+ npx shadcn@latest add "https://r.assistant-ui.com/thread-list"
116
+ ```
117
+
118
+ ```tsx
119
+ <div className="grid grid-cols-[250px_1fr]">
120
+ <ThreadList />
121
+ <Thread />
122
+ </div>
123
+ ```
@@ -0,0 +1,19 @@
1
+ ---
2
+ title: Architecture
3
+ ---
4
+
5
+ import Image from "next/image";
6
+ import architecture from "@/assets/docs/architecture.png";
7
+
8
+ ### Architecture
9
+
10
+ `assistant-ui` consists of two parts, **_Runtime_** and **_UI Components_**.
11
+
12
+ <Image
13
+ src={architecture}
14
+ alt="Architecture diagram, UI components connected to the runtime layer and the runtime layer connected to LLM and tools"
15
+ height={300}
16
+ className="mx-auto my-2 dark:hue-rotate-180 dark:invert"
17
+ />
18
+
19
+ The Runtime and UI Components each require independent setup and both must be set up.
@@ -0,0 +1,163 @@
1
+ ---
2
+ title: Runtime Layer
3
+ ---
4
+
5
+ assistant-ui components are full stack components. This means that they include both the UI presentation, but also logic to communicate with an external system. This logic is handled by the runtime layer and APIs.
6
+
7
+ You interact with the runtime layer in two ways:
8
+
9
+ - defining a runtime for your app
10
+ - using the runtime APIs to interact with the runtime
11
+
12
+ ## Defining a runtime
13
+
14
+ assistant-ui ships with two low-level runtimes:
15
+
16
+ - `useLocalRuntime`
17
+ - `useExternalStoreRuntime`
18
+
19
+ Both of these runtimes let you implement your own runtime. The conceptual difference between the two is that `useLocalRuntime` takes ownership of the data layer, while `useExternalStoreRuntime` does not.
20
+
21
+ If you have a stateful API to integrate, use `useExternalStoreRuntime`, if you have a stateless API to integrate, use `useLocalRuntime`.
22
+
23
+ ### Higher level runtimes
24
+
25
+ For many services and APIs, assistant-ui provides deeper integrations. These are built with the two low-level runtimes mentioned above.
26
+
27
+ - `useChatRuntime`: Connect to Vercel AI SDK backends
28
+ - `useVercelUseChatRuntime`: Integrate with Vercel AI SDK's `useChat` hook
29
+ - `useVercelUseAssistantRuntime`: Integrate with Vercel AI SDK's `useAssistant` hook (OpenAI Assistants API)
30
+ - `useVercelRSCRuntime`: Integrate with Vercel AI SDK React Server Components
31
+ - `useLangGraphRuntime`: Connect to LangGraph Cloud
32
+ - ...
33
+
34
+ ### Runtime Providers
35
+
36
+ The following components accept a `runtime` prop:
37
+
38
+ - `AssistantRuntimeProvider`
39
+ - `Thread`
40
+
41
+ These components put the Runtime in the React Context, so that all child components can access the runtime.
42
+
43
+ ### Runtime Adapters
44
+
45
+ Most runtimes accept additional adapters to configure extra integrations:
46
+
47
+ - ChatModelAdapter: Configures the backend API
48
+ - AttachmentAdapter: Configures the file/media attachment API
49
+ - SpeechSynthesisAdapter: Configures the speech API
50
+ - FeedbackAdapter: Configures the feedback API
51
+ - SuggestionAdapter: Configures dynamic suggestion generation based on conversation context
52
+
53
+ ## Using the runtime APIs
54
+
55
+ The same API used by the assistant-ui components is also available to you. This allows you to build your own UI components and integrate them with the runtime layer.
56
+
57
+ ### Runtime Hierarchy
58
+
59
+ The runtime API is nested as such:
60
+
61
+ import { File, Folder, Files } from "fumadocs-ui/components/files";
62
+
63
+ <Files>
64
+ <Folder name="AssistantRuntime" defaultOpen>
65
+ <Folder name="ThreadListRuntime" defaultOpen>
66
+ <Folder name="ThreadRuntime" defaultOpen>
67
+ <Folder name="MessageRuntime" defaultOpen>
68
+ <Folder
69
+ name="ContentPartRuntime (Text / Reasoning / Image / Audio / Tool-Call / UI)"
70
+ defaultOpen
71
+ ></Folder>
72
+ <Folder name="MessageAttachmentRuntime" defaultOpen></Folder>
73
+ <Folder name="EditComposerRuntime" defaultOpen>
74
+ <Folder name="EditComposerAttachmentRuntime" defaultOpen></Folder>
75
+ </Folder>
76
+ </Folder>
77
+ <Folder name="ThreadComposerRuntime" defaultOpen>
78
+ <Folder name="ThreadComposerAttachmentRuntime" defaultOpen></Folder>
79
+ </Folder>
80
+ </Folder>
81
+ </Folder>
82
+ </Folder>
83
+ </Files>
84
+
85
+ The AssistantRuntime (which encompasses everything), is sometimes simply called `Runtime`.
86
+
87
+ ### Runtime Context Provider Components
88
+
89
+ The following components provide the runtime APIs:
90
+
91
+ ```tsx
92
+ // provides AssistantRuntime, ThreadListRuntime, ThreadRuntime, ComposerRuntime (ThreadComposer)
93
+ <AssistantRuntimeProvider runtime={runtime} />
94
+
95
+ // renders every message, provides MessageRuntime, ComposerRuntime (EditComposer)
96
+ <ThreadPrimitive.Messages components={{ Message, ... }} />
97
+
98
+ // renders every content part, provides ContentPartRuntime
99
+ <MessagePrimitive.Content components={{ Text, Reasoning, Image, Audio, UI, tools }} />
100
+
101
+ // renders every attachment, provides AttachmentRuntime (Thread or EditComposer)
102
+ <ComposerPrimitive.Attachments components={{ Attachment, ... }} />
103
+
104
+ // renders every attachment, provides AtatchmentRuntime (Message)
105
+ <MessagePrimitive.Attachments components={{ Attachment, ... }} />
106
+
107
+ // provides a custom TextContentPartRuntime
108
+ <TextContentPartProvider text="Hello!" />
109
+ ```
110
+
111
+ ### Accessing runtime APIs
112
+
113
+ You can access the runtime APIs with react hooks:
114
+
115
+ ```tsx
116
+ const runtime = useAssistantRuntime();
117
+ const threadRuntime = useThreadRuntime();
118
+ const messageRuntime = useMessageRuntime();
119
+ const contentPartRuntime = useContentPartRuntime();
120
+
121
+ // thread manager has no separate hook (1:1 relationship with assistant runtime)
122
+ const ThreadListRuntime = useAssistantRuntime().threads;
123
+
124
+ // composer runtime is multi-use
125
+ const composerRuntime = useComposerRuntime(); // refers to edit composer if available, otherwise thread composer
126
+
127
+ // thread manager has no separate hook (1:1 relationship with assistant runtime)
128
+ const threadComposer = useThreadRuntime().composer;
129
+
130
+ // thread manager has no separate hook (1:1 relationship with assistant runtime)
131
+ const editComposerRuntime = useMessageRuntime().composer;
132
+
133
+ // attachment runtime is multi-use
134
+ const attachmentRuntime = useAttachmentRuntime(); // refers to the closest attachment runtime
135
+ const threadComposerAttachmentRuntime = useThreadComposerAttachmentRuntime();
136
+ const editComposerAttachmentRuntime = useEditComposerAttachmentRuntime();
137
+ const messageAttachmentRuntime = useMessageAttachmentRuntime();
138
+ ```
139
+
140
+ ### Accessing runtime state
141
+
142
+ Most runtimes also expose a state through two methods `getState` and `subscribe`. The following helper hooks subscribe to the state, so that your component is updated when the state changes:
143
+
144
+ ```tsx
145
+ useThreadList(); // get thread manager state
146
+ useThread(); // get thread state
147
+ useMessage(); // get message state
148
+ useContentPart(); // get content part state
149
+ useComposer(); // get composer state
150
+ useThreadComposer(); // get thread composer state
151
+ useEditComposer(); // get edit composer state
152
+ useAttachment(); // get attachment state
153
+ useThreadComposerAttachment(); // get thread composer attachment state
154
+ useEditComposerAttachment(); // get edit composer attachment state
155
+ useMessageAttachment(); // get message attachment state
156
+ ```
157
+
158
+ You might not want to subscribe to evey update. In that case, pass a callback selector to the hook:
159
+
160
+ ```tsx
161
+ // only subscribe to role changes
162
+ const role = useMessage((state) => message.role);
163
+ ```
@@ -0,0 +1,9 @@
1
+ ---
2
+ title: Why assistant-ui?
3
+ ---
4
+
5
+ assistant-ui is a collection of powerful, modular primitives to build AI chat interfaces.
6
+
7
+ The modular approach means that you can incrementally adopt assistant-ui (e.g. use the backend connectors and bring your own components, or use the frontend compoents and bring your own backend).
8
+ You can also partially opt out of assistant-ui whenever you hit any limitation in the library.
9
+
@@ -0,0 +1,71 @@
1
+ ---
2
+ title: makeAssistantVisible
3
+ ---
4
+
5
+ `makeAssistantVisible` is a higher-order component (HOC) that makes React components "visible" by the assistant, allowing it to understand and interact with the component's HTML structure.
6
+
7
+ ## Usage
8
+
9
+ ```tsx
10
+ import { makeAssistantVisible } from "@assistant-ui/react";
11
+
12
+ const Button = ({ onClick, children }) => (
13
+ <button onClick={onClick}>{children}</button>
14
+ );
15
+
16
+ // Basic usage - makes component HTML readable
17
+ const ReadableButton = makeAssistantVisible(Button);
18
+
19
+ // With clickable configuration
20
+ const ClickableButton = makeAssistantVisible(Button, {
21
+ clickable: true, // Enables the click tool
22
+ });
23
+ ```
24
+
25
+ ## API Reference
26
+
27
+ ### Parameters
28
+
29
+ - `Component`: The base React component to enhance
30
+ - `config`: Optional configuration object
31
+ - `clickable`: When true, enables the assistant to programmatically click the component
32
+
33
+ ### Behavior
34
+
35
+ The HOC will:
36
+
37
+ 1. Make the component's HTML structure available to the assistant via the system context
38
+ 2. Optionally provide a `click` tool if `clickable` is true
39
+ 3. Handle nested readable components (only the outermost component's HTML is provided)
40
+ 4. Forward refs and maintain component props
41
+
42
+ ## Example
43
+
44
+ ```tsx
45
+ // Create a readable form input
46
+ const Input = ({ label, ...props }) => (
47
+ <div>
48
+ <label>{label}</label>
49
+ <input {...props} />
50
+ </div>
51
+ );
52
+
53
+ const ReadableInput = makeAssistantVisible(Input);
54
+
55
+ // Use in your component
56
+ function Form() {
57
+ return (
58
+ <ReadableInput label="Email" type="email" placeholder="Enter your email" />
59
+ );
60
+ }
61
+ ```
62
+
63
+ ## Technical Details
64
+
65
+ When a component is made readable:
66
+
67
+ - It's wrapped in a `ReadableContext.Provider` to handle nesting
68
+ - The component's `outerHTML` is provided as system context
69
+ - If `clickable` is true, a unique `data-click-id` is added and a `click` tool is provided
70
+ - The click tool uses `querySelector` and simulates a click event
71
+ - All props and refs are properly forwarded to maintain component functionality