@mastra/ai-sdk 1.0.0-beta.11 → 1.0.0-beta.13
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 +79 -0
- package/dist/chat-route.d.ts +2 -0
- package/dist/chat-route.d.ts.map +1 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/index.cjs +65 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +66 -31
- package/dist/index.js.map +1 -1
- package/dist/middleware.d.ts.map +1 -1
- package/dist/transformers.d.ts +8 -7
- package/dist/transformers.d.ts.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,84 @@
|
|
|
1
1
|
# @mastra/ai-sdk
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.13
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add embedded documentation support for Mastra packages ([#11472](https://github.com/mastra-ai/mastra/pull/11472))
|
|
8
|
+
|
|
9
|
+
Mastra packages now include embedded documentation in the published npm package under `dist/docs/`. This enables coding agents and AI assistants to understand and use the framework by reading documentation directly from `node_modules`.
|
|
10
|
+
|
|
11
|
+
Each package includes:
|
|
12
|
+
- **SKILL.md** - Entry point explaining the package's purpose and capabilities
|
|
13
|
+
- **SOURCE_MAP.json** - Machine-readable index mapping exports to types and implementation files
|
|
14
|
+
- **Topic folders** - Conceptual documentation organized by feature area
|
|
15
|
+
|
|
16
|
+
Documentation is driven by the `packages` frontmatter field in MDX files, which maps docs to their corresponding packages. CI validation ensures all docs include this field.
|
|
17
|
+
|
|
18
|
+
- Fixed agent network not returning text response when routing agent handles requests without delegation. ([#11497](https://github.com/mastra-ai/mastra/pull/11497))
|
|
19
|
+
|
|
20
|
+
**What changed:**
|
|
21
|
+
- Agent networks now correctly stream text responses when the routing agent decides to handle a request itself instead of delegating to sub-agents, workflows, or tools
|
|
22
|
+
- Added fallback in transformers to ensure text is always returned even if core events are missing
|
|
23
|
+
|
|
24
|
+
**Why this matters:**
|
|
25
|
+
Previously, when using `toAISdkV5Stream` or `networkRoute()` outside of the Mastra Studio UI, no text content was returned when the routing agent handled requests directly. This fix ensures consistent behavior across all API routes.
|
|
26
|
+
|
|
27
|
+
Fixes #11219
|
|
28
|
+
|
|
29
|
+
- Refactor the MessageList class from ~4000 LOC monolith to ~850 LOC with focused, single-responsibility modules. This improves maintainability, testability, and makes the codebase easier to understand. ([#11658](https://github.com/mastra-ai/mastra/pull/11658))
|
|
30
|
+
- Extract message format adapters (AIV4Adapter, AIV5Adapter) for SDK conversions
|
|
31
|
+
- Extract TypeDetector for centralized message format identification
|
|
32
|
+
- Extract MessageStateManager for tracking message sources and persistence
|
|
33
|
+
- Extract MessageMerger for streaming message merge logic
|
|
34
|
+
- Extract StepContentExtractor for step content extraction
|
|
35
|
+
- Extract CacheKeyGenerator for message deduplication
|
|
36
|
+
- Consolidate provider compatibility utilities (Gemini, Anthropic, OpenAI)
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
message-list/
|
|
40
|
+
├── message-list.ts # Main class (~850 LOC, down from ~4000)
|
|
41
|
+
├── adapters/ # SDK format conversions
|
|
42
|
+
│ ├── AIV4Adapter.ts # MastraDBMessage <-> AI SDK V4
|
|
43
|
+
│ └── AIV5Adapter.ts # MastraDBMessage <-> AI SDK V5
|
|
44
|
+
├── cache/
|
|
45
|
+
│ └── CacheKeyGenerator.ts # Deduplication keys
|
|
46
|
+
├── conversion/
|
|
47
|
+
│ ├── input-converter.ts # Any format -> MastraDBMessage
|
|
48
|
+
│ ├── output-converter.ts # MastraDBMessage -> SDK formats
|
|
49
|
+
│ ├── step-content.ts # Step content extraction
|
|
50
|
+
│ └── to-prompt.ts # LLM prompt formatting
|
|
51
|
+
├── detection/
|
|
52
|
+
│ └── TypeDetector.ts # Format identification
|
|
53
|
+
├── merge/
|
|
54
|
+
│ └── MessageMerger.ts # Streaming merge logic
|
|
55
|
+
├── state/
|
|
56
|
+
│ └── MessageStateManager.ts # Source & persistence tracking
|
|
57
|
+
└── utils/
|
|
58
|
+
└── provider-compat.ts # Provider-specific fixes
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
- Fix autoresume not working fine in useChat ([#11486](https://github.com/mastra-ai/mastra/pull/11486))
|
|
62
|
+
|
|
63
|
+
- Updated dependencies [[`d2d3e22`](https://github.com/mastra-ai/mastra/commit/d2d3e22a419ee243f8812a84e3453dd44365ecb0), [`bc72b52`](https://github.com/mastra-ai/mastra/commit/bc72b529ee4478fe89ecd85a8be47ce0127b82a0), [`05b8bee`](https://github.com/mastra-ai/mastra/commit/05b8bee9e50e6c2a4a2bf210eca25ee212ca24fa), [`c042bd0`](https://github.com/mastra-ai/mastra/commit/c042bd0b743e0e86199d0cb83344ca7690e34a9c), [`940a2b2`](https://github.com/mastra-ai/mastra/commit/940a2b27480626ed7e74f55806dcd2181c1dd0c2), [`e0941c3`](https://github.com/mastra-ai/mastra/commit/e0941c3d7fc75695d5d258e7008fd5d6e650800c), [`0c0580a`](https://github.com/mastra-ai/mastra/commit/0c0580a42f697cd2a7d5973f25bfe7da9055038a), [`28f5f89`](https://github.com/mastra-ai/mastra/commit/28f5f89705f2409921e3c45178796c0e0d0bbb64), [`e601b27`](https://github.com/mastra-ai/mastra/commit/e601b272c70f3a5ecca610373aa6223012704892), [`3d3366f`](https://github.com/mastra-ai/mastra/commit/3d3366f31683e7137d126a3a57174a222c5801fb), [`5a4953f`](https://github.com/mastra-ai/mastra/commit/5a4953f7d25bb15ca31ed16038092a39cb3f98b3), [`eb9e522`](https://github.com/mastra-ai/mastra/commit/eb9e522ce3070a405e5b949b7bf5609ca51d7fe2), [`20e6f19`](https://github.com/mastra-ai/mastra/commit/20e6f1971d51d3ff6dd7accad8aaaae826d540ed), [`4f0b3c6`](https://github.com/mastra-ai/mastra/commit/4f0b3c66f196c06448487f680ccbb614d281e2f7), [`74c4f22`](https://github.com/mastra-ai/mastra/commit/74c4f22ed4c71e72598eacc346ba95cdbc00294f), [`81b6a8f`](https://github.com/mastra-ai/mastra/commit/81b6a8ff79f49a7549d15d66624ac1a0b8f5f971), [`e4d366a`](https://github.com/mastra-ai/mastra/commit/e4d366aeb500371dd4210d6aa8361a4c21d87034), [`a4f010b`](https://github.com/mastra-ai/mastra/commit/a4f010b22e4355a5fdee70a1fe0f6e4a692cc29e), [`73b0bb3`](https://github.com/mastra-ai/mastra/commit/73b0bb394dba7c9482eb467a97ab283dbc0ef4db), [`5627a8c`](https://github.com/mastra-ai/mastra/commit/5627a8c6dc11fe3711b3fa7a6ffd6eb34100a306), [`3ff45d1`](https://github.com/mastra-ai/mastra/commit/3ff45d10e0c80c5335a957ab563da72feb623520), [`251df45`](https://github.com/mastra-ai/mastra/commit/251df4531407dfa46d805feb40ff3fb49769f455), [`f894d14`](https://github.com/mastra-ai/mastra/commit/f894d148946629af7b1f452d65a9cf864cec3765), [`c2b9547`](https://github.com/mastra-ai/mastra/commit/c2b9547bf435f56339f23625a743b2147ab1c7a6), [`580b592`](https://github.com/mastra-ai/mastra/commit/580b5927afc82fe460dfdf9a38a902511b6b7e7f), [`58e3931`](https://github.com/mastra-ai/mastra/commit/58e3931af9baa5921688566210f00fb0c10479fa), [`08bb631`](https://github.com/mastra-ai/mastra/commit/08bb631ae2b14684b2678e3549d0b399a6f0561e), [`4fba91b`](https://github.com/mastra-ai/mastra/commit/4fba91bec7c95911dc28e369437596b152b04cd0), [`12b0cc4`](https://github.com/mastra-ai/mastra/commit/12b0cc4077d886b1a552637dedb70a7ade93528c)]:
|
|
64
|
+
- @mastra/core@1.0.0-beta.20
|
|
65
|
+
|
|
66
|
+
## 1.0.0-beta.12
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- Fix data chunk property filtering to only include type, data, and id properties ([#11477](https://github.com/mastra-ai/mastra/pull/11477))
|
|
71
|
+
|
|
72
|
+
Previously, when `isDataChunkType` checks were performed, the entire chunk object was returned, potentially letting extra properties like `from`, `runId`, `metadata`, etc go through. This could cause issues with `useChat` and other UI components.
|
|
73
|
+
|
|
74
|
+
Now, all locations that handle `DataChunkType` properly destructure and return only the allowed properties:
|
|
75
|
+
- `type` (required): The chunk type identifier starting with "data-"
|
|
76
|
+
- `data` (required): The actual data payload
|
|
77
|
+
- `id` (optional): An optional identifier for the chunk
|
|
78
|
+
|
|
79
|
+
- Updated dependencies [[`e54953e`](https://github.com/mastra-ai/mastra/commit/e54953ed8ce1b28c0d62a19950163039af7834b4), [`7d56d92`](https://github.com/mastra-ai/mastra/commit/7d56d9213886e8353956d7d40df10045fd12b299), [`fdac646`](https://github.com/mastra-ai/mastra/commit/fdac646033a0930a1a4e00d13aa64c40bb7f1e02), [`d07b568`](https://github.com/mastra-ai/mastra/commit/d07b5687819ea8cb1dffa776d0c1765faf4aa1ae), [`68ec97d`](https://github.com/mastra-ai/mastra/commit/68ec97d4c07c6393fcf95c2481fc5d73da99f8c8), [`4aa55b3`](https://github.com/mastra-ai/mastra/commit/4aa55b383cf06043943359ea316572fd969861a7)]:
|
|
80
|
+
- @mastra/core@1.0.0-beta.19
|
|
81
|
+
|
|
3
82
|
## 1.0.0-beta.11
|
|
4
83
|
|
|
5
84
|
### Patch Changes
|
package/dist/chat-route.d.ts
CHANGED
|
@@ -6,6 +6,8 @@ import type { InferUIMessageChunk, UIMessage } from 'ai';
|
|
|
6
6
|
export type ChatStreamHandlerParams<UI_MESSAGE extends UIMessage, OUTPUT extends OutputSchema = undefined> = AgentExecutionOptions<OUTPUT> & {
|
|
7
7
|
messages: UI_MESSAGE[];
|
|
8
8
|
resumeData?: Record<string, any>;
|
|
9
|
+
/** The trigger for the request - sent by AI SDK's useChat hook */
|
|
10
|
+
trigger?: 'submit-message' | 'regenerate-message';
|
|
9
11
|
};
|
|
10
12
|
export type ChatStreamHandlerOptions<UI_MESSAGE extends UIMessage, OUTPUT extends OutputSchema = undefined> = {
|
|
11
13
|
mastra: Mastra;
|
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":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAGzD,MAAM,MAAM,uBAAuB,CACjC,UAAU,SAAS,SAAS,EAC5B,MAAM,SAAS,YAAY,GAAG,SAAS,IACrC,qBAAqB,CAAC,MAAM,CAAC,GAAG;IAClC,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"chat-route.d.ts","sourceRoot":"","sources":["../src/chat-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,KAAK,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AAGzD,MAAM,MAAM,uBAAuB,CACjC,UAAU,SAAS,SAAS,EAC5B,MAAM,SAAS,YAAY,GAAG,SAAS,IACrC,qBAAqB,CAAC,MAAM,CAAC,GAAG;IAClC,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,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
|
-
var validatorSymbol = Symbol.for("vercel.ai.validator");
|
|
242
|
+
var validatorSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.validator");
|
|
243
243
|
function validator(validate) {
|
|
244
244
|
return { [validatorSymbol]: true, validate };
|
|
245
245
|
}
|
|
@@ -322,7 +322,7 @@ var getRelativePath = (pathA, pathB) => {
|
|
|
322
322
|
}
|
|
323
323
|
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
324
324
|
};
|
|
325
|
-
var ignoreOverride = Symbol(
|
|
325
|
+
var ignoreOverride = /* @__PURE__ */ Symbol(
|
|
326
326
|
"Let zodToJsonSchema decide on which parser to use"
|
|
327
327
|
);
|
|
328
328
|
var defaultOptions = {
|
|
@@ -1442,7 +1442,7 @@ function zodSchema(zodSchema2, options) {
|
|
|
1442
1442
|
return zod3Schema(zodSchema2);
|
|
1443
1443
|
}
|
|
1444
1444
|
}
|
|
1445
|
-
var schemaSymbol = Symbol.for("vercel.ai.schema");
|
|
1445
|
+
var schemaSymbol = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
|
|
1446
1446
|
function jsonSchema(jsonSchema2, {
|
|
1447
1447
|
validate
|
|
1448
1448
|
} = {}) {
|
|
@@ -2999,7 +2999,8 @@ function convertMastraChunkToAISDKv5({
|
|
|
2999
2999
|
runId: chunk.runId,
|
|
3000
3000
|
toolCallId: chunk.payload.toolCallId,
|
|
3001
3001
|
toolName: chunk.payload.toolName,
|
|
3002
|
-
args: chunk.payload.args
|
|
3002
|
+
args: chunk.payload.args,
|
|
3003
|
+
resumeSchema: chunk.payload.resumeSchema
|
|
3003
3004
|
}
|
|
3004
3005
|
};
|
|
3005
3006
|
case "tool-call-suspended":
|
|
@@ -3010,7 +3011,8 @@ function convertMastraChunkToAISDKv5({
|
|
|
3010
3011
|
runId: chunk.runId,
|
|
3011
3012
|
toolCallId: chunk.payload.toolCallId,
|
|
3012
3013
|
toolName: chunk.payload.toolName,
|
|
3013
|
-
suspendPayload: chunk.payload.suspendPayload
|
|
3014
|
+
suspendPayload: chunk.payload.suspendPayload,
|
|
3015
|
+
resumeSchema: chunk.payload.resumeSchema
|
|
3014
3016
|
}
|
|
3015
3017
|
};
|
|
3016
3018
|
case "tool-call-input-streaming-start":
|
|
@@ -3276,7 +3278,8 @@ function convertFullStreamChunkToUIMessageStream({
|
|
|
3276
3278
|
${JSON.stringify(part)}`
|
|
3277
3279
|
);
|
|
3278
3280
|
}
|
|
3279
|
-
|
|
3281
|
+
const { type, data, id } = part.output;
|
|
3282
|
+
return { type, data, ...id !== void 0 && { id } };
|
|
3280
3283
|
}
|
|
3281
3284
|
return;
|
|
3282
3285
|
}
|
|
@@ -3338,7 +3341,8 @@ function convertFullStreamChunkToUIMessageStream({
|
|
|
3338
3341
|
${JSON.stringify(part)}`
|
|
3339
3342
|
);
|
|
3340
3343
|
}
|
|
3341
|
-
|
|
3344
|
+
const { type, data, id } = part;
|
|
3345
|
+
return { type, data, ...id !== void 0 && { id } };
|
|
3342
3346
|
}
|
|
3343
3347
|
return;
|
|
3344
3348
|
}
|
|
@@ -3346,7 +3350,7 @@ function convertFullStreamChunkToUIMessageStream({
|
|
|
3346
3350
|
}
|
|
3347
3351
|
|
|
3348
3352
|
// src/transformers.ts
|
|
3349
|
-
var PRIMITIVE_CACHE_SYMBOL = Symbol("primitive-cache");
|
|
3353
|
+
var PRIMITIVE_CACHE_SYMBOL = /* @__PURE__ */ Symbol("primitive-cache");
|
|
3350
3354
|
function WorkflowStreamToAISDKTransformer({
|
|
3351
3355
|
includeTextStreamParts
|
|
3352
3356
|
} = {}) {
|
|
@@ -3383,7 +3387,15 @@ function AgentNetworkToAISDKTransformer() {
|
|
|
3383
3387
|
},
|
|
3384
3388
|
transform(chunk, controller) {
|
|
3385
3389
|
const transformed = transformNetwork(chunk, bufferedNetworks);
|
|
3386
|
-
if (transformed)
|
|
3390
|
+
if (transformed) {
|
|
3391
|
+
if (Array.isArray(transformed)) {
|
|
3392
|
+
for (const item of transformed) {
|
|
3393
|
+
controller.enqueue(item);
|
|
3394
|
+
}
|
|
3395
|
+
} else {
|
|
3396
|
+
controller.enqueue(transformed);
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3387
3399
|
}
|
|
3388
3400
|
});
|
|
3389
3401
|
}
|
|
@@ -3696,7 +3708,8 @@ function transformWorkflow(payload, bufferedWorkflows, isNested, includeTextStre
|
|
|
3696
3708
|
${JSON.stringify(output)}`
|
|
3697
3709
|
);
|
|
3698
3710
|
}
|
|
3699
|
-
|
|
3711
|
+
const { type, data, id } = output;
|
|
3712
|
+
return { type, data, ...id !== void 0 && { id } };
|
|
3700
3713
|
}
|
|
3701
3714
|
return null;
|
|
3702
3715
|
}
|
|
@@ -3708,7 +3721,12 @@ function transformWorkflow(payload, bufferedWorkflows, isNested, includeTextStre
|
|
|
3708
3721
|
${JSON.stringify(payload)}`
|
|
3709
3722
|
);
|
|
3710
3723
|
}
|
|
3711
|
-
|
|
3724
|
+
const { type, data, id } = payload;
|
|
3725
|
+
return {
|
|
3726
|
+
type,
|
|
3727
|
+
data,
|
|
3728
|
+
...id !== void 0 && { id }
|
|
3729
|
+
};
|
|
3712
3730
|
}
|
|
3713
3731
|
return null;
|
|
3714
3732
|
}
|
|
@@ -3722,7 +3740,8 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
3722
3740
|
name: payload.payload.networkId,
|
|
3723
3741
|
steps: [],
|
|
3724
3742
|
usage: null,
|
|
3725
|
-
output: null
|
|
3743
|
+
output: null,
|
|
3744
|
+
hasEmittedText: false
|
|
3726
3745
|
});
|
|
3727
3746
|
}
|
|
3728
3747
|
const current = bufferedNetworks.get(payload.runId);
|
|
@@ -3757,6 +3776,7 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
3757
3776
|
case "routing-agent-text-start": {
|
|
3758
3777
|
const current = bufferedNetworks.get(payload.runId);
|
|
3759
3778
|
if (!current) return null;
|
|
3779
|
+
current.hasEmittedText = true;
|
|
3760
3780
|
return {
|
|
3761
3781
|
type: "text-start",
|
|
3762
3782
|
id: payload.runId
|
|
@@ -3765,6 +3785,7 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
3765
3785
|
case "routing-agent-text-delta": {
|
|
3766
3786
|
const current = bufferedNetworks.get(payload.runId);
|
|
3767
3787
|
if (!current) return null;
|
|
3788
|
+
current.hasEmittedText = true;
|
|
3768
3789
|
return {
|
|
3769
3790
|
type: "text-delta",
|
|
3770
3791
|
id: payload.runId,
|
|
@@ -3939,15 +3960,25 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
3939
3960
|
case "network-execution-event-step-finish": {
|
|
3940
3961
|
const current = bufferedNetworks.get(payload.runId);
|
|
3941
3962
|
if (!current) return null;
|
|
3942
|
-
|
|
3963
|
+
const resultText = payload.payload?.result;
|
|
3964
|
+
const dataNetworkChunk = {
|
|
3943
3965
|
type: isNested ? "data-tool-network" : "data-network",
|
|
3944
3966
|
id: payload.runId,
|
|
3945
3967
|
data: {
|
|
3946
3968
|
...current,
|
|
3947
3969
|
status: "finished",
|
|
3948
|
-
output:
|
|
3970
|
+
output: resultText ?? current.output
|
|
3949
3971
|
}
|
|
3950
3972
|
};
|
|
3973
|
+
if (!current.hasEmittedText && resultText && typeof resultText === "string" && resultText.length > 0) {
|
|
3974
|
+
current.hasEmittedText = true;
|
|
3975
|
+
return [
|
|
3976
|
+
{ type: "text-start", id: payload.runId },
|
|
3977
|
+
{ type: "text-delta", id: payload.runId, delta: resultText },
|
|
3978
|
+
dataNetworkChunk
|
|
3979
|
+
];
|
|
3980
|
+
}
|
|
3981
|
+
return dataNetworkChunk;
|
|
3951
3982
|
}
|
|
3952
3983
|
case "network-execution-event-finish": {
|
|
3953
3984
|
const current = bufferedNetworks.get(payload.runId);
|
|
@@ -3971,8 +4002,8 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
3971
4002
|
${JSON.stringify(payload)}`
|
|
3972
4003
|
);
|
|
3973
4004
|
}
|
|
3974
|
-
const { type, data } = payload.payload;
|
|
3975
|
-
return { type, data };
|
|
4005
|
+
const { type, data, id } = payload.payload;
|
|
4006
|
+
return { type, data, ...id !== void 0 && { id } };
|
|
3976
4007
|
}
|
|
3977
4008
|
if (isWorkflowExecutionDataChunkType(payload)) {
|
|
3978
4009
|
if (!("data" in payload.payload)) {
|
|
@@ -3981,8 +4012,8 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
3981
4012
|
${JSON.stringify(payload)}`
|
|
3982
4013
|
);
|
|
3983
4014
|
}
|
|
3984
|
-
const { type, data } = payload.payload;
|
|
3985
|
-
return { type, data };
|
|
4015
|
+
const { type, data, id } = payload.payload;
|
|
4016
|
+
return { type, data, ...id !== void 0 && { id } };
|
|
3986
4017
|
}
|
|
3987
4018
|
if (payload.type.startsWith("agent-execution-event-")) {
|
|
3988
4019
|
const stepId = payload.payload.runId;
|
|
@@ -4042,8 +4073,8 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
4042
4073
|
${JSON.stringify(payload)}`
|
|
4043
4074
|
);
|
|
4044
4075
|
}
|
|
4045
|
-
const { type, data } = payload;
|
|
4046
|
-
return { type, data };
|
|
4076
|
+
const { type, data, id } = payload;
|
|
4077
|
+
return { type, data, ...id !== void 0 && { id } };
|
|
4047
4078
|
}
|
|
4048
4079
|
return null;
|
|
4049
4080
|
}
|
|
@@ -4091,7 +4122,7 @@ async function handleChatStream({
|
|
|
4091
4122
|
sendReasoning = false,
|
|
4092
4123
|
sendSources = false
|
|
4093
4124
|
}) {
|
|
4094
|
-
const { messages, resumeData, runId, requestContext, ...rest } = params;
|
|
4125
|
+
const { messages, resumeData, runId, requestContext, trigger, ...rest } = params;
|
|
4095
4126
|
if (resumeData && !runId) {
|
|
4096
4127
|
throw new Error("runId is required when resumeData is provided");
|
|
4097
4128
|
}
|
|
@@ -4102,20 +4133,24 @@ async function handleChatStream({
|
|
|
4102
4133
|
if (!Array.isArray(messages)) {
|
|
4103
4134
|
throw new Error("Messages must be an array of UIMessage objects");
|
|
4104
4135
|
}
|
|
4105
|
-
const mergedOptions = {
|
|
4106
|
-
...defaultOptions2,
|
|
4107
|
-
...rest,
|
|
4108
|
-
...runId && { runId },
|
|
4109
|
-
requestContext: requestContext || defaultOptions2?.requestContext
|
|
4110
|
-
};
|
|
4111
|
-
const result = resumeData ? await agentObj.resumeStream(resumeData, mergedOptions) : await agentObj.stream(messages, mergedOptions);
|
|
4112
4136
|
let lastMessageId;
|
|
4113
|
-
|
|
4137
|
+
let messagesToSend = messages;
|
|
4138
|
+
if (messages.length > 0) {
|
|
4114
4139
|
const lastMessage = messages[messages.length - 1];
|
|
4115
4140
|
if (lastMessage?.role === "assistant") {
|
|
4116
4141
|
lastMessageId = lastMessage.id;
|
|
4142
|
+
if (trigger === "regenerate-message") {
|
|
4143
|
+
messagesToSend = messages.slice(0, -1);
|
|
4144
|
+
}
|
|
4117
4145
|
}
|
|
4118
4146
|
}
|
|
4147
|
+
const mergedOptions = {
|
|
4148
|
+
...defaultOptions2,
|
|
4149
|
+
...rest,
|
|
4150
|
+
...runId && { runId },
|
|
4151
|
+
requestContext: requestContext || defaultOptions2?.requestContext
|
|
4152
|
+
};
|
|
4153
|
+
const result = resumeData ? await agentObj.resumeStream(resumeData, mergedOptions) : await agentObj.stream(messagesToSend, mergedOptions);
|
|
4119
4154
|
return createUIMessageStream({
|
|
4120
4155
|
originalMessages: messages,
|
|
4121
4156
|
execute: async ({ writer }) => {
|
|
@@ -4622,7 +4657,7 @@ function createProcessorMiddleware(options) {
|
|
|
4622
4657
|
}
|
|
4623
4658
|
}
|
|
4624
4659
|
}
|
|
4625
|
-
const newPrompt = messageList.get.all.aiV5.prompt().map(agent.
|
|
4660
|
+
const newPrompt = messageList.get.all.aiV5.prompt().map(agent.aiV5ModelMessageToV2PromptMessage);
|
|
4626
4661
|
return {
|
|
4627
4662
|
...params,
|
|
4628
4663
|
prompt: newPrompt
|