@mastra/client-js 0.1.23-alpha.0 → 0.2.0-alpha.1
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/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +24 -0
- package/dist/index.cjs +83 -85
- package/dist/index.d.cts +73 -78
- package/dist/index.d.ts +73 -78
- package/dist/index.js +83 -85
- package/package.json +6 -5
- package/src/client.ts +20 -21
- package/src/resources/agent.ts +4 -3
- package/src/resources/index.ts +2 -2
- package/src/resources/{vnext-workflow.ts → legacy-workflow.ts} +124 -143
- package/src/resources/tool.ts +4 -3
- package/src/resources/workflow.ts +121 -109
- package/src/types.ts +21 -18
- package/src/utils/index.ts +11 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/client-js@0.
|
|
2
|
+
> @mastra/client-js@0.2.0-alpha.1 build /home/runner/work/mastra/mastra/client-sdks/client-js
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
[34mCLI[39m Cleaning output folder
|
|
10
10
|
[34mESM[39m Build start
|
|
11
11
|
[34mCJS[39m Build start
|
|
12
|
-
[32mCJS[39m [1mdist/index.cjs [22m[32m41.
|
|
13
|
-
[32mCJS[39m ⚡️ Build success in
|
|
14
|
-
[32mESM[39m [1mdist/index.js [22m[32m41.
|
|
15
|
-
[32mESM[39m ⚡️ Build success in
|
|
12
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m41.29 KB[39m
|
|
13
|
+
[32mCJS[39m ⚡️ Build success in 1179ms
|
|
14
|
+
[32mESM[39m [1mdist/index.js [22m[32m41.00 KB[39m
|
|
15
|
+
[32mESM[39m ⚡️ Build success in 1188ms
|
|
16
16
|
[34mDTS[39m Build start
|
|
17
|
-
[32mDTS[39m ⚡️ Build success in
|
|
18
|
-
[32mDTS[39m [1mdist/index.d.ts [22m[32m30.
|
|
19
|
-
[32mDTS[39m [1mdist/index.d.cts [22m[32m30.
|
|
17
|
+
[32mDTS[39m ⚡️ Build success in 13211ms
|
|
18
|
+
[32mDTS[39m [1mdist/index.d.ts [22m[32m30.61 KB[39m
|
|
19
|
+
[32mDTS[39m [1mdist/index.d.cts [22m[32m30.61 KB[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @mastra/client-js
|
|
2
2
|
|
|
3
|
+
## 0.2.0-alpha.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 83da932: Move @mastra/core to peerdeps
|
|
8
|
+
- 5eb5a99: Remove pino from @mastra/core into @mastra/loggers
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- b3a3d63: BREAKING: Make vnext workflow the default worklow, and old workflow legacy_workflow
|
|
13
|
+
- 0215b0b: Add description to vnext workflow response
|
|
14
|
+
- 5063646: Accept plain obects as runtimeContext
|
|
15
|
+
- Updated dependencies [b3a3d63]
|
|
16
|
+
- Updated dependencies [344f453]
|
|
17
|
+
- Updated dependencies [0a3ae6d]
|
|
18
|
+
- Updated dependencies [95911be]
|
|
19
|
+
- Updated dependencies [5eb5a99]
|
|
20
|
+
- Updated dependencies [7e632c5]
|
|
21
|
+
- Updated dependencies [1e9fbfa]
|
|
22
|
+
- Updated dependencies [b2ae5aa]
|
|
23
|
+
- Updated dependencies [a7292b0]
|
|
24
|
+
- Updated dependencies [0dcb9f0]
|
|
25
|
+
- @mastra/core@0.10.0-alpha.1
|
|
26
|
+
|
|
3
27
|
## 0.1.23-alpha.0
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -5,6 +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 runtimeContext = require('@mastra/core/runtime-context');
|
|
8
9
|
|
|
9
10
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
11
|
|
|
@@ -260,6 +261,15 @@ var BaseResource = class {
|
|
|
260
261
|
throw lastError || new Error("Request failed");
|
|
261
262
|
}
|
|
262
263
|
};
|
|
264
|
+
function parseClientRuntimeContext(runtimeContext$1) {
|
|
265
|
+
if (runtimeContext$1) {
|
|
266
|
+
if (runtimeContext$1 instanceof runtimeContext.RuntimeContext) {
|
|
267
|
+
return Object.fromEntries(runtimeContext$1.entries());
|
|
268
|
+
}
|
|
269
|
+
return runtimeContext$1;
|
|
270
|
+
}
|
|
271
|
+
return void 0;
|
|
272
|
+
}
|
|
263
273
|
|
|
264
274
|
// src/resources/agent.ts
|
|
265
275
|
var AgentVoice = class extends BaseResource {
|
|
@@ -333,7 +343,7 @@ var Agent = class extends BaseResource {
|
|
|
333
343
|
...params,
|
|
334
344
|
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
335
345
|
experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
|
|
336
|
-
runtimeContext:
|
|
346
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
337
347
|
};
|
|
338
348
|
return this.request(`/api/agents/${this.agentId}/generate`, {
|
|
339
349
|
method: "POST",
|
|
@@ -350,7 +360,7 @@ var Agent = class extends BaseResource {
|
|
|
350
360
|
...params,
|
|
351
361
|
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
352
362
|
experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
|
|
353
|
-
runtimeContext:
|
|
363
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
354
364
|
};
|
|
355
365
|
const response = await this.request(`/api/agents/${this.agentId}/stream`, {
|
|
356
366
|
method: "POST",
|
|
@@ -578,24 +588,24 @@ var Vector = class extends BaseResource {
|
|
|
578
588
|
}
|
|
579
589
|
};
|
|
580
590
|
|
|
581
|
-
// src/resources/workflow.ts
|
|
591
|
+
// src/resources/legacy-workflow.ts
|
|
582
592
|
var RECORD_SEPARATOR = "";
|
|
583
|
-
var
|
|
593
|
+
var LegacyWorkflow = class extends BaseResource {
|
|
584
594
|
constructor(options, workflowId) {
|
|
585
595
|
super(options);
|
|
586
596
|
this.workflowId = workflowId;
|
|
587
597
|
}
|
|
588
598
|
/**
|
|
589
|
-
* Retrieves details about the workflow
|
|
590
|
-
* @returns Promise containing workflow details including steps and graphs
|
|
599
|
+
* Retrieves details about the legacy workflow
|
|
600
|
+
* @returns Promise containing legacy workflow details including steps and graphs
|
|
591
601
|
*/
|
|
592
602
|
details() {
|
|
593
|
-
return this.request(`/api/workflows/${this.workflowId}`);
|
|
603
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}`);
|
|
594
604
|
}
|
|
595
605
|
/**
|
|
596
|
-
* Retrieves all runs for a workflow
|
|
606
|
+
* Retrieves all runs for a legacy workflow
|
|
597
607
|
* @param params - Parameters for filtering runs
|
|
598
|
-
* @returns Promise containing workflow runs array
|
|
608
|
+
* @returns Promise containing legacy workflow runs array
|
|
599
609
|
*/
|
|
600
610
|
runs(params) {
|
|
601
611
|
const searchParams = new URLSearchParams();
|
|
@@ -615,25 +625,13 @@ var Workflow = class extends BaseResource {
|
|
|
615
625
|
searchParams.set("resourceId", params.resourceId);
|
|
616
626
|
}
|
|
617
627
|
if (searchParams.size) {
|
|
618
|
-
return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
|
|
628
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/runs?${searchParams}`);
|
|
619
629
|
} else {
|
|
620
|
-
return this.request(`/api/workflows/${this.workflowId}/runs`);
|
|
630
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/runs`);
|
|
621
631
|
}
|
|
622
632
|
}
|
|
623
633
|
/**
|
|
624
|
-
*
|
|
625
|
-
* Executes the workflow with the provided parameters
|
|
626
|
-
* @param params - Parameters required for workflow execution
|
|
627
|
-
* @returns Promise containing the workflow execution results
|
|
628
|
-
*/
|
|
629
|
-
execute(params) {
|
|
630
|
-
return this.request(`/api/workflows/${this.workflowId}/execute`, {
|
|
631
|
-
method: "POST",
|
|
632
|
-
body: params
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
/**
|
|
636
|
-
* Creates a new workflow run
|
|
634
|
+
* Creates a new legacy workflow run
|
|
637
635
|
* @returns Promise containing the generated run ID
|
|
638
636
|
*/
|
|
639
637
|
createRun(params) {
|
|
@@ -641,34 +639,34 @@ var Workflow = class extends BaseResource {
|
|
|
641
639
|
if (!!params?.runId) {
|
|
642
640
|
searchParams.set("runId", params.runId);
|
|
643
641
|
}
|
|
644
|
-
return this.request(`/api/workflows/${this.workflowId}/
|
|
642
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/create-run?${searchParams.toString()}`, {
|
|
645
643
|
method: "POST"
|
|
646
644
|
});
|
|
647
645
|
}
|
|
648
646
|
/**
|
|
649
|
-
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
647
|
+
* Starts a legacy workflow run synchronously without waiting for the workflow to complete
|
|
650
648
|
* @param params - Object containing the runId and triggerData
|
|
651
649
|
* @returns Promise containing success message
|
|
652
650
|
*/
|
|
653
651
|
start(params) {
|
|
654
|
-
return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
|
|
652
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/start?runId=${params.runId}`, {
|
|
655
653
|
method: "POST",
|
|
656
654
|
body: params?.triggerData
|
|
657
655
|
});
|
|
658
656
|
}
|
|
659
657
|
/**
|
|
660
|
-
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
658
|
+
* Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
|
|
661
659
|
* @param stepId - ID of the step to resume
|
|
662
|
-
* @param runId - ID of the workflow run
|
|
663
|
-
* @param context - Context to resume the workflow with
|
|
664
|
-
* @returns Promise containing the workflow resume results
|
|
660
|
+
* @param runId - ID of the legacy workflow run
|
|
661
|
+
* @param context - Context to resume the legacy workflow with
|
|
662
|
+
* @returns Promise containing the legacy workflow resume results
|
|
665
663
|
*/
|
|
666
664
|
resume({
|
|
667
665
|
stepId,
|
|
668
666
|
runId,
|
|
669
667
|
context
|
|
670
668
|
}) {
|
|
671
|
-
return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
|
|
669
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/resume?runId=${runId}`, {
|
|
672
670
|
method: "POST",
|
|
673
671
|
body: {
|
|
674
672
|
stepId,
|
|
@@ -686,18 +684,18 @@ var Workflow = class extends BaseResource {
|
|
|
686
684
|
if (!!params?.runId) {
|
|
687
685
|
searchParams.set("runId", params.runId);
|
|
688
686
|
}
|
|
689
|
-
return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
687
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
690
688
|
method: "POST",
|
|
691
689
|
body: params?.triggerData
|
|
692
690
|
});
|
|
693
691
|
}
|
|
694
692
|
/**
|
|
695
|
-
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
693
|
+
* Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
696
694
|
* @param params - Object containing the runId, stepId, and context
|
|
697
695
|
* @returns Promise containing the workflow resume results
|
|
698
696
|
*/
|
|
699
697
|
resumeAsync(params) {
|
|
700
|
-
return this.request(`/api/workflows/${this.workflowId}/resume-async?runId=${params.runId}`, {
|
|
698
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/resume-async?runId=${params.runId}`, {
|
|
701
699
|
method: "POST",
|
|
702
700
|
body: {
|
|
703
701
|
stepId: params.stepId,
|
|
@@ -751,16 +749,16 @@ var Workflow = class extends BaseResource {
|
|
|
751
749
|
}
|
|
752
750
|
}
|
|
753
751
|
/**
|
|
754
|
-
* Watches workflow transitions in real-time
|
|
752
|
+
* Watches legacy workflow transitions in real-time
|
|
755
753
|
* @param runId - Optional run ID to filter the watch stream
|
|
756
|
-
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
754
|
+
* @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
|
|
757
755
|
*/
|
|
758
756
|
async watch({ runId }, onRecord) {
|
|
759
|
-
const response = await this.request(`/api/workflows/${this.workflowId}/watch?runId=${runId}`, {
|
|
757
|
+
const response = await this.request(`/api/workflows/legacy/${this.workflowId}/watch?runId=${runId}`, {
|
|
760
758
|
stream: true
|
|
761
759
|
});
|
|
762
760
|
if (!response.ok) {
|
|
763
|
-
throw new Error(`Failed to watch workflow: ${response.statusText}`);
|
|
761
|
+
throw new Error(`Failed to watch legacy workflow: ${response.statusText}`);
|
|
764
762
|
}
|
|
765
763
|
if (!response.body) {
|
|
766
764
|
throw new Error("Response body is null");
|
|
@@ -796,7 +794,7 @@ var Tool = class extends BaseResource {
|
|
|
796
794
|
}
|
|
797
795
|
const body = {
|
|
798
796
|
data: params.data,
|
|
799
|
-
runtimeContext:
|
|
797
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
800
798
|
};
|
|
801
799
|
return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
|
|
802
800
|
method: "POST",
|
|
@@ -805,15 +803,15 @@ var Tool = class extends BaseResource {
|
|
|
805
803
|
}
|
|
806
804
|
};
|
|
807
805
|
|
|
808
|
-
// src/resources/
|
|
806
|
+
// src/resources/workflow.ts
|
|
809
807
|
var RECORD_SEPARATOR2 = "";
|
|
810
|
-
var
|
|
808
|
+
var Workflow = class extends BaseResource {
|
|
811
809
|
constructor(options, workflowId) {
|
|
812
810
|
super(options);
|
|
813
811
|
this.workflowId = workflowId;
|
|
814
812
|
}
|
|
815
813
|
/**
|
|
816
|
-
* Creates an async generator that processes a readable stream and yields
|
|
814
|
+
* Creates an async generator that processes a readable stream and yields workflow records
|
|
817
815
|
* separated by the Record Separator character (\x1E)
|
|
818
816
|
*
|
|
819
817
|
* @param stream - The readable stream to process
|
|
@@ -858,16 +856,16 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
858
856
|
}
|
|
859
857
|
}
|
|
860
858
|
/**
|
|
861
|
-
* Retrieves details about the
|
|
862
|
-
* @returns Promise containing
|
|
859
|
+
* Retrieves details about the workflow
|
|
860
|
+
* @returns Promise containing workflow details including steps and graphs
|
|
863
861
|
*/
|
|
864
862
|
details() {
|
|
865
|
-
return this.request(`/api/workflows
|
|
863
|
+
return this.request(`/api/workflows/${this.workflowId}`);
|
|
866
864
|
}
|
|
867
865
|
/**
|
|
868
|
-
* Retrieves all runs for a
|
|
866
|
+
* Retrieves all runs for a workflow
|
|
869
867
|
* @param params - Parameters for filtering runs
|
|
870
|
-
* @returns Promise containing
|
|
868
|
+
* @returns Promise containing workflow runs array
|
|
871
869
|
*/
|
|
872
870
|
runs(params) {
|
|
873
871
|
const searchParams = new URLSearchParams();
|
|
@@ -887,13 +885,13 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
887
885
|
searchParams.set("resourceId", params.resourceId);
|
|
888
886
|
}
|
|
889
887
|
if (searchParams.size) {
|
|
890
|
-
return this.request(`/api/workflows
|
|
888
|
+
return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
|
|
891
889
|
} else {
|
|
892
|
-
return this.request(`/api/workflows
|
|
890
|
+
return this.request(`/api/workflows/${this.workflowId}/runs`);
|
|
893
891
|
}
|
|
894
892
|
}
|
|
895
893
|
/**
|
|
896
|
-
* Creates a new
|
|
894
|
+
* Creates a new workflow run
|
|
897
895
|
* @param params - Optional object containing the optional runId
|
|
898
896
|
* @returns Promise containing the runId of the created run
|
|
899
897
|
*/
|
|
@@ -902,24 +900,24 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
902
900
|
if (!!params?.runId) {
|
|
903
901
|
searchParams.set("runId", params.runId);
|
|
904
902
|
}
|
|
905
|
-
return this.request(`/api/workflows
|
|
903
|
+
return this.request(`/api/workflows/${this.workflowId}/create-run?${searchParams.toString()}`, {
|
|
906
904
|
method: "POST"
|
|
907
905
|
});
|
|
908
906
|
}
|
|
909
907
|
/**
|
|
910
|
-
* Starts a
|
|
908
|
+
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
911
909
|
* @param params - Object containing the runId, inputData and runtimeContext
|
|
912
910
|
* @returns Promise containing success message
|
|
913
911
|
*/
|
|
914
912
|
start(params) {
|
|
915
|
-
const runtimeContext =
|
|
916
|
-
return this.request(`/api/workflows
|
|
913
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
914
|
+
return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
|
|
917
915
|
method: "POST",
|
|
918
916
|
body: { inputData: params?.inputData, runtimeContext }
|
|
919
917
|
});
|
|
920
918
|
}
|
|
921
919
|
/**
|
|
922
|
-
* Resumes a suspended
|
|
920
|
+
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
923
921
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
924
922
|
* @returns Promise containing success message
|
|
925
923
|
*/
|
|
@@ -929,8 +927,8 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
929
927
|
resumeData,
|
|
930
928
|
...rest
|
|
931
929
|
}) {
|
|
932
|
-
const runtimeContext =
|
|
933
|
-
return this.request(`/api/workflows
|
|
930
|
+
const runtimeContext = parseClientRuntimeContext(rest.runtimeContext);
|
|
931
|
+
return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
|
|
934
932
|
method: "POST",
|
|
935
933
|
stream: true,
|
|
936
934
|
body: {
|
|
@@ -941,29 +939,29 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
941
939
|
});
|
|
942
940
|
}
|
|
943
941
|
/**
|
|
944
|
-
* Starts a
|
|
942
|
+
* Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
|
|
945
943
|
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
946
|
-
* @returns Promise containing the
|
|
944
|
+
* @returns Promise containing the workflow execution results
|
|
947
945
|
*/
|
|
948
946
|
startAsync(params) {
|
|
949
947
|
const searchParams = new URLSearchParams();
|
|
950
948
|
if (!!params?.runId) {
|
|
951
949
|
searchParams.set("runId", params.runId);
|
|
952
950
|
}
|
|
953
|
-
const runtimeContext =
|
|
954
|
-
return this.request(`/api/workflows
|
|
951
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
952
|
+
return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
955
953
|
method: "POST",
|
|
956
954
|
body: { inputData: params.inputData, runtimeContext }
|
|
957
955
|
});
|
|
958
956
|
}
|
|
959
957
|
/**
|
|
960
|
-
* Resumes a suspended
|
|
958
|
+
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
961
959
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
962
|
-
* @returns Promise containing the
|
|
960
|
+
* @returns Promise containing the workflow resume results
|
|
963
961
|
*/
|
|
964
962
|
resumeAsync(params) {
|
|
965
|
-
const runtimeContext =
|
|
966
|
-
return this.request(`/api/workflows
|
|
963
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
964
|
+
return this.request(`/api/workflows/${this.workflowId}/resume-async?runId=${params.runId}`, {
|
|
967
965
|
method: "POST",
|
|
968
966
|
body: {
|
|
969
967
|
step: params.step,
|
|
@@ -973,16 +971,16 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
973
971
|
});
|
|
974
972
|
}
|
|
975
973
|
/**
|
|
976
|
-
* Watches
|
|
974
|
+
* Watches workflow transitions in real-time
|
|
977
975
|
* @param runId - Optional run ID to filter the watch stream
|
|
978
|
-
* @returns AsyncGenerator that yields parsed records from the
|
|
976
|
+
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
979
977
|
*/
|
|
980
978
|
async watch({ runId }, onRecord) {
|
|
981
|
-
const response = await this.request(`/api/workflows
|
|
979
|
+
const response = await this.request(`/api/workflows/${this.workflowId}/watch?runId=${runId}`, {
|
|
982
980
|
stream: true
|
|
983
981
|
});
|
|
984
982
|
if (!response.ok) {
|
|
985
|
-
throw new Error(`Failed to watch
|
|
983
|
+
throw new Error(`Failed to watch workflow: ${response.statusText}`);
|
|
986
984
|
}
|
|
987
985
|
if (!response.body) {
|
|
988
986
|
throw new Error("Response body is null");
|
|
@@ -1193,6 +1191,21 @@ var MastraClient = class extends BaseResource {
|
|
|
1193
1191
|
getTool(toolId) {
|
|
1194
1192
|
return new Tool(this.options, toolId);
|
|
1195
1193
|
}
|
|
1194
|
+
/**
|
|
1195
|
+
* Retrieves all available legacy workflows
|
|
1196
|
+
* @returns Promise containing map of legacy workflow IDs to legacy workflow details
|
|
1197
|
+
*/
|
|
1198
|
+
getLegacyWorkflows() {
|
|
1199
|
+
return this.request("/api/workflows/legacy");
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* Gets a legacy workflow instance by ID
|
|
1203
|
+
* @param workflowId - ID of the legacy workflow to retrieve
|
|
1204
|
+
* @returns Legacy Workflow instance
|
|
1205
|
+
*/
|
|
1206
|
+
getLegacyWorkflow(workflowId) {
|
|
1207
|
+
return new LegacyWorkflow(this.options, workflowId);
|
|
1208
|
+
}
|
|
1196
1209
|
/**
|
|
1197
1210
|
* Retrieves all available workflows
|
|
1198
1211
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
@@ -1208,21 +1221,6 @@ var MastraClient = class extends BaseResource {
|
|
|
1208
1221
|
getWorkflow(workflowId) {
|
|
1209
1222
|
return new Workflow(this.options, workflowId);
|
|
1210
1223
|
}
|
|
1211
|
-
/**
|
|
1212
|
-
* Retrieves all available vNext workflows
|
|
1213
|
-
* @returns Promise containing map of vNext workflow IDs to vNext workflow details
|
|
1214
|
-
*/
|
|
1215
|
-
getVNextWorkflows() {
|
|
1216
|
-
return this.request("/api/workflows/v-next");
|
|
1217
|
-
}
|
|
1218
|
-
/**
|
|
1219
|
-
* Gets a vNext workflow instance by ID
|
|
1220
|
-
* @param workflowId - ID of the vNext workflow to retrieve
|
|
1221
|
-
* @returns vNext Workflow instance
|
|
1222
|
-
*/
|
|
1223
|
-
getVNextWorkflow(workflowId) {
|
|
1224
|
-
return new VNextWorkflow(this.options, workflowId);
|
|
1225
|
-
}
|
|
1226
1224
|
/**
|
|
1227
1225
|
* Gets a vector instance by name
|
|
1228
1226
|
* @param vectorName - Name of the vector to retrieve
|