@mastra/client-js 0.0.0-cli-debug-2-20250611100354 → 0.0.0-cloudflare-deployer-dont-install-deps-20250714111754

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
2
  import { ServerInfo, MCPToolType, ServerDetailInfo } from '@mastra/core/mcp';
3
- import { processDataStream } from '@ai-sdk/ui-utils';
4
- import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyWorkflowRuns, WorkflowRuns, QueryResult, GenerateReturn } from '@mastra/core';
3
+ import { processDataStream, processTextStream } from '@ai-sdk/ui-utils';
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
7
  import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
8
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 {
@@ -52,14 +53,14 @@ type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> =
52
53
  experimental_output?: T;
53
54
  runtimeContext?: RuntimeContext | Record<string, any>;
54
55
  clientTools?: ToolsInput;
55
- } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
56
+ } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
56
57
  type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
57
58
  messages: string | string[] | CoreMessage[] | AiMessageType[];
58
59
  output?: T;
59
60
  experimental_output?: T;
60
61
  runtimeContext?: RuntimeContext | Record<string, any>;
61
62
  clientTools?: ToolsInput;
62
- } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
63
+ } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
63
64
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
64
65
  evals: any[];
65
66
  instructions: string;
@@ -89,6 +90,8 @@ interface GetWorkflowRunsParams {
89
90
  }
90
91
  type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
91
92
  type GetWorkflowRunsResponse = WorkflowRuns;
