@vitemcp/server 1.9.3 → 1.9.4
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 +3 -3
- package/dist/ViteMCP.js +2 -2
- package/dist/chunk-4LNVOTEL.js +115 -0
- package/dist/chunk-4LNVOTEL.js.map +1 -0
- package/dist/{chunk-3O5CBV4T.js → chunk-5RAYSJ4N.js} +3 -3
- package/dist/{chunk-3O5CBV4T.js.map → chunk-5RAYSJ4N.js.map} +1 -1
- package/dist/{chunk-SM24SJ4X.cjs → chunk-L6BHGIXM.cjs} +53 -16
- package/dist/chunk-L6BHGIXM.cjs.map +1 -0
- package/dist/{chunk-WRKQIQHB.cjs → chunk-OJUNDONA.cjs} +7 -7
- package/dist/{chunk-WRKQIQHB.cjs.map → chunk-OJUNDONA.cjs.map} +1 -1
- package/dist/edge/index.cjs +5 -5
- package/dist/edge/index.js +1 -1
- package/dist/openapi/index.cjs +12 -12
- package/dist/openapi/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-NKMXT32U.js +0 -78
- package/dist/chunk-NKMXT32U.js.map +0 -1
- package/dist/chunk-SM24SJ4X.cjs.map +0 -1
|
@@ -10,16 +10,53 @@ var formatBytes = (bytes) => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
// src/ownKeysOnly.ts
|
|
13
|
-
var ownKeysOnly = (schema) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
var ownKeysOnly = (schema) => Object.defineProperty(schema, "~standard", {
|
|
14
|
+
value: withOwnKeysOnly(schema["~standard"])
|
|
15
|
+
});
|
|
16
|
+
var withOwnKeysOnly = (standard) => ({
|
|
17
|
+
...standard,
|
|
18
|
+
validate: async (value) => {
|
|
19
|
+
const copies = /* @__PURE__ */ new Map();
|
|
20
|
+
const result = await standard.validate(withoutPrototypes(value, copies));
|
|
21
|
+
if (!result.issues && copies.size > 0) {
|
|
22
|
+
restorePrototypes(result.value, new Set(copies.values()), /* @__PURE__ */ new Set());
|
|
21
23
|
}
|
|
22
|
-
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
var withoutPrototypes = (value, copies) => {
|
|
28
|
+
if (!isPlain(value)) {
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
const existing = copies.get(value);
|
|
32
|
+
if (existing) {
|
|
33
|
+
return existing;
|
|
34
|
+
}
|
|
35
|
+
const copy = Array.isArray(value) ? [] : /* @__PURE__ */ Object.create(null);
|
|
36
|
+
copies.set(value, copy);
|
|
37
|
+
for (const [key, item] of Object.entries(value)) {
|
|
38
|
+
copy[key] = withoutPrototypes(item, copies);
|
|
39
|
+
}
|
|
40
|
+
return copy;
|
|
41
|
+
};
|
|
42
|
+
var restorePrototypes = (value, copies, seen) => {
|
|
43
|
+
if (!isPlain(value) || seen.has(value)) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
seen.add(value);
|
|
47
|
+
if (copies.has(value) && !Array.isArray(value)) {
|
|
48
|
+
Object.setPrototypeOf(value, Object.prototype);
|
|
49
|
+
}
|
|
50
|
+
for (const item of Object.values(value)) {
|
|
51
|
+
restorePrototypes(item, copies, seen);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var isPlain = (value) => {
|
|
55
|
+
if (typeof value !== "object" || value === null) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
const prototype = Object.getPrototypeOf(value);
|
|
59
|
+
return Array.isArray(value) || prototype === Object.prototype || prototype === null;
|
|
23
60
|
};
|
|
24
61
|
|
|
25
62
|
// src/toSdkSchema.ts
|
|
@@ -27,18 +64,18 @@ var toSdkSchema = async (schema, io, convert) => {
|
|
|
27
64
|
if (!schema) {
|
|
28
65
|
return void 0;
|
|
29
66
|
}
|
|
30
|
-
const standard =
|
|
67
|
+
const standard = withOwnKeysOnly(
|
|
68
|
+
schema["~standard"]
|
|
69
|
+
);
|
|
31
70
|
if (standard.jsonSchema) {
|
|
32
|
-
return
|
|
71
|
+
return { "~standard": standard };
|
|
33
72
|
}
|
|
34
73
|
const json = await convert(schema, io);
|
|
35
74
|
const advertised = io === "input" ? strictInputSchema(json) : json;
|
|
36
75
|
return {
|
|
37
76
|
"~standard": {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
vendor: standard.vendor,
|
|
41
|
-
version: standard.version
|
|
77
|
+
...standard,
|
|
78
|
+
jsonSchema: { input: () => advertised, output: () => advertised }
|
|
42
79
|
}
|
|
43
80
|
};
|
|
44
81
|
};
|
|
@@ -75,4 +112,4 @@ var strictInputSchema = (schema) => ({
|
|
|
75
112
|
|
|
76
113
|
|
|
77
114
|
exports.formatBytes = formatBytes; exports.ownKeysOnly = ownKeysOnly; exports.toSdkSchema = toSdkSchema; exports.valibotToJsonSchema = valibotToJsonSchema;
|
|
78
|
-
//# sourceMappingURL=chunk-
|
|
115
|
+
//# sourceMappingURL=chunk-L6BHGIXM.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/server/server/dist/chunk-L6BHGIXM.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;AECC;AAEF,EAAA;AACR;AAkBU;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;AF5DY;AACA;AG5BC;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;AHbY;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/server/server/dist/chunk-L6BHGIXM.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 */\nexport const ownKeysOnly = <S extends StandardSchemaV1>(schema: S): S =>\n Object.defineProperty(schema, \"~standard\", {\n value: withOwnKeysOnly(schema[\"~standard\"]),\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"]}
|
|
@@ -6,7 +6,7 @@ var _chunkP32QRCBTcjs = require('./chunk-P32QRCBT.cjs');
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkL6BHGIXMcjs = require('./chunk-L6BHGIXM.cjs');
|
|
10
10
|
|
|
11
11
|
// src/ViteMCP.ts
|
|
12
12
|
|
|
@@ -368,7 +368,7 @@ async function compileSchema(schema) {
|
|
|
368
368
|
);
|
|
369
369
|
}
|
|
370
370
|
const Ajv = unwrapDefault(unwrapDefault(ajvModule));
|
|
371
|
-
const ajv = new Ajv({ allErrors: true, strict: false });
|
|
371
|
+
const ajv = new Ajv({ allErrors: true, ownProperties: true, strict: false });
|
|
372
372
|
try {
|
|
373
373
|
const formatsModule = await Promise.resolve().then(() => _interopRequireWildcard(require("ajv-formats")));
|
|
374
374
|
const addFormats = unwrapDefault(
|
|
@@ -1214,7 +1214,7 @@ var ViteMCP = class {
|
|
|
1214
1214
|
res.end(
|
|
1215
1215
|
JSON.stringify({
|
|
1216
1216
|
error: "invalid_request",
|
|
1217
|
-
error_description: `Request body exceeds ${
|
|
1217
|
+
error_description: `Request body exceeds ${_chunkL6BHGIXMcjs.formatBytes.call(void 0, maxBodySize)}`
|
|
1218
1218
|
})
|
|
1219
1219
|
);
|
|
1220
1220
|
return;
|
|
@@ -1289,7 +1289,7 @@ var ViteMCP = class {
|
|
|
1289
1289
|
*/
|
|
1290
1290
|
async #toSdkSchema(schema, label, io) {
|
|
1291
1291
|
try {
|
|
1292
|
-
return await
|
|
1292
|
+
return await _chunkL6BHGIXMcjs.toSdkSchema.call(void 0, schema, io, convertToJsonSchema);
|
|
1293
1293
|
} catch (error) {
|
|
1294
1294
|
throw new UnexpectedStateError(
|
|
1295
1295
|
`${label} is not a supported Standard Schema: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -1426,7 +1426,7 @@ var readCappedNodeBody = async (req, maxBytes) => {
|
|
|
1426
1426
|
}
|
|
1427
1427
|
return Buffer.concat(chunks);
|
|
1428
1428
|
};
|
|
1429
|
-
var convertToJsonSchema = async (schema, io) => schema["~standard"].vendor === "valibot" ?
|
|
1429
|
+
var convertToJsonSchema = async (schema, io) => schema["~standard"].vendor === "valibot" ? _chunkL6BHGIXMcjs.valibotToJsonSchema.call(void 0, schema, io) : _xsschema.toJsonSchema.call(void 0, schema);
|
|
1430
1430
|
var assertStandardSchema = (schema, toolName, field) => {
|
|
1431
1431
|
if (schema === void 0) {
|
|
1432
1432
|
return;
|
|
@@ -1463,7 +1463,7 @@ var promptArgsSchema = (prompt) => {
|
|
|
1463
1463
|
) : described;
|
|
1464
1464
|
shape[arg.name] = arg.required ? base : base.optional();
|
|
1465
1465
|
}
|
|
1466
|
-
return
|
|
1466
|
+
return _chunkL6BHGIXMcjs.ownKeysOnly.call(void 0, _zod.z.object(shape));
|
|
1467
1467
|
};
|
|
1468
1468
|
var isStructuredResult = (value) => {
|
|
1469
1469
|
if (!Object.hasOwn(value, "structuredContent") || value.structuredContent === void 0) {
|
|
@@ -1532,4 +1532,4 @@ var normalizeToolResult = (result, hasOutputSchema) => {
|
|
|
1532
1532
|
|
|
1533
1533
|
|
|
1534
1534
|
exports.cancelResponseBody = cancelResponseBody; exports.DiscoveryDocumentCache = DiscoveryDocumentCache; exports.jsonSchemaAdapter = jsonSchemaAdapter; exports.delay = _promises5.setTimeout; exports.MEDIA_FETCH_TIMEOUT_MS = MEDIA_FETCH_TIMEOUT_MS; exports.ViteMCPError = ViteMCPError; exports.UnexpectedStateError = UnexpectedStateError; exports.UserError = UserError; exports.imageContent = imageContent; exports.audioContent = audioContent; exports.ServerState = ServerState; exports.ViteMCP = ViteMCP;
|
|
1535
|
-
//# sourceMappingURL=chunk-
|
|
1535
|
+
//# sourceMappingURL=chunk-OJUNDONA.cjs.map
|