@youdotcom-oss/ai-sdk-plugin 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.d.ts CHANGED
@@ -137,10 +137,17 @@ export declare const youExpress: (config?: YouToolsConfig) => import("ai").Tool<
137
137
  */
138
138
  export declare const youContents: (config?: YouToolsConfig) => import("ai").Tool<{
139
139
  urls: string[];
140
- format: "markdown" | "html";
140
+ formats?: ("markdown" | "html" | "metadata")[] | undefined;
141
+ format?: "markdown" | "html" | undefined;
142
+ crawl_timeout?: number | undefined;
141
143
  }, {
142
144
  url: string;
143
145
  title?: string | undefined;
144
146
  html?: string | undefined;
145
147
  markdown?: string | undefined;
148
+ metadata?: {
149
+ jsonld?: Record<string, unknown>[] | undefined;
150
+ opengraph?: Record<string, string> | undefined;
151
+ twitter?: Record<string, string> | undefined;
152
+ } | undefined;
146
153
  }[]>;
package/dist/main.js CHANGED
@@ -9,7 +9,7 @@ var __export = (target, all) => {
9
9
  });
10
10
  };
11
11
 
12
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/core/core.js
12
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/core.js
13
13
  var NEVER = Object.freeze({
14
14
  status: "aborted"
15
15
  });
@@ -85,7 +85,7 @@ function config(newConfig) {
85
85
  Object.assign(globalConfig, newConfig);
86
86
  return globalConfig;
87
87
  }
88
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/core/util.js
88
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/util.js
89
89
  var exports_util = {};
