@mastra/client-js 0.0.0-agui-20250501191909 → 0.0.0-cli-debug-20250611094457

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/src/types.ts CHANGED
@@ -1,18 +1,23 @@
1
1
  import type {
2
- MessageType,
2
+ MastraMessageV1,
3
3
  AiMessageType,
4
4
  CoreMessage,
5
5
  QueryResult,
6
- StepAction,
7
- StepGraph,
8
6
  StorageThreadType,
9
- BaseLogMessage,
10
- WorkflowRunResult as CoreWorkflowRunResult,
11
7
  WorkflowRuns,
8
+ LegacyWorkflowRuns,
12
9
  } from '@mastra/core';
10
+ import type { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
11
+ import type { BaseLogMessage, LogLevel } from '@mastra/core/logger';
13
12
 
14
- import type { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
15
- import type { NewWorkflow, WatchEvent, WorkflowResult as VNextWorkflowResult } from '@mastra/core/workflows/vNext';
13
+ import type { MCPToolType, ServerInfo } from '@mastra/core/mcp';
14
+ import type { RuntimeContext } from '@mastra/core/runtime-context';
15
+ import type { Workflow, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
16
+ import type {
17
+ StepAction,
18
+ StepGraph,
19
+ LegacyWorkflowRunResult as CoreLegacyWorkflowRunResult,
20
+ } from '@mastra/core/workflows/legacy';
16
21
  import type { JSONSchema7 } from 'json-schema';
17
22
  import type { ZodSchema } from 'zod';
18
23
 
@@ -38,21 +43,42 @@ export interface RequestOptions {
38
43
  signal?: AbortSignal;
39
44
  }
40
45
 
46
+ type WithoutMethods<T> = {
47
+ [K in keyof T as T[K] extends (...args: any[]) => any
48
+ ? never
49
+ : T[K] extends { (): any }
50
+ ? never
51
+ : T[K] extends undefined | ((...args: any[]) => any)
52
+ ? never
53
+ : K]: T[K];
54
+ };
55
+
41
56
  export interface GetAgentResponse {
42
57
  name: string;
43
58
  instructions: string;
44
59
  tools: Record<string, GetToolResponse>;
60
+ workflows: Record<string, GetWorkflowResponse>;
45
61
  provider: string;
46
62
  modelId: string;
63
+ defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
64
+ defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
47
65
  }
48
66
 
49
67
  export type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
50
68
  messages: string | string[] | CoreMessage[] | AiMessageType[];
51
- } & Partial<AgentGenerateOptions<T>>;
69
+ output?: T;
70
+ experimental_output?: T;
71
+ runtimeContext?: RuntimeContext | Record<string, any>;
72
+ clientTools?: ToolsInput;
73
+ } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
52
74
 
53
75
  export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
54
76
  messages: string | string[] | CoreMessage[] | AiMessageType[];
55
- } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
77
+ output?: T;
78
+ experimental_output?: T;
79
+ runtimeContext?: RuntimeContext | Record<string, any>;
80
+ clientTools?: ToolsInput;
81
+ } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
56
82
 
