@assistant-ui/mcp-docs-server 0.1.29 → 0.1.30

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 (53) hide show
  1. package/.docs/organized/code-examples/waterfall.md +15 -7
  2. package/.docs/organized/code-examples/with-a2a.md +8 -20
  3. package/.docs/organized/code-examples/with-ag-ui.md +9 -6
  4. package/.docs/organized/code-examples/with-ai-sdk-v6.md +8 -8
  5. package/.docs/organized/code-examples/with-artifacts.md +10 -8
  6. package/.docs/organized/code-examples/with-assistant-transport.md +9 -10
  7. package/.docs/organized/code-examples/with-chain-of-thought.md +7 -7
  8. package/.docs/organized/code-examples/with-cloud-standalone.md +13 -10
  9. package/.docs/organized/code-examples/with-cloud.md +8 -9
  10. package/.docs/organized/code-examples/with-custom-thread-list.md +8 -8
  11. package/.docs/organized/code-examples/with-elevenlabs-conversational.md +15 -10
  12. package/.docs/organized/code-examples/with-elevenlabs-scribe.md +11 -11
  13. package/.docs/organized/code-examples/with-expo.md +20 -16
  14. package/.docs/organized/code-examples/with-external-store.md +7 -7
  15. package/.docs/organized/code-examples/with-ffmpeg.md +15 -10
  16. package/.docs/organized/code-examples/with-generative-ui.md +7 -7
  17. package/.docs/organized/code-examples/with-google-adk.md +6 -6
  18. package/.docs/organized/code-examples/with-heat-graph.md +5 -5
  19. package/.docs/organized/code-examples/with-interactables.md +8 -23
  20. package/.docs/organized/code-examples/with-langchain.md +437 -0
  21. package/.docs/organized/code-examples/with-langgraph.md +15 -15
  22. package/.docs/organized/code-examples/with-livekit.md +15 -10
  23. package/.docs/organized/code-examples/with-opencode.md +8 -10
  24. package/.docs/organized/code-examples/with-parent-id-grouping.md +8 -8
  25. package/.docs/organized/code-examples/with-react-hook-form.md +219 -147
  26. package/.docs/organized/code-examples/with-react-ink.md +2 -2
  27. package/.docs/organized/code-examples/with-react-router.md +10 -10
  28. package/.docs/organized/code-examples/with-store.md +8 -5
  29. package/.docs/organized/code-examples/with-tanstack.md +8 -8
  30. package/.docs/organized/code-examples/with-tap-runtime.md +9 -5
  31. package/.docs/raw/docs/(docs)/guides/mentions.mdx +248 -109
  32. package/.docs/raw/docs/(docs)/guides/slash-commands.mdx +112 -92
  33. package/.docs/raw/docs/(docs)/rtl.mdx +79 -0
  34. package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +149 -40
  35. package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +2 -0
  36. package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +4 -0
  37. package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +1 -1
  38. package/.docs/raw/docs/primitives/composer.mdx +94 -62
  39. package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +57 -0
  40. package/.docs/raw/docs/runtimes/custom/custom-thread-list.mdx +47 -1
  41. package/.docs/raw/docs/runtimes/custom/external-store.mdx +1 -1
  42. package/.docs/raw/docs/runtimes/langchain/comparison.mdx +60 -0
  43. package/.docs/raw/docs/runtimes/langchain/index.mdx +210 -0
  44. package/.docs/raw/docs/runtimes/langgraph/index.mdx +155 -63
  45. package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +12 -4
  46. package/.docs/raw/docs/ui/composer-trigger-popover.mdx +199 -0
  47. package/.docs/raw/docs/ui/directive-text.mdx +113 -0
  48. package/.docs/raw/docs/ui/reasoning.mdx +13 -9
  49. package/dist/utils/logger.js +1 -1
  50. package/dist/utils/logger.js.map +1 -1
  51. package/package.json +3 -3
  52. package/src/utils/logger.ts +1 -1
  53. package/.docs/raw/docs/ui/mention.mdx +0 -168
