@mastra/server 0.10.4-alpha.0 → 0.10.4-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/dist/_tsup-dts-rollup.d.cts +9 -14
- package/dist/_tsup-dts-rollup.d.ts +9 -14
- package/dist/{chunk-Y3TOVSL7.js → chunk-6MQO3273.js} +18 -3
- package/dist/{chunk-ALIRNI4O.js → chunk-7IBZ4L35.js} +9 -30
- package/dist/{chunk-6GMFUWZI.js → chunk-HYP7B2TL.js} +5 -16
- package/dist/{chunk-2NY7AYR6.cjs → chunk-JKF6PRPU.cjs} +21 -42
- package/dist/{chunk-D5ER2QU5.cjs → chunk-P77X4SV2.cjs} +22 -7
- package/dist/{chunk-ZEQYIG7R.js → chunk-TEZOEGR4.js} +1 -1
- package/dist/{chunk-GLFMWRYT.cjs → chunk-TJO277H7.cjs} +9 -20
- package/dist/{chunk-LVT55U2N.cjs → chunk-UZ7FJ66C.cjs} +7 -7
- package/dist/{chunk-4E27IXKK.js → chunk-WKWHYFX4.js} +35 -35
- package/dist/{chunk-7UOYXBSH.cjs → chunk-XUGQSVZ4.cjs} +35 -35
- package/dist/server/handlers/agents.cjs +7 -7
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/legacyWorkflows.cjs +11 -11
- package/dist/server/handlers/legacyWorkflows.js +1 -1
- package/dist/server/handlers/tools.cjs +5 -5
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/workflows.cjs +12 -12
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +8 -8
- package/dist/server/handlers.js +4 -4
- package/package.json +3 -3
|
@@ -23,7 +23,7 @@ import type { Message } from '@mastra/core/a2a';
|
|
|
23
23
|
import type { QueryResult } from '@mastra/core/vector';
|
|
24
24
|
import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
|
|
25
25
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
26
|
-
import { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
|
|
26
|
+
import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
|
|
27
27
|
import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
|
|
28
28
|
import { Step } from '@mastra/core/workflows';
|
|
29
29
|
import { StepExecutionContext } from '@mastra/core/workflows/legacy';
|
|
@@ -141,17 +141,15 @@ export declare function describeIndex({ mastra, vectorName, indexName, }: Pick<V
|
|
|
141
141
|
metric: string | undefined;
|
|
142
142
|
}>;
|
|
143
143
|
|
|
144
|
-
export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, runtimeContext,
|
|
144
|
+
export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, runtimeContext, }: Pick<ToolsContext, 'mastra' | 'toolId'> & {
|
|
145
145
|
agentId?: string;
|
|
146
146
|
data: any;
|
|
147
147
|
runtimeContext: RuntimeContext_2;
|
|
148
|
-
runtimeContextFromRequest: Record<string, unknown>;
|
|
149
148
|
}): Promise<any>;
|
|
150
149
|
|
|
151
|
-
export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mastra, runId, toolId, data, runtimeContext,
|
|
150
|
+
export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mastra, runId, toolId, data, runtimeContext, }: Pick<ToolsContext, "mastra" | "toolId" | "runId"> & {
|
|
152
151
|
data?: unknown;
|
|
153
152
|
runtimeContext: RuntimeContext_2;
|
|
154
|
-
runtimeContextFromRequest: Record<string, unknown>;
|
|
155
153
|
}) => Promise<any>;
|
|
156
154
|
|
|
157
155
|
export declare function generateHandler({ mastra, runtimeContext, agentId, body, }: Context & {
|
|
@@ -180,7 +178,8 @@ export declare function generateSpeechHandler({ mastra, agentId, body, }: VoiceC
|
|
|
180
178
|
};
|
|
181
179
|
}): Promise<NodeJS.ReadableStream>;
|
|
182
180
|
|
|
183
|
-
export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, }: Context & {
|
|
181
|
+
export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, isPlayground, }: Context & {
|
|
182
|
+
isPlayground?: boolean;
|
|
184
183
|
runtimeContext: RuntimeContext;
|
|
185
184
|
agentId: string;
|
|
186
185
|
}): Promise<{
|
|
@@ -599,13 +598,12 @@ export declare function resumeAsyncLegacyWorkflowHandler({ mastra, workflowId, r
|
|
|
599
598
|
runtimeContext: RuntimeContext;
|
|
600
599
|
}): Promise<Omit<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>, "runId"> | undefined>;
|
|
601
600
|
|
|
602
|
-
export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext,
|
|
601
|
+
export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
|
|
603
602
|
body: {
|
|
604
603
|
step: string | string[];
|
|
605
604
|
resumeData?: unknown;
|
|
606
605
|
};
|
|
607
606
|
runtimeContext?: RuntimeContext_2;
|
|
608
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
609
607
|
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
610
608
|
|
|
611
609
|
export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
|
|
@@ -650,10 +648,9 @@ export declare function startAsyncLegacyWorkflowHandler({ mastra, runtimeContext
|
|
|
650
648
|
runtimeContext: RuntimeContext;
|
|
651
649
|
}): Promise<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>>;
|
|
652
650
|
|
|
653
|
-
export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData,
|
|
651
|
+
export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
654
652
|
inputData?: unknown;
|
|
655
653
|
runtimeContext?: RuntimeContext_2;
|
|
656
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
657
654
|
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
658
655
|
|
|
659
656
|
export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
@@ -663,10 +660,9 @@ export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext,
|
|
|
663
660
|
message: string;
|
|
664
661
|
}>;
|
|
665
662
|
|
|
666
|
-
export declare function startWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData,
|
|
663
|
+
export declare function startWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
667
664
|
inputData?: unknown;
|
|
668
665
|
runtimeContext?: RuntimeContext_2;
|
|
669
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
670
666
|
}): Promise<{
|
|
671
667
|
message: string;
|
|
672
668
|
}>;
|
|
@@ -710,10 +706,9 @@ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body,
|
|
|
710
706
|
} & Parameters<AgentNetwork['stream']>[1];
|
|
711
707
|
}): Promise<Response>;
|
|
712
708
|
|
|
713
|
-
export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData,
|
|
709
|
+
export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
714
710
|
inputData?: unknown;
|
|
715
711
|
runtimeContext?: RuntimeContext_2;
|
|
716
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
717
712
|
}): {
|
|
718
713
|
stream: globalThis.ReadableStream<StreamEvent>;
|
|
719
714
|
getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
@@ -23,7 +23,7 @@ import type { Message } from '@mastra/core/a2a';
|
|
|
23
23
|
import type { QueryResult } from '@mastra/core/vector';
|
|
24
24
|
import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
|
|
25
25
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
26
|
-
import { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
|
|
26
|
+
import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
|
|
27
27
|
import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
|
|
28
28
|
import { Step } from '@mastra/core/workflows';
|
|
29
29
|
import { StepExecutionContext } from '@mastra/core/workflows/legacy';
|
|
@@ -141,17 +141,15 @@ export declare function describeIndex({ mastra, vectorName, indexName, }: Pick<V
|
|
|
141
141
|
metric: string | undefined;
|
|
142
142
|
}>;
|
|
143
143
|
|
|
144
|
-
export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, runtimeContext,
|
|
144
|
+
export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, runtimeContext, }: Pick<ToolsContext, 'mastra' | 'toolId'> & {
|
|
145
145
|
agentId?: string;
|
|
146
146
|
data: any;
|
|
147
147
|
runtimeContext: RuntimeContext_2;
|
|
148
|
-
runtimeContextFromRequest: Record<string, unknown>;
|
|
149
148
|
}): Promise<any>;
|
|
150
149
|
|
|
151
|
-
export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mastra, runId, toolId, data, runtimeContext,
|
|
150
|
+
export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mastra, runId, toolId, data, runtimeContext, }: Pick<ToolsContext, "mastra" | "toolId" | "runId"> & {
|
|
152
151
|
data?: unknown;
|
|
153
152
|
runtimeContext: RuntimeContext_2;
|
|
154
|
-
runtimeContextFromRequest: Record<string, unknown>;
|
|
155
153
|
}) => Promise<any>;
|
|
156
154
|
|
|
157
155
|
export declare function generateHandler({ mastra, runtimeContext, agentId, body, }: Context & {
|
|
@@ -180,7 +178,8 @@ export declare function generateSpeechHandler({ mastra, agentId, body, }: VoiceC
|
|
|
180
178
|
};
|
|
181
179
|
}): Promise<NodeJS.ReadableStream>;
|
|
182
180
|
|
|
183
|
-
export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, }: Context & {
|
|
181
|
+
export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, isPlayground, }: Context & {
|
|
182
|
+
isPlayground?: boolean;
|
|
184
183
|
runtimeContext: RuntimeContext;
|
|
185
184
|
agentId: string;
|
|
186
185
|
}): Promise<{
|
|
@@ -599,13 +598,12 @@ export declare function resumeAsyncLegacyWorkflowHandler({ mastra, workflowId, r
|
|
|
599
598
|
runtimeContext: RuntimeContext;
|
|
600
599
|
}): Promise<Omit<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>, "runId"> | undefined>;
|
|
601
600
|
|
|
602
|
-
export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext,
|
|
601
|
+
export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
|
|
603
602
|
body: {
|
|
604
603
|
step: string | string[];
|
|
605
604
|
resumeData?: unknown;
|
|
606
605
|
};
|
|
607
606
|
runtimeContext?: RuntimeContext_2;
|
|
608
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
609
607
|
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
610
608
|
|
|
611
609
|
export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
|
|
@@ -650,10 +648,9 @@ export declare function startAsyncLegacyWorkflowHandler({ mastra, runtimeContext
|
|
|
650
648
|
runtimeContext: RuntimeContext;
|
|
651
649
|
}): Promise<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>>;
|
|
652
650
|
|
|
653
|
-
export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData,
|
|
651
|
+
export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
654
652
|
inputData?: unknown;
|
|
655
653
|
runtimeContext?: RuntimeContext_2;
|
|
656
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
657
654
|
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
658
655
|
|
|
659
656
|
export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
@@ -663,10 +660,9 @@ export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext,
|
|
|
663
660
|
message: string;
|
|
664
661
|
}>;
|
|
665
662
|
|
|
666
|
-
export declare function startWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData,
|
|
663
|
+
export declare function startWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
667
664
|
inputData?: unknown;
|
|
668
665
|
runtimeContext?: RuntimeContext_2;
|
|
669
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
670
666
|
}): Promise<{
|
|
671
667
|
message: string;
|
|
672
668
|
}>;
|
|
@@ -710,10 +706,9 @@ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body,
|
|
|
710
706
|
} & Parameters<AgentNetwork['stream']>[1];
|
|
711
707
|
}): Promise<Response>;
|
|
712
708
|
|
|
713
|
-
export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData,
|
|
709
|
+
export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
714
710
|
inputData?: unknown;
|
|
715
711
|
runtimeContext?: RuntimeContext_2;
|
|
716
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
717
712
|
}): {
|
|
718
713
|
stream: globalThis.ReadableStream<StreamEvent>;
|
|
719
714
|
getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stringify, esm_default } from './chunk-
|
|
1
|
+
import { stringify, esm_default } from './chunk-WKWHYFX4.js';
|
|
2
2
|
import { validateBody } from './chunk-H5PTF3Y4.js';
|
|
3
3
|
import { handleError } from './chunk-M5ABIP7D.js';
|
|
4
4
|
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
@@ -74,7 +74,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
|
|
|
74
74
|
async function getAgentByIdHandler({
|
|
75
75
|
mastra,
|
|
76
76
|
runtimeContext,
|
|
77
|
-
agentId
|
|
77
|
+
agentId,
|
|
78
|
+
isPlayground = false
|
|
78
79
|
}) {
|
|
79
80
|
try {
|
|
80
81
|
const agent = mastra.getAgent(agentId);
|
|
@@ -108,7 +109,21 @@ async function getAgentByIdHandler({
|
|
|
108
109
|
logger.error("Error getting workflows for agent", { agentName: agent.name, error });
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
|
-
|
|
112
|
+
let proxyRuntimeContext = runtimeContext;
|
|
113
|
+
if (isPlayground) {
|
|
114
|
+
proxyRuntimeContext = new Proxy(runtimeContext, {
|
|
115
|
+
get(target, prop) {
|
|
116
|
+
if (prop === "get") {
|
|
117
|
+
return function(key) {
|
|
118
|
+
const value = target.get(key);
|
|
119
|
+
return value ?? `<${key}>`;
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return Reflect.get(target, prop);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
const instructions = await agent.getInstructions({ runtimeContext: proxyRuntimeContext });
|
|
112
127
|
const llm = await agent.getLLM({ runtimeContext });
|
|
113
128
|
return {
|
|
114
129
|
name: agent.name,
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { stringify, esm_default } from './chunk-
|
|
1
|
+
import { stringify, esm_default } from './chunk-WKWHYFX4.js';
|
|
2
2
|
import { handleError } from './chunk-M5ABIP7D.js';
|
|
3
3
|
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
4
4
|
import { __export } from './chunk-MLKGABMK.js';
|
|
5
5
|
import { ReadableStream } from 'stream/web';
|
|
6
|
-
import { RuntimeContext } from '@mastra/core/di';
|
|
7
6
|
|
|
8
7
|
// src/server/handlers/workflows.ts
|
|
9
8
|
var workflows_exports = {};
|
|
@@ -129,8 +128,7 @@ async function startAsyncWorkflowHandler({
|
|
|
129
128
|
runtimeContext,
|
|
130
129
|
workflowId,
|
|
131
130
|
runId,
|
|
132
|
-
inputData
|
|
133
|
-
runtimeContextFromRequest
|
|
131
|
+
inputData
|
|
134
132
|
}) {
|
|
135
133
|
try {
|
|
136
134
|
if (!workflowId) {
|
|
@@ -140,14 +138,10 @@ async function startAsyncWorkflowHandler({
|
|
|
140
138
|
if (!workflow) {
|
|
141
139
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
142
140
|
}
|
|
143
|
-
const finalRuntimeContext = new RuntimeContext([
|
|
144
|
-
...Array.from(runtimeContext?.entries() ?? []),
|
|
145
|
-
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
146
|
-
]);
|
|
147
141
|
const _run = workflow.createRun({ runId });
|
|
148
142
|
const result = await _run.start({
|
|
149
143
|
inputData,
|
|
150
|
-
runtimeContext
|
|
144
|
+
runtimeContext
|
|
151
145
|
});
|
|
152
146
|
return result;
|
|
153
147
|
} catch (error) {
|
|
@@ -159,8 +153,7 @@ async function startWorkflowRunHandler({
|
|
|
159
153
|
runtimeContext,
|
|
160
154
|
workflowId,
|
|
161
155
|
runId,
|
|
162
|
-
inputData
|
|
163
|
-
runtimeContextFromRequest
|
|
156
|
+
inputData
|
|
164
157
|
}) {
|
|
165
158
|
try {
|
|
166
159
|
if (!workflowId) {
|
|
@@ -174,14 +167,10 @@ async function startWorkflowRunHandler({
|
|
|
174
167
|
if (!run) {
|
|
175
168
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
176
169
|
}
|
|
177
|
-
const finalRuntimeContext = new RuntimeContext([
|
|
178
|
-
...Array.from(runtimeContext?.entries() ?? []),
|
|
179
|
-
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
180
|
-
]);
|
|
181
170
|
const _run = workflow.createRun({ runId });
|
|
182
171
|
void _run.start({
|
|
183
172
|
inputData,
|
|
184
|
-
runtimeContext
|
|
173
|
+
runtimeContext
|
|
185
174
|
});
|
|
186
175
|
return { message: "Workflow run started" };
|
|
187
176
|
} catch (e) {
|
|
@@ -239,8 +228,7 @@ function streamWorkflowHandler({
|
|
|
239
228
|
runtimeContext,
|
|
240
229
|
workflowId,
|
|
241
230
|
runId,
|
|
242
|
-
inputData
|
|
243
|
-
runtimeContextFromRequest
|
|
231
|
+
inputData
|
|
244
232
|
}) {
|
|
245
233
|
try {
|
|
246
234
|
if (!workflowId) {
|
|
@@ -253,14 +241,10 @@ function streamWorkflowHandler({
|
|
|
253
241
|
if (!workflow) {
|
|
254
242
|
throw new HTTPException(404, { message: "Workflow not found" });
|
|
255
243
|
}
|
|
256
|
-
const finalRuntimeContext = new RuntimeContext([
|
|
257
|
-
...Array.from(runtimeContext?.entries() ?? []),
|
|
258
|
-
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
259
|
-
]);
|
|
260
244
|
const run = workflow.createRun({ runId });
|
|
261
245
|
const result = run.stream({
|
|
262
246
|
inputData,
|
|
263
|
-
runtimeContext
|
|
247
|
+
runtimeContext
|
|
264
248
|
});
|
|
265
249
|
return result;
|
|
266
250
|
} catch (error) {
|
|
@@ -272,8 +256,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
272
256
|
workflowId,
|
|
273
257
|
runId,
|
|
274
258
|
body,
|
|
275
|
-
runtimeContext
|
|
276
|
-
runtimeContextFromRequest
|
|
259
|
+
runtimeContext
|
|
277
260
|
}) {
|
|
278
261
|
try {
|
|
279
262
|
if (!workflowId) {
|
|
@@ -290,15 +273,11 @@ async function resumeAsyncWorkflowHandler({
|
|
|
290
273
|
if (!run) {
|
|
291
274
|
throw new HTTPException(404, { message: "Workflow run not found" });
|
|
292
275
|
}
|
|
293
|
-
const finalRuntimeContext = new RuntimeContext([
|
|
294
|
-
...Array.from(runtimeContext?.entries() ?? []),
|
|
295
|
-
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
296
|
-
]);
|
|
297
276
|
const _run = workflow.createRun({ runId });
|
|
298
277
|
const result = await _run.resume({
|
|
299
278
|
step: body.step,
|
|
300
279
|
resumeData: body.resumeData,
|
|
301
|
-
runtimeContext
|
|
280
|
+
runtimeContext
|
|
302
281
|
});
|
|
303
282
|
return result;
|
|
304
283
|
} catch (error) {
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { stringify, esm_default } from './chunk-
|
|
1
|
+
import { stringify, esm_default } from './chunk-WKWHYFX4.js';
|
|
2
2
|
import { validateBody } from './chunk-H5PTF3Y4.js';
|
|
3
3
|
import { handleError } from './chunk-M5ABIP7D.js';
|
|
4
4
|
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
5
5
|
import { __export } from './chunk-MLKGABMK.js';
|
|
6
|
-
import { RuntimeContext } from '@mastra/core/di';
|
|
7
6
|
import { isVercelTool } from '@mastra/core/tools';
|
|
8
7
|
|
|
9
8
|
// src/server/handlers/tools.ts
|
|
@@ -58,8 +57,7 @@ function executeToolHandler(tools) {
|
|
|
58
57
|
runId,
|
|
59
58
|
toolId,
|
|
60
59
|
data,
|
|
61
|
-
runtimeContext
|
|
62
|
-
runtimeContextFromRequest
|
|
60
|
+
runtimeContext
|
|
63
61
|
}) => {
|
|
64
62
|
try {
|
|
65
63
|
if (!toolId) {
|
|
@@ -77,15 +75,11 @@ function executeToolHandler(tools) {
|
|
|
77
75
|
const result2 = await tool.execute(data);
|
|
78
76
|
return result2;
|
|
79
77
|
}
|
|
80
|
-
const finalRuntimeContext = new RuntimeContext([
|
|
81
|
-
...Array.from(runtimeContext.entries()),
|
|
82
|
-
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
83
|
-
]);
|
|
84
78
|
const result = await tool.execute({
|
|
85
79
|
context: data,
|
|
86
80
|
mastra,
|
|
87
81
|
runId,
|
|
88
|
-
runtimeContext
|
|
82
|
+
runtimeContext
|
|
89
83
|
});
|
|
90
84
|
return result;
|
|
91
85
|
} catch (error) {
|
|
@@ -98,8 +92,7 @@ async function executeAgentToolHandler({
|
|
|
98
92
|
agentId,
|
|
99
93
|
toolId,
|
|
100
94
|
data,
|
|
101
|
-
runtimeContext
|
|
102
|
-
runtimeContextFromRequest
|
|
95
|
+
runtimeContext
|
|
103
96
|
}) {
|
|
104
97
|
try {
|
|
105
98
|
const agent = agentId ? mastra.getAgent(agentId) : null;
|
|
@@ -114,13 +107,9 @@ async function executeAgentToolHandler({
|
|
|
114
107
|
if (!tool?.execute) {
|
|
115
108
|
throw new HTTPException(400, { message: "Tool is not executable" });
|
|
116
109
|
}
|
|
117
|
-
const finalRuntimeContext = new RuntimeContext([
|
|
118
|
-
...Array.from(runtimeContext.entries()),
|
|
119
|
-
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
120
|
-
]);
|
|
121
110
|
const result = await tool.execute({
|
|
122
111
|
context: data,
|
|
123
|
-
runtimeContext
|
|
112
|
+
runtimeContext,
|
|
124
113
|
mastra,
|
|
125
114
|
runId: agentId
|
|
126
115
|
});
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkXUGQSVZ4_cjs = require('./chunk-XUGQSVZ4.cjs');
|
|
4
4
|
var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
|
|
5
5
|
var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
|
|
6
6
|
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
7
7
|
var web = require('stream/web');
|
|
8
|
-
var di = require('@mastra/core/di');
|
|
9
8
|
|
|
10
9
|
// src/server/handlers/workflows.ts
|
|
11
10
|
var workflows_exports = {};
|
|
@@ -33,16 +32,16 @@ async function getWorkflowsHandler({ mastra }) {
|
|
|
33
32
|
acc2[key2] = {
|
|
34
33
|
id: step.id,
|
|
35
34
|
description: step.description,
|
|
36
|
-
inputSchema: step.inputSchema ?
|
|
37
|
-
outputSchema: step.outputSchema ?
|
|
38
|
-
resumeSchema: step.resumeSchema ?
|
|
39
|
-
suspendSchema: step.suspendSchema ?
|
|
35
|
+
inputSchema: step.inputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(step.inputSchema)) : void 0,
|
|
36
|
+
outputSchema: step.outputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(step.outputSchema)) : void 0,
|
|
37
|
+
resumeSchema: step.resumeSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(step.resumeSchema)) : void 0,
|
|
38
|
+
suspendSchema: step.suspendSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(step.suspendSchema)) : void 0
|
|
40
39
|
};
|
|
41
40
|
return acc2;
|
|
42
41
|
}, {}),
|
|
43
42
|
stepGraph: workflow.serializedStepGraph,
|
|
44
|
-
inputSchema: workflow.inputSchema ?
|
|
45
|
-
outputSchema: workflow.outputSchema ?
|
|
43
|
+
inputSchema: workflow.inputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(workflow.inputSchema)) : void 0,
|
|
44
|
+
outputSchema: workflow.outputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(workflow.outputSchema)) : void 0
|
|
46
45
|
};
|
|
47
46
|
return acc;
|
|
48
47
|
}, {});
|
|
@@ -65,18 +64,18 @@ async function getWorkflowByIdHandler({ mastra, workflowId }) {
|
|
|
65
64
|
acc[key] = {
|
|
66
65
|
id: step.id,
|
|
67
66
|
description: step.description,
|
|
68
|
-
inputSchema: step.inputSchema ?
|
|
69
|
-
outputSchema: step.outputSchema ?
|
|
70
|
-
resumeSchema: step.resumeSchema ?
|
|
71
|
-
suspendSchema: step.suspendSchema ?
|
|
67
|
+
inputSchema: step.inputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(step.inputSchema)) : void 0,
|
|
68
|
+
outputSchema: step.outputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(step.outputSchema)) : void 0,
|
|
69
|
+
resumeSchema: step.resumeSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(step.resumeSchema)) : void 0,
|
|
70
|
+
suspendSchema: step.suspendSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(step.suspendSchema)) : void 0
|
|
72
71
|
};
|
|
73
72
|
return acc;
|
|
74
73
|
}, {}),
|
|
75
74
|
name: workflow.name,
|
|
76
75
|
description: workflow.description,
|
|
77
76
|
stepGraph: workflow.serializedStepGraph,
|
|
78
|
-
inputSchema: workflow.inputSchema ?
|
|
79
|
-
outputSchema: workflow.outputSchema ?
|
|
77
|
+
inputSchema: workflow.inputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(workflow.inputSchema)) : void 0,
|
|
78
|
+
outputSchema: workflow.outputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(workflow.outputSchema)) : void 0
|
|
80
79
|
};
|
|
81
80
|
} catch (error) {
|
|
82
81
|
throw new chunkOCWPVYNI_cjs.HTTPException(500, { message: error?.message || "Error getting workflow" });
|
|
@@ -131,8 +130,7 @@ async function startAsyncWorkflowHandler({
|
|
|
131
130
|
runtimeContext,
|
|
132
131
|
workflowId,
|
|
133
132
|
runId,
|
|
134
|
-
inputData
|
|
135
|
-
runtimeContextFromRequest
|
|
133
|
+
inputData
|
|
136
134
|
}) {
|
|
137
135
|
try {
|
|
138
136
|
if (!workflowId) {
|
|
@@ -142,14 +140,10 @@ async function startAsyncWorkflowHandler({
|
|
|
142
140
|
if (!workflow) {
|
|
143
141
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
144
142
|
}
|
|
145
|
-
const finalRuntimeContext = new di.RuntimeContext([
|
|
146
|
-
...Array.from(runtimeContext?.entries() ?? []),
|
|
147
|
-
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
148
|
-
]);
|
|
149
143
|
const _run = workflow.createRun({ runId });
|
|
150
144
|
const result = await _run.start({
|
|
151
145
|
inputData,
|
|
152
|
-
runtimeContext
|
|
146
|
+
runtimeContext
|
|
153
147
|
});
|
|
154
148
|
return result;
|
|
155
149
|
} catch (error) {
|
|
@@ -161,8 +155,7 @@ async function startWorkflowRunHandler({
|
|
|
161
155
|
runtimeContext,
|
|
162
156
|
workflowId,
|
|
163
157
|
runId,
|
|
164
|
-
inputData
|
|
165
|
-
runtimeContextFromRequest
|
|
158
|
+
inputData
|
|
166
159
|
}) {
|
|
167
160
|
try {
|
|
168
161
|
if (!workflowId) {
|
|
@@ -176,14 +169,10 @@ async function startWorkflowRunHandler({
|
|
|
176
169
|
if (!run) {
|
|
177
170
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
178
171
|
}
|
|
179
|
-
const finalRuntimeContext = new di.RuntimeContext([
|
|
180
|
-
...Array.from(runtimeContext?.entries() ?? []),
|
|
181
|
-
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
182
|
-
]);
|
|
183
172
|
const _run = workflow.createRun({ runId });
|
|
184
173
|
void _run.start({
|
|
185
174
|
inputData,
|
|
186
|
-
runtimeContext
|
|
175
|
+
runtimeContext
|
|
187
176
|
});
|
|
188
177
|
return { message: "Workflow run started" };
|
|
189
178
|
} catch (e) {
|
|
@@ -241,8 +230,7 @@ function streamWorkflowHandler({
|
|
|
241
230
|
runtimeContext,
|
|
242
231
|
workflowId,
|
|
243
232
|
runId,
|
|
244
|
-
inputData
|
|
245
|
-
runtimeContextFromRequest
|
|
233
|
+
inputData
|
|
246
234
|
}) {
|
|
247
235
|
try {
|
|
248
236
|
if (!workflowId) {
|
|
@@ -255,14 +243,10 @@ function streamWorkflowHandler({
|
|
|
255
243
|
if (!workflow) {
|
|
256
244
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow not found" });
|
|
257
245
|
}
|
|
258
|
-
const finalRuntimeContext = new di.RuntimeContext([
|
|
259
|
-
...Array.from(runtimeContext?.entries() ?? []),
|
|
260
|
-
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
261
|
-
]);
|
|
262
246
|
const run = workflow.createRun({ runId });
|
|
263
247
|
const result = run.stream({
|
|
264
248
|
inputData,
|
|
265
|
-
runtimeContext
|
|
249
|
+
runtimeContext
|
|
266
250
|
});
|
|
267
251
|
return result;
|
|
268
252
|
} catch (error) {
|
|
@@ -274,8 +258,7 @@ async function resumeAsyncWorkflowHandler({
|
|
|
274
258
|
workflowId,
|
|
275
259
|
runId,
|
|
276
260
|
body,
|
|
277
|
-
runtimeContext
|
|
278
|
-
runtimeContextFromRequest
|
|
261
|
+
runtimeContext
|
|
279
262
|
}) {
|
|
280
263
|
try {
|
|
281
264
|
if (!workflowId) {
|
|
@@ -292,15 +275,11 @@ async function resumeAsyncWorkflowHandler({
|
|
|
292
275
|
if (!run) {
|
|
293
276
|
throw new chunkOCWPVYNI_cjs.HTTPException(404, { message: "Workflow run not found" });
|
|
294
277
|
}
|
|
295
|
-
const finalRuntimeContext = new di.RuntimeContext([
|
|
296
|
-
...Array.from(runtimeContext?.entries() ?? []),
|
|
297
|
-
...Array.from(Object.entries(runtimeContextFromRequest ?? {}))
|
|
298
|
-
]);
|
|
299
278
|
const _run = workflow.createRun({ runId });
|
|
300
279
|
const result = await _run.resume({
|
|
301
280
|
step: body.step,
|
|
302
281
|
resumeData: body.resumeData,
|
|
303
|
-
runtimeContext
|
|
282
|
+
runtimeContext
|
|
304
283
|
});
|
|
305
284
|
return result;
|
|
306
285
|
} catch (error) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkXUGQSVZ4_cjs = require('./chunk-XUGQSVZ4.cjs');
|
|
4
4
|
var chunk57CJTIPW_cjs = require('./chunk-57CJTIPW.cjs');
|
|
5
5
|
var chunk64U3UDTH_cjs = require('./chunk-64U3UDTH.cjs');
|
|
6
6
|
var chunkOCWPVYNI_cjs = require('./chunk-OCWPVYNI.cjs');
|
|
@@ -29,8 +29,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
|
|
|
29
29
|
const _tool = tool;
|
|
30
30
|
acc[key] = {
|
|
31
31
|
..._tool,
|
|
32
|
-
inputSchema: _tool.inputSchema ?
|
|
33
|
-
outputSchema: _tool.outputSchema ?
|
|
32
|
+
inputSchema: _tool.inputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(_tool.inputSchema)) : void 0,
|
|
33
|
+
outputSchema: _tool.outputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(_tool.outputSchema)) : void 0
|
|
34
34
|
};
|
|
35
35
|
return acc;
|
|
36
36
|
}, {});
|
|
@@ -76,7 +76,8 @@ async function getAgentsHandler({ mastra, runtimeContext }) {
|
|
|
76
76
|
async function getAgentByIdHandler({
|
|
77
77
|
mastra,
|
|
78
78
|
runtimeContext,
|
|
79
|
-
agentId
|
|
79
|
+
agentId,
|
|
80
|
+
isPlayground = false
|
|
80
81
|
}) {
|
|
81
82
|
try {
|
|
82
83
|
const agent = mastra.getAgent(agentId);
|
|
@@ -88,8 +89,8 @@ async function getAgentByIdHandler({
|
|
|
88
89
|
const _tool = tool;
|
|
89
90
|
acc[key] = {
|
|
90
91
|
..._tool,
|
|
91
|
-
inputSchema: _tool.inputSchema ?
|
|
92
|
-
outputSchema: _tool.outputSchema ?
|
|
92
|
+
inputSchema: _tool.inputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(_tool.inputSchema)) : void 0,
|
|
93
|
+
outputSchema: _tool.outputSchema ? chunkXUGQSVZ4_cjs.stringify(chunkXUGQSVZ4_cjs.esm_default(_tool.outputSchema)) : void 0
|
|
93
94
|
};
|
|
94
95
|
return acc;
|
|
95
96
|
}, {});
|
|
@@ -110,7 +111,21 @@ async function getAgentByIdHandler({
|
|
|
110
111
|
logger.error("Error getting workflows for agent", { agentName: agent.name, error });
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
+
let proxyRuntimeContext = runtimeContext;
|
|
115
|
+
if (isPlayground) {
|
|
116
|
+
proxyRuntimeContext = new Proxy(runtimeContext, {
|
|
117
|
+
get(target, prop) {
|
|
118
|
+
if (prop === "get") {
|
|
119
|
+
return function(key) {
|
|
120
|
+
const value = target.get(key);
|
|
121
|
+
return value ?? `<${key}>`;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return Reflect.get(target, prop);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
const instructions = await agent.getInstructions({ runtimeContext: proxyRuntimeContext });
|
|
114
129
|
const llm = await agent.getLLM({ runtimeContext });
|
|
115
130
|
return {
|
|
116
131
|
name: agent.name,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stringify, esm_default } from './chunk-
|
|
1
|
+
import { stringify, esm_default } from './chunk-WKWHYFX4.js';
|
|
2
2
|
import { handleError } from './chunk-M5ABIP7D.js';
|
|
3
3
|
import { HTTPException } from './chunk-NYN7KFXL.js';
|
|
4
4
|
import { __export } from './chunk-MLKGABMK.js';
|