@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.js CHANGED
@@ -207,7 +207,11 @@ function filter(obj) {
207
207
  }
208
208
  function secureJsonParse(text2) {
209
209
  const { stackTraceLimit } = Error;
210
- Error.stackTraceLimit = 0;
210
+ try {
211
+ Error.stackTraceLimit = 0;
212
+ } catch (e) {
213
+ return _parse(text2);
214
+ }
211
215
  try {
212
216
  return _parse(text2);
213
217
  } finally {
@@ -332,11 +336,11 @@ function parseAnyDef() {
332
336
  return {};
333
337
  }
334
338
  function parseArrayDef(def, refs) {
335
- var _a17, _b, _c;
339
+ var _a16, _b, _c;
336
340
  const res = {
337
341
  type: "array"
338
342
  };
339
- if (((_a17 = def.type) == null ? void 0 : _a17._def) && ((_c = (_b = def.type) == null ? void 0 : _b._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
343
+ if (((_a16 = def.type) == null ? void 0 : _a16._def) && ((_c = (_b = def.type) == null ? void 0 : _b._def) == null ? void 0 : _c.typeName) !== ZodFirstPartyTypeKind.ZodAny) {
340
344
  res.items = parseDef(def.type._def, {
341
345
  ...refs,
342
346
  currentPath: [...refs.currentPath, "items"]
@@ -695,8 +699,8 @@ function escapeNonAlphaNumeric(source) {
695
699
  return result;
696
700
  }
697
701
  function addFormat(schema, value, message, refs) {
698
- var _a17;
699
- if (schema.format || ((_a17 = schema.anyOf) == null ? void 0 : _a17.some((x) => x.format))) {
702
+ var _a16;
703
+ if (schema.format || ((_a16 = schema.anyOf) == null ? void 0 : _a16.some((x) => x.format))) {
700
704
  if (!schema.anyOf) {
701
705
  schema.anyOf = [];
702
706
  }
@@ -715,8 +719,8 @@ function addFormat(schema, value, message, refs) {
715
719
  }
716
720
  }
717
721
  function addPattern(schema, regex, message, refs) {
718
- var _a17;
719
- if (schema.pattern || ((_a17 = schema.allOf) == null ? void 0 : _a17.some((x) => x.pattern))) {
722
+ var _a16;
723
+ if (schema.pattern || ((_a16 = schema.allOf) == null ? void 0 : _a16.some((x) => x.pattern))) {
720
724
  if (!schema.allOf) {
721
725
  schema.allOf = [];
722
726
  }
@@ -735,7 +739,7 @@ function addPattern(schema, regex, message, refs) {
735
739
  }
736
740
  }
737
741
  function stringifyRegExpWithFlags(regex, refs) {
738
- var _a17;
742
+ var _a16;
739
743
  if (!refs.applyRegexFlags || !regex.flags) {
740
744
  return regex.source;
741
745
  }
@@ -765,7 +769,7 @@ function stringifyRegExpWithFlags(regex, refs) {
765
769
  pattern += source[i];
766
770
  pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
767
771
  inCharRange = false;
768
- } else if (source[i + 1] === "-" && ((_a17 = source[i + 2]) == null ? void 0 : _a17.match(/[a-z]/))) {
772
+ } else if (source[i + 1] === "-" && ((_a16 = source[i + 2]) == null ? void 0 : _a16.match(/[a-z]/))) {
769
773
  pattern += source[i];
770
774
  inCharRange = true;
771
775
  } else {
@@ -807,13 +811,13 @@ function stringifyRegExpWithFlags(regex, refs) {
807
811
  return pattern;
808
812
  }
809
813
  function parseRecordDef(def, refs) {
810
- var _a17, _b, _c, _d, _e, _f;
814
+ var _a16, _b, _c, _d, _e, _f;
811
815
  const schema = {
812
816
  type: "object",
813
- additionalProperties: (_a17 = parseDef(def.valueType._def, {
817
+ additionalProperties: (_a16 = parseDef(def.valueType._def, {
814
818
  ...refs,
815
819
  currentPath: [...refs.currentPath, "additionalProperties"]
816
- })) != null ? _a17 : refs.allowedAdditionalProperties
820
+ })) != null ? _a16 : refs.allowedAdditionalProperties
817
821
  };
818
822
  if (((_b = def.keyType) == null ? void 0 : _b._def.typeName) === ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
819
823
  const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
@@ -1070,8 +1074,8 @@ function safeIsOptional(schema) {
1070
1074
  }
1071
1075
  }
1072
1076
  var parseOptionalDef = (def, refs) => {
1073
- var _a17;
1074
- if (refs.currentPath.toString() === ((_a17 = refs.propertyPath) == null ? void 0 : _a17.toString())) {
1077
+ var _a16;
1078
+ if (refs.currentPath.toString() === ((_a16 = refs.propertyPath) == null ? void 0 : _a16.toString())) {
1075
1079
  return parseDef(def.innerType._def, refs);
1076
1080
  }
1077
1081
  const innerSchema = parseDef(def.innerType._def, {
@@ -1241,10 +1245,10 @@ var selectParser = (def, typeName, refs) => {
1241
1245
  }
1242
1246
  };
1243
1247
  function parseDef(def, refs, forceResolution = false) {
1244
- var _a17;
1248
+ var _a16;
1245
1249
  const seenItem = refs.seen.get(def);
1246
1250
  if (refs.override) {
1247
- const overrideResult = (_a17 = refs.override) == null ? void 0 : _a17.call(
1251
+ const overrideResult = (_a16 = refs.override) == null ? void 0 : _a16.call(
1248
1252
  refs,
1249
1253
  def,
1250
1254
  refs,
@@ -1310,11 +1314,11 @@ var getRefs = (options) => {
1310
1314
  currentPath,
1311
1315
  propertyPath: void 0,
1312
1316
  seen: new Map(
1313
- Object.entries(_options.definitions).map(([name17, def]) => [
1317
+ Object.entries(_options.definitions).map(([name16, def]) => [
1314
1318
  def._def,
1315
1319
  {
1316
1320
  def: def._def,
1317
- path: [..._options.basePath, _options.definitionPath, name17],
1321
+ path: [..._options.basePath, _options.definitionPath, name16],
1318
1322
  // Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
1319
1323
  jsonSchema: void 0
1320
1324
  }
@@ -1323,7 +1327,7 @@ var getRefs = (options) => {
1323
1327
  };
1324
1328
  };
1325
1329
  var zodToJsonSchema = (schema, options) => {
1326
- var _a17;
1330
+ var _a16;
1327
1331
  const refs = getRefs(options);
1328
1332
  let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
1329
1333
  (acc, [name23, schema2]) => {
@@ -1342,31 +1346,31 @@ var zodToJsonSchema = (schema, options) => {
1342
1346
  },
1343
1347
  {}
1344
1348
  ) : void 0;
1345
- const name17 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
1346
- const main = (_a17 = parseDef(
1349
+ const name16 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
1350
+ const main = (_a16 = parseDef(
1347
1351
  schema._def,
1348
- name17 === void 0 ? refs : {
1352
+ name16 === void 0 ? refs : {
1349
1353
  ...refs,
1350
- currentPath: [...refs.basePath, refs.definitionPath, name17]
1354
+ currentPath: [...refs.basePath, refs.definitionPath, name16]
1351
1355
  },
1352
1356
  false
1353
- )) != null ? _a17 : parseAnyDef();
1357
+ )) != null ? _a16 : parseAnyDef();
1354
1358
  const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
1355
1359
  if (title !== void 0) {
1356
1360
  main.title = title;
1357
1361
  }
1358
- const combined = name17 === void 0 ? definitions ? {
1362
+ const combined = name16 === void 0 ? definitions ? {
1359
1363
  ...main,
1360
1364
  [refs.definitionPath]: definitions
1361
1365
  } : main : {
1362
1366
  $ref: [
1363
1367
  ...refs.$refStrategy === "relative" ? [] : refs.basePath,
1364
1368
  refs.definitionPath,
1365
- name17
1369
+ name16
1366
1370
  ].join("/"),
1367
1371
  [refs.definitionPath]: {
1368
1372
  ...definitions,
1369
- [name17]: main
1373
+ [name16]: main
1370
1374
  }
1371
1375
  };
1372
1376
  combined.$schema = "http://json-schema.org/draft-07/schema#";
@@ -1374,8 +1378,8 @@ var zodToJsonSchema = (schema, options) => {
1374
1378
  };
1375
1379
  var zod_to_json_schema_default = zodToJsonSchema;
1376
1380
  function zod3Schema(zodSchema2, options) {
1377
- var _a17;
1378
- const useReferences = (_a17 = void 0 ) != null ? _a17 : false;
1381
+ var _a16;
1382
+ const useReferences = (_a16 = void 0 ) != null ? _a16 : false;
1379
1383
  return jsonSchema(
1380
1384
  // defer json schema creation to avoid unnecessary computation when only validation is needed
1381
1385
  () => zod_to_json_schema_default(zodSchema2, {
@@ -1390,8 +1394,8 @@ function zod3Schema(zodSchema2, options) {
1390
1394
  );
1391
1395
  }
1392
1396
  function zod4Schema(zodSchema2, options) {
1393
- var _a17;
1394
- const useReferences = (_a17 = void 0 ) != null ? _a17 : false;
1397
+ var _a16;
1398
+ const useReferences = (_a16 = void 0 ) != null ? _a16 : false;
1395
1399
  return jsonSchema(
1396
1400
  // defer json schema creation to avoid unnecessary computation when only validation is needed
1397
1401
  () => z4.toJSONSchema(zodSchema2, {
@@ -1446,13 +1450,13 @@ function asSchema(schema) {
1446
1450
  }
1447
1451
  var __defProp = Object.defineProperty;
1448
1452
  var __export = (target, all) => {
1449
- for (var name17 in all)
1450
- __defProp(target, name17, { get: all[name17], enumerable: true });
1453
+ for (var name16 in all)
1454
+ __defProp(target, name16, { get: all[name16], enumerable: true });
1451
1455
  };
1452
- var name72 = "AI_NoObjectGeneratedError";
1453
- var marker72 = `vercel.ai.error.${name72}`;
1454
- var symbol72 = Symbol.for(marker72);
1455
- var _a72;
1456
+ var name62 = "AI_NoObjectGeneratedError";
1457
+ var marker62 = `vercel.ai.error.${name62}`;
1458
+ var symbol62 = Symbol.for(marker62);
1459
+ var _a62;
1456
1460
  var NoObjectGeneratedError = class extends AISDKError {
1457
1461
  constructor({
1458
1462
  message = "No object generated.",
@@ -1462,18 +1466,18 @@ var NoObjectGeneratedError = class extends AISDKError {
1462
1466
  usage,
1463
1467
  finishReason
1464
1468
  }) {
1465
- super({ name: name72, message, cause });
1466
- this[_a72] = true;
1469
+ super({ name: name62, message, cause });
1470
+ this[_a62] = true;
1467
1471
  this.text = text2;
1468
1472
  this.response = response;
1469
1473
  this.usage = usage;
1470
1474
  this.finishReason = finishReason;
1471
1475
  }
1472
1476
  static isInstance(error) {
1473
- return AISDKError.hasMarker(error, marker72);
1477
+ return AISDKError.hasMarker(error, marker62);
1474
1478
  }
1475
1479
  };
1476
- _a72 = symbol72;
1480
+ _a62 = symbol62;
1477
1481
  var dataContentSchema = z.union([
1478
1482
  z.string(),
1479
1483
  z.instanceof(Uint8Array),
@@ -1481,8 +1485,8 @@ var dataContentSchema = z.union([
1481
1485
  z.custom(
1482
1486
  // Buffer might not be available in some environments such as CloudFlare:
1483
1487
  (value) => {
1484
- var _a17, _b;
1485
- return (_b = (_a17 = globalThis.Buffer) == null ? void 0 : _a17.isBuffer(value)) != null ? _b : false;
1488
+ var _a16, _b;
1489
+ return (_b = (_a16 = globalThis.Buffer) == null ? void 0 : _a16.isBuffer(value)) != null ? _b : false;
1486
1490
  },
1487
1491
  { message: "Must be a Buffer" }
1488
1492
  )
@@ -2071,7 +2075,7 @@ function processUIMessageStream({
2071
2075
  new TransformStream({
2072
2076
  async transform(chunk, controller) {
2073
2077
  await runUpdateMessageJob(async ({ state, write }) => {
2074
- var _a17, _b, _c, _d;
2078
+ var _a16, _b, _c, _d;
2075
2079
  function getToolInvocation(toolCallId) {
2076
2080
  const toolInvocations = state.message.parts.filter(isToolUIPart);
2077
2081
  const toolInvocation = toolInvocations.find(
@@ -2099,7 +2103,7 @@ function processUIMessageStream({
2099
2103
  return toolInvocation;
2100
2104
  }
2101
2105
  function updateToolPart(options) {
2102
- var _a18;
2106
+ var _a17;
2103
2107
  const part = state.message.parts.find(
2104
2108
  (part2) => isToolUIPart(part2) && part2.toolCallId === options.toolCallId
2105
2109
  );
@@ -2112,7 +2116,7 @@ function processUIMessageStream({
2112
2116
  anyPart.errorText = anyOptions.errorText;
2113
2117
  anyPart.rawInput = anyOptions.rawInput;
2114
2118
  anyPart.preliminary = anyOptions.preliminary;
2115
- anyPart.providerExecuted = (_a18 = anyOptions.providerExecuted) != null ? _a18 : part.providerExecuted;
2119
+ anyPart.providerExecuted = (_a17 = anyOptions.providerExecuted) != null ? _a17 : part.providerExecuted;
2116
2120
  if (anyOptions.providerMetadata != null && part.state === "input-available") {
2117
2121
  part.callProviderMetadata = anyOptions.providerMetadata;
2118
2122
  }
@@ -2132,7 +2136,7 @@ function processUIMessageStream({
2132
2136
  }
2133
2137
  }
2134
2138
  function updateDynamicToolPart(options) {
2135
- var _a18;
2139
+ var _a17, _b2;
2136
2140
  const part = state.message.parts.find(
2137
2141
  (part2) => part2.type === "dynamic-tool" && part2.toolCallId === options.toolCallId
2138
2142
  );
@@ -2144,8 +2148,9 @@ function processUIMessageStream({
2144
2148
  anyPart.input = anyOptions.input;
2145
2149
  anyPart.output = anyOptions.output;
2146
2150
  anyPart.errorText = anyOptions.errorText;
2147
- anyPart.rawInput = (_a18 = anyOptions.rawInput) != null ? _a18 : anyPart.rawInput;
2151
+ anyPart.rawInput = (_a17 = anyOptions.rawInput) != null ? _a17 : anyPart.rawInput;
2148
2152
  anyPart.preliminary = anyOptions.preliminary;
2153
+ anyPart.providerExecuted = (_b2 = anyOptions.providerExecuted) != null ? _b2 : part.providerExecuted;
2149
2154
  if (anyOptions.providerMetadata != null && part.state === "input-available") {
2150
2155
  part.callProviderMetadata = anyOptions.providerMetadata;
2151
2156
  }
@@ -2159,6 +2164,7 @@ function processUIMessageStream({
2159
2164
  output: anyOptions.output,
2160
2165
  errorText: anyOptions.errorText,
2161
2166
  preliminary: anyOptions.preliminary,
2167
+ providerExecuted: anyOptions.providerExecuted,
2162
2168
  ...anyOptions.providerMetadata != null ? { callProviderMetadata: anyOptions.providerMetadata } : {}
2163
2169
  });
2164
2170
  }
@@ -2191,7 +2197,7 @@ function processUIMessageStream({
2191
2197
  case "text-delta": {
2192
2198
  const textPart = state.activeTextParts[chunk.id];
2193
2199
  textPart.text += chunk.delta;
2194
- textPart.providerMetadata = (_a17 = chunk.providerMetadata) != null ? _a17 : textPart.providerMetadata;
2200
+ textPart.providerMetadata = (_a16 = chunk.providerMetadata) != null ? _a16 : textPart.providerMetadata;
2195
2201
  write();
2196
2202
  break;
2197
2203
  }
@@ -2275,7 +2281,8 @@ function processUIMessageStream({
2275
2281
  toolCallId: chunk.toolCallId,
2276
2282
  toolName: chunk.toolName,
2277
2283
  state: "input-streaming",
2278
- input: void 0
2284
+ input: void 0,
2285
+ providerExecuted: chunk.providerExecuted
2279
2286
  });
2280
2287
  } else {
2281
2288
  updateToolPart({
@@ -2320,6 +2327,7 @@ function processUIMessageStream({
2320
2327
  toolName: chunk.toolName,
2321
2328
  state: "input-available",
2322
2329
  input: chunk.input,
2330
+ providerExecuted: chunk.providerExecuted,
2323
2331
  providerMetadata: chunk.providerMetadata
2324
2332
  });
2325
2333
  } else {
@@ -2348,6 +2356,7 @@ function processUIMessageStream({
2348
2356
  state: "output-error",
2349
2357
  input: chunk.input,
2350
2358
  errorText: chunk.errorText,
2359
+ providerExecuted: chunk.providerExecuted,
2351
2360
  providerMetadata: chunk.providerMetadata
2352
2361
  });
2353
2362
  } else {
@@ -2403,7 +2412,8 @@ function processUIMessageStream({
2403
2412
  toolName: toolInvocation.toolName,
2404
2413
  state: "output-error",
2405
2414
  input: toolInvocation.input,
2406
- errorText: chunk.errorText
2415
+ errorText: chunk.errorText,
2416
+ providerExecuted: chunk.providerExecuted
2407
2417
  });
2408
2418
  } else {
2409
2419
  const toolInvocation = getToolInvocation(chunk.toolCallId);
@@ -2413,7 +2423,8 @@ function processUIMessageStream({
2413
2423
  state: "output-error",
2414
2424
  input: toolInvocation.input,
2415
2425
  rawInput: toolInvocation.rawInput,
2416
- errorText: chunk.errorText
2426
+ errorText: chunk.errorText,
2427
+ providerExecuted: chunk.providerExecuted
2417
2428
  });
2418
2429
  }
2419
2430
  write();
@@ -2439,6 +2450,9 @@ function processUIMessageStream({
2439
2450
  break;
2440
2451
  }
2441
2452
  case "finish": {
2453
+ if (chunk.finishReason != null) {
2454
+ state.finishReason = chunk.finishReason;
2455
+ }
2442
2456
  await updateMessageMetadata(chunk.messageMetadata);
2443
2457
  if (chunk.messageMetadata != null) {
2444
2458
  write();
@@ -2544,7 +2558,8 @@ function handleUIMessageStreamFinish({
2544
2558
  messages: [
2545
2559
  ...isContinuation ? originalMessages.slice(0, -1) : originalMessages,
2546
2560
  state.message
2547
- ]
2561
+ ],
2562
+ finishReason: state.finishReason
2548
2563
  });
2549
2564
  };
2550
2565
  return processUIMessageStream({
@@ -2651,7 +2666,7 @@ var wrapLanguageModel = ({
2651
2666
  modelId,
2652
2667
  providerId
2653
2668
  }) => {
2654
- return asArray(middlewareArg).reverse().reduce((wrappedModel, middleware) => {
2669
+ return [...asArray(middlewareArg)].reverse().reduce((wrappedModel, middleware) => {
2655
2670
  return doWrap({ model: wrappedModel, middleware, modelId, providerId });
2656
2671
  }, model);
2657
2672
  };
@@ -2668,7 +2683,7 @@ var doWrap = ({
2668
2683
  modelId,
2669
2684
  providerId
2670
2685
  }) => {
2671
- var _a17, _b, _c;
2686
+ var _a16, _b, _c;
2672
2687
  async function doTransform({
2673
2688
  params,
2674
2689
  type
@@ -2677,7 +2692,7 @@ var doWrap = ({
2677
2692
  }
2678
2693
  return {
2679
2694
  specificationVersion: "v2",
2680
- provider: (_a17 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a17 : model.provider,
2695
+ provider: (_a16 = providerId != null ? providerId : overrideProvider == null ? void 0 : overrideProvider({ model })) != null ? _a16 : model.provider,
2681
2696
  modelId: (_b = modelId != null ? modelId : overrideModelId == null ? void 0 : overrideModelId({ model })) != null ? _b : model.modelId,
2682
2697
  supportedUrls: (_c = overrideSupportedUrls == null ? void 0 : overrideSupportedUrls({ model })) != null ? _c : model.supportedUrls,
2683
2698
  async doGenerate(params) {
@@ -2699,130 +2714,6 @@ var doWrap = ({
2699
2714
  }
2700
2715
  };
2701
2716
  };
2702
- var ClientOrServerImplementationSchema = z.looseObject({
2703
- name: z.string(),
2704
- version: z.string()
2705
- });
2706
- var BaseParamsSchema = z.looseObject({
2707
- _meta: z.optional(z.object({}).loose())
2708
- });
2709
- var ResultSchema = BaseParamsSchema;
2710
- var RequestSchema = z.object({
2711
- method: z.string(),
2712
- params: z.optional(BaseParamsSchema)
2713
- });
2714
- var ServerCapabilitiesSchema = z.looseObject({
2715
- experimental: z.optional(z.object({}).loose()),
2716
- logging: z.optional(z.object({}).loose()),
2717
- prompts: z.optional(
2718
- z.looseObject({
2719
- listChanged: z.optional(z.boolean())
2720
- })
2721
- ),
2722
- resources: z.optional(
2723
- z.looseObject({
2724
- subscribe: z.optional(z.boolean()),
2725
- listChanged: z.optional(z.boolean())
2726
- })
2727
- ),
2728
- tools: z.optional(
2729
- z.looseObject({
2730
- listChanged: z.optional(z.boolean())
2731
- })
2732
- )
2733
- });
2734
- ResultSchema.extend({
2735
- protocolVersion: z.string(),
2736
- capabilities: ServerCapabilitiesSchema,
2737
- serverInfo: ClientOrServerImplementationSchema,
2738
- instructions: z.optional(z.string())
2739
- });
2740
- var PaginatedResultSchema = ResultSchema.extend({
2741
- nextCursor: z.optional(z.string())
2742
- });
2743
- var ToolSchema = z.object({
2744
- name: z.string(),
2745
- description: z.optional(z.string()),
2746
- inputSchema: z.object({
2747
- type: z.literal("object"),
2748
- properties: z.optional(z.object({}).loose())
2749
- }).loose()
2750
- }).loose();
2751
- PaginatedResultSchema.extend({
2752
- tools: z.array(ToolSchema)
2753
- });
2754
- var TextContentSchema = z.object({
2755
- type: z.literal("text"),
2756
- text: z.string()
2757
- }).loose();
2758
- var ImageContentSchema = z.object({
2759
- type: z.literal("image"),
2760
- data: z.base64(),
2761
- mimeType: z.string()
2762
- }).loose();
2763
- var ResourceContentsSchema = z.object({
2764
- /**
2765
- * The URI of this resource.
2766
- */
2767
- uri: z.string(),
2768
- /**
2769
- * The MIME type of this resource, if known.
2770
- */
2771
- mimeType: z.optional(z.string())
2772
- }).loose();
2773
- var TextResourceContentsSchema = ResourceContentsSchema.extend({
2774
- text: z.string()
2775
- });
2776
- var BlobResourceContentsSchema = ResourceContentsSchema.extend({
2777
- blob: z.base64()
2778
- });
2779
- var EmbeddedResourceSchema = z.object({
2780
- type: z.literal("resource"),
2781
- resource: z.union([TextResourceContentsSchema, BlobResourceContentsSchema])
2782
- }).loose();
2783
- ResultSchema.extend({
2784
- content: z.array(
2785
- z.union([TextContentSchema, ImageContentSchema, EmbeddedResourceSchema])
2786
- ),
2787
- isError: z.boolean().default(false).optional()
2788
- }).or(
2789
- ResultSchema.extend({
2790
- toolResult: z.unknown()
2791
- })
2792
- );
2793
- var JSONRPC_VERSION = "2.0";
2794
- var JSONRPCRequestSchema = z.object({
2795
- jsonrpc: z.literal(JSONRPC_VERSION),
2796
- id: z.union([z.string(), z.number().int()])
2797
- }).merge(RequestSchema).strict();
2798
- var JSONRPCResponseSchema = z.object({
2799
- jsonrpc: z.literal(JSONRPC_VERSION),
2800
- id: z.union([z.string(), z.number().int()]),
2801
- result: ResultSchema
2802
- }).strict();
2803
- var JSONRPCErrorSchema = z.object({
2804
- jsonrpc: z.literal(JSONRPC_VERSION),
2805
- id: z.union([z.string(), z.number().int()]),
2806
- error: z.object({
2807
- code: z.number().int(),
2808
- message: z.string(),
2809
- data: z.optional(z.unknown())
2810
- })
2811
- }).strict();
2812
- var JSONRPCNotificationSchema = z.object({
2813
- jsonrpc: z.literal(JSONRPC_VERSION)
2814
- }).merge(
2815
- z.object({
2816
- method: z.string(),
2817
- params: z.optional(BaseParamsSchema)
2818
- })
2819
- ).strict();
2820
- z.union([
2821
- JSONRPCRequestSchema,
2822
- JSONRPCNotificationSchema,
2823
- JSONRPCResponseSchema,
2824
- JSONRPCErrorSchema
2825
- ]);
2826
2717
  function createUIMessageStream({
2827
2718
  execute,
2828
2719
  onError = getErrorMessage2,