@assistant-ui/mcp-docs-server 0.1.35 → 0.1.38

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 (177) hide show
  1. package/.docs/organized/code-examples/waterfall.md +1 -1
  2. package/.docs/organized/code-examples/with-a2a.md +2 -2
  3. package/.docs/organized/code-examples/with-ag-ui.md +2 -2
  4. package/.docs/organized/code-examples/with-ai-sdk-v6.md +4 -4
  5. package/.docs/organized/code-examples/with-artifacts.md +4 -4
  6. package/.docs/organized/code-examples/with-assistant-transport.md +70 -54
  7. package/.docs/organized/code-examples/with-browser-extension.md +4 -4
  8. package/.docs/organized/code-examples/with-chain-of-thought.md +40 -89
  9. package/.docs/organized/code-examples/with-cloud-standalone.md +4 -4
  10. package/.docs/organized/code-examples/with-cloud.md +4 -4
  11. package/.docs/organized/code-examples/with-custom-thread-list.md +4 -4
  12. package/.docs/organized/code-examples/with-elevenlabs-conversational.md +7 -7
  13. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +7 -7
  14. package/.docs/organized/code-examples/with-eve.md +343 -0
  15. package/.docs/organized/code-examples/with-expo.md +910 -933
  16. package/.docs/organized/code-examples/with-external-store.md +2 -2
  17. package/.docs/organized/code-examples/with-ffmpeg.md +5 -8
  18. package/.docs/organized/code-examples/with-generative-ui.md +6 -6
  19. package/.docs/organized/code-examples/with-google-adk.md +3 -3
  20. package/.docs/organized/code-examples/with-heat-graph.md +1 -1
  21. package/.docs/organized/code-examples/with-image-generation.md +4 -4
  22. package/.docs/organized/code-examples/with-interactables.md +166 -338
  23. package/.docs/organized/code-examples/with-langchain.md +4 -4
  24. package/.docs/organized/code-examples/with-langgraph.md +20 -157
  25. package/.docs/organized/code-examples/with-livekit.md +8 -8
  26. package/.docs/organized/code-examples/with-mcp.md +19 -10
  27. package/.docs/organized/code-examples/with-opencode.md +3 -3
  28. package/.docs/organized/code-examples/with-pi.md +9 -7
  29. package/.docs/organized/code-examples/with-react-hook-form.md +13 -6
  30. package/.docs/organized/code-examples/with-react-ink-web.md +5 -5
  31. package/.docs/organized/code-examples/with-react-ink.md +1 -1
  32. package/.docs/organized/code-examples/with-react-router.md +11 -11
  33. package/.docs/organized/code-examples/with-resumable-stream.md +5 -5
  34. package/.docs/organized/code-examples/with-store.md +1 -1
  35. package/.docs/organized/code-examples/with-tanstack.md +7 -7
  36. package/.docs/organized/code-examples/with-tap-runtime.md +2 -2
  37. package/.docs/organized/code-examples/with-virtualized-thread.md +44 -24
  38. package/.docs/raw/docs/(docs)/cli.mdx +5 -3
  39. package/.docs/raw/docs/(docs)/devtools.mdx +25 -2
  40. package/.docs/raw/docs/(docs)/index.mdx +5 -2
  41. package/.docs/raw/docs/(docs)/installation.mdx +5 -2
  42. package/.docs/raw/docs/(reference)/api-reference/external-store/message-conversion.mdx +16 -16
  43. package/.docs/raw/docs/(reference)/api-reference/hooks/composer-triggers.mdx +73 -42
  44. package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +3 -20
  45. package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +234 -166
  46. package/.docs/raw/docs/(reference)/api-reference/integrations/eve.mdx +51 -0
  47. package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +4 -1
  48. package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +70 -38
  49. package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +30 -0
  50. package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +7 -0
  51. package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +26 -0
  52. package/.docs/raw/docs/(reference)/api-reference/primitives/chain-of-thought.mdx +15 -0
  53. package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +103 -0
  54. package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +16 -0
  55. package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +56 -0
  56. package/.docs/raw/docs/(reference)/api-reference/primitives/queue-item.mdx +12 -0
  57. package/.docs/raw/docs/(reference)/api-reference/primitives/selection-toolbar.mdx +12 -0
  58. package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +14 -0
  59. package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +57 -1
  60. package/.docs/raw/docs/(reference)/api-reference/tools/index.mdx +6 -0
  61. package/.docs/raw/docs/(reference)/api-reference/tools/interactables-legacy.mdx +55 -0
  62. package/.docs/raw/docs/(reference)/api-reference/tools/interactables.mdx +151 -0
  63. package/.docs/raw/docs/(reference)/api-reference/tools/rendering.mdx +15 -15
  64. package/.docs/raw/docs/(reference)/api-reference/tools/toolkits.mdx +20 -20
  65. package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +25 -9
  66. package/.docs/raw/docs/cloud/langgraph.mdx +1 -1
  67. package/.docs/raw/docs/guides/headless-composer-input.mdx +113 -0
  68. package/.docs/raw/docs/guides/latex.mdx +28 -22
  69. package/.docs/raw/docs/guides/mentions.mdx +32 -7
  70. package/.docs/raw/docs/guides/slash-commands.mdx +3 -6
  71. package/.docs/raw/docs/guides/speech.mdx +5 -7
  72. package/.docs/raw/docs/guides/virtualization.mdx +77 -7
  73. package/.docs/raw/docs/guides/voice.mdx +3 -2
  74. package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +4 -12
  75. package/.docs/raw/docs/integrations/auth/better-auth.mdx +7 -10
  76. package/.docs/raw/docs/integrations/auth/clerk.mdx +3 -9
  77. package/.docs/raw/docs/integrations/auth/next-auth.mdx +3 -8
  78. package/.docs/raw/docs/integrations/frameworks/ai-sdk.mdx +11 -8
  79. package/.docs/raw/docs/integrations/index.mdx +6 -13
  80. package/.docs/raw/docs/integrations/observability/helicone.mdx +3 -4
  81. package/.docs/raw/docs/integrations/observability/langfuse.mdx +3 -5
  82. package/.docs/raw/docs/integrations/observability/langsmith.mdx +5 -4
  83. package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +4 -3
  84. package/.docs/raw/docs/migrations/react-langgraph-v0-7.mdx +2 -2
  85. package/.docs/raw/docs/primitives/composer.mdx +8 -0
  86. package/.docs/raw/docs/primitives/thread-list.mdx +30 -6
  87. package/.docs/raw/docs/primitives/thread.mdx +24 -0
  88. package/.docs/raw/docs/runtimes/a2a/quickstart.mdx +1 -1
  89. package/.docs/raw/docs/runtimes/ag-ui/quickstart.mdx +1 -1
  90. package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +24 -1
  91. package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +1 -1
  92. package/.docs/raw/docs/runtimes/custom/external-store.mdx +54 -0
  93. package/.docs/raw/docs/runtimes/eve/overview.mdx +100 -0
  94. package/.docs/raw/docs/runtimes/eve/quickstart.mdx +143 -0
  95. package/.docs/raw/docs/runtimes/google-adk/quickstart.mdx +1 -1
  96. package/.docs/raw/docs/runtimes/langchain.mdx +388 -20
  97. package/.docs/raw/docs/runtimes/langgraph/quickstart.mdx +1 -1
  98. package/.docs/raw/docs/runtimes/langgraph/tutorial/part-1.mdx +1 -1
  99. package/.docs/raw/docs/runtimes/opencode/hooks.mdx +1 -1
  100. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +6 -0
  101. package/.docs/raw/docs/tools/defining-tools.mdx +9 -0
  102. package/.docs/raw/docs/tools/generative-ui.mdx +37 -0
  103. package/.docs/raw/docs/tools/interactables-legacy.mdx +410 -0
  104. package/.docs/raw/docs/tools/interactables.mdx +892 -223
  105. package/.docs/raw/docs/tools/mcp-apps.mdx +12 -3
  106. package/.docs/raw/docs/tools/mcp.mdx +9 -4
  107. package/.docs/raw/docs/tools/multi-agent.mdx +5 -0
  108. package/.docs/raw/docs/tools/user-managed-mcp.mdx +17 -3
  109. package/.docs/raw/docs/ui/composer-trigger-popover.mdx +2 -0
  110. package/.docs/raw/docs/ui/file.mdx +1 -1
  111. package/.docs/raw/docs/ui/follow-up-suggestions.mdx +80 -0
  112. package/.docs/raw/docs/ui/model-selector.mdx +38 -5
  113. package/.docs/raw/docs/ui/part-grouping.mdx +38 -0
  114. package/.docs/raw/docs/utilities/react-o11y.mdx +92 -6
  115. package/README.md +1 -1
  116. package/dist/constants.d.ts +2 -1
  117. package/dist/constants.d.ts.map +1 -1
  118. package/dist/constants.js +2 -1
  119. package/dist/constants.js.map +1 -1
  120. package/dist/index.d.ts.map +1 -1
  121. package/dist/index.js +30 -2
  122. package/dist/index.js.map +1 -1
  123. package/dist/prepare-docs/copy-raw.d.ts.map +1 -1
  124. package/dist/prepare-docs/copy-raw.js +0 -4
  125. package/dist/prepare-docs/copy-raw.js.map +1 -1
  126. package/dist/tools/docs.d.ts.map +1 -1
  127. package/dist/tools/docs.js +18 -6
  128. package/dist/tools/docs.js.map +1 -1
  129. package/dist/tools/examples.d.ts +3 -1
  130. package/dist/tools/examples.d.ts.map +1 -1
  131. package/dist/tools/examples.js +1 -1
  132. package/dist/tools/examples.js.map +1 -1
  133. package/dist/tools/resources.d.ts +7 -0
  134. package/dist/tools/resources.d.ts.map +1 -0
  135. package/dist/tools/resources.js +74 -0
  136. package/dist/tools/resources.js.map +1 -0
  137. package/dist/tools/search.d.ts +33 -0
  138. package/dist/tools/search.d.ts.map +1 -0
  139. package/dist/tools/search.js +39 -0
  140. package/dist/tools/search.js.map +1 -0
  141. package/dist/tools/tests/test-setup.d.ts.map +1 -1
  142. package/dist/tools/tests/test-setup.js +3 -1
  143. package/dist/tools/tests/test-setup.js.map +1 -1
  144. package/dist/utils/mdx.d.ts +2 -1
  145. package/dist/utils/mdx.d.ts.map +1 -1
  146. package/dist/utils/mdx.js +19 -2
  147. package/dist/utils/mdx.js.map +1 -1
  148. package/dist/utils/paths.d.ts +2 -1
  149. package/dist/utils/paths.d.ts.map +1 -1
  150. package/dist/utils/paths.js +18 -1
  151. package/dist/utils/paths.js.map +1 -1
  152. package/dist/utils/search.d.ts +10 -0
  153. package/dist/utils/search.d.ts.map +1 -0
  154. package/dist/utils/search.js +97 -0
  155. package/dist/utils/search.js.map +1 -0
  156. package/package.json +4 -4
  157. package/src/constants.ts +2 -0
  158. package/src/index.ts +28 -6
  159. package/src/prepare-docs/copy-raw.ts +0 -5
  160. package/src/tools/docs.ts +30 -4
  161. package/src/tools/examples.ts +4 -2
  162. package/src/tools/resources.ts +114 -0
  163. package/src/tools/search.ts +46 -0
  164. package/src/tools/tests/completions.test.ts +46 -0
  165. package/src/tools/tests/directory-size-cap.test.ts +50 -0
  166. package/src/tools/tests/mcp-protocol.test.ts +21 -1
  167. package/src/tools/tests/resources.test.ts +102 -0
  168. package/src/tools/tests/search.test.ts +37 -0
  169. package/src/tools/tests/test-setup.ts +2 -0
  170. package/src/utils/mdx.ts +21 -1
  171. package/src/utils/paths.ts +22 -0
  172. package/src/utils/search.ts +131 -0
  173. package/.docs/raw/blog/2024-07-29-hello/index.mdx +0 -64
  174. package/.docs/raw/blog/2024-09-11/index.mdx +0 -10
  175. package/.docs/raw/blog/2024-12-15/index.mdx +0 -10
  176. package/.docs/raw/blog/2025-01-31-changelog/index.mdx +0 -127
  177. package/.docs/raw/blog/2026-03-launch-week/index.mdx +0 -258
