@mastra/ai-sdk 1.0.0-beta.5 → 1.0.0-beta.6
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 +9 -0
- package/dist/chat-route.d.ts +13 -8
- package/dist/chat-route.d.ts.map +1 -1
- package/dist/convert-streams.d.ts +1 -2
- package/dist/convert-streams.d.ts.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/network-route.d.ts +37 -4
- package/dist/network-route.d.ts.map +1 -1
- package/dist/workflow-route.d.ts +34 -4
- package/dist/workflow-route.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/network-route.d.ts
CHANGED
|
@@ -14,19 +14,26 @@ export type NetworkStreamHandlerOptions<OUTPUT extends OutputSchema = undefined>
|
|
|
14
14
|
defaultOptions?: AgentExecutionOptions<OUTPUT, 'mastra'>;
|
|
15
15
|
};
|
|
16
16
|
/**
|
|
17
|
-
* Framework-agnostic handler for streaming agent network execution in AI SDK format.
|
|
18
|
-
* Use this function directly when you need to handle network streaming outside of Hono
|
|
17
|
+
* Framework-agnostic handler for streaming agent network execution in AI SDK-compatible format.
|
|
18
|
+
* Use this function directly when you need to handle network streaming outside of Hono or Mastra's own apiRoutes feature.
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
|
+
* ```ts
|
|
21
22
|
* // Next.js App Router
|
|
23
|
+
* import { handleNetworkStream } from '@mastra/ai-sdk';
|
|
24
|
+
* import { createUIMessageStreamResponse } from 'ai';
|
|
25
|
+
* import { mastra } from '@/src/mastra';
|
|
26
|
+
*
|
|
22
27
|
* export async function POST(req: Request) {
|
|
23
28
|
* const params = await req.json();
|
|
24
|
-
*
|
|
29
|
+
* const stream = await handleNetworkStream({
|
|
25
30
|
* mastra,
|
|
26
|
-
* agentId: '
|
|
31
|
+
* agentId: 'routingAgent',
|
|
27
32
|
* params,
|
|
28
33
|
* });
|
|
34
|
+
* return createUIMessageStreamResponse({ stream });
|
|
29
35
|
* }
|
|
36
|
+
* ```
|
|
30
37
|
*/
|
|
31
38
|
export declare function handleNetworkStream<UI_MESSAGE extends UIMessage, OUTPUT extends OutputSchema = undefined>({ mastra, agentId, params, defaultOptions, }: NetworkStreamHandlerOptions<OUTPUT>): Promise<ReadableStream<InferUIMessageChunk<UI_MESSAGE>>>;
|
|
32
39
|
export type NetworkRouteOptions<OUTPUT extends OutputSchema = undefined> = {
|
|
@@ -38,5 +45,31 @@ export type NetworkRouteOptions<OUTPUT extends OutputSchema = undefined> = {
|
|
|
38
45
|
agent: string;
|
|
39
46
|
defaultOptions?: AgentExecutionOptions<OUTPUT, 'mastra'>;
|
|
40
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Creates a network route handler for streaming agent network execution using the AI SDK-compatible format.
|
|
50
|
+
*
|
|
51
|
+
* This function registers an HTTP POST endpoint that accepts messages, executes an agent network, and streams the response back to the client in AI SDK-compatible format. Agent networks allow a routing agent to delegate tasks to other agents.
|
|
52
|
+
*
|
|
53
|
+
* @param {NetworkRouteOptions} options - Configuration options for the network route
|
|
54
|
+
* @param {string} [options.path='/network/:agentId'] - The route path. Include `:agentId` for dynamic routing
|
|
55
|
+
* @param {string} [options.agent] - Fixed agent ID when not using dynamic routing
|
|
56
|
+
* @param {AgentExecutionOptions} [options.defaultOptions] - Default options passed to agent execution
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* // Dynamic agent routing
|
|
60
|
+
* networkRoute({
|
|
61
|
+
* path: '/network/:agentId',
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* // Fixed agent with custom path
|
|
66
|
+
* networkRoute({
|
|
67
|
+
* path: '/api/orchestrator',
|
|
68
|
+
* agent: 'router-agent',
|
|
69
|
+
* defaultOptions: {
|
|
70
|
+
* maxSteps: 10,
|
|
71
|
+
* },
|
|
72
|
+
* });
|
|
73
|
+
*/
|
|
41
74
|
export declare function networkRoute<OUTPUT extends OutputSchema = undefined>({ path, agent, defaultOptions, }: NetworkRouteOptions<OUTPUT>): ReturnType<typeof registerApiRoute>;
|
|
42
75
|
//# sourceMappingURL=network-route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-route.d.ts","sourceRoot":"","sources":["../src/network-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,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,0BAA0B,CAAC,MAAM,SAAS,YAAY,GAAG,SAAS,IAAI,qBAAqB,CACrG,MAAM,EACN,QAAQ,CACT,GAAG;IACF,QAAQ,EAAE,gBAAgB,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,2BAA2B,CAAC,MAAM,SAAS,YAAY,GAAG,SAAS,IAAI;IACjF,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,0BAA0B,CAAC,MAAM,CAAC,CAAC;IAC3C,cAAc,CAAC,EAAE,qBAAqB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CAC1D,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"network-route.d.ts","sourceRoot":"","sources":["../src/network-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,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CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;CAAE,CAAC;AAE9F;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAAC,MAAM,SAAS,YAAY,GAAG,SAAS,EAAE,EACpE,IAA0B,EAC1B,KAAK,EACL,cAAc,GACf,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAwFnE"}
|
package/dist/workflow-route.d.ts
CHANGED
|
@@ -19,19 +19,26 @@ export type WorkflowStreamHandlerOptions = {
|
|
|
19
19
|
includeTextStreamParts?: boolean;
|
|
20
20
|
};
|
|
21
21
|
/**
|
|
22
|
-
* Framework-agnostic handler for streaming workflow execution in AI SDK format.
|
|
23
|
-
* Use this function directly when you need to handle workflow streaming outside of Hono
|
|
22
|
+
* Framework-agnostic handler for streaming workflow execution in AI SDK-compatible format.
|
|
23
|
+
* Use this function directly when you need to handle workflow streaming outside of Hono or Mastra's own apiRoutes feature.
|
|
24
24
|
*
|
|
25
25
|
* @example
|
|
26
|
+
* ```ts
|
|
26
27
|
* // Next.js App Router
|
|
28
|
+
* import { handleWorkflowStream } from '@mastra/ai-sdk';
|
|
29
|
+
* import { createUIMessageStreamResponse } from 'ai';
|
|
30
|
+
* import { mastra } from '@/src/mastra';
|
|
31
|
+
*
|
|
27
32
|
* export async function POST(req: Request) {
|
|
28
33
|
* const params = await req.json();
|
|
29
|
-
*
|
|
34
|
+
* const stream = await handleWorkflowStream({
|
|
30
35
|
* mastra,
|
|
31
|
-
* workflowId: '
|
|
36
|
+
* workflowId: 'weatherWorkflow',
|
|
32
37
|
* params,
|
|
33
38
|
* });
|
|
39
|
+
* return createUIMessageStreamResponse({ stream });
|
|
34
40
|
* }
|
|
41
|
+
* ```
|
|
35
42
|
*/
|
|
36
43
|
export declare function handleWorkflowStream<UI_MESSAGE extends UIMessage>({ mastra, workflowId, params, includeTextStreamParts, }: WorkflowStreamHandlerOptions): Promise<ReadableStream<InferUIMessageChunk<UI_MESSAGE>>>;
|
|
37
44
|
export type WorkflowRouteOptions = {
|
|
@@ -43,5 +50,28 @@ export type WorkflowRouteOptions = {
|
|
|
43
50
|
workflow: string;
|
|
44
51
|
includeTextStreamParts?: boolean;
|
|
45
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* Creates a workflow route handler for streaming workflow execution using the AI SDK format.
|
|
55
|
+
*
|
|
56
|
+
* This function registers an HTTP POST endpoint that accepts input data, executes a workflow, and streams the response back to the client in AI SDK-compatible format.
|
|
57
|
+
*
|
|
58
|
+
* @param {WorkflowRouteOptions} options - Configuration options for the workflow route
|
|
59
|
+
* @param {string} [options.path='/api/workflows/:workflowId/stream'] - The route path. Include `:workflowId` for dynamic routing
|
|
60
|
+
* @param {string} [options.workflow] - Fixed workflow ID when not using dynamic routing
|
|
61
|
+
* @param {boolean} [options.includeTextStreamParts=true] - Whether to include text stream parts in the output
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* // Dynamic workflow routing
|
|
65
|
+
* workflowRoute({
|
|
66
|
+
* path: '/api/workflows/:workflowId/stream',
|
|
67
|
+
* });
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* // Fixed workflow with custom path
|
|
71
|
+
* workflowRoute({
|
|
72
|
+
* path: '/api/data-pipeline/stream',
|
|
73
|
+
* workflow: 'data-processing-workflow',
|
|
74
|
+
* });
|
|
75
|
+
*/
|
|
46
76
|
export declare function workflowRoute({ path, workflow, includeTextStreamParts, }: WorkflowRouteOptions): ReturnType<typeof registerApiRoute>;
|
|
47
77
|
//# sourceMappingURL=workflow-route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-route.d.ts","sourceRoot":"","sources":["../src/workflow-route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AACj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
|
|
4
4
|
"description": "Adds custom API routes to be compatible with the AI SDK UI parts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"vitest": "4.0.12",
|
|
46
46
|
"zod": "^3.25.76",
|
|
47
47
|
"@internal/lint": "0.0.53",
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
48
|
+
"@internal/types-builder": "0.0.28",
|
|
49
|
+
"@mastra/core": "1.0.0-beta.8"
|
|
50
50
|
},
|
|
51
51
|
"keywords": [
|
|
52
52
|
"mastra",
|