@mastra/server 0.0.0-cli-debug-2-20250611100354 → 0.0.0-cloudflare-deployer-dont-install-deps-20250714111754
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/LICENSE.md +11 -42
- package/dist/_tsup-dts-rollup.d.cts +275 -28
- package/dist/_tsup-dts-rollup.d.ts +275 -28
- package/dist/{chunk-OCWPVYNI.cjs → chunk-2KZFMI6P.cjs} +1 -0
- package/dist/{chunk-VPNDC2DI.cjs → chunk-2SLFAFTR.cjs} +12 -12
- package/dist/chunk-3CNDE7QY.cjs +308 -0
- package/dist/{chunk-QLG2PFHE.js → chunk-4D66QEKC.js} +2 -2
- package/dist/{chunk-TEZOEGR4.js → chunk-5PQQ42EZ.js} +8 -8
- package/dist/{chunk-BNEY4P4P.cjs → chunk-7TP2LX5L.cjs} +16 -16
- package/dist/chunk-B2PAS2IB.cjs +514 -0
- package/dist/{chunk-6F2H7Y45.js → chunk-BK4XT6EG.js} +29 -14
- package/dist/{chunk-57CJTIPW.cjs → chunk-CCGRCYWJ.cjs} +2 -2
- package/dist/{chunk-C7564HUT.js → chunk-CRCR3ZUK.js} +3 -3
- package/dist/{chunk-TJO277H7.cjs → chunk-FRVBFMO2.cjs} +20 -20
- package/dist/{chunk-B4MQFJ7G.cjs → chunk-G7KH752Y.cjs} +5 -5
- package/dist/{chunk-7IBZ4L35.js → chunk-H7DMHBKY.js} +181 -27
- package/dist/{chunk-UZ7FJ66C.cjs → chunk-JMLYCXMK.cjs} +43 -43
- package/dist/{chunk-CP55EVBK.js → chunk-KHZKYUNR.js} +15 -11
- package/dist/{chunk-I7KJZNX5.js → chunk-KOHWJYJT.js} +110 -25
- package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
- package/dist/chunk-LF7P5PLR.js +14 -0
- package/dist/{chunk-XUGQSVZ4.cjs → chunk-LI436ITD.cjs} +107 -69
- package/dist/{chunk-HYP7B2TL.js → chunk-LRCAAFUA.js} +4 -4
- package/dist/{chunk-JEWNMAYQ.cjs → chunk-LZ3VJXSO.cjs} +43 -28
- package/dist/{chunk-WKWHYFX4.js → chunk-MEGCYGBU.js} +108 -70
- package/dist/chunk-PZQDCRPV.cjs +16 -0
- package/dist/{chunk-IMBY5XUG.cjs → chunk-QGX47B5D.cjs} +7 -7
- package/dist/{chunk-BFOA2QQY.js → chunk-RG473F6Y.js} +2 -2
- package/dist/{chunk-CMMOIUFC.cjs → chunk-RHSWAXKB.cjs} +34 -30
- package/dist/{chunk-H5PTF3Y4.js → chunk-RSEO4XPX.js} +1 -1
- package/dist/{chunk-55DOQLP6.js → chunk-WNVFNNWN.js} +2 -2
- package/dist/server/handlers/agents.cjs +7 -7
- package/dist/server/handlers/agents.js +1 -1
- package/dist/server/handlers/error.cjs +2 -2
- package/dist/server/handlers/error.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/memory.cjs +17 -9
- package/dist/server/handlers/memory.d.cts +2 -0
- package/dist/server/handlers/memory.d.ts +2 -0
- package/dist/server/handlers/memory.js +1 -1
- package/dist/server/handlers/network.cjs +5 -5
- package/dist/server/handlers/network.js +1 -1
- package/dist/server/handlers/telemetry.cjs +3 -3
- package/dist/server/handlers/telemetry.js +1 -1
- package/dist/server/handlers/tools.cjs +5 -5
- package/dist/server/handlers/tools.js +1 -1
- package/dist/server/handlers/utils.cjs +2 -2
- package/dist/server/handlers/utils.js +1 -1
- package/dist/server/handlers/vNextNetwork.cjs +218 -0
- package/dist/server/handlers/vNextNetwork.d.cts +6 -0
- package/dist/server/handlers/vNextNetwork.d.ts +6 -0
- package/dist/server/handlers/vNextNetwork.js +211 -0
- package/dist/server/handlers/vector.cjs +7 -7
- package/dist/server/handlers/vector.js +1 -1
- package/dist/server/handlers/voice.cjs +5 -5
- package/dist/server/handlers/voice.js +1 -1
- package/dist/server/handlers/workflows.cjs +24 -12
- package/dist/server/handlers/workflows.d.cts +3 -0
- package/dist/server/handlers/workflows.d.ts +3 -0
- package/dist/server/handlers/workflows.js +1 -1
- package/dist/server/handlers.cjs +20 -20
- package/dist/server/handlers.js +10 -10
- package/package.json +11 -12
- package/dist/chunk-64U3UDTH.cjs +0 -13
- package/dist/chunk-6TJSHFCJ.cjs +0 -221
- package/dist/chunk-JKF6PRPU.cjs +0 -357
- package/dist/chunk-M5ABIP7D.js +0 -11
|
@@ -5,7 +5,8 @@ import type { Artifact } from '@mastra/core/a2a';
|
|
|
5
5
|
import type { BaseLogMessage } from '@mastra/core/logger';
|
|
6
6
|
import { CoreMessage } from 'ai';
|
|
7
7
|
import type { CoreMessage as CoreMessage_2 } from '@mastra/core/llm';
|
|
8
|
-
import {
|
|
8
|
+
import { DefaultEngineType } from '@mastra/core';
|
|
9
|
+
import { EvalRow } from '@mastra/core';
|
|
9
10
|
import { GenerateObjectResult } from 'ai';
|
|
10
11
|
import { GenerateTextResult } from 'ai';
|
|
11
12
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
@@ -17,19 +18,22 @@ import { LegacyWorkflowRunResult } from '@mastra/core/workflows/legacy';
|
|
|
17
18
|
import type { LegacyWorkflowRuns } from '@mastra/core/storage';
|
|
18
19
|
import type { LogLevel } from '@mastra/core/logger';
|
|
19
20
|
import type { Mastra } from '@mastra/core/mastra';
|
|
21
|
+
import type { MastraError } from '@mastra/core/error';
|
|
20
22
|
import type { MastraMemory } from '@mastra/core/memory';
|
|
21
|
-
import { MastraMessageV1 } from '@mastra/core
|
|
23
|
+
import { MastraMessageV1 } from '@mastra/core';
|
|
22
24
|
import type { Message } from '@mastra/core/a2a';
|
|
23
25
|
import type { QueryResult } from '@mastra/core/vector';
|
|
24
26
|
import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
|
|
27
|
+
import { ReadableStream as ReadableStream_3 } from 'stream/web';
|
|
25
28
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
26
29
|
import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
|
|
27
30
|
import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
|
|
28
|
-
import { Step } from '@mastra/core
|
|
31
|
+
import { Step } from '@mastra/core';
|
|
29
32
|
import { StepExecutionContext } from '@mastra/core/workflows/legacy';
|
|
30
33
|
import { StepGraph } from '@mastra/core/workflows/legacy';
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
34
|
+
import { StepResult } from '@mastra/core';
|
|
35
|
+
import { StorageThreadType } from '@mastra/core';
|
|
36
|
+
import { StreamEvent } from '@mastra/core';
|
|
33
37
|
import { Task } from '@mastra/core/a2a';
|
|
34
38
|
import { TaskAndHistory } from '@mastra/core/a2a';
|
|
35
39
|
import type { TaskContext } from '@mastra/core/a2a';
|
|
@@ -40,11 +44,20 @@ import type { TaskStatus } from '@mastra/core/a2a';
|
|
|
40
44
|
import type { ToolAction } from '@mastra/core/tools';
|
|
41
45
|
import { UIMessage } from 'ai';
|
|
42
46
|
import type { VercelTool } from '@mastra/core/tools';
|
|
47
|
+
import type { WatchEvent } from '@mastra/core/workflows';
|
|
43
48
|
import type { Workflow } from '@mastra/core/workflows';
|
|
44
49
|
import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows/legacy';
|
|
45
|
-
import { WorkflowResult } from '@mastra/core
|
|
50
|
+
import { WorkflowResult } from '@mastra/core';
|
|
46
51
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
52
|
+
import { WorkingMemoryTemplate } from '@mastra/core';
|
|
53
|
+
import { ZodBoolean } from 'zod';
|
|
54
|
+
import { ZodEnum } from 'zod';
|
|
55
|
+
import { ZodNumber } from 'zod';
|
|
56
|
+
import { ZodObject } from 'zod';
|
|
57
|
+
import { ZodOptional } from 'zod';
|
|
58
|
+
import { ZodString } from 'zod';
|
|
47
59
|
import { ZodType } from 'zod';
|
|
60
|
+
import { ZodTypeAny } from 'zod';
|
|
48
61
|
import { ZodTypeDef } from 'zod';
|
|
49
62
|
|
|
50
63
|
export declare namespace a2a {
|
|
@@ -69,13 +82,17 @@ export declare namespace agents {
|
|
|
69
82
|
}
|
|
70
83
|
}
|
|
71
84
|
|
|
72
|
-
export declare interface ApiError extends
|
|
85
|
+
export declare interface ApiError extends MastraError {
|
|
73
86
|
message: string;
|
|
74
87
|
status?: number;
|
|
75
88
|
}
|
|
76
89
|
|
|
77
90
|
export declare function applyUpdateToTaskAndHistory(current: TaskAndHistory, update: Omit<TaskStatus, 'timestamp'> | Artifact): TaskAndHistory;
|
|
78
91
|
|
|
92
|
+
export declare function cancelWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<{
|
|
93
|
+
message: string;
|
|
94
|
+
}>;
|
|
95
|
+
|
|
79
96
|
declare type ClientErrorStatusCode = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 421 | 422 | 423 | 424 | 425 | 426 | 428 | 429 | 431 | 451;
|
|
80
97
|
|
|
81
98
|
export declare interface Context {
|
|
@@ -111,7 +128,7 @@ export declare function createTaskContext({ task, userMessage, history, activeCa
|
|
|
111
128
|
activeCancellations: Set<string>;
|
|
112
129
|
}): TaskContext;
|
|
113
130
|
|
|
114
|
-
export declare function createThreadHandler({ mastra, agentId, body, }: Pick<MemoryContext, 'mastra' | 'agentId'> & {
|
|
131
|
+
export declare function createThreadHandler({ mastra, agentId, body, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {
|
|
115
132
|
body?: Omit<Parameters<MastraMemory['createThread']>[0], 'resourceId'> & {
|
|
116
133
|
resourceId?: string;
|
|
117
134
|
};
|
|
@@ -127,7 +144,7 @@ export declare function deleteIndex({ mastra, vectorName, indexName, }: Pick<Vec
|
|
|
127
144
|
success: boolean;
|
|
128
145
|
}>;
|
|
129
146
|
|
|
130
|
-
export declare function deleteThreadHandler({ mastra, agentId, threadId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'>): Promise<{
|
|
147
|
+
export declare function deleteThreadHandler({ mastra, agentId, threadId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'>): Promise<{
|
|
131
148
|
result: string;
|
|
132
149
|
}>;
|
|
133
150
|
|
|
@@ -152,14 +169,15 @@ export declare function executeToolHandler(tools: ToolsContext['tools']): ({ mas
|
|
|
152
169
|
runtimeContext: RuntimeContext_2;
|
|
153
170
|
}) => Promise<any>;
|
|
154
171
|
|
|
155
|
-
export declare function generateHandler({ mastra, runtimeContext, agentId, body, }: Context & {
|
|
172
|
+
export declare function generateHandler({ mastra, runtimeContext, agentId, body, abortSignal, }: Context & {
|
|
156
173
|
runtimeContext: RuntimeContext;
|
|
157
174
|
agentId: string;
|
|
158
175
|
body: GetBody<'generate'> & {
|
|
159
176
|
resourceid?: string;
|
|
160
177
|
runtimeContext?: Record<string, unknown>;
|
|
161
178
|
};
|
|
162
|
-
|
|
179
|
+
abortSignal?: AbortSignal;
|
|
180
|
+
}): Promise<GenerateTextResult<any, unknown>>;
|
|
163
181
|
|
|
164
182
|
export declare function generateHandler_alias_1({ mastra, runtimeContext, networkId, body, }: NetworkContext & {
|
|
165
183
|
runtimeContext: RuntimeContext;
|
|
@@ -178,6 +196,20 @@ export declare function generateSpeechHandler({ mastra, agentId, body, }: VoiceC
|
|
|
178
196
|
};
|
|
179
197
|
}): Promise<NodeJS.ReadableStream>;
|
|
180
198
|
|
|
199
|
+
export declare function generateVNextNetworkHandler({ mastra, runtimeContext, networkId, body, }: NetworkContext_2 & {
|
|
200
|
+
runtimeContext: RuntimeContext;
|
|
201
|
+
body: {
|
|
202
|
+
message: string;
|
|
203
|
+
threadId?: string;
|
|
204
|
+
resourceId?: string;
|
|
205
|
+
};
|
|
206
|
+
}): Promise<{
|
|
207
|
+
task: string;
|
|
208
|
+
result: string;
|
|
209
|
+
resourceId: string;
|
|
210
|
+
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
211
|
+
}>;
|
|
212
|
+
|
|
181
213
|
export declare function getAgentByIdHandler({ mastra, runtimeContext, agentId, isPlayground, }: Context & {
|
|
182
214
|
isPlayground?: boolean;
|
|
183
215
|
runtimeContext: RuntimeContext;
|
|
@@ -216,7 +248,17 @@ export declare function getAgentExecutionHandler({ requestId, mastra, agentId, r
|
|
|
216
248
|
|
|
217
249
|
export declare function getAgentsHandler({ mastra, runtimeContext }: Context & {
|
|
218
250
|
runtimeContext: RuntimeContext;
|
|
219
|
-
}): Promise<
|
|
251
|
+
}): Promise<Record<string, Omit<{
|
|
252
|
+
id: string;
|
|
253
|
+
name: any;
|
|
254
|
+
instructions: string;
|
|
255
|
+
tools: any;
|
|
256
|
+
workflows: {};
|
|
257
|
+
provider: string;
|
|
258
|
+
modelId: string;
|
|
259
|
+
defaultGenerateOptions: any;
|
|
260
|
+
defaultStreamOptions: any;
|
|
261
|
+
}, "id">>>;
|
|
220
262
|
|
|
221
263
|
declare type GetBody<T extends keyof Agent & {
|
|
222
264
|
[K in keyof Agent]: Agent[K] extends (...args: any) => any ? K : never;
|
|
@@ -293,11 +335,11 @@ export declare function getLogTransports({ mastra }: Pick<LogsContext, 'mastra'>
|
|
|
293
335
|
transports: string[];
|
|
294
336
|
}>;
|
|
295
337
|
|
|
296
|
-
export declare function getMemoryStatusHandler({ mastra, agentId }: Pick<MemoryContext, 'mastra' | 'agentId'>): Promise<{
|
|
338
|
+
export declare function getMemoryStatusHandler({ mastra, agentId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'>): Promise<{
|
|
297
339
|
result: boolean;
|
|
298
340
|
}>;
|
|
299
341
|
|
|
300
|
-
export declare function getMessagesHandler({ mastra, agentId, threadId, limit, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'> & {
|
|
342
|
+
export declare function getMessagesHandler({ mastra, agentId, threadId, limit, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {
|
|
301
343
|
limit?: number;
|
|
302
344
|
}): Promise<{
|
|
303
345
|
messages: CoreMessage[];
|
|
@@ -343,16 +385,67 @@ export declare function getSpeakersHandler({ mastra, agentId }: VoiceContext): P
|
|
|
343
385
|
|
|
344
386
|
export declare function getTelemetryHandler({ mastra, body }: TelemetryContext): Promise<any[]>;
|
|
345
387
|
|
|
346
|
-
export declare function getThreadByIdHandler({ mastra, agentId, threadId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'>): Promise<StorageThreadType>;
|
|
388
|
+
export declare function getThreadByIdHandler({ mastra, agentId, threadId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'>): Promise<StorageThreadType>;
|
|
347
389
|
|
|
348
|
-
export declare function getThreadsHandler({ mastra, agentId, resourceId, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'resourceId'>): Promise<StorageThreadType[]>;
|
|
390
|
+
export declare function getThreadsHandler({ mastra, agentId, resourceId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'resourceId' | 'networkId' | 'runtimeContext'>): Promise<StorageThreadType[]>;
|
|
349
391
|
|
|
350
392
|
export declare function getToolByIdHandler({ tools, toolId }: Pick<ToolsContext, 'tools' | 'toolId'>): Promise<any>;
|
|
351
393
|
|
|
352
394
|
export declare function getToolsHandler({ tools }: Pick<ToolsContext, 'tools'>): Promise<Record<string, any>>;
|
|
353
395
|
|
|
396
|
+
export declare function getVNextNetworkByIdHandler({ mastra, networkId, runtimeContext, }: Pick<NetworkContext_2, 'mastra' | 'networkId' | 'runtimeContext'>): Promise<{
|
|
397
|
+
id: string;
|
|
398
|
+
name: string;
|
|
399
|
+
instructions: string;
|
|
400
|
+
agents: {
|
|
401
|
+
name: string;
|
|
402
|
+
provider: string;
|
|
403
|
+
modelId: string;
|
|
404
|
+
}[];
|
|
405
|
+
workflows: {
|
|
406
|
+
name: string | undefined;
|
|
407
|
+
description: string | undefined;
|
|
408
|
+
inputSchema: string | undefined;
|
|
409
|
+
outputSchema: string | undefined;
|
|
410
|
+
}[];
|
|
411
|
+
tools: {
|
|
412
|
+
id: string;
|
|
413
|
+
description: string;
|
|
414
|
+
}[];
|
|
415
|
+
routingModel: {
|
|
416
|
+
provider: string;
|
|
417
|
+
modelId: string;
|
|
418
|
+
};
|
|
419
|
+
}>;
|
|
420
|
+
|
|
421
|
+
export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pick<NetworkContext_2, 'mastra' | 'runtimeContext'>): Promise<{
|
|
422
|
+
id: string;
|
|
423
|
+
name: string;
|
|
424
|
+
instructions: string;
|
|
425
|
+
tools: {
|
|
426
|
+
id: string;
|
|
427
|
+
description: string;
|
|
428
|
+
}[];
|
|
429
|
+
agents: {
|
|
430
|
+
name: string;
|
|
431
|
+
provider: string;
|
|
432
|
+
modelId: string;
|
|
433
|
+
}[];
|
|
434
|
+
workflows: {
|
|
435
|
+
name: string | undefined;
|
|
436
|
+
description: string | undefined;
|
|
437
|
+
inputSchema: string | undefined;
|
|
438
|
+
outputSchema: string | undefined;
|
|
439
|
+
}[];
|
|
440
|
+
routingModel: {
|
|
441
|
+
provider: string;
|
|
442
|
+
modelId: string;
|
|
443
|
+
};
|
|
444
|
+
}[]>;
|
|
445
|
+
|
|
354
446
|
export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext_3): Promise<{
|
|
355
|
-
steps: SerializedStep
|
|
447
|
+
steps: Record<string, SerializedStep>;
|
|
448
|
+
allSteps: Record<string, SerializedStep>;
|
|
356
449
|
name: string | undefined;
|
|
357
450
|
description: string | undefined;
|
|
358
451
|
stepGraph: SerializedStepFlowEntry[];
|
|
@@ -362,6 +455,8 @@ export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowC
|
|
|
362
455
|
|
|
363
456
|
export declare function getWorkflowRunByIdHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<ReturnType<Workflow['getWorkflowRunById']>>;
|
|
364
457
|
|
|
458
|
+
export declare function getWorkflowRunExecutionResultHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<WatchEvent['payload']['workflowState']>;
|
|
459
|
+
|
|
365
460
|
export declare function getWorkflowRunsHandler({ mastra, workflowId, fromDate, toDate, limit, offset, resourceId, }: WorkflowContext_3 & {
|
|
366
461
|
fromDate?: Date;
|
|
367
462
|
toDate?: Date;
|
|
@@ -372,6 +467,21 @@ export declare function getWorkflowRunsHandler({ mastra, workflowId, fromDate, t
|
|
|
372
467
|
|
|
373
468
|
export declare function getWorkflowsHandler({ mastra }: WorkflowContext_3): Promise<any>;
|
|
374
469
|
|
|
470
|
+
/**
|
|
471
|
+
* Handler to get the working memory for a thread (optionally resource-scoped).
|
|
472
|
+
* @returns workingMemory - the working memory for the thread
|
|
473
|
+
* @returns source - thread or resource
|
|
474
|
+
*/
|
|
475
|
+
export declare function getWorkingMemoryHandler({ mastra, agentId, threadId, resourceId, networkId, runtimeContext, memoryConfig, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {
|
|
476
|
+
resourceId?: Parameters<MastraMemory['getWorkingMemory']>[0]['resourceId'];
|
|
477
|
+
memoryConfig?: Parameters<MastraMemory['getWorkingMemory']>[0]['memoryConfig'];
|
|
478
|
+
}): Promise<{
|
|
479
|
+
workingMemory: string | null;
|
|
480
|
+
source: string;
|
|
481
|
+
workingMemoryTemplate: WorkingMemoryTemplate | null;
|
|
482
|
+
threadExists: boolean;
|
|
483
|
+
}>;
|
|
484
|
+
|
|
375
485
|
export declare function handleError(error: unknown, defaultMessage: string): never;
|
|
376
486
|
|
|
377
487
|
export declare function handleTaskCancel({ requestId, taskStore, agentId, taskId, logger, }: {
|
|
@@ -466,11 +576,13 @@ export declare class HTTPException extends Error {
|
|
|
466
576
|
* @property res - Optional response object to use.
|
|
467
577
|
* @property message - Optional custom error message.
|
|
468
578
|
* @property cause - Optional cause of the error.
|
|
579
|
+
* @property stack - Optional stack trace for the error.
|
|
469
580
|
*/
|
|
470
581
|
declare type HTTPExceptionOptions = {
|
|
471
582
|
res?: Response;
|
|
472
583
|
message?: string;
|
|
473
584
|
cause?: unknown;
|
|
585
|
+
stack?: string;
|
|
474
586
|
};
|
|
475
587
|
|
|
476
588
|
/**
|
|
@@ -541,6 +653,62 @@ declare type LogsContext = {
|
|
|
541
653
|
};
|
|
542
654
|
};
|
|
543
655
|
|
|
656
|
+
export declare function loopStreamVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
|
|
657
|
+
runtimeContext: RuntimeContext;
|
|
658
|
+
body: {
|
|
659
|
+
message: string;
|
|
660
|
+
threadId?: string;
|
|
661
|
+
resourceId?: string;
|
|
662
|
+
maxIterations?: number;
|
|
663
|
+
};
|
|
664
|
+
}): Promise<{
|
|
665
|
+
stream: ReadableStream_3<StreamEvent>;
|
|
666
|
+
getWorkflowState: () => Promise<WorkflowResult<ZodObject< {
|
|
667
|
+
task: ZodString;
|
|
668
|
+
resourceId: ZodString;
|
|
669
|
+
resourceType: ZodEnum<["agent", "workflow", "none", "tool", "none"]>;
|
|
670
|
+
prompt: ZodString;
|
|
671
|
+
result: ZodString;
|
|
672
|
+
isComplete: ZodOptional<ZodBoolean>;
|
|
673
|
+
completionReason: ZodOptional<ZodString>;
|
|
674
|
+
iteration: ZodNumber;
|
|
675
|
+
}, "strip", ZodTypeAny, {
|
|
676
|
+
prompt: string;
|
|
677
|
+
resourceId: string;
|
|
678
|
+
result: string;
|
|
679
|
+
task: string;
|
|
680
|
+
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
681
|
+
iteration: number;
|
|
682
|
+
isComplete?: boolean | undefined;
|
|
683
|
+
completionReason?: string | undefined;
|
|
684
|
+
}, {
|
|
685
|
+
prompt: string;
|
|
686
|
+
resourceId: string;
|
|
687
|
+
result: string;
|
|
688
|
+
task: string;
|
|
689
|
+
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
690
|
+
iteration: number;
|
|
691
|
+
isComplete?: boolean | undefined;
|
|
692
|
+
completionReason?: string | undefined;
|
|
693
|
+
}>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
|
|
694
|
+
}>;
|
|
695
|
+
|
|
696
|
+
export declare function loopVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
|
|
697
|
+
runtimeContext: RuntimeContext;
|
|
698
|
+
body: {
|
|
699
|
+
message: string;
|
|
700
|
+
};
|
|
701
|
+
}): Promise<{
|
|
702
|
+
status: "success";
|
|
703
|
+
result: {
|
|
704
|
+
text: string;
|
|
705
|
+
iteration: number;
|
|
706
|
+
};
|
|
707
|
+
steps: {
|
|
708
|
+
[x: string]: StepResult<any, any, any, any> | StepResult<unknown, unknown, unknown, unknown>;
|
|
709
|
+
};
|
|
710
|
+
}>;
|
|
711
|
+
|
|
544
712
|
export declare namespace memory {
|
|
545
713
|
export {
|
|
546
714
|
getMemoryStatusHandler,
|
|
@@ -550,7 +718,9 @@ export declare namespace memory {
|
|
|
550
718
|
createThreadHandler,
|
|
551
719
|
updateThreadHandler,
|
|
552
720
|
deleteThreadHandler,
|
|
553
|
-
getMessagesHandler
|
|
721
|
+
getMessagesHandler,
|
|
722
|
+
getWorkingMemoryHandler,
|
|
723
|
+
updateWorkingMemoryHandler
|
|
554
724
|
}
|
|
555
725
|
}
|
|
556
726
|
|
|
@@ -558,6 +728,8 @@ declare interface MemoryContext extends Context {
|
|
|
558
728
|
agentId?: string;
|
|
559
729
|
resourceId?: string;
|
|
560
730
|
threadId?: string;
|
|
731
|
+
networkId?: string;
|
|
732
|
+
runtimeContext?: RuntimeContext_2;
|
|
561
733
|
}
|
|
562
734
|
|
|
563
735
|
export declare namespace network {
|
|
@@ -574,6 +746,11 @@ declare interface NetworkContext extends Context {
|
|
|
574
746
|
runtimeContext: RuntimeContext;
|
|
575
747
|
}
|
|
576
748
|
|
|
749
|
+
declare interface NetworkContext_2 extends Context {
|
|
750
|
+
networkId?: string;
|
|
751
|
+
runtimeContext: RuntimeContext;
|
|
752
|
+
}
|
|
753
|
+
|
|
577
754
|
export declare function normalizeError(error: any, reqId: number | string | null, taskId?: string, logger?: IMastraLogger): JSONRPCResponse<null, unknown>;
|
|
578
755
|
|
|
579
756
|
declare interface QueryRequest {
|
|
@@ -604,7 +781,7 @@ export declare function resumeAsyncWorkflowHandler({ mastra, workflowId, runId,
|
|
|
604
781
|
resumeData?: unknown;
|
|
605
782
|
};
|
|
606
783
|
runtimeContext?: RuntimeContext_2;
|
|
607
|
-
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
784
|
+
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
|
|
608
785
|
|
|
609
786
|
export declare function resumeLegacyWorkflowHandler({ mastra, workflowId, runId, body, runtimeContext, }: WorkflowContext & {
|
|
610
787
|
body: {
|
|
@@ -626,12 +803,19 @@ export declare function resumeWorkflowHandler({ mastra, workflowId, runId, body,
|
|
|
626
803
|
message: string;
|
|
627
804
|
}>;
|
|
628
805
|
|
|
629
|
-
export declare function saveMessagesHandler({ mastra, agentId, body, }: Pick<MemoryContext, 'mastra' | 'agentId'> & {
|
|
806
|
+
export declare function saveMessagesHandler({ mastra, agentId, body, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {
|
|
630
807
|
body: {
|
|
631
808
|
messages: Parameters<MastraMemory['saveMessages']>[0]['messages'];
|
|
632
809
|
};
|
|
633
810
|
}): Promise<MastraMessageV1[]>;
|
|
634
811
|
|
|
812
|
+
export declare function sendWorkflowRunEventHandler({ mastra, workflowId, runId, event, data, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
813
|
+
event: string;
|
|
814
|
+
data: unknown;
|
|
815
|
+
}): Promise<{
|
|
816
|
+
message: string;
|
|
817
|
+
}>;
|
|
818
|
+
|
|
635
819
|
declare type SerializedStep = {
|
|
636
820
|
id: string;
|
|
637
821
|
description: string;
|
|
@@ -651,7 +835,7 @@ export declare function startAsyncLegacyWorkflowHandler({ mastra, runtimeContext
|
|
|
651
835
|
export declare function startAsyncWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
652
836
|
inputData?: unknown;
|
|
653
837
|
runtimeContext?: RuntimeContext_2;
|
|
654
|
-
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
838
|
+
}): Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
|
|
655
839
|
|
|
656
840
|
export declare function startLegacyWorkflowRunHandler({ mastra, runtimeContext, workflowId, runId, triggerData, }: Pick<WorkflowContext, 'mastra' | 'workflowId' | 'runId'> & {
|
|
657
841
|
triggerData?: unknown;
|
|
@@ -690,13 +874,14 @@ export declare function storeTelemetryHandler({ mastra, body }: Context & {
|
|
|
690
874
|
traceCount: number;
|
|
691
875
|
}>;
|
|
692
876
|
|
|
693
|
-
export declare function streamGenerateHandler({ mastra, runtimeContext, agentId, body, }: Context & {
|
|
877
|
+
export declare function streamGenerateHandler({ mastra, runtimeContext, agentId, body, abortSignal, }: Context & {
|
|
694
878
|
runtimeContext: RuntimeContext;
|
|
695
879
|
agentId: string;
|
|
696
880
|
body: GetBody<'stream'> & {
|
|
697
881
|
resourceid?: string;
|
|
698
882
|
runtimeContext?: string;
|
|
699
883
|
};
|
|
884
|
+
abortSignal?: AbortSignal;
|
|
700
885
|
}): Promise<Response | undefined>;
|
|
701
886
|
|
|
702
887
|
export declare function streamGenerateHandler_alias_1({ mastra, networkId, body, runtimeContext, }: NetworkContext & {
|
|
@@ -706,13 +891,61 @@ export declare function streamGenerateHandler_alias_1({ mastra, networkId, body,
|
|
|
706
891
|
} & Parameters<AgentNetwork['stream']>[1];
|
|
707
892
|
}): Promise<Response>;
|
|
708
893
|
|
|
894
|
+
export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
|
|
895
|
+
runtimeContext: RuntimeContext;
|
|
896
|
+
body: {
|
|
897
|
+
message: string;
|
|
898
|
+
threadId?: string;
|
|
899
|
+
resourceId?: string;
|
|
900
|
+
};
|
|
901
|
+
}): Promise<{
|
|
902
|
+
stream: ReadableStream_3<StreamEvent>;
|
|
903
|
+
getWorkflowState: () => Promise<WorkflowResult<ZodObject< {
|
|
904
|
+
task: ZodString;
|
|
905
|
+
resourceId: ZodString;
|
|
906
|
+
resourceType: ZodEnum<["agent", "workflow", "none", "tool", "none"]>;
|
|
907
|
+
prompt: ZodString;
|
|
908
|
+
result: ZodString;
|
|
909
|
+
isComplete: ZodOptional<ZodBoolean>;
|
|
910
|
+
completionReason: ZodOptional<ZodString>;
|
|
911
|
+
iteration: ZodNumber;
|
|
912
|
+
threadId: ZodOptional<ZodString>;
|
|
913
|
+
threadResourceId: ZodOptional<ZodString>;
|
|
914
|
+
isOneOff: ZodBoolean;
|
|
915
|
+
}, "strip", ZodTypeAny, {
|
|
916
|
+
prompt: string;
|
|
917
|
+
resourceId: string;
|
|
918
|
+
result: string;
|
|
919
|
+
task: string;
|
|
920
|
+
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
921
|
+
iteration: number;
|
|
922
|
+
isOneOff: boolean;
|
|
923
|
+
threadId?: string | undefined;
|
|
924
|
+
threadResourceId?: string | undefined;
|
|
925
|
+
isComplete?: boolean | undefined;
|
|
926
|
+
completionReason?: string | undefined;
|
|
927
|
+
}, {
|
|
928
|
+
prompt: string;
|
|
929
|
+
resourceId: string;
|
|
930
|
+
result: string;
|
|
931
|
+
task: string;
|
|
932
|
+
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
933
|
+
iteration: number;
|
|
934
|
+
isOneOff: boolean;
|
|
935
|
+
threadId?: string | undefined;
|
|
936
|
+
threadResourceId?: string | undefined;
|
|
937
|
+
isComplete?: boolean | undefined;
|
|
938
|
+
completionReason?: string | undefined;
|
|
939
|
+
}>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
|
|
940
|
+
}>;
|
|
941
|
+
|
|
709
942
|
export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
|
|
710
943
|
inputData?: unknown;
|
|
711
944
|
runtimeContext?: RuntimeContext_2;
|
|
712
|
-
}): {
|
|
713
|
-
stream:
|
|
714
|
-
getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any>[]>>;
|
|
715
|
-
}
|
|
945
|
+
}): Promise<{
|
|
946
|
+
stream: ReadableStream_2<StreamEvent>;
|
|
947
|
+
getWorkflowState: () => Promise<WorkflowResult<ZodType<any, ZodTypeDef, any>, Step<string, any, any, any, any, any>[]>>;
|
|
948
|
+
}>;
|
|
716
949
|
|
|
717
950
|
declare type SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 226;
|
|
718
951
|
|
|
@@ -780,10 +1013,21 @@ export declare type UnOfficalStatusCode = UnofficialStatusCode;
|
|
|
780
1013
|
*/
|
|
781
1014
|
export declare type UnofficialStatusCode = -1;
|
|
782
1015
|
|
|
783
|
-
export declare function updateThreadHandler({ mastra, agentId, threadId, body, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId'> & {
|
|
1016
|
+
export declare function updateThreadHandler({ mastra, agentId, threadId, body, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {
|
|
784
1017
|
body?: Parameters<MastraMemory['saveThread']>[0]['thread'];
|
|
785
1018
|
}): Promise<StorageThreadType>;
|
|
786
1019
|
|
|
1020
|
+
/**
|
|
1021
|
+
* Handler to update the working memory for a thread (optionally resource-scoped).
|
|
1022
|
+
* @param threadId - the thread id
|
|
1023
|
+
* @param body - the body containing the working memory to update and the resource id (optional)
|
|
1024
|
+
*/
|
|
1025
|
+
export declare function updateWorkingMemoryHandler({ mastra, agentId, threadId, body, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'> & {
|
|
1026
|
+
body: Omit<Parameters<MastraMemory['updateWorkingMemory']>[0], 'threadId'>;
|
|
1027
|
+
}): Promise<{
|
|
1028
|
+
success: boolean;
|
|
1029
|
+
}>;
|
|
1030
|
+
|
|
787
1031
|
declare interface UpsertRequest {
|
|
788
1032
|
indexName: string;
|
|
789
1033
|
vectors: number[][];
|
|
@@ -846,6 +1090,7 @@ export declare namespace workflows {
|
|
|
846
1090
|
getWorkflowsHandler,
|
|
847
1091
|
getWorkflowByIdHandler,
|
|
848
1092
|
getWorkflowRunByIdHandler,
|
|
1093
|
+
getWorkflowRunExecutionResultHandler,
|
|
849
1094
|
createWorkflowRunHandler,
|
|
850
1095
|
startAsyncWorkflowHandler,
|
|
851
1096
|
startWorkflowRunHandler,
|
|
@@ -853,7 +1098,9 @@ export declare namespace workflows {
|
|
|
853
1098
|
streamWorkflowHandler,
|
|
854
1099
|
resumeAsyncWorkflowHandler,
|
|
855
1100
|
resumeWorkflowHandler,
|
|
856
|
-
getWorkflowRunsHandler
|
|
1101
|
+
getWorkflowRunsHandler,
|
|
1102
|
+
cancelWorkflowRunHandler,
|
|
1103
|
+
sendWorkflowRunEventHandler
|
|
857
1104
|
}
|
|
858
1105
|
}
|
|
859
1106
|
|
|
@@ -13,6 +13,7 @@ var HTTPException = class extends Error {
|
|
|
13
13
|
super(options?.message, { cause: options?.cause });
|
|
14
14
|
this.res = options?.res;
|
|
15
15
|
this.status = status;
|
|
16
|
+
this.stack = options?.stack || this.stack;
|
|
16
17
|
}
|
|
17
18
|
/**
|
|
18
19
|
* Returns the response object associated with the exception.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
3
|
+
var chunkCCGRCYWJ_cjs = require('./chunk-CCGRCYWJ.cjs');
|
|
4
|
+
var chunkPZQDCRPV_cjs = require('./chunk-PZQDCRPV.cjs');
|
|
5
|
+
var chunk2KZFMI6P_cjs = require('./chunk-2KZFMI6P.cjs');
|
|
6
6
|
var chunk75ZPJI57_cjs = require('./chunk-75ZPJI57.cjs');
|
|
7
7
|
|
|
8
8
|
// src/server/handlers/network.ts
|
|
@@ -47,7 +47,7 @@ async function getNetworksHandler({
|
|
|
47
47
|
);
|
|
48
48
|
return serializedNetworks;
|
|
49
49
|
} catch (error) {
|
|
50
|
-
return
|
|
50
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error getting networks");
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
async function getNetworkByIdHandler({
|
|
@@ -62,7 +62,7 @@ async function getNetworkByIdHandler({
|
|
|
62
62
|
return network2.formatAgentId(routingAgent2.name) === networkId;
|
|
63
63
|
});
|
|
64
64
|
if (!network) {
|
|
65
|
-
throw new
|
|
65
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
|
|
66
66
|
}
|
|
67
67
|
const routingAgent = network.getRoutingAgent();
|
|
68
68
|
const routingLLM = await routingAgent.getLLM({ runtimeContext });
|
|
@@ -88,7 +88,7 @@ async function getNetworkByIdHandler({
|
|
|
88
88
|
};
|
|
89
89
|
return serializedNetwork;
|
|
90
90
|
} catch (error) {
|
|
91
|
-
return
|
|
91
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error getting network by ID");
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
async function generateHandler({
|
|
@@ -100,14 +100,14 @@ async function generateHandler({
|
|
|
100
100
|
try {
|
|
101
101
|
const network = mastra.getNetwork(networkId);
|
|
102
102
|
if (!network) {
|
|
103
|
-
throw new
|
|
103
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
chunkCCGRCYWJ_cjs.validateBody({ messages: body.messages });
|
|
106
106
|
const { messages, ...rest } = body;
|
|
107
107
|
const result = await network.generate(messages, { ...rest, runtimeContext });
|
|
108
108
|
return result;
|
|
109
109
|
} catch (error) {
|
|
110
|
-
return
|
|
110
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error generating from network");
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
async function streamGenerateHandler({
|
|
@@ -119,9 +119,9 @@ async function streamGenerateHandler({
|
|
|
119
119
|
try {
|
|
120
120
|
const network = mastra.getNetwork(networkId);
|
|
121
121
|
if (!network) {
|
|
122
|
-
throw new
|
|
122
|
+
throw new chunk2KZFMI6P_cjs.HTTPException(404, { message: "Network not found" });
|
|
123
123
|
}
|
|
124
|
-
|
|
124
|
+
chunkCCGRCYWJ_cjs.validateBody({ messages: body.messages });
|
|
125
125
|
const { messages, output, ...rest } = body;
|
|
126
126
|
const streamResult = await network.stream(messages, {
|
|
127
127
|
output,
|
|
@@ -137,7 +137,7 @@ async function streamGenerateHandler({
|
|
|
137
137
|
});
|
|
138
138
|
return streamResponse;
|
|
139
139
|
} catch (error) {
|
|
140
|
-
return
|
|
140
|
+
return chunkPZQDCRPV_cjs.handleError(error, "Error streaming from network");
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
143
|
|