@mastra/client-js 0.0.0-default-storage-virtual-file-20250410035748 → 0.0.0-expose-more-playground-ui-20250501175749

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,11 +1,301 @@
1
1
  # @mastra/client-js
2
2
 
3
- ## 0.0.0-default-storage-virtual-file-20250410035748
3
+ ## 0.0.0-expose-more-playground-ui-20250501175749
4
+
5
+ ### Patch Changes
6
+
7
+ - 254f5c3: Audit, cleanup MastraClient
8
+ - 0097d50: Add serializedStepGraph to vNext workflow
9
+ Return serializedStepGraph from vNext workflow
10
+ Use serializedStepGraph in vNext workflow graph
11
+ - 2429c74: Add get workflow runs api to client-js
12
+ - Updated dependencies [967b41c]
13
+ - Updated dependencies [26738f4]
14
+ - Updated dependencies [b804723]
15
+ - Updated dependencies [0097d50]
16
+ - @mastra/core@0.0.0-expose-more-playground-ui-20250501175749
17
+
18
+ ## 0.1.20-alpha.2
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [26738f4]
23
+ - @mastra/core@0.9.2-alpha.2
24
+
25
+ ## 0.1.20-alpha.1
26
+
27
+ ### Patch Changes
28
+
29
+ - 254f5c3: Audit, cleanup MastraClient
30
+ - 2429c74: Add get workflow runs api to client-js
31
+ - Updated dependencies [b804723]
32
+ - @mastra/core@0.9.2-alpha.1
33
+
34
+ ## 0.1.20-alpha.0
35
+
36
+ ### Patch Changes
37
+
38
+ - 0097d50: Add serializedStepGraph to vNext workflow
39
+ Return serializedStepGraph from vNext workflow
40
+ Use serializedStepGraph in vNext workflow graph
41
+ - Updated dependencies [0097d50]
42
+ - @mastra/core@0.9.2-alpha.0
43
+
44
+ ## 0.1.19
45
+
46
+ ### Patch Changes
47
+
48
+ - b50b9b7: Add vNext workflow to client-js
49
+ - 11d4485: Show VNext workflows on the playground
50
+ Show running status for step in vNext workflowState
51
+ - Updated dependencies [405b63d]
52
+ - Updated dependencies [81fb7f6]
53
+ - Updated dependencies [20275d4]
54
+ - Updated dependencies [7d1892c]
55
+ - Updated dependencies [a90a082]
56
+ - Updated dependencies [2d17c73]
57
+ - Updated dependencies [61e92f5]
58
+ - Updated dependencies [35955b0]
59
+ - Updated dependencies [6262bd5]
60
+ - Updated dependencies [c1409ef]
61
+ - Updated dependencies [3e7b69d]
62
+ - Updated dependencies [e4943b8]
63
+ - Updated dependencies [11d4485]
64
+ - Updated dependencies [479f490]
65
+ - Updated dependencies [c23a81c]
66
+ - Updated dependencies [2d4001d]
67
+ - Updated dependencies [c71013a]
68
+ - Updated dependencies [1d3b1cd]
69
+ - @mastra/core@0.9.1
70
+
71
+ ## 0.1.19-alpha.8
72
+
73
+ ### Patch Changes
74
+
75
+ - Updated dependencies [2d17c73]
76
+ - @mastra/core@0.9.1-alpha.8
77
+
78
+ ## 0.1.19-alpha.7
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies [1d3b1cd]
83
+ - @mastra/core@0.9.1-alpha.7
84
+
85
+ ## 0.1.19-alpha.6
86
+
87
+ ### Patch Changes
88
+
89
+ - Updated dependencies [c23a81c]
90
+ - @mastra/core@0.9.1-alpha.6
91
+
92
+ ## 0.1.19-alpha.5
93
+
94
+ ### Patch Changes
95
+
96
+ - Updated dependencies [3e7b69d]
97
+ - @mastra/core@0.9.1-alpha.5
98
+
99
+ ## 0.1.19-alpha.4
100
+
101
+ ### Patch Changes
102
+
103
+ - Updated dependencies [e4943b8]
104
+ - Updated dependencies [479f490]
105
+ - @mastra/core@0.9.1-alpha.4
106
+
107
+ ## 0.1.19-alpha.3
108
+
109
+ ### Patch Changes
110
+
111
+ - Updated dependencies [6262bd5]
112
+ - @mastra/core@0.9.1-alpha.3
113
+
114
+ ## 0.1.19-alpha.2
115
+
116
+ ### Patch Changes
117
+
118
+ - Updated dependencies [405b63d]
119
+ - Updated dependencies [61e92f5]
120
+ - Updated dependencies [c71013a]
121
+ - @mastra/core@0.9.1-alpha.2
122
+
123
+ ## 0.1.19-alpha.1
124
+
125
+ ### Patch Changes
126
+
127
+ - b50b9b7: Add vNext workflow to client-js
128
+ - 11d4485: Show VNext workflows on the playground
129
+ Show running status for step in vNext workflowState
130
+ - Updated dependencies [20275d4]
131
+ - Updated dependencies [7d1892c]
132
+ - Updated dependencies [a90a082]
133
+ - Updated dependencies [35955b0]
134
+ - Updated dependencies [c1409ef]
135
+ - Updated dependencies [11d4485]
136
+ - Updated dependencies [2d4001d]
137
+ - @mastra/core@0.9.1-alpha.1
138
+
139
+ ## 0.1.19-alpha.0
140
+
141
+ ### Patch Changes
142
+
143
+ - Updated dependencies [81fb7f6]
144
+ - @mastra/core@0.9.1-alpha.0
145
+
146
+ ## 0.1.18
147
+
148
+ ### Patch Changes
149
+
150
+ - 2538066: Fix memory thread creation from client SDK
151
+ - Updated dependencies [000a6d4]
152
+ - Updated dependencies [08bb78e]
153
+ - Updated dependencies [ed2f549]
154
+ - Updated dependencies [7e92011]
155
+ - Updated dependencies [9ee4293]
156
+ - Updated dependencies [03f3cd0]
157
+ - Updated dependencies [c0f22b4]
158
+ - Updated dependencies [71d9444]
159
+ - Updated dependencies [157c741]
160
+ - Updated dependencies [8a8a73b]
161
+ - Updated dependencies [0a033fa]
162
+ - Updated dependencies [fe3ae4d]
163
+ - Updated dependencies [9c26508]
164
+ - Updated dependencies [0f4eae3]
165
+ - Updated dependencies [16a8648]
166
+ - Updated dependencies [6f92295]
167
+ - @mastra/core@0.9.0
168
+
169
+ ## 0.1.18-alpha.8
170
+
171
+ ### Patch Changes
172
+
173
+ - 2538066: Fix memory thread creation from client SDK
174
+ - Updated dependencies [000a6d4]
175
+ - Updated dependencies [ed2f549]
176
+ - Updated dependencies [c0f22b4]
177
+ - Updated dependencies [0a033fa]
178
+ - Updated dependencies [9c26508]
179
+ - Updated dependencies [0f4eae3]
180
+ - Updated dependencies [16a8648]
181
+ - @mastra/core@0.9.0-alpha.8
182
+
183
+ ## 0.1.18-alpha.7
184
+
185
+ ### Patch Changes
186
+
187
+ - Updated dependencies [71d9444]
188
+ - @mastra/core@0.9.0-alpha.7
189
+
190
+ ## 0.1.18-alpha.6
191
+
192
+ ### Patch Changes
193
+
194
+ - Updated dependencies [157c741]
195
+ - @mastra/core@0.9.0-alpha.6
196
+
197
+ ## 0.1.18-alpha.5
198
+
199
+ ### Patch Changes
200
+
201
+ - Updated dependencies [08bb78e]
202
+ - @mastra/core@0.9.0-alpha.5
203
+
204
+ ## 0.1.18-alpha.4
205
+
206
+ ### Patch Changes
207
+
208
+ - Updated dependencies [7e92011]
209
+ - @mastra/core@0.9.0-alpha.4
210
+
211
+ ## 0.1.18-alpha.3
212
+
213
+ ### Patch Changes
214
+
215
+ - Updated dependencies [fe3ae4d]
216
+ - @mastra/core@0.9.0-alpha.3
217
+
218
+ ## 0.1.18-alpha.2
219
+
220
+ ### Patch Changes
221
+
222
+ - Updated dependencies [9ee4293]
223
+ - @mastra/core@0.8.4-alpha.2
224
+
225
+ ## 0.1.18-alpha.1
226
+
227
+ ### Patch Changes
228
+
229
+ - Updated dependencies [8a8a73b]
230
+ - Updated dependencies [6f92295]
231
+ - @mastra/core@0.8.4-alpha.1
232
+
233
+ ## 0.1.18-alpha.0
234
+
235
+ ### Patch Changes
236
+
237
+ - Updated dependencies [03f3cd0]
238
+ - @mastra/core@0.8.4-alpha.0
239
+
240
+ ## 0.1.17
241
+
242
+ ### Patch Changes
243
+
244
+ - 37bb612: Add Elastic-2.0 licensing for packages
245
+ - bc4acb3: updated traces to not be wrapped in traces object
246
+ - Updated dependencies [d72318f]
247
+ - Updated dependencies [0bcc862]
248
+ - Updated dependencies [10a8caf]
249
+ - Updated dependencies [359b089]
250
+ - Updated dependencies [32e7b71]
251
+ - Updated dependencies [37bb612]
252
+ - Updated dependencies [7f1b291]
253
+ - @mastra/core@0.8.3
254
+
255
+ ## 0.1.17-alpha.5
256
+
257
+ ### Patch Changes
258
+
259
+ - Updated dependencies [d72318f]
260
+ - @mastra/core@0.8.3-alpha.5
261
+
262
+ ## 0.1.17-alpha.4
263
+
264
+ ### Patch Changes
265
+
266
+ - Updated dependencies [7f1b291]
267
+ - @mastra/core@0.8.3-alpha.4
268
+
269
+ ## 0.1.17-alpha.3
270
+
271
+ ### Patch Changes
272
+
273
+ - Updated dependencies [10a8caf]
274
+ - @mastra/core@0.8.3-alpha.3
275
+
276
+ ## 0.1.17-alpha.2
277
+
278
+ ### Patch Changes
279
+
280
+ - Updated dependencies [0bcc862]
281
+ - @mastra/core@0.8.3-alpha.2
282
+
283
+ ## 0.1.17-alpha.1
284
+
285
+ ### Patch Changes
286
+
287
+ - 37bb612: Add Elastic-2.0 licensing for packages
288
+ - bc4acb3: updated traces to not be wrapped in traces object
289
+ - Updated dependencies [32e7b71]
290
+ - Updated dependencies [37bb612]
291
+ - @mastra/core@0.8.3-alpha.1
292
+
293
+ ## 0.1.17-alpha.0
4
294
 
