@mastra/client-js 0.0.0-vector-query-sources-20250516172905 → 0.0.0-vector-query-tool-provider-options-20250828222356
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/.turbo/turbo-build.log +18 -0
- package/CHANGELOG.md +1318 -2
- package/LICENSE.md +11 -42
- package/README.md +2 -1
- package/dist/adapters/agui.d.ts +23 -0
- package/dist/adapters/agui.d.ts.map +1 -0
- package/dist/client.d.ts +274 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/example.d.ts +2 -0
- package/dist/example.d.ts.map +1 -0
- package/dist/index.cjs +1801 -137
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +4 -883
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1803 -139
- package/dist/index.js.map +1 -0
- package/dist/resources/a2a.d.ts +41 -0
- package/dist/resources/a2a.d.ts.map +1 -0
- package/dist/resources/agent.d.ts +130 -0
- package/dist/resources/agent.d.ts.map +1 -0
- package/dist/resources/base.d.ts +13 -0
- package/dist/resources/base.d.ts.map +1 -0
- package/dist/resources/index.d.ts +12 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/legacy-workflow.d.ts +87 -0
- package/dist/resources/legacy-workflow.d.ts.map +1 -0
- package/dist/resources/mcp-tool.d.ts +27 -0
- package/dist/resources/mcp-tool.d.ts.map +1 -0
- package/dist/resources/memory-thread.d.ts +53 -0
- package/dist/resources/memory-thread.d.ts.map +1 -0
- package/dist/resources/network-memory-thread.d.ts +47 -0
- package/dist/resources/network-memory-thread.d.ts.map +1 -0
- package/dist/resources/network.d.ts +30 -0
- package/dist/resources/network.d.ts.map +1 -0
- package/dist/resources/observability.d.ts +19 -0
- package/dist/resources/observability.d.ts.map +1 -0
- package/dist/resources/tool.d.ts +23 -0
- package/dist/resources/tool.d.ts.map +1 -0
- package/dist/resources/vNextNetwork.d.ts +42 -0
- package/dist/resources/vNextNetwork.d.ts.map +1 -0
- package/dist/resources/vector.d.ts +48 -0
- package/dist/resources/vector.d.ts.map +1 -0
- package/dist/resources/workflow.d.ts +154 -0
- package/dist/resources/workflow.d.ts.map +1 -0
- package/dist/types.d.ts +449 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/process-client-tools.d.ts +3 -0
- package/dist/utils/process-client-tools.d.ts.map +1 -0
- package/dist/utils/process-mastra-stream.d.ts +7 -0
- package/dist/utils/process-mastra-stream.d.ts.map +1 -0
- package/dist/utils/zod-to-json-schema.d.ts +3 -0
- package/dist/utils/zod-to-json-schema.d.ts.map +1 -0
- package/eslint.config.js +6 -1
- package/integration-tests/agui-adapter.test.ts +122 -0
- package/integration-tests/package.json +18 -0
- package/integration-tests/src/mastra/index.ts +35 -0
- package/integration-tests/vitest.config.ts +9 -0
- package/package.json +32 -19
- package/src/adapters/agui.test.ts +116 -3
- package/src/adapters/agui.ts +30 -12
- package/src/client.ts +333 -24
- package/src/example.ts +46 -15
- package/src/index.test.ts +429 -6
- package/src/index.ts +1 -0
- package/src/resources/a2a.ts +35 -25
- package/src/resources/agent.ts +1284 -20
- package/src/resources/base.ts +8 -1
- package/src/resources/index.ts +3 -2
- package/src/resources/{vnext-workflow.ts → legacy-workflow.ts} +124 -143
- package/src/resources/memory-thread.test.ts +285 -0
- package/src/resources/memory-thread.ts +37 -1
- package/src/resources/network-memory-thread.test.ts +269 -0
- package/src/resources/network-memory-thread.ts +81 -0
- package/src/resources/network.ts +7 -7
- package/src/resources/observability.ts +53 -0
- package/src/resources/tool.ts +4 -3
- package/src/resources/vNextNetwork.ts +194 -0
- package/src/resources/workflow.ts +255 -96
- package/src/types.ts +262 -36
- package/src/utils/index.ts +11 -0
- package/src/utils/process-client-tools.ts +32 -0
- package/src/utils/process-mastra-stream.test.ts +353 -0
- package/src/utils/process-mastra-stream.ts +49 -0
- package/src/utils/zod-to-json-schema.ts +23 -3
- package/src/v2-messages.test.ts +180 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +2 -2
- package/tsup.config.ts +17 -0
- package/dist/index.d.cts +0 -883
package/src/types.ts
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
AgentExecutionOptions,
|
|
3
|
+
AgentGenerateOptions,
|
|
4
|
+
AgentStreamOptions,
|
|
5
|
+
ToolsInput,
|
|
6
|
+
UIMessageWithMetadata,
|
|
7
|
+
} from '@mastra/core/agent';
|
|
8
|
+
import type { MessageListInput } from '@mastra/core/agent/message-list';
|
|
9
|
+
import type { CoreMessage } from '@mastra/core/llm';
|
|
10
|
+
import type { BaseLogMessage, LogLevel } from '@mastra/core/logger';
|
|
11
|
+
import type { MCPToolType, ServerInfo } from '@mastra/core/mcp';
|
|
12
|
+
import type { AiMessageType, MastraMessageV1, MastraMessageV2, StorageThreadType } from '@mastra/core/memory';
|
|
13
|
+
import type { RuntimeContext } from '@mastra/core/runtime-context';
|
|
14
|
+
import type { MastraScorerEntry, ScoreRowData } from '@mastra/core/scores';
|
|
15
|
+
import type {
|
|
16
|
+
AITraceRecord,
|
|
17
|
+
AISpanRecord,
|
|
18
|
+
LegacyWorkflowRuns,
|
|
19
|
+
StorageGetMessagesArg,
|
|
20
|
+
PaginationInfo,
|
|
21
|
+
WorkflowRun,
|
|
22
|
+
WorkflowRuns,
|
|
23
|
+
} from '@mastra/core/storage';
|
|
24
|
+
import type { OutputSchema } from '@mastra/core/stream';
|
|
25
|
+
import type { QueryResult } from '@mastra/core/vector';
|
|
26
|
+
import type { Workflow, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
|
|
27
|
+
import type {
|
|
6
28
|
StepAction,
|
|
7
29
|
StepGraph,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
WorkflowRunResult as CoreWorkflowRunResult,
|
|
11
|
-
VNextWorkflowRuns,
|
|
12
|
-
WorkflowRuns,
|
|
13
|
-
} from '@mastra/core';
|
|
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';
|
|
18
|
-
import type { NewWorkflow, WatchEvent, WorkflowResult as VNextWorkflowResult } from '@mastra/core/workflows/vNext';
|
|
30
|
+
LegacyWorkflowRunResult as CoreLegacyWorkflowRunResult,
|
|
31
|
+
} from '@mastra/core/workflows/legacy';
|
|
19
32
|
import type { JSONSchema7 } from 'json-schema';
|
|
20
33
|
import type { ZodSchema } from 'zod';
|
|
21
34
|
|
|
@@ -31,6 +44,9 @@ export interface ClientOptions {
|
|
|
31
44
|
/** Custom headers to include with requests */
|
|
32
45
|
headers?: Record<string, string>;
|
|
33
46
|
/** Abort signal for request */
|
|
47
|
+
abortSignal?: AbortSignal;
|
|
48
|
+
/** Credentials mode for requests. See https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials for more info. */
|
|
49
|
+
credentials?: 'omit' | 'same-origin' | 'include';
|
|
34
50
|
}
|
|
35
51
|
|
|
36
52
|
export interface RequestOptions {
|
|
@@ -38,7 +54,8 @@ export interface RequestOptions {
|
|
|
38
54
|
headers?: Record<string, string>;
|
|
39
55
|
body?: any;
|
|
40
56
|
stream?: boolean;
|
|
41
|
-
|
|
57
|
+
/** Credentials mode for requests. See https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials for more info. */
|
|
58
|
+
credentials?: 'omit' | 'same-origin' | 'include';
|
|
42
59
|
}
|
|
43
60
|
|
|
44
61
|
type WithoutMethods<T> = {
|
|
@@ -58,21 +75,42 @@ export interface GetAgentResponse {
|
|
|
58
75
|
workflows: Record<string, GetWorkflowResponse>;
|
|
59
76
|
provider: string;
|
|
60
77
|
modelId: string;
|
|
78
|
+
modelVersion: string;
|
|
79
|
+
defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
|
|
80
|
+
defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
|
|
61
81
|
}
|
|
62
82
|
|
|
63
83
|
export type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
64
|
-
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
84
|
+
messages: string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[];
|
|
65
85
|
output?: T;
|
|
66
86
|
experimental_output?: T;
|
|
67
|
-
runtimeContext?: RuntimeContext
|
|
68
|
-
|
|
87
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
88
|
+
clientTools?: ToolsInput;
|
|
89
|
+
} & WithoutMethods<
|
|
90
|
+
Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>
|
|
91
|
+
>;
|
|
69
92
|
|
|
70
93
|
export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
71
|
-
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
94
|
+
messages: string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[];
|
|
72
95
|
output?: T;
|
|
73
96
|
experimental_output?: T;
|
|
74
|
-
runtimeContext?: RuntimeContext
|
|
75
|
-
|
|
97
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
98
|
+
clientTools?: ToolsInput;
|
|
99
|
+
} & WithoutMethods<
|
|
100
|
+
Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>
|
|
101
|
+
>;
|
|
102
|
+
|
|
103
|
+
export type StreamVNextParams<OUTPUT extends OutputSchema | undefined = undefined> = {
|
|
104
|
+
messages: MessageListInput;
|
|
105
|
+
output?: OUTPUT;
|
|
106
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
107
|
+
clientTools?: ToolsInput;
|
|
108
|
+
} & WithoutMethods<Omit<AgentExecutionOptions<OUTPUT>, 'output' | 'runtimeContext' | 'clientTools' | 'options'>>;
|
|
109
|
+
|
|
110
|
+
export type UpdateModelParams = {
|
|
111
|
+
modelId: string;
|
|
112
|
+
provider: 'openai' | 'anthropic' | 'groq' | 'xai' | 'google';
|
|
113
|
+
};
|
|
76
114
|
|
|
77
115
|
export interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
78
116
|
evals: any[];
|
|
@@ -88,7 +126,7 @@ export interface GetToolResponse {
|
|
|
88
126
|
outputSchema: string;
|
|
89
127
|
}
|
|
90
128
|
|
|
91
|
-
export interface
|
|
129
|
+
export interface GetLegacyWorkflowResponse {
|
|
92
130
|
name: string;
|
|
93
131
|
triggerSchema: string;
|
|
94
132
|
steps: Record<string, StepAction<any, any, any, any>>;
|
|
@@ -105,19 +143,24 @@ export interface GetWorkflowRunsParams {
|
|
|
105
143
|
resourceId?: string;
|
|
106
144
|
}
|
|
107
145
|
|
|
146
|
+
export type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
|
|
147
|
+
|
|
108
148
|
export type GetWorkflowRunsResponse = WorkflowRuns;
|
|
109
149
|
|
|
110
|
-
export type
|
|
150
|
+
export type GetWorkflowRunByIdResponse = WorkflowRun;
|
|
111
151
|
|
|
112
|
-
export type
|
|
152
|
+
export type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
|
|
153
|
+
|
|
154
|
+
export type LegacyWorkflowRunResult = {
|
|
113
155
|
activePaths: Record<string, { status: string; suspendPayload?: any; stepPath: string[] }>;
|
|
114
|
-
results:
|
|
156
|
+
results: CoreLegacyWorkflowRunResult<any, any, any>['results'];
|
|
115
157
|
timestamp: number;
|
|
116
158
|
runId: string;
|
|
117
159
|
};
|
|
118
160
|
|
|
119
|
-
export interface
|
|
161
|
+
export interface GetWorkflowResponse {
|
|
120
162
|
name: string;
|
|
163
|
+
description?: string;
|
|
121
164
|
steps: {
|
|
122
165
|
[key: string]: {
|
|
123
166
|
id: string;
|
|
@@ -128,14 +171,25 @@ export interface GetVNextWorkflowResponse {
|
|
|
128
171
|
suspendSchema: string;
|
|
129
172
|
};
|
|
130
173
|
};
|
|
131
|
-
|
|
174
|
+
allSteps: {
|
|
175
|
+
[key: string]: {
|
|
176
|
+
id: string;
|
|
177
|
+
description: string;
|
|
178
|
+
inputSchema: string;
|
|
179
|
+
outputSchema: string;
|
|
180
|
+
resumeSchema: string;
|
|
181
|
+
suspendSchema: string;
|
|
182
|
+
isWorkflow: boolean;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
stepGraph: Workflow['serializedStepGraph'];
|
|
132
186
|
inputSchema: string;
|
|
133
187
|
outputSchema: string;
|
|
134
188
|
}
|
|
135
189
|
|
|
136
|
-
export type
|
|
190
|
+
export type WorkflowWatchResult = WatchEvent & { runId: string };
|
|
137
191
|
|
|
138
|
-
export type
|
|
192
|
+
export type WorkflowRunResult = WorkflowResult<any, any>;
|
|
139
193
|
export interface UpsertVectorParams {
|
|
140
194
|
indexName: string;
|
|
141
195
|
vectors: number[][];
|
|
@@ -167,20 +221,33 @@ export interface GetVectorIndexResponse {
|
|
|
167
221
|
}
|
|
168
222
|
|
|
169
223
|
export interface SaveMessageToMemoryParams {
|
|
170
|
-
messages:
|
|
224
|
+
messages: (MastraMessageV1 | MastraMessageV2)[];
|
|
171
225
|
agentId: string;
|
|
172
226
|
}
|
|
173
227
|
|
|
174
|
-
export
|
|
228
|
+
export interface SaveNetworkMessageToMemoryParams {
|
|
229
|
+
messages: (MastraMessageV1 | MastraMessageV2)[];
|
|
230
|
+
networkId: string;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export type SaveMessageToMemoryResponse = (MastraMessageV1 | MastraMessageV2)[];
|
|
175
234
|
|
|
176
235
|
export interface CreateMemoryThreadParams {
|
|
177
|
-
title
|
|
178
|
-
metadata
|
|
236
|
+
title?: string;
|
|
237
|
+
metadata?: Record<string, any>;
|
|
179
238
|
resourceId: string;
|
|
180
|
-
threadId
|
|
239
|
+
threadId?: string;
|
|
181
240
|
agentId: string;
|
|
182
241
|
}
|
|
183
242
|
|
|
243
|
+
export interface CreateNetworkMemoryThreadParams {
|
|
244
|
+
title?: string;
|
|
245
|
+
metadata?: Record<string, any>;
|
|
246
|
+
resourceId: string;
|
|
247
|
+
threadId?: string;
|
|
248
|
+
networkId: string;
|
|
249
|
+
}
|
|
250
|
+
|
|
184
251
|
export type CreateMemoryThreadResponse = StorageThreadType;
|
|
185
252
|
|
|
186
253
|
export interface GetMemoryThreadParams {
|
|
@@ -188,6 +255,11 @@ export interface GetMemoryThreadParams {
|
|
|
188
255
|
agentId: string;
|
|
189
256
|
}
|
|
190
257
|
|
|
258
|
+
export interface GetNetworkMemoryThreadParams {
|
|
259
|
+
resourceId: string;
|
|
260
|
+
networkId: string;
|
|
261
|
+
}
|
|
262
|
+
|
|
191
263
|
export type GetMemoryThreadResponse = StorageThreadType[];
|
|
192
264
|
|
|
193
265
|
export interface UpdateMemoryThreadParams {
|
|
@@ -203,21 +275,45 @@ export interface GetMemoryThreadMessagesParams {
|
|
|
203
275
|
limit?: number;
|
|
204
276
|
}
|
|
205
277
|
|
|
278
|
+
export type GetMemoryThreadMessagesPaginatedParams = Omit<StorageGetMessagesArg, 'threadConfig' | 'threadId'>;
|
|
279
|
+
|
|
206
280
|
export interface GetMemoryThreadMessagesResponse {
|
|
207
281
|
messages: CoreMessage[];
|
|
208
282
|
uiMessages: AiMessageType[];
|
|
209
283
|
}
|
|
210
284
|
|
|
285
|
+
export type GetMemoryThreadMessagesPaginatedResponse = PaginationInfo & {
|
|
286
|
+
messages: MastraMessageV1[] | MastraMessageV2[];
|
|
287
|
+
};
|
|
288
|
+
|
|
211
289
|
export interface GetLogsParams {
|
|
212
290
|
transportId: string;
|
|
291
|
+
fromDate?: Date;
|
|
292
|
+
toDate?: Date;
|
|
293
|
+
logLevel?: LogLevel;
|
|
294
|
+
filters?: Record<string, string>;
|
|
295
|
+
page?: number;
|
|
296
|
+
perPage?: number;
|
|
213
297
|
}
|
|
214
298
|
|
|
215
299
|
export interface GetLogParams {
|
|
216
300
|
runId: string;
|
|
217
301
|
transportId: string;
|
|
302
|
+
fromDate?: Date;
|
|
303
|
+
toDate?: Date;
|
|
304
|
+
logLevel?: LogLevel;
|
|
305
|
+
filters?: Record<string, string>;
|
|
306
|
+
page?: number;
|
|
307
|
+
perPage?: number;
|
|
218
308
|
}
|
|
219
309
|
|
|
220
|
-
export type GetLogsResponse =
|
|
310
|
+
export type GetLogsResponse = {
|
|
311
|
+
logs: BaseLogMessage[];
|
|
312
|
+
total: number;
|
|
313
|
+
page: number;
|
|
314
|
+
perPage: number;
|
|
315
|
+
hasMore: boolean;
|
|
316
|
+
};
|
|
221
317
|
|
|
222
318
|
export type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
|
|
223
319
|
|
|
@@ -276,6 +372,7 @@ export interface GetTelemetryParams {
|
|
|
276
372
|
}
|
|
277
373
|
|
|
278
374
|
export interface GetNetworkResponse {
|
|
375
|
+
id: string;
|
|
279
376
|
name: string;
|
|
280
377
|
instructions: string;
|
|
281
378
|
agents: Array<{
|
|
@@ -290,6 +387,71 @@ export interface GetNetworkResponse {
|
|
|
290
387
|
state?: Record<string, any>;
|
|
291
388
|
}
|
|
292
389
|
|
|
390
|
+
export interface GetVNextNetworkResponse {
|
|
391
|
+
id: string;
|
|
392
|
+
name: string;
|
|
393
|
+
instructions: string;
|
|
394
|
+
agents: Array<{
|
|
395
|
+
name: string;
|
|
396
|
+
provider: string;
|
|
397
|
+
modelId: string;
|
|
398
|
+
}>;
|
|
399
|
+
routingModel: {
|
|
400
|
+
provider: string;
|
|
401
|
+
modelId: string;
|
|
402
|
+
};
|
|
403
|
+
workflows: Array<{
|
|
404
|
+
name: string;
|
|
405
|
+
description: string;
|
|
406
|
+
inputSchema: string | undefined;
|
|
407
|
+
outputSchema: string | undefined;
|
|
408
|
+
}>;
|
|
409
|
+
tools: Array<{
|
|
410
|
+
id: string;
|
|
411
|
+
description: string;
|
|
412
|
+
}>;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export interface GenerateVNextNetworkResponse {
|
|
416
|
+
task: string;
|
|
417
|
+
result: string;
|
|
418
|
+
resourceId: string;
|
|
419
|
+
resourceType: 'none' | 'tool' | 'agent' | 'workflow';
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
export interface GenerateOrStreamVNextNetworkParams {
|
|
423
|
+
message: string;
|
|
424
|
+
threadId?: string;
|
|
425
|
+
resourceId?: string;
|
|
426
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
export interface LoopStreamVNextNetworkParams {
|
|
430
|
+
message: string;
|
|
431
|
+
threadId?: string;
|
|
432
|
+
resourceId?: string;
|
|
433
|
+
maxIterations?: number;
|
|
434
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
export interface LoopVNextNetworkResponse {
|
|
438
|
+
status: 'success';
|
|
439
|
+
result: {
|
|
440
|
+
task: string;
|
|
441
|
+
resourceId: string;
|
|
442
|
+
resourceType: 'agent' | 'workflow' | 'none' | 'tool';
|
|
443
|
+
result: string;
|
|
444
|
+
iteration: number;
|
|
445
|
+
isOneOff: boolean;
|
|
446
|
+
prompt: string;
|
|
447
|
+
threadId?: string | undefined;
|
|
448
|
+
threadResourceId?: string | undefined;
|
|
449
|
+
isComplete?: boolean | undefined;
|
|
450
|
+
completionReason?: string | undefined;
|
|
451
|
+
};
|
|
452
|
+
steps: WorkflowResult<any, any>['steps'];
|
|
453
|
+
}
|
|
454
|
+
|
|
293
455
|
export interface McpServerListResponse {
|
|
294
456
|
servers: ServerInfo[];
|
|
295
457
|
next: string | null;
|
|
@@ -301,8 +463,72 @@ export interface McpToolInfo {
|
|
|
301
463
|
name: string;
|
|
302
464
|
description?: string;
|
|
303
465
|
inputSchema: string;
|
|
466
|
+
toolType?: MCPToolType;
|
|
304
467
|
}
|
|
305
468
|
|
|
306
469
|
export interface McpServerToolListResponse {
|
|
307
470
|
tools: McpToolInfo[];
|
|
308
471
|
}
|
|
472
|
+
|
|
473
|
+
export type ClientScoreRowData = Omit<ScoreRowData, 'createdAt' | 'updatedAt'> & {
|
|
474
|
+
createdAt: string;
|
|
475
|
+
updatedAt: string;
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
// Scores-related types
|
|
479
|
+
export interface GetScoresByRunIdParams {
|
|
480
|
+
runId: string;
|
|
481
|
+
page?: number;
|
|
482
|
+
perPage?: number;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export interface GetScoresByScorerIdParams {
|
|
486
|
+
scorerId: string;
|
|
487
|
+
entityId?: string;
|
|
488
|
+
entityType?: string;
|
|
489
|
+
page?: number;
|
|
490
|
+
perPage?: number;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
export interface GetScoresByEntityIdParams {
|
|
494
|
+
entityId: string;
|
|
495
|
+
entityType: string;
|
|
496
|
+
page?: number;
|
|
497
|
+
perPage?: number;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
export interface SaveScoreParams {
|
|
501
|
+
score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export interface GetScoresResponse {
|
|
505
|
+
pagination: {
|
|
506
|
+
total: number;
|
|
507
|
+
page: number;
|
|
508
|
+
perPage: number;
|
|
509
|
+
hasMore: boolean;
|
|
510
|
+
};
|
|
511
|
+
scores: ClientScoreRowData[];
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
export interface SaveScoreResponse {
|
|
515
|
+
score: ClientScoreRowData;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
export type GetScorerResponse = MastraScorerEntry & {
|
|
519
|
+
agentIds: string[];
|
|
520
|
+
workflowIds: string[];
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
export interface GetScorersResponse {
|
|
524
|
+
scorers: Array<GetScorerResponse>;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
export interface GetAITraceResponse {
|
|
528
|
+
trace: AITraceRecord;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
export interface GetAITracesResponse {
|
|
532
|
+
spans: AISpanRecord[];
|
|
533
|
+
pagination: PaginationInfo;
|
|
534
|
+
}
|
|
@@ -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 type { ToolsInput } from '@mastra/core/agent';
|
|
2
|
+
import { isVercelTool } from '@mastra/core/tools/is-vercel-tool';
|
|
3
|
+
import { zodToJsonSchema } from './zod-to-json-schema';
|
|
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
|
+
}
|