@@ -0,0 +1,199 @@
1
+ ---
2
+ title: Composer Trigger Popover
3
+ description: Reusable picker UI for @ mentions, / slash commands, and any other character-triggered popover.
4
+ ---
5
+
6
+ import { ComposerTriggerPopoverSample } from "@/components/docs/samples/composer-trigger-popover";
7
+
8
+ <ComposerTriggerPopoverSample />
9
+
10
+ ## Getting Started
11
+
12
+ <Steps>
13
+ <Step>
14
+
15
+ ### Add `composer-trigger-popover`
16
+
17
+ <InstallCommand shadcn={["composer-trigger-popover"]} />
18
+
19
+ This adds `/components/assistant-ui/composer-trigger-popover.tsx` — a generic picker UI (Categories + Items + Back) driven by an adapter and one of two behavior props: `directive` (insert a chip) or `action` (run a callback).
20
+
21
+ </Step>
22
+ <Step>
23
+
24
+ ### Wrap the composer
25
+
26
+ Place `ComposerPrimitive.Unstable_TriggerPopoverRoot` around your composer. Any number of `ComposerTriggerPopover` declarations can live inside — each with its own trigger character, adapter, and behavior prop.
27
+
28
+ ```tsx title="components/assistant-ui/thread.tsx"
29
+ import { ComposerPrimitive } from "@assistant-ui/react";
30
+ import { ComposerTriggerPopover } from "@/components/assistant-ui/composer-trigger-popover";
31
+
32
+ const Composer = () => (
33
+ <ComposerPrimitive.Unstable_TriggerPopoverRoot>
34
+ <ComposerPrimitive.Root>
35
+ <ComposerPrimitive.Input placeholder="Type @ to mention, / for commands..." />
36
+ <ComposerPrimitive.Send />
37
+
38
+ {/* triggers declared here */}
39
+ </ComposerPrimitive.Root>
40
+ </ComposerPrimitive.Unstable_TriggerPopoverRoot>
41
+ );
42
+ ```
43
+
44
+ </Step>
45
+ </Steps>
46
+
47
+ ## @ Mention
48
+
49
+ Pair the popover with `unstable_useMentionAdapter` — the hook returns a spreadable `{ adapter, directive }` bundle so selecting an item writes a `:tool[Label]{name=id}` directive into the composer text.
50
+
51
+ ```tsx
52
+ import { unstable_useMentionAdapter } from "@assistant-ui/react";
53
+ import { WrenchIcon } from "lucide-react";
54
+
55
+ const mention = unstable_useMentionAdapter();
56
+
57
+ <ComposerTriggerPopover
58
+ char="@"
59
+ {...mention}
60
+ fallbackIcon={WrenchIcon}
61
+ />;
62
+ ```
63
+
64
+ Override formatter or add an `onInserted` callback via hook options: `unstable_useMentionAdapter({ formatter, onInserted })`.
65
+
66
+ `unstable_useMentionAdapter` also accepts `items` (flat custom list), `categories` (multi-category drill-down), and `includeModelContextTools` for fine-grained control. See the [Mentions guide](/docs/guides/mentions#built-in-mention-adapter).
67
+
68
+ Render selected mentions as chips in user messages with [`DirectiveText`](/docs/ui/directive-text). For inline chips **inside** the composer, use [`LexicalComposerInput`](/docs/guides/mentions#textarea-vs-lexical).
69
+
70
+ ## / Slash Command
71
+
72
+ Use [`unstable_useSlashCommandAdapter`](/docs/guides/slash-commands) to bundle commands (data + `execute`) into `{ adapter, action }` — then plug both into `ComposerTriggerPopover`. By default a directive chip is left in the composer as an audit trail; pass `removeOnExecute` to strip the `/command` text entirely. `iconMap` maps `metadata.icon` strings on items and categories to Lucide icons.
73
+
74
+ ```tsx
75
+ import {
76
+ unstable_useSlashCommandAdapter,
77
+ type Unstable_SlashCommand,
78
+ } from "@assistant-ui/react";
79
+ import { FileTextIcon, GlobeIcon, LanguagesIcon, SlashIcon } from "lucide-react";
80
+
81
+ const SLASH_COMMANDS: readonly Unstable_SlashCommand[] = [
82
+ {
83
+ id: "summarize",
84
+ description: "Summarize the conversation",
85
+ icon: "FileText",
86
+ execute: () => {/* ... */},
87
+ },
88
+ {
89
+ id: "translate",
90
+ description: "Translate to another language",
91
+ icon: "Languages",
92
+ execute: () => {/* ... */},
93
+ },
94
+ {
95
+ id: "search",
96
+ description: "Search the web",
97
+ icon: "Globe",
98
+ execute: () => {/* ... */},
99
+ },
100
+ ];
101
+
102
+ function SlashComposer() {
103
+ const slash = unstable_useSlashCommandAdapter({ commands: SLASH_COMMANDS });
104
+
105
+ return (
106
+ <ComposerTriggerPopover
107
+ char="/"
108
+ {...slash}
109
+ iconMap={{
110
+ FileText: FileTextIcon,
111
+ Languages: LanguagesIcon,
112
+ Globe: GlobeIcon,
113
+ }}
114
+ fallbackIcon={SlashIcon}
115
+ />
116
+ );
117
+ }
118
+ ```
119
+
120
+ ## Combining Triggers
121
+
122
+ Multiple popovers coexist under one `TriggerPopoverRoot`. Each reads state from its own declaration, so `@` and `/` never collide.
123
+
124
+ ```tsx
125
+ const commandHandlers: Record<string, () => void> = {
126
+ summarize: () => {/* ... */},
127
+ translate: () => {/* ... */},
128
+ };
129
+
130
+ <ComposerPrimitive.Unstable_TriggerPopoverRoot>
131
+ <ComposerPrimitive.Root>
132
+ <ComposerPrimitive.Input placeholder="Type @ to mention, / for commands..." />
133
+
134
+ <ComposerTriggerPopover
135
+ char="@"
136
+ adapter={mentionAdapter}
137
+ directive={{ formatter: unstable_defaultDirectiveFormatter }}
138
+ fallbackIcon={WrenchIcon}
139
+ />
140
+ <ComposerTriggerPopover
141
+ char="/"
142
+ adapter={slashAdapter}
143
+ action={{
144
+ formatter: unstable_defaultDirectiveFormatter,
145
+ onExecute: (item) => commandHandlers[item.id]?.(),
146
+ }}
147
+ iconMap={slashIcons}
148
+ fallbackIcon={SlashIcon}
149
+ />
150
+ </ComposerPrimitive.Root>
151
+ </ComposerPrimitive.Unstable_TriggerPopoverRoot>
152
+ ```
153
+
154
+ ## Keyboard Navigation
155
+
156
+ | Key | Action |
157
+ | --- | --- |
158
+ | <Kbd>ArrowDown</Kbd> | Highlight next item |
159
+ | <Kbd>ArrowUp</Kbd> | Highlight previous item |
160
+ | <Kbd>Enter</Kbd> | Select highlighted item / drill into category |
161
+ | <Kbd>Escape</Kbd> | Close popover |
162
+ | <Kbd>Backspace</Kbd> | Go back to categories (when query is empty) |
163
+
164
+ ## API Reference
165
+
166
+ | Prop | Type | Default | Description |
167
+ | --- | --- | --- | --- |
168
+ | `char` | `string` | — | Trigger character, e.g. `"@"` or `"/"` (required; unique within the root) |
169
+ | `adapter` | `Unstable_TriggerAdapter` | — | Provides categories, items, and search (required) |
170
+ | `directive` | `{ formatter, onInserted?, chip? }` | — | Enables directive-insert behavior. Mutually exclusive with `action`. |
171
+ | `action` | `{ formatter, onExecute, removeOnExecute?, chip? }` | — | Enables action behavior. Mutually exclusive with `directive`. |
172
+ | `iconMap` | `Record<string, IconComponent>` | — | Maps `item.metadata.icon` / `category.metadata.icon` strings to icons |
173
+ | `fallbackIcon` | `IconComponent` | `SparklesIcon` | Icon used when no `iconMap` entry matches |
174
+ | `backLabel` | `string` | `"Back"` | Back button label |
175
+ | `emptyCategoriesLabel` | `string` | `"No items available"` | Shown when no categories are available |
176
+ | `emptyItemsLabel` | `string` | `"No matching items"` | Shown when no items match |
177
+
178
+ All other props (`className`, etc.) forward to the underlying popover `div`.
179
+
180
+ ### `directive` object
181
+
182
+ | Field | Type | Description |
183
+ | --- | --- | --- |
184
+ | `formatter` | `Unstable_DirectiveFormatter` | Serializes the selected item into the directive text written to the composer |
185
+ | `onInserted` | `(item) => void` | Optional callback fired after the directive has been inserted |
186
+
187
+ ### `action` object
188
+
189
+ | Field | Type | Description |
190
+ | --- | --- | --- |
191
+ | `formatter` | `Unstable_DirectiveFormatter` | Serializes the selected item into the chip left behind (unused when `removeOnExecute`) |
192
+ | `onExecute` | `(item) => void` | Callback fired when an item is selected |
193
+ | `removeOnExecute` | `boolean` | When `true`, strips the trigger text instead of leaving a chip. Default `false`. |
194
+
195
+ ## Related
196
+
197
+ - [Directive Text](/docs/ui/directive-text) — renderer for mention chips in user messages
198
+ - [Mentions guide](/docs/guides/mentions) — `@`-mention architecture and formatter details
199
+ - [Slash Commands guide](/docs/guides/slash-commands) — `/`-command architecture
@@ -0,0 +1,113 @@
1
+ ---
2
+ title: Directive Text
3
+ description: Render mention directives as inline chips in user messages.
4
+ ---
5
+
6
+ import { DirectiveTextSample } from "@/components/docs/samples/directive-text";
7
+
8
+ <DirectiveTextSample />
9
+
10
+ `DirectiveText` parses the directive syntax written by [`ComposerTriggerPopover`](/docs/ui/composer-trigger-popover) (default: `:type[label]{name=id}`) and renders each segment as an inline chip. Use it as the `Text` component in user messages so the raw directive syntax never shows up.
11
+
12
+ ## Getting Started
13
+
14
+ <Steps>
15
+ <Step>
16
+
17
+ ### Add `directive-text`
18
+
19
+ <InstallCommand shadcn={["directive-text"]} />
20
+
21
+ This adds `/components/assistant-ui/directive-text.tsx` with `DirectiveText` and the `createDirectiveText(formatter, options?)` factory.
22
+
23
+ </Step>
24
+ <Step>
25
+
26
+ ### Use in user messages
27
+
28
+ Pass `DirectiveText` as the `Text` component in `MessagePrimitive.Parts`:
29
+
30
+ ```tsx title="components/assistant-ui/thread.tsx"
31
+ import { DirectiveText } from "@/components/assistant-ui/directive-text";
32
+
33
+ const UserMessage = () => (
34
+ <MessagePrimitive.Root>
35
+ <MessagePrimitive.Parts components={{ Text: DirectiveText }} />
36
+ </MessagePrimitive.Root>
37
+ );
38
+ ```
39
+
40
+ Keep your markdown renderer (e.g. `MarkdownText`) for assistant messages — assistants rarely emit directive syntax.
41
+
42
+ </Step>
43
+ </Steps>
44
+
45
+ ## Icons per Directive Type
46
+
47
+ `DirectiveText` ships icon-free by default — every parsed segment renders as a plain label chip regardless of its `type`. To add icons, use the `createDirectiveText` factory and pass an `iconMap` that routes each `type` string to an icon component, plus an optional `fallbackIcon` for unmapped types:
48
+
49
+ ```tsx
50
+ import { createDirectiveText } from "@/components/assistant-ui/directive-text";
51
+ import { unstable_defaultDirectiveFormatter } from "@assistant-ui/core";
52
+ import { FileTextIcon, SparklesIcon, UserIcon, WrenchIcon } from "lucide-react";
53
+
54
+ const DirectiveTextWithIcons = createDirectiveText(
55
+ unstable_defaultDirectiveFormatter,
56
+ {
57
+ iconMap: {
58
+ tool: WrenchIcon,
59
+ user: UserIcon,
60
+ file: FileTextIcon,
61
+ },
62
+ fallbackIcon: SparklesIcon,
63
+ },
64
+ );
65
+
66
+ <MessagePrimitive.Parts components={{ Text: DirectiveTextWithIcons }} />;
67
+ ```
68
+
69
+ A matching `iconMap` / `fallbackIcon` option is accepted by [`ComposerTriggerPopover`](/docs/ui/composer-trigger-popover), where it routes `item.metadata.icon` strings instead of `type` — keeping icon configuration consistent across the composer and the rendered message.
70
+
71
+ ## Custom Formatter
72
+
73
+ The default format is `:type[label]{name=id}`. For a different format, build a custom `Unstable_DirectiveFormatter` and wrap it with `createDirectiveText`:
74
+
75
+ ```tsx
76
+ import type { Unstable_DirectiveFormatter } from "@assistant-ui/core";
77
+ import { createDirectiveText } from "@/components/assistant-ui/directive-text";
78
+
79
+ const slashFormatter: Unstable_DirectiveFormatter = {
80
+ serialize: (item) => `/${item.id}`,
81
+ parse: (text) => {
82
+ /* return alternating text / mention segments */
83
+ },
84
+ };
85
+
86
+ const SlashDirectiveText = createDirectiveText(slashFormatter);
87
+ ```
88
+
89
+ Pass the **same formatter** to the composer trigger's `directive={{ formatter }}` (or `action={{ formatter }}`) so insertion and rendering stay consistent.
90
+
91
+ ## Customizing the Chip
92
+
93
+ Because `directive-text.tsx` is copied into your project, you can also edit it directly — swap the chip styling, read `data-directive-id` to link to a detail page, or replace the chip wrapper entirely.
94
+
95
+ ## API Reference
96
+
97
+ ### `DirectiveText`
98
+
99
+ A `TextMessagePartComponent` that parses `:type[label]{name=id}` directives and renders them as inline chips. Uses the default formatter from `@assistant-ui/core` and renders chips without icons. For per-type icons, build a component with `createDirectiveText(formatter, { iconMap })`.
100
+
101
+ ### `createDirectiveText(formatter, options?)`
102
+
103
+ Factory that returns a `TextMessagePartComponent` bound to a custom `Unstable_DirectiveFormatter`.
104
+
105
+ | Option | Type | Description |
106
+ | --- | --- | --- |
107
+ | `iconMap` | `Record<string, ComponentType<{ className?: string }>>` | Maps a directive segment's `type` to an icon rendered inside the chip |
108
+ | `fallbackIcon` | `ComponentType<{ className?: string }>` | Icon used when no `iconMap` entry matches. When neither option resolves, the chip renders without an icon. |
109
+
110
+ ## Related
111
+
112
+ - [Composer Trigger Popover](/docs/ui/composer-trigger-popover) — the picker that inserts directives
113
+ - [Mentions guide](/docs/guides/mentions) — directive format, backend parsing
@@ -23,22 +23,26 @@ This adds a `/components/assistant-ui/reasoning.tsx` file to your project.
23
23
 
24
24
  ### Use in your application
25
25
 
26
- Pass the `Reasoning` and `ReasoningGroup` components to the `MessagePrimitive.Parts` component:
26
+ Pass the `Reasoning` and `ReasoningGroup` components to `MessagePrimitive.Parts` via the `components` prop. Using them together is the recommended default — `ReasoningGroup` wraps consecutive reasoning parts in a collapsible container for a smooth out-of-the-box UI.
27
27
 
28
- ```tsx title="/app/components/assistant-ui/thread.tsx" {2,10-11}
28
+ ```tsx title="/app/components/assistant-ui/thread.tsx"
29
29
  import { MessagePrimitive } from "@assistant-ui/react";
30
- import { Reasoning } from "@/components/assistant-ui/reasoning";
30
+ import { MarkdownText } from "@/components/assistant-ui/markdown-text";
31
+ import { ToolFallback } from "@/components/assistant-ui/tool-fallback";
32
+ import { Reasoning, ReasoningGroup } from "@/components/assistant-ui/reasoning"; // [!code ++]
31
33
 
32
34
  const AssistantMessage: FC = () => {
33
35
  return (
34
36
  <MessagePrimitive.Root className="...">
35
37
  <div className="...">
36
- <MessagePrimitive.Parts>
37
- {({ part }) => {
38
- if (part.type === "reasoning") return <Reasoning {...part} />;
39
- return null;
38
+ <MessagePrimitive.Parts
39
+ components={{
40
+ Text: MarkdownText,
41
+ Reasoning, // [!code ++]
42
+ ReasoningGroup, // [!code ++]
43
+ tools: { Fallback: ToolFallback },
40
44
  }}
41
- </MessagePrimitive.Parts>
45
+ />
42
46
  </div>
43
47
  <AssistantActionBar />
44
48
  <BranchPicker className="..." />
@@ -57,7 +61,7 @@ The component consists of two parts:
57
61
  1. `Reasoning`: Renders individual reasoning message part content (with markdown support)
58
62
  2. `ReasoningGroup`: Wraps consecutive reasoning parts in a collapsible container
59
63
 
60
- Consecutive reasoning parts are automatically grouped together by the `ReasoningGroup` component.
64
+ Consecutive reasoning parts are automatically grouped together by `ReasoningGroup`. We recommend using both together as the default — you can drop `ReasoningGroup` or build your own layout with the composable API below if you need more flexibility.
61
65
 
62
66
  > When using the composable API, `Reasoning.Text` is a plain container. Add `<MarkdownText />` for markdown rendering.
63
67
 
@@ -1,7 +1,7 @@
1
1
  import { IS_PREPARE_MODE } from "../constants.js";
2
2
  export const logger = {
3
3
  debug: (message, ...args) => {
4
- if (process.env["DEBUG"]) {
4
+ if (process.env.DEBUG) {
5
5
  console.debug(`[DEBUG] ${message}`, ...args);
6
6
  }
7
7
  },
@@ -1 +1 @@
1
- {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;QACzC,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,KAAK,CAAC,WAAW,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;QACxC,IAAI,eAAe,EAAE,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IACD,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;QACzC,OAAO,CAAC,KAAK,CAAC,WAAW,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC/C,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;QACxC,OAAO,CAAC,IAAI,CAAC,UAAU,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC7C,CAAC;CACF,CAAC"}
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;QACzC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;YACtB,OAAO,CAAC,KAAK,CAAC,WAAW,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QAC/C,CAAC;IACH,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;QACxC,IAAI,eAAe,EAAE,CAAC;YACpB,OAAO,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IACD,KAAK,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;QACzC,OAAO,CAAC,KAAK,CAAC,WAAW,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC/C,CAAC;IACD,IAAI,EAAE,CAAC,OAAe,EAAE,GAAG,IAAW,EAAE,EAAE;QACxC,OAAO,CAAC,IAAI,CAAC,UAAU,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAC7C,CAAC;CACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@assistant-ui/mcp-docs-server",
3
- "version": "0.1.29",
3
+ "version": "0.1.30",
4
4
  "description": "MCP server for assistant-ui documentation and examples",
5
5
  "keywords": [
6
6
  "mcp",
@@ -39,8 +39,8 @@
39
39
  "devDependencies": {
40
40
  "@types/node": "^25.6.0",
41
41
  "tsx": "^4.21.0",
42
- "vitest": "^4.1.4",
43
- "@assistant-ui/x-buildutils": "0.0.5"
42
+ "vitest": "^4.1.5",
43
+ "@assistant-ui/x-buildutils": "0.0.6"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public",
@@ -2,7 +2,7 @@ import { IS_PREPARE_MODE } from "../constants.js";
2
2
 
3
3
  export const logger = {
4
4
  debug: (message: string, ...args: any[]) => {
5
- if (process.env["DEBUG"]) {
5
+ if (process.env.DEBUG) {
6
6
  console.debug(`[DEBUG] ${message}`, ...args);
7
7
  }
8
8
  },
@@ -1,168 +0,0 @@
1
- ---
2
- title: Mention
3
- description: Let users @-mention tools in the composer with a keyboard-navigable popover picker and inline chips.
4
- ---
5
-
6
- ## Getting Started
7
-
8
- <Steps>
9
- <Step>
10
-
11
- ### Add `composer-mention`
12
-
13
- <InstallCommand shadcn={["composer-mention"]} />
14
-
15
- This adds a `/components/assistant-ui/composer-mention.tsx` file with `ComposerMentionPopover`, `ComposerMentionRoot`, and `DirectiveText`.
16
-
17
- </Step>
18
- <Step>
19
-
20
- ### Wrap the Composer
21
-
22
- Wrap your composer with `ComposerMentionPopover.Root` and add `<ComposerMentionPopover />` inside:
23
-
24
- ```tsx title="components/assistant-ui/thread.tsx" {1,7,10}
25
- import { ComposerMentionPopover } from "@/components/assistant-ui/composer-mention";
26
-
27
- const Composer = () => {
28
- return (
29
- <ComposerMentionPopover.Root>
30
- <ComposerPrimitive.Root>
31
- <ComposerPrimitive.Input placeholder="Type @ to mention a tool..." />
32
- <ComposerPrimitive.Send />
33
- <ComposerMentionPopover />
34
- </ComposerPrimitive.Root>
35
- </ComposerMentionPopover.Root>
36
- );
37
- };
38
- ```
39
-
40
- The popover automatically shows registered tools when the user types `@`.
41
-
42
- </Step>
43
- <Step>
44
-
45
- ### Render Mentions in User Messages
46
-
47
- Use `DirectiveText` as the `Text` component for **user messages** so mention directives render as inline chips instead of raw `:tool[label]` syntax:
48
-
49
- ```tsx title="components/assistant-ui/thread.tsx" {1,8}
50
- import { DirectiveText } from "@/components/assistant-ui/composer-mention";
51
-
52
- const UserMessage = () => {
53
- return (
54
- <MessagePrimitive.Root>
55
- <MessagePrimitive.Parts
56
- components={{
57
- Text: DirectiveText,
58
- }}
59
- />
60
- </MessagePrimitive.Root>
61
- );
62
- };
63
- ```
64
-
65
- <Callout>
66
- `DirectiveText` renders plain text with mention chips. For assistant messages
67
- that contain markdown, keep using your markdown renderer (e.g. `MarkdownText`).
68
- </Callout>
69
-
70
- </Step>
71
- </Steps>
72
-
73
- ## With Lexical Rich Editor
74
-
75
- For inline mention chips in the composer (not just the popover), use `LexicalComposerInput` from `@assistant-ui/react-lexical`:
76
-
77
- ```bash
78
- npm install @assistant-ui/react-lexical lexical @lexical/react
79
- ```
80
-
81
- Replace `ComposerPrimitive.Input` with `LexicalComposerInput`:
82
-
83
- ```tsx title="components/assistant-ui/thread.tsx" {1,8}
84
- import { LexicalComposerInput } from "@assistant-ui/react-lexical";
85
-
86
- const Composer = () => {
87
- return (
88
- <ComposerMentionPopover.Root>
89
- <ComposerPrimitive.Root>
90
- <LexicalComposerInput placeholder="Type @ to mention a tool..." />
91
- <ComposerPrimitive.Send />
92
- <ComposerMentionPopover />
93
- </ComposerPrimitive.Root>
94
- </ComposerMentionPopover.Root>
95
- );
96
- };
97
- ```
98
-
99
- `LexicalComposerInput` auto-wires to `MentionContext` — no extra props needed. Selected mentions appear as inline chips that are treated as atomic units (select, delete, undo as a whole).
100
-
101
- ## Custom Formatter
102
-
103
- The default directive format is `:type[label]{name=id}`. To use a custom format, pass a `formatter` to both the mention root and the message renderer:
104
-
105
- ```tsx
106
- import { ComposerMentionPopover } from "@/components/assistant-ui/composer-mention";
107
- import { createDirectiveText } from "@/components/assistant-ui/composer-mention";
108
-
109
- const myFormatter = {
110
- serialize: (item) => `@${item.id}`,
111
- parse: (text) => [{ kind: "text", text }], // implement your parsing
112
- };
113
-
114
- // In composer (textarea path):
115
- <ComposerMentionPopover.Root formatter={myFormatter}>
116
- ...
117
- </ComposerMentionPopover.Root>
118
-
119
- // In composer (Lexical path — also pass formatter):
120
- <ComposerMentionPopover.Root formatter={myFormatter}>
121
- <ComposerPrimitive.Root>
122
- <LexicalComposerInput formatter={myFormatter} />
123
- ...
124
- </ComposerPrimitive.Root>
125
- </ComposerMentionPopover.Root>
126
-
127
- // In user messages:
128
- const MyDirectiveText = createDirectiveText(myFormatter);
129
- <MessagePrimitive.Parts components={{ Text: MyDirectiveText }} />
130
- ```
131
-
132
- ## Keyboard Navigation
133
-
134
- The mention popover supports full keyboard navigation out of the box:
135
-
136
- | Key | Action |
137
- | --- | --- |
138
- | <Kbd>ArrowDown</Kbd> | Highlight next item |
139
- | <Kbd>ArrowUp</Kbd> | Highlight previous item |
140
- | <Kbd>Enter</Kbd> | Select highlighted item / drill into category |
141
- | <Kbd>Escape</Kbd> | Close popover |
142
- | <Kbd>Backspace</Kbd> | Go back to categories (when query is empty) |
143
-
144
- ## Components
145
-
146
- ### `ComposerMentionPopover.Root`
147
-
148
- Wraps the composer with mention context and a tool mention adapter. Provides the `@`-trigger detection, keyboard navigation, and popover state.
149
-
150
- | Prop | Type | Default | Description |
151
- | --- | --- | --- | --- |
152
- | `adapter` | `Unstable_MentionAdapter` | Tool adapter | Custom mention adapter |
153
- | `trigger` | `string` | `"@"` | Character(s) that open the popover |
154
- | `formatter` | `Unstable_DirectiveFormatter` | Default | Custom directive serializer/parser |
155
- | `formatLabel` | `(name: string) => string` | Title case | Format tool names for display |
156
- | `categoryLabel` | `string` | `"Tools"` | Label for the tools category |
157
-
158
- ### `ComposerMentionPopover`
159
-
160
- Pre-built popover containing categories and items lists. Only renders when the `@` trigger is active.
161
-
162
- ### `DirectiveText`
163
-
164
- A `TextMessagePartComponent` that parses `:type[label]{name=id}` directives and renders them as styled inline chips.
165
-
166
- ### `createDirectiveText(formatter)`
167
-
168
- Factory function that creates a `TextMessagePartComponent` using a custom `Unstable_DirectiveFormatter`.