@mastra/client-js 0.0.0-inject-middleware-20250528222017 → 0.0.0-issue-7498-20250905233741

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 +1370 -2
  2. package/LICENSE.md +11 -42
  3. package/README.md +7 -4
  4. package/dist/client.d.ts +280 -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 +2062 -286
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.ts +4 -900
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +2064 -288
  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 +161 -0
  17. package/dist/resources/agent-builder.d.ts.map +1 -0
  18. package/dist/resources/agent.d.ts +155 -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 +13 -0
  23. package/dist/resources/index.d.ts.map +1 -0
  24. package/dist/resources/legacy-workflow.d.ts +87 -0
  25. package/dist/resources/legacy-workflow.d.ts.map +1 -0
  26. package/dist/resources/mcp-tool.d.ts +27 -0
  27. package/dist/resources/mcp-tool.d.ts.map +1 -0
  28. package/dist/resources/memory-thread.d.ts +53 -0
  29. package/dist/resources/memory-thread.d.ts.map +1 -0
  30. package/dist/resources/network-memory-thread.d.ts +47 -0
  31. package/dist/resources/network-memory-thread.d.ts.map +1 -0
  32. package/dist/resources/network.d.ts +30 -0
  33. package/dist/resources/network.d.ts.map +1 -0
  34. package/dist/resources/observability.d.ts +19 -0
  35. package/dist/resources/observability.d.ts.map +1 -0
  36. package/dist/resources/tool.d.ts +23 -0
  37. package/dist/resources/tool.d.ts.map +1 -0
  38. package/dist/resources/vNextNetwork.d.ts +42 -0
  39. package/dist/resources/vNextNetwork.d.ts.map +1 -0
  40. package/dist/resources/vector.d.ts +48 -0
  41. package/dist/resources/vector.d.ts.map +1 -0
  42. package/dist/resources/workflow.d.ts +154 -0
  43. package/dist/resources/workflow.d.ts.map +1 -0
  44. package/dist/types.d.ts +461 -0
  45. package/dist/types.d.ts.map +1 -0
  46. package/dist/utils/index.d.ts +3 -0
  47. package/dist/utils/index.d.ts.map +1 -0
  48. package/dist/utils/process-client-tools.d.ts +3 -0
  49. package/dist/utils/process-client-tools.d.ts.map +1 -0
  50. package/dist/utils/process-mastra-stream.d.ts +7 -0
  51. package/dist/utils/process-mastra-stream.d.ts.map +1 -0
  52. package/dist/utils/zod-to-json-schema.d.ts +3 -0
  53. package/dist/utils/zod-to-json-schema.d.ts.map +1 -0
  54. package/package.json +38 -21
  55. package/dist/index.d.cts +0 -900
  56. package/eslint.config.js +0 -6
  57. package/src/adapters/agui.test.ts +0 -180
  58. package/src/adapters/agui.ts +0 -239
  59. package/src/client.ts +0 -334
  60. package/src/example.ts +0 -64
  61. package/src/index.test.ts +0 -830
  62. package/src/index.ts +0 -2
  63. package/src/resources/a2a.ts +0 -88
  64. package/src/resources/agent.ts +0 -197
  65. package/src/resources/base.ts +0 -70
  66. package/src/resources/index.ts +0 -10
  67. package/src/resources/legacy-workflow.ts +0 -242
  68. package/src/resources/mcp-tool.ts +0 -48
  69. package/src/resources/memory-thread.ts +0 -63
  70. package/src/resources/network.ts +0 -86
  71. package/src/resources/tool.ts +0 -45
  72. package/src/resources/vector.ts +0 -83
  73. package/src/resources/workflow.ts +0 -353
  74. package/src/types.ts +0 -314
  75. package/src/utils/index.ts +0 -11
  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,900 +1,4 @@
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, MessageType, LegacyWorkflowRuns, WorkflowRuns, QueryResult, GenerateReturn } from '@mastra/core';
5
- import { JSONSchema7 } from 'json-schema';
6
- import { ZodSchema } from 'zod';
7
- import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
8
- import { BaseLogMessage } from '@mastra/core/logger';
9
- import { RuntimeContext } from '@mastra/core/runtime-context';
10
- import { Workflow as Workflow$1, WorkflowResult, WatchEvent } 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
- } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
55
- type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
56
- messages: string | string[] | CoreMessage[] | AiMessageType[];
57
- output?: T;
58
- experimental_output?: T;
59
- runtimeContext?: RuntimeContext | Record<string, any>;
60
- } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
61
- interface GetEvalsByAgentIdResponse extends GetAgentResponse {
62
- evals: any[];
63
- instructions: string;
64
- name: string;
65
- id: string;
66
- }
67
- interface GetToolResponse {
68
- id: string;
69
- description: string;
70
- inputSchema: string;
71
- outputSchema: string;
72
- }
73
- interface GetLegacyWorkflowResponse {
74
- name: string;
75
- triggerSchema: string;
76
- steps: Record<string, StepAction<any, any, any, any>>;
77
- stepGraph: StepGraph;
78
- stepSubscriberGraph: Record<string, StepGraph>;
79
- workflowId?: string;
80
- }
81
- interface GetWorkflowRunsParams {
82
- fromDate?: Date;
83
- toDate?: Date;
84
- limit?: number;
85
- offset?: number;
86
- resourceId?: string;
87
- }
88
- type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
89
- type GetWorkflowRunsResponse = WorkflowRuns;
90
- type LegacyWorkflowRunResult = {
91
- activePaths: Record<string, {
92
- status: string;
93
- suspendPayload?: any;
94
- stepPath: string[];
95
- }>;
96
- results: LegacyWorkflowRunResult$1<any, any, any>['results'];
97
- timestamp: number;
98
- runId: string;
99
- };
100
- interface GetWorkflowResponse {
101
- name: string;
102
- description?: string;
103
- steps: {
104
- [key: string]: {
105
- id: string;
106
- description: string;
107
- inputSchema: string;
108
- outputSchema: string;
109
- resumeSchema: string;
110
- suspendSchema: string;
111
- };
112
- };
113
- stepGraph: Workflow$1['serializedStepGraph'];
114
- inputSchema: string;
115
- outputSchema: string;
116
- }
117
- type WorkflowWatchResult = WatchEvent & {
118
- runId: string;
119
- };
120
- type WorkflowRunResult = WorkflowResult<any, any>;
121
- interface UpsertVectorParams {
122
- indexName: string;
123
- vectors: number[][];
124
- metadata?: Record<string, any>[];
125
- ids?: string[];
126
- }
127
- interface CreateIndexParams {
128
- indexName: string;
129
- dimension: number;
130
- metric?: 'cosine' | 'euclidean' | 'dotproduct';
131
- }
132
- interface QueryVectorParams {
133
- indexName: string;
134
- queryVector: number[];
135
- topK?: number;
136
- filter?: Record<string, any>;
137
- includeVector?: boolean;
138
- }
139
- interface QueryVectorResponse {
140
- results: QueryResult[];
141
- }
142
- interface GetVectorIndexResponse {
143
- dimension: number;
144
- metric: 'cosine' | 'euclidean' | 'dotproduct';
145
- count: number;
146
- }
147
- interface SaveMessageToMemoryParams {
148
- messages: MessageType[];
149
- agentId: string;
150
- }
151
- type SaveMessageToMemoryResponse = MessageType[];
152
- interface CreateMemoryThreadParams {
153
- title?: string;
154
- metadata?: Record<string, any>;
155
- resourceId: string;
156
- threadId?: string;
157
- agentId: string;
158
- }
159
- type CreateMemoryThreadResponse = StorageThreadType;
160
- interface GetMemoryThreadParams {
161
- resourceId: string;
162
- agentId: string;
163
- }
164
- type GetMemoryThreadResponse = StorageThreadType[];
165
- interface UpdateMemoryThreadParams {
166
- title: string;
167
- metadata: Record<string, any>;
168
- resourceId: string;
169
- }
170
- interface GetMemoryThreadMessagesParams {
171
- /**
172
- * Limit the number of messages to retrieve (default: 40)
173
- */
174
- limit?: number;
175
- }
176
- interface GetMemoryThreadMessagesResponse {
177
- messages: CoreMessage[];
178
- uiMessages: AiMessageType[];
179
- }
180
- interface GetLogsParams {
181
- transportId: string;
182
- }
183
- interface GetLogParams {
184
- runId: string;
185
- transportId: string;
186
- }
187
- type GetLogsResponse = BaseLogMessage[];
188
- type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
189
- type SpanStatus = {
190
- code: number;
191
- };
192
- type SpanOther = {
193
- droppedAttributesCount: number;
194
- droppedEventsCount: number;
195
- droppedLinksCount: number;
196
- };
197
- type SpanEventAttributes = {
198
- key: string;
199
- value: {
200
- [key: string]: string | number | boolean | null;
201
- };
202
- };
203
- type SpanEvent = {
204
- attributes: SpanEventAttributes[];
205
- name: string;
206
- timeUnixNano: string;
207
- droppedAttributesCount: number;
208
- };
209
- type Span = {
210
- id: string;
211
- parentSpanId: string | null;
212
- traceId: string;
213
- name: string;
214
- scope: string;
215
- kind: number;
216
- status: SpanStatus;
217
- events: SpanEvent[];
218
- links: any[];
219
- attributes: Record<string, string | number | boolean | null>;
220
- startTime: number;
221
- endTime: number;
222
- duration: number;
223
- other: SpanOther;
224
- createdAt: string;
225
- };
226
- interface GetTelemetryResponse {
227
- traces: Span[];
228
- }
229
- interface GetTelemetryParams {
230
- name?: string;
231
- scope?: string;
232
- page?: number;
233
- perPage?: number;
234
- attribute?: Record<string, string>;
235
- fromDate?: Date;
236
- toDate?: Date;
237
- }
238
- interface GetNetworkResponse {
239
- name: string;
240
- instructions: string;
241
- agents: Array<{
242
- name: string;
243
- provider: string;
244
- modelId: string;
245
- }>;
246
- routingModel: {
247
- provider: string;
248
- modelId: string;
249
- };
250
- state?: Record<string, any>;
251
- }
252
- interface McpServerListResponse {
253
- servers: ServerInfo[];
254
- next: string | null;
255
- total_count: number;
256
- }
257
- interface McpToolInfo {
258
- id: string;
259
- name: string;
260
- description?: string;
261
- inputSchema: string;
262
- toolType?: MCPToolType;
263
- }
264
- interface McpServerToolListResponse {
265
- tools: McpToolInfo[];
266
- }
267
-
268
- declare class BaseResource {
269
- readonly options: ClientOptions;
270
- constructor(options: ClientOptions);
271
- /**
272
- * Makes an HTTP request to the API with retries and exponential backoff
273
- * @param path - The API endpoint path
274
- * @param options - Optional request configuration
275
- * @returns Promise containing the response data
276
- */
277
- request<T>(path: string, options?: RequestOptions): Promise<T>;
278
- }
279
-
280
- declare class AgentVoice extends BaseResource {
281
- private agentId;
282
- constructor(options: ClientOptions, agentId: string);
283
- /**
284
- * Convert text to speech using the agent's voice provider
285
- * @param text - Text to convert to speech
286
- * @param options - Optional provider-specific options for speech generation
287
- * @returns Promise containing the audio data
288
- */
289
- speak(text: string, options?: {
290
- speaker?: string;
291
- [key: string]: any;
292
- }): Promise<Response>;
293
- /**
294
- * Convert speech to text using the agent's voice provider
295
- * @param audio - Audio data to transcribe
296
- * @param options - Optional provider-specific options
297
- * @returns Promise containing the transcribed text
298
- */
299
- listen(audio: Blob, options?: Record<string, any>): Promise<{
300
- text: string;
301
- }>;
302
- /**
303
- * Get available speakers for the agent's voice provider
304
- * @returns Promise containing list of available speakers
305
- */
306
- getSpeakers(): Promise<Array<{
307
- voiceId: string;
308
- [key: string]: any;
309
- }>>;
310
- }
311
- declare class Agent extends BaseResource {
312
- private agentId;
313
- readonly voice: AgentVoice;
314
- constructor(options: ClientOptions, agentId: string);
315
- /**
316
- * Retrieves details about the agent
317
- * @returns Promise containing agent details including model and instructions
318
- */
319
- details(): Promise<GetAgentResponse>;
320
- /**
321
- * Generates a response from the agent
322
- * @param params - Generation parameters including prompt
323
- * @returns Promise containing the generated response
324
- */
325
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
326
- /**
327
- * Streams a response from the agent
328
- * @param params - Stream parameters including prompt
329
- * @returns Promise containing the enhanced Response object with processDataStream method
330
- */
331
- stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
332
- processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
333
- }>;
334
- /**
335
- * Gets details about a specific tool available to the agent
336
- * @param toolId - ID of the tool to retrieve
337
- * @returns Promise containing tool details
338
- */
339
- getTool(toolId: string): Promise<GetToolResponse>;
340
- /**
341
- * Executes a tool for the agent
342
- * @param toolId - ID of the tool to execute
343
- * @param params - Parameters required for tool execution
344
- * @returns Promise containing the tool execution results
345
- */
346
- executeTool(toolId: string, params: {
347
- data: any;
348
- runtimeContext?: RuntimeContext;
349
- }): Promise<any>;
350
- /**
351
- * Retrieves evaluation results for the agent
352
- * @returns Promise containing agent evaluations
353
- */
354
- evals(): Promise<GetEvalsByAgentIdResponse>;
355
- /**
356
- * Retrieves live evaluation results for the agent
357
- * @returns Promise containing live agent evaluations
358
- */
359
- liveEvals(): Promise<GetEvalsByAgentIdResponse>;
360
- }
361
-
362
- declare class Network extends BaseResource {
363
- private networkId;
364
- constructor(options: ClientOptions, networkId: string);
365
- /**
366
- * Retrieves details about the network
367
- * @returns Promise containing network details
368
- */
369
- details(): Promise<GetNetworkResponse>;
370
- /**
371
- * Generates a response from the agent
372
- * @param params - Generation parameters including prompt
373
- * @returns Promise containing the generated response
374
- */
375
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
376
- /**
377
- * Streams a response from the agent
378
- * @param params - Stream parameters including prompt
379
- * @returns Promise containing the enhanced Response object with processDataStream method
380
- */
381
- stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
382
- processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
383
- }>;
384
- }
385
-
386
- declare class MemoryThread extends BaseResource {
387
- private threadId;
388
- private agentId;
389
- constructor(options: ClientOptions, threadId: string, agentId: string);
390
- /**
391
- * Retrieves the memory thread details
392
- * @returns Promise containing thread details including title and metadata
393
- */
394
- get(): Promise<StorageThreadType>;
395
- /**
396
- * Updates the memory thread properties
397
- * @param params - Update parameters including title and metadata
398
- * @returns Promise containing updated thread details
399
- */
400
- update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
401
- /**
402
- * Deletes the memory thread
403
- * @returns Promise containing deletion result
404
- */
405
- delete(): Promise<{
406
- result: string;
407
- }>;
408
- /**
409
- * Retrieves messages associated with the thread
410
- * @param params - Optional parameters including limit for number of messages to retrieve
411
- * @returns Promise containing thread messages and UI messages
412
- */
413
- getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
414
- }
415
-
416
- declare class Vector extends BaseResource {
417
- private vectorName;
418
- constructor(options: ClientOptions, vectorName: string);
419
- /**
420
- * Retrieves details about a specific vector index
421
- * @param indexName - Name of the index to get details for
422
- * @returns Promise containing vector index details
423
- */
424
- details(indexName: string): Promise<GetVectorIndexResponse>;
425
- /**
426
- * Deletes a vector index
427
- * @param indexName - Name of the index to delete
428
- * @returns Promise indicating deletion success
429
- */
430
- delete(indexName: string): Promise<{
431
- success: boolean;
432
- }>;
433
- /**
434
- * Retrieves a list of all available indexes
435
- * @returns Promise containing array of index names
436
- */
437
- getIndexes(): Promise<{
438
- indexes: string[];
439
- }>;
440
- /**
441
- * Creates a new vector index
442
- * @param params - Parameters for index creation including dimension and metric
443
- * @returns Promise indicating creation success
444
- */
445
- createIndex(params: CreateIndexParams): Promise<{
446
- success: boolean;
447
- }>;
448
- /**
449
- * Upserts vectors into an index
450
- * @param params - Parameters containing vectors, metadata, and optional IDs
451
- * @returns Promise containing array of vector IDs
452
- */
453
- upsert(params: UpsertVectorParams): Promise<string[]>;
454
- /**
455
- * Queries vectors in an index
456
- * @param params - Query parameters including query vector and search options
457
- * @returns Promise containing query results
458
- */
459
- query(params: QueryVectorParams): Promise<QueryVectorResponse>;
460
- }
461
-
462
- declare class LegacyWorkflow extends BaseResource {
463
- private workflowId;
464
- constructor(options: ClientOptions, workflowId: string);
465
- /**
466
- * Retrieves details about the legacy workflow
467
- * @returns Promise containing legacy workflow details including steps and graphs
468
- */
469
- details(): Promise<GetLegacyWorkflowResponse>;
470
- /**
471
- * Retrieves all runs for a legacy workflow
472
- * @param params - Parameters for filtering runs
473
- * @returns Promise containing legacy workflow runs array
474
- */
475
- runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
476
- /**
477
- * Creates a new legacy workflow run
478
- * @returns Promise containing the generated run ID
479
- */
480
- createRun(params?: {
481
- runId?: string;
482
- }): Promise<{
483
- runId: string;
484
- }>;
485
- /**
486
- * Starts a legacy workflow run synchronously without waiting for the workflow to complete
487
- * @param params - Object containing the runId and triggerData
488
- * @returns Promise containing success message
489
- */
490
- start(params: {
491
- runId: string;
492
- triggerData: Record<string, any>;
493
- }): Promise<{
494
- message: string;
495
- }>;
496
- /**
497
- * Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
498
- * @param stepId - ID of the step to resume
499
- * @param runId - ID of the legacy workflow run
500
- * @param context - Context to resume the legacy workflow with
501
- * @returns Promise containing the legacy workflow resume results
502
- */
503
- resume({ stepId, runId, context, }: {
504
- stepId: string;
505
- runId: string;
506
- context: Record<string, any>;
507
- }): Promise<{
508
- message: string;
509
- }>;
510
- /**
511
- * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
512
- * @param params - Object containing the optional runId and triggerData
513
- * @returns Promise containing the workflow execution results
514
- */
515
- startAsync(params: {
516
- runId?: string;
517
- triggerData: Record<string, any>;
518
- }): Promise<LegacyWorkflowRunResult>;
519
- /**
520
- * Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
521
- * @param params - Object containing the runId, stepId, and context
522
- * @returns Promise containing the workflow resume results
523
- */
524
- resumeAsync(params: {
525
- runId: string;
526
- stepId: string;
527
- context: Record<string, any>;
528
- }): Promise<LegacyWorkflowRunResult>;
529
- /**
530
- * Creates an async generator that processes a readable stream and yields records
531
- * separated by the Record Separator character (\x1E)
532
- *
533
- * @param stream - The readable stream to process
534
- * @returns An async generator that yields parsed records
535
- */
536
- private streamProcessor;
537
- /**
538
- * Watches legacy workflow transitions in real-time
539
- * @param runId - Optional run ID to filter the watch stream
540
- * @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
541
- */
542
- watch({ runId }: {
543
- runId?: string;
544
- }, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
545
- }
546
-
547
- declare class Tool extends BaseResource {
548
- private toolId;
549
- constructor(options: ClientOptions, toolId: string);
550
- /**
551
- * Retrieves details about the tool
552
- * @returns Promise containing tool details including description and schemas
553
- */
554
- details(): Promise<GetToolResponse>;
555
- /**
556
- * Executes the tool with the provided parameters
557
- * @param params - Parameters required for tool execution
558
- * @returns Promise containing the tool execution results
559
- */
560
- execute(params: {
561
- data: any;
562
- runId?: string;
563
- runtimeContext?: RuntimeContext | Record<string, any>;
564
- }): Promise<any>;
565
- }
566
-
567
- declare class Workflow extends BaseResource {
568
- private workflowId;
569
- constructor(options: ClientOptions, workflowId: string);
570
- /**
571
- * Creates an async generator that processes a readable stream and yields workflow records
572
- * separated by the Record Separator character (\x1E)
573
- *
574
- * @param stream - The readable stream to process
575
- * @returns An async generator that yields parsed records
576
- */
577
- private streamProcessor;
578
- /**
579
- * Retrieves details about the workflow
580
- * @returns Promise containing workflow details including steps and graphs
581
- */
582
- details(): Promise<GetWorkflowResponse>;
583
- /**
584
- * Retrieves all runs for a workflow
585
- * @param params - Parameters for filtering runs
586
- * @returns Promise containing workflow runs array
587
- */
588
- runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
589
- /**
590
- * Creates a new workflow run
591
- * @param params - Optional object containing the optional runId
592
- * @returns Promise containing the runId of the created run
593
- */
594
- createRun(params?: {
595
- runId?: string;
596
- }): Promise<{
597
- runId: string;
598
- }>;
599
- /**
600
- * Starts a workflow run synchronously without waiting for the workflow to complete
601
- * @param params - Object containing the runId, inputData and runtimeContext
602
- * @returns Promise containing success message
603
- */
604
- start(params: {
605
- runId: string;
606
- inputData: Record<string, any>;
607
- runtimeContext?: RuntimeContext | Record<string, any>;
608
- }): Promise<{
609
- message: string;
610
- }>;
611
- /**
612
- * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
613
- * @param params - Object containing the runId, step, resumeData and runtimeContext
614
- * @returns Promise containing success message
615
- */
616
- resume({ step, runId, resumeData, ...rest }: {
617
- step: string | string[];
618
- runId: string;
619
- resumeData?: Record<string, any>;
620
- runtimeContext?: RuntimeContext | Record<string, any>;
621
- }): Promise<{
622
- message: string;
623
- }>;
624
- /**
625
- * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
626
- * @param params - Object containing the optional runId, inputData and runtimeContext
627
- * @returns Promise containing the workflow execution results
628
- */
629
- startAsync(params: {
630
- runId?: string;
631
- inputData: Record<string, any>;
632
- runtimeContext?: RuntimeContext | Record<string, any>;
633
- }): Promise<WorkflowRunResult>;
634
- /**
635
- * Starts a vNext workflow run and returns a stream
636
- * @param params - Object containing the optional runId, inputData and runtimeContext
637
- * @returns Promise containing the vNext workflow execution results
638
- */
639
- stream(params: {
640
- runId?: string;
641
- inputData: Record<string, any>;
642
- runtimeContext?: RuntimeContext;
643
- }): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
644
- /**
645
- * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
646
- * @param params - Object containing the runId, step, resumeData and runtimeContext
647
- * @returns Promise containing the workflow resume results
648
- */
649
- resumeAsync(params: {
650
- runId: string;
651
- step: string | string[];
652
- resumeData?: Record<string, any>;
653
- runtimeContext?: RuntimeContext | Record<string, any>;
654
- }): Promise<WorkflowRunResult>;
655
- /**
656
- * Watches workflow transitions in real-time
657
- * @param runId - Optional run ID to filter the watch stream
658
- * @returns AsyncGenerator that yields parsed records from the workflow watch stream
659
- */
660
- watch({ runId }: {
661
- runId?: string;
662
- }, onRecord: (record: WorkflowWatchResult) => void): Promise<void>;
663
- /**
664
- * Creates a new ReadableStream from an iterable or async iterable of objects,
665
- * serializing each as JSON and separating them with the record separator (\x1E).
666
- *
667
- * @param records - An iterable or async iterable of objects to stream
668
- * @returns A ReadableStream emitting the records as JSON strings separated by the record separator
669
- */
670
- static createRecordStream(records: Iterable<any> | AsyncIterable<any>): ReadableStream;
671
- }
672
-
673
- /**
674
- * Class for interacting with an agent via the A2A protocol
675
- */
676
- declare class A2A extends BaseResource {
677
- private agentId;
678
- constructor(options: ClientOptions, agentId: string);
679
- /**
680
- * Get the agent card with metadata about the agent
681
- * @returns Promise containing the agent card information
682
- */
683
- getCard(): Promise<AgentCard>;
684
- /**
685
- * Send a message to the agent and get a response
686
- * @param params - Parameters for the task
687
- * @returns Promise containing the task response
688
- */
689
- sendMessage(params: TaskSendParams): Promise<{
690
- task: Task;
691
- }>;
692
- /**
693
- * Get the status and result of a task
694
- * @param params - Parameters for querying the task
695
- * @returns Promise containing the task response
696
- */
697
- getTask(params: TaskQueryParams): Promise<Task>;
698
- /**
699
- * Cancel a running task
700
- * @param params - Parameters identifying the task to cancel
701
- * @returns Promise containing the task response
702
- */
703
- cancelTask(params: TaskIdParams): Promise<{
704
- task: Task;
705
- }>;
706
- /**
707
- * Send a message and subscribe to streaming updates (not fully implemented)
708
- * @param params - Parameters for the task
709
- * @returns Promise containing the task response
710
- */
711
- sendAndSubscribe(params: TaskSendParams): Promise<Response>;
712
- }
713
-
714
- /**
715
- * Represents a specific tool available on a specific MCP server.
716
- * Provides methods to get details and execute the tool.
717
- */
718
- declare class MCPTool extends BaseResource {
719
- private serverId;
720
- private toolId;
721
- constructor(options: ClientOptions, serverId: string, toolId: string);
722
- /**
723
- * Retrieves details about this specific tool from the MCP server.
724
- * @returns Promise containing the tool's information (name, description, schema).
725
- */
726
- details(): Promise<McpToolInfo>;
727
- /**
728
- * Executes this specific tool on the MCP server.
729
- * @param params - Parameters for tool execution, including data/args and optional runtimeContext.
730
- * @returns Promise containing the result of the tool execution.
731
- */
732
- execute(params: {
733
- data?: any;
734
- runtimeContext?: RuntimeContext;
735
- }): Promise<any>;
736
- }
737
-
738
- declare class MastraClient extends BaseResource {
739
- constructor(options: ClientOptions);
740
- /**
741
- * Retrieves all available agents
742
- * @returns Promise containing map of agent IDs to agent details
743
- */
744
- getAgents(): Promise<Record<string, GetAgentResponse>>;
745
- getAGUI({ resourceId }: {
746
- resourceId: string;
747
- }): Promise<Record<string, AbstractAgent>>;
748
- /**
749
- * Gets an agent instance by ID
750
- * @param agentId - ID of the agent to retrieve
751
- * @returns Agent instance
752
- */
753
- getAgent(agentId: string): Agent;
754
- /**
755
- * Retrieves memory threads for a resource
756
- * @param params - Parameters containing the resource ID
757
- * @returns Promise containing array of memory threads
758
- */
759
- getMemoryThreads(params: GetMemoryThreadParams): Promise<GetMemoryThreadResponse>;
760
- /**
761
- * Creates a new memory thread
762
- * @param params - Parameters for creating the memory thread
763
- * @returns Promise containing the created memory thread
764
- */
765
- createMemoryThread(params: CreateMemoryThreadParams): Promise<CreateMemoryThreadResponse>;
766
- /**
767
- * Gets a memory thread instance by ID
768
- * @param threadId - ID of the memory thread to retrieve
769
- * @returns MemoryThread instance
770
- */
771
- getMemoryThread(threadId: string, agentId: string): MemoryThread;
772
- /**
773
- * Saves messages to memory
774
- * @param params - Parameters containing messages to save
775
- * @returns Promise containing the saved messages
776
- */
777
- saveMessageToMemory(params: SaveMessageToMemoryParams): Promise<SaveMessageToMemoryResponse>;
778
- /**
779
- * Gets the status of the memory system
780
- * @returns Promise containing memory system status
781
- */
782
- getMemoryStatus(agentId: string): Promise<{
783
- result: boolean;
784
- }>;
785
- /**
786
- * Retrieves all available tools
787
- * @returns Promise containing map of tool IDs to tool details
788
- */
789
- getTools(): Promise<Record<string, GetToolResponse>>;
790
- /**
791
- * Gets a tool instance by ID
792
- * @param toolId - ID of the tool to retrieve
793
- * @returns Tool instance
794
- */
795
- getTool(toolId: string): Tool;
796
- /**
797
- * Retrieves all available legacy workflows
798
- * @returns Promise containing map of legacy workflow IDs to legacy workflow details
799
- */
800
- getLegacyWorkflows(): Promise<Record<string, GetLegacyWorkflowResponse>>;
801
- /**
802
- * Gets a legacy workflow instance by ID
803
- * @param workflowId - ID of the legacy workflow to retrieve
804
- * @returns Legacy Workflow instance
805
- */
806
- getLegacyWorkflow(workflowId: string): LegacyWorkflow;
807
- /**
808
- * Retrieves all available workflows
809
- * @returns Promise containing map of workflow IDs to workflow details
810
- */
811
- getWorkflows(): Promise<Record<string, GetWorkflowResponse>>;
812
- /**
813
- * Gets a workflow instance by ID
814
- * @param workflowId - ID of the workflow to retrieve
815
- * @returns Workflow instance
816
- */
817
- getWorkflow(workflowId: string): Workflow;
818
- /**
819
- * Gets a vector instance by name
820
- * @param vectorName - Name of the vector to retrieve
821
- * @returns Vector instance
822
- */
823
- getVector(vectorName: string): Vector;
824
- /**
825
- * Retrieves logs
826
- * @param params - Parameters for filtering logs
827
- * @returns Promise containing array of log messages
828
- */
829
- getLogs(params: GetLogsParams): Promise<GetLogsResponse>;
830
- /**
831
- * Gets logs for a specific run
832
- * @param params - Parameters containing run ID to retrieve
833
- * @returns Promise containing array of log messages
834
- */
835
- getLogForRun(params: GetLogParams): Promise<GetLogsResponse>;
836
- /**
837
- * List of all log transports
838
- * @returns Promise containing list of log transports
839
- */
840
- getLogTransports(): Promise<{
841
- transports: string[];
842
- }>;
843
- /**
844
- * List of all traces (paged)
845
- * @param params - Parameters for filtering traces
846
- * @returns Promise containing telemetry data
847
- */
848
- getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse>;
849
- /**
850
- * Retrieves all available networks
851
- * @returns Promise containing map of network IDs to network details
852
- */
853
- getNetworks(): Promise<Record<string, GetNetworkResponse>>;
854
- /**
855
- * Gets a network instance by ID
856
- * @param networkId - ID of the network to retrieve
857
- * @returns Network instance
858
- */
859
- getNetwork(networkId: string): Network;
860
- /**
861
- * Retrieves a list of available MCP servers.
862
- * @param params - Optional parameters for pagination (limit, offset).
863
- * @returns Promise containing the list of MCP servers and pagination info.
864
- */
865
- getMcpServers(params?: {
866
- limit?: number;
867
- offset?: number;
868
- }): Promise<McpServerListResponse>;
869
- /**
870
- * Retrieves detailed information for a specific MCP server.
871
- * @param serverId - The ID of the MCP server to retrieve.
872
- * @param params - Optional parameters, e.g., specific version.
873
- * @returns Promise containing the detailed MCP server information.
874
- */
875
- getMcpServerDetails(serverId: string, params?: {
876
- version?: string;
877
- }): Promise<ServerDetailInfo>;
878
- /**
879
- * Retrieves a list of tools for a specific MCP server.
880
- * @param serverId - The ID of the MCP server.
881
- * @returns Promise containing the list of tools.
882
- */
883
- getMcpServerTools(serverId: string): Promise<McpServerToolListResponse>;
884
- /**
885
- * Gets an MCPTool resource instance for a specific tool on an MCP server.
886
- * This instance can then be used to fetch details or execute the tool.
887
- * @param serverId - The ID of the MCP server.
888
- * @param toolId - The ID of the tool.
889
- * @returns MCPTool instance.
890
- */
891
- getMcpServerTool(serverId: string, toolId: string): MCPTool;
892
- /**
893
- * Gets an A2A client for interacting with an agent via the A2A protocol
894
- * @param agentId - ID of the agent to interact with
895
- * @returns A2A client instance
896
- */
897
- getA2A(agentId: string): A2A;
898
- }
899
-
900
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
1
+ export * from './client.js';
2
+ export * from './types.js';
3
+ export type { UIMessageWithMetadata } from '@mastra/core/agent';
4
+ //# sourceMappingURL=index.d.ts.map