@mastra/ai-sdk 1.3.4-alpha.0 → 1.4.0-alpha.2
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 +34 -0
- package/README.md +27 -0
- package/dist/_types/@internal_ai-v6/dist/index.d.ts +1695 -109
- package/dist/chat-route.d.ts +8 -1
- package/dist/chat-route.d.ts.map +1 -1
- package/dist/convert-messages.d.ts.map +1 -1
- package/dist/index.cjs +78 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +78 -3
- package/dist/index.js.map +1 -1
- package/dist/network-route.d.ts +5 -1
- package/dist/network-route.d.ts.map +1 -1
- package/dist/transformers.d.ts.map +1 -1
- package/dist/ui.cjs +21 -4
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.js +21 -4
- package/dist/ui.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { chatRoute, handleChatStream } from './chat-route.js';
|
|
2
|
-
export type { chatRouteOptions, ChatStreamHandlerParams, ChatStreamHandlerOptions } from './chat-route.js';
|
|
2
|
+
export type { chatRouteOptions, ChatStreamHandlerParams, ChatStreamHandlerOptions, AgentVersionOptions, } from './chat-route.js';
|
|
3
3
|
export { workflowRoute, handleWorkflowStream } from './workflow-route.js';
|
|
4
4
|
export type { WorkflowRouteOptions, WorkflowStreamHandlerParams, WorkflowStreamHandlerOptions } from './workflow-route.js';
|
|
5
5
|
export type { WorkflowDataPart } from './transformers.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3D,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3D,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACvE,YAAY,EAAE,oBAAoB,EAAE,2BAA2B,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;AACxH,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACpE,YAAY,EAAE,mBAAmB,EAAE,0BAA0B,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AACpH,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGnE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,+BAA+B,EAAE,MAAM,cAAc,CAAC;AAGhH,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -12277,6 +12277,14 @@ function createAgentStreamToAISDKTransformer(convertMastraChunkToAISDK, {
|
|
|
12277
12277
|
if (chunk.type === "finish") {
|
|
12278
12278
|
finishEventSent = true;
|
|
12279
12279
|
}
|
|
12280
|
+
if (chunk.type === "object-result") {
|
|
12281
|
+
controller.enqueue({
|
|
12282
|
+
type: "data-structured-output",
|
|
12283
|
+
data: {
|
|
12284
|
+
object: chunk.object
|
|
12285
|
+
}
|
|
12286
|
+
});
|
|
12287
|
+
}
|
|
12280
12288
|
const part = convertMastraChunkToAISDK({ chunk, mode: "stream" });
|
|
12281
12289
|
const transformedChunk = convertFullStreamChunkToUIMessageStream({
|
|
12282
12290
|
part,
|
|
@@ -13155,6 +13163,7 @@ function toAISdkStream(stream, options = {
|
|
|
13155
13163
|
async function handleChatStream({
|
|
13156
13164
|
mastra,
|
|
13157
13165
|
agentId,
|
|
13166
|
+
agentVersion,
|
|
13158
13167
|
params,
|
|
13159
13168
|
defaultOptions: defaultOptions3,
|
|
13160
13169
|
version = "v5",
|
|
@@ -13169,7 +13178,7 @@ async function handleChatStream({
|
|
|
13169
13178
|
if (resumeData && !runId) {
|
|
13170
13179
|
throw new Error("runId is required when resumeData is provided");
|
|
13171
13180
|
}
|
|
13172
|
-
const agentObj = mastra.getAgentById(agentId);
|
|
13181
|
+
const agentObj = agentVersion ? await mastra.getAgentById(agentId, agentVersion) : mastra.getAgentById(agentId);
|
|
13173
13182
|
if (!agentObj) {
|
|
13174
13183
|
throw new Error(`Agent ${agentId} not found`);
|
|
13175
13184
|
}
|
|
@@ -13245,6 +13254,7 @@ function chatRoute({
|
|
|
13245
13254
|
agent,
|
|
13246
13255
|
defaultOptions: defaultOptions3,
|
|
13247
13256
|
version = "v5",
|
|
13257
|
+
agentVersion,
|
|
13248
13258
|
sendStart = true,
|
|
13249
13259
|
sendFinish = true,
|
|
13250
13260
|
sendReasoning = false,
|
|
@@ -13268,6 +13278,25 @@ function chatRoute({
|
|
|
13268
13278
|
schema: {
|
|
13269
13279
|
type: "string"
|
|
13270
13280
|
}
|
|
13281
|
+
},
|
|
13282
|
+
{
|
|
13283
|
+
name: "versionId",
|
|
13284
|
+
in: "query",
|
|
13285
|
+
required: false,
|
|
13286
|
+
description: "Specific agent version ID to use. Mutually exclusive with status.",
|
|
13287
|
+
schema: {
|
|
13288
|
+
type: "string"
|
|
13289
|
+
}
|
|
13290
|
+
},
|
|
13291
|
+
{
|
|
13292
|
+
name: "status",
|
|
13293
|
+
in: "query",
|
|
13294
|
+
required: false,
|
|
13295
|
+
description: "Which stored config version to resolve: draft (latest) or published (active version). Mutually exclusive with versionId.",
|
|
13296
|
+
schema: {
|
|
13297
|
+
type: "string",
|
|
13298
|
+
enum: ["draft", "published"]
|
|
13299
|
+
}
|
|
13271
13300
|
}
|
|
13272
13301
|
],
|
|
13273
13302
|
requestBody: {
|
|
@@ -13375,9 +13404,20 @@ function chatRoute({
|
|
|
13375
13404
|
if (!agentToUse) {
|
|
13376
13405
|
throw new Error("Agent ID is required");
|
|
13377
13406
|
}
|
|
13407
|
+
const queryVersionId = c.req.query("versionId");
|
|
13408
|
+
const rawStatus = c.req.query("status");
|
|
13409
|
+
if (queryVersionId && rawStatus) {
|
|
13410
|
+
throw new Error('Query parameters "versionId" and "status" are mutually exclusive');
|
|
13411
|
+
}
|
|
13412
|
+
if (rawStatus && rawStatus !== "draft" && rawStatus !== "published") {
|
|
13413
|
+
throw new Error('Query parameter "status" must be "draft" or "published"');
|
|
13414
|
+
}
|
|
13415
|
+
const queryStatus = rawStatus;
|
|
13416
|
+
const effectiveAgentVersion = queryVersionId ? { versionId: queryVersionId } : queryStatus ? { status: queryStatus } : agentVersion;
|
|
13378
13417
|
const handlerOptions = {
|
|
13379
13418
|
mastra,
|
|
13380
13419
|
agentId: agentToUse,
|
|
13420
|
+
agentVersion: effectiveAgentVersion,
|
|
13381
13421
|
params: {
|
|
13382
13422
|
...params,
|
|
13383
13423
|
requestContext: effectiveRequestContext,
|
|
@@ -13549,12 +13589,13 @@ function workflowRoute({
|
|
|
13549
13589
|
async function handleNetworkStream({
|
|
13550
13590
|
mastra,
|
|
13551
13591
|
agentId,
|
|
13592
|
+
agentVersion,
|
|
13552
13593
|
params,
|
|
13553
13594
|
defaultOptions: defaultOptions3,
|
|
13554
13595
|
version = "v5"
|
|
13555
13596
|
}) {
|
|
13556
13597
|
const { messages, ...rest } = params;
|
|
13557
|
-
const agentObj = mastra.getAgentById(agentId);
|
|
13598
|
+
const agentObj = agentVersion ? await mastra.getAgentById(agentId, agentVersion) : mastra.getAgentById(agentId);
|
|
13558
13599
|
if (!agentObj) {
|
|
13559
13600
|
throw new Error(`Agent ${agentId} not found`);
|
|
13560
13601
|
}
|
|
@@ -13591,7 +13632,8 @@ function networkRoute({
|
|
|
13591
13632
|
path = "/network/:agentId",
|
|
13592
13633
|
agent,
|
|
13593
13634
|
defaultOptions: defaultOptions3,
|
|
13594
|
-
version = "v5"
|
|
13635
|
+
version = "v5",
|
|
13636
|
+
agentVersion
|
|
13595
13637
|
}) {
|
|
13596
13638
|
if (!agent && !path.includes("/:agentId")) {
|
|
13597
13639
|
throw new Error("Path must include :agentId to route to the correct agent or pass the agent explicitly");
|
|
@@ -13609,6 +13651,20 @@ function networkRoute({
|
|
|
13609
13651
|
required: true,
|
|
13610
13652
|
description: "The ID of the routing agent to execute as a network",
|
|
13611
13653
|
schema: { type: "string" }
|
|
13654
|
+
},
|
|
13655
|
+
{
|
|
13656
|
+
name: "versionId",
|
|
13657
|
+
in: "query",
|
|
13658
|
+
required: false,
|
|
13659
|
+
description: "Specific agent version ID to use. Mutually exclusive with status.",
|
|
13660
|
+
schema: { type: "string" }
|
|
13661
|
+
},
|
|
13662
|
+
{
|
|
13663
|
+
name: "status",
|
|
13664
|
+
in: "query",
|
|
13665
|
+
required: false,
|
|
13666
|
+
description: "Which stored config version to resolve: draft (latest) or published (active version). Mutually exclusive with versionId.",
|
|
13667
|
+
schema: { type: "string", enum: ["draft", "published"] }
|
|
13612
13668
|
}
|
|
13613
13669
|
],
|
|
13614
13670
|
requestBody: {
|
|
@@ -13637,6 +13693,14 @@ function networkRoute({
|
|
|
13637
13693
|
description: "Streaming AI SDK UIMessage event stream for the agent network",
|
|
13638
13694
|
content: { "text/plain": { schema: { type: "string", description: "SSE stream" } } }
|
|
13639
13695
|
},
|
|
13696
|
+
"400": {
|
|
13697
|
+
description: "Bad request - invalid input",
|
|
13698
|
+
content: {
|
|
13699
|
+
"application/json": {
|
|
13700
|
+
schema: { type: "object", properties: { error: { type: "string" } } }
|
|
13701
|
+
}
|
|
13702
|
+
}
|
|
13703
|
+
},
|
|
13640
13704
|
"404": {
|
|
13641
13705
|
description: "Agent not found",
|
|
13642
13706
|
content: {
|
|
@@ -13668,9 +13732,20 @@ function networkRoute({
|
|
|
13668
13732
|
if (!agentToUse) {
|
|
13669
13733
|
throw new Error("Agent ID is required");
|
|
13670
13734
|
}
|
|
13735
|
+
const queryVersionId = c.req.query("versionId");
|
|
13736
|
+
const rawStatus = c.req.query("status");
|
|
13737
|
+
if (queryVersionId && rawStatus) {
|
|
13738
|
+
throw new Error('Query parameters "versionId" and "status" are mutually exclusive');
|
|
13739
|
+
}
|
|
13740
|
+
if (rawStatus && rawStatus !== "draft" && rawStatus !== "published") {
|
|
13741
|
+
throw new Error('Query parameter "status" must be "draft" or "published"');
|
|
13742
|
+
}
|
|
13743
|
+
const queryStatus = rawStatus;
|
|
13744
|
+
const effectiveAgentVersion = queryVersionId ? { versionId: queryVersionId } : queryStatus ? { status: queryStatus } : agentVersion;
|
|
13671
13745
|
const handlerOptions = {
|
|
13672
13746
|
mastra,
|
|
13673
13747
|
agentId: agentToUse,
|
|
13748
|
+
agentVersion: effectiveAgentVersion,
|
|
13674
13749
|
params: {
|
|
13675
13750
|
...params,
|
|
13676
13751
|
requestContext: effectiveRequestContext
|