@mastra/client-js 0.0.0-course-20250527170450 → 0.0.0-custom-instrumentation-20250708222033

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.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import { AbstractAgent } from '@ag-ui/client';
2
- import { ServerInfo, ServerDetailInfo } from '@mastra/core/mcp';
2
+ import { ServerInfo, MCPToolType, ServerDetailInfo } from '@mastra/core/mcp';
3
3
  import { processDataStream } from '@ai-sdk/ui-utils';
4
- import { CoreMessage, AiMessageType, StorageThreadType, MessageType, LegacyWorkflowRuns, WorkflowRuns, QueryResult, GenerateReturn } from '@mastra/core';
4
+ import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn } from '@mastra/core';
5
5
  import { JSONSchema7 } from 'json-schema';
6
6
  import { ZodSchema } from 'zod';
7
- import { BaseLogMessage } from '@mastra/core/logger';
8
- import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
7
+ import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
8
+ import { LogLevel, BaseLogMessage } from '@mastra/core/logger';
9
9
  import { RuntimeContext } from '@mastra/core/runtime-context';
10
- import { Workflow as Workflow$1, WorkflowResult, WatchEvent } from '@mastra/core/workflows';
10
+ import { Workflow as Workflow$1, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
11
11
  import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
12
12
  import * as stream_web from 'stream/web';
13
13
  import { AgentCard, TaskSendParams, Task, TaskQueryParams, TaskIdParams } from '@mastra/core/a2a';
@@ -23,13 +23,14 @@ interface ClientOptions {
23
23
  maxBackoffMs?: number;
24
24
  /** Custom headers to include with requests */
25
25
  headers?: Record<string, string>;
26
+ /** Abort signal for request */
27
+ abortSignal?: AbortSignal;
26
28
  }
27
29
  interface RequestOptions {
28
30
  method?: string;
29
31
  headers?: Record<string, string>;
30
32
  body?: any;
31
33
  stream?: boolean;
32
- signal?: AbortSignal;
33
34
  }
34
35
  type WithoutMethods<T> = {
35
36
  [K in keyof T as T[K] extends (...args: any[]) => any ? never : T[K] extends {
@@ -51,13 +52,15 @@ type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> =
51
52
  output?: T;
52
53
  experimental_output?: T;
53
54
  runtimeContext?: RuntimeContext | Record<string, any>;
54
- } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
55
+ clientTools?: ToolsInput;
56
+ } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
55
57
  type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
56
58
  messages: string | string[] | CoreMessage[] | AiMessageType[];
57
59
  output?: T;
58
60
  experimental_output?: T;
59
61
  runtimeContext?: RuntimeContext | Record<string, any>;
60
- } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
62
+ clientTools?: ToolsInput;
63
+ } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
61
64
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
62
65
  evals: any[];
63
66
  instructions: string;
@@ -87,6 +90,8 @@ interface GetWorkflowRunsParams {
87
90
  }
88
91
  type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
89
92
  type GetWorkflowRunsResponse = WorkflowRuns;
