@mastra/client-js 0.0.0-mcp-changeset-20250707162621 → 0.0.0-message-list-update-20250715150321

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,6 +1,6 @@
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';
3
+ import { processDataStream, processTextStream } from '@ai-sdk/ui-utils';
4
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';
@@ -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;
@@ -332,12 +333,14 @@ interface GenerateOrStreamVNextNetworkParams {
332
333
  message: string;
333
334
  threadId?: string;
334
335
  resourceId?: string;
336
+ runtimeContext?: RuntimeContext | Record<string, any>;
335
337
  }
336
338
  interface LoopStreamVNextNetworkParams {
337
339
  message: string;
338
340
  threadId?: string;
339
341
  resourceId?: string;
340
342
  maxIterations?: number;
343
+ runtimeContext?: RuntimeContext | Record<string, any>;
341
344
  }
342
345
  interface LoopVNextNetworkResponse {
343
346
  status: 'success';
@@ -439,18 +442,19 @@ declare class Agent extends BaseResource {
439
442
  experimental_output: T;
440
443
  }): Promise<GenerateReturn<T>>;
441
444
  private processChatResponse;
445
+ /**
446
+ * Processes the stream response and handles tool calls
447
+ */
448
+ private processStreamResponse;
442
449
  /**
443
450
  * Streams a response from the agent
444
451
  * @param params - Stream parameters including prompt
445
- * @returns Promise containing the enhanced Response object with processDataStream method
452
+ * @returns Promise containing the enhanced Response object with processDataStream and processTextStream methods
446
453
  */
447
454
  stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
448
455
  processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
456
+ processTextStream: (options?: Omit<Parameters<typeof processTextStream>[0], 'stream'>) => Promise<void>;
449
457
  }>;
450
- /**
451
- * Processes the stream response and handles tool calls
452
- */
453
- private processStreamResponse;
454
458
  /**
455
459
  * Gets details about a specific tool available to the agent
456
460
  * @param toolId - ID of the tool to retrieve
@@ -890,6 +894,36 @@ declare class MCPTool extends BaseResource {
890
894
  }): Promise<any>;
891
895
  }
892
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
+
893
927
  declare class VNextNetwork extends BaseResource {
894
928
  private networkId;
895
929
  constructor(options: ClientOptions, networkId: string);
@@ -911,6 +945,7 @@ declare class VNextNetwork extends BaseResource {
911
945
  */
912
946
  loop(params: {
913
947
  message: string;
948
+ runtimeContext?: RuntimeContext | Record<string, any>;
914
949
  }): Promise<LoopVNextNetworkResponse>;
915
950
  private streamProcessor;
916
951
  /**
@@ -927,36 +962,6 @@ declare class VNextNetwork extends BaseResource {
927
962
  loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
928
963
  }
929
964
 
930
- declare class NetworkMemoryThread extends BaseResource {
931
- private threadId;
932
- private networkId;
933
- constructor(options: ClientOptions, threadId: string, networkId: string);
934
- /**
935
- * Retrieves the memory thread details
936
- * @returns Promise containing thread details including title and metadata
937
- */
938
- get(): Promise<StorageThreadType>;
939
- /**
940
- * Updates the memory thread properties
941
- * @param params - Update parameters including title and metadata
942
- * @returns Promise containing updated thread details
943
- */
944
- update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
945
- /**
946
- * Deletes the memory thread
947
- * @returns Promise containing deletion result
948
- */
949
- delete(): Promise<{
950
- result: string;
951
- }>;
952
- /**
953
- * Retrieves messages associated with the thread
954
- * @param params - Optional parameters including limit for number of messages to retrieve
955
- * @returns Promise containing thread messages and UI messages
956
- */
957
- getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
958
- }
959
-
960
965
  declare class MastraClient extends BaseResource {
961
966
  constructor(options: ClientOptions);
962
967
  /**
@@ -1159,6 +1164,31 @@ declare class MastraClient extends BaseResource {
1159
1164
  * @returns A2A client instance
1160
1165
  */
1161
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>;
1162
1192
  }
