@mastra/client-js 0.0.0-mcp-server-update-parse-20250421171139 → 0.0.0-mcp-server-deploy-20250507160341

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/CHANGELOG.md CHANGED
@@ -1,21 +1,209 @@
1
1
  # @mastra/client-js
2
2
 
3
- ## 0.0.0-mcp-server-update-parse-20250421171139
3
+ ## 0.0.0-mcp-server-deploy-20250507160341
4
4
 
5
5
  ### Patch Changes
6
6
 
7
+ - 4155f47: Add parameters to filter workflow runs
8
+ Add fromDate and toDate to telemetry parameters
9
+ - 254f5c3: Audit, cleanup MastraClient
10
+ - 0097d50: Add serializedStepGraph to vNext workflow
11
+ Return serializedStepGraph from vNext workflow
12
+ Use serializedStepGraph in vNext workflow graph
13
+ - 2429c74: Add get workflow runs api to client-js
14
+ - Updated dependencies [967b41c]
15
+ - Updated dependencies [26738f4]
16
+ - Updated dependencies [4155f47]
17
+ - Updated dependencies [b804723]
18
+ - Updated dependencies [ccef9f9]
19
+ - Updated dependencies [0097d50]
20
+ - Updated dependencies [17826a9]
21
+ - Updated dependencies [51e6923]
22
+ - @mastra/core@0.0.0-mcp-server-deploy-20250507160341
23
+
24
+ ## 0.1.20-alpha.4
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [ccef9f9]
29
+ - Updated dependencies [51e6923]
30
+ - @mastra/core@0.9.2-alpha.4
31
+
32
+ ## 0.1.20-alpha.3
33
+
34
+ ### Patch Changes
35
+
36
+ - 4155f47: Add parameters to filter workflow runs
37
+ Add fromDate and toDate to telemetry parameters
38
+ - Updated dependencies [967b41c]
39
+ - Updated dependencies [4155f47]
40
+ - Updated dependencies [17826a9]
41
+ - @mastra/core@0.9.2-alpha.3
42
+
43
+ ## 0.1.20-alpha.2
44
+
45
+ ### Patch Changes
46
+
47
+ - Updated dependencies [26738f4]
48
+ - @mastra/core@0.9.2-alpha.2
49
+
50
+ ## 0.1.20-alpha.1
51
+
52
+ ### Patch Changes
53
+
54
+ - 254f5c3: Audit, cleanup MastraClient
55
+ - 2429c74: Add get workflow runs api to client-js
56
+ - Updated dependencies [b804723]
57
+ - @mastra/core@0.9.2-alpha.1
58
+
59
+ ## 0.1.20-alpha.0
60
+
61
+ ### Patch Changes
62
+
63
+ - 0097d50: Add serializedStepGraph to vNext workflow
64
+ Return serializedStepGraph from vNext workflow
65
+ Use serializedStepGraph in vNext workflow graph
66
+ - Updated dependencies [0097d50]
67
+ - @mastra/core@0.9.2-alpha.0
68
+
69
+ ## 0.1.19
70
+
71
+ ### Patch Changes
72
+
73
+ - b50b9b7: Add vNext workflow to client-js
74
+ - 11d4485: Show VNext workflows on the playground
75
+ Show running status for step in vNext workflowState
76
+ - Updated dependencies [405b63d]
77
+ - Updated dependencies [81fb7f6]
78
+ - Updated dependencies [20275d4]
79
+ - Updated dependencies [7d1892c]
80
+ - Updated dependencies [a90a082]
81
+ - Updated dependencies [2d17c73]
82
+ - Updated dependencies [61e92f5]
83
+ - Updated dependencies [35955b0]
84
+ - Updated dependencies [6262bd5]
85
+ - Updated dependencies [c1409ef]
86
+ - Updated dependencies [3e7b69d]
87
+ - Updated dependencies [e4943b8]
88
+ - Updated dependencies [11d4485]
89
+ - Updated dependencies [479f490]
90
+ - Updated dependencies [c23a81c]
91
+ - Updated dependencies [2d4001d]
92
+ - Updated dependencies [c71013a]
93
+ - Updated dependencies [1d3b1cd]
94
+ - @mastra/core@0.9.1
95
+
96
+ ## 0.1.19-alpha.8
97
+
98
+ ### Patch Changes
99
+
100
+ - Updated dependencies [2d17c73]
101
+ - @mastra/core@0.9.1-alpha.8
102
+
103
+ ## 0.1.19-alpha.7
104
+
105
+ ### Patch Changes
106
+
107
+ - Updated dependencies [1d3b1cd]
108
+ - @mastra/core@0.9.1-alpha.7
109
+
110
+ ## 0.1.19-alpha.6
111
+
112
+ ### Patch Changes
113
+
114
+ - Updated dependencies [c23a81c]
115
+ - @mastra/core@0.9.1-alpha.6
116
+
117
+ ## 0.1.19-alpha.5
118
+
119
+ ### Patch Changes
120
+
121
+ - Updated dependencies [3e7b69d]
122
+ - @mastra/core@0.9.1-alpha.5
123
+
124
+ ## 0.1.19-alpha.4
125
+
126
+ ### Patch Changes
127
+
128
+ - Updated dependencies [e4943b8]
129
+ - Updated dependencies [479f490]
130
+ - @mastra/core@0.9.1-alpha.4
131
+
132
+ ## 0.1.19-alpha.3
133
+
134
+ ### Patch Changes
135
+
136
+ - Updated dependencies [6262bd5]
137
+ - @mastra/core@0.9.1-alpha.3
138
+
139
+ ## 0.1.19-alpha.2
140
+
141
+ ### Patch Changes
142
+
143
+ - Updated dependencies [405b63d]
144
+ - Updated dependencies [61e92f5]
145
+ - Updated dependencies [c71013a]
146
+ - @mastra/core@0.9.1-alpha.2
147
+
148
+ ## 0.1.19-alpha.1
149
+
150
+ ### Patch Changes
151
+
152
+ - b50b9b7: Add vNext workflow to client-js
153
+ - 11d4485: Show VNext workflows on the playground
154
+ Show running status for step in vNext workflowState
155
+ - Updated dependencies [20275d4]
156
+ - Updated dependencies [7d1892c]
157
+ - Updated dependencies [a90a082]
158
+ - Updated dependencies [35955b0]
159
+ - Updated dependencies [c1409ef]
160
+ - Updated dependencies [11d4485]
161
+ - Updated dependencies [2d4001d]
162
+ - @mastra/core@0.9.1-alpha.1
163
+
164
+ ## 0.1.19-alpha.0
165
+
166
+ ### Patch Changes
167
+
168
+ - Updated dependencies [81fb7f6]
169
+ - @mastra/core@0.9.1-alpha.0
170
+
171
+ ## 0.1.18
172
+
173
+ ### Patch Changes
174
+
175
+ - 2538066: Fix memory thread creation from client SDK
176
+ - Updated dependencies [000a6d4]
7
177
  - Updated dependencies [08bb78e]
