@mastra/ai-sdk 1.1.2 → 1.1.3-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 +9 -0
- package/dist/chat-route.d.ts.map +1 -1
- package/dist/index.cjs +33 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -5
- package/dist/index.js.map +1 -1
- package/dist/middleware.d.ts.map +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mastra/ai-sdk
|
|
2
2
|
|
|
3
|
+
## 1.1.3-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed `handleChatStream` not merging `providerOptions` from `params` and `defaultOptions`. Previously, `params.providerOptions` would completely replace `defaultOptions.providerOptions` instead of merging them. Now provider-specific keys from both sources are merged, with `params.providerOptions` taking precedence for the same provider. ([#13820](https://github.com/mastra-ai/mastra/pull/13820))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`4f71b43`](https://github.com/mastra-ai/mastra/commit/4f71b436a4a6b8839842d8da47b57b84509af56c), [`a070277`](https://github.com/mastra-ai/mastra/commit/a07027766ce195ba74d0783116d894cbab25d44c), [`b628b91`](https://github.com/mastra-ai/mastra/commit/b628b9128b372c0f54214d902b07279f03443900), [`332c014`](https://github.com/mastra-ai/mastra/commit/332c014e076b81edf7fe45b58205882726415e90), [`6b63153`](https://github.com/mastra-ai/mastra/commit/6b63153878ea841c0f4ce632ba66bb33e57e9c1b), [`4246e34`](https://github.com/mastra-ai/mastra/commit/4246e34cec9c26636d0965942268e6d07c346671), [`b8837ee`](https://github.com/mastra-ai/mastra/commit/b8837ee77e2e84197609762bfabd8b3da326d30c), [`5d950f7`](https://github.com/mastra-ai/mastra/commit/5d950f7bf426a215a1808f0abef7de5c8336ba1c), [`28c85b1`](https://github.com/mastra-ai/mastra/commit/28c85b184fc32b40f7f160483c982da6d388ecbd), [`e9a08fb`](https://github.com/mastra-ai/mastra/commit/e9a08fbef1ada7e50e961e2f54f55e8c10b4a45c), [`631ffd8`](https://github.com/mastra-ai/mastra/commit/631ffd82fed108648b448b28e6a90e38c5f53bf5), [`aae2295`](https://github.com/mastra-ai/mastra/commit/aae2295838a2d329ad6640829e87934790ffe5b8), [`aa61f29`](https://github.com/mastra-ai/mastra/commit/aa61f29ff8095ce46a4ae16e46c4d8c79b2b685b), [`7ff3714`](https://github.com/mastra-ai/mastra/commit/7ff37148515439bb3be009a60e02c3e363299760), [`41d79a1`](https://github.com/mastra-ai/mastra/commit/41d79a14bd8cb6de1e2565fd0a04786bae2f211b), [`e673376`](https://github.com/mastra-ai/mastra/commit/e6733763ad1321aa7e5ae15096b9c2104f93b1f3), [`b2204c9`](https://github.com/mastra-ai/mastra/commit/b2204c98a42848bbfb6f0440f005dc2b6354f1cd), [`a1bf1e3`](https://github.com/mastra-ai/mastra/commit/a1bf1e385ed4c0ef6f11b56c5887442970d127f2), [`b6f647a`](https://github.com/mastra-ai/mastra/commit/b6f647ae2388e091f366581595feb957e37d5b40), [`0c57b8b`](https://github.com/mastra-ai/mastra/commit/0c57b8b0a69a97b5a4ae3f79be6c610f29f3cf7b), [`b081f27`](https://github.com/mastra-ai/mastra/commit/b081f272cf411716e1d6bd72ceac4bcee2657b19), [`0c09eac`](https://github.com/mastra-ai/mastra/commit/0c09eacb1926f64cfdc9ae5c6d63385cf8c9f72c), [`6b9b93d`](https://github.com/mastra-ai/mastra/commit/6b9b93d6f459d1ba6e36f163abf62a085ddb3d64), [`31b6067`](https://github.com/mastra-ai/mastra/commit/31b6067d0cc3ab10e1b29c36147f3b5266bc714a), [`797ac42`](https://github.com/mastra-ai/mastra/commit/797ac4276de231ad2d694d9aeca75980f6cd0419), [`0bc289e`](https://github.com/mastra-ai/mastra/commit/0bc289e2d476bf46c5b91c21969e8d0c6864691c), [`9b75a06`](https://github.com/mastra-ai/mastra/commit/9b75a06e53ebb0b950ba7c1e83a0142047185f46), [`4c3a1b1`](https://github.com/mastra-ai/mastra/commit/4c3a1b122ea083e003d71092f30f3b31680b01c0), [`85cc3b3`](https://github.com/mastra-ai/mastra/commit/85cc3b3b6f32ae4b083c26498f50d5b250ba944b), [`97ea28c`](https://github.com/mastra-ai/mastra/commit/97ea28c746e9e4147d56047bbb1c4a92417a3fec), [`d567299`](https://github.com/mastra-ai/mastra/commit/d567299cf81e02bd9d5221d4bc05967d6c224161), [`716ffe6`](https://github.com/mastra-ai/mastra/commit/716ffe68bed81f7c2690bc8581b9e140f7bf1c3d), [`8296332`](https://github.com/mastra-ai/mastra/commit/8296332de21c16e3dfc3d0b2d615720a6dc88f2f), [`4df2116`](https://github.com/mastra-ai/mastra/commit/4df211619dd922c047d396ca41cd7027c8c4c8e7), [`2219c1a`](https://github.com/mastra-ai/mastra/commit/2219c1acbd21da116da877f0036ffb985a9dd5a3), [`17c4145`](https://github.com/mastra-ai/mastra/commit/17c4145166099354545582335b5252bdfdfd908b)]:
|
|
10
|
+
- @mastra/core@1.11.0-alpha.0
|
|
11
|
+
|
|
3
12
|
## 1.1.2
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/dist/chat-route.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-route.d.ts","sourceRoot":"","sources":["../src/chat-route.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"chat-route.d.ts","sourceRoot":"","sources":["../src/chat-route.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,KAAK,EAAE,qBAAqB,EAA6B,MAAM,oBAAoB,CAAC;AAC3F,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAA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GAAG,CACA;IACE,IAAI,EAAE,GAAG,MAAM,WAAW,MAAM,EAAE,CAAC;IACnC,KAAK,CAAC,EAAE,KAAK,CAAC;CACf,GACD;IACE,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CACJ,GAAG;IACA,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,SAAS,CAAC,MAAM,GAAG,SAAS,EAAE,EAC5C,IAAuB,EACvB,KAAK,EACL,cAAc,EACd,SAAgB,EAChB,UAAiB,EACjB,aAAqB,EACrB,WAAmB,GACpB,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAkKhE"}
|
package/dist/index.cjs
CHANGED
|
@@ -6437,13 +6437,21 @@ async function handleChatStream({
|
|
|
6437
6437
|
}
|
|
6438
6438
|
}
|
|
6439
6439
|
}
|
|
6440
|
-
const
|
|
6441
|
-
|
|
6442
|
-
|
|
6440
|
+
const { structuredOutput: restStructuredOutput, ...restOptions } = rest;
|
|
6441
|
+
const { structuredOutput: defaultStructuredOutput, ...defaultOptionsRest } = defaultOptions2 ?? {};
|
|
6442
|
+
const structuredOutput = restStructuredOutput ?? defaultStructuredOutput;
|
|
6443
|
+
const mergedProviderOptions = {
|
|
6444
|
+
...defaultOptions2?.providerOptions,
|
|
6445
|
+
...restOptions.providerOptions
|
|
6446
|
+
};
|
|
6447
|
+
const baseOptions = {
|
|
6448
|
+
...defaultOptionsRest,
|
|
6449
|
+
...restOptions,
|
|
6443
6450
|
...runId && { runId },
|
|
6444
|
-
requestContext: requestContext || defaultOptions2?.requestContext
|
|
6451
|
+
requestContext: requestContext || defaultOptions2?.requestContext,
|
|
6452
|
+
...Object.keys(mergedProviderOptions).length > 0 && { providerOptions: mergedProviderOptions }
|
|
6445
6453
|
};
|
|
6446
|
-
const result = resumeData ? await agentObj.resumeStream(resumeData,
|
|
6454
|
+
const result = resumeData ? structuredOutput ? await agentObj.resumeStream(resumeData, { ...baseOptions, structuredOutput }) : await agentObj.resumeStream(resumeData, baseOptions) : structuredOutput ? await agentObj.stream(messagesToSend, { ...baseOptions, structuredOutput }) : await agentObj.stream(messagesToSend, baseOptions);
|
|
6447
6455
|
return createUIMessageStream({
|
|
6448
6456
|
originalMessages: messages,
|
|
6449
6457
|
execute: async ({ writer }) => {
|
|
@@ -7164,6 +7172,13 @@ function createProcessorMiddleware(options) {
|
|
|
7164
7172
|
messages: messageList.get.all.db(),
|
|
7165
7173
|
messageList,
|
|
7166
7174
|
state: {},
|
|
7175
|
+
result: {
|
|
7176
|
+
text: "",
|
|
7177
|
+
usage: { inputTokens: 0, outputTokens: 0, totalTokens: 0 },
|
|
7178
|
+
finishReason: "unknown",
|
|
7179
|
+
steps: []
|
|
7180
|
+
},
|
|
7181
|
+
retryCount: 0,
|
|
7167
7182
|
requestContext,
|
|
7168
7183
|
abort: (reason) => {
|
|
7169
7184
|
throw new agent.TripWire(reason || "Aborted by processor");
|
|
@@ -7298,10 +7313,23 @@ function createProcessorMiddleware(options) {
|
|
|
7298
7313
|
if (!processor.processOutputResult) continue;
|
|
7299
7314
|
try {
|
|
7300
7315
|
const procState = processorStates.get(processor.id);
|
|
7316
|
+
const finishChunk = (procState?.streamParts ?? []).find((p) => p.type === "finish");
|
|
7317
|
+
const outputResult = {
|
|
7318
|
+
text: (procState?.streamParts ?? []).filter((p) => p.type === "text-delta").map((p) => p.payload?.text ?? "").join(""),
|
|
7319
|
+
usage: finishChunk?.payload?.output?.usage ?? {
|
|
7320
|
+
inputTokens: 0,
|
|
7321
|
+
outputTokens: 0,
|
|
7322
|
+
totalTokens: 0
|
|
7323
|
+
},
|
|
7324
|
+
finishReason: finishChunk?.payload?.stepResult?.reason ?? "unknown",
|
|
7325
|
+
steps: []
|
|
7326
|
+
};
|
|
7301
7327
|
await processor.processOutputResult({
|
|
7302
7328
|
messages: messageList.get.all.db(),
|
|
7303
7329
|
messageList,
|
|
7304
7330
|
state: procState?.customState ?? {},
|
|
7331
|
+
result: outputResult,
|
|
7332
|
+
retryCount: 0,
|
|
7305
7333
|
requestContext,
|
|
7306
7334
|
abort: (reason) => {
|
|
7307
7335
|
throw new agent.TripWire(reason || "Aborted by processor");
|