93
+ type GetWorkflowRunByIdResponse = WorkflowRun;
94
+ type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
92
95
  type LegacyWorkflowRunResult = {
93
96
  activePaths: Record<string, {
94
97
  status: string;
@@ -112,6 +115,17 @@ interface GetWorkflowResponse {
112
115
  suspendSchema: string;
113
116
  };
114
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
+ };
115
129
  stepGraph: Workflow$1['serializedStepGraph'];
116
130
  inputSchema: string;
117
131
  outputSchema: string;
@@ -150,6 +164,10 @@ interface SaveMessageToMemoryParams {
150
164
  messages: MastraMessageV1[];
151
165
  agentId: string;
152
166
  }
167
+ interface SaveNetworkMessageToMemoryParams {
168
+ messages: MastraMessageV1[];
169
+ networkId: string;
170
+ }
153
171
  type SaveMessageToMemoryResponse = MastraMessageV1[];
154
172
  interface CreateMemoryThreadParams {
155
173
  title?: string;
@@ -158,11 +176,22 @@ interface CreateMemoryThreadParams {
158
176
  threadId?: string;
159
177
  agentId: string;
160
178
  }
179
+ interface CreateNetworkMemoryThreadParams {
180
+ title?: string;
181
+ metadata?: Record<string, any>;
182
+ resourceId: string;
183
+ threadId?: string;
184
+ networkId: string;
185
+ }
161
186
  type CreateMemoryThreadResponse = StorageThreadType;
162
187
  interface GetMemoryThreadParams {
163
188
  resourceId: string;
164
189
  agentId: string;
165
190
  }
191
+ interface GetNetworkMemoryThreadParams {
192
+ resourceId: string;
193
+ networkId: string;
194
+ }
166
195
  type GetMemoryThreadResponse = StorageThreadType[];
167
196
  interface UpdateMemoryThreadParams {
168
197
  title: string;
@@ -256,6 +285,7 @@ interface GetTelemetryParams {
256
285
  toDate?: Date;
257
286
  }
258
287
  interface GetNetworkResponse {
288
+ id: string;
259
289
  name: string;
260
290
  instructions: string;
261
291
  agents: Array<{
@@ -269,6 +299,56 @@ interface GetNetworkResponse {
269
299
  };
270
300
  state?: Record<string, any>;
271
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
+ runtimeContext?: RuntimeContext | Record<string, any>;
337
+ }
338
+ interface LoopStreamVNextNetworkParams {
339
+ message: string;
340
+ threadId?: string;
341
+ resourceId?: string;
342
+ maxIterations?: number;
343
+ runtimeContext?: RuntimeContext | Record<string, any>;
344
+ }
345
+ interface LoopVNextNetworkResponse {
346
+ status: 'success';
347
+ result: {
348
+ text: string;
349
+ };
350
+ steps: WorkflowResult<any, any>['steps'];
351
+ }
272
352
  interface McpServerListResponse {
273
353
  servers: ServerInfo[];
274
354
  next: string | null;
@@ -361,13 +441,19 @@ declare class Agent extends BaseResource {
361
441
  output?: never;
362
442
  experimental_output: T;
363
443
  }): Promise<GenerateReturn<T>>;
444
+ private processChatResponse;
445
+ /**
446
+ * Processes the stream response and handles tool calls
447
+ */
448
+ private processStreamResponse;
364
449
  /**
365
450
  * Streams a response from the agent
366
451
  * @param params - Stream parameters including prompt
367
- * @returns Promise containing the enhanced Response object with processDataStream method
452
+ * @returns Promise containing the enhanced Response object with processDataStream and processTextStream methods
368
453
  */
369
454
  stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
370
455
  processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
456
+ processTextStream: (options?: Omit<Parameters<typeof processTextStream>[0], 'stream'>) => Promise<void>;
371
457
  }>;
372
458
  /**
373
459
  * Gets details about a specific tool available to the agent
@@ -624,6 +710,38 @@ declare class Workflow extends BaseResource {
624
710
  * @returns Promise containing workflow runs array
625
711
  */
626
712
  runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
713
+ /**
714
+ * Retrieves a specific workflow run by its ID
715
+ * @param runId - The ID of the workflow run to retrieve
716
+ * @returns Promise containing the workflow run details
717
+ */
718
+ runById(runId: string): Promise<GetWorkflowRunByIdResponse>;
719
+ /**
720
+ * Retrieves the execution result for a specific workflow run by its ID
721
+ * @param runId - The ID of the workflow run to retrieve the execution result for
722
+ * @returns Promise containing the workflow run execution result
723
+ */
724
+ runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse>;
725
+ /**
726
+ * Cancels a specific workflow run by its ID
727
+ * @param runId - The ID of the workflow run to cancel
728
+ * @returns Promise containing a success message
729
+ */
730
+ cancelRun(runId: string): Promise<{
731
+ message: string;
732
+ }>;
733
+ /**
734
+ * Sends an event to a specific workflow run by its ID
735
+ * @param params - Object containing the runId, event and data
736
+ * @returns Promise containing a success message
737
+ */
738
+ sendRunEvent(params: {
739
+ runId: string;
740
+ event: string;
741
+ data: unknown;
742
+ }): Promise<{
743
+ message: string;
744
+ }>;
627
745
  /**
628
746
  * Creates a new workflow run
629
747
  * @param params - Optional object containing the optional runId
@@ -670,15 +788,18 @@ declare class Workflow extends BaseResource {
670
788
  runtimeContext?: RuntimeContext | Record<string, any>;
671
789
  }): Promise<WorkflowRunResult>;
672
790
  /**
673
- * Starts a vNext workflow run and returns a stream
791
+ * Starts a workflow run and returns a stream
674
792
  * @param params - Object containing the optional runId, inputData and runtimeContext
675
- * @returns Promise containing the vNext workflow execution results
793
+ * @returns Promise containing the workflow execution results
676
794
  */
677
795
  stream(params: {
678
796
  runId?: string;
679
797
  inputData: Record<string, any>;
680
798
  runtimeContext?: RuntimeContext;
681
- }): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
799
+ }): Promise<stream_web.ReadableStream<{
800
+ type: string;
801
+ payload: any;
802
+ }>>;
682
803
  /**
683
804
  * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
684
805
  * @param params - Object containing the runId, step, resumeData and runtimeContext
@@ -773,6 +894,74 @@ declare class MCPTool extends BaseResource {
773
894
  }): Promise<any>;
774
895
  }
775
896
 
897
+ declare class NetworkMemoryThread extends BaseResource {
898
+ private threadId;
899
+ private networkId;
900
+ constructor(options: ClientOptions, threadId: string, networkId: string);
901
+ /**
902
+ * Retrieves the memory thread details
903
+ * @returns Promise containing thread details including title and metadata
904
+ */
905
+ get(): Promise<StorageThreadType>;
906
+ /**
907
+ * Updates the memory thread properties
908
+ * @param params - Update parameters including title and metadata
909
+ * @returns Promise containing updated thread details
910
+ */
911
+ update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
912
+ /**
913
+ * Deletes the memory thread
914
+ * @returns Promise containing deletion result
915
+ */
916
+ delete(): Promise<{
917
+ result: string;
918
+ }>;
919
+ /**
920
+ * Retrieves messages associated with the thread
921
+ * @param params - Optional parameters including limit for number of messages to retrieve
922
+ * @returns Promise containing thread messages and UI messages
923
+ */
924
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
925
+ }
926
+
927
+ declare class VNextNetwork extends BaseResource {
928
+ private networkId;
929
+ constructor(options: ClientOptions, networkId: string);
930
+ /**
931
+ * Retrieves details about the network
932
+ * @returns Promise containing vNext network details
933
+ */
934
+ details(): Promise<GetVNextNetworkResponse>;
935
+ /**
936
+ * Generates a response from the v-next network
937
+ * @param params - Generation parameters including message
938
+ * @returns Promise containing the generated response
939
+ */
940
+ generate(params: GenerateOrStreamVNextNetworkParams): Promise<GenerateVNextNetworkResponse>;
941
+ /**
942
+ * Generates a response from the v-next network using multiple primitives
943
+ * @param params - Generation parameters including message
944
+ * @returns Promise containing the generated response
945
+ */
946
+ loop(params: {
947
+ message: string;
948
+ runtimeContext?: RuntimeContext | Record<string, any>;
949
+ }): Promise<LoopVNextNetworkResponse>;
950
+ private streamProcessor;
951
+ /**
952
+ * Streams a response from the v-next network
953
+ * @param params - Stream parameters including message
954
+ * @returns Promise containing the results
955
+ */
956
+ stream(params: GenerateOrStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
957
+ /**
958
+ * Streams a response from the v-next network loop
959
+ * @param params - Stream parameters including message
960
+ * @returns Promise containing the results
961
+ */
962
+ loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
963
+ }
964
+
776
965
  declare class MastraClient extends BaseResource {
777
966
  constructor(options: ClientOptions);
778
967
  /**
@@ -820,6 +1009,37 @@ declare class MastraClient extends BaseResource {
820
1009
  getMemoryStatus(agentId: string): Promise<{
821
1010
  result: boolean;
822
1011
  }>;
1012
+ /**
1013
+ * Retrieves memory threads for a resource
1014
+ * @param params - Parameters containing the resource ID
1015
+ * @returns Promise containing array of memory threads
1016
+ */
1017
+ getNetworkMemoryThreads(params: GetNetworkMemoryThreadParams): Promise<GetMemoryThreadResponse>;
1018
+ /**
1019
+ * Creates a new memory thread
1020
+ * @param params - Parameters for creating the memory thread
1021
+ * @returns Promise containing the created memory thread
1022
+ */
1023
+ createNetworkMemoryThread(params: CreateNetworkMemoryThreadParams): Promise<CreateMemoryThreadResponse>;
1024
+ /**
1025
+ * Gets a memory thread instance by ID
1026
+ * @param threadId - ID of the memory thread to retrieve
1027
+ * @returns MemoryThread instance
1028
+ */
1029
+ getNetworkMemoryThread(threadId: string, networkId: string): NetworkMemoryThread;
1030
+ /**
1031
+ * Saves messages to memory
1032
+ * @param params - Parameters containing messages to save
1033
+ * @returns Promise containing the saved messages
1034
+ */
1035
+ saveNetworkMessageToMemory(params: SaveNetworkMessageToMemoryParams): Promise<SaveMessageToMemoryResponse>;
1036
+ /**
1037
+ * Gets the status of the memory system
1038
+ * @returns Promise containing memory system status
1039
+ */
1040
+ getNetworkMemoryStatus(networkId: string): Promise<{
1041
+ result: boolean;
1042
+ }>;
823
1043
  /**
824
1044
  * Retrieves all available tools
825
1045
  * @returns Promise containing map of tool IDs to tool details
@@ -888,13 +1108,24 @@ declare class MastraClient extends BaseResource {
888
1108
  * Retrieves all available networks
889
1109
  * @returns Promise containing map of network IDs to network details
890
1110
  */
891
- getNetworks(): Promise<Record<string, GetNetworkResponse>>;
1111
+ getNetworks(): Promise<Array<GetNetworkResponse>>;
1112
+ /**
1113
+ * Retrieves all available vNext networks
1114
+ * @returns Promise containing map of vNext network IDs to vNext network details
1115
+ */
1116
+ getVNextNetworks(): Promise<Array<GetVNextNetworkResponse>>;
892
1117
  /**
893
1118
  * Gets a network instance by ID
894
1119
  * @param networkId - ID of the network to retrieve
895
1120
  * @returns Network instance
896
1121
  */
897
1122
  getNetwork(networkId: string): Network;
1123
+ /**
1124
+ * Gets a vNext network instance by ID
1125
+ * @param networkId - ID of the vNext network to retrieve
1126
+ * @returns vNext Network instance
1127
+ */
1128
+ getVNextNetwork(networkId: string): VNextNetwork;
898
1129
  /**
899
1130
  * Retrieves a list of available MCP servers.
900
1131
  * @param params - Optional parameters for pagination (limit, offset).
@@ -933,6 +1164,31 @@ declare class MastraClient extends BaseResource {
933
1164
  * @returns A2A client instance
934
1165
  */
935
1166
  getA2A(agentId: string): A2A;
1167
+ /**
1168
+ * Retrieves the working memory for a specific thread (optionally resource-scoped).
1169
+ * @param agentId - ID of the agent.
1170
+ * @param threadId - ID of the thread.
1171
+ * @param resourceId - Optional ID of the resource.
1172
+ * @returns Working memory for the specified thread or resource.
1173
+ */
1174
+ getWorkingMemory({ agentId, threadId, resourceId, }: {
1175
+ agentId: string;
1176
+ threadId: string;
1177
+ resourceId?: string;
1178
+ }): Promise<unknown>;
1179
+ /**
1180
+ * Updates the working memory for a specific thread (optionally resource-scoped).
1181
+ * @param agentId - ID of the agent.
1182
+ * @param threadId - ID of the thread.
1183
+ * @param workingMemory - The new working memory content.
1184
+ * @param resourceId - Optional ID of the resource.
1185
+ */
1186
+ updateWorkingMemory({ agentId, threadId, workingMemory, resourceId, }: {
1187
+ agentId: string;
1188
+ threadId: string;
1189
+ workingMemory: string;
1190
+ resourceId?: string;
1191
+ }): Promise<unknown>;
936
1192
  }
937
1193
 
938
- 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 };
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 };