@mastra/client-js 0.0.0-fix-generate-title-20250616171351 → 0.0.0-fix-fetching-workflow-snapshots-20250625000954

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: streamResponse.body,
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,79 @@ 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
+ await this.processChatResponse({
730
+ stream: response.clone().body,
731
+ update: ({ message }) => {
732
+ messages.push(message);
733
+ },
734
+ onFinish: ({ finishReason, message }) => {
735
+ if (finishReason === "tool-calls") {
736
+ finishReasonToolCalls = true;
737
+ const toolCall = [...message?.parts ?? []].reverse().find((part) => part.type === "tool-invocation")?.toolInvocation;
738
+ if (toolCall) {
739
+ toolCalls.push(toolCall);
740
+ }
741
+ }
742
+ },
743
+ lastMessage: void 0
409
744
  });
410
- };
745
+ if (finishReasonToolCalls && !hasProcessedToolCalls) {
746
+ hasProcessedToolCalls = true;
747
+ for (const toolCall of toolCalls) {
748
+ const clientTool = processedParams.clientTools?.[toolCall.toolName];
749
+ if (clientTool && clientTool.execute) {
750
+ const result = await clientTool.execute(
751
+ {
752
+ context: toolCall?.args,
753
+ runId: processedParams.runId,
754
+ resourceId: processedParams.resourceId,
755
+ threadId: processedParams.threadId,
756
+ runtimeContext: processedParams.runtimeContext
757
+ },
758
+ {
759
+ messages: response.messages,
760
+ toolCallId: toolCall?.toolCallId
761
+ }
762
+ );
763
+ const lastMessage = JSON.parse(JSON.stringify(messages[messages.length - 1]));
764
+ const toolInvocationPart = lastMessage?.parts?.find(
765
+ (part) => part.type === "tool-invocation" && part.toolInvocation?.toolCallId === toolCall.toolCallId
766
+ );
767
+ if (toolInvocationPart) {
768
+ toolInvocationPart.toolInvocation = {
769
+ ...toolInvocationPart.toolInvocation,
770
+ state: "result",
771
+ result
772
+ };
773
+ }
774
+ const toolInvocation = lastMessage?.toolInvocations?.find(
775
+ (toolInvocation2) => toolInvocation2.toolCallId === toolCall.toolCallId
776
+ );
777
+ if (toolInvocation) {
778
+ toolInvocation.state = "result";
779
+ toolInvocation.result = result;
780
+ }
781
+ const originalMessages = processedParams.messages;
782
+ const messageArray = Array.isArray(originalMessages) ? originalMessages : [originalMessages];
783
+ this.processStreamResponse(
784
+ {
785
+ ...processedParams,
786
+ messages: [...messageArray, ...messages, lastMessage]
787
+ },
788
+ writable
789
+ );
790
+ }
791
+ }
792
+ }
793
+ } catch (error) {
794
+ console.error("Error processing stream response:", error);
795
+ }
411
796
  return response;
412
797
  }
413
798
  /**
@@ -802,7 +1187,7 @@ var LegacyWorkflow = class extends BaseResource {
802
1187
  };
803
1188
 
804
1189
  // src/resources/tool.ts
805
- var Tool = class extends BaseResource {
1190
+ var Tool2 = class extends BaseResource {
806
1191
  constructor(options, toolId) {
807
1192
  super(options);
808
1193
  this.toolId = toolId;
@@ -907,10 +1292,10 @@ var Workflow = class extends BaseResource {
907
1292
  if (params?.toDate) {
908
1293
  searchParams.set("toDate", params.toDate.toISOString());
909
1294
  }
910
- if (params?.limit) {
1295
+ if (params?.limit !== void 0) {
911
1296
  searchParams.set("limit", String(params.limit));
912
1297
  }
913
- if (params?.offset) {
1298
+ if (params?.offset !== void 0) {
914
1299
  searchParams.set("offset", String(params.offset));
915
1300
  }
916
1301
  if (params?.resourceId) {
@@ -1003,9 +1388,9 @@ var Workflow = class extends BaseResource {
1003
1388
  });
1004
1389
  }
1005
1390
  /**
1006
- * Starts a vNext workflow run and returns a stream
1391
+ * Starts a workflow run and returns a stream
1007
1392
  * @param params - Object containing the optional runId, inputData and runtimeContext
1008
- * @returns Promise containing the vNext workflow execution results
1393
+ * @returns Promise containing the workflow execution results
1009
1394
  */
