@mastra/server 0.0.0-fix-fetch-workflow-runs-20250624231457 → 0.0.0-fix-traces-pagination-plus-share-for-cloud-20250717083008
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 +115 -12
- package/dist/_tsup-dts-rollup.d.ts +115 -12
- package/dist/{chunk-OCWPVYNI.cjs → chunk-2KZFMI6P.cjs} +1 -0
- package/dist/{chunk-VPNDC2DI.cjs → chunk-2SLFAFTR.cjs} +12 -12
- package/dist/{chunk-RQ2Z56EC.cjs → chunk-3CNDE7QY.cjs} +92 -35
- package/dist/{chunk-QLG2PFHE.js → chunk-4D66QEKC.js} +2 -2
- package/dist/{chunk-N2YBMSO2.js → chunk-5PQQ42EZ.js} +8 -8
- package/dist/{chunk-BNEY4P4P.cjs → chunk-7TP2LX5L.cjs} +16 -16
- package/dist/{chunk-TO5U6HW3.cjs → chunk-B2PAS2IB.cjs} +147 -68
- package/dist/{chunk-PMUATKV2.js → chunk-BK4XT6EG.js} +5 -5
- package/dist/{chunk-57CJTIPW.cjs → chunk-CCGRCYWJ.cjs} +2 -2
- package/dist/{chunk-C7564HUT.js → chunk-CRCR3ZUK.js} +3 -3
- package/dist/{chunk-CPPYMJX5.cjs → chunk-FRVBFMO2.cjs} +20 -20
- package/dist/{chunk-B4MQFJ7G.cjs → chunk-G7KH752Y.cjs} +5 -5
- package/dist/{chunk-SOBBILUG.js → chunk-H7DMHBKY.js} +89 -12
- package/dist/{chunk-4DTDPTQC.cjs → chunk-JMLYCXMK.cjs} +43 -43
- package/dist/{chunk-R5VGYBV6.js → chunk-KHZKYUNR.js} +3 -3
- package/dist/{chunk-XUIJ7WRT.js → chunk-KOHWJYJT.js} +60 -5
- package/dist/{chunk-NYN7KFXL.js → chunk-LCM566I4.js} +1 -0
- package/dist/chunk-LF7P5PLR.js +14 -0
- package/dist/{chunk-MN6F4D5A.cjs → chunk-LI436ITD.cjs} +107 -69
- package/dist/{chunk-XR7VJOOP.js → chunk-LRCAAFUA.js} +4 -4
- package/dist/{chunk-GKM45O24.cjs → chunk-LZ3VJXSO.cjs} +19 -19
- package/dist/{chunk-OSZM4EAY.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-WJY57THV.cjs → chunk-RHSWAXKB.cjs} +22 -22
- 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 +63 -20
- package/dist/server/handlers/vNextNetwork.d.cts +1 -0
- package/dist/server/handlers/vNextNetwork.d.ts +1 -0
- package/dist/server/handlers/vNextNetwork.js +47 -5
- 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 +21 -13
- package/dist/server/handlers/workflows.d.cts +2 -0
- package/dist/server/handlers/workflows.d.ts +2 -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 +7 -7
- package/dist/chunk-64U3UDTH.cjs +0 -13
- package/dist/chunk-M5ABIP7D.js +0 -11
package/LICENSE.md
CHANGED
|
@@ -1,46 +1,15 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Apache License 2.0
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2025
|
|
3
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
you may not use this file except in compliance with the License.
|
|
7
|
+
You may obtain a copy of the License at
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
|
|
9
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
17
|
-
|
|
18
|
-
**Patents**
|
|
19
|
-
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
20
|
-
|
|
21
|
-
**Notices**
|
|
22
|
-
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
|
|
23
|
-
|
|
24
|
-
If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
|
|
25
|
-
|
|
26
|
-
**No Other Rights**
|
|
27
|
-
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
28
|
-
|
|
29
|
-
**Termination**
|
|
30
|
-
If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
|
|
31
|
-
|
|
32
|
-
**No Liability**
|
|
33
|
-
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
|
|
34
|
-
|
|
35
|
-
**Definitions**
|
|
36
|
-
The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
|
|
37
|
-
|
|
38
|
-
_you_ refers to the individual or entity agreeing to these terms.
|
|
39
|
-
|
|
40
|
-
_your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
41
|
-
|
|
42
|
-
_your licenses_ are all the licenses granted to you for the software under these terms.
|
|
43
|
-
|
|
44
|
-
_use_ means anything you do with the software requiring one of your licenses.
|
|
45
|
-
|
|
46
|
-
_trademark_ means trademarks, service marks, and similar rights.
|
|
11
|
+
Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
See the License for the specific language governing permissions and
|
|
15
|
+
limitations under the License.
|
|
@@ -5,8 +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 { DefaultEngineType } from '@mastra/core
|
|
9
|
-
import { EvalRow } from '@mastra/core
|
|
8
|
+
import { DefaultEngineType } from '@mastra/core';
|
|
9
|
+
import { EvalRow } from '@mastra/core';
|
|
10
10
|
import { GenerateObjectResult } from 'ai';
|
|
11
11
|
import { GenerateTextResult } from 'ai';
|
|
12
12
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
@@ -18,8 +18,9 @@ import { LegacyWorkflowRunResult } from '@mastra/core/workflows/legacy';
|
|
|
18
18
|
import type { LegacyWorkflowRuns } from '@mastra/core/storage';
|
|
19
19
|
import type { LogLevel } from '@mastra/core/logger';
|
|
20
20
|
import type { Mastra } from '@mastra/core/mastra';
|
|
21
|
+
import type { MastraError } from '@mastra/core/error';
|
|
21
22
|
import type { MastraMemory } from '@mastra/core/memory';
|
|
22
|
-
import { MastraMessageV1 } from '@mastra/core
|
|
23
|
+
import { MastraMessageV1 } from '@mastra/core';
|
|
23
24
|
import type { Message } from '@mastra/core/a2a';
|
|
24
25
|
import type { QueryResult } from '@mastra/core/vector';
|
|
25
26
|
import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
|
|
@@ -27,12 +28,12 @@ import { ReadableStream as ReadableStream_3 } from 'stream/web';
|
|
|
27
28
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
28
29
|
import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
|
|
29
30
|
import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
|
|
30
|
-
import { Step } from '@mastra/core
|
|
31
|
+
import { Step } from '@mastra/core';
|
|
31
32
|
import { StepExecutionContext } from '@mastra/core/workflows/legacy';
|
|
32
33
|
import { StepGraph } from '@mastra/core/workflows/legacy';
|
|
33
|
-
import { StepResult } from '@mastra/core
|
|
34
|
-
import { StorageThreadType } from '@mastra/core
|
|
35
|
-
import { StreamEvent } from '@mastra/core
|
|
34
|
+
import { StepResult } from '@mastra/core';
|
|
35
|
+
import { StorageThreadType } from '@mastra/core';
|
|
36
|
+
import { StreamEvent } from '@mastra/core';
|
|
36
37
|
import { Task } from '@mastra/core/a2a';
|
|
37
38
|
import { TaskAndHistory } from '@mastra/core/a2a';
|
|
38
39
|
import type { TaskContext } from '@mastra/core/a2a';
|
|
@@ -46,8 +47,9 @@ import type { VercelTool } from '@mastra/core/tools';
|
|
|
46
47
|
import type { WatchEvent } from '@mastra/core/workflows';
|
|
47
48
|
import type { Workflow } from '@mastra/core/workflows';
|
|
48
49
|
import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows/legacy';
|
|
49
|
-
import { WorkflowResult } from '@mastra/core
|
|
50
|
+
import { WorkflowResult } from '@mastra/core';
|
|
50
51
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
52
|
+
import { WorkingMemoryTemplate } from '@mastra/core';
|
|
51
53
|
import { ZodBoolean } from 'zod';
|
|
52
54
|
import { ZodEnum } from 'zod';
|
|
53
55
|
import { ZodNumber } from 'zod';
|
|
@@ -80,13 +82,17 @@ export declare namespace agents {
|
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
export declare interface ApiError extends
|
|
85
|
+
export declare interface ApiError extends MastraError {
|
|
84
86
|
message: string;
|
|
85
87
|
status?: number;
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
export declare function applyUpdateToTaskAndHistory(current: TaskAndHistory, update: Omit<TaskStatus, 'timestamp'> | Artifact): TaskAndHistory;
|
|
89
91
|
|
|
92
|
+
export declare function cancelWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<{
|
|
93
|
+
message: string;
|
|
94
|
+
}>;
|
|
95
|
+
|
|
90
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;
|
|
91
97
|
|
|
92
98
|
export declare interface Context {
|
|
@@ -402,6 +408,10 @@ export declare function getVNextNetworkByIdHandler({ mastra, networkId, runtimeC
|
|
|
402
408
|
inputSchema: string | undefined;
|
|
403
409
|
outputSchema: string | undefined;
|
|
404
410
|
}[];
|
|
411
|
+
tools: {
|
|
412
|
+
id: string;
|
|
413
|
+
description: string;
|
|
414
|
+
}[];
|
|
405
415
|
routingModel: {
|
|
406
416
|
provider: string;
|
|
407
417
|
modelId: string;
|
|
@@ -412,6 +422,10 @@ export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pic
|
|
|
412
422
|
id: string;
|
|
413
423
|
name: string;
|
|
414
424
|
instructions: string;
|
|
425
|
+
tools: {
|
|
426
|
+
id: string;
|
|
427
|
+
description: string;
|
|
428
|
+
}[];
|
|
415
429
|
agents: {
|
|
416
430
|
name: string;
|
|
417
431
|
provider: string;
|
|
@@ -430,7 +444,8 @@ export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pic
|
|
|
430
444
|
}[]>;
|
|
431
445
|
|
|
432
446
|
export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext_3): Promise<{
|
|
433
|
-
steps: SerializedStep
|
|
447
|
+
steps: Record<string, SerializedStep>;
|
|
448
|
+
allSteps: Record<string, SerializedStep>;
|
|
434
449
|
name: string | undefined;
|
|
435
450
|
description: string | undefined;
|
|
436
451
|
stepGraph: SerializedStepFlowEntry[];
|
|
@@ -452,6 +467,21 @@ export declare function getWorkflowRunsHandler({ mastra, workflowId, fromDate, t
|
|
|
452
467
|
|
|
453
468
|
export declare function getWorkflowsHandler({ mastra }: WorkflowContext_3): Promise<any>;
|
|
454
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
|
+
|
|
455
485
|
export declare function handleError(error: unknown, defaultMessage: string): never;
|
|
456
486
|
|
|
457
487
|
export declare function handleTaskCancel({ requestId, taskStore, agentId, taskId, logger, }: {
|
|
@@ -546,11 +576,13 @@ export declare class HTTPException extends Error {
|
|
|
546
576
|
* @property res - Optional response object to use.
|
|
547
577
|
* @property message - Optional custom error message.
|
|
548
578
|
* @property cause - Optional cause of the error.
|
|
579
|
+
* @property stack - Optional stack trace for the error.
|
|
549
580
|
*/
|
|
550
581
|
declare type HTTPExceptionOptions = {
|
|
551
582
|
res?: Response;
|
|
552
583
|
message?: string;
|
|
553
584
|
cause?: unknown;
|
|
585
|
+
stack?: string;
|
|
554
586
|
};
|
|
555
587
|
|
|
556
588
|
/**
|
|
@@ -621,6 +653,46 @@ declare type LogsContext = {
|
|
|
621
653
|
};
|
|
622
654
|
};
|
|
623
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
|
+
|
|
624
696
|
export declare function loopVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
|
|
625
697
|
runtimeContext: RuntimeContext;
|
|
626
698
|
body: {
|
|
@@ -646,7 +718,9 @@ export declare namespace memory {
|
|
|
646
718
|
createThreadHandler,
|
|
647
719
|
updateThreadHandler,
|
|
648
720
|
deleteThreadHandler,
|
|
649
|
-
getMessagesHandler
|
|
721
|
+
getMessagesHandler,
|
|
722
|
+
getWorkingMemoryHandler,
|
|
723
|
+
updateWorkingMemoryHandler
|
|
650
724
|
}
|
|
651
725
|
}
|
|
652
726
|
|
|
@@ -735,6 +809,13 @@ export declare function saveMessagesHandler({ mastra, agentId, body, networkId,
|
|
|
735
809
|
};
|
|
736
810
|
}): Promise<MastraMessageV1[]>;
|
|
737
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
|
+
|
|
738
819
|
declare type SerializedStep = {
|
|
739
820
|
id: string;
|
|
740
821
|
description: string;
|
|
@@ -828,6 +909,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
|
|
|
828
909
|
isComplete: ZodOptional<ZodBoolean>;
|
|
829
910
|
completionReason: ZodOptional<ZodString>;
|
|
830
911
|
iteration: ZodNumber;
|
|
912
|
+
threadId: ZodOptional<ZodString>;
|
|
913
|
+
threadResourceId: ZodOptional<ZodString>;
|
|
914
|
+
isOneOff: ZodBoolean;
|
|
831
915
|
}, "strip", ZodTypeAny, {
|
|
832
916
|
prompt: string;
|
|
833
917
|
resourceId: string;
|
|
@@ -835,6 +919,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
|
|
|
835
919
|
task: string;
|
|
836
920
|
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
837
921
|
iteration: number;
|
|
922
|
+
isOneOff: boolean;
|
|
923
|
+
threadId?: string | undefined;
|
|
924
|
+
threadResourceId?: string | undefined;
|
|
838
925
|
isComplete?: boolean | undefined;
|
|
839
926
|
completionReason?: string | undefined;
|
|
840
927
|
}, {
|
|
@@ -844,6 +931,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
|
|
|
844
931
|
task: string;
|
|
845
932
|
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
846
933
|
iteration: number;
|
|
934
|
+
isOneOff: boolean;
|
|
935
|
+
threadId?: string | undefined;
|
|
936
|
+
threadResourceId?: string | undefined;
|
|
847
937
|
isComplete?: boolean | undefined;
|
|
848
938
|
completionReason?: string | undefined;
|
|
849
939
|
}>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
|
|
@@ -927,6 +1017,17 @@ export declare function updateThreadHandler({ mastra, agentId, threadId, body, n
|
|
|
927
1017
|
body?: Parameters<MastraMemory['saveThread']>[0]['thread'];
|
|
928
1018
|
}): Promise<StorageThreadType>;
|
|
929
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
|
+
|
|
930
1031
|
declare interface UpsertRequest {
|
|
931
1032
|
indexName: string;
|
|
932
1033
|
vectors: number[][];
|
|
@@ -997,7 +1098,9 @@ export declare namespace workflows {
|
|
|
997
1098
|
streamWorkflowHandler,
|
|
998
1099
|
resumeAsyncWorkflowHandler,
|
|
999
1100
|
resumeWorkflowHandler,
|
|
1000
|
-
getWorkflowRunsHandler
|
|
1101
|
+
getWorkflowRunsHandler,
|
|
1102
|
+
cancelWorkflowRunHandler,
|
|
1103
|
+
sendWorkflowRunEventHandler
|
|
1001
1104
|
}
|
|
1002
1105
|
}
|
|
1003
1106
|
|
|
@@ -5,8 +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 { DefaultEngineType } from '@mastra/core
|
|
9
|
-
import { EvalRow } from '@mastra/core
|
|
8
|
+
import { DefaultEngineType } from '@mastra/core';
|
|
9
|
+
import { EvalRow } from '@mastra/core';
|
|
10
10
|
import { GenerateObjectResult } from 'ai';
|
|
11
11
|
import { GenerateTextResult } from 'ai';
|
|
12
12
|
import type { IMastraLogger } from '@mastra/core/logger';
|
|
@@ -18,8 +18,9 @@ import { LegacyWorkflowRunResult } from '@mastra/core/workflows/legacy';
|
|
|
18
18
|
import type { LegacyWorkflowRuns } from '@mastra/core/storage';
|
|
19
19
|
import type { LogLevel } from '@mastra/core/logger';
|
|
20
20
|
import type { Mastra } from '@mastra/core/mastra';
|
|
21
|
+
import type { MastraError } from '@mastra/core/error';
|
|
21
22
|
import type { MastraMemory } from '@mastra/core/memory';
|
|
22
|
-
import { MastraMessageV1 } from '@mastra/core
|
|
23
|
+
import { MastraMessageV1 } from '@mastra/core';
|
|
23
24
|
import type { Message } from '@mastra/core/a2a';
|
|
24
25
|
import type { QueryResult } from '@mastra/core/vector';
|
|
25
26
|
import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
|
|
@@ -27,12 +28,12 @@ import { ReadableStream as ReadableStream_3 } from 'stream/web';
|
|
|
27
28
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
28
29
|
import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
|
|
29
30
|
import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
|
|
30
|
-
import { Step } from '@mastra/core
|
|
31
|
+
import { Step } from '@mastra/core';
|
|
31
32
|
import { StepExecutionContext } from '@mastra/core/workflows/legacy';
|
|
32
33
|
import { StepGraph } from '@mastra/core/workflows/legacy';
|
|
33
|
-
import { StepResult } from '@mastra/core
|
|
34
|
-
import { StorageThreadType } from '@mastra/core
|
|
35
|
-
import { StreamEvent } from '@mastra/core
|
|
34
|
+
import { StepResult } from '@mastra/core';
|
|
35
|
+
import { StorageThreadType } from '@mastra/core';
|
|
36
|
+
import { StreamEvent } from '@mastra/core';
|
|
36
37
|
import { Task } from '@mastra/core/a2a';
|
|
37
38
|
import { TaskAndHistory } from '@mastra/core/a2a';
|
|
38
39
|
import type { TaskContext } from '@mastra/core/a2a';
|
|
@@ -46,8 +47,9 @@ import type { VercelTool } from '@mastra/core/tools';
|
|
|
46
47
|
import type { WatchEvent } from '@mastra/core/workflows';
|
|
47
48
|
import type { Workflow } from '@mastra/core/workflows';
|
|
48
49
|
import { WorkflowContext as WorkflowContext_2 } from '@mastra/core/workflows/legacy';
|
|
49
|
-
import { WorkflowResult } from '@mastra/core
|
|
50
|
+
import { WorkflowResult } from '@mastra/core';
|
|
50
51
|
import type { WorkflowRuns } from '@mastra/core/storage';
|
|
52
|
+
import { WorkingMemoryTemplate } from '@mastra/core';
|
|
51
53
|
import { ZodBoolean } from 'zod';
|
|
52
54
|
import { ZodEnum } from 'zod';
|
|
53
55
|
import { ZodNumber } from 'zod';
|
|
@@ -80,13 +82,17 @@ export declare namespace agents {
|
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
export declare interface ApiError extends
|
|
85
|
+
export declare interface ApiError extends MastraError {
|
|
84
86
|
message: string;
|
|
85
87
|
status?: number;
|
|
86
88
|
}
|
|
87
89
|
|
|
88
90
|
export declare function applyUpdateToTaskAndHistory(current: TaskAndHistory, update: Omit<TaskStatus, 'timestamp'> | Artifact): TaskAndHistory;
|
|
89
91
|
|
|
92
|
+
export declare function cancelWorkflowRunHandler({ mastra, workflowId, runId, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'>): Promise<{
|
|
93
|
+
message: string;
|
|
94
|
+
}>;
|
|
95
|
+
|
|
90
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;
|
|
91
97
|
|
|
92
98
|
export declare interface Context {
|
|
@@ -402,6 +408,10 @@ export declare function getVNextNetworkByIdHandler({ mastra, networkId, runtimeC
|
|
|
402
408
|
inputSchema: string | undefined;
|
|
403
409
|
outputSchema: string | undefined;
|
|
404
410
|
}[];
|
|
411
|
+
tools: {
|
|
412
|
+
id: string;
|
|
413
|
+
description: string;
|
|
414
|
+
}[];
|
|
405
415
|
routingModel: {
|
|
406
416
|
provider: string;
|
|
407
417
|
modelId: string;
|
|
@@ -412,6 +422,10 @@ export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pic
|
|
|
412
422
|
id: string;
|
|
413
423
|
name: string;
|
|
414
424
|
instructions: string;
|
|
425
|
+
tools: {
|
|
426
|
+
id: string;
|
|
427
|
+
description: string;
|
|
428
|
+
}[];
|
|
415
429
|
agents: {
|
|
416
430
|
name: string;
|
|
417
431
|
provider: string;
|
|
@@ -430,7 +444,8 @@ export declare function getVNextNetworksHandler({ mastra, runtimeContext, }: Pic
|
|
|
430
444
|
}[]>;
|
|
431
445
|
|
|
432
446
|
export declare function getWorkflowByIdHandler({ mastra, workflowId }: WorkflowContext_3): Promise<{
|
|
433
|
-
steps: SerializedStep
|
|
447
|
+
steps: Record<string, SerializedStep>;
|
|
448
|
+
allSteps: Record<string, SerializedStep>;
|
|
434
449
|
name: string | undefined;
|
|
435
450
|
description: string | undefined;
|
|
436
451
|
stepGraph: SerializedStepFlowEntry[];
|
|
@@ -452,6 +467,21 @@ export declare function getWorkflowRunsHandler({ mastra, workflowId, fromDate, t
|
|
|
452
467
|
|
|
453
468
|
export declare function getWorkflowsHandler({ mastra }: WorkflowContext_3): Promise<any>;
|
|
454
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
|
+
|
|
455
485
|
export declare function handleError(error: unknown, defaultMessage: string): never;
|
|
456
486
|
|
|
457
487
|
export declare function handleTaskCancel({ requestId, taskStore, agentId, taskId, logger, }: {
|
|
@@ -546,11 +576,13 @@ export declare class HTTPException extends Error {
|
|
|
546
576
|
* @property res - Optional response object to use.
|
|
547
577
|
* @property message - Optional custom error message.
|
|
548
578
|
* @property cause - Optional cause of the error.
|
|
579
|
+
* @property stack - Optional stack trace for the error.
|
|
549
580
|
*/
|
|
550
581
|
declare type HTTPExceptionOptions = {
|
|
551
582
|
res?: Response;
|
|
552
583
|
message?: string;
|
|
553
584
|
cause?: unknown;
|
|
585
|
+
stack?: string;
|
|
554
586
|
};
|
|
555
587
|
|
|
556
588
|
/**
|
|
@@ -621,6 +653,46 @@ declare type LogsContext = {
|
|
|
621
653
|
};
|
|
622
654
|
};
|
|
623
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
|
+
|
|
624
696
|
export declare function loopVNextNetworkHandler({ mastra, networkId, body, runtimeContext, }: NetworkContext_2 & {
|
|
625
697
|
runtimeContext: RuntimeContext;
|
|
626
698
|
body: {
|
|
@@ -646,7 +718,9 @@ export declare namespace memory {
|
|
|
646
718
|
createThreadHandler,
|
|
647
719
|
updateThreadHandler,
|
|
648
720
|
deleteThreadHandler,
|
|
649
|
-
getMessagesHandler
|
|
721
|
+
getMessagesHandler,
|
|
722
|
+
getWorkingMemoryHandler,
|
|
723
|
+
updateWorkingMemoryHandler
|
|
650
724
|
}
|
|
651
725
|
}
|
|
652
726
|
|
|
@@ -735,6 +809,13 @@ export declare function saveMessagesHandler({ mastra, agentId, body, networkId,
|
|
|
735
809
|
};
|
|
736
810
|
}): Promise<MastraMessageV1[]>;
|
|
737
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
|
+
|
|
738
819
|
declare type SerializedStep = {
|
|
739
820
|
id: string;
|
|
740
821
|
description: string;
|
|
@@ -828,6 +909,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
|
|
|
828
909
|
isComplete: ZodOptional<ZodBoolean>;
|
|
829
910
|
completionReason: ZodOptional<ZodString>;
|
|
830
911
|
iteration: ZodNumber;
|
|
912
|
+
threadId: ZodOptional<ZodString>;
|
|
913
|
+
threadResourceId: ZodOptional<ZodString>;
|
|
914
|
+
isOneOff: ZodBoolean;
|
|
831
915
|
}, "strip", ZodTypeAny, {
|
|
832
916
|
prompt: string;
|
|
833
917
|
resourceId: string;
|
|
@@ -835,6 +919,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
|
|
|
835
919
|
task: string;
|
|
836
920
|
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
837
921
|
iteration: number;
|
|
922
|
+
isOneOff: boolean;
|
|
923
|
+
threadId?: string | undefined;
|
|
924
|
+
threadResourceId?: string | undefined;
|
|
838
925
|
isComplete?: boolean | undefined;
|
|
839
926
|
completionReason?: string | undefined;
|
|
840
927
|
}, {
|
|
@@ -844,6 +931,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
|
|
|
844
931
|
task: string;
|
|
845
932
|
resourceType: "none" | "tool" | "workflow" | "agent";
|
|
846
933
|
iteration: number;
|
|
934
|
+
isOneOff: boolean;
|
|
935
|
+
threadId?: string | undefined;
|
|
936
|
+
threadResourceId?: string | undefined;
|
|
847
937
|
isComplete?: boolean | undefined;
|
|
848
938
|
completionReason?: string | undefined;
|
|
849
939
|
}>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
|
|
@@ -927,6 +1017,17 @@ export declare function updateThreadHandler({ mastra, agentId, threadId, body, n
|
|
|
927
1017
|
body?: Parameters<MastraMemory['saveThread']>[0]['thread'];
|
|
928
1018
|
}): Promise<StorageThreadType>;
|
|
929
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
|
+
|
|
930
1031
|
declare interface UpsertRequest {
|
|
931
1032
|
indexName: string;
|
|
932
1033
|
vectors: number[][];
|
|
@@ -997,7 +1098,9 @@ export declare namespace workflows {
|
|
|
997
1098
|
streamWorkflowHandler,
|
|
998
1099
|
resumeAsyncWorkflowHandler,
|
|
999
1100
|
resumeWorkflowHandler,
|
|
1000
|
-
getWorkflowRunsHandler
|
|
1101
|
+
getWorkflowRunsHandler,
|
|
1102
|
+
cancelWorkflowRunHandler,
|
|
1103
|
+
sendWorkflowRunEventHandler
|
|
1001
1104
|
}
|
|
1002
1105
|
}
|
|
1003
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
|
|