@mastra/client-js 0.0.0-working-memory-per-user-20250620161509 → 0.0.0-zod-v4-compat-part-2-20250820135355

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