@ai-sdk-tool/parser 3.3.0 → 3.3.2

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.
@@ -47,6 +47,153 @@ function getSchemaType(schema) {
47
47
  }
48
48
  return;
49
49
  }
50
+ function schemaAllowsPropertyViaCombinators(s, key, depth) {
51
+ const anyOfValues = s.anyOf;
52
+ const oneOfValues = s.oneOf;
53
+ const allOfValues = s.allOf;
54
+ let hasCombinator = false;
55
+ let anyOfAllows = true;
56
+ let oneOfAllows = true;
57
+ let allOfAllows = true;
58
+ if (Array.isArray(anyOfValues)) {
59
+ hasCombinator = true;
60
+ anyOfAllows = anyOfValues.some(
61
+ (sub) => schemaHasProperty(sub, key, depth + 1)
62
+ );
63
+ }
64
+ if (Array.isArray(oneOfValues)) {
65
+ hasCombinator = true;
66
+ oneOfAllows = oneOfValues.some(
67
+ (sub) => schemaHasProperty(sub, key, depth + 1)
68
+ );
69
+ }
70
+ if (Array.isArray(allOfValues)) {
71
+ hasCombinator = true;
72
+ allOfAllows = allOfValues.every(
73
+ (sub) => schemaHasProperty(sub, key, depth + 1)
74
+ );
75
+ }
76
+ if (!hasCombinator) {
77
+ return false;
78
+ }
79
+ return anyOfAllows && oneOfAllows && allOfAllows;
80
+ }
81
+ function schemaHasPropertyDirectly(s, key) {
82
+ const props = s.properties;
83
+ if (props && typeof props === "object" && !Array.isArray(props) && Object.hasOwn(props, key) && props[key] !== false) {
84
+ return true;
85
+ }
86
+ const required = s.required;
87
+ if (Array.isArray(required) && required.includes(key)) {
88
+ return true;
89
+ }
90
+ const patternSchemas = getPatternSchemasForKey(s.patternProperties, key);
91
+ return patternSchemas.some((schema) => schema !== false);
92
+ }
93
+ function schemaHasPropertyViaAdditional(s) {
94
+ const additional = s.additionalProperties;
95
+ if (additional === true || additional && typeof additional === "object" && !Array.isArray(additional)) {
96
+ return true;
97
+ }
98
+ if (Object.hasOwn(s, "additionalProperties")) {
99
+ return false;
100
+ }
101
+ const type = s.type;
102
+ const isObjectType = type === "object" || Array.isArray(type) && type.includes("object");
103
+ const hasObjectKeywords = s.properties && typeof s.properties === "object" && !Array.isArray(s.properties) || s.patternProperties && typeof s.patternProperties === "object" && !Array.isArray(s.patternProperties) || Array.isArray(s.required) && s.required.length > 0;
104
+ return !!(isObjectType || hasObjectKeywords);
105
+ }
106
+ function schemaDisallowsPropertyDirectly(s, key) {
107
+ const props = s.properties;
108
+ if (props && typeof props === "object" && !Array.isArray(props) && Object.hasOwn(props, key) && props[key] === false) {
109
+ return true;
110
+ }
111
+ const patternSchemas = getPatternSchemasForKey(s.patternProperties, key);
112
+ return patternSchemas.some((schema) => schema === false);
113
+ }
114
+ function schemaHasProperty(schema, key, depth = 0) {
115
+ if (depth > 5) {
116
+ return true;
117
+ }
118
+ const unwrapped = unwrapJsonSchema(schema);
119
+ if (schemaIsUnconstrained(unwrapped)) {
120
+ return true;
121
+ }
122
+ if (!unwrapped || typeof unwrapped !== "object") {
123
+ return false;
124
+ }
125
+ const s = unwrapped;
126
+ if (schemaDisallowsPropertyDirectly(s, key)) {
127
+ return false;
128
+ }
129
+ if (schemaHasPropertyDirectly(s, key)) {
130
+ return true;
131
+ }
132
+ if (schemaHasPropertyViaAdditional(s)) {
133
+ return true;
134
+ }
135
+ return schemaAllowsPropertyViaCombinators(s, key, depth);
136
+ }
137
+ function schemaIsUnconstrained(schema) {
138
+ const unwrapped = unwrapJsonSchema(schema);
139
+ if (unwrapped == null || unwrapped === true) {
140
+ return true;
141
+ }
142
+ if (typeof unwrapped !== "object" || Array.isArray(unwrapped)) {
143
+ return false;
144
+ }
145
+ return Object.keys(unwrapped).length === 0;
146
+ }
147
+ function getPatternSchemasForKey(patternProperties, key) {
148
+ if (!patternProperties || typeof patternProperties !== "object" || Array.isArray(patternProperties)) {
149
+ return [];
150
+ }
151
+ const schemas = [];
152
+ for (const [pattern, schema] of Object.entries(
153
+ patternProperties
154
+ )) {
155
+ try {
156
+ const regex = new RegExp(pattern);
157
+ if (regex.test(key)) {
158
+ schemas.push(schema);
159
+ }
160
+ } catch (e) {
161
+ }
162
+ }
163
+ return schemas;
164
+ }
165
+ function coerceValueForKey(value, key, unwrapped) {
166
+ const schemas = [];
167
+ const props = unwrapped.properties;
168
+ if (props && Object.hasOwn(props, key)) {
169
+ schemas.push(props[key]);
170
+ }
171
+ const patternSchemas = getPatternSchemasForKey(
172
+ unwrapped.patternProperties,
173
+ key
174
+ );
175
+ if (patternSchemas.length > 0) {
176
+ schemas.push(...patternSchemas);
177
+ }
178
+ if (schemas.length > 0) {
179
+ let out = value;
180
+ for (const schema of schemas) {
181
+ if (typeof schema === "boolean") {
182
+ continue;
183
+ }
184
+ out = coerceBySchema(out, schema);
185
+ }
186
+ return out;
187
+ }
188
+ const additional = unwrapped.additionalProperties;
189
+ if (additional && typeof additional === "object" && !Array.isArray(additional)) {
190
+ return coerceBySchema(value, additional);
191
+ }
192
+ if (additional === true || additional === false) {
193
+ return value;
194
+ }
195
+ return coerceBySchema(value, void 0);
196
+ }
50
197
  function coerceStringWithoutSchema(value) {
51
198
  const s = value.trim();
52
199
  const lower = s.toLowerCase();
@@ -77,13 +224,7 @@ function coerceStringToObject(s, unwrapped) {
77
224
  normalized = normalized.replace(EMPTY_OBJECT_REGEX, "{}");
78
225
  const obj = JSON.parse(normalized);
79
226
  if (obj && typeof obj === "object" && !Array.isArray(obj)) {
80
- const props = unwrapped.properties;
81
- const out = {};
82
- for (const [k, v] of Object.entries(obj)) {
83
- const propSchema = props ? props[k] : void 0;
84
- out[k] = typeof propSchema === "boolean" ? v : coerceBySchema(v, propSchema);
85
- }
86
- return out;
227
+ return coerceObjectToObject(obj, unwrapped);
87
228
  }
88
229
  } catch (e) {
89
230
  }
@@ -113,10 +254,8 @@ function coerceStringToArray(s, unwrapped) {
113
254
  }
114
255
  function coerceObjectToObject(value, unwrapped) {
115
256
  const out = {};
116
- const props = unwrapped.properties;
117
257
  for (const [k, v] of Object.entries(value)) {
118
- const propSchema = props ? props[k] : void 0;
119
- out[k] = typeof propSchema === "boolean" ? v : coerceBySchema(v, propSchema);
258
+ out[k] = coerceValueForKey(v, k, unwrapped);
120
259
  }
121
260
  return out;
122
261
  }
@@ -133,16 +272,22 @@ function coerceObjectToArray(maybe, prefixItems, itemsSchema) {
133
272
  return coerceArrayToArray(arr, prefixItems, itemsSchema);
134
273
  }
135
274
  const keys = Object.keys(maybe);
136
- if (keys.length === 1) {
137
- const singleValue = maybe[keys[0]];
138
- if (Array.isArray(singleValue)) {
139
- return singleValue.map((v) => coerceBySchema(v, itemsSchema));
140
- }
141
- }
142
275
  if (keys.length > 0 && keys.every((k) => DIGIT_KEY_REGEX.test(k))) {
143
276
  const arr = keys.sort((a, b) => Number(a) - Number(b)).map((k) => maybe[k]);
144
277
  return coerceArrayToArray(arr, prefixItems, itemsSchema);
145
278
  }
279
+ if (keys.length === 1) {
280
+ const singleKey = keys[0];
281
+ if (!(schemaIsUnconstrained(itemsSchema) || schemaHasProperty(itemsSchema, singleKey))) {
282
+ const singleValue = maybe[singleKey];
283
+ if (Array.isArray(singleValue)) {
284
+ return singleValue.map((v) => coerceBySchema(v, itemsSchema));
285
+ }
286
+ if (singleValue && typeof singleValue === "object") {
287
+ return [coerceBySchema(singleValue, itemsSchema)];
288
+ }
289
+ }
290
+ }
146
291
  return null;
147
292
  }
