@vitemcp/server 1.9.4 → 1.9.6
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/dist/ViteMCP.cjs +4 -4
- package/dist/ViteMCP.js +3 -3
- package/dist/auth/index.cjs +2 -2
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-5RAYSJ4N.js → chunk-2GDWFXWP.js} +3 -3
- package/dist/{chunk-OJUNDONA.cjs → chunk-IBZFPUBF.cjs} +8 -8
- package/dist/{chunk-OJUNDONA.cjs.map → chunk-IBZFPUBF.cjs.map} +1 -1
- package/dist/{chunk-P32QRCBT.cjs → chunk-NSHLX6PZ.cjs} +18 -2
- package/dist/chunk-NSHLX6PZ.cjs.map +1 -0
- package/dist/{chunk-4SRXSCYR.js → chunk-WXZQZWBE.js} +18 -2
- package/dist/{chunk-4SRXSCYR.js.map → chunk-WXZQZWBE.js.map} +1 -1
- package/dist/{chunk-4LNVOTEL.js → chunk-XQI4HYU6.js} +10 -4
- package/dist/chunk-XQI4HYU6.js.map +1 -0
- package/dist/{chunk-L6BHGIXM.cjs → chunk-ZVA6Y7EO.cjs} +11 -5
- package/dist/chunk-ZVA6Y7EO.cjs.map +1 -0
- package/dist/edge/index.cjs +5 -5
- package/dist/edge/index.js +1 -1
- package/dist/openapi/index.cjs +45 -42
- package/dist/openapi/index.cjs.map +1 -1
- package/dist/openapi/index.js +31 -28
- package/dist/openapi/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-4LNVOTEL.js.map +0 -1
- package/dist/chunk-L6BHGIXM.cjs.map +0 -1
- package/dist/chunk-P32QRCBT.cjs.map +0 -1
- /package/dist/{chunk-5RAYSJ4N.js.map → chunk-2GDWFXWP.js.map} +0 -0
|
@@ -10,9 +10,15 @@ var formatBytes = (bytes) => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// src/ownKeysOnly.ts
|
|
13
|
-
var ownKeysOnly = (schema) =>
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
var ownKeysOnly = (schema) => {
|
|
14
|
+
const standard = withOwnKeysOnly(schema["~standard"]);
|
|
15
|
+
return Object.defineProperty(schema, "~standard", {
|
|
16
|
+
value: {
|
|
17
|
+
...standard,
|
|
18
|
+
validate: (value) => standard.validate(value ?? {})
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
16
22
|
var withOwnKeysOnly = (standard) => ({
|
|
17
23
|
...standard,
|
|
18
24
|
validate: async (value) => {
|
|
@@ -112,4 +118,4 @@ export {
|
|
|
112
118
|
toSdkSchema,
|
|
113
119
|
valibotToJsonSchema
|
|
114
120
|
};
|
|
115
|
-
//# sourceMappingURL=chunk-
|
|
121
|
+
//# sourceMappingURL=chunk-XQI4HYU6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/formatBytes.ts","../src/ownKeysOnly.ts","../src/toSdkSchema.ts"],"sourcesContent":["/** Renders a byte cap the way the error message should read (e.g. \"1 MiB\"). */\nexport const formatBytes = (bytes: number): string => {\n if (bytes >= 1024 * 1024 && bytes % (1024 * 1024) === 0) {\n return `${bytes / (1024 * 1024)} MiB`;\n }\n\n if (bytes >= 1024 && bytes % 1024 === 0) {\n return `${bytes / 1024} KiB`;\n }\n\n return `${bytes} bytes`;\n};\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\n/**\n * Has `schema` validate by own keys only — see `withOwnKeysOnly` — by\n * replacing its `~standard` in place. The schema keeps its `shape`, which the\n * SDK reads to complete an argument, and its JSON Schema, which `prompts/list`\n * is built from.\n *\n * For the argument schemas `ViteMCP` and `EdgeViteMCP` build for their\n * prompts. A tool's schemas belong to whoever wrote the tool, so\n * `toSdkSchema` wraps them instead.\n *\n * An argument map the request left out validates as an empty one, as the SDK\n * already arranges for a tool's. `prompts/get` may omit `arguments`, and the\n * SDK validates the map as it was sent, so a prompt whose arguments are all\n * optional refused the request as \"expected object, received undefined\".\n */\nexport const ownKeysOnly = <S extends StandardSchemaV1>(schema: S): S => {\n const standard = withOwnKeysOnly(schema[\"~standard\"]);\n\n return Object.defineProperty(schema, \"~standard\", {\n value: {\n ...standard,\n validate: (value: unknown) => standard.validate(value ?? {}),\n },\n });\n};\n\n/**\n * `standard`, with a `validate` that sees only the keys an object has of its\n * own.\n *\n * Zod and Valibot look each key up with `in` and read it with `[]`, and both\n * walk the prototype chain, so a key that was left out reads as present when\n * `Object.prototype` has a member by that name. An optional argument called\n * `toString`, `constructor` or `valueOf`, at any depth, failed every request\n * that left it out, as \"expected string, received function\", and a required\n * one was reported as the wrong type instead of as missing. Validating a copy\n * whose objects have no prototype leaves the library nothing to inherit.\n *\n * A library that hands its input back, as ArkType and `jsonSchemaAdapter` do,\n * hands back the copy, so the copied objects get their prototype back before\n * the value goes on: `execute` still receives ordinary objects.\n */\nexport const withOwnKeysOnly = <P extends StandardSchemaV1.Props>(\n standard: P,\n): P => ({\n ...standard,\n validate: async (value: unknown) => {\n const copies = new Map<object, object>();\n const result = await standard.validate(withoutPrototypes(value, copies));\n\n if (!result.issues && copies.size > 0) {\n restorePrototypes(result.value, new Set(copies.values()), new Set());\n }\n\n return result;\n },\n});\n\n/**\n * `value`, with each plain object in it, at any depth, copied onto one without\n * a prototype, and each array copied to reach them. `copies` maps every\n * original to its copy, so one that occurs twice, or inside itself, is copied\n * once.\n */\nconst withoutPrototypes = (\n value: unknown,\n copies: Map<object, object>,\n): unknown => {\n if (!isPlain(value)) {\n return value;\n }\n\n const existing = copies.get(value);\n\n if (existing) {\n return existing;\n }\n\n const copy: Record<string, unknown> = Array.isArray(value)\n ? []\n : Object.create(null);\n\n copies.set(value, copy);\n\n for (const [key, item] of Object.entries(value)) {\n copy[key] = withoutPrototypes(item, copies);\n }\n\n return copy;\n};\n\n/**\n * Gives each object copy in `copies` that `value` holds, at any depth,\n * `Object.prototype` back.\n */\nconst restorePrototypes = (\n value: unknown,\n copies: Set<object>,\n seen: Set<object>,\n): void => {\n if (!isPlain(value) || seen.has(value)) {\n return;\n }\n\n seen.add(value);\n\n if (copies.has(value) && !Array.isArray(value)) {\n Object.setPrototypeOf(value, Object.prototype);\n }\n\n for (const item of Object.values(value)) {\n restorePrototypes(item, copies, seen);\n }\n};\n\n/**\n * An array, or an object made by a literal or without a prototype: what JSON\n * parses to, and the only kinds of object that are copied.\n */\nconst isPlain = (value: unknown): value is Record<string, unknown> => {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const prototype: unknown = Object.getPrototypeOf(value);\n\n return (\n Array.isArray(value) || prototype === Object.prototype || prototype === null\n );\n};\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { JsonSchema } from \"xsschema\";\n\nimport { withOwnKeysOnly } from \"./ownKeysOnly.js\";\n\n/**\n * Turns a Standard Schema that carries no JSON Schema into one. Which\n * libraries that can be done for depends on the runtime, so each entry point\n * supplies its own.\n */\nexport type JsonSchemaConverter = (\n schema: StandardSchemaV1,\n io: \"input\" | \"output\",\n) => Promise<JsonSchema>;\n\n/**\n * A tool's schema as the SDK registers it: one that validates by own keys only\n * (see `withOwnKeysOnly`) and carries a JSON Schema. The schema itself is left\n * as it was, since whoever wrote it may use it elsewhere.\n *\n * Zod v4 and ArkType emit JSON Schema natively, and theirs is kept; anything\n * else (Valibot, say) is converted, and the conversion is only what\n * `tools/list` advertises. Validation stays with the library the schema was\n * written in: the conversion drops what JSON Schema cannot say — a transform,\n * a `check()` — so validating against it instead would pass `execute`\n * arguments the schema never produced.\n *\n * Advertised inputs are closed with `strictInputSchema`. Outputs are left as\n * converted, since closing them would misdescribe results the schema allows.\n *\n * Shared by `ViteMCP` and `EdgeViteMCP`, so what a tool advertises does not\n * depend on which of them serves it. Rejects when `convert` does.\n */\nexport const toSdkSchema = async (\n schema: unknown,\n io: \"input\" | \"output\",\n convert: JsonSchemaConverter,\n): Promise<unknown> => {\n if (!schema) {\n return undefined;\n }\n\n const standard = withOwnKeysOnly(\n (\n schema as {\n \"~standard\": { jsonSchema?: unknown } & StandardSchemaV1.Props;\n }\n )[\"~standard\"],\n );\n\n if (standard.jsonSchema) {\n return { \"~standard\": standard };\n }\n\n const json = await convert(schema as StandardSchemaV1, io);\n const advertised = io === \"input\" ? strictInputSchema(json) : json;\n\n return {\n \"~standard\": {\n ...standard,\n jsonSchema: { input: () => advertised, output: () => advertised },\n },\n };\n};\n\n/**\n * JSON Schema for a Valibot schema, for advertising.\n *\n * Valibot's converter is called directly so it can be told to skip what JSON\n * Schema cannot express — a transform, a `check()` — rather than refuse the\n * whole schema. Valibot still validates, so the copy only has to describe what\n * a caller sends (`typeMode: \"input\"`, which stops at the first transform) or\n * receives (`\"output\"`).\n *\n * The `import()` has to stay inside the `try`. An edge bundle is built with\n * every import resolved ahead of time, and a bundler fails the build over one\n * it cannot resolve — unless it can see the failure is handled, in which case\n * a server that never touches Valibot builds without the converter installed.\n */\nexport const valibotToJsonSchema: JsonSchemaConverter = async (schema, io) => {\n let converter;\n\n try {\n converter = await import(\"@valibot/to-json-schema\");\n } catch {\n throw new Error(\n 'The \"@valibot/to-json-schema\" package is required to describe Valibot ' +\n \"schemas. Install it with: npm install @valibot/to-json-schema\",\n );\n }\n\n return converter.toJsonSchema(schema as never, {\n errorMode: \"ignore\",\n typeMode: io,\n }) as JsonSchema;\n};\n\n/**\n * Closes an advertised input schema's objects to undeclared keys, except where\n * the schema describes those keys itself. A record's value schema, or an\n * object's rest schema, arrives as `additionalProperties`; replacing it with\n * `false` would tell clients the tool takes none of those keys, so a\n * `v.record()` argument could only ever be sent as `{}`.\n */\nconst strictInputSchema = (schema: JsonSchema): JsonSchema => ({\n ...schema,\n additionalProperties:\n typeof schema.additionalProperties === \"object\"\n ? schema.additionalProperties\n : false,\n ...(schema.properties && {\n properties: Object.fromEntries(\n Object.entries(schema.properties).map(([key, value]) => [\n key,\n typeof value === \"object\" && value.type === \"object\"\n ? strictInputSchema(value)\n : value,\n ]),\n ),\n }),\n});\n"],"mappings":"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","names":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }// src/formatBytes.ts
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/formatBytes.ts
|
|
2
2
|
var formatBytes = (bytes) => {
|
|
3
3
|
if (bytes >= 1024 * 1024 && bytes % (1024 * 1024) === 0) {
|
|
4
4
|
return `${bytes / (1024 * 1024)} MiB`;
|
|
@@ -10,9 +10,15 @@ var formatBytes = (bytes) => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// src/ownKeysOnly.ts
|
|
13
|
-
var ownKeysOnly = (schema) =>
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
var ownKeysOnly = (schema) => {
|
|
14
|
+
const standard = withOwnKeysOnly(schema["~standard"]);
|
|
15
|
+
return Object.defineProperty(schema, "~standard", {
|
|
16
|
+
value: {
|
|
17
|
+
...standard,
|
|
18
|
+
validate: (value) => standard.validate(_nullishCoalesce(value, () => ( {})))
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
16
22
|
var withOwnKeysOnly = (standard) => ({
|
|
17
23
|
...standard,
|
|
18
24
|
validate: async (value) => {
|
|
@@ -112,4 +118,4 @@ var strictInputSchema = (schema) => ({
|
|
|
112
118
|
|
|
113
119
|
|
|
114
120
|
exports.formatBytes = formatBytes; exports.ownKeysOnly = ownKeysOnly; exports.toSdkSchema = toSdkSchema; exports.valibotToJsonSchema = valibotToJsonSchema;
|
|
115
|
-
//# sourceMappingURL=chunk-
|
|
121
|
+
//# sourceMappingURL=chunk-ZVA6Y7EO.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/server/server/dist/chunk-ZVA6Y7EO.cjs","../src/formatBytes.ts","../src/ownKeysOnly.ts","../src/toSdkSchema.ts"],"names":[],"mappings":"AAAA;ACCO,IAAM,YAAA,EAAc,CAAC,KAAA,EAAA,GAA0B;AACpD,EAAA,GAAA,CAAI,MAAA,GAAS,KAAA,EAAO,KAAA,GAAQ,MAAA,EAAA,CAAS,KAAA,EAAO,IAAA,EAAA,IAAU,CAAA,EAAG;AACvD,IAAA,OAAO,CAAA,EAAA;AACT,EAAA;AAEI,EAAA;AACK,IAAA;AACT,EAAA;AAEU,EAAA;AACZ;ADDY;AACA;AEMC;AACL,EAAA;AAEC,EAAA;AACE,IAAA;AACF,MAAA;AACH,MAAA;AACF,IAAA;AACD,EAAA;AACH;AAkBa;AAGR,EAAA;AACO,EAAA;AACF,IAAA;AACA,IAAA;AAED,IAAA;AACH,MAAA;AACF,IAAA;AAEO,IAAA;AACT,EAAA;AACF;AAQM;AAIC,EAAA;AACI,IAAA;AACT,EAAA;AAEM,EAAA;AAEF,EAAA;AACK,IAAA;AACT,EAAA;AAEM,EAAA;AAIC,EAAA;AAEP,EAAA;AACU,IAAA;AACV,EAAA;AAEO,EAAA;AACT;AAMM;AAKC,EAAA;AACH,IAAA;AACF,EAAA;AAES,EAAA;AAEL,EAAA;AACK,IAAA;AACT,EAAA;AAEA,EAAA;AACE,IAAA;AACF,EAAA;AACF;AAMM;AACA,EAAA;AACK,IAAA;AACT,EAAA;AAEM,EAAA;AAGJ,EAAA;AAEJ;AFjEY;AACA;AGlCC;AAKN,EAAA;AACI,IAAA;AACT,EAAA;AAEM,EAAA;AAKF,IAAA;AACJ,EAAA;AAEI,EAAA;AACK,IAAA;AACT,EAAA;AAEM,EAAA;AACA,EAAA;AAEC,EAAA;AACL,IAAA;AACK,MAAA;AACH,MAAA;AACF,IAAA;AACF,EAAA;AACF;AAgBa;AACP,EAAA;AAEA,EAAA;AACF,IAAA;AACM,EAAA;AACA,IAAA;AACJ,MAAA;AAEF,IAAA;AACF,EAAA;AAEO,EAAA;AACL,IAAA;AACA,IAAA;AACD,EAAA;AACH;AASM;AACD,EAAA;AACH,EAAA;AAIW,EAAA;AACT,IAAA;AACE,MAAA;AACE,QAAA;AACA,QAAA;AAGD,MAAA;AACH,IAAA;AACF,EAAA;AACF;AHPY;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/server/server/dist/chunk-ZVA6Y7EO.cjs","sourcesContent":[null,"/** Renders a byte cap the way the error message should read (e.g. \"1 MiB\"). */\nexport const formatBytes = (bytes: number): string => {\n if (bytes >= 1024 * 1024 && bytes % (1024 * 1024) === 0) {\n return `${bytes / (1024 * 1024)} MiB`;\n }\n\n if (bytes >= 1024 && bytes % 1024 === 0) {\n return `${bytes / 1024} KiB`;\n }\n\n return `${bytes} bytes`;\n};\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\n/**\n * Has `schema` validate by own keys only — see `withOwnKeysOnly` — by\n * replacing its `~standard` in place. The schema keeps its `shape`, which the\n * SDK reads to complete an argument, and its JSON Schema, which `prompts/list`\n * is built from.\n *\n * For the argument schemas `ViteMCP` and `EdgeViteMCP` build for their\n * prompts. A tool's schemas belong to whoever wrote the tool, so\n * `toSdkSchema` wraps them instead.\n *\n * An argument map the request left out validates as an empty one, as the SDK\n * already arranges for a tool's. `prompts/get` may omit `arguments`, and the\n * SDK validates the map as it was sent, so a prompt whose arguments are all\n * optional refused the request as \"expected object, received undefined\".\n */\nexport const ownKeysOnly = <S extends StandardSchemaV1>(schema: S): S => {\n const standard = withOwnKeysOnly(schema[\"~standard\"]);\n\n return Object.defineProperty(schema, \"~standard\", {\n value: {\n ...standard,\n validate: (value: unknown) => standard.validate(value ?? {}),\n },\n });\n};\n\n/**\n * `standard`, with a `validate` that sees only the keys an object has of its\n * own.\n *\n * Zod and Valibot look each key up with `in` and read it with `[]`, and both\n * walk the prototype chain, so a key that was left out reads as present when\n * `Object.prototype` has a member by that name. An optional argument called\n * `toString`, `constructor` or `valueOf`, at any depth, failed every request\n * that left it out, as \"expected string, received function\", and a required\n * one was reported as the wrong type instead of as missing. Validating a copy\n * whose objects have no prototype leaves the library nothing to inherit.\n *\n * A library that hands its input back, as ArkType and `jsonSchemaAdapter` do,\n * hands back the copy, so the copied objects get their prototype back before\n * the value goes on: `execute` still receives ordinary objects.\n */\nexport const withOwnKeysOnly = <P extends StandardSchemaV1.Props>(\n standard: P,\n): P => ({\n ...standard,\n validate: async (value: unknown) => {\n const copies = new Map<object, object>();\n const result = await standard.validate(withoutPrototypes(value, copies));\n\n if (!result.issues && copies.size > 0) {\n restorePrototypes(result.value, new Set(copies.values()), new Set());\n }\n\n return result;\n },\n});\n\n/**\n * `value`, with each plain object in it, at any depth, copied onto one without\n * a prototype, and each array copied to reach them. `copies` maps every\n * original to its copy, so one that occurs twice, or inside itself, is copied\n * once.\n */\nconst withoutPrototypes = (\n value: unknown,\n copies: Map<object, object>,\n): unknown => {\n if (!isPlain(value)) {\n return value;\n }\n\n const existing = copies.get(value);\n\n if (existing) {\n return existing;\n }\n\n const copy: Record<string, unknown> = Array.isArray(value)\n ? []\n : Object.create(null);\n\n copies.set(value, copy);\n\n for (const [key, item] of Object.entries(value)) {\n copy[key] = withoutPrototypes(item, copies);\n }\n\n return copy;\n};\n\n/**\n * Gives each object copy in `copies` that `value` holds, at any depth,\n * `Object.prototype` back.\n */\nconst restorePrototypes = (\n value: unknown,\n copies: Set<object>,\n seen: Set<object>,\n): void => {\n if (!isPlain(value) || seen.has(value)) {\n return;\n }\n\n seen.add(value);\n\n if (copies.has(value) && !Array.isArray(value)) {\n Object.setPrototypeOf(value, Object.prototype);\n }\n\n for (const item of Object.values(value)) {\n restorePrototypes(item, copies, seen);\n }\n};\n\n/**\n * An array, or an object made by a literal or without a prototype: what JSON\n * parses to, and the only kinds of object that are copied.\n */\nconst isPlain = (value: unknown): value is Record<string, unknown> => {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const prototype: unknown = Object.getPrototypeOf(value);\n\n return (\n Array.isArray(value) || prototype === Object.prototype || prototype === null\n );\n};\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { JsonSchema } from \"xsschema\";\n\nimport { withOwnKeysOnly } from \"./ownKeysOnly.js\";\n\n/**\n * Turns a Standard Schema that carries no JSON Schema into one. Which\n * libraries that can be done for depends on the runtime, so each entry point\n * supplies its own.\n */\nexport type JsonSchemaConverter = (\n schema: StandardSchemaV1,\n io: \"input\" | \"output\",\n) => Promise<JsonSchema>;\n\n/**\n * A tool's schema as the SDK registers it: one that validates by own keys only\n * (see `withOwnKeysOnly`) and carries a JSON Schema. The schema itself is left\n * as it was, since whoever wrote it may use it elsewhere.\n *\n * Zod v4 and ArkType emit JSON Schema natively, and theirs is kept; anything\n * else (Valibot, say) is converted, and the conversion is only what\n * `tools/list` advertises. Validation stays with the library the schema was\n * written in: the conversion drops what JSON Schema cannot say — a transform,\n * a `check()` — so validating against it instead would pass `execute`\n * arguments the schema never produced.\n *\n * Advertised inputs are closed with `strictInputSchema`. Outputs are left as\n * converted, since closing them would misdescribe results the schema allows.\n *\n * Shared by `ViteMCP` and `EdgeViteMCP`, so what a tool advertises does not\n * depend on which of them serves it. Rejects when `convert` does.\n */\nexport const toSdkSchema = async (\n schema: unknown,\n io: \"input\" | \"output\",\n convert: JsonSchemaConverter,\n): Promise<unknown> => {\n if (!schema) {\n return undefined;\n }\n\n const standard = withOwnKeysOnly(\n (\n schema as {\n \"~standard\": { jsonSchema?: unknown } & StandardSchemaV1.Props;\n }\n )[\"~standard\"],\n );\n\n if (standard.jsonSchema) {\n return { \"~standard\": standard };\n }\n\n const json = await convert(schema as StandardSchemaV1, io);\n const advertised = io === \"input\" ? strictInputSchema(json) : json;\n\n return {\n \"~standard\": {\n ...standard,\n jsonSchema: { input: () => advertised, output: () => advertised },\n },\n };\n};\n\n/**\n * JSON Schema for a Valibot schema, for advertising.\n *\n * Valibot's converter is called directly so it can be told to skip what JSON\n * Schema cannot express — a transform, a `check()` — rather than refuse the\n * whole schema. Valibot still validates, so the copy only has to describe what\n * a caller sends (`typeMode: \"input\"`, which stops at the first transform) or\n * receives (`\"output\"`).\n *\n * The `import()` has to stay inside the `try`. An edge bundle is built with\n * every import resolved ahead of time, and a bundler fails the build over one\n * it cannot resolve — unless it can see the failure is handled, in which case\n * a server that never touches Valibot builds without the converter installed.\n */\nexport const valibotToJsonSchema: JsonSchemaConverter = async (schema, io) => {\n let converter;\n\n try {\n converter = await import(\"@valibot/to-json-schema\");\n } catch {\n throw new Error(\n 'The \"@valibot/to-json-schema\" package is required to describe Valibot ' +\n \"schemas. Install it with: npm install @valibot/to-json-schema\",\n );\n }\n\n return converter.toJsonSchema(schema as never, {\n errorMode: \"ignore\",\n typeMode: io,\n }) as JsonSchema;\n};\n\n/**\n * Closes an advertised input schema's objects to undeclared keys, except where\n * the schema describes those keys itself. A record's value schema, or an\n * object's rest schema, arrives as `additionalProperties`; replacing it with\n * `false` would tell clients the tool takes none of those keys, so a\n * `v.record()` argument could only ever be sent as `{}`.\n */\nconst strictInputSchema = (schema: JsonSchema): JsonSchema => ({\n ...schema,\n additionalProperties:\n typeof schema.additionalProperties === \"object\"\n ? schema.additionalProperties\n : false,\n ...(schema.properties && {\n properties: Object.fromEntries(\n Object.entries(schema.properties).map(([key, value]) => [\n key,\n typeof value === \"object\" && value.type === \"object\"\n ? strictInputSchema(value)\n : value,\n ]),\n ),\n }),\n});\n"]}
|
package/dist/edge/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkZVA6Y7EOcjs = require('../chunk-ZVA6Y7EO.cjs');
|
|
7
7
|
|
|
8
8
|
// src/edge/index.ts
|
|
9
9
|
var _server = require('@modelcontextprotocol/server');
|
|
@@ -16,7 +16,7 @@ var convertToJsonSchema = async (schema, io) => {
|
|
|
16
16
|
`Schema library "${vendor}" carries no JSON Schema (\`~standard.jsonSchema\`), and EdgeViteMCP converts only Valibot's. Use Zod 4, ArkType or Valibot.`
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
|
-
return
|
|
19
|
+
return _chunkZVA6Y7EOcjs.valibotToJsonSchema.call(void 0, schema, io);
|
|
20
20
|
};
|
|
21
21
|
var readCappedRequest = async (request, maxBytes) => {
|
|
22
22
|
if (!request.body) {
|
|
@@ -107,7 +107,7 @@ var EdgeViteMCP = class {
|
|
|
107
107
|
}
|
|
108
108
|
if (!capped) {
|
|
109
109
|
return invalidRequest(
|
|
110
|
-
`Request body exceeds ${
|
|
110
|
+
`Request body exceeds ${_chunkZVA6Y7EOcjs.formatBytes.call(void 0, this.#maxBodySize)}`
|
|
111
111
|
);
|
|
112
112
|
}
|
|
113
113
|
this.#handler ??= _server.createMcpHandler.call(void 0, () => this.#buildServer());
|
|
@@ -172,7 +172,7 @@ var EdgeViteMCP = class {
|
|
|
172
172
|
for (const arg of _nullishCoalesce(prompt.arguments, () => ( []))) {
|
|
173
173
|
shape[arg.name] = arg.required ? _zod.z.string() : _zod.z.string().optional();
|
|
174
174
|
}
|
|
175
|
-
const argsSchema = _optionalChain([prompt, 'access', _ => _.arguments, 'optionalAccess', _2 => _2.length]) ?
|
|
175
|
+
const argsSchema = _optionalChain([prompt, 'access', _ => _.arguments, 'optionalAccess', _2 => _2.length]) ? _chunkZVA6Y7EOcjs.ownKeysOnly.call(void 0, _zod.z.object(shape)) : void 0;
|
|
176
176
|
const load = async (args) => {
|
|
177
177
|
const text = await prompt.load(_nullishCoalesce(args, () => ( {})));
|
|
178
178
|
return {
|
|
@@ -202,7 +202,7 @@ var EdgeViteMCP = class {
|
|
|
202
202
|
#sdkSchemaFor(tool) {
|
|
203
203
|
let schema = this.#toolSchemas.get(tool);
|
|
204
204
|
if (!schema) {
|
|
205
|
-
schema =
|
|
205
|
+
schema = _chunkZVA6Y7EOcjs.toSdkSchema.call(void 0, tool.parameters, "input", convertToJsonSchema).then(
|
|
206
206
|
(inputSchema) => ({ inputSchema }),
|
|
207
207
|
(error) => {
|
|
208
208
|
this.#logger.error(
|
package/dist/edge/index.js
CHANGED
package/dist/openapi/index.cjs
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
7
|
-
require('../chunk-
|
|
8
|
-
require('../chunk-
|
|
6
|
+
var _chunkIBZFPUBFcjs = require('../chunk-IBZFPUBF.cjs');
|
|
7
|
+
require('../chunk-NSHLX6PZ.cjs');
|
|
8
|
+
require('../chunk-ZVA6Y7EO.cjs');
|
|
9
9
|
|
|
10
10
|
// src/openapi/parameters.ts
|
|
11
11
|
var appendQueryParameter = (query, parameter, value) => {
|
|
@@ -111,7 +111,7 @@ var serializeSimple = (value, explode, name, style) => {
|
|
|
111
111
|
([, entry]) => entry !== void 0
|
|
112
112
|
);
|
|
113
113
|
if (style === "matrix" && explode) {
|
|
114
|
-
return entries.map(([key, entry]) => `;${key}=${encode(entry)}`).join("");
|
|
114
|
+
return entries.map(([key, entry]) => `;${encodeURIComponent(key)}=${encode(entry)}`).join("");
|
|
115
115
|
}
|
|
116
116
|
if (explode) {
|
|
117
117
|
return entries.map(([key, entry]) => `${encodeURIComponent(key)}=${encode(entry)}`).join(style === "label" ? "." : ",");
|
|
@@ -130,7 +130,7 @@ var executeRequest = async (options) => {
|
|
|
130
130
|
const query = new URLSearchParams();
|
|
131
131
|
const cookies = [];
|
|
132
132
|
const headers = new Headers();
|
|
133
|
-
const bodyValues =
|
|
133
|
+
const bodyValues = /* @__PURE__ */ Object.create(null);
|
|
134
134
|
for (const [key, value] of Object.entries(args)) {
|
|
135
135
|
const binder = binding.parameters[key];
|
|
136
136
|
if (!binder || value === void 0) {
|
|
@@ -206,7 +206,7 @@ var resolveBaseUrl = (servers, origin, override) => {
|
|
|
206
206
|
}
|
|
207
207
|
let url = server.url;
|
|
208
208
|
for (const [name, variable] of Object.entries(_nullishCoalesce(server.variables, () => ( {})))) {
|
|
209
|
-
url = url.replaceAll(`{${name}}`, variable.default);
|
|
209
|
+
url = url.replaceAll(`{${name}}`, () => variable.default);
|
|
210
210
|
}
|
|
211
211
|
try {
|
|
212
212
|
return trimSlash(new URL(url).toString());
|
|
@@ -242,7 +242,8 @@ var appendFormValue = (form, name, value) => {
|
|
|
242
242
|
};
|
|
243
243
|
var buildBody = (binding, values, headers) => {
|
|
244
244
|
const encoding = binding.bodyEncoding;
|
|
245
|
-
|
|
245
|
+
const sendEmpty = _optionalChain([encoding, 'optionalAccess', _3 => _3.kind]) === "json" && binding.bodyRequired;
|
|
246
|
+
if (!encoding || Object.keys(values).length === 0 && !sendEmpty) {
|
|
246
247
|
return void 0;
|
|
247
248
|
}
|
|
248
249
|
const payload = binding.wholeBodyKey ? values[binding.wholeBodyKey] : values;
|
|
@@ -270,18 +271,18 @@ var buildBody = (binding, values, headers) => {
|
|
|
270
271
|
var buildPath = (route, values) => {
|
|
271
272
|
const unfilled = [...route.path.matchAll(/\{([^{}]*)\}/g)].filter(([, name]) => !values.has(name)).map(([placeholder]) => placeholder);
|
|
272
273
|
if (unfilled.length > 0) {
|
|
273
|
-
throw new (0,
|
|
274
|
+
throw new (0, _chunkIBZFPUBFcjs.UserError)(
|
|
274
275
|
`${route.method.toUpperCase()} ${route.path} cannot be called: the OpenAPI document declares no path parameter for ${unfilled.join(", ")}.`
|
|
275
276
|
);
|
|
276
277
|
}
|
|
277
278
|
let path = route.path;
|
|
278
279
|
for (const [name, value] of values) {
|
|
279
|
-
path = path.replaceAll(`{${name}}`, value);
|
|
280
|
+
path = path.replaceAll(`{${name}}`, () => value);
|
|
280
281
|
}
|
|
281
282
|
const written = new Set(route.path.split("/").filter(isDotSegment));
|
|
282
283
|
const introduced = path.split("/").find((segment) => isDotSegment(segment) && !written.has(segment));
|
|
283
284
|
if (introduced !== void 0) {
|
|
284
|
-
throw new (0,
|
|
285
|
+
throw new (0, _chunkIBZFPUBFcjs.UserError)(
|
|
285
286
|
`${route.method.toUpperCase()} ${route.path} cannot be called with a path segment of "${introduced}": a URL resolves it as a step through the path, so the request would reach a different endpoint.`
|
|
286
287
|
);
|
|
287
288
|
}
|
|
@@ -299,7 +300,7 @@ var readResponse = async (response, options) => {
|
|
|
299
300
|
const mediaType = contentType.split(";")[0].trim().toLowerCase();
|
|
300
301
|
const label = `${route.method.toUpperCase()} ${route.path}`;
|
|
301
302
|
if (!response.ok) {
|
|
302
|
-
throw new (0,
|
|
303
|
+
throw new (0, _chunkIBZFPUBFcjs.UserError)(
|
|
303
304
|
`${label} failed with ${response.status} ${response.statusText}: ${truncate(
|
|
304
305
|
await response.text(),
|
|
305
306
|
2e3
|
|
@@ -311,7 +312,7 @@ var readResponse = async (response, options) => {
|
|
|
311
312
|
if (bytes.byteLength <= MAX_INLINE_MEDIA_BYTES) {
|
|
312
313
|
return mediaType.startsWith("image/") ? { data: toBase64(bytes), mimeType: mediaType, type: "image" } : { data: toBase64(bytes), mimeType: mediaType, type: "audio" };
|
|
313
314
|
}
|
|
314
|
-
throw new (0,
|
|
315
|
+
throw new (0, _chunkIBZFPUBFcjs.UserError)(
|
|
315
316
|
`${label} returned ${bytes.byteLength} bytes of ${contentType}, too large to return inline.`
|
|
316
317
|
);
|
|
317
318
|
}
|
|
@@ -321,7 +322,7 @@ var readResponse = async (response, options) => {
|
|
|
321
322
|
return { structuredContent: parsed };
|
|
322
323
|
}
|
|
323
324
|
if (binding.outputSchema) {
|
|
324
|
-
throw new (0,
|
|
325
|
+
throw new (0, _chunkIBZFPUBFcjs.UserError)(
|
|
325
326
|
`${label} declares a JSON object response but returned ${contentType || "an untyped body"}. Set \`outputSchema: false\` if this document's response schemas do not match the API.`
|
|
326
327
|
);
|
|
327
328
|
}
|
|
@@ -343,7 +344,7 @@ var setHeader = (headers, name, value) => {
|
|
|
343
344
|
try {
|
|
344
345
|
headers.set(name, value);
|
|
345
346
|
} catch (e2) {
|
|
346
|
-
throw new (0,
|
|
347
|
+
throw new (0, _chunkIBZFPUBFcjs.UserError)(
|
|
347
348
|
`"${name}" is not a valid header name, or the value given for it is not a valid header value.`
|
|
348
349
|
);
|
|
349
350
|
}
|
|
@@ -388,8 +389,8 @@ var loadSpec = async (spec) => {
|
|
|
388
389
|
return { document: assertOpenApi3(parsed), origin };
|
|
389
390
|
};
|
|
390
391
|
var assertOpenApi3 = (document) => {
|
|
391
|
-
if (!_optionalChain([document, 'optionalAccess',
|
|
392
|
-
const found = _nullishCoalesce(_optionalChain([document, 'optionalAccess',
|
|
392
|
+
if (!_optionalChain([document, 'optionalAccess', _4 => _4.openapi, 'optionalAccess', _5 => _5.startsWith, 'call', _6 => _6("3.")])) {
|
|
393
|
+
const found = _nullishCoalesce(_optionalChain([document, 'optionalAccess', _7 => _7.openapi]), () => ( (_optionalChain([document, 'optionalAccess', _8 => _8.swagger]) ? `Swagger ${document.swagger}` : void 0)));
|
|
393
394
|
throw new Error(
|
|
394
395
|
`fromOpenAPI supports OpenAPI 3.x documents only (found ${_nullishCoalesce(found, () => ( "no recognisable version field"))}). Convert a Swagger 2.0 document first \u2014 https://converter.swagger.io converts one in place.`
|
|
395
396
|
);
|
|
@@ -435,7 +436,7 @@ var hasExternalRef = (root) => {
|
|
|
435
436
|
}
|
|
436
437
|
return false;
|
|
437
438
|
};
|
|
438
|
-
var isHttpUrl = (value) =>
|
|
439
|
+
var isHttpUrl = (value) => /^https?:\/\//i.test(value);
|
|
439
440
|
var parseJson = (text) => {
|
|
440
441
|
try {
|
|
441
442
|
const value = JSON.parse(text);
|
|
@@ -450,7 +451,7 @@ var readSpecText = async (spec) => {
|
|
|
450
451
|
headers: { accept: "application/json, text/yaml, */*" }
|
|
451
452
|
});
|
|
452
453
|
if (!response.ok) {
|
|
453
|
-
await
|
|
454
|
+
await _chunkIBZFPUBFcjs.cancelResponseBody.call(void 0, response);
|
|
454
455
|
throw new Error(
|
|
455
456
|
`Failed to fetch the OpenAPI document from ${spec}: ${response.status} ${response.statusText}`
|
|
456
457
|
);
|
|
@@ -529,7 +530,7 @@ var mergeParameters = (pathLevel, operationLevel) => {
|
|
|
529
530
|
(parameter) => !overridden.has(`${parameter.in}:${parameter.name}`)
|
|
530
531
|
),
|
|
531
532
|
...operationLevel
|
|
532
|
-
].filter((parameter) => _optionalChain([parameter, 'optionalAccess',
|
|
533
|
+
].filter((parameter) => _optionalChain([parameter, 'optionalAccess', _9 => _9.name]) && parameter.in);
|
|
533
534
|
};
|
|
534
535
|
var resolvePathItem = (document, pathItem) => {
|
|
535
536
|
const followed = /* @__PURE__ */ new Set();
|
|
@@ -571,7 +572,7 @@ var readPointer = (root, pointer) => {
|
|
|
571
572
|
let node = root;
|
|
572
573
|
for (const rawSegment of path.slice(1).split("/")) {
|
|
573
574
|
const segment = decodeSegment(rawSegment);
|
|
574
|
-
node = _optionalChain([node, 'optionalAccess',
|
|
575
|
+
node = _optionalChain([node, 'optionalAccess', _10 => _10[segment]]);
|
|
575
576
|
}
|
|
576
577
|
return node;
|
|
577
578
|
};
|
|
@@ -602,7 +603,7 @@ var generateToolNames = (routes, override) => {
|
|
|
602
603
|
return names;
|
|
603
604
|
};
|
|
604
605
|
var baseNameFor = (route, override) => {
|
|
605
|
-
const explicit = typeof override === "function" ? override(toOperationSummary(route)) : route.operationId
|
|
606
|
+
const explicit = typeof override === "function" ? override(toOperationSummary(route)) : route.operationId && override && Object.hasOwn(override, route.operationId) ? override[route.operationId] : void 0;
|
|
606
607
|
if (explicit) {
|
|
607
608
|
return explicit;
|
|
608
609
|
}
|
|
@@ -797,24 +798,24 @@ var buildToolBinding = (route, normalizer, withOutputSchema) => {
|
|
|
797
798
|
parameter
|
|
798
799
|
]);
|
|
799
800
|
}
|
|
800
|
-
const collides = (name, occurrences) => occurrences.length > 1 || body.properties.has(name);
|
|
801
|
+
const collides = (name, occurrences) => name === "__proto__" || occurrences.length > 1 || body.properties.has(name);
|
|
801
802
|
const takenKeys = new Set(body.properties.keys());
|
|
802
803
|
for (const [name, occurrences] of byName) {
|
|
803
804
|
if (!collides(name, occurrences)) {
|
|
804
805
|
takenKeys.add(name);
|
|
805
806
|
}
|
|
806
807
|
}
|
|
808
|
+
const claimKey = (base) => {
|
|
809
|
+
let key = base;
|
|
810
|
+
for (let suffix = 2; takenKeys.has(key); suffix++) {
|
|
811
|
+
key = `${base}_${suffix}`;
|
|
812
|
+
}
|
|
813
|
+
takenKeys.add(key);
|
|
814
|
+
return key;
|
|
815
|
+
};
|
|
807
816
|
for (const [name, occurrences] of byName) {
|
|
808
817
|
for (const parameter of occurrences) {
|
|
809
|
-
|
|
810
|
-
if (collides(name, occurrences)) {
|
|
811
|
-
const base = `${name}__${parameter.in}`;
|
|
812
|
-
key = base;
|
|
813
|
-
for (let suffix = 2; takenKeys.has(key); suffix++) {
|
|
814
|
-
key = `${base}_${suffix}`;
|
|
815
|
-
}
|
|
816
|
-
takenKeys.add(key);
|
|
817
|
-
}
|
|
818
|
+
const key = collides(name, occurrences) ? claimKey(`${name}__${parameter.in}`) : name;
|
|
818
819
|
properties[key] = describeParameter(parameter, normalizer);
|
|
819
820
|
parameters[key] = { kind: "parameter", parameter };
|
|
820
821
|
if (parameter.in === "path" || parameter.required) {
|
|
@@ -823,10 +824,11 @@ var buildToolBinding = (route, normalizer, withOutputSchema) => {
|
|
|
823
824
|
}
|
|
824
825
|
}
|
|
825
826
|
for (const [name, property] of body.properties) {
|
|
826
|
-
|
|
827
|
-
|
|
827
|
+
const key = name === "__proto__" ? claimKey(`${name}__body`) : name;
|
|
828
|
+
properties[key] = property.schema;
|
|
829
|
+
parameters[key] = { kind: "body", name };
|
|
828
830
|
if (property.required) {
|
|
829
|
-
required.push(
|
|
831
|
+
required.push(key);
|
|
830
832
|
}
|
|
831
833
|
}
|
|
832
834
|
const inputSchema = {
|
|
@@ -841,6 +843,7 @@ var buildToolBinding = (route, normalizer, withOutputSchema) => {
|
|
|
841
843
|
}
|
|
842
844
|
return {
|
|
843
845
|
bodyEncoding: body.encoding,
|
|
846
|
+
bodyRequired: body.required,
|
|
844
847
|
caveat: body.caveat,
|
|
845
848
|
inputSchema,
|
|
846
849
|
outputSchema: withOutputSchema ? buildOutputSchema(route, normalizer) : void 0,
|
|
@@ -868,10 +871,10 @@ var describeBody = (route, normalizer) => {
|
|
|
868
871
|
const schema = rawSchema ? normalizer.normalize(rawSchema) : void 0;
|
|
869
872
|
if (kind === "text") {
|
|
870
873
|
properties.set("body", { required, schema: _nullishCoalesce(schema, () => ( { type: "string" })) });
|
|
871
|
-
return { encoding, properties, wholeBodyKey: "body" };
|
|
874
|
+
return { encoding, properties, required, wholeBodyKey: "body" };
|
|
872
875
|
}
|
|
873
876
|
if (!schema) {
|
|
874
|
-
return { encoding, properties };
|
|
877
|
+
return { encoding, properties, required };
|
|
875
878
|
}
|
|
876
879
|
const object = flattenObject(schema, normalizer.definitions);
|
|
877
880
|
if (object && Object.keys(object.properties).length > 0) {
|
|
@@ -881,10 +884,10 @@ var describeBody = (route, normalizer) => {
|
|
|
881
884
|
schema: property
|
|
882
885
|
});
|
|
883
886
|
}
|
|
884
|
-
return { encoding, properties };
|
|
887
|
+
return { encoding, properties, required };
|
|
885
888
|
}
|
|
886
889
|
properties.set("body", { required, schema });
|
|
887
|
-
return { encoding, properties, wholeBodyKey: "body" };
|
|
890
|
+
return { encoding, properties, required, wholeBodyKey: "body" };
|
|
888
891
|
};
|
|
889
892
|
var MAX_OUTPUT_SCHEMA_DEFINITIONS = 100;
|
|
890
893
|
var buildOutputSchema = (route, normalizer) => {
|
|
@@ -929,7 +932,7 @@ var flattenObject = (schema, definitions, depth = 0) => {
|
|
|
929
932
|
);
|
|
930
933
|
}
|
|
931
934
|
if (Array.isArray(schema.allOf) && schema.allOf.length > 0) {
|
|
932
|
-
const properties2 =
|
|
935
|
+
const properties2 = /* @__PURE__ */ Object.create(null);
|
|
933
936
|
const required = /* @__PURE__ */ new Set();
|
|
934
937
|
for (const branch of schema.allOf) {
|
|
935
938
|
const part = flattenObject(
|
|
@@ -1029,7 +1032,7 @@ var fromOpenAPI = async (options) => {
|
|
|
1029
1032
|
const selected = selectRoutes(extractRoutes(document), options);
|
|
1030
1033
|
const names = generateToolNames(selected, options.toolNames);
|
|
1031
1034
|
const normalizer = createSchemaNormalizer(document);
|
|
1032
|
-
const server = _nullishCoalesce(options.server, () => ( new (0,
|
|
1035
|
+
const server = _nullishCoalesce(options.server, () => ( new (0, _chunkIBZFPUBFcjs.ViteMCP)({
|
|
1033
1036
|
description: _optionalChain([document, 'access', _23 => _23.info, 'optionalAccess', _24 => _24.description]),
|
|
1034
1037
|
name: _nullishCoalesce(_nullishCoalesce(options.name, () => ( _optionalChain([document, 'access', _25 => _25.info, 'optionalAccess', _26 => _26.title]))), () => ( "OpenAPI")),
|
|
1035
1038
|
version: _nullishCoalesce(options.version, () => ( semanticVersion(_optionalChain([document, 'access', _27 => _27.info, 'optionalAccess', _28 => _28.version]))))
|
|
@@ -1068,8 +1071,8 @@ var fromOpenAPI = async (options) => {
|
|
|
1068
1071
|
route
|
|
1069
1072
|
}),
|
|
1070
1073
|
name,
|
|
1071
|
-
outputSchema: binding.outputSchema ?
|
|
1072
|
-
parameters:
|
|
1074
|
+
outputSchema: binding.outputSchema ? _chunkIBZFPUBFcjs.jsonSchemaAdapter.call(void 0, binding.outputSchema) : void 0,
|
|
1075
|
+
parameters: _chunkIBZFPUBFcjs.jsonSchemaAdapter.call(void 0, binding.inputSchema),
|
|
1073
1076
|
timeoutMs: options.timeoutMs
|
|
1074
1077
|
});
|
|
1075
1078
|
}
|