@mastra/client-js 0.0.0-fix-message-list-merge-20250718043058 → 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.
package/dist/index.d.cts CHANGED
@@ -1,12 +1,15 @@
1
1
  import { AbstractAgent } from '@ag-ui/client';
2
2
  import { ServerInfo, MCPToolType, ServerDetailInfo } from '@mastra/core/mcp';
3
- import { processDataStream, processTextStream } from '@ai-sdk/ui-utils';
4
- import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn } from '@mastra/core';
3
+ import { processDataStream } from '@ai-sdk/ui-utils';
4
+ import { GenerateReturn } from '@mastra/core/llm';
5
5
  import { JSONSchema7 } from 'json-schema';
6
6
  import { ZodSchema } from 'zod';
7
- import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
7
+ import { CoreMessage, AiMessageType, StorageThreadType, StorageGetMessagesArg, PaginationInfo, MastraMessageV1, MastraMessageV2, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn as GenerateReturn$1 } from '@mastra/core';
8
+ import { AgentGenerateOptions, AgentStreamOptions, UIMessageWithMetadata, ToolsInput } from '@mastra/core/agent';
9
+ export { UIMessageWithMetadata } from '@mastra/core/agent';
8
10
  import { LogLevel, BaseLogMessage } from '@mastra/core/logger';
9
11
  import { RuntimeContext } from '@mastra/core/runtime-context';
12
+ import { MastraScorerEntry, ScoreRowData } from '@mastra/core/scores';
10
13
  import { Workflow as Workflow$1, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
11
14
  import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
12
15
  import * as stream_web from 'stream/web';
@@ -48,14 +51,14 @@ interface GetAgentResponse {
48
51
  defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
49
52
  }
50
53
  type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
51
- messages: string | string[] | CoreMessage[] | AiMessageType[];
54
+ messages: string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[];
52
55
  output?: T;
53
56
  experimental_output?: T;
54
57
  runtimeContext?: RuntimeContext | Record<string, any>;
55
58
  clientTools?: ToolsInput;
56
59
  } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
57
60
  type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
58
- messages: string | string[] | CoreMessage[] | AiMessageType[];
61
+ messages: string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[];
59
62
  output?: T;
60
63
  experimental_output?: T;
61
64
  runtimeContext?: RuntimeContext | Record<string, any>;
@@ -161,14 +164,14 @@ interface GetVectorIndexResponse {
161
164
  count: number;
162
165
  }
163
166
  interface SaveMessageToMemoryParams {
164
- messages: MastraMessageV1[];
167
+ messages: (MastraMessageV1 | MastraMessageV2)[];
165
168
  agentId: string;
166
169
  }
167
170
  interface SaveNetworkMessageToMemoryParams {
168
- messages: MastraMessageV1[];
171
+ messages: (MastraMessageV1 | MastraMessageV2)[];
169
172
  networkId: string;
170
173
  }
