@mastra/client-js 0.0.0-transpile-packages-20250724123433 → 0.0.0-transpile-packages-20250731152758

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.
Files changed (71) hide show
  1. package/.turbo/turbo-build.log +2 -17
  2. package/CHANGELOG.md +202 -2
  3. package/dist/adapters/agui.d.ts +23 -0
  4. package/dist/adapters/agui.d.ts.map +1 -0
  5. package/dist/client.d.ts +265 -0
  6. package/dist/client.d.ts.map +1 -0
  7. package/dist/example.d.ts +2 -0
  8. package/dist/example.d.ts.map +1 -0
  9. package/dist/index.cjs +348 -251
  10. package/dist/index.cjs.map +1 -0
  11. package/dist/index.d.ts +4 -1224
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +348 -251
  14. package/dist/index.js.map +1 -0
  15. package/dist/resources/a2a.d.ts +44 -0
  16. package/dist/resources/a2a.d.ts.map +1 -0
  17. package/dist/resources/agent.d.ts +112 -0
  18. package/dist/resources/agent.d.ts.map +1 -0
  19. package/dist/resources/base.d.ts +13 -0
  20. package/dist/resources/base.d.ts.map +1 -0
  21. package/dist/resources/index.d.ts +11 -0
  22. package/dist/resources/index.d.ts.map +1 -0
  23. package/dist/resources/legacy-workflow.d.ts +87 -0
  24. package/dist/resources/legacy-workflow.d.ts.map +1 -0
  25. package/dist/resources/mcp-tool.d.ts +27 -0
  26. package/dist/resources/mcp-tool.d.ts.map +1 -0
  27. package/dist/resources/memory-thread.d.ts +53 -0
  28. package/dist/resources/memory-thread.d.ts.map +1 -0
  29. package/dist/resources/network-memory-thread.d.ts +47 -0
  30. package/dist/resources/network-memory-thread.d.ts.map +1 -0
  31. package/dist/resources/network.d.ts +30 -0
  32. package/dist/resources/network.d.ts.map +1 -0
  33. package/dist/resources/tool.d.ts +23 -0
  34. package/dist/resources/tool.d.ts.map +1 -0
  35. package/dist/resources/vNextNetwork.d.ts +42 -0
  36. package/dist/resources/vNextNetwork.d.ts.map +1 -0
  37. package/dist/resources/vector.d.ts +48 -0
  38. package/dist/resources/vector.d.ts.map +1 -0
  39. package/dist/resources/workflow.d.ts +154 -0
  40. package/dist/resources/workflow.d.ts.map +1 -0
  41. package/dist/types.d.ts +422 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/utils/index.d.ts +3 -0
  44. package/dist/utils/index.d.ts.map +1 -0
  45. package/dist/utils/process-client-tools.d.ts +3 -0
  46. package/dist/utils/process-client-tools.d.ts.map +1 -0
  47. package/dist/utils/zod-to-json-schema.d.ts +105 -0
  48. package/dist/utils/zod-to-json-schema.d.ts.map +1 -0
  49. package/integration-tests/agui-adapter.test.ts +122 -0
  50. package/integration-tests/package.json +18 -0
  51. package/integration-tests/src/mastra/index.ts +35 -0
  52. package/integration-tests/vitest.config.ts +9 -0
  53. package/package.json +10 -7
  54. package/src/adapters/agui.test.ts +145 -3
  55. package/src/client.ts +97 -0
  56. package/src/index.test.ts +349 -1
  57. package/src/index.ts +1 -0
  58. package/src/resources/agent.ts +285 -300
  59. package/src/resources/base.ts +3 -1
  60. package/src/resources/memory-thread.test.ts +285 -0
  61. package/src/resources/memory-thread.ts +18 -0
  62. package/src/resources/network-memory-thread.test.ts +269 -0
  63. package/src/resources/network-memory-thread.ts +18 -0
  64. package/src/resources/network.ts +4 -3
  65. package/src/types.ts +61 -6
  66. package/src/utils/process-client-tools.ts +1 -1
  67. package/src/v2-messages.test.ts +180 -0
  68. package/tsconfig.build.json +9 -0
  69. package/tsconfig.json +1 -1
  70. package/tsup.config.ts +22 -0
  71. package/dist/index.d.cts +0 -1224
package/dist/index.cjs CHANGED
@@ -5,7 +5,7 @@ var rxjs = require('rxjs');
5
5
  var uiUtils = require('@ai-sdk/ui-utils');
