@mastra/client-js 0.0.0-generate-message-id-20250512171942 → 0.0.0-inject-middleware-20250528213451

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.js CHANGED
@@ -3,6 +3,7 @@ import { Observable } from 'rxjs';
3
3
  import { processDataStream } from '@ai-sdk/ui-utils';
4
4
  import { ZodSchema } from 'zod';
5
5
  import originalZodToJsonSchema from 'zod-to-json-schema';
6
+ import { RuntimeContext } from '@mastra/core/runtime-context';
6
7
 
7
8
  // src/adapters/agui.ts
8
9
  var AGUIAdapter = class extends AbstractAgent {
@@ -214,7 +215,7 @@ var BaseResource = class {
214
215
  let delay = backoffMs;
215
216
  for (let attempt = 0; attempt <= retries; attempt++) {
216
217
  try {
217
- const response = await fetch(`${baseUrl}${path}`, {
218
+ const response = await fetch(`${baseUrl.replace(/\/$/, "")}${path}`, {
218
219
  ...options,
219
220
  headers: {
220
221
  ...headers,
@@ -254,6 +255,15 @@ var BaseResource = class {
254
255
  throw lastError || new Error("Request failed");
255
256
  }
256
257
  };
258
+ function parseClientRuntimeContext(runtimeContext) {
259
+ if (runtimeContext) {
260
+ if (runtimeContext instanceof RuntimeContext) {
261
+ return Object.fromEntries(runtimeContext.entries());
262
+ }
263
+ return runtimeContext;
264
+ }
265
+ return void 0;
266
+ }
257
267
 
258
268
  // src/resources/agent.ts
259
269
  var AgentVoice = class extends BaseResource {
@@ -325,9 +335,9 @@ var Agent = class extends BaseResource {
325
335
  generate(params) {
326
336
  const processedParams = {
327
337
  ...params,
328
- output: zodToJsonSchema(params.output),
329
- experimental_output: zodToJsonSchema(params.experimental_output),
330
- runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
338
+ output: params.output ? zodToJsonSchema(params.output) : void 0,
339
+ experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
340
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
331
341
  };
332
342
  return this.request(`/api/agents/${this.agentId}/generate`, {
333
343
  method: "POST",
@@ -342,9 +352,9 @@ var Agent = class extends BaseResource {
342
352
  async stream(params) {
343
353
  const processedParams = {
344
354
  ...params,
345
- output: zodToJsonSchema(params.output),
346
- experimental_output: zodToJsonSchema(params.experimental_output),
347
- runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
355
+ output: params.output ? zodToJsonSchema(params.output) : void 0,
356
+ experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
357
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
348
358
  };
349
359
  const response = await this.request(`/api/agents/${this.agentId}/stream`, {
350
360
  method: "POST",
@@ -494,10 +504,15 @@ var MemoryThread = class extends BaseResource {
494
504
  }
495
505
  /**
496
506
  * Retrieves messages associated with the thread
507
+ * @param params - Optional parameters including limit for number of messages to retrieve
497
508
  * @returns Promise containing thread messages and UI messages
498
509
  */
499
- getMessages() {
500
- return this.request(`/api/memory/threads/${this.threadId}/messages?agentId=${this.agentId}`);
510
+ getMessages(params) {
511
+ const query = new URLSearchParams({
512
+ agentId: this.agentId,
513
+ ...params?.limit ? { limit: params.limit.toString() } : {}
514
+ });
515
+ return this.request(`/api/memory/threads/${this.threadId}/messages?${query.toString()}`);
501
516
  }
502
517
  };
503
518
 
@@ -567,24 +582,24 @@ var Vector = class extends BaseResource {
567
582
  }
568
583
  };
569
584
 
570
- // src/resources/workflow.ts
585
+ // src/resources/legacy-workflow.ts
571
586
  var RECORD_SEPARATOR = "";
572
- var Workflow = class extends BaseResource {
587
+ var LegacyWorkflow = class extends BaseResource {
573
588
  constructor(options, workflowId) {
574
589
  super(options);
575
590
  this.workflowId = workflowId;
576
591
  }
577
592
  /**
578
- * Retrieves details about the workflow
579
- * @returns Promise containing workflow details including steps and graphs
593
+ * Retrieves details about the legacy workflow
594
+ * @returns Promise containing legacy workflow details including steps and graphs
580
595
  */
581
596
  details() {
582
- return this.request(`/api/workflows/${this.workflowId}`);
597
+ return this.request(`/api/workflows/legacy/${this.workflowId}`);
583
598
  }
584
599
  /**
585
- * Retrieves all runs for a workflow
600
+ * Retrieves all runs for a legacy workflow
586
601
  * @param params - Parameters for filtering runs
587
- * @returns Promise containing workflow runs array
602
+ * @returns Promise containing legacy workflow runs array
588
603
  */
589
604
  runs(params) {
590
605
  const searchParams = new URLSearchParams();
@@ -604,25 +619,13 @@ var Workflow = class extends BaseResource {
604
619
  searchParams.set("resourceId", params.resourceId);
605
620
  }
606
621
  if (searchParams.size) {
607
- return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
622
+ return this.request(`/api/workflows/legacy/${this.workflowId}/runs?${searchParams}`);
608
623
  } else {
609
- return this.request(`/api/workflows/${this.workflowId}/runs`);
624
+ return this.request(`/api/workflows/legacy/${this.workflowId}/runs`);
610
625
  }
611
626
  }
612
627
  /**
613
- * @deprecated Use `startAsync` instead
614
- * Executes the workflow with the provided parameters
615
- * @param params - Parameters required for workflow execution
616
- * @returns Promise containing the workflow execution results
617
- */
618
- execute(params) {
619
- return this.request(`/api/workflows/${this.workflowId}/execute`, {
620
- method: "POST",
621
- body: params
622
- });
623
- }
624
- /**
625
- * Creates a new workflow run
628
+ * Creates a new legacy workflow run
626
629
  * @returns Promise containing the generated run ID
627
630
  */
628
631
  createRun(params) {
@@ -630,34 +633,34 @@ var Workflow = class extends BaseResource {
630
633
  if (!!params?.runId) {
631
634
  searchParams.set("runId", params.runId);
632
635
  }
633
- return this.request(`/api/workflows/${this.workflowId}/createRun?${searchParams.toString()}`, {
636
+ return this.request(`/api/workflows/legacy/${this.workflowId}/create-run?${searchParams.toString()}`, {
634
637
  method: "POST"
635
638
  });
636
639
  }
637
640
  /**
638
- * Starts a workflow run synchronously without waiting for the workflow to complete
641
+ * Starts a legacy workflow run synchronously without waiting for the workflow to complete
639
642
  * @param params - Object containing the runId and triggerData
640
643
  * @returns Promise containing success message
641
644
  */
642
645
  start(params) {
643
- return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
646
+ return this.request(`/api/workflows/legacy/${this.workflowId}/start?runId=${params.runId}`, {
644
647
  method: "POST",
645
648
  body: params?.triggerData
646
649
  });
647
650
  }
648
651
  /**
649
- * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
652
+ * Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
650
653
  * @param stepId - ID of the step to resume
651
- * @param runId - ID of the workflow run
652
- * @param context - Context to resume the workflow with
653
- * @returns Promise containing the workflow resume results
654
+ * @param runId - ID of the legacy workflow run
655
+ * @param context - Context to resume the legacy workflow with
656
+ * @returns Promise containing the legacy workflow resume results
654
657
  */
655
658
  resume({
656
659
  stepId,
657
660
  runId,
658
661
  context
659
662
  }) {
660
- return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
663
+ return this.request(`/api/workflows/legacy/${this.workflowId}/resume?runId=${runId}`, {
661
664
  method: "POST",
662
665
  body: {
663
666
  stepId,
@@ -675,18 +678,18 @@ var Workflow = class extends BaseResource {
675
678
  if (!!params?.runId) {
676
679
  searchParams.set("runId", params.runId);
677
680
  }
678
- return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
681
+ return this.request(`/api/workflows/legacy/${this.workflowId}/start-async?${searchParams.toString()}`, {
679
682
  method: "POST",
680
683
  body: params?.triggerData
681
684
  });
682
685
  }
683
686
  /**
684
- * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
687
+ * Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
685
688
  * @param params - Object containing the runId, stepId, and context
686
689
  * @returns Promise containing the workflow resume results
687
690
  */
688
691
  resumeAsync(params) {
689
- return this.request(`/api/workflows/${this.workflowId}/resume-async?runId=${params.runId}`, {
692
+ return this.request(`/api/workflows/legacy/${this.workflowId}/resume-async?runId=${params.runId}`, {
690
693
  method: "POST",
691
694
  body: {
692
695
  stepId: params.stepId,
@@ -740,16 +743,16 @@ var Workflow = class extends BaseResource {
740
743
  }
741
744
  }
742
745
  /**
743
- * Watches workflow transitions in real-time
746
+ * Watches legacy workflow transitions in real-time
744
747
  * @param runId - Optional run ID to filter the watch stream
745
- * @returns AsyncGenerator that yields parsed records from the workflow watch stream
748
+ * @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
746
749
  */
747
750
  async watch({ runId }, onRecord) {
748
- const response = await this.request(`/api/workflows/${this.workflowId}/watch?runId=${runId}`, {
751
+ const response = await this.request(`/api/workflows/legacy/${this.workflowId}/watch?runId=${runId}`, {
749
752
  stream: true
750
753
  });
751
754
  if (!response.ok) {
752
- throw new Error(`Failed to watch workflow: ${response.statusText}`);
755
+ throw new Error(`Failed to watch legacy workflow: ${response.statusText}`);
753
756
  }
754
757
  if (!response.body) {
755
758
  throw new Error("Response body is null");
@@ -785,7 +788,7 @@ var Tool = class extends BaseResource {
785
788
  }
786
789
  const body = {
787
790
  data: params.data,
788
- runtimeContext: params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0
791
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
789
792
  };
790
793
  return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
791
794
  method: "POST",
@@ -793,14 +796,16 @@ var Tool = class extends BaseResource {
793
796
  });
794
797
  }
795
798
  };
799
+
800
+ // src/resources/workflow.ts
796
801
  var RECORD_SEPARATOR2 = "";
797
- var VNextWorkflow = class extends BaseResource {
802
+ var Workflow = class extends BaseResource {
798
803
  constructor(options, workflowId) {
799
804
  super(options);
800
805
  this.workflowId = workflowId;
801
806
  }
802
807
  /**
803
- * Creates an async generator that processes a readable stream and yields vNext workflow records
808
+ * Creates an async generator that processes a readable stream and yields workflow records
804
809
  * separated by the Record Separator character (\x1E)
805
810
  *
806
811
  * @param stream - The readable stream to process
@@ -845,16 +850,16 @@ var VNextWorkflow = class extends BaseResource {
845
850
  }
846
851
  }
847
852
  /**
848
- * Retrieves details about the vNext workflow
849
- * @returns Promise containing vNext workflow details including steps and graphs
853
+ * Retrieves details about the workflow
854
+ * @returns Promise containing workflow details including steps and graphs
850
855
  */
851
856
  details() {
852
- return this.request(`/api/workflows/v-next/${this.workflowId}`);
857
+ return this.request(`/api/workflows/${this.workflowId}`);
853
858
  }
854
859
  /**
855
- * Retrieves all runs for a vNext workflow
860
+ * Retrieves all runs for a workflow
856
861
  * @param params - Parameters for filtering runs
857
- * @returns Promise containing vNext workflow runs array
862
+ * @returns Promise containing workflow runs array
858
863
  */
859
864
  runs(params) {
860
865
  const searchParams = new URLSearchParams();
@@ -874,13 +879,13 @@ var VNextWorkflow = class extends BaseResource {
874
879
  searchParams.set("resourceId", params.resourceId);
875
880
  }
876
881
  if (searchParams.size) {
877
- return this.request(`/api/workflows/v-next/${this.workflowId}/runs?${searchParams}`);
882
+ return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
878
883
  } else {
879
- return this.request(`/api/workflows/v-next/${this.workflowId}/runs`);
884
+ return this.request(`/api/workflows/${this.workflowId}/runs`);
880
885
  }
881
886
  }
882
887
  /**
883
- * Creates a new vNext workflow run
888
+ * Creates a new workflow run
884
889
  * @param params - Optional object containing the optional runId
885
890
  * @returns Promise containing the runId of the created run
886
891
  */
@@ -889,24 +894,24 @@ var VNextWorkflow = class extends BaseResource {
889
894
  if (!!params?.runId) {
890
895
  searchParams.set("runId", params.runId);
891
896
  }
892
- return this.request(`/api/workflows/v-next/${this.workflowId}/create-run?${searchParams.toString()}`, {
897
+ return this.request(`/api/workflows/${this.workflowId}/create-run?${searchParams.toString()}`, {
893
898
  method: "POST"
894
899
  });
895
900
  }
896
901
  /**
897
- * Starts a vNext workflow run synchronously without waiting for the workflow to complete
902
+ * Starts a workflow run synchronously without waiting for the workflow to complete
898
903
  * @param params - Object containing the runId, inputData and runtimeContext
899
904
  * @returns Promise containing success message
900
905
  */
901
906
  start(params) {
902
- const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
903
- return this.request(`/api/workflows/v-next/${this.workflowId}/start?runId=${params.runId}`, {
907
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
908
+ return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
904
909
  method: "POST",
905
910
  body: { inputData: params?.inputData, runtimeContext }
906
911
  });
907
912
  }
908
913
  /**
909
- * Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
914
+ * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
910
915
  * @param params - Object containing the runId, step, resumeData and runtimeContext
911
916
  * @returns Promise containing success message
912
917
  */
@@ -916,8 +921,8 @@ var VNextWorkflow = class extends BaseResource {
916
921
  resumeData,
917
922
  ...rest
918
923
  }) {
919
- const runtimeContext = rest.runtimeContext ? Object.fromEntries(rest.runtimeContext.entries()) : void 0;
920
- return this.request(`/api/workflows/v-next/${this.workflowId}/resume?runId=${runId}`, {
924
+ const runtimeContext = parseClientRuntimeContext(rest.runtimeContext);
925
+ return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
921
926
  method: "POST",
922
927
  stream: true,
923
928
  body: {
@@ -928,29 +933,76 @@ var VNextWorkflow = class extends BaseResource {
928
933
  });
929
934
  }
930
935
  /**
931
- * Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
936
+ * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
932
937
  * @param params - Object containing the optional runId, inputData and runtimeContext
933
- * @returns Promise containing the vNext workflow execution results
938
+ * @returns Promise containing the workflow execution results
934
939
  */
935
940
  startAsync(params) {
936
941
  const searchParams = new URLSearchParams();
937
942
  if (!!params?.runId) {
938
943
  searchParams.set("runId", params.runId);
939
944
  }
940
- const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
941
- return this.request(`/api/workflows/v-next/${this.workflowId}/start-async?${searchParams.toString()}`, {
945
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
946
+ return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
942
947
  method: "POST",
943
948
  body: { inputData: params.inputData, runtimeContext }
944
949
  });
945
950
  }
946
951
  /**
947
- * Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
952
+ * Starts a vNext workflow run and returns a stream
953
+ * @param params - Object containing the optional runId, inputData and runtimeContext
954
+ * @returns Promise containing the vNext workflow execution results
955
+ */
956
+ async stream(params) {
957
+ const searchParams = new URLSearchParams();
958
+ if (!!params?.runId) {
959
+ searchParams.set("runId", params.runId);
960
+ }
961
+ const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
962
+ const response = await this.request(
963
+ `/api/workflows/${this.workflowId}/stream?${searchParams.toString()}`,
964
+ {
965
+ method: "POST",
966
+ body: { inputData: params.inputData, runtimeContext },
967
+ stream: true
968
+ }
969
+ );
970
+ if (!response.ok) {
971
+ throw new Error(`Failed to stream vNext workflow: ${response.statusText}`);
972
+ }
973
+ if (!response.body) {
974
+ throw new Error("Response body is null");
975
+ }
976
+ const transformStream = new TransformStream({
977
+ start() {
978
+ },
979
+ async transform(chunk, controller) {
980
+ try {
981
+ const decoded = new TextDecoder().decode(chunk);
982
+ const chunks = decoded.split(RECORD_SEPARATOR2);
983
+ for (const chunk2 of chunks) {
984
+ if (chunk2) {
985
+ try {
986
+ const parsedChunk = JSON.parse(chunk2);
987
+ controller.enqueue(parsedChunk);
988
+ } catch {
989
+ }
990
+ }
991
+ }
992
+ } catch {
993
+ }
994
+ }
995
+ });
996
+ return response.body.pipeThrough(transformStream);
997
+ }
998
+ /**
999
+ * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
948
1000
  * @param params - Object containing the runId, step, resumeData and runtimeContext
949
- * @returns Promise containing the vNext workflow resume results
1001
+ * @returns Promise containing the workflow resume results
950
1002
  */
951
1003
  resumeAsync(params) {
952
- const runtimeContext = params.runtimeContext ? Object.fromEntries(params.runtimeContext.entries()) : void 0;
953
- return this.request(`/api/workflows/v-next/${this.workflowId}/resume-async?runId=${params.runId}`, {
1004
+ const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
1005
+ return this.request(`/api/workflows/${this.workflowId}/resume-async?runId=${params.runId}`, {
954
1006
  method: "POST",
955
1007
  body: {
956
1008
  step: params.step,
@@ -960,24 +1012,51 @@ var VNextWorkflow = class extends BaseResource {
960
1012
  });
961
1013
  }
962
1014
  /**
963
- * Watches vNext workflow transitions in real-time
1015
+ * Watches workflow transitions in real-time
964
1016
  * @param runId - Optional run ID to filter the watch stream
965
- * @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
1017
+ * @returns AsyncGenerator that yields parsed records from the workflow watch stream
966
1018
  */
967
1019
  async watch({ runId }, onRecord) {
968
- const response = await this.request(`/api/workflows/v-next/${this.workflowId}/watch?runId=${runId}`, {
1020
+ const response = await this.request(`/api/workflows/${this.workflowId}/watch?runId=${runId}`, {
969
1021
  stream: true
970
1022
  });
971
1023
  if (!response.ok) {
972
- throw new Error(`Failed to watch vNext workflow: ${response.statusText}`);
1024
+ throw new Error(`Failed to watch workflow: ${response.statusText}`);
973
1025
  }
974
1026
  if (!response.body) {
975
1027
  throw new Error("Response body is null");
976
1028
  }
977
1029
  for await (const record of this.streamProcessor(response.body)) {
978
- onRecord(record);
1030
+ if (typeof record === "string") {
1031
+ onRecord(JSON.parse(record));
1032
+ } else {
1033
+ onRecord(record);
1034
+ }
979
1035
  }
980
1036
  }
1037
+ /**
1038
+ * Creates a new ReadableStream from an iterable or async iterable of objects,
1039
+ * serializing each as JSON and separating them with the record separator (\x1E).
1040
+ *
1041
+ * @param records - An iterable or async iterable of objects to stream
1042
+ * @returns A ReadableStream emitting the records as JSON strings separated by the record separator
1043
+ */
1044
+ static createRecordStream(records) {
1045
+ const encoder = new TextEncoder();
1046
+ return new ReadableStream({
1047
+ async start(controller) {
1048
+ try {
1049
+ for await (const record of records) {
1050
+ const json = JSON.stringify(record) + RECORD_SEPARATOR2;
1051
+ controller.enqueue(encoder.encode(json));
1052
+ }
1053
+ controller.close();
1054
+ } catch (err) {
1055
+ controller.error(err);
1056
+ }
1057
+ }
1058
+ });
1059
+ }
981
1060
  };
982
1061
 
983
1062
  // src/resources/a2a.ts
@@ -1054,6 +1133,40 @@ var A2A = class extends BaseResource {
1054
1133
  }
1055
1134
  };
1056
1135
 
1136
+ // src/resources/mcp-tool.ts
1137
+ var MCPTool = class extends BaseResource {
1138
+ serverId;
1139
+ toolId;
1140
+ constructor(options, serverId, toolId) {
1141
+ super(options);
1142
+ this.serverId = serverId;
1143
+ this.toolId = toolId;
1144
+ }
1145
+ /**
1146
+ * Retrieves details about this specific tool from the MCP server.
1147
+ * @returns Promise containing the tool's information (name, description, schema).
1148
+ */
1149
+ details() {
1150
+ return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}`);
1151
+ }
1152
+ /**
1153
+ * Executes this specific tool on the MCP server.
1154
+ * @param params - Parameters for tool execution, including data/args and optional runtimeContext.
1155
+ * @returns Promise containing the result of the tool execution.
1156
+ */
1157
+ execute(params) {
1158
+ const body = {};
1159
+ if (params.data !== void 0) body.data = params.data;
1160
+ if (params.runtimeContext !== void 0) {
1161
+ body.runtimeContext = params.runtimeContext;
1162
+ }
1163
+ return this.request(`/api/mcp/${this.serverId}/tools/${this.toolId}/execute`, {
1164
+ method: "POST",
1165
+ body: Object.keys(body).length > 0 ? body : void 0
1166
+ });
1167
+ }
1168
+ };
1169
+
1057
1170
  // src/client.ts
1058
1171
  var MastraClient = class extends BaseResource {
1059
1172
  constructor(options) {
@@ -1146,6 +1259,21 @@ var MastraClient = class extends BaseResource {
1146
1259
  getTool(toolId) {
1147
1260
  return new Tool(this.options, toolId);
1148
1261
  }
1262
+ /**
1263
+ * Retrieves all available legacy workflows
1264
+ * @returns Promise containing map of legacy workflow IDs to legacy workflow details
1265
+ */
1266
+ getLegacyWorkflows() {
1267
+ return this.request("/api/workflows/legacy");
1268
+ }
1269
+ /**
1270
+ * Gets a legacy workflow instance by ID
1271
+ * @param workflowId - ID of the legacy workflow to retrieve
1272
+ * @returns Legacy Workflow instance
1273
+ */
1274
+ getLegacyWorkflow(workflowId) {
1275
+ return new LegacyWorkflow(this.options, workflowId);
1276
+ }
1149
1277
  /**
1150
1278
  * Retrieves all available workflows
1151
1279
  * @returns Promise containing map of workflow IDs to workflow details
@@ -1161,21 +1289,6 @@ var MastraClient = class extends BaseResource {
1161
1289
  getWorkflow(workflowId) {
1162
1290
  return new Workflow(this.options, workflowId);
1163
1291
  }
1164
- /**
1165
- * Retrieves all available vNext workflows
1166
- * @returns Promise containing map of vNext workflow IDs to vNext workflow details
1167
- */
1168
- getVNextWorkflows() {
1169
- return this.request("/api/workflows/v-next");
1170
- }
1171
- /**
1172
- * Gets a vNext workflow instance by ID
1173
- * @param workflowId - ID of the vNext workflow to retrieve
1174
- * @returns vNext Workflow instance
1175
- */
1176
- getVNextWorkflow(workflowId) {
1177
- return new VNextWorkflow(this.options, workflowId);
1178
- }
1179
1292
  /**
1180
1293
  * Gets a vector instance by name
1181
1294
  * @param vectorName - Name of the vector to retrieve
@@ -1264,6 +1377,54 @@ var MastraClient = class extends BaseResource {
1264
1377
  getNetwork(networkId) {
1265
1378
  return new Network(this.options, networkId);
1266
1379
  }
1380
+ /**
1381
+ * Retrieves a list of available MCP servers.
1382
+ * @param params - Optional parameters for pagination (limit, offset).
1383
+ * @returns Promise containing the list of MCP servers and pagination info.
1384
+ */
1385
+ getMcpServers(params) {
1386
+ const searchParams = new URLSearchParams();
1387
+ if (params?.limit !== void 0) {
1388
+ searchParams.set("limit", String(params.limit));
1389
+ }
1390
+ if (params?.offset !== void 0) {
1391
+ searchParams.set("offset", String(params.offset));
1392
+ }
1393
+ const queryString = searchParams.toString();
1394
+ return this.request(`/api/mcp/v0/servers${queryString ? `?${queryString}` : ""}`);
1395
+ }
1396
+ /**
1397
+ * Retrieves detailed information for a specific MCP server.
1398
+ * @param serverId - The ID of the MCP server to retrieve.
1399
+ * @param params - Optional parameters, e.g., specific version.
1400
+ * @returns Promise containing the detailed MCP server information.
1401
+ */
1402
+ getMcpServerDetails(serverId, params) {
1403
+ const searchParams = new URLSearchParams();
1404
+ if (params?.version) {
1405
+ searchParams.set("version", params.version);
1406
+ }
1407
+ const queryString = searchParams.toString();
1408
+ return this.request(`/api/mcp/v0/servers/${serverId}${queryString ? `?${queryString}` : ""}`);
1409
+ }
1410
+ /**
1411
+ * Retrieves a list of tools for a specific MCP server.
1412
+ * @param serverId - The ID of the MCP server.
1413
+ * @returns Promise containing the list of tools.
1414
+ */
1415
+ getMcpServerTools(serverId) {
1416
+ return this.request(`/api/mcp/${serverId}/tools`);
1417
+ }
1418
+ /**
1419
+ * Gets an MCPTool resource instance for a specific tool on an MCP server.
1420
+ * This instance can then be used to fetch details or execute the tool.
1421
+ * @param serverId - The ID of the MCP server.
1422
+ * @param toolId - The ID of the tool.
1423
+ * @returns MCPTool instance.
1424
+ */
1425
+ getMcpServerTool(serverId, toolId) {
1426
+ return new MCPTool(this.options, serverId, toolId);
1427
+ }
1267
1428
  /**
1268
1429
  * Gets an A2A client for interacting with an agent via the A2A protocol
1269
1430
  * @param agentId - ID of the agent to interact with
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/client-js",
3
- "version": "0.0.0-generate-message-id-20250512171942",
3
+ "version": "0.0.0-inject-middleware-20250528213451",
4
4
  "description": "The official TypeScript library for the Mastra Client API",
5
5
  "author": "",
6
6
  "type": "module",
@@ -27,11 +27,11 @@
27
27
  "json-schema": "^0.4.0",
28
28
  "rxjs": "7.8.1",
29
29
  "zod": "^3.24.3",
30
- "zod-to-json-schema": "^3.24.5",
31
- "@mastra/core": "0.0.0-generate-message-id-20250512171942"
30
+ "zod-to-json-schema": "^3.24.5"
32
31
  },
33
32
  "peerDependencies": {
34
- "zod": "^3.0.0"
33
+ "zod": "^3.0.0",
34
+ "@mastra/core": "^0.10.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@babel/preset-env": "^7.26.9",
@@ -42,7 +42,8 @@
42
42
  "tsup": "^8.4.0",
43
43
  "typescript": "^5.8.2",
44
44
  "vitest": "^3.1.2",
45
- "@internal/lint": "0.0.0-generate-message-id-20250512171942"
45
+ "@internal/lint": "0.0.0-inject-middleware-20250528213451",
46
+ "@mastra/core": "0.0.0-inject-middleware-20250528213451"
46
47
  },
47
48
  "scripts": {
48
49
  "build": "tsup src/index.ts --format esm,cjs --dts --clean --treeshake=smallest --splitting",