@mastra/client-js 0.0.0-tool-call-parts-20250630193309 → 0.0.0-transpile-packages-20250730132657

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,14 @@
1
1
  import { AbstractAgent } from '@ag-ui/client';
2
2
  import { ServerInfo, MCPToolType, ServerDetailInfo } from '@mastra/core/mcp';
3
3
  import { processDataStream } from '@ai-sdk/ui-utils';
4
- import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn } from '@mastra/core';
4
+ import { GenerateReturn } from '@mastra/core/llm';
5
5
  import { JSONSchema7 } from 'json-schema';
6
6
  import { ZodSchema } from 'zod';
7
+ import { CoreMessage, AiMessageType, StorageThreadType, StorageGetMessagesArg, PaginationInfo, MastraMessageV1, MastraMessageV2, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn as GenerateReturn$1 } from '@mastra/core';
7
8
  import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
8
9
  import { LogLevel, BaseLogMessage } from '@mastra/core/logger';
9
10
  import { RuntimeContext } from '@mastra/core/runtime-context';
11
+ import { MastraScorerEntry, ScoreRowData } from '@mastra/core/scores';
10
12
  import { Workflow as Workflow$1, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
11
13
  import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
12
14
  import * as stream_web from 'stream/web';
@@ -23,13 +25,14 @@ interface ClientOptions {
23
25
  maxBackoffMs?: number;
24
26
  /** Custom headers to include with requests */
25
27
  headers?: Record<string, string>;
28
+ /** Abort signal for request */
29
+ abortSignal?: AbortSignal;
26
30
  }
27
31
  interface RequestOptions {
28
32
  method?: string;
29
33
  headers?: Record<string, string>;
30
34
  body?: any;
31
35
  stream?: boolean;
32
- signal?: AbortSignal;
33
36
  }
34
37
  type WithoutMethods<T> = {
35
38
  [K in keyof T as T[K] extends (...args: any[]) => any ? never : T[K] extends {
@@ -52,14 +55,14 @@ type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> =
52
55
  experimental_output?: T;
53
56
  runtimeContext?: RuntimeContext | Record<string, any>;
54
57
  clientTools?: ToolsInput;
55
- } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
58
+ } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
56
59
  type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
57
60
  messages: string | string[] | CoreMessage[] | AiMessageType[];
58
61
  output?: T;
59
62
  experimental_output?: T;
60
63
  runtimeContext?: RuntimeContext | Record<string, any>;
61
64
  clientTools?: ToolsInput;
62
- } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
65
+ } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
63
66
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
64
67
  evals: any[];
65
68
  instructions: string;
@@ -114,6 +117,17 @@ interface GetWorkflowResponse {
114
117
  suspendSchema: string;
115
118
  };
116
119
  };
120
+ allSteps: {
121
+ [key: string]: {
122
+ id: string;
123
+ description: string;
124
+ inputSchema: string;
125
+ outputSchema: string;
126
+ resumeSchema: string;
127
+ suspendSchema: string;
128
+ isWorkflow: boolean;
129
+ };
130
+ };
117
131
  stepGraph: Workflow$1['serializedStepGraph'];
118
132
  inputSchema: string;
119
133
  outputSchema: string;
@@ -192,10 +206,14 @@ interface GetMemoryThreadMessagesParams {
192
206
  */
193
207
  limit?: number;
194
208
  }
209
+ type GetMemoryThreadMessagesPaginatedParams = Omit<StorageGetMessagesArg, 'threadConfig' | 'threadId'>;
195
210
  interface GetMemoryThreadMessagesResponse {
196
211
  messages: CoreMessage[];
197
212
  uiMessages: AiMessageType[];
198
213
  }
