@mastra/client-js 0.0.0-tsconfig-compile-20250703214351 → 0.0.0-unified-sidebar-20251010130811

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 (78) hide show
  1. package/CHANGELOG.md +1400 -2
  2. package/LICENSE.md +11 -42
  3. package/README.md +6 -7
  4. package/dist/client.d.ts +278 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/example.d.ts +2 -0
  7. package/dist/example.d.ts.map +1 -0
  8. package/dist/index.cjs +1761 -674
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.ts +5 -1164
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +1759 -674
  13. package/dist/index.js.map +1 -0
  14. package/dist/resources/a2a.d.ts +41 -0
  15. package/dist/resources/a2a.d.ts.map +1 -0
  16. package/dist/resources/agent-builder.d.ts +160 -0
  17. package/dist/resources/agent-builder.d.ts.map +1 -0
  18. package/dist/resources/agent.d.ts +184 -0
  19. package/dist/resources/agent.d.ts.map +1 -0
  20. package/dist/resources/base.d.ts +13 -0
  21. package/dist/resources/base.d.ts.map +1 -0
  22. package/dist/resources/index.d.ts +11 -0
  23. package/dist/resources/index.d.ts.map +1 -0
  24. package/dist/resources/mcp-tool.d.ts +28 -0
  25. package/dist/resources/mcp-tool.d.ts.map +1 -0
  26. package/dist/resources/memory-thread.d.ts +53 -0
  27. package/dist/resources/memory-thread.d.ts.map +1 -0
  28. package/dist/resources/network-memory-thread.d.ts +47 -0
  29. package/dist/resources/network-memory-thread.d.ts.map +1 -0
  30. package/dist/resources/observability.d.ts +35 -0
  31. package/dist/resources/observability.d.ts.map +1 -0
  32. package/dist/resources/tool.d.ts +24 -0
  33. package/dist/resources/tool.d.ts.map +1 -0
  34. package/dist/resources/vector.d.ts +51 -0
  35. package/dist/resources/vector.d.ts.map +1 -0
  36. package/dist/resources/workflow.d.ts +269 -0
  37. package/dist/resources/workflow.d.ts.map +1 -0
  38. package/dist/tools.d.ts +22 -0
  39. package/dist/tools.d.ts.map +1 -0
  40. package/dist/types.d.ts +479 -0
  41. package/dist/types.d.ts.map +1 -0
  42. package/dist/utils/index.d.ts +5 -0
  43. package/dist/utils/index.d.ts.map +1 -0
  44. package/dist/utils/process-client-tools.d.ts +3 -0
  45. package/dist/utils/process-client-tools.d.ts.map +1 -0
  46. package/dist/utils/process-mastra-stream.d.ts +11 -0
  47. package/dist/utils/process-mastra-stream.d.ts.map +1 -0
  48. package/dist/utils/zod-to-json-schema.d.ts +3 -0
  49. package/dist/utils/zod-to-json-schema.d.ts.map +1 -0
  50. package/package.json +27 -15
  51. package/.turbo/turbo-build.log +0 -19
  52. package/dist/index.d.cts +0 -1164
  53. package/eslint.config.js +0 -6
  54. package/src/adapters/agui.test.ts +0 -180
  55. package/src/adapters/agui.ts +0 -239
  56. package/src/client.ts +0 -480
  57. package/src/example.ts +0 -67
  58. package/src/index.test.ts +0 -830
  59. package/src/index.ts +0 -2
  60. package/src/resources/a2a.ts +0 -88
  61. package/src/resources/agent.ts +0 -763
  62. package/src/resources/base.ts +0 -71
  63. package/src/resources/index.ts +0 -10
  64. package/src/resources/legacy-workflow.ts +0 -242
  65. package/src/resources/mcp-tool.ts +0 -48
  66. package/src/resources/memory-thread.ts +0 -63
  67. package/src/resources/network-memory-thread.ts +0 -63
  68. package/src/resources/network.ts +0 -85
  69. package/src/resources/tool.ts +0 -45
  70. package/src/resources/vNextNetwork.ts +0 -177
  71. package/src/resources/vector.ts +0 -83
  72. package/src/resources/workflow.ts +0 -396
  73. package/src/types.ts +0 -422
  74. package/src/utils/index.ts +0 -11
  75. package/src/utils/process-client-tools.ts +0 -32
  76. package/src/utils/zod-to-json-schema.ts +0 -10
  77. package/tsconfig.json +0 -5
  78. package/vitest.config.js +0 -8
