@mastra/client-js 0.0.0-switch-to-core-20250424015131 → 0.0.0-vector-query-sources-20250516172905

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,8 +1,14 @@
1
- import { CoreMessage, AiMessageType, StorageThreadType, MessageType, StepAction, StepGraph, WorkflowRunResult as WorkflowRunResult$1, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
1
+ import { AbstractAgent } from '@ag-ui/client';
2
+ import { processDataStream } from '@ai-sdk/ui-utils';
3
+ import { StepAction, StepGraph, CoreMessage, AiMessageType, StorageThreadType, MessageType, WorkflowRuns, WorkflowRunResult as WorkflowRunResult$1, VNextWorkflowRuns, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
2
4
  import { JSONSchema7 } from 'json-schema';
3
5
  import { ZodSchema } from 'zod';
4
- import { processDataStream } from '@ai-sdk/ui-utils';
5
6
  import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
7
+ import { RuntimeContext } from '@mastra/core/runtime-context';
8
+ import { ServerInfo, ServerDetailInfo } from '@mastra/core/mcp';
9
+ import { NewWorkflow, WorkflowResult, WatchEvent } from '@mastra/core/workflows/vNext';
10
+ import { RuntimeContext as RuntimeContext$1 } from '@mastra/core/di';
11
+ import { AgentCard, TaskSendParams, Task, TaskQueryParams, TaskIdParams } from '@mastra/core/a2a';
6
12
 
7
13
  interface ClientOptions {
8
14
  /** Base URL for API requests */
@@ -23,21 +29,36 @@ interface RequestOptions {
23
29
  stream?: boolean;
24
30
  signal?: AbortSignal;
25
31
  }
32
+ type WithoutMethods<T> = {
33
+ [K in keyof T as T[K] extends (...args: any[]) => any ? never : T[K] extends {
34
+ (): any;
35
+ } ? never : T[K] extends undefined | ((...args: any[]) => any) ? never : K]: T[K];
36
+ };
26
37
  interface GetAgentResponse {
27
38
  name: string;
28
39
  instructions: string;
29
40
  tools: Record<string, GetToolResponse>;
41
+ workflows: Record<string, GetWorkflowResponse>;
30
42
  provider: string;
31
43
  modelId: string;
32
44
  }
33
45
  type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
34
46
  messages: string | string[] | CoreMessage[] | AiMessageType[];
35
- } & Partial<AgentGenerateOptions<T>>;
47
+ output?: T;
48
+ experimental_output?: T;
49
+ runtimeContext?: RuntimeContext;
50
+ } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
36
51
  type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
37
52
  messages: string | string[] | CoreMessage[] | AiMessageType[];
38
- } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
53
+ output?: T;
54
+ experimental_output?: T;
55
+ runtimeContext?: RuntimeContext;
56
+ } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
39
57
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
40
58
  evals: any[];
59
+ instructions: string;
60
+ name: string;
61
+ id: string;
41
62
  }