171
- type SaveMessageToMemoryResponse = MastraMessageV1[];
174
+ type SaveMessageToMemoryResponse = (MastraMessageV1 | MastraMessageV2)[];
172
175
  interface CreateMemoryThreadParams {
173
176
  title?: string;
174
177
  metadata?: Record<string, any>;
@@ -204,10 +207,14 @@ interface GetMemoryThreadMessagesParams {
204
207
  */
205
208
  limit?: number;
206
209
  }
210
+ type GetMemoryThreadMessagesPaginatedParams = Omit<StorageGetMessagesArg, 'threadConfig' | 'threadId'>;
207
211
  interface GetMemoryThreadMessagesResponse {
208
212
  messages: CoreMessage[];
209
213
  uiMessages: AiMessageType[];
210
214
  }
215
+ type GetMemoryThreadMessagesPaginatedResponse = PaginationInfo & {
216
+ messages: MastraMessageV1[] | MastraMessageV2[];
217
+ };
211
218
  interface GetLogsParams {
212
219
  transportId: string;
213
220
  fromDate?: Date;
@@ -345,7 +352,17 @@ interface LoopStreamVNextNetworkParams {
345
352
  interface LoopVNextNetworkResponse {
346
353
  status: 'success';
347
354
  result: {
348
- text: string;
355
+ task: string;
356
+ resourceId: string;
357
+ resourceType: 'agent' | 'workflow' | 'none' | 'tool';
358
+ result: string;
359
+ iteration: number;
360
+ isOneOff: boolean;
361
+ prompt: string;
362
+ threadId?: string | undefined;
363
+ threadResourceId?: string | undefined;
364
+ isComplete?: boolean | undefined;
365
+ completionReason?: string | undefined;
349
366
  };
350
367
  steps: WorkflowResult<any, any>['steps'];
351
368
  }
@@ -364,6 +381,50 @@ interface McpToolInfo {
364
381
  interface McpServerToolListResponse {
365
382
  tools: McpToolInfo[];
366
383
  }
384
+ type ClientScoreRowData = Omit<ScoreRowData, 'createdAt' | 'updatedAt'> & {
385
+ createdAt: string;
386
+ updatedAt: string;
387
+ };
388
+ interface GetScoresByRunIdParams {
389
+ runId: string;
390
+ page?: number;
391
+ perPage?: number;
392
+ }
393
+ interface GetScoresByScorerIdParams {
394
+ scorerId: string;
395
+ entityId?: string;
396
+ entityType?: string;
397
+ page?: number;
398
+ perPage?: number;
399
+ }
400
+ interface GetScoresByEntityIdParams {
401
+ entityId: string;
402
+ entityType: string;
403
+ page?: number;
404
+ perPage?: number;
405
+ }
406
+ interface SaveScoreParams {
407
+ score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>;
408
+ }
409
+ interface GetScoresResponse {
410
+ pagination: {
411
+ total: number;
412
+ page: number;
413
+ perPage: number;
414
+ hasMore: boolean;
415
+ };
416
+ scores: ClientScoreRowData[];
417
+ }
418
+ interface SaveScoreResponse {
419
+ score: ClientScoreRowData;
420
+ }
421
+ type GetScorerResponse = MastraScorerEntry & {
422
+ agentIds: string[];
423
+ workflowIds: string[];
424
+ };
425
+ interface GetScorersResponse {
426
+ scorers: Array<GetScorerResponse>;
427
+ }
367
428
 
368
429
  declare class BaseResource {
369
430
  readonly options: ClientOptions;
@@ -429,32 +490,31 @@ declare class Agent extends BaseResource {
429
490
  * @param params - Generation parameters including prompt
430
491
  * @returns Promise containing the generated response
431
492
  */
432
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
493
+ generate(params: GenerateParams<undefined> & {
433
494
  output?: never;
434
495
  experimental_output?: never;
435
- }): Promise<GenerateReturn<T>>;
436
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
437
- output: T;
496
+ }): Promise<GenerateReturn<any, undefined, undefined>>;
497
+ generate<Output extends JSONSchema7 | ZodSchema>(params: GenerateParams<Output> & {
498
+ output: Output;
438
499
  experimental_output?: never;
439
- }): Promise<GenerateReturn<T>>;
440
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
500
+ }): Promise<GenerateReturn<any, Output, undefined>>;
501
+ generate<StructuredOutput extends JSONSchema7 | ZodSchema>(params: GenerateParams<StructuredOutput> & {
441
502
  output?: never;
442
- experimental_output: T;
443
- }): Promise<GenerateReturn<T>>;
503
+ experimental_output: StructuredOutput;
504
+ }): Promise<GenerateReturn<any, undefined, StructuredOutput>>;
444
505
  private processChatResponse;
445
- /**
446
- * Processes the stream response and handles tool calls
447
- */
448
- private processStreamResponse;
449
506
  /**
450
507
  * Streams a response from the agent
451
508
  * @param params - Stream parameters including prompt
452
- * @returns Promise containing the enhanced Response object with processDataStream and processTextStream methods
509
+ * @returns Promise containing the enhanced Response object with processDataStream method
453
510
  */
454
511
  stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
455
512
  processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
456
- processTextStream: (options?: Omit<Parameters<typeof processTextStream>[0], 'stream'>) => Promise<void>;
457
513
  }>;