214
+ type GetMemoryThreadMessagesPaginatedResponse = PaginationInfo & {
215
+ messages: MastraMessageV1[] | MastraMessageV2[];
216
+ };
199
217
  interface GetLogsParams {
200
218
  transportId: string;
201
219
  fromDate?: Date;
@@ -321,17 +339,29 @@ interface GenerateOrStreamVNextNetworkParams {
321
339
  message: string;
322
340
  threadId?: string;
323
341
  resourceId?: string;
342
+ runtimeContext?: RuntimeContext | Record<string, any>;
324
343
  }
325
344
  interface LoopStreamVNextNetworkParams {
326
345
  message: string;
327
346
  threadId?: string;
328
347
  resourceId?: string;
329
348
  maxIterations?: number;
349
+ runtimeContext?: RuntimeContext | Record<string, any>;
330
350
  }
331
351
  interface LoopVNextNetworkResponse {
332
352
  status: 'success';
333
353
  result: {
334
- text: string;
354
+ task: string;
355
+ resourceId: string;
356
+ resourceType: 'agent' | 'workflow' | 'none' | 'tool';
357
+ result: string;
358
+ iteration: number;
359
+ isOneOff: boolean;
360
+ prompt: string;
361
+ threadId?: string | undefined;
362
+ threadResourceId?: string | undefined;
363
+ isComplete?: boolean | undefined;
364
+ completionReason?: string | undefined;
335
365
  };
336
366
  steps: WorkflowResult<any, any>['steps'];
337
367
  }
@@ -350,6 +380,50 @@ interface McpToolInfo {
350
380
  interface McpServerToolListResponse {
351
381
  tools: McpToolInfo[];
352
382
  }
383
+ type ClientScoreRowData = Omit<ScoreRowData, 'createdAt' | 'updatedAt'> & {
384
+ createdAt: string;
385
+ updatedAt: string;
386
+ };
387
+ interface GetScoresByRunIdParams {
388
+ runId: string;
389
+ page?: number;
390
+ perPage?: number;
391
+ }
392
+ interface GetScoresByScorerIdParams {
393
+ scorerId: string;
394
+ entityId?: string;
395
+ entityType?: string;
396
+ page?: number;
397
+ perPage?: number;
398
+ }
399
+ interface GetScoresByEntityIdParams {
400
+ entityId: string;
401
+ entityType: string;
402
+ page?: number;
403
+ perPage?: number;
404
+ }
405
+ interface SaveScoreParams {
406
+ score: ScoreRowData;
407
+ }
408
+ interface GetScoresResponse {
409
+ pagination: {
410
+ total: number;
411
+ page: number;
412
+ perPage: number;
413
+ hasMore: boolean;
414
+ };
415
+ scores: ClientScoreRowData[];
416
+ }
417
+ interface SaveScoreResponse {
418
+ score: ClientScoreRowData;
419
+ }
420
+ type GetScorerResponse = MastraScorerEntry & {
421
+ agentIds: string[];
422
+ workflowIds: string[];
423
+ };
424
+ interface GetScorersResponse {
425
+ scorers: Array<GetScorerResponse>;
426
+ }
353
427
 
354
428
  declare class BaseResource {
355
429
  readonly options: ClientOptions;
@@ -415,18 +489,18 @@ declare class Agent extends BaseResource {
415
489
  * @param params - Generation parameters including prompt
416
490
  * @returns Promise containing the generated response
417
491
  */
418
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
492
+ generate(params: GenerateParams<undefined> & {
419
493
  output?: never;
420
494
  experimental_output?: never;
421
- }): Promise<GenerateReturn<T>>;
422
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
423
- output: T;
495
+ }): Promise<GenerateReturn<any, undefined, undefined>>;
496
+ generate<Output extends JSONSchema7 | ZodSchema>(params: GenerateParams<Output> & {
497
+ output: Output;
424
498
  experimental_output?: never;
425
- }): Promise<GenerateReturn<T>>;
426
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
499
+ }): Promise<GenerateReturn<any, Output, undefined>>;
500
+ generate<StructuredOutput extends JSONSchema7 | ZodSchema>(params: GenerateParams<StructuredOutput> & {
427
501
  output?: never;
428
- experimental_output: T;
429
- }): Promise<GenerateReturn<T>>;
502
+ experimental_output: StructuredOutput;
503
+ }): Promise<GenerateReturn<any, undefined, StructuredOutput>>;
430
504
  private processChatResponse;
431
505
  /**
432
506
  * Streams a response from the agent
@@ -481,7 +555,7 @@ declare class Network extends BaseResource {
481
555
  * @param params - Generation parameters including prompt
482
556
  * @returns Promise containing the generated response
483
557
  */
