@assistant-ui/mcp-docs-server 0.1.31 → 0.1.33
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 +23 -25
- package/.docs/organized/code-examples/with-a2a.md +28 -28
- package/.docs/organized/code-examples/with-ag-ui.md +35 -30
- package/.docs/organized/code-examples/with-ai-sdk-v6.md +16 -14
- package/.docs/organized/code-examples/with-artifacts.md +44 -38
- package/.docs/organized/code-examples/with-assistant-transport.md +68 -56
- package/.docs/organized/code-examples/with-browser-extension.md +357 -0
- package/.docs/organized/code-examples/with-chain-of-thought.md +425 -90
- package/.docs/organized/code-examples/with-cloud-standalone.md +30 -29
- package/.docs/organized/code-examples/with-cloud.md +16 -14
- package/.docs/organized/code-examples/with-custom-thread-list.md +19 -17
- package/.docs/organized/code-examples/with-elevenlabs-conversational.md +29 -26
- package/.docs/organized/code-examples/with-elevenlabs-scribe.md +20 -18
- package/.docs/organized/code-examples/with-expo.md +37 -31
- package/.docs/organized/code-examples/with-external-store.md +13 -11
- package/.docs/organized/code-examples/with-ffmpeg.md +327 -290
- package/.docs/organized/code-examples/with-generative-ui.md +1195 -194
- package/.docs/organized/code-examples/with-google-adk.md +13 -11
- package/.docs/organized/code-examples/with-heat-graph.md +16 -14
- package/.docs/organized/code-examples/with-image-generation.md +456 -0
- package/.docs/organized/code-examples/with-interactables.md +322 -244
- package/.docs/organized/code-examples/with-langchain.md +18 -16
- package/.docs/organized/code-examples/with-langgraph.md +95 -88
- package/.docs/organized/code-examples/with-livekit.md +30 -27
- package/.docs/organized/code-examples/with-mcp.md +754 -0
- package/.docs/organized/code-examples/with-opencode.md +70 -70
- package/.docs/organized/code-examples/with-react-hook-form.md +24 -22
- package/.docs/organized/code-examples/with-react-ink.md +4 -4
- package/.docs/organized/code-examples/with-react-router.md +20 -18
- package/.docs/organized/code-examples/with-resumable-stream.md +661 -0
- package/.docs/organized/code-examples/with-store.md +22 -20
- package/.docs/organized/code-examples/with-tanstack.md +18 -19
- package/.docs/organized/code-examples/with-tap-runtime.md +31 -28
- package/.docs/raw/docs/(docs)/architecture.mdx +43 -2
- package/.docs/raw/docs/(docs)/cli.mdx +2 -2
- package/.docs/raw/docs/(docs)/copilots/model-context.mdx +34 -26
- package/.docs/raw/docs/(docs)/copilots/motivation.mdx +32 -26
- package/.docs/raw/docs/(docs)/index.mdx +2 -2
- package/.docs/raw/docs/(docs)/installation.mdx +2 -2
- package/.docs/raw/docs/(reference)/api-reference/adapters/attachments.mdx +26 -24
- package/.docs/raw/docs/(reference)/api-reference/adapters/feedback.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/index.mdx +20 -12
- package/.docs/raw/docs/(reference)/api-reference/adapters/model.mdx +44 -0
- package/.docs/raw/docs/(reference)/api-reference/adapters/persistence.mdx +41 -16
- package/.docs/raw/docs/(reference)/api-reference/adapters/runtime.mdx +12 -23
- package/.docs/raw/docs/(reference)/api-reference/adapters/suggestions.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/context-providers/assistant-runtime-provider.mdx +37 -8
- package/.docs/raw/docs/(reference)/api-reference/context-providers/index.mdx +11 -9
- package/.docs/raw/docs/(reference)/api-reference/context-providers/scoped-providers.mdx +64 -0
- package/.docs/raw/docs/(reference)/api-reference/external-store/index.mdx +22 -0
- package/.docs/raw/docs/(reference)/api-reference/external-store/message-conversion.mdx +52 -0
- package/.docs/raw/docs/(reference)/api-reference/external-store/runtime.mdx +46 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/index.mdx +18 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/rendering.mdx +33 -0
- package/.docs/raw/docs/(reference)/api-reference/generative-ui/spec.mdx +45 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/composer-triggers.mdx +98 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/index.mdx +18 -13
- package/.docs/raw/docs/(reference)/api-reference/hooks/model-context.mdx +31 -52
- package/.docs/raw/docs/(reference)/api-reference/hooks/primitives.mdx +640 -0
- package/.docs/raw/docs/(reference)/api-reference/hooks/runtimes.mdx +15 -28
- package/.docs/raw/docs/(reference)/api-reference/hooks/state.mdx +64 -18
- package/.docs/raw/docs/(reference)/api-reference/hooks/utilities.mdx +434 -0
- package/.docs/raw/docs/(reference)/api-reference/integrations/cloud-ai-sdk.mdx +24 -0
- package/.docs/raw/docs/(reference)/api-reference/integrations/index.mdx +11 -12
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-ai-sdk.mdx +109 -0
- package/.docs/raw/docs/(reference)/api-reference/model-context/context.mdx +58 -0
- package/.docs/raw/docs/(reference)/api-reference/model-context/index.mdx +22 -0
- package/.docs/raw/docs/(reference)/api-reference/model-context/registry.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/overview.mdx +109 -132
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar-more.mdx +78 -221
- package/.docs/raw/docs/(reference)/api-reference/primitives/action-bar.mdx +127 -242
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-if.mdx +39 -20
- package/.docs/raw/docs/(reference)/api-reference/primitives/assistant-modal.mdx +66 -87
- package/.docs/raw/docs/(reference)/api-reference/primitives/attachment.mdx +50 -58
- package/.docs/raw/docs/(reference)/api-reference/primitives/branch-picker.mdx +80 -48
- package/.docs/raw/docs/(reference)/api-reference/primitives/chain-of-thought.mdx +67 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/composer.mdx +323 -461
- package/.docs/raw/docs/(reference)/api-reference/primitives/error.mdx +36 -43
- package/.docs/raw/docs/(reference)/api-reference/primitives/index.mdx +29 -24
- package/.docs/raw/docs/(reference)/api-reference/primitives/message-part.mdx +63 -245
- package/.docs/raw/docs/(reference)/api-reference/primitives/message.mdx +202 -588
- package/.docs/raw/docs/(reference)/api-reference/primitives/queue-item.mdx +65 -0
- package/.docs/raw/docs/(reference)/api-reference/primitives/selection-toolbar.mdx +35 -22
- package/.docs/raw/docs/(reference)/api-reference/primitives/suggestion.mdx +57 -140
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item-more.mdx +70 -161
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list-item.mdx +84 -108
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread-list.mdx +77 -96
- package/.docs/raw/docs/(reference)/api-reference/primitives/thread.mdx +173 -349
- package/.docs/raw/docs/(reference)/api-reference/runtimes/assistant-runtime.mdx +9 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/attachment-runtime.mdx +10 -21
- package/.docs/raw/docs/(reference)/api-reference/runtimes/composer-runtime.mdx +15 -70
- package/.docs/raw/docs/(reference)/api-reference/runtimes/index.mdx +18 -13
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-part-runtime.mdx +25 -28
- package/.docs/raw/docs/(reference)/api-reference/runtimes/message-runtime.mdx +11 -63
- package/.docs/raw/docs/(reference)/api-reference/runtimes/queue-state.mdx +20 -0
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-item-runtime.mdx +11 -48
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-list-runtime.mdx +10 -47
- package/.docs/raw/docs/(reference)/api-reference/runtimes/thread-runtime.mdx +18 -30
- package/.docs/raw/docs/(reference)/api-reference/tools/component-tools.mdx +85 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/index.mdx +39 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/rendering.mdx +127 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/status.mdx +42 -0
- package/.docs/raw/docs/(reference)/api-reference/tools/toolkits.mdx +91 -0
- package/.docs/raw/docs/(reference)/api-reference/transport/assistant-transport.mdx +48 -0
- package/.docs/raw/docs/(reference)/api-reference/transport/frame.mdx +62 -0
- package/.docs/raw/docs/(reference)/api-reference/transport/index.mdx +22 -0
- package/.docs/raw/docs/(reference)/api-reference/utilities/index.mdx +19 -0
- package/.docs/raw/docs/(reference)/api-reference/utilities/miscellaneous.mdx +143 -0
- package/.docs/raw/docs/(reference)/api-reference/voice/index.mdx +22 -0
- package/.docs/raw/docs/(reference)/api-reference/voice/session.mdx +54 -0
- package/.docs/raw/docs/(reference)/api-reference/voice/speech-dictation.mdx +36 -0
- package/.docs/raw/docs/cloud/ai-sdk.mdx +1 -3
- package/.docs/raw/docs/cloud/index.mdx +2 -2
- package/.docs/raw/docs/guides/attachments.mdx +4 -4
- package/.docs/raw/docs/guides/branching.mdx +1 -1
- package/.docs/raw/docs/guides/chain-of-thought.mdx +12 -14
- package/.docs/raw/docs/guides/context-api.mdx +6 -5
- package/.docs/raw/docs/guides/dictation.mdx +2 -2
- package/.docs/raw/docs/guides/editing.mdx +1 -1
- package/.docs/raw/docs/guides/image-generation.mdx +74 -0
- package/.docs/raw/docs/guides/index.mdx +5 -14
- package/.docs/raw/docs/guides/latex.mdx +2 -2
- package/.docs/raw/docs/guides/mentions.mdx +6 -6
- package/.docs/raw/docs/guides/message-timing.mdx +38 -5
- package/.docs/raw/docs/guides/quoting.mdx +1 -1
- package/.docs/raw/docs/guides/resumable-stream-deployment.mdx +212 -0
- package/.docs/raw/docs/guides/resumable-stream-stores.mdx +152 -0
- package/.docs/raw/docs/guides/resumable-streams.mdx +210 -0
- package/.docs/raw/docs/guides/slash-commands.mdx +2 -2
- package/.docs/raw/docs/guides/speech.mdx +2 -2
- package/.docs/raw/docs/guides/suggestions.mdx +89 -5
- package/.docs/raw/docs/guides/voice.mdx +2 -2
- package/.docs/raw/docs/ink/adapters.mdx +37 -1
- package/.docs/raw/docs/ink/custom-backend.mdx +59 -8
- package/.docs/raw/docs/ink/hooks.mdx +98 -85
- package/.docs/raw/docs/ink/index.mdx +10 -11
- package/.docs/raw/docs/ink/migration.mdx +1 -1
- package/.docs/raw/docs/ink/primitives.mdx +350 -9
- 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/ai-sdk.mdx +3 -3
- package/.docs/raw/docs/integrations/frameworks/cloudflare-agents/overview.mdx +282 -0
- package/.docs/raw/docs/integrations/frameworks/mastra/overview.mdx +2 -2
- package/.docs/raw/docs/integrations/frameworks/mastra/separate-server.mdx +1 -1
- package/.docs/raw/docs/integrations/gateways/index.mdx +9 -4
- package/.docs/raw/docs/integrations/index.mdx +17 -5
- package/.docs/raw/docs/integrations/observability/langfuse.mdx +8 -1
- package/.docs/raw/docs/integrations/observability/langsmith.mdx +8 -4
- package/.docs/raw/docs/integrations/persistence/custom-adapter.mdx +17 -2
- package/.docs/raw/docs/migrations/toolkit-tools.mdx +226 -0
- package/.docs/raw/docs/primitives/chain-of-thought.mdx +10 -16
- package/.docs/raw/docs/primitives/composer.mdx +53 -0
- package/.docs/raw/docs/primitives/index.mdx +2 -2
- package/.docs/raw/docs/primitives/message.mdx +9 -10
- package/.docs/raw/docs/primitives/suggestion.mdx +9 -0
- package/.docs/raw/docs/react-native/hooks.mdx +57 -82
- package/.docs/raw/docs/react-native/index.mdx +4 -4
- package/.docs/raw/docs/react-native/migration.mdx +1 -1
- package/.docs/raw/docs/react-native/primitives.mdx +2 -2
- package/.docs/raw/docs/runtimes/a2a/client-and-hooks.mdx +7 -4
- package/.docs/raw/docs/runtimes/a2a/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/ag-ui/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/ag-ui/runtime-options.mdx +32 -1
- package/.docs/raw/docs/runtimes/ai-sdk/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/ai-sdk/v4-legacy.mdx +7 -2
- package/.docs/raw/docs/runtimes/ai-sdk/v5-legacy.mdx +1 -1
- package/.docs/raw/docs/runtimes/ai-sdk/v6.mdx +129 -1
- package/.docs/raw/docs/runtimes/concepts/threads.mdx +7 -1
- package/.docs/raw/docs/runtimes/custom/data-stream.mdx +27 -2
- package/.docs/raw/docs/runtimes/custom/external-store.mdx +9 -1
- package/.docs/raw/docs/runtimes/custom/local-runtime.mdx +18 -7
- package/.docs/raw/docs/runtimes/custom/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/google-adk/hooks.mdx +108 -38
- package/.docs/raw/docs/runtimes/google-adk/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/langchain.mdx +2 -2
- package/.docs/raw/docs/runtimes/langgraph/generative-ui.mdx +2 -2
- package/.docs/raw/docs/runtimes/langgraph/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/langgraph/streaming.mdx +1 -1
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-2.mdx +64 -50
- package/.docs/raw/docs/runtimes/langgraph/tutorial/part-3.mdx +98 -86
- package/.docs/raw/docs/runtimes/opencode/overview.mdx +2 -2
- package/.docs/raw/docs/runtimes/opencode/quickstart.mdx +1 -1
- package/.docs/raw/docs/runtimes/pick-a-runtime.mdx +12 -5
- package/.docs/raw/docs/tools/backend.mdx +136 -0
- package/.docs/raw/docs/tools/defining-tools.mdx +413 -0
- package/.docs/raw/docs/tools/dynamic-tools.mdx +110 -0
- package/.docs/raw/docs/tools/generative-ui.mdx +214 -0
- package/.docs/raw/docs/tools/index.mdx +76 -0
- package/.docs/raw/docs/{guides → tools}/interactables.mdx +3 -3
- package/.docs/raw/docs/tools/mcp-apps.mdx +231 -0
- package/.docs/raw/docs/{integrations/tools → tools}/mcp.mdx +77 -50
- package/.docs/raw/docs/{guides → tools}/multi-agent.mdx +19 -21
- package/.docs/raw/docs/tools/tool-ui.mdx +967 -0
- package/.docs/raw/docs/tools/user-managed-mcp.mdx +337 -0
- package/.docs/raw/docs/ui/composer-trigger-popover.mdx +11 -1
- package/.docs/raw/docs/ui/directive-text.mdx +3 -3
- package/.docs/raw/docs/ui/mcp-config.mdx +102 -0
- package/.docs/raw/docs/ui/model-selector.mdx +8 -8
- package/.docs/raw/docs/ui/part-grouping.mdx +84 -50
- package/.docs/raw/docs/ui/reasoning.mdx +4 -5
- package/.docs/raw/docs/ui/sources.mdx +17 -0
- package/.docs/raw/docs/ui/streamdown.mdx +34 -2
- package/.docs/raw/docs/ui/thread-list.mdx +2 -2
- package/.docs/raw/docs/ui/thread.mdx +2 -2
- package/.docs/raw/docs/ui/tool-group.mdx +5 -6
- package/.docs/raw/docs/utilities/heat-graph.mdx +1 -1
- package/README.md +14 -72
- package/dist/constants.d.ts +12 -9
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +13 -9
- package/dist/constants.js.map +1 -1
- package/dist/index.d.ts +7 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -24
- package/dist/index.js.map +1 -1
- package/dist/prepare-docs/code-examples.d.ts +4 -1
- package/dist/prepare-docs/code-examples.d.ts.map +1 -1
- package/dist/prepare-docs/code-examples.js +109 -121
- package/dist/prepare-docs/code-examples.js.map +1 -1
- package/dist/prepare-docs/copy-raw.d.ts +4 -1
- package/dist/prepare-docs/copy-raw.d.ts.map +1 -1
- package/dist/prepare-docs/copy-raw.js +45 -42
- package/dist/prepare-docs/copy-raw.js.map +1 -1
- package/dist/prepare-docs/prepare.d.ts +1 -2
- package/dist/prepare-docs/prepare.js +17 -17
- package/dist/prepare-docs/prepare.js.map +1 -1
- package/dist/stdio.d.ts +1 -3
- package/dist/stdio.js +6 -3
- package/dist/stdio.js.map +1 -1
- package/dist/tools/docs.d.ts +20 -15
- package/dist/tools/docs.d.ts.map +1 -1
- package/dist/tools/docs.js +140 -161
- package/dist/tools/docs.js.map +1 -1
- package/dist/tools/examples.d.ts +20 -15
- package/dist/tools/examples.d.ts.map +1 -1
- package/dist/tools/examples.js +74 -86
- package/dist/tools/examples.js.map +1 -1
- package/dist/tools/tests/test-setup.d.ts +5 -2
- package/dist/tools/tests/test-setup.d.ts.map +1 -1
- package/dist/tools/tests/test-setup.js +21 -28
- package/dist/tools/tests/test-setup.js.map +1 -1
- package/dist/utils/logger.d.ts +8 -5
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +17 -17
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/mcp-format.d.ts +8 -5
- package/dist/utils/mcp-format.d.ts.map +1 -1
- package/dist/utils/mcp-format.js +9 -9
- package/dist/utils/mcp-format.js.map +1 -1
- package/dist/utils/mdx.d.ts +8 -6
- package/dist/utils/mdx.d.ts.map +1 -1
- package/dist/utils/mdx.js +22 -22
- package/dist/utils/mdx.js.map +1 -1
- package/dist/utils/paths.d.ts +9 -6
- package/dist/utils/paths.d.ts.map +1 -1
- package/dist/utils/paths.js +66 -76
- package/dist/utils/paths.js.map +1 -1
- package/dist/utils/security.d.ts +4 -1
- package/dist/utils/security.d.ts.map +1 -1
- package/dist/utils/security.js +19 -40
- package/dist/utils/security.js.map +1 -1
- package/package.json +5 -5
- package/.docs/organized/code-examples/with-parent-id-grouping.md +0 -596
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool-ui.mdx +0 -151
- package/.docs/raw/docs/(docs)/copilots/make-assistant-tool.mdx +0 -230
- package/.docs/raw/docs/(reference)/api-reference/adapters/feedback-speech.mdx +0 -41
- package/.docs/raw/docs/(reference)/api-reference/context-providers/text-message-part-provider.mdx +0 -40
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-data-stream.mdx +0 -260
- package/.docs/raw/docs/(reference)/api-reference/integrations/react-hook-form.mdx +0 -103
- package/.docs/raw/docs/(reference)/api-reference/integrations/vercel-ai-sdk.mdx +0 -254
- package/.docs/raw/docs/guides/tool-ui.mdx +0 -858
- package/.docs/raw/docs/guides/tools.mdx +0 -675
- package/dist/prepare-docs/prepare.d.ts.map +0 -1
- package/dist/stdio.d.ts.map +0 -1
- /package/.docs/raw/docs/{(reference)/migrations → migrations}/deprecation-policy.mdx +0 -0
- /package/.docs/raw/docs/{(reference) → migrations}/react-compatibility.mdx +0 -0
- /package/.docs/raw/docs/{(reference)/migrations → migrations}/react-langgraph-v0-7.mdx +0 -0
- /package/.docs/raw/docs/{(reference)/migrations → migrations}/v0-11.mdx +0 -0
- /package/.docs/raw/docs/{(reference)/migrations → migrations}/v0-12.mdx +0 -0
- /package/.docs/raw/docs/{(reference)/migrations → migrations}/v0-14.mdx +0 -0
package/dist/tools/docs.d.ts
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import { z } from "zod/v3";
|
|
2
|
+
|
|
3
|
+
//#region src/tools/docs.d.ts
|
|
2
4
|
declare const docsInputSchema: z.ZodObject<{
|
|
3
|
-
|
|
5
|
+
paths: z.ZodArray<z.ZodString, "many">;
|
|
4
6
|
}, "strip", z.ZodTypeAny, {
|
|
5
|
-
|
|
7
|
+
paths: string[];
|
|
6
8
|
}, {
|
|
7
|
-
|
|
9
|
+
paths: string[];
|
|
8
10
|
}>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
declare const docsTools: {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
parameters: {
|
|
15
|
+
paths: z.ZodArray<z.ZodString, "many">;
|
|
16
|
+
};
|
|
17
|
+
execute: ({
|
|
18
|
+
paths
|
|
19
|
+
}: z.infer<typeof docsInputSchema>) => Promise<{
|
|
20
|
+
content: Array<{
|
|
21
|
+
type: "text";
|
|
22
|
+
text: string;
|
|
20
23
|
}>;
|
|
24
|
+
}>;
|
|
21
25
|
};
|
|
22
|
-
|
|
26
|
+
//#endregion
|
|
27
|
+
export { docsTools };
|
|
23
28
|
//# sourceMappingURL=docs.d.ts.map
|
package/dist/tools/docs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.d.ts","
|
|
1
|
+
{"version":3,"file":"docs.d.ts","names":[],"sources":["../../src/tools/docs.ts"],"mappings":";;;cAeM,eAAA,EAAe,CAAA,CAAA,SAAA;;;;;;;cAoJR,SAAA;;;;;;;;KAKgB,CAAA,CAAE,KAAA,QAAa,eAAA,MAAgB,OAAA"}
|
package/dist/tools/docs.js
CHANGED
|
@@ -1,168 +1,147 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { stat, lstat } from "node:fs/promises";
|
|
3
|
-
import { join, extname } from "node:path";
|
|
4
|
-
import { DOCS_PATH, MDX_EXTENSION, MAX_FILE_SIZE } from "../constants.js";
|
|
1
|
+
import { DOCS_PATH, MAX_FILE_SIZE, MDX_EXTENSION } from "../constants.js";
|
|
5
2
|
import { logger } from "../utils/logger.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
import { findNearestPaths, getAvailablePaths, listDirContents, pathExists } from "../utils/paths.js";
|
|
4
|
+
import { formatMDXContent, readMDXFile } from "../utils/mdx.js";
|
|
8
5
|
import { formatMCPResponse } from "../utils/mcp-format.js";
|
|
9
6
|
import { sanitizePath } from "../utils/security.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
7
|
+
import { extname, join } from "node:path";
|
|
8
|
+
import { z } from "zod/v3";
|
|
9
|
+
import { lstat, stat } from "node:fs/promises";
|
|
10
|
+
//#region src/tools/docs.ts
|
|
11
|
+
const docsInputSchema = z.object({ paths: z.array(z.string()).min(1).describe("Documentation paths to retrieve (e.g., [\"getting-started\", \"api-reference/primitives/thread\"])") });
|
|
16
12
|
async function readDocumentation(docPath) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
path: docPath,
|
|
114
|
-
found: false,
|
|
115
|
-
suggestions,
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
if (error instanceof Error && error.message.includes("Invalid path")) {
|
|
120
|
-
return {
|
|
121
|
-
path: docPath,
|
|
122
|
-
found: false,
|
|
123
|
-
error: error.message,
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
throw error;
|
|
127
|
-
}
|
|
13
|
+
logger.debug(`Reading documentation for path: ${docPath}`);
|
|
14
|
+
if (docPath === "/" || docPath === "") {
|
|
15
|
+
const { directories, files } = await listDirContents(DOCS_PATH);
|
|
16
|
+
return {
|
|
17
|
+
path: "/",
|
|
18
|
+
found: true,
|
|
19
|
+
type: "directory",
|
|
20
|
+
directories,
|
|
21
|
+
files: files.map((f) => f.replace(MDX_EXTENSION, ""))
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
const fullPath = join(DOCS_PATH, sanitizePath(docPath));
|
|
26
|
+
try {
|
|
27
|
+
if ((await lstat(fullPath)).isSymbolicLink()) {
|
|
28
|
+
logger.warn(`Symlink detected at path: ${fullPath}`);
|
|
29
|
+
return {
|
|
30
|
+
path: docPath,
|
|
31
|
+
found: false,
|
|
32
|
+
error: "Symlinks are not allowed for security reasons"
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
} catch {}
|
|
36
|
+
if (await pathExists(fullPath)) {
|
|
37
|
+
const stats = await stat(fullPath);
|
|
38
|
+
if (stats.isFile() && stats.size > 10485760) {
|
|
39
|
+
logger.warn(`File too large: ${fullPath} (${stats.size} bytes)`);
|
|
40
|
+
return {
|
|
41
|
+
path: docPath,
|
|
42
|
+
found: false,
|
|
43
|
+
error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
if (stats.isDirectory()) {
|
|
47
|
+
const { directories, files } = await listDirContents(fullPath);
|
|
48
|
+
const contents = {};
|
|
49
|
+
for (const file of files) {
|
|
50
|
+
const mdxContent = await readMDXFile(join(fullPath, file));
|
|
51
|
+
if (mdxContent) {
|
|
52
|
+
const fileName = file.replace(MDX_EXTENSION, "");
|
|
53
|
+
contents[fileName] = formatMDXContent(mdxContent);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const content = Object.keys(contents).length > 0 ? JSON.stringify(contents, null, 2) : void 0;
|
|
57
|
+
return {
|
|
58
|
+
path: docPath,
|
|
59
|
+
found: true,
|
|
60
|
+
type: "directory",
|
|
61
|
+
directories,
|
|
62
|
+
files: files.map((f) => f.replace(MDX_EXTENSION, "")),
|
|
63
|
+
...content !== void 0 && { content }
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const mdxPath = extname(fullPath) === ".mdx" ? fullPath : `${fullPath}${MDX_EXTENSION}`;
|
|
68
|
+
try {
|
|
69
|
+
const mdxLstats = await lstat(mdxPath);
|
|
70
|
+
if (mdxLstats.isSymbolicLink()) {
|
|
71
|
+
logger.warn(`Symlink detected at MDX path: ${mdxPath}`);
|
|
72
|
+
return {
|
|
73
|
+
path: docPath,
|
|
74
|
+
found: false,
|
|
75
|
+
error: "Symlinks are not allowed for security reasons"
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (mdxLstats.size > 10485760) {
|
|
79
|
+
logger.warn(`MDX file too large: ${mdxPath} (${mdxLstats.size} bytes)`);
|
|
80
|
+
return {
|
|
81
|
+
path: docPath,
|
|
82
|
+
found: false,
|
|
83
|
+
error: `File size exceeds maximum allowed size of ${MAX_FILE_SIZE} bytes`
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
} catch {}
|
|
87
|
+
if (await pathExists(mdxPath)) {
|
|
88
|
+
const mdxContent = await readMDXFile(mdxPath);
|
|
89
|
+
if (mdxContent) return {
|
|
90
|
+
path: docPath,
|
|
91
|
+
found: true,
|
|
92
|
+
type: "file",
|
|
93
|
+
content: formatMDXContent(mdxContent)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
path: docPath,
|
|
98
|
+
found: false,
|
|
99
|
+
suggestions: findNearestPaths(docPath, await getAvailablePaths())
|
|
100
|
+
};
|
|
101
|
+
} catch (error) {
|
|
102
|
+
if (error instanceof Error && error.message.includes("Invalid path")) return {
|
|
103
|
+
path: docPath,
|
|
104
|
+
found: false,
|
|
105
|
+
error: error.message
|
|
106
|
+
};
|
|
107
|
+
throw error;
|
|
108
|
+
}
|
|
128
109
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
error: "Failed to retrieve documentation",
|
|
163
|
-
message: error instanceof Error ? error.message : String(error),
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
},
|
|
110
|
+
const docsTools = {
|
|
111
|
+
name: "assistantUIDocs",
|
|
112
|
+
description: "Retrieve assistant-ui documentation by path. Use \"/\" to list all sections. Supports multiple paths in a single request.",
|
|
113
|
+
parameters: docsInputSchema.shape,
|
|
114
|
+
execute: async ({ paths }) => {
|
|
115
|
+
logger.info(`Retrieving documentation for paths: ${paths.join(", ")}`);
|
|
116
|
+
try {
|
|
117
|
+
const results = await Promise.all(paths.map((path) => readDocumentation(path)));
|
|
118
|
+
if (results.length === 1) {
|
|
119
|
+
const result = results[0];
|
|
120
|
+
if (result.error) return formatMCPResponse({
|
|
121
|
+
error: result.error,
|
|
122
|
+
path: result.path
|
|
123
|
+
});
|
|
124
|
+
if (!result.found) return formatMCPResponse({
|
|
125
|
+
error: `Documentation not found for path: ${result.path}`,
|
|
126
|
+
suggestions: result.suggestions,
|
|
127
|
+
hint: "Use \"/\" to list all available documentation sections"
|
|
128
|
+
});
|
|
129
|
+
return formatMCPResponse(result);
|
|
130
|
+
}
|
|
131
|
+
return formatMCPResponse({
|
|
132
|
+
results,
|
|
133
|
+
summary: `Retrieved ${results.filter((r) => r.found).length} of ${results.length} requested paths`
|
|
134
|
+
});
|
|
135
|
+
} catch (error) {
|
|
136
|
+
logger.error("Failed to retrieve documentation", error);
|
|
137
|
+
return formatMCPResponse({
|
|
138
|
+
error: "Failed to retrieve documentation",
|
|
139
|
+
message: error instanceof Error ? error.message : String(error)
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
167
143
|
};
|
|
144
|
+
//#endregion
|
|
145
|
+
export { docsTools };
|
|
146
|
+
|
|
168
147
|
//# sourceMappingURL=docs.js.map
|
package/dist/tools/docs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docs.js","
|
|
1
|
+
{"version":3,"file":"docs.js","names":[],"sources":["../../src/tools/docs.ts"],"sourcesContent":["import { z } from \"zod/v3\";\nimport { stat, lstat } from \"node:fs/promises\";\nimport { join, extname } from \"node:path\";\nimport { DOCS_PATH, MDX_EXTENSION, MAX_FILE_SIZE } 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 suggestions?: 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 for (const file of files) {\n const mdxContent = await readMDXFile(join(fullPath, file));\n if (mdxContent) {\n const fileName = file.replace(MDX_EXTENSION, \"\");\n contents[fileName] = formatMDXContent(mdxContent);\n }\n }\n\n const content =\n 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 ...(content !== undefined && { content }),\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 return {\n path: docPath,\n found: true,\n type: \"file\",\n content: formatMDXContent(mdxContent),\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.shape,\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.d.ts
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import { z } from "zod/v3";
|
|
2
|
+
|
|
3
|
+
//#region src/tools/examples.d.ts
|
|
2
4
|
declare const examplesInputSchema: z.ZodObject<{
|
|
3
|
-
|
|
5
|
+
example: z.ZodOptional<z.ZodString>;
|
|
4
6
|
}, "strip", z.ZodTypeAny, {
|
|
5
|
-
|
|
7
|
+
example?: string | undefined;
|
|
6
8
|
}, {
|
|
7
|
-
|
|
9
|
+
example?: string | undefined;
|
|
8
10
|
}>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
declare const examplesTools: {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
parameters: {
|
|
15
|
+
example: z.ZodOptional<z.ZodString>;
|
|
16
|
+
};
|
|
17
|
+
execute: ({
|
|
18
|
+
example
|
|
19
|
+
}: z.infer<typeof examplesInputSchema>) => Promise<{
|
|
20
|
+
content: Array<{
|
|
21
|
+
type: "text";
|
|
22
|
+
text: string;
|
|
20
23
|
}>;
|
|
24
|
+
}>;
|
|
21
25
|
};
|
|
22
|
-
|
|
26
|
+
//#endregion
|
|
27
|
+
export { examplesTools };
|
|
23
28
|
//# sourceMappingURL=examples.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"examples.d.ts","
|
|
1
|
+
{"version":3,"file":"examples.d.ts","names":[],"sources":["../../src/tools/examples.ts"],"mappings":";;;cAQM,mBAAA,EAAmB,CAAA,CAAA,SAAA;;;;;;;cA8CZ,aAAA;;;;;;;;KAKkB,CAAA,CAAE,KAAA,QAAa,mBAAA,MAAoB,OAAA"}
|
package/dist/tools/examples.js
CHANGED
|
@@ -1,95 +1,83 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { readFile, readdir, lstat } from "node:fs/promises";
|
|
3
|
-
import { join, extname } from "node:path";
|
|
4
|
-
import { CODE_EXAMPLES_PATH, MAX_FILE_SIZE } from "../constants.js";
|
|
1
|
+
import { CODE_EXAMPLES_PATH } from "../constants.js";
|
|
5
2
|
import { logger } from "../utils/logger.js";
|
|
6
3
|
import { formatMCPResponse } from "../utils/mcp-format.js";
|
|
7
4
|
import { sanitizePath } from "../utils/security.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
5
|
+
import { extname, join } from "node:path";
|
|
6
|
+
import { z } from "zod/v3";
|
|
7
|
+
import { lstat, readFile, readdir } from "node:fs/promises";
|
|
8
|
+
//#region src/tools/examples.ts
|
|
9
|
+
const examplesInputSchema = z.object({ example: z.string().optional().describe("Example name (e.g., \"with-ai-sdk-v6\"). Leave empty to list all examples.") });
|
|
14
10
|
async function listCodeExamples() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
logger.error("Failed to list code examples", error);
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
11
|
+
try {
|
|
12
|
+
return (await readdir(CODE_EXAMPLES_PATH)).filter((file) => extname(file) === ".md").map((file) => file.replace(".md", "")).sort();
|
|
13
|
+
} catch (error) {
|
|
14
|
+
logger.error("Failed to list code examples", error);
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
26
17
|
}
|
|
27
18
|
async function readCodeExample(exampleName) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
logger.error(`Failed to read example: ${exampleName}`, error);
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
19
|
+
try {
|
|
20
|
+
const filePath = join(CODE_EXAMPLES_PATH, `${sanitizePath(exampleName)}.md`);
|
|
21
|
+
const stats = await lstat(filePath);
|
|
22
|
+
if (stats.isSymbolicLink()) {
|
|
23
|
+
logger.warn(`Attempted to read symlink: ${filePath}`);
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
if (stats.size > 10485760) {
|
|
27
|
+
logger.warn(`File size exceeds limit: ${filePath} (${stats.size} bytes)`);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
return await readFile(filePath, "utf-8");
|
|
31
|
+
} catch (error) {
|
|
32
|
+
logger.error(`Failed to read example: ${exampleName}`, error);
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
47
35
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
},
|
|
36
|
+
const examplesTools = {
|
|
37
|
+
name: "assistantUIExamples",
|
|
38
|
+
description: "List available examples or retrieve complete code for a specific example",
|
|
39
|
+
parameters: examplesInputSchema.shape,
|
|
40
|
+
execute: async ({ example }) => {
|
|
41
|
+
try {
|
|
42
|
+
if (!example) {
|
|
43
|
+
logger.info("Listing all available examples");
|
|
44
|
+
const examples = await listCodeExamples();
|
|
45
|
+
if (examples.length === 0) return formatMCPResponse({
|
|
46
|
+
error: "No examples found. Please run documentation preparation first.",
|
|
47
|
+
hint: "Run: pnpm prepare-docs"
|
|
48
|
+
});
|
|
49
|
+
return formatMCPResponse({
|
|
50
|
+
type: "list",
|
|
51
|
+
examples,
|
|
52
|
+
total: examples.length,
|
|
53
|
+
hint: "Use example parameter to get complete code for any example"
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
logger.info(`Retrieving example: ${example}`);
|
|
57
|
+
const content = await readCodeExample(example);
|
|
58
|
+
if (!content) {
|
|
59
|
+
const availableExamples = await listCodeExamples();
|
|
60
|
+
return formatMCPResponse({
|
|
61
|
+
error: `Example not found: ${example}`,
|
|
62
|
+
availableExamples,
|
|
63
|
+
hint: "Use without example parameter to list all available examples"
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
return formatMCPResponse({
|
|
67
|
+
type: "example",
|
|
68
|
+
name: example,
|
|
69
|
+
content
|
|
70
|
+
});
|
|
71
|
+
} catch (error) {
|
|
72
|
+
logger.error("Failed to retrieve examples", error);
|
|
73
|
+
return formatMCPResponse({
|
|
74
|
+
error: "Failed to retrieve examples",
|
|
75
|
+
message: error instanceof Error ? error.message : String(error)
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
94
79
|
};
|
|
80
|
+
//#endregion
|
|
81
|
+
export { examplesTools };
|
|
82
|
+
|
|
95
83
|
//# sourceMappingURL=examples.js.map
|