@mastra/server 1.0.3-alpha.0 → 1.0.3-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.
@@ -1,4 +1,6 @@
1
- Elastic License 2.0 (ELv2)
1
+ # Elastic License 2.0 (ELv2)
2
+
3
+ Copyright (c) 2025 Mastra AI, Inc.
2
4
 
3
5
  **Acceptance**
4
6
  By using the software, you agree to all of the terms and conditions below.
@@ -1,27 +1,27 @@
1
1
  import type { Agent } from '@mastra/core/agent';
2
2
  import type { AgentNetwork } from '@mastra/core/network';
3
- import { BaseLogMessage } from '@mastra/core';
3
+ import type { BaseLogMessage } from '@mastra/core/logger';
4
+ import type { Container } from '@mastra/core/di';
4
5
  import { CoreMessage } from 'ai';
5
- import { EvalRow } from '@mastra/core';
6
+ import { EvalRow } from '@mastra/core/storage';
6
7
  import { GenerateObjectResult } from 'ai';
7
8
  import { GenerateTextResult } from 'ai';
8
9
  import type { Mastra } from '@mastra/core/mastra';
9
- import type { Mastra as Mastra_2 } from '@mastra/core';
10
10
  import type { MastraMemory } from '@mastra/core/memory';
11
11
  import { Message } from 'ai';
12
- import { MessageType } from '@mastra/core';
12
+ import { MessageType } from '@mastra/core/memory';
13
13
  import type { QueryResult } from '@mastra/core/vector';
14
14
  import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
15
- import { Step } from '@mastra/core';
16
- import { StepExecutionContext } from '@mastra/core';
17
- import { StepGraph } from '@mastra/core';
18
- import { StorageThreadType } from '@mastra/core';
15
+ import { Step } from '@mastra/core/workflows';
16
+ import { StepExecutionContext } from '@mastra/core/workflows';
17
+ import { StepGraph } from '@mastra/core/workflows';
18
+ import { StorageThreadType } from '@mastra/core/memory';
19
19
  import type { ToolAction } from '@mastra/core/tools';
20
20
  import type { VercelTool } from '@mastra/core/tools';
21
21
  import type { Workflow } from '@mastra/core/workflows';
22
- import { WorkflowContext as WorkflowContext_2 } from '@mastra/core';
23
- import { WorkflowRunResult } from '@mastra/core';
24
- import { WorkflowRuns } from '@mastra/core';
22
+ import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows';
23
+ import { WorkflowRunResult } from '@mastra/core/workflows';
24
+ import type { WorkflowRuns } from '@mastra/core/storage';
25
25
 
26
26
  export declare namespace agents {
27
27
  export {
@@ -96,14 +96,16 @@ export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mas
96
96
  data?: unknown;
97
97
  }) => Promise<any>;
98
98
 
