@mastra/client-js 0.0.0-fix-message-embedding-20250506021742 → 0.0.0-fix-fetch-workflow-runs-20250624231457

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,24 @@
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
+ WorkflowRun,
9
+ LegacyWorkflowRuns,
12
10
  } from '@mastra/core';
11
+ import type { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
12
+ import type { BaseLogMessage, LogLevel } from '@mastra/core/logger';
13
13
 
14
- import type { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
15
- import type { NewWorkflow, WatchEvent, WorkflowResult as VNextWorkflowResult } from '@mastra/core/workflows/vNext';
14
+ import type { MCPToolType, ServerInfo } from '@mastra/core/mcp';
15
+ import type { RuntimeContext } from '@mastra/core/runtime-context';
16
+ import type { Workflow, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
17
+ import type {
18
+ StepAction,
19
+ StepGraph,
20
+ LegacyWorkflowRunResult as CoreLegacyWorkflowRunResult,
21
+ } from '@mastra/core/workflows/legacy';
16
22
  import type { JSONSchema7 } from 'json-schema';
17
23
  import type { ZodSchema } from 'zod';
18
24
 
@@ -38,21 +44,42 @@ export interface RequestOptions {
38
44
  signal?: AbortSignal;
39
45
  }
40
46
 
47
+ type WithoutMethods<T> = {
48
+ [K in keyof T as T[K] extends (...args: any[]) => any
49
+ ? never
50
+ : T[K] extends { (): any }
51
+ ? never
52
+ : T[K] extends undefined | ((...args: any[]) => any)
53
+ ? never
54
+ : K]: T[K];
55
+ };
56
+
41
57
  export interface GetAgentResponse {
42
58
  name: string;
43
59
  instructions: string;
44
60
  tools: Record<string, GetToolResponse>;
61
+ workflows: Record<string, GetWorkflowResponse>;
45
62
  provider: string;
46
63
  modelId: string;
64
+ defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
65
+ defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
47
66
  }
48
67
 
49
68
  export type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
50
69
  messages: string | string[] | CoreMessage[] | AiMessageType[];
51
- } & Partial<AgentGenerateOptions<T>>;
70
+ output?: T;
71
+ experimental_output?: T;
72
+ runtimeContext?: RuntimeContext | Record<string, any>;
73
+ clientTools?: ToolsInput;
74
+ } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
52
75
 
53
76
  export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
54
77
  messages: string | string[] | CoreMessage[] | AiMessageType[];
55
- } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
78
+ output?: T;
79
+ experimental_output?: T;
80
+ runtimeContext?: RuntimeContext | Record<string, any>;
81
+ clientTools?: ToolsInput;
82
+ } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
56
83
 
