@mastra/server 1.38.0 → 1.39.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.
Files changed (202) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/_types/@mastra_schema-compat/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +11 -8
  3. package/dist/{api-schema-manifest-E3RU6MLF.cjs → api-schema-manifest-ALHYYJMN.cjs} +4 -4
  4. package/dist/{api-schema-manifest-E3RU6MLF.cjs.map → api-schema-manifest-ALHYYJMN.cjs.map} +1 -1
  5. package/dist/{api-schema-manifest-DNC2KIKD.js → api-schema-manifest-PQ6VZTB3.js} +3 -3
  6. package/dist/{api-schema-manifest-DNC2KIKD.js.map → api-schema-manifest-PQ6VZTB3.js.map} +1 -1
  7. package/dist/chunk-2ONW75MN.cjs +477 -0
  8. package/dist/chunk-2ONW75MN.cjs.map +1 -0
  9. package/dist/{chunk-CJMJQR2K.cjs → chunk-3APAH25G.cjs} +4 -4
  10. package/dist/{chunk-CJMJQR2K.cjs.map → chunk-3APAH25G.cjs.map} +1 -1
  11. package/dist/{chunk-PXYR3D6L.cjs → chunk-3D55EABW.cjs} +3 -9
  12. package/dist/chunk-3D55EABW.cjs.map +1 -0
  13. package/dist/{chunk-WXJSYUBX.cjs → chunk-3KXE2KXE.cjs} +4 -4
  14. package/dist/{chunk-WXJSYUBX.cjs.map → chunk-3KXE2KXE.cjs.map} +1 -1
  15. package/dist/{chunk-APV6QKRZ.cjs → chunk-4W7KQRF5.cjs} +28 -28
  16. package/dist/{chunk-APV6QKRZ.cjs.map → chunk-4W7KQRF5.cjs.map} +1 -1
  17. package/dist/{chunk-L33BLLID.cjs → chunk-544IXGBW.cjs} +168 -166
  18. package/dist/chunk-544IXGBW.cjs.map +1 -0
  19. package/dist/{chunk-VH6QCEN7.cjs → chunk-5DDUXRAY.cjs} +102 -102
  20. package/dist/{chunk-VH6QCEN7.cjs.map → chunk-5DDUXRAY.cjs.map} +1 -1
  21. package/dist/{chunk-DNKTFFOV.cjs → chunk-5WB7PKHN.cjs} +4 -4
  22. package/dist/{chunk-DNKTFFOV.cjs.map → chunk-5WB7PKHN.cjs.map} +1 -1
  23. package/dist/{chunk-ODIMB6T6.cjs → chunk-6MP52DMQ.cjs} +7 -7
  24. package/dist/{chunk-ODIMB6T6.cjs.map → chunk-6MP52DMQ.cjs.map} +1 -1
  25. package/dist/{chunk-3LUN33E7.cjs → chunk-76ONC2XD.cjs} +85 -19
  26. package/dist/chunk-76ONC2XD.cjs.map +1 -0
  27. package/dist/{chunk-TLMAHJTC.cjs → chunk-77IY4RTO.cjs} +16 -16
  28. package/dist/{chunk-TLMAHJTC.cjs.map → chunk-77IY4RTO.cjs.map} +1 -1
  29. package/dist/{chunk-5PCUNLFX.js → chunk-AEH5OCIH.js} +3 -3
  30. package/dist/{chunk-5PCUNLFX.js.map → chunk-AEH5OCIH.js.map} +1 -1
  31. package/dist/{chunk-WADS7CD7.js → chunk-AW5INHG7.js} +4 -4
  32. package/dist/{chunk-WADS7CD7.js.map → chunk-AW5INHG7.js.map} +1 -1
  33. package/dist/{chunk-P7FVOCQB.cjs → chunk-AX6REP5O.cjs} +4 -4
  34. package/dist/{chunk-P7FVOCQB.cjs.map → chunk-AX6REP5O.cjs.map} +1 -1
  35. package/dist/{chunk-4DVNH3KJ.js → chunk-B5NMA52D.js} +4 -4
  36. package/dist/{chunk-4DVNH3KJ.js.map → chunk-B5NMA52D.js.map} +1 -1
  37. package/dist/{chunk-4T6DC425.js → chunk-CBG6LUEW.js} +3 -3
  38. package/dist/{chunk-4T6DC425.js.map → chunk-CBG6LUEW.js.map} +1 -1
  39. package/dist/{chunk-SDBN3DIS.cjs → chunk-D5M3VILP.cjs} +26 -26
  40. package/dist/{chunk-SDBN3DIS.cjs.map → chunk-D5M3VILP.cjs.map} +1 -1
  41. package/dist/{chunk-Z2ZMHHQW.js → chunk-E7AEYMKH.js} +3 -3
  42. package/dist/{chunk-Z2ZMHHQW.js.map → chunk-E7AEYMKH.js.map} +1 -1
  43. package/dist/{chunk-J6OD53OV.js → chunk-ESJTIVEQ.js} +12 -3
  44. package/dist/chunk-ESJTIVEQ.js.map +1 -0
  45. package/dist/{chunk-T2FBYRYD.cjs → chunk-ET7KSUVJ.cjs} +12 -2
  46. package/dist/chunk-ET7KSUVJ.cjs.map +1 -0
  47. package/dist/{chunk-T6IXA4ZQ.js → chunk-FQCCUWMS.js} +3 -3
  48. package/dist/{chunk-T6IXA4ZQ.js.map → chunk-FQCCUWMS.js.map} +1 -1
  49. package/dist/{chunk-QRIHD5UO.js → chunk-G2CL5JMK.js} +5 -5
  50. package/dist/{chunk-QRIHD5UO.js.map → chunk-G2CL5JMK.js.map} +1 -1
  51. package/dist/{chunk-XDOMY4VL.cjs → chunk-GAERIPY2.cjs} +5 -5
  52. package/dist/{chunk-XDOMY4VL.cjs.map → chunk-GAERIPY2.cjs.map} +1 -1
  53. package/dist/{chunk-QM3NYDZZ.js → chunk-HEBNJ6KJ.js} +4 -4
  54. package/dist/{chunk-QM3NYDZZ.js.map → chunk-HEBNJ6KJ.js.map} +1 -1
  55. package/dist/{chunk-AT5ZCHIV.cjs → chunk-HGREXGI2.cjs} +3 -3
  56. package/dist/{chunk-AT5ZCHIV.cjs.map → chunk-HGREXGI2.cjs.map} +1 -1
  57. package/dist/{chunk-RBONVWGZ.js → chunk-HJVMQDSZ.js} +9 -3
  58. package/dist/chunk-HJVMQDSZ.js.map +1 -0
  59. package/dist/{chunk-MFYZWOKE.cjs → chunk-IGE7NPFH.cjs} +5 -5
  60. package/dist/{chunk-MFYZWOKE.cjs.map → chunk-IGE7NPFH.cjs.map} +1 -1
  61. package/dist/{chunk-UFYCA27U.js → chunk-IONXSX77.js} +5 -3
  62. package/dist/chunk-IONXSX77.js.map +1 -0
  63. package/dist/{chunk-RTYOFB6W.cjs → chunk-IU3ZRZSG.cjs} +5 -3
  64. package/dist/chunk-IU3ZRZSG.cjs.map +1 -0
  65. package/dist/{chunk-76I5G5W5.js → chunk-JMEMSVJ5.js} +4 -9
  66. package/dist/chunk-JMEMSVJ5.js.map +1 -0
  67. package/dist/{chunk-56F2IRK3.js → chunk-K6XESXNQ.js} +3 -3
  68. package/dist/{chunk-56F2IRK3.js.map → chunk-K6XESXNQ.js.map} +1 -1
  69. package/dist/{chunk-43KD3CRE.cjs → chunk-LBVQK4LO.cjs} +16 -5
  70. package/dist/chunk-LBVQK4LO.cjs.map +1 -0
  71. package/dist/{chunk-IJFPP2XB.js → chunk-LNBKA6IA.js} +69 -4
  72. package/dist/chunk-LNBKA6IA.js.map +1 -0
  73. package/dist/{chunk-BKYFKSJI.js → chunk-LPYCF5B2.js} +3 -3
  74. package/dist/{chunk-BKYFKSJI.js.map → chunk-LPYCF5B2.js.map} +1 -1
  75. package/dist/{chunk-DRXZDKLU.js → chunk-LQQCTO6D.js} +3 -3
  76. package/dist/{chunk-DRXZDKLU.js.map → chunk-LQQCTO6D.js.map} +1 -1
  77. package/dist/{chunk-HX5BGP6D.cjs → chunk-LYF4J3JE.cjs} +17 -17
  78. package/dist/{chunk-HX5BGP6D.cjs.map → chunk-LYF4J3JE.cjs.map} +1 -1
  79. package/dist/chunk-NQLS4Z3W.js +472 -0
  80. package/dist/chunk-NQLS4Z3W.js.map +1 -0
  81. package/dist/{chunk-KSZXXQHZ.js → chunk-NTE3Q3BA.js} +3 -3
  82. package/dist/{chunk-KSZXXQHZ.js.map → chunk-NTE3Q3BA.js.map} +1 -1
  83. package/dist/{chunk-5FPJ4RT4.js → chunk-OCWY55IQ.js} +3 -3
  84. package/dist/{chunk-5FPJ4RT4.js.map → chunk-OCWY55IQ.js.map} +1 -1
  85. package/dist/{chunk-GPAQ47NG.cjs → chunk-QVFQUBC7.cjs} +9 -3
  86. package/dist/chunk-QVFQUBC7.cjs.map +1 -0
  87. package/dist/{chunk-7GOHECZP.js → chunk-SEAEQN2H.js} +3 -3
  88. package/dist/{chunk-7GOHECZP.js.map → chunk-SEAEQN2H.js.map} +1 -1
  89. package/dist/{chunk-6XSS54BL.cjs → chunk-THXUZHS6.cjs} +7 -7
  90. package/dist/{chunk-6XSS54BL.cjs.map → chunk-THXUZHS6.cjs.map} +1 -1
  91. package/dist/{chunk-M7HLT2GO.js → chunk-UOQHTFYI.js} +3 -3
  92. package/dist/{chunk-M7HLT2GO.js.map → chunk-UOQHTFYI.js.map} +1 -1
  93. package/dist/{chunk-5SK4SJJH.js → chunk-V4G7MSFL.js} +3 -3
  94. package/dist/{chunk-5SK4SJJH.js.map → chunk-V4G7MSFL.js.map} +1 -1
  95. package/dist/{chunk-XB6H6LOM.js → chunk-VSB4S6R5.js} +3 -3
  96. package/dist/{chunk-XB6H6LOM.js.map → chunk-VSB4S6R5.js.map} +1 -1
  97. package/dist/{chunk-4DGDQWQQ.cjs → chunk-VWFP6O2W.cjs} +14 -14
  98. package/dist/{chunk-4DGDQWQQ.cjs.map → chunk-VWFP6O2W.cjs.map} +1 -1
  99. package/dist/{chunk-ZNMKBPTN.cjs → chunk-WUPBIK5J.cjs} +15 -15
  100. package/dist/{chunk-ZNMKBPTN.cjs.map → chunk-WUPBIK5J.cjs.map} +1 -1
  101. package/dist/{chunk-F27R55RI.cjs → chunk-XGFN7MMF.cjs} +4 -4
  102. package/dist/{chunk-F27R55RI.cjs.map → chunk-XGFN7MMF.cjs.map} +1 -1
  103. package/dist/{chunk-YW252K6H.js → chunk-XNGC2C6Z.js} +20 -18
  104. package/dist/chunk-XNGC2C6Z.js.map +1 -0
  105. package/dist/{chunk-7GSR7HQ2.js → chunk-Y5CIOSHU.js} +4 -4
  106. package/dist/{chunk-7GSR7HQ2.js.map → chunk-Y5CIOSHU.js.map} +1 -1
  107. package/dist/{chunk-OJNVSXOF.js → chunk-YH4WGIEH.js} +16 -5
  108. package/dist/chunk-YH4WGIEH.js.map +1 -0
  109. package/dist/{chunk-NSXV3FWO.cjs → chunk-ZIWTQGJV.cjs} +20 -20
  110. package/dist/{chunk-NSXV3FWO.cjs.map → chunk-ZIWTQGJV.cjs.map} +1 -1
  111. package/dist/constants-DVRTNEGY-A5OAGF3M.js +3 -0
  112. package/dist/{constants-SPS7MR4D-YRZDDIPO.js.map → constants-DVRTNEGY-A5OAGF3M.js.map} +1 -1
  113. package/dist/{constants-SPS7MR4D-ZMHAFWSH.cjs → constants-DVRTNEGY-ZGCNETZ3.cjs} +8 -8
  114. package/dist/{constants-SPS7MR4D-ZMHAFWSH.cjs.map → constants-DVRTNEGY-ZGCNETZ3.cjs.map} +1 -1
  115. package/dist/{dist-HIWM6H43.js → dist-LWX2CRMH.js} +304 -125
  116. package/dist/dist-LWX2CRMH.js.map +1 -0
  117. package/dist/{dist-LZYJXHUM.cjs → dist-QFLLP7OJ.cjs} +336 -157
  118. package/dist/dist-QFLLP7OJ.cjs.map +1 -0
  119. package/dist/docs/SKILL.md +1 -1
  120. package/dist/docs/assets/SOURCE_MAP.json +1 -1
  121. package/dist/{observational-memory-TJFOX3YN-A2QE2E3I.cjs → observational-memory-G52HNRHE-73KIWQ2G.cjs} +31 -31
  122. package/dist/{observational-memory-TJFOX3YN-A2QE2E3I.cjs.map → observational-memory-G52HNRHE-73KIWQ2G.cjs.map} +1 -1
  123. package/dist/{observational-memory-TJFOX3YN-P3KG2OXA.js → observational-memory-G52HNRHE-RHA4V77M.js} +4 -4
  124. package/dist/{observational-memory-TJFOX3YN-P3KG2OXA.js.map → observational-memory-G52HNRHE-RHA4V77M.js.map} +1 -1
  125. package/dist/server/auth/helpers.d.ts +3 -4
  126. package/dist/server/auth/helpers.d.ts.map +1 -1
  127. package/dist/server/auth/index.cjs +15 -15
  128. package/dist/server/auth/index.js +1 -1
  129. package/dist/server/handlers/a2a.cjs +14 -14
  130. package/dist/server/handlers/a2a.js +1 -1
  131. package/dist/server/handlers/agent-builder.cjs +17 -17
  132. package/dist/server/handlers/agent-builder.js +1 -1
  133. package/dist/server/handlers/agent-versions.cjs +8 -8
  134. package/dist/server/handlers/agent-versions.js +1 -1
  135. package/dist/server/handlers/agents.cjs +45 -45
  136. package/dist/server/handlers/agents.d.ts +4 -0
  137. package/dist/server/handlers/agents.d.ts.map +1 -1
  138. package/dist/server/handlers/agents.js +1 -1
  139. package/dist/server/handlers/auth.cjs +12 -12
  140. package/dist/server/handlers/auth.js +1 -1
  141. package/dist/server/handlers/conversations.cjs +5 -5
  142. package/dist/server/handlers/conversations.js +1 -1
  143. package/dist/server/handlers/memory.cjs +27 -27
  144. package/dist/server/handlers/memory.d.ts.map +1 -1
  145. package/dist/server/handlers/memory.js +1 -1
  146. package/dist/server/handlers/responses.cjs +4 -4
  147. package/dist/server/handlers/responses.js +1 -1
  148. package/dist/server/handlers/scorer-versions.cjs +8 -8
  149. package/dist/server/handlers/scorer-versions.js +1 -1
  150. package/dist/server/handlers/scores.cjs +7 -7
  151. package/dist/server/handlers/scores.js +1 -1
  152. package/dist/server/handlers/stored-agent-favorites.cjs +3 -3
  153. package/dist/server/handlers/stored-agent-favorites.js +1 -1
  154. package/dist/server/handlers/stored-agents.cjs +12 -8
  155. package/dist/server/handlers/stored-agents.d.ts +26 -0
  156. package/dist/server/handlers/stored-agents.d.ts.map +1 -1
  157. package/dist/server/handlers/stored-agents.js +1 -1
  158. package/dist/server/handlers/stored-scorers.cjs +6 -6
  159. package/dist/server/handlers/stored-scorers.js +1 -1
  160. package/dist/server/handlers/system.cjs +3 -3
  161. package/dist/server/handlers/system.js +1 -1
  162. package/dist/server/handlers/tools.cjs +6 -6
  163. package/dist/server/handlers/tools.js +1 -1
  164. package/dist/server/handlers/workflows.cjs +27 -27
  165. package/dist/server/handlers/workflows.js +1 -1
  166. package/dist/server/handlers.cjs +18 -18
  167. package/dist/server/handlers.js +9 -9
  168. package/dist/server/schemas/agents.d.ts +2 -0
  169. package/dist/server/schemas/agents.d.ts.map +1 -1
  170. package/dist/server/schemas/index.cjs +119 -115
  171. package/dist/server/schemas/index.js +5 -5
  172. package/dist/server/schemas/stored-agents.d.ts +17 -0
  173. package/dist/server/schemas/stored-agents.d.ts.map +1 -1
  174. package/dist/server/server-adapter/index.cjs +23 -16
  175. package/dist/server/server-adapter/index.cjs.map +1 -1
  176. package/dist/server/server-adapter/index.d.ts.map +1 -1
  177. package/dist/server/server-adapter/index.js +11 -4
  178. package/dist/server/server-adapter/index.js.map +1 -1
  179. package/dist/server/server-adapter/routes/stored-agents.d.ts +2 -1
  180. package/dist/server/server-adapter/routes/stored-agents.d.ts.map +1 -1
  181. package/dist/working-memory-state-J7ASTNXX-JNDYMEET.js +3 -0
  182. package/dist/working-memory-state-J7ASTNXX-JNDYMEET.js.map +1 -0
  183. package/dist/working-memory-state-J7ASTNXX-WEIO7C67.cjs +24 -0
  184. package/dist/working-memory-state-J7ASTNXX-WEIO7C67.cjs.map +1 -0
  185. package/package.json +9 -9
  186. package/dist/chunk-3LUN33E7.cjs.map +0 -1
  187. package/dist/chunk-43KD3CRE.cjs.map +0 -1
  188. package/dist/chunk-76I5G5W5.js.map +0 -1
  189. package/dist/chunk-GPAQ47NG.cjs.map +0 -1
  190. package/dist/chunk-IJFPP2XB.js.map +0 -1
  191. package/dist/chunk-J6OD53OV.js.map +0 -1
  192. package/dist/chunk-L33BLLID.cjs.map +0 -1
  193. package/dist/chunk-OJNVSXOF.js.map +0 -1
  194. package/dist/chunk-PXYR3D6L.cjs.map +0 -1
  195. package/dist/chunk-RBONVWGZ.js.map +0 -1
  196. package/dist/chunk-RTYOFB6W.cjs.map +0 -1
  197. package/dist/chunk-T2FBYRYD.cjs.map +0 -1
  198. package/dist/chunk-UFYCA27U.js.map +0 -1
  199. package/dist/chunk-YW252K6H.js.map +0 -1
  200. package/dist/constants-SPS7MR4D-YRZDDIPO.js +0 -3
  201. package/dist/dist-HIWM6H43.js.map +0 -1
  202. package/dist/dist-LZYJXHUM.cjs.map +0 -1
