@mastra/ai-sdk 1.0.0-beta.12 → 1.0.0-beta.14
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 +88 -0
- package/dist/chat-route.d.ts +2 -0
- package/dist/chat-route.d.ts.map +1 -1
- package/dist/convert-streams.d.ts +1 -1
- package/dist/convert-streams.d.ts.map +1 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/index.cjs +51 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +52 -21
- package/dist/index.js.map +1 -1
- package/dist/middleware.d.ts.map +1 -1
- package/dist/transformers.d.ts +3 -1
- package/dist/transformers.d.ts.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,93 @@
|
|
|
1
1
|
# @mastra/ai-sdk
|
|
2
2
|
|
|
3
|
+
## 1.0.0-beta.14
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add structured output support to agent.network() method. Users can now pass a `structuredOutput` option with a Zod schema to get typed results from network execution. ([#11701](https://github.com/mastra-ai/mastra/pull/11701))
|
|
8
|
+
|
|
9
|
+
The stream exposes `.object` (Promise) and `.objectStream` (ReadableStream) getters, and emits `network-object` and `network-object-result` chunk types. The structured output is generated after task completion using the provided schema.
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
const stream = await agent.network('Research AI trends', {
|
|
13
|
+
structuredOutput: {
|
|
14
|
+
schema: z.object({
|
|
15
|
+
summary: z.string(),
|
|
16
|
+
recommendations: z.array(z.string()),
|
|
17
|
+
}),
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const result = await stream.object;
|
|
22
|
+
// result is typed: { summary: string; recommendations: string[] }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
- Updated dependencies [[`08766f1`](https://github.com/mastra-ai/mastra/commit/08766f15e13ac0692fde2a8bd366c2e16e4321df), [`ae8baf7`](https://github.com/mastra-ai/mastra/commit/ae8baf7d8adcb0ff9dac11880400452bc49b33ff), [`cfabdd4`](https://github.com/mastra-ai/mastra/commit/cfabdd4aae7a726b706942d6836eeca110fb6267), [`a0e437f`](https://github.com/mastra-ai/mastra/commit/a0e437fac561b28ee719e0302d72b2f9b4c138f0), [`bec5efd`](https://github.com/mastra-ai/mastra/commit/bec5efde96653ccae6604e68c696d1bc6c1a0bf5), [`9eedf7d`](https://github.com/mastra-ai/mastra/commit/9eedf7de1d6e0022a2f4e5e9e6fe1ec468f9b43c)]:
|
|
26
|
+
- @mastra/core@1.0.0-beta.21
|
|
27
|
+
|
|
28
|
+
## 1.0.0-beta.13
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- Add embedded documentation support for Mastra packages ([#11472](https://github.com/mastra-ai/mastra/pull/11472))
|
|
33
|
+
|
|
34
|
+
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`.
|
|
35
|
+
|
|
36
|
+
Each package includes:
|
|
37
|
+
- **SKILL.md** - Entry point explaining the package's purpose and capabilities
|
|
38
|
+
- **SOURCE_MAP.json** - Machine-readable index mapping exports to types and implementation files
|
|
39
|
+
- **Topic folders** - Conceptual documentation organized by feature area
|
|
40
|
+
|
|
41
|
+
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.
|
|
42
|
+
|
|
43
|
+
- Fixed agent network not returning text response when routing agent handles requests without delegation. ([#11497](https://github.com/mastra-ai/mastra/pull/11497))
|
|
44
|
+
|
|
45
|
+
**What changed:**
|
|
46
|
+
- 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
|
|
47
|
+
- Added fallback in transformers to ensure text is always returned even if core events are missing
|
|
48
|
+
|
|
49
|
+
**Why this matters:**
|
|
50
|
+
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.
|
|
51
|
+
|
|
52
|
+
Fixes #11219
|
|
53
|
+
|
|
54
|
+
- 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))
|
|
55
|
+
- Extract message format adapters (AIV4Adapter, AIV5Adapter) for SDK conversions
|
|
56
|
+
- Extract TypeDetector for centralized message format identification
|
|
57
|
+
- Extract MessageStateManager for tracking message sources and persistence
|
|
58
|
+
- Extract MessageMerger for streaming message merge logic
|
|
59
|
+
- Extract StepContentExtractor for step content extraction
|
|
60
|
+
- Extract CacheKeyGenerator for message deduplication
|
|
61
|
+
- Consolidate provider compatibility utilities (Gemini, Anthropic, OpenAI)
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
message-list/
|
|
65
|
+
├── message-list.ts # Main class (~850 LOC, down from ~4000)
|
|
66
|
+
├── adapters/ # SDK format conversions
|
|
67
|
+
│ ├── AIV4Adapter.ts # MastraDBMessage <-> AI SDK V4
|
|
68
|
+
│ └── AIV5Adapter.ts # MastraDBMessage <-> AI SDK V5
|
|
69
|
+
├── cache/
|
|
70
|
+
│ └── CacheKeyGenerator.ts # Deduplication keys
|
|
71
|
+
├── conversion/
|
|
72
|
+
│ ├── input-converter.ts # Any format -> MastraDBMessage
|
|
73
|
+
│ ├── output-converter.ts # MastraDBMessage -> SDK formats
|
|
74
|
+
│ ├── step-content.ts # Step content extraction
|
|
75
|
+
│ └── to-prompt.ts # LLM prompt formatting
|
|
76
|
+
├── detection/
|
|
77
|
+
│ └── TypeDetector.ts # Format identification
|
|
78
|
+
├── merge/
|
|
79
|
+
│ └── MessageMerger.ts # Streaming merge logic
|
|
80
|
+
├── state/
|
|
81
|
+
│ └── MessageStateManager.ts # Source & persistence tracking
|
|
82
|
+
└── utils/
|
|
83
|
+
└── provider-compat.ts # Provider-specific fixes
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- Fix autoresume not working fine in useChat ([#11486](https://github.com/mastra-ai/mastra/pull/11486))
|
|
87
|
+
|
|
88
|
+
- 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)]:
|
|
89
|
+
- @mastra/core@1.0.0-beta.20
|
|
90
|
+
|
|
3
91
|
## 1.0.0-beta.12
|
|
4
92
|
|
|
5
93
|
### 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;A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E,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,SAAS,YAAY,GAAG,SAAS,EAAE,EACjE,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,CAiKhE"}
|
|
@@ -65,7 +65,7 @@ export declare function toAISdkV5Stream<TOutput extends ZodType<any>, TInput ext
|
|
|
65
65
|
from: 'workflow';
|
|
66
66
|
includeTextStreamParts?: boolean;
|
|
67
67
|
}): ReadableStream<InferUIMessageChunk<UIMessage>>;
|
|
68
|
-
export declare function toAISdkV5Stream(stream: MastraAgentNetworkStream
|
|
68
|
+
export declare function toAISdkV5Stream<OUTPUT extends OutputSchema = undefined>(stream: MastraAgentNetworkStream<OUTPUT>, options: {
|
|
69
69
|
from: 'network';
|
|
70
70
|
}): ReadableStream<InferUIMessageChunk<UIMessage>>;
|
|
71
71
|
export declare function toAISdkV5Stream<TOutput extends OutputSchema>(stream: MastraModelOutput<TOutput>, options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-streams.d.ts","sourceRoot":"","sources":["../src/convert-streams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAEjB,YAAY,EACZ,wBA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,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,CA6OlH"}
|
package/dist/index.cjs
CHANGED
|
@@ -239,7 +239,7 @@ function secureJsonParse(text2) {
|
|
|
239
239
|
Error.stackTraceLimit = stackTraceLimit;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
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":
|
|
@@ -3348,7 +3350,7 @@ function convertFullStreamChunkToUIMessageStream({
|
|
|
3348
3350
|
}
|
|
3349
3351
|
|
|
3350
3352
|
// src/transformers.ts
|
|
3351
|
-
var PRIMITIVE_CACHE_SYMBOL = Symbol("primitive-cache");
|
|
3353
|
+
var PRIMITIVE_CACHE_SYMBOL = /* @__PURE__ */ Symbol("primitive-cache");
|
|
3352
3354
|
function WorkflowStreamToAISDKTransformer({
|
|
3353
3355
|
includeTextStreamParts
|
|
3354
3356
|
} = {}) {
|
|
@@ -3385,7 +3387,15 @@ function AgentNetworkToAISDKTransformer() {
|
|
|
3385
3387
|
},
|
|
3386
3388
|
transform(chunk, controller) {
|
|
3387
3389
|
const transformed = transformNetwork(chunk, bufferedNetworks);
|
|
3388
|
-
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
|
+
}
|
|
3389
3399
|
}
|
|
3390
3400
|
});
|
|
3391
3401
|
}
|
|
@@ -3730,7 +3740,8 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
3730
3740
|
name: payload.payload.networkId,
|
|
3731
3741
|
steps: [],
|
|
3732
3742
|
usage: null,
|
|
3733
|
-
output: null
|
|
3743
|
+
output: null,
|
|
3744
|
+
hasEmittedText: false
|
|
3734
3745
|
});
|
|
3735
3746
|
}
|
|
3736
3747
|
const current = bufferedNetworks.get(payload.runId);
|
|
@@ -3765,6 +3776,7 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
3765
3776
|
case "routing-agent-text-start": {
|
|
3766
3777
|
const current = bufferedNetworks.get(payload.runId);
|
|
3767
3778
|
if (!current) return null;
|
|
3779
|
+
current.hasEmittedText = true;
|
|
3768
3780
|
return {
|
|
3769
3781
|
type: "text-start",
|
|
3770
3782
|
id: payload.runId
|
|
@@ -3773,6 +3785,7 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
3773
3785
|
case "routing-agent-text-delta": {
|
|
3774
3786
|
const current = bufferedNetworks.get(payload.runId);
|
|
3775
3787
|
if (!current) return null;
|
|
3788
|
+
current.hasEmittedText = true;
|
|
3776
3789
|
return {
|
|
3777
3790
|
type: "text-delta",
|
|
3778
3791
|
id: payload.runId,
|
|
@@ -3947,15 +3960,25 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
3947
3960
|
case "network-execution-event-step-finish": {
|
|
3948
3961
|
const current = bufferedNetworks.get(payload.runId);
|
|
3949
3962
|
if (!current) return null;
|
|
3950
|
-
|
|
3963
|
+
const resultText = payload.payload?.result;
|
|
3964
|
+
const dataNetworkChunk = {
|
|
3951
3965
|
type: isNested ? "data-tool-network" : "data-network",
|
|
3952
3966
|
id: payload.runId,
|
|
3953
3967
|
data: {
|
|
3954
3968
|
...current,
|
|
3955
3969
|
status: "finished",
|
|
3956
|
-
output:
|
|
3970
|
+
output: resultText ?? current.output
|
|
3957
3971
|
}
|
|
3958
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;
|
|
3959
3982
|
}
|
|
3960
3983
|
case "network-execution-event-finish": {
|
|
3961
3984
|
const current = bufferedNetworks.get(payload.runId);
|
|
@@ -3971,6 +3994,10 @@ function transformNetwork(payload, bufferedNetworks, isNested) {
|
|
|
3971
3994
|
}
|
|
3972
3995
|
};
|
|
3973
3996
|
}
|
|
3997
|
+
case "network-object":
|
|
3998
|
+
case "network-object-result": {
|
|
3999
|
+
return null;
|
|
4000
|
+
}
|
|
3974
4001
|
default: {
|
|
3975
4002
|
if (isAgentExecutionDataChunkType(payload)) {
|
|
3976
4003
|
if (!("data" in payload.payload)) {
|
|
@@ -4099,7 +4126,7 @@ async function handleChatStream({
|
|
|
4099
4126
|
sendReasoning = false,
|
|
4100
4127
|
sendSources = false
|
|
4101
4128
|
}) {
|
|
4102
|
-
const { messages, resumeData, runId, requestContext, ...rest } = params;
|
|
4129
|
+
const { messages, resumeData, runId, requestContext, trigger, ...rest } = params;
|
|
4103
4130
|
if (resumeData && !runId) {
|
|
4104
4131
|
throw new Error("runId is required when resumeData is provided");
|
|
4105
4132
|
}
|
|
@@ -4110,20 +4137,24 @@ async function handleChatStream({
|
|
|
4110
4137
|
if (!Array.isArray(messages)) {
|
|
4111
4138
|
throw new Error("Messages must be an array of UIMessage objects");
|
|
4112
4139
|
}
|
|
4113
|
-
const mergedOptions = {
|
|
4114
|
-
...defaultOptions2,
|
|
4115
|
-
...rest,
|
|
4116
|
-
...runId && { runId },
|
|
4117
|
-
requestContext: requestContext || defaultOptions2?.requestContext
|
|
4118
|
-
};
|
|
4119
|
-
const result = resumeData ? await agentObj.resumeStream(resumeData, mergedOptions) : await agentObj.stream(messages, mergedOptions);
|
|
4120
4140
|
let lastMessageId;
|
|
4121
|
-
|
|
4141
|
+
let messagesToSend = messages;
|
|
4142
|
+
if (messages.length > 0) {
|
|
4122
4143
|
const lastMessage = messages[messages.length - 1];
|
|
4123
4144
|
if (lastMessage?.role === "assistant") {
|
|
4124
4145
|
lastMessageId = lastMessage.id;
|
|
4146
|
+
if (trigger === "regenerate-message") {
|
|
4147
|
+
messagesToSend = messages.slice(0, -1);
|
|
4148
|
+
}
|
|
4125
4149
|
}
|
|
4126
4150
|
}
|
|
4151
|
+
const mergedOptions = {
|
|
4152
|
+
...defaultOptions2,
|
|
4153
|
+
...rest,
|
|
4154
|
+
...runId && { runId },
|
|
4155
|
+
requestContext: requestContext || defaultOptions2?.requestContext
|
|
4156
|
+
};
|
|
4157
|
+
const result = resumeData ? await agentObj.resumeStream(resumeData, mergedOptions) : await agentObj.stream(messagesToSend, mergedOptions);
|
|
4127
4158
|
return createUIMessageStream({
|
|
4128
4159
|
originalMessages: messages,
|
|
4129
4160
|
execute: async ({ writer }) => {
|
|
@@ -4630,7 +4661,7 @@ function createProcessorMiddleware(options) {
|
|
|
4630
4661
|
}
|
|
4631
4662
|
}
|
|
4632
4663
|
}
|
|
4633
|
-
const newPrompt = messageList.get.all.aiV5.prompt().map(agent.
|
|
4664
|
+
const newPrompt = messageList.get.all.aiV5.prompt().map(agent.aiV5ModelMessageToV2PromptMessage);
|
|
4634
4665
|
return {
|
|
4635
4666
|
...params,
|
|
4636
4667
|
prompt: newPrompt
|