93
+ type GetWorkflowRunByIdResponse = WorkflowRun;
94
+ type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
90
95
  type LegacyWorkflowRunResult = {
91
96
  activePaths: Record<string, {
92
97
  status: string;
@@ -110,6 +115,17 @@ interface GetWorkflowResponse {
110
115
  suspendSchema: string;
111
116
  };
112
117
  };
118
+ allSteps: {
119
+ [key: string]: {
120
+ id: string;
121
+ description: string;
122
+ inputSchema: string;
123
+ outputSchema: string;
124
+ resumeSchema: string;
125
+ suspendSchema: string;
126
+ isWorkflow: boolean;
127
+ };
128
+ };
113
129
  stepGraph: Workflow$1['serializedStepGraph'];
114
130
  inputSchema: string;
115
131
  outputSchema: string;
@@ -145,10 +161,14 @@ interface GetVectorIndexResponse {
145
161
  count: number;
146
162
  }
147
163
  interface SaveMessageToMemoryParams {
148
- messages: MessageType[];
164
+ messages: MastraMessageV1[];
149
165
  agentId: string;
150
166
  }
151
- type SaveMessageToMemoryResponse = MessageType[];
167
+ interface SaveNetworkMessageToMemoryParams {
168
+ messages: MastraMessageV1[];
169
+ networkId: string;
170
+ }
171
+ type SaveMessageToMemoryResponse = MastraMessageV1[];
152
172
  interface CreateMemoryThreadParams {
153
173
  title?: string;
154
174
  metadata?: Record<string, any>;
@@ -156,11 +176,22 @@ interface CreateMemoryThreadParams {
156
176
  threadId?: string;
157
177
  agentId: string;
158
178
  }
179
+ interface CreateNetworkMemoryThreadParams {
180
+ title?: string;
181
+ metadata?: Record<string, any>;
182
+ resourceId: string;
183
+ threadId?: string;
184
+ networkId: string;
185
+ }
159
186
  type CreateMemoryThreadResponse = StorageThreadType;
160
187
  interface GetMemoryThreadParams {
161
188
  resourceId: string;
162
189
  agentId: string;
163
190
  }
191
+ interface GetNetworkMemoryThreadParams {
192
+ resourceId: string;
193
+ networkId: string;
194
+ }
164
195
  type GetMemoryThreadResponse = StorageThreadType[];
165
196
  interface UpdateMemoryThreadParams {
166
197
  title: string;
@@ -179,12 +210,30 @@ interface GetMemoryThreadMessagesResponse {
179
210
  }
180
211
  interface GetLogsParams {
181
212
  transportId: string;
213
+ fromDate?: Date;
214
+ toDate?: Date;
215
+ logLevel?: LogLevel;
216
+ filters?: Record<string, string>;
217
+ page?: number;
218
+ perPage?: number;
182
219
  }
183
220
  interface GetLogParams {
184
221
  runId: string;
185
222
  transportId: string;
223
+ fromDate?: Date;
224
+ toDate?: Date;
225
+ logLevel?: LogLevel;
226
+ filters?: Record<string, string>;
227
+ page?: number;
228
+ perPage?: number;
186
229
  }
187
- type GetLogsResponse = BaseLogMessage[];
230
+ type GetLogsResponse = {
231
+ logs: BaseLogMessage[];
232
+ total: number;
233
+ page: number;
234
+ perPage: number;
235
+ hasMore: boolean;
236
+ };
188
237
  type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
189
238
  type SpanStatus = {
190
239
  code: number;
@@ -236,6 +285,7 @@ interface GetTelemetryParams {
236
285
  toDate?: Date;
237
286
  }
238
287
  interface GetNetworkResponse {
288
+ id: string;
239
289
  name: string;
240
290
  instructions: string;
241
291
  agents: Array<{
@@ -249,6 +299,54 @@ interface GetNetworkResponse {
249
299
  };
250
300
  state?: Record<string, any>;
251
301
  }
302
+ interface GetVNextNetworkResponse {
303
+ id: string;
304
+ name: string;
305
+ instructions: string;
306
+ agents: Array<{
307
+ name: string;
308
+ provider: string;
309
+ modelId: string;
310
+ }>;
311
+ routingModel: {
312
+ provider: string;
313
+ modelId: string;
314
+ };
315
+ workflows: Array<{
316
+ name: string;
317
+ description: string;
318
+ inputSchema: string | undefined;
319
+ outputSchema: string | undefined;
320
+ }>;
321
+ tools: Array<{
322
+ id: string;
323
+ description: string;
324
+ }>;
325
+ }
326
+ interface GenerateVNextNetworkResponse {
327
+ task: string;
328
+ result: string;
329
+ resourceId: string;
330
+ resourceType: 'none' | 'tool' | 'agent' | 'workflow';
331
+ }
332
+ interface GenerateOrStreamVNextNetworkParams {
333
+ message: string;
334
+ threadId?: string;
335
+ resourceId?: string;
336
+ }
337
+ interface LoopStreamVNextNetworkParams {
338
+ message: string;
339
+ threadId?: string;
340
+ resourceId?: string;
341
+ maxIterations?: number;
342
+ }
343
+ interface LoopVNextNetworkResponse {
344
+ status: 'success';
345
+ result: {
346
+ text: string;
347
+ };
348
+ steps: WorkflowResult<any, any>['steps'];
349
+ }
252
350
  interface McpServerListResponse {
253
351
  servers: ServerInfo[];
254
352
  next: string | null;
@@ -259,6 +357,7 @@ interface McpToolInfo {
259
357
  name: string;
260
358
  description?: string;
261
359
  inputSchema: string;
360
+ toolType?: MCPToolType;
262
361
  }
263
362
  interface McpServerToolListResponse {
264
363
  tools: McpToolInfo[];
@@ -306,6 +405,13 @@ declare class AgentVoice extends BaseResource {
306
405
  voiceId: string;
307
406
  [key: string]: any;
308
407
  }>>;
408
+ /**
409
+ * Get the listener configuration for the agent's voice provider
410
+ * @returns Promise containing a check if the agent has listening capabilities
411
+ */
412
+ getListener(): Promise<{
413
+ enabled: boolean;
414
+ }>;
309
415
  }
310
416
  declare class Agent extends BaseResource {
311
417
  private agentId;
@@ -321,7 +427,19 @@ declare class Agent extends BaseResource {
321
427
  * @param params - Generation parameters including prompt
322
428
  * @returns Promise containing the generated response
323
429
  */
324
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
430
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
431
+ output?: never;
432
+ experimental_output?: never;
433
+ }): Promise<GenerateReturn<T>>;
434
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
435
+ output: T;
436
+ experimental_output?: never;
437
+ }): Promise<GenerateReturn<T>>;
438
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
439
+ output?: never;
440
+ experimental_output: T;
441
+ }): Promise<GenerateReturn<T>>;
442
+ private processChatResponse;
325
443
  /**
326
444
  * Streams a response from the agent
327
445
  * @param params - Stream parameters including prompt
@@ -330,6 +448,10 @@ declare class Agent extends BaseResource {
330
448
  stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
331
449
  processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
332
450
  }>;
451
+ /**
452
+ * Processes the stream response and handles tool calls
453
+ */
454
+ private processStreamResponse;
333
455
  /**
334
456
  * Gets details about a specific tool available to the agent
335
457
  * @param toolId - ID of the tool to retrieve
@@ -585,6 +707,38 @@ declare class Workflow extends BaseResource {
585
707
  * @returns Promise containing workflow runs array
586
708
  */
587
709
  runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
710
+ /**
711
+ * Retrieves a specific workflow run by its ID
712
+ * @param runId - The ID of the workflow run to retrieve
713
+ * @returns Promise containing the workflow run details
714
+ */
715
+ runById(runId: string): Promise<GetWorkflowRunByIdResponse>;
716
+ /**
717
+ * Retrieves the execution result for a specific workflow run by its ID
718
+ * @param runId - The ID of the workflow run to retrieve the execution result for
719
+ * @returns Promise containing the workflow run execution result
720
+ */
721
+ runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse>;
722
+ /**
723
+ * Cancels a specific workflow run by its ID
724
+ * @param runId - The ID of the workflow run to cancel
725
+ * @returns Promise containing a success message
726
+ */
727
+ cancelRun(runId: string): Promise<{
728
+ message: string;
729
+ }>;
730
+ /**
731
+ * Sends an event to a specific workflow run by its ID
732
+ * @param params - Object containing the runId, event and data
733
+ * @returns Promise containing a success message
734
+ */
735
+ sendRunEvent(params: {
736
+ runId: string;
737
+ event: string;
738
+ data: unknown;
739
+ }): Promise<{
740
+ message: string;
741
+ }>;
588
742
  /**
589
743
  * Creates a new workflow run
590
744
  * @param params - Optional object containing the optional runId
@@ -631,15 +785,18 @@ declare class Workflow extends BaseResource {
631
785
  runtimeContext?: RuntimeContext | Record<string, any>;
632
786
  }): Promise<WorkflowRunResult>;
633
787
  /**
634
- * Starts a vNext workflow run and returns a stream
788
+ * Starts a workflow run and returns a stream
635
789
  * @param params - Object containing the optional runId, inputData and runtimeContext
636
- * @returns Promise containing the vNext workflow execution results
790
+ * @returns Promise containing the workflow execution results
637
791
  */
638
792
  stream(params: {
639
793
  runId?: string;
640
794
  inputData: Record<string, any>;
641
795
  runtimeContext?: RuntimeContext;
642
- }): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
796
+ }): Promise<stream_web.ReadableStream<{
797
+ type: string;
798
+ payload: any;
799
+ }>>;
643
800
  /**
644
801
  * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
645
802
  * @param params - Object containing the runId, step, resumeData and runtimeContext
@@ -734,6 +891,73 @@ declare class MCPTool extends BaseResource {
734
891
  }): Promise<any>;
735
892
  }
736
893
 
894
+ declare class VNextNetwork extends BaseResource {
895
+ private networkId;
896
+ constructor(options: ClientOptions, networkId: string);
897
+ /**
898
+ * Retrieves details about the network
899
+ * @returns Promise containing vNext network details
900
+ */
901
+ details(): Promise<GetVNextNetworkResponse>;
902
+ /**
903
+ * Generates a response from the v-next network
904
+ * @param params - Generation parameters including message
905
+ * @returns Promise containing the generated response
906
+ */
907
+ generate(params: GenerateOrStreamVNextNetworkParams): Promise<GenerateVNextNetworkResponse>;
908
+ /**
909
+ * Generates a response from the v-next network using multiple primitives
910
+ * @param params - Generation parameters including message
911
+ * @returns Promise containing the generated response
912
+ */
913
+ loop(params: {
914
+ message: string;
915
+ }): Promise<LoopVNextNetworkResponse>;
916
+ private streamProcessor;
917
+ /**
918
+ * Streams a response from the v-next network
919
+ * @param params - Stream parameters including message
920
+ * @returns Promise containing the results
921
+ */
922
+ stream(params: GenerateOrStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
923
+ /**
924
+ * Streams a response from the v-next network loop
925
+ * @param params - Stream parameters including message
926
+ * @returns Promise containing the results
927
+ */
928
+ loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
929
+ }
930
+
931
+ declare class NetworkMemoryThread extends BaseResource {
932
+ private threadId;
933
+ private networkId;
934
+ constructor(options: ClientOptions, threadId: string, networkId: string);
935
+ /**
936
+ * Retrieves the memory thread details
937
+ * @returns Promise containing thread details including title and metadata
938
+ */
939
+ get(): Promise<StorageThreadType>;
940
+ /**
941
+ * Updates the memory thread properties
942
+ * @param params - Update parameters including title and metadata
943
+ * @returns Promise containing updated thread details
944
+ */
945
+ update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
946
+ /**
947
+ * Deletes the memory thread
948
+ * @returns Promise containing deletion result
949
+ */
950
+ delete(): Promise<{
951
+ result: string;
952
+ }>;
953
+ /**
954
+ * Retrieves messages associated with the thread
955
+ * @param params - Optional parameters including limit for number of messages to retrieve
956
+ * @returns Promise containing thread messages and UI messages
957
+ */
958
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
959
+ }
960
+
737
961
  declare class MastraClient extends BaseResource {
738
962
  constructor(options: ClientOptions);
739
963
  /**
@@ -781,6 +1005,37 @@ declare class MastraClient extends BaseResource {
781
1005
  getMemoryStatus(agentId: string): Promise<{
782
1006
  result: boolean;
783
1007
  }>;
1008
+ /**
1009
+ * Retrieves memory threads for a resource
1010
+ * @param params - Parameters containing the resource ID
1011
+ * @returns Promise containing array of memory threads
1012
+ */
1013
+ getNetworkMemoryThreads(params: GetNetworkMemoryThreadParams): Promise<GetMemoryThreadResponse>;
1014
+ /**
1015
+ * Creates a new memory thread
1016
+ * @param params - Parameters for creating the memory thread
1017
+ * @returns Promise containing the created memory thread
1018
+ */
1019
+ createNetworkMemoryThread(params: CreateNetworkMemoryThreadParams): Promise<CreateMemoryThreadResponse>;
1020
+ /**
1021
+ * Gets a memory thread instance by ID
1022
+ * @param threadId - ID of the memory thread to retrieve
1023
+ * @returns MemoryThread instance
1024
+ */
1025
+ getNetworkMemoryThread(threadId: string, networkId: string): NetworkMemoryThread;
1026
+ /**
1027
+ * Saves messages to memory
1028
+ * @param params - Parameters containing messages to save
1029
+ * @returns Promise containing the saved messages
1030
+ */
1031
+ saveNetworkMessageToMemory(params: SaveNetworkMessageToMemoryParams): Promise<SaveMessageToMemoryResponse>;
1032
+ /**
1033
+ * Gets the status of the memory system
1034
+ * @returns Promise containing memory system status
1035
+ */
1036
+ getNetworkMemoryStatus(networkId: string): Promise<{
1037
+ result: boolean;
1038
+ }>;
784
1039
  /**
785
1040
  * Retrieves all available tools
786
1041
  * @returns Promise containing map of tool IDs to tool details
@@ -849,13 +1104,24 @@ declare class MastraClient extends BaseResource {
849
1104
  * Retrieves all available networks
850
1105
  * @returns Promise containing map of network IDs to network details
851
1106
  */
852
- getNetworks(): Promise<Record<string, GetNetworkResponse>>;
1107
+ getNetworks(): Promise<Array<GetNetworkResponse>>;
1108
+ /**
1109
+ * Retrieves all available vNext networks
1110
+ * @returns Promise containing map of vNext network IDs to vNext network details
1111
+ */
1112
+ getVNextNetworks(): Promise<Array<GetVNextNetworkResponse>>;
853
1113
  /**
854
1114
  * Gets a network instance by ID
855
1115
  * @param networkId - ID of the network to retrieve
856
1116
  * @returns Network instance
857
1117
  */
858
1118
  getNetwork(networkId: string): Network;
1119
+ /**
1120
+ * Gets a vNext network instance by ID
1121
+ * @param networkId - ID of the vNext network to retrieve
1122
+ * @returns vNext Network instance
1123
+ */
1124
+ getVNextNetwork(networkId: string): VNextNetwork;
859
1125
  /**
860
1126
  * Retrieves a list of available MCP servers.
861
1127
  * @param params - Optional parameters for pagination (limit, offset).
@@ -896,4 +1162,4 @@ declare class MastraClient extends BaseResource {
896
1162
  getA2A(agentId: string): A2A;
897
1163
  }
898
1164
 
899
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
1165
+ 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 };