@mastra/client-js 0.0.0-fix-message-embedding-20250506021742 → 0.0.0-fix-generate-title-20250616171351

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,17 +179,17 @@ 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 type SaveMessageToMemoryResponse = MastraMessageV1[];
153
187
 
154
188
  export interface CreateMemoryThreadParams {
155
- title: string;
156
- metadata: Record<string, any>;
189
+ title?: string;
190
+ metadata?: Record<string, any>;
157
191
  resourceId: string;
158
- threadId: string;
192
+ threadId?: string;
159
193
  agentId: string;
160
194
  }
161
195
 
@@ -174,6 +208,13 @@ export interface UpdateMemoryThreadParams {
174
208
  resourceId: string;
175
209
  }
176
210
 
211
+ export interface GetMemoryThreadMessagesParams {
212
+ /**
213
+ * Limit the number of messages to retrieve (default: 40)
214
+ */
215
+ limit?: number;
216
+ }
217
+
177
218
  export interface GetMemoryThreadMessagesResponse {
178
219
  messages: CoreMessage[];
179
220
  uiMessages: AiMessageType[];
@@ -181,14 +222,32 @@ export interface GetMemoryThreadMessagesResponse {
181
222
 
182
223
  export interface GetLogsParams {
183
224
  transportId: string;
225
+ fromDate?: Date;
226
+ toDate?: Date;
227
+ logLevel?: LogLevel;
228
+ filters?: Record<string, string>;
229
+ page?: number;
230
+ perPage?: number;
184
231
  }
185
232
 
186
233
  export interface GetLogParams {
187
234
  runId: string;
188
235
  transportId: string;
236
+ fromDate?: Date;
237
+ toDate?: Date;
238
+ logLevel?: LogLevel;
239
+ filters?: Record<string, string>;
240
+ page?: number;
241
+ perPage?: number;
189
242
  }
190
243
 
191
- export type GetLogsResponse = BaseLogMessage[];
244
+ export type GetLogsResponse = {
245
+ logs: BaseLogMessage[];
246
+ total: number;
247
+ page: number;
248
+ perPage: number;
249
+ hasMore: boolean;
250
+ };
192
251
 
193
252
  export type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
194
253
 
@@ -260,3 +319,21 @@ export interface GetNetworkResponse {
260
319
  };
261
320
  state?: Record<string, any>;
262
321
  }
322
+
323
+ export interface McpServerListResponse {
324
+ servers: ServerInfo[];
325
+ next: string | null;
326
+ total_count: number;
327
+ }
328
+
329
+ export interface McpToolInfo {
330
+ id: string;
331
+ name: string;
332
+ description?: string;
333
+ inputSchema: string;
334
+ toolType?: MCPToolType;
335
+ }
336
+
337
+ export interface McpServerToolListResponse {
338
+ tools: McpToolInfo[];
339
+ }
@@ -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
+ }