90
90
  __export(exports_util, {
91
91
  unwrapMessage: () => unwrapMessage,
@@ -104,6 +104,7 @@ __export(exports_util, {
104
104
  prefixIssues: () => prefixIssues,
105
105
  pick: () => pick,
106
106
  partial: () => partial,
107
+ parsedType: () => parsedType,
107
108
  optionalKeys: () => optionalKeys,
108
109
  omit: () => omit,
109
110
  objectClone: () => objectClone,
@@ -461,6 +462,11 @@ var BIGINT_FORMAT_RANGES = {
461
462
  };
462
463
  function pick(schema, mask) {
463
464
  const currDef = schema._zod.def;
465
+ const checks = currDef.checks;
466
+ const hasChecks = checks && checks.length > 0;
467
+ if (hasChecks) {
468
+ throw new Error(".pick() cannot be used on object schemas containing refinements");
469
+ }
464
470
  const def = mergeDefs(schema._zod.def, {
465
471
  get shape() {
466
472
  const newShape = {};
@@ -481,6 +487,11 @@ function pick(schema, mask) {
481
487
  }
482
488
  function omit(schema, mask) {
483
489
  const currDef = schema._zod.def;
490
+ const checks = currDef.checks;
491
+ const hasChecks = checks && checks.length > 0;
492
+ if (hasChecks) {
493
+ throw new Error(".omit() cannot be used on object schemas containing refinements");
494
+ }
484
495
  const def = mergeDefs(schema._zod.def, {
485
496
  get shape() {
486
497
  const newShape = { ...schema._zod.def.shape };
@@ -506,15 +517,19 @@ function extend(schema, shape) {
506
517
  const checks = schema._zod.def.checks;
507
518
  const hasChecks = checks && checks.length > 0;
508
519
  if (hasChecks) {
509
- throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
520
+ const existingShape = schema._zod.def.shape;
521
+ for (const key in shape) {
522
+ if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
523
+ throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
524
+ }
525
+ }
510
526
  }
511
527
  const def = mergeDefs(schema._zod.def, {
512
528
  get shape() {
513
529
  const _shape = { ...schema._zod.def.shape, ...shape };
514
530
  assignProp(this, "shape", _shape);
515
531
  return _shape;
516
- },
517
- checks: []
532
+ }
518
533
  });
519
534
  return clone(schema, def);
520
535
  }
@@ -522,15 +537,13 @@ function safeExtend(schema, shape) {
522
537
  if (!isPlainObject(shape)) {
523
538
  throw new Error("Invalid input to safeExtend: expected a plain object");
524
539
  }
525
- const def = {
526
- ...schema._zod.def,
540
+ const def = mergeDefs(schema._zod.def, {
527
541
  get shape() {
528
542
  const _shape = { ...schema._zod.def.shape, ...shape };
529
543
  assignProp(this, "shape", _shape);
530
544
  return _shape;
531
- },
532
- checks: schema._zod.def.checks
533
- };
545
+ }
546
+ });
534
547
  return clone(schema, def);
535
548
  }
536
549
  function merge(a, b) {
@@ -548,6 +561,12 @@ function merge(a, b) {
548
561
  return clone(a, def);
549
562
  }
550
563
  function partial(Class, schema, mask) {
564
+ const currDef = schema._zod.def;
565
+ const checks = currDef.checks;
566
+ const hasChecks = checks && checks.length > 0;
567
+ if (hasChecks) {
568
+ throw new Error(".partial() cannot be used on object schemas containing refinements");
569
+ }
551
570
  const def = mergeDefs(schema._zod.def, {
552
571
  get shape() {
553
572
  const oldShape = schema._zod.def.shape;
@@ -606,8 +625,7 @@ function required(Class, schema, mask) {
606
625
  }
607
626
  assignProp(this, "shape", shape);
608
627
  return shape;
609
- },
610
- checks: []
628
+ }
611
629
  });
612
630
  return clone(schema, def);
613
631
  }
@@ -661,6 +679,27 @@ function getLengthableOrigin(input) {
661
679
  return "string";
662
680
  return "unknown";
663
681
  }
682
+ function parsedType(data) {
683
+ const t = typeof data;
684
+ switch (t) {
685
+ case "number": {
686
+ return Number.isNaN(data) ? "nan" : "number";
687
+ }
688
+ case "object": {
689
+ if (data === null) {
690
+ return "null";
691
+ }
692
+ if (Array.isArray(data)) {
693
+ return "array";
694
+ }
695
+ const obj = data;
696
+ if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
697
+ return obj.constructor.name;
698
+ }
699
+ }
700
+ }
701
+ return t;
702
+ }
664
703
  function issue(...args) {
665
704
  const [iss, input, inst] = args;
666
705
  if (typeof iss === "string") {
@@ -720,7 +759,7 @@ class Class {
720
759
  constructor(..._args) {}
721
760
  }
722
761
 
723
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/core/errors.js
762
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/errors.js
724
763
  var initializer = (inst, def) => {
725
764
  inst.name = "$ZodError";
726
765
  Object.defineProperty(inst, "_zod", {
@@ -786,7 +825,7 @@ function formatError(error, mapper = (issue2) => issue2.message) {
786
825
  return fieldErrors;
787
826
  }
788
827
 
789
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/core/parse.js
828
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/parse.js
790
829
  var _parse = (_Err) => (schema, value, _ctx, _params) => {
791
830
  const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
792
831
  const result = schema._zod.run({ value, issues: [] }, ctx);
@@ -863,7 +902,7 @@ var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
863
902
  var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
864
903
  return _safeParseAsync(_Err)(schema, value, _ctx);
865
904
  };
866
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/core/regexes.js
905
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/regexes.js
867
906
  var cuid = /^[cC][^\s-]{8,}$/;
868
907
  var cuid2 = /^[0-9a-z]+$/;
869
908
  var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
@@ -888,7 +927,7 @@ var cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]
888
927
  var cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
889
928
  var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
890
929
  var base64url = /^[A-Za-z0-9_-]*$/;
891
- var e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
930
+ var e164 = /^\+[1-9]\d{6,14}$/;
892
931
  var dateSource = `(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;
893
932
  var date = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
894
933
  function timeSource(args) {
@@ -914,12 +953,12 @@ var string = (params) => {
914
953
  return new RegExp(`^${regex}$`);
915
954
  };
916
955
  var integer = /^-?\d+$/;
917
- var number = /^-?\d+(?:\.\d+)?/;
956
+ var number = /^-?\d+(?:\.\d+)?$/;
918
957
  var boolean = /^(?:true|false)$/i;
919
958
  var lowercase = /^[^A-Z]*$/;
920
959
  var uppercase = /^[^a-z]*$/;
921
960
 
922
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/core/checks.js
961
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/checks.js
923
962
  var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
924
963
  var _a;
925
964
  inst._zod ?? (inst._zod = {});
@@ -951,7 +990,7 @@ var $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (inst,
951
990
  payload.issues.push({
952
991
  origin,
953
992
  code: "too_big",
954
- maximum: def.value,
993
+ maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
955
994
  input: payload.value,
956
995
  inclusive: def.inclusive,
957
996
  inst,
@@ -979,7 +1018,7 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
979
1018
  payload.issues.push({
980
1019
  origin,
981
1020
  code: "too_small",
982
- minimum: def.value,
1021
+ minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
983
1022
  input: payload.value,
984
1023
  inclusive: def.inclusive,
985
1024
  inst,
@@ -1046,6 +1085,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
1046
1085
  note: "Integers must be within the safe integer range.",
1047
1086
  inst,
1048
1087
  origin,
1088
+ inclusive: true,
1049
1089
  continue: !def.abort
1050
1090
  });
1051
1091
  } else {
@@ -1056,6 +1096,7 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
1056
1096
  note: "Integers must be within the safe integer range.",
1057
1097
  inst,
1058
1098
  origin,
1099
+ inclusive: true,
1059
1100
  continue: !def.abort
1060
1101
  });
1061
1102
  }
@@ -1079,7 +1120,9 @@ var $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberFormat"
1079
1120
  input,
1080
1121
  code: "too_big",
1081
1122
  maximum,
1082
- inst
1123
+ inclusive: true,
1124
+ inst,
1125
+ continue: !def.abort
1083
1126
  });
1084
1127
  }
1085
1128
  };
@@ -1304,7 +1347,7 @@ var $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (ins
1304
1347
  };
1305
1348
  });
1306
1349
 
1307
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/core/doc.js
1350
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/doc.js
1308
1351
  class Doc {
1309
1352
  constructor(args = []) {
1310
1353
  this.content = [];
@@ -1342,14 +1385,14 @@ class Doc {
1342
1385
  }
1343
1386
  }
1344
1387
 
1345
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/core/versions.js
1388
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/versions.js
1346
1389
  var version = {
1347
1390
  major: 4,
1348
- minor: 2,
1349
- patch: 0
1391
+ minor: 3,
1392
+ patch: 6
1350
1393
  };
1351
1394
 
1352
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/core/schemas.js
1395
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/schemas.js
1353
1396
  var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1354
1397
  var _a;
1355
1398
  inst ?? (inst = {});
@@ -1446,7 +1489,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1446
1489
  return runChecks(result, checks, ctx);
1447
1490
  };
1448
1491
  }
1449
- inst["~standard"] = {
1492
+ defineLazy(inst, "~standard", () => ({
1450
1493
  validate: (value) => {
1451
1494
  try {
1452
1495
  const r = safeParse(inst, value);
@@ -1457,7 +1500,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
1457
1500
  },
1458
1501
  vendor: "zod",
1459
1502
  version: 1
1460
- };
1503
+ }));
1461
1504
  });
1462
1505
  var $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
1463
1506
  $ZodType.init(inst, def);
@@ -1855,8 +1898,11 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1855
1898
  return payload;
1856
1899
  };
1857
1900
  });
1858
- function handlePropertyResult(result, final, key, input) {
1901
+ function handlePropertyResult(result, final, key, input, isOptionalOut) {
1859
1902
  if (result.issues.length) {
1903
+ if (isOptionalOut && !(key in input)) {
1904
+ return;
1905
+ }
1860
1906
  final.issues.push(...prefixIssues(key, result.issues));
1861
1907
  }
1862
1908
  if (result.value === undefined) {
@@ -1888,6 +1934,7 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1888
1934
  const keySet = def.keySet;
1889
1935
  const _catchall = def.catchall._zod;
1890
1936
  const t = _catchall.def.type;
1937
+ const isOptionalOut = _catchall.optout === "optional";
1891
1938
  for (const key in input) {
1892
1939
  if (keySet.has(key))
1893
1940
  continue;
@@ -1897,9 +1944,9 @@ function handleCatchall(proms, input, payload, ctx, def, inst) {
1897
1944
  }
1898
1945
  const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1899
1946
  if (r instanceof Promise) {
1900
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
1947
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
1901
1948
  } else {
1902
- handlePropertyResult(r, payload, key, input);
1949
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
1903
1950
  }
1904
1951
  }
1905
1952
  if (unrecognized.length) {
@@ -1965,11 +2012,12 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1965
2012
  const shape = value.shape;
1966
2013
  for (const key of value.keys) {
1967
2014
  const el = shape[key];
2015
+ const isOptionalOut = el._zod.optout === "optional";
1968
2016
  const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1969
2017
  if (r instanceof Promise) {
1970
- proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
2018
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input, isOptionalOut)));
1971
2019
  } else {
1972
- handlePropertyResult(r, payload, key, input);
2020
+ handlePropertyResult(r, payload, key, input, isOptionalOut);
1973
2021
  }
1974
2022
  }
1975
2023
  if (!catchall) {
@@ -1999,8 +2047,31 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
1999
2047
  for (const key of normalized.keys) {
2000
2048
  const id = ids[key];
2001
2049
  const k = esc(key);
2050
+ const schema = shape[key];
2051
+ const isOptionalOut = schema?._zod?.optout === "optional";
2002
2052
  doc.write(`const ${id} = ${parseStr(key)};`);
2003
- doc.write(`
2053
+ if (isOptionalOut) {
2054
+ doc.write(`
2055
+ if (${id}.issues.length) {
2056
+ if (${k} in input) {
2057
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2058
+ ...iss,
2059
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
2060
+ })));
2061
+ }
2062
+ }
2063
+
2064
+ if (${id}.value === undefined) {
2065
+ if (${k} in input) {
2066
+ newResult[${k}] = undefined;
2067
+ }
2068
+ } else {
2069
+ newResult[${k}] = ${id}.value;
2070
+ }
2071
+
2072
+ `);
2073
+ } else {
2074
+ doc.write(`
2004
2075
  if (${id}.issues.length) {
2005
2076
  payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
2006
2077
  ...iss,
@@ -2008,7 +2079,6 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
2008
2079
  })));
2009
2080
  }
2010
2081
 
2011
-
2012
2082
  if (${id}.value === undefined) {
2013
2083
  if (${k} in input) {
2014
2084
  newResult[${k}] = undefined;
@@ -2018,6 +2088,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
2018
2088
  }
2019
2089
 
2020
2090
  `);
2091
+ }
2021
2092
  }
2022
2093
  doc.write(`payload.value = newResult;`);
2023
2094
  doc.write(`return payload;`);
@@ -2180,11 +2251,34 @@ function mergeValues(a, b) {
2180
2251
  return { valid: false, mergeErrorPath: [] };
2181
2252
  }
2182
2253
  function handleIntersectionResults(result, left, right) {
2183
- if (left.issues.length) {
2184
- result.issues.push(...left.issues);
2254
+ const unrecKeys = new Map;
2255
+ let unrecIssue;
2256
+ for (const iss of left.issues) {
2257
+ if (iss.code === "unrecognized_keys") {
2258
+ unrecIssue ?? (unrecIssue = iss);
2259
+ for (const k of iss.keys) {
2260
+ if (!unrecKeys.has(k))
2261
+ unrecKeys.set(k, {});
2262
+ unrecKeys.get(k).l = true;
2263
+ }
2264
+ } else {
2265
+ result.issues.push(iss);
2266
+ }
2267
+ }
2268
+ for (const iss of right.issues) {
2269
+ if (iss.code === "unrecognized_keys") {
2270
+ for (const k of iss.keys) {
2271
+ if (!unrecKeys.has(k))
2272
+ unrecKeys.set(k, {});
2273
+ unrecKeys.get(k).r = true;
2274
+ }
2275
+ } else {
2276
+ result.issues.push(iss);
2277
+ }
2185
2278
  }
2186
- if (right.issues.length) {
2187
- result.issues.push(...right.issues);
2279
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
2280
+ if (bothKeys.length && unrecIssue) {
2281
+ result.issues.push({ ...unrecIssue, keys: bothKeys });
2188
2282
  }
2189
2283
  if (aborted(result))
2190
2284
  return result;
@@ -2195,6 +2289,114 @@ function handleIntersectionResults(result, left, right) {
2195
2289
  result.value = merged.data;
2196
2290
  return result;
2197
2291
  }
2292
+ var $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
2293
+ $ZodType.init(inst, def);
2294
+ inst._zod.parse = (payload, ctx) => {
2295
+ const input = payload.value;
2296
+ if (!isPlainObject(input)) {
2297
+ payload.issues.push({
2298
+ expected: "record",
2299
+ code: "invalid_type",
2300
+ input,
2301
+ inst
2302
+ });
2303
+ return payload;
2304
+ }
2305
+ const proms = [];
2306
+ const values = def.keyType._zod.values;
2307
+ if (values) {
2308
+ payload.value = {};
2309
+ const recordKeys = new Set;
2310
+ for (const key of values) {
2311
+ if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
2312
+ recordKeys.add(typeof key === "number" ? key.toString() : key);
2313
+ const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2314
+ if (result instanceof Promise) {
2315
+ proms.push(result.then((result2) => {
2316
+ if (result2.issues.length) {
2317
+ payload.issues.push(...prefixIssues(key, result2.issues));
2318
+ }
2319
+ payload.value[key] = result2.value;
2320
+ }));
2321
+ } else {
2322
+ if (result.issues.length) {
2323
+ payload.issues.push(...prefixIssues(key, result.issues));
2324
+ }
2325
+ payload.value[key] = result.value;
2326
+ }
2327
+ }
2328
+ }
2329
+ let unrecognized;
2330
+ for (const key in input) {
2331
+ if (!recordKeys.has(key)) {
2332
+ unrecognized = unrecognized ?? [];
2333
+ unrecognized.push(key);
2334
+ }
2335
+ }
2336
+ if (unrecognized && unrecognized.length > 0) {
2337
+ payload.issues.push({
2338
+ code: "unrecognized_keys",
2339
+ input,
2340
+ inst,
2341
+ keys: unrecognized
2342
+ });
2343
+ }
2344
+ } else {
2345
+ payload.value = {};
2346
+ for (const key of Reflect.ownKeys(input)) {
2347
+ if (key === "__proto__")
2348
+ continue;
2349
+ let keyResult = def.keyType._zod.run({ value: key, issues: [] }, ctx);
2350
+ if (keyResult instanceof Promise) {
2351
+ throw new Error("Async schemas not supported in object keys currently");
2352
+ }
2353
+ const checkNumericKey = typeof key === "string" && number.test(key) && keyResult.issues.length;
2354
+ if (checkNumericKey) {
2355
+ const retryResult = def.keyType._zod.run({ value: Number(key), issues: [] }, ctx);
2356
+ if (retryResult instanceof Promise) {
2357
+ throw new Error("Async schemas not supported in object keys currently");
2358
+ }
2359
+ if (retryResult.issues.length === 0) {
2360
+ keyResult = retryResult;
2361
+ }
2362
+ }
2363
+ if (keyResult.issues.length) {
2364
+ if (def.mode === "loose") {
2365
+ payload.value[key] = input[key];
2366
+ } else {
2367
+ payload.issues.push({
2368
+ code: "invalid_key",
2369
+ origin: "record",
2370
+ issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
2371
+ input: key,
2372
+ path: [key],
2373
+ inst
2374
+ });
2375
+ }
2376
+ continue;
2377
+ }
2378
+ const result = def.valueType._zod.run({ value: input[key], issues: [] }, ctx);
2379
+ if (result instanceof Promise) {
2380
+ proms.push(result.then((result2) => {
2381
+ if (result2.issues.length) {
2382
+ payload.issues.push(...prefixIssues(key, result2.issues));
2383
+ }
2384
+ payload.value[keyResult.value] = result2.value;
2385
+ }));
2386
+ } else {
2387
+ if (result.issues.length) {
2388
+ payload.issues.push(...prefixIssues(key, result.issues));
2389
+ }
2390
+ payload.value[keyResult.value] = result.value;
2391
+ }
2392
+ }
2393
+ }
2394
+ if (proms.length) {
2395
+ return Promise.all(proms).then(() => payload);
2396
+ }
2397
+ return payload;
2398
+ };
2399
+ });
2198
2400
  var $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
2199
2401
  $ZodType.init(inst, def);
2200
2402
  const values = getEnumValues(def.entries);
@@ -2288,6 +2490,14 @@ var $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
2288
2490
  return def.innerType._zod.run(payload, ctx);
2289
2491
  };
2290
2492
  });
2493
+ var $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
2494
+ $ZodOptional.init(inst, def);
2495
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2496
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
2497
+ inst._zod.parse = (payload, ctx) => {
2498
+ return def.innerType._zod.run(payload, ctx);
2499
+ };
2500
+ });
2291
2501
  var $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
2292
2502
  $ZodType.init(inst, def);
2293
2503
  defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
@@ -2488,7 +2698,7 @@ function handleRefineResult(result, payload, input, inst) {
2488
2698
  payload.issues.push(issue(_iss));
2489
2699
  }
2490
2700
  }
2491
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/core/registries.js
2701
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/registries.js
2492
2702
  var _a;
2493
2703
  var $output = Symbol("ZodOutput");
2494
2704
  var $input = Symbol("ZodInput");
@@ -2502,9 +2712,6 @@ class $ZodRegistry {
2502
2712
  const meta = _meta[0];
2503
2713
  this._map.set(schema, meta);
2504
2714
  if (meta && typeof meta === "object" && "id" in meta) {
2505
- if (this._idmap.has(meta.id)) {
2506
- throw new Error(`ID ${meta.id} already exists in the registry`);
2507
- }
2508
2715
  this._idmap.set(meta.id, schema);
2509
2716
  }
2510
2717
  return this;
@@ -2541,7 +2748,7 @@ function registry() {
2541
2748
  }
2542
2749
  (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2543
2750
  var globalRegistry = globalThis.__zod_globalRegistry;
2544
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/core/api.js
2751
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/api.js
2545
2752
  function _string(Class2, params) {
2546
2753
  return new Class2({
2547
2754
  type: "string",
@@ -2995,7 +3202,7 @@ function _check(fn, params) {
2995
3202
  ch._zod.check = fn;
2996
3203
  return ch;
2997
3204
  }
2998
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/core/to-json-schema.js
3205
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/to-json-schema.js
2999
3206
  function initializeContext(params) {
3000
3207
  let target = params?.target ?? "draft-2020-12";
3001
3208
  if (target === "draft-4")
@@ -3039,12 +3246,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
3039
3246
  schemaPath: [..._params.schemaPath, schema],
3040
3247
  path: _params.path
3041
3248
  };
3042
- const parent = schema._zod.parent;
3043
- if (parent) {
3044
- result.ref = parent;
3045
- process2(parent, ctx, params);
3046
- ctx.seen.get(parent).isParent = true;
3047
- } else if (schema._zod.processJSONSchema) {
3249
+ if (schema._zod.processJSONSchema) {
3048
3250
  schema._zod.processJSONSchema(ctx, result.schema, params);
3049
3251
  } else {
3050
3252
  const _json = result.schema;
@@ -3054,6 +3256,13 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
3054
3256
  }
3055
3257
  processor(schema, ctx, _json, params);
3056
3258
  }
3259
+ const parent = schema._zod.parent;
3260
+ if (parent) {
3261
+ if (!result.ref)
3262
+ result.ref = parent;
3263
+ process2(parent, ctx, params);
3264
+ ctx.seen.get(parent).isParent = true;
3265
+ }
3057
3266
  }
3058
3267
  const meta = ctx.metadataRegistry.get(schema);
3059
3268
  if (meta)
@@ -3072,6 +3281,17 @@ function extractDefs(ctx, schema) {
3072
3281
  const root = ctx.seen.get(schema);
3073
3282
  if (!root)
3074
3283
  throw new Error("Unprocessed schema. This is a bug in Zod.");
3284
+ const idToSchema = new Map;
3285
+ for (const entry of ctx.seen.entries()) {
3286
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
3287
+ if (id) {
3288
+ const existing = idToSchema.get(id);
3289
+ if (existing && existing !== entry[0]) {
3290
+ throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
3291
+ }
3292
+ idToSchema.set(id, entry[0]);
3293
+ }
3294
+ }
3075
3295
  const makeURI = (entry) => {
3076
3296
  const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
3077
3297
  if (ctx.external) {
@@ -3151,30 +3371,65 @@ function finalize(ctx, schema) {
3151
3371
  throw new Error("Unprocessed schema. This is a bug in Zod.");
3152
3372
  const flattenRef = (zodSchema) => {
3153
3373
  const seen = ctx.seen.get(zodSchema);
3374
+ if (seen.ref === null)
3375
+ return;
3154
3376
  const schema2 = seen.def ?? seen.schema;
3155
3377
  const _cached = { ...schema2 };
3156
- if (seen.ref === null) {
3157
- return;
3158
- }
3159
3378
  const ref = seen.ref;
3160
3379
  seen.ref = null;
3161
3380
  if (ref) {
3162
3381
  flattenRef(ref);
3163
- const refSchema = ctx.seen.get(ref).schema;
3382
+ const refSeen = ctx.seen.get(ref);
3383
+ const refSchema = refSeen.schema;
3164
3384
  if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
3165
3385
  schema2.allOf = schema2.allOf ?? [];
3166
3386
  schema2.allOf.push(refSchema);
3167
3387
  } else {
3168
3388
  Object.assign(schema2, refSchema);
3169
- Object.assign(schema2, _cached);
3389
+ }
3390
+ Object.assign(schema2, _cached);
3391
+ const isParentRef = zodSchema._zod.parent === ref;
3392
+ if (isParentRef) {
3393
+ for (const key in schema2) {
3394
+ if (key === "$ref" || key === "allOf")
3395
+ continue;
3396
+ if (!(key in _cached)) {
3397
+ delete schema2[key];
3398
+ }
3399
+ }
3400
+ }
3401
+ if (refSchema.$ref && refSeen.def) {
3402
+ for (const key in schema2) {
3403
+ if (key === "$ref" || key === "allOf")
3404
+ continue;
3405
+ if (key in refSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(refSeen.def[key])) {
3406
+ delete schema2[key];
3407
+ }
3408
+ }
3170
3409
  }
3171
3410
  }
3172
- if (!seen.isParent)
3173
- ctx.override({
3174
- zodSchema,
3175
- jsonSchema: schema2,
3176
- path: seen.path ?? []
3177
- });
3411
+ const parent = zodSchema._zod.parent;
3412
+ if (parent && parent !== ref) {
3413
+ flattenRef(parent);
3414
+ const parentSeen = ctx.seen.get(parent);
3415
+ if (parentSeen?.schema.$ref) {
3416
+ schema2.$ref = parentSeen.schema.$ref;
3417
+ if (parentSeen.def) {
3418
+ for (const key in schema2) {
3419
+ if (key === "$ref" || key === "allOf")
3420
+ continue;
3421
+ if (key in parentSeen.def && JSON.stringify(schema2[key]) === JSON.stringify(parentSeen.def[key])) {
3422
+ delete schema2[key];
3423
+ }
3424
+ }
3425
+ }
3426
+ }
3427
+ }
3428
+ ctx.override({
3429
+ zodSchema,
3430
+ jsonSchema: schema2,
3431
+ path: seen.path ?? []
3432
+ });
3178
3433
  };
3179
3434
  for (const entry of [...ctx.seen.entries()].reverse()) {
3180
3435
  flattenRef(entry[0]);
@@ -3216,8 +3471,8 @@ function finalize(ctx, schema) {
3216
3471
  value: {
3217
3472
  ...schema["~standard"],
3218
3473
  jsonSchema: {
3219
- input: createStandardJSONSchemaMethod(schema, "input"),
3220
- output: createStandardJSONSchemaMethod(schema, "output")
3474
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
3475
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
3221
3476
  }
3222
3477
  },
3223
3478
  enumerable: false,
@@ -3285,14 +3540,14 @@ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
3285
3540
  extractDefs(ctx, schema);
3286
3541
  return finalize(ctx, schema);
3287
3542
  };
3288
- var createStandardJSONSchemaMethod = (schema, io) => (params) => {
3543
+ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
3289
3544
  const { libraryOptions, target } = params ?? {};
3290
- const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors: {} });
3545
+ const ctx = initializeContext({ ...libraryOptions ?? {}, target, io, processors });
3291
3546
  process2(schema, ctx);
3292
3547
  extractDefs(ctx, schema);
3293
3548
  return finalize(ctx, schema);
3294
3549
  };
3295
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/core/json-schema-processors.js
3550
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/core/json-schema-processors.js
3296
3551
  var formatMap = {
3297
3552
  guid: "uuid",
3298
3553
  url: "uri",
@@ -3312,6 +3567,9 @@ var stringProcessor = (schema, ctx, _json, _params) => {
3312
3567
  json.format = formatMap[format] ?? format;
3313
3568
  if (json.format === "")
3314
3569
  delete json.format;
3570
+ if (format === "time") {
3571
+ delete json.format;
3572
+ }
3315
3573
  }
3316
3574
  if (contentEncoding)
3317
3575
  json.contentEncoding = contentEncoding;
@@ -3515,6 +3773,42 @@ var intersectionProcessor = (schema, ctx, json, params) => {
3515
3773
  ];
3516
3774
  json.allOf = allOf;
3517
3775
  };
3776
+ var recordProcessor = (schema, ctx, _json, params) => {
3777
+ const json = _json;
3778
+ const def = schema._zod.def;
3779
+ json.type = "object";
3780
+ const keyType = def.keyType;
3781
+ const keyBag = keyType._zod.bag;
3782
+ const patterns = keyBag?.patterns;
3783
+ if (def.mode === "loose" && patterns && patterns.size > 0) {
3784
+ const valueSchema = process2(def.valueType, ctx, {
3785
+ ...params,
3786
+ path: [...params.path, "patternProperties", "*"]
3787
+ });
3788
+ json.patternProperties = {};
3789
+ for (const pattern of patterns) {
3790
+ json.patternProperties[pattern.source] = valueSchema;
3791
+ }
3792
+ } else {
3793
+ if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
3794
+ json.propertyNames = process2(def.keyType, ctx, {
3795
+ ...params,
3796
+ path: [...params.path, "propertyNames"]
3797
+ });
3798
+ }
3799
+ json.additionalProperties = process2(def.valueType, ctx, {
3800
+ ...params,
3801
+ path: [...params.path, "additionalProperties"]
3802
+ });
3803
+ }
3804
+ const keyValues = keyType._zod.values;
3805
+ if (keyValues) {
3806
+ const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
3807
+ if (validKeyValues.length > 0) {
3808
+ json.required = validKeyValues;
3809
+ }
3810
+ }
3811
+ };
3518
3812
  var nullableProcessor = (schema, ctx, json, params) => {
3519
3813
  const def = schema._zod.def;
3520
3814
  const inner = process2(def.innerType, ctx, params);
@@ -3580,7 +3874,7 @@ var optionalProcessor = (schema, ctx, _json, params) => {
3580
3874
  const seen = ctx.seen.get(schema);
3581
3875
  seen.ref = def.innerType;
3582
3876
  };
3583
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/classic/iso.js
3877
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/iso.js
3584
3878
  var ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
3585
3879
  $ZodISODateTime.init(inst, def);
3586
3880
  ZodStringFormat.init(inst, def);
@@ -3610,7 +3904,7 @@ function duration2(params) {
3610
3904
  return _isoDuration(ZodISODuration, params);
3611
3905
  }
3612
3906
 
3613
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/classic/errors.js
3907
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/errors.js
3614
3908
  var initializer2 = (inst, issues) => {
3615
3909
  $ZodError.init(inst, issues);
3616
3910
  inst.name = "ZodError";
@@ -3645,7 +3939,7 @@ var ZodRealError = $constructor("ZodError", initializer2, {
3645
3939
  Parent: Error
3646
3940
  });
3647
3941
 
3648
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/classic/parse.js
3942
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/parse.js
3649
3943
  var parse3 = /* @__PURE__ */ _parse(ZodRealError);
3650
3944
  var parseAsync2 = /* @__PURE__ */ _parseAsync(ZodRealError);
3651
3945
  var safeParse2 = /* @__PURE__ */ _safeParse(ZodRealError);
@@ -3659,7 +3953,7 @@ var safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3659
3953
  var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3660
3954
  var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3661
3955
 
3662
- // ../../node_modules/.bun/zod@4.2.0/node_modules/zod/v4/classic/schemas.js
3956
+ // ../../node_modules/.bun/zod@4.3.6/node_modules/zod/v4/classic/schemas.js
3663
3957
  var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3664
3958
  $ZodType.init(inst, def);
3665
3959
  Object.assign(inst["~standard"], {
@@ -3678,8 +3972,11 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3678
3972
  ...def.checks ?? [],
3679
3973
  ...checks2.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
3680
3974
  ]
3681
- }));
3975
+ }), {
3976
+ parent: true
3977
+ });
3682
3978
  };
3979
+ inst.with = inst.check;
3683
3980
  inst.clone = (def2, params) => clone(inst, def2, params);
3684
3981
  inst.brand = () => inst;
3685
3982
  inst.register = (reg, meta2) => {
@@ -3703,6 +4000,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3703
4000
  inst.superRefine = (refinement) => inst.check(superRefine(refinement));
3704
4001
  inst.overwrite = (fn) => inst.check(_overwrite(fn));
3705
4002
  inst.optional = () => optional(inst);
4003
+ inst.exactOptional = () => exactOptional(inst);
3706
4004
  inst.nullable = () => nullable(inst);
3707
4005
  inst.nullish = () => optional(nullable(inst));
3708
4006
  inst.nonoptional = (params) => nonoptional(inst, params);
@@ -3736,6 +4034,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
3736
4034
  };
3737
4035
  inst.isOptional = () => inst.safeParse(undefined).success;
3738
4036
  inst.isNullable = () => inst.safeParse(null).success;
4037
+ inst.apply = (fn) => fn(inst);
3739
4038
  return inst;
3740
4039
  });
3741
4040
  var _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
@@ -4016,6 +4315,21 @@ function intersection(left, right) {
4016
4315
  right
4017
4316
  });
4018
4317
  }
4318
+ var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
4319
+ $ZodRecord.init(inst, def);
4320
+ ZodType.init(inst, def);
4321
+ inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
4322
+ inst.keyType = def.keyType;
4323
+ inst.valueType = def.valueType;
4324
+ });
4325
+ function record(keyType, valueType, params) {
4326
+ return new ZodRecord({
4327
+ type: "record",
4328
+ keyType,
4329
+ valueType,
4330
+ ...exports_util.normalizeParams(params)
4331
+ });
4332
+ }
4019
4333
  var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
