@vitemcp/server 1.10.2 → 1.10.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.
Files changed (35) hide show
  1. package/dist/{OAuthProvider-STkC4R2N.d.cts → OAuthProvider-DbC_47_h.d.cts} +38 -5
  2. package/dist/{OAuthProvider-STkC4R2N.d.ts → OAuthProvider-DbC_47_h.d.ts} +38 -5
  3. package/dist/ViteMCP.cjs +4 -4
  4. package/dist/ViteMCP.d.cts +2 -2
  5. package/dist/ViteMCP.d.ts +2 -2
  6. package/dist/ViteMCP.js +3 -3
  7. package/dist/auth/index.cjs +2 -2
  8. package/dist/auth/index.d.cts +2 -2
  9. package/dist/auth/index.d.ts +2 -2
  10. package/dist/auth/index.js +1 -1
  11. package/dist/{chunk-NLBRDP5F.js → chunk-3QRGEISD.js} +113 -42
  12. package/dist/chunk-3QRGEISD.js.map +1 -0
  13. package/dist/{chunk-FSPSPB7Y.cjs → chunk-K2UCX3GS.cjs} +9 -9
  14. package/dist/{chunk-FSPSPB7Y.cjs.map → chunk-K2UCX3GS.cjs.map} +1 -1
  15. package/dist/{chunk-4LU4AXU4.cjs → chunk-LVPE26OW.cjs} +121 -50
  16. package/dist/chunk-LVPE26OW.cjs.map +1 -0
  17. package/dist/{chunk-3W6VP3KX.js → chunk-QYNWHXTM.js} +3 -3
  18. package/dist/{chunk-NZGRSB2D.cjs → chunk-R4RK2DR2.cjs} +147 -3
  19. package/dist/chunk-R4RK2DR2.cjs.map +1 -0
  20. package/dist/{chunk-BLXUZUZ4.js → chunk-YDEROYNS.js} +147 -3
  21. package/dist/chunk-YDEROYNS.js.map +1 -0
  22. package/dist/edge/index.cjs +6 -6
  23. package/dist/edge/index.js +1 -1
  24. package/dist/openapi/index.cjs +23 -16
  25. package/dist/openapi/index.cjs.map +1 -1
  26. package/dist/openapi/index.d.cts +3 -3
  27. package/dist/openapi/index.d.ts +3 -3
  28. package/dist/openapi/index.js +13 -6
  29. package/dist/openapi/index.js.map +1 -1
  30. package/package.json +1 -1
  31. package/dist/chunk-4LU4AXU4.cjs.map +0 -1
  32. package/dist/chunk-BLXUZUZ4.js.map +0 -1
  33. package/dist/chunk-NLBRDP5F.js.map +0 -1
  34. package/dist/chunk-NZGRSB2D.cjs.map +0 -1
  35. /package/dist/{chunk-3W6VP3KX.js.map → chunk-QYNWHXTM.js.map} +0 -0
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  withoutTrailingSlash
3
- } from "./chunk-NLBRDP5F.js";
3
+ } from "./chunk-3QRGEISD.js";
4
4
  import {
5
5
  formatBytes,
6
6
  ownKeysOnly,
7
7
  resolveMaxToolInputElements,
8
8
  toSdkSchema,
9
9
  valibotToJsonSchema
10
- } from "./chunk-BLXUZUZ4.js";
10
+ } from "./chunk-YDEROYNS.js";
11
11
 
12
12
  // src/ViteMCP.ts
