@mastra/client-js 0.10.6-alpha.1 → 0.10.6-alpha.3

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 CHANGED
@@ -252,6 +252,7 @@ var BaseResource = class {
252
252
  const response = await fetch(`${baseUrl.replace(/\/$/, "")}${path}`, {
253
253
  ...options,
254
254
  headers: {
255
+ ...options.method === "POST" || options.method === "PUT" ? { "content-type": "application/json" } : {},
255
256
  ...headers,
256
257
  ...options.headers
257
258
  // TODO: Bring this back once we figure out what we/users need to do to make this work with cross-origin requests
@@ -298,8 +299,6 @@ function parseClientRuntimeContext(runtimeContext$1) {
298
299
  }
299
300
  return void 0;
300
301
  }
301
-
302
- // src/resources/agent.ts
303
302
  var AgentVoice = class extends BaseResource {
304
303
  constructor(options, agentId) {
305
304
  super(options);
@@ -368,7 +367,7 @@ var Agent = class extends BaseResource {
368
367
  details() {
369
368
  return this.request(`/api/agents/${this.agentId}`);
370
369
  }
371
- generate(params) {
370
+ async generate(params) {
372
371
  const processedParams = {
373
372
  ...params,
374
373
  output: params.output ? zodToJsonSchema(params.output) : void 0,
@@ -376,10 +375,310 @@ var Agent = class extends BaseResource {
376
375
  runtimeContext: parseClientRuntimeContext(params.runtimeContext),
377
376
  clientTools: processClientTools(params.clientTools)
378
377
  };
379
- return this.request(`/api/agents/${this.agentId}/generate`, {
378
+ const { runId, resourceId, threadId, runtimeContext } = processedParams;
379
+ const response = await this.request(`/api/agents/${this.agentId}/generate`, {
380
380
  method: "POST",
381
381
  body: processedParams
382
382
  });
383
+ if (response.finishReason === "tool-calls") {
384
+ for (const toolCall of response.toolCalls) {
385
+ const clientTool = params.clientTools?.[toolCall.toolName];
386
+ if (clientTool && clientTool.execute) {
387
+ const result = await clientTool.execute(
388
+ { context: toolCall?.args, runId, resourceId, threadId, runtimeContext },
389
+ {
390
+ messages: response.messages,
391
+ toolCallId: toolCall?.toolCallId
392
+ }
393
+ );
394
+ const updatedMessages = [
395
+ {
396
+ role: "user",
397
+ content: params.messages
398
+ },
399
+ ...response.response.messages,
400
+ {
401
+ role: "tool",
402
+ content: [
403
+ {
404
+ type: "tool-result",
405
+ toolCallId: toolCall.toolCallId,
406
+ toolName: toolCall.toolName,
407
+ result
408
+ }
409
+ ]
410
+ }
411
+ ];
412
+ return this.generate({
413
+ ...params,
414
+ messages: updatedMessages
415
+ });
416
+ }
417
+ }
418
+ }
419
+ return response;
420
+ }
421
+ async processChatResponse({
422
+ stream,
423
+ update,
424
+ onToolCall,
425
+ onFinish,
426
+ getCurrentDate = () => /* @__PURE__ */ new Date(),
427
+ lastMessage
428
+ }) {
429
+ const replaceLastMessage = lastMessage?.role === "assistant";
430
+ let step = replaceLastMessage ? 1 + // find max step in existing tool invocations:
431
+ (lastMessage.toolInvocations?.reduce((max, toolInvocation) => {
432
+ return Math.max(max, toolInvocation.step ?? 0);
433
+ }, 0) ?? 0) : 0;
434
+ const message = replaceLastMessage ? structuredClone(lastMessage) : {
435
+ id: crypto.randomUUID(),
436
+ createdAt: getCurrentDate(),
437
+ role: "assistant",
438
+ content: "",
439
+ parts: []
440
+ };
441
+ let currentTextPart = void 0;
442
+ let currentReasoningPart = void 0;
443
+ let currentReasoningTextDetail = void 0;
444
+ function updateToolInvocationPart(toolCallId, invocation) {
445
+ const part = message.parts.find(
446
+ (part2) => part2.type === "tool-invocation" && part2.toolInvocation.toolCallId === toolCallId
447
+ );
448
+ if (part != null) {
449
+ part.toolInvocation = invocation;
450
+ } else {
451
+ message.parts.push({
452
+ type: "tool-invocation",
453
+ toolInvocation: invocation
454
+ });
455
+ }
456
+ }
457
+ const data = [];
458
+ let messageAnnotations = replaceLastMessage ? lastMessage?.annotations : void 0;
459
+ const partialToolCalls = {};
460
+ let usage = {
461
+ completionTokens: NaN,
462
+ promptTokens: NaN,
463
+ totalTokens: NaN
464
+ };
465
+ let finishReason = "unknown";
466
+ function execUpdate() {
467
+ const copiedData = [...data];
468
+ if (messageAnnotations?.length) {
469
+ message.annotations = messageAnnotations;
470
+ }
471
+ const copiedMessage = {
472
+ // deep copy the message to ensure that deep changes (msg attachments) are updated
473
+ // with SolidJS. SolidJS uses referential integration of sub-objects to detect changes.
474
+ ...structuredClone(message),
475
+ // add a revision id to ensure that the message is updated with SWR. SWR uses a
476
+ // hashing approach by default to detect changes, but it only works for shallow
477
+ // changes. This is why we need to add a revision id to ensure that the message
478
+ // is updated with SWR (without it, the changes get stuck in SWR and are not
479
+ // forwarded to rendering):
480
+ revisionId: crypto.randomUUID()
481
+ };
482
+ update({
483
+ message: copiedMessage,
484
+ data: copiedData,
485
+ replaceLastMessage
486
+ });
487
+ }
488
+ await uiUtils.processDataStream({
489
+ stream,
490
+ onTextPart(value) {
491
+ if (currentTextPart == null) {
492
+ currentTextPart = {
493
+ type: "text",
494
+ text: value
495
+ };
496
+ message.parts.push(currentTextPart);
497
+ } else {
498
+ currentTextPart.text += value;
499
+ }
500
+ message.content += value;
501
+ execUpdate();
502
+ },
503
+ onReasoningPart(value) {
504
+ if (currentReasoningTextDetail == null) {
505
+ currentReasoningTextDetail = { type: "text", text: value };
506
+ if (currentReasoningPart != null) {
507
+ currentReasoningPart.details.push(currentReasoningTextDetail);
508
+ }
509
+ } else {
510
+ currentReasoningTextDetail.text += value;
511
+ }
512
+ if (currentReasoningPart == null) {
513
+ currentReasoningPart = {
514
+ type: "reasoning",
515
+ reasoning: value,
516
+ details: [currentReasoningTextDetail]
517
+ };
518
+ message.parts.push(currentReasoningPart);
519
+ } else {
520
+ currentReasoningPart.reasoning += value;
521
+ }
522
+ message.reasoning = (message.reasoning ?? "") + value;
523
+ execUpdate();
524
+ },
525
+ onReasoningSignaturePart(value) {
526
+ if (currentReasoningTextDetail != null) {
527
+ currentReasoningTextDetail.signature = value.signature;
528
+ }
529
+ },
530
+ onRedactedReasoningPart(value) {
531
+ if (currentReasoningPart == null) {
532
+ currentReasoningPart = {
533
+ type: "reasoning",
534
+ reasoning: "",
535
+ details: []
536
+ };
537
+ message.parts.push(currentReasoningPart);
538
+ }
539
+ currentReasoningPart.details.push({
540
+ type: "redacted",
541
+ data: value.data
542
+ });
543
+ currentReasoningTextDetail = void 0;
544
+ execUpdate();
545
+ },
546
+ onFilePart(value) {
547
+ message.parts.push({
548
+ type: "file",
549
+ mimeType: value.mimeType,
550
+ data: value.data
551
+ });
552
+ execUpdate();
553
+ },
554
+ onSourcePart(value) {
555
+ message.parts.push({
556
+ type: "source",
557
+ source: value
558
+ });
559
+ execUpdate();
560
+ },
561
+ onToolCallStreamingStartPart(value) {
562
+ if (message.toolInvocations == null) {
563
+ message.toolInvocations = [];
564
+ }
565
+ partialToolCalls[value.toolCallId] = {
566
+ text: "",
567
+ step,
568
+ toolName: value.toolName,
569
+ index: message.toolInvocations.length
570
+ };
571
+ const invocation = {
572
+ state: "partial-call",
573
+ step,
574
+ toolCallId: value.toolCallId,
575
+ toolName: value.toolName,
576
+ args: void 0
577
+ };
578
+ message.toolInvocations.push(invocation);
579
+ updateToolInvocationPart(value.toolCallId, invocation);
580
+ execUpdate();
581
+ },
582
+ onToolCallDeltaPart(value) {
583
+ const partialToolCall = partialToolCalls[value.toolCallId];
584
+ partialToolCall.text += value.argsTextDelta;
585
+ const { value: partialArgs } = uiUtils.parsePartialJson(partialToolCall.text);
586
+ const invocation = {
587
+ state: "partial-call",
588
+ step: partialToolCall.step,
589
+ toolCallId: value.toolCallId,
590
+ toolName: partialToolCall.toolName,
591
+ args: partialArgs
592
+ };
593
+ message.toolInvocations[partialToolCall.index] = invocation;
594
+ updateToolInvocationPart(value.toolCallId, invocation);
595
+ execUpdate();
596
+ },
597
+ async onToolCallPart(value) {
598
+ const invocation = {
599
+ state: "call",
600
+ step,
601
+ ...value
602
+ };
603
+ if (partialToolCalls[value.toolCallId] != null) {
604
+ message.toolInvocations[partialToolCalls[value.toolCallId].index] = invocation;
605
+ } else {
606
+ if (message.toolInvocations == null) {
607
+ message.toolInvocations = [];
608
+ }
609
+ message.toolInvocations.push(invocation);
610
+ }
611
+ updateToolInvocationPart(value.toolCallId, invocation);
612
+ execUpdate();
613
+ if (onToolCall) {
614
+ const result = await onToolCall({ toolCall: value });
615
+ if (result != null) {
616
+ const invocation2 = {
617
+ state: "result",
618
+ step,
619
+ ...value,
620
+ result
621
+ };
622
+ message.toolInvocations[message.toolInvocations.length - 1] = invocation2;
623
+ updateToolInvocationPart(value.toolCallId, invocation2);
624
+ execUpdate();
625
+ }
626
+ }
627
+ },
628
+ onToolResultPart(value) {
629
+ const toolInvocations = message.toolInvocations;
630
+ if (toolInvocations == null) {
631
+ throw new Error("tool_result must be preceded by a tool_call");
632
+ }
633
+ const toolInvocationIndex = toolInvocations.findIndex((invocation2) => invocation2.toolCallId === value.toolCallId);
634
+ if (toolInvocationIndex === -1) {
635
+ throw new Error("tool_result must be preceded by a tool_call with the same toolCallId");
636
+ }
637
+ const invocation = {
638
+ ...toolInvocations[toolInvocationIndex],
639
+ state: "result",
640
+ ...value
641
+ };
642
+ toolInvocations[toolInvocationIndex] = invocation;
643
+ updateToolInvocationPart(value.toolCallId, invocation);
644
+ execUpdate();
645
+ },
646
+ onDataPart(value) {
647
+ data.push(...value);
648
+ execUpdate();
649
+ },
650
+ onMessageAnnotationsPart(value) {
651
+ if (messageAnnotations == null) {
652
+ messageAnnotations = [...value];
653
+ } else {
654
+ messageAnnotations.push(...value);
655
+ }
656
+ execUpdate();
657
+ },
658
+ onFinishStepPart(value) {
659
+ step += 1;
660
+ currentTextPart = value.isContinued ? currentTextPart : void 0;
661
+ currentReasoningPart = void 0;
662
+ currentReasoningTextDetail = void 0;
663
+ },
664
+ onStartStepPart(value) {
665
+ if (!replaceLastMessage) {
666
+ message.id = value.messageId;
667
+ }
668
+ message.parts.push({ type: "step-start" });
669
+ execUpdate();
670
+ },
671
+ onFinishMessagePart(value) {
672
+ finishReason = value.finishReason;
673
+ if (value.usage != null) {
674
+ usage = value.usage;
675
+ }
676
+ },
677
+ onErrorPart(error) {
678
+ throw new Error(error);
679
+ }
680
+ });
681
+ onFinish?.({ message, finishReason, usage });
383
682
  }
384
683
  /**
385
684
  * Streams a response from the agent
@@ -394,6 +693,25 @@ var Agent = class extends BaseResource {
394
693
  runtimeContext: parseClientRuntimeContext(params.runtimeContext),
395
694
  clientTools: processClientTools(params.clientTools)
396
695
  };
696
+ const { readable, writable } = new TransformStream();
697
+ const response = await this.processStreamResponse(processedParams, writable);
698
+ const streamResponse = new Response(readable, {
699
+ status: response.status,
700
+ statusText: response.statusText,
701
+ headers: response.headers
702
+ });
703
+ streamResponse.processDataStream = async (options = {}) => {
704
+ await uiUtils.processDataStream({
705
+ stream: readable,
706
+ ...options
707
+ });
708
+ };
709
+ return streamResponse;
710
+ }
711
+ /**
712
+ * Processes the stream response and handles tool calls
713
+ */
714
+ async processStreamResponse(processedParams, writable) {
397
715
  const response = await this.request(`/api/agents/${this.agentId}/stream`, {
398
716
  method: "POST",
399
717
  body: processedParams,
@@ -402,12 +720,81 @@ var Agent = class extends BaseResource {
402
720
  if (!response.body) {
403
721
  throw new Error("No response body");
404
722
  }
405
- response.processDataStream = async (options = {}) => {
406
- await uiUtils.processDataStream({
407
- stream: response.body,
408
- ...options
723
+ try {
724
+ let toolCalls = [];
725
+ let finishReasonToolCalls = false;
726
+ let messages = [];
727
+ let hasProcessedToolCalls = false;
728
+ response.clone().body.pipeTo(writable, {
729
+ preventClose: true
409
730
  });
410
- };
731
+ await this.processChatResponse({
732
+ stream: response.clone().body,
733
+ update: ({ message }) => {
734
+ messages.push(message);
735
+ },
736
+ onFinish: ({ finishReason, message }) => {
737
+ if (finishReason === "tool-calls") {
738
+ finishReasonToolCalls = true;
739
+ const toolCall = [...message?.parts ?? []].reverse().find((part) => part.type === "tool-invocation")?.toolInvocation;
740
+ if (toolCall) {
741
+ toolCalls.push(toolCall);
742
+ }
743
+ }
744
+ },
745
+ lastMessage: void 0
746
+ });
747
+ if (finishReasonToolCalls && !hasProcessedToolCalls) {
748
+ hasProcessedToolCalls = true;
749
+ for (const toolCall of toolCalls) {
750
+ const clientTool = processedParams.clientTools?.[toolCall.toolName];
751
+ if (clientTool && clientTool.execute) {
752
+ const result = await clientTool.execute(
753
+ {
754
+ context: toolCall?.args,
755
+ runId: processedParams.runId,
756
+ resourceId: processedParams.resourceId,
757
+ threadId: processedParams.threadId,
758
+ runtimeContext: processedParams.runtimeContext
759
+ },
760
+ {
761
+ messages: response.messages,
762
+ toolCallId: toolCall?.toolCallId
763
+ }
764
+ );
765
+ const lastMessage = JSON.parse(JSON.stringify(messages[messages.length - 1]));
766
+ const toolInvocationPart = lastMessage?.parts?.find(
767
+ (part) => part.type === "tool-invocation" && part.toolInvocation?.toolCallId === toolCall.toolCallId
768
+ );
769
+ if (toolInvocationPart) {
770
+ toolInvocationPart.toolInvocation = {
771
+ ...toolInvocationPart.toolInvocation,
772
+ state: "result",
773
+ result
774
+ };
775
+ }
776
+ const toolInvocation = lastMessage?.toolInvocations?.find(
777
+ (toolInvocation2) => toolInvocation2.toolCallId === toolCall.toolCallId
778
+ );
779
+ if (toolInvocation) {
780
+ toolInvocation.state = "result";
781
+ toolInvocation.result = result;
782
+ }
783
+ const originalMessages = processedParams.messages;
784
+ const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
785
+ this.processStreamResponse(
786
+ {
787
+ ...processedParams,
788
+ messages: [...messageArray, ...messages, lastMessage]
789
+ },
790
+ writable
791
+ );
792
+ }
793
+ }
794
+ }
795
+ } catch (error) {
796
+ console.error("Error processing stream response:", error);
797
+ }
411
798
  return response;
412
799
  }
413
800
  /**
@@ -802,7 +1189,7 @@ var LegacyWorkflow = class extends BaseResource {
802
1189
  };
803
1190
 
804
1191
  // src/resources/tool.ts
805
- var Tool = class extends BaseResource {
1192
+ var Tool2 = class extends BaseResource {
806
1193
  constructor(options, toolId) {
807
1194
  super(options);
808
1195
  this.toolId = toolId;
@@ -1003,9 +1390,9 @@ var Workflow = class extends BaseResource {
1003
1390
  });
1004
1391
  }
1005
1392
  /**
1006
- * Starts a vNext workflow run and returns a stream
1393
+ * Starts a workflow run and returns a stream
1007
1394
  * @param params - Object containing the optional runId, inputData and runtimeContext
1008
- * @returns Promise containing the vNext workflow execution results
1395
+ * @returns Promise containing the workflow execution results
1009
1396
  */
1010
1397
  async stream(params) {
1011
1398
  const searchParams = new URLSearchParams();
@@ -1221,6 +1608,155 @@ var MCPTool = class extends BaseResource {
1221
1608
  }
1222
1609
  };
1223
1610
 
1611
+ // src/resources/vNextNetwork.ts
1612
+ var RECORD_SEPARATOR3 = "";
1613
+ var VNextNetwork = class extends BaseResource {
1614
+ constructor(options, networkId) {
1615
+ super(options);
1616
+ this.networkId = networkId;
1617
+ }
1618
+ /**
1619
+ * Retrieves details about the network
1620
+ * @returns Promise containing vNext network details
1621
+ */
1622
+ details() {
1623
+ return this.request(`/api/networks/v-next/${this.networkId}`);
1624
+ }
1625
+ /**
1626
+ * Generates a response from the v-next network
1627
+ * @param params - Generation parameters including message
1628
+ * @returns Promise containing the generated response
1629
+ */
1630
+ generate(params) {
1631
+ return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
1632
+ method: "POST",
1633
+ body: params
1634
+ });
1635
+ }
1636
+ /**
1637
+ * Generates a response from the v-next network using multiple primitives
1638
+ * @param params - Generation parameters including message
1639
+ * @returns Promise containing the generated response
1640
+ */
1641
+ loop(params) {
1642
+ return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
1643
+ method: "POST",
1644
+ body: params
1645
+ });
1646
+ }
1647
+ async *streamProcessor(stream) {
1648
+ const reader = stream.getReader();
1649
+ let doneReading = false;
1650
+ let buffer = "";
1651
+ try {
1652
+ while (!doneReading) {
1653
+ const { done, value } = await reader.read();
1654
+ doneReading = done;
1655
+ if (done && !value) continue;
1656
+ try {
1657
+ const decoded = value ? new TextDecoder().decode(value) : "";
1658
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR3);
1659
+ buffer = chunks.pop() || "";
1660
+ for (const chunk of chunks) {
1661
+ if (chunk) {
1662
+ if (typeof chunk === "string") {
1663
+ try {
1664
+ const parsedChunk = JSON.parse(chunk);
1665
+ yield parsedChunk;
1666
+ } catch {
1667
+ }
1668
+ }
1669
+ }
1670
+ }
1671
+ } catch {
1672
+ }
1673
+ }
1674
+ if (buffer) {
1675
+ try {
1676
+ yield JSON.parse(buffer);
1677
+ } catch {
1678
+ }
1679
+ }
1680
+ } finally {
1681
+ reader.cancel().catch(() => {
1682
+ });
1683
+ }
1684
+ }
1685
+ /**
1686
+ * Streams a response from the v-next network
1687
+ * @param params - Stream parameters including message
1688
+ * @returns Promise containing the results
1689
+ */
1690
+ async stream(params, onRecord) {
1691
+ const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
1692
+ method: "POST",
1693
+ body: params,
1694
+ stream: true
1695
+ });
1696
+ if (!response.ok) {
1697
+ throw new Error(`Failed to stream vNext network: ${response.statusText}`);
1698
+ }
1699
+ if (!response.body) {
1700
+ throw new Error("Response body is null");
1701
+ }
1702
+ for await (const record of this.streamProcessor(response.body)) {
1703
+ if (typeof record === "string") {
1704
+ onRecord(JSON.parse(record));
1705
+ } else {
1706
+ onRecord(record);
1707
+ }
1708
+ }
1709
+ }
1710
+ };
1711
+
1712
+ // src/resources/network-memory-thread.ts
1713
+ var NetworkMemoryThread = class extends BaseResource {
1714
+ constructor(options, threadId, networkId) {
1715
+ super(options);
1716
+ this.threadId = threadId;
1717
+ this.networkId = networkId;
1718
+ }
1719
+ /**
1720
+ * Retrieves the memory thread details
1721
+ * @returns Promise containing thread details including title and metadata
1722
+ */
1723
+ get() {
1724
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
1725
+ }
1726
+ /**
1727
+ * Updates the memory thread properties
1728
+ * @param params - Update parameters including title and metadata
1729
+ * @returns Promise containing updated thread details
1730
+ */
1731
+ update(params) {
1732
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1733
+ method: "PATCH",
1734
+ body: params
1735
+ });
1736
+ }
1737
+ /**
1738
+ * Deletes the memory thread
1739
+ * @returns Promise containing deletion result
1740
+ */
1741
+ delete() {
1742
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1743
+ method: "DELETE"
1744
+ });
1745
+ }
1746
+ /**
1747
+ * Retrieves messages associated with the thread
1748
+ * @param params - Optional parameters including limit for number of messages to retrieve
1749
+ * @returns Promise containing thread messages and UI messages
1750
+ */
1751
+ getMessages(params) {
1752
+ const query = new URLSearchParams({
1753
+ networkId: this.networkId,
1754
+ ...params?.limit ? { limit: params.limit.toString() } : {}
1755
+ });
1756
+ return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
1757
+ }
1758
+ };
1759
+
1224
1760
  // src/client.ts
1225
1761
  var MastraClient = class extends BaseResource {
1226
1762
  constructor(options) {
@@ -1298,6 +1834,48 @@ var MastraClient = class extends BaseResource {
1298
1834
  getMemoryStatus(agentId) {
1299
1835
  return this.request(`/api/memory/status?agentId=${agentId}`);
1300
1836
  }
1837
+ /**
1838
+ * Retrieves memory threads for a resource
1839
+ * @param params - Parameters containing the resource ID
1840
+ * @returns Promise containing array of memory threads
1841
+ */
1842
+ getNetworkMemoryThreads(params) {
1843
+ return this.request(`/api/memory/network/threads?resourceid=${params.resourceId}&networkId=${params.networkId}`);
1844
+ }
1845
+ /**
1846
+ * Creates a new memory thread
1847
+ * @param params - Parameters for creating the memory thread
1848
+ * @returns Promise containing the created memory thread
1849
+ */
1850
+ createNetworkMemoryThread(params) {
1851
+ return this.request(`/api/memory/network/threads?networkId=${params.networkId}`, { method: "POST", body: params });
1852
+ }
1853
+ /**
1854
+ * Gets a memory thread instance by ID
1855
+ * @param threadId - ID of the memory thread to retrieve
1856
+ * @returns MemoryThread instance
1857
+ */
1858
+ getNetworkMemoryThread(threadId, networkId) {
1859
+ return new NetworkMemoryThread(this.options, threadId, networkId);
1860
+ }
1861
+ /**
1862
+ * Saves messages to memory
1863
+ * @param params - Parameters containing messages to save
1864
+ * @returns Promise containing the saved messages
1865
+ */
1866
+ saveNetworkMessageToMemory(params) {
1867
+ return this.request(`/api/memory/network/save-messages?networkId=${params.networkId}`, {
1868
+ method: "POST",
1869
+ body: params
1870
+ });
1871
+ }
1872
+ /**
1873
+ * Gets the status of the memory system
1874
+ * @returns Promise containing memory system status
1875
+ */
1876
+ getNetworkMemoryStatus(networkId) {
1877
+ return this.request(`/api/memory/network/status?networkId=${networkId}`);
1878
+ }
1301
1879
  /**
1302
1880
  * Retrieves all available tools
1303
1881
  * @returns Promise containing map of tool IDs to tool details
@@ -1311,7 +1889,7 @@ var MastraClient = class extends BaseResource {
1311
1889
  * @returns Tool instance
1312
1890
  */
1313
1891
  getTool(toolId) {
1314
- return new Tool(this.options, toolId);
1892
+ return new Tool2(this.options, toolId);
1315
1893
  }
1316
1894
  /**
1317
1895
  * Retrieves all available legacy workflows
@@ -1494,6 +2072,13 @@ var MastraClient = class extends BaseResource {
1494
2072
  getNetworks() {
1495
2073
  return this.request("/api/networks");
1496
2074
  }
2075
+ /**
2076
+ * Retrieves all available vNext networks
2077
+ * @returns Promise containing map of vNext network IDs to vNext network details
2078
+ */
2079
+ getVNextNetworks() {
2080
+ return this.request("/api/networks/v-next");
2081
+ }
1497
2082
  /**
1498
2083
  * Gets a network instance by ID
1499
2084
  * @param networkId - ID of the network to retrieve
@@ -1502,6 +2087,14 @@ var MastraClient = class extends BaseResource {
1502
2087
  getNetwork(networkId) {
1503
2088
  return new Network(this.options, networkId);
1504
2089
  }
2090
+ /**
2091
+ * Gets a vNext network instance by ID
2092
+ * @param networkId - ID of the vNext network to retrieve
2093
+ * @returns vNext Network instance
2094
+ */
2095
+ getVNextNetwork(networkId) {
2096
+ return new VNextNetwork(this.options, networkId);
2097
+ }
1505
2098
  /**
1506
2099
  * Retrieves a list of available MCP servers.
1507
2100
  * @param params - Optional parameters for pagination (limit, offset).