4020
4334
  $ZodEnum.init(inst, def);
4021
4335
  ZodType.init(inst, def);
@@ -4133,6 +4447,18 @@ function optional(innerType) {
4133
4447
  innerType
4134
4448
  });
4135
4449
  }
4450
+ var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
4451
+ $ZodExactOptional.init(inst, def);
4452
+ ZodType.init(inst, def);
4453
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4454
+ inst.unwrap = () => inst._zod.def.innerType;
4455
+ });
4456
+ function exactOptional(innerType) {
4457
+ return new ZodExactOptional({
4458
+ type: "optional",
4459
+ innerType
4460
+ });
4461
+ }
4136
4462
  var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
4137
4463
  $ZodNullable.init(inst, def);
4138
4464
  ZodType.init(inst, def);
@@ -4243,24 +4569,36 @@ function superRefine(fn) {
4243
4569
 
4244
4570
  // ../mcp/src/contents/contents.schemas.ts
4245
4571
  var ContentsQuerySchema = object({
4246
- urls: array(string2().url()).min(1).describe("URLs to extract content from"),
4247
- format: _enum(["markdown", "html"]).optional().default("markdown").describe("Output format: markdown (text) or html (layout)")
4572
+ urls: array(string2().url()).min(1).describe('Array of webpage URLs to extract content from (e.g., ["https://example.com"])'),
4573
+ formats: array(_enum(["markdown", "html", "metadata"])).optional().describe('Output formats: array of "markdown" (text), "html" (layout), or "metadata" (structured data)'),
4574
+ format: _enum(["markdown", "html"]).optional().describe("(Deprecated) Output format - use formats array instead"),
4575
+ crawl_timeout: number2().min(1).max(60).optional().describe("Optional timeout in seconds (1-60) for page crawling")
4248
4576
  });
4249
4577
  var ContentsItemSchema = object({
4250
4578
  url: string2().describe("URL"),
4251
4579
  title: string2().optional().describe("Title"),
4252
4580
  html: string2().optional().describe("HTML content"),
4253
- markdown: string2().optional().describe("Markdown content")
4581
+ markdown: string2().optional().describe("Markdown content"),
4582
+ metadata: object({
4583
+ jsonld: array(record(string2(), unknown())).optional().describe("JSON-LD structured data (Schema.org)"),
4584
+ opengraph: record(string2(), string2()).optional().describe("OpenGraph meta tags"),
4585
+ twitter: record(string2(), string2()).optional().describe("Twitter Card metadata")
4586
+ }).optional().describe("Structured metadata when available")
4254
4587
  });
4255
4588
  var ContentsApiResponseSchema = array(ContentsItemSchema);
4256
4589
  var ContentsStructuredContentSchema = object({
4257
4590
  count: number2().describe("URLs processed"),
4258
- format: string2().describe("Content format"),
4591
+ formats: array(string2()).describe("Content formats requested"),
4259
4592
  items: array(object({
4260
4593
  url: string2().describe("URL"),
4261
4594
  title: string2().optional().describe("Title"),
4262
- content: string2().describe("Extracted content"),
4263
- contentLength: number2().describe("Content length")
4595
+ markdown: string2().optional().describe("Markdown content"),
4596
+ html: string2().optional().describe("HTML content"),
4597
+ metadata: object({
4598
+ jsonld: array(record(string2(), unknown())).optional(),
4599
+ opengraph: record(string2(), string2()).optional(),
4600
+ twitter: record(string2(), string2()).optional()
4601
+ }).optional().describe("Structured metadata")
4264
4602
  })).describe("Extracted items")
4265
4603
  });
4266
4604
  // ../mcp/src/shared/api-constants.ts
@@ -4279,13 +4617,21 @@ var checkResponseForErrors = (responseData) => {
4279
4617
 
4280
4618
  // ../mcp/src/contents/contents.utils.ts
4281
4619
  var fetchContents = async ({
4282
- contentsQuery: { urls, format = "markdown" },
4620
+ contentsQuery: { urls, formats, format, crawl_timeout },
4283
4621
  YDC_API_KEY = process.env.YDC_API_KEY,
4284
4622
  getUserAgent
4285
4623
  }) => {
4286
4624
  if (!YDC_API_KEY) {
4287
4625
  throw new Error("YDC_API_KEY is required for Contents API");
4288
4626
  }
4627
+ const requestFormats = formats || (format ? [format] : ["markdown"]);
4628
+ const requestBody = {
4629
+ urls,
4630
+ formats: requestFormats
4631
+ };
4632
+ if (crawl_timeout !== undefined) {
4633
+ requestBody.crawl_timeout = crawl_timeout;
4634
+ }
4289
4635
  const options = {
4290
4636
  method: "POST",
4291
4637
  headers: new Headers({
@@ -4293,10 +4639,7 @@ var fetchContents = async ({
4293
4639
  "Content-Type": "application/json",
4294
4640
  "User-Agent": getUserAgent()
4295
4641
  }),
4296
- body: JSON.stringify({
4297
- urls,
4298
- format
4299
- })
4642
+ body: JSON.stringify(requestBody)
4300
4643
  };
4301
4644
  const response = await fetch(CONTENTS_API_URL, options);
4302
4645
  if (!response.ok) {
@@ -4548,11 +4891,13 @@ var SearchStructuredContentSchema = object({
4548
4891
  results: object({
4549
4892
  web: array(object({
4550
4893
  url: string2().describe("URL"),
4551
- title: string2().describe("Title")
4894
+ title: string2().describe("Title"),
4895
+ page_age: string2().optional().describe("Publication timestamp")
4552
4896
  })).optional().describe("Web results"),
4553
4897
  news: array(object({
4554
4898
  url: string2().describe("URL"),
4555
- title: string2().describe("Title")
4899
+ title: string2().describe("Title"),
4900
+ page_age: string2().describe("Publication timestamp")
4556
4901
  })).optional().describe("News results")
4557
4902
  }).optional().describe("Search results")
4558
4903
  });
@@ -4606,7 +4951,7 @@ import { tool } from "ai";
4606
4951
  // package.json
4607
4952
  var package_default = {
4608
4953
  name: "@youdotcom-oss/ai-sdk-plugin",
4609
- version: "1.0.0",
4954
+ version: "1.0.1",
4610
4955
  description: "Vercel AI SDK plugin for You.com web search, AI agents, and content extraction via MCP",
4611
4956
  license: "MIT",
4612
4957
  engines: {
@@ -4641,13 +4986,10 @@ var package_default = {
4641
4986
  ".": {
4642
4987
  types: "./dist/main.d.ts",
4643
4988
  default: "./dist/main.js"
4644
- },
4645
- "./templates/generate-text": "./templates/generate-text.ts",
4646
- "./templates/streaming-text": "./templates/streaming-text.ts"
4989
+ }
4647
4990
  },
4648
4991
  files: [
4649
- "dist",
4650
- "templates"
4992
+ "dist"
4651
4993
  ],
4652
4994
  publishConfig: {
4653
4995
  access: "public"
@@ -4675,13 +5017,14 @@ var package_default = {
4675
5017
  },
4676
5018
  types: "./dist/main.d.ts",
4677
5019
  dependencies: {
4678
- "@youdotcom-oss/mcp": "1.3.10"
5020
+ "@youdotcom-oss/mcp": "1.5.1"
4679
5021
  },
4680
5022
  peerDependencies: {
4681
- ai: "^5.0.0"
5023
+ ai: "^6.0.0"
4682
5024
  },
4683
5025
  devDependencies: {
4684
- "@ai-sdk/anthropic": "^2.0.56"
5026
+ "@ai-sdk/anthropic": "^3.0.14",
5027
+ ai: "^6.0.37"
4685
5028
  }
4686
5029
  };
4687
5030
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youdotcom-oss/ai-sdk-plugin",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Vercel AI SDK plugin for You.com web search, AI agents, and content extraction via MCP",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -35,13 +35,10 @@
35
35
  ".": {
36
36
  "types": "./dist/main.d.ts",
37
37
  "default": "./dist/main.js"
38
- },
39
- "./templates/generate-text": "./templates/generate-text.ts",
40
- "./templates/streaming-text": "./templates/streaming-text.ts"
38
+ }
41
39
  },
42
40
  "files": [
43
- "dist",
44
- "templates"
41
+ "dist"
45
42
  ],
46
43
  "publishConfig": {
47
44
  "access": "public"
@@ -69,12 +66,13 @@
69
66
  },
70
67
  "types": "./dist/main.d.ts",
71
68
  "dependencies": {
72
- "@youdotcom-oss/mcp": "1.3.10"
69
+ "@youdotcom-oss/mcp": "1.5.1"
73
70
  },
74
71
  "peerDependencies": {
75
- "ai": "^5.0.0"
72
+ "ai": "^6.0.0"
76
73
  },
77
74
  "devDependencies": {
78
- "@ai-sdk/anthropic": "^2.0.56"
75
+ "@ai-sdk/anthropic": "^3.0.14",
76
+ "ai": "^6.0.37"
79
77
  }
80
78
  }
@@ -1,78 +0,0 @@
1
- /**
2
- * AI SDK Integration Template - generateText()
3
- *
4
- * Shows how to integrate You.com tools with Vercel AI SDK's generateText().
5
- *
6
- * Key Integration Points:
7
- * 1. Import tools: youSearch(), youExpress(), youContents()
8
- * 2. Add to tools object
9
- * 3. API key: Use env variable or pass directly to each tool
10
- * 4. Model handles everything - you just get result.text
11
- */
12
-
13
- import { createAnthropic } from '@ai-sdk/anthropic';
14
- import { youContents, youExpress, youSearch } from '@youdotcom-oss/ai-sdk-plugin';
15
- import { generateText } from 'ai';
16
-
17
- // ============================================================================
18
- // INTEGRATION STEP 1: Environment Variables
19
- // ============================================================================
20
- // Option A: Use environment variables (recommended)
21
- // Set YDC_API_KEY in your .env file - tools read it automatically
22
-
23
- if (!process.env.YDC_API_KEY) {
24
- throw new Error('YDC_API_KEY environment variable is required');
25
- }
26
-
27
- // Your AI provider key (Anthropic, OpenAI, etc.)
28
- if (!process.env.ANTHROPIC_API_KEY) {
29
- throw new Error('ANTHROPIC_API_KEY environment variable is required');
30
- }
31
-
32
- // ============================================================================
33
- // INTEGRATION STEP 2: Add Tools to generateText
34
- // ============================================================================
35
-
36
- const anthropic = createAnthropic();
37
-
38
- // Single tool example
39
- const result = await generateText({
40
- model: anthropic('claude-sonnet-4-5-20250929'),
41
- tools: {
42
- search: youSearch(), // Reads YDC_API_KEY from environment
43
- },
44
- prompt: 'Your dynamic prompt here', // Replace with your actual prompt
45
- });
46
-
47
- console.log(result.text); // Model-formatted response with search results
48
-
49
- // ============================================================================
50
- // Multiple Tools (model chooses which to use)
51
- // ============================================================================
52
-
53
- const multiToolResult = await generateText({
54
- model: anthropic('claude-sonnet-4-5-20250929'),
55
- tools: {
56
- search: youSearch(),
57
- agent: youExpress(),
58
- extract: youContents(),
59
- },
60
- prompt: 'Your prompt here',
61
- });
62
-
63
- console.log(multiToolResult.text);
64
-
65
- // ============================================================================
66
- // INTEGRATION OPTION B: Pass API Key Directly
67
- // ============================================================================
68
- // Override environment variable per tool if needed
69
-
70
- const customKeyResult = await generateText({
71
- model: anthropic('claude-sonnet-4-5-20250929'),
72
- tools: {
73
- search: youSearch({ apiKey: 'your-key-here' }),
74
- },
75
- prompt: 'Your prompt here',
76
- });
77
-
78
- console.log(customKeyResult.text);
@@ -1,123 +0,0 @@
1
- /**
2
- * AI SDK Integration Template - streamText()
3
- *
4
- * Shows how to integrate You.com tools with Vercel AI SDK's streamText().
5
- *
6
- * Key Integration Points:
7
- * 1. Import tools: youSearch(), youExpress(), youContents()
8
- * 2. Add to tools object
9
- * 3. IMPORTANT: Use stopWhen with stepCountIs(2 + number_of_tools) minimum
10
- * 4. Consume textStream for real-time UI updates
11
- * 5. Model handles formatting - you just render the stream
12
- */
13
-
14
- import { createAnthropic } from '@ai-sdk/anthropic';
15
- import { youContents, youExpress, youSearch } from '@youdotcom-oss/ai-sdk-plugin';
16
- import { stepCountIs, streamText } from 'ai';
17
-
18
- // ============================================================================
19
- // INTEGRATION STEP 1: Environment Variables
20
- // ============================================================================
21
-
22
- if (!process.env.YDC_API_KEY) {
23
- throw new Error('YDC_API_KEY environment variable is required');
24
- }
25
-
26
- if (!process.env.ANTHROPIC_API_KEY) {
27
- throw new Error('ANTHROPIC_API_KEY environment variable is required');
28
- }
29
-
30
- // ============================================================================
31
- // INTEGRATION STEP 2: Add Tools + Configure stopWhen
32
- // ============================================================================
33
- // Use stopWhen: stepCountIs(3) - works for any number of tools with Anthropic
34
-
35
- const anthropic = createAnthropic();
36
-
37
- const result = streamText({
38
- model: anthropic('claude-sonnet-4-5-20250929'),
39
- tools: {
40
- search: youSearch(),
41
- },
42
- stopWhen: stepCountIs(3), // 3 steps works regardless of tool count (Anthropic)
43
- prompt: 'Your dynamic prompt here', // Replace with actual prompt
44
- });
45
-
46
- // ============================================================================
47
- // INTEGRATION STEP 3: Consume the Stream
48
- // ============================================================================
49
- // Stream text to your UI in real-time
50
-
51
- for await (const chunk of result.textStream) {
52
- process.stdout.write(chunk); // Or update your UI component
53
- }
54
-
55
- // ============================================================================
56
- // Multiple Tools Example
57
- // ============================================================================
58
- // stepCountIs(3) works with any number of tools when using Anthropic
59
-
60
- const multiToolStream = streamText({
61
- model: anthropic('claude-sonnet-4-5-20250929'),
62
- tools: {
63
- search: youSearch(),
64
- agent: youExpress(),
65
- extract: youContents(),
66
- },
67
- stopWhen: stepCountIs(3), // 3 steps works for 1, 2, or 3+ tools (Anthropic)
68
- prompt: 'Your prompt here',
69
- });
70
-
71
- for await (const chunk of multiToolStream.textStream) {
72
- process.stdout.write(chunk);
73
- }
74
-
75
- // ============================================================================
76
- // Web Framework Integration Examples
77
- // ============================================================================
78
-
79
- // Next.js App Router (Route Handler)
80
- // export async function POST(req: Request) {
81
- // const { messages } = await req.json();
82
- //
83
- // const result = streamText({
84
- // model: anthropic('claude-sonnet-4-5-20250929'),
85
- // tools: { search: youSearch() },
86
- // stopWhen: stepCountIs(3),
87
- // messages,
88
- // });
89
- //
90
- // return result.toDataStreamResponse();
91
- // }
92
-
93
- // Express.js
94
- // app.post('/api/chat', async (req, res) => {
95
- // const { prompt } = req.body;
96
- //
97
- // const result = streamText({
98
- // model: anthropic('claude-sonnet-4-5-20250929'),
99
- // tools: { search: youSearch() },
100
- // stopWhen: stepCountIs(3),
101
- // prompt,
102
- // });
103
- //
104
- // result.pipeDataStreamToResponse(res);
105
- // });
106
-
107
- // React Component (using useChat hook)
108
- // import { useChat } from 'ai/react';
109
- //
110
- // function ChatComponent() {
111
- // const { messages, input, handleInputChange, handleSubmit } = useChat({
112
- // api: '/api/chat', // Your endpoint with You.com tools
113
- // });
114
- //
115
- // return (
116
- // <div>
117
- // {messages.map(m => <div key={m.id}>{m.content}</div>)}
118
- // <form onSubmit={handleSubmit}>
119
- // <input value={input} onChange={handleInputChange} />
120
- // </form>
121
- // </div>
122
- // );
123
- // }