@mastra/server 0.0.0-pg-pool-options-20250428183821 → 0.0.0-redis-cloud-transporter-20250508194049

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/README.md CHANGED
@@ -1,159 +1,72 @@
1
- # @mastra/deployer
1
+ # @mastra/server
2
2
 
3
- Core deployment infrastructure for Mastra applications, handling build, packaging, and deployment processes.
3
+ Typed HTTP handlers and utilities for exposing a `Mastra` instance over HTTP.
4
+ This package powers `mastra dev` and can be added to your own server to provide
5
+ REST and streaming endpoints for agents, workflows, telemetry and more.
4
6
 
5
7
  ## Installation
6
8
 
7
9
  ```bash
8
- npm install @mastra/deployer
10
+ npm install @mastra/server
9
11
  ```
10
12
 
11
- ## Overview
12
-
13
- The `@mastra/deployer` package provides the foundational deployment infrastructure for Mastra applications. It handles:
14
-
15
- - Project building and bundling
16
- - Dependency management
17
- - Environment configuration
18
- - Development and production deployments
19
-
20
13
  ## Usage
21
14
 
22
- ```typescript
23
- import { Deployer } from '@mastra/deployer';
15
+ The handlers are framework agnostic functions which accept a `Mastra` instance
16
+ and a request context. They are typically mounted under a URL prefix within your
17
+ web framework of choice:
24
18
 
25
- // Create a deployer instance
26
- const deployer = new Deployer({
27
- dir: '/path/to/project',
28
- type: 'Deploy', // or 'Dev' for development mode
19
+ ```typescript
20
+ import { Hono } from 'hono';
21
+ import { handlers } from '@mastra/server';
22
+ import { mastra } from './mastra-instance';
23
+
24
+ const app = new Hono();
25
+
26
+ app.get('/mastra/agents', ctx => handlers.agents.getAgentsHandler({ mastra, runtimeContext: ctx }));
27
+ app.post('/mastra/agents/:id/generate', async ctx => {
28
+ const body = await ctx.req.json();
29
+ return handlers.agents.generateHandler({
30
+ mastra,
31
+ runtimeContext: ctx,
32
+ agentId: ctx.req.param('id'),
33
+ body,
34
+ });
29
35
  });
30
36
 
31
- // Install dependencies
32
- await deployer.install();
33
-
34
- // Write package.json
35
- await deployer.writePackageJson();
36
-
37
- // Get Mastra instance
38
- const { mastra } = await deployer.getMastra();
37
+ // Mount additional handlers as required
39
38
  ```
40
39
 
41
- ## Configuration
42
-
43
- ### Required Parameters
44
-
45
- - `dir`: Project directory path
46
- - `type`: Deployment type ('Deploy' or 'Dev')
40
+ Running `mastra dev` starts a local development UI at
41
+ `http://localhost:3000` using these handlers.
47
42
 
48
- ## Features
43
+ ## Available Handler Groups
49
44
 
50
- ### Project Structure Management
45
+ - **Agents** - list defined agents, retrieve metadata, and run `generate`
46
+ or `stream`.
47
+ - **Workflows** - start and inspect workflow runs.
48
+ - **Tools** - discover tools available to the `Mastra` instance.
49
+ - **Memory** - interact with configured memory stores.
50
+ - **Logs** - query runtime logs when a supporting logger transport is used.
51
+ - **Telemetry** - expose metrics produced by the telemetry subsystem.
52
+ - **Networks** - interact with agent networks.
53
+ - **Vector / Voice** - endpoints related to vector stores and voice synthesis.
51
54
 
52
- - Creates and manages `.mastra` directory
53
- - Handles package.json generation and updates
54
- - Manages project dependencies
55
+ Handlers return JSON serialisable data and throw an `HTTPException` (subclass of
56
+ `Error`) when a failure should result in a non-2xx HTTP status.
55
57
 
56
- ### Dependency Management
58
+ ## OpenAPI Spec Generation
57
59
 
58
- - Automatic dependency installation
59
- - Workspace dependency resolution
60
- - Version management for @mastra packages
60
+ The local OpenAPI specification used by the CLI playground and similar tools can
61
+ be refreshed by running:
61
62
 