5
295
  ### Patch Changes
6
296
 
7
297
  - Updated dependencies [359b089]
8
- - @mastra/core@0.0.0-default-storage-virtual-file-20250410035748
298
+ - @mastra/core@0.8.3-alpha.0
9
299
 
10
300
  ## 0.1.16
11
301
 
@@ -1,4 +1,6 @@
1
- Elastic License 2.0 (ELv2)
1
+ # Elastic License 2.0 (ELv2)
2
+
3
+ Copyright (c) 2025 Mastra AI, Inc.
2
4
 
3
5
  **Acceptance**
4
6
  By using the software, you agree to all of the terms and conditions below.
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,13 @@ 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
+ * @returns Promise containing workflow runs array
379
+ */
380
+ runs() {
381
+ return this.request(`/api/workflows/${this.workflowId}/runs`);
382
+ }
376
383
  /**
377
384
  * @deprecated Use `startAsync` instead
378
385
  * Executes the workflow with the provided parameters
@@ -489,7 +496,7 @@ var Workflow = class extends BaseResource {
489
496
  }
490
497
  }
491
498
  }
492
- } catch (error) {
499
+ } catch {
493
500
  }
494
501
  }
495
502
  if (buffer) {
@@ -543,13 +550,180 @@ var Tool = class extends BaseResource {
543
550
  * @returns Promise containing the tool execution results
544
551
  */
