@mastra/agent-builder 1.0.34-alpha.4 → 1.0.34-alpha.5

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,13 @@
1
1
  # @mastra/agent-builder
2
2
 
3
+ ## 1.0.34-alpha.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`b59316f`](https://github.com/mastra-ai/mastra/commit/b59316ffa0f7688165b0f9c81ccdf85da461e5b2), [`bae381b`](https://github.com/mastra-ai/mastra/commit/bae381b57cdb8d161340642b47d892de0706d464), [`55f1e2d`](https://github.com/mastra-ai/mastra/commit/55f1e2d65425b95a49ae788053b266f256e38c96), [`d48a705`](https://github.com/mastra-ai/mastra/commit/d48a705ff3dfbdc7a996e07ecd8293b5effd9a2a)]:
8
+ - @mastra/core@1.33.0-alpha.12
9
+ - @mastra/memory@1.18.0-alpha.4
10
+
3
11
  ## 1.0.34-alpha.4
4
12
 
5
13
  ### Patch Changes
package/dist/index.js CHANGED
@@ -4969,9 +4969,6 @@ 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;
4975
4972
  function noop(_arg) {
4976
4973
  }
4977
4974
  function createParser(callbacks) {
@@ -4979,109 +4976,39 @@ function createParser(callbacks) {
4979
4976
  throw new TypeError(
4980
4977
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
4981
4978
  );
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) {
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 === "") {
5043
4989
  dispatchEvent();
5044
4990
  return;
5045
4991
  }
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
- }
4992
+ if (line.startsWith(":")) {
4993
+ onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
5067
4994
  return;
5068
4995
  }
5069
- const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
5070
- if (fieldSeparatorIndex === -1) {
5071
- processField(line, "", line);
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);
5072
5000
  return;
5073
5001
  }
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);
5002
+ processField(line, "", line);
5076
5003
  }
5077
5004
  function processField(field, value, line) {
5078
5005
  switch (field) {
5079
5006
  case "event":
5080
- eventType = value || void 0;
5007
+ eventType = value;
5081
5008
  break;
5082
5009
  case "data":
5083
- data = dataLines === 0 ? value : `${data}
5084
- ${value}`, dataLines++;
5010
+ data = `${data}${value}
5011
+ `;
5085
5012
  break;
5086
5013
  case "id":
5087
5014
  id = value.includes("\0") ? void 0 : value;
@@ -5106,26 +5033,37 @@ ${value}`, dataLines++;
5106
5033
  }
5107
5034
  }
5108
5035
  function dispatchEvent() {
5109
- dataLines > 0 && onEvent({
5036
+ data.length > 0 && onEvent({
5110
5037
  id,
5111
- event: eventType,
5112
- data
5113
- }), id = void 0, data = "", dataLines = 0, eventType = void 0;
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 = "";
5114
5044
  }
5115
5045
  function reset(options = {}) {
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;
5046
+ incompleteLine && options.consume && parseLine(incompleteLine), isFirstChunk = true, id = void 0, data = "", eventType = "", incompleteLine = "";
5121
5047
  }
5122
5048
  return { feed, reset };
5123
5049
  }
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;
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];
5129
5067
  }
5130
5068
  var EventSourceParserStream = class extends TransformStream {
5131
5069
  constructor({ onError, onRetry, onComment } = {}) {
@@ -8083,7 +8021,7 @@ async function getVercelRequestId() {
8083
8021
  var _a93;
8084
8022
  return (_a93 = getContext().headers) == null ? void 0 : _a93["x-vercel-id"];
8085
8023
  }
8086
- var VERSION2 = "2.0.86";
8024
+ var VERSION2 = "2.0.88";
8087
8025
  var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
8088
8026
  function createGatewayProvider(options = {}) {
8089
8027
  var _a93, _b92;