13
13
  import {
@@ -1711,4 +1711,4 @@ export {
1711
1711
  ServerState,
1712
1712
  ViteMCP
1713
1713
  };
1714
- //# sourceMappingURL=chunk-3W6VP3KX.js.map
1714
+ //# sourceMappingURL=chunk-QYNWHXTM.js.map
@@ -79,6 +79,145 @@ var resolveMaxToolInputElements = (value) => {
79
79
  return value;
80
80
  };
81
81
 
82
+ // src/mergeObjectIntersections.ts
83
+ var SUBSCHEMA = /* @__PURE__ */ new Set([
84
+ "additionalItems",
85
+ "additionalProperties",
86
+ "contains",
87
+ "else",
88
+ "if",
89
+ "not",
90
+ "propertyNames",
91
+ "then",
92
+ "unevaluatedItems",
93
+ "unevaluatedProperties"
94
+ ]);
95
+ var SUBSCHEMA_LIST = /* @__PURE__ */ new Set(["allOf", "anyOf", "oneOf", "prefixItems"]);
96
+ var SUBSCHEMA_MAP = /* @__PURE__ */ new Set([
97
+ "$defs",
98
+ "definitions",
99
+ "dependentSchemas",
100
+ "patternProperties",
101
+ "properties"
102
+ ]);
103
+ var OPERAND_KEYWORDS = /* @__PURE__ */ new Set([
104
+ "additionalProperties",
105
+ "description",
106
+ "properties",
107
+ "required",
108
+ "title",
109
+ "type"
110
+ ]);
111
+ var HOST_KEYWORDS = /* @__PURE__ */ new Set([
112
+ "$defs",
113
+ "$id",
114
+ "$schema",
115
+ "allOf",
116
+ "definitions",
117
+ "description",
118
+ "title",
119
+ "type"
120
+ ]);
121
+ var mergeObjectIntersections = (schema) => walk(schema);
122
+ var walk = (schema) => {
123
+ if (!isSchema(schema)) {
124
+ return schema;
125
+ }
126
+ const entries = Object.entries(schema);
127
+ const walked = entries.map(([keyword, value]) => [
128
+ keyword,
129
+ walkKeyword(keyword, value)
130
+ ]);
131
+ const node = walked.some(([, value], index) => value !== entries[index][1]) ? Object.fromEntries(walked) : schema;
132
+ return _nullishCoalesce(mergeAllOf(node), () => ( node));
133
+ };
134
+ var walkKeyword = (keyword, value) => {
135
+ if (keyword === "items") {
136
+ return Array.isArray(value) ? walkList(value) : walk(value);
137
+ }
138
+ if (SUBSCHEMA.has(keyword)) {
139
+ return walk(value);
140
+ }
141
+ if (SUBSCHEMA_LIST.has(keyword)) {
142
+ return Array.isArray(value) ? walkList(value) : value;
143
+ }
144
+ if (SUBSCHEMA_MAP.has(keyword) && isSchema(value)) {
145
+ const entries = Object.entries(value);
146
+ const walked = entries.map(([name, subschema]) => [
147
+ name,
148
+ walk(subschema)
149
+ ]);
150
+ return walked.some(
151
+ ([, subschema], index) => subschema !== entries[index][1]
152
+ ) ? Object.fromEntries(walked) : value;
153
+ }
154
+ return value;
155
+ };
156
+ var walkList = (list) => {
157
+ const walked = list.map(walk);
158
+ return walked.some((item, index) => item !== list[index]) ? walked : list;
159
+ };
160
+ var mergeAllOf = (node) => {
161
+ const operands = node.allOf;
162
+ if (!Array.isArray(operands) || operands.length === 0 || Object.keys(node).some((keyword) => !HOST_KEYWORDS.has(keyword)) || node.type !== void 0 && node.type !== "object" || !operands.every(isObjectOperand)) {
163
+ return void 0;
164
+ }
165
+ const closures = operands.map(closureOf);
166
+ if (closures.includes(void 0) || !closures.includes("closed")) {
167
+ return void 0;
168
+ }
169
+ const declared = /* @__PURE__ */ new Map();
170
+ const required = /* @__PURE__ */ new Set();
171
+ for (const operand of operands) {
172
+ for (const [name, subschema] of Object.entries(_nullishCoalesce(operand.properties, () => ( {})))) {
173
+ declared.set(name, [..._nullishCoalesce(declared.get(name), () => ( [])), subschema]);
174
+ }
175
+ for (const name of _nullishCoalesce(operand.required, () => ( []))) {
176
+ required.add(name);
177
+ }
178
+ }
179
+ const properties = [...declared].map(
180
+ ([name, declarations]) => {
181
+ const distinct = [
182
+ ...new Map(
183
+ declarations.map((declaration) => [
184
+ JSON.stringify(declaration),
185
+ declaration
186
+ ])
187
+ ).values()
188
+ ];
189
+ if (distinct.length === 1) {
190
+ return [name, distinct[0]];
191
+ }
192
+ const intersection = { allOf: distinct };
193
+ return [name, _nullishCoalesce(mergeAllOf(intersection), () => ( intersection))];
194
+ }
195
+ );
196
+ return {
197
+ ...Object.fromEntries(
198
+ Object.entries(node).filter(([keyword]) => keyword !== "allOf")
199
+ ),
200
+ ...closures.every((closure) => closure === "closed") && {
201
+ additionalProperties: false
202
+ },
203
+ properties: Object.fromEntries(properties),
204
+ ...required.size > 0 && { required: [...required] },
205
+ type: "object"
206
+ };
207
+ };
208
+ var isObjectOperand = (operand) => isSchema(operand) && operand.type === "object" && Object.keys(operand).every((keyword) => OPERAND_KEYWORDS.has(keyword)) && (operand.properties === void 0 || isSchema(operand.properties)) && (operand.required === void 0 || Array.isArray(operand.required) && operand.required.every((name) => typeof name === "string"));
209
+ var closureOf = (operand) => {
210
+ const rest = operand.additionalProperties;
211
+ if (rest === false) {
212
+ return "closed";
213
+ }
214
+ if (rest === void 0 || rest === true || isSchema(rest) && Object.keys(rest).length === 0) {
215
+ return "open";
216
+ }
217
+ return void 0;
218
+ };
219
+ var isSchema = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
220
+
82
221
  // src/toSdkSchema.ts
83
222
  var SDK_TARGET = "draft-2020-12";
84
223
  var LENIENT_OPTIONS = /* @__PURE__ */ new Map([
@@ -99,11 +238,15 @@ var toSdkSchema = async (schema, io, convert) => {
99
238
  io
100
239
  );
101
240
  assertDescribesArguments(json2, io);
102
- return lenient ? advertising(standard, json2) : { "~standard": standard };
241
+ const advertised = io === "output" ? advertisedOutput(json2, standard.vendor) : json2;
242
+ return lenient || advertised !== json2 ? advertising(standard, advertised) : { "~standard": standard };
103
243
  }
104
244
  const json = await convert(schema, io);
105
245
  assertDescribesArguments(json, io);
106
- return advertising(standard, io === "input" ? strictInputSchema(json) : json);
246
+ return advertising(
247
+ standard,
248
+ io === "input" ? strictInputSchema(json) : advertisedOutput(json, standard.vendor)
249
+ );
107
250
  };
108
251
  var valibotToJsonSchema = async (schema, io) => {
109
252
  let converter;
@@ -119,6 +262,7 @@ var valibotToJsonSchema = async (schema, io) => {
119
262
  typeMode: io
120
263
  });
121
264
  };