1010
1395
  async stream(params) {
1011
1396
  const searchParams = new URLSearchParams();
@@ -1221,6 +1606,155 @@ var MCPTool = class extends BaseResource {
1221
1606
  }
1222
1607
  };
1223
1608
 
1609
+ // src/resources/vNextNetwork.ts
1610
+ var RECORD_SEPARATOR3 = "";
1611
+ var VNextNetwork = class extends BaseResource {
1612
+ constructor(options, networkId) {
1613
+ super(options);
1614
+ this.networkId = networkId;
1615
+ }
1616
+ /**
1617
+ * Retrieves details about the network
1618
+ * @returns Promise containing vNext network details
1619
+ */
1620
+ details() {
1621
+ return this.request(`/api/networks/v-next/${this.networkId}`);
1622
+ }
1623
+ /**
1624
+ * Generates a response from the v-next network
1625
+ * @param params - Generation parameters including message
1626
+ * @returns Promise containing the generated response
1627
+ */
1628
+ generate(params) {
1629
+ return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
1630
+ method: "POST",
1631
+ body: params
1632
+ });
1633
+ }
1634
+ /**
1635
+ * Generates a response from the v-next network using multiple primitives
1636
+ * @param params - Generation parameters including message
1637
+ * @returns Promise containing the generated response
1638
+ */
1639
+ loop(params) {
1640
+ return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
1641
+ method: "POST",
1642
+ body: params
1643
+ });
1644
+ }
1645
+ async *streamProcessor(stream) {
1646
+ const reader = stream.getReader();
1647
+ let doneReading = false;
1648
+ let buffer = "";
1649
+ try {
1650
+ while (!doneReading) {
1651
+ const { done, value } = await reader.read();
1652
+ doneReading = done;
1653
+ if (done && !value) continue;
1654
+ try {
1655
+ const decoded = value ? new TextDecoder().decode(value) : "";
1656
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR3);
1657
+ buffer = chunks.pop() || "";
1658
+ for (const chunk of chunks) {
1659
+ if (chunk) {
1660
+ if (typeof chunk === "string") {
1661
+ try {
1662
+ const parsedChunk = JSON.parse(chunk);
1663
+ yield parsedChunk;
1664
+ } catch {
1665
+ }
1666
+ }
1667
+ }
1668
+ }
1669
+ } catch {
1670
+ }
1671
+ }
1672
+ if (buffer) {
1673
+ try {
1674
+ yield JSON.parse(buffer);
1675
+ } catch {
1676
+ }
1677
+ }
1678
+ } finally {
1679
+ reader.cancel().catch(() => {
1680
+ });
1681
+ }
1682
+ }
1683
+ /**
1684
+ * Streams a response from the v-next network
1685
+ * @param params - Stream parameters including message
1686
+ * @returns Promise containing the results
1687
+ */
1688
+ async stream(params, onRecord) {
1689
+ const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
1690
+ method: "POST",
1691
+ body: params,
1692
+ stream: true
1693
+ });
1694
+ if (!response.ok) {
1695
+ throw new Error(`Failed to stream vNext network: ${response.statusText}`);
1696
+ }
1697
+ if (!response.body) {
1698
+ throw new Error("Response body is null");
1699
+ }
1700
+ for await (const record of this.streamProcessor(response.body)) {
1701
+ if (typeof record === "string") {
1702
+ onRecord(JSON.parse(record));
1703
+ } else {
1704
+ onRecord(record);
1705
+ }
1706
+ }
1707
+ }
1708
+ };
1709
+
1710
+ // src/resources/network-memory-thread.ts
1711
+ var NetworkMemoryThread = class extends BaseResource {
1712
+ constructor(options, threadId, networkId) {
1713
+ super(options);
1714
+ this.threadId = threadId;
1715
+ this.networkId = networkId;
1716
+ }
1717
+ /**
1718
+ * Retrieves the memory thread details
1719
+ * @returns Promise containing thread details including title and metadata
1720
+ */
1721
+ get() {
1722
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
1723
+ }
1724
+ /**
1725
+ * Updates the memory thread properties
1726
+ * @param params - Update parameters including title and metadata
1727
+ * @returns Promise containing updated thread details
1728
+ */
1729
+ update(params) {
1730
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1731
+ method: "PATCH",
1732
+ body: params
1733
+ });
1734
+ }
1735
+ /**
1736
+ * Deletes the memory thread
1737
+ * @returns Promise containing deletion result
1738
+ */
1739
+ delete() {
1740
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1741
+ method: "DELETE"
1742
+ });
1743
+ }
1744
+ /**
1745
+ * Retrieves messages associated with the thread
1746
+ * @param params - Optional parameters including limit for number of messages to retrieve
1747
+ * @returns Promise containing thread messages and UI messages
1748
+ */
1749
+ getMessages(params) {
1750
+ const query = new URLSearchParams({
1751
+ networkId: this.networkId,
1752
+ ...params?.limit ? { limit: params.limit.toString() } : {}
1753
+ });
1754
+ return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
1755
+ }
1756
+ };
1757
+
1224
1758
  // src/client.ts
