@mastra/ai-sdk 1.4.4-alpha.0 → 1.4.5-alpha.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.
- package/CHANGELOG.md +18 -0
- package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +11 -8
- package/dist/helpers.d.ts.map +1 -1
- package/dist/index.cjs +137 -67
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +137 -67
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @mastra/ai-sdk
|
|
2
2
|
|
|
3
|
+
## 1.4.5-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed client-side tool tracing for useChat by carrying observability context through AI SDK v6 `toolMetadata` on `tool-input-available` stream chunks. ([#17202](https://github.com/mastra-ai/mastra/pull/17202))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`053735a`](https://github.com/mastra-ai/mastra/commit/053735a75c2c18e23ce34d9468007efa4a45f4c4), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`34839c1`](https://github.com/mastra-ai/mastra/commit/34839c1910b6964bf59ed0cee58844efebbb684e), [`a952852`](https://github.com/mastra-ai/mastra/commit/a952852c971a21fb646cd907c75fcf4443cdc963)]:
|
|
10
|
+
- @mastra/core@1.42.0-alpha.3
|
|
11
|
+
|
|
12
|
+
## 1.4.4
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Fixed processor middleware so `args.systemMessages` only contains untagged system messages. Tagged processor-owned system messages stay on the message list and are still included in the final model input. ([#16950](https://github.com/mastra-ai/mastra/pull/16950))
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`fa63872`](https://github.com/mastra-ai/mastra/commit/fa6387280954e6b667bec5714b55ba082bc627ff), [`d779de3`](https://github.com/mastra-ai/mastra/commit/d779de3cd9d2e7ed8110547190e2f15e786a0e41), [`1750c97`](https://github.com/mastra-ai/mastra/commit/1750c975d6179fbf6db2813b15229d4f8f23fc55), [`9283971`](https://github.com/mastra-ai/mastra/commit/928397157009b4aef4d5fdf3a0a273cb371beb55), [`f07b646`](https://github.com/mastra-ai/mastra/commit/f07b64604ab7d25391179790b7fd4823df9e2dff), [`d8838ae`](https://github.com/mastra-ai/mastra/commit/d8838ae80b69780361693d27098f7f6684af12fe), [`40f9297`](https://github.com/mastra-ai/mastra/commit/40f9297003b921c62373d3e8d3a4bda76c9f6de3), [`19a8658`](https://github.com/mastra-ai/mastra/commit/19a86589c788ef48bb6c1b0612cc82a201857379), [`850af77`](https://github.com/mastra-ai/mastra/commit/850af7779cb87c350804488734544a5b1843de25), [`0f0d1ba`](https://github.com/mastra-ai/mastra/commit/0f0d1ba67bfcb2204e571401662f1eceefc03357), [`a18775a`](https://github.com/mastra-ai/mastra/commit/a18775a693172546ee2378d39b67d4e32895b251), [`1baf2d1`](https://github.com/mastra-ai/mastra/commit/1baf2d152c6881338ff8f114633d5316fe13dd15), [`8c31bcd`](https://github.com/mastra-ai/mastra/commit/8c31bcdb00e597880d5939b1b7d7566fbe5dacae), [`0e32507`](https://github.com/mastra-ai/mastra/commit/0e32507962cdfa5569b7bda5bc6fb3dd34e40b03), [`95b14cd`](https://github.com/mastra-ai/mastra/commit/95b14cdd820e86d97ac05fe568424c513a252e31), [`07c3de7`](https://github.com/mastra-ai/mastra/commit/07c3de7f7bc418beccaea3b5e6b7f7cdda79d492), [`0bf2d93`](https://github.com/mastra-ai/mastra/commit/0bf2d932d20e2936f2d9abb8c0a86e24fbc97ec6), [`7b0d34c`](https://github.com/mastra-ai/mastra/commit/7b0d34cfe4a2fce22ac86ae17404685ff67a2ddb), [`a659a77`](https://github.com/mastra-ai/mastra/commit/a659a779bdebe3a52a518c56d2260592d0240fe0), [`aa36be2`](https://github.com/mastra-ai/mastra/commit/aa36be23aa513b7dc53cb8ca16b7fab8f20e43ad), [`3332be9`](https://github.com/mastra-ai/mastra/commit/3332be9701ecd77aba840959d9a1d1ce7aef02d3), [`212c635`](https://github.com/mastra-ai/mastra/commit/212c635203e61d036ab41db8ff86c3893dc795b3), [`d8838ae`](https://github.com/mastra-ai/mastra/commit/d8838ae80b69780361693d27098f7f6684af12fe), [`9aa5a73`](https://github.com/mastra-ai/mastra/commit/9aa5a73e7e110f6e9365eec69364a33d5f03bb56), [`f73c789`](https://github.com/mastra-ai/mastra/commit/f73c789e8ef21561580395d2c410119cab5848c8), [`8bd16da`](https://github.com/mastra-ai/mastra/commit/8bd16da73a4cb874d739373643dbd6a6e7f88684), [`c8630f8`](https://github.com/mastra-ai/mastra/commit/c8630f80d4f40cb5d22e60ab162b618b1907167a), [`94dfef6`](https://github.com/mastra-ai/mastra/commit/94dfef6e2bf19a88467ea3940afcbce88a433f0f), [`47f71dc`](https://github.com/mastra-ai/mastra/commit/47f71dc6fbcbd12d71e21a979e676e20a02bd77d), [`50ceae2`](https://github.com/mastra-ai/mastra/commit/50ceae270878e2f8fb2b2c6c2faab09df0007c8a), [`a122f79`](https://github.com/mastra-ai/mastra/commit/a122f79427ae225ec79c7b2ed46278da48d04b17), [`8cdde58`](https://github.com/mastra-ai/mastra/commit/8cdde5875bbba6702d9df226f2b20232b8d75d6c), [`3a081c1`](https://github.com/mastra-ai/mastra/commit/3a081c1255c5ae8c99f6dad91cc612934ef6f2bd), [`49f8abc`](https://github.com/mastra-ai/mastra/commit/49f8abce8258e4f2f87bd326acfbdb641264a47c), [`847ff1e`](https://github.com/mastra-ai/mastra/commit/847ff1e0d94368d94b2e173e4e0908e115568ef3), [`0c1ed1d`](https://github.com/mastra-ai/mastra/commit/0c1ed1d00c7d87b5ac99ca95896211a2fa9189fa), [`259d409`](https://github.com/mastra-ai/mastra/commit/259d409a514174299dbde1ff5e1121209b3ba850), [`9e16c68`](https://github.com/mastra-ai/mastra/commit/9e16c6818b6485ccb43df28aba6f3a2219d28662), [`cefca33`](https://github.com/mastra-ai/mastra/commit/cefca33ae666e69810c935fedf95a929c173d1d7), [`d00e8c5`](https://github.com/mastra-ai/mastra/commit/d00e8c50daebe5bce5bf2f48bde39c86fc3d2fe4), [`36fa7e2`](https://github.com/mastra-ai/mastra/commit/36fa7e24d14e58a1eb46147097b32f583e5b8775), [`87e9774`](https://github.com/mastra-ai/mastra/commit/87e97741c1e493cd6d62f478eb810b49bda4d57c), [`65a72e7`](https://github.com/mastra-ai/mastra/commit/65a72e70c25eedea8ff985a6624b96be2850236b), [`fe9eacd`](https://github.com/mastra-ai/mastra/commit/fe9eacd9545a0a9d64aad31c9fa90294a425289e), [`4c02027`](https://github.com/mastra-ai/mastra/commit/4c020277235eaa6b1dc957c90ad0639eef213992), [`0f77241`](https://github.com/mastra-ai/mastra/commit/0f7724108806703799a8ba80ad0f09414afd5066), [`849efb9`](https://github.com/mastra-ai/mastra/commit/849efb9fca6dc976589c1f90a303fea618769109), [`92ff509`](https://github.com/mastra-ai/mastra/commit/92ff5098ef8a990438ca038077021a5f7541ec1d), [`3fce5e7`](https://github.com/mastra-ai/mastra/commit/3fce5e70d011d289043e75003ef3336ed4aa43c3), [`a763592`](https://github.com/mastra-ai/mastra/commit/a763592c3db46963ef1011cfe16fe372816e775e), [`db79c86`](https://github.com/mastra-ai/mastra/commit/db79c86c60723d57e02f9636ca2611bd4515f194), [`6855012`](https://github.com/mastra-ai/mastra/commit/685501247cc4717506f3e89beed03509d63a5370), [`80c7737`](https://github.com/mastra-ai/mastra/commit/80c7737e32d7917b5f356957d67c169d01744fd3), [`7fef31c`](https://github.com/mastra-ai/mastra/commit/7fef31c0d2a6d362a43a647a8a4f6ab893758a23), [`7fef31c`](https://github.com/mastra-ai/mastra/commit/7fef31c0d2a6d362a43a647a8a4f6ab893758a23), [`3f1cf47`](https://github.com/mastra-ai/mastra/commit/3f1cf476f74c1e4cc2df908837e05853a5347e31)]:
|
|
19
|
+
- @mastra/core@1.38.0
|
|
20
|
+
|
|
3
21
|
## 1.4.4-alpha.0
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -1549,16 +1549,16 @@ declare interface EventSourceMessage {
|
|
|
1549
1549
|
* implementation in that browsers will default this to `message`, whereas this parser will
|
|
1550
1550
|
* leave this as `undefined` if not explicitly declared.
|
|
1551
1551
|
*/
|
|
1552
|
-
event?: string | undefined
|
|
1552
|
+
event?: string | undefined;
|
|
1553
1553
|
/**
|
|
1554
1554
|
* ID of the message, if any was provided by the server. Can be used by clients to keep the
|
|
1555
1555
|
* last received message ID in sync when reconnecting.
|
|
1556
1556
|
*/
|
|
1557
|
-
id?: string | undefined
|
|
1557
|
+
id?: string | undefined;
|
|
1558
1558
|
/**
|
|
1559
1559
|
* The data received for this message
|
|
1560
1560
|
*/
|
|
1561
|
-
data: string
|
|
1561
|
+
data: string;
|
|
1562
1562
|
}
|
|
1563
1563
|
|
|
1564
1564
|
/**
|
|
@@ -1582,8 +1582,11 @@ declare interface EventSourceMessage {
|
|
|
1582
1582
|
*
|
|
1583
1583
|
* @public
|
|
1584
1584
|
*/
|
|
1585
|
-
declare class EventSourceParserStream extends TransformStream<
|
|
1586
|
-
|
|
1585
|
+
declare class EventSourceParserStream extends TransformStream<
|
|
1586
|
+
string,
|
|
1587
|
+
EventSourceMessage
|
|
1588
|
+
> {
|
|
1589
|
+
constructor({ onError, onRetry, onComment }?: StreamOptions);
|
|
1587
1590
|
}
|
|
1588
1591
|
|
|
1589
1592
|
/**
|
|
@@ -6830,19 +6833,19 @@ declare interface StreamOptions {
|
|
|
6830
6833
|
*
|
|
6831
6834
|
* @defaultValue `undefined`
|
|
6832
6835
|
*/
|
|
6833
|
-
onError?: (
|
|
6836
|
+
onError?: ("terminate" | ((error: Error) => void)) | undefined;
|
|
6834
6837
|
/**
|
|
6835
6838
|
* Callback for when a reconnection interval is sent from the server.
|
|
6836
6839
|
*
|
|
6837
6840
|
* @param retry - The number of milliseconds to wait before reconnecting.
|
|
6838
6841
|
*/
|
|
6839
|
-
onRetry?: ((retry: number) => void) | undefined
|
|
6842
|
+
onRetry?: ((retry: number) => void) | undefined;
|
|
6840
6843
|
/**
|
|
6841
6844
|
* Callback for when a comment is encountered in the stream.
|
|
6842
6845
|
*
|
|
6843
6846
|
* @param comment - The comment encountered in the stream.
|
|
6844
6847
|
*/
|
|
6845
|
-
onComment?: ((comment: string) => void) | undefined
|
|
6848
|
+
onComment?: ((comment: string) => void) | undefined;
|
|
6846
6849
|
}
|
|
6847
6850
|
|
|
6848
6851
|
/**
|
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EAEnB,gBAAgB,EAChB,cAAc,EACd,OAAO,EACP,SAAS,EACT,YAAY,EACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAEV,YAAY,IAAI,cAAc,EAC9B,mBAAmB,IAAI,qBAAqB,EAE5C,mBAAmB,EACnB,SAAS,IAAI,WAAW,EACzB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGxF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAE1C;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAK5E;AAED,MAAM,MAAM,eAAe,CAAC,MAAM,GAAG,SAAS,IAC1C,cAAc,CAAC,OAAO,CAAC,GACvB,gBAAgB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GACjC,mBAAmB,GACnB,aAAa,GACb,SAAS,CAAC;AAEd,MAAM,MAAM,kBAAkB,GAAG;IAAE,IAAI,EAAE,YAA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C,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;IACpC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,GACG,mBAAmB,CAAC,UAAU,CAAC,GAC/B,qBAAqB,CAAC,WAAW,CAAC,GAClC,kBAAkB,GAClB,qBAAqB,GACrB,oBAAoB,GACpB,SAAS,CAsQZ"}
|
package/dist/index.cjs
CHANGED
|
@@ -30,7 +30,7 @@ function _interopNamespace(e) {
|
|
|
30
30
|
|
|
31
31
|
var z4__namespace = /*#__PURE__*/_interopNamespace(z4);
|
|
32
32
|
|
|
33
|
-
// ../../packages/_vendored/ai_v5/dist/chunk-
|
|
33
|
+
// ../../packages/_vendored/ai_v5/dist/chunk-YVS43WX4.js
|
|
34
34
|
var marker = "vercel.ai.error";
|
|
35
35
|
var symbol = Symbol.for(marker);
|
|
36
36
|
var _a;
|
|
@@ -209,6 +209,9 @@ var ParseError = class extends Error {
|
|
|
209
209
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
210
210
|
}
|
|
211
211
|
};
|
|
212
|
+
var LF = 10;
|
|
213
|
+
var CR = 13;
|
|
214
|
+
var SPACE = 32;
|
|
212
215
|
function noop(_arg) {
|
|
213
216
|
}
|
|
214
217
|
function createParser(callbacks) {
|
|
@@ -216,39 +219,109 @@ function createParser(callbacks) {
|
|
|
216
219
|
throw new TypeError(
|
|
217
220
|
"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
|
|
218
221
|
);
|
|
219
|
-
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
|
|
220
|
-
let
|
|
221
|
-
function feed(
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
222
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];
|
|
223
|
+
let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
|
|
224
|
+
function feed(chunk) {
|
|
225
|
+
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
226
|
+
const trailing2 = processLines(chunk);
|
|
227
|
+
trailing2 !== "" && pendingFragments.push(trailing2);
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
if (chunk.indexOf(`
|
|
231
|
+
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
232
|
+
pendingFragments.push(chunk);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
pendingFragments.push(chunk);
|
|
236
|
+
const input = pendingFragments.join("");
|
|
237
|
+
pendingFragments.length = 0;
|
|
238
|
+
const trailing = processLines(input);
|
|
239
|
+
trailing !== "" && pendingFragments.push(trailing);
|
|
240
|
+
}
|
|
241
|
+
function processLines(chunk) {
|
|
242
|
+
let searchIndex = 0;
|
|
243
|
+
if (chunk.indexOf("\r") === -1) {
|
|
244
|
+
let lfIndex = chunk.indexOf(`
|
|
245
|
+
`, searchIndex);
|
|
246
|
+
for (; lfIndex !== -1; ) {
|
|
247
|
+
if (searchIndex === lfIndex) {
|
|
248
|
+
dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
249
|
+
`, searchIndex);
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
253
|
+
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
254
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
255
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
256
|
+
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
257
|
+
`, searchIndex);
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
data = dataLines === 0 ? value : `${data}
|
|
261
|
+
${value}`, dataLines++;
|
|
262
|
+
} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
263
|
+
chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
|
|
264
|
+
lfIndex
|
|
265
|
+
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
266
|
+
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
267
|
+
`, searchIndex);
|
|
268
|
+
}
|
|
269
|
+
return chunk.slice(searchIndex);
|
|
270
|
+
}
|
|
271
|
+
for (; searchIndex < chunk.length; ) {
|
|
272
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
273
|
+
`, searchIndex);
|
|
274
|
+
let lineEnd = -1;
|
|
275
|
+
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)
|
|
276
|
+
break;
|
|
277
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
|
|
278
|
+
}
|
|
279
|
+
return chunk.slice(searchIndex);
|
|
280
|
+
}
|
|
281
|
+
function parseLine(chunk, start, end) {
|
|
282
|
+
if (start === end) {
|
|
229
283
|
dispatchEvent();
|
|
230
284
|
return;
|
|
231
285
|
}
|
|
232
|
-
|
|
233
|
-
|
|
286
|
+
const firstCharCode = chunk.charCodeAt(start);
|
|
287
|
+
if (isDataPrefix(chunk, start, firstCharCode)) {
|
|
288
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
289
|
+
data = dataLines === 0 ? value2 : `${data}
|
|
290
|
+
${value2}`, dataLines++;
|
|
234
291
|
return;
|
|
235
292
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
239
|
-
processField(field, value, line);
|
|
293
|
+
if (isEventPrefix(chunk, start, firstCharCode)) {
|
|
294
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
|
|
240
295
|
return;
|
|
241
296
|
}
|
|
242
|
-
|
|
297
|
+
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
298
|
+
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
299
|
+
id = value2.includes("\0") ? void 0 : value2;
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
if (firstCharCode === 58) {
|
|
303
|
+
if (onComment) {
|
|
304
|
+
const line2 = chunk.slice(start, end);
|
|
305
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
|
|
306
|
+
}
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
310
|
+
if (fieldSeparatorIndex === -1) {
|
|
311
|
+
processField(line, "", line);
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
315
|
+
processField(field, value, line);
|
|
243
316
|
}
|
|
244
317
|
function processField(field, value, line) {
|
|
245
318
|
switch (field) {
|
|
246
319
|
case "event":
|
|
247
|
-
eventType = value;
|
|
320
|
+
eventType = value || void 0;
|
|
248
321
|
break;
|
|
249
322
|
case "data":
|
|
250
|
-
data = `${data}
|
|
251
|
-
|
|
323
|
+
data = dataLines === 0 ? value : `${data}
|
|
324
|
+
${value}`, dataLines++;
|
|
252
325
|
break;
|
|
253
326
|
case "id":
|
|
254
327
|
id = value.includes("\0") ? void 0 : value;
|
|
@@ -273,37 +346,26 @@ function createParser(callbacks) {
|
|
|
273
346
|
}
|
|
274
347
|
}
|
|
275
348
|
function dispatchEvent() {
|
|
276
|
-
|
|
349
|
+
dataLines > 0 && onEvent({
|
|
277
350
|
id,
|
|
278
|
-
event: eventType
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
data: data.endsWith(`
|
|
282
|
-
`) ? data.slice(0, -1) : data
|
|
283
|
-
}), id = void 0, data = "", eventType = "";
|
|
351
|
+
event: eventType,
|
|
352
|
+
data
|
|
353
|
+
}), id = void 0, data = "", dataLines = 0, eventType = void 0;
|
|
284
354
|
}
|
|
285
355
|
function reset(options = {}) {
|
|
286
|
-
|
|
356
|
+
if (options.consume && pendingFragments.length > 0) {
|
|
357
|
+
const incompleteLine = pendingFragments.join("");
|
|
358
|
+
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
359
|
+
}
|
|
360
|
+
isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
|
|
287
361
|
}
|
|
288
362
|
return { feed, reset };
|
|
289
363
|
}
|
|
290
|
-
function
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
`, searchIndex);
|
|
296
|
-
let lineEnd = -1;
|
|
297
|
-
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) {
|
|
298
|
-
incompleteLine = chunk.slice(searchIndex);
|
|
299
|
-
break;
|
|
300
|
-
} else {
|
|
301
|
-
const line = chunk.slice(searchIndex, lineEnd);
|
|
302
|
-
lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
|
|
303
|
-
` && searchIndex++;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
return [lines, incompleteLine];
|
|
364
|
+
function isDataPrefix(chunk, i, firstCharCode) {
|
|
365
|
+
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
366
|
+
}
|
|
367
|
+
function isEventPrefix(chunk, i, firstCharCode) {
|
|
368
|
+
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;
|
|
307
369
|
}
|
|
308
370
|
var EventSourceParserStream = class extends TransformStream {
|
|
309
371
|
constructor({ onError, onRetry, onComment } = {}) {
|
|
@@ -5713,9 +5775,9 @@ var ParseError2 = class extends Error {
|
|
|
5713
5775
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
5714
5776
|
}
|
|
5715
5777
|
};
|
|
5716
|
-
var
|
|
5717
|
-
var
|
|
5718
|
-
var
|
|
5778
|
+
var LF2 = 10;
|
|
5779
|
+
var CR2 = 13;
|
|
5780
|
+
var SPACE2 = 32;
|
|
5719
5781
|
function noop2(_arg) {
|
|
5720
5782
|
}
|
|
5721
5783
|
function createParser2(callbacks) {
|
|
@@ -5754,17 +5816,17 @@ function createParser2(callbacks) {
|
|
|
5754
5816
|
continue;
|
|
5755
5817
|
}
|
|
5756
5818
|
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
5757
|
-
if (
|
|
5758
|
-
const valueStart = chunk.charCodeAt(searchIndex + 5) ===
|
|
5759
|
-
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) ===
|
|
5819
|
+
if (isDataPrefix2(chunk, searchIndex, firstCharCode)) {
|
|
5820
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE2 ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
5821
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF2) {
|
|
5760
5822
|
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
5761
5823
|
`, searchIndex);
|
|
5762
5824
|
continue;
|
|
5763
5825
|
}
|
|
5764
5826
|
data = dataLines === 0 ? value : `${data}
|
|
5765
5827
|
${value}`, dataLines++;
|
|
5766
|
-
} else
|
|
5767
|
-
chunk.charCodeAt(searchIndex + 6) ===
|
|
5828
|
+
} else isEventPrefix2(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
5829
|
+
chunk.charCodeAt(searchIndex + 6) === SPACE2 ? searchIndex + 7 : searchIndex + 6,
|
|
5768
5830
|
lfIndex
|
|
5769
5831
|
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
5770
5832
|
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
@@ -5778,7 +5840,7 @@ ${value}`, dataLines++;
|
|
|
5778
5840
|
let lineEnd = -1;
|
|
5779
5841
|
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)
|
|
5780
5842
|
break;
|
|
5781
|
-
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) ===
|
|
5843
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR2 && chunk.charCodeAt(searchIndex) === LF2 && searchIndex++;
|
|
5782
5844
|
}
|
|
5783
5845
|
return chunk.slice(searchIndex);
|
|
5784
5846
|
}
|
|
@@ -5788,25 +5850,25 @@ ${value}`, dataLines++;
|
|
|
5788
5850
|
return;
|
|
5789
5851
|
}
|
|
5790
5852
|
const firstCharCode = chunk.charCodeAt(start);
|
|
5791
|
-
if (
|
|
5792
|
-
const valueStart = chunk.charCodeAt(start + 5) ===
|
|
5853
|
+
if (isDataPrefix2(chunk, start, firstCharCode)) {
|
|
5854
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE2 ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
5793
5855
|
data = dataLines === 0 ? value2 : `${data}
|
|
5794
5856
|
${value2}`, dataLines++;
|
|
5795
5857
|
return;
|
|
5796
5858
|
}
|
|
5797
|
-
if (
|
|
5798
|
-
eventType = chunk.slice(chunk.charCodeAt(start + 6) ===
|
|
5859
|
+
if (isEventPrefix2(chunk, start, firstCharCode)) {
|
|
5860
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE2 ? start + 7 : start + 6, end) || void 0;
|
|
5799
5861
|
return;
|
|
5800
5862
|
}
|
|
5801
5863
|
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
5802
|
-
const value2 = chunk.slice(chunk.charCodeAt(start + 3) ===
|
|
5864
|
+
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE2 ? start + 4 : start + 3, end);
|
|
5803
5865
|
id = value2.includes("\0") ? void 0 : value2;
|
|
5804
5866
|
return;
|
|
5805
5867
|
}
|
|
5806
5868
|
if (firstCharCode === 58) {
|
|
5807
5869
|
if (onComment) {
|
|
5808
5870
|
const line2 = chunk.slice(start, end);
|
|
5809
|
-
onComment(line2.slice(chunk.charCodeAt(start + 1) ===
|
|
5871
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE2 ? 2 : 1));
|
|
5810
5872
|
}
|
|
5811
5873
|
return;
|
|
5812
5874
|
}
|
|
@@ -5815,7 +5877,7 @@ ${value2}`, dataLines++;
|
|
|
5815
5877
|
processField(line, "", line);
|
|
5816
5878
|
return;
|
|
5817
5879
|
}
|
|
5818
|
-
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) ===
|
|
5880
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE2 ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
5819
5881
|
processField(field, value, line);
|
|
5820
5882
|
}
|
|
5821
5883
|
function processField(field, value, line) {
|
|
@@ -5865,10 +5927,10 @@ ${value}`, dataLines++;
|
|
|
5865
5927
|
}
|
|
5866
5928
|
return { feed, reset };
|
|
5867
5929
|
}
|
|
5868
|
-
function
|
|
5930
|
+
function isDataPrefix2(chunk, i, firstCharCode) {
|
|
5869
5931
|
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
5870
5932
|
}
|
|
5871
|
-
function
|
|
5933
|
+
function isEventPrefix2(chunk, i, firstCharCode) {
|
|
5872
5934
|
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;
|
|
5873
5935
|
}
|
|
5874
5936
|
var EventSourceParserStream2 = class extends TransformStream {
|
|
@@ -12154,7 +12216,8 @@ function convertMastraChunkToAISDKBase({
|
|
|
12154
12216
|
providerMetadata: chunk.payload.providerMetadata,
|
|
12155
12217
|
providerExecuted: chunk.payload.providerExecuted,
|
|
12156
12218
|
toolName: chunk.payload.toolName,
|
|
12157
|
-
input: hasTransformedToolPayload(displayInputTransform) ? displayInputTransform.transformed : chunk.payload.args
|
|
12219
|
+
input: hasTransformedToolPayload(displayInputTransform) ? displayInputTransform.transformed : chunk.payload.args,
|
|
12220
|
+
...chunk.payload.observability ? { observability: chunk.payload.observability } : {}
|
|
12158
12221
|
};
|
|
12159
12222
|
case "tool-call-approval":
|
|
12160
12223
|
return {
|
|
@@ -12189,7 +12252,8 @@ function convertMastraChunkToAISDKBase({
|
|
|
12189
12252
|
toolName: chunk.payload.toolName,
|
|
12190
12253
|
dynamic: !!chunk.payload.dynamic,
|
|
12191
12254
|
providerMetadata: chunk.payload.providerMetadata,
|
|
12192
|
-
providerExecuted: chunk.payload.providerExecuted
|
|
12255
|
+
providerExecuted: chunk.payload.providerExecuted,
|
|
12256
|
+
...chunk.payload.observability ? { observability: chunk.payload.observability } : {}
|
|
12193
12257
|
};
|
|
12194
12258
|
case "tool-call-input-streaming-end":
|
|
12195
12259
|
return {
|
|
@@ -12516,6 +12580,7 @@ function convertFullStreamChunkToUIMessageStream({
|
|
|
12516
12580
|
};
|
|
12517
12581
|
}
|
|
12518
12582
|
case "tool-call": {
|
|
12583
|
+
const observability = part.observability;
|
|
12519
12584
|
return {
|
|
12520
12585
|
type: "tool-input-available",
|
|
12521
12586
|
toolCallId: part.toolCallId,
|
|
@@ -12523,7 +12588,12 @@ function convertFullStreamChunkToUIMessageStream({
|
|
|
12523
12588
|
input: part.input,
|
|
12524
12589
|
...part.providerExecuted != null ? { providerExecuted: part.providerExecuted } : {},
|
|
12525
12590
|
...part.providerMetadata != null ? { providerMetadata: part.providerMetadata } : {},
|
|
12526
|
-
...part.dynamic != null ? { dynamic: part.dynamic } : {}
|
|
12591
|
+
...part.dynamic != null ? { dynamic: part.dynamic } : {},
|
|
12592
|
+
...observability != null ? {
|
|
12593
|
+
toolMetadata: {
|
|
12594
|
+
__mastraObservability: observability
|
|
12595
|
+
}
|
|
12596
|
+
} : {}
|
|
12527
12597
|
};
|
|
12528
12598
|
}
|
|
12529
12599
|
case "tool-approval-request": {
|