8
178
  - Updated dependencies [ed2f549]
9
179
  - Updated dependencies [7e92011]
10
180
  - Updated dependencies [9ee4293]
11
181
  - Updated dependencies [03f3cd0]
182
+ - Updated dependencies [c0f22b4]
12
183
  - Updated dependencies [71d9444]
13
184
  - Updated dependencies [157c741]
14
185
  - Updated dependencies [8a8a73b]
15
- - Updated dependencies [dc12442]
186
+ - Updated dependencies [0a033fa]
16
187
  - Updated dependencies [fe3ae4d]
188
+ - Updated dependencies [9c26508]
189
+ - Updated dependencies [0f4eae3]
190
+ - Updated dependencies [16a8648]
17
191
  - Updated dependencies [6f92295]
18
- - @mastra/core@0.0.0-mcp-server-update-parse-20250421171139
192
+ - @mastra/core@0.9.0
193
+
194
+ ## 0.1.18-alpha.8
195
+
196
+ ### Patch Changes
197
+
198
+ - 2538066: Fix memory thread creation from client SDK
199
+ - Updated dependencies [000a6d4]
200
+ - Updated dependencies [ed2f549]
201
+ - Updated dependencies [c0f22b4]
202
+ - Updated dependencies [0a033fa]
203
+ - Updated dependencies [9c26508]
204
+ - Updated dependencies [0f4eae3]
205
+ - Updated dependencies [16a8648]
206
+ - @mastra/core@0.9.0-alpha.8
19
207
 
