@mastra/ai-sdk 0.0.0-model-router-unknown-provider-20251017212006 → 0.0.0-moving-fetching-hooks-to-playground-ui-and-expose-them-20251023071821
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 +41 -3
- package/dist/helpers.d.ts +2 -2
- package/dist/helpers.d.ts.map +1 -1
- package/dist/index.cjs +60 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +60 -5
- package/dist/index.js.map +1 -1
- package/dist/to-ai-sdk-format.d.ts +5 -2
- package/dist/to-ai-sdk-format.d.ts.map +1 -1
- package/dist/transformers.d.ts +11 -23
- package/dist/transformers.d.ts.map +1 -1
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,51 @@
|
|
|
1
1
|
# @mastra/ai-sdk
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-moving-fetching-hooks-to-playground-ui-and-expose-them-20251023071821
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix streaming of custom chunks, workflow & network support ([#9109](https://github.com/mastra-ai/mastra/pull/9109))
|
|
8
|
+
|
|
9
|
+
## 0.2.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Pass original messages in chatRoute to fix uiMessages duplication #8830 ([#8904](https://github.com/mastra-ai/mastra/pull/8904))
|
|
14
|
+
|
|
15
|
+
- network routing agent text delta ai-sdk streaming ([#8979](https://github.com/mastra-ai/mastra/pull/8979))
|
|
16
|
+
|
|
17
|
+
- Support writing custom top level stream chunks ([#8922](https://github.com/mastra-ai/mastra/pull/8922))
|
|
18
|
+
|
|
19
|
+
- Refactor workflowstream into workflow output with fullStream property ([#9048](https://github.com/mastra-ai/mastra/pull/9048))
|
|
20
|
+
|
|
21
|
+
- Update peerdeps to 0.23.0-0 ([#9043](https://github.com/mastra-ai/mastra/pull/9043))
|
|
22
|
+
|
|
23
|
+
- Updated dependencies [[`c67ca32`](https://github.com/mastra-ai/mastra/commit/c67ca32e3c2cf69bfc146580770c720220ca44ac), [`efb5ed9`](https://github.com/mastra-ai/mastra/commit/efb5ed946ae7f410bc68c9430beb4b010afd25ec), [`dbc9e12`](https://github.com/mastra-ai/mastra/commit/dbc9e1216ba575ba59ead4afb727a01215f7de4f), [`99e41b9`](https://github.com/mastra-ai/mastra/commit/99e41b94957cdd25137d3ac12e94e8b21aa01b68), [`c28833c`](https://github.com/mastra-ai/mastra/commit/c28833c5b6d8e10eeffd7f7d39129d53b8bca240), [`8ea07b4`](https://github.com/mastra-ai/mastra/commit/8ea07b4bdc73e4218437dbb6dcb0f4b23e745a44), [`ba201b8`](https://github.com/mastra-ai/mastra/commit/ba201b8f8feac4c72350f2dbd52c13c7297ba7b0), [`f053e89`](https://github.com/mastra-ai/mastra/commit/f053e89160dbd0bd3333fc3492f68231b5c7c349), [`4fc4136`](https://github.com/mastra-ai/mastra/commit/4fc413652866a8d2240694fddb2562e9edbb70df), [`b78e04d`](https://github.com/mastra-ai/mastra/commit/b78e04d935a16ecb1e59c5c96e564903527edddd), [`d10baf5`](https://github.com/mastra-ai/mastra/commit/d10baf5a3c924f2a6654e23a3e318ed03f189b76), [`038c55a`](https://github.com/mastra-ai/mastra/commit/038c55a7090fc1b1513a966386d3072617f836ac), [`182f045`](https://github.com/mastra-ai/mastra/commit/182f0458f25bd70aa774e64fd923c8a483eddbf1), [`9a1a485`](https://github.com/mastra-ai/mastra/commit/9a1a4859b855e37239f652bf14b1ecd1029b8c4e), [`9257233`](https://github.com/mastra-ai/mastra/commit/9257233c4ffce09b2bedc2a9adbd70d7a83fa8e2), [`7620d2b`](https://github.com/mastra-ai/mastra/commit/7620d2bddeb4fae4c3c0a0b4e672969795fca11a), [`b2365f0`](https://github.com/mastra-ai/mastra/commit/b2365f038dd4c5f06400428b224af963f399ad50), [`0f1a4c9`](https://github.com/mastra-ai/mastra/commit/0f1a4c984fb4b104b2f0b63ba18c9fa77f567700), [`9029ba3`](https://github.com/mastra-ai/mastra/commit/9029ba34459c8859fed4c6b73efd8e2d0021e7ba), [`426cc56`](https://github.com/mastra-ai/mastra/commit/426cc561c85ae76a112ded2385532a91f9f9f074), [`00931fb`](https://github.com/mastra-ai/mastra/commit/00931fb1a21aa42c4fbc20c2c40dd62466b8fc8f), [`e473bfe`](https://github.com/mastra-ai/mastra/commit/e473bfe416c0b8e876973c2b6a6f13c394b7a93f), [`b78e04d`](https://github.com/mastra-ai/mastra/commit/b78e04d935a16ecb1e59c5c96e564903527edddd), [`2db6160`](https://github.com/mastra-ai/mastra/commit/2db6160e2022ff8827c15d30157e684683b934b5), [`8aeea37`](https://github.com/mastra-ai/mastra/commit/8aeea37efdde347c635a67fed56794943b7f74ec), [`02fe153`](https://github.com/mastra-ai/mastra/commit/02fe15351d6021d214da48ec982a0e9e4150bcee), [`648e2ca`](https://github.com/mastra-ai/mastra/commit/648e2ca42da54838c6ccbdaadc6fadd808fa6b86), [`74567b3`](https://github.com/mastra-ai/mastra/commit/74567b3d237ae3915cd0bca3cf55fa0a64e4e4a4), [`b65c5e0`](https://github.com/mastra-ai/mastra/commit/b65c5e0fe6f3c390a9a8bbcf69304d972c3a4afb), [`15a1733`](https://github.com/mastra-ai/mastra/commit/15a1733074cee8bd37370e1af34cd818e89fa7ac), [`fc2a774`](https://github.com/mastra-ai/mastra/commit/fc2a77468981aaddc3e77f83f0c4ad4a4af140da), [`4e08933`](https://github.com/mastra-ai/mastra/commit/4e08933625464dfde178347af5b6278fcf34188e)]:
|
|
24
|
+
- @mastra/core@0.22.0
|
|
25
|
+
|
|
26
|
+
## 0.2.2-alpha.1
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- Refactor workflowstream into workflow output with fullStream property ([#9048](https://github.com/mastra-ai/mastra/pull/9048))
|
|
31
|
+
|
|
32
|
+
- Update peerdeps to 0.23.0-0 ([#9043](https://github.com/mastra-ai/mastra/pull/9043))
|
|
33
|
+
|
|
34
|
+
- Updated dependencies [[`efb5ed9`](https://github.com/mastra-ai/mastra/commit/efb5ed946ae7f410bc68c9430beb4b010afd25ec), [`8ea07b4`](https://github.com/mastra-ai/mastra/commit/8ea07b4bdc73e4218437dbb6dcb0f4b23e745a44), [`ba201b8`](https://github.com/mastra-ai/mastra/commit/ba201b8f8feac4c72350f2dbd52c13c7297ba7b0), [`4fc4136`](https://github.com/mastra-ai/mastra/commit/4fc413652866a8d2240694fddb2562e9edbb70df), [`b78e04d`](https://github.com/mastra-ai/mastra/commit/b78e04d935a16ecb1e59c5c96e564903527edddd), [`d10baf5`](https://github.com/mastra-ai/mastra/commit/d10baf5a3c924f2a6654e23a3e318ed03f189b76), [`038c55a`](https://github.com/mastra-ai/mastra/commit/038c55a7090fc1b1513a966386d3072617f836ac), [`182f045`](https://github.com/mastra-ai/mastra/commit/182f0458f25bd70aa774e64fd923c8a483eddbf1), [`7620d2b`](https://github.com/mastra-ai/mastra/commit/7620d2bddeb4fae4c3c0a0b4e672969795fca11a), [`b2365f0`](https://github.com/mastra-ai/mastra/commit/b2365f038dd4c5f06400428b224af963f399ad50), [`9029ba3`](https://github.com/mastra-ai/mastra/commit/9029ba34459c8859fed4c6b73efd8e2d0021e7ba), [`426cc56`](https://github.com/mastra-ai/mastra/commit/426cc561c85ae76a112ded2385532a91f9f9f074), [`00931fb`](https://github.com/mastra-ai/mastra/commit/00931fb1a21aa42c4fbc20c2c40dd62466b8fc8f), [`e473bfe`](https://github.com/mastra-ai/mastra/commit/e473bfe416c0b8e876973c2b6a6f13c394b7a93f), [`b78e04d`](https://github.com/mastra-ai/mastra/commit/b78e04d935a16ecb1e59c5c96e564903527edddd), [`648e2ca`](https://github.com/mastra-ai/mastra/commit/648e2ca42da54838c6ccbdaadc6fadd808fa6b86), [`b65c5e0`](https://github.com/mastra-ai/mastra/commit/b65c5e0fe6f3c390a9a8bbcf69304d972c3a4afb)]:
|
|
35
|
+
- @mastra/core@0.22.0-alpha.1
|
|
36
|
+
|
|
37
|
+
## 0.2.2-alpha.0
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
|
6
40
|
|
|
7
41
|
- Pass original messages in chatRoute to fix uiMessages duplication #8830 ([#8904](https://github.com/mastra-ai/mastra/pull/8904))
|
|
8
42
|
|
|
9
|
-
-
|
|
10
|
-
|
|
43
|
+
- network routing agent text delta ai-sdk streaming ([#8979](https://github.com/mastra-ai/mastra/pull/8979))
|
|
44
|
+
|
|
45
|
+
- Support writing custom top level stream chunks ([#8922](https://github.com/mastra-ai/mastra/pull/8922))
|
|
46
|
+
|
|
47
|
+
- Updated dependencies [[`c67ca32`](https://github.com/mastra-ai/mastra/commit/c67ca32e3c2cf69bfc146580770c720220ca44ac), [`dbc9e12`](https://github.com/mastra-ai/mastra/commit/dbc9e1216ba575ba59ead4afb727a01215f7de4f), [`99e41b9`](https://github.com/mastra-ai/mastra/commit/99e41b94957cdd25137d3ac12e94e8b21aa01b68), [`c28833c`](https://github.com/mastra-ai/mastra/commit/c28833c5b6d8e10eeffd7f7d39129d53b8bca240), [`f053e89`](https://github.com/mastra-ai/mastra/commit/f053e89160dbd0bd3333fc3492f68231b5c7c349), [`9a1a485`](https://github.com/mastra-ai/mastra/commit/9a1a4859b855e37239f652bf14b1ecd1029b8c4e), [`9257233`](https://github.com/mastra-ai/mastra/commit/9257233c4ffce09b2bedc2a9adbd70d7a83fa8e2), [`0f1a4c9`](https://github.com/mastra-ai/mastra/commit/0f1a4c984fb4b104b2f0b63ba18c9fa77f567700), [`2db6160`](https://github.com/mastra-ai/mastra/commit/2db6160e2022ff8827c15d30157e684683b934b5), [`8aeea37`](https://github.com/mastra-ai/mastra/commit/8aeea37efdde347c635a67fed56794943b7f74ec), [`02fe153`](https://github.com/mastra-ai/mastra/commit/02fe15351d6021d214da48ec982a0e9e4150bcee), [`74567b3`](https://github.com/mastra-ai/mastra/commit/74567b3d237ae3915cd0bca3cf55fa0a64e4e4a4), [`15a1733`](https://github.com/mastra-ai/mastra/commit/15a1733074cee8bd37370e1af34cd818e89fa7ac), [`fc2a774`](https://github.com/mastra-ai/mastra/commit/fc2a77468981aaddc3e77f83f0c4ad4a4af140da), [`4e08933`](https://github.com/mastra-ai/mastra/commit/4e08933625464dfde178347af5b6278fcf34188e)]:
|
|
48
|
+
- @mastra/core@0.21.2-alpha.0
|
|
11
49
|
|
|
12
50
|
## 0.2.1
|
|
13
51
|
|
package/dist/helpers.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChunkType } from '@mastra/core';
|
|
2
|
-
import type { PartialSchemaOutput, OutputSchema } from '@mastra/core/stream';
|
|
2
|
+
import type { PartialSchemaOutput, OutputSchema, DataChunkType } from '@mastra/core/stream';
|
|
3
3
|
import type { InferUIMessageChunk, ObjectStreamPart, TextStreamPart, ToolSet, UIMessage } from 'ai';
|
|
4
4
|
export type OutputChunkType<OUTPUT extends OutputSchema = undefined> = TextStreamPart<ToolSet> | ObjectStreamPart<PartialSchemaOutput<OUTPUT>> | undefined;
|
|
5
5
|
export type ToolAgentChunkType = {
|
|
@@ -22,7 +22,7 @@ export declare function convertMastraChunkToAISDKv5<OUTPUT extends OutputSchema
|
|
|
22
22
|
mode?: 'generate' | 'stream';
|
|
23
23
|
}): OutputChunkType<OUTPUT>;
|
|
24
24
|
export declare function convertFullStreamChunkToUIMessageStream<UI_MESSAGE extends UIMessage>({ part, messageMetadataValue, sendReasoning, sendSources, onError, sendStart, sendFinish, responseMessageId, }: {
|
|
25
|
-
part: TextStreamPart<ToolSet> | {
|
|
25
|
+
part: TextStreamPart<ToolSet> | DataChunkType | {
|
|
26
26
|
type: 'tool-output';
|
|
27
27
|
toolCallId: string;
|
|
28
28
|
output: any;
|
package/dist/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","s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AG,QAAQ,CAAC;CAC9B,GAAG,eAAe,CAAC,MAAM,CAAC,CAqN1B;AAED,wBAAgB,uCAAuC,CAAC,UAAU,SAAS,SAAS,EAAE,EACpF,IAAI,EACJ,oBAAoB,EACpB,aAAa,EACb,WAAW,EACX,OAAO,EACP,SAAS,EACT,UAAU,EACV,iBAAiB,GAClB,EAAE;IAED,IAAI,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,aAAa,GAAG;QAAE,IAAI,EAAE,aAAa,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,GAAG,CAAA;KAAE,CAAC;IACzG,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,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,GAAG,mBAAmB,CAAC,UAAU,CAAC,GAAG,kBAAkB,GAAG,qBAAqB,GAAG,oBAAoB,GAAG,SAAS,CAiOlH"}
|
package/dist/index.cjs
CHANGED
|
@@ -5,6 +5,13 @@ var ai = require('ai');
|
|
|
5
5
|
var stream = require('@mastra/core/stream');
|
|
6
6
|
|
|
7
7
|
// src/chat-route.ts
|
|
8
|
+
|
|
9
|
+
// src/utils.ts
|
|
10
|
+
var isDataChunkType = (chunk) => {
|
|
11
|
+
return chunk && typeof chunk === "object" && "type" in chunk && chunk.type?.startsWith("data-");
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// src/helpers.ts
|
|
8
15
|
function convertMastraChunkToAISDKv5({
|
|
9
16
|
chunk,
|
|
10
17
|
mode = "stream"
|
|
@@ -210,6 +217,9 @@ function convertMastraChunkToAISDKv5({
|
|
|
210
217
|
...chunk.payload || {}
|
|
211
218
|
};
|
|
212
219
|
}
|
|
220
|
+
if ("type" in chunk && chunk.type?.startsWith("data-")) {
|
|
221
|
+
return chunk;
|
|
222
|
+
}
|
|
213
223
|
return;
|
|
214
224
|
}
|
|
215
225
|
}
|
|
@@ -223,7 +233,7 @@ function convertFullStreamChunkToUIMessageStream({
|
|
|
223
233
|
sendFinish,
|
|
224
234
|
responseMessageId
|
|
225
235
|
}) {
|
|
226
|
-
const partType = part
|
|
236
|
+
const partType = part?.type;
|
|
227
237
|
switch (partType) {
|
|
228
238
|
case "text-start": {
|
|
229
239
|
return {
|
|
@@ -380,8 +390,16 @@ function convertFullStreamChunkToUIMessageStream({
|
|
|
380
390
|
return;
|
|
381
391
|
}
|
|
382
392
|
default: {
|
|
383
|
-
|
|
384
|
-
|
|
393
|
+
if (isDataChunkType(part)) {
|
|
394
|
+
if (!("data" in part)) {
|
|
395
|
+
throw new Error(
|
|
396
|
+
`UI Messages require a data property when using data- prefixed chunks
|
|
397
|
+
${JSON.stringify(part)}`
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
return part;
|
|
401
|
+
}
|
|
402
|
+
return;
|
|
385
403
|
}
|
|
386
404
|
}
|
|
387
405
|
}
|
|
@@ -667,8 +685,18 @@ function transformWorkflow(payload, bufferedWorkflows, isNested) {
|
|
|
667
685
|
}
|
|
668
686
|
};
|
|
669
687
|
}
|
|
670
|
-
default:
|
|
688
|
+
default: {
|
|
689
|
+
if (isDataChunkType(payload)) {
|
|
690
|
+
if (!("data" in payload)) {
|
|
691
|
+
throw new Error(
|
|
692
|
+
`UI Messages require a data property when using data- prefixed chunks
|
|
693
|
+
${JSON.stringify(payload)}`
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
return payload;
|
|
697
|
+
}
|
|
671
698
|
return null;
|
|
699
|
+
}
|
|
672
700
|
}
|
|
673
701
|
}
|
|
674
702
|
function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
@@ -691,6 +719,23 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
691
719
|
}
|
|
692
720
|
};
|
|
693
721
|
}
|
|
722
|
+
case "routing-agent-text-start": {
|
|
723
|
+
const current = bufferedNetworks.get(payload.runId);
|
|
724
|
+
if (!current) return null;
|
|
725
|
+
return {
|
|
726
|
+
type: "text-start",
|
|
727
|
+
id: payload.runId
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
case "routing-agent-text-delta": {
|
|
731
|
+
const current = bufferedNetworks.get(payload.runId);
|
|
732
|
+
if (!current) return null;
|
|
733
|
+
return {
|
|
734
|
+
type: "text-delta",
|
|
735
|
+
id: payload.runId,
|
|
736
|
+
delta: payload.payload.text
|
|
737
|
+
};
|
|
738
|
+
}
|
|
694
739
|
case "agent-execution-start": {
|
|
695
740
|
const current = bufferedNetworks.get(payload.payload.runId) || { name: "", steps: [] };
|
|
696
741
|
current.steps.push({
|
|
@@ -853,8 +898,18 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
853
898
|
}
|
|
854
899
|
};
|
|
855
900
|
}
|
|
856
|
-
default:
|
|
901
|
+
default: {
|
|
902
|
+
if (isDataChunkType(payload)) {
|
|
903
|
+
if (!("data" in payload)) {
|
|
904
|
+
throw new Error(
|
|
905
|
+
`UI Messages require a data property when using data- prefixed chunks
|
|
906
|
+
${JSON.stringify(payload)}`
|
|
907
|
+
);
|
|
908
|
+
}
|
|
909
|
+
return payload;
|
|
910
|
+
}
|
|
857
911
|
return null;
|
|
912
|
+
}
|
|
858
913
|
}
|
|
859
914
|
}
|
|
860
915
|
|