@mastra/server 0.10.3 → 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 +32 -16
- package/dist/_tsup-dts-rollup.d.ts +32 -16
- package/dist/{chunk-J3PKLB3A.js → chunk-6MQO3273.js} +18 -3
- package/dist/{chunk-KUNQFY2W.js → chunk-7IBZ4L35.js} +10 -31
- package/dist/{chunk-B6AYBJUA.js → chunk-HYP7B2TL.js} +5 -16
- package/dist/{chunk-NEOOQUKW.cjs → chunk-IMBY5XUG.cjs} +36 -4
- package/dist/{chunk-MMO2HDM6.cjs → chunk-JKF6PRPU.cjs} +21 -42
- package/dist/{chunk-A3KDUGS7.cjs → chunk-P77X4SV2.cjs} +22 -7
- package/dist/{chunk-DQLE3DVM.js → chunk-QLG2PFHE.js} +36 -4
- package/dist/{chunk-W7VCKPAD.js → chunk-TEZOEGR4.js} +2 -2
- package/dist/{chunk-7VOSGHNC.cjs → chunk-TJO277H7.cjs} +9 -20
- package/dist/{chunk-YIOVBYZH.cjs → chunk-UZ7FJ66C.cjs} +7 -7
- package/dist/{chunk-LIVAK2DM.js → chunk-WKWHYFX4.js} +35 -35
- package/dist/{chunk-YWLUOY3D.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/logs.cjs +4 -4
- package/dist/server/handlers/logs.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 +10 -10
- package/dist/server/handlers.js +5 -5
- package/package.json +8 -8
|
@@ -15,6 +15,7 @@ import { LegacyStep } from '@mastra/core/workflows/legacy';
|
|
|
15
15
|
import type { LegacyWorkflow } from '@mastra/core/workflows/legacy';
|
|
16
16
|
import { LegacyWorkflowRunResult } from '@mastra/core/workflows/legacy';
|
|
17
17
|
import type { LegacyWorkflowRuns } from '@mastra/core/storage';
|
|
18
|
+
import type { LogLevel } from '@mastra/core/logger';
|
|
18
19
|
import type { Mastra } from '@mastra/core/mastra';
|
|
19
20
|
import type { MastraMemory } from '@mastra/core/memory';
|
|
20
21
|
import { MastraMessageV1 } from '@mastra/core/memory';
|
|
@@ -22,7 +23,7 @@ import type { Message } from '@mastra/core/a2a';
|
|
|
22
23
|
import type { QueryResult } from '@mastra/core/vector';
|
|
23
24
|
import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
|
|
24
25
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
25
|
-
import { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
|
|
26
|
+
import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
|
|
26
27
|
import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
|
|
27
28
|
import { Step } from '@mastra/core/workflows';
|
|
28
29
|
import { StepExecutionContext } from '@mastra/core/workflows/legacy';
|
|
@@ -140,17 +141,15 @@ export declare function describeIndex({ mastra, vectorName, indexName, }: Pick<V
|
|
|
140
141
|
metric: string | undefined;
|
|
141
142
|
}>;
|
|
142
143
|
|
|
143
|
-
export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, runtimeContext,
|
|
144
|
+
export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, runtimeContext, }: Pick<ToolsContext, 'mastra' | 'toolId'> & {
|
|
144
145
|
agentId?: string;
|
|
145
146
|
data: any;
|
|
146
147
|
runtimeContext: RuntimeContext_2;
|
|
147
|
-
runtimeContextFromRequest: Record<string, unknown>;
|
|
148
148
|
}): Promise<any>;
|
|
149
149
|
|
|
150
|
-
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"> & {
|
|
151
151
|
data?: unknown;
|
|
152
152
|
runtimeContext: RuntimeContext_2;
|
|
153
|
-
runtimeContextFromRequest: Record<string, unknown>;
|
|
154
153
|
}) => Promise<any>;
|
|
155
154
|
|
|
156
155
|
export declare function generateHandler({ mastra, runtimeContext, agentId, body, }: Context & {
|
|
@@ -179,7 +178,8 @@ export declare function generateSpeechHandler({ mastra, agentId, body, }: VoiceC
|
|
|
179
178
|
};
|
|
180
179
|
}): Promise<NodeJS.ReadableStream>;
|
|
181
180
|
|
|
182
|
-
export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, }: Context & {
|
|
181
|
+
export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, isPlayground, }: Context & {
|
|
182
|
+
isPlayground?: boolean;
|
|
183
183
|
runtimeContext: RuntimeContext;
|
|
184
184
|
agentId: string;
|
|
185
185
|
}): Promise<{
|
|
@@ -273,9 +273,21 @@ export declare function getLiveEvalsByAgentIdHandler({ mastra, runtimeContext, a
|
|
|
273
273
|
evals: EvalRow[];
|
|
274
274
|
}>;
|
|
275
275
|
|
|
276
|
-
export declare function getLogsByRunIdHandler({ mastra, runId, transportId, }: Pick<LogsContext, 'mastra' | 'runId' | 'transportId'>): Promise<
|
|
276
|
+
export declare function getLogsByRunIdHandler({ mastra, runId, transportId, params, }: Pick<LogsContext, 'mastra' | 'runId' | 'transportId' | 'params'>): Promise<{
|
|
277
|
+
logs: BaseLogMessage[];
|
|
278
|
+
total: number;
|
|
279
|
+
page: number;
|
|
280
|
+
perPage: number;
|
|
281
|
+
hasMore: boolean;
|
|
282
|
+
}>;
|
|
277
283
|
|
|
278
|
-
export declare function getLogsHandler({ mastra, transportId, }: Pick<LogsContext, 'mastra' | 'transportId'>): Promise<
|
|
284
|
+
export declare function getLogsHandler({ mastra, transportId, params, }: Pick<LogsContext, 'mastra' | 'transportId' | 'params'>): Promise<{
|
|
285
|
+
logs: BaseLogMessage[];
|
|
286
|
+
total: number;
|
|
287
|
+
page: number;
|
|
288
|
+
perPage: number;
|
|
289
|
+
hasMore: boolean;
|
|
290
|
+
}>;
|
|
279
291
|
|
|
280
292
|
export declare function getLogTransports({ mastra }: Pick<LogsContext, 'mastra'>): Promise<{
|
|
281
293
|
transports: string[];
|
|
@@ -519,6 +531,14 @@ declare type LogsContext = {
|
|
|
519
531
|
mastra: Mastra;
|
|
520
532
|
transportId?: string;
|
|
521
533
|
runId?: string;
|
|
534
|
+
params?: {
|
|
535
|
+
fromDate?: Date;
|
|
536
|
+
toDate?: Date;
|
|
537
|
+
logLevel?: LogLevel;
|
|
538
|
+
filters?: string | string[];
|
|
539
|
+
page?: number;
|
|
540
|
+
perPage?: number;
|
|
541
|
+
};
|
|
522
542
|
};
|
|
523
543
|
|
|
524
544
|
export declare namespace memory {
|
|
@@ -578,13 +598,12 @@ export declare function resumeAsyncLegacyWorkflowHandler({ mastra, workflowId, r
|
|
|
578
598
|
runtimeContext: RuntimeContext;
|
|
579
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>;
|
|
580
600
|
|
|
581
|
-
export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext,
|
|
601
|
+
export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
|
|
582
602
|
body: {
|
|
583
603
|
step: string | string[];
|
|
584
604
|
resumeData?: unknown;
|
|
585
605
|
};
|
|
586
606
|
runtimeContext?: RuntimeContext_2;
|
|
587
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
588
607
|
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
589
608
|
|
|
590
609
|
export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
|
|
@@ -629,10 +648,9 @@ export declare function startAsyncLegacyWorkflowHandler({ mastra, runtimeContext
|
|
|
629
648
|
runtimeContext: RuntimeContext;
|
|
630
649
|
}): Promise<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>>;
|
|
631
650
|
|
|
632
|
-
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'> & {
|
|
633
652
|
inputData?: unknown;
|
|
634
653
|
runtimeContext?: RuntimeContext_2;
|
|
635
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
636
654
|
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
637
655
|
|
|
638
656
|
export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
@@ -642,10 +660,9 @@ export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext,
|
|
|
642
660
|
message: string;
|
|
643
661
|
}>;
|
|
644
662
|
|
|
645
|
-
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'> & {
|
|
646
664
|
inputData?: unknown;
|
|
647
665
|
runtimeContext?: RuntimeContext_2;
|
|
648
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
649
666
|
}): Promise<{
|
|
650
667
|
message: string;
|
|
651
668
|
}>;
|
|
@@ -689,10 +706,9 @@ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body,
|
|
|
689
706
|
} & Parameters<AgentNetwork['stream']>[1];
|
|
690
707
|
}): Promise<Response>;
|
|
691
708
|
|
|
692
|
-
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'> & {
|
|
693
710
|
inputData?: unknown;
|
|
694
711
|
runtimeContext?: RuntimeContext_2;
|
|
695
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
696
712
|
}): {
|
|
697
713
|
stream: globalThis.ReadableStream<StreamEvent>;
|
|
698
714
|
getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
@@ -15,6 +15,7 @@ import { LegacyStep } from '@mastra/core/workflows/legacy';
|
|
|
15
15
|
import type { LegacyWorkflow } from '@mastra/core/workflows/legacy';
|
|
16
16
|
import { LegacyWorkflowRunResult } from '@mastra/core/workflows/legacy';
|
|
17
17
|
import type { LegacyWorkflowRuns } from '@mastra/core/storage';
|
|
18
|
+
import type { LogLevel } from '@mastra/core/logger';
|
|
18
19
|
import type { Mastra } from '@mastra/core/mastra';
|
|
19
20
|
import type { MastraMemory } from '@mastra/core/memory';
|
|
20
21
|
import { MastraMessageV1 } from '@mastra/core/memory';
|
|
@@ -22,7 +23,7 @@ import type { Message } from '@mastra/core/a2a';
|
|
|
22
23
|
import type { QueryResult } from '@mastra/core/vector';
|
|
23
24
|
import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
|
|
24
25
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
25
|
-
import { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
|
|
26
|
+
import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
|
|
26
27
|
import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
|
|
27
28
|
import { Step } from '@mastra/core/workflows';
|
|
28
29
|
import { StepExecutionContext } from '@mastra/core/workflows/legacy';
|
|
@@ -140,17 +141,15 @@ export declare function describeIndex({ mastra, vectorName, indexName, }: Pick<V
|
|
|
140
141
|
metric: string | undefined;
|
|
141
142
|
}>;
|
|
142
143
|
|
|
143
|
-
export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, runtimeContext,
|
|
144
|
+
export declare function executeAgentToolHandler({ mastra, agentId, toolId, data, runtimeContext, }: Pick<ToolsContext, 'mastra' | 'toolId'> & {
|
|
144
145
|
agentId?: string;
|
|
145
146
|
data: any;
|
|
146
147
|
runtimeContext: RuntimeContext_2;
|
|
147
|
-
runtimeContextFromRequest: Record<string, unknown>;
|
|
148
148
|
}): Promise<any>;
|
|
149
149
|
|
|
150
|
-
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"> & {
|
|
151
151
|
data?: unknown;
|
|
152
152
|
runtimeContext: RuntimeContext_2;
|
|
153
|
-
runtimeContextFromRequest: Record<string, unknown>;
|
|
154
153
|
}) => Promise<any>;
|
|
155
154
|
|
|
156
155
|
export declare function generateHandler({ mastra, runtimeContext, agentId, body, }: Context & {
|
|
@@ -179,7 +178,8 @@ export declare function generateSpeechHandler({ mastra, agentId, body, }: VoiceC
|
|
|
179
178
|
};
|
|
180
179
|
}): Promise<NodeJS.ReadableStream>;
|
|
181
180
|
|
|
182
|
-
export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, }: Context & {
|
|
181
|
+
export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, isPlayground, }: Context & {
|
|
182
|
+
isPlayground?: boolean;
|
|
183
183
|
runtimeContext: RuntimeContext;
|
|
184
184
|
agentId: string;
|
|
185
185
|
}): Promise<{
|
|
@@ -273,9 +273,21 @@ export declare function getLiveEvalsByAgentIdHandler({ mastra, runtimeContext, a
|
|
|
273
273
|
evals: EvalRow[];
|
|
274
274
|
}>;
|
|
275
275
|
|
|
276
|
-
export declare function getLogsByRunIdHandler({ mastra, runId, transportId, }: Pick<LogsContext, 'mastra' | 'runId' | 'transportId'>): Promise<
|
|
276
|
+
export declare function getLogsByRunIdHandler({ mastra, runId, transportId, params, }: Pick<LogsContext, 'mastra' | 'runId' | 'transportId' | 'params'>): Promise<{
|
|
277
|
+
logs: BaseLogMessage[];
|
|
278
|
+
total: number;
|
|
279
|
+
page: number;
|
|
280
|
+
perPage: number;
|
|
281
|
+
hasMore: boolean;
|
|
282
|
+
}>;
|
|
277
283
|
|
|
278
|
-
export declare function getLogsHandler({ mastra, transportId, }: Pick<LogsContext, 'mastra' | 'transportId'>): Promise<
|
|
284
|
+
export declare function getLogsHandler({ mastra, transportId, params, }: Pick<LogsContext, 'mastra' | 'transportId' | 'params'>): Promise<{
|
|
285
|
+
logs: BaseLogMessage[];
|
|
286
|
+
total: number;
|
|
287
|
+
page: number;
|
|
288
|
+
perPage: number;
|
|
289
|
+
hasMore: boolean;
|
|
290
|
+
}>;
|
|
279
291
|
|
|
280
292
|
export declare function getLogTransports({ mastra }: Pick<LogsContext, 'mastra'>): Promise<{
|
|
281
293
|
transports: string[];
|
|
@@ -519,6 +531,14 @@ declare type LogsContext = {
|
|
|
519
531
|
mastra: Mastra;
|
|
520
532
|
transportId?: string;
|
|
521
533
|
runId?: string;
|
|
534
|
+
params?: {
|
|
535
|
+
fromDate?: Date;
|
|
536
|
+
toDate?: Date;
|
|
537
|
+
logLevel?: LogLevel;
|
|
538
|
+
filters?: string | string[];
|
|
539
|
+
page?: number;
|
|
540
|
+
perPage?: number;
|
|
541
|
+
};
|
|
522
542
|
};
|
|
523
543
|
|
|
524
544
|
export declare namespace memory {
|
|
@@ -578,13 +598,12 @@ export declare function resumeAsyncLegacyWorkflowHandler({ mastra, workflowId, r
|
|
|
578
598
|
runtimeContext: RuntimeContext;
|
|
579
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>;
|
|
580
600
|
|
|
581
|
-
export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext,
|
|
601
|
+
export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext_3 & {
|
|
582
602
|
body: {
|
|
583
603
|
step: string | string[];
|
|
584
604
|
resumeData?: unknown;
|
|
585
605
|
};
|
|
586
606
|
runtimeContext?: RuntimeContext_2;
|
|
587
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
588
607
|
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
589
608
|
|
|
590
609
|
export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
|
|
@@ -629,10 +648,9 @@ export declare function startAsyncLegacyWorkflowHandler({ mastra, runtimeContext
|
|
|
629
648
|
runtimeContext: RuntimeContext;
|
|
630
649
|
}): Promise<LegacyWorkflowRunResult<any, LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext_2<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], any>>;
|
|
631
650
|
|
|
632
|
-
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'> & {
|
|
633
652
|
inputData?: unknown;
|
|
634
653
|
runtimeContext?: RuntimeContext_2;
|
|
635
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
636
654
|
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
637
655
|
|
|
638
656
|
export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
@@ -642,10 +660,9 @@ export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext,
|
|
|
642
660
|
message: string;
|
|
643
661
|
}>;
|
|
644
662
|
|
|
645
|
-
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'> & {
|
|
646
664
|
inputData?: unknown;
|
|
647
665
|
runtimeContext?: RuntimeContext_2;
|
|
648
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
649
666
|
}): Promise<{
|
|
650
667
|
message: string;
|
|
651
668
|
}>;
|
|
@@ -689,10 +706,9 @@ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body,
|
|
|
689
706
|
} & Parameters<AgentNetwork['stream']>[1];
|
|
690
707
|
}): Promise<Response>;
|
|
691
708
|
|
|
692
|
-
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'> & {
|
|
693
710
|
inputData?: unknown;
|
|
694
711
|
runtimeContext?: RuntimeContext_2;
|
|
695
|
-
runtimeContextFromRequest?: Record<string, unknown>;
|
|
696
712
|
}): {
|
|
697
713
|
stream: globalThis.ReadableStream<StreamEvent>;
|
|
698
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
|
-
import { ReadableStream } from '
|
|
6
|
-
import { RuntimeContext } from '@mastra/core/di';
|
|
5
|
+
import { ReadableStream } from 'stream/web';
|
|
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
|
});
|
|
@@ -13,11 +13,26 @@ chunk75ZPJI57_cjs.__export(logs_exports, {
|
|
|
13
13
|
});
|
|
14
14
|
async function getLogsHandler({
|
|
15
15
|
mastra,
|
|
16
|
-
transportId
|
|
16
|
+
transportId,
|
|
17
|
+
params
|
|
17
18
|
}) {
|
|
18
19
|
try {
|
|
19
20
|
chunk57CJTIPW_cjs.validateBody({ transportId });
|
|
20
|
-
const
|
|
21
|
+
const { fromDate, toDate, logLevel, filters: _filters, page, perPage } = params || {};
|
|
22
|
+
const filters = _filters ? Object.fromEntries(
|
|
23
|
+
(Array.isArray(_filters) ? _filters : [_filters]).map((attr) => {
|
|
24
|
+
const [key, value] = attr.split(":");
|
|
25
|
+
return [key, value];
|
|
26
|
+
})
|
|
27
|
+
) : void 0;
|
|
28
|
+
const logs = await mastra.getLogs(transportId, {
|
|
29
|
+
fromDate,
|
|
30
|
+
toDate,
|
|
31
|
+
logLevel,
|
|
32
|
+
filters,
|
|
33
|
+
page: page ? Number(page) : void 0,
|
|
34
|
+
perPage: perPage ? Number(perPage) : void 0
|
|
35
|
+
});
|
|
21
36
|
return logs;
|
|
22
37
|
} catch (error) {
|
|
23
38
|
return chunk64U3UDTH_cjs.handleError(error, "Error getting logs");
|
|
@@ -26,11 +41,28 @@ async function getLogsHandler({
|
|
|
26
41
|
async function getLogsByRunIdHandler({
|
|
27
42
|
mastra,
|
|
28
43
|
runId,
|
|
29
|
-
transportId
|
|
44
|
+
transportId,
|
|
45
|
+
params
|
|
30
46
|
}) {
|
|
31
47
|
try {
|
|
32
48
|
chunk57CJTIPW_cjs.validateBody({ runId, transportId });
|
|
33
|
-
const
|
|
49
|
+
const { fromDate, toDate, logLevel, filters: _filters, page, perPage } = params || {};
|
|
50
|
+
const filters = _filters ? Object.fromEntries(
|
|
51
|
+
(Array.isArray(_filters) ? _filters : [_filters]).map((attr) => {
|
|
52
|
+
const [key, value] = attr.split(":");
|
|
53
|
+
return [key, value];
|
|
54
|
+
})
|
|
55
|
+
) : void 0;
|
|
56
|
+
const logs = await mastra.getLogsByRunId({
|
|
57
|
+
runId,
|
|
58
|
+
transportId,
|
|
59
|
+
fromDate,
|
|
60
|
+
toDate,
|
|
61
|
+
logLevel,
|
|
62
|
+
filters,
|
|
63
|
+
page: page ? Number(page) : void 0,
|
|
64
|
+
perPage: perPage ? Number(perPage) : void 0
|
|
65
|
+
});
|
|
34
66
|
return logs;
|
|
35
67
|
} catch (error) {
|
|
36
68
|
return chunk64U3UDTH_cjs.handleError(error, "Error getting logs by run ID");
|