@mastra/agent-builder 1.0.34-alpha.0 → 1.0.34-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @mastra/agent-builder
2
2
 
3
+ ## 1.0.34-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - dependencies updates: ([#16126](https://github.com/mastra-ai/mastra/pull/16126))
8
+ - Updated dependency [`@ai-sdk/anthropic-v5@npm:@ai-sdk/anthropic@2.0.79` ↗︎](https://www.npmjs.com/package/@ai-sdk/anthropic-v5/v/2.0.79) (from `npm:@ai-sdk/anthropic@2.0.77`, in `dependencies`)
9
+ - Updated dependency [`@ai-sdk/google-v5@npm:@ai-sdk/google@2.0.72` ↗︎](https://www.npmjs.com/package/@ai-sdk/google-v5/v/2.0.72) (from `npm:@ai-sdk/google@2.0.70`, in `dependencies`)
10
+ - Updated dependency [`@ai-sdk/groq-v5@npm:@ai-sdk/groq@2.0.40` ↗︎](https://www.npmjs.com/package/@ai-sdk/groq-v5/v/2.0.40) (from `npm:@ai-sdk/groq@2.0.38`, in `dependencies`)
11
+ - Updated dependency [`@ai-sdk/openai-v5@npm:@ai-sdk/openai@2.0.106` ↗︎](https://www.npmjs.com/package/@ai-sdk/openai-v5/v/2.0.106) (from `npm:@ai-sdk/openai@2.0.103`, in `dependencies`)
12
+ - Updated dependency [`@ai-sdk/xai-v5@npm:@ai-sdk/xai@2.0.72` ↗︎](https://www.npmjs.com/package/@ai-sdk/xai-v5/v/2.0.72) (from `npm:@ai-sdk/xai@2.0.68`, in `dependencies`)
13
+ - Updated dependencies [[`9f17410`](https://github.com/mastra-ai/mastra/commit/9f1741080def23d42ee50b39887a385ae316a3c6), [`c6eb39e`](https://github.com/mastra-ai/mastra/commit/c6eb39ea6dca381c6563cb240237fbe608e02f93), [`900d086`](https://github.com/mastra-ai/mastra/commit/900d086bb737b9cf2fcf68f11b0389b801a2738c), [`4c0e286`](https://github.com/mastra-ai/mastra/commit/4c0e28637c9cfb4f416549b55e97ebfa13319dfc), [`25184ff`](https://github.com/mastra-ai/mastra/commit/25184ffaf1293ec95119426eb1a1f8d38831b96c), [`aebde9c`](https://github.com/mastra-ai/mastra/commit/aebde9cfacf56592c6b6350cae721740fe090b8a)]:
14
+ - @mastra/core@1.33.0-alpha.4
15
+
3
16
  ## 1.0.34-alpha.0
4
17
 
5
18
  ### Patch Changes
package/dist/index.js CHANGED
@@ -4969,6 +4969,9 @@ var ParseError = class extends Error {
4969
4969
  super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
4970
4970
  }
4971
4971
  };
4972
+ var LF = 10;
4973
+ var CR = 13;
4974
+ var SPACE = 32;
4972
4975
  function noop(_arg) {
4973
4976
  }
4974
4977
  function createParser(callbacks) {
@@ -4976,39 +4979,109 @@ function createParser(callbacks) {
4976
4979
  throw new TypeError(
4977
4980
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
4978
4981
  );
4979
- const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
4980
- let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = "";
4981
- function feed(newChunk) {
4982
- const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`);
4983
- for (const line of complete)
4984
- parseLine(line);
4985
- incompleteLine = incomplete, isFirstChunk = false;
4986
- }
4987
- function parseLine(line) {
4988
- if (line === "") {
4982
+ const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];
4983
+ let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
4984
+ function feed(chunk) {
4985
+ if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
4986
+ const trailing2 = processLines(chunk);
4987
+ trailing2 !== "" && pendingFragments.push(trailing2);
4988
+ return;
4989
+ }
4990
+ if (chunk.indexOf(`
4991
+ `) === -1 && chunk.indexOf("\r") === -1) {
4992
+ pendingFragments.push(chunk);
4993
+ return;
4994
+ }
4995
+ pendingFragments.push(chunk);
4996
+ const input = pendingFragments.join("");
4997
+ pendingFragments.length = 0;
4998
+ const trailing = processLines(input);
4999
+ trailing !== "" && pendingFragments.push(trailing);
5000
+ }
5001
+ function processLines(chunk) {
5002
+ let searchIndex = 0;
5003
+ if (chunk.indexOf("\r") === -1) {
5004
+ let lfIndex = chunk.indexOf(`
5005
+ `, searchIndex);
5006
+ for (; lfIndex !== -1; ) {
5007
+ if (searchIndex === lfIndex) {
5008
+ dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
5009
+ `, searchIndex);
5010
+ continue;
5011
+ }
5012
+ const firstCharCode = chunk.charCodeAt(searchIndex);
5013
+ if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
5014
+ const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
5015
+ if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
5016
+ onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
5017
+ `, searchIndex);
5018
+ continue;
5019
+ }
5020
+ data = dataLines === 0 ? value : `${data}
5021
+ ${value}`, dataLines++;
5022
+ } else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
5023
+ chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
5024
+ lfIndex
5025
+ ) || void 0 : parseLine(chunk, searchIndex, lfIndex);
5026
+ searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
5027
+ `, searchIndex);
5028
+ }
5029
+ return chunk.slice(searchIndex);
5030
+ }
5031
+ for (; searchIndex < chunk.length; ) {
5032
+ const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
5033
+ `, searchIndex);
5034
+ let lineEnd = -1;
5035
+ if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1)
5036
+ break;
5037
+ parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
5038
+ }
5039
+ return chunk.slice(searchIndex);
5040
+ }
5041
+ function parseLine(chunk, start, end) {
5042
+ if (start === end) {
4989
5043
  dispatchEvent();
4990
5044
  return;
4991
5045
  }
4992
- if (line.startsWith(":")) {
4993
- onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
5046
+ const firstCharCode = chunk.charCodeAt(start);
5047
+ if (isDataPrefix(chunk, start, firstCharCode)) {
5048
+ const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
5049
+ data = dataLines === 0 ? value2 : `${data}
5050
+ ${value2}`, dataLines++;
5051
+ return;
5052
+ }
5053
+ if (isEventPrefix(chunk, start, firstCharCode)) {
5054
+ eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
5055
+ return;
5056
+ }
5057
+ if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
5058
+ const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
5059
+ id = value2.includes("\0") ? void 0 : value2;
5060
+ return;
5061
+ }
5062
+ if (firstCharCode === 58) {
5063
+ if (onComment) {
5064
+ const line2 = chunk.slice(start, end);
5065
+ onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
5066
+ }
4994
5067
  return;
4995
5068
  }
4996
- const fieldSeparatorIndex = line.indexOf(":");
4997
- if (fieldSeparatorIndex !== -1) {
4998
- const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
4999
- processField(field, value, line);
5069
+ const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
5070
+ if (fieldSeparatorIndex === -1) {
5071
+ processField(line, "", line);
5000
5072
  return;
5001
5073
  }
5002
- processField(line, "", line);
5074
+ const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
5075
+ processField(field, value, line);
5003
5076
  }
5004
5077
  function processField(field, value, line) {
5005
5078
  switch (field) {
5006
5079
  case "event":
5007
- eventType = value;
5080
+ eventType = value || void 0;
5008
5081
  break;
5009
5082
  case "data":
5010
- data = `${data}${value}
5011
- `;
5083
+ data = dataLines === 0 ? value : `${data}
5084
+ ${value}`, dataLines++;
5012
5085
  break;
5013
5086
  case "id":
5014
5087
  id = value.includes("\0") ? void 0 : value;
@@ -5033,37 +5106,26 @@ function createParser(callbacks) {
5033
5106
  }
5034
5107
  }
5035
5108
  function dispatchEvent() {
5036
- data.length > 0 && onEvent({
5109
+ dataLines > 0 && onEvent({
5037
5110
  id,
5038
- event: eventType || void 0,
5039
- // If the data buffer's last character is a U+000A LINE FEED (LF) character,
5040
- // then remove the last character from the data buffer.
5041
- data: data.endsWith(`
5042
- `) ? data.slice(0, -1) : data
5043
- }), id = void 0, data = "", eventType = "";
5111
+ event: eventType,
5112
+ data
5113
+ }), id = void 0, data = "", dataLines = 0, eventType = void 0;
5044
5114
  }
5045
5115
  function reset(options = {}) {
5046
- incompleteLine && options.consume && parseLine(incompleteLine), isFirstChunk = true, id = void 0, data = "", eventType = "", incompleteLine = "";
5116
+ if (options.consume && pendingFragments.length > 0) {
5117
+ const incompleteLine = pendingFragments.join("");
5118
+ parseLine(incompleteLine, 0, incompleteLine.length);
5119
+ }
5120
+ isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
5047
5121
  }
5048
5122
  return { feed, reset };
5049
5123
  }
5050
- function splitLines(chunk) {
5051
- const lines = [];
5052
- let incompleteLine = "", searchIndex = 0;
5053
- for (; searchIndex < chunk.length; ) {
5054
- const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
5055
- `, searchIndex);
5056
- let lineEnd = -1;
5057
- if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
5058
- incompleteLine = chunk.slice(searchIndex);
5059
- break;
5060
- } else {
5061
- const line = chunk.slice(searchIndex, lineEnd);
5062
- lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
5063
- ` && searchIndex++;
5064
- }
5065
- }
5066
- return [lines, incompleteLine];
5124
+ function isDataPrefix(chunk, i, firstCharCode) {
5125
+ return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
5126
+ }
5127
+ function isEventPrefix(chunk, i, firstCharCode) {
5128
+ return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
5067
5129
  }
5068
5130
  var EventSourceParserStream = class extends TransformStream {
5069
5131
  constructor({ onError, onRetry, onComment } = {}) {
@@ -5199,7 +5261,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
5199
5261
  );
5200
5262
  return Object.fromEntries(normalizedHeaders.entries());
5201
5263
  }
5202
- var VERSION = "3.0.23";
5264
+ var VERSION = "3.0.25";
5203
5265
  var getOriginalFetch = () => globalThis.fetch;
5204
5266
  var getFromApi = async ({
5205
5267
  url,
@@ -5668,6 +5730,33 @@ var createJsonResponseHandler = (responseSchema) => async ({ response, url, requ
5668
5730
  rawValue: parsedResult.rawValue
5669
5731
  };
5670
5732
  };
5733
+ var schemaSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
5734
+ function lazySchema(createSchema) {
5735
+ let schema;
5736
+ return () => {
5737
+ if (schema == null) {
5738
+ schema = createSchema();
5739
+ }
5740
+ return schema;
5741
+ };
5742
+ }
5743
+ function jsonSchema(jsonSchema2, {
5744
+ validate
5745
+ } = {}) {
5746
+ return {
5747
+ [schemaSymbol]: true,
5748
+ _type: void 0,
5749
+ // should never be used directly
5750
+ [validatorSymbol]: true,
5751
+ get jsonSchema() {
5752
+ if (typeof jsonSchema2 === "function") {
5753
+ jsonSchema2 = jsonSchema2();
5754
+ }
5755
+ return jsonSchema2;
5756
+ },
5757
+ validate
5758
+ };
5759
+ }
5671
5760
  function addAdditionalPropertiesToJsonSchema(jsonSchema2) {
5672
5761
  if (jsonSchema2.type === "object") {
5673
5762
  jsonSchema2.additionalProperties = false;
@@ -5693,13 +5782,6 @@ function addAdditionalPropertiesToJsonSchema(jsonSchema2) {
5693
5782
  }
5694
5783
  return jsonSchema2;
5695
5784
  }
5696
- var getRelativePath = (pathA, pathB) => {
5697
- let i = 0;
5698
- for (; i < pathA.length && i < pathB.length; i++) {
5699
- if (pathA[i] !== pathB[i]) break;
5700
- }
5701
- return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
5702
- };
5703
5785
  var ignoreOverride = /* @__PURE__ */ Symbol(
5704
5786
  "Let zodToJsonSchema decide on which parser to use"
5705
5787
  );
@@ -6643,6 +6725,13 @@ var selectParser = (def, typeName, refs) => {
6643
6725
  return /* @__PURE__ */ ((_) => void 0)();
6644
6726
  }
6645
6727
  };
6728
+ var getRelativePath = (pathA, pathB) => {
6729
+ let i = 0;
6730
+ for (; i < pathA.length && i < pathB.length; i++) {
6731
+ if (pathA[i] !== pathB[i]) break;
6732
+ }
6733
+ return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
6734
+ };
6646
6735
  function parseDef(def, refs, forceResolution = false) {
6647
6736
  var _a223;
6648
6737
  const seenItem = refs.seen.get(def);
@@ -6822,33 +6911,6 @@ function zodSchema(zodSchema2, options) {
6822
6911
  return zod3Schema(zodSchema2);
6823
6912
  }
6824
6913
  }
6825
- var schemaSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
6826
- function lazySchema(createSchema) {
6827
- let schema;
6828
- return () => {
6829
- if (schema == null) {
6830
- schema = createSchema();
6831
- }
6832
- return schema;
6833
- };
6834
- }
6835
- function jsonSchema(jsonSchema2, {
6836
- validate
6837
- } = {}) {
6838
- return {
6839
- [schemaSymbol]: true,
6840
- _type: void 0,
6841
- // should never be used directly
6842
- [validatorSymbol]: true,
6843
- get jsonSchema() {
6844
- if (typeof jsonSchema2 === "function") {
6845
- jsonSchema2 = jsonSchema2();
6846
- }
6847
- return jsonSchema2;
6848
- },
6849
- validate
6850
- };
6851
- }
6852
6914
  function isSchema(value) {
6853
6915
  return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && "jsonSchema" in value && "validate" in value;
6854
6916
  }
@@ -7136,6 +7198,19 @@ var gatewayErrorResponseSchema = lazyValidator(
7136
7198
  })
7137
7199
  )
7138
7200
  );
7201
+ function extractApiCallResponse(error) {
7202
+ if (error.data !== void 0) {
7203
+ return error.data;
7204
+ }
7205
+ if (error.responseBody != null) {
7206
+ try {
7207
+ return JSON.parse(error.responseBody);
7208
+ } catch (e) {
7209
+ return error.responseBody;
7210
+ }
7211
+ }
7212
+ return {};
7213
+ }
7139
7214
  var name72 = "GatewayTimeoutError";
7140
7215
  var marker82 = `vercel.ai.gateway.error.${name72}`;
7141
7216
  var symbol82 = Symbol.for(marker82);
@@ -7222,19 +7297,6 @@ async function asGatewayError(error, authMethod) {
7222
7297
  authMethod
7223
7298
  });
7224
7299
  }
7225
- function extractApiCallResponse(error) {
7226
- if (error.data !== void 0) {
7227
- return error.data;
7228
- }
7229
- if (error.responseBody != null) {
7230
- try {
7231
- return JSON.parse(error.responseBody);
7232
- } catch (e) {
7233
- return error.responseBody;
7234
- }
7235
- }
7236
- return {};
7237
- }
7238
7300
  var GATEWAY_AUTH_METHOD_HEADER = "ai-gateway-auth-method";
7239
7301
  async function parseAuthMethod(headers) {
7240
7302
  const result = await safeValidateTypes({
@@ -8021,7 +8083,7 @@ async function getVercelRequestId() {
8021
8083
  var _a93;
8022
8084
  return (_a93 = getContext().headers) == null ? void 0 : _a93["x-vercel-id"];
8023
8085
  }
8024
- var VERSION2 = "2.0.82";
8086
+ var VERSION2 = "2.0.86";
8025
8087
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
8026
8088
  function createGatewayProvider(options = {}) {
8027
8089
  var _a93, _b92;