99
- export declare function generateHandler({ mastra, agentId, body, }: Context & {
99
+ export declare function generateHandler({ mastra, container, agentId, body, }: Context & {
100
+ container: Container;
100
101
  agentId: string;
101
102
  body: GetBody<'generate'> & {
102
103
  resourceid?: string;
103
104
  };
104
105
  }): Promise<GenerateTextResult<any, any>>;
105
106
 
106
- export declare function generateHandler_alias_1({ mastra, networkId, body, }: NetworkContext & {
107
+ export declare function generateHandler_alias_1({ mastra, container, networkId, body, }: NetworkContext & {
108
+ container: Container;
107
109
  body: {
108
110
  messages?: Parameters<AgentNetwork['generate']>[0];
109
111
  } & Parameters<AgentNetwork['generate']>[1];
@@ -159,7 +161,7 @@ export declare function getLiveEvalsByAgentIdHandler({ mastra, agentId }: Contex
159
161
 
160
162
  export declare function getLogsByRunIdHandler({ mastra, runId, transportId, }: Pick<LogsContext, 'mastra' | 'runId' | 'transportId'>): Promise<BaseLogMessage[] | undefined>;
161
163
 
162
- export declare function getLogsHandler({ mastra, transportId }: Pick<LogsContext, 'mastra' | 'transportId'>): Promise<BaseLogMessage[]>;
164
+ export declare function getLogsHandler({ mastra, transportId, }: Pick<LogsContext, 'mastra' | 'transportId'>): Promise<BaseLogMessage[]>;
163
165
 
164
166
  export declare function getLogTransports({ mastra }: Pick<LogsContext, 'mastra'>): Promise<{
165
167
  transports: string[];
@@ -362,18 +364,20 @@ export declare function queryVectors({ mastra, vectorName, query, }: Pick<Vector
362
364
 
363
365
  declare type RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;
364
366
 
365
- export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, }: WorkflowContext & {
367
+ export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, container, }: WorkflowContext & {
366
368
  body: {
367
369
  stepId: string;
368
370
  context: any;
369
371
  };
372
+ container: Container;
370
373
  }): Promise<Omit<WorkflowRunResult<any, Step<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, Step<string, any, any, any>[], Record<string, any>>>>[], any>, "runId"> | undefined>;
371
374
 
372
- export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, }: WorkflowContext & {
375
+ export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, container, }: WorkflowContext & {
373
376
  body: {
374
377
  stepId: string;
375
378
  context: any;
376
379
  };
380
+ container: Container;
377
381
  }): Promise<{
378
382
  message: string;
379
383
  }>;
@@ -386,12 +390,14 @@ export declare function saveMessagesHandler({ mastra, agentId, body, }: Pick<Mem
386
390
 
387
391
  declare type ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
388
392
 
389
- export declare function startAsyncWorkflowHandler({ mastra, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
393
+ export declare function startAsyncWorkflowHandler({ mastra, container, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
390
394
  triggerData?: unknown;
395
+ container: Container;
391
396
  }): Promise<WorkflowRunResult<any, Step<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, Step<string, any, any, any>[], Record<string, any>>>>[], any>>;
392
397
 
393
- export declare function startWorkflowRunHandler({ mastra, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
398
+ export declare function startWorkflowRunHandler({ mastra, container, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
394
399
  triggerData?: unknown;
400
+ container: Container;
395
401
  }): Promise<{
396
402
  message: string;
397
403
  }>;
@@ -415,14 +421,16 @@ export declare function storeTelemetryHandler({ mastra, body }: Context & {
415
421
  traceCount: number;
416
422
  }>;
417
423
 
418
- export declare function streamGenerateHandler({ mastra, agentId, body, }: Context & {
424
+ export declare function streamGenerateHandler({ mastra, container, agentId, body, }: Context & {
425
+ container: Container;
419
426
  agentId: string;
420
427
  body: GetBody<'stream'> & {
421
428
  resourceid?: string;
422
429
  };
423
430
  }): Promise<Response | undefined>;
424
431
 
425
- export declare function streamGenerateHandler_alias_1({ mastra, networkId, body, }: NetworkContext & {
432
+ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body, container, }: NetworkContext & {
433
+ container: Container;
426
434
  body: {
427
435
  messages?: Parameters<AgentNetwork['stream']>[0];
428
436
  } & Parameters<AgentNetwork['stream']>[1];
@@ -540,8 +548,7 @@ declare interface VoiceContext extends Context {
540
548
 
541
549
  export declare function watchWorkflowHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReadableStream_2<string>>;
542
550
 
543
- declare interface WorkflowContext {
544
- mastra: Mastra_2;
551
+ declare interface WorkflowContext extends Context {
545
552
  workflowId?: string;
546
553
  runId?: string;
547
554
  }
@@ -1,27 +1,27 @@
1
1
  import type { Agent } from '@mastra/core/agent';
2
2
  import type { AgentNetwork } from '@mastra/core/network';
3
- import { BaseLogMessage } from '@mastra/core';
3
+ import type { BaseLogMessage } from '@mastra/core/logger';
4
+ import type { Container } from '@mastra/core/di';
4
5
  import { CoreMessage } from 'ai';
5
- import { EvalRow } from '@mastra/core';
6
+ import { EvalRow } from '@mastra/core/storage';
6
7
  import { GenerateObjectResult } from 'ai';
7
8
  import { GenerateTextResult } from 'ai';
8
9
  import type { Mastra } from '@mastra/core/mastra';
9
- import type { Mastra as Mastra_2 } from '@mastra/core';
10
10
  import type { MastraMemory } from '@mastra/core/memory';
11
11
  import { Message } from 'ai';
12
- import { MessageType } from '@mastra/core';
12
+ import { MessageType } from '@mastra/core/memory';
13
13
  import type { QueryResult } from '@mastra/core/vector';
14
14
  import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
15
- import { Step } from '@mastra/core';
16
- import { StepExecutionContext } from '@mastra/core';
17
- import { StepGraph } from '@mastra/core';
18
- import { StorageThreadType } from '@mastra/core';
15
+ import { Step } from '@mastra/core/workflows';
16
+ import { StepExecutionContext } from '@mastra/core/workflows';
17
+ import { StepGraph } from '@mastra/core/workflows';
18
+ import { StorageThreadType } from '@mastra/core/memory';
19
19
  import type { ToolAction } from '@mastra/core/tools';
20
20
  import type { VercelTool } from '@mastra/core/tools';
21
21
  import type { Workflow } from '@mastra/core/workflows';
22
- import { WorkflowContext as WorkflowContext_2 } from '@mastra/core';
23
- import { WorkflowRunResult } from '@mastra/core';
24
- import { WorkflowRuns } from '@mastra/core';
22
+ import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows';
23
+ import { WorkflowRunResult } from '@mastra/core/workflows';
24
+ import type { WorkflowRuns } from '@mastra/core/storage';
25
25
 
26
26
  export declare namespace agents {
27
27
  export {
@@ -96,14 +96,16 @@ export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mas
96
96
  data?: unknown;
97
97
  }) => Promise<any>;
98
98
 
99
- export declare function generateHandler({ mastra, agentId, body, }: Context & {
99
+ export declare function generateHandler({ mastra, container, agentId, body, }: Context & {
100
+ container: Container;
100
101
  agentId: string;
101
102
  body: GetBody<'generate'> & {
102
103
  resourceid?: string;
103
104
  };
104
105
  }): Promise<GenerateTextResult<any, any>>;
105
106
 
106
- export declare function generateHandler_alias_1({ mastra, networkId, body, }: NetworkContext & {
107
+ export declare function generateHandler_alias_1({ mastra, container, networkId, body, }: NetworkContext & {
108
+ container: Container;
107
109
  body: {
108
110
  messages?: Parameters<AgentNetwork['generate']>[0];
109
111
  } & Parameters<AgentNetwork['generate']>[1];
@@ -159,7 +161,7 @@ export declare function getLiveEvalsByAgentIdHandler({ mastra, agentId }: Contex
159
161
 
160
162
  export declare function getLogsByRunIdHandler({ mastra, runId, transportId, }: Pick<LogsContext, 'mastra' | 'runId' | 'transportId'>): Promise<BaseLogMessage[] | undefined>;
161
163
 
162
- export declare function getLogsHandler({ mastra, transportId }: Pick<LogsContext, 'mastra' | 'transportId'>): Promise<BaseLogMessage[]>;
164
+ export declare function getLogsHandler({ mastra, transportId, }: Pick<LogsContext, 'mastra' | 'transportId'>): Promise<BaseLogMessage[]>;
163
165
 
164
166
  export declare function getLogTransports({ mastra }: Pick<LogsContext, 'mastra'>): Promise<{
165
167
  transports: string[];
@@ -362,18 +364,20 @@ export declare function queryVectors({ mastra, vectorName, query, }: Pick<Vector
362
364
 
363
365
  declare type RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;
364
366
 
365
- export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, }: WorkflowContext & {
367
+ export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, container, }: WorkflowContext & {
366
368
  body: {
367
369
  stepId: string;
368
370
  context: any;
369
371
  };
372
+ container: Container;
370
373
  }): Promise<Omit<WorkflowRunResult<any, Step<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, Step<string, any, any, any>[], Record<string, any>>>>[], any>, "runId"> | undefined>;
371
374
 
372
- export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, }: WorkflowContext & {
375
+ export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body, container, }: WorkflowContext & {
373
376
  body: {
374
377
  stepId: string;
375
378
  context: any;
376
379
  };
380
+ container: Container;
377
381
  }): Promise<{
378
382
  message: string;
379
383
  }>;
@@ -386,12 +390,14 @@ export declare function saveMessagesHandler({ mastra, agentId, body, }: Pick<Mem
386
390
 
387
391
  declare type ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
388
392
 
389
- export declare function startAsyncWorkflowHandler({ mastra, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
393
+ export declare function startAsyncWorkflowHandler({ mastra, container, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
390
394
  triggerData?: unknown;
395
+ container: Container;
391
396
  }): Promise<WorkflowRunResult<any, Step<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, Step<string, any, any, any>[], Record<string, any>>>>[], any>>;
392
397
 
393
- export declare function startWorkflowRunHandler({ mastra, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
398
+ export declare function startWorkflowRunHandler({ mastra, container, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
394
399
  triggerData?: unknown;
400
+ container: Container;
395
401
  }): Promise<{
396
402
  message: string;
397
403
  }>;
@@ -415,14 +421,16 @@ export declare function storeTelemetryHandler({ mastra, body }: Context & {
415
421
  traceCount: number;
416
422
  }>;
417
423
 
418
- export declare function streamGenerateHandler({ mastra, agentId, body, }: Context & {
424
+ export declare function streamGenerateHandler({ mastra, container, agentId, body, }: Context & {
425
+ container: Container;
419
426
  agentId: string;
420
427
  body: GetBody<'stream'> & {
421
428
  resourceid?: string;
422
429
  };
423
430
  }): Promise<Response | undefined>;
424
431
 
425
- export declare function streamGenerateHandler_alias_1({ mastra, networkId, body, }: NetworkContext & {
432
+ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body, container, }: NetworkContext & {
433
+ container: Container;
426
434
  body: {
427
435
  messages?: Parameters<AgentNetwork['stream']>[0];
428
436
  } & Parameters<AgentNetwork['stream']>[1];
@@ -540,8 +548,7 @@ declare interface VoiceContext extends Context {
540
548
 
541
549
  export declare function watchWorkflowHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'>): Promise<ReadableStream_2<string>>;
542
550
 
543
- declare interface WorkflowContext {
544
- mastra: Mastra_2;
551
+ declare interface WorkflowContext extends Context {
545
552
  workflowId?: string;
546
553
  runId?: string;
547
554
  }
@@ -9,7 +9,10 @@ __export(logs_exports, {
9
9
  getLogsByRunIdHandler: () => getLogsByRunIdHandler,
10
10
  getLogsHandler: () => getLogsHandler
11
11
  });
12
- async function getLogsHandler({ mastra, transportId }) {
12
+ async function getLogsHandler({
13
+ mastra,
14
+ transportId
15
+ }) {
13
16
  try {
14
17
  validateBody({ transportId });
15
18
  const logs = await mastra.getLogs(transportId);
@@ -97,6 +97,7 @@ async function getLiveEvalsByAgentIdHandler({ mastra, agentId }) {
97
97
  }
98
98
  async function generateHandler({
99
99
  mastra,
100
+ container,
100
101
  agentId,
101
102
  body
102
103
  }) {
@@ -111,7 +112,8 @@ async function generateHandler({
111
112
  const result = await agent.generate(messages, {
112
113
  ...rest,
113
114
  // @ts-expect-error TODO fix types
114
- resourceId: finalResourceId
115
+ resourceId: finalResourceId,
116
+ container
115
117
  });
116
118
  return result;
117
119
  } catch (error) {
@@ -120,6 +122,7 @@ async function generateHandler({
120
122
  }
121
123
  async function streamGenerateHandler({
122
124
  mastra,
125
+ container,
123
126
  agentId,
124
127
  body
125
128
  }) {
@@ -134,7 +137,8 @@ async function streamGenerateHandler({
134
137
  const streamResult = await agent.stream(messages, {
135
138
  ...rest,
136
139
  // @ts-expect-error TODO fix types
137
- resourceId: finalResourceId
140
+ resourceId: finalResourceId,
141
+ container
138
142
  });
139
143
  const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
140
144
  sendUsage: true,
@@ -80,6 +80,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
80
80
  }
81
81
  async function startAsyncWorkflowHandler({
82
82
  mastra,
83
+ container,
83
84
  workflowId,
84
85
  runId,
85
86
  triggerData
@@ -95,7 +96,8 @@ async function startAsyncWorkflowHandler({
95
96
  if (!runId) {
96
97
  const { start } = workflow.createRun();
97
98
  const result2 = await start({
98
- triggerData
99
+ triggerData,
100
+ container
99
101
  });
100
102
  return result2;
101
103
  }
@@ -104,7 +106,8 @@ async function startAsyncWorkflowHandler({
104
106
  throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
105
107
  }
106
108
  const result = await run.start({
107
- triggerData
109
+ triggerData,
110
+ container
108
111
  });
109
112
  return result;
110
113
  } catch (error) {
@@ -157,6 +160,7 @@ async function createRunHandler({
157
160
  }
158
161
  async function startWorkflowRunHandler({
159
162
  mastra,
163
+ container,
160
164
  workflowId,
161
165
  runId,
162
166
  triggerData
@@ -174,7 +178,8 @@ async function startWorkflowRunHandler({
174
178
  throw new chunkFV45V6WC_cjs.HTTPException(404, { message: "Workflow run not found" });
175
179
  }
176
180
  await run.start({
177
- triggerData
181
+ triggerData,
182
+ container
178
183
  });
179
184
  return { message: "Workflow run started" };
180
185
  } catch (e) {
@@ -229,7 +234,8 @@ async function resumeAsyncWorkflowHandler({
229
234
  mastra,
230
235
  workflowId,
231
236
  runId,
232
- body
237
+ body,
238
+ container
233
239
  }) {
234
240
  try {
235
241
  if (!workflowId) {
@@ -245,7 +251,8 @@ async function resumeAsyncWorkflowHandler({
245
251
  }
246
252
  const result = await run.resume({
247
253
  stepId: body.stepId,
248
- context: body.context
254
+ context: body.context,
255
+ container
249
256
  });
250
257
  return result;
251
258
  } catch (error) {
@@ -256,7 +263,8 @@ async function resumeWorkflowHandler({
256
263
  mastra,
257
264
  workflowId,
258
265
  runId,
259
- body
266
+ body,
267
+ container
260
268
  }) {
261
269
  try {
262
270
  if (!workflowId) {
@@ -272,7 +280,8 @@ async function resumeWorkflowHandler({
272
280
  }
273
281
  await run.resume({
274
282
  stepId: body.stepId,
275
- context: body.context
283
+ context: body.context,
284
+ container
276
285
  });
277
286
  return { message: "Workflow run resumed" };
278
287
  } catch (error) {
@@ -71,6 +71,7 @@ async function getNetworkByIdHandler({ mastra, networkId }) {
71
71
  }
72
72
  async function generateHandler({
73
73
  mastra,
74
+ container,
74
75
  networkId,
75
76
  body
76
77
  }) {
@@ -81,7 +82,7 @@ async function generateHandler({
81
82
  }
82
83
  chunkQN4KF3BH_cjs.validateBody({ messages: body.messages });
83
84
  const { messages, ...rest } = body;
84
- const result = await network.generate(messages, rest);
85
+ const result = await network.generate(messages, { ...rest, container });
85
86
  return result;
86
87
  } catch (error) {
87
88
  return chunkZLBRQFDD_cjs.handleError(error, "Error generating from network");
@@ -90,7 +91,8 @@ async function generateHandler({
90
91
  async function streamGenerateHandler({
91
92
  mastra,
92
93
  networkId,
93
- body
94
+ body,
95
+ container
94
96
  }) {
95
97
  try {
96
98
  const network = mastra.getNetwork(networkId);
@@ -101,7 +103,8 @@ async function streamGenerateHandler({
101
103
  const { messages, output, ...rest } = body;
102
104
  const streamResult = await network.stream(messages, {
103
105
  output,
104
- ...rest
106
+ ...rest,
107
+ container
105
108
  });
106
109
  const streamResponse = output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
107
110
  sendUsage: true,
@@ -78,6 +78,7 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
78
78
  }
79
79
  async function startAsyncWorkflowHandler({
80
80
  mastra,
81
+ container,
81
82
  workflowId,
82
83
  runId,
83
84
  triggerData
@@ -93,7 +94,8 @@ async function startAsyncWorkflowHandler({
93
94
  if (!runId) {
94
95
  const { start } = workflow.createRun();
95
96
  const result2 = await start({
96
- triggerData
97
+ triggerData,
98
+ container
97
99
  });
98
100
  return result2;
99
101
  }
@@ -102,7 +104,8 @@ async function startAsyncWorkflowHandler({
102
104
  throw new HTTPException(404, { message: "Workflow run not found" });
103
105
  }
104
106
  const result = await run.start({
105
- triggerData
107
+ triggerData,
108
+ container
106
109
  });
107
110
  return result;
108
111
  } catch (error) {
@@ -155,6 +158,7 @@ async function createRunHandler({
155
158
  }
156
159
  async function startWorkflowRunHandler({
157
160
  mastra,
161
+ container,
158
162
  workflowId,
159
163
  runId,
160
164
  triggerData
@@ -172,7 +176,8 @@ async function startWorkflowRunHandler({
172
176
  throw new HTTPException(404, { message: "Workflow run not found" });
173
177
  }
174
178
  await run.start({
175
- triggerData
179
+ triggerData,
180
+ container
176
181
  });
177
182
  return { message: "Workflow run started" };
178
183
  } catch (e) {
@@ -227,7 +232,8 @@ async function resumeAsyncWorkflowHandler({
227
232
  mastra,
228
233
  workflowId,
229
234
  runId,
230
- body
235
+ body,
236
+ container
231
237
  }) {
232
238
  try {
233
239
  if (!workflowId) {
@@ -243,7 +249,8 @@ async function resumeAsyncWorkflowHandler({
243
249
  }
244
250
  const result = await run.resume({
245
251
  stepId: body.stepId,
246
- context: body.context
252
+ context: body.context,
253
+ container
247
254
  });
248
255
  return result;
249
256
  } catch (error) {
@@ -254,7 +261,8 @@ async function resumeWorkflowHandler({
254
261
  mastra,
255
262
  workflowId,
256
263
  runId,
257
- body
264
+ body,
265
+ container
258
266
  }) {
259
267
  try {
260
268
  if (!workflowId) {
@@ -270,7 +278,8 @@ async function resumeWorkflowHandler({
270
278
  }
271
279
  await run.resume({
272
280
  stepId: body.stepId,
273
- context: body.context
281
+ context: body.context,
282
+ container
274
283
  });
275
284
  return { message: "Workflow run resumed" };
276
285
  } catch (error) {
@@ -11,7 +11,10 @@ chunkFV45V6WC_cjs.__export(logs_exports, {
11
11
  getLogsByRunIdHandler: () => getLogsByRunIdHandler,
12
12
  getLogsHandler: () => getLogsHandler
13
13
  });
14
- async function getLogsHandler({ mastra, transportId }) {
14
+ async function getLogsHandler({
15
+ mastra,
16
+ transportId
17
+ }) {
15
18
  try {
16
19
  chunkQN4KF3BH_cjs.validateBody({ transportId });
17
20
  const logs = await mastra.getLogs(transportId);
@@ -69,6 +69,7 @@ async function getNetworkByIdHandler({ mastra, networkId }) {
69
69
  }
70
70
  async function generateHandler({
71
71
  mastra,
72
+ container,
72
73
  networkId,
73
74
  body
74
75
  }) {
@@ -79,7 +80,7 @@ async function generateHandler({
79
80
  }
80
81
  validateBody({ messages: body.messages });
81
82
  const { messages, ...rest } = body;
82
- const result = await network.generate(messages, rest);
83
+ const result = await network.generate(messages, { ...rest, container });
83
84
  return result;
84
85
  } catch (error) {
85
86
  return handleError(error, "Error generating from network");
@@ -88,7 +89,8 @@ async function generateHandler({
88
89
  async function streamGenerateHandler({
89
90
  mastra,
90
91
  networkId,
91
- body
92
+ body,
93
+ container
92
94
  }) {
93
95
  try {
94
96
  const network = mastra.getNetwork(networkId);
@@ -99,7 +101,8 @@ async function streamGenerateHandler({
99
101
  const { messages, output, ...rest } = body;
100
102
  const streamResult = await network.stream(messages, {
101
103
  output,
102
- ...rest
104
+ ...rest,
105
+ container
103
106
  });
104
107
  const streamResponse = output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
105
108
  sendUsage: true,
@@ -99,6 +99,7 @@ async function getLiveEvalsByAgentIdHandler({ mastra, agentId }) {
99
99
  }
100
100
  async function generateHandler({
101
101
  mastra,
102
+ container,
102
103
  agentId,
103
104
  body
104
105
  }) {
@@ -113,7 +114,8 @@ async function generateHandler({
113
114
  const result = await agent.generate(messages, {
114
115
  ...rest,
115
116
  // @ts-expect-error TODO fix types
116
- resourceId: finalResourceId
117
+ resourceId: finalResourceId,
118
+ container
117
119
  });
118
120
  return result;
119
121
  } catch (error) {
@@ -122,6 +124,7 @@ async function generateHandler({
122
124
  }
123
125
  async function streamGenerateHandler({
124
126
  mastra,
127
+ container,
125
128
  agentId,
126
129
  body
127
130
  }) {
@@ -136,7 +139,8 @@ async function streamGenerateHandler({
136
139
  const streamResult = await agent.stream(messages, {
137
140
  ...rest,
138
141
  // @ts-expect-error TODO fix types
139
- resourceId: finalResourceId
142
+ resourceId: finalResourceId,
143
+ container
140
144
  });
141
145
  const streamResponse = rest.output ? streamResult.toTextStreamResponse() : streamResult.toDataStreamResponse({
142
146
  sendUsage: true,
@@ -1,30 +1,30 @@
1
1
  'use strict';
2
2
 
3
- var chunkGV52BII2_cjs = require('../../chunk-GV52BII2.cjs');
3
+ var chunkZ46X3YCB_cjs = require('../../chunk-Z46X3YCB.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "generateHandler", {
8
8
  enumerable: true,
9
- get: function () { return chunkGV52BII2_cjs.generateHandler; }
9
+ get: function () { return chunkZ46X3YCB_cjs.generateHandler; }
10
10
  });
11
11
  Object.defineProperty(exports, "getAgentByIdHandler", {
12
12
  enumerable: true,
13
- get: function () { return chunkGV52BII2_cjs.getAgentByIdHandler; }
13
+ get: function () { return chunkZ46X3YCB_cjs.getAgentByIdHandler; }
14
14
  });
15
15
  Object.defineProperty(exports, "getAgentsHandler", {
16
16
  enumerable: true,
17
- get: function () { return chunkGV52BII2_cjs.getAgentsHandler; }
17
+ get: function () { return chunkZ46X3YCB_cjs.getAgentsHandler; }
18
18
  });
19
19
  Object.defineProperty(exports, "getEvalsByAgentIdHandler", {
20
20
  enumerable: true,
21
- get: function () { return chunkGV52BII2_cjs.getEvalsByAgentIdHandler; }
21
+ get: function () { return chunkZ46X3YCB_cjs.getEvalsByAgentIdHandler; }
22
22
  });
23
23
  Object.defineProperty(exports, "getLiveEvalsByAgentIdHandler", {
24
24
  enumerable: true,
25
- get: function () { return chunkGV52BII2_cjs.getLiveEvalsByAgentIdHandler; }
25
+ get: function () { return chunkZ46X3YCB_cjs.getLiveEvalsByAgentIdHandler; }
26
26
  });
27
27
  Object.defineProperty(exports, "streamGenerateHandler", {
28
28
  enumerable: true,
29
- get: function () { return chunkGV52BII2_cjs.streamGenerateHandler; }
29
+ get: function () { return chunkZ46X3YCB_cjs.streamGenerateHandler; }
30
30
  });
@@ -1 +1 @@
1
- export { generateHandler, getAgentByIdHandler, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, streamGenerateHandler } from '../../chunk-BMA2ORRT.js';
1
+ export { generateHandler, getAgentByIdHandler, getAgentsHandler, getEvalsByAgentIdHandler, getLiveEvalsByAgentIdHandler, streamGenerateHandler } from '../../chunk-67WTHYAV.js';
@@ -1,18 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var chunkVB7KH62D_cjs = require('../../chunk-VB7KH62D.cjs');
3
+ var chunkSKBVVI24_cjs = require('../../chunk-SKBVVI24.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "getLogTransports", {
8
8
  enumerable: true,
9
- get: function () { return chunkVB7KH62D_cjs.getLogTransports; }
9
+ get: function () { return chunkSKBVVI24_cjs.getLogTransports; }
10
10
  });
11
11
  Object.defineProperty(exports, "getLogsByRunIdHandler", {
12
12
  enumerable: true,
13
- get: function () { return chunkVB7KH62D_cjs.getLogsByRunIdHandler; }
13
+ get: function () { return chunkSKBVVI24_cjs.getLogsByRunIdHandler; }
14
14
  });
15
15
  Object.defineProperty(exports, "getLogsHandler", {
16
16
  enumerable: true,
17
- get: function () { return chunkVB7KH62D_cjs.getLogsHandler; }
17
+ get: function () { return chunkSKBVVI24_cjs.getLogsHandler; }
18
18
  });
@@ -1 +1 @@
1
- export { getLogTransports, getLogsByRunIdHandler, getLogsHandler } from '../../chunk-2JQC6JWP.js';
1
+ export { getLogTransports, getLogsByRunIdHandler, getLogsHandler } from '../../chunk-3EJZQ6TQ.js';
@@ -1,22 +1,22 @@
1
1
  'use strict';
2
2
 
3
- var chunk5JOF627H_cjs = require('../../chunk-5JOF627H.cjs');
3
+ var chunkJLDXUWK7_cjs = require('../../chunk-JLDXUWK7.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "generateHandler", {
8
8
  enumerable: true,
9
- get: function () { return chunk5JOF627H_cjs.generateHandler; }
9
+ get: function () { return chunkJLDXUWK7_cjs.generateHandler; }
10
10
  });
11
11
  Object.defineProperty(exports, "getNetworkByIdHandler", {
12
12
  enumerable: true,
13
- get: function () { return chunk5JOF627H_cjs.getNetworkByIdHandler; }
13
+ get: function () { return chunkJLDXUWK7_cjs.getNetworkByIdHandler; }
14
14
  });
15
15
  Object.defineProperty(exports, "getNetworksHandler", {
16
16
  enumerable: true,
17
- get: function () { return chunk5JOF627H_cjs.getNetworksHandler; }
17
+ get: function () { return chunkJLDXUWK7_cjs.getNetworksHandler; }
18
18
  });
19
19
  Object.defineProperty(exports, "streamGenerateHandler", {
20
20
  enumerable: true,
21
- get: function () { return chunk5JOF627H_cjs.streamGenerateHandler; }
21
+ get: function () { return chunkJLDXUWK7_cjs.streamGenerateHandler; }
22
22
  });
@@ -1 +1 @@
1
- export { generateHandler, getNetworkByIdHandler, getNetworksHandler, streamGenerateHandler } from '../../chunk-2YONKUWB.js';
1
+ export { generateHandler, getNetworkByIdHandler, getNetworksHandler, streamGenerateHandler } from '../../chunk-YANVFOYA.js';
@@ -1,46 +1,46 @@
1
1
  'use strict';
2
2
 
3
- var chunkX37I6GZT_cjs = require('../../chunk-X37I6GZT.cjs');
3
+ var chunkB64YROKU_cjs = require('../../chunk-B64YROKU.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "createRunHandler", {
8
8
  enumerable: true,
9
- get: function () { return chunkX37I6GZT_cjs.createRunHandler; }
9
+ get: function () { return chunkB64YROKU_cjs.createRunHandler; }
10
10
  });
11
11
  Object.defineProperty(exports, "getWorkflowByIdHandler", {
12
12
  enumerable: true,
13
- get: function () { return chunkX37I6GZT_cjs.getWorkflowByIdHandler; }
13
+ get: function () { return chunkB64YROKU_cjs.getWorkflowByIdHandler; }
14
14
  });
15
15
  Object.defineProperty(exports, "getWorkflowRunHandler", {
16
16
  enumerable: true,
17
- get: function () { return chunkX37I6GZT_cjs.getWorkflowRunHandler; }
17
+ get: function () { return chunkB64YROKU_cjs.getWorkflowRunHandler; }
18
18
  });
19
19
  Object.defineProperty(exports, "getWorkflowRunsHandler", {
20
20
  enumerable: true,
21
- get: function () { return chunkX37I6GZT_cjs.getWorkflowRunsHandler; }
21
+ get: function () { return chunkB64YROKU_cjs.getWorkflowRunsHandler; }
22
22
  });
23
23
  Object.defineProperty(exports, "getWorkflowsHandler", {
24
24
  enumerable: true,
25
- get: function () { return chunkX37I6GZT_cjs.getWorkflowsHandler; }
25
+ get: function () { return chunkB64YROKU_cjs.getWorkflowsHandler; }
26
26
  });
27
27
  Object.defineProperty(exports, "resumeAsyncWorkflowHandler", {
28
28
  enumerable: true,
29
- get: function () { return chunkX37I6GZT_cjs.resumeAsyncWorkflowHandler; }
29
+ get: function () { return chunkB64YROKU_cjs.resumeAsyncWorkflowHandler; }
30
30
  });
31
31
  Object.defineProperty(exports, "resumeWorkflowHandler", {
32
32
  enumerable: true,
33
- get: function () { return chunkX37I6GZT_cjs.resumeWorkflowHandler; }
33
+ get: function () { return chunkB64YROKU_cjs.resumeWorkflowHandler; }
34
34
  });
35
35
  Object.defineProperty(exports, "startAsyncWorkflowHandler", {
36
36
  enumerable: true,
37
- get: function () { return chunkX37I6GZT_cjs.startAsyncWorkflowHandler; }
37
+ get: function () { return chunkB64YROKU_cjs.startAsyncWorkflowHandler; }
38
38
  });
39
39
  Object.defineProperty(exports, "startWorkflowRunHandler", {
40
40
  enumerable: true,
41
- get: function () { return chunkX37I6GZT_cjs.startWorkflowRunHandler; }
41
+ get: function () { return chunkB64YROKU_cjs.startWorkflowRunHandler; }
42
42
  });
43
43
  Object.defineProperty(exports, "watchWorkflowHandler", {
44
44
  enumerable: true,
45
- get: function () { return chunkX37I6GZT_cjs.watchWorkflowHandler; }
45
+ get: function () { return chunkB64YROKU_cjs.watchWorkflowHandler; }
46
46
  });
@@ -1 +1 @@
1
- export { createRunHandler, getWorkflowByIdHandler, getWorkflowRunHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler } from '../../chunk-ILW7XYNJ.js';
1
+ export { createRunHandler, getWorkflowByIdHandler, getWorkflowRunHandler, getWorkflowRunsHandler, getWorkflowsHandler, resumeAsyncWorkflowHandler, resumeWorkflowHandler, startAsyncWorkflowHandler, startWorkflowRunHandler, watchWorkflowHandler } from '../../chunk-OPP7H5TW.js';
@@ -3,11 +3,11 @@
3
3
  var chunk4C3EPMMF_cjs = require('../chunk-4C3EPMMF.cjs');
4
4
  var chunkM56ECCHK_cjs = require('../chunk-M56ECCHK.cjs');
5
5
  var chunkA7DF4ETD_cjs = require('../chunk-A7DF4ETD.cjs');
6
- var chunkX37I6GZT_cjs = require('../chunk-X37I6GZT.cjs');
7
- var chunkGV52BII2_cjs = require('../chunk-GV52BII2.cjs');
8
- var chunkVB7KH62D_cjs = require('../chunk-VB7KH62D.cjs');
6
+ var chunkB64YROKU_cjs = require('../chunk-B64YROKU.cjs');
7
+ var chunkZ46X3YCB_cjs = require('../chunk-Z46X3YCB.cjs');
8
+ var chunkSKBVVI24_cjs = require('../chunk-SKBVVI24.cjs');
9
9
  var chunk2FJURXCL_cjs = require('../chunk-2FJURXCL.cjs');
10
- var chunk5JOF627H_cjs = require('../chunk-5JOF627H.cjs');
10
+ var chunkJLDXUWK7_cjs = require('../chunk-JLDXUWK7.cjs');
11
11
  var chunkCWSDZEZG_cjs = require('../chunk-CWSDZEZG.cjs');
12
12
 
13
13
 
@@ -26,15 +26,15 @@ Object.defineProperty(exports, "voice", {
26
26
  });
27
27
  Object.defineProperty(exports, "workflows", {
28
28
  enumerable: true,
29
- get: function () { return chunkX37I6GZT_cjs.workflows_exports; }
29
+ get: function () { return chunkB64YROKU_cjs.workflows_exports; }
30
30
  });
31
31
  Object.defineProperty(exports, "agents", {
32
32
  enumerable: true,
33
- get: function () { return chunkGV52BII2_cjs.agents_exports; }
33
+ get: function () { return chunkZ46X3YCB_cjs.agents_exports; }
34
34
  });
35
35
  Object.defineProperty(exports, "logs", {
36
36
  enumerable: true,
37
- get: function () { return chunkVB7KH62D_cjs.logs_exports; }
37
+ get: function () { return chunkSKBVVI24_cjs.logs_exports; }
38
38
  });
39
39
  Object.defineProperty(exports, "memory", {
40
40
  enumerable: true,
@@ -42,7 +42,7 @@ Object.defineProperty(exports, "memory", {
42
42
  });
43
43
  Object.defineProperty(exports, "network", {
44
44
  enumerable: true,
45
- get: function () { return chunk5JOF627H_cjs.network_exports; }
45
+ get: function () { return chunkJLDXUWK7_cjs.network_exports; }
46
46
  });
47
47
  Object.defineProperty(exports, "telemetry", {
48
48
  enumerable: true,
@@ -1,9 +1,9 @@
1
1
  export { tools_exports as tools } from '../chunk-YNSGUC2O.js';
2
2
  export { vector_exports as vector } from '../chunk-4JINXASC.js';
3
3
  export { voice_exports as voice } from '../chunk-3RVHWGWO.js';
4
- export { workflows_exports as workflows } from '../chunk-ILW7XYNJ.js';
5
- export { agents_exports as agents } from '../chunk-BMA2ORRT.js';
6
- export { logs_exports as logs } from '../chunk-2JQC6JWP.js';
4
+ export { workflows_exports as workflows } from '../chunk-OPP7H5TW.js';
5
+ export { agents_exports as agents } from '../chunk-67WTHYAV.js';
6
+ export { logs_exports as logs } from '../chunk-3EJZQ6TQ.js';
7
7
  export { memory_exports as memory } from '../chunk-RBQASTUP.js';
8
- export { network_exports as network } from '../chunk-2YONKUWB.js';
8
+ export { network_exports as network } from '../chunk-YANVFOYA.js';
9
9
  export { telemetry_exports as telemetry } from '../chunk-DVPP5S6I.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/server",
3
- "version": "1.0.3-alpha.0",
3
+ "version": "1.0.3-alpha.2",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -43,10 +43,10 @@
43
43
  },
44
44
  "keywords": [],
45
45
  "author": "",
46
- "license": "ISC",
46
+ "license": "Elastic-2.0",
47
47
  "dependencies": {},
48
48
  "peerDependencies": {
49
- "@mastra/core": "^0.8.3-alpha.0"
49
+ "@mastra/core": "^0.8.3-alpha.2"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@ai-sdk/openai": "^1.3.2",
@@ -58,8 +58,8 @@
58
58
  "typescript": "^5.8.2",
59
59
  "vitest": "^2.1.9",
60
60
  "zod-to-json-schema": "^3.24.3",
61
- "@mastra/core": "0.8.3-alpha.0",
62
- "@internal/lint": "0.0.1"
61
+ "@mastra/core": "0.8.3-alpha.2",
62
+ "@internal/lint": "0.0.2-alpha.0"
63
63
  },
64
64
  "scripts": {
65
65
  "build": "tsup src/index.ts src/server/handlers.ts src/server/handlers/*.ts !src/server/handlers/*.test.ts --format esm,cjs --clean --experimental-dts --treeshake=smallest --splitting",