42
63
  interface GetToolResponse {
43
64
  id: string;
@@ -53,6 +74,15 @@ interface GetWorkflowResponse {
53
74
  stepSubscriberGraph: Record<string, StepGraph>;
54
75
  workflowId?: string;
55
76
  }
77
+ interface GetWorkflowRunsParams {
78
+ fromDate?: Date;
79
+ toDate?: Date;
80
+ limit?: number;
81
+ offset?: number;
82
+ resourceId?: string;
83
+ }
84
+ type GetWorkflowRunsResponse = WorkflowRuns;
85
+ type GetVNextWorkflowRunsResponse = VNextWorkflowRuns;
56
86
  type WorkflowRunResult = {
57
87
  activePaths: Record<string, {
58
88
  status: string;
@@ -63,6 +93,26 @@ type WorkflowRunResult = {
63
93
  timestamp: number;
64
94
  runId: string;
65
95
  };
96
+ interface GetVNextWorkflowResponse {
97
+ name: string;
98
+ steps: {
99
+ [key: string]: {
100
+ id: string;
101
+ description: string;
102
+ inputSchema: string;
103
+ outputSchema: string;
104
+ resumeSchema: string;
105
+ suspendSchema: string;
106
+ };
107
+ };
108
+ stepGraph: NewWorkflow['serializedStepGraph'];
109
+ inputSchema: string;
110
+ outputSchema: string;
111
+ }
112
+ type VNextWorkflowWatchResult = WatchEvent & {
113
+ runId: string;
114
+ };
115
+ type VNextWorkflowRunResult = WorkflowResult<any, any>;
66
116
  interface UpsertVectorParams {
67
117
  indexName: string;
68
118
  vectors: number[][];
@@ -112,6 +162,12 @@ interface UpdateMemoryThreadParams {
112
162
  metadata: Record<string, any>;
113
163
  resourceId: string;
114
164
  }
165
+ interface GetMemoryThreadMessagesParams {
166
+ /**
167
+ * Limit the number of messages to retrieve (default: 40)
168
+ */
169
+ limit?: number;
170
+ }
115
171
  interface GetMemoryThreadMessagesResponse {
116
172
  messages: CoreMessage[];
117
173
  uiMessages: AiMessageType[];
@@ -171,6 +227,8 @@ interface GetTelemetryParams {
171
227
  page?: number;
172
228
  perPage?: number;
173
229
  attribute?: Record<string, string>;
230
+ fromDate?: Date;
231
+ toDate?: Date;
174
232
  }
175
233
  interface GetNetworkResponse {
176
234
  name: string;
@@ -186,6 +244,20 @@ interface GetNetworkResponse {
186
244
  };
187
245
  state?: Record<string, any>;
188
246
  }
247
+ interface McpServerListResponse {
248
+ servers: ServerInfo[];
249
+ next: string | null;
250
+ total_count: number;
251
+ }
252
+ interface McpToolInfo {
253
+ id: string;
254
+ name: string;
255
+ description?: string;
256
+ inputSchema: string;
257
+ }
258
+ interface McpServerToolListResponse {
259
+ tools: McpToolInfo[];
260
+ }
189
261
 
190
262
  declare class BaseResource {
191
263
  readonly options: ClientOptions;
@@ -218,7 +290,9 @@ declare class AgentVoice extends BaseResource {
218
290
  * @param options - Optional provider-specific options
219
291
  * @returns Promise containing the transcribed text
220
292
  */
221
- listen(audio: Blob, options?: Record<string, any>): Promise<Response>;
293
+ listen(audio: Blob, options?: Record<string, any>): Promise<{
294
+ text: string;
295
+ }>;
222
296
  /**
223
297
  * Get available speakers for the agent's voice provider
224
298
  * @returns Promise containing list of available speakers
@@ -257,6 +331,16 @@ declare class Agent extends BaseResource {
257
331
  * @returns Promise containing tool details
258
332
  */
259
333
  getTool(toolId: string): Promise<GetToolResponse>;
334
+ /**
335
+ * Executes a tool for the agent
336
+ * @param toolId - ID of the tool to execute
337
+ * @param params - Parameters required for tool execution
338
+ * @returns Promise containing the tool execution results
339
+ */
340
+ executeTool(toolId: string, params: {
341
+ data: any;
342
+ runtimeContext?: RuntimeContext$1;
343
+ }): Promise<any>;
260
344
  /**
261
345
  * Retrieves evaluation results for the agent
262
346
  * @returns Promise containing agent evaluations
@@ -317,9 +401,10 @@ declare class MemoryThread extends BaseResource {
317
401
  }>;
318
402
  /**
319
403
  * Retrieves messages associated with the thread
404
+ * @param params - Optional parameters including limit for number of messages to retrieve
320
405
  * @returns Promise containing thread messages and UI messages
321
406
  */
322
- getMessages(): Promise<GetMemoryThreadMessagesResponse>;
407
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
323
408
  }
324
409
 
325
410
  declare class Vector extends BaseResource {
@@ -376,6 +461,12 @@ declare class Workflow extends BaseResource {
376
461
  * @returns Promise containing workflow details including steps and graphs
377
462
  */
378
463
  details(): Promise<GetWorkflowResponse>;
464
+ /**
465
+ * Retrieves all runs for a workflow
466
+ * @param params - Parameters for filtering runs
467
+ * @returns Promise containing workflow runs array
468
+ */
469
+ runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
379
470
  /**
380
471
  * @deprecated Use `startAsync` instead
381
472
  * Executes the workflow with the provided parameters
@@ -469,6 +560,161 @@ declare class Tool extends BaseResource {
469
560
  */
470
561
  execute(params: {
471
562
  data: any;
563
+ runId?: string;
564
+ runtimeContext?: RuntimeContext$1;
565
+ }): Promise<any>;
566
+ }
567
+
568
+ declare class VNextWorkflow extends BaseResource {
569
+ private workflowId;
570
+ constructor(options: ClientOptions, workflowId: string);
571
+ /**
572
+ * Creates an async generator that processes a readable stream and yields vNext workflow records
573
+ * separated by the Record Separator character (\x1E)
574
+ *
575
+ * @param stream - The readable stream to process
576
+ * @returns An async generator that yields parsed records
577
+ */
578
+ private streamProcessor;
579
+ /**
580
+ * Retrieves details about the vNext workflow
581
+ * @returns Promise containing vNext workflow details including steps and graphs
582
+ */
583
+ details(): Promise<GetVNextWorkflowResponse>;
584
+ /**
585
+ * Retrieves all runs for a vNext workflow
586
+ * @param params - Parameters for filtering runs
587
+ * @returns Promise containing vNext workflow runs array
588
+ */
589
+ runs(params?: GetWorkflowRunsParams): Promise<GetVNextWorkflowRunsResponse>;
590
+ /**
591
+ * Creates a new vNext workflow run
592
+ * @param params - Optional object containing the optional runId
593
+ * @returns Promise containing the runId of the created run
594
+ */
595
+ createRun(params?: {
596
+ runId?: string;
597
+ }): Promise<{
598
+ runId: string;
599
+ }>;
600
+ /**
601
+ * Starts a vNext workflow run synchronously without waiting for the workflow to complete
602
+ * @param params - Object containing the runId, inputData and runtimeContext
603
+ * @returns Promise containing success message
604
+ */
605
+ start(params: {
606
+ runId: string;
607
+ inputData: Record<string, any>;
608
+ runtimeContext?: RuntimeContext;
609
+ }): Promise<{
610
+ message: string;
611
+ }>;
612
+ /**
613
+ * Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
614
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
615
+ * @returns Promise containing success message
616
+ */
617
+ resume({ step, runId, resumeData, ...rest }: {
618
+ step: string | string[];
619
+ runId: string;
620
+ resumeData?: Record<string, any>;
621
+ runtimeContext?: RuntimeContext;
622
+ }): Promise<{
623
+ message: string;
624
+ }>;
625
+ /**
626
+ * Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
627
+ * @param params - Object containing the optional runId, inputData and runtimeContext
628
+ * @returns Promise containing the vNext workflow execution results
629
+ */
630
+ startAsync(params: {
631
+ runId?: string;
632
+ inputData: Record<string, any>;
633
+ runtimeContext?: RuntimeContext;
634
+ }): Promise<VNextWorkflowRunResult>;
635
+ /**
636
+ * Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
637
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
638
+ * @returns Promise containing the vNext workflow resume results
639
+ */
640
+ resumeAsync(params: {
641
+ runId: string;
642
+ step: string | string[];
643
+ resumeData?: Record<string, any>;
644
+ runtimeContext?: RuntimeContext;
645
+ }): Promise<VNextWorkflowRunResult>;
646
+ /**
647
+ * Watches vNext workflow transitions in real-time
648
+ * @param runId - Optional run ID to filter the watch stream
649
+ * @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
650
+ */
651
+ watch({ runId }: {
652
+ runId?: string;
653
+ }, onRecord: (record: VNextWorkflowWatchResult) => void): Promise<void>;
654
+ }
655
+
656
+ /**
657
+ * Class for interacting with an agent via the A2A protocol
658
+ */
659
+ declare class A2A extends BaseResource {
660
+ private agentId;
661
+ constructor(options: ClientOptions, agentId: string);
662
+ /**
663
+ * Get the agent card with metadata about the agent
664
+ * @returns Promise containing the agent card information
665
+ */
666
+ getCard(): Promise<AgentCard>;
667
+ /**
668
+ * Send a message to the agent and get a response
669
+ * @param params - Parameters for the task
670
+ * @returns Promise containing the task response
671
+ */
672
+ sendMessage(params: TaskSendParams): Promise<{
673
+ task: Task;
674
+ }>;
675
+ /**
676
+ * Get the status and result of a task
677
+ * @param params - Parameters for querying the task
678
+ * @returns Promise containing the task response
679
+ */
680
+ getTask(params: TaskQueryParams): Promise<Task>;
681
+ /**
682
+ * Cancel a running task
683
+ * @param params - Parameters identifying the task to cancel
684
+ * @returns Promise containing the task response
685
+ */
686
+ cancelTask(params: TaskIdParams): Promise<{
687
+ task: Task;
688
+ }>;
689
+ /**
690
+ * Send a message and subscribe to streaming updates (not fully implemented)
691
+ * @param params - Parameters for the task
692
+ * @returns Promise containing the task response
693
+ */
694
+ sendAndSubscribe(params: TaskSendParams): Promise<Response>;
695
+ }
696
+
697
+ /**
698
+ * Represents a specific tool available on a specific MCP server.
699
+ * Provides methods to get details and execute the tool.
700
+ */
701
+ declare class MCPTool extends BaseResource {
702
+ private serverId;
703
+ private toolId;
704
+ constructor(options: ClientOptions, serverId: string, toolId: string);
705
+ /**
706
+ * Retrieves details about this specific tool from the MCP server.
707
+ * @returns Promise containing the tool's information (name, description, schema).
708
+ */
709
+ details(): Promise<McpToolInfo>;
710
+ /**
711
+ * Executes this specific tool on the MCP server.
712
+ * @param params - Parameters for tool execution, including data/args and optional runtimeContext.
713
+ * @returns Promise containing the result of the tool execution.
714
+ */
715
+ execute(params: {
716
+ data?: any;
717
+ runtimeContext?: RuntimeContext;
472
718
  }): Promise<any>;
473
719
  }
474
720
 
@@ -479,6 +725,9 @@ declare class MastraClient extends BaseResource {
479
725
  * @returns Promise containing map of agent IDs to agent details
480
726
  */
481
727
  getAgents(): Promise<Record<string, GetAgentResponse>>;
728
+ getAGUI({ resourceId }: {
729
+ resourceId: string;
730
+ }): Promise<Record<string, AbstractAgent>>;
482
731
  /**
483
732
  * Gets an agent instance by ID
484
733
  * @param agentId - ID of the agent to retrieve
@@ -538,6 +787,17 @@ declare class MastraClient extends BaseResource {
538
787
  * @returns Workflow instance
539
788
  */
540
789
  getWorkflow(workflowId: string): Workflow;
790
+ /**
791
+ * Retrieves all available vNext workflows
792
+ * @returns Promise containing map of vNext workflow IDs to vNext workflow details
793
+ */
794
+ getVNextWorkflows(): Promise<Record<string, GetVNextWorkflowResponse>>;
795
+ /**
796
+ * Gets a vNext workflow instance by ID
797
+ * @param workflowId - ID of the vNext workflow to retrieve
798
+ * @returns vNext Workflow instance
799
+ */
800
+ getVNextWorkflow(workflowId: string): VNextWorkflow;
541
801
  /**
542
802
  * Gets a vector instance by name
543
803
  * @param vectorName - Name of the vector to retrieve
@@ -580,6 +840,44 @@ declare class MastraClient extends BaseResource {
580
840
  * @returns Network instance
581
841
  */
582
842
  getNetwork(networkId: string): Network;
843
+ /**
844
+ * Retrieves a list of available MCP servers.
845
+ * @param params - Optional parameters for pagination (limit, offset).
846
+ * @returns Promise containing the list of MCP servers and pagination info.
847
+ */
848
+ getMcpServers(params?: {
849
+ limit?: number;
850
+ offset?: number;
851
+ }): Promise<McpServerListResponse>;
852
+ /**
853
+ * Retrieves detailed information for a specific MCP server.
854
+ * @param serverId - The ID of the MCP server to retrieve.
855
+ * @param params - Optional parameters, e.g., specific version.
856
+ * @returns Promise containing the detailed MCP server information.
857
+ */
858
+ getMcpServerDetails(serverId: string, params?: {
859
+ version?: string;
860
+ }): Promise<ServerDetailInfo>;
861
+ /**
862
+ * Retrieves a list of tools for a specific MCP server.
863
+ * @param serverId - The ID of the MCP server.
864
+ * @returns Promise containing the list of tools.
865
+ */
866
+ getMcpServerTools(serverId: string): Promise<McpServerToolListResponse>;
867
+ /**
868
+ * Gets an MCPTool resource instance for a specific tool on an MCP server.
869
+ * This instance can then be used to fetch details or execute the tool.
870
+ * @param serverId - The ID of the MCP server.
871
+ * @param toolId - The ID of the tool.
872
+ * @returns MCPTool instance.
873
+ */
874
+ getMcpServerTool(serverId: string, toolId: string): MCPTool;
875
+ /**
876
+ * Gets an A2A client for interacting with an agent via the A2A protocol
877
+ * @param agentId - ID of the agent to interact with
878
+ * @returns A2A client instance
879
+ */
880
+ getA2A(agentId: string): A2A;
583
881
  }
584
882
 
585
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult };
883
+ export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextWorkflowResponse, type GetVNextWorkflowRunsResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, 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 VNextWorkflowRunResult, type VNextWorkflowWatchResult, type WorkflowRunResult };