@mastra/client-js 0.0.0-trigger-playground-ui-package-20250506151043 → 0.0.0-vector-sources-20250516175436
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/CHANGELOG.md +156 -2
- package/dist/index.cjs +248 -22
- package/dist/index.d.cts +162 -9
- package/dist/index.d.ts +162 -9
- package/dist/index.js +244 -22
- package/package.json +6 -6
- package/src/adapters/agui.test.ts +19 -6
- package/src/adapters/agui.ts +31 -11
- package/src/client.ts +77 -1
- package/src/example.ts +29 -30
- package/src/index.test.ts +121 -1
- package/src/resources/a2a.ts +88 -0
- package/src/resources/agent.ts +26 -34
- package/src/resources/base.ts +1 -1
- package/src/resources/index.ts +2 -0
- package/src/resources/mcp-tool.ts +48 -0
- package/src/resources/memory-thread.ts +13 -3
- package/src/resources/network.ts +5 -11
- package/src/resources/tool.ts +8 -2
- package/src/resources/vnext-workflow.ts +10 -6
- package/src/types.ts +48 -2
- package/src/utils/zod-to-json-schema.ts +10 -0
|
@@ -2,8 +2,8 @@ import type { RuntimeContext } from '@mastra/core/runtime-context';
|
|
|
2
2
|
import type {
|
|
3
3
|
ClientOptions,
|
|
4
4
|
GetVNextWorkflowResponse,
|
|
5
|
+
GetVNextWorkflowRunsResponse,
|
|
5
6
|
GetWorkflowRunsParams,
|
|
6
|
-
GetWorkflowRunsResponse,
|
|
7
7
|
VNextWorkflowRunResult,
|
|
8
8
|
VNextWorkflowWatchResult,
|
|
9
9
|
} from '../types';
|
|
@@ -104,7 +104,7 @@ export class VNextWorkflow extends BaseResource {
|
|
|
104
104
|
* @param params - Parameters for filtering runs
|
|
105
105
|
* @returns Promise containing vNext workflow runs array
|
|
106
106
|
*/
|
|
107
|
-
runs(params?: GetWorkflowRunsParams): Promise<
|
|
107
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetVNextWorkflowRunsResponse> {
|
|
108
108
|
const searchParams = new URLSearchParams();
|
|
109
109
|
if (params?.fromDate) {
|
|
110
110
|
searchParams.set('fromDate', params.fromDate.toISOString());
|
|
@@ -156,9 +156,10 @@ export class VNextWorkflow extends BaseResource {
|
|
|
156
156
|
inputData: Record<string, any>;
|
|
157
157
|
runtimeContext?: RuntimeContext;
|
|
158
158
|
}): Promise<{ message: string }> {
|
|
159
|
+
const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : undefined;
|
|
159
160
|
return this.request(`/api/workflows/v-next/${this.workflowId}/start?runId=${params.runId}`, {
|
|
160
161
|
method: 'POST',
|
|
161
|
-
body: { inputData: params?.inputData, runtimeContext
|
|
162
|
+
body: { inputData: params?.inputData, runtimeContext },
|
|
162
163
|
});
|
|
163
164
|
}
|
|
164
165
|
|
|
@@ -171,13 +172,14 @@ export class VNextWorkflow extends BaseResource {
|
|
|
171
172
|
step,
|
|
172
173
|
runId,
|
|
173
174
|
resumeData,
|
|
174
|
-
|
|
175
|
+
...rest
|
|
175
176
|
}: {
|
|
176
177
|
step: string | string[];
|
|
177
178
|
runId: string;
|
|
178
179
|
resumeData?: Record<string, any>;
|
|
179
180
|
runtimeContext?: RuntimeContext;
|
|
180
181
|
}): Promise<{ message: string }> {
|
|
182
|
+
const runtimeContext = rest.runtimeContext ? Object.fromEntries(rest.runtimeContext.entries()) : undefined;
|
|
181
183
|
return this.request(`/api/workflows/v-next/${this.workflowId}/resume?runId=${runId}`, {
|
|
182
184
|
method: 'POST',
|
|
183
185
|
stream: true,
|
|
@@ -205,9 +207,10 @@ export class VNextWorkflow extends BaseResource {
|
|
|
205
207
|
searchParams.set('runId', params.runId);
|
|
206
208
|
}
|
|
207
209
|
|
|
210
|
+
const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : undefined;
|
|
208
211
|
return this.request(`/api/workflows/v-next/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
209
212
|
method: 'POST',
|
|
210
|
-
body: { inputData: params.inputData, runtimeContext
|
|
213
|
+
body: { inputData: params.inputData, runtimeContext },
|
|
211
214
|
});
|
|
212
215
|
}
|
|
213
216
|
|
|
@@ -222,12 +225,13 @@ export class VNextWorkflow extends BaseResource {
|
|
|
222
225
|
resumeData?: Record<string, any>;
|
|
223
226
|
runtimeContext?: RuntimeContext;
|
|
224
227
|
}): Promise<VNextWorkflowRunResult> {
|
|
228
|
+
const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : undefined;
|
|
225
229
|
return this.request(`/api/workflows/v-next/${this.workflowId}/resume-async?runId=${params.runId}`, {
|
|
226
230
|
method: 'POST',
|
|
227
231
|
body: {
|
|
228
232
|
step: params.step,
|
|
229
233
|
resumeData: params.resumeData,
|
|
230
|
-
runtimeContext
|
|
234
|
+
runtimeContext,
|
|
231
235
|
},
|
|
232
236
|
});
|
|
233
237
|
}
|
package/src/types.ts
CHANGED
|
@@ -8,10 +8,13 @@ import type {
|
|
|
8
8
|
StorageThreadType,
|
|
9
9
|
BaseLogMessage,
|
|
10
10
|
WorkflowRunResult as CoreWorkflowRunResult,
|
|
11
|
+
VNextWorkflowRuns,
|
|
11
12
|
WorkflowRuns,
|
|
12
13
|
} from '@mastra/core';
|
|
13
14
|
|
|
14
15
|
import type { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
|
|
16
|
+
import type { RuntimeContext } from '@mastra/core/runtime-context';
|
|
17
|
+
import type { ServerInfo } from '@mastra/core/mcp';
|
|
15
18
|
import type { NewWorkflow, WatchEvent, WorkflowResult as VNextWorkflowResult } from '@mastra/core/workflows/vNext';
|
|
16
19
|
import type { JSONSchema7 } from 'json-schema';
|
|
17
20
|
import type { ZodSchema } from 'zod';
|
|
@@ -38,21 +41,38 @@ export interface RequestOptions {
|
|
|
38
41
|
signal?: AbortSignal;
|
|
39
42
|
}
|
|
40
43
|
|
|
44
|
+
type WithoutMethods<T> = {
|
|
45
|
+
[K in keyof T as T[K] extends (...args: any[]) => any
|
|
46
|
+
? never
|
|
47
|
+
: T[K] extends { (): any }
|
|
48
|
+
? never
|
|
49
|
+
: T[K] extends undefined | ((...args: any[]) => any)
|
|
50
|
+
? never
|
|
51
|
+
: K]: T[K];
|
|
52
|
+
};
|
|
53
|
+
|
|
41
54
|
export interface GetAgentResponse {
|
|
42
55
|
name: string;
|
|
43
56
|
instructions: string;
|
|
44
57
|
tools: Record<string, GetToolResponse>;
|
|
58
|
+
workflows: Record<string, GetWorkflowResponse>;
|
|
45
59
|
provider: string;
|
|
46
60
|
modelId: string;
|
|
47
61
|
}
|
|
48
62
|
|
|
49
63
|
export type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
50
64
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
51
|
-
|
|
65
|
+
output?: T;
|
|
66
|
+
experimental_output?: T;
|
|
67
|
+
runtimeContext?: RuntimeContext;
|
|
68
|
+
} & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
|
|
52
69
|
|
|
53
70
|
export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
54
71
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
55
|
-
|
|
72
|
+
output?: T;
|
|
73
|
+
experimental_output?: T;
|
|
74
|
+
runtimeContext?: RuntimeContext;
|
|
75
|
+
} & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
|
|
56
76
|
|
|
57
77
|
export interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
58
78
|
evals: any[];
|
|
@@ -87,6 +107,8 @@ export interface GetWorkflowRunsParams {
|
|
|
87
107
|
|
|
88
108
|
export type GetWorkflowRunsResponse = WorkflowRuns;
|
|
89
109
|
|
|
110
|
+
export type GetVNextWorkflowRunsResponse = VNextWorkflowRuns;
|
|
111
|
+
|
|
90
112
|
export type WorkflowRunResult = {
|
|
91
113
|
activePaths: Record<string, { status: string; suspendPayload?: any; stepPath: string[] }>;
|
|
92
114
|
results: CoreWorkflowRunResult<any, any, any>['results'];
|
|
@@ -174,6 +196,13 @@ export interface UpdateMemoryThreadParams {
|
|
|
174
196
|
resourceId: string;
|
|
175
197
|
}
|
|
176
198
|
|
|
199
|
+
export interface GetMemoryThreadMessagesParams {
|
|
200
|
+
/**
|
|
201
|
+
* Limit the number of messages to retrieve (default: 40)
|
|
202
|
+
*/
|
|
203
|
+
limit?: number;
|
|
204
|
+
}
|
|
205
|
+
|
|
177
206
|
export interface GetMemoryThreadMessagesResponse {
|
|
178
207
|
messages: CoreMessage[];
|
|
179
208
|
uiMessages: AiMessageType[];
|
|
@@ -260,3 +289,20 @@ export interface GetNetworkResponse {
|
|
|
260
289
|
};
|
|
261
290
|
state?: Record<string, any>;
|
|
262
291
|
}
|
|
292
|
+
|
|
293
|
+
export interface McpServerListResponse {
|
|
294
|
+
servers: ServerInfo[];
|
|
295
|
+
next: string | null;
|
|
296
|
+
total_count: number;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
export interface McpToolInfo {
|
|
300
|
+
id: string;
|
|
301
|
+
name: string;
|
|
302
|
+
description?: string;
|
|
303
|
+
inputSchema: string;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export interface McpServerToolListResponse {
|
|
307
|
+
tools: McpToolInfo[];
|
|
308
|
+
}
|
|
@@ -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
|
+
}
|