@mastra/ai-sdk 0.0.0-fix-11329-windows-path-20251222155941 → 0.0.0-fix-local-pkg-cwd-20251224015404

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.cjs CHANGED
@@ -228,7 +228,11 @@ function filter(obj) {
228
228
  }
229
229
  function secureJsonParse(text2) {
230
230
  const { stackTraceLimit } = Error;
231
- Error.stackTraceLimit = 0;
231
+ try {
232
+ Error.stackTraceLimit = 0;
233
+ } catch (e) {
234
+ return _parse(text2);
235
+ }
232
236
  try {
233
237
  return _parse(text2);
234
238
  } finally {
@@ -353,11 +357,11 @@ function parseAnyDef() {
353
357
  return {};
354
358
  }
355
359
  function parseArrayDef(def, refs) {
356
- var _a17, _b, _c;
360
+ var _a16, _b, _c;
357
361
  const res = {
358
362
  type: "array"
359
363
  };
360
- if (((_a17 = def.type) == null ? void 0 : _a17._def) && ((_c = (_b = def.type) == null ? void 0 : _b._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
364
+ if (((_a16 = def.type) == null ? void 0 : _a16._def) && ((_c = (_b = def.type) == null ? void 0 : _b._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
361
365
  res.items = parseDef(def.type._def, {
362
366
  ...refs,
363
367
  currentPath: [...refs.currentPath, "items"]
@@ -716,8 +720,8 @@ function escapeNonAlphaNumeric(source) {
716
720
  return result;
717
721
  }
718
722
  function addFormat(schema, value, message, refs) {
719
- var _a17;
720
- if (schema.format || ((_a17 = schema.anyOf) == null ? void 0 : _a17.some((x) => x.format))) {
723
+ var _a16;
724
+ if (schema.format || ((_a16 = schema.anyOf) == null ? void 0 : _a16.some((x) => x.format))) {
721
725
  if (!schema.anyOf) {
722
726
  schema.anyOf = [];
723
727
  }
@@ -736,8 +740,8 @@ function addFormat(schema, value, message, refs) {
736
740
  }
737
741
  }
738
742
  function addPattern(schema, regex, message, refs) {
739
- var _a17;
740
- if (schema.pattern || ((_a17 = schema.allOf) == null ? void 0 : _a17.some((x) => x.pattern))) {
743
+ var _a16;
744
+ if (schema.pattern || ((_a16 = schema.allOf) == null ? void 0 : _a16.some((x) => x.pattern))) {
741
745
  if (!schema.allOf) {
742
746
  schema.allOf = [];
743
747
  }
@@ -756,7 +760,7 @@ function addPattern(schema, regex, message, refs) {
756
760
  }
757
761
  }
758
762
  function stringifyRegExpWithFlags(regex, refs) {
759
- var _a17;
763
+ var _a16;
760
764
  if (!refs.applyRegexFlags || !regex.flags) {
761
765
  return regex.source;
762
766
  }
@@ -786,7 +790,7 @@ function stringifyRegExpWithFlags(regex, refs) {
786
790
  pattern += source[i];
787
791
  pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
788
792
  inCharRange = false;
789
- } else if (source[i + 1] === "-" && ((_a17 = source[i + 2]) == null ? void 0 : _a17.match(/[a-z]/))) {
793
+ } else if (source[i + 1] === "-" && ((_a16 = source[i + 2]) == null ? void 0 : _a16.match(/[a-z]/))) {
790
794
  pattern += source[i];
791
795
  inCharRange = true;
792
796
  } else {
@@ -828,13 +832,13 @@ function stringifyRegExpWithFlags(regex, refs) {
828
832
  return pattern;
829
833
  }
830
834
  function parseRecordDef(def, refs) {
831
- var _a17, _b, _c, _d, _e, _f;
835
+ var _a16, _b, _c, _d, _e, _f;
832
836
  const schema = {
833
837
  type: "object",
834
- additionalProperties: (_a17 = parseDef(def.valueType._def, {
838
+ additionalProperties: (_a16 = parseDef(def.valueType._def, {
835
839
  ...refs,
836
840
  currentPath: [...refs.currentPath, "additionalProperties"]
837
- })) != null ? _a17 : refs.allowedAdditionalProperties
841
+ })) != null ? _a16 : refs.allowedAdditionalProperties
838
842
  };
839
843
  if (((_b = def.keyType) == null ? void 0 : _b._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
840
844
  const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
@@ -1091,8 +1095,8 @@ function safeIsOptional(schema) {
1091
1095
  }
1092
1096
  }
1093
1097
  var parseOptionalDef = (def, refs) => {
1094
- var _a17;
1095
- if (refs.currentPath.toString() === ((_a17 = refs.propertyPath) == null ? void 0 : _a17.toString())) {
1098
+ var _a16;
1099
+ if (refs.currentPath.toString() === ((_a16 = refs.propertyPath) == null ? void 0 : _a16.toString())) {
1096
1100
  return parseDef(def.innerType._def, refs);
1097
1101
  }
1098
1102
  const innerSchema = parseDef(def.innerType._def, {
@@ -1262,10 +1266,10 @@ var selectParser = (def, typeName, refs) => {
1262
1266
  }
1263
1267
  };
1264
1268
  function parseDef(def, refs, forceResolution = false) {
1265
- var _a17;
1269
+ var _a16;
1266
1270
  const seenItem = refs.seen.get(def);
1267
1271
  if (refs.override) {
1268
- const overrideResult = (_a17 = refs.override) == null ? void 0 : _a17.call(
1272
+ const overrideResult = (_a16 = refs.override) == null ? void 0 : _a16.call(
1269
1273
  refs,
1270
1274
  def,
1271
1275
  refs,
@@ -1331,11 +1335,11 @@ var getRefs = (options) => {
1331
1335
  currentPath,
1332
1336
  propertyPath: void 0,
1333
1337
  seen: new Map(
1334
- Object.entries(_options.definitions).map(([name17, def]) => [
1338
+ Object.entries(_options.definitions).map(([name16, def]) => [
1335
1339
  def._def,
1336
1340
  {
1337
1341
  def: def._def,
1338
- path: [..._options.basePath, _options.definitionPath, name17],
1342
+ path: [..._options.basePath, _options.definitionPath, name16],
1339
1343
  // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
1340
1344
  jsonSchema: void 0
1341
1345
  }
@@ -1344,7 +1348,7 @@ var getRefs = (options) => {
1344
1348
  };
1345
1349
  };
1346
1350
  var zodToJsonSchema = (schema, options) => {
1347
- var _a17;
1351
+ var _a16;
1348
1352
  const refs = getRefs(options);
1349
1353
  let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
1350
1354
  (acc, [name23, schema2]) => {
@@ -1363,31 +1367,31 @@ var zodToJsonSchema = (schema, options) => {
1363
1367
  },
1364
1368
  {}
1365
1369
  ) : void 0;
1366
- const name17 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
1367
- const main = (_a17 = parseDef(
1370
+ const name16 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
1371
+ const main = (_a16 = parseDef(
1368
1372
  schema._def,
1369
- name17 === void 0 ? refs : {
1373
+ name16 === void 0 ? refs : {
1370
1374
  ...refs,
1371
- currentPath: [...refs.basePath, refs.definitionPath, name17]
1375
+ currentPath: [...refs.basePath, refs.definitionPath, name16]
1372
1376
  },
1373
1377
  false
1374
- )) != null ? _a17 : parseAnyDef();
1378
+ )) != null ? _a16 : parseAnyDef();
1375
1379
  const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
1376
1380
  if (title !== void 0) {
1377
1381
  main.title = title;
1378
1382
  }
1379
- const combined = name17 === void 0 ? definitions ? {
1383
+ const combined = name16 === void 0 ? definitions ? {
1380
1384
  ...main,
1381
1385
  [refs.definitionPath]: definitions
1382
1386
  } : main : {
1383
1387
  $ref: [
1384
1388
  ...refs.$refStrategy === "relative" ? [] : refs.basePath,
1385
1389
  refs.definitionPath,
1386
- name17
1390
+ name16
1387
1391
  ].join("/"),
1388
1392
  [refs.definitionPath]: {
1389
1393
  ...definitions,
1390
- [name17]: main
1394
+ [name16]: main
1391
1395
  }
1392
1396
  };
1393
1397
  combined.$schema = "http://json-schema.org/draft-07/schema#";
@@ -1395,8 +1399,8 @@ var zodToJsonSchema = (schema, options) => {
1395
1399
  };
1396
1400
  var zod_to_json_schema_default = zodToJsonSchema;
1397
1401
  function zod3Schema(zodSchema2, options) {
1398
- var _a17;
1399
- const useReferences = (_a17 = void 0 ) != null ? _a17 : false;
1402
+ var _a16;
1403
+ const useReferences = (_a16 = void 0 ) != null ? _a16 : false;
1400
1404
  return jsonSchema(
1401
1405
  // defer json schema creation to avoid unnecessary computation when only validation is needed
1402
1406
  () => zod_to_json_schema_default(zodSchema2, {
@@ -1411,8 +1415,8 @@ function zod3Schema(zodSchema2, options) {
1411
1415
  );
1412
1416
  }
1413
1417
  function zod4Schema(zodSchema2, options) {
1414
- var _a17;
1415
- const useReferences = (_a17 = void 0 ) != null ? _a17 : false;
1418
+ var _a16;
1419
+ const useReferences = (_a16 = void 0 ) != null ? _a16 : false;
1416
1420
  return jsonSchema(
1417
1421
  // defer json schema creation to avoid unnecessary computation when only validation is needed
1418
1422
  () => z4__namespace.toJSONSchema(zodSchema2, {
@@ -1467,13 +1471,13 @@ function asSchema(schema) {
1467
1471
  }
1468
1472
  var __defProp = Object.defineProperty;
1469
1473
  var __export = (target, all) => {
1470
- for (var name17 in all)
1471
- __defProp(target, name17, { get: all[name17], enumerable: true });
1474
+ for (var name16 in all)
1475
+ __defProp(target, name16, { get: all[name16], enumerable: true });
1472
1476
  };
1473
- var name72 = "AI_NoObjectGeneratedError";
1474
- var marker72 = `vercel.ai.error.${name72}`;
1475
- var symbol72 = Symbol.for(marker72);
1476
- var _a72;
1477
+ var name62 = "AI_NoObjectGeneratedError";
1478
+ var marker62 = `vercel.ai.error.${name62}`;
1479
+ var symbol62 = Symbol.for(marker62);
1480
+ var _a62;
1477
1481
  var NoObjectGeneratedError = class extends AISDKError {
1478
1482
  constructor({
1479
1483
  message = "No object generated.",
@@ -1483,18 +1487,18 @@ var NoObjectGeneratedError = class extends AISDKError {
1483
1487
  usage,
1484
1488
  finishReason
1485
1489
  }) {
1486
- super({ name: name72, message, cause });
1487
- this[_a72] = true;
1490
+ super({ name: name62, message, cause });
1491
+ this[_a62] = true;
1488
1492
  this.text = text2;
1489
1493
  this.response = response;
1490
1494
  this.usage = usage;
1491
1495
  this.finishReason = finishReason;
1492
1496
  }
1493
1497
  static isInstance(error) {
1494
- return AISDKError.hasMarker(error, marker72);
1498
+ return AISDKError.hasMarker(error, marker62);
1495
1499
  }
1496
1500
  };
1497
- _a72 = symbol72;
1501
+ _a62 = symbol62;
1498
1502
  var dataContentSchema = z4.z.union([
1499
1503
  z4.z.string(),
1500
1504
  z4.z.instanceof(Uint8Array),
@@ -1502,8 +1506,8 @@ var dataContentSchema = z4.z.union([
1502
1506
  z4.z.custom(
1503
1507
  // Buffer might not be available in some environments such as CloudFlare:
1504
1508
  (value) => {
1505
- var _a17, _b;
1506
- return (_b = (_a17 = globalThis.Buffer) == null ? void 0 : _a17.isBuffer(value)) != null ? _b : false;
1509
+ var _a16, _b;
1510
+ return (_b = (_a16 = globalThis.Buffer) == null ? void 0 : _a16.isBuffer(value)) != null ? _b : false;
1507
1511
  },
1508
1512
  { message: "Must be a Buffer" }
1509
1513
  )
@@ -2092,7 +2096,7 @@ function processUIMessageStream({
2092
2096
  new TransformStream({
2093
2097
  async transform(chunk, controller) {
2094
2098
  await runUpdateMessageJob(async ({ state, write }) => {
2095
- var _a17, _b, _c, _d;
2099
+ var _a16, _b, _c, _d;
2096
2100
  function getToolInvocation(toolCallId) {
2097
2101
  const toolInvocations = state.message.parts.filter(isToolUIPart);
2098
2102
  const toolInvocation = toolInvocations.find(
@@ -2120,7 +2124,7 @@ function processUIMessageStream({
2120
2124
  return toolInvocation;
2121
2125
  }
2122
2126
  function updateToolPart(options) {
2123
- var _a18;
2127
+ var _a17;
2124
2128
  const part = state.message.parts.find(
2125
2129
  (part2) => isToolUIPart(part2) && part2.toolCallId === options.toolCallId
2126
2130
  );
@@ -2133,7 +2137,7 @@ function processUIMessageStream({
2133
2137
  anyPart.errorText = anyOptions.errorText;
2134
2138
  anyPart.rawInput = anyOptions.rawInput;
2135
2139
  anyPart.preliminary = anyOptions.preliminary;
2136
- anyPart.providerExecuted = (_a18 = anyOptions.providerExecuted) != null ? _a18 : part.providerExecuted;
2140
+ anyPart.providerExecuted = (_a17 = anyOptions.providerExecuted) != null ? _a17 : part.providerExecuted;
2137
2141
  if (anyOptions.providerMetadata != null && part.state === "input-available") {
2138
2142
  part.callProviderMetadata = anyOptions.providerMetadata;
2139
2143
  }
@@ -2153,7 +2157,7 @@ function processUIMessageStream({
2153
2157
  }
2154
2158
  }
2155
2159
  function updateDynamicToolPart(options) {
2156
- var _a18;
2160
+ var _a17, _b2;
2157
2161
  const part = state.message.parts.find(
2158
2162
  (part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId
2159
2163
  );
@@ -2165,8 +2169,9 @@ function processUIMessageStream({
2165
2169
  anyPart.input = anyOptions.input;
2166
2170
  anyPart.output = anyOptions.output;
2167
2171
  anyPart.errorText = anyOptions.errorText;
2168
- anyPart.rawInput = (_a18 = anyOptions.rawInput) != null ? _a18 : anyPart.rawInput;
2172
+ anyPart.rawInput = (_a17 = anyOptions.rawInput) != null ? _a17 : anyPart.rawInput;
2169
2173
  anyPart.preliminary = anyOptions.preliminary;
2174
+ anyPart.providerExecuted = (_b2 = anyOptions.providerExecuted) != null ? _b2 : part.providerExecuted;
2170
2175
  if (anyOptions.providerMetadata != null && part.state === "input-available") {
2171
2176
  part.callProviderMetadata = anyOptions.providerMetadata;
2172
2177
  }
@@ -2180,6 +2185,7 @@ function processUIMessageStream({
2180
2185
  output: anyOptions.output,
2181
2186
  errorText: anyOptions.errorText,
2182
2187
  preliminary: anyOptions.preliminary,
2188
+ providerExecuted: anyOptions.providerExecuted,
2183
2189
  ...anyOptions.providerMetadata != null ? { callProviderMetadata: anyOptions.providerMetadata } : {}
2184
2190
  });
2185
2191
  }
@@ -2212,7 +2218,7 @@ function processUIMessageStream({
2212
2218
  case "text-delta": {
2213
2219
  const textPart = state.activeTextParts[chunk.id];
2214
2220
  textPart.text += chunk.delta;
2215
- textPart.providerMetadata = (_a17 = chunk.providerMetadata) != null ? _a17 : textPart.providerMetadata;
2221
+ textPart.providerMetadata = (_a16 = chunk.providerMetadata) != null ? _a16 : textPart.providerMetadata;
2216
2222
  write();
2217
2223
  break;
2218
2224
  }
@@ -2296,7 +2302,8 @@ function processUIMessageStream({
2296
2302
  toolCallId: chunk.toolCallId,
2297
2303
  toolName: chunk.toolName,
2298
2304
  state: "input-streaming",
2299
- input: void 0
2305
+ input: void 0,
2306
+ providerExecuted: chunk.providerExecuted
2300
2307
  });
2301
2308
  } else {
2302
2309
  updateToolPart({
@@ -2341,6 +2348,7 @@ function processUIMessageStream({
2341
2348
  toolName: chunk.toolName,
2342
2349
  state: "input-available",
2343
2350
  input: chunk.input,
2351
+ providerExecuted: chunk.providerExecuted,
2344
2352
  providerMetadata: chunk.providerMetadata
2345
2353
  });
2346
2354
  } else {
@@ -2369,6 +2377,7 @@ function processUIMessageStream({
2369
2377
  state: "output-error",
2370
2378
  input: chunk.input,
2371
2379
  errorText: chunk.errorText,
2380
+ providerExecuted: chunk.providerExecuted,
2372
2381
  providerMetadata: chunk.providerMetadata
2373
2382
  });
2374
2383
  } else {
@@ -2424,7 +2433,8 @@ function processUIMessageStream({
2424
2433
  toolName: toolInvocation.toolName,
2425
2434
  state: "output-error",
2426
2435
  input: toolInvocation.input,
2427
- errorText: chunk.errorText
2436
+ errorText: chunk.errorText,
2437
+ providerExecuted: chunk.providerExecuted
2428
2438
  });
2429
2439
  } else {
2430
2440
  const toolInvocation = getToolInvocation(chunk.toolCallId);
@@ -2434,7 +2444,8 @@ function processUIMessageStream({
2434
2444
  state: "output-error",
2435
2445
  input: toolInvocation.input,
2436
2446
  rawInput: toolInvocation.rawInput,
2437
- errorText: chunk.errorText
2447
+ errorText: chunk.errorText,
2448
+ providerExecuted: chunk.providerExecuted
2438
2449
  });
2439
2450
  }
2440
2451
  write();
@@ -2460,6 +2471,9 @@ function processUIMessageStream({
2460
2471
  break;
2461
2472
  }
2462
2473
  case "finish": {
2474
+ if (chunk.finishReason != null) {
2475
+ state.finishReason = chunk.finishReason;
2476
+ }
2463
2477
  await updateMessageMetadata(chunk.messageMetadata);
2464
2478
  if (chunk.messageMetadata != null) {
2465
2479
  write();
@@ -2565,7 +2579,8 @@ function handleUIMessageStreamFinish({
2565
2579
  messages: [
2566
2580
  ...isContinuation ? originalMessages.slice(0, -1) : originalMessages,
2567
2581
  state.message
2568
- ]
2582
+ ],
2583
+ finishReason: state.finishReason
2569
2584
  });
2570
2585
  };
2571
2586
  return processUIMessageStream({
@@ -2672,7 +2687,7 @@ var wrapLanguageModel = ({
2672
2687
  modelId,
2673
2688
  providerId
2674
2689
  }) => {
2675
- return asArray(middlewareArg).reverse().reduce((wrappedModel, middleware) => {
2690
+ return [...asArray(middlewareArg)].reverse().reduce((wrappedModel, middleware) => {
2676
2691
  return doWrap({ model: wrappedModel, middleware, modelId, providerId });
2677
2692
  }, model);
2678
2693
  };
@@ -2689,7 +2704,7 @@ var doWrap = ({
2689
2704
  modelId,
2690
2705
  providerId
2691
2706
  }) => {
2692
- var _a17, _b, _c;
2707
+ var _a16, _b, _c;
2693
2708
  async function doTransform({
2694
2709
  params,
2695
2710
  type
@@ -2698,7 +2713,7 @@ var doWrap = ({
2698
2713
  }
2699
2714
  return {
2700
2715
  specificationVersion: "v2",
2701
- provider: (_a17 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a17 : model.provider,
2716
+ provider: (_a16 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a16 : model.provider,
2702
2717
  modelId: (_b = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b : model.modelId,
2703
2718
  supportedUrls: (_c = overrideSupportedUrls == null ? void 0 : overrideSupportedUrls({ model })) != null ? _c : model.supportedUrls,
2704
2719
  async doGenerate(params) {
@@ -2720,130 +2735,6 @@ var doWrap = ({
2720
2735
  }
2721
2736
  };
2722
2737
  };
2723
- var ClientOrServerImplementationSchema = z4.z.looseObject({
2724
- name: z4.z.string(),
2725
- version: z4.z.string()
2726
- });
2727
- var BaseParamsSchema = z4.z.looseObject({
2728
- _meta: z4.z.optional(z4.z.object({}).loose())
2729
- });
2730
- var ResultSchema = BaseParamsSchema;
2731
- var RequestSchema = z4.z.object({
2732
- method: z4.z.string(),
2733
- params: z4.z.optional(BaseParamsSchema)
2734
- });
2735
- var ServerCapabilitiesSchema = z4.z.looseObject({
2736
- experimental: z4.z.optional(z4.z.object({}).loose()),
2737
- logging: z4.z.optional(z4.z.object({}).loose()),
2738
- prompts: z4.z.optional(
2739
- z4.z.looseObject({
2740
- listChanged: z4.z.optional(z4.z.boolean())
2741
- })
2742
- ),
2743
- resources: z4.z.optional(
2744
- z4.z.looseObject({
2745
- subscribe: z4.z.optional(z4.z.boolean()),
2746
- listChanged: z4.z.optional(z4.z.boolean())
2747
- })
2748
- ),
2749
- tools: z4.z.optional(
2750
- z4.z.looseObject({
2751
- listChanged: z4.z.optional(z4.z.boolean())
2752
- })
2753
- )
2754
- });
2755
- ResultSchema.extend({
2756
- protocolVersion: z4.z.string(),
2757
- capabilities: ServerCapabilitiesSchema,
2758
- serverInfo: ClientOrServerImplementationSchema,
2759
- instructions: z4.z.optional(z4.z.string())
2760
- });
2761
- var PaginatedResultSchema = ResultSchema.extend({
2762
- nextCursor: z4.z.optional(z4.z.string())
2763
- });
2764
- var ToolSchema = z4.z.object({
2765
- name: z4.z.string(),
2766
- description: z4.z.optional(z4.z.string()),
2767
- inputSchema: z4.z.object({
2768
- type: z4.z.literal("object"),
2769
- properties: z4.z.optional(z4.z.object({}).loose())
2770
- }).loose()
2771
- }).loose();
2772
- PaginatedResultSchema.extend({
2773
- tools: z4.z.array(ToolSchema)
2774
- });
2775
- var TextContentSchema = z4.z.object({
2776
- type: z4.z.literal("text"),
2777
- text: z4.z.string()
2778
- }).loose();
2779
- var ImageContentSchema = z4.z.object({
2780
- type: z4.z.literal("image"),
2781
- data: z4.z.base64(),
2782
- mimeType: z4.z.string()
2783
- }).loose();
2784
- var ResourceContentsSchema = z4.z.object({
2785
- /**
2786
- * The URI of this resource.
2787
- */
2788
- uri: z4.z.string(),
2789
- /**
2790
- * The MIME type of this resource, if known.
2791
- */
2792
- mimeType: z4.z.optional(z4.z.string())
2793
- }).loose();
2794
- var TextResourceContentsSchema = ResourceContentsSchema.extend({
2795
- text: z4.z.string()
2796
- });
2797
- var BlobResourceContentsSchema = ResourceContentsSchema.extend({
2798
- blob: z4.z.base64()
2799
- });
2800
- var EmbeddedResourceSchema = z4.z.object({
2801
- type: z4.z.literal("resource"),
2802
- resource: z4.z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
2803
- }).loose();
2804
- ResultSchema.extend({
2805
- content: z4.z.array(
2806
- z4.z.union([TextContentSchema, ImageContentSchema, EmbeddedResourceSchema])
2807
- ),
2808
- isError: z4.z.boolean().default(false).optional()
2809
- }).or(
2810
- ResultSchema.extend({
2811
- toolResult: z4.z.unknown()
2812
- })
2813
- );
2814
- var JSONRPC_VERSION = "2.0";
2815
- var JSONRPCRequestSchema = z4.z.object({
2816
- jsonrpc: z4.z.literal(JSONRPC_VERSION),
2817
- id: z4.z.union([z4.z.string(), z4.z.number().int()])
2818
- }).merge(RequestSchema).strict();
2819
- var JSONRPCResponseSchema = z4.z.object({
2820
- jsonrpc: z4.z.literal(JSONRPC_VERSION),
2821
- id: z4.z.union([z4.z.string(), z4.z.number().int()]),
2822
- result: ResultSchema
2823
- }).strict();
2824
- var JSONRPCErrorSchema = z4.z.object({
2825
- jsonrpc: z4.z.literal(JSONRPC_VERSION),
2826
- id: z4.z.union([z4.z.string(), z4.z.number().int()]),
2827
- error: z4.z.object({
2828
- code: z4.z.number().int(),
2829
- message: z4.z.string(),
2830
- data: z4.z.optional(z4.z.unknown())
2831
- })
2832
- }).strict();
2833
- var JSONRPCNotificationSchema = z4.z.object({
2834
- jsonrpc: z4.z.literal(JSONRPC_VERSION)
2835
- }).merge(
2836
- z4.z.object({
2837
- method: z4.z.string(),
2838
- params: z4.z.optional(BaseParamsSchema)
2839
- })
2840
- ).strict();
2841
- z4.z.union([
2842
- JSONRPCRequestSchema,
2843
- JSONRPCNotificationSchema,
2844
- JSONRPCResponseSchema,
2845
- JSONRPCErrorSchema
2846
- ]);
2847
2738
  function createUIMessageStream({
2848
2739
  execute,
2849
2740
  onError = getErrorMessage2,