148
293
  function coercePrimitiveToArray(value, prefixItems, itemsSchema) {
@@ -202,11 +347,15 @@ function coerceArrayValue(value, prefixItems, itemsSchema) {
202
347
  if (result !== null) {
203
348
  return result;
204
349
  }
350
+ if (getSchemaType(itemsSchema) === "array") {
351
+ return [value];
352
+ }
353
+ return [coerceBySchema(value, itemsSchema)];
205
354
  }
206
355
  if (value == null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
207
356
  return coercePrimitiveToArray(value, prefixItems, itemsSchema);
208
357
  }
209
- return value;
358
+ return [value];
210
359
  }
211
360
  function coerceBySchema(value, schema) {
212
361
  const unwrapped = unwrapJsonSchema(schema);
@@ -237,4 +386,4 @@ export {
237
386
  getSchemaType,
238
387
  coerceBySchema
239
388
  };
240
- //# sourceMappingURL=chunk-DZB6Y354.js.map
389
+ //# sourceMappingURL=chunk-OUGMLYAW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schema-coerce/index.ts"],"sourcesContent":["// Regex constants for performance\nconst NUMERIC_REGEX = /^-?\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?$/;\nconst EMPTY_OBJECT_REGEX = /^\\{\\s*\\}$/s;\nconst NEWLINE_SPLIT_REGEX = /\\n+/;\nconst COMMA_SPLIT_REGEX = /,\\s*/;\nconst DIGIT_KEY_REGEX = /^\\d+$/;\n\nexport function unwrapJsonSchema(schema: unknown): unknown {\n if (!schema || typeof schema !== \"object\") {\n return schema;\n }\n const s = schema as Record<string, unknown>;\n if (s.jsonSchema && typeof s.jsonSchema === \"object\") {\n return unwrapJsonSchema(s.jsonSchema);\n }\n return schema;\n}\n\nexport function getSchemaType(schema: unknown): string | undefined {\n const unwrapped = unwrapJsonSchema(schema);\n if (!unwrapped || typeof unwrapped !== \"object\") {\n return;\n }\n const t: unknown = (unwrapped as Record<string, unknown>).type;\n if (typeof t === \"string\") {\n return t;\n }\n if (Array.isArray(t)) {\n const preferred = [\n \"object\",\n \"array\",\n \"boolean\",\n \"number\",\n \"integer\",\n \"string\",\n ];\n for (const p of preferred) {\n if (t.includes(p)) {\n return p;\n }\n }\n }\n const s = unwrapped as Record<string, unknown>;\n if (s && typeof s === \"object\" && (s.properties || s.additionalProperties)) {\n return \"object\";\n }\n if (\n s &&\n typeof s === \"object\" &&\n (s.items || (s as Record<string, unknown>).prefixItems)\n ) {\n return \"array\";\n }\n return;\n}\n\n/**\n * Checks if a property is allowed through schema combinators (anyOf, oneOf, allOf).\n *\n * @param s - The schema object to check\n * @param key - The property key to look for\n * @param depth - Current recursion depth\n * @returns `true` if at least one combinator exists AND allows the property;\n * `false` if no combinators exist OR none allow the property.\n * When no combinators are present, returns `false` so the caller can\n * fall back to other property-checking methods.\n *\n * **oneOf semantics**: JSON Schema's `oneOf` requires exactly one schema to match,\n * but for coercion heuristics we treat it like `anyOf` (at least one allows).\n * This is intentional because:\n * 1. We're determining if a property CAN exist, not validating exact matches\n * 2. Coercion should be permissive - if any branch allows the property, we allow it\n * 3. Strict oneOf validation would require runtime value inspection, not just schema analysis\n */\nfunction schemaAllowsPropertyViaCombinators(\n s: Record<string, unknown>,\n key: string,\n depth: number\n): boolean {\n const anyOfValues = s.anyOf;\n const oneOfValues = s.oneOf;\n const allOfValues = s.allOf;\n\n let hasCombinator = false;\n let anyOfAllows = true;\n let oneOfAllows = true;\n let allOfAllows = true;\n\n if (Array.isArray(anyOfValues)) {\n hasCombinator = true;\n anyOfAllows = anyOfValues.some((sub) =>\n schemaHasProperty(sub, key, depth + 1)\n );\n }\n\n if (Array.isArray(oneOfValues)) {\n hasCombinator = true;\n oneOfAllows = oneOfValues.some((sub) =>\n schemaHasProperty(sub, key, depth + 1)\n );\n }\n\n if (Array.isArray(allOfValues)) {\n hasCombinator = true;\n allOfAllows = allOfValues.every((sub) =>\n schemaHasProperty(sub, key, depth + 1)\n );\n }\n\n if (!hasCombinator) {\n return false;\n }\n\n return anyOfAllows && oneOfAllows && allOfAllows;\n}\n\nfunction schemaHasPropertyDirectly(\n s: Record<string, unknown>,\n key: string\n): boolean {\n const props = s.properties;\n if (\n props &&\n typeof props === \"object\" &&\n !Array.isArray(props) &&\n Object.hasOwn(props, key) &&\n (props as Record<string, unknown>)[key] !== false\n ) {\n return true;\n }\n const required = s.required;\n if (Array.isArray(required) && required.includes(key)) {\n return true;\n }\n const patternSchemas = getPatternSchemasForKey(s.patternProperties, key);\n return patternSchemas.some((schema) => schema !== false);\n}\n\n/**\n * Checks if a schema allows additional properties beyond those explicitly defined.\n *\n * JSON Schema behavior for additionalProperties:\n * - `additionalProperties: true` or `additionalProperties: { schema }`: Explicitly allows additional properties\n * - `additionalProperties: false`: Explicitly disallows additional properties\n * - `additionalProperties` not specified: Defaults to allowing additional properties (JSON Schema spec)\n *\n * When `additionalProperties` is not explicitly set, this function returns `true` if the schema\n * appears to be an object schema (has `type: \"object\"`, `properties`, `patternProperties`, or `required`).\n * This follows the JSON Schema specification where omitting `additionalProperties` is equivalent to `true`.\n *\n * **Important**: This means schemas like `{ type: \"object\", properties: { foo: ... } }` without\n * `additionalProperties: false` will be treated as allowing any additional property, which affects\n * single-key object unwrapping behavior in array coercion.\n *\n * @param s - The schema object to check\n * @returns `true` if the schema allows additional properties, `false` otherwise\n */\nfunction schemaHasPropertyViaAdditional(s: Record<string, unknown>): boolean {\n const additional = s.additionalProperties;\n if (\n additional === true ||\n (additional && typeof additional === \"object\" && !Array.isArray(additional))\n ) {\n return true;\n }\n if (Object.hasOwn(s, \"additionalProperties\")) {\n return false;\n }\n const type = s.type;\n const isObjectType =\n type === \"object\" || (Array.isArray(type) && type.includes(\"object\"));\n const hasObjectKeywords =\n (s.properties &&\n typeof s.properties === \"object\" &&\n !Array.isArray(s.properties)) ||\n (s.patternProperties &&\n typeof s.patternProperties === \"object\" &&\n !Array.isArray(s.patternProperties)) ||\n (Array.isArray(s.required) && s.required.length > 0);\n return !!(isObjectType || hasObjectKeywords);\n}\n\nfunction schemaDisallowsPropertyDirectly(\n s: Record<string, unknown>,\n key: string\n): boolean {\n const props = s.properties;\n if (\n props &&\n typeof props === \"object\" &&\n !Array.isArray(props) &&\n Object.hasOwn(props, key) &&\n (props as Record<string, unknown>)[key] === false\n ) {\n return true;\n }\n const patternSchemas = getPatternSchemasForKey(s.patternProperties, key);\n return patternSchemas.some((schema) => schema === false);\n}\n\n/**\n * Checks if a schema allows a specific property key.\n *\n * Recursively checks through schema combinators (allOf, anyOf, oneOf) to determine\n * if the given key is allowed by the schema.\n *\n * @param schema - The JSON Schema to check\n * @param key - The property key to check for\n * @param depth - Current recursion depth (default: 0)\n * @returns `true` if the schema allows the property, `false` otherwise\n *\n * @remarks\n * The depth limit of 5 prevents infinite recursion in deeply nested or circular\n * schema references. This limit is sufficient for most real-world schemas while\n * protecting against pathological cases. When the limit is exceeded, the function\n * conservatively returns `true` to prevent unwrapping - it's safer to keep a\n * wrapper key than to incorrectly remove it and lose data.\n */\nfunction schemaHasProperty(schema: unknown, key: string, depth = 0): boolean {\n if (depth > 5) {\n return true;\n }\n const unwrapped = unwrapJsonSchema(schema);\n // Unconstrained schemas (true, null, {}) allow any property\n if (schemaIsUnconstrained(unwrapped)) {\n return true;\n }\n if (!unwrapped || typeof unwrapped !== \"object\") {\n return false;\n }\n const s = unwrapped as Record<string, unknown>;\n\n if (schemaDisallowsPropertyDirectly(s, key)) {\n return false;\n }\n if (schemaHasPropertyDirectly(s, key)) {\n return true;\n }\n if (schemaHasPropertyViaAdditional(s)) {\n return true;\n }\n return schemaAllowsPropertyViaCombinators(s, key, depth);\n}\n\nfunction schemaIsUnconstrained(schema: unknown): boolean {\n const unwrapped = unwrapJsonSchema(schema);\n if (unwrapped == null || unwrapped === true) {\n return true;\n }\n if (typeof unwrapped !== \"object\" || Array.isArray(unwrapped)) {\n return false;\n }\n return Object.keys(unwrapped).length === 0;\n}\n\n/**\n * Gets all schemas from patternProperties that match the given key.\n *\n * @param patternProperties - The patternProperties object from a JSON Schema\n * @param key - The property key to match against patterns\n * @returns Array of schemas whose patterns match the key\n *\n * @remarks\n * **Security consideration**: This function executes regex patterns from the schema.\n * In typical usage (AI SDK tool parsing), schemas come from trusted application code.\n * However, if schemas can originate from untrusted sources, be aware of potential\n * ReDoS (Regular Expression Denial of Service) with malicious patterns like `(a+)+$`.\n * Consider adding regex timeout or safe-regex validation if processing untrusted schemas.\n */\nfunction getPatternSchemasForKey(\n patternProperties: unknown,\n key: string\n): unknown[] {\n if (\n !patternProperties ||\n typeof patternProperties !== \"object\" ||\n Array.isArray(patternProperties)\n ) {\n return [];\n }\n const schemas: unknown[] = [];\n for (const [pattern, schema] of Object.entries(\n patternProperties as Record<string, unknown>\n )) {\n try {\n const regex = new RegExp(pattern);\n if (regex.test(key)) {\n schemas.push(schema);\n }\n } catch {\n // Ignore invalid regex patterns.\n }\n }\n return schemas;\n}\n\nfunction coerceValueForKey(\n value: unknown,\n key: string,\n unwrapped: Record<string, unknown>\n): unknown {\n const schemas: unknown[] = [];\n const props = unwrapped.properties as Record<string, unknown> | undefined;\n if (props && Object.hasOwn(props, key)) {\n schemas.push(props[key]);\n }\n const patternSchemas = getPatternSchemasForKey(\n unwrapped.patternProperties,\n key\n );\n if (patternSchemas.length > 0) {\n schemas.push(...patternSchemas);\n }\n\n if (schemas.length > 0) {\n let out = value;\n for (const schema of schemas) {\n if (typeof schema === \"boolean\") {\n continue;\n }\n out = coerceBySchema(out, schema);\n }\n return out;\n }\n\n const additional = unwrapped.additionalProperties;\n if (\n additional &&\n typeof additional === \"object\" &&\n !Array.isArray(additional)\n ) {\n return coerceBySchema(value, additional);\n }\n if (additional === true || additional === false) {\n return value;\n }\n\n return coerceBySchema(value, undefined);\n}\n\n/**\n * Coerce string value without schema information\n */\nfunction coerceStringWithoutSchema(value: string): unknown {\n const s = value.trim();\n const lower = s.toLowerCase();\n if (lower === \"true\") {\n return true;\n }\n if (lower === \"false\") {\n return false;\n }\n if (NUMERIC_REGEX.test(s)) {\n const num = Number(s);\n if (Number.isFinite(num)) {\n return num;\n }\n }\n\n // Fallback: try parsing JSON-like strings when no schema info\n if (\n (s.startsWith(\"{\") && s.endsWith(\"}\")) ||\n (s.startsWith(\"[\") && s.endsWith(\"]\"))\n ) {\n try {\n const parsed = JSON.parse(s);\n return coerceBySchema(parsed, undefined);\n } catch {\n // If parsing fails, return original value\n }\n }\n return value;\n}\n\n/**\n * Coerce string to object using schema\n */\nfunction coerceStringToObject(\n s: string,\n unwrapped: Record<string, unknown>\n): unknown {\n try {\n let normalized = s.replace(/'/g, '\"');\n normalized = normalized.replace(EMPTY_OBJECT_REGEX, \"{}\");\n\n const obj = JSON.parse(normalized);\n if (obj && typeof obj === \"object\" && !Array.isArray(obj)) {\n return coerceObjectToObject(obj as Record<string, unknown>, unwrapped);\n }\n } catch {\n // fallthrough\n }\n return null;\n}\n\n/**\n * Coerce string to array using schema\n */\nfunction coerceStringToArray(\n s: string,\n unwrapped: Record<string, unknown>\n): unknown {\n const prefixItems = Array.isArray(unwrapped.prefixItems)\n ? (unwrapped.prefixItems as unknown[])\n : undefined;\n const itemsSchema = unwrapped.items as unknown;\n\n try {\n const normalized = s.replace(/'/g, '\"');\n const arr = JSON.parse(normalized);\n if (Array.isArray(arr)) {\n if (prefixItems && arr.length === prefixItems.length) {\n return arr.map((v, i) => coerceBySchema(v, prefixItems[i]));\n }\n return arr.map((v) => coerceBySchema(v, itemsSchema));\n }\n } catch {\n const csv = s.includes(\"\\n\")\n ? s.split(NEWLINE_SPLIT_REGEX)\n : s.split(COMMA_SPLIT_REGEX);\n const trimmed = csv.map((x) => x.trim()).filter((x) => x.length > 0);\n if (prefixItems && trimmed.length === prefixItems.length) {\n return trimmed.map((x, i) => coerceBySchema(x, prefixItems[i]));\n }\n return trimmed.map((x) => coerceBySchema(x, itemsSchema));\n }\n return null;\n}\n\n/**\n * Coerce object to object using schema\n */\nfunction coerceObjectToObject(\n value: Record<string, unknown>,\n unwrapped: Record<string, unknown>\n): Record<string, unknown> {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(value)) {\n out[k] = coerceValueForKey(v, k, unwrapped);\n }\n return out;\n}\n\n/**\n * Coerce array to array using schema\n */\nfunction coerceArrayToArray(\n value: unknown[],\n prefixItems: unknown[] | undefined,\n itemsSchema: unknown\n): unknown[] {\n if (prefixItems && value.length === prefixItems.length) {\n return value.map((v, i) => coerceBySchema(v, prefixItems[i]));\n }\n return value.map((v) => coerceBySchema(v, itemsSchema));\n}\n\n/**\n * Coerce object to array using schema\n */\nfunction coerceObjectToArray(\n maybe: Record<string, unknown>,\n prefixItems: unknown[] | undefined,\n itemsSchema: unknown\n): unknown {\n if (Object.hasOwn(maybe, \"item\")) {\n const items = maybe.item as unknown;\n const arr = Array.isArray(items) ? items : [items];\n return coerceArrayToArray(arr, prefixItems, itemsSchema);\n }\n\n const keys = Object.keys(maybe);\n\n // Check for numeric keys (traditional tuple handling)\n if (keys.length > 0 && keys.every((k) => DIGIT_KEY_REGEX.test(k))) {\n const arr = keys.sort((a, b) => Number(a) - Number(b)).map((k) => maybe[k]);\n return coerceArrayToArray(arr, prefixItems, itemsSchema);\n }\n\n // Check for single field that contains an array or object (common XML pattern)\n // This handles both: { user: [{ name: \"A\" }, { name: \"B\" }] } and { user: { name: \"A\" } }\n if (keys.length === 1) {\n const singleKey = keys[0];\n if (\n !(\n schemaIsUnconstrained(itemsSchema) ||\n schemaHasProperty(itemsSchema, singleKey)\n )\n ) {\n const singleValue = maybe[singleKey];\n if (Array.isArray(singleValue)) {\n return singleValue.map((v) => coerceBySchema(v, itemsSchema));\n }\n // Also extract when single key's value is an object and wrap in array (single/multiple element consistency)\n if (singleValue && typeof singleValue === \"object\") {\n return [coerceBySchema(singleValue, itemsSchema)];\n }\n }\n }\n\n return null;\n}\n\n/**\n * Coerce primitive to array using schema\n */\nfunction coercePrimitiveToArray(\n value: unknown,\n prefixItems: unknown[] | undefined,\n itemsSchema: unknown\n): unknown[] {\n if (prefixItems && prefixItems.length > 0) {\n return [coerceBySchema(value, prefixItems[0])];\n }\n return [coerceBySchema(value, itemsSchema)];\n}\n\n/**\n * Coerce string to primitive type using schema\n */\nfunction coerceStringToPrimitive(\n s: string,\n schemaType: string | undefined\n): unknown {\n if (schemaType === \"boolean\") {\n const lower = s.toLowerCase();\n if (lower === \"true\") {\n return true;\n }\n if (lower === \"false\") {\n return false;\n }\n }\n if (\n (schemaType === \"number\" || schemaType === \"integer\") &&\n NUMERIC_REGEX.test(s)\n ) {\n const num = Number(s);\n if (Number.isFinite(num)) {\n return num;\n }\n }\n return null;\n}\n\nfunction coerceStringValue(\n value: string,\n schemaType: string | undefined,\n u: Record<string, unknown>\n): unknown {\n const s = value.trim();\n\n if (schemaType === \"object\") {\n const result = coerceStringToObject(s, u);\n if (result !== null) {\n return result;\n }\n }\n\n if (schemaType === \"array\") {\n const result = coerceStringToArray(s, u);\n if (result !== null) {\n return result;\n }\n }\n\n const primitiveResult = coerceStringToPrimitive(s, schemaType);\n if (primitiveResult !== null) {\n return primitiveResult;\n }\n\n return value;\n}\n\nfunction coerceArrayValue(\n value: unknown,\n prefixItems: unknown[] | undefined,\n itemsSchema: unknown\n): unknown {\n if (Array.isArray(value)) {\n return coerceArrayToArray(value, prefixItems, itemsSchema);\n }\n\n if (value && typeof value === \"object\") {\n const result = coerceObjectToArray(\n value as Record<string, unknown>,\n prefixItems,\n itemsSchema\n );\n if (result !== null) {\n return result;\n }\n // To prevent infinite recursion, check if the itemsSchema is also for an array.\n // If so, just wrap the object. Otherwise, coerce it against the itemsSchema.\n if (getSchemaType(itemsSchema) === \"array\") {\n return [value];\n }\n return [coerceBySchema(value, itemsSchema)];\n }\n\n if (\n value == null ||\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"boolean\"\n ) {\n return coercePrimitiveToArray(value, prefixItems, itemsSchema);\n }\n\n return [value];\n}\n\nexport function coerceBySchema(value: unknown, schema?: unknown): unknown {\n const unwrapped = unwrapJsonSchema(schema);\n if (!unwrapped || typeof unwrapped !== \"object\") {\n if (typeof value === \"string\") {\n return coerceStringWithoutSchema(value);\n }\n return value;\n }\n\n const schemaType = getSchemaType(unwrapped);\n const u = unwrapped as Record<string, unknown>;\n\n // Handle string values\n if (typeof value === \"string\") {\n return coerceStringValue(value, schemaType, u);\n }\n\n // Handle object to object coercion\n if (\n schemaType === \"object\" &&\n value &&\n typeof value === \"object\" &&\n !Array.isArray(value)\n ) {\n return coerceObjectToObject(value as Record<string, unknown>, u);\n }\n\n // Handle array coercion\n if (schemaType === \"array\") {\n const prefixItems = Array.isArray(u.prefixItems)\n ? (u.prefixItems as unknown[])\n : undefined;\n const itemsSchema = u.items as unknown;\n\n return coerceArrayValue(value, prefixItems, itemsSchema);\n }\n\n return value;\n}\n"],"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A,EACjE;AAGA,MAAI,eAAe,SAAS;AAC1B,UAAM,cAAc,MAAM,QAAQ,EAAE,WAAW,IAC1C,EAAE,cACH;AACJ,UAAM,cAAc,EAAE;AAEtB,WAAO,iBAAiB,OAAO,aAAa,WAAW;AAAA,EACzD;AAEA,SAAO;AACT;","names":[]}
@@ -2,7 +2,7 @@ import {
2
2
  coerceBySchema,
3
3
  getSchemaType,
4
4
  unwrapJsonSchema
5
- } from "./chunk-DZB6Y354.js";
5
+ } from "./chunk-OUGMLYAW.js";
6
6
 
