@mastra/client-js 0.1.23-alpha.0 → 0.10.0
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 +61 -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/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 {
|
|
@@ -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 {
|
|
@@ -327,7 +337,7 @@ var Agent = class extends BaseResource {
|
|
|
327
337
|
...params,
|
|
328
338
|
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
329
339
|
experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
|
|
330
|
-
runtimeContext:
|
|
340
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
331
341
|
};
|
|
332
342
|
return this.request(`/api/agents/${this.agentId}/generate`, {
|
|
333
343
|
method: "POST",
|
|
@@ -344,7 +354,7 @@ var Agent = class extends BaseResource {
|
|
|
344
354
|
...params,
|
|
345
355
|
output: params.output ? zodToJsonSchema(params.output) : void 0,
|
|
346
356
|
experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : void 0,
|
|
347
|
-
runtimeContext:
|
|
357
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
348
358
|
};
|
|
349
359
|
const response = await this.request(`/api/agents/${this.agentId}/stream`, {
|
|
350
360
|
method: "POST",
|
|
@@ -572,24 +582,24 @@ var Vector = class extends BaseResource {
|
|
|
572
582
|
}
|
|
573
583
|
};
|
|
574
584
|
|
|
575
|
-
// src/resources/workflow.ts
|
|
585
|
+
// src/resources/legacy-workflow.ts
|
|
576
586
|
var RECORD_SEPARATOR = "";
|
|
577
|
-
var
|
|
587
|
+
var LegacyWorkflow = class extends BaseResource {
|
|
578
588
|
constructor(options, workflowId) {
|
|
579
589
|
super(options);
|
|
580
590
|
this.workflowId = workflowId;
|
|
581
591
|
}
|
|
582
592
|
/**
|
|
583
|
-
* Retrieves details about the workflow
|
|
584
|
-
* @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
|
|
585
595
|
*/
|
|
586
596
|
details() {
|
|
587
|
-
return this.request(`/api/workflows/${this.workflowId}`);
|
|
597
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}`);
|
|
588
598
|
}
|
|
589
599
|
/**
|
|
590
|
-
* Retrieves all runs for a workflow
|
|
600
|
+
* Retrieves all runs for a legacy workflow
|
|
591
601
|
* @param params - Parameters for filtering runs
|
|
592
|
-
* @returns Promise containing workflow runs array
|
|
602
|
+
* @returns Promise containing legacy workflow runs array
|
|
593
603
|
*/
|
|
594
604
|
runs(params) {
|
|
595
605
|
const searchParams = new URLSearchParams();
|
|
@@ -609,25 +619,13 @@ var Workflow = class extends BaseResource {
|
|
|
609
619
|
searchParams.set("resourceId", params.resourceId);
|
|
610
620
|
}
|
|
611
621
|
if (searchParams.size) {
|
|
612
|
-
return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
|
|
622
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/runs?${searchParams}`);
|
|
613
623
|
} else {
|
|
614
|
-
return this.request(`/api/workflows/${this.workflowId}/runs`);
|
|
624
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/runs`);
|
|
615
625
|
}
|
|
616
626
|
}
|
|
617
627
|
/**
|
|
618
|
-
*
|
|
619
|
-
* Executes the workflow with the provided parameters
|
|
620
|
-
* @param params - Parameters required for workflow execution
|
|
621
|
-
* @returns Promise containing the workflow execution results
|
|
622
|
-
*/
|
|
623
|
-
execute(params) {
|
|
624
|
-
return this.request(`/api/workflows/${this.workflowId}/execute`, {
|
|
625
|
-
method: "POST",
|
|
626
|
-
body: params
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
/**
|
|
630
|
-
* Creates a new workflow run
|
|
628
|
+
* Creates a new legacy workflow run
|
|
631
629
|
* @returns Promise containing the generated run ID
|
|
632
630
|
*/
|
|
633
631
|
createRun(params) {
|
|
@@ -635,34 +633,34 @@ var Workflow = class extends BaseResource {
|
|
|
635
633
|
if (!!params?.runId) {
|
|
636
634
|
searchParams.set("runId", params.runId);
|
|
637
635
|
}
|
|
638
|
-
return this.request(`/api/workflows/${this.workflowId}/
|
|
636
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/create-run?${searchParams.toString()}`, {
|
|
639
637
|
method: "POST"
|
|
640
638
|
});
|
|
641
639
|
}
|
|
642
640
|
/**
|
|
643
|
-
* 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
|
|
644
642
|
* @param params - Object containing the runId and triggerData
|
|
645
643
|
* @returns Promise containing success message
|
|
646
644
|
*/
|
|
647
645
|
start(params) {
|
|
648
|
-
return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
|
|
646
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/start?runId=${params.runId}`, {
|
|
649
647
|
method: "POST",
|
|
650
648
|
body: params?.triggerData
|
|
651
649
|
});
|
|
652
650
|
}
|
|
653
651
|
/**
|
|
654
|
-
* 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
|
|
655
653
|
* @param stepId - ID of the step to resume
|
|
656
|
-
* @param runId - ID of the workflow run
|
|
657
|
-
* @param context - Context to resume the workflow with
|
|
658
|
-
* @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
|
|
659
657
|
*/
|
|
660
658
|
resume({
|
|
661
659
|
stepId,
|
|
662
660
|
runId,
|
|
663
661
|
context
|
|
664
662
|
}) {
|
|
665
|
-
return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
|
|
663
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/resume?runId=${runId}`, {
|
|
666
664
|
method: "POST",
|
|
667
665
|
body: {
|
|
668
666
|
stepId,
|
|
@@ -680,18 +678,18 @@ var Workflow = class extends BaseResource {
|
|
|
680
678
|
if (!!params?.runId) {
|
|
681
679
|
searchParams.set("runId", params.runId);
|
|
682
680
|
}
|
|
683
|
-
return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
681
|
+
return this.request(`/api/workflows/legacy/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
684
682
|
method: "POST",
|
|
685
683
|
body: params?.triggerData
|
|
686
684
|
});
|
|
687
685
|
}
|
|
688
686
|
/**
|
|
689
|
-
* 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
|
|
690
688
|
* @param params - Object containing the runId, stepId, and context
|
|
691
689
|
* @returns Promise containing the workflow resume results
|
|
692
690
|
*/
|
|
693
691
|
resumeAsync(params) {
|
|
694
|
-
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}`, {
|
|
695
693
|
method: "POST",
|
|
696
694
|
body: {
|
|
697
695
|
stepId: params.stepId,
|
|
@@ -745,16 +743,16 @@ var Workflow = class extends BaseResource {
|
|
|
745
743
|
}
|
|
746
744
|
}
|
|
747
745
|
/**
|
|
748
|
-
* Watches workflow transitions in real-time
|
|
746
|
+
* Watches legacy workflow transitions in real-time
|
|
749
747
|
* @param runId - Optional run ID to filter the watch stream
|
|
750
|
-
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
748
|
+
* @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
|
|
751
749
|
*/
|
|
752
750
|
async watch({ runId }, onRecord) {
|
|
753
|
-
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}`, {
|
|
754
752
|
stream: true
|
|
755
753
|
});
|
|
756
754
|
if (!response.ok) {
|
|
757
|
-
throw new Error(`Failed to watch workflow: ${response.statusText}`);
|
|
755
|
+
throw new Error(`Failed to watch legacy workflow: ${response.statusText}`);
|
|
758
756
|
}
|
|
759
757
|
if (!response.body) {
|
|
760
758
|
throw new Error("Response body is null");
|
|
@@ -790,7 +788,7 @@ var Tool = class extends BaseResource {
|
|
|
790
788
|
}
|
|
791
789
|
const body = {
|
|
792
790
|
data: params.data,
|
|
793
|
-
runtimeContext:
|
|
791
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext)
|
|
794
792
|
};
|
|
795
793
|
return this.request(`/api/tools/${this.toolId}/execute?${url.toString()}`, {
|
|
796
794
|
method: "POST",
|
|
@@ -799,15 +797,15 @@ var Tool = class extends BaseResource {
|
|
|
799
797
|
}
|
|
800
798
|
};
|
|
801
799
|
|
|
802
|
-
// src/resources/
|
|
800
|
+
// src/resources/workflow.ts
|
|
803
801
|
var RECORD_SEPARATOR2 = "";
|
|
804
|
-
var
|
|
802
|
+
var Workflow = class extends BaseResource {
|
|
805
803
|
constructor(options, workflowId) {
|
|
806
804
|
super(options);
|
|
807
805
|
this.workflowId = workflowId;
|
|
808
806
|
}
|
|
809
807
|
/**
|
|
810
|
-
* Creates an async generator that processes a readable stream and yields
|
|
808
|
+
* Creates an async generator that processes a readable stream and yields workflow records
|
|
811
809
|
* separated by the Record Separator character (\x1E)
|
|
812
810
|
*
|
|
813
811
|
* @param stream - The readable stream to process
|
|
@@ -852,16 +850,16 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
852
850
|
}
|
|
853
851
|
}
|
|
854
852
|
/**
|
|
855
|
-
* Retrieves details about the
|
|
856
|
-
* @returns Promise containing
|
|
853
|
+
* Retrieves details about the workflow
|
|
854
|
+
* @returns Promise containing workflow details including steps and graphs
|
|
857
855
|
*/
|
|
858
856
|
details() {
|
|
859
|
-
return this.request(`/api/workflows
|
|
857
|
+
return this.request(`/api/workflows/${this.workflowId}`);
|
|
860
858
|
}
|
|
861
859
|
/**
|
|
862
|
-
* Retrieves all runs for a
|
|
860
|
+
* Retrieves all runs for a workflow
|
|
863
861
|
* @param params - Parameters for filtering runs
|
|
864
|
-
* @returns Promise containing
|
|
862
|
+
* @returns Promise containing workflow runs array
|
|
865
863
|
*/
|
|
866
864
|
runs(params) {
|
|
867
865
|
const searchParams = new URLSearchParams();
|
|
@@ -881,13 +879,13 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
881
879
|
searchParams.set("resourceId", params.resourceId);
|
|
882
880
|
}
|
|
883
881
|
if (searchParams.size) {
|
|
884
|
-
return this.request(`/api/workflows
|
|
882
|
+
return this.request(`/api/workflows/${this.workflowId}/runs?${searchParams}`);
|
|
885
883
|
} else {
|
|
886
|
-
return this.request(`/api/workflows
|
|
884
|
+
return this.request(`/api/workflows/${this.workflowId}/runs`);
|
|
887
885
|
}
|
|
888
886
|
}
|
|
889
887
|
/**
|
|
890
|
-
* Creates a new
|
|
888
|
+
* Creates a new workflow run
|
|
891
889
|
* @param params - Optional object containing the optional runId
|
|
892
890
|
* @returns Promise containing the runId of the created run
|
|
893
891
|
*/
|
|
@@ -896,24 +894,24 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
896
894
|
if (!!params?.runId) {
|
|
897
895
|
searchParams.set("runId", params.runId);
|
|
898
896
|
}
|
|
899
|
-
return this.request(`/api/workflows
|
|
897
|
+
return this.request(`/api/workflows/${this.workflowId}/create-run?${searchParams.toString()}`, {
|
|
900
898
|
method: "POST"
|
|
901
899
|
});
|
|
902
900
|
}
|
|
903
901
|
/**
|
|
904
|
-
* Starts a
|
|
902
|
+
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
905
903
|
* @param params - Object containing the runId, inputData and runtimeContext
|
|
906
904
|
* @returns Promise containing success message
|
|
907
905
|
*/
|
|
908
906
|
start(params) {
|
|
909
|
-
const runtimeContext =
|
|
910
|
-
return this.request(`/api/workflows
|
|
907
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
908
|
+
return this.request(`/api/workflows/${this.workflowId}/start?runId=${params.runId}`, {
|
|
911
909
|
method: "POST",
|
|
912
910
|
body: { inputData: params?.inputData, runtimeContext }
|
|
913
911
|
});
|
|
914
912
|
}
|
|
915
913
|
/**
|
|
916
|
-
* Resumes a suspended
|
|
914
|
+
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
917
915
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
918
916
|
* @returns Promise containing success message
|
|
919
917
|
*/
|
|
@@ -923,8 +921,8 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
923
921
|
resumeData,
|
|
924
922
|
...rest
|
|
925
923
|
}) {
|
|
926
|
-
const runtimeContext =
|
|
927
|
-
return this.request(`/api/workflows
|
|
924
|
+
const runtimeContext = parseClientRuntimeContext(rest.runtimeContext);
|
|
925
|
+
return this.request(`/api/workflows/${this.workflowId}/resume?runId=${runId}`, {
|
|
928
926
|
method: "POST",
|
|
929
927
|
stream: true,
|
|
930
928
|
body: {
|
|
@@ -935,29 +933,29 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
935
933
|
});
|
|
936
934
|
}
|
|
937
935
|
/**
|
|
938
|
-
* Starts a
|
|
936
|
+
* Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
|
|
939
937
|
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
940
|
-
* @returns Promise containing the
|
|
938
|
+
* @returns Promise containing the workflow execution results
|
|
941
939
|
*/
|
|
942
940
|
startAsync(params) {
|
|
943
941
|
const searchParams = new URLSearchParams();
|
|
944
942
|
if (!!params?.runId) {
|
|
945
943
|
searchParams.set("runId", params.runId);
|
|
946
944
|
}
|
|
947
|
-
const runtimeContext =
|
|
948
|
-
return this.request(`/api/workflows
|
|
945
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
946
|
+
return this.request(`/api/workflows/${this.workflowId}/start-async?${searchParams.toString()}`, {
|
|
949
947
|
method: "POST",
|
|
950
948
|
body: { inputData: params.inputData, runtimeContext }
|
|
951
949
|
});
|
|
952
950
|
}
|
|
953
951
|
/**
|
|
954
|
-
* Resumes a suspended
|
|
952
|
+
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
955
953
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
956
|
-
* @returns Promise containing the
|
|
954
|
+
* @returns Promise containing the workflow resume results
|
|
957
955
|
*/
|
|
958
956
|
resumeAsync(params) {
|
|
959
|
-
const runtimeContext =
|
|
960
|
-
return this.request(`/api/workflows
|
|
957
|
+
const runtimeContext = parseClientRuntimeContext(params.runtimeContext);
|
|
958
|
+
return this.request(`/api/workflows/${this.workflowId}/resume-async?runId=${params.runId}`, {
|
|
961
959
|
method: "POST",
|
|
962
960
|
body: {
|
|
963
961
|
step: params.step,
|
|
@@ -967,16 +965,16 @@ var VNextWorkflow = class extends BaseResource {
|
|
|
967
965
|
});
|
|
968
966
|
}
|
|
969
967
|
/**
|
|
970
|
-
* Watches
|
|
968
|
+
* Watches workflow transitions in real-time
|
|
971
969
|
* @param runId - Optional run ID to filter the watch stream
|
|
972
|
-
* @returns AsyncGenerator that yields parsed records from the
|
|
970
|
+
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
973
971
|
*/
|
|
974
972
|
async watch({ runId }, onRecord) {
|
|
975
|
-
const response = await this.request(`/api/workflows
|
|
973
|
+
const response = await this.request(`/api/workflows/${this.workflowId}/watch?runId=${runId}`, {
|
|
976
974
|
stream: true
|
|
977
975
|
});
|
|
978
976
|
if (!response.ok) {
|
|
979
|
-
throw new Error(`Failed to watch
|
|
977
|
+
throw new Error(`Failed to watch workflow: ${response.statusText}`);
|
|
980
978
|
}
|
|
981
979
|
if (!response.body) {
|
|
982
980
|
throw new Error("Response body is null");
|
|
@@ -1187,6 +1185,21 @@ var MastraClient = class extends BaseResource {
|
|
|
1187
1185
|
getTool(toolId) {
|
|
1188
1186
|
return new Tool(this.options, toolId);
|
|
1189
1187
|
}
|
|
1188
|
+
/**
|
|
1189
|
+
* Retrieves all available legacy workflows
|
|
1190
|
+
* @returns Promise containing map of legacy workflow IDs to legacy workflow details
|
|
1191
|
+
*/
|
|
1192
|
+
getLegacyWorkflows() {
|
|
1193
|
+
return this.request("/api/workflows/legacy");
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Gets a legacy workflow instance by ID
|
|
1197
|
+
* @param workflowId - ID of the legacy workflow to retrieve
|
|
1198
|
+
* @returns Legacy Workflow instance
|
|
1199
|
+
*/
|
|
1200
|
+
getLegacyWorkflow(workflowId) {
|
|
1201
|
+
return new LegacyWorkflow(this.options, workflowId);
|
|
1202
|
+
}
|
|
1190
1203
|
/**
|
|
1191
1204
|
* Retrieves all available workflows
|
|
1192
1205
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
@@ -1202,21 +1215,6 @@ var MastraClient = class extends BaseResource {
|
|
|
1202
1215
|
getWorkflow(workflowId) {
|
|
1203
1216
|
return new Workflow(this.options, workflowId);
|
|
1204
1217
|
}
|
|
1205
|
-
/**
|
|
1206
|
-
* Retrieves all available vNext workflows
|
|
1207
|
-
* @returns Promise containing map of vNext workflow IDs to vNext workflow details
|
|
1208
|
-
*/
|
|
1209
|
-
getVNextWorkflows() {
|
|
1210
|
-
return this.request("/api/workflows/v-next");
|
|
1211
|
-
}
|
|
1212
|
-
/**
|
|
1213
|
-
* Gets a vNext workflow instance by ID
|
|
1214
|
-
* @param workflowId - ID of the vNext workflow to retrieve
|
|
1215
|
-
* @returns vNext Workflow instance
|
|
1216
|
-
*/
|
|
1217
|
-
getVNextWorkflow(workflowId) {
|
|
1218
|
-
return new VNextWorkflow(this.options, workflowId);
|
|
1219
|
-
}
|
|
1220
1218
|
/**
|
|
1221
1219
|
* Gets a vector instance by name
|
|
1222
1220
|
* @param vectorName - Name of the vector to retrieve
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/client-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
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.9.5-alpha.0"
|
|
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.
|
|
45
|
+
"@internal/lint": "0.0.6",
|
|
46
|
+
"@mastra/core": "0.10.0"
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|
|
48
49
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean --treeshake=smallest --splitting",
|
package/src/client.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { AbstractAgent } from '@ag-ui/client';
|
|
2
|
+
import type { ServerDetailInfo } from '@mastra/core/mcp';
|
|
2
3
|
import { AGUIAdapter } from './adapters/agui';
|
|
3
4
|
import {
|
|
4
5
|
Agent,
|
|
@@ -8,9 +9,9 @@ import {
|
|
|
8
9
|
Vector,
|
|
9
10
|
BaseResource,
|
|
10
11
|
Network,
|
|
11
|
-
VNextWorkflow,
|
|
12
12
|
A2A,
|
|
13
13
|
MCPTool,
|
|
14
|
+
LegacyWorkflow,
|
|
14
15
|
} from './resources';
|
|
15
16
|
import type {
|
|
16
17
|
ClientOptions,
|
|
@@ -26,15 +27,13 @@ import type {
|
|
|
26
27
|
GetTelemetryParams,
|
|
27
28
|
GetTelemetryResponse,
|
|
28
29
|
GetToolResponse,
|
|
29
|
-
GetVNextWorkflowResponse,
|
|
30
30
|
GetWorkflowResponse,
|
|
31
31
|
SaveMessageToMemoryParams,
|
|
32
32
|
SaveMessageToMemoryResponse,
|
|
33
33
|
McpServerListResponse,
|
|
34
34
|
McpServerToolListResponse,
|
|
35
|
-
|
|
35
|
+
GetLegacyWorkflowResponse,
|
|
36
36
|
} from './types';
|
|
37
|
-
import type { ServerDetailInfo } from '@mastra/core/mcp';
|
|
38
37
|
|
|
39
38
|
export class MastraClient extends BaseResource {
|
|
40
39
|
constructor(options: ClientOptions) {
|
|
@@ -141,6 +140,23 @@ export class MastraClient extends BaseResource {
|
|
|
141
140
|
return new Tool(this.options, toolId);
|
|
142
141
|
}
|
|
143
142
|
|
|
143
|
+
/**
|
|
144
|
+
* Retrieves all available legacy workflows
|
|
145
|
+
* @returns Promise containing map of legacy workflow IDs to legacy workflow details
|
|
146
|
+
*/
|
|
147
|
+
public getLegacyWorkflows(): Promise<Record<string, GetLegacyWorkflowResponse>> {
|
|
148
|
+
return this.request('/api/workflows/legacy');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Gets a legacy workflow instance by ID
|
|
153
|
+
* @param workflowId - ID of the legacy workflow to retrieve
|
|
154
|
+
* @returns Legacy Workflow instance
|
|
155
|
+
*/
|
|
156
|
+
public getLegacyWorkflow(workflowId: string) {
|
|
157
|
+
return new LegacyWorkflow(this.options, workflowId);
|
|
158
|
+
}
|
|
159
|
+
|
|
144
160
|
/**
|
|
145
161
|
* Retrieves all available workflows
|
|
146
162
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
@@ -158,23 +174,6 @@ export class MastraClient extends BaseResource {
|
|
|
158
174
|
return new Workflow(this.options, workflowId);
|
|
159
175
|
}
|
|
160
176
|
|
|
161
|
-
/**
|
|
162
|
-
* Retrieves all available vNext workflows
|
|
163
|
-
* @returns Promise containing map of vNext workflow IDs to vNext workflow details
|
|
164
|
-
*/
|
|
165
|
-
public getVNextWorkflows(): Promise<Record<string, GetVNextWorkflowResponse>> {
|
|
166
|
-
return this.request('/api/workflows/v-next');
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Gets a vNext workflow instance by ID
|
|
171
|
-
* @param workflowId - ID of the vNext workflow to retrieve
|
|
172
|
-
* @returns vNext Workflow instance
|
|
173
|
-
*/
|
|
174
|
-
public getVNextWorkflow(workflowId: string) {
|
|
175
|
-
return new VNextWorkflow(this.options, workflowId);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
177
|
/**
|
|
179
178
|
* Gets a vector instance by name
|
|
180
179
|
* @param vectorName - Name of the vector to retrieve
|
package/src/resources/agent.ts
CHANGED
|
@@ -14,7 +14,8 @@ import type {
|
|
|
14
14
|
} from '../types';
|
|
15
15
|
|
|
16
16
|
import { BaseResource } from './base';
|
|
17
|
-
import type { RuntimeContext } from '@mastra/core/
|
|
17
|
+
import type { RuntimeContext } from '@mastra/core/runtime-context';
|
|
18
|
+
import { parseClientRuntimeContext } from '../utils';
|
|
18
19
|
|
|
19
20
|
export class AgentVoice extends BaseResource {
|
|
20
21
|
constructor(
|
|
@@ -102,7 +103,7 @@ export class Agent extends BaseResource {
|
|
|
102
103
|
...params,
|
|
103
104
|
output: params.output ? zodToJsonSchema(params.output) : undefined,
|
|
104
105
|
experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : undefined,
|
|
105
|
-
runtimeContext:
|
|
106
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
106
107
|
};
|
|
107
108
|
|
|
108
109
|
return this.request(`/api/agents/${this.agentId}/generate`, {
|
|
@@ -127,7 +128,7 @@ export class Agent extends BaseResource {
|
|
|
127
128
|
...params,
|
|
128
129
|
output: params.output ? zodToJsonSchema(params.output) : undefined,
|
|
129
130
|
experimental_output: params.experimental_output ? zodToJsonSchema(params.experimental_output) : undefined,
|
|
130
|
-
runtimeContext:
|
|
131
|
+
runtimeContext: parseClientRuntimeContext(params.runtimeContext),
|
|
131
132
|
};
|
|
132
133
|
|
|
133
134
|
const response: Response & {
|
package/src/resources/index.ts
CHANGED
|
@@ -2,9 +2,9 @@ export * from './agent';
|
|
|
2
2
|
export * from './network';
|
|
3
3
|
export * from './memory-thread';
|
|
4
4
|
export * from './vector';
|
|
5
|
-
export * from './workflow';
|
|
5
|
+
export * from './legacy-workflow';
|
|
6
6
|
export * from './tool';
|
|
7
7
|
export * from './base';
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './workflow';
|
|
9
9
|
export * from './a2a';
|
|
10
10
|
export * from './mcp-tool';
|