@blade-hq/agent-react 2612.0.0-beta.8 → 2612.0.0-beta.80
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/README.md +47 -0
- package/dist/SessionPluginConfigForm-7LJ5SUNY.js +9 -0
- package/dist/SessionPluginConfigForm-7LJ5SUNY.js.map +1 -0
- package/dist/chat/AgentLoopBlock.d.ts +0 -2
- package/dist/chat/AskUserQuestionBlock.d.ts +3 -20
- package/dist/chat/AssistantTurnBlock.d.ts +1 -9
- package/dist/chat/AttachmentPreviewDialog.d.ts +0 -1
- package/dist/chat/ChatLoadingIndicator.d.ts +7 -0
- package/dist/chat/ContextAttachmentPills.d.ts +4 -0
- package/dist/chat/CurrentPlanPanel.d.ts +0 -3
- package/dist/chat/FileDeliveryCards.d.ts +0 -4
- package/dist/chat/FinalArtifactCards.d.ts +0 -1
- package/dist/chat/ImageLightbox.d.ts +1 -1
- package/dist/chat/LiteMessageList.d.ts +5 -3
- package/dist/chat/MessageFileAttachmentList.d.ts +0 -5
- package/dist/chat/QuestionnaireQuestionBlock.d.ts +11 -0
- package/dist/chat/SessionReplayBar.d.ts +0 -1
- package/dist/chat/TextAttachmentPills.d.ts +0 -3
- package/dist/chat/TurnNavRail.d.ts +1 -7
- package/dist/chat/WorkflowRunBlock.d.ts +21 -4
- package/dist/chat/ai-elements/shimmer.d.ts +0 -4
- package/dist/chat/customization.d.ts +1 -1
- package/dist/chat/index.d.ts +3 -2
- package/dist/chat/markdown/ExternalAnchor.d.ts +2 -2
- package/dist/chat/markdown/MarkdownContent.d.ts +3 -0
- package/dist/chat/message-list-blocks.d.ts +0 -1
- package/dist/chat/runtime/actions.d.ts +2 -2
- package/dist/chat/runtime/background-task-dismissals.d.ts +0 -1
- package/dist/chat/runtime/composer-channels.d.ts +0 -3
- package/dist/chat/runtime/input-cache-reset.d.ts +0 -5
- package/dist/chat/runtime/input-services.d.ts +10 -0
- package/dist/chat/runtime/session-source.d.ts +0 -5
- package/dist/chat/runtime/use-chat-actions.d.ts +0 -4
- package/dist/chat/turn-locate-channel.d.ts +53 -0
- package/dist/{chat-OCLOVB3H.css → chat-IHPRU35X.css} +5 -18
- package/dist/chat.css +5 -18
- package/dist/chunk-66JXSDLB.js +13770 -0
- package/dist/chunk-66JXSDLB.js.map +1 -0
- package/dist/chunk-C3LBNHVM.js +9482 -0
- package/dist/chunk-C3LBNHVM.js.map +1 -0
- package/dist/chunk-F4MWGSKX.js +1308 -0
- package/dist/chunk-F4MWGSKX.js.map +1 -0
- package/dist/chunk-FBGCDXRK.js +607 -0
- package/dist/chunk-FBGCDXRK.js.map +1 -0
- package/dist/{chunk-67GHJQK5.js → chunk-FDB3J5QF.js} +3889 -26106
- package/dist/chunk-FDB3J5QF.js.map +1 -0
- package/dist/chunk-FH5HA3GW.js +2416 -0
- package/dist/chunk-FH5HA3GW.js.map +1 -0
- package/dist/chunk-KHJEIHMJ.js +973 -0
- package/dist/chunk-KHJEIHMJ.js.map +1 -0
- package/dist/chunk-MWILWSPG.js +9629 -0
- package/dist/chunk-MWILWSPG.js.map +1 -0
- package/dist/chunk-NRYLAO3X.js +3978 -0
- package/dist/chunk-NRYLAO3X.js.map +1 -0
- package/dist/{chunk-MERN5XEM.js → chunk-SK43YNRX.js} +4181 -16594
- package/dist/chunk-SK43YNRX.js.map +1 -0
- package/dist/components/AccountConnectorRules.d.ts +7 -0
- package/dist/components/AccountConnectors.d.ts +13 -0
- package/dist/components/BrowserConnectionDialog.d.ts +8 -0
- package/dist/components/ChatInput.d.ts +1 -15
- package/dist/components/ConfigConnection.d.ts +16 -0
- package/dist/components/ConnectorAuthorizationProgress.d.ts +6 -0
- package/dist/components/ConnectorConnection.d.ts +4 -0
- package/dist/components/ConnectorDetail.d.ts +46 -0
- package/dist/components/ConnectorPanel.d.ts +3 -1
- package/dist/components/ConnectorRulesPanel.d.ts +10 -0
- package/dist/components/ConnectorRuntimeDiagnostics.d.ts +5 -0
- package/dist/components/DeviceConnection.d.ts +17 -0
- package/dist/components/FeishuCapabilitySelection.d.ts +14 -0
- package/dist/components/FeishuPermissionStatus.d.ts +7 -0
- package/dist/components/LlmAdvancedSettings.d.ts +0 -1
- package/dist/components/ManagedConnection.d.ts +12 -0
- package/dist/components/McpAppFrame.d.ts +17 -0
- package/dist/components/PackEventNotice.d.ts +3 -0
- package/dist/components/PlanUpdateBlock.d.ts +0 -1
- package/dist/components/SessionPluginConfigForm.d.ts +4 -1
- package/dist/components/SessionPluginIcon.d.ts +1 -0
- package/dist/components/plugin-connector.d.ts +1 -0
- package/dist/connectors.d.ts +6 -0
- package/dist/connectors.js +19 -0
- package/dist/connectors.js.map +1 -0
- package/dist/embed/blade-chat-element.d.ts +0 -8
- package/dist/embed/entry.d.ts +13 -19
- package/dist/hooks/use-message-pin.d.ts +1 -1
- package/dist/hooks/use-turn-navigation.d.ts +19 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +23 -3
- package/dist/internal.d.ts +7 -3
- package/dist/internal.js +59 -71
- package/dist/internal.js.map +1 -1
- package/dist/lib/message-shortcuts.d.ts +5 -0
- package/dist/questions.d.ts +7 -0
- package/dist/questions.js +910 -0
- package/dist/questions.js.map +1 -0
- package/dist/rich-input/ConnectButton.d.ts +7 -5
- package/dist/rich-input/FileCompletionMenu.d.ts +1 -2
- package/dist/rich-input/InputActionSubmenu.d.ts +10 -0
- package/dist/rich-input/SkillActionMenu.d.ts +10 -0
- package/dist/rich-input/SkillStatusBar.d.ts +0 -6
- package/dist/rich-input/extensions/skill-mention.d.ts +3 -20
- package/dist/rich-input/index.d.ts +3 -2
- package/dist/rich-input/lib/composer-content.d.ts +5 -1
- package/dist/rich-input/lib/plugin-suggestions.d.ts +5 -5
- package/dist/rich-input/lib/reference-candidates.d.ts +0 -1
- package/dist/rich-input/lib/skill-suggestions.d.ts +1 -1
- package/dist/rich-input/lib/user-home.d.ts +0 -17
- package/dist/rich-input/services.d.ts +1 -1
- package/dist/rich-input/voice/VoiceWaveform.d.ts +0 -3
- package/dist/rich-input.js +793 -1068
- package/dist/rich-input.js.map +1 -1
- package/dist/style.css +16 -55
- package/dist/style.full.css +23 -77
- package/dist/tool-details.d.ts +8 -0
- package/dist/tool-details.js +25 -0
- package/dist/tool-details.js.map +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/LICENSE +216 -0
- package/node_modules/@modelcontextprotocol/ext-apps/README.md +284 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/docs/patterns.d.ts +9 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.d.ts +1348 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.examples.d.ts +9 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.js +39 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-bridge.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app-with-deps.js +82 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.d.ts +1214 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.examples.d.ts +9 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.js +39 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/app.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/constants.d.ts +65 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/events.d.ts +47 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/events.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/generated/schema.d.ts +1047 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/generated/schema.json +6170 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/generated/schema.test.d.ts +41 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/interop-v1.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/legacy-handlers.d.ts +66 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/legacy-handlers.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/message-transport.d.ts +126 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/message-transport.examples.d.ts +9 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/message-transport.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/index.d.ts +37 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/index.examples.d.ts +6 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/index.js +39 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/react-with-deps.js +82 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useApp.d.ts +115 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useApp.examples.d.ts +6 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useAutoResize.d.ts +54 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useAutoResize.examples.d.ts +6 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useDocumentTheme.d.ts +44 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useDocumentTheme.examples.d.ts +6 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useHostStyles.d.ts +113 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/react/useHostStyles.examples.d.ts +6 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.d.ts +381 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.examples.d.ts +9 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.js +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/server/index.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/spec.types.d.ts +698 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/standard-schema.d.ts +23 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/styles.d.ts +184 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/styles.examples.d.ts +9 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/types.d.ts +33 -0
- package/node_modules/@modelcontextprotocol/ext-apps/dist/src/wire-compat.test.d.ts +1 -0
- package/node_modules/@modelcontextprotocol/ext-apps/package.json +144 -0
- package/node_modules/@standard-schema/spec/LICENSE +21 -0
- package/node_modules/@standard-schema/spec/README.md +198 -0
- package/node_modules/@standard-schema/spec/dist/index.cjs +18 -0
- package/node_modules/@standard-schema/spec/dist/index.d.cts +119 -0
- package/node_modules/@standard-schema/spec/dist/index.d.ts +119 -0
- package/node_modules/@standard-schema/spec/dist/index.js +0 -0
- package/node_modules/@standard-schema/spec/package.json +52 -0
- package/package.json +19 -3
- package/public-api.md +60 -4
- package/dist/chunk-67GHJQK5.js.map +0 -1
- package/dist/chunk-DPDXGYGM.js +0 -258
- package/dist/chunk-DPDXGYGM.js.map +0 -1
- package/dist/chunk-MERN5XEM.js.map +0 -1
- package/dist/lib/agent-computer-command.d.ts +0 -32
- package/dist/rich-input/extensions/workflow-mention.d.ts +0 -10
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { StandardJSONSchemaV1, StandardSchemaV1, StandardTypedV1 } from "@standard-schema/spec";
|
|
2
|
+
import type { StandardSchemaWithJSON } from "@modelcontextprotocol/client";
|
|
3
|
+
/**
|
|
4
|
+
* A schema that implements both Standard Schema (validation) and Standard JSON
|
|
5
|
+
* Schema (serialization). Zod v4, ArkType, and Valibot (via
|
|
6
|
+
* `@valibot/to-json-schema`) all satisfy this. Re-exported from the SDK so
|
|
7
|
+
* View authors can import it alongside {@link app!App `App`}.
|
|
8
|
+
*
|
|
9
|
+
* @see https://standardschema.dev/
|
|
10
|
+
*/
|
|
11
|
+
export type { StandardJSONSchemaV1, StandardSchemaV1, StandardSchemaWithJSON, StandardTypedV1, };
|
|
12
|
+
/**
|
|
13
|
+
* Serialize a Standard Schema to JSON Schema for the given direction.
|
|
14
|
+
*
|
|
15
|
+
* Requires `~standard.jsonSchema` (zod v4, ArkType, Valibot, …); schemas
|
|
16
|
+
* without it throw.
|
|
17
|
+
*/
|
|
18
|
+
export declare function standardSchemaToJsonSchema(schema: StandardSchemaV1, io: "input" | "output"): Promise<Record<string, unknown>>;
|
|
19
|
+
/**
|
|
20
|
+
* Validate a value against a Standard Schema. Returns the parsed value on
|
|
21
|
+
* success or throws with a formatted issue list (optionally prefixed).
|
|
22
|
+
*/
|
|
23
|
+
export declare function validateStandardSchema<S extends StandardSchemaV1>(schema: S, value: unknown, errorPrefix?: string): Promise<StandardSchemaV1.InferOutput<S>>;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { McpUiStyles, McpUiTheme } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Get the current document theme from the root HTML element.
|
|
4
|
+
*
|
|
5
|
+
* Reads the theme from the `data-theme` attribute on `document.documentElement`.
|
|
6
|
+
* Falls back to checking for a `dark` class for compatibility with Tailwind CSS
|
|
7
|
+
* dark mode conventions.
|
|
8
|
+
*
|
|
9
|
+
* @returns The current theme ("light" or "dark")
|
|
10
|
+
*
|
|
11
|
+
* @example Check current theme
|
|
12
|
+
* ```ts source="./styles.examples.ts#getDocumentTheme_checkCurrent"
|
|
13
|
+
* const theme = getDocumentTheme();
|
|
14
|
+
* document.body.classList.toggle("dark", theme === "dark");
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @see {@link applyDocumentTheme `applyDocumentTheme`} to set the theme
|
|
18
|
+
* @see {@link McpUiTheme `McpUiTheme`} for the theme type
|
|
19
|
+
*/
|
|
20
|
+
export declare function getDocumentTheme(): McpUiTheme;
|
|
21
|
+
/**
|
|
22
|
+
* Apply a theme to the document root element.
|
|
23
|
+
*
|
|
24
|
+
* Sets the `data-theme` attribute and CSS `color-scheme` property on
|
|
25
|
+
* `document.documentElement`. This enables CSS selectors like
|
|
26
|
+
* `[data-theme="dark"]` and ensures native elements (scrollbars, form controls)
|
|
27
|
+
* respect the theme.
|
|
28
|
+
*
|
|
29
|
+
* @param theme - The theme to apply ("light" or "dark")
|
|
30
|
+
*
|
|
31
|
+
* @example Apply theme from host context
|
|
32
|
+
* ```ts source="./styles.examples.ts#applyDocumentTheme_fromHostContext"
|
|
33
|
+
* // Apply when host context changes
|
|
34
|
+
* app.onhostcontextchanged = (ctx) => {
|
|
35
|
+
* if (ctx.theme) {
|
|
36
|
+
* applyDocumentTheme(ctx.theme);
|
|
37
|
+
* }
|
|
38
|
+
* };
|
|
39
|
+
*
|
|
40
|
+
* // Apply initial theme after connecting
|
|
41
|
+
* app.connect().then(() => {
|
|
42
|
+
* const ctx = app.getHostContext();
|
|
43
|
+
* if (ctx?.theme) {
|
|
44
|
+
* applyDocumentTheme(ctx.theme);
|
|
45
|
+
* }
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @example Use with CSS selectors
|
|
50
|
+
* ```css
|
|
51
|
+
* [data-theme="dark"] {
|
|
52
|
+
* --bg-color: #1a1a1a;
|
|
53
|
+
* }
|
|
54
|
+
* [data-theme="light"] {
|
|
55
|
+
* --bg-color: #ffffff;
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @see {@link getDocumentTheme `getDocumentTheme`} to read the current theme
|
|
60
|
+
* @see {@link McpUiTheme `McpUiTheme`} for the theme type
|
|
61
|
+
*/
|
|
62
|
+
export declare function applyDocumentTheme(theme: McpUiTheme): void;
|
|
63
|
+
/**
|
|
64
|
+
* Apply host style variables as CSS custom properties on an element.
|
|
65
|
+
*
|
|
66
|
+
* This function takes the `variables` object from {@link McpUiHostContext.styles `McpUiHostContext.styles`} and sets
|
|
67
|
+
* each CSS variable on the specified root element (defaults to `document.documentElement`).
|
|
68
|
+
* This allows apps to use the host's theming values via CSS variables like
|
|
69
|
+
* `var(--color-background-primary)`.
|
|
70
|
+
*
|
|
71
|
+
* @param styles - The style variables object from `McpUiHostContext.styles.variables`
|
|
72
|
+
* @param root - The element to apply styles to (defaults to `document.documentElement`)
|
|
73
|
+
*
|
|
74
|
+
* @example Apply style variables from host context
|
|
75
|
+
* ```ts source="./styles.examples.ts#applyHostStyleVariables_fromHostContext"
|
|
76
|
+
* // Use CSS variables in your styles
|
|
77
|
+
* document.body.style.background = "var(--color-background-primary)";
|
|
78
|
+
*
|
|
79
|
+
* // Apply when host context changes
|
|
80
|
+
* app.onhostcontextchanged = (ctx) => {
|
|
81
|
+
* if (ctx.styles?.variables) {
|
|
82
|
+
* applyHostStyleVariables(ctx.styles.variables);
|
|
83
|
+
* }
|
|
84
|
+
* };
|
|
85
|
+
*
|
|
86
|
+
* // Apply initial styles after connecting
|
|
87
|
+
* app.connect().then(() => {
|
|
88
|
+
* const ctx = app.getHostContext();
|
|
89
|
+
* if (ctx?.styles?.variables) {
|
|
90
|
+
* applyHostStyleVariables(ctx.styles.variables);
|
|
91
|
+
* }
|
|
92
|
+
* });
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @example Apply to a specific element
|
|
96
|
+
* ```ts source="./styles.examples.ts#applyHostStyleVariables_toElement"
|
|
97
|
+
* app.onhostcontextchanged = (ctx) => {
|
|
98
|
+
* const container = document.getElementById("app-root");
|
|
99
|
+
* if (container && ctx.styles?.variables) {
|
|
100
|
+
* applyHostStyleVariables(ctx.styles.variables, container);
|
|
101
|
+
* }
|
|
102
|
+
* };
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* @example Use host style variables in CSS
|
|
106
|
+
* ```css
|
|
107
|
+
* body {
|
|
108
|
+
* background-color: var(--color-background-primary);
|
|
109
|
+
* color: var(--color-text-primary);
|
|
110
|
+
* }
|
|
111
|
+
*
|
|
112
|
+
* .card {
|
|
113
|
+
* background-color: var(--color-background-secondary);
|
|
114
|
+
* border: 1px solid var(--color-border-primary);
|
|
115
|
+
* }
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* @see {@link McpUiStyles `McpUiStyles`} for the available CSS variables
|
|
119
|
+
* @see {@link McpUiHostContext `McpUiHostContext`} for the full host context structure
|
|
120
|
+
*/
|
|
121
|
+
export declare function applyHostStyleVariables(styles: McpUiStyles, root?: HTMLElement): void;
|
|
122
|
+
/**
|
|
123
|
+
* Apply host font CSS to the document.
|
|
124
|
+
*
|
|
125
|
+
* This function takes the `css.fonts` string from `McpUiHostContext.styles` and
|
|
126
|
+
* injects it as a `<style>` tag. The CSS can contain `@font-face` rules for
|
|
127
|
+
* self-hosted fonts, `@import` statements for Google Fonts or other font services,
|
|
128
|
+
* or a combination of both.
|
|
129
|
+
*
|
|
130
|
+
* The styles are only injected once. Subsequent calls are no-ops and will not
|
|
131
|
+
* create duplicate style tags.
|
|
132
|
+
*
|
|
133
|
+
* @param fontCss - CSS string containing `@font-face` rules and/or `@import` statements
|
|
134
|
+
*
|
|
135
|
+
* @example Apply fonts from host context
|
|
136
|
+
* ```ts source="./styles.examples.ts#applyHostFonts_fromHostContext"
|
|
137
|
+
* // Apply when host context changes
|
|
138
|
+
* app.onhostcontextchanged = (ctx) => {
|
|
139
|
+
* if (ctx.styles?.css?.fonts) {
|
|
140
|
+
* applyHostFonts(ctx.styles.css.fonts);
|
|
141
|
+
* }
|
|
142
|
+
* };
|
|
143
|
+
*
|
|
144
|
+
* // Apply initial fonts after connecting
|
|
145
|
+
* app.connect().then(() => {
|
|
146
|
+
* const ctx = app.getHostContext();
|
|
147
|
+
* if (ctx?.styles?.css?.fonts) {
|
|
148
|
+
* applyHostFonts(ctx.styles.css.fonts);
|
|
149
|
+
* }
|
|
150
|
+
* });
|
|
151
|
+
* ```
|
|
152
|
+
*
|
|
153
|
+
* @example Host providing self-hosted fonts
|
|
154
|
+
* ```ts source="./styles.examples.ts#applyHostFonts_selfHosted"
|
|
155
|
+
* // Example of what a host might provide:
|
|
156
|
+
* const fontCss = `
|
|
157
|
+
* @font-face {
|
|
158
|
+
* font-family: "Anthropic Sans";
|
|
159
|
+
* src: url("https://assets.anthropic.com/.../Regular.otf") format("opentype");
|
|
160
|
+
* font-weight: 400;
|
|
161
|
+
* }
|
|
162
|
+
* `;
|
|
163
|
+
* applyHostFonts(fontCss);
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @example Host providing Google Fonts
|
|
167
|
+
* ```ts source="./styles.examples.ts#applyHostFonts_googleFonts"
|
|
168
|
+
* // Example of what a host might provide:
|
|
169
|
+
* const fontCss = `
|
|
170
|
+
* @import url('https://fonts.googleapis.com/css2?family=Roboto&display=swap');
|
|
171
|
+
* `;
|
|
172
|
+
* applyHostFonts(fontCss);
|
|
173
|
+
* ```
|
|
174
|
+
*
|
|
175
|
+
* @example Use host fonts in CSS
|
|
176
|
+
* ```css
|
|
177
|
+
* body {
|
|
178
|
+
* font-family: var(--font-sans, system-ui, sans-serif);
|
|
179
|
+
* }
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* @see {@link McpUiHostContext `McpUiHostContext`} for the full host context structure
|
|
183
|
+
*/
|
|
184
|
+
export declare function applyHostFonts(fontCss: string): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-checked examples for style utilities in {@link ./styles.ts `styles.ts`}.
|
|
3
|
+
*
|
|
4
|
+
* These examples are included in the API documentation via `@includeCode` tags.
|
|
5
|
+
* Each function's region markers define the code snippet that appears in the docs.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Apps Protocol Types and Schemas
|
|
3
|
+
*
|
|
4
|
+
* This file re-exports types from `spec.types.ts` and schemas from `generated/schema.ts`.
|
|
5
|
+
* Compile-time verification is handled by `generated/schema.test.ts`.
|
|
6
|
+
*
|
|
7
|
+
* @see `spec.types.ts` for the source of truth TypeScript interfaces
|
|
8
|
+
* @see `generated/schema.ts` for auto-generated Zod schemas
|
|
9
|
+
* @see `generated/schema.test.ts` for compile-time verification
|
|
10
|
+
*/
|
|
11
|
+
import type { CallToolRequest, CallToolResult, CreateMessageRequest, CreateMessageResult, CreateMessageResultWithTools, EmptyResult, ListPromptsRequest, ListPromptsResult, ListResourceTemplatesRequest, ListResourceTemplatesResult, ListResourcesRequest, ListResourcesResult, ListToolsRequest, ListToolsResult, LoggingMessageNotification, PingRequest, PromptListChangedNotification, ReadResourceRequest, ReadResourceResult, ResourceListChangedNotification, ToolListChangedNotification } from "@modelcontextprotocol/client";
|
|
12
|
+
import type { McpUiDownloadFileRequest, McpUiDownloadFileResult, McpUiHostContextChangedNotification, McpUiInitializeRequest, McpUiInitializeResult, McpUiInitializedNotification, McpUiMessageRequest, McpUiMessageResult, McpUiOpenLinkRequest, McpUiOpenLinkResult, McpUiRequestDisplayModeRequest, McpUiRequestDisplayModeResult, McpUiRequestTeardownNotification, McpUiResourceTeardownRequest, McpUiResourceTeardownResult, McpUiSandboxProxyReadyNotification, McpUiSandboxResourceReadyNotification, McpUiSizeChangedNotification, McpUiToolCancelledNotification, McpUiToolInputNotification, McpUiToolInputPartialNotification, McpUiToolResultNotification, McpUiUpdateModelContextRequest } from "./spec.types.js";
|
|
13
|
+
export { LATEST_PROTOCOL_VERSION, OPEN_LINK_METHOD, DOWNLOAD_FILE_METHOD, MESSAGE_METHOD, SANDBOX_PROXY_READY_METHOD, SANDBOX_RESOURCE_READY_METHOD, SIZE_CHANGED_METHOD, TOOL_INPUT_METHOD, TOOL_INPUT_PARTIAL_METHOD, TOOL_RESULT_METHOD, TOOL_CANCELLED_METHOD, HOST_CONTEXT_CHANGED_METHOD, REQUEST_TEARDOWN_METHOD, RESOURCE_TEARDOWN_METHOD, INITIALIZE_METHOD, INITIALIZED_METHOD, REQUEST_DISPLAY_MODE_METHOD, type McpUiTheme, type McpUiDisplayMode, type McpUiStyleVariableKey, type McpUiStyles, type McpUiHostCss, type McpUiHostStyles, type McpUiOpenLinkRequest, type McpUiOpenLinkResult, type McpUiDownloadFileRequest, type McpUiDownloadFileResult, type McpUiMessageRequest, type McpUiMessageResult, type McpUiUpdateModelContextRequest, type McpUiSupportedContentBlockModalities, type McpUiSandboxProxyReadyNotification, type McpUiSandboxResourceReadyNotification, type McpUiSizeChangedNotification, type McpUiToolInputNotification, type McpUiToolInputPartialNotification, type McpUiToolResultNotification, type McpUiToolCancelledNotification, type McpUiHostContext, type McpUiHostContextChangedNotification, type McpUiResourceTeardownRequest, type McpUiResourceTeardownResult, type McpUiRequestTeardownNotification, type McpUiHostCapabilities, type McpUiAppCapabilities, type McpUiInitializeRequest, type McpUiInitializeResult, type McpUiInitializedNotification, type McpUiResourceCsp, type McpUiResourcePermissions, type McpUiResourceMeta, type McpUiRequestDisplayModeRequest, type McpUiRequestDisplayModeResult, type McpUiToolVisibility, type McpUiToolMeta, type McpUiClientCapabilities, } from "./spec.types.js";
|
|
14
|
+
export { McpUiThemeSchema, McpUiDisplayModeSchema, McpUiHostCssSchema, McpUiHostStylesSchema, McpUiOpenLinkRequestSchema, McpUiOpenLinkResultSchema, McpUiDownloadFileRequestSchema, McpUiDownloadFileResultSchema, McpUiMessageRequestSchema, McpUiMessageResultSchema, McpUiUpdateModelContextRequestSchema, McpUiSupportedContentBlockModalitiesSchema, McpUiSandboxProxyReadyNotificationSchema, McpUiSandboxResourceReadyNotificationSchema, McpUiSizeChangedNotificationSchema, McpUiToolInputNotificationSchema, McpUiToolInputPartialNotificationSchema, McpUiToolResultNotificationSchema, McpUiToolCancelledNotificationSchema, McpUiHostContextSchema, McpUiHostContextChangedNotificationSchema, McpUiResourceTeardownRequestSchema, McpUiResourceTeardownResultSchema, McpUiRequestTeardownNotificationSchema, McpUiHostCapabilitiesSchema, McpUiAppCapabilitiesSchema, McpUiInitializeRequestSchema, McpUiInitializeResultSchema, McpUiInitializedNotificationSchema, McpUiResourceCspSchema, McpUiResourcePermissionsSchema, McpUiResourceMetaSchema, McpUiRequestDisplayModeRequestSchema, McpUiRequestDisplayModeResultSchema, McpUiToolVisibilitySchema, McpUiToolMetaSchema, } from "./generated/schema.js";
|
|
15
|
+
/**
|
|
16
|
+
* Union of every request an {@link app!App `App`} may send or receive.
|
|
17
|
+
*
|
|
18
|
+
* @deprecated 1.x fed this to the SDK's `Protocol` generics; SDK 2.x derives
|
|
19
|
+
* request types from the method name, so nothing consumes it anymore.
|
|
20
|
+
*/
|
|
21
|
+
export type AppRequest = McpUiInitializeRequest | McpUiOpenLinkRequest | McpUiDownloadFileRequest | McpUiMessageRequest | McpUiUpdateModelContextRequest | McpUiResourceTeardownRequest | McpUiRequestDisplayModeRequest | CallToolRequest | ListToolsRequest | ListResourcesRequest | ListResourceTemplatesRequest | ReadResourceRequest | ListPromptsRequest | CreateMessageRequest | PingRequest;
|
|
22
|
+
/**
|
|
23
|
+
* Union of every notification an {@link app!App `App`} may send or receive.
|
|
24
|
+
*
|
|
25
|
+
* @deprecated See {@link AppRequest}.
|
|
26
|
+
*/
|
|
27
|
+
export type AppNotification = McpUiHostContextChangedNotification | McpUiToolInputNotification | McpUiToolInputPartialNotification | McpUiToolResultNotification | McpUiToolCancelledNotification | McpUiSandboxResourceReadyNotification | ToolListChangedNotification | ResourceListChangedNotification | PromptListChangedNotification | McpUiInitializedNotification | McpUiSizeChangedNotification | McpUiSandboxProxyReadyNotification | McpUiRequestTeardownNotification | LoggingMessageNotification;
|
|
28
|
+
/**
|
|
29
|
+
* Union of every result an {@link app!App `App`} may send or receive.
|
|
30
|
+
*
|
|
31
|
+
* @deprecated See {@link AppRequest}.
|
|
32
|
+
*/
|
|
33
|
+
export type AppResult = McpUiInitializeResult | McpUiOpenLinkResult | McpUiDownloadFileResult | McpUiMessageResult | McpUiResourceTeardownResult | McpUiRequestDisplayModeResult | CallToolResult | ListToolsResult | ListResourcesResult | ListResourceTemplatesResult | ReadResourceResult | ListPromptsResult | CreateMessageResult | CreateMessageResultWithTools | EmptyResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@modelcontextprotocol/ext-apps",
|
|
3
|
+
"repository": {
|
|
4
|
+
"type": "git",
|
|
5
|
+
"url": "https://github.com/modelcontextprotocol/ext-apps"
|
|
6
|
+
},
|
|
7
|
+
"homepage": "https://github.com/modelcontextprotocol/ext-apps",
|
|
8
|
+
"version": "2.0.0",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"description": "MCP Apps SDK — Enable MCP servers to display interactive user interfaces in conversational clients.",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=20"
|
|
14
|
+
},
|
|
15
|
+
"main": "./dist/src/app.js",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/src/app.d.ts",
|
|
19
|
+
"default": "./dist/src/app.js"
|
|
20
|
+
},
|
|
21
|
+
"./app-with-deps": {
|
|
22
|
+
"types": "./dist/src/app.d.ts",
|
|
23
|
+
"default": "./dist/src/app-with-deps.js"
|
|
24
|
+
},
|
|
25
|
+
"./react": {
|
|
26
|
+
"types": "./dist/src/react/index.d.ts",
|
|
27
|
+
"default": "./dist/src/react/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./react-with-deps": {
|
|
30
|
+
"types": "./dist/src/react/index.d.ts",
|
|
31
|
+
"default": "./dist/src/react/react-with-deps.js"
|
|
32
|
+
},
|
|
33
|
+
"./app-bridge": {
|
|
34
|
+
"types": "./dist/src/app-bridge.d.ts",
|
|
35
|
+
"default": "./dist/src/app-bridge.js"
|
|
36
|
+
},
|
|
37
|
+
"./server": {
|
|
38
|
+
"types": "./dist/src/server/index.d.ts",
|
|
39
|
+
"default": "./dist/src/server/index.js"
|
|
40
|
+
},
|
|
41
|
+
"./schema.json": "./dist/src/generated/schema.json"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist"
|
|
45
|
+
],
|
|
46
|
+
"workspaces": [
|
|
47
|
+
"examples/*"
|
|
48
|
+
],
|
|
49
|
+
"scripts": {
|
|
50
|
+
"start": "npm run examples:dev",
|
|
51
|
+
"generate:schemas": "tsx scripts/generate-schemas.ts && prettier --write \"src/generated/**/*\"",
|
|
52
|
+
"sync:snippets": "bun scripts/sync-snippets.ts",
|
|
53
|
+
"build": "npm run generate:schemas && npm run sync:snippets && node scripts/run-bun.mjs build.bun.ts && node scripts/link-self.mjs",
|
|
54
|
+
"prepack": "npm run build",
|
|
55
|
+
"build:all": "npm run examples:build",
|
|
56
|
+
"test": "bun test src examples",
|
|
57
|
+
"test:dependency-isolation": "npm run build && node scripts/check-dependency-isolation.mjs",
|
|
58
|
+
"test:e2e": "playwright test",
|
|
59
|
+
"test:e2e:update": "playwright test --update-snapshots",
|
|
60
|
+
"test:e2e:ui": "playwright test --ui",
|
|
61
|
+
"test:e2e:docker": "docker run --rm -e EXAMPLE -v $(pwd):/work -w /work -it mcr.microsoft.com/playwright:v1.57.0-noble sh -c 'apt-get update -qq && apt-get install -qq -y python3-venv curl > /dev/null && curl -LsSf https://astral.sh/uv/install.sh | sh && export PATH=\"$HOME/.local/bin:$PATH\" && npm i -g bun && npm ci && npx playwright test'",
|
|
62
|
+
"test:e2e:docker:update": "npm run build:all && docker run --rm -e EXAMPLE -v $(pwd):/work -w /work -it mcr.microsoft.com/playwright:v1.57.0-noble sh -c 'apt-get update -qq && apt-get install -qq -y python3-venv curl > /dev/null && curl -LsSf https://astral.sh/uv/install.sh | sh && export PATH=\"$HOME/.local/bin:$PATH\" && npm i -g bun && npm ci && npx playwright test --update-snapshots'",
|
|
63
|
+
"preexamples:build": "npm run build",
|
|
64
|
+
"examples:build": "bun examples/run-all.ts build",
|
|
65
|
+
"examples:start": "NODE_ENV=development npm run build && bun examples/run-all.ts start",
|
|
66
|
+
"examples:dev": "NODE_ENV=development bun examples/run-all.ts dev",
|
|
67
|
+
"watch": "nodemon --watch src --ext ts,tsx --exec 'bun build.bun.ts'",
|
|
68
|
+
"prepare": "npm run build && husky",
|
|
69
|
+
"docs": "typedoc",
|
|
70
|
+
"docs:watch": "typedoc --watch",
|
|
71
|
+
"generate:screenshots": "npm run build:all && docker run --rm -e EXAMPLE -e GENERATE_SCREENSHOTS=1 -v $(pwd):/work -w /work mcr.microsoft.com/playwright:v1.57.0-noble sh -c 'apt-get update -qq && apt-get install -qq -y python3-venv curl > /dev/null && curl -LsSf https://astral.sh/uv/install.sh | sh && export PATH=\"$HOME/.local/bin:$PATH\" && npm i -g bun && npm ci && npx playwright test tests/e2e/generate-grid-screenshots.spec.ts'",
|
|
72
|
+
"prettier": "prettier -u \"**/*.{js,jsx,ts,tsx,mjs,json,md,yml,yaml}\" --check",
|
|
73
|
+
"prettier:fix": "prettier -u \"**/*.{js,jsx,ts,tsx,mjs,json,md,yml,yaml}\" --write",
|
|
74
|
+
"check:versions": "node scripts/check-versions.mjs",
|
|
75
|
+
"bump": "node scripts/bump-version.mjs",
|
|
76
|
+
"update-lock:docker": "rm -rf node_modules package-lock.json examples/*/node_modules && docker run --rm --platform linux/amd64 -v $(pwd):/work -w /work -e HOME=/tmp node:latest npm i --registry=https://registry.npmjs.org/ --ignore-scripts && rm -rf node_modules examples/*/node_modules && npm i --registry=https://registry.npmjs.org/"
|
|
77
|
+
},
|
|
78
|
+
"author": "Olivier Chafik",
|
|
79
|
+
"//interop": "The @modelcontextprotocol/sdk 1.x and ext-apps-v1 devDependencies exist only for src/interop-v1.test.ts, which runs the published 1.7.5 package against this build. The library does not use them.",
|
|
80
|
+
"devDependencies": {
|
|
81
|
+
"@boneskull/typedoc-plugin-mermaid": "^0.2.0",
|
|
82
|
+
"@modelcontextprotocol/client": "2.0.0",
|
|
83
|
+
"@modelcontextprotocol/core": "2.0.0",
|
|
84
|
+
"@modelcontextprotocol/sdk": "1.30.0",
|
|
85
|
+
"@modelcontextprotocol/server": "2.0.0",
|
|
86
|
+
"@playwright/test": "1.57.0",
|
|
87
|
+
"@types/bun": "^1.3.2",
|
|
88
|
+
"@types/node": "20.19.27",
|
|
89
|
+
"@types/react": "^19.2.2",
|
|
90
|
+
"@types/react-dom": "^19.2.2",
|
|
91
|
+
"bun": "^1.2.21",
|
|
92
|
+
"caniuse-lite": "1.0.30001763",
|
|
93
|
+
"cheerio": "1.1.2",
|
|
94
|
+
"concurrently": "^9.2.1",
|
|
95
|
+
"cors": "^2.8.5",
|
|
96
|
+
"cross-env": "^10.1.0",
|
|
97
|
+
"electron-to-chromium": "1.5.267",
|
|
98
|
+
"esbuild": "^0.25.12",
|
|
99
|
+
"express": "^5.1.0",
|
|
100
|
+
"ext-apps-v1": "npm:@modelcontextprotocol/ext-apps@1.7.5",
|
|
101
|
+
"husky": "^9.1.7",
|
|
102
|
+
"nodemon": "^3.1.0",
|
|
103
|
+
"playwright": "1.57.0",
|
|
104
|
+
"playwright-core": "1.57.0",
|
|
105
|
+
"prettier": "^3.6.2",
|
|
106
|
+
"react": "^19.2.0",
|
|
107
|
+
"react-dom": "^19.2.0",
|
|
108
|
+
"sharp": "^0.35.3",
|
|
109
|
+
"ts-to-zod": "^5.1.0",
|
|
110
|
+
"tsx": "^4.21.0",
|
|
111
|
+
"typedoc": "^0.28.14",
|
|
112
|
+
"typedoc-github-theme": "^0.4.0",
|
|
113
|
+
"typescript": "^5.9.3",
|
|
114
|
+
"zod": "^4.2.0"
|
|
115
|
+
},
|
|
116
|
+
"peerDependencies": {
|
|
117
|
+
"@modelcontextprotocol/client": "^2.0.0",
|
|
118
|
+
"@modelcontextprotocol/core": "^2.0.0",
|
|
119
|
+
"@modelcontextprotocol/server": "^2.0.0",
|
|
120
|
+
"react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
121
|
+
"react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
122
|
+
"zod": "^4.2.0"
|
|
123
|
+
},
|
|
124
|
+
"peerDependenciesMeta": {
|
|
125
|
+
"@modelcontextprotocol/server": {
|
|
126
|
+
"optional": true
|
|
127
|
+
},
|
|
128
|
+
"react": {
|
|
129
|
+
"optional": true
|
|
130
|
+
},
|
|
131
|
+
"react-dom": {
|
|
132
|
+
"optional": true
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"overrides": {
|
|
136
|
+
"seroval": "1.4.1",
|
|
137
|
+
"seroval-plugins": "1.4.2",
|
|
138
|
+
"solid-js": "1.9.10",
|
|
139
|
+
"@types/node": "20.19.27"
|
|
140
|
+
},
|
|
141
|
+
"dependencies": {
|
|
142
|
+
"@standard-schema/spec": "^1.1.0"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Colin McDonnell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
<h1 align="center">
|
|
2
|
+
<img alt="Standard Schema fire logo" loading="lazy" width="50" height="50" decoding="async" data-nimg="1" style="color:transparent" src="https://standardschema.dev/favicon.svg">
|
|
3
|
+
</br>
|
|
4
|
+
Standard Schema</h1>
|
|
5
|
+
<p align="center">
|
|
6
|
+
A family of specs for interoperable TypeScript
|
|
7
|
+
<br/>
|
|
8
|
+
<a href="https://standardschema.dev">standardschema.dev</a>
|
|
9
|
+
</p>
|
|
10
|
+
<br/>
|
|
11
|
+
|
|
12
|
+
<!-- start -->
|
|
13
|
+
|
|
14
|
+
The Standard Schema project is a set of interfaces that standardize the provision and consumption of shared functionality in the TypeScript ecosystem.
|
|
15
|
+
|
|
16
|
+
Its goal is to allow tools to accept a single input that includes all the types and capabilities they need— no library-specific adapters, no extra dependencies. The result is an ecosystem that's fair for implementers, friendly for consumers, and open for end users.
|
|
17
|
+
|
|
18
|
+
## The specifications
|
|
19
|
+
|
|
20
|
+
The specifications can be found below in their entirety. Libraries wishing to implement a spec can copy/paste the code block below into their codebase. They're also available at `@standard-schema/spec` on [npm](https://www.npmjs.com/package/@standard-schema/spec) and [JSR](https://jsr.io/@standard-schema/spec).
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
// #########################
|
|
24
|
+
// ### Standard Typed ###
|
|
25
|
+
// #########################
|
|
26
|
+
|
|
27
|
+
/** The Standard Typed interface. This is a base type extended by other specs. */
|
|
28
|
+
export interface StandardTypedV1<Input = unknown, Output = Input> {
|
|
29
|
+
/** The Standard properties. */
|
|
30
|
+
readonly "~standard": StandardTypedV1.Props<Input, Output>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export declare namespace StandardTypedV1 {
|
|
34
|
+
/** The Standard Typed properties interface. */
|
|
35
|
+
export interface Props<Input = unknown, Output = Input> {
|
|
36
|
+
/** The version number of the standard. */
|
|
37
|
+
readonly version: 1;
|
|
38
|
+
/** The vendor name of the schema library. */
|
|
39
|
+
readonly vendor: string;
|
|
40
|
+
/** Inferred types associated with the schema. */
|
|
41
|
+
readonly types?: Types<Input, Output> | undefined;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** The Standard Typed types interface. */
|
|
45
|
+
export interface Types<Input = unknown, Output = Input> {
|
|
46
|
+
/** The input type of the schema. */
|
|
47
|
+
readonly input: Input;
|
|
48
|
+
/** The output type of the schema. */
|
|
49
|
+
readonly output: Output;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Infers the input type of a Standard Typed. */
|
|
53
|
+
export type InferInput<Schema extends StandardTypedV1> = NonNullable<
|
|
54
|
+
Schema["~standard"]["types"]
|
|
55
|
+
>["input"];
|
|
56
|
+
|
|
57
|
+
/** Infers the output type of a Standard Typed. */
|
|
58
|
+
export type InferOutput<Schema extends StandardTypedV1> = NonNullable<
|
|
59
|
+
Schema["~standard"]["types"]
|
|
60
|
+
>["output"];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ##########################
|
|
64
|
+
// ### Standard Schema ###
|
|
65
|
+
// ##########################
|
|
66
|
+
|
|
67
|
+
/** The Standard Schema interface. */
|
|
68
|
+
export interface StandardSchemaV1<Input = unknown, Output = Input> {
|
|
69
|
+
/** The Standard Schema properties. */
|
|
70
|
+
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export declare namespace StandardSchemaV1 {
|
|
74
|
+
/** The Standard Schema properties interface. */
|
|
75
|
+
export interface Props<Input = unknown, Output = Input>
|
|
76
|
+
extends StandardTypedV1.Props<Input, Output> {
|
|
77
|
+
/** Validates unknown input values. */
|
|
78
|
+
readonly validate: (
|
|
79
|
+
value: unknown,
|
|
80
|
+
options?: StandardSchemaV1.Options | undefined
|
|
81
|
+
) => Result<Output> | Promise<Result<Output>>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The result interface of the validate function. */
|
|
85
|
+
export type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
86
|
+
|
|
87
|
+
/** The result interface if validation succeeds. */
|
|
88
|
+
export interface SuccessResult<Output> {
|
|
89
|
+
/** The typed output value. */
|
|
90
|
+
readonly value: Output;
|
|
91
|
+
/** A falsy value for `issues` indicates success. */
|
|
92
|
+
readonly issues?: undefined;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface Options {
|
|
96
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
97
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** The result interface if validation fails. */
|
|
101
|
+
export interface FailureResult {
|
|
102
|
+
/** The issues of failed validation. */
|
|
103
|
+
readonly issues: ReadonlyArray<Issue>;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The issue interface of the failure output. */
|
|
107
|
+
export interface Issue {
|
|
108
|
+
/** The error message of the issue. */
|
|
109
|
+
readonly message: string;
|
|
110
|
+
/** The path of the issue, if any. */
|
|
111
|
+
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** The path segment interface of the issue. */
|
|
115
|
+
export interface PathSegment {
|
|
116
|
+
/** The key representing a path segment. */
|
|
117
|
+
readonly key: PropertyKey;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** The Standard types interface. */
|
|
121
|
+
export interface Types<Input = unknown, Output = Input>
|
|
122
|
+
extends StandardTypedV1.Types<Input, Output> {}
|
|
123
|
+
|
|
124
|
+
/** Infers the input type of a Standard. */
|
|
125
|
+
export type InferInput<Schema extends StandardTypedV1> =
|
|
126
|
+
StandardTypedV1.InferInput<Schema>;
|
|
127
|
+
|
|
128
|
+
/** Infers the output type of a Standard. */
|
|
129
|
+
export type InferOutput<Schema extends StandardTypedV1> =
|
|
130
|
+
StandardTypedV1.InferOutput<Schema>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ###############################
|
|
134
|
+
// ### Standard JSON Schema ###
|
|
135
|
+
// ###############################
|
|
136
|
+
|
|
137
|
+
/** The Standard JSON Schema interface. */
|
|
138
|
+
export interface StandardJSONSchemaV1<Input = unknown, Output = Input> {
|
|
139
|
+
/** The Standard JSON Schema properties. */
|
|
140
|
+
readonly "~standard": StandardJSONSchemaV1.Props<Input, Output>;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export declare namespace StandardJSONSchemaV1 {
|
|
144
|
+
/** The Standard JSON Schema properties interface. */
|
|
145
|
+
export interface Props<Input = unknown, Output = Input>
|
|
146
|
+
extends StandardTypedV1.Props<Input, Output> {
|
|
147
|
+
/** Methods for generating the input/output JSON Schema. */
|
|
148
|
+
readonly jsonSchema: StandardJSONSchemaV1.Converter;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** The Standard JSON Schema converter interface. */
|
|
152
|
+
export interface Converter {
|
|
153
|
+
/** Converts the input type to JSON Schema. May throw if conversion is not supported. */
|
|
154
|
+
readonly input: (
|
|
155
|
+
options: StandardJSONSchemaV1.Options
|
|
156
|
+
) => Record<string, unknown>;
|
|
157
|
+
/** Converts the output type to JSON Schema. May throw if conversion is not supported. */
|
|
158
|
+
readonly output: (
|
|
159
|
+
options: StandardJSONSchemaV1.Options
|
|
160
|
+
) => Record<string, unknown>;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* The target version of the generated JSON Schema.
|
|
165
|
+
*
|
|
166
|
+
* It is *strongly recommended* that implementers support `"draft-2020-12"` and `"draft-07"`, as they are both in wide use. All other targets can be implemented on a best-effort basis. Libraries should throw if they don't support a specified target.
|
|
167
|
+
*
|
|
168
|
+
* The `"openapi-3.0"` target is intended as a standardized specifier for OpenAPI 3.0 which is a superset of JSON Schema `"draft-04"`.
|
|
169
|
+
*/
|
|
170
|
+
export type Target =
|
|
171
|
+
| "draft-2020-12"
|
|
172
|
+
| "draft-07"
|
|
173
|
+
| "openapi-3.0"
|
|
174
|
+
// Accepts any string for future targets while preserving autocomplete
|
|
175
|
+
| ({} & string);
|
|
176
|
+
|
|
177
|
+
/** The options for the input/output methods. */
|
|
178
|
+
export interface Options {
|
|
179
|
+
/** Specifies the target version of the generated JSON Schema. Support for all versions is on a best-effort basis. If a given version is not supported, the library should throw. */
|
|
180
|
+
readonly target: Target;
|
|
181
|
+
|
|
182
|
+
/** Explicit support for additional vendor-specific parameters, if needed. */
|
|
183
|
+
readonly libraryOptions?: Record<string, unknown> | undefined;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** The Standard types interface. */
|
|
187
|
+
export interface Types<Input = unknown, Output = Input>
|
|
188
|
+
extends StandardTypedV1.Types<Input, Output> {}
|
|
189
|
+
|
|
190
|
+
/** Infers the input type of a Standard. */
|
|
191
|
+
export type InferInput<Schema extends StandardTypedV1> =
|
|
192
|
+
StandardTypedV1.InferInput<Schema>;
|
|
193
|
+
|
|
194
|
+
/** Infers the output type of a Standard. */
|
|
195
|
+
export type InferOutput<Schema extends StandardTypedV1> =
|
|
196
|
+
StandardTypedV1.InferOutput<Schema>;
|
|
197
|
+
}
|
|
198
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __copyProps = (to, from, except, desc) => {
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
+
for (let key of __getOwnPropNames(from))
|
|
9
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
|
+
};
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var src_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(src_exports);
|