545
552
  execute(params) {
546
- return this.request(`/api/tools/${this.toolId}/execute`, {
553
+ const url = new URLSearchParams();
554
+ if (params.runId) {
555
+ url.set("runId", params.runId);
556
+ }
557
+ return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
547
558
  method: "POST",
548
- body: params
559
+ body: params.data
549
560
  });
550
561
  }
551
562
  };
552
563
 
564
+ // src/resources/vnext-workflow.ts
565
+ var RECORD_SEPARATOR2 = "";
566
+ var VNextWorkflow = class extends BaseResource {
567
+ constructor(options, workflowId) {
568
+ super(options);
569
+ this.workflowId = workflowId;
570
+ }
571
+ /**
572
+ * Creates an async generator that processes a readable stream and yields vNext workflow records
573
+ * separated by the Record Separator character (\x1E)
574
+ *
575
+ * @param stream - The readable stream to process
576
+ * @returns An async generator that yields parsed records
577
+ */
578
+ async *streamProcessor(stream) {
579
+ const reader = stream.getReader();
580
+ let doneReading = false;
581
+ let buffer = "";
582
+ try {
583
+ while (!doneReading) {
584
+ const { done, value } = await reader.read();
585
+ doneReading = done;
586
+ if (done && !value) continue;
587
+ try {
588
+ const decoded = value ? new TextDecoder().decode(value) : "";
589
+ const chunks = (buffer + decoded).split(RECORD_SEPARATOR2);
590
+ buffer = chunks.pop() || "";
591
+ for (const chunk of chunks) {
592
+ if (chunk) {
593
+ if (typeof chunk === "string") {
594
+ try {
595
+ const parsedChunk = JSON.parse(chunk);
596
+ yield parsedChunk;
597
+ } catch {
598
+ }
599
+ }
600
+ }
601
+ }
602
+ } catch {
603
+ }
604
+ }
605
+ if (buffer) {
606
+ try {
607
+ yield JSON.parse(buffer);
608
+ } catch {
609
+ }
610
+ }
611
+ } finally {
612
+ reader.cancel().catch(() => {
613
+ });
614
+ }
615
+ }
616
+ /**
617
+ * Retrieves details about the vNext workflow
618
+ * @returns Promise containing vNext workflow details including steps and graphs
619
+ */
620
+ details() {
621
+ return this.request(`/api/workflows/v-next/${this.workflowId}`);
622
+ }
623
+ /**
624
+ * Retrieves all runs for a vNext workflow
625
+ * @returns Promise containing vNext workflow runs array
626
+ */
627
+ runs() {
628
+ return this.request(`/api/workflows/v-next/${this.workflowId}/runs`);
629
+ }
630
+ /**
631
+ * Creates a new vNext workflow run
632
+ * @param params - Optional object containing the optional runId
633
+ * @returns Promise containing the runId of the created run
634
+ */
635
+ createRun(params) {
636
+ const searchParams = new URLSearchParams();
637
+ if (!!params?.runId) {
638
+ searchParams.set("runId", params.runId);
639
+ }
640
+ return this.request(`/api/workflows/v-next/${this.workflowId}/create-run?${searchParams.toString()}`, {
641
+ method: "POST"
642
+ });
643
+ }
644
+ /**
645
+ * Starts a vNext workflow run synchronously without waiting for the workflow to complete
646
+ * @param params - Object containing the runId, inputData and runtimeContext
647
+ * @returns Promise containing success message
648
+ */
649
+ start(params) {
650
+ return this.request(`/api/workflows/v-next/${this.workflowId}/start?runId=${params.runId}`, {
651
+ method: "POST",
652
+ body: { inputData: params?.inputData, runtimeContext: params.runtimeContext }
653
+ });
654
+ }
655
+ /**
656
+ * Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
657
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
658
+ * @returns Promise containing success message
659
+ */
660
+ resume({
661
+ step,
662
+ runId,
663
+ resumeData,
664
+ runtimeContext
665
+ }) {
666
+ return this.request(`/api/workflows/v-next/${this.workflowId}/resume?runId=${runId}`, {
667
+ method: "POST",
668
+ stream: true,
669
+ body: {
670
+ step,
671
+ resumeData,
672
+ runtimeContext
673
+ }
674
+ });
675
+ }
676
+ /**
677
+ * Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
678
+ * @param params - Object containing the optional runId, inputData and runtimeContext
679
+ * @returns Promise containing the vNext workflow execution results
680
+ */
681
+ startAsync(params) {
682
+ const searchParams = new URLSearchParams();
683
+ if (!!params?.runId) {
684
+ searchParams.set("runId", params.runId);
685
+ }
686
+ return this.request(`/api/workflows/v-next/${this.workflowId}/start-async?${searchParams.toString()}`, {
687
+ method: "POST",
688
+ body: { inputData: params.inputData, runtimeContext: params.runtimeContext }
689
+ });
690
+ }
691
+ /**
692
+ * Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
693
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
694
+ * @returns Promise containing the vNext workflow resume results
695
+ */
696
+ resumeAsync(params) {
697
+ return this.request(`/api/workflows/v-next/${this.workflowId}/resume-async?runId=${params.runId}`, {
698
+ method: "POST",
699
+ body: {
700
+ step: params.step,
701
+ resumeData: params.resumeData,
702
+ runtimeContext: params.runtimeContext
703
+ }
704
+ });
705
+ }
706
+ /**
707
+ * Watches vNext workflow transitions in real-time
708
+ * @param runId - Optional run ID to filter the watch stream
709
+ * @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
710
+ */
711
+ async watch({ runId }, onRecord) {
712
+ const response = await this.request(`/api/workflows/v-next/${this.workflowId}/watch?runId=${runId}`, {
713
+ stream: true
714
+ });
715
+ if (!response.ok) {
716
+ throw new Error(`Failed to watch vNext workflow: ${response.statusText}`);
717
+ }
718
+ if (!response.body) {
719
+ throw new Error("Response body is null");
720
+ }
721
+ for await (const record of this.streamProcessor(response.body)) {
722
+ onRecord(record);
723
+ }
724
+ }
725
+ };
726
+
553
727
  // src/client.ts
554
728
  var MastraClient = class extends BaseResource {
555
729
  constructor(options) {
@@ -642,6 +816,21 @@ var MastraClient = class extends BaseResource {
642
816
  getWorkflow(workflowId) {
643
817
  return new Workflow(this.options, workflowId);
644
818
  }
819
+ /**
820
+ * Retrieves all available vNext workflows
821
+ * @returns Promise containing map of vNext workflow IDs to vNext workflow details
822
+ */
823
+ getVNextWorkflows() {
824
+ return this.request("/api/workflows/v-next");
825
+ }
826
+ /**
827
+ * Gets a vNext workflow instance by ID
828
+ * @param workflowId - ID of the vNext workflow to retrieve
829
+ * @returns vNext Workflow instance
830
+ */
831
+ getVNextWorkflow(workflowId) {
832
+ return new VNextWorkflow(this.options, workflowId);
833
+ }
645
834
  /**
646
835
  * Gets a vector instance by name
647
836
  * @param vectorName - Name of the vector to retrieve