@qwen-code/qwen-code 0.18.1 → 0.18.3-preview.0

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 (74) hide show
  1. package/README.md +2 -1
  2. package/bundled/qc-helper/docs/common-workflow.md +4 -4
  3. package/bundled/qc-helper/docs/configuration/model-providers.md +1 -1
  4. package/bundled/qc-helper/docs/configuration/settings.md +77 -77
  5. package/bundled/qc-helper/docs/features/channels/feishu.md +16 -0
  6. package/bundled/qc-helper/docs/features/mcp.md +1 -1
  7. package/bundled/qc-helper/docs/features/sub-agents.md +3 -3
  8. package/bundled/qc-helper/docs/qwen-serve.md +24 -12
  9. package/bundled/qc-helper/docs/reference/keyboard-shortcuts.md +30 -30
  10. package/bundled/review/SKILL.md +10 -4
  11. package/bundled/simplify/SKILL.md +1 -1
  12. package/chunks/{agent-XT7NHZ5H.js → agent-X42UKL4M.js} +5 -5
  13. package/chunks/{agent-headless-LNRE63ZL.js → agent-headless-7FQ7NX6G.js} +5 -5
  14. package/chunks/{anthropicContentGenerator-DCI26OQF.js → anthropicContentGenerator-KLBHYGH6.js} +1 -1
  15. package/chunks/{askUserQuestion-ITYUTWLR.js → askUserQuestion-QPZXR3UO.js} +1 -1
  16. package/chunks/{chunk-BXYRCW2C.js → chunk-3U2ZIZDP.js} +10 -5
  17. package/chunks/{chunk-XZTNBSMW.js → chunk-6X6PTTH3.js} +1 -1
  18. package/chunks/{chunk-7KPZFE5A.js → chunk-C64WAJOC.js} +1 -1
  19. package/chunks/{chunk-WJ3SND6W.js → chunk-JHSQY3J5.js} +2 -2
  20. package/chunks/{chunk-3NRO6NHX.js → chunk-MN5RAXVB.js} +3 -3
  21. package/chunks/{chunk-RON7LFNH.js → chunk-P5CE42XM.js} +6 -6
  22. package/chunks/{chunk-Y7KMDUEP.js → chunk-QP4R5FTG.js} +1 -1
  23. package/chunks/{chunk-QILTEBWS.js → chunk-RTTAC5VW.js} +1 -1
  24. package/chunks/{chunk-IS7UA4W3.js → chunk-U62OHNQR.js} +4 -4
  25. package/chunks/{chunk-6T7Y7USE.js → chunk-VFW7VM7A.js} +1354 -1028
  26. package/chunks/{chunk-HQUWWSSP.js → chunk-VIEIRAK3.js} +1 -1
  27. package/chunks/{chunk-HED55F43.js → chunk-VU6A2OBJ.js} +15 -5
  28. package/chunks/{chunk-DHZREJTG.js → chunk-YJDVHAGL.js} +1 -1
  29. package/chunks/{chunk-A2ZIEEGJ.js → chunk-ZNUMXPNK.js} +592 -43
  30. package/chunks/{computer-use-4YX3JGBV.js → computer-use-WHPP33BI.js} +5 -5
  31. package/chunks/{contextCommand-KS2H7MW5.js → contextCommand-WP7BU7IY.js} +7 -7
  32. package/chunks/{cron-create-CAPUKK7I.js → cron-create-DQKRQMCP.js} +1 -1
  33. package/chunks/{cron-delete-G3KAR26Q.js → cron-delete-DOFPHFTI.js} +1 -1
  34. package/chunks/{cron-list-ZA4ZIUS5.js → cron-list-RCVOO3CB.js} +1 -1
  35. package/chunks/{dist-VEGFONCF.js → dist-2UCAYOX7.js} +2 -2
  36. package/chunks/{dist-X4EXN7W6.js → dist-33LHH26D.js} +1 -1
  37. package/chunks/{dist-YLS6NI7H.js → dist-KF43SZZV.js} +1 -1
  38. package/chunks/{dist-7YWFWOCJ.js → dist-UH7CYT7F.js} +2 -2
  39. package/chunks/{edit-2ARPEO4B.js → edit-V22UFE4F.js} +7 -9
  40. package/chunks/{enter-worktree-IXNXNAW5.js → enter-worktree-HYS5U3QO.js} +5 -5
  41. package/chunks/{enterPlanMode-TAKAGAYP.js → enterPlanMode-UR2KPB4Y.js} +5 -5
  42. package/chunks/{exit-worktree-LHTRV7ML.js → exit-worktree-JNIUZIZ3.js} +5 -5
  43. package/chunks/{exitPlanMode-MK5UAITL.js → exitPlanMode-NJY3Y6XQ.js} +11 -9
  44. package/chunks/{geminiContentGenerator-HFJIGO77.js → geminiContentGenerator-SDUMCYHD.js} +1 -1
  45. package/chunks/{glob-I2USLUSC.js → glob-Z6UYFZCH.js} +5 -5
  46. package/chunks/{grep-WBIF7THR.js → grep-WHWDB2HD.js} +5 -5
  47. package/chunks/{ls-2R5RHLX5.js → ls-TRD77UTS.js} +1 -1
  48. package/chunks/{lsp-XKH6ZIAN.js → lsp-2VFWQPZS.js} +1 -1
  49. package/chunks/{monitor-WU7UFATU.js → monitor-F4V4YEE4.js} +5 -5
  50. package/chunks/{notebook-edit-KUHYPXEM.js → notebook-edit-P45433KC.js} +6 -6
  51. package/chunks/{openaiContentGenerator-5PLHYJQL.js → openaiContentGenerator-DRXB5MSN.js} +5 -5
  52. package/chunks/{qwenContentGenerator-TSKW73KY.js → qwenContentGenerator-3XZMXLHX.js} +7 -7
  53. package/chunks/{read-file-VIPF2PS6.js → read-file-WQPROSSJ.js} +3 -3
  54. package/chunks/{ripGrep-XLIZTYE7.js → ripGrep-EAE7GW6T.js} +5 -5
  55. package/chunks/{scheduler-O66SLJGU.js → scheduler-WCMRRLYM.js} +5 -5
  56. package/chunks/{send-message-CTME7DXD.js → send-message-QZOC5GA2.js} +1 -1
  57. package/chunks/{serve-BWOLYT62.js → serve-BVDNMP5D.js} +709 -26
  58. package/chunks/{shell-XE7UYKOO.js → shell-W4LWEOQL.js} +5 -5
  59. package/chunks/{skill-RZWM6XMC.js → skill-VTJI4OPM.js} +3 -3
  60. package/chunks/{src-L5P7K4MH.js → src-E42UOH5I.js} +11 -5
  61. package/chunks/{syntheticOutput-ZJGSU7OQ.js → syntheticOutput-WJSUK4SZ.js} +2 -2
  62. package/chunks/{task-create-EE6JEM7G.js → task-create-GGSC27HO.js} +2 -2
  63. package/chunks/{task-list-EESYAC65.js → task-list-EDHHHSK4.js} +1 -1
  64. package/chunks/{task-stop-XZVCFFYY.js → task-stop-WR5PDVZY.js} +1 -1
  65. package/chunks/{task-update-EIO4HNE3.js → task-update-UR7NUHBV.js} +2 -2
  66. package/chunks/{team-create-R2H7Y3SG.js → team-create-OAGMFFDJ.js} +5 -5
  67. package/chunks/{team-delete-A7LXPGV7.js → team-delete-FC33URJK.js} +1 -1
  68. package/chunks/{todoWrite-VRKSGAWM.js → todoWrite-GO2ME7ZV.js} +1 -1
  69. package/chunks/{tool-search-USSQMTMS.js → tool-search-XZPD5EPI.js} +3 -3
  70. package/chunks/{web-fetch-GHAZUA54.js → web-fetch-NLLATYIL.js} +2 -2
  71. package/chunks/{workflow-5LNNLNUR.js → workflow-AIC3XOX5.js} +249 -24
  72. package/chunks/{write-file-2I7HP24C.js → write-file-6GIRRW43.js} +6 -6
  73. package/cli.js +1320 -536
  74. package/package.json +2 -2