@@ -0,0 +1,102 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { server } from "../../index.js";
3
+
4
+ function handler(method: string) {
5
+ const handlers = (server as any).server._requestHandlers;
6
+ const h = handlers.get(method);
7
+ if (!h) throw new Error(`No handler for ${method}`);
8
+ return h;
9
+ }
10
+
11
+ describe("MCP resources", () => {
12
+ it("lists docs and example resources", async () => {
13
+ const result = await handler("resources/list")(
14
+ { method: "resources/list", params: {} },
15
+ {},
16
+ );
17
+ expect(result.resources.length).toBeGreaterThan(0);
18
+ expect(
19
+ result.resources.some((r: any) => r.uri.startsWith("aui-docs:///")),
20
+ ).toBe(true);
21
+ expect(
22
+ result.resources.some((r: any) => r.uri.startsWith("aui-example:///")),
23
+ ).toBe(true);
24
+ });
25
+
26
+ it("reads a documentation resource as markdown", async () => {
27
+ const list = await handler("resources/list")(
28
+ { method: "resources/list", params: {} },
29
+ {},
30
+ );
31
+ const doc = list.resources.find((r: any) =>
32
+ r.uri.startsWith("aui-docs:///"),
33
+ );
34
+ const read = await handler("resources/read")(
35
+ { method: "resources/read", params: { uri: doc.uri } },
36
+ {},
37
+ );
38
+ expect(read.contents[0].mimeType).toBe("text/markdown");
39
+ expect(typeof read.contents[0].text).toBe("string");
40
+ expect(read.contents[0].text.length).toBeGreaterThan(0);
41
+ });
42
+
43
+ it("reads a slash-containing documentation resource", async () => {
44
+ const list = await handler("resources/list")(
45
+ { method: "resources/list", params: {} },
46
+ {},
47
+ );
48
+ const prefix = "aui-docs:///";
49
+ const nested = list.resources.find(
50
+ (r: any) =>
51
+ r.uri.startsWith(prefix) && r.uri.slice(prefix.length).includes("/"),
52
+ );
53
+ expect(nested).toBeDefined();
54
+ const read = await handler("resources/read")(
55
+ { method: "resources/read", params: { uri: nested.uri } },
56
+ {},
57
+ );
58
+ expect(read.contents[0].mimeType).toBe("text/markdown");
59
+ expect(read.contents[0].text.length).toBeGreaterThan(0);
60
+ });
61
+
62
+ it("errors on an unknown documentation resource", async () => {
63
+ await expect(
64
+ handler("resources/read")(
65
+ {
66
+ method: "resources/read",
67
+ params: { uri: "aui-docs:///definitely-not-a-real-doc" },
68
+ },
69
+ {},
70
+ ),
71
+ ).rejects.toThrow();
72
+ });
73
+
74
+ it("reads an example resource as markdown", async () => {
75
+ const list = await handler("resources/list")(
76
+ { method: "resources/list", params: {} },
77
+ {},
78
+ );
79
+ const example = list.resources.find((r: any) =>
80
+ r.uri.startsWith("aui-example:///"),
81
+ );
82
+ const read = await handler("resources/read")(
83
+ { method: "resources/read", params: { uri: example.uri } },
84
+ {},
85
+ );
86
+ expect(read.contents[0].mimeType).toBe("text/markdown");
87
+ expect(typeof read.contents[0].text).toBe("string");
88
+ expect(read.contents[0].text.length).toBeGreaterThan(0);
89
+ });
90
+
91
+ it("errors on an unknown example resource", async () => {
92
+ await expect(
93
+ handler("resources/read")(
94
+ {
95
+ method: "resources/read",
96
+ params: { uri: "aui-example:///definitely-not-a-real-example" },
97
+ },
98
+ {},
99
+ ),
100
+ ).rejects.toThrow();
101
+ });
102
+ });
@@ -0,0 +1,37 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { testContext } from "./test-setup.js";
3
+
4
+ describe("assistantUISearch", () => {
5
+ it("returns ranked matches for a known term", async () => {
6
+ const result = await testContext.callTool("assistantUISearch", {
7
+ query: "thread",
8
+ });
9
+ expect(result.total).toBeGreaterThan(0);
10
+ expect(result.results[0].path).toBeDefined();
11
+ expect(result.results[0].title).toBeDefined();
12
+ expect(result.results[0].snippet).toBeDefined();
13
+ });
14
+
15
+ it("returns no matches for a nonsense query", async () => {
16
+ const result = await testContext.callTool("assistantUISearch", {
17
+ query: "zzzqqxnotarealdocterm",
18
+ });
19
+ expect(result.total).toBe(0);
20
+ expect(result.results).toHaveLength(0);
21
+ });
22
+
23
+ it("respects the limit", async () => {
24
+ const result = await testContext.callTool("assistantUISearch", {
25
+ query: "ui",
26
+ limit: 3,
27
+ });
28
+ expect(result.results.length).toBeLessThanOrEqual(3);
29
+ });
30
+
31
+ it("defaults to at most 10 results when no limit is given", async () => {
32
+ const result = await testContext.callTool("assistantUISearch", {
33
+ query: "ui",
34
+ });
35
+ expect(result.results.length).toBeLessThanOrEqual(10);
36
+ });
37
+ });
@@ -4,10 +4,12 @@ import { join } from "node:path";
4
4
  import { PACKAGE_DIR } from "../../constants.js";