514
+ /**
515
+ * Processes the stream response and handles tool calls
516
+ */
517
+ private processStreamResponse;
458
518
  /**
459
519
  * Gets details about a specific tool available to the agent
460
520
  * @param toolId - ID of the tool to retrieve
@@ -496,7 +556,7 @@ declare class Network extends BaseResource {
496
556
  * @param params - Generation parameters including prompt
497
557
  * @returns Promise containing the generated response
498
558
  */
499
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
559
+ generate<Output extends JSONSchema7 | ZodSchema | undefined = undefined, StructuredOutput extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<Output>): Promise<GenerateReturn$1<any, Output, StructuredOutput>>;
500
560
  /**
501
561
  * Streams a response from the agent
502
562
  * @param params - Stream parameters including prompt
@@ -535,6 +595,26 @@ declare class MemoryThread extends BaseResource {
535
595
  * @returns Promise containing thread messages and UI messages
536
596
  */
537
597
  getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
598
+ /**
599
+ * Retrieves paginated messages associated with the thread with advanced filtering and selection options
600
+ * @param params - Pagination parameters including selectBy criteria, page, perPage, date ranges, and message inclusion options
601
+ * @returns Promise containing paginated thread messages with pagination metadata (total, page, perPage, hasMore)
602
+ */
603
+ getMessagesPaginated({ selectBy, ...rest }: GetMemoryThreadMessagesPaginatedParams): Promise<GetMemoryThreadMessagesPaginatedResponse>;
604
+ /**
605
+ * Deletes one or more messages from the thread
606
+ * @param messageIds - Can be a single message ID (string), array of message IDs,
607
+ * message object with id property, or array of message objects
608
+ * @returns Promise containing deletion result
609
+ */
610
+ deleteMessages(messageIds: string | string[] | {
611
+ id: string;
612
+ } | {
613
+ id: string;
614
+ }[]): Promise<{
615
+ success: boolean;
616
+ message: string;
617
+ }>;
538
618
  }
539
619
 
540
620
  declare class Vector extends BaseResource {
@@ -752,6 +832,16 @@ declare class Workflow extends BaseResource {
752
832
  }): Promise<{
753
833
  runId: string;
754
834
  }>;
835
+ /**
836
+ * Creates a new workflow run (alias for createRun)
837
+ * @param params - Optional object containing the optional runId
838
+ * @returns Promise containing the runId of the created run
839
+ */
840
+ createRunAsync(params?: {
841
+ runId?: string;
842
+ }): Promise<{
843
+ runId: string;
844
+ }>;
755
845
  /**
756
846
  * Starts a workflow run synchronously without waiting for the workflow to complete
757
847
  * @param params - Object containing the runId, inputData and runtimeContext
@@ -922,6 +1012,20 @@ declare class NetworkMemoryThread extends BaseResource {
922
1012
  * @returns Promise containing thread messages and UI messages
923
1013
  */
924
1014
  getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
1015
+ /**
1016
+ * Deletes one or more messages from the thread
1017
+ * @param messageIds - Can be a single message ID (string), array of message IDs,
1018
+ * message object with id property, or array of message objects
1019
+ * @returns Promise containing deletion result
1020
+ */
1021
+ deleteMessages(messageIds: string | string[] | {
1022
+ id: string;
1023
+ } | {
1024
+ id: string;
1025
+ }[]): Promise<{
1026
+ success: boolean;
1027
+ message: string;
1028
+ }>;
925
1029
  }
926
1030
 
927
1031
  declare class VNextNetwork extends BaseResource {
@@ -1189,6 +1293,36 @@ declare class MastraClient extends BaseResource {
1189
1293
  workingMemory: string;
1190
1294
  resourceId?: string;
1191
1295
  }): Promise<unknown>;
