@mindstudio-ai/agent 0.1.4 → 0.1.6
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/README.md +46 -0
- package/dist/cli.js +756 -288
- package/dist/index.d.ts +240 -214
- package/dist/index.js +225 -56
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +757 -289
- package/llms.txt +47 -16
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -610,58 +610,6 @@ function applyStepMethods(AgentClass) {
|
|
|
610
610
|
};
|
|
611
611
|
}
|
|
612
612
|
|
|
613
|
-
// src/generated/helpers.ts
|
|
614
|
-
function applyHelperMethods(AgentClass) {
|
|
615
|
-
const proto = AgentClass.prototype;
|
|
616
|
-
proto.listModels = function() {
|
|
617
|
-
return this._request("GET", "/helpers/models").then((r) => r.data);
|
|
618
|
-
};
|
|
619
|
-
proto.listModelsByType = function(modelType) {
|
|
620
|
-
return this._request("GET", `/helpers/models/${modelType}`).then((r) => r.data);
|
|
621
|
-
};
|
|
622
|
-
proto.listModelsSummary = function() {
|
|
623
|
-
return this._request("GET", "/helpers/models-summary").then((r) => r.data);
|
|
624
|
-
};
|
|
625
|
-
proto.listModelsSummaryByType = function(modelType) {
|
|
626
|
-
return this._request("GET", `/helpers/models-summary/${modelType}`).then((r) => r.data);
|
|
627
|
-
};
|
|
628
|
-
proto.listConnectors = function() {
|
|
629
|
-
return this._request("GET", "/helpers/connectors").then((r) => r.data);
|
|
630
|
-
};
|
|
631
|
-
proto.getConnector = function(serviceId) {
|
|
632
|
-
return this._request("GET", `/helpers/connectors/${serviceId}`).then((r) => r.data);
|
|
633
|
-
};
|
|
634
|
-
proto.getConnectorAction = function(serviceId, actionId) {
|
|
635
|
-
return this._request("GET", `/helpers/connectors/${serviceId}/${actionId}`).then((r) => r.data);
|
|
636
|
-
};
|
|
637
|
-
proto.listConnections = function() {
|
|
638
|
-
return this._request("GET", "/helpers/connections").then((r) => r.data);
|
|
639
|
-
};
|
|
640
|
-
proto.estimateStepCost = function(stepType, step, options) {
|
|
641
|
-
return this._request("POST", "/helpers/step-cost-estimate", { step: { type: stepType, ...step }, ...options }).then((r) => r.data);
|
|
642
|
-
};
|
|
643
|
-
proto.changeName = function(displayName) {
|
|
644
|
-
return this._request("POST", "/account/change-name", { displayName }).then(() => {
|
|
645
|
-
});
|
|
646
|
-
};
|
|
647
|
-
proto.changeProfilePicture = function(profilePictureUrl) {
|
|
648
|
-
return this._request("POST", "/account/change-profile-picture", { profilePictureUrl }).then(() => {
|
|
649
|
-
});
|
|
650
|
-
};
|
|
651
|
-
proto.uploadFile = async function(content, options) {
|
|
652
|
-
const { data } = await this._request("POST", "/account/upload", { extension: options.extension, ...options.type != null && { type: options.type } });
|
|
653
|
-
const { uploadUrl, url } = data;
|
|
654
|
-
const buf = content.buffer.slice(content.byteOffset, content.byteOffset + content.byteLength);
|
|
655
|
-
const res = await fetch(uploadUrl, {
|
|
656
|
-
method: "PUT",
|
|
657
|
-
body: buf,
|
|
658
|
-
headers: options.type ? { "Content-Type": options.type } : {}
|
|
659
|
-
});
|
|
660
|
-
if (!res.ok) throw new Error(`Upload failed: ${res.status} ${res.statusText}`);
|
|
661
|
-
return { url };
|
|
662
|
-
};
|
|
663
|
-
}
|
|
664
|
-
|
|
665
613
|
// src/client.ts
|
|
666
614
|
var DEFAULT_BASE_URL = "https://v1.mindstudio-api.com";
|
|
667
615
|
var DEFAULT_MAX_RETRIES = 3;
|
|
@@ -733,6 +681,85 @@ var MindStudioAgent = class {
|
|
|
733
681
|
$billingEvents: billingEvents != null ? JSON.parse(billingEvents) : void 0
|
|
734
682
|
};
|
|
735
683
|
}
|
|
684
|
+
/**
|
|
685
|
+
* Execute multiple steps in parallel in a single request.
|
|
686
|
+
*
|
|
687
|
+
* All steps run in parallel on the server. Results are returned in the same
|
|
688
|
+
* order as the input. Individual step failures do not affect other steps —
|
|
689
|
+
* partial success is possible.
|
|
690
|
+
*
|
|
691
|
+
* ```ts
|
|
692
|
+
* const { results } = await agent.executeStepBatch([
|
|
693
|
+
* { stepType: 'generateImage', step: { prompt: 'a sunset' } },
|
|
694
|
+
* { stepType: 'textToSpeech', step: { text: 'Hello world' } },
|
|
695
|
+
* ]);
|
|
696
|
+
* ```
|
|
697
|
+
*/
|
|
698
|
+
async executeStepBatch(steps, options) {
|
|
699
|
+
const threadId = options?.threadId ?? (this._reuseThreadId ? this._threadId : void 0);
|
|
700
|
+
const { data } = await request(this._httpConfig, "POST", "/steps/execute-batch", {
|
|
701
|
+
steps,
|
|
702
|
+
...options?.appId != null && { appId: options.appId },
|
|
703
|
+
...threadId != null && { threadId }
|
|
704
|
+
});
|
|
705
|
+
const results = await Promise.all(
|
|
706
|
+
data.results.map(async (r) => {
|
|
707
|
+
if (r.output != null) {
|
|
708
|
+
return {
|
|
709
|
+
stepType: r.stepType,
|
|
710
|
+
output: r.output,
|
|
711
|
+
billingCost: r.billingCost,
|
|
712
|
+
error: r.error
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
if (r.outputUrl) {
|
|
716
|
+
const res = await fetch(r.outputUrl);
|
|
717
|
+
if (!res.ok) {
|
|
718
|
+
return {
|
|
719
|
+
stepType: r.stepType,
|
|
720
|
+
error: `Failed to fetch output from S3: ${res.status} ${res.statusText}`
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
const envelope = await res.json();
|
|
724
|
+
return {
|
|
725
|
+
stepType: r.stepType,
|
|
726
|
+
output: envelope.value,
|
|
727
|
+
billingCost: r.billingCost
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
return {
|
|
731
|
+
stepType: r.stepType,
|
|
732
|
+
billingCost: r.billingCost,
|
|
733
|
+
error: r.error
|
|
734
|
+
};
|
|
735
|
+
})
|
|
736
|
+
);
|
|
737
|
+
if (this._reuseThreadId && data.threadId) {
|
|
738
|
+
this._threadId = data.threadId;
|
|
739
|
+
}
|
|
740
|
+
return {
|
|
741
|
+
results,
|
|
742
|
+
totalBillingCost: data.totalBillingCost,
|
|
743
|
+
appId: data.appId,
|
|
744
|
+
threadId: data.threadId
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* Get the authenticated user's identity and organization info.
|
|
749
|
+
*
|
|
750
|
+
* ```ts
|
|
751
|
+
* const info = await agent.getUserInfo();
|
|
752
|
+
* console.log(info.displayName, info.organizationName);
|
|
753
|
+
* ```
|
|
754
|
+
*/
|
|
755
|
+
async getUserInfo() {
|
|
756
|
+
const { data } = await request(
|
|
757
|
+
this._httpConfig,
|
|
758
|
+
"GET",
|
|
759
|
+
"/account/userinfo"
|
|
760
|
+
);
|
|
761
|
+
return data;
|
|
762
|
+
}
|
|
736
763
|
/**
|
|
737
764
|
* List all pre-built agents in the organization.
|
|
738
765
|
*
|
|
@@ -809,16 +836,158 @@ var MindStudioAgent = class {
|
|
|
809
836
|
return poll.result;
|
|
810
837
|
}
|
|
811
838
|
}
|
|
812
|
-
/** @internal Used by generated
|
|
839
|
+
/** @internal Used by generated action methods. */
|
|
813
840
|
_request(method, path, body) {
|
|
814
841
|
return request(this._httpConfig, method, path, body);
|
|
815
842
|
}
|
|
843
|
+
// -------------------------------------------------------------------------
|
|
844
|
+
// Helper methods — models
|
|
845
|
+
// -------------------------------------------------------------------------
|
|
846
|
+
/** List all available AI models. */
|
|
847
|
+
async listModels() {
|
|
848
|
+
const { data } = await request(
|
|
849
|
+
this._httpConfig,
|
|
850
|
+
"GET",
|
|
851
|
+
"/helpers/models"
|
|
852
|
+
);
|
|
853
|
+
return data;
|
|
854
|
+
}
|
|
855
|
+
/** List AI models filtered by type. */
|
|
856
|
+
async listModelsByType(modelType) {
|
|
857
|
+
const { data } = await request(
|
|
858
|
+
this._httpConfig,
|
|
859
|
+
"GET",
|
|
860
|
+
`/helpers/models/${modelType}`
|
|
861
|
+
);
|
|
862
|
+
return data;
|
|
863
|
+
}
|
|
864
|
+
/** List all available AI models (summary). Returns only id, name, type, and tags. */
|
|
865
|
+
async listModelsSummary() {
|
|
866
|
+
const { data } = await request(
|
|
867
|
+
this._httpConfig,
|
|
868
|
+
"GET",
|
|
869
|
+
"/helpers/models-summary"
|
|
870
|
+
);
|
|
871
|
+
return data;
|
|
872
|
+
}
|
|
873
|
+
/** List AI models (summary) filtered by type. */
|
|
874
|
+
async listModelsSummaryByType(modelType) {
|
|
875
|
+
const { data } = await request(
|
|
876
|
+
this._httpConfig,
|
|
877
|
+
"GET",
|
|
878
|
+
`/helpers/models-summary/${modelType}`
|
|
879
|
+
);
|
|
880
|
+
return data;
|
|
881
|
+
}
|
|
882
|
+
// -------------------------------------------------------------------------
|
|
883
|
+
// Helper methods — OAuth connectors & connections
|
|
884
|
+
// -------------------------------------------------------------------------
|
|
885
|
+
/**
|
|
886
|
+
* List available OAuth connector services (Slack, Google, HubSpot, etc.).
|
|
887
|
+
*
|
|
888
|
+
* These are third-party integrations from the MindStudio Connector Registry.
|
|
889
|
+
* For most tasks, use actions directly instead.
|
|
890
|
+
*/
|
|
891
|
+
async listConnectors() {
|
|
892
|
+
const { data } = await request(
|
|
893
|
+
this._httpConfig,
|
|
894
|
+
"GET",
|
|
895
|
+
"/helpers/connectors"
|
|
896
|
+
);
|
|
897
|
+
return data;
|
|
898
|
+
}
|
|
899
|
+
/** Get details for a single OAuth connector service. */
|
|
900
|
+
async getConnector(serviceId) {
|
|
901
|
+
const { data } = await request(
|
|
902
|
+
this._httpConfig,
|
|
903
|
+
"GET",
|
|
904
|
+
`/helpers/connectors/${serviceId}`
|
|
905
|
+
);
|
|
906
|
+
return data;
|
|
907
|
+
}
|
|
908
|
+
/** Get the full configuration for an OAuth connector action, including input fields. */
|
|
909
|
+
async getConnectorAction(serviceId, actionId) {
|
|
910
|
+
const { data } = await request(
|
|
911
|
+
this._httpConfig,
|
|
912
|
+
"GET",
|
|
913
|
+
`/helpers/connectors/${serviceId}/${actionId}`
|
|
914
|
+
);
|
|
915
|
+
return data;
|
|
916
|
+
}
|
|
917
|
+
/** List OAuth connections for the organization. These are authenticated third-party service links. */
|
|
918
|
+
async listConnections() {
|
|
919
|
+
const { data } = await request(
|
|
920
|
+
this._httpConfig,
|
|
921
|
+
"GET",
|
|
922
|
+
"/helpers/connections"
|
|
923
|
+
);
|
|
924
|
+
return data;
|
|
925
|
+
}
|
|
926
|
+
// -------------------------------------------------------------------------
|
|
927
|
+
// Helper methods — cost estimation
|
|
928
|
+
// -------------------------------------------------------------------------
|
|
929
|
+
/** Estimate the cost of executing an action before running it. */
|
|
930
|
+
async estimateStepCost(stepType, step, options) {
|
|
931
|
+
const { data } = await request(this._httpConfig, "POST", "/helpers/step-cost-estimate", {
|
|
932
|
+
step: { type: stepType, ...step },
|
|
933
|
+
...options
|
|
934
|
+
});
|
|
935
|
+
return data;
|
|
936
|
+
}
|
|
937
|
+
// -------------------------------------------------------------------------
|
|
938
|
+
// Account methods
|
|
939
|
+
// -------------------------------------------------------------------------
|
|
940
|
+
/** Update the display name of the authenticated user/agent. */
|
|
941
|
+
async changeName(displayName) {
|
|
942
|
+
await request(this._httpConfig, "POST", "/account/change-name", {
|
|
943
|
+
name: displayName
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
/** Update the profile picture of the authenticated user/agent. */
|
|
947
|
+
async changeProfilePicture(url) {
|
|
948
|
+
await request(this._httpConfig, "POST", "/account/change-profile-picture", {
|
|
949
|
+
url
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* Upload a file to the MindStudio CDN.
|
|
954
|
+
*
|
|
955
|
+
* Gets a signed upload URL, PUTs the file content, and returns the
|
|
956
|
+
* permanent public URL.
|
|
957
|
+
*/
|
|
958
|
+
async uploadFile(content, options) {
|
|
959
|
+
const { data } = await request(
|
|
960
|
+
this._httpConfig,
|
|
961
|
+
"POST",
|
|
962
|
+
"/account/upload",
|
|
963
|
+
{
|
|
964
|
+
extension: options.extension,
|
|
965
|
+
...options.type != null && { type: options.type }
|
|
966
|
+
}
|
|
967
|
+
);
|
|
968
|
+
const buf = content.buffer.slice(
|
|
969
|
+
content.byteOffset,
|
|
970
|
+
content.byteOffset + content.byteLength
|
|
971
|
+
);
|
|
972
|
+
const res = await fetch(data.uploadUrl, {
|
|
973
|
+
method: "PUT",
|
|
974
|
+
body: buf,
|
|
975
|
+
headers: options.type ? { "Content-Type": options.type } : {}
|
|
976
|
+
});
|
|
977
|
+
if (!res.ok) {
|
|
978
|
+
throw new MindStudioError(
|
|
979
|
+
`Upload failed: ${res.status} ${res.statusText}`,
|
|
980
|
+
"upload_error",
|
|
981
|
+
res.status
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
return { url: data.url };
|
|
985
|
+
}
|
|
816
986
|
};
|
|
817
987
|
function sleep2(ms) {
|
|
818
988
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
819
989
|
}
|
|
820
990
|
applyStepMethods(MindStudioAgent);
|
|
821
|
-
applyHelperMethods(MindStudioAgent);
|
|
822
991
|
function resolveToken(provided, config) {
|
|
823
992
|
if (provided) return { token: provided, authType: "apiKey" };
|
|
824
993
|
if (process.env.MINDSTUDIO_API_KEY)
|
|
@@ -1665,8 +1834,8 @@ var stepMetadata = {
|
|
|
1665
1834
|
"postToX": {
|
|
1666
1835
|
stepType: "postToX",
|
|
1667
1836
|
description: "Create a post on X (Twitter) from the connected account.",
|
|
1668
|
-
usageNotes: "- Requires an X OAuth connection (connectionId).\n-
|
|
1669
|
-
inputSchema: { "type": "object", "properties": { "text": { "type": "string", "description": "The text content of the post (max 280 characters)" }, "connectionId": { "type": "string", "description": "X (Twitter) OAuth connection ID" } }, "required": ["text"] },
|
|
1837
|
+
usageNotes: "- Requires an X OAuth connection (connectionId).\n- Maximum 280 characters of text.\n- Optionally attach up to 4 media items (images, GIFs, or videos) via mediaUrls.\n- Media URLs must be publicly accessible. The service fetches and uploads them to X.\n- Supported formats: JPEG, PNG, GIF, WEBP, MP4. Images up to 5MB, videos up to 512MB.",
|
|
1838
|
+
inputSchema: { "type": "object", "properties": { "text": { "type": "string", "description": "The text content of the post (max 280 characters)" }, "connectionId": { "type": "string", "description": "X (Twitter) OAuth connection ID" }, "mediaUrls": { "type": "array", "items": { "type": "string" }, "description": "Up to 4 URLs of images, GIFs, or videos to attach to the post" } }, "required": ["text"] },
|
|
1670
1839
|
outputSchema: { "description": "This step does not produce output data." }
|
|
1671
1840
|
},
|
|
1672
1841
|
"postToZapier": {
|