484
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
558
+ generate<Output extends JSONSchema7 | ZodSchema | undefined = undefined, StructuredOutput extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<Output>): Promise<GenerateReturn$1<any, Output, StructuredOutput>>;
485
559
  /**
486
560
  * Streams a response from the agent
487
561
  * @param params - Stream parameters including prompt
@@ -520,6 +594,12 @@ declare class MemoryThread extends BaseResource {
520
594
  * @returns Promise containing thread messages and UI messages
521
595
  */
522
596
  getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
597
+ /**
598
+ * Retrieves paginated messages associated with the thread with advanced filtering and selection options
599
+ * @param params - Pagination parameters including selectBy criteria, page, perPage, date ranges, and message inclusion options
600
+ * @returns Promise containing paginated thread messages with pagination metadata (total, page, perPage, hasMore)
601
+ */
602
+ getMessagesPaginated({ selectBy, ...rest }: GetMemoryThreadMessagesPaginatedParams): Promise<GetMemoryThreadMessagesPaginatedResponse>;
523
603
  }
524
604
 
525
605
  declare class Vector extends BaseResource {
@@ -707,6 +787,26 @@ declare class Workflow extends BaseResource {
707
787
  * @returns Promise containing the workflow run execution result
708
788
  */
709
789
  runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse>;
790
+ /**
791
+ * Cancels a specific workflow run by its ID
792
+ * @param runId - The ID of the workflow run to cancel
793
+ * @returns Promise containing a success message
794
+ */
795
+ cancelRun(runId: string): Promise<{
796
+ message: string;
797
+ }>;
798
+ /**
799
+ * Sends an event to a specific workflow run by its ID
800
+ * @param params - Object containing the runId, event and data
801
+ * @returns Promise containing a success message
802
+ */
803
+ sendRunEvent(params: {
804
+ runId: string;
805
+ event: string;
806
+ data: unknown;
807
+ }): Promise<{
808
+ message: string;
809
+ }>;
710
810
  /**
711
811
  * Creates a new workflow run
712
812
  * @param params - Optional object containing the optional runId
@@ -717,6 +817,16 @@ declare class Workflow extends BaseResource {
717
817
  }): Promise<{
718
818
  runId: string;
719
819
  }>;
820
+ /**
821
+ * Creates a new workflow run (alias for createRun)
822
+ * @param params - Optional object containing the optional runId
823
+ * @returns Promise containing the runId of the created run
824
+ */
825
+ createRunAsync(params?: {
826
+ runId?: string;
827
+ }): Promise<{
828
+ runId: string;
829
+ }>;
720
830
  /**
721
831
  * Starts a workflow run synchronously without waiting for the workflow to complete
722
832
  * @param params - Object containing the runId, inputData and runtimeContext
@@ -859,6 +969,36 @@ declare class MCPTool extends BaseResource {
859
969
  }): Promise<any>;
860
970
  }
861
971
 
972
+ declare class NetworkMemoryThread extends BaseResource {
973
+ private threadId;
974
+ private networkId;
975
+ constructor(options: ClientOptions, threadId: string, networkId: string);
976
+ /**
977
+ * Retrieves the memory thread details
978
+ * @returns Promise containing thread details including title and metadata
979
+ */
980
+ get(): Promise<StorageThreadType>;
981
+ /**
982
+ * Updates the memory thread properties
983
+ * @param params - Update parameters including title and metadata
984
+ * @returns Promise containing updated thread details
985
+ */
986
+ update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
987
+ /**
988
+ * Deletes the memory thread
989
+ * @returns Promise containing deletion result
990
+ */
991
+ delete(): Promise<{
992
+ result: string;
993
+ }>;
994
+ /**
995
+ * Retrieves messages associated with the thread
996
+ * @param params - Optional parameters including limit for number of messages to retrieve
997
+ * @returns Promise containing thread messages and UI messages
998
+ */
999
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
1000
+ }
1001
+
862
1002
  declare class VNextNetwork extends BaseResource {
863
1003
  private networkId;
864
1004
  constructor(options: ClientOptions, networkId: string);
@@ -880,6 +1020,7 @@ declare class VNextNetwork extends BaseResource {
880
1020
  */
881
1021
  loop(params: {
882
1022
  message: string;
1023
+ runtimeContext?: RuntimeContext | Record<string, any>;
883
1024
  }): Promise<LoopVNextNetworkResponse>;
884
1025
  private streamProcessor;
885
1026
  /**
@@ -896,36 +1037,6 @@ declare class VNextNetwork extends BaseResource {
896
1037
  loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
897
1038
  }
898
1039
 
899
- declare class NetworkMemoryThread extends BaseResource {
900
- private threadId;
901
- private networkId;
902
- constructor(options: ClientOptions, threadId: string, networkId: string);
903
- /**
904
- * Retrieves the memory thread details
905
- * @returns Promise containing thread details including title and metadata
906
- */
907
- get(): Promise<StorageThreadType>;
908
- /**
909
- * Updates the memory thread properties
910
- * @param params - Update parameters including title and metadata
911
- * @returns Promise containing updated thread details
912
- */
913
- update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
914
- /**
915
- * Deletes the memory thread
916
- * @returns Promise containing deletion result
917
- */
918
- delete(): Promise<{
919
- result: string;
920
- }>;
921
- /**
922
- * Retrieves messages associated with the thread
923
- * @param params - Optional parameters including limit for number of messages to retrieve
924
- * @returns Promise containing thread messages and UI messages
925
- */
926
- getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
927
- }
928
-
929
1040
  declare class MastraClient extends BaseResource {
930
1041
  constructor(options: ClientOptions);
931
1042
  /**
@@ -1128,6 +1239,61 @@ declare class MastraClient extends BaseResource {
1128
1239
  * @returns A2A client instance
1129
1240
  */
1130
1241
  getA2A(agentId: string): A2A;
1242
+ /**
1243
+ * Retrieves the working memory for a specific thread (optionally resource-scoped).
1244
+ * @param agentId - ID of the agent.
1245
+ * @param threadId - ID of the thread.
1246
+ * @param resourceId - Optional ID of the resource.
1247
+ * @returns Working memory for the specified thread or resource.
1248
+ */
1249
+ getWorkingMemory({ agentId, threadId, resourceId, }: {
1250
+ agentId: string;
1251
+ threadId: string;
1252
+ resourceId?: string;
1253
+ }): Promise<unknown>;
1254
+ /**
1255
+ * Updates the working memory for a specific thread (optionally resource-scoped).
1256
+ * @param agentId - ID of the agent.
1257
+ * @param threadId - ID of the thread.
1258
+ * @param workingMemory - The new working memory content.
1259
+ * @param resourceId - Optional ID of the resource.
1260
+ */
1261
+ updateWorkingMemory({ agentId, threadId, workingMemory, resourceId, }: {
1262
+ agentId: string;
1263
+ threadId: string;
1264
+ workingMemory: string;
1265
+ resourceId?: string;
1266
+ }): Promise<unknown>;
1267
+ /**
1268
+ * Retrieves all available scorers
1269
+ * @returns Promise containing list of available scorers
1270
+ */
1271
+ getScorers(): Promise<Record<string, GetScorerResponse>>;
1272
+ /**
1273
+ * Retrieves a scorer by ID
1274
+ * @param scorerId - ID of the scorer to retrieve
1275
+ * @returns Promise containing the scorer
1276
+ */
1277
+ getScorer(scorerId: string): Promise<GetScorerResponse>;
1278
+ getScoresByScorerId(params: GetScoresByScorerIdParams): Promise<GetScoresResponse>;
1279
+ /**
1280
+ * Retrieves scores by run ID
1281
+ * @param params - Parameters containing run ID and pagination options
1282
+ * @returns Promise containing scores and pagination info
1283
+ */
1284
+ getScoresByRunId(params: GetScoresByRunIdParams): Promise<GetScoresResponse>;
1285
+ /**
1286
+ * Retrieves scores by entity ID and type
1287
+ * @param params - Parameters containing entity ID, type, and pagination options
1288
+ * @returns Promise containing scores and pagination info
1289
+ */
1290
+ getScoresByEntityId(params: GetScoresByEntityIdParams): Promise<GetScoresResponse>;
1291
+ /**
1292
+ * Saves a score
1293
+ * @param params - Parameters containing the score data to save
1294
+ * @returns Promise containing the saved score
1295
+ */
1296
+ saveScore(params: SaveScoreParams): Promise<SaveScoreResponse>;
1131
1297
  }
1132
1298
 
1133
- 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 };
1299
+ 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 };