265
+ var advertisedOutput = (json, vendor) => vendor === "zod" ? mergeObjectIntersections(json) : json;
122
266
  var advertising = (standard, advertised) => ({
123
267
  "~standard": {
124
268
  ...standard,
@@ -170,4 +314,4 @@ var strictInputSchema = (schema) => ({
170
314
 
171
315
 
172
316
  exports.formatBytes = formatBytes; exports.ownKeysOnly = ownKeysOnly; exports.resolveMaxToolInputElements = resolveMaxToolInputElements; exports.toSdkSchema = toSdkSchema; exports.valibotToJsonSchema = valibotToJsonSchema;
173
- //# sourceMappingURL=chunk-NZGRSB2D.cjs.map
317
+ //# sourceMappingURL=chunk-R4RK2DR2.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/server/server/dist/chunk-R4RK2DR2.cjs","../src/formatBytes.ts","../src/ownKeysOnly.ts","../src/toolInputLimit.ts","../src/mergeObjectIntersections.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,I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,IAAA;AAGT,EAAA;AAEM,EAAA;AAEN,EAAA;AAEO,EAAA;AACL,IAAA;AACO,IAAA;AAGT,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;AAIA;AAIJ,EAAA;AACK,IAAA;AACH,IAAA;AACF,EAAA;AACF;AAQM;AAIA,EAAA;AACI,IAAA;AACJ,MAAA;AACE,QAAA;AACD,MAAA;AACH,IAAA;AACF,EAAA;AACF;AAMM;AAKA,EAAA;AACK,IAAA;AACA,EAAA;AACD,IAAA;AAED,IAAA;AACG,MAAA;AACR,IAAA;AAEO,IAAA;AACC,MAAA;AACN,MAAA;AACF,IAAA;AACF,EAAA;AACF;AAeM;AACD,EAAA;AACG,EAAA;AACJ,IAAA;AAIF,EAAA;AACW,EAAA;AACT,IAAA;AACE,MAAA;AACE,QAAA;AACA,QAAA;AAGD,MAAA;AACH,IAAA;AACF,EAAA;AACF;ALyDY;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/server/server/dist/chunk-R4RK2DR2.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","/**\n * `maxToolInputElements` when a server sets none.\n *\n * Validation keeps every issue it finds, so what checking one call costs grows\n * with how many elements its arguments hold, and a cap on the body does not\n * bound it: half a million invalid elements fit in 1 MiB, and Zod kept half a\n * gigabyte of issues reporting them. Ten thousand keep that near 8 MB.\n */\nconst DEFAULT_MAX_TOOL_INPUT_ELEMENTS = 10_000;\n\n/**\n * The limit a server was given, or the default, refused where the SDK would\n * refuse it. The SDK checks as it builds a server, and a server is built for\n * every request: checked once up front, a bad value stops the server from\n * being created rather than failing every request it would have answered.\n */\nexport const resolveMaxToolInputElements = (\n value: number | undefined,\n): number => {\n if (value === undefined) {\n return DEFAULT_MAX_TOOL_INPUT_ELEMENTS;\n }\n\n if (typeof value !== \"number\" || Number.isNaN(value) || value < 1) {\n throw new RangeError(\n `maxToolInputElements must be a number of at least 1, or Infinity, got ${String(value)}`,\n );\n }\n\n return value;\n};\n","import type { JsonSchema } from \"xsschema\";\n\ntype Schema = Record<string, unknown>;\n\n/** Keywords whose value is one subschema. */\nconst SUBSCHEMA = new Set([\n \"additionalItems\",\n \"additionalProperties\",\n \"contains\",\n \"else\",\n \"if\",\n \"not\",\n \"propertyNames\",\n \"then\",\n \"unevaluatedItems\",\n \"unevaluatedProperties\",\n]);\n\n/** Keywords whose value is a list of subschemas. */\nconst SUBSCHEMA_LIST = new Set([\"allOf\", \"anyOf\", \"oneOf\", \"prefixItems\"]);\n\n/** Keywords whose value maps names to subschemas. */\nconst SUBSCHEMA_MAP = new Set([\n \"$defs\",\n \"definitions\",\n \"dependentSchemas\",\n \"patternProperties\",\n \"properties\",\n]);\n\n/** What an operand may say and still be merged: an object's shape, and labels. */\nconst OPERAND_KEYWORDS = new Set([\n \"additionalProperties\",\n \"description\",\n \"properties\",\n \"required\",\n \"title\",\n \"type\",\n]);\n\n/** What may sit beside an `allOf` that is merged, and stays there. */\nconst HOST_KEYWORDS = new Set([\n \"$defs\",\n \"$id\",\n \"$schema\",\n \"allOf\",\n \"definitions\",\n \"description\",\n \"title\",\n \"type\",\n]);\n\n/**\n * An output schema with each intersection of objects that closes one of them\n * merged into a single object.\n *\n * Zod describes `a.and(b)` as an `allOf` of the two and, in output mode,\n * closes each `z.object()` to the keys it declares, since parsing strips the\n * rest. Under `allOf` every operand has to accept the whole result, and each\n * refuses the keys the others declare, so the schema matched no result at\n * all: the client refused every one, though Zod had just produced it. Zod\n * merges them itself from 4.5 on.\n *\n * The merged object declares every operand's properties, requires what any of\n * them required, and is closed only if all of them were: a key one operand\n * leaves open can reach the result. A property declared twice, differently,\n * must match both declarations, so it becomes an `allOf` of them, merged the\n * same way.\n *\n * Anything else is left as it was: an operand behind a `$ref`, one with a rest\n * schema or composition of its own, or an `allOf` with no closed operand,\n * which every result can already satisfy. Only subschemas are walked; `const`,\n * `default`, `enum` and `examples` hold data, which may look like a schema.\n * Returns `schema` itself when nothing was merged.\n */\nexport const mergeObjectIntersections = (schema: JsonSchema): JsonSchema =>\n walk(schema) as JsonSchema;\n\nconst walk = (schema: unknown): unknown => {\n if (!isSchema(schema)) {\n return schema;\n }\n\n const entries = Object.entries(schema);\n const walked = entries.map(([keyword, value]): [string, unknown] => [\n keyword,\n walkKeyword(keyword, value),\n ]);\n const node = walked.some(([, value], index) => value !== entries[index][1])\n ? (Object.fromEntries(walked) as Schema)\n : schema;\n\n return mergeAllOf(node) ?? node;\n};\n\nconst walkKeyword = (keyword: string, value: unknown): unknown => {\n // `items` is one subschema, or a list of them before draft 2020-12.\n if (keyword === \"items\") {\n return Array.isArray(value) ? walkList(value) : walk(value);\n }\n\n if (SUBSCHEMA.has(keyword)) {\n return walk(value);\n }\n\n if (SUBSCHEMA_LIST.has(keyword)) {\n return Array.isArray(value) ? walkList(value) : value;\n }\n\n if (SUBSCHEMA_MAP.has(keyword) && isSchema(value)) {\n const entries = Object.entries(value);\n const walked = entries.map(([name, subschema]): [string, unknown] => [\n name,\n walk(subschema),\n ]);\n\n return walked.some(\n ([, subschema], index) => subschema !== entries[index][1],\n )\n ? Object.fromEntries(walked)\n : value;\n }\n\n return value;\n};\n\nconst walkList = (list: unknown[]): unknown[] => {\n const walked = list.map(walk);\n\n return walked.some((item, index) => item !== list[index]) ? walked : list;\n};\n\n/** `node` with its `allOf` merged into one object, if it should be. */\nconst mergeAllOf = (node: Schema): Schema | undefined => {\n const operands = node.allOf;\n\n if (\n !Array.isArray(operands) ||\n operands.length === 0 ||\n Object.keys(node).some((keyword) => !HOST_KEYWORDS.has(keyword)) ||\n (node.type !== undefined && node.type !== \"object\") ||\n !operands.every(isObjectOperand)\n ) {\n return undefined;\n }\n\n const closures = operands.map(closureOf);\n\n if (closures.includes(undefined) || !closures.includes(\"closed\")) {\n return undefined;\n }\n\n const declared = new Map<string, unknown[]>();\n const required = new Set<string>();\n\n for (const operand of operands) {\n for (const [name, subschema] of Object.entries(operand.properties ?? {})) {\n declared.set(name, [...(declared.get(name) ?? []), subschema]);\n }\n\n for (const name of operand.required ?? []) {\n required.add(name);\n }\n }\n\n const properties = [...declared].map(\n ([name, declarations]): [string, unknown] => {\n const distinct = [\n ...new Map(\n declarations.map((declaration) => [\n JSON.stringify(declaration),\n declaration,\n ]),\n ).values(),\n ];\n\n if (distinct.length === 1) {\n return [name, distinct[0]];\n }\n\n const intersection = { allOf: distinct };\n\n return [name, mergeAllOf(intersection) ?? intersection];\n },\n );\n\n return {\n ...Object.fromEntries(\n Object.entries(node).filter(([keyword]) => keyword !== \"allOf\"),\n ),\n ...(closures.every((closure) => closure === \"closed\") && {\n additionalProperties: false,\n }),\n properties: Object.fromEntries(properties),\n ...(required.size > 0 && { required: [...required] }),\n type: \"object\",\n };\n};\n\ntype ObjectOperand = {\n properties?: Schema;\n required?: string[];\n} & Schema;\n\nconst isObjectOperand = (operand: unknown): operand is ObjectOperand =>\n isSchema(operand) &&\n operand.type === \"object\" &&\n Object.keys(operand).every((keyword) => OPERAND_KEYWORDS.has(keyword)) &&\n (operand.properties === undefined || isSchema(operand.properties)) &&\n (operand.required === undefined ||\n (Array.isArray(operand.required) &&\n operand.required.every((name) => typeof name === \"string\")));\n\n/**\n * Whether an operand refuses undeclared keys or allows any. `undefined` for a\n * rest schema, which constrains them in a way a merge would have to keep.\n */\nconst closureOf = (operand: ObjectOperand): \"closed\" | \"open\" | undefined => {\n const rest = operand.additionalProperties;\n\n if (rest === false) {\n return \"closed\";\n }\n\n if (\n rest === undefined ||\n rest === true ||\n (isSchema(rest) && Object.keys(rest).length === 0)\n ) {\n return \"open\";\n }\n\n return undefined;\n};\n\nconst isSchema = (value: unknown): value is Schema =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { JsonSchema } from \"xsschema\";\n\nimport { mergeObjectIntersections } from \"./mergeObjectIntersections.js\";\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 * `~standard.jsonSchema`, as Zod v4 and ArkType implement it. Declared here\n * because `@standard-schema/spec` 1.0 predates it.\n */\ntype NativeJsonSchema = Record<\n \"input\" | \"output\",\n (options: {\n libraryOptions?: Record<string, unknown>;\n target: string;\n }) => JsonSchema\n>;\n\n/** The draft the SDK asks a schema for when `tools/list` describes a tool. */\nconst SDK_TARGET = \"draft-2020-12\";\n\n/**\n * What a library is told so that it leaves open the parts of a schema JSON\n * Schema cannot say, rather than refuse the schema over them. Zod describes\n * such a part as `{}`. ArkType hands over what it had worked out before it\n * reached the part: `{}` for a `Date`, `{ type: \"string\" }` for a string under\n * a `narrow()`.\n *\n * A library not named here is left to refuse, and its tool is not served.\n */\nconst LENIENT_OPTIONS = new Map<string, Record<string, unknown>>([\n [\"arktype\", { fallback: (context: { base: JsonSchema }) => context.base }],\n [\"zod\", { unrepresentable: \"any\" }],\n]);\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 * A native schema is converted here too, once, the way the SDK will for\n * `tools/list`. The SDK converts every tool in the one handler, so a schema\n * its library refused to convert — a `z.date()`, a `z.bigint()`, an ArkType\n * `narrow()` — failed the list for every tool, though each could still be\n * called. One refused is asked for again with what JSON Schema cannot say left\n * open (see `LENIENT_OPTIONS`), which is what Valibot's converter is already\n * told, and that copy is advertised in place of the library's own.\n *\n * Converted inputs are closed with `strictInputSchema`. Outputs are not closed,\n * since that would misdescribe results the schema allows; a Zod output's\n * intersections of objects are merged instead (see `advertisedOutput`), and a\n * native schema with one is advertised from the merged copy.\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, when a\n * library refuses a schema even leniently, and for an input schema that does\n * not describe an object: each caller leaves that tool out and serves the rest.\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\": {\n jsonSchema?: NativeJsonSchema;\n } & StandardSchemaV1.Props;\n }\n )[\"~standard\"],\n );\n\n if (standard.jsonSchema) {\n const { json, lenient } = nativeJsonSchema(\n standard.jsonSchema,\n standard.vendor,\n io,\n );\n\n assertDescribesArguments(json, io);\n\n const advertised =\n io === \"output\" ? advertisedOutput(json, standard.vendor) : json;\n\n return lenient || advertised !== json\n ? advertising(standard, advertised)\n : { \"~standard\": standard };\n }\n\n const json = await convert(schema as StandardSchemaV1, io);\n\n assertDescribesArguments(json, io);\n\n return advertising(\n standard,\n io === \"input\"\n ? strictInputSchema(json)\n : advertisedOutput(json, standard.vendor),\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 * An output schema as advertised: Zod's with its intersections of objects\n * merged (see `mergeObjectIntersections`). Zod closes an output object whose\n * undeclared keys it strips, so only its intersections allow no result at\n * all. Another library's closed operand is a strict object, and its\n * intersection is refused at runtime as well, so it is described as it is.\n */\nconst advertisedOutput = (json: JsonSchema, vendor: string): JsonSchema =>\n vendor === \"zod\" ? mergeObjectIntersections(json) : json;\n\n/** `standard`, carrying `advertised` as its JSON Schema, input and output. */\nconst advertising = <P extends StandardSchemaV1.Props>(\n standard: P,\n advertised: JsonSchema,\n) => ({\n \"~standard\": {\n ...standard,\n jsonSchema: { input: () => advertised, output: () => advertised },\n },\n});\n\n/**\n * Refuses an input schema that describes anything but an object. A tool's\n * arguments are always one, and the SDK will not list a schema that says\n * otherwise: `parameters: z.string()` failed `tools/list` for every tool, as an\n * unconvertible schema did.\n */\nconst assertDescribesArguments = (\n json: JsonSchema,\n io: \"input\" | \"output\",\n): void => {\n if (io === \"input\" && json.type !== undefined && json.type !== \"object\") {\n throw new Error(\n `A tool's arguments are an object, and this schema describes ${JSON.stringify(\n json.type,\n )}. Wrap it in an object schema.`,\n );\n }\n};\n\n/**\n * A schema's own JSON Schema, and whether it had to be asked for leniently.\n * Throws what the library does when it refuses the schema either way.\n */\nconst nativeJsonSchema = (\n native: NativeJsonSchema,\n vendor: string,\n io: \"input\" | \"output\",\n): { json: JsonSchema; lenient: boolean } => {\n try {\n return { json: native[io]({ target: SDK_TARGET }), lenient: false };\n } catch (error) {\n const libraryOptions = LENIENT_OPTIONS.get(vendor);\n\n if (!libraryOptions) {\n throw error;\n }\n\n return {\n json: native[io]({ libraryOptions, target: SDK_TARGET }),\n lenient: true,\n };\n }\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 *\n * Nor is an object closed whose keys are declared elsewhere: in its `allOf`,\n * `anyOf` or `oneOf` branches — a `v.intersect()`, `v.union()` or\n * `v.variant()` — or behind a `$ref`, which is how a `v.lazy()` arrives.\n * `additionalProperties` sees only the `properties` beside it, so closing one\n * refused every key declared elsewhere, and every argument with them.\n */\nconst strictInputSchema = (schema: JsonSchema): JsonSchema => ({\n ...schema,\n ...(!(schema.allOf ?? schema.anyOf ?? schema.oneOf ?? schema.$ref) && {\n additionalProperties:\n typeof schema.additionalProperties === \"object\"\n ? schema.additionalProperties\n : false,\n }),\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"]}
@@ -79,6 +79,145 @@ var resolveMaxToolInputElements = (value) => {
79
79
  return value;
80
80
  };
81
81
 
82
+ // src/mergeObjectIntersections.ts
83
+ var SUBSCHEMA = /* @__PURE__ */ new Set([
84
+ "additionalItems",
85
+ "additionalProperties",
86
+ "contains",
87
+ "else",
88
+ "if",
89
+ "not",
90
+ "propertyNames",
91
+ "then",
92
+ "unevaluatedItems",
93
+ "unevaluatedProperties"
94
+ ]);
95
+ var SUBSCHEMA_LIST = /* @__PURE__ */ new Set(["allOf", "anyOf", "oneOf", "prefixItems"]);
96
+ var SUBSCHEMA_MAP = /* @__PURE__ */ new Set([
97
+ "$defs",
98
+ "definitions",
99
+ "dependentSchemas",
100
+ "patternProperties",
101
+ "properties"
102
+ ]);
103
+ var OPERAND_KEYWORDS = /* @__PURE__ */ new Set([
104
+ "additionalProperties",
105
+ "description",
106
+ "properties",
107
+ "required",
108
+ "title",
109
+ "type"
110
+ ]);
111
+ var HOST_KEYWORDS = /* @__PURE__ */ new Set([
112
+ "$defs",
113
+ "$id",
114
+ "$schema",
115
+ "allOf",
116
+ "definitions",
117
+ "description",
118
+ "title",
119
+ "type"
120
+ ]);
121
+ var mergeObjectIntersections = (schema) => walk(schema);
122
+ var walk = (schema) => {
123
+ if (!isSchema(schema)) {
124
+ return schema;
125
+ }
126
+ const entries = Object.entries(schema);
127
+ const walked = entries.map(([keyword, value]) => [
128
+ keyword,
129
+ walkKeyword(keyword, value)
130
+ ]);
131
+ const node = walked.some(([, value], index) => value !== entries[index][1]) ? Object.fromEntries(walked) : schema;
132
+ return mergeAllOf(node) ?? node;
133
+ };
134
+ var walkKeyword = (keyword, value) => {
135
+ if (keyword === "items") {
136
+ return Array.isArray(value) ? walkList(value) : walk(value);
137
+ }
138
+ if (SUBSCHEMA.has(keyword)) {
139
+ return walk(value);
140
+ }
141
+ if (SUBSCHEMA_LIST.has(keyword)) {
142
+ return Array.isArray(value) ? walkList(value) : value;
143
+ }
144
+ if (SUBSCHEMA_MAP.has(keyword) && isSchema(value)) {
145
+ const entries = Object.entries(value);
146
+ const walked = entries.map(([name, subschema]) => [
147
+ name,
148
+ walk(subschema)
149
+ ]);
150
+ return walked.some(
151
+ ([, subschema], index) => subschema !== entries[index][1]
152
+ ) ? Object.fromEntries(walked) : value;
153
+ }
154
+ return value;
155
+ };
156
+ var walkList = (list) => {
157
+ const walked = list.map(walk);
158
+ return walked.some((item, index) => item !== list[index]) ? walked : list;
159
+ };
160
+ var mergeAllOf = (node) => {
161
+ const operands = node.allOf;
162
+ if (!Array.isArray(operands) || operands.length === 0 || Object.keys(node).some((keyword) => !HOST_KEYWORDS.has(keyword)) || node.type !== void 0 && node.type !== "object" || !operands.every(isObjectOperand)) {
163
+ return void 0;
164
+ }
165
+ const closures = operands.map(closureOf);
166
+ if (closures.includes(void 0) || !closures.includes("closed")) {
167
+ return void 0;
168
+ }
169
+ const declared = /* @__PURE__ */ new Map();
170
+ const required = /* @__PURE__ */ new Set();
171
+ for (const operand of operands) {
172
+ for (const [name, subschema] of Object.entries(operand.properties ?? {})) {
173
+ declared.set(name, [...declared.get(name) ?? [], subschema]);
174
+ }
175
+ for (const name of operand.required ?? []) {
176
+ required.add(name);
177
+ }
178
+ }
179
+ const properties = [...declared].map(
180
+ ([name, declarations]) => {
181
+ const distinct = [
182
+ ...new Map(
183
+ declarations.map((declaration) => [
184
+ JSON.stringify(declaration),
185
+ declaration
186
+ ])
187
+ ).values()
188
+ ];
189
+ if (distinct.length === 1) {
190
+ return [name, distinct[0]];
191
+ }
192
+ const intersection = { allOf: distinct };
193
+ return [name, mergeAllOf(intersection) ?? intersection];
194
+ }
195
+ );
196
+ return {
197
+ ...Object.fromEntries(
198
+ Object.entries(node).filter(([keyword]) => keyword !== "allOf")
199
+ ),
200
+ ...closures.every((closure) => closure === "closed") && {
201
+ additionalProperties: false
202
+ },
203
+ properties: Object.fromEntries(properties),
204
+ ...required.size > 0 && { required: [...required] },
205
+ type: "object"
206
+ };
207
+ };
208
+ var isObjectOperand = (operand) => isSchema(operand) && operand.type === "object" && Object.keys(operand).every((keyword) => OPERAND_KEYWORDS.has(keyword)) && (operand.properties === void 0 || isSchema(operand.properties)) && (operand.required === void 0 || Array.isArray(operand.required) && operand.required.every((name) => typeof name === "string"));
209
+ var closureOf = (operand) => {
210
+ const rest = operand.additionalProperties;
211
+ if (rest === false) {
212
+ return "closed";
213
+ }
214
+ if (rest === void 0 || rest === true || isSchema(rest) && Object.keys(rest).length === 0) {
215
+ return "open";
216
+ }
217
+ return void 0;
218
+ };
219
+ var isSchema = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
220
+
82
221
  // src/toSdkSchema.ts
83
222
  var SDK_TARGET = "draft-2020-12";
84
223
  var LENIENT_OPTIONS = /* @__PURE__ */ new Map([
@@ -99,11 +238,15 @@ var toSdkSchema = async (schema, io, convert) => {
99
238
  io
100
239
  );
101
240
  assertDescribesArguments(json2, io);
102
- return lenient ? advertising(standard, json2) : { "~standard": standard };
241
+ const advertised = io === "output" ? advertisedOutput(json2, standard.vendor) : json2;
242
+ return lenient || advertised !== json2 ? advertising(standard, advertised) : { "~standard": standard };
103
243
  }
104
244
  const json = await convert(schema, io);
105
245
  assertDescribesArguments(json, io);
106
- return advertising(standard, io === "input" ? strictInputSchema(json) : json);
246
+ return advertising(
247
+ standard,
248
+ io === "input" ? strictInputSchema(json) : advertisedOutput(json, standard.vendor)
249
+ );
107
250
  };
108
251
  var valibotToJsonSchema = async (schema, io) => {
109
252
  let converter;
@@ -119,6 +262,7 @@ var valibotToJsonSchema = async (schema, io) => {
119
262
  typeMode: io
120
263
  });
121
264
  };
265
+ var advertisedOutput = (json, vendor) => vendor === "zod" ? mergeObjectIntersections(json) : json;
122
266
  var advertising = (standard, advertised) => ({
123
267
  "~standard": {
124
268
  ...standard,
@@ -170,4 +314,4 @@ export {
170
314
  toSdkSchema,
171
315
  valibotToJsonSchema
172
316
  };
173
- //# sourceMappingURL=chunk-BLXUZUZ4.js.map
317
+ //# sourceMappingURL=chunk-YDEROYNS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/formatBytes.ts","../src/ownKeysOnly.ts","../src/toolInputLimit.ts","../src/mergeObjectIntersections.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","/**\n * `maxToolInputElements` when a server sets none.\n *\n * Validation keeps every issue it finds, so what checking one call costs grows\n * with how many elements its arguments hold, and a cap on the body does not\n * bound it: half a million invalid elements fit in 1 MiB, and Zod kept half a\n * gigabyte of issues reporting them. Ten thousand keep that near 8 MB.\n */\nconst DEFAULT_MAX_TOOL_INPUT_ELEMENTS = 10_000;\n\n/**\n * The limit a server was given, or the default, refused where the SDK would\n * refuse it. The SDK checks as it builds a server, and a server is built for\n * every request: checked once up front, a bad value stops the server from\n * being created rather than failing every request it would have answered.\n */\nexport const resolveMaxToolInputElements = (\n value: number | undefined,\n): number => {\n if (value === undefined) {\n return DEFAULT_MAX_TOOL_INPUT_ELEMENTS;\n }\n\n if (typeof value !== \"number\" || Number.isNaN(value) || value < 1) {\n throw new RangeError(\n `maxToolInputElements must be a number of at least 1, or Infinity, got ${String(value)}`,\n );\n }\n\n return value;\n};\n","import type { JsonSchema } from \"xsschema\";\n\ntype Schema = Record<string, unknown>;\n\n/** Keywords whose value is one subschema. */\nconst SUBSCHEMA = new Set([\n \"additionalItems\",\n \"additionalProperties\",\n \"contains\",\n \"else\",\n \"if\",\n \"not\",\n \"propertyNames\",\n \"then\",\n \"unevaluatedItems\",\n \"unevaluatedProperties\",\n]);\n\n/** Keywords whose value is a list of subschemas. */\nconst SUBSCHEMA_LIST = new Set([\"allOf\", \"anyOf\", \"oneOf\", \"prefixItems\"]);\n\n/** Keywords whose value maps names to subschemas. */\nconst SUBSCHEMA_MAP = new Set([\n \"$defs\",\n \"definitions\",\n \"dependentSchemas\",\n \"patternProperties\",\n \"properties\",\n]);\n\n/** What an operand may say and still be merged: an object's shape, and labels. */\nconst OPERAND_KEYWORDS = new Set([\n \"additionalProperties\",\n \"description\",\n \"properties\",\n \"required\",\n \"title\",\n \"type\",\n]);\n\n/** What may sit beside an `allOf` that is merged, and stays there. */\nconst HOST_KEYWORDS = new Set([\n \"$defs\",\n \"$id\",\n \"$schema\",\n \"allOf\",\n \"definitions\",\n \"description\",\n \"title\",\n \"type\",\n]);\n\n/**\n * An output schema with each intersection of objects that closes one of them\n * merged into a single object.\n *\n * Zod describes `a.and(b)` as an `allOf` of the two and, in output mode,\n * closes each `z.object()` to the keys it declares, since parsing strips the\n * rest. Under `allOf` every operand has to accept the whole result, and each\n * refuses the keys the others declare, so the schema matched no result at\n * all: the client refused every one, though Zod had just produced it. Zod\n * merges them itself from 4.5 on.\n *\n * The merged object declares every operand's properties, requires what any of\n * them required, and is closed only if all of them were: a key one operand\n * leaves open can reach the result. A property declared twice, differently,\n * must match both declarations, so it becomes an `allOf` of them, merged the\n * same way.\n *\n * Anything else is left as it was: an operand behind a `$ref`, one with a rest\n * schema or composition of its own, or an `allOf` with no closed operand,\n * which every result can already satisfy. Only subschemas are walked; `const`,\n * `default`, `enum` and `examples` hold data, which may look like a schema.\n * Returns `schema` itself when nothing was merged.\n */\nexport const mergeObjectIntersections = (schema: JsonSchema): JsonSchema =>\n walk(schema) as JsonSchema;\n\nconst walk = (schema: unknown): unknown => {\n if (!isSchema(schema)) {\n return schema;\n }\n\n const entries = Object.entries(schema);\n const walked = entries.map(([keyword, value]): [string, unknown] => [\n keyword,\n walkKeyword(keyword, value),\n ]);\n const node = walked.some(([, value], index) => value !== entries[index][1])\n ? (Object.fromEntries(walked) as Schema)\n : schema;\n\n return mergeAllOf(node) ?? node;\n};\n\nconst walkKeyword = (keyword: string, value: unknown): unknown => {\n // `items` is one subschema, or a list of them before draft 2020-12.\n if (keyword === \"items\") {\n return Array.isArray(value) ? walkList(value) : walk(value);\n }\n\n if (SUBSCHEMA.has(keyword)) {\n return walk(value);\n }\n\n if (SUBSCHEMA_LIST.has(keyword)) {\n return Array.isArray(value) ? walkList(value) : value;\n }\n\n if (SUBSCHEMA_MAP.has(keyword) && isSchema(value)) {\n const entries = Object.entries(value);\n const walked = entries.map(([name, subschema]): [string, unknown] => [\n name,\n walk(subschema),\n ]);\n\n return walked.some(\n ([, subschema], index) => subschema !== entries[index][1],\n )\n ? Object.fromEntries(walked)\n : value;\n }\n\n return value;\n};\n\nconst walkList = (list: unknown[]): unknown[] => {\n const walked = list.map(walk);\n\n return walked.some((item, index) => item !== list[index]) ? walked : list;\n};\n\n/** `node` with its `allOf` merged into one object, if it should be. */\nconst mergeAllOf = (node: Schema): Schema | undefined => {\n const operands = node.allOf;\n\n if (\n !Array.isArray(operands) ||\n operands.length === 0 ||\n Object.keys(node).some((keyword) => !HOST_KEYWORDS.has(keyword)) ||\n (node.type !== undefined && node.type !== \"object\") ||\n !operands.every(isObjectOperand)\n ) {\n return undefined;\n }\n\n const closures = operands.map(closureOf);\n\n if (closures.includes(undefined) || !closures.includes(\"closed\")) {\n return undefined;\n }\n\n const declared = new Map<string, unknown[]>();\n const required = new Set<string>();\n\n for (const operand of operands) {\n for (const [name, subschema] of Object.entries(operand.properties ?? {})) {\n declared.set(name, [...(declared.get(name) ?? []), subschema]);\n }\n\n for (const name of operand.required ?? []) {\n required.add(name);\n }\n }\n\n const properties = [...declared].map(\n ([name, declarations]): [string, unknown] => {\n const distinct = [\n ...new Map(\n declarations.map((declaration) => [\n JSON.stringify(declaration),\n declaration,\n ]),\n ).values(),\n ];\n\n if (distinct.length === 1) {\n return [name, distinct[0]];\n }\n\n const intersection = { allOf: distinct };\n\n return [name, mergeAllOf(intersection) ?? intersection];\n },\n );\n\n return {\n ...Object.fromEntries(\n Object.entries(node).filter(([keyword]) => keyword !== \"allOf\"),\n ),\n ...(closures.every((closure) => closure === \"closed\") && {\n additionalProperties: false,\n }),\n properties: Object.fromEntries(properties),\n ...(required.size > 0 && { required: [...required] }),\n type: \"object\",\n };\n};\n\ntype ObjectOperand = {\n properties?: Schema;\n required?: string[];\n} & Schema;\n\nconst isObjectOperand = (operand: unknown): operand is ObjectOperand =>\n isSchema(operand) &&\n operand.type === \"object\" &&\n Object.keys(operand).every((keyword) => OPERAND_KEYWORDS.has(keyword)) &&\n (operand.properties === undefined || isSchema(operand.properties)) &&\n (operand.required === undefined ||\n (Array.isArray(operand.required) &&\n operand.required.every((name) => typeof name === \"string\")));\n\n/**\n * Whether an operand refuses undeclared keys or allows any. `undefined` for a\n * rest schema, which constrains them in a way a merge would have to keep.\n */\nconst closureOf = (operand: ObjectOperand): \"closed\" | \"open\" | undefined => {\n const rest = operand.additionalProperties;\n\n if (rest === false) {\n return \"closed\";\n }\n\n if (\n rest === undefined ||\n rest === true ||\n (isSchema(rest) && Object.keys(rest).length === 0)\n ) {\n return \"open\";\n }\n\n return undefined;\n};\n\nconst isSchema = (value: unknown): value is Schema =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n","import type { StandardSchemaV1 } from \"@standard-schema/spec\";\nimport type { JsonSchema } from \"xsschema\";\n\nimport { mergeObjectIntersections } from \"./mergeObjectIntersections.js\";\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 * `~standard.jsonSchema`, as Zod v4 and ArkType implement it. Declared here\n * because `@standard-schema/spec` 1.0 predates it.\n */\ntype NativeJsonSchema = Record<\n \"input\" | \"output\",\n (options: {\n libraryOptions?: Record<string, unknown>;\n target: string;\n }) => JsonSchema\n>;\n\n/** The draft the SDK asks a schema for when `tools/list` describes a tool. */\nconst SDK_TARGET = \"draft-2020-12\";\n\n/**\n * What a library is told so that it leaves open the parts of a schema JSON\n * Schema cannot say, rather than refuse the schema over them. Zod describes\n * such a part as `{}`. ArkType hands over what it had worked out before it\n * reached the part: `{}` for a `Date`, `{ type: \"string\" }` for a string under\n * a `narrow()`.\n *\n * A library not named here is left to refuse, and its tool is not served.\n */\nconst LENIENT_OPTIONS = new Map<string, Record<string, unknown>>([\n [\"arktype\", { fallback: (context: { base: JsonSchema }) => context.base }],\n [\"zod\", { unrepresentable: \"any\" }],\n]);\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 * A native schema is converted here too, once, the way the SDK will for\n * `tools/list`. The SDK converts every tool in the one handler, so a schema\n * its library refused to convert — a `z.date()`, a `z.bigint()`, an ArkType\n * `narrow()` — failed the list for every tool, though each could still be\n * called. One refused is asked for again with what JSON Schema cannot say left\n * open (see `LENIENT_OPTIONS`), which is what Valibot's converter is already\n * told, and that copy is advertised in place of the library's own.\n *\n * Converted inputs are closed with `strictInputSchema`. Outputs are not closed,\n * since that would misdescribe results the schema allows; a Zod output's\n * intersections of objects are merged instead (see `advertisedOutput`), and a\n * native schema with one is advertised from the merged copy.\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, when a\n * library refuses a schema even leniently, and for an input schema that does\n * not describe an object: each caller leaves that tool out and serves the rest.\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\": {\n jsonSchema?: NativeJsonSchema;\n } & StandardSchemaV1.Props;\n }\n )[\"~standard\"],\n );\n\n if (standard.jsonSchema) {\n const { json, lenient } = nativeJsonSchema(\n standard.jsonSchema,\n standard.vendor,\n io,\n );\n\n assertDescribesArguments(json, io);\n\n const advertised =\n io === \"output\" ? advertisedOutput(json, standard.vendor) : json;\n\n return lenient || advertised !== json\n ? advertising(standard, advertised)\n : { \"~standard\": standard };\n }\n\n const json = await convert(schema as StandardSchemaV1, io);\n\n assertDescribesArguments(json, io);\n\n return advertising(\n standard,\n io === \"input\"\n ? strictInputSchema(json)\n : advertisedOutput(json, standard.vendor),\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 * An output schema as advertised: Zod's with its intersections of objects\n * merged (see `mergeObjectIntersections`). Zod closes an output object whose\n * undeclared keys it strips, so only its intersections allow no result at\n * all. Another library's closed operand is a strict object, and its\n * intersection is refused at runtime as well, so it is described as it is.\n */\nconst advertisedOutput = (json: JsonSchema, vendor: string): JsonSchema =>\n vendor === \"zod\" ? mergeObjectIntersections(json) : json;\n\n/** `standard`, carrying `advertised` as its JSON Schema, input and output. */\nconst advertising = <P extends StandardSchemaV1.Props>(\n standard: P,\n advertised: JsonSchema,\n) => ({\n \"~standard\": {\n ...standard,\n jsonSchema: { input: () => advertised, output: () => advertised },\n },\n});\n\n/**\n * Refuses an input schema that describes anything but an object. A tool's\n * arguments are always one, and the SDK will not list a schema that says\n * otherwise: `parameters: z.string()` failed `tools/list` for every tool, as an\n * unconvertible schema did.\n */\nconst assertDescribesArguments = (\n json: JsonSchema,\n io: \"input\" | \"output\",\n): void => {\n if (io === \"input\" && json.type !== undefined && json.type !== \"object\") {\n throw new Error(\n `A tool's arguments are an object, and this schema describes ${JSON.stringify(\n json.type,\n )}. Wrap it in an object schema.`,\n );\n }\n};\n\n/**\n * A schema's own JSON Schema, and whether it had to be asked for leniently.\n * Throws what the library does when it refuses the schema either way.\n */\nconst nativeJsonSchema = (\n native: NativeJsonSchema,\n vendor: string,\n io: \"input\" | \"output\",\n): { json: JsonSchema; lenient: boolean } => {\n try {\n return { json: native[io]({ target: SDK_TARGET }), lenient: false };\n } catch (error) {\n const libraryOptions = LENIENT_OPTIONS.get(vendor);\n\n if (!libraryOptions) {\n throw error;\n }\n\n return {\n json: native[io]({ libraryOptions, target: SDK_TARGET }),\n lenient: true,\n };\n }\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 *\n * Nor is an object closed whose keys are declared elsewhere: in its `allOf`,\n * `anyOf` or `oneOf` branches — a `v.intersect()`, `v.union()` or\n * `v.variant()` — or behind a `$ref`, which is how a `v.lazy()` arrives.\n * `additionalProperties` sees only the `properties` beside it, so closing one\n * refused every key declared elsewhere, and every argument with them.\n */\nconst strictInputSchema = (schema: JsonSchema): JsonSchema => ({\n ...schema,\n ...(!(schema.allOf ?? schema.anyOf ?? schema.oneOf ?? schema.$ref) && {\n additionalProperties:\n typeof schema.additionalProperties === \"object\"\n ? schema.additionalProperties\n : false,\n }),\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":";AACO,IAAM,cAAc,CAAC,UAA0B;AACpD,MAAI,SAAS,OAAO,QAAQ,SAAS,OAAO,UAAU,GAAG;AACvD,WAAO,GAAG,SAAS,OAAO,KAAK;AAAA,EACjC;AAEA,MAAI,SAAS,QAAQ,QAAQ,SAAS,GAAG;AACvC,WAAO,GAAG,QAAQ,IAAI;AAAA,EACxB;AAEA,SAAO,GAAG,KAAK;AACjB;;;ACMO,IAAM,cAAc,CAA6B,WAAiB;AACvE,QAAM,WAAW,gBAAgB,OAAO,WAAW,CAAC;AAEpD,SAAO,OAAO,eAAe,QAAQ,aAAa;AAAA,IAChD,OAAO;AAAA,MACL,GAAG;AAAA,MACH,UAAU,CAAC,UAAmB,SAAS,SAAS,SAAS,CAAC,CAAC;AAAA,IAC7D;AAAA,EACF,CAAC;AACH;AAkBO,IAAM,kBAAkB,CAC7B,cACO;AAAA,EACP,GAAG;AAAA,EACH,UAAU,OAAO,UAAmB;AAClC,UAAM,SAAS,oBAAI,IAAoB;AACvC,UAAM,SAAS,MAAM,SAAS,SAAS,kBAAkB,OAAO,MAAM,CAAC;AAEvE,QAAI,CAAC,OAAO,UAAU,OAAO,OAAO,GAAG;AACrC,wBAAkB,OAAO,OAAO,IAAI,IAAI,OAAO,OAAO,CAAC,GAAG,oBAAI,IAAI,CAAC;AAAA,IACrE;AAEA,WAAO;AAAA,EACT;AACF;AAQA,IAAM,oBAAoB,CACxB,OACA,WACY;AACZ,MAAI,CAAC,QAAQ,KAAK,GAAG;AACnB,WAAO;AAAA,EACT;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OAAO,UAAU,EAAE,IAAI,CAAC,CAAC,KAAK,KAAK,MAAM;AAAA,QACtD;AAAA,QACA,OAAO,UAAU,YAAY,MAAM,SAAS,WACxC,kBAAkB,KAAK,IACvB;AAAA,MACN,CAAC;AAAA,IACH;AAAA,EACF;AACF;","names":["json"]}
@@ -4,7 +4,7 @@
4
4
 
5
5
 
6
6
 
7
- var _chunkNZGRSB2Dcjs = require('../chunk-NZGRSB2D.cjs');
7
+ var _chunkR4RK2DR2cjs = require('../chunk-R4RK2DR2.cjs');
8
8
 
9
9
  // src/edge/index.ts
10
10
  var _server = require('@modelcontextprotocol/server');
@@ -17,7 +17,7 @@ var convertToJsonSchema = async (schema, io) => {
17
17
  `Schema library "${vendor}" carries no JSON Schema (\`~standard.jsonSchema\`), and EdgeViteMCP converts only Valibot's. Use Zod 4, ArkType or Valibot.`
18
18
  );
19
19
  }
20
- return _chunkNZGRSB2Dcjs.valibotToJsonSchema.call(void 0, schema, io);
20
+ return _chunkR4RK2DR2cjs.valibotToJsonSchema.call(void 0, schema, io);
21
21
  };
22
22
  var readCappedRequest = async (request, maxBytes) => {
23
23
  if (!request.body) {
@@ -81,7 +81,7 @@ var EdgeViteMCP = class {
81
81
  this.#version = options.version;
82
82
  this.#logger = _nullishCoalesce(options.logger, () => ( console));
83
83
  this.#maxBodySize = _nullishCoalesce(options.maxBodySize, () => ( DEFAULT_MAX_BODY_SIZE));
84
- this.#maxToolInputElements = _chunkNZGRSB2Dcjs.resolveMaxToolInputElements.call(void 0,
84
+ this.#maxToolInputElements = _chunkR4RK2DR2cjs.resolveMaxToolInputElements.call(void 0,
85
85
  options.maxToolInputElements
86
86
  );
87
87
  this.#mcpPath = _nullishCoalesce(options.mcpPath, () => ( "/mcp"));
@@ -121,7 +121,7 @@ var EdgeViteMCP = class {
121
121
  }
122
122
  if (!capped) {
123
123
  return invalidRequest(
124
- `Request body exceeds ${_chunkNZGRSB2Dcjs.formatBytes.call(void 0, this.#maxBodySize)}`
124
+ `Request body exceeds ${_chunkR4RK2DR2cjs.formatBytes.call(void 0, this.#maxBodySize)}`
125
125
  );
126
126
  }
127
127
  this.#handler ??= _server.createMcpHandler.call(void 0, () => this.#buildServer(), {
@@ -192,7 +192,7 @@ var EdgeViteMCP = class {
192
192
  for (const arg of _nullishCoalesce(prompt.arguments, () => ( []))) {
193
193
  shape[arg.name] = arg.required ? _zod.z.string() : _zod.z.string().optional();
194
194
  }
195
- const argsSchema = _optionalChain([prompt, 'access', _ => _.arguments, 'optionalAccess', _2 => _2.length]) ? _chunkNZGRSB2Dcjs.ownKeysOnly.call(void 0, _zod.z.object(shape)) : void 0;
195
+ const argsSchema = _optionalChain([prompt, 'access', _ => _.arguments, 'optionalAccess', _2 => _2.length]) ? _chunkR4RK2DR2cjs.ownKeysOnly.call(void 0, _zod.z.object(shape)) : void 0;
196
196
  const load = async (args) => {
197
197
  const text = await prompt.load(_nullishCoalesce(args, () => ( {})));
198
198
  return {
@@ -222,7 +222,7 @@ var EdgeViteMCP = class {
222
222
  #sdkSchemaFor(tool) {
223
223
  let schema = this.#toolSchemas.get(tool);
224
224
  if (!schema) {
225
- schema = _chunkNZGRSB2Dcjs.toSdkSchema.call(void 0, tool.parameters, "input", convertToJsonSchema).then(
225
+ schema = _chunkR4RK2DR2cjs.toSdkSchema.call(void 0, tool.parameters, "input", convertToJsonSchema).then(
226
226
  (inputSchema) => ({ inputSchema }),
227
227
  (error) => {
228
228
  this.#logger.error(
@@ -4,7 +4,7 @@ import {
4
4
  resolveMaxToolInputElements,
5
5
  toSdkSchema,
6
6
  valibotToJsonSchema
7
- } from "../chunk-BLXUZUZ4.js";
7
+ } from "../chunk-YDEROYNS.js";
8
8
 
9
9
  // src/edge/index.ts
10
10
  import { createMcpHandler, McpServer } from "@modelcontextprotocol/server";