20
208
  ## 0.1.18-alpha.7
21
209
 
package/dist/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ var uiUtils = require('@ai-sdk/ui-utils');
3
4
  var zod = require('zod');
4
5
  var zodToJsonSchema = require('zod-to-json-schema');
5
- var uiUtils = require('@ai-sdk/ui-utils');
6
6
 
7
7
  // src/resources/agent.ts
8
8
 
@@ -373,6 +373,34 @@ var Workflow = class extends BaseResource {
373
373
  details() {
374
374
  return this.request(`/api/workflows/${this.workflowId}`);
375
375
  }
376
+ /**
377
+ * Retrieves all runs for a workflow
378
+ * @param params - Parameters for filtering runs
379
+ * @returns Promise containing workflow runs array
380
+ */
381
+ runs(params) {
382
+ const searchParams = new URLSearchParams();
383
+ if (params?.fromDate) {
384
+ searchParams.set("fromDate", params.fromDate.toISOString());
385
+ }
386
+ if (params?.toDate) {
387
+ searchParams.set("toDate", params.toDate.toISOString());
388
+ }
389
+ if (params?.limit) {
390
+ searchParams.set("limit", String(params.limit));
391
+ }
392
+ if (params?.offset) {
393
+ searchParams.set("offset", String(params.offset));
394
+ }
395
+ if (params?.resourceId) {
396
+ searchParams.set("resourceId", params.resourceId);
397
+ }
398
+ if (searchParams.size) {
399
+ return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
400
+ } else {
401
+ return this.request(`/api/workflows/${this.workflowId}/runs`);
402
+ }
403
+ }
376
404
  /**
377
405
  * @deprecated Use `startAsync` instead
378
406
  * Executes the workflow with the provided parameters
@@ -489,7 +517,7 @@ var Workflow = class extends BaseResource {
489
517
  }
490
518
  }
491
519
  }
492
- } catch (error) {
520
+ } catch {
493
521
  }
494
522
  }
495
523
  if (buffer) {
@@ -543,13 +571,216 @@ var Tool = class extends BaseResource {
543
571
  * @returns Promise containing the tool execution results
544
572
  */
545
573
  execute(params) {
546
- return this.request(`/api/tools/${this.toolId}/execute`, {
574
+ const url = new URLSearchParams();
575
+ if (params.runId) {
576
+ url.set("runId", params.runId);
577
+ }
578
+ return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
547
579
  method: "POST",
548
- body: params
580
+ body: params.data
549
581
  });
550
582
  }
551
583
  };
552
584
 