5
5
  import { docsTools } from "../docs.js";
6
6
  import { examplesTools } from "../examples.js";
7
+ import { searchTools } from "../search.js";
7
8
 
8
9
  const tools = {
9
10
  assistantUIDocs: docsTools,
10
11
  assistantUIExamples: examplesTools,
12
+ assistantUISearch: searchTools,
11
13
  };
12
14
 
13
15
  export const testContext = {
package/src/utils/mdx.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { readFile } from "node:fs/promises";
1
+ import { readFile, lstat } from "node:fs/promises";
2
2
  import matter from "gray-matter";
3
+ import { MAX_FILE_SIZE } from "../constants.js";
3
4
  import { logger } from "./logger.js";
4
5
 
5
6
  interface MDXContent {
@@ -32,6 +33,25 @@ export async function readMDXFile(
32
33
  }
33
34
  }
34
35
 
36
+ export async function readMDXFileSafe(
37
+ filePath: string,
38
+ ): Promise<MDXContent | null> {
39
+ try {
40
+ const stats = await lstat(filePath);
41
+ if (stats.isSymbolicLink()) {
42
+ logger.warn(`Attempted to read symlink: ${filePath}`);
43
+ return null;
44
+ }
45
+ if (stats.size > MAX_FILE_SIZE) {
46
+ logger.warn(`File size exceeds limit: ${filePath} (${stats.size} bytes)`);
47
+ return null;
48
+ }
49
+ } catch {
50
+ return null;
51
+ }
52
+ return readMDXFile(filePath);
53
+ }
54
+
35
55
  export function formatMDXContent(mdxContent: MDXContent): string {
36
56
  const { content, frontmatter } = mdxContent;
37
57
 
@@ -66,6 +66,28 @@ export async function getAvailablePaths(): Promise<string[]> {
66
66
  return paths.sort();
67
67
  }
68
68
 
69
+ export async function getAvailableDocFiles(): Promise<string[]> {
70
+ const files: string[] = [];
71
+
72
+ async function scanDirectory(dir: string, prefix = ""): Promise<void> {
73
+ const { directories, files: dirFiles } = await listDirContents(dir);
74
+
75
+ for (const file of dirFiles) {
76
+ if (extname(file) !== MDX_EXTENSION) continue;
77
+ const name = file.replace(MDX_EXTENSION, "");
78
+ files.push(prefix ? `${prefix}/${name}` : name);
79
+ }
80
+
81
+ for (const subdir of directories) {
82
+ const newPrefix = prefix ? `${prefix}/${subdir}` : subdir;
83
+ await scanDirectory(join(dir, subdir), newPrefix);
84
+ }
85
+ }
86
+
87
+ await scanDirectory(DOCS_PATH);
88
+ return files.sort();
89
+ }
90
+
69
91
  export function findNearestPaths(
70
92
  requestedPath: string,
71
93
  availablePaths: string[],
@@ -0,0 +1,131 @@
1
+ import { join } from "node:path";
2
+ import { DOCS_PATH, MDX_EXTENSION } from "../constants.js";
3
+ import { getAvailablePaths, pathExists } from "./paths.js";
4
+ import { readMDXFile } from "./mdx.js";
5
+
6
+ const SCORE_WEIGHTS = {
7
+ FULL_QUERY: { title: 10, path: 8, description: 5 },
8
+ TOKEN: { title: 3, path: 2, description: 1, content: 0.5 },
9
+ } as const;
10
+
11
+ interface IndexEntry {
12
+ path: string;
13
+ title: string;
14
+ description: string;
15
+ content: string;
16
+ excerpt: string;
17
+ }
18
+
19
+ export interface SearchResult {
20
+ path: string;
21
+ title: string;
22
+ snippet: string;
23
+ }
24
+
25
+ let indexPromise: Promise<IndexEntry[]> | null = null;
26
+
27
+ function deriveTitle(
28
+ path: string,
29
+ frontmatter: Record<string, unknown>,
30
+ ): string {
31
+ const fmTitle = frontmatter["title"];
32
+ if (typeof fmTitle === "string" && fmTitle.trim()) return fmTitle;
33
+ return path.split("/").pop() ?? path;
34
+ }
35
+
36
+ async function buildIndex(): Promise<IndexEntry[]> {
37
+ const paths = await getAvailablePaths();
38
+ const entries = await Promise.all(
39
+ paths.map(async (path): Promise<IndexEntry | null> => {
40
+ const filePath = join(DOCS_PATH, `${path}${MDX_EXTENSION}`);
41
+ if (!(await pathExists(filePath))) return null;
42
+ const mdx = await readMDXFile(filePath);
43
+ if (!mdx) return null;
44
+ const description = mdx.frontmatter["description"];
45
+ return {
46
+ path,
47
+ title: deriveTitle(path, mdx.frontmatter),
48
+ description: typeof description === "string" ? description : "",
49
+ content: mdx.content,
50
+ excerpt: mdx.excerpt ?? "",
51
+ };
52
+ }),
53
+ );
54
+ return entries.filter((entry): entry is IndexEntry => entry !== null);
55
+ }
56
+
57
+ function getIndex(): Promise<IndexEntry[]> {
58
+ if (!indexPromise) {
59
+ indexPromise = buildIndex().catch((error) => {
60
+ indexPromise = null;
61
+ throw error;
62
+ });
63
+ }
64
+ return indexPromise;
65
+ }
66
+
67
+ function makeSnippet(
68
+ content: string,
69
+ tokens: string[],
70
+ excerpt: string,
71
+ ): string {
72
+ const lower = content.toLowerCase();
73
+ for (const token of tokens) {
74
+ const idx = lower.indexOf(token);
75
+ if (idx >= 0) {
76
+ const start = Math.max(0, idx - 60);
77
+ const end = Math.min(content.length, idx + token.length + 100);
78
+ const slice = content.slice(start, end).replace(/\s+/g, " ").trim();
79
+ return `${start > 0 ? "…" : ""}${slice}${end < content.length ? "…" : ""}`;
80
+ }
81
+ }
82
+ if (excerpt) return excerpt.slice(0, 160);
83
+ const firstLine = content.split("\n").find((line) => line.trim());
84
+ return firstLine ? firstLine.replace(/^#+\s*/, "").slice(0, 160) : "";
85
+ }
86
+
87
+ function scoreEntry(
88
+ entry: IndexEntry,
89
+ query: string,
90
+ tokens: string[],
91
+ ): number {
92
+ const title = entry.title.toLowerCase();
93
+ const path = entry.path.toLowerCase();
94
+ const description = entry.description.toLowerCase();
95
+ const content = entry.content.toLowerCase();
96
+
97
+ let score = 0;
98
+ if (title.includes(query)) score += SCORE_WEIGHTS.FULL_QUERY.title;
99
+ if (path.includes(query)) score += SCORE_WEIGHTS.FULL_QUERY.path;
100
+ if (description.includes(query))
101
+ score += SCORE_WEIGHTS.FULL_QUERY.description;
102
+
103
+ for (const token of tokens) {
104
+ if (title.includes(token)) score += SCORE_WEIGHTS.TOKEN.title;
105
+ if (path.includes(token)) score += SCORE_WEIGHTS.TOKEN.path;
106
+ if (description.includes(token)) score += SCORE_WEIGHTS.TOKEN.description;
107
+ if (content.includes(token)) score += SCORE_WEIGHTS.TOKEN.content;
108
+ }
109
+ return score;
110
+ }
111
+
112
+ export async function searchDocs(
113
+ query: string,
114
+ limit = 10,
115
+ ): Promise<SearchResult[]> {
116
+ const normalized = query.trim().toLowerCase();
117
+ if (!normalized) return [];
118
+ const tokens = normalized.split(/\s+/).filter(Boolean);
119
+
120
+ const index = await getIndex();
121
+ return index
122
+ .map((entry) => ({ entry, score: scoreEntry(entry, normalized, tokens) }))
123
+ .filter((scored) => scored.score > 0)
124
+ .sort((a, b) => b.score - a.score)
125
+ .slice(0, limit)
126
+ .map(({ entry }) => ({
127
+ path: entry.path,
128
+ title: entry.title,
129
+ snippet: makeSnippet(entry.content, tokens, entry.excerpt),
130
+ }));
131
+ }
@@ -1,64 +0,0 @@
1
- ---
2
- title: Hello, assistant-ui
3
- description: assistant-ui is an open-source AI chat component for React.
4
- author: Simon Farshid
5
- date: 2024-07-29T12:00:00
6
- ---
7
-
8
- import Image from "next/image";
9
- import { TestimonialContainer } from "@/components/home/testimonials/testimonials";
10
- import { BLOG_TESTIMONIALS } from "@/components/home/testimonials/data";
11
- import npmDownloads from "./npm-downloads.png";
12
- import assistantUi from "./assistant-ui-screenshot.png";
13
-
14
- After spending the last two years building Gen-AI prototypes and products, I realized that all software will soon have a natural language interface. OpenAI's ChatGPT sets the quality bar high and I wanted to have a similar UX in my own apps. No solution on the market came anywhere close, so I built assistant-ui.
15
-
16
- assistant-ui is an open-source, embeddable, customizable AI chat component for React web apps. You can use it to build GPT wrappers, in-app copilots, or agentic systems. It supports rich content (markdown, code highlighting, charts, tables), generative UI, message editing, ..., across all the major model providers.
17
-
18
- <Image
19
- src={assistantUi}
20
- alt="screenshot of assistant-ui"
21
- width={398}
22
- height={498}
23
- className="mx-auto rounded-xl border drop-shadow"
24
- />
25
-
26
- Earlier last month, I released the project to the world. The feedback from early adopters has been overwhelmingly positive:
27
-
28
- <div className="not-prose mx-auto max-w-md">
29
- <TestimonialContainer testimonials={BLOG_TESTIMONIALS} />
30
- </div>
31
-
32
- It didn't take long for developers to start building with assistant-ui. Here are some of my favorite products from the community:
33
-
34
- - [Helicone](https://helicone.ai/) - open-source LLM observability platform
35
- - [screenpipe](https://screenpi.pe/) - AI to remember everything you see, say or hear
36
- - [myresume.guru](http://myresume.guru) - AI resume optimizer to land your dream job
37
-
38
- With 250+ stars on [GitHub](https://github.com/assistant-ui/assistant-ui) and over 1k [npm](https://www.npmjs.com/package/@assistant-ui/react) weekly downloads, we got a vibrant growing community of developers who care about the user experience.
39
-
40
- <Image
41
- src={npmDownloads}
42
- alt="graph showing 1355 weekly npm downloads"
43
- width={381}
44
- height={94}
45
- className="mx-auto dark:hue-rotate-180 dark:invert"
46
- />
47
-
48
- I want to thank the following contributors who got the project to where it is today:
49
-
50
- - [@m13v](https://github.com/m13v) for contributing two examples and several how-to videos
51
- - [@okisdev](https://github.com/okisdev) for multiple bugfixes
52
- - [@Rajaniraiyn](https://github.com/Rajaniraiyn) for improving streaming support for REST APIs
53
- - @ccbkai for integrating Chrome's `window.ai` with assistant-ui
54
- - [@stingfeng](https://github.com/stingfeng/dify-extensions) for building a [Dify](https://dify.ai) integration
55
- - [@Ephibbs](https://github.com/Ephibbs/flowtoken) for building a Perplexity-style text streaming library ([Demo](https://assistant-ui-flowtoken-demo.vercel.app/))
56
- - … and so many others
57
-
58
- assistant-ui builds on top of [Radix UI](https://www.radix-ui.com/), [Tailwind](https://tailwindcss.com/), [shadcn/ui](https://ui.shadcn.com/), [Vercel AI SDK](https://sdk.vercel.ai/docs/introduction) and other amazing open-source projects.
59
-
60
- Over the coming month, I'll be rolling out multimodal support, so you can use your voice and upload images. There's so much more in the pipeline that I can't wait to unveil!
61
-
62
- Today, several companies like [Helicone (YC W23)](https://x.com/justinstorre/status/1816849882612904156) are using assistant-ui to power a core part of their product. If your company wants to do the same, please [get in touch](https://cal.com/simon-farshid/assistant-ui).
63
-
64
- If you're building conversational AI, join us on [Discord](https://discord.gg/S9dwgCNEFs). If you're technical and want to shape how we interact with AIs of the future, [send me an email](mailto:simon@assistant-ui.com).
@@ -1,10 +0,0 @@
1
- ---
2
- title: Build conversational AI agents with LangGraph and assistant-ui
3
- description: Announcing our collaboration with LangChain
4
- author: Harrison Chase
5
- date: 2024-09-11T12:00:00
6
- ---
7
-
8
- import { Redirect } from "./redirect";
9
-
10
- <Redirect />
@@ -1,10 +0,0 @@
1
- ---
2
- title: Announcing github-assistant
3
- description: github-assistant answers questions about your GitHub repositories.
4
- author: Amir Zohrenejad
5
- date: 2024-12-15T12:00:00
6
- ---
7
-
8
- import { Redirect } from "./redirect";
9
-
10
- <Redirect />
@@ -1,127 +0,0 @@
1
- ---
2
- title: January 2025 Changelog
3
- description: shadcn/ui, Thread Management, Improvements to AI SDK and LangGraph support
4
- author: Simon Farshid
5
- date: 2025-01-31T12:00:00
6
- ---
7
-
8
- <Callout emoji="🎉">
9
- This is the first edition of our changelog. We post these updates on a monthly
10
- basis. If you want more frequent updates about our new features, join our
11
- Discord where we have a `#changelog` channel that is updated on a daily basis.
12
- </Callout>
13
-
14
- ## Summary
15
-
16
- In January, we shipped 36 new versions of our package `@assistant-ui/react`. We also crossed 10k weekly downloads on npm for the first time. 🎉
17
-
18
- ## shadcn/ui CLI support
19
-
20
- You can now install all components using the shadcn CLI, e.g.
21
-
22
- ```sh
23
- npx shadcn@latest add "https://r.assistant-ui.com/thread"
24
- ```
25
-
26
- We began a migration towards distributing our components as unstyled primitives and using the shadcn CLI to drop styles in your project.
27
-
28
- ## Styled components moved to @assistant-ui/react-ui
29
-
30
- All styled components (Thread, ThreadList, AssistantModal, makeMarkdownText, etc.) have been moved to a new package, `@assistant-ui/ui`.
31
-
32
- To ease the migration, we added a migration codemod:
33
-
34
- ```sh
35
- npx assistant-ui upgrade
36
- ```
37
-
38
- This will update your codebase to use the new package. This new package remains supported, however, based on the learnings from existing users, we recommend all new projects to use our shadcn/ui CLI instead.
39
-
40
- ## Customizing the max-width of the Thread
41
-
42
- You can now customize the max-width of the thread via `--aui-thread-max-width` CSS variable.
43
-
44
- ## Thread Management
45
-
46
- One of our main focus areas in this month was on the new Thread Management API. The new ThreadList API is available under `runtime.threads`. It allows you to create, switch to, rename, archive, and delete threads.
47
-
48
- We shipped a `<ThreadList />` component which gives the user the UI to manage their threads.
49
-
50
- We also shipped a few hooks `useThreadListItem()`, `useThreadListItemRuntime()`, `useRemoteThreadListRuntime()` and `useCloudThreadListRuntime()`.
51
-
52
- ## Assistant Cloud
53
-
54
- We rolled out the new Assistant Cloud service to early users. This is a managed service for persistence, chat history, and thread management.
55
- Our runtimes are being upgraded to support Assistant Cloud natively by letting you pass a `cloud` object to the runtime hook.
56
-
57
- Keep an eye out for the public announcement of Assistant Cloud in a few days.
58
-
59
- ## Improvements to our LangGraph Integration
60
-
61
- - We now have full support for LangGraph's `interrupt()`/`Command` API. You can check out the new example repository [here](https://github.com/assistant-ui/assistant-ui-langgraph-interrupt).
62
- - We now also support starting LangGraph runs without a user message (based on button input or other events).
63
- - Cancellation of runs is now supported via an `abortSignal` being passed to the LangGraph runtime adapter.
64
-
65
- ## Improvements to our AI SDK Integration
66
-
67
- We now give you access to annotations and data packets in the assistant message:
68
-
69
- ```tsx
70
- type AssistantMessage = {
71
- metadata: {
72
- unstable_annotations: [...],
73
- unstable_data: [...],
74
- }
75
- }
76
- ```
77
-
78
- ## AI SDK recommended for new projects
79
-
80
- For new projects, we recommend using the AI SDK integration. Previously, we recommended our custom SDK called `useEdgeRuntime`.
81
- With our improved AI SDK integration, we believe it is time to recommend AI SDK for new projects, giving you access to the AI SDK ecosystem.
82
-
83
- The edge runtime remains maintained and supported for existing projects.
84
-
85
- ## Misc
86
-
87
- - **Refactors & API Enhancements**:
88
-
89
- - Renamed `ModelConfig` to `ModelContext`.
90
- - Moved `switchToThread / switchToNewThread` under `runtime.threads`.
91
- - Deprecated `UIContentPart`.
92
- - `ToolCallContentPart.args` is now a `JSONObject`.
93
- - `MessagePrimitive.tools.Override` introduced.
94
- - Added `AppendMessage.sourceId` to provide better tracking.
95
- - Reverse order of threads in `useRemoteThreadListRuntime` for better visibility.
96
- - Added `threads.getById` and `threads.main` APIs.
97
- - Introduced `AssistantCloudThreadHistoryAdapter` to handle cloud-based thread history.
98
- - Auto-injection of history adapter in the local runtime.
99
- - Tool call `id` + `args` are now optional in `ThreadMessageLike`.
100
- - Added `ThreadListPrimitive.Root`.
101
- - `ComposerRuntime.clearAttachments` API added.
102
- - Improved input support for IME keyboards (e.g., Chinese, Japanese, Korean).
103
- - Moved repository to a new GitHub organization (`assistant-ui/assistant-ui`).
104
-
105
- - **External Store & Data Handling**:
106
-
107
- - Enhanced `ExternalStoreAdapter` to support metadata and attachments.
108
- - Renamed `getExternalStoreMessage` to `getExternalStoreMessages`.
109
- - Tool call `args` streaming support in our Python SDK.
110
-
111
- - **User Interface & Styling**:
112
-
113
- - Styled UI assistant message footer.
114
- - Improved attachment filename handling to prevent overflow.
115
- - Renamed CSS class to `aui-thread-welcome-suggestions`.
116
-
117
- - **Performance Optimizations**:
118
-
119
- - Memoized `MessageRepository.getMessages()` for better efficiency.
120
- - Marked `ChatAdapter` types as readonly.
121
-
122
- - **Bug Fixes**:
123
-
124
- - Fixed event subscription issues in thread lists.
125
- - Fixed import errors in React server environments.
126
- - Prevented excessive classes being included via TailwindCSS.
127
- - Fixed AI SDK annotation packet errors.