@mastra/client-js 0.0.0-storage-20250225005900 → 0.0.0-vnextWorkflows-20250417075051

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.cjs ADDED
@@ -0,0 +1,729 @@
1
+ 'use strict';
2
+
3
+ var zod = require('zod');
4
+ var zodToJsonSchema = require('zod-to-json-schema');
5
+ var uiUtils = require('@ai-sdk/ui-utils');
6
+
7
+ // src/resources/agent.ts
8
+
9
+ // src/resources/base.ts
10
+ var BaseResource = class {
11
+ options;
12
+ constructor(options) {
13
+ this.options = options;
14
+ }
15
+ /**
16
+ * Makes an HTTP request to the API with retries and exponential backoff
17
+ * @param path - The API endpoint path
18
+ * @param options - Optional request configuration
19
+ * @returns Promise containing the response data
20
+ */
21
+ async request(path, options = {}) {
22
+ let lastError = null;
23
+ const { baseUrl, retries = 3, backoffMs = 100, maxBackoffMs = 1e3, headers = {} } = this.options;
24
+ let delay = backoffMs;
25
+ for (let attempt = 0; attempt <= retries; attempt++) {
26
+ try {
27
+ const response = await fetch(`${baseUrl}${path}`, {
28
+ ...options,
29
+ headers: {
30
+ ...headers,
31
+ ...options.headers
32
+ // TODO: Bring this back once we figure out what we/users need to do to make this work with cross-origin requests
33
+ // 'x-mastra-client-type': 'js',
34
+ },
35
+ body: options.body instanceof FormData ? options.body : options.body ? JSON.stringify(options.body) : void 0
36
+ });
37
+ if (!response.ok) {
38
+ const errorBody = await response.text();
39
+ let errorMessage = `HTTP error! status: ${response.status}`;
40
+ try {
41
+ const errorJson = JSON.parse(errorBody);
42
+ errorMessage += ` - ${JSON.stringify(errorJson)}`;
43
+ } catch {
44
+ if (errorBody) {
45
+ errorMessage += ` - ${errorBody}`;
46
+ }
47
+ }
48
+ throw new Error(errorMessage);
49
+ }
50
+ if (options.stream) {
51
+ return response;
52
+ }
53
+ const data = await response.json();
54
+ return data;
55
+ } catch (error) {
56
+ lastError = error;
57
+ if (attempt === retries) {
58
+ break;
59
+ }
60
+ await new Promise((resolve) => setTimeout(resolve, delay));
61
+ delay = Math.min(delay * 2, maxBackoffMs);
62
+ }
63
+ }
64
+ throw lastError || new Error("Request failed");
65
+ }
66
+ };
67
+
68
+ // src/resources/agent.ts
69
+ var AgentVoice = class extends BaseResource {
70
+ constructor(options, agentId) {
71
+ super(options);
72
+ this.agentId = agentId;
73
+ this.agentId = agentId;
74
+ }
75
+ /**
76
+ * Convert text to speech using the agent's voice provider
77
+ * @param text - Text to convert to speech
78
+ * @param options - Optional provider-specific options for speech generation
79
+ * @returns Promise containing the audio data
80
+ */
81
+ async speak(text, options) {
82
+ return this.request(`/api/agents/${this.agentId}/voice/speak`, {
83
+ method: "POST",
84
+ headers: {
85
+ "Content-Type": "application/json"
86
+ },
87
+ body: { input: text, options },
88
+ stream: true
89
+ });
90
+ }
91
+ /**
92
+ * Convert speech to text using the agent's voice provider
93
+ * @param audio - Audio data to transcribe
94
+ * @param options - Optional provider-specific options
95
+ * @returns Promise containing the transcribed text
96
+ */
97
+ listen(audio, options) {
98
+ const formData = new FormData();
99
+ formData.append("audio", audio);
100
+ if (options) {
101
+ formData.append("options", JSON.stringify(options));
102
+ }
103
+ return this.request(`/api/agents/${this.agentId}/voice/listen`, {
104
+ method: "POST",
105
+ body: formData
106
+ });
107
+ }
108
+ /**
109
+ * Get available speakers for the agent's voice provider
110
+ * @returns Promise containing list of available speakers
111
+ */
112
+ getSpeakers() {
113
+ return this.request(`/api/agents/${this.agentId}/voice/speakers`);
114
+ }
115
+ };
116
+ var Agent = class extends BaseResource {
117
+ constructor(options, agentId) {
118
+ super(options);
119
+ this.agentId = agentId;
120
+ this.voice = new AgentVoice(options, this.agentId);
121
+ }
122
+ voice;
123
+ /**
124
+ * Retrieves details about the agent
125
+ * @returns Promise containing agent details including model and instructions
126
+ */
127
+ details() {
128
+ return this.request(`/api/agents/${this.agentId}`);
129
+ }
130
+ /**
131
+ * Generates a response from the agent
132
+ * @param params - Generation parameters including prompt
133
+ * @returns Promise containing the generated response
134
+ */
135
+ generate(params) {
136
+ const processedParams = {
137
+ ...params,
138
+ output: params.output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.output) : params.output,
139
+ experimental_output: params.experimental_output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.experimental_output) : params.experimental_output
140
+ };
141
+ return this.request(`/api/agents/${this.agentId}/generate`, {
142
+ method: "POST",
143
+ body: processedParams
144
+ });
145
+ }
146
+ /**
147
+ * Streams a response from the agent
148
+ * @param params - Stream parameters including prompt
149
+ * @returns Promise containing the enhanced Response object with processDataStream method
150
+ */
151
+ async stream(params) {
152
+ const processedParams = {
153
+ ...params,
154
+ output: params.output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.output) : params.output,
155
+ experimental_output: params.experimental_output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.experimental_output) : params.experimental_output
156
+ };
157
+ const response = await this.request(`/api/agents/${this.agentId}/stream`, {
158
+ method: "POST",
159
+ body: processedParams,
160
+ stream: true
161
+ });
162
+ if (!response.body) {
163
+ throw new Error("No response body");
164
+ }
165
+ response.processDataStream = async (options = {}) => {
166
+ await uiUtils.processDataStream({
167
+ stream: response.body,
168
+ ...options
169
+ });
170
+ };
171
+ return response;
172
+ }
173
+ /**
174
+ * Gets details about a specific tool available to the agent
175
+ * @param toolId - ID of the tool to retrieve
176
+ * @returns Promise containing tool details
177
+ */
178
+ getTool(toolId) {
179
+ return this.request(`/api/agents/${this.agentId}/tools/${toolId}`);
180
+ }
181
+ /**
182
+ * Retrieves evaluation results for the agent
183
+ * @returns Promise containing agent evaluations
184
+ */
185
+ evals() {
186
+ return this.request(`/api/agents/${this.agentId}/evals/ci`);
187
+ }
188
+ /**
189
+ * Retrieves live evaluation results for the agent
190
+ * @returns Promise containing live agent evaluations
191
+ */
192
+ liveEvals() {
193
+ return this.request(`/api/agents/${this.agentId}/evals/live`);
194
+ }
195
+ };
196
+ var Network = class extends BaseResource {
197
+ constructor(options, networkId) {
198
+ super(options);
199
+ this.networkId = networkId;
200
+ }
201
+ /**
202
+ * Retrieves details about the network
203
+ * @returns Promise containing network details
204
+ */
205
+ details() {
206
+ return this.request(`/api/networks/${this.networkId}`);
207
+ }
208
+ /**
209
+ * Generates a response from the agent
210
+ * @param params - Generation parameters including prompt
211
+ * @returns Promise containing the generated response
212
+ */
213
+ generate(params) {
214
+ const processedParams = {
215
+ ...params,
216
+ output: params.output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.output) : params.output,
217
+ experimental_output: params.experimental_output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.experimental_output) : params.experimental_output
218
+ };
219
+ return this.request(`/api/networks/${this.networkId}/generate`, {
220
+ method: "POST",
221
+ body: processedParams
222
+ });
223
+ }
224
+ /**
225
+ * Streams a response from the agent
226
+ * @param params - Stream parameters including prompt
227
+ * @returns Promise containing the enhanced Response object with processDataStream method
228
+ */
229
+ async stream(params) {
230
+ const processedParams = {
231
+ ...params,
232
+ output: params.output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.output) : params.output,
233
+ experimental_output: params.experimental_output instanceof zod.ZodSchema ? zodToJsonSchema.zodToJsonSchema(params.experimental_output) : params.experimental_output
234
+ };
235
+ const response = await this.request(`/api/networks/${this.networkId}/stream`, {
236
+ method: "POST",
237
+ body: processedParams,
238
+ stream: true
239
+ });
240
+ if (!response.body) {
241
+ throw new Error("No response body");
242
+ }
243
+ response.processDataStream = async (options = {}) => {
244
+ await uiUtils.processDataStream({
245
+ stream: response.body,
246
+ ...options
247
+ });
248
+ };
249
+ return response;
250
+ }
251
+ };
252
+
253
+ // src/resources/memory-thread.ts
254
+ var MemoryThread = class extends BaseResource {
255
+ constructor(options, threadId, agentId) {
256
+ super(options);
257
+ this.threadId = threadId;
258
+ this.agentId = agentId;
259
+ }
260
+ /**
261
+ * Retrieves the memory thread details
262
+ * @returns Promise containing thread details including title and metadata
263
+ */
264
+ get() {
265
+ return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`);
266
+ }
267
+ /**
268
+ * Updates the memory thread properties
269
+ * @param params - Update parameters including title and metadata
270
+ * @returns Promise containing updated thread details
271
+ */
272
+ update(params) {
273
+ return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`, {
274
+ method: "PATCH",
275
+ body: params
276
+ });
277
+ }
278
+ /**
279
+ * Deletes the memory thread
280
+ * @returns Promise containing deletion result
281
+ */
282
+ delete() {
283
+ return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`, {
284
+ method: "DELETE"
285
+ });
286
+ }
287
+ /**
288
+ * Retrieves messages associated with the thread
289
+ * @returns Promise containing thread messages and UI messages
290
+ */
291
+ getMessages() {
292
+ return this.request(`/api/memory/threads/${this.threadId}/messages?agentId=${this.agentId}`);
293
+ }
294
+ };
295
+
296
+ // src/resources/vector.ts
297
+ var Vector = class extends BaseResource {
298
+ constructor(options, vectorName) {
299
+ super(options);
300
+ this.vectorName = vectorName;
301
+ }
302
+ /**
303
+ * Retrieves details about a specific vector index
304
+ * @param indexName - Name of the index to get details for
305
+ * @returns Promise containing vector index details
306
+ */
307
+ details(indexName) {
308
+ return this.request(`/api/vector/${this.vectorName}/indexes/${indexName}`);
309
+ }
310
+ /**
311
+ * Deletes a vector index
312
+ * @param indexName - Name of the index to delete
313
+ * @returns Promise indicating deletion success
314
+ */
315
+ delete(indexName) {
316
+ return this.request(`/api/vector/${this.vectorName}/indexes/${indexName}`, {
317
+ method: "DELETE"
318
+ });
319
+ }
320
+ /**
321
+ * Retrieves a list of all available indexes
322
+ * @returns Promise containing array of index names
323
+ */
324
+ getIndexes() {
325
+ return this.request(`/api/vector/${this.vectorName}/indexes`);
326
+ }
327
+ /**
328
+ * Creates a new vector index
329
+ * @param params - Parameters for index creation including dimension and metric
330
+ * @returns Promise indicating creation success
331
+ */
332
+ createIndex(params) {
333
+ return this.request(`/api/vector/${this.vectorName}/create-index`, {
334
+ method: "POST",
335
+ body: params
336
+ });
337
+ }
338
+ /**
339
+ * Upserts vectors into an index
340
+ * @param params - Parameters containing vectors, metadata, and optional IDs
341
+ * @returns Promise containing array of vector IDs
342
+ */
343
+ upsert(params) {
344
+ return this.request(`/api/vector/${this.vectorName}/upsert`, {
345
+ method: "POST",
346
+ body: params
347
+ });
348
+ }
349
+ /**
350
+ * Queries vectors in an index
351
+ * @param params - Query parameters including query vector and search options
352
+ * @returns Promise containing query results
353
+ */
354
+ query(params) {
355
+ return this.request(`/api/vector/${this.vectorName}/query`, {
356
+ method: "POST",
357
+ body: params
358
+ });
359
+ }
360
+ };
361
+
362
+ // src/resources/workflow.ts
363
+ var RECORD_SEPARATOR = "";
364
+ var Workflow = class extends BaseResource {
365
+ constructor(options, workflowId) {
366
+ super(options);
367
+ this.workflowId = workflowId;
368
+ }
369
+ /**
370
+ * Retrieves details about the workflow
371
+ * @returns Promise containing workflow details including steps and graphs
372
+ */
373
+ details() {
374
+ return this.request(`/api/workflows/${this.workflowId}`);
375
+ }
376
+ /**
377
+ * @deprecated Use `startAsync` instead
378
+ * Executes the workflow with the provided parameters
379
+ * @param params - Parameters required for workflow execution
380
+ * @returns Promise containing the workflow execution results
381
+ */
382
+ execute(params) {
383
+ return this.request(`/api/workflows/${this.workflowId}/execute`, {
384
+ method: "POST",
385
+ body: params
386
+ });
387
+ }
388
+ /**
389
+ * Creates a new workflow run
390
+ * @returns Promise containing the generated run ID
391
+ */
392
+ createRun(params) {
393
+ const searchParams = new URLSearchParams();
394
+ if (!!params?.runId) {
395
+ searchParams.set("runId", params.runId);
396
+ }
397
+ return this.request(`/api/workflows/${this.workflowId}/createRun?${searchParams.toString()}`, {
398
+ method: "POST"
399
+ });
400
+ }
401
+ /**
402
+ * Starts a workflow run synchronously without waiting for the workflow to complete
403
+ * @param params - Object containing the runId and triggerData
404
+ * @returns Promise containing success message
405
+ */
406
+ start(params) {
407
+ return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
408
+ method: "POST",
409
+ body: params?.triggerData
410
+ });
411
+ }
412
+ /**
413
+ * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
414
+ * @param stepId - ID of the step to resume
415
+ * @param runId - ID of the workflow run
416
+ * @param context - Context to resume the workflow with
417
+ * @returns Promise containing the workflow resume results
418
+ */
419
+ resume({
420
+ stepId,
421
+ runId,
422
+ context
423
+ }) {
424
+ return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
425
+ method: "POST",
426
+ body: {
427
+ stepId,
428
+ context
429
+ }
430
+ });
431
+ }
432
+ /**
433
+ * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
434
+ * @param params - Object containing the optional runId and triggerData
435
+ * @returns Promise containing the workflow execution results
436
+ */
437
+ startAsync(params) {
438
+ const searchParams = new URLSearchParams();
439
+ if (!!params?.runId) {
440
+ searchParams.set("runId", params.runId);
441
+ }
442
+ return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
443
+ method: "POST",
444
+ body: params?.triggerData
445
+ });
446
+ }
447
+ /**
448
+ * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
449
+ * @param params - Object containing the runId, stepId, and context
450
+ * @returns Promise containing the workflow resume results
451
+ */
452
+ resumeAsync(params) {
453
+ return this.request(`/api/workflows/${this.workflowId}/resume-async?runId=${params.runId}`, {
454
+ method: "POST",
455
+ body: {
456
+ stepId: params.stepId,
457
+ context: params.context
458
+ }
459
+ });
460
+ }
461
+ /**
462
+ * Creates an async generator that processes a readable stream and yields records
463
+ * separated by the Record Separator character (\x1E)
464
+ *
465
+ * @param stream - The readable stream to process
466
+ * @returns An async generator that yields parsed records
467
+ */
468
+ async *streamProcessor(stream) {
469
+ const reader = stream.getReader();
470
+ let doneReading = false;
471
+ let buffer = "";
472
+ try {
473
+ while (!doneReading) {
474
+ const { done, value } = await reader.read();
475
+ doneReading = done;
476
+ if (done && !value) continue;
477
+ try {
478
+ const decoded = value ? new TextDecoder().decode(value) : "";
479
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR);
480
+ buffer = chunks.pop() || "";
481
+ for (const chunk of chunks) {
482
+ if (chunk) {
483
+ if (typeof chunk === "string") {
484
+ try {
485
+ const parsedChunk = JSON.parse(chunk);
486
+ yield parsedChunk;
487
+ } catch {
488
+ }
489
+ }
490
+ }
491
+ }
492
+ } catch (error) {
493
+ }
494
+ }
495
+ if (buffer) {
496
+ try {
497
+ yield JSON.parse(buffer);
498
+ } catch {
499
+ }
500
+ }
501
+ } finally {
502
+ reader.cancel().catch(() => {
503
+ });
504
+ }
505
+ }
506
+ /**
507
+ * Watches workflow transitions in real-time
508
+ * @param runId - Optional run ID to filter the watch stream
509
+ * @returns AsyncGenerator that yields parsed records from the workflow watch stream
510
+ */
511
+ async watch({ runId }, onRecord) {
512
+ const response = await this.request(`/api/workflows/${this.workflowId}/watch?runId=${runId}`, {
513
+ stream: true
514
+ });
515
+ if (!response.ok) {
516
+ throw new Error(`Failed to watch workflow: ${response.statusText}`);
517
+ }
518
+ if (!response.body) {
519
+ throw new Error("Response body is null");
520
+ }
521
+ for await (const record of this.streamProcessor(response.body)) {
522
+ onRecord(record);
523
+ }
524
+ }
525
+ };
526
+
527
+ // src/resources/tool.ts
528
+ var Tool = class extends BaseResource {
529
+ constructor(options, toolId) {
530
+ super(options);
531
+ this.toolId = toolId;
532
+ }
533
+ /**
534
+ * Retrieves details about the tool
535
+ * @returns Promise containing tool details including description and schemas
536
+ */
537
+ details() {
538
+ return this.request(`/api/tools/${this.toolId}`);
539
+ }
540
+ /**
541
+ * Executes the tool with the provided parameters
542
+ * @param params - Parameters required for tool execution
543
+ * @returns Promise containing the tool execution results
544
+ */
545
+ execute(params) {
546
+ return this.request(`/api/tools/${this.toolId}/execute`, {
547
+ method: "POST",
548
+ body: params
549
+ });
550
+ }
551
+ };
552
+
553
+ // src/client.ts
554
+ var MastraClient = class extends BaseResource {
555
+ constructor(options) {
556
+ super(options);
557
+ }
558
+ /**
559
+ * Retrieves all available agents
560
+ * @returns Promise containing map of agent IDs to agent details
561
+ */
562
+ getAgents() {
563
+ return this.request("/api/agents");
564
+ }
565
+ /**
566
+ * Gets an agent instance by ID
567
+ * @param agentId - ID of the agent to retrieve
568
+ * @returns Agent instance
569
+ */
570
+ getAgent(agentId) {
571
+ return new Agent(this.options, agentId);
572
+ }
573
+ /**
574
+ * Retrieves memory threads for a resource
575
+ * @param params - Parameters containing the resource ID
576
+ * @returns Promise containing array of memory threads
577
+ */
578
+ getMemoryThreads(params) {
579
+ return this.request(`/api/memory/threads?resourceid=${params.resourceId}&agentId=${params.agentId}`);
580
+ }
581
+ /**
582
+ * Creates a new memory thread
583
+ * @param params - Parameters for creating the memory thread
584
+ * @returns Promise containing the created memory thread
585
+ */
586
+ createMemoryThread(params) {
587
+ return this.request(`/api/memory/threads?agentId=${params.agentId}`, { method: "POST", body: params });
588
+ }
589
+ /**
590
+ * Gets a memory thread instance by ID
591
+ * @param threadId - ID of the memory thread to retrieve
592
+ * @returns MemoryThread instance
593
+ */
594
+ getMemoryThread(threadId, agentId) {
595
+ return new MemoryThread(this.options, threadId, agentId);
596
+ }
597
+ /**
598
+ * Saves messages to memory
599
+ * @param params - Parameters containing messages to save
600
+ * @returns Promise containing the saved messages
601
+ */
602
+ saveMessageToMemory(params) {
603
+ return this.request(`/api/memory/save-messages?agentId=${params.agentId}`, {
604
+ method: "POST",
605
+ body: params
606
+ });
607
+ }
608
+ /**
609
+ * Gets the status of the memory system
610
+ * @returns Promise containing memory system status
611
+ */
612
+ getMemoryStatus(agentId) {
613
+ return this.request(`/api/memory/status?agentId=${agentId}`);
614
+ }
615
+ /**
616
+ * Retrieves all available tools
617
+ * @returns Promise containing map of tool IDs to tool details
618
+ */
619
+ getTools() {
620
+ return this.request("/api/tools");
621
+ }
622
+ /**
623
+ * Gets a tool instance by ID
624
+ * @param toolId - ID of the tool to retrieve
625
+ * @returns Tool instance
626
+ */
627
+ getTool(toolId) {
628
+ return new Tool(this.options, toolId);
629
+ }
630
+ /**
631
+ * Retrieves all available workflows
632
+ * @returns Promise containing map of workflow IDs to workflow details
633
+ */
634
+ getWorkflows() {
635
+ return this.request("/api/workflows");
636
+ }
637
+ /**
638
+ * Gets a workflow instance by ID
639
+ * @param workflowId - ID of the workflow to retrieve
640
+ * @returns Workflow instance
641
+ */
642
+ getWorkflow(workflowId) {
643
+ return new Workflow(this.options, workflowId);
644
+ }
645
+ /**
646
+ * Gets a vector instance by name
647
+ * @param vectorName - Name of the vector to retrieve
648
+ * @returns Vector instance
649
+ */
650
+ getVector(vectorName) {
651
+ return new Vector(this.options, vectorName);
652
+ }
653
+ /**
654
+ * Retrieves logs
655
+ * @param params - Parameters for filtering logs
656
+ * @returns Promise containing array of log messages
657
+ */
658
+ getLogs(params) {
659
+ return this.request(`/api/logs?transportId=${params.transportId}`);
660
+ }
661
+ /**
662
+ * Gets logs for a specific run
663
+ * @param params - Parameters containing run ID to retrieve
664
+ * @returns Promise containing array of log messages
665
+ */
666
+ getLogForRun(params) {
667
+ return this.request(`/api/logs/${params.runId}?transportId=${params.transportId}`);
668
+ }
669
+ /**
670
+ * List of all log transports
671
+ * @returns Promise containing list of log transports
672
+ */
673
+ getLogTransports() {
674
+ return this.request("/api/logs/transports");
675
+ }
676
+ /**
677
+ * List of all traces (paged)
678
+ * @param params - Parameters for filtering traces
679
+ * @returns Promise containing telemetry data
680
+ */
681
+ getTelemetry(params) {
682
+ const { name, scope, page, perPage, attribute } = params || {};
683
+ const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
684
+ const searchParams = new URLSearchParams();
685
+ if (name) {
686
+ searchParams.set("name", name);
687
+ }
688
+ if (scope) {
689
+ searchParams.set("scope", scope);
690
+ }
691
+ if (page) {
692
+ searchParams.set("page", String(page));
693
+ }
694
+ if (perPage) {
695
+ searchParams.set("perPage", String(perPage));
696
+ }
697
+ if (_attribute) {
698
+ if (Array.isArray(_attribute)) {
699
+ for (const attr of _attribute) {
700
+ searchParams.append("attribute", attr);
701
+ }
702
+ } else {
703
+ searchParams.set("attribute", _attribute);
704
+ }
705
+ }
706
+ if (searchParams.size) {
707
+ return this.request(`/api/telemetry?${searchParams}`);
708
+ } else {
709
+ return this.request(`/api/telemetry`);
710
+ }
711
+ }
712
+ /**
713
+ * Retrieves all available networks
714
+ * @returns Promise containing map of network IDs to network details
715
+ */
716
+ getNetworks() {
717
+ return this.request("/api/networks");
718
+ }
719
+ /**
720
+ * Gets a network instance by ID
721
+ * @param networkId - ID of the network to retrieve
722
+ * @returns Network instance
723
+ */
724
+ getNetwork(networkId) {
725
+ return new Network(this.options, networkId);
726
+ }
727
+ };
728
+
729
+ exports.MastraClient = MastraClient;