@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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,YAAY,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { AbstractAgent, EventType } from '@ag-ui/client';
2
2
  import { Observable } from 'rxjs';
3
- import { processTextStream, processDataStream, parsePartialJson } from '@ai-sdk/ui-utils';
3
+ import { processDataStream, parsePartialJson } from '@ai-sdk/ui-utils';
4
4
  import { ZodSchema } from 'zod';
5
5
  import originalZodToJsonSchema from 'zod-to-json-schema';
6
- import { isVercelTool } from '@mastra/core/tools';
6
+ import { isVercelTool } from '@mastra/core/tools/is-vercel-tool';
7
7
  import { v4 } from '@lukeed/uuid';
8
8
  import { RuntimeContext } from '@mastra/core/runtime-context';
9
9
 
@@ -247,7 +247,7 @@ var BaseResource = class {
247
247
  const response = await fetch(`${baseUrl.replace(/\/$/, "")}${path}`, {
248
248
  ...options,
249
249
  headers: {
250
- ...options.body && (options.method === "POST" || options.method === "PUT") ? { "content-type": "application/json" } : {},
250
+ ...options.body && !(options.body instanceof FormData) && (options.method === "POST" || options.method === "PUT") ? { "content-type": "application/json" } : {},
251
251
  ...headers,
252
252
  ...options.headers
253
253
  // TODO: Bring this back once we figure out what we/users need to do to make this work with cross-origin requests
@@ -372,10 +372,13 @@ var Agent = class extends BaseResource {
372
372
  clientTools: processClientTools(params.clientTools)
373
373
  };
374
374
  const { runId, resourceId, threadId, runtimeContext } = processedParams;
375
- const response = await this.request(`/api/agents/${this.agentId}/generate`, {
376
- method: "POST",
377
- body: processedParams
378
- });
375
+ const response = await this.request(
376
+ `/api/agents/${this.agentId}/generate`,
377
+ {
378
+ method: "POST",
379
+ body: processedParams
380
+ }
381
+ );
379
382
  if (response.finishReason === "tool-calls") {
380
383
  const toolCalls = response.toolCalls;
381
384
  if (!toolCalls || !Array.isArray(toolCalls)) {
@@ -424,8 +427,7 @@ var Agent = class extends BaseResource {
424
427
  onToolCall,
425
428
  onFinish,
426
429
  getCurrentDate = () => /* @__PURE__ */ new Date(),
427
- lastMessage,
428
- streamProtocol
430
+ lastMessage
429
431
  }) {
430
432
  const replaceLastMessage = lastMessage?.role === "assistant";
431
433
  let step = replaceLastMessage ? 1 + // find max step in existing tool invocations:
@@ -486,213 +488,228 @@ var Agent = class extends BaseResource {
486
488
  replaceLastMessage
487
489
  });
488
490
  }
489
- if (streamProtocol === "text") {
490
- await processTextStream({
491
- stream,
492
- onTextPart(value) {
493
- message.content += value;
494
- execUpdate();
491
+ await processDataStream({
492
+ stream,
493
+ onTextPart(value) {
494
+ if (currentTextPart == null) {
495
+ currentTextPart = {
496
+ type: "text",
497
+ text: value
498
+ };
499
+ message.parts.push(currentTextPart);
500
+ } else {
501
+ currentTextPart.text += value;
495
502
  }
496
- });
497
- onFinish?.({ message, finishReason, usage });
498
- } else {
499
- await processDataStream({
500
- stream,
501
- onTextPart(value) {
502
- if (currentTextPart == null) {
503
- currentTextPart = {
504
- type: "text",
505
- text: value
506
- };
507
- message.parts.push(currentTextPart);
508
- } else {
509
- currentTextPart.text += value;
510
- }
511
- message.content += value;
512
- execUpdate();
513
- },
514
- onReasoningPart(value) {
515
- if (currentReasoningTextDetail == null) {
516
- currentReasoningTextDetail = { type: "text", text: value };
517
- if (currentReasoningPart != null) {
518
- currentReasoningPart.details.push(currentReasoningTextDetail);
519
- }
520
- } else {
521
- currentReasoningTextDetail.text += value;
522
- }
523
- if (currentReasoningPart == null) {
524
- currentReasoningPart = {
525
- type: "reasoning",
526
- reasoning: value,
527
- details: [currentReasoningTextDetail]
528
- };
529
- message.parts.push(currentReasoningPart);
530
- } else {
531
- currentReasoningPart.reasoning += value;
532
- }
533
- message.reasoning = (message.reasoning ?? "") + value;
534
- execUpdate();
535
- },
536
- onReasoningSignaturePart(value) {
537
- if (currentReasoningTextDetail != null) {
538
- currentReasoningTextDetail.signature = value.signature;
539
- }
540
- },
541
- onRedactedReasoningPart(value) {
542
- if (currentReasoningPart == null) {
543
- currentReasoningPart = {
544
- type: "reasoning",
545
- reasoning: "",
546
- details: []
547
- };
548
- message.parts.push(currentReasoningPart);
503
+ message.content += value;
504
+ execUpdate();
505
+ },
506
+ onReasoningPart(value) {
507
+ if (currentReasoningTextDetail == null) {
508
+ currentReasoningTextDetail = { type: "text", text: value };
509
+ if (currentReasoningPart != null) {
510
+ currentReasoningPart.details.push(currentReasoningTextDetail);
549
511
  }
550
- currentReasoningPart.details.push({
551
- type: "redacted",
552
- data: value.data
553
- });
554
- currentReasoningTextDetail = void 0;
555
- execUpdate();
556
- },
557
- onFilePart(value) {
558
- message.parts.push({
559
- type: "file",
560
- mimeType: value.mimeType,
561
- data: value.data
562
- });
563
- execUpdate();
564
- },
565
- onSourcePart(value) {
566
- message.parts.push({
567
- type: "source",
568
- source: value
569
- });
570
- execUpdate();
571
- },
572
- onToolCallStreamingStartPart(value) {
512
+ } else {
513
+ currentReasoningTextDetail.text += value;
514
+ }
515
+ if (currentReasoningPart == null) {
516
+ currentReasoningPart = {
517
+ type: "reasoning",
518
+ reasoning: value,
519
+ details: [currentReasoningTextDetail]
520
+ };
521
+ message.parts.push(currentReasoningPart);
522
+ } else {
523
+ currentReasoningPart.reasoning += value;
524
+ }
525
+ message.reasoning = (message.reasoning ?? "") + value;
526
+ execUpdate();
527
+ },
528
+ onReasoningSignaturePart(value) {
529
+ if (currentReasoningTextDetail != null) {
530
+ currentReasoningTextDetail.signature = value.signature;
531
+ }
532
+ },
533
+ onRedactedReasoningPart(value) {
534
+ if (currentReasoningPart == null) {
535
+ currentReasoningPart = {
536
+ type: "reasoning",
537
+ reasoning: "",
538
+ details: []
539
+ };
540
+ message.parts.push(currentReasoningPart);
541
+ }
542
+ currentReasoningPart.details.push({
543
+ type: "redacted",
544
+ data: value.data
545
+ });
546
+ currentReasoningTextDetail = void 0;
547
+ execUpdate();
548
+ },
549
+ onFilePart(value) {
550
+ message.parts.push({
551
+ type: "file",
552
+ mimeType: value.mimeType,
553
+ data: value.data
554
+ });
555
+ execUpdate();
556
+ },
557
+ onSourcePart(value) {
558
+ message.parts.push({
559
+ type: "source",
560
+ source: value
561
+ });
562
+ execUpdate();
563
+ },
564
+ onToolCallStreamingStartPart(value) {
565
+ if (message.toolInvocations == null) {
566
+ message.toolInvocations = [];
567
+ }
568
+ partialToolCalls[value.toolCallId] = {
569
+ text: "",
570
+ step,
571
+ toolName: value.toolName,
572
+ index: message.toolInvocations.length
573
+ };
574
+ const invocation = {
575
+ state: "partial-call",
576
+ step,
577
+ toolCallId: value.toolCallId,
578
+ toolName: value.toolName,
579
+ args: void 0
580
+ };
581
+ message.toolInvocations.push(invocation);
582
+ updateToolInvocationPart(value.toolCallId, invocation);
583
+ execUpdate();
584
+ },
585
+ onToolCallDeltaPart(value) {
586
+ const partialToolCall = partialToolCalls[value.toolCallId];
587
+ partialToolCall.text += value.argsTextDelta;
588
+ const { value: partialArgs } = parsePartialJson(partialToolCall.text);
589
+ const invocation = {
590
+ state: "partial-call",
591
+ step: partialToolCall.step,
592
+ toolCallId: value.toolCallId,
593
+ toolName: partialToolCall.toolName,
594
+ args: partialArgs
595
+ };
596
+ message.toolInvocations[partialToolCall.index] = invocation;
597
+ updateToolInvocationPart(value.toolCallId, invocation);
598
+ execUpdate();
599
+ },
600
+ async onToolCallPart(value) {
601
+ const invocation = {
602
+ state: "call",
603
+ step,
604
+ ...value
605
+ };
606
+ if (partialToolCalls[value.toolCallId] != null) {
607
+ message.toolInvocations[partialToolCalls[value.toolCallId].index] = invocation;
608
+ } else {
573
609
  if (message.toolInvocations == null) {
574
610
  message.toolInvocations = [];
575
611
  }
576
- partialToolCalls[value.toolCallId] = {
577
- text: "",
578
- step,
579
- toolName: value.toolName,
580
- index: message.toolInvocations.length
581
- };
582
- const invocation = {
583
- state: "partial-call",
584
- step,
585
- toolCallId: value.toolCallId,
586
- toolName: value.toolName,
587
- args: void 0
588
- };
589
612
  message.toolInvocations.push(invocation);
590
- updateToolInvocationPart(value.toolCallId, invocation);
591
- execUpdate();
592
- },
593
- onToolCallDeltaPart(value) {
594
- const partialToolCall = partialToolCalls[value.toolCallId];
595
- partialToolCall.text += value.argsTextDelta;
596
- const { value: partialArgs } = parsePartialJson(partialToolCall.text);
597
- const invocation = {
598
- state: "partial-call",
599
- step: partialToolCall.step,
600
- toolCallId: value.toolCallId,
601
- toolName: partialToolCall.toolName,
602
- args: partialArgs
603
- };
604
- message.toolInvocations[partialToolCall.index] = invocation;
605
- updateToolInvocationPart(value.toolCallId, invocation);
606
- execUpdate();
607
- },
608
- async onToolCallPart(value) {
609
- const invocation = {
610
- state: "call",
611
- step,
612
- ...value
613
- };
614
- if (partialToolCalls[value.toolCallId] != null) {
615
- message.toolInvocations[partialToolCalls[value.toolCallId].index] = invocation;
616
- } else {
617
- if (message.toolInvocations == null) {
618
- message.toolInvocations = [];
619
- }
620
- message.toolInvocations.push(invocation);
621
- }
622
- updateToolInvocationPart(value.toolCallId, invocation);
623
- execUpdate();
624
- if (onToolCall) {
625
- const result = await onToolCall({ toolCall: value });
626
- if (result != null) {
627
- const invocation2 = {
628
- state: "result",
629
- step,
630
- ...value,
631
- result
632
- };
633
- message.toolInvocations[message.toolInvocations.length - 1] = invocation2;
634
- updateToolInvocationPart(value.toolCallId, invocation2);
635
- execUpdate();
636
- }
637
- }
638
- },
639
- onToolResultPart(value) {
640
- const toolInvocations = message.toolInvocations;
641
- if (toolInvocations == null) {
642
- throw new Error("tool_result must be preceded by a tool_call");
643
- }
644
- const toolInvocationIndex = toolInvocations.findIndex(
645
- (invocation2) => invocation2.toolCallId === value.toolCallId
646
- );
647
- if (toolInvocationIndex === -1) {
648
- throw new Error("tool_result must be preceded by a tool_call with the same toolCallId");
649
- }
650
- const invocation = {
651
- ...toolInvocations[toolInvocationIndex],
652
- state: "result",
653
- ...value
654
- };
655
- toolInvocations[toolInvocationIndex] = invocation;
656
- updateToolInvocationPart(value.toolCallId, invocation);
657
- execUpdate();
658
- },
659
- onDataPart(value) {
660
- data.push(...value);
661
- execUpdate();
662
- },
663
- onMessageAnnotationsPart(value) {
664
- if (messageAnnotations == null) {
665
- messageAnnotations = [...value];
666
- } else {
667
- messageAnnotations.push(...value);
668
- }
669
- execUpdate();
670
- },
671
- onFinishStepPart(value) {
672
- step += 1;
673
- currentTextPart = value.isContinued ? currentTextPart : void 0;
674
- currentReasoningPart = void 0;
675
- currentReasoningTextDetail = void 0;
676
- },
677
- onStartStepPart(value) {
678
- if (!replaceLastMessage) {
679
- message.id = value.messageId;
680
- }
681
- message.parts.push({ type: "step-start" });
682
- execUpdate();
683
- },
684
- onFinishMessagePart(value) {
685
- finishReason = value.finishReason;
686
- if (value.usage != null) {
687
- usage = value.usage;
613
+ }
614
+ updateToolInvocationPart(value.toolCallId, invocation);
615
+ execUpdate();
616
+ if (onToolCall) {
617
+ const result = await onToolCall({ toolCall: value });
618
+ if (result != null) {
619
+ const invocation2 = {
620
+ state: "result",
621
+ step,
622
+ ...value,
623
+ result
624
+ };
625
+ message.toolInvocations[message.toolInvocations.length - 1] = invocation2;
626
+ updateToolInvocationPart(value.toolCallId, invocation2);
627
+ execUpdate();
688
628
  }
689
- },
690
- onErrorPart(error) {
691
- throw new Error(error);
692
629
  }
630
+ },
631
+ onToolResultPart(value) {
632
+ const toolInvocations = message.toolInvocations;
633
+ if (toolInvocations == null) {
634
+ throw new Error("tool_result must be preceded by a tool_call");
635
+ }
636
+ const toolInvocationIndex = toolInvocations.findIndex((invocation2) => invocation2.toolCallId === value.toolCallId);
637
+ if (toolInvocationIndex === -1) {
638
+ throw new Error("tool_result must be preceded by a tool_call with the same toolCallId");
639
+ }
640
+ const invocation = {
641
+ ...toolInvocations[toolInvocationIndex],
642
+ state: "result",
643
+ ...value
644
+ };
645
+ toolInvocations[toolInvocationIndex] = invocation;
646
+ updateToolInvocationPart(value.toolCallId, invocation);
647
+ execUpdate();
648
+ },
649
+ onDataPart(value) {
650
+ data.push(...value);
651
+ execUpdate();
652
+ },
653
+ onMessageAnnotationsPart(value) {
654
+ if (messageAnnotations == null) {
655
+ messageAnnotations = [...value];
656
+ } else {
657
+ messageAnnotations.push(...value);
658
+ }
659
+ execUpdate();
660
+ },
661
+ onFinishStepPart(value) {
662
+ step += 1;
663
+ currentTextPart = value.isContinued ? currentTextPart : void 0;
664
+ currentReasoningPart = void 0;
665
+ currentReasoningTextDetail = void 0;
666
+ },
667
+ onStartStepPart(value) {
668
+ if (!replaceLastMessage) {
669
+ message.id = value.messageId;
670
+ }
671
+ message.parts.push({ type: "step-start" });
672
+ execUpdate();
673
+ },
674
+ onFinishMessagePart(value) {
675
+ finishReason = value.finishReason;
676
+ if (value.usage != null) {
677
+ usage = value.usage;
678
+ }
679
+ },
680
+ onErrorPart(error) {
681
+ throw new Error(error);
682
+ }
683
+ });
684
+ onFinish?.({ message, finishReason, usage });
685
+ }
686
+ /**
687
+ * Streams a response from the agent
688
+ * @param params - Stream parameters including prompt
689
+ * @returns Promise containing the enhanced Response object with processDataStream method
690
+ */
691
+ async stream(params) {
692
+ const processedParams = {
693
+ ...params,
694
+ output: params.output ? zodToJsonSchema(params.output) : void 0,
695
+ experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
696
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext),
697
+ clientTools: processClientTools(params.clientTools)
698
+ };
699
+ const { readable, writable } = new TransformStream();
700
+ const response = await this.processStreamResponse(processedParams, writable);
701
+ const streamResponse = new Response(readable, {
702
+ status: response.status,
703
+ statusText: response.statusText,
704
+ headers: response.headers
705
+ });
706
+ streamResponse.processDataStream = async (options = {}) => {
707
+ await processDataStream({
708
+ stream: streamResponse.body,
709
+ ...options
693
710
  });
694
- onFinish?.({ message, finishReason, usage });
695
- }
711
+ };
712
+ return streamResponse;
696
713
  }
697
714
  /**
698
715
  * Processes the stream response and handles tool calls
@@ -707,7 +724,6 @@ var Agent = class extends BaseResource {
707
724
  throw new Error("No response body");
708
725
  }
709
726
  try {
710
- const streamProtocol = processedParams.output ? "text" : "data";
711
727
  let toolCalls = [];
712
728
  let messages = [];
713
729
  const [streamForWritable, streamForProcessing] = response.body.tee();
@@ -719,7 +735,12 @@ var Agent = class extends BaseResource {
719
735
  this.processChatResponse({
720
736
  stream: streamForProcessing,
721
737
  update: ({ message }) => {
722
- messages.push(message);
738
+ const existingIndex = messages.findIndex((m) => m.id === message.id);
739
+ if (existingIndex !== -1) {
740
+ messages[existingIndex] = message;
741
+ } else {
742
+ messages.push(message);
743
+ }
723
744
  },
724
745
  onFinish: async ({ finishReason, message }) => {
725
746
  if (finishReason === "tool-calls") {
@@ -779,63 +800,29 @@ var Agent = class extends BaseResource {
779
800
  this.processStreamResponse(
780
801
  {
781
802
  ...processedParams,
782
- messages: [...messageArray, ...messages, lastMessage]
803
+ messages: [...messageArray, ...messages.filter((m) => m.id !== lastMessage.id), lastMessage]
783
804
  },
784
805
  writable
785
- );
806
+ ).catch((error) => {
807
+ console.error("Error processing stream response:", error);
808
+ });
786
809
  }
787
810
  }
788
811
  } else {
789
812
  setTimeout(() => {
790
- if (!writable.locked) {
791
- writable.close();
792
- }
813
+ writable.close();
793
814
  }, 0);
794
815
  }
795
816
  },
796
- lastMessage: void 0,
797
- streamProtocol
817
+ lastMessage: void 0
818
+ }).catch((error) => {
819
+ console.error("Error processing stream response:", error);
798
820
  });
799
821
  } catch (error) {
800
822
  console.error("Error processing stream response:", error);
801
823
  }
802
824
  return response;
803
825
  }
804
- /**
805
- * Streams a response from the agent
806
- * @param params - Stream parameters including prompt
807
- * @returns Promise containing the enhanced Response object with processDataStream and processTextStream methods
808
- */
809
- async stream(params) {
810
- const processedParams = {
811
- ...params,
812
- output: params.output ? zodToJsonSchema(params.output) : void 0,
813
- experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
814
- runtimeContext: parseClientRuntimeContext(params.runtimeContext),
815
- clientTools: processClientTools(params.clientTools)
816
- };
817
- const { readable, writable } = new TransformStream();
818
- const response = await this.processStreamResponse(processedParams, writable);
819
- const streamResponse = new Response(readable, {
820
- status: response.status,
821
- statusText: response.statusText,
822
- headers: response.headers
823
- });
824
- streamResponse.processDataStream = async (options = {}) => {
825
- await processDataStream({
826
- stream: streamResponse.body,
827
- ...options
828
- });
829
- };
830
- streamResponse.processTextStream = async (options) => {
831
- await processTextStream({
832
- stream: streamResponse.body,
833
- onTextPart: options?.onTextPart ?? (() => {
834
- })
835
- });
836
- };
837
- return streamResponse;
838
- }
839
826
  /**
840
827
  * Gets details about a specific tool available to the agent
841
828
  * @param toolId - ID of the tool to retrieve
@@ -993,6 +980,21 @@ var MemoryThread = class extends BaseResource {
993
980
  });
994
981
  return this.request(`/api/memory/threads/${this.threadId}/messages/paginated?${query.toString()}`);
995
982
  }
983
+ /**
984
+ * Deletes one or more messages from the thread
985
+ * @param messageIds - Can be a single message ID (string), array of message IDs,
986
+ * message object with id property, or array of message objects
987
+ * @returns Promise containing deletion result
988
+ */
989
+ deleteMessages(messageIds) {
990
+ const query = new URLSearchParams({
991
+ agentId: this.agentId
992
+ });
993
+ return this.request(`/api/memory/messages/delete?${query.toString()}`, {
994
+ method: "POST",
995
+ body: { messageIds }
996
+ });
997
+ }
996
998
  };
997
999
 
998
1000
  // src/resources/vector.ts
@@ -1741,6 +1743,21 @@ var NetworkMemoryThread = class extends BaseResource {
1741
1743
  });
1742
1744
  return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
1743
1745
  }
1746
+ /**
1747
+ * Deletes one or more messages from the thread
1748
+ * @param messageIds - Can be a single message ID (string), array of message IDs,
1749
+ * message object with id property, or array of message objects
1750
+ * @returns Promise containing deletion result
1751
+ */
1752
+ deleteMessages(messageIds) {
1753
+ const query = new URLSearchParams({
1754
+ networkId: this.networkId
1755
+ });
1756
+ return this.request(`/api/memory/network/messages/delete?${query.toString()}`, {
1757
+ method: "POST",
1758
+ body: { messageIds }
1759
+ });
1760
+ }
1744
1761
  };
1745
1762
 
1746
1763
  // src/resources/vNextNetwork.ts
@@ -2310,6 +2327,86 @@ var MastraClient = class extends BaseResource {
2310
2327
  }
2311
2328
  });
2312
2329
  }
2330
+ /**
2331
+ * Retrieves all available scorers
2332
+ * @returns Promise containing list of available scorers
2333
+ */
2334
+ getScorers() {
2335
+ return this.request("/api/scores/scorers");
2336
+ }
2337
+ /**
2338
+ * Retrieves a scorer by ID
2339
+ * @param scorerId - ID of the scorer to retrieve
2340
+ * @returns Promise containing the scorer
2341
+ */
2342
+ getScorer(scorerId) {
2343
+ return this.request(`/api/scores/scorers/${scorerId}`);
2344
+ }
2345
+ getScoresByScorerId(params) {
2346
+ const { page, perPage, scorerId, entityId, entityType } = params;
2347
+ const searchParams = new URLSearchParams();
2348
+ if (entityId) {
2349
+ searchParams.set("entityId", entityId);
2350
+ }
2351
+ if (entityType) {
2352
+ searchParams.set("entityType", entityType);
2353
+ }
2354
+ if (page !== void 0) {
2355
+ searchParams.set("page", String(page));
2356
+ }
2357
+ if (perPage !== void 0) {
2358
+ searchParams.set("perPage", String(perPage));
2359
+ }
2360
+ const queryString = searchParams.toString();
2361
+ return this.request(`/api/scores/scorer/${scorerId}${queryString ? `?${queryString}` : ""}`);
2362
+ }
2363
+ /**
2364
+ * Retrieves scores by run ID
2365
+ * @param params - Parameters containing run ID and pagination options
2366
+ * @returns Promise containing scores and pagination info
2367
+ */
2368
+ getScoresByRunId(params) {
2369
+ const { runId, page, perPage } = params;
2370
+ const searchParams = new URLSearchParams();
2371
+ if (page !== void 0) {
2372
+ searchParams.set("page", String(page));
2373
+ }
2374
+ if (perPage !== void 0) {
2375
+ searchParams.set("perPage", String(perPage));
2376
+ }
2377
+ const queryString = searchParams.toString();
2378
+ return this.request(`/api/scores/run/${runId}${queryString ? `?${queryString}` : ""}`);
2379
+ }
2380
+ /**
2381
+ * Retrieves scores by entity ID and type
2382
+ * @param params - Parameters containing entity ID, type, and pagination options
2383
+ * @returns Promise containing scores and pagination info
2384
+ */
2385
+ getScoresByEntityId(params) {
2386
+ const { entityId, entityType, page, perPage } = params;
2387
+ const searchParams = new URLSearchParams();
2388
+ if (page !== void 0) {
2389
+ searchParams.set("page", String(page));
2390
+ }
2391
+ if (perPage !== void 0) {
2392
+ searchParams.set("perPage", String(perPage));
2393
+ }
2394
+ const queryString = searchParams.toString();
2395
+ return this.request(`/api/scores/entity/${entityType}/${entityId}${queryString ? `?${queryString}` : ""}`);
2396
+ }
2397
+ /**
2398
+ * Saves a score
2399
+ * @param params - Parameters containing the score data to save
2400
+ * @returns Promise containing the saved score
2401
+ */
2402
+ saveScore(params) {
2403
+ return this.request("/api/scores", {
2404
+ method: "POST",
2405
+ body: params
2406
+ });
2407
+ }
2313
2408
  };
2314
2409
 
2315
2410
  export { MastraClient };
2411
+ //# sourceMappingURL=index.js.map
2412
+ //# sourceMappingURL=index.js.map