@mastra/client-js 0.0.0-switch-to-core-20250424015131 → 0.0.0-taofeeqInngest-20250603090617

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,16 +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,
7
+ WorkflowRuns,
8
+ LegacyWorkflowRuns,
11
9
  } from '@mastra/core';
12
-
13
10
  import type { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
11
+ import type { BaseLogMessage } from '@mastra/core/logger';
12
+
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';
14
21
  import type { JSONSchema7 } from 'json-schema';
15
22
  import type { ZodSchema } from 'zod';
16
23
 
@@ -36,24 +43,46 @@ export interface RequestOptions {
36
43
  signal?: AbortSignal;
37
44
  }
38
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
+
39
56
  export interface GetAgentResponse {
40
57
  name: string;
41
58
  instructions: string;
42
59
  tools: Record<string, GetToolResponse>;
60
+ workflows: Record<string, GetWorkflowResponse>;
43
61
  provider: string;
44
62
  modelId: string;
63
+ defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
64
+ defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
45
65
  }
46
66
 
47
67
  export type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
48
68
  messages: string | string[] | CoreMessage[] | AiMessageType[];
49
- } & Partial<AgentGenerateOptions<T>>;
69
+ output?: T;
70
+ experimental_output?: T;
71
+ runtimeContext?: RuntimeContext | Record<string, any>;
72
+ } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
50
73
 
51
74
  export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
52
75
  messages: string | string[] | CoreMessage[] | AiMessageType[];
53
- } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
76
+ output?: T;
77
+ experimental_output?: T;
78
+ runtimeContext?: RuntimeContext | Record<string, any>;
79
+ } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
54
80
 
55
81
  export interface GetEvalsByAgentIdResponse extends GetAgentResponse {
56
82
  evals: any[];
83
+ instructions: string;
84
+ name: string;
85
+ id: string;
57
86
  }
58
87
 
59
88
  export interface GetToolResponse {
@@ -63,7 +92,7 @@ export interface GetToolResponse {
63
92
  outputSchema: string;
64
93
  }
65
94
 
66
- export interface GetWorkflowResponse {
95
+ export interface GetLegacyWorkflowResponse {
67
96
  name: string;
68
97
  triggerSchema: string;
69
98
  steps: Record<string, StepAction<any, any, any, any>>;
@@ -72,12 +101,46 @@ export interface GetWorkflowResponse {
72
101
  workflowId?: string;
73
102
  }
74
103
 
75
- export type WorkflowRunResult = {
104
+ export interface GetWorkflowRunsParams {
105
+ fromDate?: Date;
106
+ toDate?: Date;
107
+ limit?: number;
108
+ offset?: number;
109
+ resourceId?: string;
110
+ }
111
+
112
+ export type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
113
+
114
+ export type GetWorkflowRunsResponse = WorkflowRuns;
115
+
116
+ export type LegacyWorkflowRunResult = {
76
117
  activePaths: Record<string, { status: string; suspendPayload?: any; stepPath: string[] }>;
77
- results: CoreWorkflowRunResult<any, any, any>['results'];
118
+ results: CoreLegacyWorkflowRunResult<any, any, any>['results'];
78
119
  timestamp: number;
79
120
  runId: string;
80
121
  };
122
+
123
+ export interface GetWorkflowResponse {
124
+ name: string;
125
+ description?: string;
126
+ steps: {
127
+ [key: string]: {
128
+ id: string;
129
+ description: string;
130
+ inputSchema: string;
131
+ outputSchema: string;
132
+ resumeSchema: string;
133
+ suspendSchema: string;
134
+ };
135
+ };
136
+ stepGraph: Workflow['serializedStepGraph'];
137
+ inputSchema: string;
138
+ outputSchema: string;
139
+ }
140
+
141
+ export type WorkflowWatchResult = WatchEvent & { runId: string };
142
+
143
+ export type WorkflowRunResult = WorkflowResult<any, any>;
81
144
  export interface UpsertVectorParams {
82
145
  indexName: string;
83
146
  vectors: number[][];
@@ -109,17 +172,17 @@ export interface GetVectorIndexResponse {
109
172
  }
110
173
 
111
174
  export interface SaveMessageToMemoryParams {
112
- messages: MessageType[];
175
+ messages: MastraMessageV1[];
113
176
  agentId: string;
114
177
  }
115
178
 
116
- export type SaveMessageToMemoryResponse = MessageType[];
179
+ export type SaveMessageToMemoryResponse = MastraMessageV1[];
117
180
 
118
181
  export interface CreateMemoryThreadParams {
119
- title: string;
120
- metadata: Record<string, any>;
182
+ title?: string;
183
+ metadata?: Record<string, any>;
121
184
  resourceId: string;
122
- threadId: string;
185
+ threadId?: string;
123
186
  agentId: string;
124
187
  }
125
188
 
@@ -138,6 +201,13 @@ export interface UpdateMemoryThreadParams {
138
201
  resourceId: string;
139
202
  }
140
203
 
204
+ export interface GetMemoryThreadMessagesParams {
205
+ /**
206
+ * Limit the number of messages to retrieve (default: 40)
207
+ */
208
+ limit?: number;
209
+ }
210
+
141
211
  export interface GetMemoryThreadMessagesResponse {
142
212
  messages: CoreMessage[];
143
213
  uiMessages: AiMessageType[];
@@ -206,6 +276,8 @@ export interface GetTelemetryParams {
206
276
  page?: number;
207
277
  perPage?: number;
208
278
  attribute?: Record<string, string>;
279
+ fromDate?: Date;
280
+ toDate?: Date;
209
281
  }
210
282
 
211
283
  export interface GetNetworkResponse {
@@ -222,3 +294,21 @@ export interface GetNetworkResponse {
222
294
  };
223
295
  state?: Record<string, any>;
224
296
  }
297
+
298
+ export interface McpServerListResponse {
299
+ servers: ServerInfo[];
300
+ next: string | null;
301
+ total_count: number;
302
+ }
303
+
304
+ export interface McpToolInfo {
305
+ id: string;
306
+ name: string;
307
+ description?: string;
308
+ inputSchema: string;
309
+ toolType?: MCPToolType;
310
+ }
311
+
312
+ export interface McpServerToolListResponse {
313
+ tools: McpToolInfo[];
314
+ }
@@ -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,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
+ }