@puckeditor/cloud-client 0.8.0-canary.fed2989a → 0.8.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.
package/dist/index.js CHANGED
@@ -9,8 +9,8 @@ var __esm = (fn, res) => function __init() {
9
9
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
10
  };
11
11
  var __export = (target, all) => {
12
- for (var name21 in all)
13
- __defProp(target, name21, { get: all[name21], enumerable: true });
12
+ for (var name23 in all)
13
+ __defProp(target, name23, { get: all[name23], enumerable: true });
14
14
  };
15
15
  var __copyProps = (to, from, except, desc) => {
16
16
  if (from && typeof from === "object" || typeof from === "function") {
@@ -58,13 +58,13 @@ var tool = (t) => t;
58
58
  // src/api/chat.ts
59
59
  init_react_import();
60
60
 
61
- // ../../node_modules/.pnpm/ai@6.0.197_zod@4.3.6/node_modules/ai/dist/index.mjs
61
+ // ../../node_modules/.pnpm/ai@6.0.230_zod@4.3.6/node_modules/ai/dist/index.mjs
62
62
  init_react_import();
63
63
 
64
- // ../../node_modules/.pnpm/@ai-sdk+provider-utils@4.0.27_zod@4.3.6/node_modules/@ai-sdk/provider-utils/dist/index.mjs
64
+ // ../../node_modules/.pnpm/@ai-sdk+provider-utils@4.0.40_zod@4.3.6/node_modules/@ai-sdk/provider-utils/dist/index.mjs
65
65
  init_react_import();
66
66
 
67
- // ../../node_modules/.pnpm/@ai-sdk+provider@3.0.10/node_modules/@ai-sdk/provider/dist/index.mjs
67
+ // ../../node_modules/.pnpm/@ai-sdk+provider@3.0.14/node_modules/@ai-sdk/provider/dist/index.mjs
68
68
  init_react_import();
69
69
  var marker = "vercel.ai.error";
70
70
  var symbol = Symbol.for(marker);
@@ -944,7 +944,7 @@ var NEVER = Object.freeze({
944
944
  status: "aborted"
945
945
  });
946
946
  // @__NO_SIDE_EFFECTS__
947
- function $constructor(name21, initializer3, params) {
947
+ function $constructor(name23, initializer3, params) {
948
948
  function init(inst, def) {
949
949
  if (!inst._zod) {
950
950
  Object.defineProperty(inst, "_zod", {
@@ -956,10 +956,10 @@ function $constructor(name21, initializer3, params) {
956
956
  enumerable: false
957
957
  });
958
958
  }
959
- if (inst._zod.traits.has(name21)) {
959
+ if (inst._zod.traits.has(name23)) {
960
960
  return;
961
961
  }
962
- inst._zod.traits.add(name21);
962
+ inst._zod.traits.add(name23);
963
963
  initializer3(inst, def);
964
964
  const proto = _.prototype;
965
965
  const keys = Object.keys(proto);
@@ -973,12 +973,12 @@ function $constructor(name21, initializer3, params) {
973
973
  const Parent = params?.Parent ?? Object;
974
974
  class Definition extends Parent {
975
975
  }
976
- Object.defineProperty(Definition, "name", { value: name21 });
976
+ Object.defineProperty(Definition, "name", { value: name23 });
977
977
  function _(def) {
978
- var _a21;
978
+ var _a23;
979
979
  const inst = params?.Parent ? new Definition() : this;
980
980
  init(inst, def);
981
- (_a21 = inst._zod).deferred ?? (_a21.deferred = []);
981
+ (_a23 = inst._zod).deferred ?? (_a23.deferred = []);
982
982
  for (const fn of inst._zod.deferred) {
983
983
  fn();
984
984
  }
@@ -989,10 +989,10 @@ function $constructor(name21, initializer3, params) {
989
989
  value: (inst) => {
990
990
  if (params?.Parent && inst instanceof params.Parent)
991
991
  return true;
992
- return inst?._zod?.traits?.has(name21);
992
+ return inst?._zod?.traits?.has(name23);
993
993
  }
994
994
  });
995
- Object.defineProperty(_, "name", { value: name21 });
995
+ Object.defineProperty(_, "name", { value: name23 });
996
996
  return _;
997
997
  }
998
998
  var $brand = Symbol("zod_brand");
@@ -1002,8 +1002,8 @@ var $ZodAsyncError = class extends Error {
1002
1002
  }
1003
1003
  };
1004
1004
  var $ZodEncodeError = class extends Error {
1005
- constructor(name21) {
1006
- super(`Encountered unidirectional transform during encode: ${name21}`);
1005
+ constructor(name23) {
1006
+ super(`Encountered unidirectional transform during encode: ${name23}`);
1007
1007
  this.name = "ZodEncodeError";
1008
1008
  }
1009
1009
  };
@@ -1582,8 +1582,8 @@ function aborted(x, startIndex = 0) {
1582
1582
  }
1583
1583
  function prefixIssues(path, issues) {
1584
1584
  return issues.map((iss) => {
1585
- var _a21;
1586
- (_a21 = iss).path ?? (_a21.path = []);
1585
+ var _a23;
1586
+ (_a23 = iss).path ?? (_a23.path = []);
1587
1587
  iss.path.unshift(path);
1588
1588
  return iss;
1589
1589
  });
@@ -1768,7 +1768,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
1768
1768
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
1769
1769
  const result = { errors: [] };
1770
1770
  const processError = (error49, path = []) => {
1771
- var _a21, _b16;
1771
+ var _a23, _b16;
1772
1772
  for (const issue2 of error49.issues) {
1773
1773
  if (issue2.code === "invalid_union" && issue2.errors.length) {
1774
1774
  issue2.errors.map((issues) => processError({ issues }, issue2.path));
@@ -1789,7 +1789,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
1789
1789
  const terminal = i === fullpath.length - 1;
1790
1790
  if (typeof el === "string") {
1791
1791
  curr.properties ?? (curr.properties = {});
1792
- (_a21 = curr.properties)[el] ?? (_a21[el] = { errors: [] });
1792
+ (_a23 = curr.properties)[el] ?? (_a23[el] = { errors: [] });
1793
1793
  curr = curr.properties[el];
1794
1794
  } else {
1795
1795
  curr.items ?? (curr.items = []);
@@ -2090,10 +2090,10 @@ var sha512_base64url = /* @__PURE__ */ fixedBase64url(86);
2090
2090
 
2091
2091
  // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/checks.js
2092
2092
  var $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
2093
- var _a21;
2093
+ var _a23;
2094
2094
  inst._zod ?? (inst._zod = {});
2095
2095
  inst._zod.def = def;
2096
- (_a21 = inst._zod).onattach ?? (_a21.onattach = []);
2096
+ (_a23 = inst._zod).onattach ?? (_a23.onattach = []);
2097
2097
  });
2098
2098
  var numericOriginMap = {
2099
2099
  number: "number",
@@ -2159,8 +2159,8 @@ var $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan",
2159
2159
  var $ZodCheckMultipleOf = /* @__PURE__ */ $constructor("$ZodCheckMultipleOf", (inst, def) => {
2160
2160
  $ZodCheck.init(inst, def);
2161
2161
  inst._zod.onattach.push((inst2) => {
2162
- var _a21;
2163
- (_a21 = inst2._zod.bag).multipleOf ?? (_a21.multipleOf = def.value);
2162
+ var _a23;
2163
+ (_a23 = inst2._zod.bag).multipleOf ?? (_a23.multipleOf = def.value);
2164
2164
  });
2165
2165
  inst._zod.check = (payload) => {
2166
2166
  if (typeof payload.value !== typeof def.value)
@@ -2293,9 +2293,9 @@ var $ZodCheckBigIntFormat = /* @__PURE__ */ $constructor("$ZodCheckBigIntFormat"
2293
2293
  };
2294
2294
  });
2295
2295
  var $ZodCheckMaxSize = /* @__PURE__ */ $constructor("$ZodCheckMaxSize", (inst, def) => {
2296
- var _a21;
2296
+ var _a23;
2297
2297
  $ZodCheck.init(inst, def);
2298
- (_a21 = inst._zod.def).when ?? (_a21.when = (payload) => {
2298
+ (_a23 = inst._zod.def).when ?? (_a23.when = (payload) => {
2299
2299
  const val = payload.value;
2300
2300
  return !nullish(val) && val.size !== void 0;
2301
2301
  });
@@ -2321,9 +2321,9 @@ var $ZodCheckMaxSize = /* @__PURE__ */ $constructor("$ZodCheckMaxSize", (inst, d
2321
2321
  };
2322
2322
  });
2323
2323
  var $ZodCheckMinSize = /* @__PURE__ */ $constructor("$ZodCheckMinSize", (inst, def) => {
2324
- var _a21;
2324
+ var _a23;
2325
2325
  $ZodCheck.init(inst, def);
2326
- (_a21 = inst._zod.def).when ?? (_a21.when = (payload) => {
2326
+ (_a23 = inst._zod.def).when ?? (_a23.when = (payload) => {
2327
2327
  const val = payload.value;
2328
2328
  return !nullish(val) && val.size !== void 0;
2329
2329
  });
@@ -2349,9 +2349,9 @@ var $ZodCheckMinSize = /* @__PURE__ */ $constructor("$ZodCheckMinSize", (inst, d
2349
2349
  };
2350
2350
  });
2351
2351
  var $ZodCheckSizeEquals = /* @__PURE__ */ $constructor("$ZodCheckSizeEquals", (inst, def) => {
2352
- var _a21;
2352
+ var _a23;
2353
2353
  $ZodCheck.init(inst, def);
2354
- (_a21 = inst._zod.def).when ?? (_a21.when = (payload) => {
2354
+ (_a23 = inst._zod.def).when ?? (_a23.when = (payload) => {
2355
2355
  const val = payload.value;
2356
2356
  return !nullish(val) && val.size !== void 0;
2357
2357
  });
@@ -2379,9 +2379,9 @@ var $ZodCheckSizeEquals = /* @__PURE__ */ $constructor("$ZodCheckSizeEquals", (i
2379
2379
  };
2380
2380
  });
2381
2381
  var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
2382
- var _a21;
2382
+ var _a23;
2383
2383
  $ZodCheck.init(inst, def);
2384
- (_a21 = inst._zod.def).when ?? (_a21.when = (payload) => {
2384
+ (_a23 = inst._zod.def).when ?? (_a23.when = (payload) => {
2385
2385
  const val = payload.value;
2386
2386
  return !nullish(val) && val.length !== void 0;
2387
2387
  });
@@ -2408,9 +2408,9 @@ var $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (ins
2408
2408
  };
2409
2409
  });
2410
2410
  var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
2411
- var _a21;
2411
+ var _a23;
2412
2412
  $ZodCheck.init(inst, def);
2413
- (_a21 = inst._zod.def).when ?? (_a21.when = (payload) => {
2413
+ (_a23 = inst._zod.def).when ?? (_a23.when = (payload) => {
2414
2414
  const val = payload.value;
2415
2415
  return !nullish(val) && val.length !== void 0;
2416
2416
  });
@@ -2437,9 +2437,9 @@ var $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (ins
2437
2437
  };
2438
2438
  });
2439
2439
  var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
2440
- var _a21;
2440
+ var _a23;
2441
2441
  $ZodCheck.init(inst, def);
2442
- (_a21 = inst._zod.def).when ?? (_a21.when = (payload) => {
2442
+ (_a23 = inst._zod.def).when ?? (_a23.when = (payload) => {
2443
2443
  const val = payload.value;
2444
2444
  return !nullish(val) && val.length !== void 0;
2445
2445
  });
@@ -2468,7 +2468,7 @@ var $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals"
2468
2468
  };
2469
2469
  });
2470
2470
  var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
2471
- var _a21, _b16;
2471
+ var _a23, _b16;
2472
2472
  $ZodCheck.init(inst, def);
2473
2473
  inst._zod.onattach.push((inst2) => {
2474
2474
  const bag = inst2._zod.bag;
@@ -2479,7 +2479,7 @@ var $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat"
2479
2479
  }
2480
2480
  });
2481
2481
  if (def.pattern)
2482
- (_a21 = inst._zod).check ?? (_a21.check = (payload) => {
2482
+ (_a23 = inst._zod).check ?? (_a23.check = (payload) => {
2483
2483
  def.pattern.lastIndex = 0;
2484
2484
  if (def.pattern.test(payload.value))
2485
2485
  return;
@@ -2683,7 +2683,7 @@ var version = {
2683
2683
 
2684
2684
  // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/core/schemas.js
2685
2685
  var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
2686
- var _a21;
2686
+ var _a23;
2687
2687
  inst ?? (inst = {});
2688
2688
  inst._zod.def = def;
2689
2689
  inst._zod.bag = inst._zod.bag || {};
@@ -2698,7 +2698,7 @@ var $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
2698
2698
  }
2699
2699
  }
2700
2700
  if (checks.length === 0) {
2701
- (_a21 = inst._zod).deferred ?? (_a21.deferred = []);
2701
+ (_a23 = inst._zod).deferred ?? (_a23.deferred = []);
2702
2702
  inst._zod.deferred?.push(() => {
2703
2703
  inst._zod.run = inst._zod.parse;
2704
2704
  });
@@ -11398,7 +11398,7 @@ function initializeContext(params) {
11398
11398
  };
11399
11399
  }
11400
11400
  function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
11401
- var _a21;
11401
+ var _a23;
11402
11402
  const def = schema._zod.def;
11403
11403
  const seen = ctx.seen.get(schema);
11404
11404
  if (seen) {
@@ -11446,7 +11446,7 @@ function process2(schema, ctx, _params = { path: [], schemaPath: [] }) {
11446
11446
  delete result.schema.default;
11447
11447
  }
11448
11448
  if (ctx.io === "input" && result.schema._prefault)
11449
- (_a21 = result.schema).default ?? (_a21.default = result.schema._prefault);
11449
+ (_a23 = result.schema).default ?? (_a23.default = result.schema._prefault);
11450
11450
  delete result.schema._prefault;
11451
11451
  const _result = ctx.seen.get(schema);
11452
11452
  return _result.schema;
@@ -18181,8 +18181,15 @@ var nullableType = ZodNullable2.create;
18181
18181
  var preprocessType = ZodEffects.createWithPreprocess;
18182
18182
  var pipelineType = ZodPipeline.create;
18183
18183
 
18184
- // ../../node_modules/.pnpm/@ai-sdk+provider-utils@4.0.27_zod@4.3.6/node_modules/@ai-sdk/provider-utils/dist/index.mjs
18184
+ // ../../node_modules/.pnpm/@ai-sdk+provider-utils@4.0.40_zod@4.3.6/node_modules/@ai-sdk/provider-utils/dist/index.mjs
18185
18185
  var { btoa: btoa2, atob: atob2 } = globalThis;
18186
+ async function cancelResponseBody(response) {
18187
+ var _a23;
18188
+ try {
18189
+ await ((_a23 = response.body) == null ? void 0 : _a23.cancel());
18190
+ } catch (e) {
18191
+ }
18192
+ }
18186
18193
  var name14 = "AI_DownloadError";
18187
18194
  var marker15 = `vercel.ai.error.${name14}`;
18188
18195
  var symbol16 = Symbol.for(marker15);
@@ -18206,58 +18213,8 @@ var DownloadError = class extends (_b15 = AISDKError, _a16 = symbol16, _b15) {
18206
18213
  return AISDKError.hasMarker(error48, marker15);
18207
18214
  }
18208
18215
  };
18209
- var DEFAULT_MAX_DOWNLOAD_SIZE = 2 * 1024 * 1024 * 1024;
18210
- async function readResponseWithSizeLimit({
18211
- response,
18212
- url: url2,
18213
- maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE
18214
- }) {
18215
- const contentLength = response.headers.get("content-length");
18216
- if (contentLength != null) {
18217
- const length = parseInt(contentLength, 10);
18218
- if (!isNaN(length) && length > maxBytes) {
18219
- throw new DownloadError({
18220
- url: url2,
18221
- message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
18222
- });
18223
- }
18224
- }
18225
- const body = response.body;
18226
- if (body == null) {
18227
- return new Uint8Array(0);
18228
- }
18229
- const reader = body.getReader();
18230
- const chunks = [];
18231
- let totalBytes = 0;
18232
- try {
18233
- while (true) {
18234
- const { done, value } = await reader.read();
18235
- if (done) {
18236
- break;
18237
- }
18238
- totalBytes += value.length;
18239
- if (totalBytes > maxBytes) {
18240
- throw new DownloadError({
18241
- url: url2,
18242
- message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes.`
18243
- });
18244
- }
18245
- chunks.push(value);
18246
- }
18247
- } finally {
18248
- try {
18249
- await reader.cancel();
18250
- } finally {
18251
- reader.releaseLock();
18252
- }
18253
- }
18254
- const result = new Uint8Array(totalBytes);
18255
- let offset = 0;
18256
- for (const chunk of chunks) {
18257
- result.set(chunk, offset);
18258
- offset += chunk.length;
18259
- }
18260
- return result;
18216
+ function isBrowserRuntime(globalThisAny = globalThis) {
18217
+ return globalThisAny.window != null;
18261
18218
  }
18262
18219
  function validateDownloadUrl(url2) {
18263
18220
  let parsed;
@@ -18278,7 +18235,7 @@ function validateDownloadUrl(url2) {
18278
18235
  message: `URL scheme must be http, https, or data, got ${parsed.protocol}`
18279
18236
  });
18280
18237
  }
18281
- const hostname3 = parsed.hostname;
18238
+ const hostname3 = parsed.hostname.toLowerCase().replace(/\.+$/, "");
18282
18239
  if (!hostname3) {
18283
18240
  throw new DownloadError({
18284
18241
  url: url2,
@@ -18321,41 +18278,175 @@ function isIPv4(hostname3) {
18321
18278
  }
18322
18279
  function isPrivateIPv4(ip) {
18323
18280
  const parts = ip.split(".").map(Number);
18324
- const [a, b] = parts;
18281
+ const [a, b, c] = parts;
18325
18282
  if (a === 0) return true;
18326
18283
  if (a === 10) return true;
18284
+ if (a === 100 && b >= 64 && b <= 127) return true;
18327
18285
  if (a === 127) return true;
18328
18286
  if (a === 169 && b === 254) return true;
18329
18287
  if (a === 172 && b >= 16 && b <= 31) return true;
18288
+ if (a === 192 && b === 0 && c === 0) return true;
18330
18289
  if (a === 192 && b === 168) return true;
18290
+ if (a === 198 && (b === 18 || b === 19)) return true;
18291
+ if (a >= 240) return true;
18331
18292
  return false;
18332
18293
  }
18294
+ function parseIPv6(ip) {
18295
+ let address = ip.toLowerCase();
18296
+ const zoneIndex = address.indexOf("%");
18297
+ if (zoneIndex !== -1) {
18298
+ address = address.slice(0, zoneIndex);
18299
+ }
18300
+ const halves = address.split("::");
18301
+ if (halves.length > 2) return null;
18302
+ const toGroups = (segment) => {
18303
+ if (segment === "") return [];
18304
+ const groups = [];
18305
+ const parts = segment.split(":");
18306
+ for (let i = 0; i < parts.length; i++) {
18307
+ const part = parts[i];
18308
+ if (part.includes(".")) {
18309
+ if (i !== parts.length - 1 || !isIPv4(part)) return null;
18310
+ const [a, b, c, d] = part.split(".").map(Number);
18311
+ groups.push(a << 8 | b, c << 8 | d);
18312
+ continue;
18313
+ }
18314
+ if (!/^[0-9a-f]{1,4}$/.test(part)) return null;
18315
+ groups.push(parseInt(part, 16));
18316
+ }
18317
+ return groups;
18318
+ };
18319
+ const head = toGroups(halves[0]);
18320
+ if (head === null) return null;
18321
+ if (halves.length === 2) {
18322
+ const tail = toGroups(halves[1]);
18323
+ if (tail === null) return null;
18324
+ const fill = 8 - head.length - tail.length;
18325
+ if (fill < 0) return null;
18326
+ return [...head, ...new Array(fill).fill(0), ...tail];
18327
+ }
18328
+ return head.length === 8 ? head : null;
18329
+ }
18333
18330
  function isPrivateIPv6(ip) {
18334
- const normalized = ip.toLowerCase();
18335
- if (normalized === "::1") return true;
18336
- if (normalized === "::") return true;
18337
- if (normalized.startsWith("::ffff:")) {
18338
- const mappedPart = normalized.slice(7);
18339
- if (isIPv4(mappedPart)) {
18340
- return isPrivateIPv4(mappedPart);
18341
- }
18342
- const hexParts = mappedPart.split(":");
18343
- if (hexParts.length === 2) {
18344
- const high = parseInt(hexParts[0], 16);
18345
- const low = parseInt(hexParts[1], 16);
18346
- if (!isNaN(high) && !isNaN(low)) {
18347
- const a = high >> 8 & 255;
18348
- const b = high & 255;
18349
- const c = low >> 8 & 255;
18350
- const d = low & 255;
18351
- return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
18352
- }
18353
- }
18354
- }
18355
- if (normalized.startsWith("fc") || normalized.startsWith("fd")) return true;
18356
- if (normalized.startsWith("fe80")) return true;
18331
+ const groups = parseIPv6(ip);
18332
+ if (groups === null) return true;
18333
+ const topZero = (count) => groups.slice(0, count).every((group) => group === 0);
18334
+ if (topZero(7) && (groups[7] === 0 || groups[7] === 1)) return true;
18335
+ if ((groups[0] & 65024) === 64512) return true;
18336
+ if ((groups[0] & 65472) === 65152) return true;
18337
+ if ((groups[0] & 65472) === 65216) return true;
18338
+ if ((groups[0] & 65280) === 65280) return true;
18339
+ const embedsIPv4 = (
18340
+ // ::/96 — IPv4-compatible (deprecated)
18341
+ topZero(6) || // ::ffff:0:0/96 — IPv4-mapped (ffff in group 5)
18342
+ topZero(5) && groups[5] === 65535 || // ::ffff:0:0/96 — IPv4-translated form (ffff in group 4, group 5 zero)
18343
+ topZero(4) && groups[4] === 65535 && groups[5] === 0 || // 64:ff9b::/96 — NAT64 well-known prefix
18344
+ groups[0] === 100 && groups[1] === 65435 && groups[2] === 0 && groups[3] === 0 && groups[4] === 0 && groups[5] === 0 || // 64:ff9b:1::/48 — NAT64 local-use prefix
18345
+ groups[0] === 100 && groups[1] === 65435 && groups[2] === 1
18346
+ );
18347
+ if (embedsIPv4) {
18348
+ const a = groups[6] >> 8 & 255;
18349
+ const b = groups[6] & 255;
18350
+ const c = groups[7] >> 8 & 255;
18351
+ const d = groups[7] & 255;
18352
+ return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
18353
+ }
18357
18354
  return false;
18358
18355
  }
18356
+ var MAX_DOWNLOAD_REDIRECTS = 10;
18357
+ async function fetchWithValidatedRedirects({
18358
+ url: url2,
18359
+ headers,
18360
+ abortSignal,
18361
+ maxRedirects = MAX_DOWNLOAD_REDIRECTS
18362
+ }) {
18363
+ const baseInit = { signal: abortSignal };
18364
+ if (headers !== void 0) {
18365
+ baseInit.headers = headers;
18366
+ }
18367
+ let currentUrl = url2;
18368
+ for (let redirectCount = 0; redirectCount <= maxRedirects; redirectCount++) {
18369
+ validateDownloadUrl(currentUrl);
18370
+ const response = await fetch(currentUrl, {
18371
+ ...baseInit,
18372
+ redirect: "manual"
18373
+ });
18374
+ if (response.type === "opaqueredirect") {
18375
+ if (!isBrowserRuntime()) {
18376
+ throw new DownloadError({
18377
+ url: url2,
18378
+ message: `Redirect from ${currentUrl} could not be validated and was blocked`
18379
+ });
18380
+ }
18381
+ return await fetch(currentUrl, { ...baseInit, redirect: "follow" });
18382
+ }
18383
+ const location = response.headers.get("location");
18384
+ if (response.status >= 300 && response.status < 400 && location) {
18385
+ await cancelResponseBody(response);
18386
+ currentUrl = new URL(location, currentUrl).toString();
18387
+ continue;
18388
+ }
18389
+ return response;
18390
+ }
18391
+ throw new DownloadError({
18392
+ url: url2,
18393
+ message: `Too many redirects (max ${maxRedirects})`
18394
+ });
18395
+ }
18396
+ var DEFAULT_MAX_DOWNLOAD_SIZE = 2 * 1024 * 1024 * 1024;
18397
+ async function readResponseWithSizeLimit({
18398
+ response,
18399
+ url: url2,
18400
+ maxBytes = DEFAULT_MAX_DOWNLOAD_SIZE
18401
+ }) {
18402
+ const contentLength = response.headers.get("content-length");
18403
+ if (contentLength != null) {
18404
+ const length = parseInt(contentLength, 10);
18405
+ if (!isNaN(length) && length > maxBytes) {
18406
+ await cancelResponseBody(response);
18407
+ throw new DownloadError({
18408
+ url: url2,
18409
+ message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
18410
+ });
18411
+ }
18412
+ }
18413
+ const body = response.body;
18414
+ if (body == null) {
18415
+ return new Uint8Array(0);
18416
+ }
18417
+ const reader = body.getReader();
18418
+ const chunks = [];
18419
+ let totalBytes = 0;
18420
+ try {
18421
+ while (true) {
18422
+ const { done, value } = await reader.read();
18423
+ if (done) {
18424
+ break;
18425
+ }
18426
+ totalBytes += value.length;
18427
+ if (totalBytes > maxBytes) {
18428
+ throw new DownloadError({
18429
+ url: url2,
18430
+ message: `Download of ${url2} exceeded maximum size of ${maxBytes} bytes.`
18431
+ });
18432
+ }
18433
+ chunks.push(value);
18434
+ }
18435
+ } finally {
18436
+ try {
18437
+ await reader.cancel();
18438
+ } finally {
18439
+ reader.releaseLock();
18440
+ }
18441
+ }
18442
+ const result = new Uint8Array(totalBytes);
18443
+ let offset = 0;
18444
+ for (const chunk of chunks) {
18445
+ result.set(chunk, offset);
18446
+ offset += chunk.length;
18447
+ }
18448
+ return result;
18449
+ }
18359
18450
  var createIdGenerator = ({
18360
18451
  prefix,
18361
18452
  size = 16,
@@ -18382,18 +18473,6 @@ var createIdGenerator = ({
18382
18473
  return () => `${prefix}${separator}${generator()}`;
18383
18474
  };
18384
18475
  var generateId = createIdGenerator();
18385
- function getErrorMessage2(error48) {
18386
- if (error48 == null) {
18387
- return "unknown error";
18388
- }
18389
- if (typeof error48 === "string") {
18390
- return error48;
18391
- }
18392
- if (error48 instanceof Error) {
18393
- return error48.message;
18394
- }
18395
- return JSON.stringify(error48);
18396
- }
18397
18476
  function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
18398
18477
  var _a23, _b22, _c;
18399
18478
  if (globalThisAny.window) {
@@ -19650,15 +19729,26 @@ function isSchema(value) {
19650
19729
  return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && "jsonSchema" in value && "validate" in value;
19651
19730
  }
19652
19731
  function asSchema(schema) {
19653
- return schema == null ? jsonSchema({ properties: {}, additionalProperties: false }) : isSchema(schema) ? schema : "~standard" in schema ? schema["~standard"].vendor === "zod" ? zodSchema(schema) : standardSchema(schema) : schema();
19732
+ return schema == null ? jsonSchema({
19733
+ type: "object",
19734
+ properties: {},
19735
+ additionalProperties: false
19736
+ }) : isSchema(schema) ? schema : "~standard" in schema ? schema["~standard"].vendor === "zod" ? zodSchema(schema) : standardSchema(schema) : schema();
19654
19737
  }
19655
19738
  function standardSchema(standardSchema2) {
19656
19739
  return jsonSchema(
19657
- () => addAdditionalPropertiesToJsonSchema(
19658
- standardSchema2["~standard"].jsonSchema.input({
19659
- target: "draft-07"
19660
- })
19661
- ),
19740
+ () => {
19741
+ if (!hasStandardJsonSchema(standardSchema2)) {
19742
+ throw new Error(
19743
+ `Standard schema vendor '${standardSchema2["~standard"].vendor}' does not support JSON Schema conversion.`
19744
+ );
19745
+ }
19746
+ return addAdditionalPropertiesToJsonSchema(
19747
+ standardSchema2["~standard"].jsonSchema.input({
19748
+ target: "draft-07"
19749
+ })
19750
+ );
19751
+ },
19662
19752
  {
19663
19753
  validate: async (value) => {
19664
19754
  const result = await standardSchema2["~standard"].validate(value);
@@ -19673,6 +19763,9 @@ function standardSchema(standardSchema2) {
19673
19763
  }
19674
19764
  );
19675
19765
  }
19766
+ function hasStandardJsonSchema(schema) {
19767
+ return schema["~standard"].jsonSchema != null;
19768
+ }
19676
19769
  function zod3Schema(zodSchema2, options) {
19677
19770
  var _a23;
19678
19771
  const useReferences = (_a23 = options == null ? void 0 : options.useReferences) != null ? _a23 : false;
@@ -19781,12 +19874,13 @@ async function resolve(value) {
19781
19874
  }
19782
19875
  return Promise.resolve(value);
19783
19876
  }
19877
+ var textDecoder = new TextDecoder();
19784
19878
 
19785
- // ../../node_modules/.pnpm/ai@6.0.197_zod@4.3.6/node_modules/ai/dist/index.mjs
19879
+ // ../../node_modules/.pnpm/ai@6.0.230_zod@4.3.6/node_modules/ai/dist/index.mjs
19786
19880
  var __defProp2 = Object.defineProperty;
19787
19881
  var __export2 = (target, all) => {
19788
- for (var name21 in all)
19789
- __defProp2(target, name21, { get: all[name21], enumerable: true });
19882
+ for (var name222 in all)
19883
+ __defProp2(target, name222, { get: all[name222], enumerable: true });
19790
19884
  };
19791
19885
  var name15 = "AI_InvalidArgumentError";
19792
19886
  var marker16 = `vercel.ai.error.${name15}`;
@@ -19803,30 +19897,35 @@ var marker32 = `vercel.ai.error.${name32}`;
19803
19897
  var symbol32 = Symbol.for(marker32);
19804
19898
  var _a32;
19805
19899
  _a32 = symbol32;
19806
- var name42 = "AI_InvalidToolInputError";
19900
+ var name42 = "AI_InvalidToolApprovalSignatureError";
19807
19901
  var marker42 = `vercel.ai.error.${name42}`;
19808
19902
  var symbol42 = Symbol.for(marker42);
19809
19903
  var _a42;
19810
19904
  _a42 = symbol42;
19811
- var name52 = "AI_ToolCallNotFoundForApprovalError";
19905
+ var name52 = "AI_InvalidToolInputError";
19812
19906
  var marker52 = `vercel.ai.error.${name52}`;
19813
19907
  var symbol52 = Symbol.for(marker52);
19814
19908
  var _a52;
19815
19909
  _a52 = symbol52;
19816
- var name62 = "AI_MissingToolResultsError";
19910
+ var name62 = "AI_ToolCallNotFoundForApprovalError";
19817
19911
  var marker62 = `vercel.ai.error.${name62}`;
19818
19912
  var symbol62 = Symbol.for(marker62);
19819
19913
  var _a62;
19820
19914
  _a62 = symbol62;
19821
- var name72 = "AI_NoImageGeneratedError";
19915
+ var name72 = "AI_MissingToolResultsError";
19822
19916
  var marker72 = `vercel.ai.error.${name72}`;
19823
19917
  var symbol72 = Symbol.for(marker72);
19824
19918
  var _a72;
19825
19919
  _a72 = symbol72;
19826
- var name82 = "AI_NoObjectGeneratedError";
19920
+ var name82 = "AI_NoImageGeneratedError";
19827
19921
  var marker82 = `vercel.ai.error.${name82}`;
19828
19922
  var symbol82 = Symbol.for(marker82);
19829
19923
  var _a82;
19924
+ _a82 = symbol82;
19925
+ var name92 = "AI_NoObjectGeneratedError";
19926
+ var marker92 = `vercel.ai.error.${name92}`;
19927
+ var symbol92 = Symbol.for(marker92);
19928
+ var _a92;
19830
19929
  var NoObjectGeneratedError = class extends AISDKError {
19831
19930
  constructor({
19832
19931
  message = "No object generated.",
@@ -19836,110 +19935,109 @@ var NoObjectGeneratedError = class extends AISDKError {
19836
19935
  usage,
19837
19936
  finishReason
19838
19937
  }) {
19839
- super({ name: name82, message, cause });
19840
- this[_a82] = true;
19938
+ super({ name: name92, message, cause });
19939
+ this[_a92] = true;
19841
19940
  this.text = text2;
19842
19941
  this.response = response;
19843
19942
  this.usage = usage;
19844
19943
  this.finishReason = finishReason;
19845
19944
  }
19846
19945
  static isInstance(error48) {
19847
- return AISDKError.hasMarker(error48, marker82);
19946
+ return AISDKError.hasMarker(error48, marker92);
19848
19947
  }
19849
19948
  };
19850
- _a82 = symbol82;
19851
- var name92 = "AI_NoOutputGeneratedError";
19852
- var marker92 = `vercel.ai.error.${name92}`;
19853
- var symbol92 = Symbol.for(marker92);
19854
- var _a92;
19855
19949
  _a92 = symbol92;
19856
- var name102 = "AI_NoSpeechGeneratedError";
19950
+ var name102 = "AI_NoOutputGeneratedError";
19857
19951
  var marker102 = `vercel.ai.error.${name102}`;
19858
19952
  var symbol102 = Symbol.for(marker102);
19859
19953
  var _a102;
19860
19954
  _a102 = symbol102;
19861
- var name112 = "AI_NoTranscriptGeneratedError";
19955
+ var name112 = "AI_NoSpeechGeneratedError";
19862
19956
  var marker112 = `vercel.ai.error.${name112}`;
19863
19957
  var symbol112 = Symbol.for(marker112);
19864
19958
  var _a112;
19865
19959
  _a112 = symbol112;
19866
- var name122 = "AI_NoVideoGeneratedError";
19960
+ var name122 = "AI_NoTranscriptGeneratedError";
19867
19961
  var marker122 = `vercel.ai.error.${name122}`;
19868
19962
  var symbol122 = Symbol.for(marker122);
19869
19963
  var _a122;
19870
19964
  _a122 = symbol122;
19871
- var name132 = "AI_NoSuchToolError";
19965
+ var name132 = "AI_NoVideoGeneratedError";
19872
19966
  var marker132 = `vercel.ai.error.${name132}`;
19873
19967
  var symbol132 = Symbol.for(marker132);
19874
19968
  var _a132;
19875
19969
  _a132 = symbol132;
19876
- var name142 = "AI_ToolCallRepairError";
19970
+ var name142 = "AI_NoSuchToolError";
19877
19971
  var marker142 = `vercel.ai.error.${name142}`;
19878
19972
  var symbol142 = Symbol.for(marker142);
19879
19973
  var _a142;
19880
19974
  _a142 = symbol142;
19881
- var name152 = "AI_UIMessageStreamError";
19975
+ var name152 = "AI_ToolCallRepairError";
19882
19976
  var marker152 = `vercel.ai.error.${name152}`;
19883
19977
  var symbol152 = Symbol.for(marker152);
19884
19978
  var _a152;
19979
+ _a152 = symbol152;
19980
+ var name16 = "AI_UIMessageStreamError";
19981
+ var marker162 = `vercel.ai.error.${name16}`;
19982
+ var symbol162 = Symbol.for(marker162);
19983
+ var _a162;
19885
19984
  var UIMessageStreamError = class extends AISDKError {
19886
19985
  constructor({
19887
19986
  chunkType,
19888
19987
  chunkId,
19889
19988
  message
19890
19989
  }) {
19891
- super({ name: name152, message });
19892
- this[_a152] = true;
19990
+ super({ name: name16, message });
19991
+ this[_a162] = true;
19893
19992
  this.chunkType = chunkType;
19894
19993
  this.chunkId = chunkId;
19895
19994
  }
19896
19995
  static isInstance(error48) {
19897
- return AISDKError.hasMarker(error48, marker152);
19996
+ return AISDKError.hasMarker(error48, marker162);
19898
19997
  }
19899
19998
  };
19900
- _a152 = symbol152;
19901
- var name16 = "AI_InvalidDataContentError";
19902
- var marker162 = `vercel.ai.error.${name16}`;
19903
- var symbol162 = Symbol.for(marker162);
19904
- var _a162;
19905
19999
  _a162 = symbol162;
19906
- var name17 = "AI_InvalidMessageRoleError";
20000
+ var name17 = "AI_InvalidDataContentError";
19907
20001
  var marker17 = `vercel.ai.error.${name17}`;
19908
20002
  var symbol172 = Symbol.for(marker17);
19909
20003
  var _a172;
19910
20004
  _a172 = symbol172;
19911
- var name18 = "AI_MessageConversionError";
20005
+ var name18 = "AI_InvalidMessageRoleError";
19912
20006
  var marker18 = `vercel.ai.error.${name18}`;
19913
20007
  var symbol18 = Symbol.for(marker18);
19914
20008
  var _a18;
19915
20009
  _a18 = symbol18;
19916
- var name19 = "AI_RetryError";
20010
+ var name19 = "AI_MessageConversionError";
19917
20011
  var marker19 = `vercel.ai.error.${name19}`;
19918
20012
  var symbol19 = Symbol.for(marker19);
19919
20013
  var _a19;
19920
20014
  _a19 = symbol19;
19921
- var VERSION = true ? "6.0.197" : "0.0.0-test";
20015
+ var name20 = "AI_RetryError";
20016
+ var marker20 = `vercel.ai.error.${name20}`;
20017
+ var symbol20 = Symbol.for(marker20);
20018
+ var _a20;
20019
+ _a20 = symbol20;
20020
+ var VERSION = true ? "6.0.230" : "0.0.0-test";
19922
20021
  var download = async ({
19923
20022
  url: url2,
19924
20023
  maxBytes,
19925
20024
  abortSignal
19926
20025
  }) => {
19927
- var _a21;
20026
+ var _a222;
19928
20027
  const urlText = url2.toString();
19929
- validateDownloadUrl(urlText);
19930
20028
  try {
19931
- const response = await fetch(urlText, {
19932
- headers: withUserAgentSuffix(
19933
- {},
19934
- `ai-sdk/${VERSION}`,
19935
- getRuntimeEnvironmentUserAgent()
19936
- ),
19937
- signal: abortSignal
20029
+ const headers = withUserAgentSuffix(
20030
+ {},
20031
+ `ai-sdk/${VERSION}`,
20032
+ getRuntimeEnvironmentUserAgent()
20033
+ );
20034
+ const response = await fetchWithValidatedRedirects({
20035
+ url: urlText,
20036
+ headers,
20037
+ abortSignal
19938
20038
  });
19939
- if (response.redirected) {
19940
- validateDownloadUrl(response.url);
19941
- }
19942
20039
  if (!response.ok) {
20040
+ await cancelResponseBody(response);
19943
20041
  throw new DownloadError({
19944
20042
  url: urlText,
19945
20043
  statusCode: response.status,
@@ -19953,7 +20051,7 @@ var download = async ({
19953
20051
  });
19954
20052
  return {
19955
20053
  data,
19956
- mediaType: (_a21 = response.headers.get("content-type")) != null ? _a21 : void 0
20054
+ mediaType: (_a222 = response.headers.get("content-type")) != null ? _a222 : void 0
19957
20055
  };
19958
20056
  } catch (error48) {
19959
20057
  if (DownloadError.isInstance(error48)) {
@@ -19969,8 +20067,8 @@ var dataContentSchema = external_exports.union([
19969
20067
  external_exports.custom(
19970
20068
  // Buffer might not be available in some environments such as CloudFlare:
19971
20069
  (value) => {
19972
- var _a21, _b16;
19973
- return (_b16 = (_a21 = globalThis.Buffer) == null ? void 0 : _a21.isBuffer(value)) != null ? _b16 : false;
20070
+ var _a222, _b16;
20071
+ return (_b16 = (_a222 = globalThis.Buffer) == null ? void 0 : _a222.isBuffer(value)) != null ? _b16 : false;
19974
20072
  },
19975
20073
  { message: "Must be a Buffer" }
19976
20074
  )
@@ -20199,6 +20297,7 @@ function mergeObjects(base, overrides) {
20199
20297
  }
20200
20298
  return result;
20201
20299
  }
20300
+ var encoder = new TextEncoder();
20202
20301
  var output_exports = {};
20203
20302
  __export2(output_exports, {
20204
20303
  array: () => array2,
@@ -20211,6 +20310,10 @@ function fixJson(input) {
20211
20310
  const stack = ["ROOT"];
20212
20311
  let lastValidIndex = -1;
20213
20312
  let literalStart = null;
20313
+ let unicodeEscapeDigits = 0;
20314
+ function isHexDigit(char) {
20315
+ return char >= "0" && char <= "9" || char >= "A" && char <= "F" || char >= "a" && char <= "f";
20316
+ }
20214
20317
  function processValueStart(char, i, swapState) {
20215
20318
  {
20216
20319
  switch (char) {
@@ -20415,7 +20518,22 @@ function fixJson(input) {
20415
20518
  }
20416
20519
  case "INSIDE_STRING_ESCAPE": {
20417
20520
  stack.pop();
20418
- lastValidIndex = i;
20521
+ if (char === "u") {
20522
+ unicodeEscapeDigits = 0;
20523
+ stack.push("INSIDE_STRING_UNICODE_ESCAPE");
20524
+ } else {
20525
+ lastValidIndex = i;
20526
+ }
20527
+ break;
20528
+ }
20529
+ case "INSIDE_STRING_UNICODE_ESCAPE": {
20530
+ if (isHexDigit(char)) {
20531
+ unicodeEscapeDigits++;
20532
+ if (unicodeEscapeDigits === 4) {
20533
+ stack.pop();
20534
+ lastValidIndex = i;
20535
+ }
20536
+ }
20419
20537
  break;
20420
20538
  }
20421
20539
  case "INSIDE_NUMBER": {
@@ -20552,7 +20670,7 @@ var text = () => ({
20552
20670
  });
20553
20671
  var object2 = ({
20554
20672
  schema: inputSchema,
20555
- name: name21,
20673
+ name: name222,
20556
20674
  description
20557
20675
  }) => {
20558
20676
  const schema = asSchema(inputSchema);
@@ -20561,7 +20679,7 @@ var object2 = ({
20561
20679
  responseFormat: resolve(schema.jsonSchema).then((jsonSchema2) => ({
20562
20680
  type: "json",
20563
20681
  schema: jsonSchema2,
20564
- ...name21 != null && { name: name21 },
20682
+ ...name222 != null && { name: name222 },
20565
20683
  ...description != null && { description }
20566
20684
  })),
20567
20685
  async parseCompleteOutput({ text: text2 }, context2) {
@@ -20615,7 +20733,7 @@ var object2 = ({
20615
20733
  };
20616
20734
  var array2 = ({
20617
20735
  element: inputElementSchema,
20618
- name: name21,
20736
+ name: name222,
20619
20737
  description
20620
20738
  }) => {
20621
20739
  const elementSchema = asSchema(inputElementSchema);
@@ -20635,7 +20753,7 @@ var array2 = ({
20635
20753
  required: ["elements"],
20636
20754
  additionalProperties: false
20637
20755
  },
20638
- ...name21 != null && { name: name21 },
20756
+ ...name222 != null && { name: name222 },
20639
20757
  ...description != null && { description }
20640
20758
  };
20641
20759
  }),
@@ -20665,6 +20783,7 @@ var array2 = ({
20665
20783
  finishReason: context2.finishReason
20666
20784
  });
20667
20785
  }
20786
+ const validatedElements = [];
20668
20787
  for (const element of outerValue.elements) {
20669
20788
  const validationResult = await safeValidateTypes({
20670
20789
  value: element,
@@ -20680,8 +20799,9 @@ var array2 = ({
20680
20799
  finishReason: context2.finishReason
20681
20800
  });
20682
20801
  }
20802
+ validatedElements.push(validationResult.value);
20683
20803
  }
20684
- return outerValue.elements;
20804
+ return validatedElements;
20685
20805
  },
20686
20806
  async parsePartialOutput({ text: text2 }) {
20687
20807
  const result = await parsePartialJson(text2);
@@ -20727,7 +20847,7 @@ var array2 = ({
20727
20847
  };
20728
20848
  var choice = ({
20729
20849
  options: choiceOptions,
20730
- name: name21,
20850
+ name: name222,
20731
20851
  description
20732
20852
  }) => {
20733
20853
  return {
@@ -20744,7 +20864,7 @@ var choice = ({
20744
20864
  required: ["result"],
20745
20865
  additionalProperties: false
20746
20866
  },
20747
- ...name21 != null && { name: name21 },
20867
+ ...name222 != null && { name: name222 },
20748
20868
  ...description != null && { description }
20749
20869
  }),
20750
20870
  async parseCompleteOutput({ text: text2 }, context2) {
@@ -20805,14 +20925,14 @@ var choice = ({
20805
20925
  };
20806
20926
  };
20807
20927
  var json2 = ({
20808
- name: name21,
20928
+ name: name222,
20809
20929
  description
20810
20930
  } = {}) => {
20811
20931
  return {
20812
20932
  name: "json",
20813
20933
  responseFormat: Promise.resolve({
20814
20934
  type: "json",
20815
- ...name21 != null && { name: name21 },
20935
+ ...name222 != null && { name: name222 },
20816
20936
  ...description != null && { description }
20817
20937
  }),
20818
20938
  async parseCompleteOutput({ text: text2 }, context2) {
@@ -20969,7 +21089,8 @@ var uiMessageChunkSchema = lazySchema(
20969
21089
  external_exports.strictObject({
20970
21090
  type: external_exports.literal("tool-approval-request"),
20971
21091
  approvalId: external_exports.string(),
20972
- toolCallId: external_exports.string()
21092
+ toolCallId: external_exports.string(),
21093
+ signature: external_exports.string().optional()
20973
21094
  }),
20974
21095
  external_exports.strictObject({
20975
21096
  type: external_exports.literal("tool-output-available"),
@@ -21077,6 +21198,9 @@ var uiMessageChunkSchema = lazySchema(
21077
21198
  function isDataUIMessageChunk(chunk) {
21078
21199
  return chunk.type.startsWith("data-");
21079
21200
  }
21201
+ function createIdMap() {
21202
+ return /* @__PURE__ */ Object.create(null);
21203
+ }
21080
21204
  function isStaticToolUIPart(part) {
21081
21205
  return part.type.startsWith("tool-");
21082
21206
  }
@@ -21100,9 +21224,9 @@ function createStreamingUIMessageState({
21100
21224
  role: "assistant",
21101
21225
  parts: []
21102
21226
  },
21103
- activeTextParts: {},
21104
- activeReasoningParts: {},
21105
- partialToolCalls: {}
21227
+ activeTextParts: createIdMap(),
21228
+ activeReasoningParts: createIdMap(),
21229
+ partialToolCalls: createIdMap()
21106
21230
  };
21107
21231
  }
21108
21232
  function processUIMessageStream({
@@ -21118,7 +21242,7 @@ function processUIMessageStream({
21118
21242
  new TransformStream({
21119
21243
  async transform(chunk, controller) {
21120
21244
  await runUpdateMessageJob(async ({ state, write }) => {
21121
- var _a21, _b16, _c, _d;
21245
+ var _a222, _b16, _c, _d;
21122
21246
  function getToolInvocation(toolCallId) {
21123
21247
  const toolInvocations = state.message.parts.filter(isToolUIPart);
21124
21248
  const toolInvocation = toolInvocations.find(
@@ -21134,7 +21258,7 @@ function processUIMessageStream({
21134
21258
  return toolInvocation;
21135
21259
  }
21136
21260
  function updateToolPart(options) {
21137
- var _a222;
21261
+ var _a23;
21138
21262
  const part = state.message.parts.find(
21139
21263
  (part2) => isStaticToolUIPart(part2) && part2.toolCallId === options.toolCallId
21140
21264
  );
@@ -21153,7 +21277,7 @@ function processUIMessageStream({
21153
21277
  if (options.toolMetadata !== void 0) {
21154
21278
  anyPart.toolMetadata = options.toolMetadata;
21155
21279
  }
21156
- anyPart.providerExecuted = (_a222 = anyOptions.providerExecuted) != null ? _a222 : part.providerExecuted;
21280
+ anyPart.providerExecuted = (_a23 = anyOptions.providerExecuted) != null ? _a23 : part.providerExecuted;
21157
21281
  const providerMetadata = anyOptions.providerMetadata;
21158
21282
  if (providerMetadata != null) {
21159
21283
  if (options.state === "output-available" || options.state === "output-error") {
@@ -21182,7 +21306,7 @@ function processUIMessageStream({
21182
21306
  }
21183
21307
  }
21184
21308
  function updateDynamicToolPart(options) {
21185
- var _a222, _b22;
21309
+ var _a23, _b22;
21186
21310
  const part = state.message.parts.find(
21187
21311
  (part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId
21188
21312
  );
@@ -21194,7 +21318,7 @@ function processUIMessageStream({
21194
21318
  anyPart.input = anyOptions.input;
21195
21319
  anyPart.output = anyOptions.output;
21196
21320
  anyPart.errorText = anyOptions.errorText;
21197
- anyPart.rawInput = (_a222 = anyOptions.rawInput) != null ? _a222 : anyPart.rawInput;
21321
+ anyPart.rawInput = (_a23 = anyOptions.rawInput) != null ? _a23 : anyPart.rawInput;
21198
21322
  anyPart.preliminary = anyOptions.preliminary;
21199
21323
  if (options.title !== void 0) {
21200
21324
  anyPart.title = options.title;
@@ -21269,7 +21393,7 @@ function processUIMessageStream({
21269
21393
  });
21270
21394
  }
21271
21395
  textPart.text += chunk.delta;
21272
- textPart.providerMetadata = (_a21 = chunk.providerMetadata) != null ? _a21 : textPart.providerMetadata;
21396
+ textPart.providerMetadata = (_a222 = chunk.providerMetadata) != null ? _a222 : textPart.providerMetadata;
21273
21397
  write();
21274
21398
  break;
21275
21399
  }
@@ -21498,7 +21622,10 @@ function processUIMessageStream({
21498
21622
  case "tool-approval-request": {
21499
21623
  const toolInvocation = getToolInvocation(chunk.toolCallId);
21500
21624
  toolInvocation.state = "approval-requested";
21501
- toolInvocation.approval = { id: chunk.approvalId };
21625
+ toolInvocation.approval = {
21626
+ id: chunk.approvalId,
21627
+ ...chunk.signature != null ? { signature: chunk.signature } : {}
21628
+ };
21502
21629
  write();
21503
21630
  break;
21504
21631
  }
@@ -21576,8 +21703,8 @@ function processUIMessageStream({
21576
21703
  break;
21577
21704
  }
21578
21705
  case "finish-step": {
21579
- state.activeTextParts = {};
21580
- state.activeReasoningParts = {};
21706
+ state.activeTextParts = createIdMap();
21707
+ state.activeReasoningParts = createIdMap();
21581
21708
  break;
21582
21709
  }
21583
21710
  case "start": {
@@ -21759,7 +21886,8 @@ var originalGenerateId2 = createIdGenerator({
21759
21886
  });
21760
21887
  function createUIMessageStream({
21761
21888
  execute,
21762
- onError = getErrorMessage2,
21889
+ onError = () => "An error occurred.",
21890
+ // prevent leaking server error details to the client by default
21763
21891
  originalMessages,
21764
21892
  onStepFinish,
21765
21893
  onFinish,
@@ -21937,7 +22065,8 @@ var uiMessagesSchema = lazySchema(
21937
22065
  approval: external_exports.object({
21938
22066
  id: external_exports.string(),
21939
22067
  approved: external_exports.never().optional(),
21940
- reason: external_exports.never().optional()
22068
+ reason: external_exports.never().optional(),
22069
+ signature: external_exports.string().optional()
21941
22070
  })
21942
22071
  }),
21943
22072
  external_exports.object({
@@ -21954,7 +22083,8 @@ var uiMessagesSchema = lazySchema(
21954
22083
  approval: external_exports.object({
21955
22084
  id: external_exports.string(),
21956
22085
  approved: external_exports.boolean(),
21957
- reason: external_exports.string().optional()
22086
+ reason: external_exports.string().optional(),
22087
+ signature: external_exports.string().optional()
21958
22088
  })
21959
22089
  }),
21960
22090
  external_exports.object({
@@ -21973,7 +22103,8 @@ var uiMessagesSchema = lazySchema(
21973
22103
  approval: external_exports.object({
21974
22104
  id: external_exports.string(),
21975
22105
  approved: external_exports.literal(true),
21976
- reason: external_exports.string().optional()
22106
+ reason: external_exports.string().optional(),
22107
+ signature: external_exports.string().optional()
21977
22108
  }).optional()
21978
22109
  }),
21979
22110
  external_exports.object({
@@ -21992,7 +22123,8 @@ var uiMessagesSchema = lazySchema(
21992
22123
  approval: external_exports.object({
21993
22124
  id: external_exports.string(),
21994
22125
  approved: external_exports.literal(true),
21995
- reason: external_exports.string().optional()
22126
+ reason: external_exports.string().optional(),
22127
+ signature: external_exports.string().optional()
21996
22128
  }).optional()
21997
22129
  }),
21998
22130
  external_exports.object({
@@ -22009,7 +22141,8 @@ var uiMessagesSchema = lazySchema(
22009
22141
  approval: external_exports.object({
22010
22142
  id: external_exports.string(),
22011
22143
  approved: external_exports.literal(false),
22012
- reason: external_exports.string().optional()
22144
+ reason: external_exports.string().optional(),
22145
+ signature: external_exports.string().optional()
22013
22146
  })
22014
22147
  }),
22015
22148
  external_exports.object({
@@ -22049,7 +22182,8 @@ var uiMessagesSchema = lazySchema(
22049
22182
  approval: external_exports.object({
22050
22183
  id: external_exports.string(),
22051
22184
  approved: external_exports.never().optional(),
22052
- reason: external_exports.never().optional()
22185
+ reason: external_exports.never().optional(),
22186
+ signature: external_exports.string().optional()
22053
22187
  })
22054
22188
  }),
22055
22189
  external_exports.object({
@@ -22065,7 +22199,8 @@ var uiMessagesSchema = lazySchema(
22065
22199
  approval: external_exports.object({
22066
22200
  id: external_exports.string(),
22067
22201
  approved: external_exports.boolean(),
22068
- reason: external_exports.string().optional()
22202
+ reason: external_exports.string().optional(),
22203
+ signature: external_exports.string().optional()
22069
22204
  })
22070
22205
  }),
22071
22206
  external_exports.object({
@@ -22083,7 +22218,8 @@ var uiMessagesSchema = lazySchema(
22083
22218
  approval: external_exports.object({
22084
22219
  id: external_exports.string(),
22085
22220
  approved: external_exports.literal(true),
22086
- reason: external_exports.string().optional()
22221
+ reason: external_exports.string().optional(),
22222
+ signature: external_exports.string().optional()
22087
22223
  }).optional()
22088
22224
  }),
22089
22225
  external_exports.object({
@@ -22101,7 +22237,8 @@ var uiMessagesSchema = lazySchema(
22101
22237
  approval: external_exports.object({
22102
22238
  id: external_exports.string(),
22103
22239
  approved: external_exports.literal(true),
22104
- reason: external_exports.string().optional()
22240
+ reason: external_exports.string().optional(),
22241
+ signature: external_exports.string().optional()
22105
22242
  }).optional()
22106
22243
  }),
22107
22244
  external_exports.object({
@@ -22117,11 +22254,24 @@ var uiMessagesSchema = lazySchema(
22117
22254
  approval: external_exports.object({
22118
22255
  id: external_exports.string(),
22119
22256
  approved: external_exports.literal(false),
22120
- reason: external_exports.string().optional()
22257
+ reason: external_exports.string().optional(),
22258
+ signature: external_exports.string().optional()
22121
22259
  })
22122
22260
  })
22123
22261
  ])
22124
- ).nonempty("Message must contain at least one part")
22262
+ )
22263
+ }).superRefine((message, context2) => {
22264
+ if (message.role !== "assistant" && message.parts.length === 0) {
22265
+ context2.addIssue({
22266
+ origin: "array",
22267
+ code: "too_small",
22268
+ minimum: 1,
22269
+ inclusive: true,
22270
+ input: message.parts,
22271
+ path: ["parts"],
22272
+ message: "Message must contain at least one part"
22273
+ });
22274
+ }
22125
22275
  })
22126
22276
  ).nonempty("Messages array must not be empty")
22127
22277
  )
@@ -22132,11 +22282,11 @@ function createDownload(options) {
22132
22282
  }
22133
22283
  var originalGenerateId4 = createIdGenerator({ prefix: "aiobj", size: 24 });
22134
22284
  var defaultDownload = createDownload();
22135
- var name20 = "AI_NoSuchProviderError";
22136
- var marker20 = `vercel.ai.error.${name20}`;
22137
- var symbol20 = Symbol.for(marker20);
22138
- var _a20;
22139
- _a20 = symbol20;
22285
+ var name21 = "AI_NoSuchProviderError";
22286
+ var marker21 = `vercel.ai.error.${name21}`;
22287
+ var symbol21 = Symbol.for(marker21);
22288
+ var _a21;
22289
+ _a21 = symbol21;
22140
22290
  var defaultDownload2 = createDownload();
22141
22291
 
22142
22292
  // src/lib/cloud-api.ts
@@ -22158,6 +22308,62 @@ var prepareUserTools = (toolRegistry) => Object.keys(toolRegistry).reduce(
22158
22308
  {}
22159
22309
  );
22160
22310
 
22311
+ // src/lib/seal-provider-key.ts
22312
+ init_react_import();
22313
+ var DEFAULT_SEALING_KEY = {
22314
+ kid: "puck-2026-07",
22315
+ publicKey: "MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAwg3kLK+8I4jz7dORQa4QM/QZ4uMBmYanJnSjgDnSCIjs3aUgRstrIe0RWhXcq0V/nzq/P8dIlVD3idyG2UlTXjJb41mPw3hg1zkjW36jtSfRxmkfQMgIEcfeGl9vTnAVdZnHpf720462ZJTxWt/Wg0Uj5202XilIWjjiM/uYzvUSNSHqqhb6hehvIu7qIHZ4nrA2KkkJyGT2IOTyuWAyApS6G9ju9+AjdIM85ycqufCdjMcso6yWnFjN3VYNfF2N9W10dvlgui0NDZjjTrl/6+ckkzAwknZBwoWl0x/cTW0zyiaUcaU4oytluFXBJM4ELIU+M9kal7ivC58WwULC22yvnZICcaGdX4h0/rlRPc6PppSbbN8NRWzNHkkqdPeqYWIJCcl0W1MvmWa2iTyhpI58Jo8VNBQbCTfdKLy/mGytg2FmBXQiwWHg212XBkG0LriBLWdfMW5KNgPu7z1bgC6Mlb7LIkjgR9qgkBNOgKf2NSuIRq+pn9GTxGJL9YhfSDnn77QExHl1QyieD1dIEDCJPX6USdSnhdi1paSRIenpJTAWcsVMtP/1nMCmSYLcCojXCATQkPALTv1ZrMv0xFL61yaW5JF9RMwYCwnh/TdS1AppdAY6ftZG3sQ3XrwTCCVbw1Cn1rxZ8t3tIbepeZ8CaRFiLuUqaSL0EGzi1x8CAwEAAQ=="
22316
+ };
22317
+ var MAX_PLAINTEXT_BYTES = 446;
22318
+ var fromBase64 = (b64) => {
22319
+ const binary = atob(b64);
22320
+ const bytes = new Uint8Array(new ArrayBuffer(binary.length));
22321
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
22322
+ return bytes;
22323
+ };
22324
+ var toBase64 = (bytes) => {
22325
+ let binary = "";
22326
+ for (const byte of bytes) binary += String.fromCharCode(byte);
22327
+ return btoa(binary);
22328
+ };
22329
+ var importCache = /* @__PURE__ */ new Map();
22330
+ var importPublicKey = (publicKey) => {
22331
+ let imported = importCache.get(publicKey);
22332
+ if (!imported) {
22333
+ imported = crypto.subtle.importKey(
22334
+ "spki",
22335
+ fromBase64(publicKey),
22336
+ { name: "RSA-OAEP", hash: "SHA-256" },
22337
+ false,
22338
+ ["encrypt"]
22339
+ );
22340
+ importCache.set(publicKey, imported);
22341
+ }
22342
+ return imported;
22343
+ };
22344
+ var activeSealingKey = DEFAULT_SEALING_KEY;
22345
+ var sealProviderKey = async (providerApiKey, puckApiKey) => {
22346
+ const sealingKey = activeSealingKey;
22347
+ if (typeof crypto === "undefined" || !crypto.subtle) {
22348
+ throw new Error(
22349
+ "BYOK requires the WebCrypto API (Node 18+ or an edge runtime) to encrypt the provider key"
22350
+ );
22351
+ }
22352
+ const encoder2 = new TextEncoder();
22353
+ const plaintext = encoder2.encode(providerApiKey);
22354
+ if (plaintext.length > MAX_PLAINTEXT_BYTES) {
22355
+ throw new Error(
22356
+ `Provider API key is too long to seal (${plaintext.length} bytes, max ${MAX_PLAINTEXT_BYTES})`
22357
+ );
22358
+ }
22359
+ const ciphertext = await crypto.subtle.encrypt(
22360
+ { name: "RSA-OAEP", label: encoder2.encode(puckApiKey) },
22361
+ await importPublicKey(sealingKey.publicKey),
22362
+ plaintext
22363
+ );
22364
+ return `v1.${sealingKey.kid}.${toBase64(new Uint8Array(ciphertext))}`;
22365
+ };
22366
+
22161
22367
  // src/lib/get-api-key.ts
22162
22368
  init_react_import();
22163
22369
  var getApiKey = () => process.env.PUCK_API_KEY;
@@ -22178,16 +22384,16 @@ var processUserTool = async ({
22178
22384
  }
22179
22385
  const responses = [];
22180
22386
  for (let i = 0; i < requestTools.length; i++) {
22181
- const { name: name21, input } = requestTools[i];
22182
- const tool2 = tools?.[name21];
22387
+ const { name: name23, input } = requestTools[i];
22388
+ const tool2 = tools?.[name23];
22183
22389
  if (!tool2) {
22184
- throw new Error(`An unknown tool was called: ${name21}`);
22390
+ throw new Error(`An unknown tool was called: ${name23}`);
22185
22391
  }
22186
22392
  if (!input) {
22187
22393
  throw new Error(`Input was not present in tool call: ${toolCallId}`);
22188
22394
  }
22189
22395
  const output = await tool2.execute(input);
22190
- responses.push({ name: name21, input, output });
22396
+ responses.push({ name: name23, input, output });
22191
22397
  }
22192
22398
  const res = await fetch(`${host}/tool`, {
22193
22399
  headers: { "x-api-key": apiKey },
@@ -22226,9 +22432,35 @@ async function* iterateSSE(body) {
22226
22432
  }
22227
22433
  }
22228
22434
 
22435
+ // src/lib/fetch-with-retry.ts
22436
+ init_react_import();
22437
+ var MAX_RETRIES = 2;
22438
+ var MAX_RETRY_AFTER_SECONDS = 10;
22439
+ var sleep = (ms) => new Promise((resolve2) => setTimeout(resolve2, ms));
22440
+ async function fetchWithRetry(input, init) {
22441
+ for (let attempt = 0; ; attempt++) {
22442
+ const res = await fetch(input, init);
22443
+ if (res.ok || res.status !== 429 || attempt >= MAX_RETRIES) {
22444
+ return res;
22445
+ }
22446
+ const retryAfter = Number(res.headers.get("Retry-After"));
22447
+ if (!Number.isFinite(retryAfter) || retryAfter <= 0 || retryAfter > MAX_RETRY_AFTER_SECONDS) {
22448
+ return res;
22449
+ }
22450
+ await res.body?.cancel().catch(() => {
22451
+ });
22452
+ await sleep(retryAfter * 1e3);
22453
+ }
22454
+ }
22455
+
22229
22456
  // src/lib/cloud-api.ts
22230
22457
  var DEFAULT_API_VERSION = "v2";
22231
- var cloudApi = async (path, body, options = {}, onChunk) => {
22458
+ var DEFAULT_V2_MODELS = {
22459
+ assembly: "openai/gpt-5.4-mini",
22460
+ design: "openai/gpt-5.6-luna"
22461
+ };
22462
+ var CLOUD_CLIENT_VERSION = true ? "0.8.0" : "unknown";
22463
+ var cloudApi = async (path, body, options = {}, onChunk, forwardHeaders) => {
22232
22464
  const {
22233
22465
  ai = {},
22234
22466
  apiKey = getApiKey(),
@@ -22240,14 +22472,31 @@ var cloudApi = async (path, body, options = {}, onChunk) => {
22240
22472
  "No Puck API key specified. Set the PUCK_API_KEY environment variable, or provide one to the function"
22241
22473
  );
22242
22474
  }
22243
- const { context, tools = {} } = ai;
22244
- const res = await fetch(`${host}/${path}`, {
22245
- headers: { "x-api-key": apiKey, "puck-api-version": apiVersion },
22475
+ const { context, tools = {}, designMode, providerOptions } = ai;
22476
+ const bodyMode = "mode" in body ? body.mode : void 0;
22477
+ const mode = bodyMode === "design" || bodyMode === void 0 && ai.mode === "design" ? "design" : "assembly";
22478
+ const model = ai.model ?? (apiVersion === DEFAULT_API_VERSION ? DEFAULT_V2_MODELS[mode] : void 0);
22479
+ const providerApiKey = ai.model || designMode?.model ? ai.providerApiKey ?? process.env.OPENAI_API_KEY : void 0;
22480
+ const sealedProviderKey = providerApiKey ? await sealProviderKey(providerApiKey, apiKey) : void 0;
22481
+ const res = await fetchWithRetry(`${host}/${path}`, {
22482
+ headers: {
22483
+ "x-api-key": apiKey,
22484
+ "puck-api-version": apiVersion,
22485
+ "x-puck-cloud-client-version": CLOUD_CLIENT_VERSION,
22486
+ ...forwardHeaders?.pluginAiVersion ? { "x-puck-plugin-ai-version": forwardHeaders.pluginAiVersion } : {},
22487
+ ...sealedProviderKey ? { "x-puck-provider-key": sealedProviderKey } : {}
22488
+ },
22246
22489
  method: "post",
22247
22490
  body: JSON.stringify({
22248
22491
  ...body,
22249
22492
  context,
22250
- tools: prepareUserTools(tools)
22493
+ tools: prepareUserTools(tools),
22494
+ ...designMode ? {
22495
+ designMode
22496
+ } : {},
22497
+ // "byok" is the historical wire slot for the model request; the
22498
+ // platform bills it Puck-hosted when no key header accompanies it.
22499
+ ...model || providerOptions ? { byok: { model, providerOptions } } : {}
22251
22500
  })
22252
22501
  });
22253
22502
  if (!res.body) {
@@ -22262,6 +22511,9 @@ var cloudApi = async (path, body, options = {}, onChunk) => {
22262
22511
  if (chunk.type === "data-user-tool") {
22263
22512
  await processUserTool({ data: chunk.data, tools, options });
22264
22513
  } else {
22514
+ if (chunk.type === "data-version-notice") {
22515
+ console.warn(chunk.data.message);
22516
+ }
22265
22517
  onChunk(chunk);
22266
22518
  }
22267
22519
  }
@@ -22269,12 +22521,18 @@ var cloudApi = async (path, body, options = {}, onChunk) => {
22269
22521
  };
22270
22522
 
22271
22523
  // src/api/chat.ts
22272
- function chat({ chatId, messages, config: config2, pageData }, options = {}) {
22524
+ var handleStreamError = (error48) => {
22525
+ console.error(error48);
22526
+ return error48 instanceof Error ? error48.message : "An error occurred.";
22527
+ };
22528
+ function chatPrivate({ chatId, messages, config: config2, pageData, mode }, options = {}, forwardHeaders) {
22529
+ const resolvedMode = mode ?? options?.ai?.mode;
22273
22530
  const stream = createUIMessageStream({
22531
+ onError: handleStreamError,
22274
22532
  execute: async ({ writer }) => {
22275
22533
  await cloudApi(
22276
22534
  "chat",
22277
- { chatId, config: config2, messages, pageData },
22535
+ { chatId, config: config2, messages, pageData, mode: resolvedMode },
22278
22536
  options,
22279
22537
  (chunk) => {
22280
22538
  if (chunk.type === "data-finish") {
@@ -22282,7 +22540,30 @@ function chat({ chatId, messages, config: config2, pageData }, options = {}) {
22282
22540
  } else {
22283
22541
  writer.write(chunk);
22284
22542
  }
22285
- }
22543
+ },
22544
+ forwardHeaders
22545
+ );
22546
+ }
22547
+ });
22548
+ return createUIMessageStreamResponse({ stream });
22549
+ }
22550
+ function chat({ chatId, messages, config: config2, pageData }, options = {}, forwardHeaders) {
22551
+ const resolvedMode = options?.ai?.mode;
22552
+ const stream = createUIMessageStream({
22553
+ onError: handleStreamError,
22554
+ execute: async ({ writer }) => {
22555
+ await cloudApi(
22556
+ "chat",
22557
+ { chatId, config: config2, messages, pageData, mode: resolvedMode },
22558
+ options,
22559
+ (chunk) => {
22560
+ if (chunk.type === "data-finish") {
22561
+ options.ai?.onFinish?.(chunk.data);
22562
+ } else {
22563
+ writer.write(chunk);
22564
+ }
22565
+ },
22566
+ forwardHeaders
22286
22567
  );
22287
22568
  }
22288
22569
  });
@@ -22297,21 +22578,40 @@ async function generate({
22297
22578
  pageData,
22298
22579
  context,
22299
22580
  tools,
22581
+ mode,
22582
+ designMode,
22300
22583
  apiKey,
22301
22584
  host,
22302
- onFinish
22585
+ onFinish,
22586
+ model,
22587
+ providerApiKey,
22588
+ providerOptions
22303
22589
  }) {
22304
22590
  let result = null;
22305
- const options = { ai: { context, tools }, apiKey, host };
22306
- await cloudApi("generate", { prompt, config: config2, pageData }, options, (chunk) => {
22307
- if (chunk.type === "data-page") {
22308
- result = chunk.data;
22309
- } else if (chunk.type === "data-finish") {
22310
- onFinish?.(chunk.data);
22311
- } else if (chunk.type === "error") {
22312
- throw new Error(chunk.errorText);
22313
- }
22314
- });
22591
+ const options = {
22592
+ ai: { context, tools, designMode, model, providerApiKey, providerOptions },
22593
+ apiKey,
22594
+ host
22595
+ };
22596
+ try {
22597
+ await cloudApi(
22598
+ "generate",
22599
+ { prompt, config: config2, pageData, mode },
22600
+ options,
22601
+ (chunk) => {
22602
+ if (chunk.type === "data-page") {
22603
+ result = chunk.data;
22604
+ } else if (chunk.type === "data-finish") {
22605
+ onFinish?.(chunk.data);
22606
+ } else if (chunk.type === "error") {
22607
+ throw new Error(chunk.errorText);
22608
+ }
22609
+ }
22610
+ );
22611
+ } catch (error48) {
22612
+ console.error(error48);
22613
+ throw error48;
22614
+ }
22315
22615
  return result;
22316
22616
  }
22317
22617
 
@@ -22480,7 +22780,9 @@ var routeRegistry = [
22480
22780
  {
22481
22781
  pattern: "/api/puck/chat",
22482
22782
  methods: {
22483
- POST: ({ body }, options) => chat(body, options)
22783
+ POST: ({ body, headers }, options) => chatPrivate(body, options, {
22784
+ pluginAiVersion: headers.get("x-puck-plugin-ai-version")
22785
+ })
22484
22786
  }
22485
22787
  }
22486
22788
  ];