@@ -3231,7 +3231,7 @@ var require_compile = __commonJS({
3231
3231
  }
3232
3232
  __name(compileSchema, "compileSchema");
3233
3233
  exports.compileSchema = compileSchema;
3234
- function resolveRef(root, baseId, ref) {
3234
+ function resolveRef2(root, baseId, ref) {
3235
3235
  var _a;
3236
3236
  ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
3237
3237
  const schOrFunc = root.refs[ref];
@@ -3248,8 +3248,8 @@ var require_compile = __commonJS({
3248
3248
  return;
3249
3249
  return root.refs[ref] = inlineOrCompile.call(this, _sch);
3250
3250
  }
3251
- __name(resolveRef, "resolveRef");
3252
- exports.resolveRef = resolveRef;
3251
+ __name(resolveRef2, "resolveRef");
3252
+ exports.resolveRef = resolveRef2;
3253
3253
  function inlineOrCompile(sch) {
3254
3254
  if ((0, resolve_1.inlineRef)(sch.schema, this.opts.inlineRefs))
3255
3255
  return sch.schema;
@@ -11098,7 +11098,7 @@ var require_compile2 = __commonJS({
11098
11098
  }
11099
11099
  __name(compileSchema, "compileSchema");
11100
11100
  exports.compileSchema = compileSchema;
11101
- function resolveRef(root, baseId, ref) {
11101
+ function resolveRef2(root, baseId, ref) {
11102
11102
  var _a;
11103
11103
  ref = (0, resolve_1.resolveUrl)(this.opts.uriResolver, baseId, ref);
11104
11104
  const schOrFunc = root.refs[ref];
@@ -11115,8 +11115,8 @@ var require_compile2 = __commonJS({
11115
11115
  return;
11116
11116
  return root.refs[ref] = inlineOrCompile.call(this, _sch);
11117
11117
  }
11118
- __name(resolveRef, "resolveRef");
11119
- exports.resolveRef = resolveRef;
11118
+ __name(resolveRef2, "resolveRef");
11119
+ exports.resolveRef = resolveRef2;
11120
11120
  function inlineOrCompile(sch) {
11121
11121
  if ((0, resolve_1.inlineRef)(sch.schema, this.opts.inlineRefs))
11122
11122
  return sch.schema;
@@ -14284,9 +14284,20 @@ var SchemaValidator = class {
14284
14284
  if (!valid && validate.errors) {
14285
14285
  fixBooleanValues(
14286
14286
  data,
14287
+ anySchema,
14288
+ anySchema
14289
+ );
14290
+ fixStringValues(
14291
+ data,
14292
+ anySchema,
14287
14293
  anySchema
14288
14294
  );
14289
14295
  fixStringifiedJsonValues(
14296
+ data,
14297
+ anySchema,
14298
+ anySchema
14299
+ );
14300
+ fixNumericValues(
14290
14301
  data,
14291
14302
  anySchema
14292
14303
  );
@@ -14298,49 +14309,371 @@ var SchemaValidator = class {
14298
14309
  return null;
14299
14310
  }
14300
14311
  };
14301
- function getAcceptedTypes(propSchema) {
14302
- const types = /* @__PURE__ */ new Set();
14303
- if (typeof propSchema["type"] === "string") {
14304
- types.add(propSchema["type"]);
14305
- } else if (Array.isArray(propSchema["type"])) {
14306
- for (const t of propSchema["type"]) {
14307
- types.add(t);
14312
+ function resolveRef(ref, rootSchema) {
14313
+ if (!ref.startsWith("#/")) return null;
14314
+ const parts = ref.slice(2).split("/");
14315
+ let current = rootSchema;
14316
+ for (const rawPart of parts) {
14317
+ if (current == null || typeof current !== "object") return null;
14318
+ const part = rawPart.replace(/~1/g, "/").replace(/~0/g, "~");
14319
+ if (!Object.hasOwn(current, part)) return null;
14320
+ current = current[part];
14321
+ }
14322
+ if (current != null && typeof current === "object" && !Array.isArray(current)) {
14323
+ return current;
14324
+ }
14325
+ return null;
14326
+ }
14327
+ __name(resolveRef, "resolveRef");
14328
+ function resolvePropSchema(propSchema, rootSchema) {
14329
+ if (!propSchema) return void 0;
14330
+ let schema = propSchema;
14331
+ let depth = 0;
14332
+ while (typeof schema["$ref"] === "string" && depth < 64) {
14333
+ depth++;
14334
+ const resolved = resolveRef(schema["$ref"], rootSchema);
14335
+ if (!resolved) return propSchema;
14336
+ schema = resolved;
14337
+ }
14338
+ return schema;
14339
+ }
14340
+ __name(resolvePropSchema, "resolvePropSchema");
14341
+ function resolveArrayElementSchema(parentSchema, rootSchema, index) {
14342
+ const prefixItems = parentSchema["prefixItems"];
14343
+ if (prefixItems && index < prefixItems.length) {
14344
+ const entry = prefixItems[index];
14345
+ if (typeof entry === "object" && entry !== null && !Array.isArray(entry)) {
14346
+ return resolvePropSchema(entry, rootSchema);
14347
+ }
14348
+ return void 0;
14349
+ }
14350
+ const itemsSchema = parentSchema["items"];
14351
+ if (itemsSchema) {
14352
+ return resolvePropSchema(itemsSchema, rootSchema);
14353
+ }
14354
+ return void 0;
14355
+ }
14356
+ __name(resolveArrayElementSchema, "resolveArrayElementSchema");
14357
+ function getCompositionVariants(schema, rootSchema) {
14358
+ const variants = [];
14359
+ for (const keyword of ["allOf", "anyOf", "oneOf"]) {
14360
+ const val = schema[keyword];
14361
+ if (Array.isArray(val)) {
14362
+ for (const item of val) {
14363
+ if (typeof item === "object" && item != null && !Array.isArray(item)) {
14364
+ const resolved = rootSchema ? resolvePropSchema(item, rootSchema) : item;
14365
+ if (resolved) variants.push(resolved);
14366
+ }
14367
+ }
14368
+ }
14369
+ }
14370
+ return variants;
14371
+ }
14372
+ __name(getCompositionVariants, "getCompositionVariants");
14373
+ function schemaHasObjectShape(schema, rootSchema) {
14374
+ if (schema["properties"] || schema["additionalProperties"]) return true;
14375
+ for (const variant of getCompositionVariants(schema, rootSchema)) {
14376
+ if (variant["properties"] || variant["additionalProperties"]) return true;
14377
+ }
14378
+ return false;
14379
+ }
14380
+ __name(schemaHasObjectShape, "schemaHasObjectShape");
14381
+ var DANGEROUS_PROP_KEYS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
14382
+ function getEffectiveProperties(schema, rootSchema) {
14383
+ const merged = /* @__PURE__ */ Object.create(null);
14384
+ for (const variant of getCompositionVariants(schema, rootSchema)) {
14385
+ const variantProps = variant["properties"];
14386
+ if (variantProps) {
14387
+ for (const [k, v] of Object.entries(variantProps)) {
14388
+ if (DANGEROUS_PROP_KEYS.has(k)) continue;
14389
+ if (!Object.hasOwn(merged, k)) merged[k] = v;
14390
+ }
14308
14391
  }
14309
14392
  }
14310
- for (const keyword of ["anyOf", "oneOf"]) {
14311
- const variants = propSchema[keyword];
14312
- if (Array.isArray(variants)) {
14313
- for (const variant of variants) {
14314
- if (typeof variant["type"] === "string") {
14315
- types.add(variant["type"]);
14316
- } else if (Array.isArray(variant["type"])) {
14317
- for (const t of variant["type"]) {
14318
- types.add(t);
14393
+ const topProps = schema["properties"];
14394
+ if (topProps) {
14395
+ for (const [k, v] of Object.entries(topProps)) {
14396
+ if (DANGEROUS_PROP_KEYS.has(k)) continue;
14397
+ merged[k] = v;
14398
+ }
14399
+ }
14400
+ return Object.keys(merged).length > 0 ? merged : void 0;
14401
+ }
14402
+ __name(getEffectiveProperties, "getEffectiveProperties");
14403
+ function getAcceptedTypes(propSchema, rootSchema, depth = 0, cache = /* @__PURE__ */ new WeakMap()) {
14404
+ if (depth > 64) return null;
14405
+ let schema = propSchema;
14406
+ if (typeof schema["$ref"] === "string" && rootSchema) {
14407
+ const resolved = resolvePropSchema(propSchema, rootSchema);
14408
+ if (!resolved || typeof resolved["$ref"] === "string") {
14409
+ return null;
14410
+ }
14411
+ schema = resolved;
14412
+ }
14413
+ const cacheable = typeof schema === "object" && schema !== null;
14414
+ if (cacheable) {
14415
+ const cached = cache.get(schema);
14416
+ if (cached !== void 0) return cached;
14417
+ }
14418
+ const types = /* @__PURE__ */ new Set();
14419
+ if (typeof schema === "object" && schema !== null) {
14420
+ if (typeof schema["type"] === "string") {
14421
+ types.add(schema["type"]);
14422
+ } else if (Array.isArray(schema["type"])) {
14423
+ for (const t of schema["type"]) {
14424
+ types.add(t);
14425
+ }
14426
+ }
14427
+ for (const keyword of ["anyOf", "oneOf", "allOf"]) {
14428
+ const variants = schema[keyword];
14429
+ if (Array.isArray(variants)) {
14430
+ for (const variant of variants) {
14431
+ const nested = getAcceptedTypes(
14432
+ variant,
14433
+ rootSchema,
14434
+ depth + 1,
14435
+ cache
14436
+ );
14437
+ if (nested) {
14438
+ for (const t of nested) {
14439
+ types.add(t);
14440
+ }
14319
14441
  }
14320
14442
  }
14321
14443
  }
14322
14444
  }
14323
14445
  }
14324
- return types.size > 0 ? types : null;
14446
+ const result = types.size > 0 ? types : null;
14447
+ if (cacheable) cache.set(schema, result);
14448
+ return result;
14325
14449
  }
14326
14450
  __name(getAcceptedTypes, "getAcceptedTypes");
14327
- function fixStringifiedJsonValues(data, schema) {
14328
- const properties = schema["properties"];
14329
- if (!properties) return;
14451
+ function valueToSchemaType(value) {
14452
+ if (value === null) return "null";
14453
+ if (typeof value === "boolean") return "boolean";
14454
+ if (typeof value === "bigint") return "integer";
14455
+ if (typeof value === "number") {
14456
+ if (!Number.isFinite(value)) return null;
14457
+ return Number.isInteger(value) ? "integer" : "number";
14458
+ }
14459
+ if (typeof value === "string") return "string";
14460
+ if (Array.isArray(value)) return "array";
14461
+ if (typeof value === "object") return "object";
14462
+ return null;
14463
+ }
14464
+ __name(valueToSchemaType, "valueToSchemaType");
14465
+ function typeIsAccepted(valueType, accepted) {
14466
+ if (accepted.has(valueType)) return true;
14467
+ if (valueType === "integer" && accepted.has("number")) return true;
14468
+ return false;
14469
+ }
14470
+ __name(typeIsAccepted, "typeIsAccepted");
14471
+ function fixStringifiedJsonValuesInArray(array, itemsSchema, root, key) {
14472
+ if (Array.isArray(itemsSchema["prefixItems"])) {
14473
+ for (let i = 0; i < array.length; i++) {
14474
+ const elSchema = resolveArrayElementSchema(itemsSchema, root, i);
14475
+ if (!elSchema) continue;
14476
+ const item = array[i];
14477
+ if (typeof item !== "string") continue;
14478
+ const trimmed = item.trim();
14479
+ if (trimmed.startsWith("[") && trimmed.endsWith("]") || trimmed.startsWith("{") && trimmed.endsWith("}")) {
14480
+ const elAccepted = getAcceptedTypes(elSchema, root);
14481
+ if (elAccepted && !elAccepted.has("string")) {
14482
+ try {
14483
+ const parsed = JSON.parse(trimmed);
14484
+ const parsedType = Array.isArray(parsed) ? "array" : typeof parsed;
14485
+ if (elAccepted.has(parsedType)) {
14486
+ debugLogger.debug(
14487
+ `coercion: ${key}[${i}] = ${String(item)} \u2192 ${JSON.stringify(parsed)} (accepted: ${[...elAccepted].join("|")})`
14488
+ );
14489
+ array[i] = parsed;
14490
+ }
14491
+ } catch {
14492
+ }
14493
+ }
14494
+ }
14495
+ }
14496
+ return;
14497
+ }
14498
+ const resolvedItems = resolvePropSchema(itemsSchema, root);
14499
+ if (!resolvedItems) return;
14500
+ const innerItems = resolvedItems["items"];
14501
+ const resolvedInner = innerItems ? resolvePropSchema(innerItems, root) : void 0;
14502
+ const itemsAccepted = resolvedInner ? getAcceptedTypes(resolvedInner, root) : null;
14503
+ if (!itemsAccepted || itemsAccepted.has("string")) return;
14504
+ for (let i = 0; i < array.length; i++) {
14505
+ const item = array[i];
14506
+ if (typeof item !== "string") continue;
14507
+ const trimmed = item.trim();
14508
+ if (trimmed.startsWith("[") && trimmed.endsWith("]") || trimmed.startsWith("{") && trimmed.endsWith("}")) {
14509
+ try {
14510
+ const parsed = JSON.parse(trimmed);
14511
+ const parsedType = Array.isArray(parsed) ? "array" : typeof parsed;
14512
+ if (itemsAccepted.has(parsedType)) {
14513
+ debugLogger.debug(
14514
+ `coercion: ${key}[${i}] = ${String(item)} \u2192 ${JSON.stringify(parsed)} (accepted: ${[...itemsAccepted].join("|")})`
14515
+ );
14516
+ array[i] = parsed;
14517
+ }
14518
+ } catch {
14519
+ }
14520
+ }
14521
+ }
14522
+ }
14523
+ __name(fixStringifiedJsonValuesInArray, "fixStringifiedJsonValuesInArray");
14524
+ function fixStringifiedJsonValues(data, schema, rootSchema, depth = 0) {
14525
+ if (depth > 64) return;
14526
+ const root = rootSchema ?? schema;
14527
+ const properties = getEffectiveProperties(schema, root);
14528
+ if (!properties && !schema["additionalProperties"]) return;
14330
14529
  for (const key of Object.keys(data)) {
14331
14530
  const value = data[key];
14332
- const propSchema = properties[key];
14333
- if (!propSchema || typeof value !== "string") continue;
14531
+ const additionalProps = schema["additionalProperties"];
14532
+ const propSchema = properties?.[key] ?? (typeof additionalProps === "object" && additionalProps !== null ? additionalProps : void 0);
14533
+ if (!propSchema) continue;
14534
+ const resolved = resolvePropSchema(
14535
+ propSchema,
14536
+ root
14537
+ );
14538
+ if (!resolved) continue;
14539
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
14540
+ if (schemaHasObjectShape(resolved, root)) {
14541
+ fixStringifiedJsonValues(
14542
+ value,
14543
+ resolved,
14544
+ root,
14545
+ depth + 1
14546
+ );
14547
+ }
14548
+ continue;
14549
+ }
14550
+ if (Array.isArray(value)) {
14551
+ if (Array.isArray(resolved["prefixItems"])) {
14552
+ for (let i = 0; i < value.length; i++) {
14553
+ const elSchema = resolveArrayElementSchema(resolved, root, i);
14554
+ if (!elSchema) continue;
14555
+ const item = value[i];
14556
+ if (typeof item === "object" && item !== null && !Array.isArray(item)) {
14557
+ if (schemaHasObjectShape(elSchema, root)) {
14558
+ fixStringifiedJsonValues(
14559
+ item,
14560
+ elSchema,
14561
+ root,
14562
+ depth + 1
14563
+ );
14564
+ }
14565
+ } else if (Array.isArray(item)) {
14566
+ if (elSchema["type"] === "array" || elSchema["items"] || elSchema["prefixItems"]) {
14567
+ fixStringifiedJsonValuesInArray(item, elSchema, root, key);
14568
+ }
14569
+ } else if (typeof item === "string") {
14570
+ const elAccepted = getAcceptedTypes(elSchema, root);
14571
+ if (elAccepted && !elAccepted.has("string")) {
14572
+ const trimmed2 = item.trim();
14573
+ if (trimmed2.startsWith("[") && trimmed2.endsWith("]") || trimmed2.startsWith("{") && trimmed2.endsWith("}")) {
14574
+ try {
14575
+ const parsed = JSON.parse(trimmed2);
14576
+ const parsedType = Array.isArray(parsed) ? "array" : typeof parsed;
14577
+ if (elAccepted.has(parsedType)) {
14578
+ debugLogger.debug(
14579
+ `coercion: ${key}[${i}] = ${String(item)} \u2192 ${JSON.stringify(parsed)} (accepted: ${[...elAccepted].join("|")})`
14580
+ );
14581
+ value[i] = parsed;
14582
+ }
14583
+ } catch {
14584
+ }
14585
+ }
14586
+ }
14587
+ }
14588
+ }
14589
+ } else {
14590
+ const itemsSchema = resolved["items"];
14591
+ if (itemsSchema) {
14592
+ const resolvedItems = resolvePropSchema(itemsSchema, root);
14593
+ if (!resolvedItems) continue;
14594
+ if (schemaHasObjectShape(resolvedItems, root)) {
14595
+ const itemsAccepted = getAcceptedTypes(resolvedItems, root);
14596
+ for (let i = 0; i < value.length; i++) {
14597
+ const item = value[i];
14598
+ if (typeof item === "object" && item !== null && !Array.isArray(item)) {
14599
+ fixStringifiedJsonValues(
14600
+ item,
14601
+ resolvedItems,
14602
+ root,
14603
+ depth + 1
14604
+ );
14605
+ } else if (typeof item === "string" && itemsAccepted && !itemsAccepted.has("string")) {
14606
+ const trimmed2 = item.trim();
14607
+ if (trimmed2.startsWith("{") && trimmed2.endsWith("}") || trimmed2.startsWith("[") && trimmed2.endsWith("]")) {
14608
+ try {
14609
+ const parsed = JSON.parse(trimmed2);
14610
+ if (itemsAccepted.has(
14611
+ Array.isArray(parsed) ? "array" : typeof parsed
14612
+ )) {
14613
+ debugLogger.debug(
14614
+ `coercion: ${key}[${i}] = ${String(item)} \u2192 ${JSON.stringify(parsed)} (accepted: ${[...itemsAccepted].join("|")})`
14615
+ );
14616
+ value[i] = parsed;
14617
+ }
14618
+ } catch {
14619
+ }
14620
+ }
14621
+ }
14622
+ }
14623
+ } else if (resolvedItems["type"] === "array" || resolvedItems["items"] || resolvedItems["prefixItems"]) {
14624
+ for (const subArray of value) {
14625
+ if (Array.isArray(subArray)) {
14626
+ fixStringifiedJsonValuesInArray(
14627
+ subArray,
14628
+ resolvedItems,
14629
+ root,
14630
+ key
14631
+ );
14632
+ }
14633
+ }
14634
+ } else {
14635
+ const itemsAccepted = getAcceptedTypes(resolvedItems, root);
14636
+ if (itemsAccepted && !itemsAccepted.has("string")) {
14637
+ for (let i = 0; i < value.length; i++) {
14638
+ const item = value[i];
14639
+ if (typeof item !== "string") continue;
14640
+ const trimmed2 = item.trim();
14641
+ if (trimmed2.startsWith("[") && trimmed2.endsWith("]") || trimmed2.startsWith("{") && trimmed2.endsWith("}")) {
14642
+ try {
14643
+ const parsed = JSON.parse(trimmed2);
14644
+ const parsedType = Array.isArray(parsed) ? "array" : typeof parsed;
14645
+ if (itemsAccepted.has(parsedType)) {
14646
+ debugLogger.debug(
14647
+ `coercion: ${key}[${i}] = ${String(item)} \u2192 ${JSON.stringify(parsed)} (accepted: ${[...itemsAccepted].join("|")})`
14648
+ );
14649
+ value[i] = parsed;
14650
+ }
14651
+ } catch {
14652
+ }
14653
+ }
14654
+ }
14655
+ }
14656
+ }
14657
+ }
14658
+ }
14659
+ continue;
14660
+ }
14661
+ if (typeof value !== "string") continue;
14334
14662
  const trimmed = value.trim();
14335
14663
  if (trimmed.startsWith("[") && trimmed.endsWith("]") || trimmed.startsWith("{") && trimmed.endsWith("}")) {
14336
- const accepted = getAcceptedTypes(propSchema);
14664
+ const accepted = getAcceptedTypes(resolved, root);
14337
14665
  if (!accepted) continue;
14338
14666
  if (accepted.has("string")) continue;
14339
- if (!accepted.has("array") && !accepted.has("object")) continue;
14667
+ if (!accepted.has("array") && !accepted.has("object")) {
14668
+ continue;
14669
+ }
14340
14670
  try {
14341
14671
  const parsed = JSON.parse(trimmed);
14342
14672
  const parsedType = Array.isArray(parsed) ? "array" : typeof parsed;
14343
14673
  if (accepted.has(parsedType)) {
14674
+ debugLogger.debug(
14675
+ `coercion: ${key} = ${String(value)} \u2192 ${JSON.stringify(parsed)} (accepted: ${[...accepted].join("|")})`
14676
+ );
14344
14677
  data[key] = parsed;
14345
14678
  }
14346
14679
  } catch {
@@ -14349,31 +14682,247 @@ function fixStringifiedJsonValues(data, schema) {
14349
14682
  }
14350
14683
  }
14351
14684
  __name(fixStringifiedJsonValues, "fixStringifiedJsonValues");
14352
- function fixBooleanValues(data, schema) {
14353
- const properties = schema?.["properties"];
14354
- const items = schema?.["items"];
14685
+ function fixNumericValues(data, schema) {
14686
+ const properties = schema["properties"];
14687
+ const items = schema["items"];
14355
14688
  for (const key of Object.keys(data)) {
14356
14689
  if (!(key in data)) continue;
14357
14690
  const value = data[key];
14358
14691
  const childSchema = Array.isArray(data) ? items : properties?.[key];
14359
14692
  if (typeof value === "object" && value !== null) {
14360
- fixBooleanValues(value, childSchema);
14693
+ fixNumericValues(value, childSchema ?? {});
14361
14694
  continue;
14362
14695
  }
14363
14696
  if (typeof value !== "string") continue;
14364
14697
  const accepted = childSchema ? getAcceptedTypes(childSchema) : null;
14365
- if (!accepted || accepted.has("string") || !accepted.has("boolean")) {
14698
+ if (!accepted || accepted.has("string")) continue;
14699
+ const wantsInteger = accepted.has("integer");
14700
+ const wantsNumber = accepted.has("number");
14701
+ if (!wantsInteger && !wantsNumber) continue;
14702
+ const trimmed = value.trim();
14703
+ if (!/^-?\d+(\.\d+)?$/.test(trimmed)) continue;
14704
+ const num = parseFloat(trimmed);
14705
+ if (wantsInteger && !wantsNumber && num % 1 !== 0) continue;
14706
+ const parsed = wantsNumber ? num : parseInt(trimmed, 10);
14707
+ if (Number.isFinite(parsed)) {
14708
+ data[key] = parsed;
14709
+ }
14710
+ }
14711
+ }
14712
+ __name(fixNumericValues, "fixNumericValues");
14713
+ function fixBooleanValues(data, schema, rootSchema, depth = 0) {
14714
+ if (depth > 64) return;
14715
+ const root = rootSchema ?? schema;
14716
+ const properties = getEffectiveProperties(schema, root);
14717
+ if (!properties && !schema["additionalProperties"]) return;
14718
+ for (const key of Object.keys(data)) {
14719
+ const value = data[key];
14720
+ const additionalProps = schema["additionalProperties"];
14721
+ const propSchema = properties?.[key] ?? (typeof additionalProps === "object" && additionalProps !== null ? additionalProps : void 0);
14722
+ const resolved = propSchema ? resolvePropSchema(propSchema, root) : void 0;
14723
+ if (typeof value === "object" && value !== null) {
14724
+ if (Array.isArray(value)) {
14725
+ if (Array.isArray(resolved?.["prefixItems"])) {
14726
+ for (let i = 0; i < value.length; i++) {
14727
+ const elSchema = resolveArrayElementSchema(resolved, root, i);
14728
+ if (!elSchema) continue;
14729
+ const item = value[i];
14730
+ if (typeof item === "object" && item !== null && !Array.isArray(item)) {
14731
+ if (schemaHasObjectShape(elSchema, root)) {
14732
+ fixBooleanValues(
14733
+ item,
14734
+ elSchema,
14735
+ root,
14736
+ depth + 1
14737
+ );
14738
+ }
14739
+ } else if (typeof item === "string") {
14740
+ const elAccepted = getAcceptedTypes(elSchema, root);
14741
+ if (elAccepted?.has("boolean") && !elAccepted.has("string")) {
14742
+ const lower = item.toLowerCase();
14743
+ if (lower === "true" || lower === "false") {
14744
+ debugLogger.debug(
14745
+ `coercion: ${key}[${i}] = ${JSON.stringify(item)} \u2192 ${lower === "true"} (accepted: ${[...elAccepted].join("|")})`
14746
+ );
14747
+ value[i] = lower === "true";
14748
+ }
14749
+ }
14750
+ }
14751
+ }
14752
+ } else {
14753
+ const itemsSchema = resolved?.["items"];
14754
+ if (itemsSchema) {
14755
+ const resolvedItems = resolvePropSchema(itemsSchema, root);
14756
+ if (!resolvedItems) continue;
14757
+ if (schemaHasObjectShape(resolvedItems, root)) {
14758
+ for (const item of value) {
14759
+ if (typeof item === "object" && item !== null && !Array.isArray(item)) {
14760
+ fixBooleanValues(
14761
+ item,
14762
+ resolvedItems,
14763
+ root,
14764
+ depth + 1
14765
+ );
14766
+ }
14767
+ }
14768
+ } else {
14769
+ const itemsAccepted = getAcceptedTypes(resolvedItems, root);
14770
+ if (itemsAccepted?.has("boolean") && !itemsAccepted.has("string")) {
14771
+ for (let i = 0; i < value.length; i++) {
14772
+ const item = value[i];
14773
+ if (typeof item === "string") {
14774
+ const lower = item.toLowerCase();
14775
+ if (lower === "true" || lower === "false") {
14776
+ debugLogger.debug(
14777
+ `coercion: ${key}[${i}] = ${JSON.stringify(item)} \u2192 ${lower === "true"} (accepted: ${[...itemsAccepted].join("|")})`
14778
+ );
14779
+ value[i] = lower === "true";
14780
+ }
14781
+ }
14782
+ }
14783
+ }
14784
+ }
14785
+ }
14786
+ }
14787
+ } else {
14788
+ if (resolved && schemaHasObjectShape(resolved, root)) {
14789
+ fixBooleanValues(
14790
+ value,
14791
+ resolved,
14792
+ root,
14793
+ depth + 1
14794
+ );
14795
+ }
14796
+ }
14366
14797
  continue;
14367
14798
  }
14368
- const lower = value.toLowerCase();
14369
- if (lower === "true") {
14370
- data[key] = true;
14371
- } else if (lower === "false") {
14372
- data[key] = false;
14799
+ if (typeof value === "string") {
14800
+ const lower = value.toLowerCase();
14801
+ if (lower !== "true" && lower !== "false") continue;
14802
+ const accepted = resolved ? getAcceptedTypes(resolved, root) : null;
14803
+ if (accepted?.has("boolean") && !accepted.has("string")) {
14804
+ debugLogger.debug(
14805
+ `coercion: ${key} = ${JSON.stringify(value)} \u2192 ${lower === "true"} (accepted: ${[...accepted].join("|")})`
14806
+ );
14807
+ data[key] = lower === "true";
14808
+ }
14373
14809
  }
14374
14810
  }
14375
14811
  }
14376
14812
  __name(fixBooleanValues, "fixBooleanValues");
14813
+ function fixStringValues(data, schema, rootSchema, depth = 0) {
14814
+ if (depth > 64) return;
14815
+ const root = rootSchema ?? schema;
14816
+ const properties = getEffectiveProperties(schema, root);
14817
+ if (!properties && !schema["additionalProperties"]) return;
14818
+ for (const key of Object.keys(data)) {
14819
+ const value = data[key];
14820
+ const additionalProps = schema["additionalProperties"];
14821
+ const propSchema = properties?.[key] ?? (typeof additionalProps === "object" && additionalProps !== null ? additionalProps : void 0);
14822
+ if (!propSchema) continue;
14823
+ const resolved = resolvePropSchema(
14824
+ propSchema,
14825
+ root
14826
+ );
14827
+ if (!resolved) continue;
14828
+ if (typeof value === "object" && value !== null) {
14829
+ if (Array.isArray(value)) {
14830
+ if (Array.isArray(resolved["prefixItems"])) {
14831
+ let coerced;
14832
+ for (let i = 0; i < value.length; i++) {
14833
+ const elSchema = resolveArrayElementSchema(resolved, root, i);
14834
+ if (!elSchema) continue;
14835
+ const item = value[i];
14836
+ if (typeof item === "object" && item !== null && !Array.isArray(item)) {
14837
+ if (schemaHasObjectShape(elSchema, root)) {
14838
+ fixStringValues(
14839
+ item,
14840
+ elSchema,
14841
+ root,
14842
+ depth + 1
14843
+ );
14844
+ }
14845
+ } else if (item !== null && item !== void 0 && (typeof item === "number" || typeof item === "boolean" || typeof item === "bigint")) {
14846
+ const elAccepted = getAcceptedTypes(elSchema, root);
14847
+ if (elAccepted?.has("string")) {
14848
+ const currentType = valueToSchemaType(item);
14849
+ if (currentType && !typeIsAccepted(currentType, elAccepted)) {
14850
+ coerced ??= [...value];
14851
+ debugLogger.debug(
14852
+ `coercion: ${key}[${i}] = ${String(item)} \u2192 ${JSON.stringify(String(item))} (accepted: ${[...elAccepted].join("|")})`
14853
+ );
14854
+ coerced[i] = String(item);
14855
+ }
14856
+ }
14857
+ }
14858
+ }
14859
+ if (coerced) data[key] = coerced;
14860
+ } else {
14861
+ const itemsSchema = resolved["items"];
14862
+ if (itemsSchema) {
14863
+ const resolvedItems = resolvePropSchema(itemsSchema, root);
14864
+ if (resolvedItems) {
14865
+ if (schemaHasObjectShape(resolvedItems, root)) {
14866
+ for (const item of value) {
14867
+ if (typeof item === "object" && item !== null && !Array.isArray(item)) {
14868
+ fixStringValues(
14869
+ item,
14870
+ resolvedItems,
14871
+ root,
14872
+ depth + 1
14873
+ );
14874
+ }
14875
+ }
14876
+ } else {
14877
+ const itemsAccepted = getAcceptedTypes(resolvedItems, root);
14878
+ if (itemsAccepted?.has("string")) {
14879
+ let coerced;
14880
+ for (let i = 0; i < value.length; i++) {
14881
+ const item = value[i];
14882
+ if (item !== null && item !== void 0 && (typeof item === "number" || typeof item === "boolean" || typeof item === "bigint")) {
14883
+ const currentType = valueToSchemaType(item);
14884
+ if (currentType && !typeIsAccepted(currentType, itemsAccepted)) {
14885
+ coerced ??= [...value];
14886
+ debugLogger.debug(
14887
+ `coercion: ${key}[${i}] = ${String(item)} \u2192 ${JSON.stringify(String(item))} (accepted: ${[...itemsAccepted].join("|")})`
14888
+ );
14889
+ coerced[i] = String(item);
14890
+ }
14891
+ }
14892
+ }
14893
+ if (coerced) data[key] = coerced;
14894
+ }
14895
+ }
14896
+ }
14897
+ }
14898
+ }
14899
+ } else {
14900
+ if (schemaHasObjectShape(resolved, root)) {
14901
+ fixStringValues(
14902
+ value,
14903
+ resolved,
14904
+ root,
14905
+ depth + 1
14906
+ );
14907
+ }
14908
+ }
14909
+ continue;
14910
+ }
14911
+ if (typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") {
14912
+ const accepted = getAcceptedTypes(resolved, root);
14913
+ if (accepted?.has("string")) {
14914
+ const currentType = valueToSchemaType(value);
14915
+ if (currentType && !typeIsAccepted(currentType, accepted)) {
14916
+ debugLogger.debug(
14917
+ `coercion: ${key} = ${String(value)} \u2192 ${JSON.stringify(String(value))} (accepted: ${[...accepted].join("|")})`
14918
+ );
14919
+ data[key] = String(value);
14920
+ }
14921
+ }
14922
+ }
14923
+ }
14924
+ }
14925
+ __name(fixStringValues, "fixStringValues");
14377
14926
 
14378
14927
  // packages/core/src/agents/runtime/agent-statistics.ts
14379
14928
  init_esbuild_shims();
@@ -14769,7 +15318,7 @@ function isTool(obj) {
14769
15318
  }
14770
15319
  __name(isTool, "isTool");
14771
15320
  function hasCycleInSchema(schema) {
14772
- function resolveRef(ref) {
15321
+ function resolveRef2(ref) {
14773
15322
  if (!ref.startsWith("#/")) {
14774
15323
  return null;
14775
15324
  }
@@ -14783,7 +15332,7 @@ function hasCycleInSchema(schema) {
14783
15332
  }
14784
15333
  return current;
14785
15334
  }
14786
- __name(resolveRef, "resolveRef");
15335
+ __name(resolveRef2, "resolveRef");
14787
15336
  function traverse(node, visitedRefs, pathRefs) {
14788
15337
  if (typeof node !== "object" || node === null) {
14789
15338
  return false;
@@ -14804,7 +15353,7 @@ function hasCycleInSchema(schema) {
14804
15353
  if (visitedRefs.has(ref)) {
14805
15354
  return false;
14806
15355
  }
14807
- const resolvedNode = resolveRef(ref);
15356
+ const resolvedNode = resolveRef2(ref);
14808
15357
  if (resolvedNode) {
14809
15358
  visitedRefs.add(ref);
14810
15359
  pathRefs.add(ref);