585
+ // src/resources/vnext-workflow.ts
586
+ var RECORD_SEPARATOR2 = "";
587
+ var VNextWorkflow = class extends BaseResource {
588
+ constructor(options, workflowId) {
589
+ super(options);
590
+ this.workflowId = workflowId;
591
+ }
592
+ /**
593
+ * Creates an async generator that processes a readable stream and yields vNext workflow records
594
+ * separated by the Record Separator character (\x1E)
595
+ *
596
+ * @param stream - The readable stream to process
597
+ * @returns An async generator that yields parsed records
598
+ */
599
+ async *streamProcessor(stream) {
600
+ const reader = stream.getReader();
601
+ let doneReading = false;
602
+ let buffer = "";
603
+ try {
604
+ while (!doneReading) {
605
+ const { done, value } = await reader.read();
606
+ doneReading = done;
607
+ if (done && !value) continue;
608
+ try {
609
+ const decoded = value ? new TextDecoder().decode(value) : "";
610
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
611
+ buffer = chunks.pop() || "";
612
+ for (const chunk of chunks) {
613
+ if (chunk) {
614
+ if (typeof chunk === "string") {
615
+ try {
616
+ const parsedChunk = JSON.parse(chunk);
617
+ yield parsedChunk;
618
+ } catch {
619
+ }
620
+ }
621
+ }
622
+ }
623
+ } catch {
624
+ }
625
+ }
626
+ if (buffer) {
627
+ try {
628
+ yield JSON.parse(buffer);
629
+ } catch {
630
+ }
631
+ }
632
+ } finally {
633
+ reader.cancel().catch(() => {
634
+ });
635
+ }
636
+ }
637
+ /**
638
+ * Retrieves details about the vNext workflow
639
+ * @returns Promise containing vNext workflow details including steps and graphs
640
+ */
641
+ details() {
642
+ return this.request(`/api/workflows/v-next/${this.workflowId}`);
643
+ }
644
+ /**
645
+ * Retrieves all runs for a vNext workflow
646
+ * @param params - Parameters for filtering runs
647
+ * @returns Promise containing vNext workflow runs array
648
+ */
649
+ runs(params) {
650
+ const searchParams = new URLSearchParams();
651
+ if (params?.fromDate) {
652
+ searchParams.set("fromDate", params.fromDate.toISOString());
653
+ }
654
+ if (params?.toDate) {
655
+ searchParams.set("toDate", params.toDate.toISOString());
656
+ }
657
+ if (params?.limit) {
658
+ searchParams.set("limit", String(params.limit));
659
+ }
660
+ if (params?.offset) {
661
+ searchParams.set("offset", String(params.offset));
662
+ }
663
+ if (params?.resourceId) {
664
+ searchParams.set("resourceId", params.resourceId);
665
+ }
666
+ if (searchParams.size) {
667
+ return this.request(`/api/workflows/v-next/${this.workflowId}/runs?${searchParams}`);
668
+ } else {
669
+ return this.request(`/api/workflows/v-next/${this.workflowId}/runs`);
670
+ }
671
+ }
672
+ /**
673
+ * Creates a new vNext workflow run
674
+ * @param params - Optional object containing the optional runId
675
+ * @returns Promise containing the runId of the created run
676
+ */
677
+ createRun(params) {
678
+ const searchParams = new URLSearchParams();
679
+ if (!!params?.runId) {
680
+ searchParams.set("runId", params.runId);
681
+ }
682
+ return this.request(`/api/workflows/v-next/${this.workflowId}/create-run?${searchParams.toString()}`, {
683
+ method: "POST"
684
+ });
685
+ }
686
+ /**
687
+ * Starts a vNext workflow run synchronously without waiting for the workflow to complete
688
+ * @param params - Object containing the runId, inputData and runtimeContext
689
+ * @returns Promise containing success message
690
+ */
691
+ start(params) {
692
+ return this.request(`/api/workflows/v-next/${this.workflowId}/start?runId=${params.runId}`, {
693
+ method: "POST",
694
+ body: { inputData: params?.inputData, runtimeContext: params.runtimeContext }
695
+ });
696
+ }
697
+ /**
698
+ * Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
699
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
700
+ * @returns Promise containing success message
701
+ */
702
+ resume({
703
+ step,
704
+ runId,
705
+ resumeData,
706
+ runtimeContext
707
+ }) {
708
+ return this.request(`/api/workflows/v-next/${this.workflowId}/resume?runId=${runId}`, {
709
+ method: "POST",
710
+ stream: true,
711
+ body: {
712
+ step,
713
+ resumeData,
714
+ runtimeContext
715
+ }
716
+ });
717
+ }
718
+ /**
719
+ * Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
720
+ * @param params - Object containing the optional runId, inputData and runtimeContext
721
+ * @returns Promise containing the vNext workflow execution results
722
+ */
723
+ startAsync(params) {
724
+ const searchParams = new URLSearchParams();
725
+ if (!!params?.runId) {
726
+ searchParams.set("runId", params.runId);
727
+ }
728
+ return this.request(`/api/workflows/v-next/${this.workflowId}/start-async?${searchParams.toString()}`, {
729
+ method: "POST",
730
+ body: { inputData: params.inputData, runtimeContext: params.runtimeContext }
731
+ });
732
+ }
733
+ /**
734
+ * Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
735
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
736
+ * @returns Promise containing the vNext workflow resume results
737
+ */
738
+ resumeAsync(params) {
739
+ return this.request(`/api/workflows/v-next/${this.workflowId}/resume-async?runId=${params.runId}`, {
740
+ method: "POST",
741
+ body: {
742
+ step: params.step,
743
+ resumeData: params.resumeData,
744
+ runtimeContext: params.runtimeContext
745
+ }
746
+ });
747
+ }
748
+ /**
749
+ * Watches vNext workflow transitions in real-time
750
+ * @param runId - Optional run ID to filter the watch stream
751
+ * @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
752
+ */
753
+ async watch({ runId }, onRecord) {
754
+ const response = await this.request(`/api/workflows/v-next/${this.workflowId}/watch?runId=${runId}`, {
755
+ stream: true
756
+ });
757
+ if (!response.ok) {
758
+ throw new Error(`Failed to watch vNext workflow: ${response.statusText}`);
759
+ }
760
+ if (!response.body) {
761
+ throw new Error("Response body is null");
762
+ }
763
+ for await (const record of this.streamProcessor(response.body)) {
764
+ onRecord(record);
765
+ }
766
+ }
767
+ };
768
+
769
+ // src/resources/mcp.ts
770
+ var MCPServer = class extends BaseResource {
771
+ constructor(options, serverId) {
772
+ super(options);
773
+ this.serverId = serverId;
774
+ }
775
+ /**
776
+ * Get details about the MCP server
777
+ * @returns Promise containing server details
778
+ */
779
+ details() {
780
+ return this.request(`/api/mcp/servers/${this.serverId}`);
781
+ }
782
+ };
783
+
553
784
  // src/client.ts
