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

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,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';
@@ -51,13 +51,15 @@ type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> =
51
51
  output?: T;
52
52
  experimental_output?: T;
53
53
  runtimeContext?: RuntimeContext | Record<string, any>;
54
- } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
54
+ clientTools?: ToolsInput;
55
+ } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
55
56
  type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
56
57
  messages: string | string[] | CoreMessage[] | AiMessageType[];
57
58
  output?: T;
58
59
  experimental_output?: T;
59
60
  runtimeContext?: RuntimeContext | Record<string, any>;
60
- } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
61
+ clientTools?: ToolsInput;
62
+ } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
61
63
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
62
64
  evals: any[];
63
65
  instructions: string;
@@ -87,6 +89,8 @@ interface GetWorkflowRunsParams {
87
89
  }
88
90
  type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
89
91
  type GetWorkflowRunsResponse = WorkflowRuns;
92
+ type GetWorkflowRunByIdResponse = WorkflowRun;
93
+ type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
90
94
  type LegacyWorkflowRunResult = {
91
95
  activePaths: Record<string, {
92
96
  status: string;
@@ -145,10 +149,14 @@ interface GetVectorIndexResponse {
145
149
  count: number;
146
150
  }
147
151
  interface SaveMessageToMemoryParams {
148
- messages: MessageType[];
152
+ messages: MastraMessageV1[];
149
153
  agentId: string;
150
154
  }
151
- type SaveMessageToMemoryResponse = MessageType[];
155
+ interface SaveNetworkMessageToMemoryParams {
156
+ messages: MastraMessageV1[];
157
+ networkId: string;
158
+ }
159
+ type SaveMessageToMemoryResponse = MastraMessageV1[];
152
160
  interface CreateMemoryThreadParams {
153
161
  title?: string;
154
162
  metadata?: Record<string, any>;
@@ -156,11 +164,22 @@ interface CreateMemoryThreadParams {
156
164
  threadId?: string;
157
165
  agentId: string;
158
166
  }
167
+ interface CreateNetworkMemoryThreadParams {
168
+ title?: string;
169
+ metadata?: Record<string, any>;
170
+ resourceId: string;
171
+ threadId?: string;
172
+ networkId: string;
173
+ }
159
174
  type CreateMemoryThreadResponse = StorageThreadType;
160
175
  interface GetMemoryThreadParams {
161
176
  resourceId: string;
162
177
  agentId: string;
163
178
  }
179
+ interface GetNetworkMemoryThreadParams {
180
+ resourceId: string;
181
+ networkId: string;
182
+ }
164
183
  type GetMemoryThreadResponse = StorageThreadType[];
165
184
  interface UpdateMemoryThreadParams {
166
185
  title: string;
@@ -179,12 +198,30 @@ interface GetMemoryThreadMessagesResponse {
179
198
  }
180
199
  interface GetLogsParams {
181
200
  transportId: string;
201
+ fromDate?: Date;
202
+ toDate?: Date;
203
+ logLevel?: LogLevel;
204
+ filters?: Record<string, string>;
205
+ page?: number;
206
+ perPage?: number;
182
207
  }
183
208
  interface GetLogParams {
184
209
  runId: string;
185
210
  transportId: string;
211
+ fromDate?: Date;
212
+ toDate?: Date;
213
+ logLevel?: LogLevel;
214
+ filters?: Record<string, string>;
215
+ page?: number;
216
+ perPage?: number;
186
217
  }
187
- type GetLogsResponse = BaseLogMessage[];
218
+ type GetLogsResponse = {
219
+ logs: BaseLogMessage[];
220
+ total: number;
221
+ page: number;
222
+ perPage: number;
223
+ hasMore: boolean;
224
+ };
188
225
  type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
189
226
  type SpanStatus = {
190
227
  code: number;
@@ -236,6 +273,7 @@ interface GetTelemetryParams {
236
273
  toDate?: Date;
237
274
  }
238
275
  interface GetNetworkResponse {
276
+ id: string;
239
277
  name: string;
240
278
  instructions: string;
241
279
  agents: Array<{
@@ -249,6 +287,50 @@ interface GetNetworkResponse {
249
287
  };
250
288
  state?: Record<string, any>;
251
289
  }
290
+ interface GetVNextNetworkResponse {
291
+ id: string;
292
+ name: string;
293
+ instructions: string;
294
+ agents: Array<{
295
+ name: string;
296
+ provider: string;
297
+ modelId: string;
298
+ }>;
299
+ routingModel: {
300
+ provider: string;
301
+ modelId: string;
302
+ };
303
+ workflows: Array<{
304
+ name: string;
305
+ description: string;
306
+ inputSchema: string | undefined;
307
+ outputSchema: string | undefined;
308
+ }>;
309
+ }
310
+ interface GenerateVNextNetworkResponse {
311
+ task: string;
312
+ result: string;
313
+ resourceId: string;
314
+ resourceType: 'none' | 'tool' | 'agent' | 'workflow';
315
+ }
316
+ interface GenerateOrStreamVNextNetworkParams {
317
+ message: string;
318
+ threadId?: string;
319
+ resourceId?: string;
320
+ }
321
+ interface LoopStreamVNextNetworkParams {
322
+ message: string;
323
+ threadId?: string;
324
+ resourceId?: string;
325
+ maxIterations?: number;
326
+ }
327
+ interface LoopVNextNetworkResponse {
328
+ status: 'success';
329
+ result: {
330
+ text: string;
331
+ };
332
+ steps: WorkflowResult<any, any>['steps'];
333
+ }
252
334
  interface McpServerListResponse {
253
335
  servers: ServerInfo[];
254
336
  next: string | null;
@@ -259,6 +341,7 @@ interface McpToolInfo {
259
341
  name: string;
260
342
  description?: string;
261
343
  inputSchema: string;
344
+ toolType?: MCPToolType;
262
345
  }
263
346
  interface McpServerToolListResponse {
264
347
  tools: McpToolInfo[];
@@ -306,6 +389,13 @@ declare class AgentVoice extends BaseResource {
306
389
  voiceId: string;
307
390
  [key: string]: any;
308
391
  }>>;
392
+ /**
393
+ * Get the listener configuration for the agent's voice provider
394
+ * @returns Promise containing a check if the agent has listening capabilities
395
+ */
396
+ getListener(): Promise<{
397
+ enabled: boolean;
398
+ }>;
309
399
  }
310
400
  declare class Agent extends BaseResource {
311
401
  private agentId;
@@ -321,7 +411,19 @@ declare class Agent extends BaseResource {
321
411
  * @param params - Generation parameters including prompt
322
412
  * @returns Promise containing the generated response
323
413
  */
324
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
414
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
415
+ output?: never;
416
+ experimental_output?: never;
417
+ }): Promise<GenerateReturn<T>>;
418
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
419
+ output: T;
420
+ experimental_output?: never;
421
+ }): Promise<GenerateReturn<T>>;
422
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
423
+ output?: never;
424
+ experimental_output: T;
425
+ }): Promise<GenerateReturn<T>>;
426
+ private processChatResponse;
325
427
  /**
326
428
  * Streams a response from the agent
327
429
  * @param params - Stream parameters including prompt
@@ -330,6 +432,10 @@ declare class Agent extends BaseResource {
330
432
  stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
331
433
  processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
332
434
  }>;
435
+ /**
436
+ * Processes the stream response and handles tool calls
437
+ */
438
+ private processStreamResponse;
333
439
  /**
334
440
  * Gets details about a specific tool available to the agent
335
441
  * @param toolId - ID of the tool to retrieve
@@ -585,6 +691,18 @@ declare class Workflow extends BaseResource {
585
691
  * @returns Promise containing workflow runs array
586
692
  */
587
693
  runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
694
+ /**
695
+ * Retrieves a specific workflow run by its ID
696
+ * @param runId - The ID of the workflow run to retrieve
697
+ * @returns Promise containing the workflow run details
698
+ */
699
+ runById(runId: string): Promise<GetWorkflowRunByIdResponse>;
700
+ /**
701
+ * Retrieves the execution result for a specific workflow run by its ID
702
+ * @param runId - The ID of the workflow run to retrieve the execution result for
703
+ * @returns Promise containing the workflow run execution result
704
+ */
705
+ runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse>;
588
706
  /**
589
707
  * Creates a new workflow run
590
708
  * @param params - Optional object containing the optional runId
@@ -631,9 +749,9 @@ declare class Workflow extends BaseResource {
631
749
  runtimeContext?: RuntimeContext | Record<string, any>;
632
750
  }): Promise<WorkflowRunResult>;
633
751
  /**
634
- * Starts a vNext workflow run and returns a stream
752
+ * Starts a workflow run and returns a stream
635
753
  * @param params - Object containing the optional runId, inputData and runtimeContext
636
- * @returns Promise containing the vNext workflow execution results
754
+ * @returns Promise containing the workflow execution results
637
755
  */
638
756
  stream(params: {
639
757
  runId?: string;
@@ -734,6 +852,73 @@ declare class MCPTool extends BaseResource {
734
852
  }): Promise<any>;
735
853
  }
736
854
 
855
+ declare class VNextNetwork extends BaseResource {
856
+ private networkId;
857
+ constructor(options: ClientOptions, networkId: string);
858
+ /**
859
+ * Retrieves details about the network
860
+ * @returns Promise containing vNext network details
861
+ */
862
+ details(): Promise<GetVNextNetworkResponse>;
863
+ /**
864
+ * Generates a response from the v-next network
865
+ * @param params - Generation parameters including message
866
+ * @returns Promise containing the generated response
867
+ */
868
+ generate(params: GenerateOrStreamVNextNetworkParams): Promise<GenerateVNextNetworkResponse>;
869
+ /**
870
+ * Generates a response from the v-next network using multiple primitives
871
+ * @param params - Generation parameters including message
872
+ * @returns Promise containing the generated response
873
+ */
874
+ loop(params: {
875
+ message: string;
876
+ }): Promise<LoopVNextNetworkResponse>;
877
+ private streamProcessor;
878
+ /**
879
+ * Streams a response from the v-next network
880
+ * @param params - Stream parameters including message
881
+ * @returns Promise containing the results
882
+ */
883
+ stream(params: GenerateOrStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
884
+ /**
885
+ * Streams a response from the v-next network loop
886
+ * @param params - Stream parameters including message
887
+ * @returns Promise containing the results
888
+ */
889
+ loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
890
+ }
891
+
892
+ declare class NetworkMemoryThread extends BaseResource {
893
+ private threadId;
894
+ private networkId;
895
+ constructor(options: ClientOptions, threadId: string, networkId: string);
896
+ /**
897
+ * Retrieves the memory thread details
898
+ * @returns Promise containing thread details including title and metadata
899
+ */
900
+ get(): Promise<StorageThreadType>;
901
+ /**
902
+ * Updates the memory thread properties
903
+ * @param params - Update parameters including title and metadata
904
+ * @returns Promise containing updated thread details
905
+ */
906
+ update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
907
+ /**
908
+ * Deletes the memory thread
909
+ * @returns Promise containing deletion result
910
+ */
911
+ delete(): Promise<{
912
+ result: string;
913
+ }>;
914
+ /**
915
+ * Retrieves messages associated with the thread
916
+ * @param params - Optional parameters including limit for number of messages to retrieve
917
+ * @returns Promise containing thread messages and UI messages
918
+ */
919
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
920
+ }
921
+
737
922
  declare class MastraClient extends BaseResource {
738
923
  constructor(options: ClientOptions);
739
924
  /**
@@ -781,6 +966,37 @@ declare class MastraClient extends BaseResource {
781
966
  getMemoryStatus(agentId: string): Promise<{
782
967
  result: boolean;
783
968
  }>;
969
+ /**
970
+ * Retrieves memory threads for a resource
971
+ * @param params - Parameters containing the resource ID
972
+ * @returns Promise containing array of memory threads
973
+ */
974
+ getNetworkMemoryThreads(params: GetNetworkMemoryThreadParams): Promise<GetMemoryThreadResponse>;
975
+ /**
976
+ * Creates a new memory thread
977
+ * @param params - Parameters for creating the memory thread
978
+ * @returns Promise containing the created memory thread
979
+ */
980
+ createNetworkMemoryThread(params: CreateNetworkMemoryThreadParams): Promise<CreateMemoryThreadResponse>;
981
+ /**
982
+ * Gets a memory thread instance by ID
983
+ * @param threadId - ID of the memory thread to retrieve
984
+ * @returns MemoryThread instance
985
+ */
986
+ getNetworkMemoryThread(threadId: string, networkId: string): NetworkMemoryThread;
987
+ /**
988
+ * Saves messages to memory
989
+ * @param params - Parameters containing messages to save
990
+ * @returns Promise containing the saved messages
991
+ */
992
+ saveNetworkMessageToMemory(params: SaveNetworkMessageToMemoryParams): Promise<SaveMessageToMemoryResponse>;
993
+ /**
994
+ * Gets the status of the memory system
995
+ * @returns Promise containing memory system status
996
+ */
997
+ getNetworkMemoryStatus(networkId: string): Promise<{
998
+ result: boolean;
999
+ }>;
784
1000
  /**
785
1001
  * Retrieves all available tools
786
1002
  * @returns Promise containing map of tool IDs to tool details
@@ -849,13 +1065,24 @@ declare class MastraClient extends BaseResource {
849
1065
  * Retrieves all available networks
850
1066
  * @returns Promise containing map of network IDs to network details
851
1067
  */
852
- getNetworks(): Promise<Record<string, GetNetworkResponse>>;
1068
+ getNetworks(): Promise<Array<GetNetworkResponse>>;
1069
+ /**
1070
+ * Retrieves all available vNext networks
1071
+ * @returns Promise containing map of vNext network IDs to vNext network details
1072
+ */
1073
+ getVNextNetworks(): Promise<Array<GetVNextNetworkResponse>>;
853
1074
  /**
854
1075
  * Gets a network instance by ID
855
1076
  * @param networkId - ID of the network to retrieve
856
1077
  * @returns Network instance
857
1078
  */
858
1079
  getNetwork(networkId: string): Network;
1080
+ /**
1081
+ * Gets a vNext network instance by ID
1082
+ * @param networkId - ID of the vNext network to retrieve
1083
+ * @returns vNext Network instance
1084
+ */
1085
+ getVNextNetwork(networkId: string): VNextNetwork;
859
1086
  /**
860
1087
  * Retrieves a list of available MCP servers.
861
1088
  * @param params - Optional parameters for pagination (limit, offset).
@@ -896,4 +1123,4 @@ declare class MastraClient extends BaseResource {
896
1123
  getA2A(agentId: string): A2A;
897
1124
  }
898
1125
 
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 };
1126
+ 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 };