@mastra/client-js 0.0.0-switch-to-core-20250424015131 → 0.0.0-tool-call-parts-20250630193309

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.
package/dist/index.js CHANGED
@@ -1,8 +1,229 @@
1
+ import { AbstractAgent, EventType } from '@ag-ui/client';
2
+ import { Observable } from 'rxjs';
3
+ import { processDataStream, parsePartialJson } from '@ai-sdk/ui-utils';
1
4
  import { ZodSchema } from 'zod';
2
- import { zodToJsonSchema } from 'zod-to-json-schema';
3
- import { processDataStream } from '@ai-sdk/ui-utils';
5
+ import originalZodToJsonSchema from 'zod-to-json-schema';
6
+ import { isVercelTool } from '@mastra/core/tools';
7
+ import { RuntimeContext } from '@mastra/core/runtime-context';
4
8
 
5
- // src/resources/agent.ts
9
+ // src/adapters/agui.ts
10
+ var AGUIAdapter = class extends AbstractAgent {
11
+ agent;
12
+ resourceId;
13
+ constructor({ agent, agentId, resourceId, ...rest }) {
14
+ super({
15
+ agentId,
16
+ ...rest
17
+ });
18
+ this.agent = agent;
19
+ this.resourceId = resourceId;
20
+ }
21
+ run(input) {
22
+ return new Observable((subscriber) => {
23
+ const convertedMessages = convertMessagesToMastraMessages(input.messages);
24
+ subscriber.next({
25
+ type: EventType.RUN_STARTED,
26
+ threadId: input.threadId,
27
+ runId: input.runId
28
+ });
29
+ this.agent.stream({
30
+ threadId: input.threadId,
31
+ resourceId: this.resourceId ?? "",
32
+ runId: input.runId,
33
+ messages: convertedMessages,
34
+ clientTools: input.tools.reduce(
35
+ (acc, tool) => {
36
+ acc[tool.name] = {
37
+ id: tool.name,
38
+ description: tool.description,
39
+ inputSchema: tool.parameters
40
+ };
41
+ return acc;
42
+ },
43
+ {}
44
+ )
45
+ }).then((response) => {
46
+ let currentMessageId = void 0;
47
+ let isInTextMessage = false;
48
+ return response.processDataStream({
49
+ onTextPart: (text) => {
50
+ if (currentMessageId === void 0) {
51
+ currentMessageId = generateUUID();
52
+ const message2 = {
53
+ type: EventType.TEXT_MESSAGE_START,
54
+ messageId: currentMessageId,
55
+ role: "assistant"
56
+ };
57
+ subscriber.next(message2);
58
+ isInTextMessage = true;
59
+ }
60
+ const message = {
61
+ type: EventType.TEXT_MESSAGE_CONTENT,
62
+ messageId: currentMessageId,
63
+ delta: text
64
+ };
65
+ subscriber.next(message);
66
+ },
67
+ onFinishMessagePart: () => {
68
+ if (currentMessageId !== void 0) {
69
+ const message = {
70
+ type: EventType.TEXT_MESSAGE_END,
71
+ messageId: currentMessageId
72
+ };
73
+ subscriber.next(message);
74
+ isInTextMessage = false;
75
+ }
76
+ subscriber.next({
77
+ type: EventType.RUN_FINISHED,
78
+ threadId: input.threadId,
79
+ runId: input.runId
80
+ });
81
+ subscriber.complete();
82
+ },
83
+ onToolCallPart(streamPart) {
84
+ const parentMessageId = currentMessageId || generateUUID();
85
+ if (isInTextMessage) {
86
+ const message = {
87
+ type: EventType.TEXT_MESSAGE_END,
88
+ messageId: parentMessageId
89
+ };
90
+ subscriber.next(message);
91
+ isInTextMessage = false;
92
+ }
93
+ subscriber.next({
94
+ type: EventType.TOOL_CALL_START,
95
+ toolCallId: streamPart.toolCallId,
96
+ toolCallName: streamPart.toolName,
97
+ parentMessageId
98
+ });
99
+ subscriber.next({
100
+ type: EventType.TOOL_CALL_ARGS,
101
+ toolCallId: streamPart.toolCallId,
102
+ delta: JSON.stringify(streamPart.args),
103
+ parentMessageId
104
+ });
105
+ subscriber.next({
106
+ type: EventType.TOOL_CALL_END,
107
+ toolCallId: streamPart.toolCallId,
108
+ parentMessageId
109
+ });
110
+ }
111
+ });
112
+ }).catch((error) => {
113
+ console.error("error", error);
114
+ subscriber.error(error);
115
+ });
116
+ return () => {
117
+ };
118
+ });
119
+ }
120
+ };
121
+ function generateUUID() {
122
+ if (typeof crypto !== "undefined") {
123
+ if (typeof crypto.randomUUID === "function") {
124
+ return crypto.randomUUID();
125
+ }
126
+ if (typeof crypto.getRandomValues === "function") {
127
+ const buffer = new Uint8Array(16);
128
+ crypto.getRandomValues(buffer);
129
+ buffer[6] = buffer[6] & 15 | 64;
130
+ buffer[8] = buffer[8] & 63 | 128;
131
+ let hex = "";
132
+ for (let i = 0; i < 16; i++) {
133
+ hex += buffer[i].toString(16).padStart(2, "0");
134
+ if (i === 3 || i === 5 || i === 7 || i === 9) hex += "-";
135
+ }
136
+ return hex;
137
+ }
138
+ }
139
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
140
+ const r = Math.random() * 16 | 0;
141
+ const v = c === "x" ? r : r & 3 | 8;
142
+ return v.toString(16);
143
+ });
144
+ }
145
+ function convertMessagesToMastraMessages(messages) {
146
+ const result = [];
147
+ for (const message of messages) {
148
+ if (message.role === "assistant") {
149
+ const parts = message.content ? [{ type: "text", text: message.content }] : [];
150
+ for (const toolCall of message.toolCalls ?? []) {
151
+ parts.push({
152
+ type: "tool-call",
153
+ toolCallId: toolCall.id,
154
+ toolName: toolCall.function.name,
155
+ args: JSON.parse(toolCall.function.arguments)
156
+ });
157
+ }
158
+ result.push({
159
+ role: "assistant",
160
+ content: parts
161
+ });
162
+ if (message.toolCalls?.length) {
163
+ result.push({
164
+ role: "tool",
165
+ content: message.toolCalls.map((toolCall) => ({
166
+ type: "tool-result",
167
+ toolCallId: toolCall.id,
168
+ toolName: toolCall.function.name,
169
+ result: JSON.parse(toolCall.function.arguments)
170
+ }))
171
+ });
172
+ }
173
+ } else if (message.role === "user") {
174
+ result.push({
175
+ role: "user",
176
+ content: message.content || ""
177
+ });
178
+ } else if (message.role === "tool") {
179
+ result.push({
180
+ role: "tool",
181
+ content: [
182
+ {
183
+ type: "tool-result",
184
+ toolCallId: message.toolCallId,
185
+ toolName: "unknown",
186
+ result: message.content
187
+ }
188
+ ]
189
+ });
190
+ }
191
+ }
192
+ return result;
193
+ }
194
+ function zodToJsonSchema(zodSchema) {
195
+ if (!(zodSchema instanceof ZodSchema)) {
196
+ return zodSchema;
197
+ }
198
+ return originalZodToJsonSchema(zodSchema, { $refStrategy: "none" });
199
+ }
200
+ function processClientTools(clientTools) {
201
+ if (!clientTools) {
202
+ return void 0;
203
+ }
204
+ return Object.fromEntries(
205
+ Object.entries(clientTools).map(([key, value]) => {
206
+ if (isVercelTool(value)) {
207
+ return [
208
+ key,
209
+ {
210
+ ...value,
211
+ parameters: value.parameters ? zodToJsonSchema(value.parameters) : void 0
212
+ }
213
+ ];
214
+ } else {
215
+ return [
216
+ key,
217
+ {
218
+ ...value,
219
+ inputSchema: value.inputSchema ? zodToJsonSchema(value.inputSchema) : void 0,
220
+ outputSchema: value.outputSchema ? zodToJsonSchema(value.outputSchema) : void 0
221
+ }
222
+ ];
223
+ }
224
+ })
225
+ );
226
+ }
6
227
 
7
228
  // src/resources/base.ts
8
229
  var BaseResource = class {
@@ -22,9 +243,10 @@ var BaseResource = class {
22
243
  let delay = backoffMs;
23
244
  for (let attempt = 0; attempt <= retries; attempt++) {
24
245
  try {
25
- const response = await fetch(`${baseUrl}${path}`, {
246
+ const response = await fetch(`${baseUrl.replace(/\/$/, "")}${path}`, {
26
247
  ...options,
27
248
  headers: {
249
+ ...options.method === "POST" || options.method === "PUT" ? { "content-type": "application/json" } : {},
28
250
  ...headers,
29
251
  ...options.headers
30
252
  // TODO: Bring this back once we figure out what we/users need to do to make this work with cross-origin requests
@@ -62,8 +284,15 @@ var BaseResource = class {
62
284
  throw lastError || new Error("Request failed");
63
285
  }
64
286
  };
65
-
66
- // src/resources/agent.ts
287
+ function parseClientRuntimeContext(runtimeContext) {
288
+ if (runtimeContext) {
289
+ if (runtimeContext instanceof RuntimeContext) {
290
+ return Object.fromEntries(runtimeContext.entries());
291
+ }
292
+ return runtimeContext;
293
+ }
294
+ return void 0;
295
+ }
67
296
  var AgentVoice = class extends BaseResource {
68
297
  constructor(options, agentId) {
69
298
  super(options);
@@ -110,6 +339,13 @@ var AgentVoice = class extends BaseResource {
110
339
  getSpeakers() {
111
340
  return this.request(`/api/agents/${this.agentId}/voice/speakers`);
112
341
  }
342
+ /**
343
+ * Get the listener configuration for the agent's voice provider
344
+ * @returns Promise containing a check if the agent has listening capabilities
345
+ */
346
+ getListener() {
347
+ return this.request(`/api/agents/${this.agentId}/voice/listener`);
348
+ }
113
349
  };
114
350
  var Agent = class extends BaseResource {
115
351
  constructor(options, agentId) {
@@ -125,21 +361,318 @@ var Agent = class extends BaseResource {
125
361
  details() {
126
362
  return this.request(`/api/agents/${this.agentId}`);
127
363
  }
128
- /**
129
- * Generates a response from the agent
130
- * @param params - Generation parameters including prompt
131
- * @returns Promise containing the generated response
132
- */
133
- generate(params) {
364
+ async generate(params) {
134
365
  const processedParams = {
135
366
  ...params,
136
- output: params.output instanceof ZodSchema ? zodToJsonSchema(params.output) : params.output,
137
- experimental_output: params.experimental_output instanceof ZodSchema ? zodToJsonSchema(params.experimental_output) : params.experimental_output
367
+ output: params.output ? zodToJsonSchema(params.output) : void 0,
368
+ experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
369
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext),
370
+ clientTools: processClientTools(params.clientTools)
138
371
  };
139
- return this.request(`/api/agents/${this.agentId}/generate`, {
372
+ const { runId, resourceId, threadId, runtimeContext } = processedParams;
373
+ const response = await this.request(`/api/agents/${this.agentId}/generate`, {
140
374
  method: "POST",
141
375
  body: processedParams
142
376
  });
377
+ if (response.finishReason === "tool-calls") {
378
+ for (const toolCall of response.toolCalls) {
379
+ const clientTool = params.clientTools?.[toolCall.toolName];
380
+ if (clientTool && clientTool.execute) {
381
+ const result = await clientTool.execute(
382
+ { context: toolCall?.args, runId, resourceId, threadId, runtimeContext },
383
+ {
384
+ messages: response.messages,
385
+ toolCallId: toolCall?.toolCallId
386
+ }
387
+ );
388
+ const updatedMessages = [
389
+ {
390
+ role: "user",
391
+ content: params.messages
392
+ },
393
+ ...response.response.messages,
394
+ {
395
+ role: "tool",
396
+ content: [
397
+ {
398
+ type: "tool-result",
399
+ toolCallId: toolCall.toolCallId,
400
+ toolName: toolCall.toolName,
401
+ result
402
+ }
403
+ ]
404
+ }
405
+ ];
406
+ return this.generate({
407
+ ...params,
408
+ messages: updatedMessages
409
+ });
410
+ }
411
+ }
412
+ }
413
+ return response;
414
+ }
415
+ async processChatResponse({
416
+ stream,
417
+ update,
418
+ onToolCall,
419
+ onFinish,
420
+ getCurrentDate = () => /* @__PURE__ */ new Date(),
421
+ lastMessage
422
+ }) {
423
+ const replaceLastMessage = lastMessage?.role === "assistant";
424
+ let step = replaceLastMessage ? 1 + // find max step in existing tool invocations:
425
+ (lastMessage.toolInvocations?.reduce((max, toolInvocation) => {
426
+ return Math.max(max, toolInvocation.step ?? 0);
427
+ }, 0) ?? 0) : 0;
428
+ const message = replaceLastMessage ? structuredClone(lastMessage) : {
429
+ id: crypto.randomUUID(),
430
+ createdAt: getCurrentDate(),
431
+ role: "assistant",
432
+ content: "",
433
+ parts: []
434
+ };
435
+ let currentTextPart = void 0;
436
+ let currentReasoningPart = void 0;
437
+ let currentReasoningTextDetail = void 0;
438
+ function updateToolInvocationPart(toolCallId, invocation) {
439
+ const part = message.parts.find(
440
+ (part2) => part2.type === "tool-invocation" && part2.toolInvocation.toolCallId === toolCallId
441
+ );
442
+ if (part != null) {
443
+ part.toolInvocation = invocation;
444
+ } else {
445
+ message.parts.push({
446
+ type: "tool-invocation",
447
+ toolInvocation: invocation
448
+ });
449
+ }
450
+ }
451
+ const data = [];
452
+ let messageAnnotations = replaceLastMessage ? lastMessage?.annotations : void 0;
453
+ const partialToolCalls = {};
454
+ let usage = {
455
+ completionTokens: NaN,
456
+ promptTokens: NaN,
457
+ totalTokens: NaN
458
+ };
459
+ let finishReason = "unknown";
460
+ function execUpdate() {
461
+ const copiedData = [...data];
462
+ if (messageAnnotations?.length) {
463
+ message.annotations = messageAnnotations;
464
+ }
465
+ const copiedMessage = {
466
+ // deep copy the message to ensure that deep changes (msg attachments) are updated
467
+ // with SolidJS. SolidJS uses referential integration of sub-objects to detect changes.
468
+ ...structuredClone(message),
469
+ // add a revision id to ensure that the message is updated with SWR. SWR uses a
470
+ // hashing approach by default to detect changes, but it only works for shallow
471
+ // changes. This is why we need to add a revision id to ensure that the message
472
+ // is updated with SWR (without it, the changes get stuck in SWR and are not
473
+ // forwarded to rendering):
474
+ revisionId: crypto.randomUUID()
475
+ };
476
+ update({
477
+ message: copiedMessage,
478
+ data: copiedData,
479
+ replaceLastMessage
480
+ });
481
+ }
482
+ await processDataStream({
483
+ stream,
484
+ onTextPart(value) {
485
+ if (currentTextPart == null) {
486
+ currentTextPart = {
487
+ type: "text",
488
+ text: value
489
+ };
490
+ message.parts.push(currentTextPart);
491
+ } else {
492
+ currentTextPart.text += value;
493
+ }
494
+ message.content += value;
495
+ execUpdate();
496
+ },
497
+ onReasoningPart(value) {
498
+ if (currentReasoningTextDetail == null) {
499
+ currentReasoningTextDetail = { type: "text", text: value };
500
+ if (currentReasoningPart != null) {
501
+ currentReasoningPart.details.push(currentReasoningTextDetail);
502
+ }
503
+ } else {
504
+ currentReasoningTextDetail.text += value;
505
+ }
506
+ if (currentReasoningPart == null) {
507
+ currentReasoningPart = {
508
+ type: "reasoning",
509
+ reasoning: value,
510
+ details: [currentReasoningTextDetail]
511
+ };
512
+ message.parts.push(currentReasoningPart);
513
+ } else {
514
+ currentReasoningPart.reasoning += value;
515
+ }
516
+ message.reasoning = (message.reasoning ?? "") + value;
517
+ execUpdate();
518
+ },
519
+ onReasoningSignaturePart(value) {
520
+ if (currentReasoningTextDetail != null) {
521
+ currentReasoningTextDetail.signature = value.signature;
522
+ }
523
+ },
524
+ onRedactedReasoningPart(value) {
525
+ if (currentReasoningPart == null) {
526
+ currentReasoningPart = {
527
+ type: "reasoning",
528
+ reasoning: "",
529
+ details: []
530
+ };
531
+ message.parts.push(currentReasoningPart);
532
+ }
533
+ currentReasoningPart.details.push({
534
+ type: "redacted",
535
+ data: value.data
536
+ });
537
+ currentReasoningTextDetail = void 0;
538
+ execUpdate();
539
+ },
540
+ onFilePart(value) {
541
+ message.parts.push({
542
+ type: "file",
543
+ mimeType: value.mimeType,
544
+ data: value.data
545
+ });
546
+ execUpdate();
547
+ },
548
+ onSourcePart(value) {
549
+ message.parts.push({
550
+ type: "source",
551
+ source: value
552
+ });
553
+ execUpdate();
554
+ },
555
+ onToolCallStreamingStartPart(value) {
556
+ if (message.toolInvocations == null) {
557
+ message.toolInvocations = [];
558
+ }
559
+ partialToolCalls[value.toolCallId] = {
560
+ text: "",
561
+ step,
562
+ toolName: value.toolName,
563
+ index: message.toolInvocations.length
564
+ };
565
+ const invocation = {
566
+ state: "partial-call",
567
+ step,
568
+ toolCallId: value.toolCallId,
569
+ toolName: value.toolName,
570
+ args: void 0
571
+ };
572
+ message.toolInvocations.push(invocation);
573
+ updateToolInvocationPart(value.toolCallId, invocation);
574
+ execUpdate();
575
+ },
576
+ onToolCallDeltaPart(value) {
577
+ const partialToolCall = partialToolCalls[value.toolCallId];
578
+ partialToolCall.text += value.argsTextDelta;
579
+ const { value: partialArgs } = parsePartialJson(partialToolCall.text);
580
+ const invocation = {
581
+ state: "partial-call",
582
+ step: partialToolCall.step,
583
+ toolCallId: value.toolCallId,
584
+ toolName: partialToolCall.toolName,
585
+ args: partialArgs
586
+ };
587
+ message.toolInvocations[partialToolCall.index] = invocation;
588
+ updateToolInvocationPart(value.toolCallId, invocation);
589
+ execUpdate();
590
+ },
591
+ async onToolCallPart(value) {
592
+ const invocation = {
593
+ state: "call",
594
+ step,
595
+ ...value
596
+ };
597
+ if (partialToolCalls[value.toolCallId] != null) {
598
+ message.toolInvocations[partialToolCalls[value.toolCallId].index] = invocation;
599
+ } else {
600
+ if (message.toolInvocations == null) {
601
+ message.toolInvocations = [];
602
+ }
603
+ message.toolInvocations.push(invocation);
604
+ }
605
+ updateToolInvocationPart(value.toolCallId, invocation);
606
+ execUpdate();
607
+ if (onToolCall) {
608
+ const result = await onToolCall({ toolCall: value });
609
+ if (result != null) {
610
+ const invocation2 = {
611
+ state: "result",
612
+ step,
613
+ ...value,
614
+ result
615
+ };
616
+ message.toolInvocations[message.toolInvocations.length - 1] = invocation2;
617
+ updateToolInvocationPart(value.toolCallId, invocation2);
618
+ execUpdate();
619
+ }
620
+ }
621
+ },
622
+ onToolResultPart(value) {
623
+ const toolInvocations = message.toolInvocations;
624
+ if (toolInvocations == null) {
625
+ throw new Error("tool_result must be preceded by a tool_call");
626
+ }
627
+ const toolInvocationIndex = toolInvocations.findIndex((invocation2) => invocation2.toolCallId === value.toolCallId);
628
+ if (toolInvocationIndex === -1) {
629
+ throw new Error("tool_result must be preceded by a tool_call with the same toolCallId");
630
+ }
631
+ const invocation = {
632
+ ...toolInvocations[toolInvocationIndex],
633
+ state: "result",
634
+ ...value
635
+ };
636
+ toolInvocations[toolInvocationIndex] = invocation;
637
+ updateToolInvocationPart(value.toolCallId, invocation);
638
+ execUpdate();
639
+ },
640
+ onDataPart(value) {
641
+ data.push(...value);
642
+ execUpdate();
643
+ },
644
+ onMessageAnnotationsPart(value) {
645
+ if (messageAnnotations == null) {
646
+ messageAnnotations = [...value];
647
+ } else {
648
+ messageAnnotations.push(...value);
649
+ }
650
+ execUpdate();
651
+ },
652
+ onFinishStepPart(value) {
653
+ step += 1;
654
+ currentTextPart = value.isContinued ? currentTextPart : void 0;
655
+ currentReasoningPart = void 0;
656
+ currentReasoningTextDetail = void 0;
657
+ },
658
+ onStartStepPart(value) {
659
+ if (!replaceLastMessage) {
660
+ message.id = value.messageId;
661
+ }
662
+ message.parts.push({ type: "step-start" });
663
+ execUpdate();
664
+ },
665
+ onFinishMessagePart(value) {
666
+ finishReason = value.finishReason;
667
+ if (value.usage != null) {
668
+ usage = value.usage;
669
+ }
670
+ },
671
+ onErrorPart(error) {
672
+ throw new Error(error);
673
+ }
674
+ });
675
+ onFinish?.({ message, finishReason, usage });
143
676
  }
144
677
  /**
145
678
  * Streams a response from the agent
@@ -149,9 +682,30 @@ var Agent = class extends BaseResource {
149
682
  async stream(params) {
150
683
  const processedParams = {
151
684
  ...params,
152
- output: params.output instanceof ZodSchema ? zodToJsonSchema(params.output) : params.output,
153
- experimental_output: params.experimental_output instanceof ZodSchema ? zodToJsonSchema(params.experimental_output) : params.experimental_output
685
+ output: params.output ? zodToJsonSchema(params.output) : void 0,
686
+ experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
687
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext),
688
+ clientTools: processClientTools(params.clientTools)
689
+ };
690
+ const { readable, writable } = new TransformStream();
691
+ const response = await this.processStreamResponse(processedParams, writable);
692
+ const streamResponse = new Response(readable, {
693
+ status: response.status,
694
+ statusText: response.statusText,
695
+ headers: response.headers
696
+ });
697
+ streamResponse.processDataStream = async (options = {}) => {
698
+ await processDataStream({
699
+ stream: streamResponse.body,
700
+ ...options
701
+ });
154
702
  };
703
+ return streamResponse;
704
+ }
705
+ /**
706
+ * Processes the stream response and handles tool calls
707
+ */
708
+ async processStreamResponse(processedParams, writable) {
155
709
  const response = await this.request(`/api/agents/${this.agentId}/stream`, {
156
710
  method: "POST",
157
711
  body: processedParams,
@@ -160,12 +714,82 @@ var Agent = class extends BaseResource {
160
714
  if (!response.body) {
161
715
  throw new Error("No response body");
162
716
  }
163
- response.processDataStream = async (options = {}) => {
164
- await processDataStream({
165
- stream: response.body,
166
- ...options
717
+ try {
718
+ let toolCalls = [];
719
+ let messages = [];
720
+ const [streamForWritable, streamForProcessing] = response.body.tee();
721
+ streamForWritable.pipeTo(writable, {
722
+ preventClose: true
723
+ }).catch((error) => {
724
+ console.error("Error piping to writable stream:", error);
167
725
  });
168
- };
726
+ this.processChatResponse({
727
+ stream: streamForProcessing,
728
+ update: ({ message }) => {
729
+ messages.push(message);
730
+ },
731
+ onFinish: async ({ finishReason, message }) => {
732
+ if (finishReason === "tool-calls") {
733
+ const toolCall = [...message?.parts ?? []].reverse().find((part) => part.type === "tool-invocation")?.toolInvocation;
734
+ if (toolCall) {
735
+ toolCalls.push(toolCall);
736
+ }
737
+ for (const toolCall2 of toolCalls) {
738
+ const clientTool = processedParams.clientTools?.[toolCall2.toolName];
739
+ if (clientTool && clientTool.execute) {
740
+ const result = await clientTool.execute(
741
+ {
742
+ context: toolCall2?.args,
743
+ runId: processedParams.runId,
744
+ resourceId: processedParams.resourceId,
745
+ threadId: processedParams.threadId,
746
+ runtimeContext: processedParams.runtimeContext
747
+ },
748
+ {
749
+ messages: response.messages,
750
+ toolCallId: toolCall2?.toolCallId
751
+ }
752
+ );
753
+ const lastMessage = JSON.parse(JSON.stringify(messages[messages.length - 1]));
754
+ const toolInvocationPart = lastMessage?.parts?.find(
755
+ (part) => part.type === "tool-invocation" && part.toolInvocation?.toolCallId === toolCall2.toolCallId
756
+ );
757
+ if (toolInvocationPart) {
758
+ toolInvocationPart.toolInvocation = {
759
+ ...toolInvocationPart.toolInvocation,
760
+ state: "result",
761
+ result
762
+ };
763
+ }
764
+ const toolInvocation = lastMessage?.toolInvocations?.find(
765
+ (toolInvocation2) => toolInvocation2.toolCallId === toolCall2.toolCallId
766
+ );
767
+ if (toolInvocation) {
768
+ toolInvocation.state = "result";
769
+ toolInvocation.result = result;
770
+ }
771
+ const originalMessages = processedParams.messages;
772
+ const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
773
+ this.processStreamResponse(
774
+ {
775
+ ...processedParams,
776
+ messages: [...messageArray, ...messages, lastMessage]
777
+ },
778
+ writable
779
+ );
780
+ }
781
+ }
782
+ } else {
783
+ setTimeout(() => {
784
+ writable.close();
785
+ }, 0);
786
+ }
787
+ },
788
+ lastMessage: void 0
789
+ });
790
+ } catch (error) {
791
+ console.error("Error processing stream response:", error);
792
+ }
169
793
  return response;
170
794
  }
171
795
  /**
@@ -176,6 +800,22 @@ var Agent = class extends BaseResource {
176
800
  getTool(toolId) {
177
801
  return this.request(`/api/agents/${this.agentId}/tools/${toolId}`);
178
802
  }
803
+ /**
804
+ * Executes a tool for the agent
805
+ * @param toolId - ID of the tool to execute
806
+ * @param params - Parameters required for tool execution
807
+ * @returns Promise containing the tool execution results
808
+ */
809
+ executeTool(toolId, params) {
810
+ const body = {
811
+ data: params.data,
812
+ runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
813
+ };
814
+ return this.request(`/api/agents/${this.agentId}/tools/${toolId}/execute`, {
815
+ method: "POST",
816
+ body
817
+ });
818
+ }
179
819
  /**
180
820
  * Retrieves evaluation results for the agent
181
821
  * @returns Promise containing agent evaluations
@@ -211,8 +851,8 @@ var Network = class extends BaseResource {
211
851
  generate(params) {
212
852
  const processedParams = {
213
853
  ...params,
214
- output: params.output instanceof ZodSchema ? zodToJsonSchema(params.output) : params.output,
215
- experimental_output: params.experimental_output instanceof ZodSchema ? zodToJsonSchema(params.experimental_output) : params.experimental_output
854
+ output: zodToJsonSchema(params.output),
855
+ experimental_output: zodToJsonSchema(params.experimental_output)
216
856
  };
217
857
  return this.request(`/api/networks/${this.networkId}/generate`, {
218
858
  method: "POST",
@@ -227,8 +867,8 @@ var Network = class extends BaseResource {
227
867
  async stream(params) {
228
868
  const processedParams = {
229
869
  ...params,
230
- output: params.output instanceof ZodSchema ? zodToJsonSchema(params.output) : params.output,
231
- experimental_output: params.experimental_output instanceof ZodSchema ? zodToJsonSchema(params.experimental_output) : params.experimental_output
870
+ output: zodToJsonSchema(params.output),
871
+ experimental_output: zodToJsonSchema(params.experimental_output)
232
872
  };
233
873
  const response = await this.request(`/api/networks/${this.networkId}/stream`, {
234
874
  method: "POST",
@@ -284,10 +924,15 @@ var MemoryThread = class extends BaseResource {
284
924
  }
285
925
  /**
286
926
  * Retrieves messages associated with the thread
927
+ * @param params - Optional parameters including limit for number of messages to retrieve
287
928
  * @returns Promise containing thread messages and UI messages
288
929
  */
289
- getMessages() {
290
- return this.request(`/api/memory/threads/${this.threadId}/messages?agentId=${this.agentId}`);
930
+ getMessages(params) {
931
+ const query = new URLSearchParams({
932
+ agentId: this.agentId,
933
+ ...params?.limit ? { limit: params.limit.toString() } : {}
934
+ });
935
+ return this.request(`/api/memory/threads/${this.threadId}/messages?${query.toString()}`);
291
936
  }
292
937
  };
293
938
 
@@ -357,34 +1002,50 @@ var Vector = class extends BaseResource {
357
1002
  }
358
1003
  };
359
1004
 
360
- // src/resources/workflow.ts
1005
+ // src/resources/legacy-workflow.ts
361
1006
  var RECORD_SEPARATOR = "";
362
- var Workflow = class extends BaseResource {
1007
+ var LegacyWorkflow = class extends BaseResource {
363
1008
  constructor(options, workflowId) {
364
1009
  super(options);
365
1010
  this.workflowId = workflowId;
366
1011
  }
367
1012
  /**
368
- * Retrieves details about the workflow
369
- * @returns Promise containing workflow details including steps and graphs
1013
+ * Retrieves details about the legacy workflow
1014
+ * @returns Promise containing legacy workflow details including steps and graphs
370
1015
  */
371
1016
  details() {
372
- return this.request(`/api/workflows/${this.workflowId}`);
1017
+ return this.request(`/api/workflows/legacy/${this.workflowId}`);
373
1018
  }
374
1019
  /**
375
- * @deprecated Use `startAsync` instead
376
- * Executes the workflow with the provided parameters
377
- * @param params - Parameters required for workflow execution
378
- * @returns Promise containing the workflow execution results
1020
+ * Retrieves all runs for a legacy workflow
1021
+ * @param params - Parameters for filtering runs
1022
+ * @returns Promise containing legacy workflow runs array
379
1023
  */
380
- execute(params) {
381
- return this.request(`/api/workflows/${this.workflowId}/execute`, {
382
- method: "POST",
383
- body: params
384
- });
1024
+ runs(params) {
1025
+ const searchParams = new URLSearchParams();
1026
+ if (params?.fromDate) {
1027
+ searchParams.set("fromDate", params.fromDate.toISOString());
1028
+ }
1029
+ if (params?.toDate) {
1030
+ searchParams.set("toDate", params.toDate.toISOString());
1031
+ }
1032
+ if (params?.limit) {
1033
+ searchParams.set("limit", String(params.limit));
1034
+ }
1035
+ if (params?.offset) {
1036
+ searchParams.set("offset", String(params.offset));
1037
+ }
1038
+ if (params?.resourceId) {
1039
+ searchParams.set("resourceId", params.resourceId);
1040
+ }
1041
+ if (searchParams.size) {
1042
+ return this.request(`/api/workflows/legacy/${this.workflowId}/runs?${searchParams}`);
1043
+ } else {
1044
+ return this.request(`/api/workflows/legacy/${this.workflowId}/runs`);
1045
+ }
385
1046
  }
386
1047
  /**
387
- * Creates a new workflow run
1048
+ * Creates a new legacy workflow run
388
1049
  * @returns Promise containing the generated run ID
389
1050
  */
390
1051
  createRun(params) {
@@ -392,34 +1053,34 @@ var Workflow = class extends BaseResource {
392
1053
  if (!!params?.runId) {
393
1054
  searchParams.set("runId", params.runId);
394
1055
  }
395
- return this.request(`/api/workflows/${this.workflowId}/createRun?${searchParams.toString()}`, {
1056
+ return this.request(`/api/workflows/legacy/${this.workflowId}/create-run?${searchParams.toString()}`, {
396
1057
  method: "POST"
397
1058
  });
398
1059
  }
399
1060
  /**
400
- * Starts a workflow run synchronously without waiting for the workflow to complete
1061
+ * Starts a legacy workflow run synchronously without waiting for the workflow to complete
401
1062
  * @param params - Object containing the runId and triggerData
402
1063
  * @returns Promise containing success message
403
1064
  */
404
1065
  start(params) {
405
- return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
1066
+ return this.request(`/api/workflows/legacy/${this.workflowId}/start?runId=${params.runId}`, {
406
1067
  method: "POST",
407
1068
  body: params?.triggerData
408
1069
  });
409
1070
  }
410
1071
  /**
411
- * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
1072
+ * Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
412
1073
  * @param stepId - ID of the step to resume
413
- * @param runId - ID of the workflow run
414
- * @param context - Context to resume the workflow with
415
- * @returns Promise containing the workflow resume results
1074
+ * @param runId - ID of the legacy workflow run
1075
+ * @param context - Context to resume the legacy workflow with
1076
+ * @returns Promise containing the legacy workflow resume results
416
1077
  */
417
1078
  resume({
418
1079
  stepId,
419
1080
  runId,
420
1081
  context
421
1082
  }) {
422
- return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
1083
+ return this.request(`/api/workflows/legacy/${this.workflowId}/resume?runId=${runId}`, {
423
1084
  method: "POST",
424
1085
  body: {
425
1086
  stepId,
@@ -437,18 +1098,18 @@ var Workflow = class extends BaseResource {
437
1098
  if (!!params?.runId) {
438
1099
  searchParams.set("runId", params.runId);
439
1100
  }
440
- return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
1101
+ return this.request(`/api/workflows/legacy/${this.workflowId}/start-async?${searchParams.toString()}`, {
441
1102
  method: "POST",
442
1103
  body: params?.triggerData
443
1104
  });
444
1105
  }
445
1106
  /**
446
- * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
1107
+ * Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
447
1108
  * @param params - Object containing the runId, stepId, and context
448
1109
  * @returns Promise containing the workflow resume results
449
1110
  */
450
1111
  resumeAsync(params) {
451
- return this.request(`/api/workflows/${this.workflowId}/resume-async?runId=${params.runId}`, {
1112
+ return this.request(`/api/workflows/legacy/${this.workflowId}/resume-async?runId=${params.runId}`, {
452
1113
  method: "POST",
453
1114
  body: {
454
1115
  stepId: params.stepId,
@@ -487,7 +1148,7 @@ var Workflow = class extends BaseResource {
487
1148
  }
488
1149
  }
489
1150
  }
490
- } catch (error) {
1151
+ } catch {
491
1152
  }
492
1153
  }
493
1154
  if (buffer) {
@@ -502,16 +1163,16 @@ var Workflow = class extends BaseResource {
502
1163
  }
503
1164
  }
504
1165
  /**
505
- * Watches workflow transitions in real-time
1166
+ * Watches legacy workflow transitions in real-time
506
1167
  * @param runId - Optional run ID to filter the watch stream
507
- * @returns AsyncGenerator that yields parsed records from the workflow watch stream
1168
+ * @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
508
1169
  */
509
1170
  async watch({ runId }, onRecord) {
510
- const response = await this.request(`/api/workflows/${this.workflowId}/watch?runId=${runId}`, {
1171
+ const response = await this.request(`/api/workflows/legacy/${this.workflowId}/watch?runId=${runId}`, {
511
1172
  stream: true
512
1173
  });
513
1174
  if (!response.ok) {
514
- throw new Error(`Failed to watch workflow: ${response.statusText}`);
1175
+ throw new Error(`Failed to watch legacy workflow: ${response.statusText}`);
515
1176
  }
516
1177
  if (!response.body) {
517
1178
  throw new Error("Response body is null");
@@ -523,7 +1184,7 @@ var Workflow = class extends BaseResource {
523
1184
  };
524
1185
 
525
1186
  // src/resources/tool.ts
526
- var Tool = class extends BaseResource {
1187
+ var Tool2 = class extends BaseResource {
527
1188
  constructor(options, toolId) {
528
1189
  super(options);
529
1190
  this.toolId = toolId;
@@ -541,61 +1202,644 @@ var Tool = class extends BaseResource {
541
1202
  * @returns Promise containing the tool execution results
542
1203
  */
543
1204
  execute(params) {
544
- return this.request(`/api/tools/${this.toolId}/execute`, {
1205
+ const url = new URLSearchParams();
1206
+ if (params.runId) {
1207
+ url.set("runId", params.runId);
1208
+ }
1209
+ const body = {
1210
+ data: params.data,
1211
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1212
+ };
1213
+ return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
545
1214
  method: "POST",
546
- body: params
1215
+ body
547
1216
  });
548
1217
  }
549
1218
  };
550
1219
 
551
- // src/client.ts
552
- var MastraClient = class extends BaseResource {
553
- constructor(options) {
1220
+ // src/resources/workflow.ts
1221
+ var RECORD_SEPARATOR2 = "";
1222
+ var Workflow = class extends BaseResource {
1223
+ constructor(options, workflowId) {
554
1224
  super(options);
1225
+ this.workflowId = workflowId;
555
1226
  }
556
1227
  /**
557
- * Retrieves all available agents
558
- * @returns Promise containing map of agent IDs to agent details
1228
+ * Creates an async generator that processes a readable stream and yields workflow records
1229
+ * separated by the Record Separator character (\x1E)
1230
+ *
1231
+ * @param stream - The readable stream to process
1232
+ * @returns An async generator that yields parsed records
559
1233
  */
560
- getAgents() {
561
- return this.request("/api/agents");
1234
+ async *streamProcessor(stream) {
1235
+ const reader = stream.getReader();
1236
+ let doneReading = false;
1237
+ let buffer = "";
1238
+ try {
1239
+ while (!doneReading) {
1240
+ const { done, value } = await reader.read();
1241
+ doneReading = done;
1242
+ if (done && !value) continue;
1243
+ try {
1244
+ const decoded = value ? new TextDecoder().decode(value) : "";
1245
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
1246
+ buffer = chunks.pop() || "";
1247
+ for (const chunk of chunks) {
1248
+ if (chunk) {
1249
+ if (typeof chunk === "string") {
1250
+ try {
1251
+ const parsedChunk = JSON.parse(chunk);
1252
+ yield parsedChunk;
1253
+ } catch {
1254
+ }
1255
+ }
1256
+ }
1257
+ }
1258
+ } catch {
1259
+ }
1260
+ }
1261
+ if (buffer) {
1262
+ try {
1263
+ yield JSON.parse(buffer);
1264
+ } catch {
1265
+ }
1266
+ }
1267
+ } finally {
1268
+ reader.cancel().catch(() => {
1269
+ });
1270
+ }
562
1271
  }
563
1272
  /**
564
- * Gets an agent instance by ID
565
- * @param agentId - ID of the agent to retrieve
566
- * @returns Agent instance
1273
+ * Retrieves details about the workflow
1274
+ * @returns Promise containing workflow details including steps and graphs
567
1275
  */
568
- getAgent(agentId) {
569
- return new Agent(this.options, agentId);
1276
+ details() {
1277
+ return this.request(`/api/workflows/${this.workflowId}`);
570
1278
  }
571
1279
  /**
572
- * Retrieves memory threads for a resource
573
- * @param params - Parameters containing the resource ID
574
- * @returns Promise containing array of memory threads
1280
+ * Retrieves all runs for a workflow
1281
+ * @param params - Parameters for filtering runs
1282
+ * @returns Promise containing workflow runs array
575
1283
  */
576
- getMemoryThreads(params) {
577
- return this.request(`/api/memory/threads?resourceid=${params.resourceId}&agentId=${params.agentId}`);
1284
+ runs(params) {
1285
+ const searchParams = new URLSearchParams();
1286
+ if (params?.fromDate) {
1287
+ searchParams.set("fromDate", params.fromDate.toISOString());
1288
+ }
1289
+ if (params?.toDate) {
1290
+ searchParams.set("toDate", params.toDate.toISOString());
1291
+ }
1292
+ if (params?.limit) {
1293
+ searchParams.set("limit", String(params.limit));
1294
+ }
1295
+ if (params?.offset) {
1296
+ searchParams.set("offset", String(params.offset));
1297
+ }
1298
+ if (params?.resourceId) {
1299
+ searchParams.set("resourceId", params.resourceId);
1300
+ }
1301
+ if (searchParams.size) {
1302
+ return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
1303
+ } else {
1304
+ return this.request(`/api/workflows/${this.workflowId}/runs`);
1305
+ }
578
1306
  }
579
1307
  /**
580
- * Creates a new memory thread
581
- * @param params - Parameters for creating the memory thread
582
- * @returns Promise containing the created memory thread
1308
+ * Retrieves a specific workflow run by its ID
1309
+ * @param runId - The ID of the workflow run to retrieve
1310
+ * @returns Promise containing the workflow run details
583
1311
  */
584
- createMemoryThread(params) {
585
- return this.request(`/api/memory/threads?agentId=${params.agentId}`, { method: "POST", body: params });
1312
+ runById(runId) {
1313
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}`);
586
1314
  }
587
1315
  /**
588
- * Gets a memory thread instance by ID
589
- * @param threadId - ID of the memory thread to retrieve
590
- * @returns MemoryThread instance
1316
+ * Retrieves the execution result for a specific workflow run by its ID
1317
+ * @param runId - The ID of the workflow run to retrieve the execution result for
1318
+ * @returns Promise containing the workflow run execution result
591
1319
  */
592
- getMemoryThread(threadId, agentId) {
593
- return new MemoryThread(this.options, threadId, agentId);
1320
+ runExecutionResult(runId) {
1321
+ return this.request(`/api/workflows/${this.workflowId}/runs/${runId}/execution-result`);
594
1322
  }
595
1323
  /**
596
- * Saves messages to memory
597
- * @param params - Parameters containing messages to save
598
- * @returns Promise containing the saved messages
1324
+ * Creates a new workflow run
1325
+ * @param params - Optional object containing the optional runId
1326
+ * @returns Promise containing the runId of the created run
1327
+ */
1328
+ createRun(params) {
1329
+ const searchParams = new URLSearchParams();
1330
+ if (!!params?.runId) {
1331
+ searchParams.set("runId", params.runId);
1332
+ }
1333
+ return this.request(`/api/workflows/${this.workflowId}/create-run?${searchParams.toString()}`, {
1334
+ method: "POST"
1335
+ });
1336
+ }
1337
+ /**
1338
+ * Starts a workflow run synchronously without waiting for the workflow to complete
1339
+ * @param params - Object containing the runId, inputData and runtimeContext
1340
+ * @returns Promise containing success message
1341
+ */
1342
+ start(params) {
1343
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
1344
+ return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
1345
+ method: "POST",
1346
+ body: { inputData: params?.inputData, runtimeContext }
1347
+ });
1348
+ }
1349
+ /**
1350
+ * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
1351
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
1352
+ * @returns Promise containing success message
1353
+ */
1354
+ resume({
1355
+ step,
1356
+ runId,
1357
+ resumeData,
1358
+ ...rest
1359
+ }) {
1360
+ const runtimeContext = parseClientRuntimeContext(rest.runtimeContext);
1361
+ return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
1362
+ method: "POST",
1363
+ stream: true,
1364
+ body: {
1365
+ step,
1366
+ resumeData,
1367
+ runtimeContext
1368
+ }
1369
+ });
1370
+ }
1371
+ /**
1372
+ * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
1373
+ * @param params - Object containing the optional runId, inputData and runtimeContext
1374
+ * @returns Promise containing the workflow execution results
1375
+ */
1376
+ startAsync(params) {
1377
+ const searchParams = new URLSearchParams();
1378
+ if (!!params?.runId) {
1379
+ searchParams.set("runId", params.runId);
1380
+ }
1381
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
1382
+ return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
1383
+ method: "POST",
1384
+ body: { inputData: params.inputData, runtimeContext }
1385
+ });
1386
+ }
1387
+ /**
1388
+ * Starts a workflow run and returns a stream
1389
+ * @param params - Object containing the optional runId, inputData and runtimeContext
1390
+ * @returns Promise containing the workflow execution results
1391
+ */
1392
+ async stream(params) {
1393
+ const searchParams = new URLSearchParams();
1394
+ if (!!params?.runId) {
1395
+ searchParams.set("runId", params.runId);
1396
+ }
1397
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
1398
+ const response = await this.request(
1399
+ `/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
1400
+ {
1401
+ method: "POST",
1402
+ body: { inputData: params.inputData, runtimeContext },
1403
+ stream: true
1404
+ }
1405
+ );
1406
+ if (!response.ok) {
1407
+ throw new Error(`Failed to stream vNext workflow: ${response.statusText}`);
1408
+ }
1409
+ if (!response.body) {
1410
+ throw new Error("Response body is null");
1411
+ }
1412
+ const transformStream = new TransformStream({
1413
+ start() {
1414
+ },
1415
+ async transform(chunk, controller) {
1416
+ try {
1417
+ const decoded = new TextDecoder().decode(chunk);
1418
+ const chunks = decoded.split(RECORD_SEPARATOR2);
1419
+ for (const chunk2 of chunks) {
1420
+ if (chunk2) {
1421
+ try {
1422
+ const parsedChunk = JSON.parse(chunk2);
1423
+ controller.enqueue(parsedChunk);
1424
+ } catch {
1425
+ }
1426
+ }
1427
+ }
1428
+ } catch {
1429
+ }
1430
+ }
1431
+ });
1432
+ return response.body.pipeThrough(transformStream);
1433
+ }
1434
+ /**
1435
+ * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
1436
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
1437
+ * @returns Promise containing the workflow resume results
1438
+ */
1439
+ resumeAsync(params) {
1440
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
1441
+ return this.request(`/api/workflows/${this.workflowId}/resume-async?runId=${params.runId}`, {
1442
+ method: "POST",
1443
+ body: {
1444
+ step: params.step,
1445
+ resumeData: params.resumeData,
1446
+ runtimeContext
1447
+ }
1448
+ });
1449
+ }
1450
+ /**
1451
+ * Watches workflow transitions in real-time
1452
+ * @param runId - Optional run ID to filter the watch stream
1453
+ * @returns AsyncGenerator that yields parsed records from the workflow watch stream
1454
+ */
1455
+ async watch({ runId }, onRecord) {
1456
+ const response = await this.request(`/api/workflows/${this.workflowId}/watch?runId=${runId}`, {
1457
+ stream: true
1458
+ });
1459
+ if (!response.ok) {
1460
+ throw new Error(`Failed to watch workflow: ${response.statusText}`);
1461
+ }
1462
+ if (!response.body) {
1463
+ throw new Error("Response body is null");
1464
+ }
1465
+ for await (const record of this.streamProcessor(response.body)) {
1466
+ if (typeof record === "string") {
1467
+ onRecord(JSON.parse(record));
1468
+ } else {
1469
+ onRecord(record);
1470
+ }
1471
+ }
1472
+ }
1473
+ /**
1474
+ * Creates a new ReadableStream from an iterable or async iterable of objects,
1475
+ * serializing each as JSON and separating them with the record separator (\x1E).
1476
+ *
1477
+ * @param records - An iterable or async iterable of objects to stream
1478
+ * @returns A ReadableStream emitting the records as JSON strings separated by the record separator
1479
+ */
1480
+ static createRecordStream(records) {
1481
+ const encoder = new TextEncoder();
1482
+ return new ReadableStream({
1483
+ async start(controller) {
1484
+ try {
1485
+ for await (const record of records) {
1486
+ const json = JSON.stringify(record) + RECORD_SEPARATOR2;
1487
+ controller.enqueue(encoder.encode(json));
1488
+ }
1489
+ controller.close();
1490
+ } catch (err) {
1491
+ controller.error(err);
1492
+ }
1493
+ }
1494
+ });
1495
+ }
1496
+ };
1497
+
1498
+ // src/resources/a2a.ts
1499
+ var A2A = class extends BaseResource {
1500
+ constructor(options, agentId) {
1501
+ super(options);
1502
+ this.agentId = agentId;
1503
+ }
1504
+ /**
1505
+ * Get the agent card with metadata about the agent
1506
+ * @returns Promise containing the agent card information
1507
+ */
1508
+ async getCard() {
1509
+ return this.request(`/.well-known/${this.agentId}/agent.json`);
1510
+ }
1511
+ /**
1512
+ * Send a message to the agent and get a response
1513
+ * @param params - Parameters for the task
1514
+ * @returns Promise containing the task response
1515
+ */
1516
+ async sendMessage(params) {
1517
+ const response = await this.request(`/a2a/${this.agentId}`, {
1518
+ method: "POST",
1519
+ body: {
1520
+ method: "tasks/send",
1521
+ params
1522
+ }
1523
+ });
1524
+ return { task: response.result };
1525
+ }
1526
+ /**
1527
+ * Get the status and result of a task
1528
+ * @param params - Parameters for querying the task
1529
+ * @returns Promise containing the task response
1530
+ */
1531
+ async getTask(params) {
1532
+ const response = await this.request(`/a2a/${this.agentId}`, {
1533
+ method: "POST",
1534
+ body: {
1535
+ method: "tasks/get",
1536
+ params
1537
+ }
1538
+ });
1539
+ return response.result;
1540
+ }
1541
+ /**
1542
+ * Cancel a running task
1543
+ * @param params - Parameters identifying the task to cancel
1544
+ * @returns Promise containing the task response
1545
+ */
1546
+ async cancelTask(params) {
1547
+ return this.request(`/a2a/${this.agentId}`, {
1548
+ method: "POST",
1549
+ body: {
1550
+ method: "tasks/cancel",
1551
+ params
1552
+ }
1553
+ });
1554
+ }
1555
+ /**
1556
+ * Send a message and subscribe to streaming updates (not fully implemented)
1557
+ * @param params - Parameters for the task
1558
+ * @returns Promise containing the task response
1559
+ */
1560
+ async sendAndSubscribe(params) {
1561
+ return this.request(`/a2a/${this.agentId}`, {
1562
+ method: "POST",
1563
+ body: {
1564
+ method: "tasks/sendSubscribe",
1565
+ params
1566
+ },
1567
+ stream: true
1568
+ });
1569
+ }
1570
+ };
1571
+
1572
+ // src/resources/mcp-tool.ts
1573
+ var MCPTool = class extends BaseResource {
1574
+ serverId;
1575
+ toolId;
1576
+ constructor(options, serverId, toolId) {
1577
+ super(options);
1578
+ this.serverId = serverId;
1579
+ this.toolId = toolId;
1580
+ }
1581
+ /**
1582
+ * Retrieves details about this specific tool from the MCP server.
1583
+ * @returns Promise containing the tool's information (name, description, schema).
1584
+ */
1585
+ details() {
1586
+ return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}`);
1587
+ }
1588
+ /**
1589
+ * Executes this specific tool on the MCP server.
1590
+ * @param params - Parameters for tool execution, including data/args and optional runtimeContext.
1591
+ * @returns Promise containing the result of the tool execution.
1592
+ */
1593
+ execute(params) {
1594
+ const body = {};
1595
+ if (params.data !== void 0) body.data = params.data;
1596
+ if (params.runtimeContext !== void 0) {
1597
+ body.runtimeContext = params.runtimeContext;
1598
+ }
1599
+ return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}/execute`, {
1600
+ method: "POST",
1601
+ body: Object.keys(body).length > 0 ? body : void 0
1602
+ });
1603
+ }
1604
+ };
1605
+
1606
+ // src/resources/vNextNetwork.ts
1607
+ var RECORD_SEPARATOR3 = "";
1608
+ var VNextNetwork = class extends BaseResource {
1609
+ constructor(options, networkId) {
1610
+ super(options);
1611
+ this.networkId = networkId;
1612
+ }
1613
+ /**
1614
+ * Retrieves details about the network
1615
+ * @returns Promise containing vNext network details
1616
+ */
1617
+ details() {
1618
+ return this.request(`/api/networks/v-next/${this.networkId}`);
1619
+ }
1620
+ /**
1621
+ * Generates a response from the v-next network
1622
+ * @param params - Generation parameters including message
1623
+ * @returns Promise containing the generated response
1624
+ */
1625
+ generate(params) {
1626
+ return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
1627
+ method: "POST",
1628
+ body: params
1629
+ });
1630
+ }
1631
+ /**
1632
+ * Generates a response from the v-next network using multiple primitives
1633
+ * @param params - Generation parameters including message
1634
+ * @returns Promise containing the generated response
1635
+ */
1636
+ loop(params) {
1637
+ return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
1638
+ method: "POST",
1639
+ body: params
1640
+ });
1641
+ }
1642
+ async *streamProcessor(stream) {
1643
+ const reader = stream.getReader();
1644
+ let doneReading = false;
1645
+ let buffer = "";
1646
+ try {
1647
+ while (!doneReading) {
1648
+ const { done, value } = await reader.read();
1649
+ doneReading = done;
1650
+ if (done && !value) continue;
1651
+ try {
1652
+ const decoded = value ? new TextDecoder().decode(value) : "";
1653
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR3);
1654
+ buffer = chunks.pop() || "";
1655
+ for (const chunk of chunks) {
1656
+ if (chunk) {
1657
+ if (typeof chunk === "string") {
1658
+ try {
1659
+ const parsedChunk = JSON.parse(chunk);
1660
+ yield parsedChunk;
1661
+ } catch {
1662
+ }
1663
+ }
1664
+ }
1665
+ }
1666
+ } catch {
1667
+ }
1668
+ }
1669
+ if (buffer) {
1670
+ try {
1671
+ yield JSON.parse(buffer);
1672
+ } catch {
1673
+ }
1674
+ }
1675
+ } finally {
1676
+ reader.cancel().catch(() => {
1677
+ });
1678
+ }
1679
+ }
1680
+ /**
1681
+ * Streams a response from the v-next network
1682
+ * @param params - Stream parameters including message
1683
+ * @returns Promise containing the results
1684
+ */
1685
+ async stream(params, onRecord) {
1686
+ const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
1687
+ method: "POST",
1688
+ body: params,
1689
+ stream: true
1690
+ });
1691
+ if (!response.ok) {
1692
+ throw new Error(`Failed to stream vNext network: ${response.statusText}`);
1693
+ }
1694
+ if (!response.body) {
1695
+ throw new Error("Response body is null");
1696
+ }
1697
+ for await (const record of this.streamProcessor(response.body)) {
1698
+ if (typeof record === "string") {
1699
+ onRecord(JSON.parse(record));
1700
+ } else {
1701
+ onRecord(record);
1702
+ }
1703
+ }
1704
+ }
1705
+ /**
1706
+ * Streams a response from the v-next network loop
1707
+ * @param params - Stream parameters including message
1708
+ * @returns Promise containing the results
1709
+ */
1710
+ async loopStream(params, onRecord) {
1711
+ const response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
1712
+ method: "POST",
1713
+ body: params,
1714
+ stream: true
1715
+ });
1716
+ if (!response.ok) {
1717
+ throw new Error(`Failed to stream vNext network loop: ${response.statusText}`);
1718
+ }
1719
+ if (!response.body) {
1720
+ throw new Error("Response body is null");
1721
+ }
1722
+ for await (const record of this.streamProcessor(response.body)) {
1723
+ if (typeof record === "string") {
1724
+ onRecord(JSON.parse(record));
1725
+ } else {
1726
+ onRecord(record);
1727
+ }
1728
+ }
1729
+ }
1730
+ };
1731
+
1732
+ // src/resources/network-memory-thread.ts
1733
+ var NetworkMemoryThread = class extends BaseResource {
1734
+ constructor(options, threadId, networkId) {
1735
+ super(options);
1736
+ this.threadId = threadId;
1737
+ this.networkId = networkId;
1738
+ }
1739
+ /**
1740
+ * Retrieves the memory thread details
1741
+ * @returns Promise containing thread details including title and metadata
1742
+ */
1743
+ get() {
1744
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
1745
+ }
1746
+ /**
1747
+ * Updates the memory thread properties
1748
+ * @param params - Update parameters including title and metadata
1749
+ * @returns Promise containing updated thread details
1750
+ */
1751
+ update(params) {
1752
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1753
+ method: "PATCH",
1754
+ body: params
1755
+ });
1756
+ }
1757
+ /**
1758
+ * Deletes the memory thread
1759
+ * @returns Promise containing deletion result
1760
+ */
1761
+ delete() {
1762
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1763
+ method: "DELETE"
1764
+ });
1765
+ }
1766
+ /**
1767
+ * Retrieves messages associated with the thread
1768
+ * @param params - Optional parameters including limit for number of messages to retrieve
1769
+ * @returns Promise containing thread messages and UI messages
1770
+ */
1771
+ getMessages(params) {
1772
+ const query = new URLSearchParams({
1773
+ networkId: this.networkId,
1774
+ ...params?.limit ? { limit: params.limit.toString() } : {}
1775
+ });
1776
+ return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
1777
+ }
1778
+ };
1779
+
1780
+ // src/client.ts
1781
+ var MastraClient = class extends BaseResource {
1782
+ constructor(options) {
1783
+ super(options);
1784
+ }
1785
+ /**
1786
+ * Retrieves all available agents
1787
+ * @returns Promise containing map of agent IDs to agent details
1788
+ */
1789
+ getAgents() {
1790
+ return this.request("/api/agents");
1791
+ }
1792
+ async getAGUI({ resourceId }) {
1793
+ const agents = await this.getAgents();
1794
+ return Object.entries(agents).reduce(
1795
+ (acc, [agentId]) => {
1796
+ const agent = this.getAgent(agentId);
1797
+ acc[agentId] = new AGUIAdapter({
1798
+ agentId,
1799
+ agent,
1800
+ resourceId
1801
+ });
1802
+ return acc;
1803
+ },
1804
+ {}
1805
+ );
1806
+ }
1807
+ /**
1808
+ * Gets an agent instance by ID
1809
+ * @param agentId - ID of the agent to retrieve
1810
+ * @returns Agent instance
1811
+ */
1812
+ getAgent(agentId) {
1813
+ return new Agent(this.options, agentId);
1814
+ }
1815
+ /**
1816
+ * Retrieves memory threads for a resource
1817
+ * @param params - Parameters containing the resource ID
1818
+ * @returns Promise containing array of memory threads
1819
+ */
1820
+ getMemoryThreads(params) {
1821
+ return this.request(`/api/memory/threads?resourceid=${params.resourceId}&agentId=${params.agentId}`);
1822
+ }
1823
+ /**
1824
+ * Creates a new memory thread
1825
+ * @param params - Parameters for creating the memory thread
1826
+ * @returns Promise containing the created memory thread
1827
+ */
1828
+ createMemoryThread(params) {
1829
+ return this.request(`/api/memory/threads?agentId=${params.agentId}`, { method: "POST", body: params });
1830
+ }
1831
+ /**
1832
+ * Gets a memory thread instance by ID
1833
+ * @param threadId - ID of the memory thread to retrieve
1834
+ * @returns MemoryThread instance
1835
+ */
1836
+ getMemoryThread(threadId, agentId) {
1837
+ return new MemoryThread(this.options, threadId, agentId);
1838
+ }
1839
+ /**
1840
+ * Saves messages to memory
1841
+ * @param params - Parameters containing messages to save
1842
+ * @returns Promise containing the saved messages
599
1843
  */
600
1844
  saveMessageToMemory(params) {
601
1845
  return this.request(`/api/memory/save-messages?agentId=${params.agentId}`, {
@@ -610,6 +1854,48 @@ var MastraClient = class extends BaseResource {
610
1854
  getMemoryStatus(agentId) {
611
1855
  return this.request(`/api/memory/status?agentId=${agentId}`);
612
1856
  }
1857
+ /**
1858
+ * Retrieves memory threads for a resource
1859
+ * @param params - Parameters containing the resource ID
1860
+ * @returns Promise containing array of memory threads
1861
+ */
1862
+ getNetworkMemoryThreads(params) {
1863
+ return this.request(`/api/memory/network/threads?resourceid=${params.resourceId}&networkId=${params.networkId}`);
1864
+ }
1865
+ /**
1866
+ * Creates a new memory thread
1867
+ * @param params - Parameters for creating the memory thread
1868
+ * @returns Promise containing the created memory thread
1869
+ */
1870
+ createNetworkMemoryThread(params) {
1871
+ return this.request(`/api/memory/network/threads?networkId=${params.networkId}`, { method: "POST", body: params });
1872
+ }
1873
+ /**
1874
+ * Gets a memory thread instance by ID
1875
+ * @param threadId - ID of the memory thread to retrieve
1876
+ * @returns MemoryThread instance
1877
+ */
1878
+ getNetworkMemoryThread(threadId, networkId) {
1879
+ return new NetworkMemoryThread(this.options, threadId, networkId);
1880
+ }
1881
+ /**
1882
+ * Saves messages to memory
1883
+ * @param params - Parameters containing messages to save
1884
+ * @returns Promise containing the saved messages
1885
+ */
1886
+ saveNetworkMessageToMemory(params) {
1887
+ return this.request(`/api/memory/network/save-messages?networkId=${params.networkId}`, {
1888
+ method: "POST",
1889
+ body: params
1890
+ });
1891
+ }
1892
+ /**
1893
+ * Gets the status of the memory system
1894
+ * @returns Promise containing memory system status
1895
+ */
1896
+ getNetworkMemoryStatus(networkId) {
1897
+ return this.request(`/api/memory/network/status?networkId=${networkId}`);
1898
+ }
613
1899
  /**
614
1900
  * Retrieves all available tools
615
1901
  * @returns Promise containing map of tool IDs to tool details
@@ -623,7 +1909,22 @@ var MastraClient = class extends BaseResource {
623
1909
  * @returns Tool instance
624
1910
  */
625
1911
  getTool(toolId) {
626
- return new Tool(this.options, toolId);
1912
+ return new Tool2(this.options, toolId);
1913
+ }
1914
+ /**
1915
+ * Retrieves all available legacy workflows
1916
+ * @returns Promise containing map of legacy workflow IDs to legacy workflow details
1917
+ */
1918
+ getLegacyWorkflows() {
1919
+ return this.request("/api/workflows/legacy");
1920
+ }
1921
+ /**
1922
+ * Gets a legacy workflow instance by ID
1923
+ * @param workflowId - ID of the legacy workflow to retrieve
1924
+ * @returns Legacy Workflow instance
1925
+ */
1926
+ getLegacyWorkflow(workflowId) {
1927
+ return new LegacyWorkflow(this.options, workflowId);
627
1928
  }
628
1929
  /**
629
1930
  * Retrieves all available workflows
@@ -654,7 +1955,41 @@ var MastraClient = class extends BaseResource {
654
1955
  * @returns Promise containing array of log messages
655
1956
  */
656
1957
  getLogs(params) {
657
- return this.request(`/api/logs?transportId=${params.transportId}`);
1958
+ const { transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
1959
+ const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
1960
+ const searchParams = new URLSearchParams();
1961
+ if (transportId) {
1962
+ searchParams.set("transportId", transportId);
1963
+ }
1964
+ if (fromDate) {
1965
+ searchParams.set("fromDate", fromDate.toISOString());
1966
+ }
1967
+ if (toDate) {
1968
+ searchParams.set("toDate", toDate.toISOString());
1969
+ }
1970
+ if (logLevel) {
1971
+ searchParams.set("logLevel", logLevel);
1972
+ }
1973
+ if (page) {
1974
+ searchParams.set("page", String(page));
1975
+ }
1976
+ if (perPage) {
1977
+ searchParams.set("perPage", String(perPage));
1978
+ }
1979
+ if (_filters) {
1980
+ if (Array.isArray(_filters)) {
1981
+ for (const filter of _filters) {
1982
+ searchParams.append("filters", filter);
1983
+ }
1984
+ } else {
1985
+ searchParams.set("filters", _filters);
1986
+ }
1987
+ }
1988
+ if (searchParams.size) {
1989
+ return this.request(`/api/logs?${searchParams}`);
1990
+ } else {
1991
+ return this.request(`/api/logs`);
1992
+ }
658
1993
  }
659
1994
  /**
660
1995
  * Gets logs for a specific run
@@ -662,7 +1997,44 @@ var MastraClient = class extends BaseResource {
662
1997
  * @returns Promise containing array of log messages
663
1998
  */
664
1999
  getLogForRun(params) {
665
- return this.request(`/api/logs/${params.runId}?transportId=${params.transportId}`);
2000
+ const { runId, transportId, fromDate, toDate, logLevel, filters, page, perPage } = params;
2001
+ const _filters = filters ? Object.entries(filters).map(([key, value]) => `${key}:${value}`) : [];
2002
+ const searchParams = new URLSearchParams();
2003
+ if (runId) {
2004
+ searchParams.set("runId", runId);
2005
+ }
2006
+ if (transportId) {
2007
+ searchParams.set("transportId", transportId);
2008
+ }
2009
+ if (fromDate) {
2010
+ searchParams.set("fromDate", fromDate.toISOString());
2011
+ }
2012
+ if (toDate) {
2013
+ searchParams.set("toDate", toDate.toISOString());
2014
+ }
2015
+ if (logLevel) {
2016
+ searchParams.set("logLevel", logLevel);
2017
+ }
2018
+ if (page) {
2019
+ searchParams.set("page", String(page));
2020
+ }
2021
+ if (perPage) {
2022
+ searchParams.set("perPage", String(perPage));
2023
+ }
2024
+ if (_filters) {
2025
+ if (Array.isArray(_filters)) {
2026
+ for (const filter of _filters) {
2027
+ searchParams.append("filters", filter);
2028
+ }
2029
+ } else {
2030
+ searchParams.set("filters", _filters);
2031
+ }
2032
+ }
2033
+ if (searchParams.size) {
2034
+ return this.request(`/api/logs/${runId}?${searchParams}`);
2035
+ } else {
2036
+ return this.request(`/api/logs/${runId}`);
2037
+ }
666
2038
  }
667
2039
  /**
668
2040
  * List of all log transports
@@ -677,7 +2049,7 @@ var MastraClient = class extends BaseResource {
677
2049
  * @returns Promise containing telemetry data
678
2050
  */
679
2051
  getTelemetry(params) {
680
- const { name, scope, page, perPage, attribute } = params || {};
2052
+ const { name, scope, page, perPage, attribute, fromDate, toDate } = params || {};
681
2053
  const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
682
2054
  const searchParams = new URLSearchParams();
683
2055
  if (name) {
@@ -701,6 +2073,12 @@ var MastraClient = class extends BaseResource {
701
2073
  searchParams.set("attribute", _attribute);
702
2074
  }
703
2075
  }
2076
+ if (fromDate) {
2077
+ searchParams.set("fromDate", fromDate.toISOString());
2078
+ }
2079
+ if (toDate) {
2080
+ searchParams.set("toDate", toDate.toISOString());
2081
+ }
704
2082
  if (searchParams.size) {
705
2083
  return this.request(`/api/telemetry?${searchParams}`);
706
2084
  } else {
@@ -714,6 +2092,13 @@ var MastraClient = class extends BaseResource {
714
2092
  getNetworks() {
715
2093
  return this.request("/api/networks");
716
2094
  }
2095
+ /**
2096
+ * Retrieves all available vNext networks
2097
+ * @returns Promise containing map of vNext network IDs to vNext network details
2098
+ */
2099
+ getVNextNetworks() {
2100
+ return this.request("/api/networks/v-next");
2101
+ }
717
2102
  /**
718
2103
  * Gets a network instance by ID
719
2104
  * @param networkId - ID of the network to retrieve
@@ -722,6 +2107,70 @@ var MastraClient = class extends BaseResource {
722
2107
  getNetwork(networkId) {
723
2108
  return new Network(this.options, networkId);
724
2109
  }
2110
+ /**
2111
+ * Gets a vNext network instance by ID
2112
+ * @param networkId - ID of the vNext network to retrieve
2113
+ * @returns vNext Network instance
2114
+ */
2115
+ getVNextNetwork(networkId) {
2116
+ return new VNextNetwork(this.options, networkId);
2117
+ }
2118
+ /**
2119
+ * Retrieves a list of available MCP servers.
2120
+ * @param params - Optional parameters for pagination (limit, offset).
2121
+ * @returns Promise containing the list of MCP servers and pagination info.
2122
+ */
2123
+ getMcpServers(params) {
2124
+ const searchParams = new URLSearchParams();
2125
+ if (params?.limit !== void 0) {
2126
+ searchParams.set("limit", String(params.limit));
2127
+ }
2128
+ if (params?.offset !== void 0) {
2129
+ searchParams.set("offset", String(params.offset));
2130
+ }
2131
+ const queryString = searchParams.toString();
2132
+ return this.request(`/api/mcp/v0/servers${queryString ? `?${queryString}` : ""}`);
2133
+ }
2134
+ /**
2135
+ * Retrieves detailed information for a specific MCP server.
2136
+ * @param serverId - The ID of the MCP server to retrieve.
2137
+ * @param params - Optional parameters, e.g., specific version.
2138
+ * @returns Promise containing the detailed MCP server information.
2139
+ */
2140
+ getMcpServerDetails(serverId, params) {
2141
+ const searchParams = new URLSearchParams();
2142
+ if (params?.version) {
2143
+ searchParams.set("version", params.version);
2144
+ }
2145
+ const queryString = searchParams.toString();
2146
+ return this.request(`/api/mcp/v0/servers/${serverId}${queryString ? `?${queryString}` : ""}`);
2147
+ }
2148
+ /**
2149
+ * Retrieves a list of tools for a specific MCP server.
2150
+ * @param serverId - The ID of the MCP server.
2151
+ * @returns Promise containing the list of tools.
2152
+ */
2153
+ getMcpServerTools(serverId) {
2154
+ return this.request(`/api/mcp/${serverId}/tools`);
2155
+ }
2156
+ /**
2157
+ * Gets an MCPTool resource instance for a specific tool on an MCP server.
2158
+ * This instance can then be used to fetch details or execute the tool.
2159
+ * @param serverId - The ID of the MCP server.
2160
+ * @param toolId - The ID of the tool.
2161
+ * @returns MCPTool instance.
2162
+ */
2163
+ getMcpServerTool(serverId, toolId) {
2164
+ return new MCPTool(this.options, serverId, toolId);
2165
+ }
2166
+ /**
2167
+ * Gets an A2A client for interacting with an agent via the A2A protocol
2168
+ * @param agentId - ID of the agent to interact with
2169
+ * @returns A2A client instance
2170
+ */
2171
+ getA2A(agentId) {
2172
+ return new A2A(this.options, agentId);
2173
+ }
725
2174
  };
726
2175
 
727
2176
  export { MastraClient };