@mastra/server 0.0.0-fix-shareable-traces-20250717112558 → 0.0.0-fix-tool-call-history-20250730195323

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.
Files changed (43) hide show
  1. package/dist/_tsup-dts-rollup.d.cts +169 -16
  2. package/dist/_tsup-dts-rollup.d.ts +169 -16
  3. package/dist/{chunk-MEGCYGBU.js → chunk-36BLNJHS.js} +37 -37
  4. package/dist/chunk-424T5F2J.cjs +157 -0
  5. package/dist/{chunk-B2PAS2IB.cjs → chunk-6KP2OBYA.cjs} +47 -17
  6. package/dist/chunk-6T5JUKOQ.js +149 -0
  7. package/dist/{chunk-LI436ITD.cjs → chunk-HISYIDYH.cjs} +37 -37
  8. package/dist/{chunk-FRVBFMO2.cjs → chunk-HRSAZUIK.cjs} +5 -5
  9. package/dist/{chunk-LZ3VJXSO.cjs → chunk-I5JKUCGE.cjs} +36 -6
  10. package/dist/{chunk-KOHWJYJT.js → chunk-PIAJQ75M.js} +248 -5
  11. package/dist/{chunk-H7DMHBKY.js → chunk-T7HAZC2E.js} +31 -2
  12. package/dist/{chunk-JMLYCXMK.cjs → chunk-UCV4247U.cjs} +7 -7
  13. package/dist/{chunk-3CNDE7QY.cjs → chunk-UEVYOKAH.cjs} +251 -4
  14. package/dist/{chunk-BK4XT6EG.js → chunk-VTTN2FW3.js} +32 -3
  15. package/dist/{chunk-LRCAAFUA.js → chunk-WBRFIHSF.js} +1 -1
  16. package/dist/{chunk-5PQQ42EZ.js → chunk-ZYAFP2AV.js} +1 -1
  17. package/dist/server/handlers/agents.cjs +11 -7
  18. package/dist/server/handlers/agents.d.cts +1 -0
  19. package/dist/server/handlers/agents.d.ts +1 -0
  20. package/dist/server/handlers/agents.js +1 -1
  21. package/dist/server/handlers/legacyWorkflows.cjs +11 -11
  22. package/dist/server/handlers/legacyWorkflows.js +1 -1
  23. package/dist/server/handlers/memory.cjs +27 -11
  24. package/dist/server/handlers/memory.d.cts +4 -0
  25. package/dist/server/handlers/memory.d.ts +4 -0
  26. package/dist/server/handlers/memory.js +1 -1
  27. package/dist/server/handlers/scores.cjs +30 -0
  28. package/dist/server/handlers/scores.d.cts +6 -0
  29. package/dist/server/handlers/scores.d.ts +6 -0
  30. package/dist/server/handlers/scores.js +1 -0
  31. package/dist/server/handlers/tools.cjs +5 -5
  32. package/dist/server/handlers/tools.js +1 -1
  33. package/dist/server/handlers/vNextNetwork.cjs +5 -5
  34. package/dist/server/handlers/vNextNetwork.js +1 -1
  35. package/dist/server/handlers/workflows.cjs +19 -15
  36. package/dist/server/handlers/workflows.d.cts +1 -0
  37. package/dist/server/handlers/workflows.d.ts +1 -0
  38. package/dist/server/handlers/workflows.js +1 -1
  39. package/dist/server/handlers.cjs +18 -13
  40. package/dist/server/handlers.d.cts +3 -2
  41. package/dist/server/handlers.d.ts +3 -2
  42. package/dist/server/handlers.js +6 -5
  43. package/package.json +5 -4
@@ -2,13 +2,13 @@ import type { Agent } from '@mastra/core/agent';
2
2
  import type { AgentCard } from '@mastra/core/a2a';
3
3
  import type { AgentNetwork } from '@mastra/core/network';
4
4
  import type { Artifact } from '@mastra/core/a2a';
5
- import type { BaseLogMessage } from '@mastra/core/logger';
5
+ import { BaseLogMessage } from '@mastra/core/logger';
6
6
  import { CoreMessage } from 'ai';
7
7
  import type { CoreMessage as CoreMessage_2 } from '@mastra/core/llm';
8
8
  import { DefaultEngineType } from '@mastra/core';