1296
+ /**
1297
+ * Retrieves all available scorers
1298
+ * @returns Promise containing list of available scorers
1299
+ */
1300
+ getScorers(): Promise<Record<string, GetScorerResponse>>;
1301
+ /**
1302
+ * Retrieves a scorer by ID
1303
+ * @param scorerId - ID of the scorer to retrieve
1304
+ * @returns Promise containing the scorer
1305
+ */
1306
+ getScorer(scorerId: string): Promise<GetScorerResponse>;
1307
+ getScoresByScorerId(params: GetScoresByScorerIdParams): Promise<GetScoresResponse>;
1308
+ /**
1309
+ * Retrieves scores by run ID
1310
+ * @param params - Parameters containing run ID and pagination options
1311
+ * @returns Promise containing scores and pagination info
1312
+ */
1313
+ getScoresByRunId(params: GetScoresByRunIdParams): Promise<GetScoresResponse>;
1314
+ /**
1315
+ * Retrieves scores by entity ID and type
1316
+ * @param params - Parameters containing entity ID, type, and pagination options
1317
+ * @returns Promise containing scores and pagination info
1318
+ */
1319
+ getScoresByEntityId(params: GetScoresByEntityIdParams): Promise<GetScoresResponse>;
1320
+ /**
1321
+ * Saves a score
1322
+ * @param params - Parameters containing the score data to save
1323
+ * @returns Promise containing the saved score
1324
+ */
1325
+ saveScore(params: SaveScoreParams): Promise<SaveScoreResponse>;
1192
1326
  }
1193
1327
 
1194
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type CreateNetworkMemoryThreadParams, type GenerateOrStreamVNextNetworkParams, type GenerateParams, type GenerateVNextNetworkResponse, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkMemoryThreadParams, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextNetworkResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunByIdResponse, type GetWorkflowRunExecutionResultResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, type LoopStreamVNextNetworkParams, type LoopVNextNetworkResponse, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type SaveNetworkMessageToMemoryParams, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
1328
+ export { type ClientOptions, type ClientScoreRowData, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type CreateNetworkMemoryThreadParams, type GenerateOrStreamVNextNetworkParams, type GenerateParams, type GenerateVNextNetworkResponse, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesPaginatedParams, type GetMemoryThreadMessagesPaginatedResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkMemoryThreadParams, type GetNetworkResponse, type GetScorerResponse, type GetScorersResponse, type GetScoresByEntityIdParams, type GetScoresByRunIdParams, type GetScoresByScorerIdParams, type GetScoresResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextNetworkResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunByIdResponse, type GetWorkflowRunExecutionResultResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, type LoopStreamVNextNetworkParams, type LoopVNextNetworkResponse, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type SaveNetworkMessageToMemoryParams, type SaveScoreParams, type SaveScoreResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
package/dist/index.d.ts CHANGED
@@ -1,12 +1,15 @@
1
1
  import { AbstractAgent } from '@ag-ui/client';
2
2
  import { ServerInfo, MCPToolType, ServerDetailInfo } from '@mastra/core/mcp';
3
- import { processDataStream, processTextStream } from '@ai-sdk/ui-utils';
4
- import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn } from '@mastra/core';
3
+ import { processDataStream } from '@ai-sdk/ui-utils';
4
+ import { GenerateReturn } from '@mastra/core/llm';
5
5
  import { JSONSchema7 } from 'json-schema';
6
6
  import { ZodSchema } from 'zod';
7
- import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
7
+ import { CoreMessage, AiMessageType, StorageThreadType, StorageGetMessagesArg, PaginationInfo, MastraMessageV1, MastraMessageV2, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn as GenerateReturn$1 } from '@mastra/core';
8
+ import { AgentGenerateOptions, AgentStreamOptions, UIMessageWithMetadata, ToolsInput } from '@mastra/core/agent';
9
+ export { UIMessageWithMetadata } from '@mastra/core/agent';
8
10
  import { LogLevel, BaseLogMessage } from '@mastra/core/logger';
9
11
  import { RuntimeContext } from '@mastra/core/runtime-context';
12
+ import { MastraScorerEntry, ScoreRowData } from '@mastra/core/scores';
10
13
  import { Workflow as Workflow$1, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
11
14
  import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
12
15
  import * as stream_web from 'stream/web';
@@ -48,14 +51,14 @@ interface GetAgentResponse {
48
51
  defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
49
52
  }
50
53
  type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
51
- messages: string | string[] | CoreMessage[] | AiMessageType[];
54
+ messages: string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[];
52
55
  output?: T;
53
56
  experimental_output?: T;
54
57
  runtimeContext?: RuntimeContext | Record<string, any>;
55
58
  clientTools?: ToolsInput;
56
59
  } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
57
60
  type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
58
- messages: string | string[] | CoreMessage[] | AiMessageType[];
61
+ messages: string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[];
59
62
  output?: T;