7
7
  // src/rxml/errors/types.ts
8
8
  var RXMLParseError = class extends Error {
@@ -1846,6 +1846,11 @@ function createIntermediateCall(toolName, rawSegment, schema) {
1846
1846
  };
1847
1847
  }
1848
1848
 
1849
+ // src/core/utils/regex.ts
1850
+ function escapeRegExp(literal) {
1851
+ return literal.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1852
+ }
1853
+
1849
1854
  // src/rxml/heuristics/xml-defaults.ts
1850
1855
  var MALFORMED_CLOSE_RE_G = /<\/\s+([A-Za-z0-9_:-]+)\s*>/g;
1851
1856
  var MALFORMED_CLOSE_RE = /<\/\s+([A-Za-z0-9_:-]+)\s*>/;
@@ -2087,9 +2092,6 @@ function getStringPropertyNames(schema) {
2087
2092
  }
2088
2093
  return names;
2089
2094
  }
2090
- function escapeRegExp(s) {
2091
- return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2092
- }
2093
2095
  function dedupeSingleTag(xml, key) {
2094
2096
  var _a, _b;
2095
2097
  const escaped = escapeRegExp(key);
@@ -2210,7 +2212,8 @@ function parse2(xml, schema, options = {}) {
2210
2212
  }
2211
2213
 
2212
2214
  export {
2215
+ escapeRegExp,
2213
2216
  stringify,
2214
2217
  parse2 as parse
2215
2218
  };
2216
- //# sourceMappingURL=chunk-TR2ARLIF.js.map
2219
+ //# sourceMappingURL=chunk-ZDBNJWLY.js.map