@mastra/ai-sdk 1.5.0-alpha.0 → 1.5.1-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 +31 -0
- package/dist/chat-route.d.ts +3 -1
- package/dist/chat-route.d.ts.map +1 -1
- package/dist/index.cjs +21 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/workflow-route.d.ts.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,36 @@
|
|
|
1
1
|
# @mastra/ai-sdk
|
|
2
2
|
|
|
3
|
+
## 1.5.1-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- `workflowRoute` now uses `MASTRA_RESOURCE_ID_KEY` from `requestContext` (set by server middleware) as the `resourceId` when creating a workflow run, falling back to the client-supplied value. This matches the precedence contract already enforced in agent calls. ([#18315](https://github.com/mastra-ai/mastra/pull/18315))
|
|
8
|
+
|
|
9
|
+
- Security: error responses from `chatRoute` and `handleChatStream` no longer leak the agent's system prompt back to the client when an upstream LLM call fails. The default error serializer now strips sensitive payload fields before they reach the response stream. ([#18335](https://github.com/mastra-ai/mastra/pull/18335))
|
|
10
|
+
|
|
11
|
+
`chatRoute` also accepts an optional `onError` for callers that want richer diagnostics on a trusted surface:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
chatRoute({
|
|
15
|
+
agent: 'support-agent',
|
|
16
|
+
onError: error => JSON.stringify(error), // full payload — only safe on trusted surfaces
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [[`65f255a`](https://github.com/mastra-ai/mastra/commit/65f255a38667beb6ceeadabfa9eb5059bfec8298), [`4a88c6e`](https://github.com/mastra-ai/mastra/commit/4a88c6e2bdce316f8d7551b4ec3449b0b06fc71c), [`87a17ef`](https://github.com/mastra-ai/mastra/commit/87a17efbd725aca6639febdc5e69e2abb3048689), [`e11ff30`](https://github.com/mastra-ai/mastra/commit/e11ff301408bf1731dca2fb7fbfcd8c819500a35), [`9d2c946`](https://github.com/mastra-ai/mastra/commit/9d2c946d0859e90ae4bcec5beeb1da7398d2ad1e), [`f1ec385`](https://github.com/mastra-ai/mastra/commit/f1ec385386f62b1a0847ec5353ae2bb169d1c3d9), [`e14986f`](https://github.com/mastra-ai/mastra/commit/e14986f6e5478d6384d04ff9a7f9a79a46a8b529), [`0be490f`](https://github.com/mastra-ai/mastra/commit/0be490fabb538c5a7de796ea0aff7d04a0bea1f3), [`0be490f`](https://github.com/mastra-ai/mastra/commit/0be490fabb538c5a7de796ea0aff7d04a0bea1f3), [`974f614`](https://github.com/mastra-ai/mastra/commit/974f614e083bd68278536f94453f7b320b86a3c7), [`31be1cf`](https://github.com/mastra-ai/mastra/commit/31be1cf5f2a7b5eef12f6123a40653b4d8115c16)]:
|
|
21
|
+
- @mastra/core@1.46.0-alpha.3
|
|
22
|
+
|
|
23
|
+
## 1.5.0
|
|
24
|
+
|
|
25
|
+
### Minor Changes
|
|
26
|
+
|
|
27
|
+
- Random bump ([#18178](https://github.com/mastra-ai/mastra/pull/18178))
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- Updated dependencies [[`7c0d868`](https://github.com/mastra-ai/mastra/commit/7c0d868d97d0fdbc04c14d0166dbf44d4c5a4a62), [`d9d2273`](https://github.com/mastra-ai/mastra/commit/d9d2273c702690c9a26eab2aebea879701d4355a), [`b04369d`](https://github.com/mastra-ai/mastra/commit/b04369d6b167c698ef103981171a8bf92808e756), [`8f3c262`](https://github.com/mastra-ai/mastra/commit/8f3c262587b335588a02d96b17fd6aca34c885b3)]:
|
|
32
|
+
- @mastra/core@1.45.0
|
|
33
|
+
|
|
3
34
|
## 1.5.0-alpha.0
|
|
4
35
|
|
|
5
36
|
### Minor Changes
|
package/dist/chat-route.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ export type chatRouteOptions<OUTPUT = undefined> = {
|
|
|
94
94
|
sendFinish?: boolean;
|
|
95
95
|
sendReasoning?: boolean;
|
|
96
96
|
sendSources?: boolean;
|
|
97
|
+
onError?: (error: unknown) => string;
|
|
97
98
|
};
|
|
98
99
|
/**
|
|
99
100
|
* Creates a chat route handler for streaming agent conversations using the AI SDK format.
|
|
@@ -108,6 +109,7 @@ export type chatRouteOptions<OUTPUT = undefined> = {
|
|
|
108
109
|
* @param {boolean} [options.sendFinish=true] - Whether to send finish events in the stream
|
|
109
110
|
* @param {boolean} [options.sendReasoning=false] - Whether to include reasoning steps in the stream
|
|
110
111
|
* @param {boolean} [options.sendSources=false] - Whether to include source citations in the stream
|
|
112
|
+
* @param {(error: unknown) => string} [options.onError] - Custom error serializer streamed to the client. When omitted, errors are passed through a default serializer that strips sensitive fields (e.g. `APICallError.requestBodyValues`, which holds the system prompt) before they reach the client.
|
|
111
113
|
*
|
|
112
114
|
* @returns {ReturnType<typeof registerApiRoute>} A registered API route handler
|
|
113
115
|
*
|
|
@@ -138,6 +140,6 @@ export type chatRouteOptions<OUTPUT = undefined> = {
|
|
|
138
140
|
* - If both `agent` and `:agentId` are present, a warning is logged and the fixed `agent` takes precedence
|
|
139
141
|
* - Request context from the incoming request overrides `defaultOptions.requestContext` if both are present
|
|
140
142
|
*/
|
|
141
|
-
export declare function chatRoute<OUTPUT = undefined>({ path, agent, defaultOptions, version, agentVersion, sendStart, sendFinish, sendReasoning, sendSources, }: chatRouteOptions<OUTPUT>): ReturnType<typeof registerApiRoute>;
|
|
143
|
+
export declare function chatRoute<OUTPUT = undefined>({ path, agent, defaultOptions, version, agentVersion, sendStart, sendFinish, sendReasoning, sendSources, onError, }: chatRouteOptions<OUTPUT>): ReturnType<typeof registerApiRoute>;
|
|
142
144
|
export {};
|
|
143
145
|
//# sourceMappingURL=chat-route.d.ts.map
|
package/dist/chat-route.d.ts.map
CHANGED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O,gBAAgB,CAAC,CAmNhE"}
|
package/dist/index.cjs
CHANGED
|
@@ -6,6 +6,7 @@ var zod = require('zod');
|
|
|
6
6
|
var server = require('@mastra/core/server');
|
|
7
7
|
var web = require('stream/web');
|
|
8
8
|
var stream = require('@mastra/core/stream');
|
|
9
|
+
var requestContext = require('@mastra/core/request-context');
|
|
9
10
|
var agent = require('@mastra/core/agent');
|
|
10
11
|
var di = require('@mastra/core/di');
|
|
11
12
|
var processors = require('@mastra/core/processors');
|
|
@@ -30,7 +31,7 @@ function _interopNamespace(e) {
|
|
|
30
31
|
|
|
31
32
|
var z4__namespace = /*#__PURE__*/_interopNamespace(z4);
|
|
32
33
|
|
|
33
|
-
// ../../packages/_vendored/ai_v5/dist/chunk-
|
|
34
|
+
// ../../packages/_vendored/ai_v5/dist/chunk-I2JBSJEA.js
|
|
34
35
|
var marker = "vercel.ai.error";
|
|
35
36
|
var symbol = Symbol.for(marker);
|
|
36
37
|
var _a;
|
|
@@ -12049,13 +12050,14 @@ var isMastraTextStreamChunk = (chunk) => {
|
|
|
12049
12050
|
"raw"
|
|
12050
12051
|
].includes(chunk.type);
|
|
12051
12052
|
};
|
|
12053
|
+
var REDACTED_ERROR_FIELDS = /* @__PURE__ */ new Set(["requestBodyValues", "responseBody", "responseHeaders", "data", "prompt"]);
|
|
12052
12054
|
function safeParseErrorObject(obj) {
|
|
12053
12055
|
if (typeof obj !== "object" || obj === null) {
|
|
12054
12056
|
return String(obj);
|
|
12055
12057
|
}
|
|
12056
12058
|
try {
|
|
12057
|
-
const stringified = JSON.stringify(obj);
|
|
12058
|
-
if (stringified === "{}") {
|
|
12059
|
+
const stringified = JSON.stringify(obj, (key, value) => REDACTED_ERROR_FIELDS.has(key) ? void 0 : value);
|
|
12060
|
+
if (stringified === "{}" || stringified === void 0) {
|
|
12059
12061
|
return String(obj);
|
|
12060
12062
|
}
|
|
12061
12063
|
return stringified;
|
|
@@ -14002,7 +14004,8 @@ function chatRoute({
|
|
|
14002
14004
|
sendStart = true,
|
|
14003
14005
|
sendFinish = true,
|
|
14004
14006
|
sendReasoning = false,
|
|
14005
|
-
sendSources = false
|
|
14007
|
+
sendSources = false,
|
|
14008
|
+
onError
|
|
14006
14009
|
}) {
|
|
14007
14010
|
if (!agent && !path.includes("/:agentId")) {
|
|
14008
14011
|
throw new Error("Path must include :agentId to route to the correct agent or pass the agent explicitly");
|
|
@@ -14171,7 +14174,8 @@ function chatRoute({
|
|
|
14171
14174
|
sendStart,
|
|
14172
14175
|
sendFinish,
|
|
14173
14176
|
sendReasoning,
|
|
14174
|
-
sendSources
|
|
14177
|
+
sendSources,
|
|
14178
|
+
onError
|
|
14175
14179
|
};
|
|
14176
14180
|
if (version === "v6") {
|
|
14177
14181
|
const uiMessageStream2 = await handleChatStream({
|
|
@@ -14194,13 +14198,23 @@ async function handleWorkflowStream({
|
|
|
14194
14198
|
sendReasoning = false,
|
|
14195
14199
|
sendSources = false
|
|
14196
14200
|
}) {
|
|
14197
|
-
const {
|
|
14201
|
+
const {
|
|
14202
|
+
runId,
|
|
14203
|
+
resourceId: resourceIdFromParams,
|
|
14204
|
+
inputData,
|
|
14205
|
+
initialState,
|
|
14206
|
+
resumeData,
|
|
14207
|
+
requestContext: requestContext$1,
|
|
14208
|
+
...rest
|
|
14209
|
+
} = params;
|
|
14210
|
+
const resourceIdFromContext = requestContext$1?.get(requestContext.MASTRA_RESOURCE_ID_KEY);
|
|
14211
|
+
const resourceId = resourceIdFromContext ?? resourceIdFromParams;
|
|
14198
14212
|
const workflowObj = mastra.getWorkflowById(workflowId);
|
|
14199
14213
|
if (!workflowObj) {
|
|
14200
14214
|
throw new Error(`Workflow ${workflowId} not found`);
|
|
14201
14215
|
}
|
|
14202
14216
|
const run = await workflowObj.createRun({ runId, resourceId, ...rest });
|
|
14203
|
-
const stream = resumeData ? run.resumeStream({ resumeData, ...rest, requestContext }) : run.stream({ inputData, initialState, ...rest, requestContext });
|
|
14217
|
+
const stream = resumeData ? run.resumeStream({ resumeData, ...rest, requestContext: requestContext$1 }) : run.stream({ inputData, initialState, ...rest, requestContext: requestContext$1 });
|
|
14204
14218
|
if (version === "v6") {
|
|
14205
14219
|
return createUIMessageStream2({
|
|
14206
14220
|
execute: async ({ writer }) => {
|