60
63
  experimental_output?: T;
61
64
  runtimeContext?: RuntimeContext | Record<string, any>;
@@ -161,14 +164,14 @@ interface GetVectorIndexResponse {
161
164
  count: number;
162
165
  }
163
166
  interface SaveMessageToMemoryParams {
164
- messages: MastraMessageV1[];
167
+ messages: (MastraMessageV1 | MastraMessageV2)[];
165
168
  agentId: string;
166
169
  }
167
170
  interface SaveNetworkMessageToMemoryParams {
168
- messages: MastraMessageV1[];
171
+ messages: (MastraMessageV1 | MastraMessageV2)[];
169
172
  networkId: string;
170
173
  }
171
- type SaveMessageToMemoryResponse = MastraMessageV1[];
174
+ type SaveMessageToMemoryResponse = (MastraMessageV1 | MastraMessageV2)[];
172
175
  interface CreateMemoryThreadParams {
173
176
  title?: string;
174
177
  metadata?: Record<string, any>;
@@ -204,10 +207,14 @@ interface GetMemoryThreadMessagesParams {
204
207
  */
205
208
  limit?: number;
206
209
  }
210
+ type GetMemoryThreadMessagesPaginatedParams = Omit<StorageGetMessagesArg, 'threadConfig' | 'threadId'>;
207
211
  interface GetMemoryThreadMessagesResponse {
208
212
  messages: CoreMessage[];
209
213
  uiMessages: AiMessageType[];
210
214
  }
215
+ type GetMemoryThreadMessagesPaginatedResponse = PaginationInfo & {
216
+ messages: MastraMessageV1[] | MastraMessageV2[];
217
+ };
211
218
  interface GetLogsParams {
212
219
  transportId: string;
213
220
  fromDate?: Date;
@@ -345,7 +352,17 @@ interface LoopStreamVNextNetworkParams {
345
352
  interface LoopVNextNetworkResponse {
346
353
  status: 'success';
347
354
  result: {
348
- text: string;
355
+ task: string;
356
+ resourceId: string;
357
+ resourceType: 'agent' | 'workflow' | 'none' | 'tool';
358
+ result: string;
359
+ iteration: number;
360
+ isOneOff: boolean;
361
+ prompt: string;
362
+ threadId?: string | undefined;
363
+ threadResourceId?: string | undefined;
364
+ isComplete?: boolean | undefined;
365
+ completionReason?: string | undefined;
349
366
  };
350
367
  steps: WorkflowResult<any, any>['steps'];
351
368
  }
@@ -364,6 +381,50 @@ interface McpToolInfo {
364
381
  interface McpServerToolListResponse {
365
382
  tools: McpToolInfo[];
366
383
  }
384
+ type ClientScoreRowData = Omit<ScoreRowData, 'createdAt' | 'updatedAt'> & {
385
+ createdAt: string;
386
+ updatedAt: string;
387
+ };
388
+ interface GetScoresByRunIdParams {
389
+ runId: string;
390
+ page?: number;
391
+ perPage?: number;
392
+ }
393
+ interface GetScoresByScorerIdParams {
394
+ scorerId: string;
395
+ entityId?: string;
396
+ entityType?: string;
397
+ page?: number;
398
+ perPage?: number;
399
+ }
400
+ interface GetScoresByEntityIdParams {
401
+ entityId: string;
402
+ entityType: string;
403
+ page?: number;
404
+ perPage?: number;
405
+ }
406
+ interface SaveScoreParams {
407
+ score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>;
408
+ }
409
+ interface GetScoresResponse {
410
+ pagination: {
411
+ total: number;
412
+ page: number;
413
+ perPage: number;
414
+ hasMore: boolean;
415
+ };
416
+ scores: ClientScoreRowData[];
417
+ }
418
+ interface SaveScoreResponse {
419
+ score: ClientScoreRowData;
420
+ }
421
+ type GetScorerResponse = MastraScorerEntry & {
422
+ agentIds: string[];
423
+ workflowIds: string[];
424
+ };
425
+ interface GetScorersResponse {
426
+ scorers: Array<GetScorerResponse>;
427
+ }
367
428
 
368
429
  declare class BaseResource {
369
430
  readonly options: ClientOptions;
@@ -429,32 +490,31 @@ declare class Agent extends BaseResource {
429
490
  * @param params - Generation parameters including prompt
430
491
  * @returns Promise containing the generated response
431
492
  */
432
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
493
+ generate(params: GenerateParams<undefined> & {
433
494
  output?: never;
434
495
  experimental_output?: never;
435
- }): Promise<GenerateReturn<T>>;
436
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
437
- output: T;
496
+ }): Promise<GenerateReturn<any, undefined, undefined>>;
497
+ generate<Output extends JSONSchema7 | ZodSchema>(params: GenerateParams<Output> & {
498
+ output: Output;
438
499
  experimental_output?: never;
439
- }): Promise<GenerateReturn<T>>;
440
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
500
+ }): Promise<GenerateReturn<any, Output, undefined>>;
501
+ generate<StructuredOutput extends JSONSchema7 | ZodSchema>(params: GenerateParams<StructuredOutput> & {
441
502
  output?: never;
442
- experimental_output: T;
443
- }): Promise<GenerateReturn<T>>;
503
+ experimental_output: StructuredOutput;
504
+ }): Promise<GenerateReturn<any, undefined, StructuredOutput>>;
444
505
  private processChatResponse;