9
9
  import { EvalRow } from '@mastra/core';
10
- import { GenerateObjectResult } from 'ai';
11
- import { GenerateTextResult } from 'ai';
10
+ import type { GenerateReturn } from '@mastra/core/llm';
11
+ import { GenerateTextResult } from '@mastra/core';
12
12
  import type { IMastraLogger } from '@mastra/core/logger';
13
13
  import type { JSONRPCError } from '@mastra/core/a2a';
14
14
  import { JSONRPCResponse } from '@mastra/core/a2a';
@@ -21,17 +21,25 @@ import type { Mastra } from '@mastra/core/mastra';
21
21
  import type { MastraError } from '@mastra/core/error';
22
22
  import type { MastraMemory } from '@mastra/core/memory';
23
23
  import { MastraMessageV1 } from '@mastra/core';
24
+ import { MastraMessageV2 } from '@mastra/core';
25
+ import type { MastraScorerEntry } from '@mastra/core/scores';
26
+ import { MastraWorkflowStream } from '@mastra/core';
27
+ import { MemoryConfig } from '@mastra/core';
24
28
  import type { Message } from '@mastra/core/a2a';
29
+ import { PaginationInfo } from '@mastra/core';
25
30
  import type { QueryResult } from '@mastra/core/vector';
26
31
  import { ReadableStream as ReadableStream_2 } from 'node:stream/web';
27
32
  import { ReadableStream as ReadableStream_3 } from 'stream/web';
28
33
  import { RuntimeContext } from '@mastra/core/runtime-context';
29
34
  import type { RuntimeContext as RuntimeContext_2 } from '@mastra/core/di';
35
+ import type { ScoreRowData } from '@mastra/core/scores';
30
36
  import type { SerializedStepFlowEntry } from '@mastra/core/workflows';
31
37
  import { Step } from '@mastra/core';
32
38
  import { StepExecutionContext } from '@mastra/core/workflows/legacy';
33
39
  import { StepGraph } from '@mastra/core/workflows/legacy';
34
40
  import { StepResult } from '@mastra/core';
41
+ import type { StorageGetMessagesArg } from '@mastra/core';
42
+ import type { StoragePagination } from '@mastra/core/storage';
35
43
  import { StorageThreadType } from '@mastra/core';
36
44
  import { StreamEvent } from '@mastra/core';
37
45
  import { Task } from '@mastra/core/a2a';
@@ -41,8 +49,10 @@ import type { TaskIdParams } from '@mastra/core/a2a';
41
49
  import type { TaskQueryParams } from '@mastra/core/a2a';
42
50
  import type { TaskSendParams } from '@mastra/core/a2a';
43
51
  import type { TaskStatus } from '@mastra/core/a2a';
52
+ import type { ThreadSortOptions } from '@mastra/core/storage';
44
53
  import type { ToolAction } from '@mastra/core/tools';
45
- import { UIMessage } from 'ai';
54
+ import { Trace } from '@mastra/core';
55
+ import { UIMessageWithMetadata } from '@mastra/core/agent';
46
56
  import type { VercelTool } from '@mastra/core/tools';
47
57
  import type { WatchEvent } from '@mastra/core/workflows';
48
58
  import type { Workflow } from '@mastra/core/workflows';
@@ -78,7 +88,8 @@ export declare namespace agents {
78
88
  getEvalsByAgentIdHandler,
79
89
  getLiveEvalsByAgentIdHandler,
80
90
  generateHandler,
81
- streamGenerateHandler
91
+ streamGenerateHandler,
92
+ streamVNextGenerateHandler
82
93
  }
83
94
  }
84
95
 
@@ -144,6 +155,21 @@ export declare function deleteIndex({ mastra, vectorName, indexName, }: Pick<Vec
144
155
  success: boolean;
145
156
  }>;
146
157
 
158
+ /**
159
+ * Handler to delete one or more messages.
160
+ * @param messageIds - Can be a single ID, array of IDs, or objects with ID property
161
+ */
162
+ export declare function deleteMessagesHandler({ mastra, agentId, messageIds, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {
163
+ messageIds: string | string[] | {
164
+ id: string;
165
+ } | {
166
+ id: string;
167
+ }[];
168
+ }): Promise<{
169
+ success: boolean;
170
+ message: string;
171
+ }>;
172
+
147
173
  export declare function deleteThreadHandler({ mastra, agentId, threadId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'>): Promise<{
148
174
  result: string;
149
175
  }>;
@@ -177,14 +203,14 @@ export declare function generateHandler({ mastra, runtimeContext, agentId, body,
177
203
  runtimeContext?: Record<string, unknown>;
178
204
  };
179
205
  abortSignal?: AbortSignal;
180
- }): Promise<GenerateTextResult<any, unknown>>;
206
+ }): Promise<GenerateTextResult<any, undefined>>;
181
207
 
182
208
  export declare function generateHandler_alias_1({ mastra, runtimeContext, networkId, body, }: NetworkContext & {
183
209
  runtimeContext: RuntimeContext;
184
210
  body: {
185
211
  messages?: Parameters<AgentNetwork['generate']>[0];
186
212
  } & Parameters<AgentNetwork['generate']>[1];
187
- }): Promise<GenerateObjectResult<any>>;
213
+ }): Promise<GenerateReturn<any, any, any>>;
188
214
 
189
215
  /**
190
216
  * Generate speech from text
@@ -335,6 +361,10 @@ export declare function getLogTransports({ mastra }: Pick<LogsContext, 'mastra'>
335
361
  transports: string[];
336
362
  }>;
337
363
 
364
+ export declare function getMemoryConfigHandler({ mastra, agentId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'>): Promise<{
365
+ config: MemoryConfig;
366
+ }>;
367
+
338
368
  export declare function getMemoryStatusHandler({ mastra, agentId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'>): Promise<{
339
369
  result: boolean;
340
370
  }>;
@@ -343,7 +373,11 @@ export declare function getMessagesHandler({ mastra, agentId, threadId, limit, n
343
373
  limit?: number;
344
374
  }): Promise<{
345
375
  messages: CoreMessage[];
346
- uiMessages: UIMessage[];
376
+ uiMessages: UIMessageWithMetadata[];
377
+ }>;
378
+
379
+ export declare function getMessagesPaginatedHandler({ mastra, threadId, resourceId, selectBy, format, }: StorageGetMessagesArg & Pick<MemoryContext, 'mastra'>): Promise<PaginationInfo & {
380
+ messages: MastraMessageV1[] | MastraMessageV2[];
347
381
  }>;
348
382
 
349
383
  export declare function getNetworkByIdHandler({ mastra, networkId, runtimeContext, }: Pick<NetworkContext, 'mastra' | 'networkId' | 'runtimeContext'>): Promise<{
@@ -376,6 +410,50 @@ export declare function getNetworksHandler({ mastra, runtimeContext, }: Pick<Net
376
410
  };
377
411
  }[]>;
378
412
 
413
+ export declare function getScorerHandler({ mastra, scorerId, runtimeContext, }: Context & {
414
+ scorerId: string;
415
+ runtimeContext: RuntimeContext;
416
+ }): Promise<(MastraScorerEntry & {
417
+ agentIds: string[];
418
+ workflowIds: string[];
419
+ }) | null>;
420
+
421
+ export declare function getScorersHandler({ mastra, runtimeContext }: Context & {
422
+ runtimeContext: RuntimeContext;
423
+ }): Promise<{
424
+ [k: string]: MastraScorerEntry & {
425
+ agentIds: string[];
426
+ workflowIds: string[];
427
+ };
428
+ }>;
429
+
430
+ export declare function getScoresByEntityIdHandler({ mastra, entityId, entityType, pagination, }: Context & {
431
+ entityId: string;
432
+ entityType: string;
433
+ pagination: StoragePagination;
434
+ }): Promise<never[] | {
435
+ pagination: PaginationInfo;
436
+ scores: ScoreRowData[];
437
+ }>;
438
+
439
+ export declare function getScoresByRunIdHandler({ mastra, runId, pagination, }: Context & {
440
+ runId: string;
441
+ pagination: StoragePagination;
442
+ }): Promise<never[] | {
443
+ pagination: PaginationInfo;
444
+ scores: ScoreRowData[];
445
+ }>;
446
+
447
+ export declare function getScoresByScorerIdHandler({ mastra, scorerId, pagination, entityId, entityType, }: Context & {
448
+ scorerId: string;
449
+ pagination: StoragePagination;
450
+ entityId?: string;
451
+ entityType?: string;
452
+ }): Promise<never[] | {
453
+ pagination: PaginationInfo;
454
+ scores: ScoreRowData[];
455
+ }>;
456
+
379
457
  /**
380
458
  * Get available speakers for an agent
381
459
  */
@@ -383,11 +461,11 @@ export declare function getSpeakersHandler({ mastra, agentId }: VoiceContext): P
383
461
  voiceId: string;
384
462
  }[]>;
385
463
 
386
- export declare function getTelemetryHandler({ mastra, body }: TelemetryContext): Promise<any[]>;
464
+ export declare function getTelemetryHandler({ mastra, body }: TelemetryContext): Promise<Trace[]>;
387
465
 
388
466
  export declare function getThreadByIdHandler({ mastra, agentId, threadId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'threadId' | 'networkId' | 'runtimeContext'>): Promise<StorageThreadType>;
389
467
 
390
- export declare function getThreadsHandler({ mastra, agentId, resourceId, networkId, runtimeContext, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'resourceId' | 'networkId' | 'runtimeContext'>): Promise<StorageThreadType[]>;
468
+ export declare function getThreadsHandler({ mastra, agentId, resourceId, networkId, runtimeContext, orderBy, sortDirection, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'resourceId' | 'networkId' | 'runtimeContext'> & ThreadSortOptions): Promise<StorageThreadType[]>;
391
469
 
392
470
  export declare function getToolByIdHandler({ tools, toolId }: Pick<ToolsContext, 'tools' | 'toolId'>): Promise<any>;
393
471
 
@@ -673,18 +751,18 @@ export declare function loopStreamVNextNetworkHandler({ mastra, networkId, body,
673
751
  completionReason: ZodOptional<ZodString>;
674
752
  iteration: ZodNumber;
675
753
  }, "strip", ZodTypeAny, {
676
- prompt: string;
677
754
  resourceId: string;
678
755
  result: string;
756
+ prompt: string;
679
757
  task: string;
680
758
  resourceType: "none" | "tool" | "workflow" | "agent";
681
759
  iteration: number;
682
760
  isComplete?: boolean | undefined;
683
761
  completionReason?: string | undefined;
684
762
  }, {
685
- prompt: string;
686
763
  resourceId: string;
687
764
  result: string;
765
+ prompt: string;
688
766
  task: string;
689
767
  resourceType: "none" | "tool" | "workflow" | "agent";
690
768
  iteration: number;
@@ -701,8 +779,17 @@ export declare function loopVNextNetworkHandler({ mastra, networkId, body, runti
701
779
  }): Promise<{
702
780
  status: "success";
703
781
  result: {
704
- text: string;
782
+ resourceId: string;
783
+ result: string;
784
+ prompt: string;
785
+ task: string;
786
+ resourceType: "none" | "tool" | "workflow" | "agent";
705
787
  iteration: number;
788
+ isOneOff: boolean;
789
+ threadId?: string | undefined;
790
+ threadResourceId?: string | undefined;
791
+ isComplete?: boolean | undefined;
792
+ completionReason?: string | undefined;
706
793
  };
707
794
  steps: {
708
795
  [x: string]: StepResult<any, any, any, any> | StepResult<unknown, unknown, unknown, unknown>;
@@ -712,15 +799,19 @@ export declare function loopVNextNetworkHandler({ mastra, networkId, body, runti
712
799
  export declare namespace memory {
713
800
  export {
714
801
  getMemoryStatusHandler,
802
+ getMemoryConfigHandler,
715
803
  getThreadsHandler,
716
804
  getThreadByIdHandler,
717
805
  saveMessagesHandler,
718
806
  createThreadHandler,
719
807
  updateThreadHandler,
720
808
  deleteThreadHandler,
809
+ getMessagesPaginatedHandler,
721
810
  getMessagesHandler,
722
811
  getWorkingMemoryHandler,
723
- updateWorkingMemoryHandler
812
+ updateWorkingMemoryHandler,
813
+ deleteMessagesHandler,
814
+ searchMemoryHandler
724
815
  }
725
816
  }
726
817
 
@@ -809,6 +900,53 @@ export declare function saveMessagesHandler({ mastra, agentId, body, networkId,
809
900
  };
810
901
  }): Promise<MastraMessageV1[]>;
811
902
 
903
+ export declare function saveScoreHandler({ mastra, score }: Context & {
904
+ score: ScoreRowData;
905
+ }): Promise<never[] | {
906
+ score: ScoreRowData;
907
+ }>;
908
+
909
+ export declare namespace scores {
910
+ export {
911
+ getScorersHandler,
912
+ getScorerHandler,
913
+ getScoresByRunIdHandler,
914
+ getScoresByScorerIdHandler,
915
+ getScoresByEntityIdHandler,
916
+ saveScoreHandler
917
+ }
918
+ }
919
+
920
+ export declare function searchMemoryHandler({ mastra, agentId, searchQuery, resourceId, threadId, limit, networkId, runtimeContext, memoryConfig, }: Pick<MemoryContext, 'mastra' | 'agentId' | 'networkId' | 'runtimeContext'> & {
921
+ searchQuery: string;
922
+ resourceId: string;
923
+ threadId?: string;
924
+ limit?: number;
925
+ memoryConfig?: any;
926
+ }): Promise<SearchResponse | ReturnType<typeof handleError>>;
927
+
928
+ declare interface SearchResponse {
929
+ results: SearchResult[];
930
+ count: number;
931
+ query: string;
932
+ searchScope?: string;
933
+ searchType?: string;
934
+ }
935
+
936
+ declare interface SearchResult {
937
+ id: string;
938
+ role: string;
939
+ content: any;
940
+ createdAt: Date;
941
+ threadId?: string;
942
+ threadTitle?: string;
943
+ score?: number;
944
+ context?: {
945
+ before?: SearchResult[];
946
+ after?: SearchResult[];
947
+ };
948
+ }
949
+
812
950
  export declare function sendWorkflowRunEventHandler({ mastra, workflowId, runId, event, data, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
813
951
  event: string;
814
952
  data: unknown;
@@ -913,9 +1051,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
913
1051
  threadResourceId: ZodOptional<ZodString>;
914
1052
  isOneOff: ZodBoolean;
915
1053
  }, "strip", ZodTypeAny, {
916
- prompt: string;
917
1054
  resourceId: string;
918
1055
  result: string;
1056
+ prompt: string;
919
1057
  task: string;
920
1058
  resourceType: "none" | "tool" | "workflow" | "agent";
921
1059
  iteration: number;
@@ -925,9 +1063,9 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
925
1063
  isComplete?: boolean | undefined;
926
1064
  completionReason?: string | undefined;
927
1065
  }, {
928
- prompt: string;
929
1066
  resourceId: string;
930
1067
  result: string;
1068
+ prompt: string;
931
1069
  task: string;
932
1070
  resourceType: "none" | "tool" | "workflow" | "agent";
933
1071
  iteration: number;
@@ -939,6 +1077,20 @@ export declare function streamGenerateVNextNetworkHandler({ mastra, networkId, b
939
1077
  }>, Step<string, any, any, any, any, DefaultEngineType>[]>>;
940
1078
  }>;
941
1079
 
1080
+ export declare function streamVNextGenerateHandler({ mastra, runtimeContext, agentId, body, abortSignal, }: Context & {
1081
+ runtimeContext: RuntimeContext;
1082
+ agentId: string;
1083
+ body: GetBody<'streamVNext'> & {
1084
+ runtimeContext?: string;
1085
+ };
1086
+ abortSignal?: AbortSignal;
1087
+ }): ReturnType<Agent['streamVNext']>;
1088
+
1089
+ export declare function streamVNextWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
1090
+ inputData?: unknown;
1091
+ runtimeContext?: RuntimeContext_2;
1092
+ }): Promise<MastraWorkflowStream>;
1093
+
942
1094
  export declare function streamWorkflowHandler({ mastra, runtimeContext, workflowId, runId, inputData, }: Pick<WorkflowContext_3, 'mastra' | 'workflowId' | 'runId'> & {
943
1095
  inputData?: unknown;
944
1096
  runtimeContext?: RuntimeContext_2;
@@ -1096,6 +1248,7 @@ export declare namespace workflows {
1096
1248
  startWorkflowRunHandler,
1097
1249
  watchWorkflowHandler,
1098
1250
  streamWorkflowHandler,
1251
+ streamVNextWorkflowHandler,
1099
1252
  resumeAsyncWorkflowHandler,
1100
1253
  resumeWorkflowHandler,
1101
1254
  getWorkflowRunsHandler,