@@ -1,8 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var chunkGVXW4BRK_cjs = require('./chunk-GVXW4BRK.cjs');
4
- var chunkAPV6QKRZ_cjs = require('./chunk-APV6QKRZ.cjs');
5
- var chunkPXYR3D6L_cjs = require('./chunk-PXYR3D6L.cjs');
4
+ var chunk4W7KQRF5_cjs = require('./chunk-4W7KQRF5.cjs');
6
5
  var chunkKGMN6MLX_cjs = require('./chunk-KGMN6MLX.cjs');
7
6
  var chunkO7I5CWRX_cjs = require('./chunk-O7I5CWRX.cjs');
8
7
  var agent = require('@mastra/core/agent');
@@ -54,7 +53,7 @@ var require_ignore = chunkO7I5CWRX_cjs.__commonJS({
54
53
  }
55
54
  var UNDEFINED = void 0;
56
55
  var EMPTY = "";
57
- var SPACE2 = " ";
56
+ var SPACE4 = " ";
58
57
  var ESCAPE = "\\";
59
58
  var REGEX_TEST_BLANK_LINE = /^\s+$/;
60
59
  var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
@@ -98,7 +97,7 @@ var require_ignore = chunkO7I5CWRX_cjs.__commonJS({
98
97
  // (a ) -> (a)
99
98
  // (a \ ) -> (a )
100
99
  /((?:\\\\)*?)(\\?\s+)$/,
101
- (_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE2 : EMPTY)
100
+ (_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE4 : EMPTY)
102
101
  ],
103
102
  // Replace (\ ) with ' '
104
103
  // (\ ) -> ' '
@@ -108,7 +107,7 @@ var require_ignore = chunkO7I5CWRX_cjs.__commonJS({
108
107
  /(\\+?)\s/g,
109
108
  (_, m1) => {
110
109
  const { length } = m1;
111
- return m1.slice(0, length - length % 2) + SPACE2;
110
+ return m1.slice(0, length - length % 2) + SPACE4;
112
111
  }
113
112
  ],
114
113
  // Escape metacharacters
@@ -502,6 +501,13 @@ var require_ignore = chunkO7I5CWRX_cjs.__commonJS({
502
501
  define(module.exports, /* @__PURE__ */ Symbol.for("setupWindows"), setupWindows);
503
502
  }
504
503
  });
504
+
505
+ // ../memory/dist/chunk-PZ5AY32C.js
506
+ var __defProp = Object.defineProperty;
507
+ var __export = (target, all) => {
508
+ for (var name4 in all)
509
+ __defProp(target, name4, { get: all[name4], enumerable: true });
510
+ };
505
511
  var E_CANCELED = new Error("request for lock canceled");
506
512
  var __awaiter$2 = function(thisArg, _arguments, P, generator) {
507
513
  function adopt(value) {
@@ -705,7 +711,7 @@ var Mutex = class {
705
711
  }
706
712
  };
707
713
  var __create = Object.create;
708
- var __defProp = Object.defineProperty;
714
+ var __defProp2 = Object.defineProperty;
709
715
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
710
716
  var __getOwnPropNames = Object.getOwnPropertyNames;
711
717
  var __getProtoOf = Object.getPrototypeOf;
@@ -717,7 +723,7 @@ var __copyProps = (to, from, except, desc) => {
717
723
  if (from && typeof from === "object" || typeof from === "function") {
718
724
  for (let key of __getOwnPropNames(from))
719
725
  if (!__hasOwnProp.call(to, key) && key !== except)
720
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
726
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
721
727
  }
722
728
  return to;
723
729
  };
@@ -726,7 +732,7 @@ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__g
726
732
  // file that has been converted to a CommonJS file using a Babel-
727
733
  // compatible transform (i.e. "__esModule" has not been set), then set
728
734
  // "default" to the CommonJS "module.exports" for node compatibility.
729
- __defProp(target, "default", { value: mod, enumerable: true }),
735
+ __defProp2(target, "default", { value: mod, enumerable: true }),
730
736
  mod
731
737
  ));
732
738
  var require_secure_json_parse = __commonJS2({
@@ -1124,7 +1130,7 @@ function safeParseJSON({
1124
1130
  }
1125
1131
  }
1126
1132
  var external_exports = {};
1127
- chunkPXYR3D6L_cjs.__export(external_exports, {
1133
+ __export(external_exports, {
1128
1134
  BRAND: () => BRAND,
1129
1135
  DIRTY: () => DIRTY,
1130
1136
  EMPTY_PATH: () => EMPTY_PATH,
@@ -7679,10 +7685,10 @@ var TraceAPI = (
7679
7685
  })()
7680
7686
  );
7681
7687
  var trace = TraceAPI.getInstance();
7682
- var __defProp2 = Object.defineProperty;
7688
+ var __defProp22 = Object.defineProperty;
7683
7689
  var __export2 = (target, all) => {
7684
7690
  for (var name173 in all)
7685
- __defProp2(target, name173, { get: all[name173], enumerable: true });
7691
+ __defProp22(target, name173, { get: all[name173], enumerable: true });
7686
7692
  };
7687
7693
  function prepareResponseHeaders(headers, {
7688
7694
  contentType,
@@ -8824,7 +8830,7 @@ function trimStartOfStream() {
8824
8830
  };
8825
8831
  }
8826
8832
  var external_exports2 = {};
8827
- chunkPXYR3D6L_cjs.__export(external_exports2, {
8833
+ __export(external_exports2, {
8828
8834
  $brand: () => $brand,
8829
8835
  $input: () => $input,
8830
8836
  $output: () => $output,
@@ -9065,7 +9071,7 @@ chunkPXYR3D6L_cjs.__export(external_exports2, {
9065
9071
  xor: () => xor
9066
9072
  });
9067
9073
  var core_exports2 = {};
9068
- chunkPXYR3D6L_cjs.__export(core_exports2, {
9074
+ __export(core_exports2, {
9069
9075
  $ZodAny: () => $ZodAny,
9070
9076
  $ZodArray: () => $ZodArray,
9071
9077
  $ZodAsyncError: () => $ZodAsyncError,
@@ -9417,7 +9423,7 @@ function config(newConfig) {
9417
9423
  return globalConfig;
9418
9424
  }
9419
9425
  var util_exports = {};
9420
- chunkPXYR3D6L_cjs.__export(util_exports, {
9426
+ __export(util_exports, {
9421
9427
  BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES,
9422
9428
  Class: () => Class,
9423
9429
  NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES,
@@ -10332,7 +10338,7 @@ var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
10332
10338
  };
10333
10339
  var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
10334
10340
  var regexes_exports = {};
10335
- chunkPXYR3D6L_cjs.__export(regexes_exports, {
10341
+ __export(regexes_exports, {
10336
10342
  base64: () => base64,
10337
10343
  base64url: () => base64url,
10338
10344
  bigint: () => bigint,
@@ -13165,7 +13171,7 @@ function handleRefineResult(result, payload, input, inst) {
13165
13171
  }
13166
13172
  }
13167
13173
  var locales_exports = {};
13168
- chunkPXYR3D6L_cjs.__export(locales_exports, {
13174
+ __export(locales_exports, {
13169
13175
  ar: () => ar_default,
13170
13176
  az: () => az_default,
13171
13177
  be: () => be_default,
@@ -21069,7 +21075,7 @@ var JSONSchemaGenerator = class {
21069
21075
  };
21070
21076
  var json_schema_exports = {};
21071
21077
  var schemas_exports2 = {};
21072
- chunkPXYR3D6L_cjs.__export(schemas_exports2, {
21078
+ __export(schemas_exports2, {
21073
21079
  ZodAny: () => ZodAny2,
21074
21080
  ZodArray: () => ZodArray2,
21075
21081
  ZodBase64: () => ZodBase64,
@@ -21238,7 +21244,7 @@ chunkPXYR3D6L_cjs.__export(schemas_exports2, {
21238
21244
  xor: () => xor
21239
21245
  });
21240
21246
  var checks_exports2 = {};
21241
- chunkPXYR3D6L_cjs.__export(checks_exports2, {
21247
+ __export(checks_exports2, {
21242
21248
  endsWith: () => _endsWith,
21243
21249
  gt: () => _gt,
21244
21250
  gte: () => _gte,
@@ -21270,7 +21276,7 @@ chunkPXYR3D6L_cjs.__export(checks_exports2, {
21270
21276
  uppercase: () => _uppercase
21271
21277
  });
21272
21278
  var iso_exports = {};
21273
- chunkPXYR3D6L_cjs.__export(iso_exports, {
21279
+ __export(iso_exports, {
21274
21280
  ZodISODate: () => ZodISODate,
21275
21281
  ZodISODateTime: () => ZodISODateTime,
21276
21282
  ZodISODuration: () => ZodISODuration,
@@ -23149,7 +23155,7 @@ function fromJSONSchema(schema, params) {
23149
23155
  return convertSchema(normalized, ctx);
23150
23156
  }
23151
23157
  var coerce_exports = {};
23152
- chunkPXYR3D6L_cjs.__export(coerce_exports, {
23158
+ __export(coerce_exports, {
23153
23159
  bigint: () => bigint3,
23154
23160
  boolean: () => boolean3,
23155
23161
  date: () => date4,
@@ -23597,6 +23603,9 @@ var ParseError = class extends Error {
23597
23603
  super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
23598
23604
  }
23599
23605
  };
23606
+ var LF = 10;
23607
+ var CR = 13;
23608
+ var SPACE = 32;
23600
23609
  function noop(_arg) {
23601
23610
  }
23602
23611
  function createParser(callbacks) {
@@ -23604,39 +23613,109 @@ function createParser(callbacks) {
23604
23613
  throw new TypeError(
23605
23614
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
23606
23615
  );
23607
- const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
23608
- let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = "";
23609
- function feed(newChunk) {
23610
- const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`);
23611
- for (const line of complete)
23612
- parseLine(line);
23613
- incompleteLine = incomplete, isFirstChunk = false;
23614
- }
23615
- function parseLine(line) {
23616
- if (line === "") {
23616
+ const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];
23617
+ let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
23618
+ function feed(chunk) {
23619
+ if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
23620
+ const trailing2 = processLines(chunk);
23621
+ trailing2 !== "" && pendingFragments.push(trailing2);
23622
+ return;
23623
+ }
23624
+ if (chunk.indexOf(`
23625
+ `) === -1 && chunk.indexOf("\r") === -1) {
23626
+ pendingFragments.push(chunk);
23627
+ return;
23628
+ }
23629
+ pendingFragments.push(chunk);
23630
+ const input = pendingFragments.join("");
23631
+ pendingFragments.length = 0;
23632
+ const trailing = processLines(input);
23633
+ trailing !== "" && pendingFragments.push(trailing);
23634
+ }
23635
+ function processLines(chunk) {
23636
+ let searchIndex = 0;
23637
+ if (chunk.indexOf("\r") === -1) {
23638
+ let lfIndex = chunk.indexOf(`
23639
+ `, searchIndex);
23640
+ for (; lfIndex !== -1; ) {
23641
+ if (searchIndex === lfIndex) {
23642
+ dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
23643
+ `, searchIndex);
23644
+ continue;
23645
+ }
23646
+ const firstCharCode = chunk.charCodeAt(searchIndex);
23647
+ if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
23648
+ const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
23649
+ if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
23650
+ onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
23651
+ `, searchIndex);
23652
+ continue;
23653
+ }
23654
+ data = dataLines === 0 ? value : `${data}
23655
+ ${value}`, dataLines++;
23656
+ } else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
23657
+ chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
23658
+ lfIndex
23659
+ ) || void 0 : parseLine(chunk, searchIndex, lfIndex);
23660
+ searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
23661
+ `, searchIndex);
23662
+ }
23663
+ return chunk.slice(searchIndex);
23664
+ }
23665
+ for (; searchIndex < chunk.length; ) {
23666
+ const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
23667
+ `, searchIndex);
23668
+ let lineEnd = -1;
23669
+ 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)
23670
+ break;
23671
+ parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
23672
+ }
23673
+ return chunk.slice(searchIndex);
23674
+ }
23675
+ function parseLine(chunk, start, end) {
23676
+ if (start === end) {
23617
23677
  dispatchEvent();
23618
23678
  return;
23619
23679
  }
23620
- if (line.startsWith(":")) {
23621
- onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
23680
+ const firstCharCode = chunk.charCodeAt(start);
23681
+ if (isDataPrefix(chunk, start, firstCharCode)) {
23682
+ const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
23683
+ data = dataLines === 0 ? value2 : `${data}
23684
+ ${value2}`, dataLines++;
23685
+ return;
23686
+ }
23687
+ if (isEventPrefix(chunk, start, firstCharCode)) {
23688
+ eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
23622
23689
  return;
23623
23690
  }
23624
- const fieldSeparatorIndex = line.indexOf(":");
23625
- if (fieldSeparatorIndex !== -1) {
23626
- const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
23627
- processField(field, value, line);
23691
+ if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
23692
+ const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
23693
+ id = value2.includes("\0") ? void 0 : value2;
23694
+ return;
23695
+ }
23696
+ if (firstCharCode === 58) {
23697
+ if (onComment) {
23698
+ const line2 = chunk.slice(start, end);
23699
+ onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
23700
+ }
23701
+ return;
23702
+ }
23703
+ const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
23704
+ if (fieldSeparatorIndex === -1) {
23705
+ processField(line, "", line);
23628
23706
  return;
23629
23707
  }
23630
- processField(line, "", line);
23708
+ const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
23709
+ processField(field, value, line);
23631
23710
  }
23632
23711
  function processField(field, value, line) {
23633
23712
  switch (field) {
23634
23713
  case "event":
23635
- eventType = value;
23714
+ eventType = value || void 0;
23636
23715
  break;
23637
23716
  case "data":
23638
- data = `${data}${value}
23639
- `;
23717
+ data = dataLines === 0 ? value : `${data}
23718
+ ${value}`, dataLines++;
23640
23719
  break;
23641
23720
  case "id":
23642
23721
  id = value.includes("\0") ? void 0 : value;
@@ -23661,37 +23740,26 @@ function createParser(callbacks) {
23661
23740
  }
23662
23741
  }
23663
23742
  function dispatchEvent() {
23664
- data.length > 0 && onEvent({
23743
+ dataLines > 0 && onEvent({
23665
23744
  id,
23666
- event: eventType || void 0,
23667
- // If the data buffer's last character is a U+000A LINE FEED (LF) character,
23668
- // then remove the last character from the data buffer.
23669
- data: data.endsWith(`
23670
- `) ? data.slice(0, -1) : data
23671
- }), id = void 0, data = "", eventType = "";
23745
+ event: eventType,
23746
+ data
23747
+ }), id = void 0, data = "", dataLines = 0, eventType = void 0;
23672
23748
  }
23673
23749
  function reset(options = {}) {
23674
- incompleteLine && options.consume && parseLine(incompleteLine), isFirstChunk = true, id = void 0, data = "", eventType = "", incompleteLine = "";
23750
+ if (options.consume && pendingFragments.length > 0) {
23751
+ const incompleteLine = pendingFragments.join("");
23752
+ parseLine(incompleteLine, 0, incompleteLine.length);
23753
+ }
23754
+ isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
23675
23755
  }
23676
23756
  return { feed, reset };
23677
23757
  }
23678
- function splitLines(chunk) {
23679
- const lines = [];
23680
- let incompleteLine = "", searchIndex = 0;
23681
- for (; searchIndex < chunk.length; ) {
23682
- const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
23683
- `, searchIndex);
23684
- let lineEnd = -1;
23685
- 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) {
23686
- incompleteLine = chunk.slice(searchIndex);
23687
- break;
23688
- } else {
23689
- const line = chunk.slice(searchIndex, lineEnd);
23690
- lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
23691
- ` && searchIndex++;
23692
- }
23693
- }
23694
- return [lines, incompleteLine];
23758
+ function isDataPrefix(chunk, i, firstCharCode) {
23759
+ return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
23760
+ }
23761
+ function isEventPrefix(chunk, i, firstCharCode) {
23762
+ 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;
23695
23763
  }
23696
23764
  var EventSourceParserStream = class extends TransformStream {
23697
23765
  constructor({ onError, onRetry, onComment } = {}) {
@@ -28777,7 +28845,7 @@ var object3 = ({
28777
28845
  };
28778
28846
  };
28779
28847
  var external_exports3 = {};
28780
- chunkPXYR3D6L_cjs.__export(external_exports3, {
28848
+ __export(external_exports3, {
28781
28849
  $brand: () => $brand2,
28782
28850
  $input: () => $input2,
28783
28851
  $output: () => $output2,
@@ -28987,7 +29055,7 @@ chunkPXYR3D6L_cjs.__export(external_exports3, {
28987
29055
  xid: () => xid4
28988
29056
  });
28989
29057
  var core_exports4 = {};
28990
- chunkPXYR3D6L_cjs.__export(core_exports4, {
29058
+ __export(core_exports4, {
28991
29059
  $ZodAny: () => $ZodAny2,
28992
29060
  $ZodArray: () => $ZodArray2,
28993
29061
  $ZodAsyncError: () => $ZodAsyncError2,
@@ -29287,7 +29355,7 @@ function config2(newConfig) {
29287
29355
  return globalConfig2;
29288
29356
  }
29289
29357
  var util_exports2 = {};
29290
- chunkPXYR3D6L_cjs.__export(util_exports2, {
29358
+ __export(util_exports2, {
29291
29359
  BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES2,
29292
29360
  Class: () => Class2,
29293
29361
  NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES2,
@@ -29997,7 +30065,7 @@ var _safeParseAsync2 = (_Err) => async (schema, value, _ctx) => {
29997
30065
  };
29998
30066
  var safeParseAsync3 = /* @__PURE__ */ _safeParseAsync2($ZodRealError2);
29999
30067
  var regexes_exports2 = {};
30000
- chunkPXYR3D6L_cjs.__export(regexes_exports2, {
30068
+ __export(regexes_exports2, {
30001
30069
  _emoji: () => _emoji3,
30002
30070
  base64: () => base643,
30003
30071
  base64url: () => base64url3,
@@ -32308,7 +32376,7 @@ function handleRefineResult2(result, payload, input, inst) {
32308
32376
  }
32309
32377
  }
32310
32378
  var locales_exports2 = {};
32311
- chunkPXYR3D6L_cjs.__export(locales_exports2, {
32379
+ __export(locales_exports2, {
32312
32380
  ar: () => ar_default2,
32313
32381
  az: () => az_default2,
32314
32382
  be: () => be_default2,
@@ -38725,7 +38793,7 @@ function isTransforming2(_schema, _ctx) {
38725
38793
  }
38726
38794
  var json_schema_exports2 = {};
38727
38795
  var iso_exports2 = {};
38728
- chunkPXYR3D6L_cjs.__export(iso_exports2, {
38796
+ __export(iso_exports2, {
38729
38797
  ZodISODate: () => ZodISODate2,
38730
38798
  ZodISODateTime: () => ZodISODateTime2,
38731
38799
  ZodISODuration: () => ZodISODuration2,
@@ -39756,7 +39824,7 @@ function getErrorMap4() {
39756
39824
  return config2().customError;
39757
39825
  }
39758
39826
  var coerce_exports2 = {};
39759
- chunkPXYR3D6L_cjs.__export(coerce_exports2, {
39827
+ __export(coerce_exports2, {
39760
39828
  bigint: () => bigint6,
39761
39829
  boolean: () => boolean6,
39762
39830
  date: () => date8,
@@ -39984,9 +40052,9 @@ var ParseError2 = class extends Error {
39984
40052
  super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
39985
40053
  }
39986
40054
  };
39987
- var LF = 10;
39988
- var CR = 13;
39989
- var SPACE = 32;
40055
+ var LF2 = 10;
40056
+ var CR2 = 13;
40057
+ var SPACE2 = 32;
39990
40058
  function noop2(_arg) {
39991
40059
  }
39992
40060
  function createParser2(callbacks) {
@@ -40025,17 +40093,17 @@ function createParser2(callbacks) {
40025
40093
  continue;
40026
40094
  }
40027
40095
  const firstCharCode = chunk.charCodeAt(searchIndex);
40028
- if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
40029
- const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
40030
- if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
40096
+ if (isDataPrefix2(chunk, searchIndex, firstCharCode)) {
40097
+ const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE2 ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
40098
+ if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF2) {
40031
40099
  onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
40032
40100
  `, searchIndex);
40033
40101
  continue;
40034
40102
  }
40035
40103
  data = dataLines === 0 ? value : `${data}
40036
40104
  ${value}`, dataLines++;
40037
- } else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
40038
- chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
40105
+ } else isEventPrefix2(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
40106
+ chunk.charCodeAt(searchIndex + 6) === SPACE2 ? searchIndex + 7 : searchIndex + 6,
40039
40107
  lfIndex
40040
40108
  ) || void 0 : parseLine(chunk, searchIndex, lfIndex);
40041
40109
  searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
@@ -40049,7 +40117,7 @@ ${value}`, dataLines++;
40049
40117
  let lineEnd = -1;
40050
40118
  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)
40051
40119
  break;
40052
- parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
40120
+ parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR2 && chunk.charCodeAt(searchIndex) === LF2 && searchIndex++;
40053
40121
  }
40054
40122
  return chunk.slice(searchIndex);
40055
40123
  }
@@ -40059,25 +40127,25 @@ ${value}`, dataLines++;
40059
40127
  return;
40060
40128
  }
40061
40129
  const firstCharCode = chunk.charCodeAt(start);
40062
- if (isDataPrefix(chunk, start, firstCharCode)) {
40063
- const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
40130
+ if (isDataPrefix2(chunk, start, firstCharCode)) {
40131
+ const valueStart = chunk.charCodeAt(start + 5) === SPACE2 ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
40064
40132
  data = dataLines === 0 ? value2 : `${data}
40065
40133
  ${value2}`, dataLines++;
40066
40134
  return;
40067
40135
  }
40068
- if (isEventPrefix(chunk, start, firstCharCode)) {
40069
- eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
40136
+ if (isEventPrefix2(chunk, start, firstCharCode)) {
40137
+ eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE2 ? start + 7 : start + 6, end) || void 0;
40070
40138
  return;
40071
40139
  }
40072
40140
  if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
40073
- const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
40141
+ const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE2 ? start + 4 : start + 3, end);
40074
40142
  id = value2.includes("\0") ? void 0 : value2;
40075
40143
  return;
40076
40144
  }
40077
40145
  if (firstCharCode === 58) {
40078
40146
  if (onComment) {
40079
40147
  const line2 = chunk.slice(start, end);
40080
- onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
40148
+ onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE2 ? 2 : 1));
40081
40149
  }
40082
40150
  return;
40083
40151
  }
@@ -40086,7 +40154,7 @@ ${value2}`, dataLines++;
40086
40154
  processField(line, "", line);
40087
40155
  return;
40088
40156
  }
40089
- const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
40157
+ const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE2 ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
40090
40158
  processField(field, value, line);
40091
40159
  }
40092
40160
  function processField(field, value, line) {
@@ -40136,10 +40204,10 @@ ${value}`, dataLines++;
40136
40204
  }
40137
40205
  return { feed, reset };
40138
40206
  }
40139
- function isDataPrefix(chunk, i, firstCharCode) {
40207
+ function isDataPrefix2(chunk, i, firstCharCode) {
40140
40208
  return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
40141
40209
  }
40142
- function isEventPrefix(chunk, i, firstCharCode) {
40210
+ function isEventPrefix2(chunk, i, firstCharCode) {
40143
40211
  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;
40144
40212
  }
40145
40213
  var EventSourceParserStream2 = class extends TransformStream {
@@ -46341,8 +46409,8 @@ function formatTimestamp(date9) {
46341
46409
  return date9.toISOString().replace("T", " ").replace(/\.\d{3}Z$/, "Z");
46342
46410
  }
46343
46411
  function truncateByTokens(text42, maxTokens, hint) {
46344
- if (chunkAPV6QKRZ_cjs.estimateTokenCount(text42) <= maxTokens) return { text: text42, wasTruncated: false };
46345
- const truncated = chunkAPV6QKRZ_cjs.truncateStringByTokens(text42, maxTokens);
46412
+ if (chunk4W7KQRF5_cjs.estimateTokenCount(text42) <= maxTokens) return { text: text42, wasTruncated: false };
46413
+ const truncated = chunk4W7KQRF5_cjs.truncateStringByTokens(text42, maxTokens);
46346
46414
  const suffix = hint ? ` [${hint} for more]` : "";
46347
46415
  return { text: truncated + suffix, wasTruncated: true };
46348
46416
  }
@@ -46394,11 +46462,11 @@ ${JSON.stringify(inv.args, null, 2)}`;
46394
46462
  });
46395
46463
  }
46396
46464
  if (inv.state === "result") {
46397
- const { value: resultValue } = chunkAPV6QKRZ_cjs.resolveToolResultValue(
46465
+ const { value: resultValue } = chunk4W7KQRF5_cjs.resolveToolResultValue(
46398
46466
  part,
46399
46467
  inv.result
46400
46468
  );
46401
- const resultStr = chunkAPV6QKRZ_cjs.formatToolResultForObserver(resultValue, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
46469
+ const resultStr = chunk4W7KQRF5_cjs.formatToolResultForObserver(resultValue, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
46402
46470
  const fullText = `[Tool Result: ${inv.toolName}]
46403
46471
  ${resultStr}`;
46404
46472
  parts.push(makePart(msg, i, "tool-result", fullText, detail, inv.toolName));
@@ -46425,7 +46493,7 @@ ${typeof rawArgs === "string" ? rawArgs : JSON.stringify(rawArgs, null, 2)}`;
46425
46493
  const toolName = part.toolName;
46426
46494
  if (toolName) {
46427
46495
  const rawResult = part.output ?? part.result;
46428
- const resultStr = chunkAPV6QKRZ_cjs.formatToolResultForObserver(rawResult, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
46496
+ const resultStr = chunk4W7KQRF5_cjs.formatToolResultForObserver(rawResult, { maxTokens: HIGH_DETAIL_TOOL_RESULT_TOKENS });
46429
46497
  const fullText = `[Tool Result: ${toolName}]
46430
46498
  ${resultStr}`;
46431
46499
  parts.push(makePart(msg, i, "tool-result", fullText, detail, toolName));
@@ -46503,9 +46571,9 @@ function expandPriority(part) {
46503
46571
  }
46504
46572
  function renderFormattedParts(parts, timestamps, options) {
46505
46573
  const text42 = buildRenderedText(parts, timestamps);
46506
- let totalTokens = chunkAPV6QKRZ_cjs.estimateTokenCount(text42);
46574
+ let totalTokens = chunk4W7KQRF5_cjs.estimateTokenCount(text42);
46507
46575
  if (totalTokens > options.maxTokens) {
46508
- const truncated = chunkAPV6QKRZ_cjs.truncateStringByTokens(text42, options.maxTokens);
46576
+ const truncated = chunk4W7KQRF5_cjs.truncateStringByTokens(text42, options.maxTokens);
46509
46577
  return { text: truncated, truncated: true, tokenOffset: totalTokens - options.maxTokens };
46510
46578
  }
46511
46579
  const truncatedIndices = parts.map((p, i) => ({ part: p, index: i })).filter(({ part }) => part.text !== part.fullText).sort((a, b) => expandPriority(a.part) - expandPriority(b.part));
@@ -46516,8 +46584,8 @@ function renderFormattedParts(parts, timestamps, options) {
46516
46584
  for (const { part, index } of truncatedIndices) {
46517
46585
  if (remaining <= 0) break;
46518
46586
  const maxTokens = expandLimit(part);
46519
- const fullTokens = chunkAPV6QKRZ_cjs.estimateTokenCount(part.fullText);
46520
- const currentTokens = chunkAPV6QKRZ_cjs.estimateTokenCount(part.text);
46587
+ const fullTokens = chunk4W7KQRF5_cjs.estimateTokenCount(part.fullText);
46588
+ const currentTokens = chunk4W7KQRF5_cjs.estimateTokenCount(part.text);
46521
46589
  const targetTokens = Math.min(fullTokens, maxTokens);
46522
46590
  const delta = targetTokens - currentTokens;
46523
46591
  if (delta <= 0) continue;
@@ -46528,17 +46596,17 @@ function renderFormattedParts(parts, timestamps, options) {
46528
46596
  const expandedLimit = Math.min(currentTokens + remaining, maxTokens);
46529
46597
  const hint = `recall cursor="${part.messageId}" partIndex=${part.partIndex} detail="high"`;
46530
46598
  const { text: expanded2 } = truncateByTokens(part.fullText, expandedLimit, hint);
46531
- const expandedDelta = chunkAPV6QKRZ_cjs.estimateTokenCount(expanded2) - currentTokens;
46599
+ const expandedDelta = chunk4W7KQRF5_cjs.estimateTokenCount(expanded2) - currentTokens;
46532
46600
  parts[index] = { ...part, text: expanded2 };
46533
46601
  remaining -= expandedDelta;
46534
46602
  }
46535
46603
  }
46536
46604
  const expanded = buildRenderedText(parts, timestamps);
46537
- const expandedTokens = chunkAPV6QKRZ_cjs.estimateTokenCount(expanded);
46605
+ const expandedTokens = chunk4W7KQRF5_cjs.estimateTokenCount(expanded);
46538
46606
  if (expandedTokens <= options.maxTokens) {
46539
46607
  return { text: expanded, truncated: false, tokenOffset: 0 };
46540
46608
  }
46541
- const hardTruncated = chunkAPV6QKRZ_cjs.truncateStringByTokens(expanded, options.maxTokens);
46609
+ const hardTruncated = chunk4W7KQRF5_cjs.truncateStringByTokens(expanded, options.maxTokens);
46542
46610
  return { text: hardTruncated, truncated: true, tokenOffset: expandedTokens - options.maxTokens };
46543
46611
  }
46544
46612
  async function recallPart({
@@ -46589,7 +46657,7 @@ async function recallPart({
46589
46657
 
46590
46658
  `;
46591
46659
  const fallbackText = `${fallbackNote}${firstNextPart.text}`;
46592
- const truncatedText2 = chunkAPV6QKRZ_cjs.truncateStringByTokens(fallbackText, maxTokens);
46660
+ const truncatedText2 = chunk4W7KQRF5_cjs.truncateStringByTokens(fallbackText, maxTokens);
46593
46661
  const wasTruncated2 = truncatedText2 !== fallbackText;
46594
46662
  return {
46595
46663
  text: truncatedText2,
@@ -46604,7 +46672,7 @@ async function recallPart({
46604
46672
  }
46605
46673
  throw new Error(`Part index ${partIndex} not found in message ${cursor}. Available indices: ${availableIndices}`);
46606
46674
  }
46607
- const truncatedText = chunkAPV6QKRZ_cjs.truncateStringByTokens(target.text, maxTokens);
46675
+ const truncatedText = chunk4W7KQRF5_cjs.truncateStringByTokens(target.text, maxTokens);
46608
46676
  const wasTruncated = truncatedText !== target.text;
46609
46677
  return {
46610
46678
  text: truncatedText,
@@ -47110,6 +47178,8 @@ var recallTool = (_memoryConfig, options) => {
47110
47178
  }
47111
47179
  });
47112
47180
  };
47181
+ var UPDATE_WORKING_MEMORY_TOOL_NAME = "updateWorkingMemory";
47182
+ var SET_WORKING_MEMORY_TOOL_NAME = "setWorkingMemory";
47113
47183
  function deepMergeWorkingMemory(existing, update) {
47114
47184
  if (!update || typeof update !== "object" || Object.keys(update).length === 0) {
47115
47185
  return existing && typeof existing === "object" ? { ...existing } : {};
@@ -47201,7 +47271,9 @@ var updateWorkingMemoryTool = (memoryConfig) => {
47201
47271
  };
47202
47272
  }
47203
47273
  const usesMergeSemantics = Boolean(schema$1);
47204
- const description = schema$1 ? `Update the working memory with new information. Data is merged with existing memory - only include fields you want to add or update. To preserve existing data, omit the field entirely. Arrays are replaced entirely when provided, so pass the complete array or omit it to keep the existing values.` : `Update the working memory with new information. Any data not included will be overwritten. Always pass data as string to the memory field. Never pass an object.`;
47274
+ const useStateSignals = memoryConfig?.workingMemory?.useStateSignals === true;
47275
+ const stateSignalsPreamble = `The current working memory state is delivered to you each turn by the system inside a <working-memory>...</working-memory> block. That block is system-emitted state, NOT something the user typed \u2014 never describe it as the user sharing it. Read from it directly when answering. Only call this tool when the user provides genuinely NEW or CHANGED facts that should be persisted; do NOT call it to re-save unchanged data.`;
47276
+ const description = schema$1 ? useStateSignals ? `${stateSignalsPreamble} Data is merged with existing memory \u2014 only include fields you want to add or update.` : `Update the working memory with new information. Data is merged with existing memory - only include fields you want to add or update. To preserve existing data, omit the field entirely. Arrays are replaced entirely when provided, so pass the complete array or omit it to keep the existing values.` : useStateSignals ? `${stateSignalsPreamble} Pass the full updated Markdown blob as a string in the memory field.` : `Update the working memory with new information. Any data not included will be overwritten. Always pass data as string to the memory field. Never pass an object.`;
47205
47277
  return tools.createTool({
47206
47278
  id: "update-working-memory",
47207
47279
  description,
@@ -47380,6 +47452,12 @@ var __experimental_updateWorkingMemoryToolVNext = (config3) => {
47380
47452
  }
47381
47453
  });
47382
47454
  };
47455
+ function createWorkingMemoryTool(config3, options = {}) {
47456
+ const useStateSignals = config3.workingMemory?.useStateSignals === true;
47457
+ const tool32 = options.vNext ? __experimental_updateWorkingMemoryToolVNext(config3) : updateWorkingMemoryTool(config3);
47458
+ const name21 = useStateSignals ? SET_WORKING_MEMORY_TOOL_NAME : UPDATE_WORKING_MEMORY_TOOL_NAME;
47459
+ return { name: name21, tool: tool32 };
47460
+ }
47383
47461
  var WORKING_MEMORY_START_TAG = "<working_memory>";
47384
47462
  var WORKING_MEMORY_END_TAG = "</working_memory>";
47385
47463
  var LEGACY_SYSTEM_REMINDER_METADATA_KEY = "dynamicAgentsMdReminder";
@@ -47484,6 +47562,7 @@ var Memory = class extends memory.MastraMemory {
47484
47562
  },
47485
47563
  observationalMemory: config3.options?.observationalMemory
47486
47564
  });
47565
+ this.assertWorkingMemoryStateSignalsCompatibility(mergedConfig);
47487
47566
  this.threadConfig = mergedConfig;
47488
47567
  const omConfig = normalizeObservationalMemoryConfig(mergedConfig.observationalMemory);
47489
47568
  if (omConfig?.retrieval && typeof omConfig.retrieval === "object" && omConfig.retrieval.vector) {
@@ -47851,6 +47930,7 @@ var Memory = class extends memory.MastraMemory {
47851
47930
  memoryConfig
47852
47931
  }) {
47853
47932
  const config3 = this.getMergedThreadConfig(memoryConfig || {});
47933
+ this.assertWorkingMemoryStateSignalsCompatibility(config3);
47854
47934
  if (!config3.workingMemory?.enabled) {
47855
47935
  throw new Error("Working memory is not enabled for this memory instance");
47856
47936
  }
@@ -47962,7 +48042,7 @@ ${workingMemory}`;
47962
48042
  }
47963
48043
  return chunks;
47964
48044
  }
47965
- hasher = chunkAPV6QKRZ_cjs.e();
48045
+ hasher = chunk4W7KQRF5_cjs.e();
47966
48046
  // embedding is computationally expensive so cache content -> embeddings/chunks
47967
48047
  embeddingCache = /* @__PURE__ */ new Map();
47968
48048
  firstEmbed;
@@ -48230,9 +48310,13 @@ ${workingMemory}`;
48230
48310
  memoryConfig
48231
48311
  }) {
48232
48312
  const config3 = this.getMergedThreadConfig(memoryConfig);
48313
+ this.assertWorkingMemoryStateSignalsCompatibility(config3);
48233
48314
  if (!config3.workingMemory?.enabled) {
48234
48315
  return null;
48235
48316
  }
48317
+ if (config3.workingMemory?.useStateSignals) {
48318
+ return null;
48319
+ }
48236
48320
  const workingMemoryTemplate = await this.getWorkingMemoryTemplate({ memoryConfig });
48237
48321
  const workingMemoryData = await this.getWorkingMemory({ threadId, resourceId, memoryConfig: config3 });
48238
48322
  if (!workingMemoryTemplate) {
@@ -48294,7 +48378,7 @@ ${workingMemory}`;
48294
48378
  if (obsSystemMessage) {
48295
48379
  systemParts.push(obsSystemMessage);
48296
48380
  }
48297
- const { OBSERVATION_CONTINUATION_HINT } = await import('./constants-SPS7MR4D-ZMHAFWSH.cjs');
48381
+ const { OBSERVATION_CONTINUATION_HINT } = await import('./constants-DVRTNEGY-ZGCNETZ3.cjs');
48298
48382
  continuationMessage = {
48299
48383
  id: "om-continuation",
48300
48384
  role: "user",
@@ -48396,7 +48480,7 @@ ${workingMemory}`;
48396
48480
  "Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
48397
48481
  );
48398
48482
  }
48399
- const { ObservationalMemory: OMClass } = await import('./observational-memory-TJFOX3YN-A2QE2E3I.cjs');
48483
+ const { ObservationalMemory: OMClass } = await import('./observational-memory-G52HNRHE-73KIWQ2G.cjs');
48400
48484
  const onIndexObservations = this.hasRetrievalSearch(omConfig.retrieval) ? async (observation) => {
48401
48485
  await this.indexObservation(observation);
48402
48486
  } : void 0;
@@ -48547,6 +48631,13 @@ Notes:
48547
48631
  const isMDWorkingMemory = !(`schema` in config3.workingMemory) && (typeof config3.workingMemory.template === `string` || config3.workingMemory.template) && config3.workingMemory;
48548
48632
  return Boolean(isMDWorkingMemory && isMDWorkingMemory.version === `vnext`);
48549
48633
  }
48634
+ assertWorkingMemoryStateSignalsCompatibility(config3) {
48635
+ if (config3?.workingMemory?.useStateSignals === true && this.isVNextWorkingMemoryConfig(config3)) {
48636
+ throw new Error(
48637
+ "workingMemory.useStateSignals is not supported with workingMemory.version: 'vnext'. Use stable template working memory or disable useStateSignals."
48638
+ );
48639
+ }
48640
+ }
48550
48641
  getObservationEmbeddingIndexName(dimensions) {
48551
48642
  const defaultDimensions = 384;
48552
48643
  const usedDimensions = dimensions ?? defaultDimensions;
@@ -48748,9 +48839,13 @@ Notes:
48748
48839
  }
48749
48840
  listTools(config3) {
48750
48841
  const mergedConfig = this.getMergedThreadConfig(config3);
48842
+ this.assertWorkingMemoryStateSignalsCompatibility(mergedConfig);
48751
48843
  const tools = {};
48752
48844
  if (mergedConfig.workingMemory?.enabled && !mergedConfig.readOnly) {
48753
- tools.updateWorkingMemory = this.isVNextWorkingMemoryConfig(mergedConfig) ? __experimental_updateWorkingMemoryToolVNext(mergedConfig) : updateWorkingMemoryTool(mergedConfig);
48845
+ const { name: name21, tool: tool32 } = createWorkingMemoryTool(mergedConfig, {
48846
+ vNext: this.isVNextWorkingMemoryConfig(mergedConfig)
48847
+ });
48848
+ tools[name21] = tool32;
48754
48849
  }
48755
48850
  const omConfig = normalizeObservationalMemoryConfig(mergedConfig.observationalMemory);
48756
48851
  if (omConfig?.retrieval) {
@@ -49296,6 +49391,10 @@ Notes:
49296
49391
  if (om) {
49297
49392
  processors.push(om);
49298
49393
  }
49394
+ const wm = await this.createWorkingMemoryStateProcessor(configuredProcessors, context2);
49395
+ if (wm) {
49396
+ processors.push(wm);
49397
+ }
49299
49398
  return processors;
49300
49399
  }
49301
49400
  /**
@@ -49333,11 +49432,29 @@ Notes:
49333
49432
  if (!effectiveConfig) return null;
49334
49433
  const engine = await this.omEngine;
49335
49434
  if (!engine) return null;
49336
- const { ObservationalMemoryProcessor } = await import('./observational-memory-TJFOX3YN-A2QE2E3I.cjs');
49435
+ const { ObservationalMemoryProcessor } = await import('./observational-memory-G52HNRHE-73KIWQ2G.cjs');
49337
49436
  return new ObservationalMemoryProcessor(engine, this, {
49338
49437
  temporalMarkers: effectiveConfig.temporalMarkers
49339
49438
  });
49340
49439
  }
49440
+ /**
49441
+ * Creates a WorkingMemoryStateProcessor when working memory is enabled and the
49442
+ * `useStateSignals` opt-in is set. Returns null otherwise or if the processor
49443
+ * is already present in the user's configured processors.
49444
+ */
49445
+ async createWorkingMemoryStateProcessor(configuredProcessors = [], context2) {
49446
+ const runtimeMemory = context2?.get("MastraMemory");
49447
+ const mergedConfig = this.getMergedThreadConfig(runtimeMemory?.memoryConfig);
49448
+ this.assertWorkingMemoryStateSignalsCompatibility(mergedConfig);
49449
+ if (!mergedConfig.workingMemory?.enabled) return null;
49450
+ if (!mergedConfig.workingMemory?.useStateSignals) return null;
49451
+ const { WORKING_MEMORY_STATE_PROCESSOR_ID: WORKING_MEMORY_STATE_PROCESSOR_ID2, WorkingMemoryStateProcessor: WorkingMemoryStateProcessor2 } = await import('./working-memory-state-J7ASTNXX-WEIO7C67.cjs');
49452
+ const alreadyConfigured = configuredProcessors.some(
49453
+ (p) => !("workflow" in p) && p.id === WORKING_MEMORY_STATE_PROCESSOR_ID2
49454
+ );
49455
+ if (alreadyConfigured) return null;
49456
+ return new WorkingMemoryStateProcessor2(this, runtimeMemory?.memoryConfig);
49457
+ }
49341
49458
  };
49342
49459
 
49343
49460
  // ../agent-builder/dist/index.js
@@ -54284,6 +54401,9 @@ var ParseError3 = class extends Error {
54284
54401
  super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
54285
54402
  }
54286
54403
  };
54404
+ var LF3 = 10;
54405
+ var CR3 = 13;
54406
+ var SPACE3 = 32;
54287
54407
  function noop3(_arg) {
54288
54408
  }
54289
54409
  function createParser3(callbacks) {
@@ -54291,39 +54411,109 @@ function createParser3(callbacks) {
54291
54411
  throw new TypeError(
54292
54412
  "`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
54293
54413
  );
54294
- const { onEvent = noop3, onError = noop3, onRetry = noop3, onComment } = callbacks;
54295
- let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = "";
54296
- function feed(newChunk) {
54297
- const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines2(`${incompleteLine}${chunk}`);
54298
- for (const line of complete)
54299
- parseLine(line);
54300
- incompleteLine = incomplete, isFirstChunk = false;
54301
- }
54302
- function parseLine(line) {
54303
- if (line === "") {
54414
+ const { onEvent = noop3, onError = noop3, onRetry = noop3, onComment } = callbacks, pendingFragments = [];
54415
+ let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
54416
+ function feed(chunk) {
54417
+ if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
54418
+ const trailing2 = processLines(chunk);
54419
+ trailing2 !== "" && pendingFragments.push(trailing2);
54420
+ return;
54421
+ }
54422
+ if (chunk.indexOf(`
54423
+ `) === -1 && chunk.indexOf("\r") === -1) {
54424
+ pendingFragments.push(chunk);
54425
+ return;
54426
+ }
54427
+ pendingFragments.push(chunk);
54428
+ const input = pendingFragments.join("");
54429
+ pendingFragments.length = 0;
54430
+ const trailing = processLines(input);
54431
+ trailing !== "" && pendingFragments.push(trailing);
54432
+ }
54433
+ function processLines(chunk) {
54434
+ let searchIndex = 0;
54435
+ if (chunk.indexOf("\r") === -1) {
54436
+ let lfIndex = chunk.indexOf(`
54437
+ `, searchIndex);
54438
+ for (; lfIndex !== -1; ) {
54439
+ if (searchIndex === lfIndex) {
54440
+ dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
54441
+ `, searchIndex);
54442
+ continue;
54443
+ }
54444
+ const firstCharCode = chunk.charCodeAt(searchIndex);
54445
+ if (isDataPrefix3(chunk, searchIndex, firstCharCode)) {
54446
+ const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE3 ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
54447
+ if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF3) {
54448
+ onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
54449
+ `, searchIndex);
54450
+ continue;
54451
+ }
54452
+ data = dataLines === 0 ? value : `${data}
54453
+ ${value}`, dataLines++;
54454
+ } else isEventPrefix3(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
54455
+ chunk.charCodeAt(searchIndex + 6) === SPACE3 ? searchIndex + 7 : searchIndex + 6,
54456
+ lfIndex
54457
+ ) || void 0 : parseLine(chunk, searchIndex, lfIndex);
54458
+ searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
54459
+ `, searchIndex);
54460
+ }
54461
+ return chunk.slice(searchIndex);
54462
+ }
54463
+ for (; searchIndex < chunk.length; ) {
54464
+ const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
54465
+ `, searchIndex);
54466
+ let lineEnd = -1;
54467
+ 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)
54468
+ break;
54469
+ parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR3 && chunk.charCodeAt(searchIndex) === LF3 && searchIndex++;
54470
+ }
54471
+ return chunk.slice(searchIndex);
54472
+ }
54473
+ function parseLine(chunk, start, end) {
54474
+ if (start === end) {
54304
54475
  dispatchEvent();
54305
54476
  return;
54306
54477
  }
54307
- if (line.startsWith(":")) {
54308
- onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
54478
+ const firstCharCode = chunk.charCodeAt(start);
54479
+ if (isDataPrefix3(chunk, start, firstCharCode)) {
54480
+ const valueStart = chunk.charCodeAt(start + 5) === SPACE3 ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
54481
+ data = dataLines === 0 ? value2 : `${data}
54482
+ ${value2}`, dataLines++;
54309
54483
  return;
54310
54484
  }
54311
- const fieldSeparatorIndex = line.indexOf(":");
54312
- if (fieldSeparatorIndex !== -1) {
54313
- const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
54314
- processField(field, value, line);
54485
+ if (isEventPrefix3(chunk, start, firstCharCode)) {
54486
+ eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE3 ? start + 7 : start + 6, end) || void 0;
54315
54487
  return;
54316
54488
  }
54317
- processField(line, "", line);
54489
+ if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
54490
+ const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE3 ? start + 4 : start + 3, end);
54491
+ id = value2.includes("\0") ? void 0 : value2;
54492
+ return;
54493
+ }
54494
+ if (firstCharCode === 58) {
54495
+ if (onComment) {
54496
+ const line2 = chunk.slice(start, end);
54497
+ onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE3 ? 2 : 1));
54498
+ }
54499
+ return;
54500
+ }
54501
+ const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
54502
+ if (fieldSeparatorIndex === -1) {
54503
+ processField(line, "", line);
54504
+ return;
54505
+ }
54506
+ const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE3 ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
54507
+ processField(field, value, line);
54318
54508
  }
54319
54509
  function processField(field, value, line) {
54320
54510
  switch (field) {
54321
54511
  case "event":
54322
- eventType = value;
54512
+ eventType = value || void 0;
54323
54513
  break;
54324
54514
  case "data":
54325
- data = `${data}${value}
54326
- `;
54515
+ data = dataLines === 0 ? value : `${data}
54516
+ ${value}`, dataLines++;
54327
54517
  break;
54328
54518
  case "id":
54329
54519
  id = value.includes("\0") ? void 0 : value;
@@ -54348,37 +54538,26 @@ function createParser3(callbacks) {
54348
54538
  }
54349
54539
  }
54350
54540
  function dispatchEvent() {
54351
- data.length > 0 && onEvent({
54541
+ dataLines > 0 && onEvent({
54352
54542
  id,
54353
- event: eventType || void 0,
54354
- // If the data buffer's last character is a U+000A LINE FEED (LF) character,
54355
- // then remove the last character from the data buffer.
54356
- data: data.endsWith(`
54357
- `) ? data.slice(0, -1) : data
54358
- }), id = void 0, data = "", eventType = "";
54543
+ event: eventType,
54544
+ data
54545
+ }), id = void 0, data = "", dataLines = 0, eventType = void 0;
54359
54546
  }
54360
54547
  function reset(options = {}) {
54361
- incompleteLine && options.consume && parseLine(incompleteLine), isFirstChunk = true, id = void 0, data = "", eventType = "", incompleteLine = "";
54548
+ if (options.consume && pendingFragments.length > 0) {
54549
+ const incompleteLine = pendingFragments.join("");
54550
+ parseLine(incompleteLine, 0, incompleteLine.length);
54551
+ }
54552
+ isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
54362
54553
  }
54363
54554
  return { feed, reset };
54364
54555
  }
54365
- function splitLines2(chunk) {
54366
- const lines = [];
54367
- let incompleteLine = "", searchIndex = 0;
54368
- for (; searchIndex < chunk.length; ) {
54369
- const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
54370
- `, searchIndex);
54371
- let lineEnd = -1;
54372
- 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) {
54373
- incompleteLine = chunk.slice(searchIndex);
54374
- break;
54375
- } else {
54376
- const line = chunk.slice(searchIndex, lineEnd);
54377
- lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
54378
- ` && searchIndex++;
54379
- }
54380
- }
54381
- return [lines, incompleteLine];
54556
+ function isDataPrefix3(chunk, i, firstCharCode) {
54557
+ return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
54558
+ }
54559
+ function isEventPrefix3(chunk, i, firstCharCode) {
54560
+ 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;
54382
54561
  }
54383
54562
  var EventSourceParserStream3 = class extends TransformStream {
54384
54563
  constructor({ onError, onRetry, onComment } = {}) {
@@ -60180,5 +60359,5 @@ exports.agentBuilderWorkflows = agentBuilderWorkflows;
60180
60359
  exports.mergeTemplateBySlug = mergeTemplateBySlug;
60181
60360
  exports.planningAndApprovalWorkflow = planningAndApprovalWorkflow;
60182
60361
  exports.workflowBuilderWorkflow = workflowBuilderWorkflow;
60183
- //# sourceMappingURL=dist-LZYJXHUM.cjs.map
60184
- //# sourceMappingURL=dist-LZYJXHUM.cjs.map
60362
+ //# sourceMappingURL=dist-QFLLP7OJ.cjs.map
60363
+ //# sourceMappingURL=dist-QFLLP7OJ.cjs.map