445
- /**
446
- * Processes the stream response and handles tool calls
447
- */
448
- private processStreamResponse;
449
506
  /**
450
507
  * Streams a response from the agent
451
508
  * @param params - Stream parameters including prompt
452
- * @returns Promise containing the enhanced Response object with processDataStream and processTextStream methods
509
+ * @returns Promise containing the enhanced Response object with processDataStream method
453
510
  */
454
511
  stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
455
512
  processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
456
- processTextStream: (options?: Omit<Parameters<typeof processTextStream>[0], 'stream'>) => Promise<void>;
457
513
  }>;
514
+ /**
515
+ * Processes the stream response and handles tool calls
516
+ */
517
+ private processStreamResponse;
458
518
  /**
459
519
  * Gets details about a specific tool available to the agent
460
520
  * @param toolId - ID of the tool to retrieve
@@ -496,7 +556,7 @@ declare class Network extends BaseResource {
496
556
  * @param params - Generation parameters including prompt
497
557
  * @returns Promise containing the generated response
498
558
  */
499
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
559
+ generate<Output extends JSONSchema7 | ZodSchema | undefined = undefined, StructuredOutput extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<Output>): Promise<GenerateReturn$1<any, Output, StructuredOutput>>;
500
560
  /**
501
561
  * Streams a response from the agent
502
562
  * @param params - Stream parameters including prompt
@@ -535,6 +595,26 @@ declare class MemoryThread extends BaseResource {
535
595
  * @returns Promise containing thread messages and UI messages
536
596
  */
537
597
  getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
598
+ /**
599
+ * Retrieves paginated messages associated with the thread with advanced filtering and selection options
600
+ * @param params - Pagination parameters including selectBy criteria, page, perPage, date ranges, and message inclusion options
601
+ * @returns Promise containing paginated thread messages with pagination metadata (total, page, perPage, hasMore)
602
+ */
603
+ getMessagesPaginated({ selectBy, ...rest }: GetMemoryThreadMessagesPaginatedParams): Promise<GetMemoryThreadMessagesPaginatedResponse>;
604
+ /**
605
+ * Deletes one or more messages from the thread
606
+ * @param messageIds - Can be a single message ID (string), array of message IDs,
607
+ * message object with id property, or array of message objects
608
+ * @returns Promise containing deletion result
609
+ */
610
+ deleteMessages(messageIds: string | string[] | {
611
+ id: string;
612
+ } | {
613
+ id: string;
614
+ }[]): Promise<{
615
+ success: boolean;
616
+ message: string;
617
+ }>;
538
618
  }
539
619
 
540
620
  declare class Vector extends BaseResource {
@@ -752,6 +832,16 @@ declare class Workflow extends BaseResource {
752
832
  }): Promise<{
753
833
  runId: string;
754
834
  }>;