1163
1193
 
1164
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 };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
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';
3
+ import { processDataStream, processTextStream } from '@ai-sdk/ui-utils';
4
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';
@@ -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;
@@ -332,12 +333,14 @@ interface GenerateOrStreamVNextNetworkParams {
332
333
  message: string;
333
334
  threadId?: string;
334
335
  resourceId?: string;
336
+ runtimeContext?: RuntimeContext | Record<string, any>;
335
337
  }
336
338
  interface LoopStreamVNextNetworkParams {
337
339
  message: string;
338
340
  threadId?: string;
339
341
  resourceId?: string;
340
342
  maxIterations?: number;
343
+ runtimeContext?: RuntimeContext | Record<string, any>;
341
344
  }
342
345
  interface LoopVNextNetworkResponse {
343
346
  status: 'success';
@@ -439,18 +442,19 @@ declare class Agent extends BaseResource {
439
442
  experimental_output: T;
440
443
  }): Promise<GenerateReturn<T>>;
441
444
  private processChatResponse;
445
+ /**
446
+ * Processes the stream response and handles tool calls
447
+ */
448
+ private processStreamResponse;
442
449
  /**
443
450
  * Streams a response from the agent
444
451
  * @param params - Stream parameters including prompt
445
- * @returns Promise containing the enhanced Response object with processDataStream method
452
+ * @returns Promise containing the enhanced Response object with processDataStream and processTextStream methods
446
453
  */
447
454
  stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
448
455
  processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
456
+ processTextStream: (options?: Omit<Parameters<typeof processTextStream>[0], 'stream'>) => Promise<void>;
449
457
  }>;
450
- /**
451
- * Processes the stream response and handles tool calls
452
- */
453
- private processStreamResponse;
454
458
  /**
455
459
  * Gets details about a specific tool available to the agent
456
460
  * @param toolId - ID of the tool to retrieve
@@ -890,6 +894,36 @@ declare class MCPTool extends BaseResource {
890
894
  }): Promise<any>;
891
895
  }
892
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
+
893
927
  declare class VNextNetwork extends BaseResource {
894
928
  private networkId;
895
929
  constructor(options: ClientOptions, networkId: string);
@@ -911,6 +945,7 @@ declare class VNextNetwork extends BaseResource {
911
945
  */
912
946
  loop(params: {
913
947
  message: string;
948
+ runtimeContext?: RuntimeContext | Record<string, any>;
914
949
  }): Promise<LoopVNextNetworkResponse>;
915
950
  private streamProcessor;
916
951
  /**
@@ -927,36 +962,6 @@ declare class VNextNetwork extends BaseResource {
927
962
  loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
928
963
  }
929
964
 
930
- declare class NetworkMemoryThread extends BaseResource {
931
- private threadId;
932
- private networkId;
933
- constructor(options: ClientOptions, threadId: string, networkId: string);
934
- /**
935
- * Retrieves the memory thread details
936
- * @returns Promise containing thread details including title and metadata
937
- */
938
- get(): Promise<StorageThreadType>;
939
- /**
940
- * Updates the memory thread properties
941
- * @param params - Update parameters including title and metadata
942
- * @returns Promise containing updated thread details
943
- */
944
- update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
945
- /**
946
- * Deletes the memory thread
947
- * @returns Promise containing deletion result
948
- */
949
- delete(): Promise<{
950
- result: string;
951
- }>;
952
- /**
953
- * Retrieves messages associated with the thread
954
- * @param params - Optional parameters including limit for number of messages to retrieve
955
- * @returns Promise containing thread messages and UI messages
956
- */
957
- getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
958
- }
959
-
960
965
  declare class MastraClient extends BaseResource {
961
966
  constructor(options: ClientOptions);
962
967
  /**
@@ -1159,6 +1164,31 @@ declare class MastraClient extends BaseResource {
1159
1164
  * @returns A2A client instance
1160
1165
  */
1161
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>;
1162
1192
  }
1163
1193
 
1164
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 };