57
84
  export interface GetEvalsByAgentIdResponse extends GetAgentResponse {
58
85
  evals: any[];
@@ -68,7 +95,7 @@ export interface GetToolResponse {
68
95
  outputSchema: string;
69
96
  }
70
97
 
71
- export interface GetWorkflowResponse {
98
+ export interface GetLegacyWorkflowResponse {
72
99
  name: string;
73
100
  triggerSchema: string;
74
101
  steps: Record<string, StepAction<any, any, any, any>>;
@@ -85,17 +112,24 @@ export interface GetWorkflowRunsParams {
85
112
  resourceId?: string;
86
113
  }
87
114
 
115
+ export type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
116
+
88
117
  export type GetWorkflowRunsResponse = WorkflowRuns;
89
118
 
90
- export type WorkflowRunResult = {
119
+ export type GetWorkflowRunByIdResponse = WorkflowRun;
120
+
121
+ export type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
122
+
123
+ export type LegacyWorkflowRunResult = {
91
124
  activePaths: Record<string, { status: string; suspendPayload?: any; stepPath: string[] }>;
92
- results: CoreWorkflowRunResult<any, any, any>['results'];
125
+ results: CoreLegacyWorkflowRunResult<any, any, any>['results'];
93
126
  timestamp: number;
94
127
  runId: string;
95
128
  };
96
129
 
97
- export interface GetVNextWorkflowResponse {
130
+ export interface GetWorkflowResponse {
98
131
  name: string;
132
+ description?: string;
99
133
  steps: {
100
134
  [key: string]: {
101
135
  id: string;
@@ -106,14 +140,14 @@ export interface GetVNextWorkflowResponse {
106
140
  suspendSchema: string;
107
141
  };
108
142
  };
109
- stepGraph: NewWorkflow['serializedStepGraph'];
143
+ stepGraph: Workflow['serializedStepGraph'];
110
144
  inputSchema: string;
111
145
  outputSchema: string;
112
146
  }
113
147
 
114
- export type VNextWorkflowWatchResult = WatchEvent & { runId: string };
148
+ export type WorkflowWatchResult = WatchEvent & { runId: string };
115
149
 
116
- export type VNextWorkflowRunResult = VNextWorkflowResult<any, any>;
150
+ export type WorkflowRunResult = WorkflowResult<any, any>;
117
151
  export interface UpsertVectorParams {
118
152
  indexName: string;
119
153
  vectors: number[][];
@@ -145,20 +179,33 @@ export interface GetVectorIndexResponse {
145
179
  }
146
180
 
147
181
  export interface SaveMessageToMemoryParams {
148
- messages: MessageType[];
182
+ messages: MastraMessageV1[];
149
183
  agentId: string;
150
184
  }
151
185
 
152
- export type SaveMessageToMemoryResponse = MessageType[];
186
+ export interface SaveNetworkMessageToMemoryParams {
187
+ messages: MastraMessageV1[];
188
+ networkId: string;
189
+ }
190
+
191
+ export type SaveMessageToMemoryResponse = MastraMessageV1[];
153
192
 
154
193
  export interface CreateMemoryThreadParams {
155
- title: string;
156
- metadata: Record<string, any>;
194
+ title?: string;
195
+ metadata?: Record<string, any>;
157
196
  resourceId: string;
158
- threadId: string;
197
+ threadId?: string;
159
198
  agentId: string;
160
199
  }
161
200
 
201
+ export interface CreateNetworkMemoryThreadParams {
202
+ title?: string;
203
+ metadata?: Record<string, any>;
204
+ resourceId: string;
205
+ threadId?: string;
206
+ networkId: string;
207
+ }
208
+
162
209
  export type CreateMemoryThreadResponse = StorageThreadType;
163
210
 
164
211
  export interface GetMemoryThreadParams {
@@ -166,6 +213,11 @@ export interface GetMemoryThreadParams {
166
213
  agentId: string;
167
214
  }
168
215
 
216
+ export interface GetNetworkMemoryThreadParams {
217
+ resourceId: string;
218
+ networkId: string;
219
+ }
220
+
169
221
  export type GetMemoryThreadResponse = StorageThreadType[];
170
222
 
171
223
  export interface UpdateMemoryThreadParams {
@@ -174,6 +226,13 @@ export interface UpdateMemoryThreadParams {
174
226
  resourceId: string;
175
227
  }
176
228
 
229
+ export interface GetMemoryThreadMessagesParams {
230
+ /**
231
+ * Limit the number of messages to retrieve (default: 40)
232
+ */
233
+ limit?: number;
234
+ }
235
+
177
236
  export interface GetMemoryThreadMessagesResponse {
178
237
  messages: CoreMessage[];
179
238
  uiMessages: AiMessageType[];
@@ -181,14 +240,32 @@ export interface GetMemoryThreadMessagesResponse {
181
240
 
182
241
  export interface GetLogsParams {
183
242
  transportId: string;
243
+ fromDate?: Date;
244
+ toDate?: Date;
245
+ logLevel?: LogLevel;
246
+ filters?: Record<string, string>;
247
+ page?: number;
248
+ perPage?: number;
184
249
  }
185
250
 
186
251
  export interface GetLogParams {
187
252
  runId: string;
188
253
  transportId: string;
254
+ fromDate?: Date;
255
+ toDate?: Date;
256
+ logLevel?: LogLevel;
257
+ filters?: Record<string, string>;
258
+ page?: number;
259
+ perPage?: number;
189
260
  }
190
261
 
191
- export type GetLogsResponse = BaseLogMessage[];
262
+ export type GetLogsResponse = {
263
+ logs: BaseLogMessage[];
264
+ total: number;
265
+ page: number;
266
+ perPage: number;
267
+ hasMore: boolean;
268
+ };
192
269
 
193
270
  export type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
194
271
 
@@ -247,6 +324,7 @@ export interface GetTelemetryParams {
247
324
  }
248
325
 
249
326
  export interface GetNetworkResponse {
327
+ id: string;
250
328
  name: string;
251
329
  instructions: string;
252
330
  agents: Array<{
@@ -260,3 +338,63 @@ export interface GetNetworkResponse {
260
338
  };
261
339
  state?: Record<string, any>;
262
340
  }
341
+
342
+ export interface GetVNextNetworkResponse {
343
+ id: string;
344
+ name: string;
345
+ instructions: string;
346
+ agents: Array<{
347
+ name: string;
348
+ provider: string;
349
+ modelId: string;
350
+ }>;
351
+ routingModel: {
352
+ provider: string;
353
+ modelId: string;
354
+ };
355
+ workflows: Array<{
356
+ name: string;
357
+ description: string;
358
+ inputSchema: string | undefined;
359
+ outputSchema: string | undefined;
360
+ }>;
361
+ }
362
+
363
+ export interface GenerateVNextNetworkResponse {
364
+ task: string;
365
+ result: string;
366
+ resourceId: string;
367
+ resourceType: 'none' | 'tool' | 'agent' | 'workflow';
368
+ }
369
+
370
+ export interface GenerateOrStreamVNextNetworkParams {
371
+ message: string;
372
+ threadId?: string;
373
+ resourceId?: string;
374
+ }
375
+
376
+ export interface LoopVNextNetworkResponse {
377
+ status: 'success';
378
+ result: {
379
+ text: string;
380
+ };
381
+ steps: WorkflowResult<any, any>['steps'];
382
+ }
383
+
384
+ export interface McpServerListResponse {
385
+ servers: ServerInfo[];
386
+ next: string | null;
387
+ total_count: number;
388
+ }
389
+
390
+ export interface McpToolInfo {
391
+ id: string;
392
+ name: string;
393
+ description?: string;
394
+ inputSchema: string;
395
+ toolType?: MCPToolType;
396
+ }
397
+
398
+ export interface McpServerToolListResponse {
399
+ tools: McpToolInfo[];
400
+ }
@@ -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,32 @@
1
+ import { isVercelTool } from '@mastra/core/tools';
2
+ import { zodToJsonSchema } from './zod-to-json-schema';
3
+ import type { ToolsInput } from '@mastra/core/agent';
4
+
5
+ export function processClientTools(clientTools: ToolsInput | undefined): ToolsInput | undefined {
6
+ if (!clientTools) {
7
+ return undefined;
8
+ }
9
+
10
+ return Object.fromEntries(
11
+ Object.entries(clientTools).map(([key, value]) => {
12
+ if (isVercelTool(value)) {
13
+ return [
14
+ key,
15
+ {
16
+ ...value,
17
+ parameters: value.parameters ? zodToJsonSchema(value.parameters) : undefined,
18
+ },
19
+ ];
20
+ } else {
21
+ return [
22
+ key,
23
+ {
24
+ ...value,
25
+ inputSchema: value.inputSchema ? zodToJsonSchema(value.inputSchema) : undefined,
26
+ outputSchema: value.outputSchema ? zodToJsonSchema(value.outputSchema) : undefined,
27
+ },
28
+ ];
29
+ }
30
+ }),
31
+ );
32
+ }
@@ -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
+ }