835
+ /**
836
+ * Creates a new workflow run (alias for createRun)
837
+ * @param params - Optional object containing the optional runId
838
+ * @returns Promise containing the runId of the created run
839
+ */
840
+ createRunAsync(params?: {
841
+ runId?: string;
842
+ }): Promise<{
843
+ runId: string;
844
+ }>;
755
845
  /**
756
846
  * Starts a workflow run synchronously without waiting for the workflow to complete
757
847
  * @param params - Object containing the runId, inputData and runtimeContext
@@ -922,6 +1012,20 @@ declare class NetworkMemoryThread extends BaseResource {
922
1012
  * @returns Promise containing thread messages and UI messages
923
1013
  */
924
1014
  getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
1015
+ /**
1016
+ * Deletes one or more messages from the thread
1017
+ * @param messageIds - Can be a single message ID (string), array of message IDs,
1018
+ * message object with id property, or array of message objects
1019
+ * @returns Promise containing deletion result
1020
+ */
1021
+ deleteMessages(messageIds: string | string[] | {
1022
+ id: string;
1023
+ } | {
1024
+ id: string;
1025
+ }[]): Promise<{
1026
+ success: boolean;
1027
+ message: string;
1028
+ }>;
925
1029
  }
926
1030
 
927
1031
  declare class VNextNetwork extends BaseResource {
@@ -1189,6 +1293,36 @@ declare class MastraClient extends BaseResource {
1189
1293
  workingMemory: string;
1190
1294
  resourceId?: string;
1191
1295
  }): Promise<unknown>;
1296
+ /**
1297
+ * Retrieves all available scorers
1298
+ * @returns Promise containing list of available scorers
1299
+ */
1300
+ getScorers(): Promise<Record<string, GetScorerResponse>>;
1301
+ /**
1302
+ * Retrieves a scorer by ID
1303
+ * @param scorerId - ID of the scorer to retrieve
1304
+ * @returns Promise containing the scorer
1305
+ */
1306
+ getScorer(scorerId: string): Promise<GetScorerResponse>;
1307
+ getScoresByScorerId(params: GetScoresByScorerIdParams): Promise<GetScoresResponse>;
1308
+ /**
1309
+ * Retrieves scores by run ID
1310
+ * @param params - Parameters containing run ID and pagination options
1311
+ * @returns Promise containing scores and pagination info
1312
+ */
1313
+ getScoresByRunId(params: GetScoresByRunIdParams): Promise<GetScoresResponse>;
1314
+ /**
1315
+ * Retrieves scores by entity ID and type
1316
+ * @param params - Parameters containing entity ID, type, and pagination options
1317
+ * @returns Promise containing scores and pagination info
1318
+ */
1319
+ getScoresByEntityId(params: GetScoresByEntityIdParams): Promise<GetScoresResponse>;
1320
+ /**
1321
+ * Saves a score
1322
+ * @param params - Parameters containing the score data to save
1323
+ * @returns Promise containing the saved score
1324
+ */
1325
+ saveScore(params: SaveScoreParams): Promise<SaveScoreResponse>;
1192
1326
  }
1193
1327
 
1194
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type CreateNetworkMemoryThreadParams, type GenerateOrStreamVNextNetworkParams, type GenerateParams, type GenerateVNextNetworkResponse, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkMemoryThreadParams, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextNetworkResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunByIdResponse, type GetWorkflowRunExecutionResultResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, type LoopStreamVNextNetworkParams, type LoopVNextNetworkResponse, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type SaveNetworkMessageToMemoryParams, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
1328
+ export { type ClientOptions, type ClientScoreRowData, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type CreateNetworkMemoryThreadParams, type GenerateOrStreamVNextNetworkParams, type GenerateParams, type GenerateVNextNetworkResponse, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesPaginatedParams, type GetMemoryThreadMessagesPaginatedResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkMemoryThreadParams, type GetNetworkResponse, type GetScorerResponse, type GetScorersResponse, type GetScoresByEntityIdParams, type GetScoresByRunIdParams, type GetScoresByScorerIdParams, type GetScoresResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextNetworkResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunByIdResponse, type GetWorkflowRunExecutionResultResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, type LoopStreamVNextNetworkParams, type LoopVNextNetworkResponse, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type SaveNetworkMessageToMemoryParams, type SaveScoreParams, type SaveScoreResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };