@mastra/client-js 0.0.0-fix-memory-xxhash-20250409202110 → 0.0.0-generate-message-id-20250512171942

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,200 @@
1
- import { ZodSchema } from 'zod';
2
- import { zodToJsonSchema } from 'zod-to-json-schema';
1
+ import { AbstractAgent, EventType } from '@ag-ui/client';
2
+ import { Observable } from 'rxjs';
3
3
  import { processDataStream } from '@ai-sdk/ui-utils';
4
+ import { ZodSchema } from 'zod';
5
+ import originalZodToJsonSchema from 'zod-to-json-schema';
4
6
 
5
- // src/resources/agent.ts
7
+ // src/adapters/agui.ts
8
+ var AGUIAdapter = class extends AbstractAgent {
9
+ agent;
10
+ resourceId;
11
+ constructor({ agent, agentId, resourceId, ...rest }) {
12
+ super({
13
+ agentId,
14
+ ...rest
15
+ });
16
+ this.agent = agent;
17
+ this.resourceId = resourceId;
18
+ }
19
+ run(input) {
20
+ return new Observable((subscriber) => {
21
+ const convertedMessages = convertMessagesToMastraMessages(input.messages);
22
+ subscriber.next({
23
+ type: EventType.RUN_STARTED,
24
+ threadId: input.threadId,
25
+ runId: input.runId
26
+ });
27
+ this.agent.stream({
28
+ threadId: input.threadId,
29
+ resourceId: this.resourceId ?? "",
30
+ runId: input.runId,
31
+ messages: convertedMessages,
32
+ clientTools: input.tools.reduce(
33
+ (acc, tool) => {
34
+ acc[tool.name] = {
35
+ id: tool.name,
36
+ description: tool.description,
37
+ inputSchema: tool.parameters
38
+ };
39
+ return acc;
40
+ },
41
+ {}
42
+ )
43
+ }).then((response) => {
44
+ let currentMessageId = void 0;
45
+ let isInTextMessage = false;
46
+ return response.processDataStream({
47
+ onTextPart: (text) => {
48
+ if (currentMessageId === void 0) {
49
+ currentMessageId = generateUUID();
50
+ const message2 = {
51
+ type: EventType.TEXT_MESSAGE_START,
52
+ messageId: currentMessageId,
53
+ role: "assistant"
54
+ };
55
+ subscriber.next(message2);
56
+ isInTextMessage = true;
57
+ }
58
+ const message = {
59
+ type: EventType.TEXT_MESSAGE_CONTENT,
60
+ messageId: currentMessageId,
61
+ delta: text
62
+ };
63
+ subscriber.next(message);
64
+ },
65
+ onFinishMessagePart: () => {
66
+ if (currentMessageId !== void 0) {
67
+ const message = {
68
+ type: EventType.TEXT_MESSAGE_END,
69
+ messageId: currentMessageId
70
+ };
71
+ subscriber.next(message);
72
+ isInTextMessage = false;
73
+ }
74
+ subscriber.next({
75
+ type: EventType.RUN_FINISHED,
76
+ threadId: input.threadId,
77
+ runId: input.runId
78
+ });
79
+ subscriber.complete();
80
+ },
81
+ onToolCallPart(streamPart) {
82
+ const parentMessageId = currentMessageId || generateUUID();
83
+ if (isInTextMessage) {
84
+ const message = {
85
+ type: EventType.TEXT_MESSAGE_END,
86
+ messageId: parentMessageId
87
+ };
88
+ subscriber.next(message);
89
+ isInTextMessage = false;
90
+ }
91
+ subscriber.next({
92
+ type: EventType.TOOL_CALL_START,
93
+ toolCallId: streamPart.toolCallId,
94
+ toolCallName: streamPart.toolName,
95
+ parentMessageId
96
+ });
97
+ subscriber.next({
98
+ type: EventType.TOOL_CALL_ARGS,
99
+ toolCallId: streamPart.toolCallId,
100
+ delta: JSON.stringify(streamPart.args),
101
+ parentMessageId
102
+ });
103
+ subscriber.next({
104
+ type: EventType.TOOL_CALL_END,
105
+ toolCallId: streamPart.toolCallId,
106
+ parentMessageId
107
+ });
108
+ }
109
+ });
110
+ }).catch((error) => {
111
+ console.error("error", error);
112
+ subscriber.error(error);
113
+ });
114
+ return () => {
115
+ };
116
+ });
117
+ }
118
+ };
119
+ function generateUUID() {
120
+ if (typeof crypto !== "undefined") {
121
+ if (typeof crypto.randomUUID === "function") {
122
+ return crypto.randomUUID();
123
+ }
124
+ if (typeof crypto.getRandomValues === "function") {
125
+ const buffer = new Uint8Array(16);
126
+ crypto.getRandomValues(buffer);
127
+ buffer[6] = buffer[6] & 15 | 64;
128
+ buffer[8] = buffer[8] & 63 | 128;
129
+ let hex = "";
130
+ for (let i = 0; i < 16; i++) {
131
+ hex += buffer[i].toString(16).padStart(2, "0");
132
+ if (i === 3 || i === 5 || i === 7 || i === 9) hex += "-";
133
+ }
134
+ return hex;
135
+ }
136
+ }
137
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
138
+ const r = Math.random() * 16 | 0;
139
+ const v = c === "x" ? r : r & 3 | 8;
140
+ return v.toString(16);
141
+ });
142
+ }
143
+ function convertMessagesToMastraMessages(messages) {
144
+ const result = [];
145
+ for (const message of messages) {
146
+ if (message.role === "assistant") {
147
+ const parts = message.content ? [{ type: "text", text: message.content }] : [];
148
+ for (const toolCall of message.toolCalls ?? []) {
149
+ parts.push({
150
+ type: "tool-call",
151
+ toolCallId: toolCall.id,
152
+ toolName: toolCall.function.name,
153
+ args: JSON.parse(toolCall.function.arguments)
154
+ });
155
+ }
156
+ result.push({
157
+ role: "assistant",
158
+ content: parts
159
+ });
160
+ if (message.toolCalls?.length) {
161
+ result.push({
162
+ role: "tool",
163
+ content: message.toolCalls.map((toolCall) => ({
164
+ type: "tool-result",
165
+ toolCallId: toolCall.id,
166
+ toolName: toolCall.function.name,
167
+ result: JSON.parse(toolCall.function.arguments)
168
+ }))
169
+ });
170
+ }
171
+ } else if (message.role === "user") {
172
+ result.push({
173
+ role: "user",
174
+ content: message.content || ""
175
+ });
176
+ } else if (message.role === "tool") {
177
+ result.push({
178
+ role: "tool",
179
+ content: [
180
+ {
181
+ type: "tool-result",
182
+ toolCallId: message.toolCallId,
183
+ toolName: "unknown",
184
+ result: message.content
185
+ }
186
+ ]
187
+ });
188
+ }
189
+ }
190
+ return result;
191
+ }
192
+ function zodToJsonSchema(zodSchema) {
193
+ if (!(zodSchema instanceof ZodSchema)) {
194
+ return zodSchema;
195
+ }
196
+ return originalZodToJsonSchema(zodSchema, { $refStrategy: "none" });
197
+ }
6
198
 
7
199
  // src/resources/base.ts
8
200
  var BaseResource = class {
@@ -133,8 +325,9 @@ var Agent = class extends BaseResource {
133
325
  generate(params) {
134
326
  const processedParams = {
135
327
  ...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
328
+ output: zodToJsonSchema(params.output),
329
+ experimental_output: zodToJsonSchema(params.experimental_output),
330
+ runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
138
331
  };
139
332
  return this.request(`/api/agents/${this.agentId}/generate`, {
140
333
  method: "POST",
@@ -149,8 +342,9 @@ var Agent = class extends BaseResource {
149
342
  async stream(params) {
150
343
  const processedParams = {
151
344
  ...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
345
+ output: zodToJsonSchema(params.output),
346
+ experimental_output: zodToJsonSchema(params.experimental_output),
347
+ runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
154
348
  };
155
349
  const response = await this.request(`/api/agents/${this.agentId}/stream`, {
156
350
  method: "POST",
@@ -176,6 +370,22 @@ var Agent = class extends BaseResource {
176
370
  getTool(toolId) {
177
371
  return this.request(`/api/agents/${this.agentId}/tools/${toolId}`);
178
372
  }
373
+ /**
374
+ * Executes a tool for the agent
375
+ * @param toolId - ID of the tool to execute
376
+ * @param params - Parameters required for tool execution
377
+ * @returns Promise containing the tool execution results
378
+ */
379
+ executeTool(toolId, params) {
380
+ const body = {
381
+ data: params.data,
382
+ runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
383
+ };
384
+ return this.request(`/api/agents/${this.agentId}/tools/${toolId}/execute`, {
385
+ method: "POST",
386
+ body
387
+ });
388
+ }
179
389
  /**
180
390
  * Retrieves evaluation results for the agent
181
391
  * @returns Promise containing agent evaluations
@@ -211,8 +421,8 @@ var Network = class extends BaseResource {
211
421
  generate(params) {
212
422
  const processedParams = {
213
423
  ...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
424
+ output: zodToJsonSchema(params.output),
425
+ experimental_output: zodToJsonSchema(params.experimental_output)
216
426
  };
217
427
  return this.request(`/api/networks/${this.networkId}/generate`, {
218
428
  method: "POST",
@@ -227,8 +437,8 @@ var Network = class extends BaseResource {
227
437
  async stream(params) {
228
438
  const processedParams = {
229
439
  ...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
440
+ output: zodToJsonSchema(params.output),
441
+ experimental_output: zodToJsonSchema(params.experimental_output)
232
442
  };
233
443
  const response = await this.request(`/api/networks/${this.networkId}/stream`, {
234
444
  method: "POST",
@@ -371,6 +581,34 @@ var Workflow = class extends BaseResource {
371
581
  details() {
372
582
  return this.request(`/api/workflows/${this.workflowId}`);
373
583
  }
584
+ /**
585
+ * Retrieves all runs for a workflow
586
+ * @param params - Parameters for filtering runs
587
+ * @returns Promise containing workflow runs array
588
+ */
589
+ runs(params) {
590
+ const searchParams = new URLSearchParams();
591
+ if (params?.fromDate) {
592
+ searchParams.set("fromDate", params.fromDate.toISOString());
593
+ }
594
+ if (params?.toDate) {
595
+ searchParams.set("toDate", params.toDate.toISOString());
596
+ }
597
+ if (params?.limit) {
598
+ searchParams.set("limit", String(params.limit));
599
+ }
600
+ if (params?.offset) {
601
+ searchParams.set("offset", String(params.offset));
602
+ }
603
+ if (params?.resourceId) {
604
+ searchParams.set("resourceId", params.resourceId);
605
+ }
606
+ if (searchParams.size) {
607
+ return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
608
+ } else {
609
+ return this.request(`/api/workflows/${this.workflowId}/runs`);
610
+ }
611
+ }
374
612
  /**
375
613
  * @deprecated Use `startAsync` instead
376
614
  * Executes the workflow with the provided parameters
@@ -487,7 +725,7 @@ var Workflow = class extends BaseResource {
487
725
  }
488
726
  }
489
727
  }
490
- } catch (error) {
728
+ } catch {
491
729
  }
492
730
  }
493
731
  if (buffer) {
@@ -541,9 +779,277 @@ var Tool = class extends BaseResource {
541
779
  * @returns Promise containing the tool execution results
542
780
  */
543
781
  execute(params) {
544
- return this.request(`/api/tools/${this.toolId}/execute`, {
782
+ const url = new URLSearchParams();
783
+ if (params.runId) {
784
+ url.set("runId", params.runId);
785
+ }
786
+ const body = {
787
+ data: params.data,
788
+ runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
789
+ };
790
+ return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
545
791
  method: "POST",
546
- body: params
792
+ body
793
+ });
794
+ }
795
+ };
796
+ var RECORD_SEPARATOR2 = "";
797
+ var VNextWorkflow = class extends BaseResource {
798
+ constructor(options, workflowId) {
799
+ super(options);
800
+ this.workflowId = workflowId;
801
+ }
802
+ /**
803
+ * Creates an async generator that processes a readable stream and yields vNext workflow records
804
+ * separated by the Record Separator character (\x1E)
805
+ *
806
+ * @param stream - The readable stream to process
807
+ * @returns An async generator that yields parsed records
808
+ */
809
+ async *streamProcessor(stream) {
810
+ const reader = stream.getReader();
811
+ let doneReading = false;
812
+ let buffer = "";
813
+ try {
814
+ while (!doneReading) {
815
+ const { done, value } = await reader.read();
816
+ doneReading = done;
817
+ if (done && !value) continue;
818
+ try {
819
+ const decoded = value ? new TextDecoder().decode(value) : "";
820
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
821
+ buffer = chunks.pop() || "";
822
+ for (const chunk of chunks) {
823
+ if (chunk) {
824
+ if (typeof chunk === "string") {
825
+ try {
826
+ const parsedChunk = JSON.parse(chunk);
827
+ yield parsedChunk;
828
+ } catch {
829
+ }
830
+ }
831
+ }
832
+ }
833
+ } catch {
834
+ }
835
+ }
836
+ if (buffer) {
837
+ try {
838
+ yield JSON.parse(buffer);
839
+ } catch {
840
+ }
841
+ }
842
+ } finally {
843
+ reader.cancel().catch(() => {
844
+ });
845
+ }
846
+ }
847
+ /**
848
+ * Retrieves details about the vNext workflow
849
+ * @returns Promise containing vNext workflow details including steps and graphs
850
+ */
851
+ details() {
852
+ return this.request(`/api/workflows/v-next/${this.workflowId}`);
853
+ }
854
+ /**
855
+ * Retrieves all runs for a vNext workflow
856
+ * @param params - Parameters for filtering runs
857
+ * @returns Promise containing vNext workflow runs array
858
+ */
859
+ runs(params) {
860
+ const searchParams = new URLSearchParams();
861
+ if (params?.fromDate) {
862
+ searchParams.set("fromDate", params.fromDate.toISOString());
863
+ }
864
+ if (params?.toDate) {
865
+ searchParams.set("toDate", params.toDate.toISOString());
866
+ }
867
+ if (params?.limit) {
868
+ searchParams.set("limit", String(params.limit));
869
+ }
870
+ if (params?.offset) {
871
+ searchParams.set("offset", String(params.offset));
872
+ }
873
+ if (params?.resourceId) {
874
+ searchParams.set("resourceId", params.resourceId);
875
+ }
876
+ if (searchParams.size) {
877
+ return this.request(`/api/workflows/v-next/${this.workflowId}/runs?${searchParams}`);
878
+ } else {
879
+ return this.request(`/api/workflows/v-next/${this.workflowId}/runs`);
880
+ }
881
+ }
882
+ /**
883
+ * Creates a new vNext workflow run
884
+ * @param params - Optional object containing the optional runId
885
+ * @returns Promise containing the runId of the created run
886
+ */
887
+ createRun(params) {
888
+ const searchParams = new URLSearchParams();
889
+ if (!!params?.runId) {
890
+ searchParams.set("runId", params.runId);
891
+ }
892
+ return this.request(`/api/workflows/v-next/${this.workflowId}/create-run?${searchParams.toString()}`, {
893
+ method: "POST"
894
+ });
895
+ }
896
+ /**
897
+ * Starts a vNext workflow run synchronously without waiting for the workflow to complete
898
+ * @param params - Object containing the runId, inputData and runtimeContext
899
+ * @returns Promise containing success message
900
+ */
901
+ start(params) {
902
+ const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
903
+ return this.request(`/api/workflows/v-next/${this.workflowId}/start?runId=${params.runId}`, {
904
+ method: "POST",
905
+ body: { inputData: params?.inputData, runtimeContext }
906
+ });
907
+ }
908
+ /**
909
+ * Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
910
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
911
+ * @returns Promise containing success message
912
+ */
913
+ resume({
914
+ step,
915
+ runId,
916
+ resumeData,
917
+ ...rest
918
+ }) {
919
+ const runtimeContext = rest.runtimeContext ? Object.fromEntries(rest.runtimeContext.entries()) : void 0;
920
+ return this.request(`/api/workflows/v-next/${this.workflowId}/resume?runId=${runId}`, {
921
+ method: "POST",
922
+ stream: true,
923
+ body: {
924
+ step,
925
+ resumeData,
926
+ runtimeContext
927
+ }
928
+ });
929
+ }
930
+ /**
931
+ * Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
932
+ * @param params - Object containing the optional runId, inputData and runtimeContext
933
+ * @returns Promise containing the vNext workflow execution results
934
+ */
935
+ startAsync(params) {
936
+ const searchParams = new URLSearchParams();
937
+ if (!!params?.runId) {
938
+ searchParams.set("runId", params.runId);
939
+ }
940
+ const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
941
+ return this.request(`/api/workflows/v-next/${this.workflowId}/start-async?${searchParams.toString()}`, {
942
+ method: "POST",
943
+ body: { inputData: params.inputData, runtimeContext }
944
+ });
945
+ }
946
+ /**
947
+ * Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
948
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
949
+ * @returns Promise containing the vNext workflow resume results
950
+ */
951
+ resumeAsync(params) {
952
+ const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
953
+ return this.request(`/api/workflows/v-next/${this.workflowId}/resume-async?runId=${params.runId}`, {
954
+ method: "POST",
955
+ body: {
956
+ step: params.step,
957
+ resumeData: params.resumeData,
958
+ runtimeContext
959
+ }
960
+ });
961
+ }
962
+ /**
963
+ * Watches vNext workflow transitions in real-time
964
+ * @param runId - Optional run ID to filter the watch stream
965
+ * @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
966
+ */
967
+ async watch({ runId }, onRecord) {
968
+ const response = await this.request(`/api/workflows/v-next/${this.workflowId}/watch?runId=${runId}`, {
969
+ stream: true
970
+ });
971
+ if (!response.ok) {
972
+ throw new Error(`Failed to watch vNext workflow: ${response.statusText}`);
973
+ }
974
+ if (!response.body) {
975
+ throw new Error("Response body is null");
976
+ }
977
+ for await (const record of this.streamProcessor(response.body)) {
978
+ onRecord(record);
979
+ }
980
+ }
981
+ };
982
+
983
+ // src/resources/a2a.ts
984
+ var A2A = class extends BaseResource {
985
+ constructor(options, agentId) {
986
+ super(options);
987
+ this.agentId = agentId;
988
+ }
989
+ /**
990
+ * Get the agent card with metadata about the agent
991
+ * @returns Promise containing the agent card information
992
+ */
993
+ async getCard() {
994
+ return this.request(`/.well-known/${this.agentId}/agent.json`);
995
+ }
996
+ /**
997
+ * Send a message to the agent and get a response
998
+ * @param params - Parameters for the task
999
+ * @returns Promise containing the task response
1000
+ */
1001
+ async sendMessage(params) {
1002
+ const response = await this.request(`/a2a/${this.agentId}`, {
1003
+ method: "POST",
1004
+ body: {
1005
+ method: "tasks/send",
1006
+ params
1007
+ }
1008
+ });
1009
+ return { task: response.result };
1010
+ }
1011
+ /**
1012
+ * Get the status and result of a task
1013
+ * @param params - Parameters for querying the task
1014
+ * @returns Promise containing the task response
1015
+ */
1016
+ async getTask(params) {
1017
+ const response = await this.request(`/a2a/${this.agentId}`, {
1018
+ method: "POST",
1019
+ body: {
1020
+ method: "tasks/get",
1021
+ params
1022
+ }
1023
+ });
1024
+ return response.result;
1025
+ }
1026
+ /**
1027
+ * Cancel a running task
1028
+ * @param params - Parameters identifying the task to cancel
1029
+ * @returns Promise containing the task response
1030
+ */
1031
+ async cancelTask(params) {
1032
+ return this.request(`/a2a/${this.agentId}`, {
1033
+ method: "POST",
1034
+ body: {
1035
+ method: "tasks/cancel",
1036
+ params
1037
+ }
1038
+ });
1039
+ }
1040
+ /**
1041
+ * Send a message and subscribe to streaming updates (not fully implemented)
1042
+ * @param params - Parameters for the task
1043
+ * @returns Promise containing the task response
1044
+ */
1045
+ async sendAndSubscribe(params) {
1046
+ return this.request(`/a2a/${this.agentId}`, {
1047
+ method: "POST",
1048
+ body: {
1049
+ method: "tasks/sendSubscribe",
1050
+ params
1051
+ },
1052
+ stream: true
547
1053
  });
548
1054
  }
549
1055
  };
@@ -560,6 +1066,21 @@ var MastraClient = class extends BaseResource {
560
1066
  getAgents() {
561
1067
  return this.request("/api/agents");
562
1068
  }
1069
+ async getAGUI({ resourceId }) {
1070
+ const agents = await this.getAgents();
1071
+ return Object.entries(agents).reduce(
1072
+ (acc, [agentId]) => {
1073
+ const agent = this.getAgent(agentId);
1074
+ acc[agentId] = new AGUIAdapter({
1075
+ agentId,
1076
+ agent,
1077
+ resourceId
1078
+ });
1079
+ return acc;
1080
+ },
1081
+ {}
1082
+ );
1083
+ }
563
1084
  /**
564
1085
  * Gets an agent instance by ID
565
1086
  * @param agentId - ID of the agent to retrieve
@@ -640,6 +1161,21 @@ var MastraClient = class extends BaseResource {
640
1161
  getWorkflow(workflowId) {
641
1162
  return new Workflow(this.options, workflowId);
642
1163
  }
1164
+ /**
1165
+ * Retrieves all available vNext workflows
1166
+ * @returns Promise containing map of vNext workflow IDs to vNext workflow details
1167
+ */
1168
+ getVNextWorkflows() {
1169
+ return this.request("/api/workflows/v-next");
1170
+ }
1171
+ /**
1172
+ * Gets a vNext workflow instance by ID
1173
+ * @param workflowId - ID of the vNext workflow to retrieve
1174
+ * @returns vNext Workflow instance
1175
+ */
1176
+ getVNextWorkflow(workflowId) {
1177
+ return new VNextWorkflow(this.options, workflowId);
1178
+ }
643
1179
  /**
644
1180
  * Gets a vector instance by name
645
1181
  * @param vectorName - Name of the vector to retrieve
@@ -677,7 +1213,7 @@ var MastraClient = class extends BaseResource {
677
1213
  * @returns Promise containing telemetry data
678
1214
  */
679
1215
  getTelemetry(params) {
680
- const { name, scope, page, perPage, attribute } = params || {};
1216
+ const { name, scope, page, perPage, attribute, fromDate, toDate } = params || {};
681
1217
  const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
682
1218
  const searchParams = new URLSearchParams();
683
1219
  if (name) {
@@ -701,6 +1237,12 @@ var MastraClient = class extends BaseResource {
701
1237
  searchParams.set("attribute", _attribute);
702
1238
  }
703
1239
  }
1240
+ if (fromDate) {
1241
+ searchParams.set("fromDate", fromDate.toISOString());
1242
+ }
1243
+ if (toDate) {
1244
+ searchParams.set("toDate", toDate.toISOString());
1245
+ }
704
1246
  if (searchParams.size) {
705
1247
  return this.request(`/api/telemetry?${searchParams}`);
706
1248
  } else {
@@ -722,6 +1264,14 @@ var MastraClient = class extends BaseResource {
722
1264
  getNetwork(networkId) {
723
1265
  return new Network(this.options, networkId);
724
1266
  }
1267
+ /**
1268
+ * Gets an A2A client for interacting with an agent via the A2A protocol
1269
+ * @param agentId - ID of the agent to interact with
1270
+ * @returns A2A client instance
1271
+ */
1272
+ getA2A(agentId) {
1273
+ return new A2A(this.options, agentId);
1274
+ }
725
1275
  };
726
1276
 
727
1277
  export { MastraClient };