6
6
  var zod = require('zod');
7
7
  var originalZodToJsonSchema = require('zod-to-json-schema');
8
- var tools = require('@mastra/core/tools');
8
+ var isVercelTool = require('@mastra/core/tools/is-vercel-tool');
9
9
  var uuid = require('@lukeed/uuid');
10
10
  var runtimeContext = require('@mastra/core/runtime-context');
11
11
 
@@ -210,7 +210,7 @@ function processClientTools(clientTools) {
210
210
  }
211
211
  return Object.fromEntries(
212
212
  Object.entries(clientTools).map(([key, value]) => {
213
- if (tools.isVercelTool(value)) {
213
+ if (isVercelTool.isVercelTool(value)) {
214
214
  return [
215
215
  key,
216
216
  {
@@ -253,7 +253,7 @@ var BaseResource = class {
253
253
  const response = await fetch(`${baseUrl.replace(/\/$/, "")}${path}`, {
254
254
  ...options,
255
255
  headers: {
256
- ...options.body && (options.method === "POST" || options.method === "PUT") ? { "content-type": "application/json" } : {},
256
+ ...options.body && !(options.body instanceof FormData) && (options.method === "POST" || options.method === "PUT") ? { "content-type": "application/json" } : {},
257
257
  ...headers,
258
258
  ...options.headers
259
259
  // TODO: Bring this back once we figure out what we/users need to do to make this work with cross-origin requests
@@ -378,10 +378,13 @@ var Agent = class extends BaseResource {
378
378
  clientTools: processClientTools(params.clientTools)
379
379
  };
380
380
  const { runId, resourceId, threadId, runtimeContext } = processedParams;
381
- const response = await this.request(`/api/agents/${this.agentId}/generate`, {
382
- method: "POST",
383
- body: processedParams
384
- });
381
+ const response = await this.request(
382
+ `/api/agents/${this.agentId}/generate`,
383
+ {
384
+ method: "POST",
385
+ body: processedParams
386
+ }
387
+ );
385
388
  if (response.finishReason === "tool-calls") {
386
389
  const toolCalls = response.toolCalls;
387
390
  if (!toolCalls || !Array.isArray(toolCalls)) {
@@ -430,8 +433,7 @@ var Agent = class extends BaseResource {
430
433
  onToolCall,
431
434
  onFinish,
432
435
  getCurrentDate = () => /* @__PURE__ */ new Date(),
433
- lastMessage,
434
- streamProtocol
436
+ lastMessage
435
437
  }) {
436
438
  const replaceLastMessage = lastMessage?.role === "assistant";
437
439
  let step = replaceLastMessage ? 1 + // find max step in existing tool invocations:
@@ -492,213 +494,228 @@ var Agent = class extends BaseResource {
492
494
  replaceLastMessage
493
495
  });
494
496
  }
495
- if (streamProtocol === "text") {
496
- await uiUtils.processTextStream({
497
- stream,
498
- onTextPart(value) {
499
- message.content += value;
500
- execUpdate();
497
+ await uiUtils.processDataStream({
498
+ stream,
499
+ onTextPart(value) {
500
+ if (currentTextPart == null) {
501
+ currentTextPart = {
502
+ type: "text",
503
+ text: value
504
+ };
505
+ message.parts.push(currentTextPart);
506
+ } else {
507
+ currentTextPart.text += value;
501
508
  }
502
- });
503
- onFinish?.({ message, finishReason, usage });
504
- } else {
505
- await uiUtils.processDataStream({
506
- stream,
507
- onTextPart(value) {
508
- if (currentTextPart == null) {
509
- currentTextPart = {
510
- type: "text",
511
- text: value
512
- };
513
- message.parts.push(currentTextPart);
514
- } else {
515
- currentTextPart.text += value;
516
- }
517
- message.content += value;
518
- execUpdate();
519
- },
520
- onReasoningPart(value) {
521
- if (currentReasoningTextDetail == null) {
522
- currentReasoningTextDetail = { type: "text", text: value };
523
- if (currentReasoningPart != null) {
524
- currentReasoningPart.details.push(currentReasoningTextDetail);
525
- }
526
- } else {
527
- currentReasoningTextDetail.text += value;
528
- }
529
- if (currentReasoningPart == null) {
530
- currentReasoningPart = {
531
- type: "reasoning",
532
- reasoning: value,
533
- details: [currentReasoningTextDetail]
534
- };
535
- message.parts.push(currentReasoningPart);
536
- } else {
537
- currentReasoningPart.reasoning += value;
538
- }
539
- message.reasoning = (message.reasoning ?? "") + value;
540
- execUpdate();
541
- },
542
- onReasoningSignaturePart(value) {
543
- if (currentReasoningTextDetail != null) {
544
- currentReasoningTextDetail.signature = value.signature;
545
- }
546
- },
547
- onRedactedReasoningPart(value) {
548
- if (currentReasoningPart == null) {
549
- currentReasoningPart = {
550
- type: "reasoning",
551
- reasoning: "",
552
- details: []
553
- };
554
- message.parts.push(currentReasoningPart);
509
+ message.content += value;
510
+ execUpdate();
511
+ },
512
+ onReasoningPart(value) {
513
+ if (currentReasoningTextDetail == null) {
514
+ currentReasoningTextDetail = { type: "text", text: value };
515
+ if (currentReasoningPart != null) {
516
+ currentReasoningPart.details.push(currentReasoningTextDetail);
555
517
  }
556
- currentReasoningPart.details.push({
557
- type: "redacted",
558
- data: value.data
559
- });
560
- currentReasoningTextDetail = void 0;
561
- execUpdate();
562
- },
563
- onFilePart(value) {
564
- message.parts.push({
565
- type: "file",
566
- mimeType: value.mimeType,
567
- data: value.data
568
- });
569
- execUpdate();
570
- },
571
- onSourcePart(value) {
572
- message.parts.push({
573
- type: "source",
574
- source: value
575
- });
576
- execUpdate();
577
- },
578
- onToolCallStreamingStartPart(value) {
518
+ } else {
519
+ currentReasoningTextDetail.text += value;
520
+ }
521
+ if (currentReasoningPart == null) {
522
+ currentReasoningPart = {
523
+ type: "reasoning",
524
+ reasoning: value,
525
+ details: [currentReasoningTextDetail]
526
+ };
527
+ message.parts.push(currentReasoningPart);
528
+ } else {
529
+ currentReasoningPart.reasoning += value;
530
+ }
531
+ message.reasoning = (message.reasoning ?? "") + value;
532
+ execUpdate();
533
+ },
534
+ onReasoningSignaturePart(value) {
535
+ if (currentReasoningTextDetail != null) {
536
+ currentReasoningTextDetail.signature = value.signature;
537
+ }
538
+ },
539
+ onRedactedReasoningPart(value) {
540
+ if (currentReasoningPart == null) {
541
+ currentReasoningPart = {
542
+ type: "reasoning",
543
+ reasoning: "",
544
+ details: []
545
+ };
546
+ message.parts.push(currentReasoningPart);
547
+ }
548
+ currentReasoningPart.details.push({
549
+ type: "redacted",
550
+ data: value.data
551
+ });
552
+ currentReasoningTextDetail = void 0;
553
+ execUpdate();
554
+ },
555
+ onFilePart(value) {
556
+ message.parts.push({
557
+ type: "file",
558
+ mimeType: value.mimeType,
559
+ data: value.data
560
+ });
561
+ execUpdate();
562
+ },
563
+ onSourcePart(value) {
564
+ message.parts.push({
565
+ type: "source",
566
+ source: value
567
+ });
568
+ execUpdate();
569
+ },
570
+ onToolCallStreamingStartPart(value) {
571
+ if (message.toolInvocations == null) {
572
+ message.toolInvocations = [];
573
+ }
574
+ partialToolCalls[value.toolCallId] = {
575
+ text: "",
576
+ step,
577
+ toolName: value.toolName,
578
+ index: message.toolInvocations.length
579
+ };
580
+ const invocation = {
581
+ state: "partial-call",
582
+ step,
583
+ toolCallId: value.toolCallId,
584
+ toolName: value.toolName,
585
+ args: void 0
586
+ };
587
+ message.toolInvocations.push(invocation);
588
+ updateToolInvocationPart(value.toolCallId, invocation);
589
+ execUpdate();
590
+ },
591
+ onToolCallDeltaPart(value) {
592
+ const partialToolCall = partialToolCalls[value.toolCallId];
593
+ partialToolCall.text += value.argsTextDelta;
594
+ const { value: partialArgs } = uiUtils.parsePartialJson(partialToolCall.text);
595
+ const invocation = {
596
+ state: "partial-call",
597
+ step: partialToolCall.step,
598
+ toolCallId: value.toolCallId,
599
+ toolName: partialToolCall.toolName,
600
+ args: partialArgs
601
+ };
602
+ message.toolInvocations[partialToolCall.index] = invocation;
603
+ updateToolInvocationPart(value.toolCallId, invocation);
604
+ execUpdate();
605
+ },
606
+ async onToolCallPart(value) {
607
+ const invocation = {
608
+ state: "call",
609
+ step,
610
+ ...value
611
+ };
612
+ if (partialToolCalls[value.toolCallId] != null) {
613
+ message.toolInvocations[partialToolCalls[value.toolCallId].index] = invocation;
614
+ } else {
579
615
  if (message.toolInvocations == null) {
580
616
  message.toolInvocations = [];
581
617
  }
582
- partialToolCalls[value.toolCallId] = {
583
- text: "",
584
- step,
585
- toolName: value.toolName,
586
- index: message.toolInvocations.length
587
- };
588
- const invocation = {
589
- state: "partial-call",
590
- step,
591
- toolCallId: value.toolCallId,
592
- toolName: value.toolName,
593
- args: void 0
594
- };
595
618
  message.toolInvocations.push(invocation);
596
- updateToolInvocationPart(value.toolCallId, invocation);
597
- execUpdate();
598
- },
599
- onToolCallDeltaPart(value) {
600
- const partialToolCall = partialToolCalls[value.toolCallId];
601
- partialToolCall.text += value.argsTextDelta;
602
- const { value: partialArgs } = uiUtils.parsePartialJson(partialToolCall.text);
603
- const invocation = {
604
- state: "partial-call",
605
- step: partialToolCall.step,
606
- toolCallId: value.toolCallId,
607
- toolName: partialToolCall.toolName,
608
- args: partialArgs
609
- };
610
- message.toolInvocations[partialToolCall.index] = invocation;
611
- updateToolInvocationPart(value.toolCallId, invocation);
612
- execUpdate();
613
- },
614
- async onToolCallPart(value) {
615
- const invocation = {
616
- state: "call",
617
- step,
618
- ...value
619
- };
620
- if (partialToolCalls[value.toolCallId] != null) {
621
- message.toolInvocations[partialToolCalls[value.toolCallId].index] = invocation;
622
- } else {
623
- if (message.toolInvocations == null) {
624
- message.toolInvocations = [];
625
- }
626
- message.toolInvocations.push(invocation);
627
- }
628
- updateToolInvocationPart(value.toolCallId, invocation);
629
- execUpdate();
630
- if (onToolCall) {
631
- const result = await onToolCall({ toolCall: value });
632
- if (result != null) {
633
- const invocation2 = {
634
- state: "result",
635
- step,
636
- ...value,
637
- result
638
- };
639
- message.toolInvocations[message.toolInvocations.length - 1] = invocation2;
640
- updateToolInvocationPart(value.toolCallId, invocation2);
641
- execUpdate();
642
- }
643
- }
644
- },
645
- onToolResultPart(value) {
646
- const toolInvocations = message.toolInvocations;
647
- if (toolInvocations == null) {
648
- throw new Error("tool_result must be preceded by a tool_call");
649
- }
650
- const toolInvocationIndex = toolInvocations.findIndex(
651
- (invocation2) => invocation2.toolCallId === value.toolCallId
652
- );
653
- if (toolInvocationIndex === -1) {
654
- throw new Error("tool_result must be preceded by a tool_call with the same toolCallId");
655
- }
656
- const invocation = {
657
- ...toolInvocations[toolInvocationIndex],
658
- state: "result",
659
- ...value
660
- };
661
- toolInvocations[toolInvocationIndex] = invocation;
662
- updateToolInvocationPart(value.toolCallId, invocation);
663
- execUpdate();
664
- },
665
- onDataPart(value) {
666
- data.push(...value);
667
- execUpdate();
668
- },
669
- onMessageAnnotationsPart(value) {
670
- if (messageAnnotations == null) {
671
- messageAnnotations = [...value];
672
- } else {
673
- messageAnnotations.push(...value);
674
- }
675
- execUpdate();
676
- },
677
- onFinishStepPart(value) {
678
- step += 1;
679
- currentTextPart = value.isContinued ? currentTextPart : void 0;
680
- currentReasoningPart = void 0;
681
- currentReasoningTextDetail = void 0;
682
- },
683
- onStartStepPart(value) {
684
- if (!replaceLastMessage) {
685
- message.id = value.messageId;
686
- }
687
- message.parts.push({ type: "step-start" });
688
- execUpdate();
689
- },
690
- onFinishMessagePart(value) {
691
- finishReason = value.finishReason;
692
- if (value.usage != null) {
693
- usage = value.usage;
619
+ }
620
+ updateToolInvocationPart(value.toolCallId, invocation);
621
+ execUpdate();
622
+ if (onToolCall) {
623
+ const result = await onToolCall({ toolCall: value });
624
+ if (result != null) {
625
+ const invocation2 = {
626
+ state: "result",
627
+ step,
628
+ ...value,
629
+ result
630
+ };
631
+ message.toolInvocations[message.toolInvocations.length - 1] = invocation2;
632
+ updateToolInvocationPart(value.toolCallId, invocation2);
633
+ execUpdate();
694
634
  }
695
- },
696
- onErrorPart(error) {
697
- throw new Error(error);
698
635
  }
636
+ },
637
+ onToolResultPart(value) {
638
+ const toolInvocations = message.toolInvocations;
639
+ if (toolInvocations == null) {
640
+ throw new Error("tool_result must be preceded by a tool_call");
641
+ }
642
+ const toolInvocationIndex = toolInvocations.findIndex((invocation2) => invocation2.toolCallId === value.toolCallId);
643
+ if (toolInvocationIndex === -1) {
644
+ throw new Error("tool_result must be preceded by a tool_call with the same toolCallId");
645
+ }
646
+ const invocation = {
647
+ ...toolInvocations[toolInvocationIndex],
648
+ state: "result",
649
+ ...value
650
+ };
651
+ toolInvocations[toolInvocationIndex] = invocation;
652
+ updateToolInvocationPart(value.toolCallId, invocation);
653
+ execUpdate();
654
+ },
655
+ onDataPart(value) {
656
+ data.push(...value);
657
+ execUpdate();
658
+ },
659
+ onMessageAnnotationsPart(value) {
660
+ if (messageAnnotations == null) {
661
+ messageAnnotations = [...value];
662
+ } else {
663
+ messageAnnotations.push(...value);
664
+ }
665
+ execUpdate();
666
+ },
667
+ onFinishStepPart(value) {
668
+ step += 1;
669
+ currentTextPart = value.isContinued ? currentTextPart : void 0;
670
+ currentReasoningPart = void 0;
671
+ currentReasoningTextDetail = void 0;
672
+ },
673
+ onStartStepPart(value) {
674
+ if (!replaceLastMessage) {
675
+ message.id = value.messageId;
676
+ }
677
+ message.parts.push({ type: "step-start" });
678
+ execUpdate();
679
+ },
680
+ onFinishMessagePart(value) {
681
+ finishReason = value.finishReason;
682
+ if (value.usage != null) {
683
+ usage = value.usage;
684
+ }
685
+ },
686
+ onErrorPart(error) {
687
+ throw new Error(error);
688
+ }
689
+ });
690
+ onFinish?.({ message, finishReason, usage });
691
+ }
692
+ /**
693
+ * Streams a response from the agent
694
+ * @param params - Stream parameters including prompt
695
+ * @returns Promise containing the enhanced Response object with processDataStream method
696
+ */
697
+ async stream(params) {
698
+ const processedParams = {
699
+ ...params,
700
+ output: params.output ? zodToJsonSchema(params.output) : void 0,
701
+ experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
702
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext),
703
+ clientTools: processClientTools(params.clientTools)
704
+ };
705
+ const { readable, writable } = new TransformStream();
706
+ const response = await this.processStreamResponse(processedParams, writable);
707
+ const streamResponse = new Response(readable, {
708
+ status: response.status,
709
+ statusText: response.statusText,
710
+ headers: response.headers
711
+ });
712
+ streamResponse.processDataStream = async (options = {}) => {
713
+ await uiUtils.processDataStream({
714
+ stream: streamResponse.body,
715
+ ...options
699
716
  });
700
- onFinish?.({ message, finishReason, usage });
701
- }
717
+ };
718
+ return streamResponse;
702
719
  }
703
720
  /**
704
721
  * Processes the stream response and handles tool calls
@@ -713,7 +730,6 @@ var Agent = class extends BaseResource {
713
730
  throw new Error("No response body");
714
731
  }
715
732
  try {
716
- const streamProtocol = processedParams.output ? "text" : "data";
717
733
  let toolCalls = [];
718
734
  let messages = [];
719
735
  const [streamForWritable, streamForProcessing] = response.body.tee();
@@ -725,7 +741,12 @@ var Agent = class extends BaseResource {
725
741
  this.processChatResponse({
726
742
  stream: streamForProcessing,
727
743
  update: ({ message }) => {
728
- messages.push(message);
744
+ const existingIndex = messages.findIndex((m) => m.id === message.id);
745
+ if (existingIndex !== -1) {
746
+ messages[existingIndex] = message;
747
+ } else {
748
+ messages.push(message);
749
+ }
729
750
  },
730
751
  onFinish: async ({ finishReason, message }) => {
731
752
  if (finishReason === "tool-calls") {
@@ -785,63 +806,29 @@ var Agent = class extends BaseResource {
785
806
  this.processStreamResponse(
786
807
  {
787
808
  ...processedParams,
788
- messages: [...messageArray, ...messages, lastMessage]
809
+ messages: [...messageArray, ...messages.filter((m) => m.id !== lastMessage.id), lastMessage]
789
810
  },
790
811
  writable
791
- );
812
+ ).catch((error) => {
813
+ console.error("Error processing stream response:", error);
814
+ });
792
815
  }
793
816
  }
794
817
  } else {
795
818
  setTimeout(() => {
796
- if (!writable.locked) {
797
- writable.close();
798
- }
819
+ writable.close();
799
820
  }, 0);
800
821
  }
801
822
  },
802
- lastMessage: void 0,
803
- streamProtocol
823
+ lastMessage: void 0
824
+ }).catch((error) => {
825
+ console.error("Error processing stream response:", error);
804
826
  });
805
827
  } catch (error) {
806
828
  console.error("Error processing stream response:", error);
807
829
  }
808
830
  return response;
809
831
  }
810
- /**
811
- * Streams a response from the agent
812
- * @param params - Stream parameters including prompt
813
- * @returns Promise containing the enhanced Response object with processDataStream and processTextStream methods
814
- */
815
- async stream(params) {
816
- const processedParams = {
817
- ...params,
818
- output: params.output ? zodToJsonSchema(params.output) : void 0,
819
- experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
820
- runtimeContext: parseClientRuntimeContext(params.runtimeContext),
821
- clientTools: processClientTools(params.clientTools)
822
- };
823
- const { readable, writable } = new TransformStream();
824
- const response = await this.processStreamResponse(processedParams, writable);
825
- const streamResponse = new Response(readable, {
826
- status: response.status,
827
- statusText: response.statusText,
828
- headers: response.headers
829
- });
830
- streamResponse.processDataStream = async (options = {}) => {
831
- await uiUtils.processDataStream({
832
- stream: streamResponse.body,
833
- ...options
834
- });
835
- };
836
- streamResponse.processTextStream = async (options) => {
837
- await uiUtils.processTextStream({
838
- stream: streamResponse.body,
839
- onTextPart: options?.onTextPart ?? (() => {
840
- })
841
- });
842
- };
843
- return streamResponse;
844
- }
845
832
  /**
846
833
  * Gets details about a specific tool available to the agent
847
834
  * @param toolId - ID of the tool to retrieve
@@ -999,6 +986,21 @@ var MemoryThread = class extends BaseResource {
999
986
  });
1000
987
  return this.request(`/api/memory/threads/${this.threadId}/messages/paginated?${query.toString()}`);
1001
988
  }
989
+ /**
990
+ * Deletes one or more messages from the thread
991
+ * @param messageIds - Can be a single message ID (string), array of message IDs,
992
+ * message object with id property, or array of message objects
993
+ * @returns Promise containing deletion result
994
+ */
995
+ deleteMessages(messageIds) {
996
+ const query = new URLSearchParams({
997
+ agentId: this.agentId
998
+ });
999
+ return this.request(`/api/memory/messages/delete?${query.toString()}`, {
1000
+ method: "POST",
1001
+ body: { messageIds }
1002
+ });
1003
+ }
1002
1004
  };
1003
1005
 
1004
1006
  // src/resources/vector.ts
@@ -1747,6 +1749,21 @@ var NetworkMemoryThread = class extends BaseResource {
1747
1749
  });
1748
1750
  return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
1749
1751
  }
1752
+ /**
1753
+ * Deletes one or more messages from the thread
1754
+ * @param messageIds - Can be a single message ID (string), array of message IDs,
1755
+ * message object with id property, or array of message objects
1756
+ * @returns Promise containing deletion result
1757
+ */
1758
+ deleteMessages(messageIds) {
1759
+ const query = new URLSearchParams({
1760
+ networkId: this.networkId
1761
+ });
1762
+ return this.request(`/api/memory/network/messages/delete?${query.toString()}`, {
1763
+ method: "POST",
1764
+ body: { messageIds }
1765
+ });
1766
+ }
1750
1767
  };
1751
1768
 
1752
1769
  // src/resources/vNextNetwork.ts
@@ -2316,6 +2333,86 @@ var MastraClient = class extends BaseResource {
2316
2333
  }
2317
2334
  });
2318
2335
  }
2336
+ /**
2337
+ * Retrieves all available scorers
2338
+ * @returns Promise containing list of available scorers
2339
+ */
2340
+ getScorers() {
2341
+ return this.request("/api/scores/scorers");
2342
+ }
2343
+ /**
2344
+ * Retrieves a scorer by ID
2345
+ * @param scorerId - ID of the scorer to retrieve
2346
+ * @returns Promise containing the scorer
2347
+ */
2348
+ getScorer(scorerId) {
2349
+ return this.request(`/api/scores/scorers/${scorerId}`);
2350
+ }
2351
+ getScoresByScorerId(params) {
2352
+ const { page, perPage, scorerId, entityId, entityType } = params;
2353
+ const searchParams = new URLSearchParams();
2354
+ if (entityId) {
2355
+ searchParams.set("entityId", entityId);
2356
+ }
2357
+ if (entityType) {
2358
+ searchParams.set("entityType", entityType);
2359
+ }
2360
+ if (page !== void 0) {
2361
+ searchParams.set("page", String(page));
2362
+ }
2363
+ if (perPage !== void 0) {
2364
+ searchParams.set("perPage", String(perPage));
2365
+ }
2366
+ const queryString = searchParams.toString();
2367
+ return this.request(`/api/scores/scorer/${scorerId}${queryString ? `?${queryString}` : ""}`);
2368
+ }
2369
+ /**
2370
+ * Retrieves scores by run ID
2371
+ * @param params - Parameters containing run ID and pagination options
2372
+ * @returns Promise containing scores and pagination info
2373
+ */
2374
+ getScoresByRunId(params) {
2375
+ const { runId, page, perPage } = params;
2376
+ const searchParams = new URLSearchParams();
2377
+ if (page !== void 0) {
2378
+ searchParams.set("page", String(page));
2379
+ }
2380
+ if (perPage !== void 0) {
2381
+ searchParams.set("perPage", String(perPage));
2382
+ }
2383
+ const queryString = searchParams.toString();
2384
+ return this.request(`/api/scores/run/${runId}${queryString ? `?${queryString}` : ""}`);
2385
+ }
2386
+ /**
2387
+ * Retrieves scores by entity ID and type
2388
+ * @param params - Parameters containing entity ID, type, and pagination options
2389
+ * @returns Promise containing scores and pagination info
2390
+ */
2391
+ getScoresByEntityId(params) {
2392
+ const { entityId, entityType, page, perPage } = params;
2393
+ const searchParams = new URLSearchParams();
2394
+ if (page !== void 0) {
2395
+ searchParams.set("page", String(page));
2396
+ }
2397
+ if (perPage !== void 0) {
2398
+ searchParams.set("perPage", String(perPage));
2399
+ }
2400
+ const queryString = searchParams.toString();
2401
+ return this.request(`/api/scores/entity/${entityType}/${entityId}${queryString ? `?${queryString}` : ""}`);
2402
+ }
2403
+ /**
2404
+ * Saves a score
2405
+ * @param params - Parameters containing the score data to save
2406
+ * @returns Promise containing the saved score
2407
+ */
2408
+ saveScore(params) {
2409
+ return this.request("/api/scores", {
2410
+ method: "POST",
2411
+ body: params
2412
+ });
2413
+ }
2319
2414
  };
2320
2415
 
2321
2416
  exports.MastraClient = MastraClient;
2417
+ //# sourceMappingURL=index.cjs.map
2418
+ //# sourceMappingURL=index.cjs.map