@assistant-ui/mcp-docs-server 0.2.1 → 0.2.3

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 (187) hide show
  1. package/.docs/organized/code-examples/waterfall.md +3 -3
  2. package/.docs/organized/code-examples/with-a2a.md +5 -4
  3. package/.docs/organized/code-examples/with-ag-ui.md +7 -6
  4. package/.docs/organized/code-examples/with-ai-sdk-v7.md +14 -13
  5. package/.docs/organized/code-examples/with-artifacts.md +12 -11
  6. package/.docs/organized/code-examples/with-assistant-transport.md +6 -5
  7. package/.docs/organized/code-examples/with-browser-extension.md +6 -6
  8. package/.docs/organized/code-examples/with-chain-of-thought.md +16 -14
  9. package/.docs/organized/code-examples/with-cloud-standalone.md +7 -7
  10. package/.docs/organized/code-examples/with-cloud.md +11 -10
  11. package/.docs/organized/code-examples/with-custom-thread-list.md +11 -10
  12. package/.docs/organized/code-examples/with-elevenlabs-conversational.md +14 -13
  13. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +15 -14
  14. package/.docs/organized/code-examples/with-eve.md +6 -5
  15. package/.docs/organized/code-examples/with-expo.md +213 -36
  16. package/.docs/organized/code-examples/with-external-store.md +6 -5
  17. package/.docs/organized/code-examples/with-ffmpeg.md +11 -10
  18. package/.docs/organized/code-examples/with-generative-ui.md +263 -29
  19. package/.docs/organized/code-examples/with-google-adk.md +5 -4
  20. package/.docs/organized/code-examples/with-heat-graph.md +3 -3
  21. package/.docs/organized/code-examples/with-image-generation.md +8 -7
  22. package/.docs/organized/code-examples/with-interactables.md +11 -10
  23. package/.docs/organized/code-examples/with-langchain.md +10 -9
  24. package/.docs/organized/code-examples/with-langgraph.md +7 -6
  25. package/.docs/organized/code-examples/with-livekit.md +15 -14
  26. package/.docs/organized/code-examples/with-mcp.md +14 -12
  27. package/.docs/organized/code-examples/with-nuxt.md +511 -575
  28. package/.docs/organized/code-examples/with-opencode.md +4 -4
  29. package/.docs/organized/code-examples/with-openui.md +450 -0
  30. package/.docs/organized/code-examples/with-pi.md +6 -5
  31. package/.docs/organized/code-examples/with-react-hook-form.md +16 -13
  32. package/.docs/organized/code-examples/with-react-ink-web.md +65 -15
  33. package/.docs/organized/code-examples/with-react-ink.md +5 -4
  34. package/.docs/organized/code-examples/with-react-router.md +8 -7
  35. package/.docs/organized/code-examples/with-resumable-stream.md +13 -12
  36. package/.docs/organized/code-examples/with-store.md +3 -3
  37. package/.docs/organized/code-examples/with-svelte.md +415 -0
  38. package/.docs/organized/code-examples/with-sveltekit.md +1061 -0
  39. package/.docs/organized/code-examples/with-tanstack.md +10 -9
  40. package/.docs/organized/code-examples/with-tap-runtime.md +5 -4
  41. package/.docs/organized/code-examples/with-virtualized-thread.md +6 -5
  42. package/.docs/organized/code-examples/with-vue.md +2 -2
  43. package/.docs/raw/docs/{(docs) → (getting-started)}/cli.mdx +6 -1
  44. package/.docs/raw/docs/{(docs) → (getting-started)}/devtools.mdx +1 -1
  45. package/.docs/raw/docs/{(docs) → (getting-started)}/index.mdx +4 -2
  46. package/.docs/raw/docs/{(docs) → (getting-started)}/installation.mdx +26 -26
  47. package/.docs/raw/docs/(reference)/api-reference/adapters/suggestions.mdx +6 -0
  48. package/.docs/raw/docs/(reference)/api-reference/context-providers/assistant-runtime-provider.mdx +1 -1
  49. package/.docs/raw/docs/(reference)/api-reference/external-store/message-conversion.mdx +6 -1
  50. package/.docs/raw/docs/(reference)/api-reference/generative-ui/slack.mdx +5 -1
  51. package/.docs/raw/docs/(reference)/api-reference/generative-ui/teams.mdx +9 -2
  52. package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +2 -2
  53. package/.docs/raw/docs/(reference)/api-reference/integrations/{react-ai-sdk.mdx → ai-sdk.mdx} +43 -18
  54. package/.docs/raw/docs/(reference)/api-reference/integrations/eve.mdx +61 -2
  55. package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +3 -3
  56. package/.docs/raw/docs/(reference)/api-reference/overview.mdx +2 -2
  57. package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +20 -2
  58. package/.docs/raw/docs/(reference)/api-reference/tools/interactables.mdx +1 -1
  59. package/.docs/raw/docs/(reference)/api-reference/tools/status.mdx +1 -1
  60. package/.docs/raw/docs/(reference)/api-reference/transport/frame.mdx +1 -1
  61. package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +32 -1
  62. package/.docs/raw/docs/(reference)/api-reference/voice/session.mdx +1 -1
  63. package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +10 -10
  64. package/.docs/raw/docs/cloud/ai-sdk.mdx +4 -2
  65. package/.docs/raw/docs/cloud/index.mdx +1 -1
  66. package/.docs/raw/docs/copilots/assistant-frame.mdx +19 -8
  67. package/.docs/raw/docs/guides/attachments.mdx +4 -4
  68. package/.docs/raw/docs/guides/branching.mdx +1 -1
  69. package/.docs/raw/docs/guides/chatgpt-subscription.mdx +1 -1
  70. package/.docs/raw/docs/guides/context-api.mdx +15 -17
  71. package/.docs/raw/docs/guides/dictation.mdx +2 -2
  72. package/.docs/raw/docs/guides/electron.mdx +1 -1
  73. package/.docs/raw/docs/guides/latex.mdx +1 -1
  74. package/.docs/raw/docs/guides/mentions.mdx +2 -0
  75. package/.docs/raw/docs/guides/message-timing.mdx +11 -5
  76. package/.docs/raw/docs/guides/quoting.mdx +1 -1
  77. package/.docs/raw/docs/guides/resumable-streams.mdx +3 -3
  78. package/.docs/raw/docs/guides/speech.mdx +1 -1
  79. package/.docs/raw/docs/guides/suggestions.mdx +8 -5
  80. package/.docs/raw/docs/guides/voice.mdx +1 -1
  81. package/.docs/raw/docs/ink/hooks.mdx +1 -1
  82. package/.docs/raw/docs/ink/index.mdx +3 -2
  83. package/.docs/raw/docs/ink/migration.mdx +1 -1
  84. package/.docs/raw/docs/ink/primitives.mdx +1 -1
  85. package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +3 -3
  86. package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +3 -3
  87. package/.docs/raw/docs/integrations/frameworks/{cloudflare-agents/overview.mdx → cloudflare-agents.mdx} +4 -3
  88. package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +1 -1
  89. package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +1 -1
  90. package/.docs/raw/docs/integrations/index.mdx +2 -2
  91. package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +149 -131
  92. package/.docs/raw/docs/migrations/toolkit-tools.mdx +2 -2
  93. package/.docs/raw/docs/migrations/v0-15.mdx +34 -0
  94. package/.docs/raw/docs/primitives/action-bar.mdx +1 -1
  95. package/.docs/raw/docs/primitives/assistant-modal.mdx +1 -1
  96. package/.docs/raw/docs/primitives/attachment.mdx +1 -1
  97. package/.docs/raw/docs/primitives/branch-picker.mdx +1 -1
  98. package/.docs/raw/docs/primitives/chain-of-thought.mdx +3 -3
  99. package/.docs/raw/docs/primitives/composer.mdx +1 -1
  100. package/.docs/raw/docs/primitives/error.mdx +1 -1
  101. package/.docs/raw/docs/primitives/message.mdx +1 -1
  102. package/.docs/raw/docs/primitives/selection-toolbar.mdx +1 -1
  103. package/.docs/raw/docs/primitives/suggestion.mdx +4 -2
  104. package/.docs/raw/docs/primitives/thread-list.mdx +1 -1
  105. package/.docs/raw/docs/primitives/thread.mdx +2 -2
  106. package/.docs/raw/docs/react-native/adapters.mdx +1 -1
  107. package/.docs/raw/docs/react-native/index.mdx +2 -2
  108. package/.docs/raw/docs/react-native/migration.mdx +2 -2
  109. package/.docs/raw/docs/react-native/primitives.mdx +142 -5
  110. package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +48 -6
  111. package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +3 -3
  112. package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +4 -4
  113. package/.docs/raw/docs/runtimes/ai-sdk/v7.mdx +31 -16
  114. package/.docs/raw/docs/runtimes/claude-managed-agents.mdx +118 -0
  115. package/.docs/raw/docs/runtimes/concepts/adapters.mdx +3 -3
  116. package/.docs/raw/docs/runtimes/concepts/architecture.mdx +3 -3
  117. package/.docs/raw/docs/runtimes/concepts/stability.mdx +2 -1
  118. package/.docs/raw/docs/runtimes/concepts/threads.mdx +73 -33
  119. package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +1 -1
  120. package/.docs/raw/docs/runtimes/custom/external-store.mdx +6 -2
  121. package/.docs/raw/docs/runtimes/langchain.mdx +2 -2
  122. package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +4 -0
  123. package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +1 -1
  124. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +9 -2
  125. package/.docs/raw/docs/tools/backend.mdx +4 -4
  126. package/.docs/raw/docs/tools/defining-tools.mdx +21 -2
  127. package/.docs/raw/docs/tools/generative-ui-primitive.mdx +180 -0
  128. package/.docs/raw/docs/tools/generative-ui-slack.mdx +167 -0
  129. package/.docs/raw/docs/tools/generative-ui-teams.mdx +160 -0
  130. package/.docs/raw/docs/tools/generative-ui.mdx +224 -211
  131. package/.docs/raw/docs/tools/index.mdx +2 -1
  132. package/.docs/raw/docs/tools/interactables.mdx +8 -7
  133. package/.docs/raw/docs/tools/mcp-apps.mdx +18 -1
  134. package/.docs/raw/docs/tools/mcp.mdx +2 -2
  135. package/.docs/raw/docs/tools/openui.mdx +175 -0
  136. package/.docs/raw/docs/tools/tool-ui.mdx +18 -7
  137. package/.docs/raw/docs/tools/user-managed-mcp.mdx +7 -3
  138. package/.docs/raw/docs/ui/assistant-modal.mdx +3 -3
  139. package/.docs/raw/docs/ui/assistant-sidebar.mdx +1 -1
  140. package/.docs/raw/docs/ui/attachment.mdx +50 -3
  141. package/.docs/raw/docs/ui/composer-trigger-popover.mdx +36 -1
  142. package/.docs/raw/docs/ui/context-display.mdx +1 -1
  143. package/.docs/raw/docs/ui/directive-text.mdx +1 -1
  144. package/.docs/raw/docs/ui/file.mdx +2 -2
  145. package/.docs/raw/docs/ui/follow-up-suggestions.mdx +1 -1
  146. package/.docs/raw/docs/ui/image.mdx +2 -2
  147. package/.docs/raw/docs/ui/markdown.mdx +40 -1
  148. package/.docs/raw/docs/ui/mermaid.mdx +1 -1
  149. package/.docs/raw/docs/ui/message-timing.mdx +1 -1
  150. package/.docs/raw/docs/ui/model-selector.mdx +4 -4
  151. package/.docs/raw/docs/ui/part-grouping.mdx +1 -1
  152. package/.docs/raw/docs/ui/quote.mdx +3 -3
  153. package/.docs/raw/docs/ui/reasoning.mdx +31 -3
  154. package/.docs/raw/docs/ui/scrollbar.mdx +1 -1
  155. package/.docs/raw/docs/ui/sources.mdx +10 -1
  156. package/.docs/raw/docs/ui/streamdown.mdx +2 -2
  157. package/.docs/raw/docs/ui/syntax-highlighting.mdx +1 -1
  158. package/.docs/raw/docs/ui/thread-list.mdx +40 -1
  159. package/.docs/raw/docs/ui/thread.mdx +49 -2
  160. package/.docs/raw/docs/ui/tool-fallback.mdx +23 -9
  161. package/.docs/raw/docs/ui/tool-group.mdx +1 -1
  162. package/.docs/raw/docs/ui/voice.mdx +1 -1
  163. package/.docs/raw/docs/utilities/react-o11y.mdx +2 -2
  164. package/dist/xulux/catalog-client.d.ts.map +1 -1
  165. package/dist/xulux/catalog-client.js +51 -6
  166. package/dist/xulux/catalog-client.js.map +1 -1
  167. package/dist/xulux/types.d.ts +7 -7
  168. package/dist/xulux/types.d.ts.map +1 -1
  169. package/dist/xulux/types.js.map +1 -1
  170. package/package.json +5 -5
  171. package/src/tools/tests/docs.test.ts +10 -7
  172. package/src/tools/tests/path-traversal.test.ts +5 -2
  173. package/src/tools/tests/xulux-templates.test.ts +63 -0
  174. package/src/xulux/catalog-client.ts +68 -23
  175. package/src/xulux/types.ts +17 -13
  176. package/.docs/raw/docs/tools/interactables-legacy.mdx +0 -423
  177. package/.docs/raw/docs/ui/accordion.mdx +0 -266
  178. package/.docs/raw/docs/ui/badge.mdx +0 -150
  179. package/.docs/raw/docs/ui/diff-viewer.mdx +0 -280
  180. package/.docs/raw/docs/ui/dot-matrix.mdx +0 -133
  181. package/.docs/raw/docs/ui/number-roll.mdx +0 -154
  182. package/.docs/raw/docs/ui/select.mdx +0 -254
  183. package/.docs/raw/docs/ui/tabs.mdx +0 -271
  184. /package/.docs/raw/docs/{(docs) → (getting-started)}/architecture.mdx +0 -0
  185. /package/.docs/raw/docs/{(docs) → (getting-started)}/base-ui.mdx +0 -0
  186. /package/.docs/raw/docs/{(docs) → (getting-started)}/llm.mdx +0 -0
  187. /package/.docs/raw/docs/{(docs) → (getting-started)}/rtl.mdx +0 -0