57
83
  export interface GetEvalsByAgentIdResponse extends GetAgentResponse {
58
84
  evals: any[];
@@ -68,7 +94,7 @@ export interface GetToolResponse {
68
94
  outputSchema: string;
69
95
  }
70
96
 
71
- export interface GetWorkflowResponse {
97
+ export interface GetLegacyWorkflowResponse {
72
98
  name: string;
73
99
  triggerSchema: string;
74
100
  steps: Record<string, StepAction<any, any, any, any>>;
@@ -77,17 +103,28 @@ export interface GetWorkflowResponse {
77
103
  workflowId?: string;
78
104
  }
79
105
 
106
+ export interface GetWorkflowRunsParams {
107
+ fromDate?: Date;
108
+ toDate?: Date;
109
+ limit?: number;
110
+ offset?: number;
111
+ resourceId?: string;
112
+ }
113
+
114
+ export type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
115
+
80
116
  export type GetWorkflowRunsResponse = WorkflowRuns;
81
117
 
82
- export type WorkflowRunResult = {
118
+ export type LegacyWorkflowRunResult = {
83
119
  activePaths: Record<string, { status: string; suspendPayload?: any; stepPath: string[] }>;
84
- results: CoreWorkflowRunResult<any, any, any>['results'];
120
+ results: CoreLegacyWorkflowRunResult<any, any, any>['results'];
85
121
  timestamp: number;
86
122
  runId: string;
87
123
  };
88
124
 
89
- export interface GetVNextWorkflowResponse {
125
+ export interface GetWorkflowResponse {
90
126
  name: string;
127
+ description?: string;
91
128
  steps: {
92
129
  [key: string]: {
93
130
  id: string;
@@ -98,14 +135,14 @@ export interface GetVNextWorkflowResponse {
98
135
  suspendSchema: string;
99
136
  };
100
137
  };
101
- stepGraph: NewWorkflow['serializedStepGraph'];
138
+ stepGraph: Workflow['serializedStepGraph'];
102
139
  inputSchema: string;
103
140
  outputSchema: string;
104
141
  }
105
142
 
106
- export type VNextWorkflowWatchResult = WatchEvent & { runId: string };
143
+ export type WorkflowWatchResult = WatchEvent & { runId: string };
107
144
 
108
- export type VNextWorkflowRunResult = VNextWorkflowResult<any, any>;
145
+ export type WorkflowRunResult = WorkflowResult<any, any>;
109
146
  export interface UpsertVectorParams {
110
147
  indexName: string;
111
148
  vectors: number[][];
@@ -137,17 +174,17 @@ export interface GetVectorIndexResponse {
137
174
  }
138
175
 
139
176
  export interface SaveMessageToMemoryParams {
140
- messages: MessageType[];
177
+ messages: MastraMessageV1[];
141
178
  agentId: string;
142
179
  }
143
180
 
144
- export type SaveMessageToMemoryResponse = MessageType[];
181
+ export type SaveMessageToMemoryResponse = MastraMessageV1[];
145
182
 
146
183
  export interface CreateMemoryThreadParams {
147
- title: string;
148
- metadata: Record<string, any>;
184
+ title?: string;
185
+ metadata?: Record<string, any>;
149
186
  resourceId: string;
150
- threadId: string;
187
+ threadId?: string;
151
188
  agentId: string;
152
189
  }
153
190
 
@@ -166,6 +203,13 @@ export interface UpdateMemoryThreadParams {
166
203
  resourceId: string;
167
204
  }
168
205
 
206
+ export interface GetMemoryThreadMessagesParams {
207
+ /**
208
+ * Limit the number of messages to retrieve (default: 40)
209
+ */
210
+ limit?: number;
211
+ }
212
+
169
213
  export interface GetMemoryThreadMessagesResponse {
170
214
  messages: CoreMessage[];
171
215
  uiMessages: AiMessageType[];
@@ -173,14 +217,32 @@ export interface GetMemoryThreadMessagesResponse {
173
217
 
174
218
  export interface GetLogsParams {
175
219
  transportId: string;
220
+ fromDate?: Date;
221
+ toDate?: Date;
222
+ logLevel?: LogLevel;
223
+ filters?: Record<string, string>;
224
+ page?: number;
225
+ perPage?: number;
176
226
  }
177
227
 
178
228
  export interface GetLogParams {
179
229
  runId: string;
180
230
  transportId: string;
231
+ fromDate?: Date;
232
+ toDate?: Date;
233
+ logLevel?: LogLevel;
234
+ filters?: Record<string, string>;
235
+ page?: number;
236
+ perPage?: number;
181
237
  }
182
238
 
183
- export type GetLogsResponse = BaseLogMessage[];
239
+ export type GetLogsResponse = {
240
+ logs: BaseLogMessage[];
241
+ total: number;
242
+ page: number;
243
+ perPage: number;
244
+ hasMore: boolean;
245
+ };
184
246
 
185
247
  export type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
186
248
 
@@ -234,6 +296,8 @@ export interface GetTelemetryParams {
234
296
  page?: number;
235
297
  perPage?: number;
236
298
  attribute?: Record<string, string>;
299
+ fromDate?: Date;
300
+ toDate?: Date;
237
301
  }
238
302
 
239
303
  export interface GetNetworkResponse {
@@ -250,3 +314,21 @@ export interface GetNetworkResponse {
250
314
  };
251
315
  state?: Record<string, any>;
252
316
  }
317
+
318
+ export interface McpServerListResponse {
319
+ servers: ServerInfo[];
320
+ next: string | null;
321
+ total_count: number;
322
+ }
323
+
324
+ export interface McpToolInfo {
325
+ id: string;
326
+ name: string;
327
+ description?: string;
328
+ inputSchema: string;
329
+ toolType?: MCPToolType;
330
+ }
331
+
332
+ export interface McpServerToolListResponse {
333
+ tools: McpToolInfo[];
334
+ }
@@ -0,0 +1,11 @@
1
+ import { RuntimeContext } from '@mastra/core/runtime-context';
2
+
3
+ export function parseClientRuntimeContext(runtimeContext?: RuntimeContext | Record<string, any>) {
4
+ if (runtimeContext) {
5
+ if (runtimeContext instanceof RuntimeContext) {
6
+ return Object.fromEntries(runtimeContext.entries());
7
+ }
8
+ return runtimeContext;
9
+ }
10
+ return undefined;
11
+ }
@@ -0,0 +1,31 @@
1
+ import { isVercelTool } from '@mastra/core/tools';
2
+ import { zodToJsonSchema } from './zod-to-json-schema';
3
+
4
+ export function processClientTools(clientTools: Record<string, any> | undefined): Record<string, any> | undefined {
5
+ if (!clientTools) {
6
+ return undefined;
7
+ }
8
+
9
+ return Object.fromEntries(
10
+ Object.entries(clientTools).map(([key, value]) => {
11
+ if (isVercelTool(value)) {
12
+ return [
13
+ key,
14
+ {
15
+ ...value,
16
+ parameters: value.parameters ? zodToJsonSchema(value.parameters) : undefined,
17
+ },
18
+ ];
19
+ } else {
20
+ return [
21
+ key,
22
+ {
23
+ ...value,
24
+ inputSchema: value.inputSchema ? zodToJsonSchema(value.inputSchema) : undefined,
25
+ outputSchema: value.outputSchema ? zodToJsonSchema(value.outputSchema) : undefined,
26
+ },
27
+ ];
28
+ }
29
+ }),
30
+ ) as Record<string, any>;
31
+ }
@@ -0,0 +1,10 @@
1
+ import { ZodSchema } from 'zod';
2
+ import originalZodToJsonSchema from 'zod-to-json-schema';
3
+
4
+ export function zodToJsonSchema<T extends ZodSchema | any>(zodSchema: T) {
5
+ if (!(zodSchema instanceof ZodSchema)) {
6
+ return zodSchema;
7
+ }
8
+
9
+ return originalZodToJsonSchema(zodSchema, { $refStrategy: 'none' });
10
+ }