@assistant-ui/mcp-docs-server 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/code-examples/waterfall.md +12 -13
- package/.docs/organized/code-examples/with-a2a.md +16 -11
- package/.docs/organized/code-examples/with-ag-ui.md +15 -13
- package/.docs/organized/code-examples/with-ai-sdk-v7.md +14 -13
- package/.docs/organized/code-examples/with-artifacts.md +14 -13
- package/.docs/organized/code-examples/with-assistant-transport.md +20 -28
- package/.docs/organized/code-examples/with-browser-extension.md +18 -11
- package/.docs/organized/code-examples/with-chain-of-thought.md +17 -15
- package/.docs/organized/code-examples/with-cloud-standalone.md +10 -11
- package/.docs/organized/code-examples/with-cloud.md +19 -14
- package/.docs/organized/code-examples/with-custom-thread-list.md +15 -14
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +14 -14
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +19 -17
- package/.docs/organized/code-examples/with-eve.md +66 -12
- package/.docs/organized/code-examples/with-expo.md +26 -31
- package/.docs/organized/code-examples/with-external-store.md +17 -12
- package/.docs/organized/code-examples/with-ffmpeg.md +21 -15
- package/.docs/organized/code-examples/with-generative-ui.md +271 -36
- package/.docs/organized/code-examples/with-google-adk.md +17 -12
- package/.docs/organized/code-examples/with-heat-graph.md +6 -7
- package/.docs/organized/code-examples/with-image-generation.md +9 -10
- package/.docs/organized/code-examples/with-interactables.md +14 -13
- package/.docs/organized/code-examples/with-langchain.md +12 -13
- package/.docs/organized/code-examples/with-langgraph.md +19 -13
- package/.docs/organized/code-examples/with-livekit.md +13 -13
- package/.docs/organized/code-examples/with-mcp.md +14 -15
- package/.docs/organized/code-examples/with-nuxt.md +2428 -0
- package/.docs/organized/code-examples/with-opencode.md +23 -14
- package/.docs/organized/code-examples/with-openui.md +449 -0
- package/.docs/organized/code-examples/with-pi.md +59 -57
- package/.docs/organized/code-examples/with-react-hook-form.md +16 -15
- package/.docs/organized/code-examples/with-react-ink-web.md +7 -8
- package/.docs/organized/code-examples/with-react-ink.md +6 -6
- package/.docs/organized/code-examples/with-react-router.md +17 -11
- package/.docs/organized/code-examples/with-resumable-stream.md +12 -13
- package/.docs/organized/code-examples/with-store.md +27 -16
- package/.docs/organized/code-examples/with-svelte.md +415 -0
- package/.docs/organized/code-examples/with-sveltekit.md +1061 -0
- package/.docs/organized/code-examples/with-tanstack.md +19 -13
- package/.docs/organized/code-examples/with-tap-runtime.md +15 -15
- package/.docs/organized/code-examples/with-virtualized-thread.md +8 -9
- package/.docs/organized/code-examples/with-vue.md +408 -0
- package/.docs/raw/docs/(docs)/cli.mdx +7 -2
- package/.docs/raw/docs/(docs)/index.mdx +9 -76
- package/.docs/raw/docs/(docs)/installation.mdx +6 -20
- package/.docs/raw/docs/(reference)/api-reference/context-providers/assistant-runtime-provider.mdx +24 -4
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/slack.mdx +5 -1
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/teams.mdx +9 -2
- package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +2 -2
- package/.docs/raw/docs/(reference)/api-reference/integrations/eve.mdx +47 -1
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +29 -4
- package/.docs/raw/docs/(reference)/api-reference/tools/status.mdx +1 -1
- package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +52 -1
- package/.docs/raw/docs/(reference)/api-reference/voice/session.mdx +1 -1
- package/.docs/raw/docs/cloud/ai-sdk-assistant-ui.mdx +2 -2
- package/.docs/raw/docs/cloud/ai-sdk.mdx +4 -4
- package/.docs/raw/docs/cloud/index.mdx +1 -1
- package/.docs/raw/docs/copilots/model-context.mdx +4 -3
- package/.docs/raw/docs/copilots/motivation.mdx +4 -4
- package/.docs/raw/docs/guides/attachments.mdx +2 -2
- package/.docs/raw/docs/guides/chain-of-thought.mdx +1 -1
- package/.docs/raw/docs/guides/context-api.mdx +15 -17
- package/.docs/raw/docs/guides/dictation.mdx +1 -1
- package/.docs/raw/docs/guides/electron.mdx +1 -1
- package/.docs/raw/docs/guides/mentions.mdx +2 -0
- package/.docs/raw/docs/guides/resumable-streams.mdx +74 -3
- package/.docs/raw/docs/guides/suggestions.mdx +15 -12
- package/.docs/raw/docs/ink/hooks.mdx +9 -4
- package/.docs/raw/docs/ink/primitives.mdx +5 -4
- package/.docs/raw/docs/integrations/attachments/custom-adapter.mdx +16 -0
- package/.docs/raw/docs/integrations/auth/better-auth.mdx +1 -1
- package/.docs/raw/docs/integrations/auth/clerk.mdx +1 -1
- package/.docs/raw/docs/integrations/auth/next-auth.mdx +1 -1
- package/.docs/raw/docs/integrations/frameworks/cloudflare-agents/overview.mdx +1 -1
- package/.docs/raw/docs/integrations/frameworks/mastra/full-stack.mdx +2 -2
- package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +1 -1
- package/.docs/raw/docs/integrations/gateways/index.mdx +2 -2
- package/.docs/raw/docs/integrations/observability/helicone.mdx +2 -2
- package/.docs/raw/docs/integrations/observability/langfuse.mdx +1 -1
- package/.docs/raw/docs/integrations/observability/langsmith.mdx +2 -2
- package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +146 -128
- package/.docs/raw/docs/migrations/toolkit-tools.mdx +15 -13
- package/.docs/raw/docs/migrations/v0-15.mdx +118 -4
- package/.docs/raw/docs/primitives/attachment.mdx +2 -2
- package/.docs/raw/docs/primitives/composer.mdx +2 -2
- package/.docs/raw/docs/primitives/message.mdx +33 -1
- package/.docs/raw/docs/primitives/suggestion.mdx +4 -2
- package/.docs/raw/docs/primitives/thread.mdx +1 -1
- package/.docs/raw/docs/react-native/hooks.mdx +14 -4
- package/.docs/raw/docs/react-native/index.mdx +1 -1
- package/.docs/raw/docs/react-native/primitives.mdx +2 -2
- package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +35 -5
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +1 -1
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +1 -1
- package/.docs/raw/docs/runtimes/ai-sdk/v6-legacy.mdx +9 -10
- package/.docs/raw/docs/runtimes/ai-sdk/v7.mdx +9 -10
- package/.docs/raw/docs/runtimes/claude-managed-agents.mdx +118 -0
- package/.docs/raw/docs/runtimes/concepts/stability.mdx +2 -1
- package/.docs/raw/docs/runtimes/concepts/threads.mdx +106 -27
- package/.docs/raw/docs/runtimes/custom/assistant-transport.mdx +19 -1
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +34 -1
- package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +36 -9
- package/.docs/raw/docs/runtimes/eve/overview.mdx +51 -0
- package/.docs/raw/docs/runtimes/eve/quickstart.mdx +51 -2
- package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +9 -12
- package/.docs/raw/docs/runtimes/langchain.mdx +1 -1
- package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +5 -1
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +7 -7
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +4 -4
- package/.docs/raw/docs/runtimes/opencode/hooks.mdx +1 -0
- package/.docs/raw/docs/runtimes/opencode/overview.mdx +10 -0
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +8 -1
- package/.docs/raw/docs/tools/backend.mdx +2 -2
- package/.docs/raw/docs/tools/defining-tools.mdx +28 -7
- package/.docs/raw/docs/tools/dynamic-tools.mdx +6 -4
- package/.docs/raw/docs/tools/generative-ui-primitive.mdx +180 -0
- package/.docs/raw/docs/tools/generative-ui-slack.mdx +167 -0
- package/.docs/raw/docs/tools/generative-ui-teams.mdx +160 -0
- package/.docs/raw/docs/tools/generative-ui.mdx +224 -211
- package/.docs/raw/docs/tools/index.mdx +2 -1
- package/.docs/raw/docs/tools/interactables.mdx +29 -17
- package/.docs/raw/docs/tools/mcp-apps.mdx +35 -6
- package/.docs/raw/docs/tools/mcp.mdx +9 -7
- package/.docs/raw/docs/tools/openui.mdx +175 -0
- package/.docs/raw/docs/tools/tool-ui.mdx +27 -24
- package/.docs/raw/docs/tools/user-managed-mcp.mdx +17 -8
- package/.docs/raw/docs/ui/attachment.mdx +27 -0
- package/.docs/raw/docs/ui/file.mdx +7 -2
- package/.docs/raw/docs/ui/image.mdx +1 -1
- package/.docs/raw/docs/ui/mcp-config.mdx +8 -3
- package/.docs/raw/docs/ui/model-selector.mdx +8 -8
- package/.docs/raw/docs/ui/part-grouping.mdx +1 -1
- package/.docs/raw/docs/ui/thread.mdx +24 -5
- package/.docs/raw/docs/utilities/react-o11y.mdx +7 -9
- package/dist/constants.js +2 -2
- package/dist/constants.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/prepare-docs/prepare.js.map +1 -1
- package/dist/tools/docs.js +4 -2
- package/dist/tools/docs.js.map +1 -1
- package/dist/tools/examples.js +2 -1
- package/dist/tools/examples.js.map +1 -1
- package/dist/tools/resources.js +2 -1
- package/dist/tools/resources.js.map +1 -1
- package/dist/tools/tests/test-setup.js +2 -1
- package/dist/tools/tests/test-setup.js.map +1 -1
- package/dist/tools/xulux-templates.js +4 -2
- package/dist/tools/xulux-templates.js.map +1 -1
- package/dist/utils/mdx.js +2 -1
- package/dist/utils/mdx.js.map +1 -1
- package/dist/xulux/catalog-client.js +1 -1
- package/dist/xulux/catalog-client.js.map +1 -1
- package/package.json +4 -4
- package/src/tools/tests/docs.test.ts +2 -2
- package/.docs/raw/docs/tools/interactables-legacy.mdx +0 -410
|
@@ -7,6 +7,11 @@ platforms: ["react"]
|
|
|
7
7
|
import { AttachmentSample } from "@/components/docs/samples/attachment";
|
|
8
8
|
import * as AttachmentRadixSamples from "@/components/docs/samples/attachment.radix";
|
|
9
9
|
import { Flavored, FlavorSwitcher } from "@/components/docs/contexts/flavor.server";
|
|
10
|
+
import { PreviewCode } from "@/components/docs/preview-code.server";
|
|
11
|
+
import { AttachmentComposerSample } from "@/components/docs/samples/attachment/composer-attachments";
|
|
12
|
+
import * as AttachmentComposerRadixSample from "@/components/docs/samples/attachment/composer-attachments.radix";
|
|
13
|
+
import { AttachmentMessageContextSample } from "@/components/docs/samples/attachment/message-attachments";
|
|
14
|
+
import * as AttachmentMessageRadixSample from "@/components/docs/samples/attachment/message-attachments.radix";
|
|
10
15
|
|
|
11
16
|
<FlavorSwitcher />
|
|
12
17
|
|
|
@@ -35,6 +40,8 @@ This adds a `/components/assistant-ui/attachment.tsx` file to your project, whic
|
|
|
35
40
|
|
|
36
41
|
### Use in your application
|
|
37
42
|
|
|
43
|
+
Add `ComposerAttachments` and `ComposerAddAttachment` to your composer:
|
|
44
|
+
|
|
38
45
|
```tsx title="/components/assistant-ui/thread.tsx" {1-4,9-10}
|
|
39
46
|
import {
|
|
40
47
|
ComposerAttachments,
|
|
@@ -59,6 +66,8 @@ const Composer: FC = () => {
|
|
|
59
66
|
};
|
|
60
67
|
```
|
|
61
68
|
|
|
69
|
+
Add `UserMessageAttachments` to your user message:
|
|
70
|
+
|
|
62
71
|
```tsx title="/components/assistant-ui/thread.tsx" {1,8}
|
|
63
72
|
import { UserMessageAttachments } from "@/components/assistant-ui/attachment";
|
|
64
73
|
|
|
@@ -82,6 +91,24 @@ const UserMessage: FC = () => {
|
|
|
82
91
|
</Step>
|
|
83
92
|
</Steps>
|
|
84
93
|
|
|
94
|
+
## Examples
|
|
95
|
+
|
|
96
|
+
### Composer
|
|
97
|
+
|
|
98
|
+
In the composer, each attachment tile shows a remove button that deletes the attachment from the composer. Use the plus button to add your own files.
|
|
99
|
+
|
|
100
|
+
<PreviewCode file="components/docs/samples/attachment/composer-attachments" name="ComposerWithAttachments" base={<AttachmentComposerSample />}>
|
|
101
|
+
<AttachmentComposerRadixSample.AttachmentComposerSample />
|
|
102
|
+
</PreviewCode>
|
|
103
|
+
|
|
104
|
+
### User Message
|
|
105
|
+
|
|
106
|
+
Message attachments are read-only. The same tile in a sent user message does not show a remove button.
|
|
107
|
+
|
|
108
|
+
<PreviewCode file="components/docs/samples/attachment/message-attachments" name="UserMessageWithAttachments" base={<AttachmentMessageContextSample />}>
|
|
109
|
+
<AttachmentMessageRadixSample.AttachmentMessageContextSample />
|
|
110
|
+
</PreviewCode>
|
|
111
|
+
|
|
85
112
|
## API Reference
|
|
86
113
|
|
|
87
114
|
### Composer Attachments
|
|
@@ -22,7 +22,7 @@ import { FileSample } from "@/components/docs/samples/file";
|
|
|
22
22
|
|
|
23
23
|
### Use in your application
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
The shipped `Thread` component renders `file` parts through `File` by default, in both assistant and user messages. In a custom thread, pass `File` to `MessagePrimitive.Parts`:
|
|
26
26
|
|
|
27
27
|
```tsx title="/components/assistant-ui/thread.tsx" {1,8}
|
|
28
28
|
import { File } from "@/components/assistant-ui/file";
|
|
@@ -115,7 +115,7 @@ import {
|
|
|
115
115
|
| `File.Icon` | MIME type-aware icon, or pass custom `children` |
|
|
116
116
|
| `File.Name` | Truncated filename |
|
|
117
117
|
| `File.Size` | Human-readable file size |
|
|
118
|
-
| `File.Download` | Download link button |
|
|
118
|
+
| `File.Download` | Download link button; renders nothing without a browser-resolvable target (`sourceType: "id"`, urls that are not http(s)/blob/data) |
|
|
119
119
|
|
|
120
120
|
### Custom Icon
|
|
121
121
|
|
|
@@ -134,6 +134,7 @@ The component also exports utility functions:
|
|
|
134
134
|
```tsx
|
|
135
135
|
import {
|
|
136
136
|
getMimeTypeIcon,
|
|
137
|
+
getFileDataKind,
|
|
137
138
|
getBase64Size,
|
|
138
139
|
formatFileSize,
|
|
139
140
|
} from "@/components/assistant-ui/file";
|
|
@@ -141,6 +142,10 @@ import {
|
|
|
141
142
|
// Get icon component for a MIME type
|
|
142
143
|
const Icon = getMimeTypeIcon("application/pdf"); // FileTextIcon
|
|
143
144
|
|
|
145
|
+
// Classify the data field of a file part; a declared sourceType wins over sniffing, except a data: payload declared as "url"
|
|
146
|
+
const kind = getFileDataKind("https://example.com/report.pdf"); // "url"
|
|
147
|
+
const ref = getFileDataKind("file-abc123", "id"); // "id"
|
|
148
|
+
|
|
144
149
|
// Calculate size from base64 string
|
|
145
150
|
const bytes = getBase64Size("SGVsbG8gV29ybGQh"); // 12
|
|
146
151
|
|
|
@@ -22,7 +22,7 @@ import { ImageSample } from "@/components/docs/samples/image";
|
|
|
22
22
|
|
|
23
23
|
### Use in your application
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
The shipped `Thread` component renders `image` parts through `Image` by default, in both assistant and user messages. In a custom thread, pass `Image` to `MessagePrimitive.Parts`:
|
|
26
26
|
|
|
27
27
|
```tsx title="/components/assistant-ui/thread.tsx" {1,8}
|
|
28
28
|
import { Image } from "@/components/assistant-ui/image";
|
|
@@ -25,7 +25,7 @@ platforms: ["react"]
|
|
|
25
25
|
```tsx title="app/providers.tsx"
|
|
26
26
|
"use client";
|
|
27
27
|
|
|
28
|
-
import { AuiProvider, useAui } from "@assistant-ui/react";
|
|
28
|
+
import { AuiConfig, AuiProvider, useAui } from "@assistant-ui/react";
|
|
29
29
|
import { McpManagerResource, defineConnector } from "@assistant-ui/react-mcp";
|
|
30
30
|
|
|
31
31
|
const connectors = [
|
|
@@ -38,8 +38,13 @@ const connectors = [
|
|
|
38
38
|
];
|
|
39
39
|
|
|
40
40
|
export function Providers({ children }: { children: React.ReactNode }) {
|
|
41
|
-
const aui = useAui(
|
|
42
|
-
|
|
41
|
+
const aui = useAui();
|
|
42
|
+
const config = AuiConfig({ mcp: McpManagerResource({ connectors }) });
|
|
43
|
+
return (
|
|
44
|
+
<AuiProvider extends={aui} config={config}>
|
|
45
|
+
{children}
|
|
46
|
+
</AuiProvider>
|
|
47
|
+
);
|
|
43
48
|
}
|
|
44
49
|
```
|
|
45
50
|
|
|
@@ -38,11 +38,11 @@ const ComposerAction: FC = () => {
|
|
|
38
38
|
<div className="flex items-center gap-1">
|
|
39
39
|
<ModelSelector
|
|
40
40
|
models={[
|
|
41
|
-
{ id: "gpt-5.
|
|
42
|
-
{ id: "gpt-5.
|
|
43
|
-
{ id: "gpt-5.
|
|
41
|
+
{ id: "gpt-5.6-luna", name: "GPT-5.6 Luna", description: "Fast and efficient" },
|
|
42
|
+
{ id: "gpt-5.6-terra", name: "GPT-5.6 Terra", description: "Balanced performance" },
|
|
43
|
+
{ id: "gpt-5.6-sol", name: "GPT-5.6 Sol", description: "Most capable", efforts: true },
|
|
44
44
|
]}
|
|
45
|
-
defaultValue="gpt-5.
|
|
45
|
+
defaultValue="gpt-5.6-luna"
|
|
46
46
|
defaultEffort="medium"
|
|
47
47
|
size="sm"
|
|
48
48
|
/>
|
|
@@ -63,7 +63,7 @@ export async function POST(req: Request) {
|
|
|
63
63
|
const { messages, config } = await req.json();
|
|
64
64
|
|
|
65
65
|
const result = streamText({
|
|
66
|
-
model: openai(config?.modelName ?? "gpt-5.
|
|
66
|
+
model: openai(config?.modelName ?? "gpt-5.6-luna"),
|
|
67
67
|
providerOptions: {
|
|
68
68
|
openai:
|
|
69
69
|
config?.reasoningEffort !== undefined
|
|
@@ -88,8 +88,8 @@ A model that declares `efforts` shows a "Thinking" row at the bottom of the popo
|
|
|
88
88
|
|
|
89
89
|
```tsx
|
|
90
90
|
{
|
|
91
|
-
id: "gpt-5.
|
|
92
|
-
name: "GPT-5.
|
|
91
|
+
id: "gpt-5.6-sol",
|
|
92
|
+
name: "GPT-5.6 Sol",
|
|
93
93
|
efforts: [
|
|
94
94
|
{ id: "minimal", name: "Minimal" },
|
|
95
95
|
{ id: "high", name: "High" },
|
|
@@ -156,7 +156,7 @@ import { ClaudeLogo, GeminiLogo, OpenAILogo } from "@/components/assistant-ui/lo
|
|
|
156
156
|
|
|
157
157
|
<ModelSelector
|
|
158
158
|
models={[
|
|
159
|
-
{ id: "gpt-5.
|
|
159
|
+
{ id: "gpt-5.6-sol", name: "GPT-5.6 Sol", icon: <OpenAILogo /> },
|
|
160
160
|
{ id: "claude-opus-4.5", name: "Claude Opus 4.5", icon: <ClaudeLogo /> },
|
|
161
161
|
{ id: "gemini-3-pro", name: "Gemini 3 Pro", icon: <GeminiLogo /> },
|
|
162
162
|
]}
|
|
@@ -575,7 +575,7 @@ Use `MessagePrimitive.Unstable_PartsGrouped` only when you need to collect non-a
|
|
|
575
575
|
name: "Unstable_Audio",
|
|
576
576
|
type: "Unstable_AudioMessagePartComponent",
|
|
577
577
|
description:
|
|
578
|
-
"Component for rendering audio content (
|
|
578
|
+
"Component for rendering audio content (deprecated, render audio/* from File)",
|
|
579
579
|
},
|
|
580
580
|
{
|
|
581
581
|
name: "tools",
|
|
@@ -111,17 +111,36 @@ export default function Chat() {
|
|
|
111
111
|
Display suggested prompts using the Suggestions API. See the [Suggestions guide](/docs/guides/suggestions) for detailed configuration.
|
|
112
112
|
|
|
113
113
|
```tsx
|
|
114
|
-
import {
|
|
114
|
+
import type { ReactNode } from "react";
|
|
115
|
+
import {
|
|
116
|
+
AssistantRuntimeProvider,
|
|
117
|
+
AuiConfig,
|
|
118
|
+
SuggestionPrimitive,
|
|
119
|
+
Suggestions,
|
|
120
|
+
ThreadPrimitive,
|
|
121
|
+
} from "@assistant-ui/react";
|
|
122
|
+
import { useChatRuntime } from "@assistant-ui/react-ai-sdk";
|
|
115
123
|
|
|
116
124
|
// Configure suggestions in your runtime provider
|
|
117
|
-
const
|
|
125
|
+
const config = AuiConfig({
|
|
118
126
|
suggestions: Suggestions(["What's the weather?", "Tell me a joke"]),
|
|
119
127
|
});
|
|
120
128
|
|
|
129
|
+
const App = ({ children }: { children: ReactNode }) => {
|
|
130
|
+
const runtime = useChatRuntime();
|
|
131
|
+
return (
|
|
132
|
+
<AssistantRuntimeProvider runtime={runtime} config={config}>
|
|
133
|
+
{children}
|
|
134
|
+
</AssistantRuntimeProvider>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
121
138
|
// Display suggestions in your thread component
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
139
|
+
const ThreadSuggestions = () => (
|
|
140
|
+
<ThreadPrimitive.Suggestions>
|
|
141
|
+
{() => <SuggestionItem />}
|
|
142
|
+
</ThreadPrimitive.Suggestions>
|
|
143
|
+
);
|
|
125
144
|
|
|
126
145
|
// Custom suggestion item
|
|
127
146
|
const SuggestionItem = () => (
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
SpanResource,
|
|
43
43
|
type SpanData,
|
|
44
44
|
} from "@assistant-ui/react-o11y";
|
|
45
|
-
import {
|
|
45
|
+
import { AuiConfig, AuiProvider } from "@assistant-ui/store";
|
|
46
46
|
|
|
47
47
|
function SpanRow() {
|
|
48
48
|
return (
|
|
@@ -59,10 +59,9 @@ function SpanRow() {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
export function TraceView({ spans }: { spans: SpanData[] }) {
|
|
62
|
-
const
|
|
63
|
-
|
|
62
|
+
const config = AuiConfig({ span: SpanResource({ spans }) });
|
|
64
63
|
return (
|
|
65
|
-
<AuiProvider
|
|
64
|
+
<AuiProvider extends={null} config={config}>
|
|
66
65
|
<SpanPrimitive.Children components={{ Span: SpanRow }} />
|
|
67
66
|
</AuiProvider>
|
|
68
67
|
);
|
|
@@ -106,10 +105,9 @@ import {
|
|
|
106
105
|
SpanByIndexProvider,
|
|
107
106
|
} from "@assistant-ui/react-o11y";
|
|
108
107
|
|
|
109
|
-
// Top-level: mount SpanResource via
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
<AuiProvider value={aui}>
|
|
108
|
+
// Top-level: mount SpanResource via AuiProvider
|
|
109
|
+
const config = AuiConfig({ span: SpanResource({ spans }) });
|
|
110
|
+
<AuiProvider extends={null} config={config}>
|
|
113
111
|
{/* Render visible spans (flat-list output respecting collapsed state) */}
|
|
114
112
|
<SpanPrimitive.Children components={{ Span: SpanRow }} />
|
|
115
113
|
</AuiProvider>;
|
|
@@ -140,7 +138,7 @@ Resource that ingests raw span data and exposes a tree-aware reactive state to p
|
|
|
140
138
|
SpanResource({ spans }: { spans: SpanData[] }): ClientOutput<"span">;
|
|
141
139
|
```
|
|
142
140
|
|
|
143
|
-
Mount through `
|
|
141
|
+
Mount through `config={config}`, where `const config = AuiConfig({ span: SpanResource({ spans }) })`.
|
|
144
142
|
|
|
145
143
|
The resource computes:
|
|
146
144
|
|
package/dist/constants.js
CHANGED
|
@@ -10,8 +10,8 @@ const DOCS_PATH = join(DOCS_BASE, "raw/docs");
|
|
|
10
10
|
const CODE_EXAMPLES_PATH = join(DOCS_BASE, "organized/code-examples");
|
|
11
11
|
const MDX_EXTENSION = ".mdx";
|
|
12
12
|
const MD_EXTENSION = ".md";
|
|
13
|
-
const MAX_FILE_SIZE =
|
|
14
|
-
const MAX_DIRECTORY_CONTENT_SIZE =
|
|
13
|
+
const MAX_FILE_SIZE = 10485760;
|
|
14
|
+
const MAX_DIRECTORY_CONTENT_SIZE = 1048576;
|
|
15
15
|
const IS_PREPARE_MODE = process.argv[1]?.includes("prepare-docs/prepare");
|
|
16
16
|
//#endregion
|
|
17
17
|
export { CODE_EXAMPLES_PATH, DOCS_PATH, EXAMPLES_PATH, IS_PREPARE_MODE, MAX_DIRECTORY_CONTENT_SIZE, MAX_FILE_SIZE, MDX_EXTENSION, MD_EXTENSION, PACKAGE_DIR, ROOT_DIR };
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\nimport { dirname, join } from \"node:path\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport const ROOT_DIR = join(__dirname, \"../../../\");\nexport const PACKAGE_DIR = join(__dirname, \"../\");\n\nexport const EXAMPLES_PATH = join(ROOT_DIR, \"examples\");\n\nconst DOCS_BASE = join(PACKAGE_DIR, \".docs\");\nexport const DOCS_PATH = join(DOCS_BASE, \"raw/docs\");\nexport const CODE_EXAMPLES_PATH = join(DOCS_BASE, \"organized/code-examples\");\n\nexport const MDX_EXTENSION = \".mdx\";\nexport const MD_EXTENSION = \".md\";\n\nexport const MAX_FILE_SIZE = 10 * 1024 * 1024;\n\nexport const MAX_DIRECTORY_CONTENT_SIZE = 1024 * 1024;\n\nexport const IS_PREPARE_MODE = process.argv[1]?.includes(\n \"prepare-docs/prepare\",\n);\n"],"mappings":";;;AAGA,MAAM,YAAY,QAAQ,cAAc,
|
|
1
|
+
{"version":3,"file":"constants.js","names":[],"sources":["../src/constants.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\nimport { dirname, join } from \"node:path\";\n\nconst __dirname = dirname(fileURLToPath(import.meta.url));\n\nexport const ROOT_DIR = join(__dirname, \"../../../\");\nexport const PACKAGE_DIR = join(__dirname, \"../\");\n\nexport const EXAMPLES_PATH = join(ROOT_DIR, \"examples\");\n\nconst DOCS_BASE = join(PACKAGE_DIR, \".docs\");\nexport const DOCS_PATH = join(DOCS_BASE, \"raw/docs\");\nexport const CODE_EXAMPLES_PATH = join(DOCS_BASE, \"organized/code-examples\");\n\nexport const MDX_EXTENSION = \".mdx\";\nexport const MD_EXTENSION = \".md\";\n\nexport const MAX_FILE_SIZE = 10 * 1024 * 1024;\n\nexport const MAX_DIRECTORY_CONTENT_SIZE = 1024 * 1024;\n\nexport const IS_PREPARE_MODE = process.argv[1]?.includes(\n \"prepare-docs/prepare\",\n);\n"],"mappings":";;;AAGA,MAAM,YAAY,QAAQ,cAAc,YAAY,GAAG,CAAC;AAExD,MAAa,WAAW,KAAK,WAAW,WAAW;AACnD,MAAa,cAAc,KAAK,WAAW,KAAK;AAEhD,MAAa,gBAAgB,KAAK,UAAU,UAAU;AAEtD,MAAM,YAAY,KAAK,aAAa,OAAO;AAC3C,MAAa,YAAY,KAAK,WAAW,UAAU;AACnD,MAAa,qBAAqB,KAAK,WAAW,yBAAyB;AAE3E,MAAa,gBAAgB;AAC7B,MAAa,eAAe;AAE5B,MAAa,gBAAgB;AAE7B,MAAa,6BAA6B;AAE1C,MAAa,kBAAkB,QAAQ,KAAK,EAAE,EAAE,SAC9C,sBACF"}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { McpServer } from \"@modelcontextprotocol/server\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/server/stdio\";\nimport { docsTools } from \"./tools/docs.js\";\nimport { examplesTools } from \"./tools/examples.js\";\nimport { searchTools } from \"./tools/search.js\";\nimport {\n xuluxTemplatesListTool,\n xuluxTemplateDetailsTool,\n xuluxTemplatePreviewTool,\n} from \"./tools/xulux-templates.js\";\nimport { xuluxPlaygroundPrompt } from \"./prompts/xulux-playground.js\";\nimport { registerResources } from \"./tools/resources.js\";\nimport { logger } from \"./utils/logger.js\";\nimport { PACKAGE_DIR } from \"./constants.js\";\n\nimport { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nconst packageJson = JSON.parse(\n readFileSync(join(PACKAGE_DIR, \"package.json\"), \"utf-8\"),\n);\n\nexport const server = new McpServer({\n name: \"assistant-ui-docs\",\n version: packageJson.version,\n});\n\nserver.registerTool(\n docsTools.name,\n {\n title: \"assistant-ui Documentation\",\n description: docsTools.description,\n inputSchema: docsTools.parameters,\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n docsTools.execute,\n);\nserver.registerTool(\n examplesTools.name,\n {\n title: \"assistant-ui Examples\",\n description: examplesTools.description,\n inputSchema: examplesTools.parameters,\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n examplesTools.execute,\n);\nserver.registerTool(\n searchTools.name,\n {\n title: \"Search assistant-ui Documentation\",\n description: searchTools.description,\n inputSchema: searchTools.parameters,\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n searchTools.execute,\n);\n\nserver.registerTool(\n xuluxTemplatesListTool.name,\n {\n title: \"assistant-ui Templates\",\n description: xuluxTemplatesListTool.description,\n inputSchema: xuluxTemplatesListTool.parameters,\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n xuluxTemplatesListTool.execute,\n);\nserver.registerTool(\n xuluxTemplateDetailsTool.name,\n {\n title: \"assistant-ui Template Details\",\n description: xuluxTemplateDetailsTool.description,\n inputSchema: xuluxTemplateDetailsTool.parameters,\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n xuluxTemplateDetailsTool.execute,\n);\nserver.registerTool(\n xuluxTemplatePreviewTool.name,\n {\n title: \"assistant-ui Template Preview URLs\",\n description: xuluxTemplatePreviewTool.description,\n inputSchema: xuluxTemplatePreviewTool.parameters,\n annotations: { readOnlyHint: false, openWorldHint: true },\n },\n xuluxTemplatePreviewTool.execute,\n);\n\nserver.registerPrompt(\n xuluxPlaygroundPrompt.name,\n {\n title: \"assistant-ui Template Workflow\",\n description: xuluxPlaygroundPrompt.description,\n },\n () => ({\n messages: [\n {\n role: \"user\" as const,\n content: { type: \"text\" as const, text: xuluxPlaygroundPrompt.text },\n },\n ],\n }),\n);\n\nregisterResources(server);\n\nexport async function runServer() {\n try {\n logger.info(\n `Starting assistant-ui MCP docs server v${packageJson.version}`,\n );\n const transport = new StdioServerTransport();\n await server.connect(transport);\n } catch (error) {\n logger.error(\"Failed to start MCP server\", error);\n process.exit(1);\n }\n}\n\nif (import.meta.url === `file://${process.argv[1]}`) {\n void runServer().catch((error) => {\n console.error(\"Failed to start server:\", error);\n process.exit(1);\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAM,cAAc,KAAK,MACvB,aAAa,KAAK,aAAa,cAAc,GAAG,OAAO,CACzD;AAEA,MAAa,SAAS,IAAI,UAAU;CAClC,MAAM;CACN,SAAS,YAAY;AACvB,CAAC;AAED,OAAO,aACL,UAAU,MACV;CACE,OAAO;CACP,aAAa,UAAU;CACvB,aAAa,UAAU;CACvB,aAAa;EAAE,cAAc;EAAM,eAAe;CAAM;AAC1D,GACA,UAAU,OACZ;AACA,OAAO,aACL,cAAc,MACd;CACE,OAAO;CACP,aAAa,cAAc;CAC3B,aAAa,cAAc;CAC3B,aAAa;EAAE,cAAc;EAAM,eAAe;CAAM;AAC1D,GACA,cAAc,OAChB;AACA,OAAO,aACL,YAAY,MACZ;CACE,OAAO;CACP,aAAa,YAAY;CACzB,aAAa,YAAY;CACzB,aAAa;EAAE,cAAc;EAAM,eAAe;CAAM;AAC1D,GACA,YAAY,OACd;AAEA,OAAO,aACL,uBAAuB,MACvB;CACE,OAAO;CACP,aAAa,uBAAuB;CACpC,aAAa,uBAAuB;CACpC,aAAa;EAAE,cAAc;EAAM,eAAe;CAAK;AACzD,GACA,uBAAuB,OACzB;AACA,OAAO,aACL,yBAAyB,MACzB;CACE,OAAO;CACP,aAAa,yBAAyB;CACtC,aAAa,yBAAyB;CACtC,aAAa;EAAE,cAAc;EAAM,eAAe;CAAK;AACzD,GACA,yBAAyB,OAC3B;AACA,OAAO,aACL,yBAAyB,MACzB;CACE,OAAO;CACP,aAAa,yBAAyB;CACtC,aAAa,yBAAyB;CACtC,aAAa;EAAE,cAAc;EAAO,eAAe;CAAK;AAC1D,GACA,yBAAyB,OAC3B;AAEA,OAAO,eACL,sBAAsB,MACtB;CACE,OAAO;CACP,aAAa,sBAAsB;AACrC,UACO,EACL,UAAU,CACR;CACE,MAAM;CACN,SAAS;EAAE,MAAM;EAAiB,MAAM,sBAAsB;CAAK;AACrE,CACF,EACF,EACF;AAEA,kBAAkB,MAAM;AAExB,eAAsB,YAAY;CAChC,IAAI;EACF,OAAO,KACL,0CAA0C,YAAY,SACxD;EACA,MAAM,YAAY,IAAI,qBAAqB;EAC3C,MAAM,OAAO,QAAQ,SAAS;CAChC,SAAS,OAAO;EACd,OAAO,MAAM,8BAA8B,KAAK;EAChD,QAAQ,KAAK,CAAC;CAChB;AACF;AAEA,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { McpServer } from \"@modelcontextprotocol/server\";\nimport { StdioServerTransport } from \"@modelcontextprotocol/server/stdio\";\nimport { docsTools } from \"./tools/docs.js\";\nimport { examplesTools } from \"./tools/examples.js\";\nimport { searchTools } from \"./tools/search.js\";\nimport {\n xuluxTemplatesListTool,\n xuluxTemplateDetailsTool,\n xuluxTemplatePreviewTool,\n} from \"./tools/xulux-templates.js\";\nimport { xuluxPlaygroundPrompt } from \"./prompts/xulux-playground.js\";\nimport { registerResources } from \"./tools/resources.js\";\nimport { logger } from \"./utils/logger.js\";\nimport { PACKAGE_DIR } from \"./constants.js\";\n\nimport { readFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\nconst packageJson = JSON.parse(\n readFileSync(join(PACKAGE_DIR, \"package.json\"), \"utf-8\"),\n);\n\nexport const server = new McpServer({\n name: \"assistant-ui-docs\",\n version: packageJson.version,\n});\n\nserver.registerTool(\n docsTools.name,\n {\n title: \"assistant-ui Documentation\",\n description: docsTools.description,\n inputSchema: docsTools.parameters,\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n docsTools.execute,\n);\nserver.registerTool(\n examplesTools.name,\n {\n title: \"assistant-ui Examples\",\n description: examplesTools.description,\n inputSchema: examplesTools.parameters,\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n examplesTools.execute,\n);\nserver.registerTool(\n searchTools.name,\n {\n title: \"Search assistant-ui Documentation\",\n description: searchTools.description,\n inputSchema: searchTools.parameters,\n annotations: { readOnlyHint: true, openWorldHint: false },\n },\n searchTools.execute,\n);\n\nserver.registerTool(\n xuluxTemplatesListTool.name,\n {\n title: \"assistant-ui Templates\",\n description: xuluxTemplatesListTool.description,\n inputSchema: xuluxTemplatesListTool.parameters,\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n xuluxTemplatesListTool.execute,\n);\nserver.registerTool(\n xuluxTemplateDetailsTool.name,\n {\n title: \"assistant-ui Template Details\",\n description: xuluxTemplateDetailsTool.description,\n inputSchema: xuluxTemplateDetailsTool.parameters,\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n xuluxTemplateDetailsTool.execute,\n);\nserver.registerTool(\n xuluxTemplatePreviewTool.name,\n {\n title: \"assistant-ui Template Preview URLs\",\n description: xuluxTemplatePreviewTool.description,\n inputSchema: xuluxTemplatePreviewTool.parameters,\n annotations: { readOnlyHint: false, openWorldHint: true },\n },\n xuluxTemplatePreviewTool.execute,\n);\n\nserver.registerPrompt(\n xuluxPlaygroundPrompt.name,\n {\n title: \"assistant-ui Template Workflow\",\n description: xuluxPlaygroundPrompt.description,\n },\n () => ({\n messages: [\n {\n role: \"user\" as const,\n content: { type: \"text\" as const, text: xuluxPlaygroundPrompt.text },\n },\n ],\n }),\n);\n\nregisterResources(server);\n\nexport async function runServer() {\n try {\n logger.info(\n `Starting assistant-ui MCP docs server v${packageJson.version}`,\n );\n const transport = new StdioServerTransport();\n await server.connect(transport);\n } catch (error) {\n logger.error(\"Failed to start MCP server\", error);\n process.exit(1);\n }\n}\n\nif (import.meta.url === `file://${process.argv[1]}`) {\n void runServer().catch((error) => {\n console.error(\"Failed to start server:\", error);\n process.exit(1);\n });\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,MAAM,cAAc,KAAK,MACvB,aAAa,KAAK,aAAa,cAAc,GAAG,OAAO,CACzD;AAEA,MAAa,SAAS,IAAI,UAAU;CAClC,MAAM;CACN,SAAS,YAAY;AACvB,CAAC;AAED,OAAO,aACL,UAAU,MACV;CACE,OAAO;CACP,aAAa,UAAU;CACvB,aAAa,UAAU;CACvB,aAAa;EAAE,cAAc;EAAM,eAAe;CAAM;AAC1D,GACA,UAAU,OACZ;AACA,OAAO,aACL,cAAc,MACd;CACE,OAAO;CACP,aAAa,cAAc;CAC3B,aAAa,cAAc;CAC3B,aAAa;EAAE,cAAc;EAAM,eAAe;CAAM;AAC1D,GACA,cAAc,OAChB;AACA,OAAO,aACL,YAAY,MACZ;CACE,OAAO;CACP,aAAa,YAAY;CACzB,aAAa,YAAY;CACzB,aAAa;EAAE,cAAc;EAAM,eAAe;CAAM;AAC1D,GACA,YAAY,OACd;AAEA,OAAO,aACL,uBAAuB,MACvB;CACE,OAAO;CACP,aAAa,uBAAuB;CACpC,aAAa,uBAAuB;CACpC,aAAa;EAAE,cAAc;EAAM,eAAe;CAAK;AACzD,GACA,uBAAuB,OACzB;AACA,OAAO,aACL,yBAAyB,MACzB;CACE,OAAO;CACP,aAAa,yBAAyB;CACtC,aAAa,yBAAyB;CACtC,aAAa;EAAE,cAAc;EAAM,eAAe;CAAK;AACzD,GACA,yBAAyB,OAC3B;AACA,OAAO,aACL,yBAAyB,MACzB;CACE,OAAO;CACP,aAAa,yBAAyB;CACtC,aAAa,yBAAyB;CACtC,aAAa;EAAE,cAAc;EAAO,eAAe;CAAK;AAC1D,GACA,yBAAyB,OAC3B;AAEA,OAAO,eACL,sBAAsB,MACtB;CACE,OAAO;CACP,aAAa,sBAAsB;AACrC,UACO,EACL,UAAU,CACR;CACE,MAAM;CACN,SAAS;EAAE,MAAM;EAAiB,MAAM,sBAAsB;CAAK;AACrE,CACF,EACF,EACF;AAEA,kBAAkB,MAAM;AAExB,eAAsB,YAAY;CAChC,IAAI;EACF,OAAO,KACL,0CAA0C,YAAY,SACxD;EACA,MAAM,YAAY,IAAI,qBAAqB;EAC3C,MAAM,OAAO,QAAQ,SAAS;CAChC,SAAS,OAAO;EACd,OAAO,MAAM,8BAA8B,KAAK;EAChD,QAAQ,KAAK,CAAC;CAChB;AACF;AAEA,IAAI,YAAY,QAAQ,UAAU,QAAQ,KAAK,MAC7C,UAAe,CAAC,CAAC,OAAO,UAAU;CAChC,QAAQ,MAAM,2BAA2B,KAAK;CAC9C,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepare.js","names":[],"sources":["../../src/prepare-docs/prepare.ts"],"sourcesContent":["import { logger } from \"../utils/logger.js\";\nimport { copyRaw } from \"./copy-raw.js\";\nimport { prepareCodeExamples } from \"./code-examples.js\";\n\nasync function prepare(): Promise<void> {\n logger.info(\"Starting documentation preparation...\");\n\n try {\n await copyRaw();\n await prepareCodeExamples();\n\n logger.info(\"Documentation preparation complete\");\n } catch (error) {\n logger.error(\"Documentation preparation failed\", error);\n throw error;\n }\n}\n\nif (import.meta.url === `file://${process.argv[1]}`) {\n prepare().catch((error) => {\n logger.error(\"Preparation failed\", error);\n process.exit(1);\n });\n}\n"],"mappings":";;;;AAIA,eAAe,UAAyB;CACtC,OAAO,KAAK,uCAAuC;CAEnD,IAAI;EACF,MAAM,QAAQ;EACd,MAAM,oBAAoB;EAE1B,OAAO,KAAK,oCAAoC;CAClD,SAAS,OAAO;EACd,OAAO,MAAM,oCAAoC,KAAK;EACtD,MAAM;CACR;AACF;AAEA,IAAI,
|
|
1
|
+
{"version":3,"file":"prepare.js","names":[],"sources":["../../src/prepare-docs/prepare.ts"],"sourcesContent":["import { logger } from \"../utils/logger.js\";\nimport { copyRaw } from \"./copy-raw.js\";\nimport { prepareCodeExamples } from \"./code-examples.js\";\n\nasync function prepare(): Promise<void> {\n logger.info(\"Starting documentation preparation...\");\n\n try {\n await copyRaw();\n await prepareCodeExamples();\n\n logger.info(\"Documentation preparation complete\");\n } catch (error) {\n logger.error(\"Documentation preparation failed\", error);\n throw error;\n }\n}\n\nif (import.meta.url === `file://${process.argv[1]}`) {\n prepare().catch((error) => {\n logger.error(\"Preparation failed\", error);\n process.exit(1);\n });\n}\n"],"mappings":";;;;AAIA,eAAe,UAAyB;CACtC,OAAO,KAAK,uCAAuC;CAEnD,IAAI;EACF,MAAM,QAAQ;EACd,MAAM,oBAAoB;EAE1B,OAAO,KAAK,oCAAoC;CAClD,SAAS,OAAO;EACd,OAAO,MAAM,oCAAoC,KAAK;EACtD,MAAM;CACR;AACF;AAEA,IAAI,YAAY,QAAQ,UAAU,QAAQ,KAAK,MAC7C,QAAQ,CAAC,CAAC,OAAO,UAAU;CACzB,OAAO,MAAM,sBAAsB,KAAK;CACxC,QAAQ,KAAK,CAAC;AAChB,CAAC"}
|
package/dist/tools/docs.js
CHANGED
|
@@ -22,7 +22,8 @@ async function readDocumentation(docPath) {
|
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
try {
|
|
25
|
-
const
|
|
25
|
+
const sanitized = sanitizePath(docPath);
|
|
26
|
+
const fullPath = join(DOCS_PATH, sanitized);
|
|
26
27
|
try {
|
|
27
28
|
if ((await lstat(fullPath)).isSymbolicLink()) {
|
|
28
29
|
logger.warn(`Symlink detected at path: ${fullPath}`);
|
|
@@ -121,10 +122,11 @@ async function readDocumentation(docPath) {
|
|
|
121
122
|
};
|
|
122
123
|
}
|
|
123
124
|
}
|
|
125
|
+
const availablePaths = await getAvailablePaths();
|
|
124
126
|
return {
|
|
125
127
|
path: docPath,
|
|
126
128
|
found: false,
|
|
127
|
-
suggestions: findNearestPaths(docPath,
|
|
129
|
+
suggestions: findNearestPaths(docPath, availablePaths)
|
|
128
130
|
};
|
|
129
131
|
} catch (error) {
|
|
130
132
|
if (error instanceof Error && error.message.includes("Invalid path")) return {
|
package/dist/tools/docs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.js","names":[],"sources":["../../src/tools/docs.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { stat, lstat } from \"node:fs/promises\";\nimport { join, extname } from \"node:path\";\nimport {\n DOCS_PATH,\n MDX_EXTENSION,\n MAX_FILE_SIZE,\n MAX_DIRECTORY_CONTENT_SIZE,\n} from \"../constants.js\";\nimport { logger } from \"../utils/logger.js\";\nimport {\n listDirContents,\n getAvailablePaths,\n findNearestPaths,\n pathExists,\n} from \"../utils/paths.js\";\nimport { readMDXFile, formatMDXContent } from \"../utils/mdx.js\";\nimport { formatMCPResponse } from \"../utils/mcp-format.js\";\nimport { sanitizePath } from \"../utils/security.js\";\n\nconst docsInputSchema = z.object({\n paths: z\n .array(z.string())\n .min(1)\n .describe(\n 'Documentation paths to retrieve (e.g., [\"getting-started\", \"api-reference/primitives/thread\"])',\n ),\n});\n\ninterface DocResult {\n path: string;\n found: boolean;\n type?: \"file\" | \"directory\";\n content?: string;\n files?: string[];\n directories?: string[];\n summaries?: Array<{ name: string; title?: string; excerpt?: string }>;\n title?: string;\n excerpt?: string;\n suggestions?: string[];\n hint?: string;\n error?: string;\n}\n\nasync function readDocumentation(docPath: string): Promise<DocResult> {\n logger.debug(`Reading documentation for path: ${docPath}`);\n\n if (docPath === \"/\" || docPath === \"\") {\n const { directories, files } = await listDirContents(DOCS_PATH);\n return {\n path: \"/\",\n found: true,\n type: \"directory\",\n directories,\n files: files.map((f) => f.replace(MDX_EXTENSION, \"\")),\n };\n }\n\n try {\n const sanitized = sanitizePath(docPath);\n const fullPath = join(DOCS_PATH, sanitized);\n\n try {\n const lstats = await lstat(fullPath);\n if (lstats.isSymbolicLink()) {\n logger.warn(`Symlink detected at path: ${fullPath}`);\n return {\n path: docPath,\n found: false,\n error: \"Symlinks are not allowed for security reasons\",\n };\n }\n } catch {}\n\n if (await pathExists(fullPath)) {\n const stats = await stat(fullPath);\n\n if (stats.isFile() && stats.size > MAX_FILE_SIZE) {\n logger.warn(`File too large: ${fullPath} (${stats.size} bytes)`);\n return {\n path: docPath,\n found: false,\n error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`,\n };\n }\n\n if (stats.isDirectory()) {\n const { directories, files } = await listDirContents(fullPath);\n\n const contents: Record<string, string> = {};\n const summaries: Array<{\n name: string;\n title?: string;\n excerpt?: string;\n }> = [];\n let aggregateSize = 0;\n let truncated = false;\n for (const file of files) {\n let fileSize: number;\n try {\n fileSize = (await stat(join(fullPath, file))).size;\n } catch (error) {\n logger.warn(\n `Failed to stat MDX file: ${join(fullPath, file)}`,\n error,\n );\n continue;\n }\n aggregateSize += fileSize;\n if (aggregateSize > MAX_DIRECTORY_CONTENT_SIZE) {\n truncated = true;\n break;\n }\n const mdxContent = await readMDXFile(join(fullPath, file));\n if (mdxContent) {\n const name = file.replace(MDX_EXTENSION, \"\");\n contents[name] = formatMDXContent(mdxContent);\n const title = mdxContent.frontmatter[\"title\"];\n summaries.push({\n name,\n ...(typeof title === \"string\" && { title }),\n ...(mdxContent.excerpt !== undefined && {\n excerpt: mdxContent.excerpt,\n }),\n });\n }\n }\n\n const content =\n !truncated && Object.keys(contents).length > 0\n ? JSON.stringify(contents, null, 2)\n : undefined;\n return {\n path: docPath,\n found: true,\n type: \"directory\",\n directories,\n files: files.map((f) => f.replace(MDX_EXTENSION, \"\")),\n ...(summaries.length > 0 && { summaries }),\n ...(content !== undefined && { content }),\n ...(truncated && {\n hint: `Directory content exceeds ${MAX_DIRECTORY_CONTENT_SIZE} bytes and was omitted; summaries cover only the files read before the limit. Request individual files by path to retrieve their content.`,\n }),\n };\n }\n }\n\n const mdxPath =\n extname(fullPath) === MDX_EXTENSION\n ? fullPath\n : `${fullPath}${MDX_EXTENSION}`;\n\n try {\n const mdxLstats = await lstat(mdxPath);\n if (mdxLstats.isSymbolicLink()) {\n logger.warn(`Symlink detected at MDX path: ${mdxPath}`);\n return {\n path: docPath,\n found: false,\n error: \"Symlinks are not allowed for security reasons\",\n };\n }\n\n if (mdxLstats.size > MAX_FILE_SIZE) {\n logger.warn(`MDX file too large: ${mdxPath} (${mdxLstats.size} bytes)`);\n return {\n path: docPath,\n found: false,\n error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`,\n };\n }\n } catch {}\n\n if (await pathExists(mdxPath)) {\n const mdxContent = await readMDXFile(mdxPath);\n\n if (mdxContent) {\n const title = mdxContent.frontmatter[\"title\"];\n return {\n path: docPath,\n found: true,\n type: \"file\",\n content: formatMDXContent(mdxContent),\n ...(typeof title === \"string\" && { title }),\n ...(mdxContent.excerpt !== undefined && {\n excerpt: mdxContent.excerpt,\n }),\n };\n }\n }\n\n const availablePaths = await getAvailablePaths();\n const suggestions = findNearestPaths(docPath, availablePaths);\n\n return {\n path: docPath,\n found: false,\n suggestions,\n };\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"Invalid path\")) {\n return {\n path: docPath,\n found: false,\n error: error.message,\n };\n }\n throw error;\n }\n}\n\nexport const docsTools = {\n name: \"assistantUIDocs\",\n description:\n 'Retrieve assistant-ui documentation by path. Use \"/\" to list all sections. Supports multiple paths in a single request.',\n parameters: docsInputSchema,\n execute: async ({ paths }: z.infer<typeof docsInputSchema>) => {\n logger.info(`Retrieving documentation for paths: ${paths.join(\", \")}`);\n\n try {\n const results = await Promise.all(\n paths.map((path) => readDocumentation(path)),\n );\n\n if (results.length === 1) {\n const result = results[0]!;\n if (result.error) {\n return formatMCPResponse({\n error: result.error,\n path: result.path,\n });\n }\n if (!result.found) {\n return formatMCPResponse({\n error: `Documentation not found for path: ${result.path}`,\n suggestions: result.suggestions,\n hint: 'Use \"/\" to list all available documentation sections',\n });\n }\n return formatMCPResponse(result);\n }\n\n return formatMCPResponse({\n results,\n summary: `Retrieved ${results.filter((r) => r.found).length} of ${results.length} requested paths`,\n });\n } catch (error) {\n logger.error(\"Failed to retrieve documentation\", error);\n return formatMCPResponse({\n error: \"Failed to retrieve documentation\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"docs.js","names":[],"sources":["../../src/tools/docs.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { stat, lstat } from \"node:fs/promises\";\nimport { join, extname } from \"node:path\";\nimport {\n DOCS_PATH,\n MDX_EXTENSION,\n MAX_FILE_SIZE,\n MAX_DIRECTORY_CONTENT_SIZE,\n} from \"../constants.js\";\nimport { logger } from \"../utils/logger.js\";\nimport {\n listDirContents,\n getAvailablePaths,\n findNearestPaths,\n pathExists,\n} from \"../utils/paths.js\";\nimport { readMDXFile, formatMDXContent } from \"../utils/mdx.js\";\nimport { formatMCPResponse } from \"../utils/mcp-format.js\";\nimport { sanitizePath } from \"../utils/security.js\";\n\nconst docsInputSchema = z.object({\n paths: z\n .array(z.string())\n .min(1)\n .describe(\n 'Documentation paths to retrieve (e.g., [\"getting-started\", \"api-reference/primitives/thread\"])',\n ),\n});\n\ninterface DocResult {\n path: string;\n found: boolean;\n type?: \"file\" | \"directory\";\n content?: string;\n files?: string[];\n directories?: string[];\n summaries?: Array<{ name: string; title?: string; excerpt?: string }>;\n title?: string;\n excerpt?: string;\n suggestions?: string[];\n hint?: string;\n error?: string;\n}\n\nasync function readDocumentation(docPath: string): Promise<DocResult> {\n logger.debug(`Reading documentation for path: ${docPath}`);\n\n if (docPath === \"/\" || docPath === \"\") {\n const { directories, files } = await listDirContents(DOCS_PATH);\n return {\n path: \"/\",\n found: true,\n type: \"directory\",\n directories,\n files: files.map((f) => f.replace(MDX_EXTENSION, \"\")),\n };\n }\n\n try {\n const sanitized = sanitizePath(docPath);\n const fullPath = join(DOCS_PATH, sanitized);\n\n try {\n const lstats = await lstat(fullPath);\n if (lstats.isSymbolicLink()) {\n logger.warn(`Symlink detected at path: ${fullPath}`);\n return {\n path: docPath,\n found: false,\n error: \"Symlinks are not allowed for security reasons\",\n };\n }\n } catch {}\n\n if (await pathExists(fullPath)) {\n const stats = await stat(fullPath);\n\n if (stats.isFile() && stats.size > MAX_FILE_SIZE) {\n logger.warn(`File too large: ${fullPath} (${stats.size} bytes)`);\n return {\n path: docPath,\n found: false,\n error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`,\n };\n }\n\n if (stats.isDirectory()) {\n const { directories, files } = await listDirContents(fullPath);\n\n const contents: Record<string, string> = {};\n const summaries: Array<{\n name: string;\n title?: string;\n excerpt?: string;\n }> = [];\n let aggregateSize = 0;\n let truncated = false;\n for (const file of files) {\n let fileSize: number;\n try {\n fileSize = (await stat(join(fullPath, file))).size;\n } catch (error) {\n logger.warn(\n `Failed to stat MDX file: ${join(fullPath, file)}`,\n error,\n );\n continue;\n }\n aggregateSize += fileSize;\n if (aggregateSize > MAX_DIRECTORY_CONTENT_SIZE) {\n truncated = true;\n break;\n }\n const mdxContent = await readMDXFile(join(fullPath, file));\n if (mdxContent) {\n const name = file.replace(MDX_EXTENSION, \"\");\n contents[name] = formatMDXContent(mdxContent);\n const title = mdxContent.frontmatter[\"title\"];\n summaries.push({\n name,\n ...(typeof title === \"string\" && { title }),\n ...(mdxContent.excerpt !== undefined && {\n excerpt: mdxContent.excerpt,\n }),\n });\n }\n }\n\n const content =\n !truncated && Object.keys(contents).length > 0\n ? JSON.stringify(contents, null, 2)\n : undefined;\n return {\n path: docPath,\n found: true,\n type: \"directory\",\n directories,\n files: files.map((f) => f.replace(MDX_EXTENSION, \"\")),\n ...(summaries.length > 0 && { summaries }),\n ...(content !== undefined && { content }),\n ...(truncated && {\n hint: `Directory content exceeds ${MAX_DIRECTORY_CONTENT_SIZE} bytes and was omitted; summaries cover only the files read before the limit. Request individual files by path to retrieve their content.`,\n }),\n };\n }\n }\n\n const mdxPath =\n extname(fullPath) === MDX_EXTENSION\n ? fullPath\n : `${fullPath}${MDX_EXTENSION}`;\n\n try {\n const mdxLstats = await lstat(mdxPath);\n if (mdxLstats.isSymbolicLink()) {\n logger.warn(`Symlink detected at MDX path: ${mdxPath}`);\n return {\n path: docPath,\n found: false,\n error: \"Symlinks are not allowed for security reasons\",\n };\n }\n\n if (mdxLstats.size > MAX_FILE_SIZE) {\n logger.warn(`MDX file too large: ${mdxPath} (${mdxLstats.size} bytes)`);\n return {\n path: docPath,\n found: false,\n error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`,\n };\n }\n } catch {}\n\n if (await pathExists(mdxPath)) {\n const mdxContent = await readMDXFile(mdxPath);\n\n if (mdxContent) {\n const title = mdxContent.frontmatter[\"title\"];\n return {\n path: docPath,\n found: true,\n type: \"file\",\n content: formatMDXContent(mdxContent),\n ...(typeof title === \"string\" && { title }),\n ...(mdxContent.excerpt !== undefined && {\n excerpt: mdxContent.excerpt,\n }),\n };\n }\n }\n\n const availablePaths = await getAvailablePaths();\n const suggestions = findNearestPaths(docPath, availablePaths);\n\n return {\n path: docPath,\n found: false,\n suggestions,\n };\n } catch (error) {\n if (error instanceof Error && error.message.includes(\"Invalid path\")) {\n return {\n path: docPath,\n found: false,\n error: error.message,\n };\n }\n throw error;\n }\n}\n\nexport const docsTools = {\n name: \"assistantUIDocs\",\n description:\n 'Retrieve assistant-ui documentation by path. Use \"/\" to list all sections. Supports multiple paths in a single request.',\n parameters: docsInputSchema,\n execute: async ({ paths }: z.infer<typeof docsInputSchema>) => {\n logger.info(`Retrieving documentation for paths: ${paths.join(\", \")}`);\n\n try {\n const results = await Promise.all(\n paths.map((path) => readDocumentation(path)),\n );\n\n if (results.length === 1) {\n const result = results[0]!;\n if (result.error) {\n return formatMCPResponse({\n error: result.error,\n path: result.path,\n });\n }\n if (!result.found) {\n return formatMCPResponse({\n error: `Documentation not found for path: ${result.path}`,\n suggestions: result.suggestions,\n hint: 'Use \"/\" to list all available documentation sections',\n });\n }\n return formatMCPResponse(result);\n }\n\n return formatMCPResponse({\n results,\n summary: `Retrieved ${results.filter((r) => r.found).length} of ${results.length} requested paths`,\n });\n } catch (error) {\n logger.error(\"Failed to retrieve documentation\", error);\n return formatMCPResponse({\n error: \"Failed to retrieve documentation\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n"],"mappings":"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"}
|
package/dist/tools/examples.js
CHANGED
|
@@ -20,7 +20,8 @@ async function scanCodeExamples() {
|
|
|
20
20
|
}
|
|
21
21
|
async function readCodeExample(exampleName) {
|
|
22
22
|
try {
|
|
23
|
-
const
|
|
23
|
+
const sanitized = sanitizePath(exampleName);
|
|
24
|
+
const filePath = join(CODE_EXAMPLES_PATH, `${sanitized}.md`);
|
|
24
25
|
const stats = await lstat(filePath);
|
|
25
26
|
if (stats.isSymbolicLink()) {
|
|
26
27
|
logger.warn(`Attempted to read symlink: ${filePath}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"examples.js","names":[],"sources":["../../src/tools/examples.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { readFile, readdir, lstat } from \"node:fs/promises\";\nimport { join, extname } from \"node:path\";\nimport { CODE_EXAMPLES_PATH, MAX_FILE_SIZE } from \"../constants.js\";\nimport { cacheListing } from \"../utils/cache.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { formatMCPResponse } from \"../utils/mcp-format.js\";\nimport { sanitizePath } from \"../utils/security.js\";\n\nconst examplesInputSchema = z.object({\n example: z\n .string()\n .optional()\n .describe(\n 'Example name (e.g., \"with-ai-sdk-v7\"). Leave empty to list all examples.',\n ),\n});\n\nconst loadCodeExamples = cacheListing(scanCodeExamples);\n\nexport function listCodeExamples(): Promise<string[]> {\n return loadCodeExamples().catch((error) => {\n logger.error(\"Failed to list code examples\", error);\n return [];\n });\n}\n\nasync function scanCodeExamples(): Promise<string[]> {\n const files = await readdir(CODE_EXAMPLES_PATH);\n return files\n .filter((file) => extname(file) === \".md\")\n .map((file) => file.replace(\".md\", \"\"))\n .sort();\n}\n\nexport async function readCodeExample(\n exampleName: string,\n): Promise<string | null> {\n try {\n const sanitized = sanitizePath(exampleName);\n const filePath = join(CODE_EXAMPLES_PATH, `${sanitized}.md`);\n\n const stats = await lstat(filePath);\n if (stats.isSymbolicLink()) {\n logger.warn(`Attempted to read symlink: ${filePath}`);\n return null;\n }\n\n if (stats.size > MAX_FILE_SIZE) {\n logger.warn(`File size exceeds limit: ${filePath} (${stats.size} bytes)`);\n return null;\n }\n\n const content = await readFile(filePath, \"utf-8\");\n return content;\n } catch (error) {\n logger.error(`Failed to read example: ${exampleName}`, error);\n return null;\n }\n}\n\nexport const examplesTools = {\n name: \"assistantUIExamples\",\n description:\n \"List available examples or retrieve complete code for a specific example\",\n parameters: examplesInputSchema,\n execute: async ({ example }: z.infer<typeof examplesInputSchema>) => {\n try {\n if (!example) {\n logger.info(\"Listing all available examples\");\n const examples = await listCodeExamples();\n\n if (examples.length === 0) {\n return formatMCPResponse({\n error:\n \"No examples found. Please run documentation preparation first.\",\n hint: \"Run: pnpm prepare-docs\",\n });\n }\n\n return formatMCPResponse({\n type: \"list\",\n examples,\n total: examples.length,\n hint: \"Use example parameter to get complete code for any example\",\n });\n }\n\n logger.info(`Retrieving example: ${example}`);\n const content = await readCodeExample(example);\n\n if (!content) {\n const availableExamples = await listCodeExamples();\n return formatMCPResponse({\n error: `Example not found: ${example}`,\n availableExamples,\n hint: \"Use without example parameter to list all available examples\",\n });\n }\n\n return formatMCPResponse({\n type: \"example\",\n name: example,\n content,\n });\n } catch (error) {\n logger.error(\"Failed to retrieve examples\", error);\n return formatMCPResponse({\n error: \"Failed to retrieve examples\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n"],"mappings":";;;;;;;;;AASA,MAAM,sBAAsB,EAAE,OAAO,EACnC,SAAS,EACN,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,4EACF,EACJ,CAAC;AAED,MAAM,mBAAmB,aAAa,gBAAgB;AAEtD,SAAgB,mBAAsC;CACpD,OAAO,iBAAiB,CAAC,CAAC,OAAO,UAAU;EACzC,OAAO,MAAM,gCAAgC,KAAK;EAClD,OAAO,CAAC;CACV,CAAC;AACH;AAEA,eAAe,mBAAsC;CAEnD,QAAO,MADa,QAAQ,kBAAkB,EAAA,CAE3C,QAAQ,SAAS,QAAQ,IAAI,MAAM,KAAK,CAAC,CACzC,KAAK,SAAS,KAAK,QAAQ,OAAO,EAAE,CAAC,CAAC,CACtC,KAAK;AACV;AAEA,eAAsB,gBACpB,aACwB;CACxB,IAAI;
|
|
1
|
+
{"version":3,"file":"examples.js","names":[],"sources":["../../src/tools/examples.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { readFile, readdir, lstat } from \"node:fs/promises\";\nimport { join, extname } from \"node:path\";\nimport { CODE_EXAMPLES_PATH, MAX_FILE_SIZE } from \"../constants.js\";\nimport { cacheListing } from \"../utils/cache.js\";\nimport { logger } from \"../utils/logger.js\";\nimport { formatMCPResponse } from \"../utils/mcp-format.js\";\nimport { sanitizePath } from \"../utils/security.js\";\n\nconst examplesInputSchema = z.object({\n example: z\n .string()\n .optional()\n .describe(\n 'Example name (e.g., \"with-ai-sdk-v7\"). Leave empty to list all examples.',\n ),\n});\n\nconst loadCodeExamples = cacheListing(scanCodeExamples);\n\nexport function listCodeExamples(): Promise<string[]> {\n return loadCodeExamples().catch((error) => {\n logger.error(\"Failed to list code examples\", error);\n return [];\n });\n}\n\nasync function scanCodeExamples(): Promise<string[]> {\n const files = await readdir(CODE_EXAMPLES_PATH);\n return files\n .filter((file) => extname(file) === \".md\")\n .map((file) => file.replace(\".md\", \"\"))\n .sort();\n}\n\nexport async function readCodeExample(\n exampleName: string,\n): Promise<string | null> {\n try {\n const sanitized = sanitizePath(exampleName);\n const filePath = join(CODE_EXAMPLES_PATH, `${sanitized}.md`);\n\n const stats = await lstat(filePath);\n if (stats.isSymbolicLink()) {\n logger.warn(`Attempted to read symlink: ${filePath}`);\n return null;\n }\n\n if (stats.size > MAX_FILE_SIZE) {\n logger.warn(`File size exceeds limit: ${filePath} (${stats.size} bytes)`);\n return null;\n }\n\n const content = await readFile(filePath, \"utf-8\");\n return content;\n } catch (error) {\n logger.error(`Failed to read example: ${exampleName}`, error);\n return null;\n }\n}\n\nexport const examplesTools = {\n name: \"assistantUIExamples\",\n description:\n \"List available examples or retrieve complete code for a specific example\",\n parameters: examplesInputSchema,\n execute: async ({ example }: z.infer<typeof examplesInputSchema>) => {\n try {\n if (!example) {\n logger.info(\"Listing all available examples\");\n const examples = await listCodeExamples();\n\n if (examples.length === 0) {\n return formatMCPResponse({\n error:\n \"No examples found. Please run documentation preparation first.\",\n hint: \"Run: pnpm prepare-docs\",\n });\n }\n\n return formatMCPResponse({\n type: \"list\",\n examples,\n total: examples.length,\n hint: \"Use example parameter to get complete code for any example\",\n });\n }\n\n logger.info(`Retrieving example: ${example}`);\n const content = await readCodeExample(example);\n\n if (!content) {\n const availableExamples = await listCodeExamples();\n return formatMCPResponse({\n error: `Example not found: ${example}`,\n availableExamples,\n hint: \"Use without example parameter to list all available examples\",\n });\n }\n\n return formatMCPResponse({\n type: \"example\",\n name: example,\n content,\n });\n } catch (error) {\n logger.error(\"Failed to retrieve examples\", error);\n return formatMCPResponse({\n error: \"Failed to retrieve examples\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n"],"mappings":";;;;;;;;;AASA,MAAM,sBAAsB,EAAE,OAAO,EACnC,SAAS,EACN,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,4EACF,EACJ,CAAC;AAED,MAAM,mBAAmB,aAAa,gBAAgB;AAEtD,SAAgB,mBAAsC;CACpD,OAAO,iBAAiB,CAAC,CAAC,OAAO,UAAU;EACzC,OAAO,MAAM,gCAAgC,KAAK;EAClD,OAAO,CAAC;CACV,CAAC;AACH;AAEA,eAAe,mBAAsC;CAEnD,QAAO,MADa,QAAQ,kBAAkB,EAAA,CAE3C,QAAQ,SAAS,QAAQ,IAAI,MAAM,KAAK,CAAC,CACzC,KAAK,SAAS,KAAK,QAAQ,OAAO,EAAE,CAAC,CAAC,CACtC,KAAK;AACV;AAEA,eAAsB,gBACpB,aACwB;CACxB,IAAI;EACF,MAAM,YAAY,aAAa,WAAW;EAC1C,MAAM,WAAW,KAAK,oBAAoB,GAAG,UAAU,IAAI;EAE3D,MAAM,QAAQ,MAAM,MAAM,QAAQ;EAClC,IAAI,MAAM,eAAe,GAAG;GAC1B,OAAO,KAAK,8BAA8B,UAAU;GACpD,OAAO;EACT;EAEA,IAAI,MAAM,OAAA,UAAsB;GAC9B,OAAO,KAAK,4BAA4B,SAAS,IAAI,MAAM,KAAK,QAAQ;GACxE,OAAO;EACT;EAGA,OAAO,MADe,SAAS,UAAU,OAAO;CAElD,SAAS,OAAO;EACd,OAAO,MAAM,2BAA2B,eAAe,KAAK;EAC5D,OAAO;CACT;AACF;AAEA,MAAa,gBAAgB;CAC3B,MAAM;CACN,aACE;CACF,YAAY;CACZ,SAAS,OAAO,EAAE,cAAmD;EACnE,IAAI;GACF,IAAI,CAAC,SAAS;IACZ,OAAO,KAAK,gCAAgC;IAC5C,MAAM,WAAW,MAAM,iBAAiB;IAExC,IAAI,SAAS,WAAW,GACtB,OAAO,kBAAkB;KACvB,OACE;KACF,MAAM;IACR,CAAC;IAGH,OAAO,kBAAkB;KACvB,MAAM;KACN;KACA,OAAO,SAAS;KAChB,MAAM;IACR,CAAC;GACH;GAEA,OAAO,KAAK,uBAAuB,SAAS;GAC5C,MAAM,UAAU,MAAM,gBAAgB,OAAO;GAE7C,IAAI,CAAC,SAAS;IACZ,MAAM,oBAAoB,MAAM,iBAAiB;IACjD,OAAO,kBAAkB;KACvB,OAAO,sBAAsB;KAC7B;KACA,MAAM;IACR,CAAC;GACH;GAEA,OAAO,kBAAkB;IACvB,MAAM;IACN,MAAM;IACN;GACF,CAAC;EACH,SAAS,OAAO;GACd,OAAO,MAAM,+BAA+B,KAAK;GACjD,OAAO,kBAAkB;IACvB,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAChE,CAAC;EACH;CACF;AACF"}
|
package/dist/tools/resources.js
CHANGED
|
@@ -42,7 +42,8 @@ function registerMarkdownResource(server, config) {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
async function readDocResource(path) {
|
|
45
|
-
const
|
|
45
|
+
const sanitized = sanitizePath(path);
|
|
46
|
+
const mdx = await readMDXFileSafe(join(DOCS_PATH, `${sanitized}${MDX_EXTENSION}`));
|
|
46
47
|
return mdx ? formatMDXContent(mdx) : null;
|
|
47
48
|
}
|
|
48
49
|
function registerResources(server) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","names":[],"sources":["../../src/tools/resources.ts"],"sourcesContent":["import { type McpServer, ResourceTemplate } from \"@modelcontextprotocol/server\";\nimport { join } from \"node:path\";\nimport { DOCS_PATH, MDX_EXTENSION } from \"../constants.js\";\nimport { getAvailableDocFiles } from \"../utils/paths.js\";\nimport { readMDXFileSafe, formatMDXContent } from \"../utils/mdx.js\";\nimport { sanitizePath } from \"../utils/security.js\";\nimport { listCodeExamples, readCodeExample } from \"./examples.js\";\nimport { logger } from \"../utils/logger.js\";\n\nconst MARKDOWN_MIME_TYPE = \"text/markdown\";\nconst DOCS_SCHEME = \"aui-docs\";\nconst EXAMPLE_SCHEME = \"aui-example\";\n\nfunction templateVarToPath(value: string | string[] | undefined): string {\n if (Array.isArray(value)) return value.join(\"/\");\n return value ?? \"\";\n}\n\ninterface MarkdownResourceConfig {\n name: string;\n scheme: string;\n variable: string;\n title: string;\n description: string;\n notFoundLabel: string;\n list: () => Promise<string[]>;\n read: (key: string) => Promise<string | null>;\n}\n\nfunction registerMarkdownResource(\n server: McpServer,\n config: MarkdownResourceConfig,\n): void {\n const {\n name,\n scheme,\n variable,\n title,\n description,\n notFoundLabel,\n list,\n read,\n } = config;\n server.registerResource(\n name,\n new ResourceTemplate(`${scheme}:///{+${variable}}`, {\n list: async () => ({\n resources: (await list()).map((key) => ({\n uri: `${scheme}:///${key}`,\n name: key,\n mimeType: MARKDOWN_MIME_TYPE,\n })),\n }),\n complete: {\n [variable]: async (value) => {\n const needle = value.toLowerCase();\n return (await list()).filter((key) =>\n key.toLowerCase().includes(needle),\n );\n },\n },\n }),\n { title, description, mimeType: MARKDOWN_MIME_TYPE },\n async (uri, variables) => {\n const key = templateVarToPath(variables[variable]);\n const text = await read(key);\n if (text === null) {\n throw new Error(`${notFoundLabel} not found: ${key}`);\n }\n return {\n contents: [{ uri: uri.href, mimeType: MARKDOWN_MIME_TYPE, text }],\n };\n },\n );\n}\n\nasync function readDocResource(path: string): Promise<string | null> {\n const sanitized = sanitizePath(path);\n const mdx = await readMDXFileSafe(\n join(DOCS_PATH, `${sanitized}${MDX_EXTENSION}`),\n );\n return mdx ? formatMDXContent(mdx) : null;\n}\n\nexport function registerResources(server: McpServer): void {\n registerMarkdownResource(server, {\n name: \"assistant-ui-docs\",\n scheme: DOCS_SCHEME,\n variable: \"path\",\n title: \"assistant-ui Documentation\",\n description:\n \"Individual assistant-ui documentation pages, readable as markdown by path.\",\n notFoundLabel: \"Documentation\",\n list: getAvailableDocFiles,\n read: readDocResource,\n });\n\n registerMarkdownResource(server, {\n name: \"assistant-ui-examples\",\n scheme: EXAMPLE_SCHEME,\n variable: \"name\",\n title: \"assistant-ui Examples\",\n description:\n \"Complete assistant-ui example projects, readable as markdown.\",\n notFoundLabel: \"Example\",\n list: listCodeExamples,\n read: readCodeExample,\n });\n\n logger.debug(\"Registered docs and examples resources\");\n}\n"],"mappings":";;;;;;;;;AASA,MAAM,qBAAqB;AAC3B,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAEvB,SAAS,kBAAkB,OAA8C;CACvE,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,KAAK,GAAG;CAC/C,OAAO,SAAS;AAClB;AAaA,SAAS,yBACP,QACA,QACM;CACN,MAAM,EACJ,MACA,QACA,UACA,OACA,aACA,eACA,MACA,SACE;CACJ,OAAO,iBACL,MACA,IAAI,iBAAiB,GAAG,OAAO,QAAQ,SAAS,IAAI;EAClD,MAAM,aAAa,EACjB,YAAY,MAAM,KAAK,EAAA,CAAG,KAAK,SAAS;GACtC,KAAK,GAAG,OAAO,MAAM;GACrB,MAAM;GACN,UAAU;EACZ,EAAE,EACJ;EACA,UAAU,GACP,WAAW,OAAO,UAAU;GAC3B,MAAM,SAAS,MAAM,YAAY;GACjC,QAAQ,MAAM,KAAK,EAAA,CAAG,QAAQ,QAC5B,IAAI,YAAY,CAAC,CAAC,SAAS,MAAM,CACnC;EACF,EACF;CACF,CAAC,GACD;EAAE;EAAO;EAAa,UAAU;CAAmB,GACnD,OAAO,KAAK,cAAc;EACxB,MAAM,MAAM,kBAAkB,UAAU,SAAS;EACjD,MAAM,OAAO,MAAM,KAAK,GAAG;EAC3B,IAAI,SAAS,MACX,MAAM,IAAI,MAAM,GAAG,cAAc,cAAc,KAAK;EAEtD,OAAO,EACL,UAAU,CAAC;GAAE,KAAK,IAAI;GAAM,UAAU;GAAoB;EAAK,CAAC,EAClE;CACF,CACF;AACF;AAEA,eAAe,gBAAgB,MAAsC;
|
|
1
|
+
{"version":3,"file":"resources.js","names":[],"sources":["../../src/tools/resources.ts"],"sourcesContent":["import { type McpServer, ResourceTemplate } from \"@modelcontextprotocol/server\";\nimport { join } from \"node:path\";\nimport { DOCS_PATH, MDX_EXTENSION } from \"../constants.js\";\nimport { getAvailableDocFiles } from \"../utils/paths.js\";\nimport { readMDXFileSafe, formatMDXContent } from \"../utils/mdx.js\";\nimport { sanitizePath } from \"../utils/security.js\";\nimport { listCodeExamples, readCodeExample } from \"./examples.js\";\nimport { logger } from \"../utils/logger.js\";\n\nconst MARKDOWN_MIME_TYPE = \"text/markdown\";\nconst DOCS_SCHEME = \"aui-docs\";\nconst EXAMPLE_SCHEME = \"aui-example\";\n\nfunction templateVarToPath(value: string | string[] | undefined): string {\n if (Array.isArray(value)) return value.join(\"/\");\n return value ?? \"\";\n}\n\ninterface MarkdownResourceConfig {\n name: string;\n scheme: string;\n variable: string;\n title: string;\n description: string;\n notFoundLabel: string;\n list: () => Promise<string[]>;\n read: (key: string) => Promise<string | null>;\n}\n\nfunction registerMarkdownResource(\n server: McpServer,\n config: MarkdownResourceConfig,\n): void {\n const {\n name,\n scheme,\n variable,\n title,\n description,\n notFoundLabel,\n list,\n read,\n } = config;\n server.registerResource(\n name,\n new ResourceTemplate(`${scheme}:///{+${variable}}`, {\n list: async () => ({\n resources: (await list()).map((key) => ({\n uri: `${scheme}:///${key}`,\n name: key,\n mimeType: MARKDOWN_MIME_TYPE,\n })),\n }),\n complete: {\n [variable]: async (value) => {\n const needle = value.toLowerCase();\n return (await list()).filter((key) =>\n key.toLowerCase().includes(needle),\n );\n },\n },\n }),\n { title, description, mimeType: MARKDOWN_MIME_TYPE },\n async (uri, variables) => {\n const key = templateVarToPath(variables[variable]);\n const text = await read(key);\n if (text === null) {\n throw new Error(`${notFoundLabel} not found: ${key}`);\n }\n return {\n contents: [{ uri: uri.href, mimeType: MARKDOWN_MIME_TYPE, text }],\n };\n },\n );\n}\n\nasync function readDocResource(path: string): Promise<string | null> {\n const sanitized = sanitizePath(path);\n const mdx = await readMDXFileSafe(\n join(DOCS_PATH, `${sanitized}${MDX_EXTENSION}`),\n );\n return mdx ? formatMDXContent(mdx) : null;\n}\n\nexport function registerResources(server: McpServer): void {\n registerMarkdownResource(server, {\n name: \"assistant-ui-docs\",\n scheme: DOCS_SCHEME,\n variable: \"path\",\n title: \"assistant-ui Documentation\",\n description:\n \"Individual assistant-ui documentation pages, readable as markdown by path.\",\n notFoundLabel: \"Documentation\",\n list: getAvailableDocFiles,\n read: readDocResource,\n });\n\n registerMarkdownResource(server, {\n name: \"assistant-ui-examples\",\n scheme: EXAMPLE_SCHEME,\n variable: \"name\",\n title: \"assistant-ui Examples\",\n description:\n \"Complete assistant-ui example projects, readable as markdown.\",\n notFoundLabel: \"Example\",\n list: listCodeExamples,\n read: readCodeExample,\n });\n\n logger.debug(\"Registered docs and examples resources\");\n}\n"],"mappings":";;;;;;;;;AASA,MAAM,qBAAqB;AAC3B,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAEvB,SAAS,kBAAkB,OAA8C;CACvE,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,KAAK,GAAG;CAC/C,OAAO,SAAS;AAClB;AAaA,SAAS,yBACP,QACA,QACM;CACN,MAAM,EACJ,MACA,QACA,UACA,OACA,aACA,eACA,MACA,SACE;CACJ,OAAO,iBACL,MACA,IAAI,iBAAiB,GAAG,OAAO,QAAQ,SAAS,IAAI;EAClD,MAAM,aAAa,EACjB,YAAY,MAAM,KAAK,EAAA,CAAG,KAAK,SAAS;GACtC,KAAK,GAAG,OAAO,MAAM;GACrB,MAAM;GACN,UAAU;EACZ,EAAE,EACJ;EACA,UAAU,GACP,WAAW,OAAO,UAAU;GAC3B,MAAM,SAAS,MAAM,YAAY;GACjC,QAAQ,MAAM,KAAK,EAAA,CAAG,QAAQ,QAC5B,IAAI,YAAY,CAAC,CAAC,SAAS,MAAM,CACnC;EACF,EACF;CACF,CAAC,GACD;EAAE;EAAO;EAAa,UAAU;CAAmB,GACnD,OAAO,KAAK,cAAc;EACxB,MAAM,MAAM,kBAAkB,UAAU,SAAS;EACjD,MAAM,OAAO,MAAM,KAAK,GAAG;EAC3B,IAAI,SAAS,MACX,MAAM,IAAI,MAAM,GAAG,cAAc,cAAc,KAAK;EAEtD,OAAO,EACL,UAAU,CAAC;GAAE,KAAK,IAAI;GAAM,UAAU;GAAoB;EAAK,CAAC,EAClE;CACF,CACF;AACF;AAEA,eAAe,gBAAgB,MAAsC;CACnE,MAAM,YAAY,aAAa,IAAI;CACnC,MAAM,MAAM,MAAM,gBAChB,KAAK,WAAW,GAAG,YAAY,eAAe,CAChD;CACA,OAAO,MAAM,iBAAiB,GAAG,IAAI;AACvC;AAEA,SAAgB,kBAAkB,QAAyB;CACzD,yBAAyB,QAAQ;EAC/B,MAAM;EACN,QAAQ;EACR,UAAU;EACV,OAAO;EACP,aACE;EACF,eAAe;EACf,MAAM;EACN,MAAM;CACR,CAAC;CAED,yBAAyB,QAAQ;EAC/B,MAAM;EACN,QAAQ;EACR,UAAU;EACV,OAAO;EACP,aACE;EACF,eAAe;EACf,MAAM;EACN,MAAM;CACR,CAAC;CAED,OAAO,MAAM,wCAAwC;AACvD"}
|
|
@@ -27,7 +27,8 @@ const testContext = { callTool: async (name, args) => {
|
|
|
27
27
|
}
|
|
28
28
|
} };
|
|
29
29
|
beforeAll(() => {
|
|
30
|
-
|
|
30
|
+
const docsPath = join(PACKAGE_DIR, ".docs");
|
|
31
|
+
if (!existsSync(docsPath)) throw new Error("Documentation not prepared. Run: pnpm build");
|
|
31
32
|
});
|
|
32
33
|
//#endregion
|
|
33
34
|
export { testContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-setup.js","names":[],"sources":["../../../src/tools/tests/test-setup.ts"],"sourcesContent":["import { beforeAll } from \"vitest\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { PACKAGE_DIR } from \"../../constants.js\";\nimport { docsTools } from \"../docs.js\";\nimport { examplesTools } from \"../examples.js\";\nimport { searchTools } from \"../search.js\";\nimport {\n xuluxTemplatesListTool,\n xuluxTemplateDetailsTool,\n xuluxTemplatePreviewTool,\n} from \"../xulux-templates.js\";\n\nconst tools = {\n assistantUIDocs: docsTools,\n assistantUIExamples: examplesTools,\n assistantUISearch: searchTools,\n assistantUITemplates: xuluxTemplatesListTool,\n assistantUITemplateDetails: xuluxTemplateDetailsTool,\n assistantUITemplatePreview: xuluxTemplatePreviewTool,\n};\n\nexport const testContext = {\n callTool: async (name: string, args: any) => {\n const tool = tools[name as keyof typeof tools];\n if (!tool) {\n throw new Error(`Tool ${name} not found`);\n }\n const result = await tool.execute(args);\n\n const text = result.content?.[0]?.text;\n if (text === undefined) {\n throw new Error(`Tool ${name} returned no content`);\n }\n try {\n return JSON.parse(text);\n } catch (error) {\n throw new Error(\n `Tool ${name} returned invalid JSON. Output: ${text}\\nParse error: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n};\n\nbeforeAll(() => {\n const docsPath = join(PACKAGE_DIR, \".docs\");\n if (!existsSync(docsPath)) {\n throw new Error(\"Documentation not prepared. Run: pnpm build\");\n }\n});\n"],"mappings":";;;;;;;;;AAaA,MAAM,QAAQ;CACZ,iBAAiB;CACjB,qBAAqB;CACrB,mBAAmB;CACnB,sBAAsB;CACtB,4BAA4B;CAC5B,4BAA4B;AAC9B;AAEA,MAAa,cAAc,EACzB,UAAU,OAAO,MAAc,SAAc;CAC3C,MAAM,OAAO,MAAM;CACnB,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,QAAQ,KAAK,WAAW;CAI1C,MAAM,QAAO,MAFQ,KAAK,QAAQ,IAAI,EAAA,CAElB,UAAU,EAAE,EAAE;CAClC,IAAI,SAAS,KAAA,GACX,MAAM,IAAI,MAAM,QAAQ,KAAK,qBAAqB;CAEpD,IAAI;EACF,OAAO,KAAK,MAAM,IAAI;CACxB,SAAS,OAAO;EACd,MAAM,IAAI,MACR,QAAQ,KAAK,kCAAkC,KAAK,iBAAiB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAC5H;CACF;AACF,EACF;AAEA,gBAAgB;
|
|
1
|
+
{"version":3,"file":"test-setup.js","names":[],"sources":["../../../src/tools/tests/test-setup.ts"],"sourcesContent":["import { beforeAll } from \"vitest\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { PACKAGE_DIR } from \"../../constants.js\";\nimport { docsTools } from \"../docs.js\";\nimport { examplesTools } from \"../examples.js\";\nimport { searchTools } from \"../search.js\";\nimport {\n xuluxTemplatesListTool,\n xuluxTemplateDetailsTool,\n xuluxTemplatePreviewTool,\n} from \"../xulux-templates.js\";\n\nconst tools = {\n assistantUIDocs: docsTools,\n assistantUIExamples: examplesTools,\n assistantUISearch: searchTools,\n assistantUITemplates: xuluxTemplatesListTool,\n assistantUITemplateDetails: xuluxTemplateDetailsTool,\n assistantUITemplatePreview: xuluxTemplatePreviewTool,\n};\n\nexport const testContext = {\n callTool: async (name: string, args: any) => {\n const tool = tools[name as keyof typeof tools];\n if (!tool) {\n throw new Error(`Tool ${name} not found`);\n }\n const result = await tool.execute(args);\n\n const text = result.content?.[0]?.text;\n if (text === undefined) {\n throw new Error(`Tool ${name} returned no content`);\n }\n try {\n return JSON.parse(text);\n } catch (error) {\n throw new Error(\n `Tool ${name} returned invalid JSON. Output: ${text}\\nParse error: ${error instanceof Error ? error.message : String(error)}`,\n );\n }\n },\n};\n\nbeforeAll(() => {\n const docsPath = join(PACKAGE_DIR, \".docs\");\n if (!existsSync(docsPath)) {\n throw new Error(\"Documentation not prepared. Run: pnpm build\");\n }\n});\n"],"mappings":";;;;;;;;;AAaA,MAAM,QAAQ;CACZ,iBAAiB;CACjB,qBAAqB;CACrB,mBAAmB;CACnB,sBAAsB;CACtB,4BAA4B;CAC5B,4BAA4B;AAC9B;AAEA,MAAa,cAAc,EACzB,UAAU,OAAO,MAAc,SAAc;CAC3C,MAAM,OAAO,MAAM;CACnB,IAAI,CAAC,MACH,MAAM,IAAI,MAAM,QAAQ,KAAK,WAAW;CAI1C,MAAM,QAAO,MAFQ,KAAK,QAAQ,IAAI,EAAA,CAElB,UAAU,EAAE,EAAE;CAClC,IAAI,SAAS,KAAA,GACX,MAAM,IAAI,MAAM,QAAQ,KAAK,qBAAqB;CAEpD,IAAI;EACF,OAAO,KAAK,MAAM,IAAI;CACxB,SAAS,OAAO;EACd,MAAM,IAAI,MACR,QAAQ,KAAK,kCAAkC,KAAK,iBAAiB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAC5H;CACF;AACF,EACF;AAEA,gBAAgB;CACd,MAAM,WAAW,KAAK,aAAa,OAAO;CAC1C,IAAI,CAAC,WAAW,QAAQ,GACtB,MAAM,IAAI,MAAM,6CAA6C;AAEjE,CAAC"}
|
|
@@ -48,7 +48,8 @@ const xuluxTemplateDetailsTool = {
|
|
|
48
48
|
logger.info(`Getting assistant-ui template details for: ${args.templateId}`);
|
|
49
49
|
try {
|
|
50
50
|
const { catalog, degraded, degradedReason } = await getXuluxCatalog();
|
|
51
|
-
|
|
51
|
+
const details = await getTemplateDetails(catalog, args);
|
|
52
|
+
return formatMCPResponse(withDegradedNote(details, degraded, degradedReason));
|
|
52
53
|
} catch (error) {
|
|
53
54
|
logger.error("Failed to get assistant-ui template details", error);
|
|
54
55
|
return formatMCPResponse({
|
|
@@ -66,7 +67,8 @@ const xuluxTemplatePreviewTool = {
|
|
|
66
67
|
logger.info(`Creating assistant-ui template preview for: ${args.templateId}`);
|
|
67
68
|
try {
|
|
68
69
|
const { catalog, degraded, degradedReason } = await getXuluxCatalog();
|
|
69
|
-
|
|
70
|
+
const result = await createTemplatePreview(catalog, args);
|
|
71
|
+
return formatMCPResponse(withDegradedNote(result, degraded, degradedReason));
|
|
70
72
|
} catch (error) {
|
|
71
73
|
logger.error("Failed to create assistant-ui template preview", error);
|
|
72
74
|
return formatMCPResponse({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"xulux-templates.js","names":[],"sources":["../../src/tools/xulux-templates.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { logger } from \"../utils/logger.js\";\nimport { formatMCPResponse } from \"../utils/mcp-format.js\";\nimport { getXuluxCatalog } from \"../xulux/catalog-client.js\";\nimport {\n createTemplatePreview,\n getTemplateDetails,\n listTemplates,\n} from \"../xulux/template-service.js\";\n\nconst emptyInputSchema = z.object({});\n\nconst detailsInputSchema = z.object({\n templateId: z.string().describe(\"The template id from assistantUITemplates\"),\n versionId: z\n .string()\n .optional()\n .describe(\n \"Optional version id. When provided, exampleConfig reflects that version's resolved defaults.\",\n ),\n});\n\nconst previewInputSchema = z.object({\n templateId: z.string().describe(\"The template id from assistantUITemplates\"),\n versionId: z\n .string()\n .optional()\n .describe(\"Version id to use. Uses the template default if omitted.\"),\n config: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n \"Customization config for the preview. Must contain only the top-level keys: hostUi, assistant, and brandTheme. \" +\n \"Use the schemas from assistantUITemplateDetails.configRoots as the source of truth for each root. \" +\n \"Do not pass any other root keys.\",\n ),\n});\n\nfunction withDegradedNote<T extends Record<string, unknown>>(\n payload: T,\n degraded: boolean,\n degradedReason?: string,\n): T & { catalogDegraded?: true; catalogDegradedReason?: string } {\n if (!degraded) return payload;\n return {\n ...payload,\n catalogDegraded: true,\n ...(degradedReason ? { catalogDegradedReason: degradedReason } : {}),\n };\n}\n\nexport const xuluxTemplatesListTool = {\n name: \"assistantUITemplates\",\n description:\n \"List the available assistant-ui hosted app templates and fixed demos with their features, customizable surfaces, and versions. \" +\n \"Call this first for any assistant-ui app-building request. Use the features and customizable fields to decide which template fits. \" +\n \"If customizable is empty, the entry is a fixed demo that should be used as-is rather than configured. \" +\n \"Call assistantUITemplateDetails on the chosen template before requesting a preview.\",\n parameters: emptyInputSchema,\n execute: async (_args: z.infer<typeof emptyInputSchema>) => {\n logger.info(\"Listing assistant-ui templates\");\n try {\n const { catalog, degraded, degradedReason } = await getXuluxCatalog();\n return formatMCPResponse(\n withDegradedNote(listTemplates(catalog), degraded, degradedReason),\n );\n } catch (error) {\n logger.error(\"Failed to list assistant-ui templates\", error);\n return formatMCPResponse({\n error: \"Failed to list assistant-ui templates\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n\nexport const xuluxTemplateDetailsTool = {\n name: \"assistantUITemplateDetails\",\n description:\n \"Get the full authoring surface for a specific assistant-ui hosted template. \" +\n \"Returns configRoots schemas (with types, defaults, and enums), rules, built-in tool input/outputShape, renderer contracts, and an exampleConfig. \" +\n \"Fixed demos return no configRoots; use those as-is without config. \" +\n \"Use this before calling assistantUITemplatePreview to understand exactly what config to write. \" +\n \"If assistantUITemplatePreview returns validationWarnings, call this again and cross-reference configRoots to correct the config.\",\n parameters: detailsInputSchema,\n execute: async (args: z.infer<typeof detailsInputSchema>) => {\n logger.info(\n `Getting assistant-ui template details for: ${args.templateId}`,\n );\n try {\n const { catalog, degraded, degradedReason } = await getXuluxCatalog();\n const details = await getTemplateDetails(catalog, args);\n return formatMCPResponse(\n withDegradedNote(\n details as unknown as Record<string, unknown>,\n degraded,\n degradedReason,\n ),\n );\n } catch (error) {\n logger.error(\"Failed to get assistant-ui template details\", error);\n return formatMCPResponse({\n error: \"Failed to get assistant-ui template details\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n\nexport const xuluxTemplatePreviewTool = {\n name: \"assistantUITemplatePreview\",\n description:\n \"Return preview and download URLs for a selected assistant-ui hosted template. \" +\n \"The previewUrl is a hosted app URL; show it to the user first, or open it with an available browser/in-app-browser tool if your client provides one. \" +\n \"If you pass config, a preview session is created on the hosted template sandbox and the returned URLs reflect that configuration. \" +\n \"Do not pass config for fixed demos that have no configRoots in assistantUITemplateDetails. \" +\n \"This tool only returns URLs.\",\n parameters: previewInputSchema,\n execute: async (args: z.infer<typeof previewInputSchema>) => {\n logger.info(\n `Creating assistant-ui template preview for: ${args.templateId}`,\n );\n try {\n const { catalog, degraded, degradedReason } = await getXuluxCatalog();\n const result = await createTemplatePreview(catalog, args);\n return formatMCPResponse(\n withDegradedNote(\n result as unknown as Record<string, unknown>,\n degraded,\n degradedReason,\n ),\n );\n } catch (error) {\n logger.error(\"Failed to create assistant-ui template preview\", error);\n return formatMCPResponse({\n error: \"Failed to create assistant-ui template preview\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n"],"mappings":";;;;;;AAUA,MAAM,mBAAmB,EAAE,OAAO,CAAC,CAAC;AAEpC,MAAM,qBAAqB,EAAE,OAAO;CAClC,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS,2CAA2C;CAC3E,WAAW,EACR,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,8FACF;AACJ,CAAC;AAED,MAAM,qBAAqB,EAAE,OAAO;CAClC,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS,2CAA2C;CAC3E,WAAW,EACR,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,0DAA0D;CACtE,QAAQ,EACL,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAC/B,SAAS,CAAC,CACV,SACC,mPAGF;AACJ,CAAC;AAED,SAAS,iBACP,SACA,UACA,gBACgE;CAChE,IAAI,CAAC,UAAU,OAAO;CACtB,OAAO;EACL,GAAG;EACH,iBAAiB;EACjB,GAAI,iBAAiB,EAAE,uBAAuB,eAAe,IAAI,CAAC;CACpE;AACF;AAEA,MAAa,yBAAyB;CACpC,MAAM;CACN,aACE;CAIF,YAAY;CACZ,SAAS,OAAO,UAA4C;EAC1D,OAAO,KAAK,gCAAgC;EAC5C,IAAI;GACF,MAAM,EAAE,SAAS,UAAU,mBAAmB,MAAM,gBAAgB;GACpE,OAAO,kBACL,iBAAiB,cAAc,OAAO,GAAG,UAAU,cAAc,CACnE;EACF,SAAS,OAAO;GACd,OAAO,MAAM,yCAAyC,KAAK;GAC3D,OAAO,kBAAkB;IACvB,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAChE,CAAC;EACH;CACF;AACF;AAEA,MAAa,2BAA2B;CACtC,MAAM;CACN,aACE;CAKF,YAAY;CACZ,SAAS,OAAO,SAA6C;EAC3D,OAAO,KACL,8CAA8C,KAAK,YACrD;EACA,IAAI;GACF,MAAM,EAAE,SAAS,UAAU,mBAAmB,MAAM,gBAAgB;
|
|
1
|
+
{"version":3,"file":"xulux-templates.js","names":[],"sources":["../../src/tools/xulux-templates.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { logger } from \"../utils/logger.js\";\nimport { formatMCPResponse } from \"../utils/mcp-format.js\";\nimport { getXuluxCatalog } from \"../xulux/catalog-client.js\";\nimport {\n createTemplatePreview,\n getTemplateDetails,\n listTemplates,\n} from \"../xulux/template-service.js\";\n\nconst emptyInputSchema = z.object({});\n\nconst detailsInputSchema = z.object({\n templateId: z.string().describe(\"The template id from assistantUITemplates\"),\n versionId: z\n .string()\n .optional()\n .describe(\n \"Optional version id. When provided, exampleConfig reflects that version's resolved defaults.\",\n ),\n});\n\nconst previewInputSchema = z.object({\n templateId: z.string().describe(\"The template id from assistantUITemplates\"),\n versionId: z\n .string()\n .optional()\n .describe(\"Version id to use. Uses the template default if omitted.\"),\n config: z\n .record(z.string(), z.unknown())\n .optional()\n .describe(\n \"Customization config for the preview. Must contain only the top-level keys: hostUi, assistant, and brandTheme. \" +\n \"Use the schemas from assistantUITemplateDetails.configRoots as the source of truth for each root. \" +\n \"Do not pass any other root keys.\",\n ),\n});\n\nfunction withDegradedNote<T extends Record<string, unknown>>(\n payload: T,\n degraded: boolean,\n degradedReason?: string,\n): T & { catalogDegraded?: true; catalogDegradedReason?: string } {\n if (!degraded) return payload;\n return {\n ...payload,\n catalogDegraded: true,\n ...(degradedReason ? { catalogDegradedReason: degradedReason } : {}),\n };\n}\n\nexport const xuluxTemplatesListTool = {\n name: \"assistantUITemplates\",\n description:\n \"List the available assistant-ui hosted app templates and fixed demos with their features, customizable surfaces, and versions. \" +\n \"Call this first for any assistant-ui app-building request. Use the features and customizable fields to decide which template fits. \" +\n \"If customizable is empty, the entry is a fixed demo that should be used as-is rather than configured. \" +\n \"Call assistantUITemplateDetails on the chosen template before requesting a preview.\",\n parameters: emptyInputSchema,\n execute: async (_args: z.infer<typeof emptyInputSchema>) => {\n logger.info(\"Listing assistant-ui templates\");\n try {\n const { catalog, degraded, degradedReason } = await getXuluxCatalog();\n return formatMCPResponse(\n withDegradedNote(listTemplates(catalog), degraded, degradedReason),\n );\n } catch (error) {\n logger.error(\"Failed to list assistant-ui templates\", error);\n return formatMCPResponse({\n error: \"Failed to list assistant-ui templates\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n\nexport const xuluxTemplateDetailsTool = {\n name: \"assistantUITemplateDetails\",\n description:\n \"Get the full authoring surface for a specific assistant-ui hosted template. \" +\n \"Returns configRoots schemas (with types, defaults, and enums), rules, built-in tool input/outputShape, renderer contracts, and an exampleConfig. \" +\n \"Fixed demos return no configRoots; use those as-is without config. \" +\n \"Use this before calling assistantUITemplatePreview to understand exactly what config to write. \" +\n \"If assistantUITemplatePreview returns validationWarnings, call this again and cross-reference configRoots to correct the config.\",\n parameters: detailsInputSchema,\n execute: async (args: z.infer<typeof detailsInputSchema>) => {\n logger.info(\n `Getting assistant-ui template details for: ${args.templateId}`,\n );\n try {\n const { catalog, degraded, degradedReason } = await getXuluxCatalog();\n const details = await getTemplateDetails(catalog, args);\n return formatMCPResponse(\n withDegradedNote(\n details as unknown as Record<string, unknown>,\n degraded,\n degradedReason,\n ),\n );\n } catch (error) {\n logger.error(\"Failed to get assistant-ui template details\", error);\n return formatMCPResponse({\n error: \"Failed to get assistant-ui template details\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n\nexport const xuluxTemplatePreviewTool = {\n name: \"assistantUITemplatePreview\",\n description:\n \"Return preview and download URLs for a selected assistant-ui hosted template. \" +\n \"The previewUrl is a hosted app URL; show it to the user first, or open it with an available browser/in-app-browser tool if your client provides one. \" +\n \"If you pass config, a preview session is created on the hosted template sandbox and the returned URLs reflect that configuration. \" +\n \"Do not pass config for fixed demos that have no configRoots in assistantUITemplateDetails. \" +\n \"This tool only returns URLs.\",\n parameters: previewInputSchema,\n execute: async (args: z.infer<typeof previewInputSchema>) => {\n logger.info(\n `Creating assistant-ui template preview for: ${args.templateId}`,\n );\n try {\n const { catalog, degraded, degradedReason } = await getXuluxCatalog();\n const result = await createTemplatePreview(catalog, args);\n return formatMCPResponse(\n withDegradedNote(\n result as unknown as Record<string, unknown>,\n degraded,\n degradedReason,\n ),\n );\n } catch (error) {\n logger.error(\"Failed to create assistant-ui template preview\", error);\n return formatMCPResponse({\n error: \"Failed to create assistant-ui template preview\",\n message: error instanceof Error ? error.message : String(error),\n });\n }\n },\n};\n"],"mappings":";;;;;;AAUA,MAAM,mBAAmB,EAAE,OAAO,CAAC,CAAC;AAEpC,MAAM,qBAAqB,EAAE,OAAO;CAClC,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS,2CAA2C;CAC3E,WAAW,EACR,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SACC,8FACF;AACJ,CAAC;AAED,MAAM,qBAAqB,EAAE,OAAO;CAClC,YAAY,EAAE,OAAO,CAAC,CAAC,SAAS,2CAA2C;CAC3E,WAAW,EACR,OAAO,CAAC,CACR,SAAS,CAAC,CACV,SAAS,0DAA0D;CACtE,QAAQ,EACL,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC,CAAC,CAC/B,SAAS,CAAC,CACV,SACC,mPAGF;AACJ,CAAC;AAED,SAAS,iBACP,SACA,UACA,gBACgE;CAChE,IAAI,CAAC,UAAU,OAAO;CACtB,OAAO;EACL,GAAG;EACH,iBAAiB;EACjB,GAAI,iBAAiB,EAAE,uBAAuB,eAAe,IAAI,CAAC;CACpE;AACF;AAEA,MAAa,yBAAyB;CACpC,MAAM;CACN,aACE;CAIF,YAAY;CACZ,SAAS,OAAO,UAA4C;EAC1D,OAAO,KAAK,gCAAgC;EAC5C,IAAI;GACF,MAAM,EAAE,SAAS,UAAU,mBAAmB,MAAM,gBAAgB;GACpE,OAAO,kBACL,iBAAiB,cAAc,OAAO,GAAG,UAAU,cAAc,CACnE;EACF,SAAS,OAAO;GACd,OAAO,MAAM,yCAAyC,KAAK;GAC3D,OAAO,kBAAkB;IACvB,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAChE,CAAC;EACH;CACF;AACF;AAEA,MAAa,2BAA2B;CACtC,MAAM;CACN,aACE;CAKF,YAAY;CACZ,SAAS,OAAO,SAA6C;EAC3D,OAAO,KACL,8CAA8C,KAAK,YACrD;EACA,IAAI;GACF,MAAM,EAAE,SAAS,UAAU,mBAAmB,MAAM,gBAAgB;GACpE,MAAM,UAAU,MAAM,mBAAmB,SAAS,IAAI;GACtD,OAAO,kBACL,iBACE,SACA,UACA,cACF,CACF;EACF,SAAS,OAAO;GACd,OAAO,MAAM,+CAA+C,KAAK;GACjE,OAAO,kBAAkB;IACvB,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAChE,CAAC;EACH;CACF;AACF;AAEA,MAAa,2BAA2B;CACtC,MAAM;CACN,aACE;CAKF,YAAY;CACZ,SAAS,OAAO,SAA6C;EAC3D,OAAO,KACL,+CAA+C,KAAK,YACtD;EACA,IAAI;GACF,MAAM,EAAE,SAAS,UAAU,mBAAmB,MAAM,gBAAgB;GACpE,MAAM,SAAS,MAAM,sBAAsB,SAAS,IAAI;GACxD,OAAO,kBACL,iBACE,QACA,UACA,cACF,CACF;EACF,SAAS,OAAO;GACd,OAAO,MAAM,kDAAkD,KAAK;GACpE,OAAO,kBAAkB;IACvB,OAAO;IACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;GAChE,CAAC;EACH;CACF;AACF"}
|
package/dist/utils/mdx.js
CHANGED
|
@@ -5,7 +5,8 @@ import matter from "gray-matter";
|
|
|
5
5
|
//#region src/utils/mdx.ts
|
|
6
6
|
async function readMDXFile(filePath) {
|
|
7
7
|
try {
|
|
8
|
-
const
|
|
8
|
+
const fileContent = await readFile(filePath, "utf-8");
|
|
9
|
+
const { content, data } = matter(fileContent);
|
|
9
10
|
const excerptMatch = content.match(/^(.+?)(?:\n\n|$)/);
|
|
10
11
|
const excerpt = excerptMatch?.[1] !== void 0 ? excerptMatch[1].replace(/^#+ /, "") : void 0;
|
|
11
12
|
return {
|
package/dist/utils/mdx.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mdx.js","names":[],"sources":["../../src/utils/mdx.ts"],"sourcesContent":["import { readFile, lstat } from \"node:fs/promises\";\nimport matter from \"gray-matter\";\nimport { MAX_FILE_SIZE } from \"../constants.js\";\nimport { logger } from \"./logger.js\";\n\ninterface MDXContent {\n content: string;\n frontmatter: Record<string, any>;\n excerpt?: string;\n}\n\nexport async function readMDXFile(\n filePath: string,\n): Promise<MDXContent | null> {\n try {\n const fileContent = await readFile(filePath, \"utf-8\");\n const { content, data } = matter(fileContent);\n\n const excerptMatch = content.match(/^(.+?)(?:\\n\\n|$)/);\n const excerpt =\n excerptMatch?.[1] !== undefined\n ? excerptMatch[1].replace(/^#+ /, \"\")\n : undefined;\n\n return {\n content,\n frontmatter: data,\n ...(excerpt !== undefined && { excerpt }),\n };\n } catch (error) {\n logger.error(`Failed to read MDX file: ${filePath}`, error);\n return null;\n }\n}\n\nexport async function readMDXFileSafe(\n filePath: string,\n): Promise<MDXContent | null> {\n try {\n const stats = await lstat(filePath);\n if (stats.isSymbolicLink()) {\n logger.warn(`Attempted to read symlink: ${filePath}`);\n return null;\n }\n if (stats.size > MAX_FILE_SIZE) {\n logger.warn(`File size exceeds limit: ${filePath} (${stats.size} bytes)`);\n return null;\n }\n } catch {\n return null;\n }\n return readMDXFile(filePath);\n}\n\nexport function formatMDXContent(mdxContent: MDXContent): string {\n const { content, frontmatter } = mdxContent;\n\n return matter.stringify(content, frontmatter);\n}\n"],"mappings":";;;;;AAWA,eAAsB,YACpB,UAC4B;CAC5B,IAAI;
|
|
1
|
+
{"version":3,"file":"mdx.js","names":[],"sources":["../../src/utils/mdx.ts"],"sourcesContent":["import { readFile, lstat } from \"node:fs/promises\";\nimport matter from \"gray-matter\";\nimport { MAX_FILE_SIZE } from \"../constants.js\";\nimport { logger } from \"./logger.js\";\n\ninterface MDXContent {\n content: string;\n frontmatter: Record<string, any>;\n excerpt?: string;\n}\n\nexport async function readMDXFile(\n filePath: string,\n): Promise<MDXContent | null> {\n try {\n const fileContent = await readFile(filePath, \"utf-8\");\n const { content, data } = matter(fileContent);\n\n const excerptMatch = content.match(/^(.+?)(?:\\n\\n|$)/);\n const excerpt =\n excerptMatch?.[1] !== undefined\n ? excerptMatch[1].replace(/^#+ /, \"\")\n : undefined;\n\n return {\n content,\n frontmatter: data,\n ...(excerpt !== undefined && { excerpt }),\n };\n } catch (error) {\n logger.error(`Failed to read MDX file: ${filePath}`, error);\n return null;\n }\n}\n\nexport async function readMDXFileSafe(\n filePath: string,\n): Promise<MDXContent | null> {\n try {\n const stats = await lstat(filePath);\n if (stats.isSymbolicLink()) {\n logger.warn(`Attempted to read symlink: ${filePath}`);\n return null;\n }\n if (stats.size > MAX_FILE_SIZE) {\n logger.warn(`File size exceeds limit: ${filePath} (${stats.size} bytes)`);\n return null;\n }\n } catch {\n return null;\n }\n return readMDXFile(filePath);\n}\n\nexport function formatMDXContent(mdxContent: MDXContent): string {\n const { content, frontmatter } = mdxContent;\n\n return matter.stringify(content, frontmatter);\n}\n"],"mappings":";;;;;AAWA,eAAsB,YACpB,UAC4B;CAC5B,IAAI;EACF,MAAM,cAAc,MAAM,SAAS,UAAU,OAAO;EACpD,MAAM,EAAE,SAAS,SAAS,OAAO,WAAW;EAE5C,MAAM,eAAe,QAAQ,MAAM,kBAAkB;EACrD,MAAM,UACJ,eAAe,OAAO,KAAA,IAClB,aAAa,EAAE,CAAC,QAAQ,QAAQ,EAAE,IAClC,KAAA;EAEN,OAAO;GACL;GACA,aAAa;GACb,GAAI,YAAY,KAAA,KAAa,EAAE,QAAQ;EACzC;CACF,SAAS,OAAO;EACd,OAAO,MAAM,4BAA4B,YAAY,KAAK;EAC1D,OAAO;CACT;AACF;AAEA,eAAsB,gBACpB,UAC4B;CAC5B,IAAI;EACF,MAAM,QAAQ,MAAM,MAAM,QAAQ;EAClC,IAAI,MAAM,eAAe,GAAG;GAC1B,OAAO,KAAK,8BAA8B,UAAU;GACpD,OAAO;EACT;EACA,IAAI,MAAM,OAAA,UAAsB;GAC9B,OAAO,KAAK,4BAA4B,SAAS,IAAI,MAAM,KAAK,QAAQ;GACxE,OAAO;EACT;CACF,QAAQ;EACN,OAAO;CACT;CACA,OAAO,YAAY,QAAQ;AAC7B;AAEA,SAAgB,iBAAiB,YAAgC;CAC/D,MAAM,EAAE,SAAS,gBAAgB;CAEjC,OAAO,OAAO,UAAU,SAAS,WAAW;AAC9C"}
|
|
@@ -2,7 +2,7 @@ import { logger } from "../utils/logger.js";
|
|
|
2
2
|
import { FALLBACK_CATALOG, FALLBACK_NOTE } from "./fallback-catalog.js";
|
|
3
3
|
//#region src/xulux/catalog-client.ts
|
|
4
4
|
const DEFAULT_CATALOG_URL = "https://www.assistant-ui.com/api/xulux/mcp-catalog";
|
|
5
|
-
const CATALOG_TTL_MS =
|
|
5
|
+
const CATALOG_TTL_MS = 3e5;
|
|
6
6
|
function getCatalogUrl() {
|
|
7
7
|
return process.env.XULUX_CATALOG_URL?.trim() || "https://www.assistant-ui.com/api/xulux/mcp-catalog";
|
|
8
8
|
}
|