@@ -26,7 +26,7 @@ describe("Path Traversal Security", () => {
26
26
 
27
27
  it("should handle multiple paths with one malicious", async () => {
28
28
  const result = await testContext.callTool("assistantUIDocs", {
29
- paths: ["(docs)/index", "../../../../etc/passwd", "guides"],
29
+ paths: ["(getting-started)/index", "../../../../etc/passwd", "guides"],
30
30
  });
31
31
 
32
32
  expect(result.results).toBeDefined();
@@ -63,7 +63,10 @@ describe("Path Traversal Security", () => {
63
63
  describe("Valid paths should still work", () => {
64
64
  it("should allow valid documentation paths", async () => {
65
65
  const result = await testContext.callTool("assistantUIDocs", {
66
- paths: ["(docs)/index", "(reference)/api-reference/primitives/thread"],
66
+ paths: [
67
+ "(getting-started)/index",
68
+ "(reference)/api-reference/primitives/thread",
69
+ ],
67
70
  });
68
71
 
69
72
  expect(result.results).toBeDefined();
@@ -134,6 +134,69 @@ describe("assistant-ui template MCP tools", () => {
134
134
  );
135
135
  });
136
136
 
137
+ it("uses the fallback catalog when a live template entry is malformed", async () => {
138
+ vi.stubGlobal(
139
+ "fetch",
140
+ vi.fn(async () =>
141
+ jsonResponse({
142
+ ...LIVE_CATALOG,
143
+ templates: [
144
+ {
145
+ id: "broken",
146
+ templateId: "broken",
147
+ kind: "template",
148
+ },
149
+ ],
150
+ }),
151
+ ),
152
+ );
153
+
154
+ const result = await callTool(xuluxTemplatesListTool, {});
155
+ expect(result.catalogDegraded).toBe(true);
156
+ expect(result.catalogDegradedReason).toContain(
157
+ "Catalog response is malformed",
158
+ );
159
+ expect(result.templates.map((t: { id: string }) => t.id)).toContain(
160
+ "base-assistant-ui",
161
+ );
162
+ });
163
+
164
+ it("names the version when the live catalog is a newer revision", async () => {
165
+ vi.stubGlobal(
166
+ "fetch",
167
+ vi.fn(async () => jsonResponse({ ...LIVE_CATALOG, version: 2 })),
168
+ );
169
+
170
+ const result = await callTool(xuluxTemplatesListTool, {});
171
+ expect(result.catalogDegraded).toBe(true);
172
+ expect(result.catalogDegradedReason).toContain(
173
+ "Unsupported catalog version: 2. Expected 1.",
174
+ );
175
+ });
176
+
177
+ it("uses the fallback catalog when a live template URL is malformed", async () => {
178
+ vi.stubGlobal(
179
+ "fetch",
180
+ vi.fn(async () =>
181
+ jsonResponse({
182
+ ...LIVE_CATALOG,
183
+ templates: [
184
+ {
185
+ ...LIVE_CATALOG.templates[0],
186
+ sandboxBaseUrl: "not a URL",
187
+ },
188
+ ],
189
+ }),
190
+ ),
191
+ );
192
+
193
+ const result = await callTool(xuluxTemplatesListTool, {});
194
+ expect(result.catalogDegraded).toBe(true);
195
+ expect(result.catalogDegradedReason).toContain(
196
+ "Catalog response is malformed",
197
+ );
198
+ });
199
+
137
200
  it("returns details and fetches exampleConfig from the selected sandbox contract", async () => {
138
201
  const fetchMock = vi.fn(async (url: string | URL) => {
139
202
  const href = String(url);
@@ -1,11 +1,65 @@
1
+ import { z } from "zod";
1
2
  import { logger } from "../utils/logger.js";
2
3
  import { FALLBACK_CATALOG, FALLBACK_NOTE } from "./fallback-catalog.js";
3
- import type { XuluxCatalog, XuluxCatalogResult } from "./types.js";
4
+ import {
5
+ XULUX_MCP_CATALOG_VERSION,
6
+ type XuluxCatalog,
7
+ type XuluxCatalogResult,
8
+ } from "./types.js";
4
9
 
5
10
  export const DEFAULT_CATALOG_URL =
6
11
  "https://www.assistant-ui.com/api/xulux/mcp-catalog";
7
12
 
8
13
  const CATALOG_TTL_MS = 5 * 60 * 1000;
14
+ const catalogUrlSchema = z.url();
15
+
16
+ const catalogVersionSchema = z.looseObject({
17
+ id: z.string(),
18
+ entryId: z.string(),
19
+ name: z.string(),
20
+ description: z.string(),
21
+ previewUrl: catalogUrlSchema,
22
+ downloadUrl: catalogUrlSchema,
23
+ });
24
+
25
+ const catalogTemplateSchema = z.looseObject({
26
+ id: z.string(),
27
+ templateId: z.string(),
28
+ versionId: z.string().nullable(),
29
+ kind: z.enum(["template", "example"]),
30
+ name: z.string(),
31
+ summary: z.string(),
32
+ assistantPlacement: z.string(),
33
+ features: z.array(z.string()),
34
+ customizable: z.array(z.string()),
35
+ versions: z.array(catalogVersionSchema),
36
+ previewUrl: catalogUrlSchema.optional(),
37
+ downloadUrl: catalogUrlSchema.optional(),
38
+ sandboxBaseUrl: catalogUrlSchema.optional(),
39
+ configRoots: z.record(z.string(), z.unknown()).optional(),
40
+ rules: z
41
+ .looseObject({
42
+ required: z.array(z.string()),
43
+ unsupported: z.array(z.string()).optional(),
44
+ })
45
+ .optional(),
46
+ tools: z
47
+ .looseObject({
48
+ builtIn: z.array(z.unknown()),
49
+ customToolSupported: z.boolean(),
50
+ renderers: z.array(z.unknown()),
51
+ })
52
+ .optional(),
53
+ });
54
+
55
+ const catalogSchema = z.looseObject({
56
+ version: z.literal(XULUX_MCP_CATALOG_VERSION),
57
+ // Not read anywhere in the package; validated for shape only, so an unused
58
+ // field cannot veto the whole catalog.
59
+ generatedAt: z.string(),
60
+ docsOrigin: z.string(),
61
+ templates: z.array(catalogTemplateSchema),
62
+ });
9
63
 
10
64
  export function getCatalogUrl(): string {
11
65
  const override = process.env.XULUX_CATALOG_URL?.trim();
@@ -13,32 +67,23 @@ export function getCatalogUrl(): string {
13
67
  }
14
68
 
15
69
  function validateCatalog(data: unknown): XuluxCatalog {
16
- if (!data || typeof data !== "object" || Array.isArray(data)) {
17
- throw new Error("Catalog response is not a JSON object.");
18
- }
19
- const catalog = data as XuluxCatalog;
20
- if (catalog.version !== 1) {
70
+ // Checked ahead of the schema so a catalog rollout reports its version
71
+ // rather than reading as a malformed payload.
72
+ const version = (data as { version?: unknown } | null)?.version;
73
+ if (version !== undefined && version !== XULUX_MCP_CATALOG_VERSION) {
21
74
  throw new Error(
22
- `Unsupported catalog version: ${String(catalog.version)}. Expected 1.`,
75
+ `Unsupported catalog version: ${String(version)}. Expected ${XULUX_MCP_CATALOG_VERSION}.`,
23
76
  );
24
77
  }
25
- if (!Array.isArray(catalog.templates)) {
26
- throw new Error("Catalog response has no templates array.");
27
- }
28
- for (const template of catalog.templates) {
29
- if (
30
- !template ||
31
- typeof template !== "object" ||
32
- typeof template.id !== "string" ||
33
- typeof template.templateId !== "string" ||
34
- (template.kind !== "template" && template.kind !== "example")
35
- ) {
36
- throw new Error(
37
- "Catalog response contains a malformed template entry (missing id/templateId/kind).",
38
- );
39
- }
78
+ const result = catalogSchema.safeParse(data);
79
+ if (!result.success) {
80
+ const issue = result.error.issues[0];
81
+ const path = issue?.path.length ? ` at ${issue.path.join(".")}` : "";
82
+ throw new Error(
83
+ `Catalog response is malformed${path}: ${issue?.message ?? "invalid catalog"}.`,
84
+ );
40
85
  }
41
- return catalog;
86
+ return result.data;
42
87
  }
43
88
 
44
89
  interface CacheEntry {
@@ -24,19 +24,23 @@ export interface XuluxCatalogTemplate {
24
24
  features: string[];
25
25
  customizable: string[];
26
26
  versions: XuluxCatalogVersion[];
27
- previewUrl?: string;
28
- downloadUrl?: string;
29
- sandboxBaseUrl?: string;
30
- configRoots?: Record<string, unknown>;
31
- rules?: {
32
- required: string[];
33
- unsupported?: string[];
34
- };
35
- tools?: {
36
- builtIn: unknown[];
37
- customToolSupported: boolean;
38
- renderers: unknown[];
39
- };
27
+ previewUrl?: string | undefined;
28
+ downloadUrl?: string | undefined;
29
+ sandboxBaseUrl?: string | undefined;
30
+ configRoots?: Record<string, unknown> | undefined;
31
+ rules?:
32
+ | {
33
+ required: string[];
34
+ unsupported?: string[] | undefined;
35
+ }
36
+ | undefined;
37
+ tools?:
38
+ | {
39
+ builtIn: unknown[];
40
+ customToolSupported: boolean;
41
+ renderers: unknown[];
42
+ }
43
+ | undefined;
40
44
  }
41
45
 
42
46
  export interface XuluxCatalog {
@@ -1,423 +0,0 @@
1
- ---
2
- title: Interactables (legacy)
3
- description: Build persistent UI elements whose state the AI can read and update — copilot interactables in React with assistant-ui for forms, dashboards, and tools.
4
- platforms: ["react"]
5
- ---
6
-
7
- <Callout type="warn">
8
- This legacy API is deprecated. For new code, use the [`unstable_` interactables API](/docs/tools/interactables). We recomment switching beccause this legacy API passes state by mutating the system message, the new, `unstable_` tagged API solves this.
9
- </Callout>
10
-
11
- Interactables are React components that live outside the chat message flow and have state that both the user and the AI can read and write. This enables AI-driven UI patterns where the assistant controls parts of your application beyond the chat window.
12
-
13
-
14
- ## Overview
15
-
16
- Unlike regular tool UIs that appear inline within messages, interactables:
17
-
18
- - **Persist across messages** — they live outside the chat thread
19
- - **Have shared state** — both the user (via React) and the AI (via auto-generated tools) can update them
20
- - **Support partial updates** — the AI only needs to send the fields it wants to change
21
- - **Are developer-placed** — you decide where they render in your app
22
- - **Auto-register tools** — the AI automatically gets a tool to update each interactable's state
23
-
24
- Common use cases:
25
-
26
- - Task boards that the AI can add items to
27
- - Data dashboards that update based on conversation
28
- - Forms that the AI pre-fills
29
- - Canvas/editor components that the AI can manipulate
30
-
31
- ## Quick Start
32
-
33
- ### 1. Register the Interactables scope
34
-
35
- ```tsx
36
- import { AuiConfig, Interactables, AssistantRuntimeProvider } from "@assistant-ui/react";
37
- import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
38
-
39
- function MyRuntimeProvider({ children }: { children: React.ReactNode }) {
40
- const runtime = useChatRuntime();
41
- const config = AuiConfig({
42
- interactables: Interactables(), // [!code ++]
43
- });
44
-
45
- return (
46
- <AssistantRuntimeProvider
47
- runtime={runtime}
48
- config={config}
49
- >
50
- {children}
51
- </AssistantRuntimeProvider>
52
- );
53
- }
54
- ```
55
-
56
- <Callout type="idea">
57
- The legacy `interactables: Interactables()` scope and the new
58
- `unstable_interactables: unstable_Interactables()` scope are mutually
59
- exclusive. Mount only one interactables API in a single provider config.
60
- </Callout>
61
-
62
- ### 2. Create an interactable
63
-
64
- ```tsx
65
- import { useAssistantInteractable, useInteractableState } from "@assistant-ui/react";
66
- import { z } from "zod";
67
-
68
- const taskBoardSchema = z.object({
69
- tasks: z.array(
70
- z.object({
71
- id: z.string(),
72
- title: z.string(),
73
- done: z.boolean(),
74
- }),
75
- ),
76
- });
77
-
78
- const taskBoardInitialState = { tasks: [] };
79
-
80
- function TaskBoard() {
81
- const id = useAssistantInteractable("taskBoard", {
82
- description: "A task board showing the user's tasks",
83
- stateSchema: taskBoardSchema,
84
- initialState: taskBoardInitialState,
85
- });
86
- const [state, { setState }] = useInteractableState(id, taskBoardInitialState);
87
-
88
- return (
89
- <div>
90
- <h2>Tasks</h2>
91
- <ul>
92
- {state.tasks.map((task) => (
93
- <li key={task.id}>
94
- <label>
95
- <input
96
- type="checkbox"
97
- checked={task.done}
98
- onChange={() =>
99
- setState((prev) => ({
100
- tasks: prev.tasks.map((t) =>
101
- t.id === task.id ? { ...t, done: !t.done } : t,
102
- ),
103
- }))
104
- }
105
- />
106
- {task.title}
107
- </label>
108
- </li>
109
- ))}
110
- </ul>
111
- </div>
112
- );
113
- }
114
- ```
115
-
116
- <Callout type="warn">
117
- Define the `stateSchema` and `initialState` **outside** the component (or
118
- memoize them). Creating a new schema on every render will cause the
119
- interactable to re-register and reset its state.
120
- </Callout>
121
-
122
- ### 3. Place it in your layout
123
-
124
- ```tsx
125
- function App() {
126
- return (
127
- <MyRuntimeProvider>
128
- <div className="flex">
129
- <Thread className="flex-1" />
130
- <TaskBoard /> {/* Lives outside the chat */}
131
- </div>
132
- </MyRuntimeProvider>
133
- );
134
- }
135
- ```
136
-
137
- Now when the user says _"Add a task called 'Buy groceries'"_, the AI will automatically call the `update_taskBoard` tool to update the state. Thanks to partial updates, the AI only needs to send the fields it wants to change.
138
-
139
- ## Partial Updates
140
-
141
- Auto-generated tools use a partial schema — all fields become optional. The AI only sends the fields it wants to change; omitted fields keep their current values.
142
-
143
- ```tsx
144
- // If the state is { title: "My Note", content: "Hello", color: "yellow" }
145
- // The AI can call: update_note({ color: "blue" })
146
- // Result: { title: "My Note", content: "Hello", color: "blue" }
147
- ```
148
-
149
- This is especially useful for large state objects where regenerating the entire state would be expensive and error-prone.
150
-
151
- <Callout type="info">
152
- Merge is shallow (one level deep). If the AI sends a nested object, it replaces
153
- that entire field rather than deep-merging into it.
154
- </Callout>
155
-
156
- ## Multiple Instances
157
-
158
- You can render multiple interactables with the same `name` but different `id`s. Each gets its own update tool:
159
-
160
- ```tsx
161
- import { useAssistantInteractable, useInteractableState } from "@assistant-ui/react";
162
- import { z } from "zod";
163
-
164
- const noteSchema = z.object({
165
- title: z.string(),
166
- content: z.string(),
167
- color: z.enum(["yellow", "blue", "green", "pink"]),
168
- });
169
-
170
- const noteInitialState = { title: "New Note", content: "", color: "yellow" as const };
171
-
172
- function NoteCard({ noteId }: { noteId: string }) {
173
- useAssistantInteractable("note", {
174
- id: noteId,
175
- description: "A sticky note",
176
- stateSchema: noteSchema,
177
- initialState: noteInitialState,
178
- });
179
- const [state] = useInteractableState(noteId, noteInitialState);
180
-
181
- return <div>{state.title}</div>;
182
- }
183
-
184
- function App() {
185
- return (
186
- <>
187
- <NoteCard noteId="note-1" /> {/* → update_note_note-1 tool */}
188
- <NoteCard noteId="note-2" /> {/* → update_note_note-2 tool */}
189
- </>
190
- );
191
- }
192
- ```
193
-
194
- When only one instance of a name exists, the tool is named `update_{name}` (e.g., `update_note`). When multiple instances exist, tools are named `update_{name}_{id}` (e.g., `update_note_note-1`).
195
-
196
- ## Selection
197
-
198
- When multiple interactables are present, you can mark one as "selected" to tell the AI which one the user is focused on:
199
-
200
- ```tsx
201
- function NoteCard({ noteId }: { noteId: string }) {
202
- useAssistantInteractable("note", {
203
- id: noteId,
204
- description: "A sticky note",
205
- stateSchema: noteSchema,
206
- initialState: noteInitialState,
207
- });
208
- const [state, { setSelected }] = useInteractableState(noteId, noteInitialState);
209
-
210
- return (
211
- <div onClick={() => setSelected(true)}>
212
- {state.title}
213
- </div>
214
- );
215
- }
216
- ```
217
-
218
- The AI sees `(SELECTED)` in the system prompt for the focused interactable, allowing it to prioritize that one in responses. For example, the user can say _"Change the color to blue"_ and the AI knows which note to update.
219
-
220
- ## API Reference
221
-
222
- ### `useAssistantInteractable`
223
-
224
- Registers an interactable with the AI assistant. Returns the instance id.
225
-
226
- ```tsx
227
- const id = useAssistantInteractable(name, config);
228
- ```
229
-
230
- **Parameters:**
231
-
232
- | Parameter | Type | Description |
233
- | --- | --- | --- |
234
- | `name` | `string` | Name for the interactable (used in tool names) |
235
- | `config.description` | `string` | Description shown to the AI |
236
- | `config.stateSchema` | `StandardSchemaV1 \| JSONSchema7` | Schema for the state (e.g., a Zod schema) |
237
- | `config.initialState` | `unknown` | Initial state value |
238
- | `config.id` | `string?` | Optional unique instance ID (auto-generated if omitted) |
239
- | `config.selected` | `boolean?` | Whether this interactable is selected |
240
-
241
- **Returns:** `string` — the instance id (auto-generated or provided).
242
-
243
- ### `useInteractableState`
244
-
245
- Reads and writes the state of a registered interactable.
246
-
247
- ```tsx
248
- const [state, { setState, setSelected, isPending, error, flush }] = useInteractableState<TState>(id, fallback?);
249
- ```
250
-
251
- **Parameters:**
252
-
253
- | Parameter | Type | Description |
254
- | --- | --- | --- |
255
- | `id` | `string` | The interactable instance id (from `useAssistantInteractable`) |
256
- | `fallback` | `TState?` | Fallback value before the interactable is registered |
257
-
258
- **Returns:** `[state, methods]`
259
-
260
- | Return | Type | Description |
261
- | --- | --- | --- |
262
- | `state` | `TState` | Current state |
263
- | `setState` | `(updater: TState \| (prev: TState) => TState) => void` | State setter (like `useState`) |
264
- | `setSelected` | `(selected: boolean) => void` | Mark this interactable as selected |
265
- | `isPending` | `boolean` | Whether a persistence save is in-flight |
266
- | `error` | `unknown` | Error from the last failed save |
267
- | `flush` | `() => Promise<void>` | Force an immediate persistence save |
268
-
269
- ### `Interactables`
270
-
271
- The scope resource that manages all interactables. Register it via your provider's `config`:
272
-
273
- ```tsx
274
- AuiConfig({
275
- interactables: Interactables(),
276
- });
277
- ```
278
-
279
- ## How It Works
280
-
281
- When you call `useAssistantInteractable("taskBoard", config)`:
282
-
283
- 1. **Registration** — the interactable is registered in the `interactables` scope with its name, description, schema, and initial state.
284
- 2. **Tool generation** — an `update_taskBoard` frontend tool is automatically created with a partial schema (all fields optional). For multiple instances, tools are named `update_{name}_{id}`.
285
- 3. **System prompt** — the AI receives a system message describing the interactable, its current state, and whether it is selected.
286
- 4. **Streaming updates** — as the AI generates the tool arguments, the interactable's state updates progressively rather than waiting for complete arguments. This gives users immediate visual feedback.
287
- 5. **Partial merge** — only the fields the AI sends are updated; the rest are preserved.
288
- 6. **Bidirectional updates** — when the AI calls the tool, the state updates and React re-renders. When the user updates state via `setState`, the model context is notified so the AI sees the latest state on the next turn.
289
-
290
- ## Persistence
291
-
292
- By default, interactable state is in-memory and lost on page refresh. You can add persistence by providing a save callback:
293
-
294
- ```tsx
295
- import { useEffect } from "react";
296
- import { AuiConfig, AuiProvider, Interactables, useAui } from "@assistant-ui/react";
297
-
298
- function MyRuntimeProvider({ children }) {
299
- const aui = useAui();
300
- const config = AuiConfig({ interactables: Interactables() });
301
- return (
302
- <AuiProvider extends={aui} config={config}>
303
- <PersistenceSetup />
304
- {children}
305
- </AuiProvider>
306
- );
307
- }
308
-
309
- function PersistenceSetup() {
310
- const aui = useAui();
311
-
312
- useEffect(() => {
313
- // Set up persistence adapter
314
- aui.interactables.setPersistenceAdapter({
315
- save: async (state) => {
316
- localStorage.setItem("interactables", JSON.stringify(state));
317
- },
318
- });
319
-
320
- // Restore saved state on mount
321
- const saved = localStorage.getItem("interactables");
322
- if (saved) {
323
- aui.interactables.importState(JSON.parse(saved));
324
- }
325
- }, [aui]);
326
-
327
- return null;
328
- }
329
- ```
330
-
331
- ### Sync Status
332
-
333
- When a persistence adapter is set, `useInteractableState` exposes sync metadata:
334
-
335
- ```tsx
336
- const [state, { setState, isPending, error, flush }] = useInteractableState(id, fallback);
337
-
338
- // isPending — true while a save is in-flight
339
- // error — the error from the last failed save, if any
340
- // flush() — force an immediate save (useful before navigation)
341
- ```
342
-
343
- State changes are automatically debounced (500ms) before saving. When a component unregisters, any pending save is flushed immediately.
344
-
345
- ### Export / Import
346
-
347
- For custom persistence strategies, use `exportState` and `importState` directly:
348
-
349
- ```tsx
350
- const snapshot = aui.interactables.exportState();
351
- // => { "note-1": { name: "note", state: { title: "Hello" } }, ... }
352
-
353
- aui.interactables.importState(snapshot);
354
- // Imported state is picked up when components next register
355
- ```
356
-
357
- ## Combining with Tools
358
-
359
- You can use `Interactables` alongside `Tools`:
360
-
361
- ```tsx
362
- AuiConfig({
363
- tools: Tools({ toolkit: myToolkit }),
364
- interactables: Interactables(),
365
- });
366
- ```
367
-
368
- ## Streaming Updates
369
-
370
- While the AI is generating tool arguments, `useInteractableState` reflects the partial state in real time as fields stream in. You can use the partial state itself plus the thread's running status to show a skeleton UI while the AI is mid-stream:
371
-
372
- ```tsx
373
- import { useAuiState } from "@assistant-ui/react";
374
-
375
- function TaskBoard() {
376
- const id = useAssistantInteractable("taskBoard", config);
377
- const [state] = useInteractableState(id, taskBoardInitialState);
378
- const isRunning = useAuiState((s) => s.thread.isRunning);
379
-
380
- const isLoading = isRunning && state.tasks.length === 0;
381
-
382
- return (
383
- <div>
384
- <h2>Tasks</h2>
385
- {isLoading ? (
386
- <div className="animate-pulse h-8 rounded bg-muted" />
387
- ) : (
388
- <ul>
389
- {state.tasks.map((task) => (
390
- <li key={task.id}>{task.title}</li>
391
- ))}
392
- </ul>
393
- )}
394
- </div>
395
- );
396
- }
397
- ```
398
-
399
- The state object updates progressively as the AI streams in each field, so partial renders work without any extra wiring. Use the runtime's `isRunning` to distinguish "still streaming, no fields yet" from "model returned an empty result".
400
-
401
- ## Schema Evolution
402
-
403
- <Callout type="warn">
404
- If you change a Zod schema after state has been persisted, the imported snapshot may silently mis-match the new shape. The adapter does a shallow merge, so extra fields are preserved and missing fields keep their initial values, but type mismatches are not caught at runtime. To avoid silent corruption, version your schema key (e.g. `"taskBoard_v2"`) or namespace it by schema hash whenever you make breaking changes. Alternatively, add a migration step in your `importState` call.
405
- </Callout>
406
-
407
- ## Unmount Behavior
408
-
409
- When a component that called `useAssistantInteractable` unmounts, the interactable is unregistered from the AI's tool list and system prompt. However, its state is preserved in the `Interactables` scope. When the component mounts again with the same name and id, the scope re-merges the preserved state rather than resetting to `initialState`. This means transient unmounts (such as React Strict Mode double-mounts or tab switches) do not lose state.
410
-
411
- ## Full Example
412
-
413
- See the complete [with-interactables example](https://github.com/assistant-ui/assistant-ui/tree/main/examples/with-interactables) for a working implementation featuring:
414
-
415
- - **Task Board** — single-instance interactable with a custom `manage_tasks` tool
416
- - **Sticky Notes** — multi-instance interactables with selection and partial updates
417
- - **localStorage persistence** — state survives page refresh via `setPersistenceAdapter`
418
- - **Sync indicator** — spinning icon while a save is in-flight (`isPending`)
419
-
420
- ## Related
421
-
422
- - [Tool UI](/docs/tools/tool-ui) — Inline tool call UIs rendered inside messages
423
- - [LangGraph Generative UI](/docs/runtimes/langgraph/generative-ui) — Structured UI components emitted by a LangGraph graph alongside messages