1225
1759
  var MastraClient = class extends BaseResource {
1226
1760
  constructor(options) {
@@ -1298,6 +1832,48 @@ var MastraClient = class extends BaseResource {
1298
1832
  getMemoryStatus(agentId) {
1299
1833
  return this.request(`/api/memory/status?agentId=${agentId}`);
1300
1834
  }
1835
+ /**
1836
+ * Retrieves memory threads for a resource
1837
+ * @param params - Parameters containing the resource ID
1838
+ * @returns Promise containing array of memory threads
1839
+ */
1840
+ getNetworkMemoryThreads(params) {
1841
+ return this.request(`/api/memory/network/threads?resourceid=${params.resourceId}&networkId=${params.networkId}`);
1842
+ }
1843
+ /**
1844
+ * Creates a new memory thread
1845
+ * @param params - Parameters for creating the memory thread
1846
+ * @returns Promise containing the created memory thread
1847
+ */
1848
+ createNetworkMemoryThread(params) {
1849
+ return this.request(`/api/memory/network/threads?networkId=${params.networkId}`, { method: "POST", body: params });
1850
+ }
1851
+ /**
1852
+ * Gets a memory thread instance by ID
1853
+ * @param threadId - ID of the memory thread to retrieve
1854
+ * @returns MemoryThread instance
1855
+ */
1856
+ getNetworkMemoryThread(threadId, networkId) {
1857
+ return new NetworkMemoryThread(this.options, threadId, networkId);
1858
+ }
1859
+ /**
1860
+ * Saves messages to memory
1861
+ * @param params - Parameters containing messages to save
1862
+ * @returns Promise containing the saved messages
1863
+ */
1864
+ saveNetworkMessageToMemory(params) {
1865
+ return this.request(`/api/memory/network/save-messages?networkId=${params.networkId}`, {
1866
+ method: "POST",
1867
+ body: params
1868
+ });
1869
+ }
1870
+ /**
1871
+ * Gets the status of the memory system
1872
+ * @returns Promise containing memory system status
1873
+ */
1874
+ getNetworkMemoryStatus(networkId) {
1875
+ return this.request(`/api/memory/network/status?networkId=${networkId}`);
1876
+ }
1301
1877
  /**
1302
1878
  * Retrieves all available tools
1303
1879
  * @returns Promise containing map of tool IDs to tool details
@@ -1311,7 +1887,7 @@ var MastraClient = class extends BaseResource {
1311
1887
  * @returns Tool instance
1312
1888
  */
1313
1889
  getTool(toolId) {
1314
- return new Tool(this.options, toolId);
1890
+ return new Tool2(this.options, toolId);
1315
1891
  }
1316
1892
  /**
1317
1893
  * Retrieves all available legacy workflows
@@ -1494,6 +2070,13 @@ var MastraClient = class extends BaseResource {
1494
2070
  getNetworks() {
1495
2071
  return this.request("/api/networks");
1496
2072
  }
2073
+ /**
2074
+ * Retrieves all available vNext networks
2075
+ * @returns Promise containing map of vNext network IDs to vNext network details
2076
+ */
2077
+ getVNextNetworks() {
2078
+ return this.request("/api/networks/v-next");
2079
+ }
1497
2080
  /**
1498
2081
  * Gets a network instance by ID
1499
2082
  * @param networkId - ID of the network to retrieve
@@ -1502,6 +2085,14 @@ var MastraClient = class extends BaseResource {
1502
2085
  getNetwork(networkId) {
1503
2086
  return new Network(this.options, networkId);
1504
2087
  }
2088
+ /**
2089
+ * Gets a vNext network instance by ID
2090
+ * @param networkId - ID of the vNext network to retrieve
2091
+ * @returns vNext Network instance
2092
+ */
2093
+ getVNextNetwork(networkId) {
2094
+ return new VNextNetwork(this.options, networkId);
2095
+ }
1505
2096
  /**
1506
2097
  * Retrieves a list of available MCP servers.
1507
2098
  * @param params - Optional parameters for pagination (limit, offset).