554
785
  var MastraClient = class extends BaseResource {
555
786
  constructor(options) {
@@ -642,6 +873,21 @@ var MastraClient = class extends BaseResource {
642
873
  getWorkflow(workflowId) {
643
874
  return new Workflow(this.options, workflowId);
644
875
  }
876
+ /**
877
+ * Retrieves all available vNext workflows
878
+ * @returns Promise containing map of vNext workflow IDs to vNext workflow details
879
+ */
880
+ getVNextWorkflows() {
881
+ return this.request("/api/workflows/v-next");
882
+ }
883
+ /**
884
+ * Gets a vNext workflow instance by ID
885
+ * @param workflowId - ID of the vNext workflow to retrieve
886
+ * @returns vNext Workflow instance
887
+ */
888
+ getVNextWorkflow(workflowId) {
889
+ return new VNextWorkflow(this.options, workflowId);
890
+ }
645
891
  /**
646
892
  * Gets a vector instance by name
647
893
  * @param vectorName - Name of the vector to retrieve
@@ -679,7 +925,7 @@ var MastraClient = class extends BaseResource {
679
925
  * @returns Promise containing telemetry data
680
926
  */
681
927
  getTelemetry(params) {
682
- const { name, scope, page, perPage, attribute } = params || {};
928
+ const { name, scope, page, perPage, attribute, fromDate, toDate } = params || {};
683
929
  const _attribute = attribute ? Object.entries(attribute).map(([key, value]) => `${key}:${value}`) : [];
684
930
  const searchParams = new URLSearchParams();
685
931
  if (name) {
@@ -703,6 +949,12 @@ var MastraClient = class extends BaseResource {
703
949
  searchParams.set("attribute", _attribute);
704
950
  }
705
951
  }
952
+ if (fromDate) {
953
+ searchParams.set("fromDate", fromDate.toISOString());
954
+ }
955
+ if (toDate) {
956
+ searchParams.set("toDate", toDate.toISOString());
957
+ }
706
958
  if (searchParams.size) {
707
959
  return this.request(`/api/telemetry?${searchParams}`);
708
960
  } else {
@@ -724,6 +976,21 @@ var MastraClient = class extends BaseResource {
724
976
  getNetwork(networkId) {
725
977
  return new Network(this.options, networkId);
726
978
  }
979
+ /**
980
+ * Retrieves all available MCP servers
981
+ * @returns Promise containing map of MCP server IDs to server details
982
+ */
983
+ getMCPServers() {
984
+ return this.request("/api/mcp/servers");
985
+ }
986
+ /**
987
+ * Gets an MCP server instance by ID
988
+ * @param serverId - ID of the MCP server to retrieve
989
+ * @returns MCPServer instance
990
+ */
991
+ getMCPServer(serverId) {
992
+ return new MCPServer(this.options, serverId);
993
+ }
727
994
  };
728
995
 
729
996
  exports.MastraClient = MastraClient;