@mastra/ai-sdk 1.3.3 → 1.4.0-alpha.1
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 +32 -0
- package/README.md +27 -0
- package/dist/chat-route.d.ts +8 -1
- package/dist/chat-route.d.ts.map +1 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/index.cjs +76 -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 +76 -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/package.json +9 -9
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
|
@@ -11975,6 +11975,9 @@ function convertFullStreamChunkToUIMessageStream({
|
|
|
11975
11975
|
};
|
|
11976
11976
|
}
|
|
11977
11977
|
case "reasoning-start": {
|
|
11978
|
+
if (!sendReasoning) {
|
|
11979
|
+
return;
|
|
11980
|
+
}
|
|
11978
11981
|
return {
|
|
11979
11982
|
type: "reasoning-start",
|
|
11980
11983
|
id: part.id,
|
|
@@ -11993,6 +11996,9 @@ function convertFullStreamChunkToUIMessageStream({
|
|
|
11993
11996
|
return;
|
|
11994
11997
|
}
|
|
11995
11998
|
case "reasoning-end": {
|
|
11999
|
+
if (!sendReasoning) {
|
|
12000
|
+
return;
|
|
12001
|
+
}
|
|
11996
12002
|
return {
|
|
11997
12003
|
type: "reasoning-end",
|
|
11998
12004
|
id: part.id,
|
|
@@ -13149,6 +13155,7 @@ function toAISdkStream(stream, options = {
|
|
|
13149
13155
|
async function handleChatStream({
|
|
13150
13156
|
mastra,
|
|
13151
13157
|
agentId,
|
|
13158
|
+
agentVersion,
|
|
13152
13159
|
params,
|
|
13153
13160
|
defaultOptions: defaultOptions3,
|
|
13154
13161
|
version = "v5",
|
|
@@ -13163,7 +13170,7 @@ async function handleChatStream({
|
|
|
13163
13170
|
if (resumeData && !runId) {
|
|
13164
13171
|
throw new Error("runId is required when resumeData is provided");
|
|
13165
13172
|
}
|
|
13166
|
-
const agentObj = mastra.getAgentById(agentId);
|
|
13173
|
+
const agentObj = agentVersion ? await mastra.getAgentById(agentId, agentVersion) : mastra.getAgentById(agentId);
|
|
13167
13174
|
if (!agentObj) {
|
|
13168
13175
|
throw new Error(`Agent ${agentId} not found`);
|
|
13169
13176
|
}
|
|
@@ -13239,6 +13246,7 @@ function chatRoute({
|
|
|
13239
13246
|
agent,
|
|
13240
13247
|
defaultOptions: defaultOptions3,
|
|
13241
13248
|
version = "v5",
|
|
13249
|
+
agentVersion,
|
|
13242
13250
|
sendStart = true,
|
|
13243
13251
|
sendFinish = true,
|
|
13244
13252
|
sendReasoning = false,
|
|
@@ -13262,6 +13270,25 @@ function chatRoute({
|
|
|
13262
13270
|
schema: {
|
|
13263
13271
|
type: "string"
|
|
13264
13272
|
}
|
|
13273
|
+
},
|
|
13274
|
+
{
|
|
13275
|
+
name: "versionId",
|
|
13276
|
+
in: "query",
|
|
13277
|
+
required: false,
|
|
13278
|
+
description: "Specific agent version ID to use. Mutually exclusive with status.",
|
|
13279
|
+
schema: {
|
|
13280
|
+
type: "string"
|
|
13281
|
+
}
|
|
13282
|
+
},
|
|
13283
|
+
{
|
|
13284
|
+
name: "status",
|
|
13285
|
+
in: "query",
|
|
13286
|
+
required: false,
|
|
13287
|
+
description: "Which stored config version to resolve: draft (latest) or published (active version). Mutually exclusive with versionId.",
|
|
13288
|
+
schema: {
|
|
13289
|
+
type: "string",
|
|
13290
|
+
enum: ["draft", "published"]
|
|
13291
|
+
}
|
|
13265
13292
|
}
|
|
13266
13293
|
],
|
|
13267
13294
|
requestBody: {
|
|
@@ -13369,9 +13396,20 @@ function chatRoute({
|
|
|
13369
13396
|
if (!agentToUse) {
|
|
13370
13397
|
throw new Error("Agent ID is required");
|
|
13371
13398
|
}
|
|
13399
|
+
const queryVersionId = c.req.query("versionId");
|
|
13400
|
+
const rawStatus = c.req.query("status");
|
|
13401
|
+
if (queryVersionId && rawStatus) {
|
|
13402
|
+
throw new Error('Query parameters "versionId" and "status" are mutually exclusive');
|
|
13403
|
+
}
|
|
13404
|
+
if (rawStatus && rawStatus !== "draft" && rawStatus !== "published") {
|
|
13405
|
+
throw new Error('Query parameter "status" must be "draft" or "published"');
|
|
13406
|
+
}
|
|
13407
|
+
const queryStatus = rawStatus;
|
|
13408
|
+
const effectiveAgentVersion = queryVersionId ? { versionId: queryVersionId } : queryStatus ? { status: queryStatus } : agentVersion;
|
|
13372
13409
|
const handlerOptions = {
|
|
13373
13410
|
mastra,
|
|
13374
13411
|
agentId: agentToUse,
|
|
13412
|
+
agentVersion: effectiveAgentVersion,
|
|
13375
13413
|
params: {
|
|
13376
13414
|
...params,
|
|
13377
13415
|
requestContext: effectiveRequestContext,
|
|
@@ -13543,12 +13581,13 @@ function workflowRoute({
|
|
|
13543
13581
|
async function handleNetworkStream({
|
|
13544
13582
|
mastra,
|
|
13545
13583
|
agentId,
|
|
13584
|
+
agentVersion,
|
|
13546
13585
|
params,
|
|
13547
13586
|
defaultOptions: defaultOptions3,
|
|
13548
13587
|
version = "v5"
|
|
13549
13588
|
}) {
|
|
13550
13589
|
const { messages, ...rest } = params;
|
|
13551
|
-
const agentObj = mastra.getAgentById(agentId);
|
|
13590
|
+
const agentObj = agentVersion ? await mastra.getAgentById(agentId, agentVersion) : mastra.getAgentById(agentId);
|
|
13552
13591
|
if (!agentObj) {
|
|
13553
13592
|
throw new Error(`Agent ${agentId} not found`);
|
|
13554
13593
|
}
|
|
@@ -13585,7 +13624,8 @@ function networkRoute({
|
|
|
13585
13624
|
path = "/network/:agentId",
|
|
13586
13625
|
agent,
|
|
13587
13626
|
defaultOptions: defaultOptions3,
|
|
13588
|
-
version = "v5"
|
|
13627
|
+
version = "v5",
|
|
13628
|
+
agentVersion
|
|
13589
13629
|
}) {
|
|
13590
13630
|
if (!agent && !path.includes("/:agentId")) {
|
|
13591
13631
|
throw new Error("Path must include :agentId to route to the correct agent or pass the agent explicitly");
|
|
@@ -13603,6 +13643,20 @@ function networkRoute({
|
|
|
13603
13643
|
required: true,
|
|
13604
13644
|
description: "The ID of the routing agent to execute as a network",
|
|
13605
13645
|
schema: { type: "string" }
|
|
13646
|
+
},
|
|
13647
|
+
{
|
|
13648
|
+
name: "versionId",
|
|
13649
|
+
in: "query",
|
|
13650
|
+
required: false,
|
|
13651
|
+
description: "Specific agent version ID to use. Mutually exclusive with status.",
|
|
13652
|
+
schema: { type: "string" }
|
|
13653
|
+
},
|
|
13654
|
+
{
|
|
13655
|
+
name: "status",
|
|
13656
|
+
in: "query",
|
|
13657
|
+
required: false,
|
|
13658
|
+
description: "Which stored config version to resolve: draft (latest) or published (active version). Mutually exclusive with versionId.",
|
|
13659
|
+
schema: { type: "string", enum: ["draft", "published"] }
|
|
13606
13660
|
}
|
|
13607
13661
|
],
|
|
13608
13662
|
requestBody: {
|
|
@@ -13631,6 +13685,14 @@ function networkRoute({
|
|
|
13631
13685
|
description: "Streaming AI SDK UIMessage event stream for the agent network",
|
|
13632
13686
|
content: { "text/plain": { schema: { type: "string", description: "SSE stream" } } }
|
|
13633
13687
|
},
|
|
13688
|
+
"400": {
|
|
13689
|
+
description: "Bad request - invalid input",
|
|
13690
|
+
content: {
|
|
13691
|
+
"application/json": {
|
|
13692
|
+
schema: { type: "object", properties: { error: { type: "string" } } }
|
|
13693
|
+
}
|
|
13694
|
+
}
|
|
13695
|
+
},
|
|
13634
13696
|
"404": {
|
|
13635
13697
|
description: "Agent not found",
|
|
13636
13698
|
content: {
|
|
@@ -13662,9 +13724,20 @@ function networkRoute({
|
|
|
13662
13724
|
if (!agentToUse) {
|
|
13663
13725
|
throw new Error("Agent ID is required");
|
|
13664
13726
|
}
|
|
13727
|
+
const queryVersionId = c.req.query("versionId");
|
|
13728
|
+
const rawStatus = c.req.query("status");
|
|
13729
|
+
if (queryVersionId && rawStatus) {
|
|
13730
|
+
throw new Error('Query parameters "versionId" and "status" are mutually exclusive');
|
|
13731
|
+
}
|
|
13732
|
+
if (rawStatus && rawStatus !== "draft" && rawStatus !== "published") {
|
|
13733
|
+
throw new Error('Query parameter "status" must be "draft" or "published"');
|
|
13734
|
+
}
|
|
13735
|
+
const queryStatus = rawStatus;
|
|
13736
|
+
const effectiveAgentVersion = queryVersionId ? { versionId: queryVersionId } : queryStatus ? { status: queryStatus } : agentVersion;
|
|
13665
13737
|
const handlerOptions = {
|
|
13666
13738
|
mastra,
|
|
13667
13739
|
agentId: agentToUse,
|
|
13740
|
+
agentVersion: effectiveAgentVersion,
|
|
13668
13741
|
params: {
|
|
13669
13742
|
...params,
|
|
13670
13743
|
requestContext: effectiveRequestContext
|