@mastra/client-js 0.0.0-vector-query-tool-provider-options-20250828222356 → 0.0.0-vector-extension-schema-20250922130418

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.
Files changed (81) hide show
  1. package/CHANGELOG.md +429 -4
  2. package/README.md +7 -9
  3. package/dist/client.d.ts +37 -21
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/index.cjs +871 -417
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +869 -417
  10. package/dist/index.js.map +1 -1
  11. package/dist/resources/agent-builder.d.ts +160 -0
  12. package/dist/resources/agent-builder.d.ts.map +1 -0
  13. package/dist/resources/agent.d.ts +56 -11
  14. package/dist/resources/agent.d.ts.map +1 -1
  15. package/dist/resources/index.d.ts +1 -1
  16. package/dist/resources/index.d.ts.map +1 -1
  17. package/dist/resources/legacy-workflow.d.ts +5 -2
  18. package/dist/resources/legacy-workflow.d.ts.map +1 -1
  19. package/dist/resources/mcp-tool.d.ts +2 -1
  20. package/dist/resources/mcp-tool.d.ts.map +1 -1
  21. package/dist/resources/observability.d.ts.map +1 -1
  22. package/dist/resources/tool.d.ts +2 -1
  23. package/dist/resources/tool.d.ts.map +1 -1
  24. package/dist/resources/vNextNetwork.d.ts +2 -1
  25. package/dist/resources/vNextNetwork.d.ts.map +1 -1
  26. package/dist/resources/vector.d.ts +5 -2
  27. package/dist/resources/vector.d.ts.map +1 -1
  28. package/dist/resources/workflow.d.ts +110 -10
  29. package/dist/resources/workflow.d.ts.map +1 -1
  30. package/dist/tools.d.ts +22 -0
  31. package/dist/tools.d.ts.map +1 -0
  32. package/dist/types.d.ts +36 -21
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/utils/index.d.ts +2 -0
  35. package/dist/utils/index.d.ts.map +1 -1
  36. package/dist/utils/process-mastra-stream.d.ts +5 -1
  37. package/dist/utils/process-mastra-stream.d.ts.map +1 -1
  38. package/package.json +19 -15
  39. package/.turbo/turbo-build.log +0 -18
  40. package/dist/adapters/agui.d.ts +0 -23
  41. package/dist/adapters/agui.d.ts.map +0 -1
  42. package/dist/resources/network.d.ts +0 -30
  43. package/dist/resources/network.d.ts.map +0 -1
  44. package/eslint.config.js +0 -11
  45. package/integration-tests/agui-adapter.test.ts +0 -122
  46. package/integration-tests/package.json +0 -18
  47. package/integration-tests/src/mastra/index.ts +0 -35
  48. package/integration-tests/vitest.config.ts +0 -9
  49. package/src/adapters/agui.test.ts +0 -293
  50. package/src/adapters/agui.ts +0 -257
  51. package/src/client.ts +0 -644
  52. package/src/example.ts +0 -95
  53. package/src/index.test.ts +0 -1253
  54. package/src/index.ts +0 -3
  55. package/src/resources/a2a.ts +0 -98
  56. package/src/resources/agent.ts +0 -1460
  57. package/src/resources/base.ts +0 -77
  58. package/src/resources/index.ts +0 -11
  59. package/src/resources/legacy-workflow.ts +0 -242
  60. package/src/resources/mcp-tool.ts +0 -48
  61. package/src/resources/memory-thread.test.ts +0 -285
  62. package/src/resources/memory-thread.ts +0 -99
  63. package/src/resources/network-memory-thread.test.ts +0 -269
  64. package/src/resources/network-memory-thread.ts +0 -81
  65. package/src/resources/network.ts +0 -86
  66. package/src/resources/observability.ts +0 -53
  67. package/src/resources/tool.ts +0 -45
  68. package/src/resources/vNextNetwork.ts +0 -194
  69. package/src/resources/vector.ts +0 -83
  70. package/src/resources/workflow.ts +0 -410
  71. package/src/types.ts +0 -534
  72. package/src/utils/index.ts +0 -11
  73. package/src/utils/process-client-tools.ts +0 -32
  74. package/src/utils/process-mastra-stream.test.ts +0 -353
  75. package/src/utils/process-mastra-stream.ts +0 -49
  76. package/src/utils/zod-to-json-schema.ts +0 -30
  77. package/src/v2-messages.test.ts +0 -180
  78. package/tsconfig.build.json +0 -9
  79. package/tsconfig.json +0 -5
  80. package/tsup.config.ts +0 -17
  81. package/vitest.config.js +0 -8
