@mastra/client-js 0.0.0-declaration-maps-20250730185206 → 0.0.0-dynamic-model-router-20251009204130

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 (90) hide show
  1. package/CHANGELOG.md +1016 -2
  2. package/README.md +6 -8
  3. package/dist/client.d.ts +57 -44
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/index.cjs +1734 -849
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.ts +3 -2
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.js +1735 -852
  10. package/dist/index.js.map +1 -1
  11. package/dist/resources/a2a.d.ts +15 -18
  12. package/dist/resources/a2a.d.ts.map +1 -1
  13. package/dist/resources/agent-builder.d.ts +160 -0
  14. package/dist/resources/agent-builder.d.ts.map +1 -0
  15. package/dist/resources/agent.d.ts +88 -16
  16. package/dist/resources/agent.d.ts.map +1 -1
  17. package/dist/resources/base.d.ts +1 -1
  18. package/dist/resources/base.d.ts.map +1 -1
  19. package/dist/resources/index.d.ts +10 -10
  20. package/dist/resources/index.d.ts.map +1 -1
  21. package/dist/resources/mcp-tool.d.ts +4 -3
  22. package/dist/resources/mcp-tool.d.ts.map +1 -1
  23. package/dist/resources/memory-thread.d.ts +3 -3
  24. package/dist/resources/memory-thread.d.ts.map +1 -1
  25. package/dist/resources/network-memory-thread.d.ts +3 -3
  26. package/dist/resources/network-memory-thread.d.ts.map +1 -1
  27. package/dist/resources/observability.d.ts +35 -0
  28. package/dist/resources/observability.d.ts.map +1 -0
  29. package/dist/resources/tool.d.ts +4 -3
  30. package/dist/resources/tool.d.ts.map +1 -1
  31. package/dist/resources/vector.d.ts +7 -4
  32. package/dist/resources/vector.d.ts.map +1 -1
  33. package/dist/resources/workflow.d.ts +129 -14
  34. package/dist/resources/workflow.d.ts.map +1 -1
  35. package/dist/tools.d.ts +22 -0
  36. package/dist/tools.d.ts.map +1 -0
  37. package/dist/types.d.ts +102 -40
  38. package/dist/types.d.ts.map +1 -1
  39. package/dist/utils/index.d.ts +2 -0
  40. package/dist/utils/index.d.ts.map +1 -1
  41. package/dist/utils/process-client-tools.d.ts.map +1 -1
  42. package/dist/utils/process-mastra-stream.d.ts +11 -0
  43. package/dist/utils/process-mastra-stream.d.ts.map +1 -0
  44. package/dist/utils/zod-to-json-schema.d.ts +2 -104
  45. package/dist/utils/zod-to-json-schema.d.ts.map +1 -1
  46. package/package.json +24 -16
  47. package/.turbo/turbo-build.log +0 -4
  48. package/dist/adapters/agui.d.ts +0 -23
  49. package/dist/adapters/agui.d.ts.map +0 -1
  50. package/dist/resources/legacy-workflow.d.ts +0 -87
  51. package/dist/resources/legacy-workflow.d.ts.map +0 -1
  52. package/dist/resources/network.d.ts +0 -30
  53. package/dist/resources/network.d.ts.map +0 -1
  54. package/dist/resources/vNextNetwork.d.ts +0 -42
  55. package/dist/resources/vNextNetwork.d.ts.map +0 -1
  56. package/eslint.config.js +0 -6
  57. package/integration-tests/agui-adapter.test.ts +0 -122
  58. package/integration-tests/package.json +0 -18
  59. package/integration-tests/src/mastra/index.ts +0 -35
  60. package/integration-tests/vitest.config.ts +0 -9
  61. package/src/adapters/agui.test.ts +0 -322
  62. package/src/adapters/agui.ts +0 -239
  63. package/src/client.ts +0 -623
  64. package/src/example.ts +0 -95
  65. package/src/index.test.ts +0 -1226
  66. package/src/index.ts +0 -3
  67. package/src/resources/a2a.ts +0 -88
  68. package/src/resources/agent.ts +0 -785
  69. package/src/resources/base.ts +0 -76
  70. package/src/resources/index.ts +0 -10
  71. package/src/resources/legacy-workflow.ts +0 -242
  72. package/src/resources/mcp-tool.ts +0 -48
  73. package/src/resources/memory-thread.test.ts +0 -285
  74. package/src/resources/memory-thread.ts +0 -99
  75. package/src/resources/network-memory-thread.test.ts +0 -269
  76. package/src/resources/network-memory-thread.ts +0 -81
  77. package/src/resources/network.ts +0 -86
  78. package/src/resources/tool.ts +0 -45
  79. package/src/resources/vNextNetwork.ts +0 -194
  80. package/src/resources/vector.ts +0 -83
  81. package/src/resources/workflow.ts +0 -410
  82. package/src/types.ts +0 -502
  83. package/src/utils/index.ts +0 -11
  84. package/src/utils/process-client-tools.ts +0 -32
  85. package/src/utils/zod-to-json-schema.ts +0 -10
  86. package/src/v2-messages.test.ts +0 -180
  87. package/tsconfig.build.json +0 -9
  88. package/tsconfig.json +0 -5
  89. package/tsup.config.ts +0 -22
  90. package/vitest.config.js +0 -8