62
- ### Environment Handling
63
-
64
- - Support for multiple environment files:
65
- - `.env`
66
- - `.env.development`
67
- - `.env.local`
68
- - Environment variable validation and processing
69
-
70
- ### Build Process
71
-
72
- - Project bundling
73
- - Asset management
74
- - Source code transformation
75
-
76
- ### Development Support
77
-
78
- - Development server configuration
79
- - Hot reloading capabilities
80
- - Debug logging
81
-
82
- ## Project Structure
83
-
84
- The deployer creates and manages the following structure:
85
-
86
- ```
87
- your-project/
88
- ├── .mastra/
89
- │ ├── package.json
90
- │ ├── mastra.mjs
91
- │ └── index.mjs
92
- ├── .env
93
- ├── .env.development
94
- ├── .env.local
95
- └── package.json
96
- ```
97
-
98
- ## Package.json Management
99
-
100
- The deployer automatically manages dependencies in the `.mastra/package.json`:
101
-
102
- ```json
103
- {
104
- "name": "server",
105
- "version": "1.0.0",
106
- "type": "module",
107
- "dependencies": {
108
- "@mastra/loggers": "latest",
109
- "hono": "4.6.17",
110
- "@hono/node-server": "^1.13.7",
111
- "superjson": "^2.2.2",
112
- "zod-to-json-schema": "^3.24.1"
113
- }
114
- }
63
+ ```bash
64
+ pnpm run pull:openapispec
115
65
  ```
116
66
 
117
- ## Methods
118
-
119
- ### `install()`
120
-
121
- Installs and updates project dependencies.
122
-
123
- ### `writePackageJson()`
124
-
125
- Generates or updates the package.json in the .mastra directory.
126
-
127
- ### `getMastra()`
128
-
129
- Returns the Mastra instance for the project.
130
-
131
- ### `getMastraPath()`
132
-
133
- Returns the path to the .mastra directory.
134
-
135
- ## Error Handling
136
-
137
- The deployer includes comprehensive error handling for:
138
-
139
- - Dependency installation failures
140
- - File system operations
141
- - Environment configuration issues
142
- - Build process errors
143
-
144
- ## Logging
145
-
146
- Built-in logging support through @mastra/core:
147
-
148
- - Debug information
149
- - Installation progress
150
- - Build status
151
- - Error reporting
67
+ within the `@mastra/server` directory.
152
68
 
153
- ## Related Packages
69
+ ## License
154
70
 
155
- - `@mastra/core`: Core Mastra functionality
156
- - `@mastra/loggers`: Logging infrastructure
157
- - Deployer implementations:
158
- - `@mastra/deployer-cloudflare`
159
- - Other platform-specific deployers
71
+ Released under the Elastic License 2.0. The full license text is available in
72
+ this repository.
@@ -13,11 +13,11 @@ import { NewStep } from '@mastra/core/workflows/vNext';
13
13
  import type { NewWorkflow } from '@mastra/core/workflows/vNext';
14
14
  import type { QueryResult } from '@mastra/core/vector';
15
15
  import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
16
- import type { RuntimeContext } from '@mastra/core/runtime-context';
16
+ import { RuntimeContext } from '@mastra/core/runtime-context';
17
17
  import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
18
+ import { SerializedStepFlowEntry } from '@mastra/core/workflows/vNext';
18
19
  import { Step } from '@mastra/core/workflows';
19
20
  import { StepExecutionContext } from '@mastra/core/workflows';
20
- import { StepFlowEntry } from '@mastra/core/workflows/vNext';
21
21
  import { StepGraph } from '@mastra/core/workflows';
22
22
  import { StorageThreadType } from '@mastra/core/memory';
23
23
  import type { ToolAction } from '@mastra/core/tools';
@@ -114,6 +114,7 @@ export declare function generateHandler({ mastra, runtimeContext, agentId, body,
114
114
  agentId: string;
115
115
  body: GetBody<'generate'> & {
116
116
  resourceid?: string;
117
+ runtimeContext?: Record<string, unknown>;
117
118
  };
118
119
  }): Promise<GenerateTextResult<any, any>>;
119
120
 
@@ -134,7 +135,8 @@ export declare function generateSpeechHandler({ mastra, agentId, body, }: VoiceC
134
135
  };
135
136
  }): Promise<NodeJS.ReadableStream>;
136
137
 
137
- export declare function getAgentByIdHandler({ mastra, agentId }: Context & {
138
+ export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, }: Context & {
139
+ runtimeContext: RuntimeContext;
138
140
  agentId: string;
139
141
  }): Promise<{
140
142
  name: any;
@@ -144,7 +146,9 @@ export declare function getAgentByIdHandler({ mastra, agentId }: Context & {
144
146
  modelId: string;
145
147
  }>;
146
148
 
147
- export declare function getAgentsHandler({ mastra }: Context): Promise<any>;
149
+ export declare function getAgentsHandler({ mastra, runtimeContext }: Context & {
150
+ runtimeContext: RuntimeContext;
151
+ }): Promise<any>;
148
152
 
149
153
  declare type GetBody<T extends keyof Agent & {
150
154
  [K in keyof Agent]: Agent[K] extends (...args: any) => any ? K : never;
@@ -152,7 +156,8 @@ declare type GetBody<T extends keyof Agent & {
152
156
  messages: Parameters<Agent[T]>[0];
153
157
  } & Parameters<Agent[T]>[1];
154
158
 
155
- export declare function getEvalsByAgentIdHandler({ mastra, agentId }: Context & {
159
+ export declare function getEvalsByAgentIdHandler({ mastra, runtimeContext, agentId, }: Context & {
160
+ runtimeContext: RuntimeContext;
156
161
  agentId: string;
157
162
  }): Promise<{
158
163
  id: string;
@@ -161,7 +166,8 @@ export declare function getEvalsByAgentIdHandler({ mastra, agentId }: Context &
161
166
  evals: EvalRow[];
162
167
  }>;
163
168
 
164
- export declare function getLiveEvalsByAgentIdHandler({ mastra, agentId }: Context & {
169
+ export declare function getLiveEvalsByAgentIdHandler({ mastra, runtimeContext, agentId, }: Context & {
170
+ runtimeContext: RuntimeContext;
165
171
  agentId: string;
166
172
  }): Promise<{
167
173
  id: string;
@@ -187,7 +193,7 @@ export declare function getMessagesHandler({ mastra, agentId, threadId, }: Pick<
187
193
  uiMessages: Message[];
188
194
  }>;
189
195
 
190
- export declare function getNetworkByIdHandler({ mastra, networkId }: Pick<NetworkContext, 'mastra' | 'networkId'>): Promise<{
196
+ export declare function getNetworkByIdHandler({ mastra, networkId, runtimeContext, }: Pick<NetworkContext, 'mastra' | 'networkId' | 'runtimeContext'>): Promise<{
191
197
  id: string;
192
198
  name: string;
193
199
  instructions: string;
@@ -202,7 +208,7 @@ export declare function getNetworkByIdHandler({ mastra, networkId }: Pick<Networ
202
208
  };
203
209
  }>;
204
210
 
205
- export declare function getNetworksHandler({ mastra }: Pick<NetworkContext, 'mastra'>): Promise<{
211
+ export declare function getNetworksHandler({ mastra, runtimeContext, }: Pick<NetworkContext, 'mastra' | 'runtimeContext'>): Promise<{
206
212
  id: string;
207
213
  name: string;
208
214
  instructions: string;
@@ -237,14 +243,20 @@ export declare function getToolsHandler({ tools }: Pick<ToolsContext, 'tools'>):
237
243
  export declare function getVNextWorkflowByIdHandler({ mastra, workflowId }: VNextWorkflowContext): Promise<{
238
244
  steps: any;
239
245
  name: string | undefined;
240
- stepGraph: StepFlowEntry[];
246
+ stepGraph: SerializedStepFlowEntry[];
241
247
  inputSchema: string | undefined;
242
248
  outputSchema: string | undefined;
243
249
  }>;
244
250
 
245
- export declare function getVNextWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<NewWorkflow['getWorkflowRun']>>;
251
+ export declare function getVNextWorkflowRunByIdHandler({ mastra, workflowId, runId, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<NewWorkflow['getWorkflowRunById']>>;
246
252
 
247
- export declare function getVNextWorkflowRunsHandler({ mastra, workflowId }: VNextWorkflowContext): Promise<WorkflowRuns>;
253
+ export declare function getVNextWorkflowRunsHandler({ mastra, workflowId, fromDate, toDate, limit, offset, resourceId, }: VNextWorkflowContext & {
254
+ fromDate?: Date;
255
+ toDate?: Date;
256
+ limit?: number;
257
+ offset?: number;
258
+ resourceId?: string;
259
+ }): Promise<WorkflowRuns>;
248
260
 
249
261
  export declare function getVNextWorkflowsHandler({ mastra }: VNextWorkflowContext): Promise<any>;
250
262
 
@@ -260,7 +272,13 @@ export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowC
260
272
 
261
273
  export declare function getWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getRun']>>;
262
274
 
263
- export declare function getWorkflowRunsHandler({ mastra, workflowId }: WorkflowContext): Promise<WorkflowRuns>;
275
+ export declare function getWorkflowRunsHandler({ mastra, workflowId, fromDate, toDate, limit, offset, resourceId, }: WorkflowContext & {
276
+ fromDate?: Date;
277
+ toDate?: Date;
278
+ limit?: number;
279
+ offset?: number;
280
+ resourceId?: string;
281
+ }): Promise<WorkflowRuns>;
264
282
 
265
283
  export declare function getWorkflowsHandler({ mastra }: WorkflowContext): Promise<any>;
266
284
 
@@ -373,6 +391,7 @@ export declare namespace network {
373
391
 
374
392
  declare interface NetworkContext extends Context {
375
393
  networkId?: string;
394
+ runtimeContext: RuntimeContext;
376
395
  }
377
396
 
378
397
  declare interface QueryRequest {
@@ -481,6 +500,7 @@ export declare function streamGenerateHandler({ mastra, runtimeContext, agentId,
481
500
  agentId: string;
482
501
  body: GetBody<'stream'> & {
483
502
  resourceid?: string;
503
+ runtimeContext?: string;
484
504
  };
485
505
  }): Promise<Response | undefined>;
486
506
 
@@ -507,6 +527,8 @@ declare interface TelemetryContext extends Context {
507
527
  page?: number;
508
528
  perPage?: number;
509
529
  attribute?: string | string[];
530
+ fromDate?: Date;
531
+ toDate?: Date;
510
532
  };
511
533
  }
512
534
 
@@ -598,7 +620,7 @@ export declare namespace vNextWorkflows {
598
620
  export {
599
621
  getVNextWorkflowsHandler,
600
622
  getVNextWorkflowByIdHandler,
601
- getVNextWorkflowRunHandler,
623
+ getVNextWorkflowRunByIdHandler,
602
624
  createVNextWorkflowRunHandler,
603
625
  startAsyncVNextWorkflowHandler,
604
626
  startVNextWorkflowRunHandler,
@@ -13,11 +13,11 @@ import { NewStep } from '@mastra/core/workflows/vNext';
13
13
  import type { NewWorkflow } from '@mastra/core/workflows/vNext';
14
14
  import type { QueryResult } from '@mastra/core/vector';
15
15
  import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
16
- import type { RuntimeContext } from '@mastra/core/runtime-context';
16
+ import { RuntimeContext } from '@mastra/core/runtime-context';
17
17
  import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
18
+ import { SerializedStepFlowEntry } from '@mastra/core/workflows/vNext';
18
19
  import { Step } from '@mastra/core/workflows';
19
20
  import { StepExecutionContext } from '@mastra/core/workflows';
20
- import { StepFlowEntry } from '@mastra/core/workflows/vNext';
21
21
  import { StepGraph } from '@mastra/core/workflows';
22
22
  import { StorageThreadType } from '@mastra/core/memory';
23
23
  import type { ToolAction } from '@mastra/core/tools';
@@ -114,6 +114,7 @@ export declare function generateHandler({ mastra, runtimeContext, agentId, body,
114
114
  agentId: string;
115
115
  body: GetBody<'generate'> & {
116
116
  resourceid?: string;
117
+ runtimeContext?: Record<string, unknown>;
117
118
  };
118
119
  }): Promise<GenerateTextResult<any, any>>;
119
120
 
@@ -134,7 +135,8 @@ export declare function generateSpeechHandler({ mastra, agentId, body, }: VoiceC
134
135
  };
135
136
  }): Promise<NodeJS.ReadableStream>;
136
137
 
137
- export declare function getAgentByIdHandler({ mastra, agentId }: Context & {
138
+ export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, }: Context & {
139
+ runtimeContext: RuntimeContext;
138
140
  agentId: string;
139
141
  }): Promise<{
140
142
  name: any;
@@ -144,7 +146,9 @@ export declare function getAgentByIdHandler({ mastra, agentId }: Context & {
144
146
  modelId: string;
145
147
  }>;
146
148
 
147
- export declare function getAgentsHandler({ mastra }: Context): Promise<any>;
149
+ export declare function getAgentsHandler({ mastra, runtimeContext }: Context & {
150
+ runtimeContext: RuntimeContext;
151
+ }): Promise<any>;
148
152
 
149
153
  declare type GetBody<T extends keyof Agent & {
150
154
  [K in keyof Agent]: Agent[K] extends (...args: any) => any ? K : never;
@@ -152,7 +156,8 @@ declare type GetBody<T extends keyof Agent & {
152
156
  messages: Parameters<Agent[T]>[0];
153
157
  } & Parameters<Agent[T]>[1];
154
158
 
155
- export declare function getEvalsByAgentIdHandler({ mastra, agentId }: Context & {
159
+ export declare function getEvalsByAgentIdHandler({ mastra, runtimeContext, agentId, }: Context & {
160
+ runtimeContext: RuntimeContext;
156
161
  agentId: string;
157
162
  }): Promise<{
158
163
  id: string;
@@ -161,7 +166,8 @@ export declare function getEvalsByAgentIdHandler({ mastra, agentId }: Context &
161
166
  evals: EvalRow[];
162
167
  }>;
163
168
 
164
- export declare function getLiveEvalsByAgentIdHandler({ mastra, agentId }: Context & {
169
+ export declare function getLiveEvalsByAgentIdHandler({ mastra, runtimeContext, agentId, }: Context & {
170
+ runtimeContext: RuntimeContext;
165
171
  agentId: string;
166
172
  }): Promise<{
167
173
  id: string;
@@ -187,7 +193,7 @@ export declare function getMessagesHandler({ mastra, agentId, threadId, }: Pick<
187
193
  uiMessages: Message[];
188
194
  }>;
189
195
 
190
- export declare function getNetworkByIdHandler({ mastra, networkId }: Pick<NetworkContext, 'mastra' | 'networkId'>): Promise<{
196
+ export declare function getNetworkByIdHandler({ mastra, networkId, runtimeContext, }: Pick<NetworkContext, 'mastra' | 'networkId' | 'runtimeContext'>): Promise<{
191
197
  id: string;
192
198
  name: string;
193
199
  instructions: string;
@@ -202,7 +208,7 @@ export declare function getNetworkByIdHandler({ mastra, networkId }: Pick<Networ
202
208
  };
203
209
  }>;
204
210
 
205
- export declare function getNetworksHandler({ mastra }: Pick<NetworkContext, 'mastra'>): Promise<{
211
+ export declare function getNetworksHandler({ mastra, runtimeContext, }: Pick<NetworkContext, 'mastra' | 'runtimeContext'>): Promise<{
206
212
  id: string;
207
213
  name: string;
208
214
  instructions: string;
@@ -237,14 +243,20 @@ export declare function getToolsHandler({ tools }: Pick<ToolsContext, 'tools'>):
237
243
  export declare function getVNextWorkflowByIdHandler({ mastra, workflowId }: VNextWorkflowContext): Promise<{
238
244
  steps: any;
239
245
  name: string | undefined;
240
- stepGraph: StepFlowEntry[];
246
+ stepGraph: SerializedStepFlowEntry[];
241
247
  inputSchema: string | undefined;
242
248
  outputSchema: string | undefined;
243
249
  }>;
244
250
 
245
- export declare function getVNextWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<NewWorkflow['getWorkflowRun']>>;
251
+ export declare function getVNextWorkflowRunByIdHandler({ mastra, workflowId, runId, }: Pick<VNextWorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<NewWorkflow['getWorkflowRunById']>>;
246
252
 
247
- export declare function getVNextWorkflowRunsHandler({ mastra, workflowId }: VNextWorkflowContext): Promise<WorkflowRuns>;
253
+ export declare function getVNextWorkflowRunsHandler({ mastra, workflowId, fromDate, toDate, limit, offset, resourceId, }: VNextWorkflowContext & {
254
+ fromDate?: Date;
255
+ toDate?: Date;
256
+ limit?: number;
257
+ offset?: number;
258
+ resourceId?: string;
259
+ }): Promise<WorkflowRuns>;
248
260
 
249
261
  export declare function getVNextWorkflowsHandler({ mastra }: VNextWorkflowContext): Promise<any>;
250
262
 
@@ -260,7 +272,13 @@ export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowC
260
272
 
261
273
  export declare function getWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getRun']>>;
262
274
 
263
- export declare function getWorkflowRunsHandler({ mastra, workflowId }: WorkflowContext): Promise<WorkflowRuns>;
275
+ export declare function getWorkflowRunsHandler({ mastra, workflowId, fromDate, toDate, limit, offset, resourceId, }: WorkflowContext & {
276
+ fromDate?: Date;
277
+ toDate?: Date;
278
+ limit?: number;
279
+ offset?: number;
280
+ resourceId?: string;
281
+ }): Promise<WorkflowRuns>;
264
282
 
265
283
  export declare function getWorkflowsHandler({ mastra }: WorkflowContext): Promise<any>;
266
284
 
@@ -373,6 +391,7 @@ export declare namespace network {
373
391
 
374
392
  declare interface NetworkContext extends Context {
375
393
  networkId?: string;
394
+ runtimeContext: RuntimeContext;
376
395
  }
377
396
 
378
397
  declare interface QueryRequest {
@@ -481,6 +500,7 @@ export declare function streamGenerateHandler({ mastra, runtimeContext, agentId,
481
500
  agentId: string;
482
501
  body: GetBody<'stream'> & {
483
502
  resourceid?: string;
503
+ runtimeContext?: string;
484
504
  };
485
505
  }): Promise<Response | undefined>;
486
506
 
@@ -507,6 +527,8 @@ declare interface TelemetryContext extends Context {
507
527
  page?: number;
508
528
  perPage?: number;
509
529
  attribute?: string | string[];
530
+ fromDate?: Date;
531
+ toDate?: Date;
510
532
  };
511
533
  }
512
534
 
@@ -598,7 +620,7 @@ export declare namespace vNextWorkflows {
598
620
  export {
599
621
  getVNextWorkflowsHandler,
600
622
  getVNextWorkflowByIdHandler,
601
- getVNextWorkflowRunHandler,
623
+ getVNextWorkflowRunByIdHandler,
602
624
  createVNextWorkflowRunHandler,
603
625
  startAsyncVNextWorkflowHandler,
604
626
  startVNextWorkflowRunHandler,
@@ -32,7 +32,9 @@ async function getWorkflowsHandler({ mastra }) {
32
32
  steps: Object.entries(workflow.steps).reduce((acc2, [key2, step]) => {
33
33
  const _step = step;
34
34
  acc2[key2] = {
35
- ..._step,
35
+ id: _step.id,
36
+ description: _step.description,
37
+ workflowId: _step.workflowId,
36
38
  inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
37
39
  outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
38
40
  };
@@ -65,7 +67,9 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
65
67
  steps: Object.entries(workflow.steps).reduce((acc, [key, step]) => {
66
68
  const _step = step;
67
69
  acc[key] = {
68
- ..._step,
70
+ id: _step.id,
71
+ description: _step.description,
72
+ workflowId: _step.workflowId,
69
73
  inputSchema: _step.inputSchema ? stringify(esm_default(_step.inputSchema)) : void 0,
70
74
  outputSchema: _step.outputSchema ? stringify(esm_default(_step.outputSchema)) : void 0
71
75
  };
@@ -286,13 +290,21 @@ async function resumeWorkflowHandler({
286
290
  return handleError(error, "Error resuming workflow");
287
291
  }
288
292
  }
289
- async function getWorkflowRunsHandler({ mastra, workflowId }) {
293
+ async function getWorkflowRunsHandler({
294
+ mastra,
295
+ workflowId,
296
+ fromDate,
297
+ toDate,
298
+ limit,
299
+ offset,
300
+ resourceId
301
+ }) {
290
302
  try {
291
303
  if (!workflowId) {
292
304
  throw new HTTPException(400, { message: "Workflow ID is required" });
293
305
  }
294
306
  const workflow = mastra.getWorkflow(workflowId);
295
- const workflowRuns = await workflow.getWorkflowRuns() || {
307
+ const workflowRuns = await workflow.getWorkflowRuns({ fromDate, toDate, limit, offset, resourceId }) || {
296
308
  runs: [],
297
309
  total: 0
298
310
  };
@@ -12,33 +12,48 @@ chunkFV45V6WC_cjs.__export(network_exports, {
12
12
  getNetworksHandler: () => getNetworksHandler,
13
13
  streamGenerateHandler: () => streamGenerateHandler
14
14
  });
15
- async function getNetworksHandler({ mastra }) {
15
+ async function getNetworksHandler({
16
+ mastra,
17
+ runtimeContext
18
+ }) {
16
19
  try {
17
20
  const networks = mastra.getNetworks();
18
- const serializedNetworks = networks.map((network) => {
19
- const routingAgent = network.getRoutingAgent();
20
- const agents = network.getAgents();
21
- return {
22
- id: network.formatAgentId(routingAgent.name),
23
- name: routingAgent.name,
24
- instructions: routingAgent.instructions,
25
- agents: agents.map((agent) => ({
26
- name: agent.name,
27
- provider: agent.llm?.getProvider(),
28
- modelId: agent.llm?.getModelId()
29
- })),
30
- routingModel: {
31
- provider: routingAgent.llm?.getProvider(),
32
- modelId: routingAgent.llm?.getModelId()
33
- }
34
- };
35
- });
21
+ const serializedNetworks = await Promise.all(
22
+ networks.map(async (network) => {
23
+ const routingAgent = network.getRoutingAgent();
24
+ const routingLLM = await routingAgent.getLLM({ runtimeContext });
25
+ const agents = network.getAgents();
26
+ return {
27
+ id: network.formatAgentId(routingAgent.name),
28
+ name: routingAgent.name,
29
+ instructions: routingAgent.instructions,
30
+ agents: await Promise.all(
31
+ agents.map(async (agent) => {
32
+ const llm = await agent.getLLM({ runtimeContext });
33
+ return {
34
+ name: agent.name,
35
+ provider: llm?.getProvider(),
36
+ modelId: llm?.getModelId()
37
+ };
38
+ })
39
+ ),
40
+ routingModel: {
41
+ provider: routingLLM?.getProvider(),
42
+ modelId: routingLLM?.getModelId()
43
+ }
44
+ };
45
+ })
46
+ );
36
47
  return serializedNetworks;
37
48
  } catch (error) {
38
49
  return chunkZLBRQFDD_cjs.handleError(error, "Error getting networks");
39
50
  }
40
51
  }
41
- async function getNetworkByIdHandler({ mastra, networkId }) {
52
+ async function getNetworkByIdHandler({
53
+ mastra,
54
+ networkId,
55
+ runtimeContext
56
+ }) {
42
57
  try {
43
58
  const networks = mastra.getNetworks();
44
59
  const network = networks.find((network2) => {
@@ -49,19 +64,25 @@ async function getNetworkByIdHandler({ mastra, networkId }) {
49
64
  throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Network not found" });
50
65
  }
51
66
  const routingAgent = network.getRoutingAgent();
67
+ const routingLLM = await routingAgent.getLLM({ runtimeContext });
52
68
  const agents = network.getAgents();
53
69
  const serializedNetwork = {
54
70
  id: network.formatAgentId(routingAgent.name),
55
71
  name: routingAgent.name,
56
72
  instructions: routingAgent.instructions,
57
- agents: agents.map((agent) => ({
58
- name: agent.name,
59
- provider: agent.llm?.getProvider(),
60
- modelId: agent.llm?.getModelId()
61
- })),
73
+ agents: await Promise.all(
74
+ agents.map(async (agent) => {
75
+ const llm = await agent.getLLM({ runtimeContext });
76
+ return {
77
+ name: agent.name,
78
+ provider: llm?.getProvider(),
79
+ modelId: llm?.getModelId()
80
+ };
81
+ })
82
+ ),
62
83
  routingModel: {
63
- provider: routingAgent.llm?.getProvider(),
64
- modelId: routingAgent.llm?.getModelId()
84
+ provider: routingLLM?.getProvider(),
85
+ modelId: routingLLM?.getModelId()
65
86
  }
66
87
  };
67
88
  return serializedNetwork;