package/src/types.ts DELETED
@@ -1,534 +0,0 @@
1
- import type {
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 {
28
- StepAction,
29
- StepGraph,
30
- LegacyWorkflowRunResult as CoreLegacyWorkflowRunResult,
31
- } from '@mastra/core/workflows/legacy';
32
- import type { JSONSchema7 } from 'json-schema';
33
- import type { ZodSchema } from 'zod';
34
-
35
- export interface ClientOptions {
36
- /** Base URL for API requests */
37
- baseUrl: string;
38
- /** Number of retry attempts for failed requests */
39
- retries?: number;
40
- /** Initial backoff time in milliseconds between retries */
41
- backoffMs?: number;
42
- /** Maximum backoff time in milliseconds between retries */
43
- maxBackoffMs?: number;
44
- /** Custom headers to include with requests */
45
- headers?: Record<string, string>;
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';
50
- }
51
-
52
- export interface RequestOptions {
53
- method?: string;
54
- headers?: Record<string, string>;
55
- body?: any;
56
- stream?: boolean;
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';
59
- }
60
-
61
- type WithoutMethods<T> = {
62
- [K in keyof T as T[K] extends (...args: any[]) => any
63
- ? never
64
- : T[K] extends { (): any }
65
- ? never
66
- : T[K] extends undefined | ((...args: any[]) => any)
67
- ? never
68
- : K]: T[K];
69
- };
70
-
71
- export interface GetAgentResponse {
72
- name: string;
73
- instructions: string;
74
- tools: Record<string, GetToolResponse>;
75
- workflows: Record<string, GetWorkflowResponse>;
76
- provider: string;
77
- modelId: string;
78
- modelVersion: string;
79
- defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
80
- defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
81
- }
82
-
83
- export type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
84
- messages: string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[];
85
- output?: T;
86
- experimental_output?: T;
87
- runtimeContext?: RuntimeContext | Record<string, any>;
88
- clientTools?: ToolsInput;
89
- } & WithoutMethods<
90
- Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>
91
- >;
92
-
93
- export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
94
- messages: string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[];
95
- output?: T;
96
- experimental_output?: T;
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
- };
114
-
115
- export interface GetEvalsByAgentIdResponse extends GetAgentResponse {
116
- evals: any[];
117
- instructions: string;
118
- name: string;
119
- id: string;
120
- }
121
-
122
- export interface GetToolResponse {
123
- id: string;
124
- description: string;
125
- inputSchema: string;
126
- outputSchema: string;
127
- }
128
-
129
- export interface GetLegacyWorkflowResponse {
130
- name: string;
131
- triggerSchema: string;
132
- steps: Record<string, StepAction<any, any, any, any>>;
133
- stepGraph: StepGraph;
134
- stepSubscriberGraph: Record<string, StepGraph>;
135
- workflowId?: string;
136
- }
137
-
138
- export interface GetWorkflowRunsParams {
139
- fromDate?: Date;
140
- toDate?: Date;
141
- limit?: number;
142
- offset?: number;
143
- resourceId?: string;
144
- }
145
-
146
- export type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
147
-
148
- export type GetWorkflowRunsResponse = WorkflowRuns;
149
-
150
- export type GetWorkflowRunByIdResponse = WorkflowRun;
151
-
152
- export type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
153
-
154
- export type LegacyWorkflowRunResult = {
155
- activePaths: Record<string, { status: string; suspendPayload?: any; stepPath: string[] }>;
156
- results: CoreLegacyWorkflowRunResult<any, any, any>['results'];
157
- timestamp: number;
158
- runId: string;
159
- };
160
-
161
- export interface GetWorkflowResponse {
162
- name: string;
163
- description?: string;
164
- steps: {
165
- [key: string]: {
166
- id: string;
167
- description: string;
168
- inputSchema: string;
169
- outputSchema: string;
170
- resumeSchema: string;
171
- suspendSchema: string;
172
- };
173
- };
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'];
186
- inputSchema: string;
187
- outputSchema: string;
188
- }
189
-
190
- export type WorkflowWatchResult = WatchEvent & { runId: string };
191
-
192
- export type WorkflowRunResult = WorkflowResult<any, any>;
193
- export interface UpsertVectorParams {
194
- indexName: string;
195
- vectors: number[][];
196
- metadata?: Record<string, any>[];
197
- ids?: string[];
198
- }
199
- export interface CreateIndexParams {
200
- indexName: string;
201
- dimension: number;
202
- metric?: 'cosine' | 'euclidean' | 'dotproduct';
203
- }
204
-
205
- export interface QueryVectorParams {
206
- indexName: string;
207
- queryVector: number[];
208
- topK?: number;
209
- filter?: Record<string, any>;
210
- includeVector?: boolean;
211
- }
212
-
213
- export interface QueryVectorResponse {
214
- results: QueryResult[];
215
- }
216
-
217
- export interface GetVectorIndexResponse {
218
- dimension: number;
219
- metric: 'cosine' | 'euclidean' | 'dotproduct';
220
- count: number;
221
- }
222
-
223
- export interface SaveMessageToMemoryParams {
224
- messages: (MastraMessageV1 | MastraMessageV2)[];
225
- agentId: string;
226
- }
227
-
228
- export interface SaveNetworkMessageToMemoryParams {
229
- messages: (MastraMessageV1 | MastraMessageV2)[];
230
- networkId: string;
231
- }
232
-
233
- export type SaveMessageToMemoryResponse = (MastraMessageV1 | MastraMessageV2)[];
234
-
235
- export interface CreateMemoryThreadParams {
236
- title?: string;
237
- metadata?: Record<string, any>;
238
- resourceId: string;
239
- threadId?: string;
240
- agentId: string;
241
- }
242
-
243
- export interface CreateNetworkMemoryThreadParams {
244
- title?: string;
245
- metadata?: Record<string, any>;
246
- resourceId: string;
247
- threadId?: string;
248
- networkId: string;
249
- }
250
-
251
- export type CreateMemoryThreadResponse = StorageThreadType;
252
-
253
- export interface GetMemoryThreadParams {
254
- resourceId: string;
255
- agentId: string;
256
- }
257
-
258
- export interface GetNetworkMemoryThreadParams {
259
- resourceId: string;
260
- networkId: string;
261
- }
262
-
263
- export type GetMemoryThreadResponse = StorageThreadType[];
264
-
265
- export interface UpdateMemoryThreadParams {
266
- title: string;
267
- metadata: Record<string, any>;
268
- resourceId: string;
269
- }
270
-
271
- export interface GetMemoryThreadMessagesParams {
272
- /**
273
- * Limit the number of messages to retrieve (default: 40)
274
- */
275
- limit?: number;
276
- }
277
-
278
- export type GetMemoryThreadMessagesPaginatedParams = Omit<StorageGetMessagesArg, 'threadConfig' | 'threadId'>;
279
-
280
- export interface GetMemoryThreadMessagesResponse {
281
- messages: CoreMessage[];
282
- uiMessages: AiMessageType[];
283
- }
284
-
285
- export type GetMemoryThreadMessagesPaginatedResponse = PaginationInfo & {
286
- messages: MastraMessageV1[] | MastraMessageV2[];
287
- };
288
-
289
- export interface GetLogsParams {
290
- transportId: string;
291
- fromDate?: Date;
292
- toDate?: Date;
293
- logLevel?: LogLevel;
294
- filters?: Record<string, string>;
295
- page?: number;
296
- perPage?: number;
297
- }
298
-
299
- export interface GetLogParams {
300
- runId: string;
301
- transportId: string;
302
- fromDate?: Date;
303
- toDate?: Date;
304
- logLevel?: LogLevel;
305
- filters?: Record<string, string>;
306
- page?: number;
307
- perPage?: number;
308
- }
309
-
310
- export type GetLogsResponse = {
311
- logs: BaseLogMessage[];
312
- total: number;
313
- page: number;
314
- perPage: number;
315
- hasMore: boolean;
316
- };
317
-
318
- export type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
319
-
320
- type SpanStatus = {
321
- code: number;
322
- };
323
-
324
- type SpanOther = {
325
- droppedAttributesCount: number;
326
- droppedEventsCount: number;
327
- droppedLinksCount: number;
328
- };
329
-
330
- type SpanEventAttributes = {
331
- key: string;
332
- value: { [key: string]: string | number | boolean | null };
333
- };
334
-
335
- type SpanEvent = {
336
- attributes: SpanEventAttributes[];
337
- name: string;
338
- timeUnixNano: string;
339
- droppedAttributesCount: number;
340
- };
341
-
342
- type Span = {
343
- id: string;
344
- parentSpanId: string | null;
345
- traceId: string;
346
- name: string;
347
- scope: string;
348
- kind: number;
349
- status: SpanStatus;
350
- events: SpanEvent[];
351
- links: any[];
352
- attributes: Record<string, string | number | boolean | null>;
353
- startTime: number;
354
- endTime: number;
355
- duration: number;
356
- other: SpanOther;
357
- createdAt: string;
358
- };
359
-
360
- export interface GetTelemetryResponse {
361
- traces: Span[];
362
- }
363
-
364
- export interface GetTelemetryParams {
365
- name?: string;
366
- scope?: string;
367
- page?: number;
368
- perPage?: number;
369
- attribute?: Record<string, string>;
370
- fromDate?: Date;
371
- toDate?: Date;
372
- }
373
-
374
- export interface GetNetworkResponse {
375
- id: string;
376
- name: string;
377
- instructions: string;
378
- agents: Array<{
379
- name: string;
380
- provider: string;
381
- modelId: string;
382
- }>;
383
- routingModel: {
384
- provider: string;
385
- modelId: string;
386
- };
387
- state?: Record<string, any>;
388
- }
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
-
455
- export interface McpServerListResponse {
456
- servers: ServerInfo[];
457
- next: string | null;
458
- total_count: number;
459
- }
460
-
461
- export interface McpToolInfo {
462
- id: string;
463
- name: string;
464
- description?: string;
465
- inputSchema: string;
466
- toolType?: MCPToolType;
467
- }
468
-
469
- export interface McpServerToolListResponse {
470
- tools: McpToolInfo[];
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
- }
@@ -1,11 +0,0 @@
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
- }
@@ -1,32 +0,0 @@
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
- }