package/src/types.ts DELETED
@@ -1,502 +0,0 @@
1
- import type {
2
- MastraMessageV1,
3
- AiMessageType,
4
- CoreMessage,
5
- QueryResult,
6
- StorageThreadType,
7
- WorkflowRuns,
8
- WorkflowRun,
9
- LegacyWorkflowRuns,
10
- StorageGetMessagesArg,
11
- PaginationInfo,
12
- MastraMessageV2,
13
- } from '@mastra/core';
14
- import type { AgentGenerateOptions, AgentStreamOptions, ToolsInput, UIMessageWithMetadata } from '@mastra/core/agent';
15
- import type { BaseLogMessage, LogLevel } from '@mastra/core/logger';
16
-
17
- import type { MCPToolType, ServerInfo } from '@mastra/core/mcp';
18
- import type { RuntimeContext } from '@mastra/core/runtime-context';
19
- import type { MastraScorer, MastraScorerEntry, ScoreRowData } from '@mastra/core/scores';
20
- import type { Workflow, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
21
- import type {
22
- StepAction,
23
- StepGraph,
24
- LegacyWorkflowRunResult as CoreLegacyWorkflowRunResult,
25
- } from '@mastra/core/workflows/legacy';
26
- import type { JSONSchema7 } from 'json-schema';
27
- import type { ZodSchema } from 'zod';
28
-
29
- export interface ClientOptions {
30
- /** Base URL for API requests */
31
- baseUrl: string;
32
- /** Number of retry attempts for failed requests */
33
- retries?: number;
34
- /** Initial backoff time in milliseconds between retries */
35
- backoffMs?: number;
36
- /** Maximum backoff time in milliseconds between retries */
37
- maxBackoffMs?: number;
38
- /** Custom headers to include with requests */
39
- headers?: Record<string, string>;
40
- /** Abort signal for request */
41
- abortSignal?: AbortSignal;
42
- }
43
-
44
- export interface RequestOptions {
45
- method?: string;
46
- headers?: Record<string, string>;
47
- body?: any;
48
- stream?: boolean;
49
- }
50
-
51
- type WithoutMethods<T> = {
52
- [K in keyof T as T[K] extends (...args: any[]) => any
53
- ? never
54
- : T[K] extends { (): any }
55
- ? never
56
- : T[K] extends undefined | ((...args: any[]) => any)
57
- ? never
58
- : K]: T[K];
59
- };
60
-
61
- export interface GetAgentResponse {
62
- name: string;
63
- instructions: string;
64
- tools: Record<string, GetToolResponse>;
65
- workflows: Record<string, GetWorkflowResponse>;
66
- provider: string;
67
- modelId: string;
68
- defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
69
- defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
70
- }
71
-
72
- export type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
73
- messages: string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[];
74
- output?: T;
75
- experimental_output?: T;
76
- runtimeContext?: RuntimeContext | Record<string, any>;
77
- clientTools?: ToolsInput;
78
- } & WithoutMethods<
79
- Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>
80
- >;
81
-
82
- export type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
83
- messages: string | string[] | CoreMessage[] | AiMessageType[] | UIMessageWithMetadata[];
84
- output?: T;
85
- experimental_output?: T;
86
- runtimeContext?: RuntimeContext | Record<string, any>;
87
- clientTools?: ToolsInput;
88
- } & WithoutMethods<
89
- Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>
90
- >;
91
-
92
- export interface GetEvalsByAgentIdResponse extends GetAgentResponse {
93
- evals: any[];
94
- instructions: string;
95
- name: string;
96
- id: string;
97
- }
98
-
99
- export interface GetToolResponse {
100
- id: string;
101
- description: string;
102
- inputSchema: string;
103
- outputSchema: string;
104
- }
105
-
106
- export interface GetLegacyWorkflowResponse {
107
- name: string;
108
- triggerSchema: string;
109
- steps: Record<string, StepAction<any, any, any, any>>;
110
- stepGraph: StepGraph;
111
- stepSubscriberGraph: Record<string, StepGraph>;
112
- workflowId?: string;
113
- }
114
-
115
- export interface GetWorkflowRunsParams {
116
- fromDate?: Date;
117
- toDate?: Date;
118
- limit?: number;
119
- offset?: number;
120
- resourceId?: string;
121
- }
122
-
123
- export type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
124
-
125
- export type GetWorkflowRunsResponse = WorkflowRuns;
126
-
127
- export type GetWorkflowRunByIdResponse = WorkflowRun;
128
-
129
- export type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
130
-
131
- export type LegacyWorkflowRunResult = {
132
- activePaths: Record<string, { status: string; suspendPayload?: any; stepPath: string[] }>;
133
- results: CoreLegacyWorkflowRunResult<any, any, any>['results'];
134
- timestamp: number;
135
- runId: string;
136
- };
137
-
138
- export interface GetWorkflowResponse {
139
- name: string;
140
- description?: string;
141
- steps: {
142
- [key: string]: {
143
- id: string;
144
- description: string;
145
- inputSchema: string;
146
- outputSchema: string;
147
- resumeSchema: string;
148
- suspendSchema: string;
149
- };
150
- };
151
- allSteps: {
152
- [key: string]: {
153
- id: string;
154
- description: string;
155
- inputSchema: string;
156
- outputSchema: string;
157
- resumeSchema: string;
158
- suspendSchema: string;
159
- isWorkflow: boolean;
160
- };
161
- };
162
- stepGraph: Workflow['serializedStepGraph'];
163
- inputSchema: string;
164
- outputSchema: string;
165
- }
166
-
167
- export type WorkflowWatchResult = WatchEvent & { runId: string };
168
-
169
- export type WorkflowRunResult = WorkflowResult<any, any>;
170
- export interface UpsertVectorParams {
171
- indexName: string;
172
- vectors: number[][];
173
- metadata?: Record<string, any>[];
174
- ids?: string[];
175
- }
176
- export interface CreateIndexParams {
177
- indexName: string;
178
- dimension: number;
179
- metric?: 'cosine' | 'euclidean' | 'dotproduct';
180
- }
181
-
182
- export interface QueryVectorParams {
183
- indexName: string;
184
- queryVector: number[];
185
- topK?: number;
186
- filter?: Record<string, any>;
187
- includeVector?: boolean;
188
- }
189
-
190
- export interface QueryVectorResponse {
191
- results: QueryResult[];
192
- }
193
-
194
- export interface GetVectorIndexResponse {
195
- dimension: number;
196
- metric: 'cosine' | 'euclidean' | 'dotproduct';
197
- count: number;
198
- }
199
-
200
- export interface SaveMessageToMemoryParams {
201
- messages: (MastraMessageV1 | MastraMessageV2)[];
202
- agentId: string;
203
- }
204
-
205
- export interface SaveNetworkMessageToMemoryParams {
206
- messages: (MastraMessageV1 | MastraMessageV2)[];
207
- networkId: string;
208
- }
209
-
210
- export type SaveMessageToMemoryResponse = (MastraMessageV1 | MastraMessageV2)[];
211
-
212
- export interface CreateMemoryThreadParams {
213
- title?: string;
214
- metadata?: Record<string, any>;
215
- resourceId: string;
216
- threadId?: string;
217
- agentId: string;
218
- }
219
-
220
- export interface CreateNetworkMemoryThreadParams {
221
- title?: string;
222
- metadata?: Record<string, any>;
223
- resourceId: string;
224
- threadId?: string;
225
- networkId: string;
226
- }
227
-
228
- export type CreateMemoryThreadResponse = StorageThreadType;
229
-
230
- export interface GetMemoryThreadParams {
231
- resourceId: string;
232
- agentId: string;
233
- }
234
-
235
- export interface GetNetworkMemoryThreadParams {
236
- resourceId: string;
237
- networkId: string;
238
- }
239
-
240
- export type GetMemoryThreadResponse = StorageThreadType[];
241
-
242
- export interface UpdateMemoryThreadParams {
243
- title: string;
244
- metadata: Record<string, any>;
245
- resourceId: string;
246
- }
247
-
248
- export interface GetMemoryThreadMessagesParams {
249
- /**
250
- * Limit the number of messages to retrieve (default: 40)
251
- */
252
- limit?: number;
253
- }
254
-
255
- export type GetMemoryThreadMessagesPaginatedParams = Omit<StorageGetMessagesArg, 'threadConfig' | 'threadId'>;
256
-
257
- export interface GetMemoryThreadMessagesResponse {
258
- messages: CoreMessage[];
259
- uiMessages: AiMessageType[];
260
- }
261
-
262
- export type GetMemoryThreadMessagesPaginatedResponse = PaginationInfo & {
263
- messages: MastraMessageV1[] | MastraMessageV2[];
264
- };
265
-
266
- export interface GetLogsParams {
267
- transportId: string;
268
- fromDate?: Date;
269
- toDate?: Date;
270
- logLevel?: LogLevel;
271
- filters?: Record<string, string>;
272
- page?: number;
273
- perPage?: number;
274
- }
275
-
276
- export interface GetLogParams {
277
- runId: string;
278
- transportId: string;
279
- fromDate?: Date;
280
- toDate?: Date;
281
- logLevel?: LogLevel;
282
- filters?: Record<string, string>;
283
- page?: number;
284
- perPage?: number;
285
- }
286
-
287
- export type GetLogsResponse = {
288
- logs: BaseLogMessage[];
289
- total: number;
290
- page: number;
291
- perPage: number;
292
- hasMore: boolean;
293
- };
294
-
295
- export type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
296
-
297
- type SpanStatus = {
298
- code: number;
299
- };
300
-
301
- type SpanOther = {
302
- droppedAttributesCount: number;
303
- droppedEventsCount: number;
304
- droppedLinksCount: number;
305
- };
306
-
307
- type SpanEventAttributes = {
308
- key: string;
309
- value: { [key: string]: string | number | boolean | null };
310
- };
311
-
312
- type SpanEvent = {
313
- attributes: SpanEventAttributes[];
314
- name: string;
315
- timeUnixNano: string;
316
- droppedAttributesCount: number;
317
- };
318
-
319
- type Span = {
320
- id: string;
321
- parentSpanId: string | null;
322
- traceId: string;
323
- name: string;
324
- scope: string;
325
- kind: number;
326
- status: SpanStatus;
327
- events: SpanEvent[];
328
- links: any[];
329
- attributes: Record<string, string | number | boolean | null>;
330
- startTime: number;
331
- endTime: number;
332
- duration: number;
333
- other: SpanOther;
334
- createdAt: string;
335
- };
336
-
337
- export interface GetTelemetryResponse {
338
- traces: Span[];
339
- }
340
-
341
- export interface GetTelemetryParams {
342
- name?: string;
343
- scope?: string;
344
- page?: number;
345
- perPage?: number;
346
- attribute?: Record<string, string>;
347
- fromDate?: Date;
348
- toDate?: Date;
349
- }
350
-
351
- export interface GetNetworkResponse {
352
- id: string;
353
- name: string;
354
- instructions: string;
355
- agents: Array<{
356
- name: string;
357
- provider: string;
358
- modelId: string;
359
- }>;
360
- routingModel: {
361
- provider: string;
362
- modelId: string;
363
- };
364
- state?: Record<string, any>;
365
- }
366
-
367
- export interface GetVNextNetworkResponse {
368
- id: string;
369
- name: string;
370
- instructions: string;
371
- agents: Array<{
372
- name: string;
373
- provider: string;
374
- modelId: string;
375
- }>;
376
- routingModel: {
377
- provider: string;
378
- modelId: string;
379
- };
380
- workflows: Array<{
381
- name: string;
382
- description: string;
383
- inputSchema: string | undefined;
384
- outputSchema: string | undefined;
385
- }>;
386
- tools: Array<{
387
- id: string;
388
- description: string;
389
- }>;
390
- }
391
-
392
- export interface GenerateVNextNetworkResponse {
393
- task: string;
394
- result: string;
395
- resourceId: string;
396
- resourceType: 'none' | 'tool' | 'agent' | 'workflow';
397
- }
398
-
399
- export interface GenerateOrStreamVNextNetworkParams {
400
- message: string;
401
- threadId?: string;
402
- resourceId?: string;
403
- runtimeContext?: RuntimeContext | Record<string, any>;
404
- }
405
-
406
- export interface LoopStreamVNextNetworkParams {
407
- message: string;
408
- threadId?: string;
409
- resourceId?: string;
410
- maxIterations?: number;
411
- runtimeContext?: RuntimeContext | Record<string, any>;
412
- }
413
-
414
- export interface LoopVNextNetworkResponse {
415
- status: 'success';
416
- result: {
417
- task: string;
418
- resourceId: string;
419
- resourceType: 'agent' | 'workflow' | 'none' | 'tool';
420
- result: string;
421
- iteration: number;
422
- isOneOff: boolean;
423
- prompt: string;
424
- threadId?: string | undefined;
425
- threadResourceId?: string | undefined;
426
- isComplete?: boolean | undefined;
427
- completionReason?: string | undefined;
428
- };
429
- steps: WorkflowResult<any, any>['steps'];
430
- }
431
-
432
- export interface McpServerListResponse {
433
- servers: ServerInfo[];
434
- next: string | null;
435
- total_count: number;
436
- }
437
-
438
- export interface McpToolInfo {
439
- id: string;
440
- name: string;
441
- description?: string;
442
- inputSchema: string;
443
- toolType?: MCPToolType;
444
- }
445
-
446
- export interface McpServerToolListResponse {
447
- tools: McpToolInfo[];
448
- }
449
-
450
- export type ClientScoreRowData = Omit<ScoreRowData, 'createdAt' | 'updatedAt'> & {
451
- createdAt: string;
452
- updatedAt: string;
453
- };
454
-
455
- // Scores-related types
456
- export interface GetScoresByRunIdParams {
457
- runId: string;
458
- page?: number;
459
- perPage?: number;
460
- }
461
-
462
- export interface GetScoresByScorerIdParams {
463
- scorerId: string;
464
- entityId?: string;
465
- entityType?: string;
466
- page?: number;
467
- perPage?: number;
468
- }
469
-
470
- export interface GetScoresByEntityIdParams {
471
- entityId: string;
472
- entityType: string;
473
- page?: number;
474
- perPage?: number;
475
- }
476
-
477
- export interface SaveScoreParams {
478
- score: Omit<ScoreRowData, 'id' | 'createdAt' | 'updatedAt'>;
479
- }
480
-
481
- export interface GetScoresResponse {
482
- pagination: {
483
- total: number;
484
- page: number;
485
- perPage: number;
486
- hasMore: boolean;
487
- };
488
- scores: ClientScoreRowData[];
489
- }
490
-
491
- export interface SaveScoreResponse {
492
- score: ClientScoreRowData;
493
- }
494
-
495
- export type GetScorerResponse = MastraScorerEntry & {
496
- agentIds: string[];
497
- workflowIds: string[];
498
- };
499
-
500
- export interface GetScorersResponse {
501
- scorers: Array<GetScorerResponse>;
502
- }
@@ -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 { isVercelTool } from '@mastra/core/tools/is-vercel-tool';
2
- import { zodToJsonSchema } from './zod-to-json-schema';
3
- import type { ToolsInput } from '@mastra/core/agent';
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
- }
@@ -1,10 +0,0 @@
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
- }