package/dist/index.d.ts CHANGED
@@ -1,1164 +1,5 @@
1
- import { AbstractAgent } from '@ag-ui/client';
2
- import { ServerInfo, MCPToolType, ServerDetailInfo } from '@mastra/core/mcp';
3
- import { processDataStream } from '@ai-sdk/ui-utils';
4
- import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn } from '@mastra/core';
5
- import { JSONSchema7 } from 'json-schema';
6
- import { ZodSchema } from 'zod';
7
- import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
8
- import { LogLevel, BaseLogMessage } from '@mastra/core/logger';
9
- import { RuntimeContext } from '@mastra/core/runtime-context';
10
- import { Workflow as Workflow$1, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
11
- import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
12
- import * as stream_web from 'stream/web';
13
- import { AgentCard, TaskSendParams, Task, TaskQueryParams, TaskIdParams } from '@mastra/core/a2a';
14
-
15
- interface ClientOptions {
16
- /** Base URL for API requests */
17
- baseUrl: string;
18
- /** Number of retry attempts for failed requests */
19
- retries?: number;
20
- /** Initial backoff time in milliseconds between retries */
21
- backoffMs?: number;
22
- /** Maximum backoff time in milliseconds between retries */
23
- maxBackoffMs?: number;
24
- /** Custom headers to include with requests */
25
- headers?: Record<string, string>;
26
- }
27
- interface RequestOptions {
28
- method?: string;
29
- headers?: Record<string, string>;
30
- body?: any;
31
- stream?: boolean;
32
- signal?: AbortSignal;
33
- }
34
- type WithoutMethods<T> = {
35
- [K in keyof T as T[K] extends (...args: any[]) => any ? never : T[K] extends {
36
- (): any;
37
- } ? never : T[K] extends undefined | ((...args: any[]) => any) ? never : K]: T[K];
38
- };
39
- interface GetAgentResponse {
40
- name: string;
41
- instructions: string;
42
- tools: Record<string, GetToolResponse>;
43
- workflows: Record<string, GetWorkflowResponse>;
44
- provider: string;
45
- modelId: string;
46
- defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
47
- defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
48
- }
49
- type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
50
- messages: string | string[] | CoreMessage[] | AiMessageType[];
51
- output?: T;
52
- experimental_output?: T;
53
- runtimeContext?: RuntimeContext | Record<string, any>;
54
- clientTools?: ToolsInput;
55
- } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
56
- type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
57
- messages: string | string[] | CoreMessage[] | AiMessageType[];
58
- output?: T;
59
- experimental_output?: T;
60
- runtimeContext?: RuntimeContext | Record<string, any>;
61
- clientTools?: ToolsInput;
62
- } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
63
- interface GetEvalsByAgentIdResponse extends GetAgentResponse {
64
- evals: any[];
65
- instructions: string;
66
- name: string;
67
- id: string;
68
- }
69
- interface GetToolResponse {
70
- id: string;
71
- description: string;
72
- inputSchema: string;
73
- outputSchema: string;
74
- }
75
- interface GetLegacyWorkflowResponse {
76
- name: string;
77
- triggerSchema: string;
78
- steps: Record<string, StepAction<any, any, any, any>>;
79
- stepGraph: StepGraph;
80
- stepSubscriberGraph: Record<string, StepGraph>;
81
- workflowId?: string;
82
- }
83
- interface GetWorkflowRunsParams {
84
- fromDate?: Date;
85
- toDate?: Date;
86
- limit?: number;
87
- offset?: number;
88
- resourceId?: string;
89
- }
90
- type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
91
- type GetWorkflowRunsResponse = WorkflowRuns;
92
- type GetWorkflowRunByIdResponse = WorkflowRun;
93
- type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
94
- type LegacyWorkflowRunResult = {
95
- activePaths: Record<string, {
96
- status: string;
97
- suspendPayload?: any;
98
- stepPath: string[];
99
- }>;
100
- results: LegacyWorkflowRunResult$1<any, any, any>['results'];
101
- timestamp: number;
102
- runId: string;
103
- };
104
- interface GetWorkflowResponse {
105
- name: string;
106
- description?: string;
107
- steps: {
108
- [key: string]: {
109
- id: string;
110
- description: string;
111
- inputSchema: string;
112
- outputSchema: string;
113
- resumeSchema: string;
114
- suspendSchema: string;
115
- };
116
- };
117
- allSteps: {
118
- [key: string]: {
119
- id: string;
120
- description: string;
121
- inputSchema: string;
122
- outputSchema: string;
123
- resumeSchema: string;
124
- suspendSchema: string;
125
- isWorkflow: boolean;
126
- };
127
- };
128
- stepGraph: Workflow$1['serializedStepGraph'];
129
- inputSchema: string;
130
- outputSchema: string;
131
- }
132
- type WorkflowWatchResult = WatchEvent & {
133
- runId: string;
134
- };
135
- type WorkflowRunResult = WorkflowResult<any, any>;
136
- interface UpsertVectorParams {
137
- indexName: string;
138
- vectors: number[][];
139
- metadata?: Record<string, any>[];
140
- ids?: string[];
141
- }
142
- interface CreateIndexParams {
143
- indexName: string;
144
- dimension: number;
145
- metric?: 'cosine' | 'euclidean' | 'dotproduct';
146
- }
147
- interface QueryVectorParams {
148
- indexName: string;
149
- queryVector: number[];
150
- topK?: number;
151
- filter?: Record<string, any>;
152
- includeVector?: boolean;
153
- }
154
- interface QueryVectorResponse {
155
- results: QueryResult[];
156
- }
157
- interface GetVectorIndexResponse {
158
- dimension: number;
159
- metric: 'cosine' | 'euclidean' | 'dotproduct';
160
- count: number;
161
- }
162
- interface SaveMessageToMemoryParams {
163
- messages: MastraMessageV1[];
164
- agentId: string;
165
- }
166
- interface SaveNetworkMessageToMemoryParams {
167
- messages: MastraMessageV1[];
168
- networkId: string;
169
- }
170
- type SaveMessageToMemoryResponse = MastraMessageV1[];
171
- interface CreateMemoryThreadParams {
172
- title?: string;
173
- metadata?: Record<string, any>;
174
- resourceId: string;
175
- threadId?: string;
176
- agentId: string;
177
- }
178
- interface CreateNetworkMemoryThreadParams {
179
- title?: string;
180
- metadata?: Record<string, any>;
181
- resourceId: string;
182
- threadId?: string;
183
- networkId: string;
184
- }
185
- type CreateMemoryThreadResponse = StorageThreadType;
186
- interface GetMemoryThreadParams {
187
- resourceId: string;
188
- agentId: string;
189
- }
190
- interface GetNetworkMemoryThreadParams {
191
- resourceId: string;
192
- networkId: string;
193
- }
194
- type GetMemoryThreadResponse = StorageThreadType[];
195
- interface UpdateMemoryThreadParams {
196
- title: string;
197
- metadata: Record<string, any>;
198
- resourceId: string;
199
- }
200
- interface GetMemoryThreadMessagesParams {
201
- /**
202
- * Limit the number of messages to retrieve (default: 40)
203
- */
204
- limit?: number;
205
- }
206
- interface GetMemoryThreadMessagesResponse {
207
- messages: CoreMessage[];
208
- uiMessages: AiMessageType[];
209
- }
210
- interface GetLogsParams {
211
- transportId: string;
212
- fromDate?: Date;
213
- toDate?: Date;
214
- logLevel?: LogLevel;
215
- filters?: Record<string, string>;
216
- page?: number;
217
- perPage?: number;
218
- }
219
- interface GetLogParams {
220
- runId: string;
221
- transportId: string;
222
- fromDate?: Date;
223
- toDate?: Date;
224
- logLevel?: LogLevel;
225
- filters?: Record<string, string>;
226
- page?: number;
227
- perPage?: number;
228
- }
229
- type GetLogsResponse = {
230
- logs: BaseLogMessage[];
231
- total: number;
232
- page: number;
233
- perPage: number;
234
- hasMore: boolean;
235
- };
236
- type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
237
- type SpanStatus = {
238
- code: number;
239
- };
240
- type SpanOther = {
241
- droppedAttributesCount: number;
242
- droppedEventsCount: number;
243
- droppedLinksCount: number;
244
- };
245
- type SpanEventAttributes = {
246
- key: string;
247
- value: {
248
- [key: string]: string | number | boolean | null;
249
- };
250
- };
251
- type SpanEvent = {
252
- attributes: SpanEventAttributes[];
253
- name: string;
254
- timeUnixNano: string;
255
- droppedAttributesCount: number;
256
- };
257
- type Span = {
258
- id: string;
259
- parentSpanId: string | null;
260
- traceId: string;
261
- name: string;
262
- scope: string;
263
- kind: number;
264
- status: SpanStatus;
265
- events: SpanEvent[];
266
- links: any[];
267
- attributes: Record<string, string | number | boolean | null>;
268
- startTime: number;
269
- endTime: number;
270
- duration: number;
271
- other: SpanOther;
272
- createdAt: string;
273
- };
274
- interface GetTelemetryResponse {
275
- traces: Span[];
276
- }
277
- interface GetTelemetryParams {
278
- name?: string;
279
- scope?: string;
280
- page?: number;
281
- perPage?: number;
282
- attribute?: Record<string, string>;
283
- fromDate?: Date;
284
- toDate?: Date;
285
- }
286
- interface GetNetworkResponse {
287
- id: string;
288
- name: string;
289
- instructions: string;
290
- agents: Array<{
291
- name: string;
292
- provider: string;
293
- modelId: string;
294
- }>;
295
- routingModel: {
296
- provider: string;
297
- modelId: string;
298
- };
299
- state?: Record<string, any>;
300
- }
301
- interface GetVNextNetworkResponse {
302
- id: string;
303
- name: string;
304
- instructions: string;
305
- agents: Array<{
306
- name: string;
307
- provider: string;
308
- modelId: string;
309
- }>;
310
- routingModel: {
311
- provider: string;
312
- modelId: string;
313
- };
314
- workflows: Array<{
315
- name: string;
316
- description: string;
317
- inputSchema: string | undefined;
318
- outputSchema: string | undefined;
319
- }>;
320
- tools: Array<{
321
- id: string;
322
- description: string;
323
- }>;
324
- }
325
- interface GenerateVNextNetworkResponse {
326
- task: string;
327
- result: string;
328
- resourceId: string;
329
- resourceType: 'none' | 'tool' | 'agent' | 'workflow';
330
- }
331
- interface GenerateOrStreamVNextNetworkParams {
332
- message: string;
333
- threadId?: string;
334
- resourceId?: string;
335
- }
336
- interface LoopStreamVNextNetworkParams {
337
- message: string;
338
- threadId?: string;
339
- resourceId?: string;
340
- maxIterations?: number;
341
- }
342
- interface LoopVNextNetworkResponse {
343
- status: 'success';
344
- result: {
345
- text: string;
346
- };
347
- steps: WorkflowResult<any, any>['steps'];
348
- }
349
- interface McpServerListResponse {
350
- servers: ServerInfo[];
351
- next: string | null;
352
- total_count: number;
353
- }
354
- interface McpToolInfo {
355
- id: string;
356
- name: string;
357
- description?: string;
358
- inputSchema: string;
359
- toolType?: MCPToolType;
360
- }
361
- interface McpServerToolListResponse {
362
- tools: McpToolInfo[];
363
- }
364
-
365
- declare class BaseResource {
366
- readonly options: ClientOptions;
367
- constructor(options: ClientOptions);
368
- /**
369
- * Makes an HTTP request to the API with retries and exponential backoff
370
- * @param path - The API endpoint path
371
- * @param options - Optional request configuration
372
- * @returns Promise containing the response data
373
- */
374
- request<T>(path: string, options?: RequestOptions): Promise<T>;
375
- }
376
-
377
- declare class AgentVoice extends BaseResource {
378
- private agentId;
379
- constructor(options: ClientOptions, agentId: string);
380
- /**
381
- * Convert text to speech using the agent's voice provider
382
- * @param text - Text to convert to speech
383
- * @param options - Optional provider-specific options for speech generation
384
- * @returns Promise containing the audio data
385
- */
386
- speak(text: string, options?: {
387
- speaker?: string;
388
- [key: string]: any;
389
- }): Promise<Response>;
390
- /**
391
- * Convert speech to text using the agent's voice provider
392
- * @param audio - Audio data to transcribe
393
- * @param options - Optional provider-specific options
394
- * @returns Promise containing the transcribed text
395
- */
396
- listen(audio: Blob, options?: Record<string, any>): Promise<{
397
- text: string;
398
- }>;
399
- /**
400
- * Get available speakers for the agent's voice provider
401
- * @returns Promise containing list of available speakers
402
- */
403
- getSpeakers(): Promise<Array<{
404
- voiceId: string;
405
- [key: string]: any;
406
- }>>;
407
- /**
408
- * Get the listener configuration for the agent's voice provider
409
- * @returns Promise containing a check if the agent has listening capabilities
410
- */
411
- getListener(): Promise<{
412
- enabled: boolean;
413
- }>;
414
- }
415
- declare class Agent extends BaseResource {
416
- private agentId;
417
- readonly voice: AgentVoice;
418
- constructor(options: ClientOptions, agentId: string);
419
- /**
420
- * Retrieves details about the agent
421
- * @returns Promise containing agent details including model and instructions
422
- */
423
- details(): Promise<GetAgentResponse>;
424
- /**
425
- * Generates a response from the agent
426
- * @param params - Generation parameters including prompt
427
- * @returns Promise containing the generated response
428
- */
429
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
430
- output?: never;
431
- experimental_output?: never;
432
- }): Promise<GenerateReturn<T>>;
433
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
434
- output: T;
435
- experimental_output?: never;
436
- }): Promise<GenerateReturn<T>>;
437
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
438
- output?: never;
439
- experimental_output: T;
440
- }): Promise<GenerateReturn<T>>;
441
- private processChatResponse;
442
- /**
443
- * Streams a response from the agent
444
- * @param params - Stream parameters including prompt
445
- * @returns Promise containing the enhanced Response object with processDataStream method
446
- */
447
- stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
448
- processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
449
- }>;
450
- /**
451
- * Processes the stream response and handles tool calls
452
- */
453
- private processStreamResponse;
454
- /**
455
- * Gets details about a specific tool available to the agent
456
- * @param toolId - ID of the tool to retrieve
457
- * @returns Promise containing tool details
458
- */
459
- getTool(toolId: string): Promise<GetToolResponse>;
460
- /**
461
- * Executes a tool for the agent
462
- * @param toolId - ID of the tool to execute
463
- * @param params - Parameters required for tool execution
464
- * @returns Promise containing the tool execution results
465
- */
466
- executeTool(toolId: string, params: {
467
- data: any;
468
- runtimeContext?: RuntimeContext;
469
- }): Promise<any>;
470
- /**
471
- * Retrieves evaluation results for the agent
472
- * @returns Promise containing agent evaluations
473
- */
474
- evals(): Promise<GetEvalsByAgentIdResponse>;
475
- /**
476
- * Retrieves live evaluation results for the agent
477
- * @returns Promise containing live agent evaluations
478
- */
479
- liveEvals(): Promise<GetEvalsByAgentIdResponse>;
480
- }
481
-
482
- declare class Network extends BaseResource {
483
- private networkId;
484
- constructor(options: ClientOptions, networkId: string);
485
- /**
486
- * Retrieves details about the network
487
- * @returns Promise containing network details
488
- */
489
- details(): Promise<GetNetworkResponse>;
490
- /**
491
- * Generates a response from the agent
492
- * @param params - Generation parameters including prompt
493
- * @returns Promise containing the generated response
494
- */
495
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
496
- /**
497
- * Streams a response from the agent
498
- * @param params - Stream parameters including prompt
499
- * @returns Promise containing the enhanced Response object with processDataStream method
500
- */
501
- stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
502
- processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
503
- }>;
504
- }
505
-
506
- declare class MemoryThread extends BaseResource {
507
- private threadId;
508
- private agentId;
509
- constructor(options: ClientOptions, threadId: string, agentId: string);
510
- /**
511
- * Retrieves the memory thread details
512
- * @returns Promise containing thread details including title and metadata
513
- */
514
- get(): Promise<StorageThreadType>;
515
- /**
516
- * Updates the memory thread properties
517
- * @param params - Update parameters including title and metadata
518
- * @returns Promise containing updated thread details
519
- */
520
- update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
521
- /**
522
- * Deletes the memory thread
523
- * @returns Promise containing deletion result
524
- */
525
- delete(): Promise<{
526
- result: string;
527
- }>;
528
- /**
529
- * Retrieves messages associated with the thread
530
- * @param params - Optional parameters including limit for number of messages to retrieve
531
- * @returns Promise containing thread messages and UI messages
532
- */
533
- getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
534
- }
535
-
536
- declare class Vector extends BaseResource {
537
- private vectorName;
538
- constructor(options: ClientOptions, vectorName: string);
539
- /**
540
- * Retrieves details about a specific vector index
541
- * @param indexName - Name of the index to get details for
542
- * @returns Promise containing vector index details
543
- */
544
- details(indexName: string): Promise<GetVectorIndexResponse>;
545
- /**
546
- * Deletes a vector index
547
- * @param indexName - Name of the index to delete
548
- * @returns Promise indicating deletion success
549
- */
550
- delete(indexName: string): Promise<{
551
- success: boolean;
552
- }>;
553
- /**
554
- * Retrieves a list of all available indexes
555
- * @returns Promise containing array of index names
556
- */
557
- getIndexes(): Promise<{
558
- indexes: string[];
559
- }>;
560
- /**
561
- * Creates a new vector index
562
- * @param params - Parameters for index creation including dimension and metric
563
- * @returns Promise indicating creation success
564
- */
565
- createIndex(params: CreateIndexParams): Promise<{
566
- success: boolean;
567
- }>;
568
- /**
569
- * Upserts vectors into an index
570
- * @param params - Parameters containing vectors, metadata, and optional IDs
571
- * @returns Promise containing array of vector IDs
572
- */
573
- upsert(params: UpsertVectorParams): Promise<string[]>;
574
- /**
575
- * Queries vectors in an index
576
- * @param params - Query parameters including query vector and search options
577
- * @returns Promise containing query results
578
- */
579
- query(params: QueryVectorParams): Promise<QueryVectorResponse>;
580
- }
581
-
582
- declare class LegacyWorkflow extends BaseResource {
583
- private workflowId;
584
- constructor(options: ClientOptions, workflowId: string);
585
- /**
586
- * Retrieves details about the legacy workflow
587
- * @returns Promise containing legacy workflow details including steps and graphs
588
- */
589
- details(): Promise<GetLegacyWorkflowResponse>;
590
- /**
591
- * Retrieves all runs for a legacy workflow
592
- * @param params - Parameters for filtering runs
593
- * @returns Promise containing legacy workflow runs array
594
- */
595
- runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
596
- /**
597
- * Creates a new legacy workflow run
598
- * @returns Promise containing the generated run ID
599
- */
600
- createRun(params?: {
601
- runId?: string;
602
- }): Promise<{
603
- runId: string;
604
- }>;
605
- /**
606
- * Starts a legacy workflow run synchronously without waiting for the workflow to complete
607
- * @param params - Object containing the runId and triggerData
608
- * @returns Promise containing success message
609
- */
610
- start(params: {
611
- runId: string;
612
- triggerData: Record<string, any>;
613
- }): Promise<{
614
- message: string;
615
- }>;
616
- /**
617
- * Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
618
- * @param stepId - ID of the step to resume
619
- * @param runId - ID of the legacy workflow run
620
- * @param context - Context to resume the legacy workflow with
621
- * @returns Promise containing the legacy workflow resume results
622
- */
623
- resume({ stepId, runId, context, }: {
624
- stepId: string;
625
- runId: string;
626
- context: Record<string, any>;
627
- }): Promise<{
628
- message: string;
629
- }>;
630
- /**
631
- * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
632
- * @param params - Object containing the optional runId and triggerData
633
- * @returns Promise containing the workflow execution results
634
- */
635
- startAsync(params: {
636
- runId?: string;
637
- triggerData: Record<string, any>;
638
- }): Promise<LegacyWorkflowRunResult>;
639
- /**
640
- * Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
641
- * @param params - Object containing the runId, stepId, and context
642
- * @returns Promise containing the workflow resume results
643
- */
644
- resumeAsync(params: {
645
- runId: string;
646
- stepId: string;
647
- context: Record<string, any>;
648
- }): Promise<LegacyWorkflowRunResult>;
649
- /**
650
- * Creates an async generator that processes a readable stream and yields records
651
- * separated by the Record Separator character (\x1E)
652
- *
653
- * @param stream - The readable stream to process
654
- * @returns An async generator that yields parsed records
655
- */
656
- private streamProcessor;
657
- /**
658
- * Watches legacy workflow transitions in real-time
659
- * @param runId - Optional run ID to filter the watch stream
660
- * @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
661
- */
662
- watch({ runId }: {
663
- runId?: string;
664
- }, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
665
- }
666
-
667
- declare class Tool extends BaseResource {
668
- private toolId;
669
- constructor(options: ClientOptions, toolId: string);
670
- /**
671
- * Retrieves details about the tool
672
- * @returns Promise containing tool details including description and schemas
673
- */
674
- details(): Promise<GetToolResponse>;
675
- /**
676
- * Executes the tool with the provided parameters
677
- * @param params - Parameters required for tool execution
678
- * @returns Promise containing the tool execution results
679
- */
680
- execute(params: {
681
- data: any;
682
- runId?: string;
683
- runtimeContext?: RuntimeContext | Record<string, any>;
684
- }): Promise<any>;
685
- }
686
-
687
- declare class Workflow extends BaseResource {
688
- private workflowId;
689
- constructor(options: ClientOptions, workflowId: string);
690
- /**
691
- * Creates an async generator that processes a readable stream and yields workflow records
692
- * separated by the Record Separator character (\x1E)
693
- *
694
- * @param stream - The readable stream to process
695
- * @returns An async generator that yields parsed records
696
- */
697
- private streamProcessor;
698
- /**
699
- * Retrieves details about the workflow
700
- * @returns Promise containing workflow details including steps and graphs
701
- */
702
- details(): Promise<GetWorkflowResponse>;
703
- /**
704
- * Retrieves all runs for a workflow
705
- * @param params - Parameters for filtering runs
706
- * @returns Promise containing workflow runs array
707
- */
708
- runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
709
- /**
710
- * Retrieves a specific workflow run by its ID
711
- * @param runId - The ID of the workflow run to retrieve
712
- * @returns Promise containing the workflow run details
713
- */
714
- runById(runId: string): Promise<GetWorkflowRunByIdResponse>;
715
- /**
716
- * Retrieves the execution result for a specific workflow run by its ID
717
- * @param runId - The ID of the workflow run to retrieve the execution result for
718
- * @returns Promise containing the workflow run execution result
719
- */
720
- runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse>;
721
- /**
722
- * Cancels a specific workflow run by its ID
723
- * @param runId - The ID of the workflow run to cancel
724
- * @returns Promise containing a success message
725
- */
726
- cancelRun(runId: string): Promise<{
727
- message: string;
728
- }>;
729
- /**
730
- * Sends an event to a specific workflow run by its ID
731
- * @param params - Object containing the runId, event and data
732
- * @returns Promise containing a success message
733
- */
734
- sendRunEvent(params: {
735
- runId: string;
736
- event: string;
737
- data: unknown;
738
- }): Promise<{
739
- message: string;
740
- }>;
741
- /**
742
- * Creates a new workflow run
743
- * @param params - Optional object containing the optional runId
744
- * @returns Promise containing the runId of the created run
745
- */
746
- createRun(params?: {
747
- runId?: string;
748
- }): Promise<{
749
- runId: string;
750
- }>;
751
- /**
752
- * Starts a workflow run synchronously without waiting for the workflow to complete
753
- * @param params - Object containing the runId, inputData and runtimeContext
754
- * @returns Promise containing success message
755
- */
756
- start(params: {
757
- runId: string;
758
- inputData: Record<string, any>;
759
- runtimeContext?: RuntimeContext | Record<string, any>;
760
- }): Promise<{
761
- message: string;
762
- }>;
763
- /**
764
- * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
765
- * @param params - Object containing the runId, step, resumeData and runtimeContext
766
- * @returns Promise containing success message
767
- */
768
- resume({ step, runId, resumeData, ...rest }: {
769
- step: string | string[];
770
- runId: string;
771
- resumeData?: Record<string, any>;
772
- runtimeContext?: RuntimeContext | Record<string, any>;
773
- }): Promise<{
774
- message: string;
775
- }>;
776
- /**
777
- * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
778
- * @param params - Object containing the optional runId, inputData and runtimeContext
779
- * @returns Promise containing the workflow execution results
780
- */
781
- startAsync(params: {
782
- runId?: string;
783
- inputData: Record<string, any>;
784
- runtimeContext?: RuntimeContext | Record<string, any>;
785
- }): Promise<WorkflowRunResult>;
786
- /**
787
- * Starts a workflow run and returns a stream
788
- * @param params - Object containing the optional runId, inputData and runtimeContext
789
- * @returns Promise containing the workflow execution results
790
- */
791
- stream(params: {
792
- runId?: string;
793
- inputData: Record<string, any>;
794
- runtimeContext?: RuntimeContext;
795
- }): Promise<stream_web.ReadableStream<{
796
- type: string;
797
- payload: any;
798
- }>>;
799
- /**
800
- * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
801
- * @param params - Object containing the runId, step, resumeData and runtimeContext
802
- * @returns Promise containing the workflow resume results
803
- */
804
- resumeAsync(params: {
805
- runId: string;
806
- step: string | string[];
807
- resumeData?: Record<string, any>;
808
- runtimeContext?: RuntimeContext | Record<string, any>;
809
- }): Promise<WorkflowRunResult>;
810
- /**
811
- * Watches workflow transitions in real-time
812
- * @param runId - Optional run ID to filter the watch stream
813
- * @returns AsyncGenerator that yields parsed records from the workflow watch stream
814
- */
815
- watch({ runId }: {
816
- runId?: string;
817
- }, onRecord: (record: WorkflowWatchResult) => void): Promise<void>;
818
- /**
819
- * Creates a new ReadableStream from an iterable or async iterable of objects,
820
- * serializing each as JSON and separating them with the record separator (\x1E).
821
- *
822
- * @param records - An iterable or async iterable of objects to stream
823
- * @returns A ReadableStream emitting the records as JSON strings separated by the record separator
824
- */
825
- static createRecordStream(records: Iterable<any> | AsyncIterable<any>): ReadableStream;
826
- }
827
-
828
- /**
829
- * Class for interacting with an agent via the A2A protocol
830
- */
831
- declare class A2A extends BaseResource {
832
- private agentId;
833
- constructor(options: ClientOptions, agentId: string);
834
- /**
835
- * Get the agent card with metadata about the agent
836
- * @returns Promise containing the agent card information
837
- */
838
- getCard(): Promise<AgentCard>;
839
- /**
840
- * Send a message to the agent and get a response
841
- * @param params - Parameters for the task
842
- * @returns Promise containing the task response
843
- */
844
- sendMessage(params: TaskSendParams): Promise<{
845
- task: Task;
846
- }>;
847
- /**
848
- * Get the status and result of a task
849
- * @param params - Parameters for querying the task
850
- * @returns Promise containing the task response
851
- */
852
- getTask(params: TaskQueryParams): Promise<Task>;
853
- /**
854
- * Cancel a running task
855
- * @param params - Parameters identifying the task to cancel
856
- * @returns Promise containing the task response
857
- */
858
- cancelTask(params: TaskIdParams): Promise<{
859
- task: Task;
860
- }>;
861
- /**
862
- * Send a message and subscribe to streaming updates (not fully implemented)
863
- * @param params - Parameters for the task
864
- * @returns Promise containing the task response
865
- */
866
- sendAndSubscribe(params: TaskSendParams): Promise<Response>;
867
- }
868
-
869
- /**
870
- * Represents a specific tool available on a specific MCP server.
871
- * Provides methods to get details and execute the tool.
872
- */
873
- declare class MCPTool extends BaseResource {
874
- private serverId;
875
- private toolId;
876
- constructor(options: ClientOptions, serverId: string, toolId: string);
877
- /**
878
- * Retrieves details about this specific tool from the MCP server.
879
- * @returns Promise containing the tool's information (name, description, schema).
880
- */
881
- details(): Promise<McpToolInfo>;
882
- /**
883
- * Executes this specific tool on the MCP server.
884
- * @param params - Parameters for tool execution, including data/args and optional runtimeContext.
885
- * @returns Promise containing the result of the tool execution.
886
- */
887
- execute(params: {
888
- data?: any;
889
- runtimeContext?: RuntimeContext;
890
- }): Promise<any>;
891
- }
892
-
893
- declare class VNextNetwork extends BaseResource {
894
- private networkId;
895
- constructor(options: ClientOptions, networkId: string);
896
- /**
897
- * Retrieves details about the network
898
- * @returns Promise containing vNext network details
899
- */
900
- details(): Promise<GetVNextNetworkResponse>;
901
- /**
902
- * Generates a response from the v-next network
903
- * @param params - Generation parameters including message
904
- * @returns Promise containing the generated response
905
- */
906
- generate(params: GenerateOrStreamVNextNetworkParams): Promise<GenerateVNextNetworkResponse>;
907
- /**
908
- * Generates a response from the v-next network using multiple primitives
909
- * @param params - Generation parameters including message
910
- * @returns Promise containing the generated response
911
- */
912
- loop(params: {
913
- message: string;
914
- }): Promise<LoopVNextNetworkResponse>;
915
- private streamProcessor;
916
- /**
917
- * Streams a response from the v-next network
918
- * @param params - Stream parameters including message
919
- * @returns Promise containing the results
920
- */
921
- stream(params: GenerateOrStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
922
- /**
923
- * Streams a response from the v-next network loop
924
- * @param params - Stream parameters including message
925
- * @returns Promise containing the results
926
- */
927
- loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
928
- }
929
-
930
- declare class NetworkMemoryThread extends BaseResource {
931
- private threadId;
932
- private networkId;
933
- constructor(options: ClientOptions, threadId: string, networkId: string);
934
- /**
935
- * Retrieves the memory thread details
936
- * @returns Promise containing thread details including title and metadata
937
- */
938
- get(): Promise<StorageThreadType>;
939
- /**
940
- * Updates the memory thread properties
941
- * @param params - Update parameters including title and metadata
942
- * @returns Promise containing updated thread details
943
- */
944
- update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
945
- /**
946
- * Deletes the memory thread
947
- * @returns Promise containing deletion result
948
- */
949
- delete(): Promise<{
950
- result: string;
951
- }>;
952
- /**
953
- * Retrieves messages associated with the thread
954
- * @param params - Optional parameters including limit for number of messages to retrieve
955
- * @returns Promise containing thread messages and UI messages
956
- */
957
- getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
958
- }
959
-
960
- declare class MastraClient extends BaseResource {
961
- constructor(options: ClientOptions);
962
- /**
963
- * Retrieves all available agents
964
- * @returns Promise containing map of agent IDs to agent details
965
- */
966
- getAgents(): Promise<Record<string, GetAgentResponse>>;
967
- getAGUI({ resourceId }: {
968
- resourceId: string;
969
- }): Promise<Record<string, AbstractAgent>>;
970
- /**
971
- * Gets an agent instance by ID
972
- * @param agentId - ID of the agent to retrieve
973
- * @returns Agent instance
974
- */
975
- getAgent(agentId: string): Agent;
976
- /**
977
- * Retrieves memory threads for a resource
978
- * @param params - Parameters containing the resource ID
979
- * @returns Promise containing array of memory threads
980
- */
981
- getMemoryThreads(params: GetMemoryThreadParams): Promise<GetMemoryThreadResponse>;
982
- /**
983
- * Creates a new memory thread
984
- * @param params - Parameters for creating the memory thread
985
- * @returns Promise containing the created memory thread
986
- */
987
- createMemoryThread(params: CreateMemoryThreadParams): Promise<CreateMemoryThreadResponse>;
988
- /**
989
- * Gets a memory thread instance by ID
990
- * @param threadId - ID of the memory thread to retrieve
991
- * @returns MemoryThread instance
992
- */
993
- getMemoryThread(threadId: string, agentId: string): MemoryThread;
994
- /**
995
- * Saves messages to memory
996
- * @param params - Parameters containing messages to save
997
- * @returns Promise containing the saved messages
998
- */
999
- saveMessageToMemory(params: SaveMessageToMemoryParams): Promise<SaveMessageToMemoryResponse>;
1000
- /**
1001
- * Gets the status of the memory system
1002
- * @returns Promise containing memory system status
1003
- */
1004
- getMemoryStatus(agentId: string): Promise<{
1005
- result: boolean;
1006
- }>;
1007
- /**
1008
- * Retrieves memory threads for a resource
1009
- * @param params - Parameters containing the resource ID
1010
- * @returns Promise containing array of memory threads
1011
- */
1012
- getNetworkMemoryThreads(params: GetNetworkMemoryThreadParams): Promise<GetMemoryThreadResponse>;
1013
- /**
1014
- * Creates a new memory thread
1015
- * @param params - Parameters for creating the memory thread
1016
- * @returns Promise containing the created memory thread
1017
- */
1018
- createNetworkMemoryThread(params: CreateNetworkMemoryThreadParams): Promise<CreateMemoryThreadResponse>;
1019
- /**
1020
- * Gets a memory thread instance by ID
1021
- * @param threadId - ID of the memory thread to retrieve
1022
- * @returns MemoryThread instance
1023
- */
1024
- getNetworkMemoryThread(threadId: string, networkId: string): NetworkMemoryThread;
1025
- /**
1026
- * Saves messages to memory
1027
- * @param params - Parameters containing messages to save
1028
- * @returns Promise containing the saved messages
1029
- */
1030
- saveNetworkMessageToMemory(params: SaveNetworkMessageToMemoryParams): Promise<SaveMessageToMemoryResponse>;
1031
- /**
1032
- * Gets the status of the memory system
1033
- * @returns Promise containing memory system status
1034
- */
1035
- getNetworkMemoryStatus(networkId: string): Promise<{
1036
- result: boolean;
1037
- }>;
1038
- /**
1039
- * Retrieves all available tools
1040
- * @returns Promise containing map of tool IDs to tool details
1041
- */
1042
- getTools(): Promise<Record<string, GetToolResponse>>;
1043
- /**
1044
- * Gets a tool instance by ID
1045
- * @param toolId - ID of the tool to retrieve
1046
- * @returns Tool instance
1047
- */
1048
- getTool(toolId: string): Tool;
1049
- /**
1050
- * Retrieves all available legacy workflows
1051
- * @returns Promise containing map of legacy workflow IDs to legacy workflow details
1052
- */
1053
- getLegacyWorkflows(): Promise<Record<string, GetLegacyWorkflowResponse>>;
1054
- /**
1055
- * Gets a legacy workflow instance by ID
1056
- * @param workflowId - ID of the legacy workflow to retrieve
1057
- * @returns Legacy Workflow instance
1058
- */
1059
- getLegacyWorkflow(workflowId: string): LegacyWorkflow;
1060
- /**
1061
- * Retrieves all available workflows
1062
- * @returns Promise containing map of workflow IDs to workflow details
1063
- */
1064
- getWorkflows(): Promise<Record<string, GetWorkflowResponse>>;
1065
- /**
1066
- * Gets a workflow instance by ID
1067
- * @param workflowId - ID of the workflow to retrieve
1068
- * @returns Workflow instance
1069
- */
1070
- getWorkflow(workflowId: string): Workflow;
1071
- /**
1072
- * Gets a vector instance by name
1073
- * @param vectorName - Name of the vector to retrieve
1074
- * @returns Vector instance
1075
- */
1076
- getVector(vectorName: string): Vector;
1077
- /**
1078
- * Retrieves logs
1079
- * @param params - Parameters for filtering logs
1080
- * @returns Promise containing array of log messages
1081
- */
1082
- getLogs(params: GetLogsParams): Promise<GetLogsResponse>;
1083
- /**
1084
- * Gets logs for a specific run
1085
- * @param params - Parameters containing run ID to retrieve
1086
- * @returns Promise containing array of log messages
1087
- */
1088
- getLogForRun(params: GetLogParams): Promise<GetLogsResponse>;
1089
- /**
1090
- * List of all log transports
1091
- * @returns Promise containing list of log transports
1092
- */
1093
- getLogTransports(): Promise<{
1094
- transports: string[];
1095
- }>;
1096
- /**
1097
- * List of all traces (paged)
1098
- * @param params - Parameters for filtering traces
1099
- * @returns Promise containing telemetry data
1100
- */
1101
- getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse>;
1102
- /**
1103
- * Retrieves all available networks
1104
- * @returns Promise containing map of network IDs to network details
1105
- */
1106
- getNetworks(): Promise<Array<GetNetworkResponse>>;
1107
- /**
1108
- * Retrieves all available vNext networks
1109
- * @returns Promise containing map of vNext network IDs to vNext network details
1110
- */
1111
- getVNextNetworks(): Promise<Array<GetVNextNetworkResponse>>;
1112
- /**
1113
- * Gets a network instance by ID
1114
- * @param networkId - ID of the network to retrieve
1115
- * @returns Network instance
1116
- */
1117
- getNetwork(networkId: string): Network;
1118
- /**
1119
- * Gets a vNext network instance by ID
1120
- * @param networkId - ID of the vNext network to retrieve
1121
- * @returns vNext Network instance
1122
- */
1123
- getVNextNetwork(networkId: string): VNextNetwork;
1124
- /**
1125
- * Retrieves a list of available MCP servers.
1126
- * @param params - Optional parameters for pagination (limit, offset).
1127
- * @returns Promise containing the list of MCP servers and pagination info.
1128
- */
1129
- getMcpServers(params?: {
1130
- limit?: number;
1131
- offset?: number;
1132
- }): Promise<McpServerListResponse>;
1133
- /**
1134
- * Retrieves detailed information for a specific MCP server.
1135
- * @param serverId - The ID of the MCP server to retrieve.
1136
- * @param params - Optional parameters, e.g., specific version.
1137
- * @returns Promise containing the detailed MCP server information.
1138
- */
1139
- getMcpServerDetails(serverId: string, params?: {
1140
- version?: string;
1141
- }): Promise<ServerDetailInfo>;
1142
- /**
1143
- * Retrieves a list of tools for a specific MCP server.
1144
- * @param serverId - The ID of the MCP server.
1145
- * @returns Promise containing the list of tools.
1146
- */
1147
- getMcpServerTools(serverId: string): Promise<McpServerToolListResponse>;
1148
- /**
1149
- * Gets an MCPTool resource instance for a specific tool on an MCP server.
1150
- * This instance can then be used to fetch details or execute the tool.
1151
- * @param serverId - The ID of the MCP server.
1152
- * @param toolId - The ID of the tool.
1153
- * @returns MCPTool instance.
1154
- */
1155
- getMcpServerTool(serverId: string, toolId: string): MCPTool;
1156
- /**
1157
- * Gets an A2A client for interacting with an agent via the A2A protocol
1158
- * @param agentId - ID of the agent to interact with
1159
- * @returns A2A client instance
1160
- */
1161
- getA2A(agentId: string): A2A;
1162
- }
1163
-
1164
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type CreateNetworkMemoryThreadParams, type GenerateOrStreamVNextNetworkParams, type GenerateParams, type GenerateVNextNetworkResponse, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkMemoryThreadParams, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextNetworkResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunByIdResponse, type GetWorkflowRunExecutionResultResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, type LoopStreamVNextNetworkParams, type LoopVNextNetworkResponse, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type SaveNetworkMessageToMemoryParams, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
1
+ export * from './client.js';
2
+ export * from './types.js';
3
+ export * from './tools.js';
4
+ export type { UIMessageWithMetadata } from '@mastra/core/agent';
5
+ //# sourceMappingURL=index.d.ts.map