@mindstudio-ai/agent 0.1.3 → 0.1.5
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/dist/cli.js +443 -284
- package/dist/index.d.ts +183 -213
- package/dist/index.js +160 -54
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +444 -285
- package/llms.txt +15 -15
- 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,22 @@ var MindStudioAgent = class {
|
|
|
733
681
|
$billingEvents: billingEvents != null ? JSON.parse(billingEvents) : void 0
|
|
734
682
|
};
|
|
735
683
|
}
|
|
684
|
+
/**
|
|
685
|
+
* Get the authenticated user's identity and organization info.
|
|
686
|
+
*
|
|
687
|
+
* ```ts
|
|
688
|
+
* const info = await agent.getUserInfo();
|
|
689
|
+
* console.log(info.displayName, info.organizationName);
|
|
690
|
+
* ```
|
|
691
|
+
*/
|
|
692
|
+
async getUserInfo() {
|
|
693
|
+
const { data } = await request(
|
|
694
|
+
this._httpConfig,
|
|
695
|
+
"GET",
|
|
696
|
+
"/account/userinfo"
|
|
697
|
+
);
|
|
698
|
+
return data;
|
|
699
|
+
}
|
|
736
700
|
/**
|
|
737
701
|
* List all pre-built agents in the organization.
|
|
738
702
|
*
|
|
@@ -809,16 +773,158 @@ var MindStudioAgent = class {
|
|
|
809
773
|
return poll.result;
|
|
810
774
|
}
|
|
811
775
|
}
|
|
812
|
-
/** @internal Used by generated
|
|
776
|
+
/** @internal Used by generated action methods. */
|
|
813
777
|
_request(method, path, body) {
|
|
814
778
|
return request(this._httpConfig, method, path, body);
|
|
815
779
|
}
|
|
780
|
+
// -------------------------------------------------------------------------
|
|
781
|
+
// Helper methods — models
|
|
782
|
+
// -------------------------------------------------------------------------
|
|
783
|
+
/** List all available AI models. */
|
|
784
|
+
async listModels() {
|
|
785
|
+
const { data } = await request(
|
|
786
|
+
this._httpConfig,
|
|
787
|
+
"GET",
|
|
788
|
+
"/helpers/models"
|
|
789
|
+
);
|
|
790
|
+
return data;
|
|
791
|
+
}
|
|
792
|
+
/** List AI models filtered by type. */
|
|
793
|
+
async listModelsByType(modelType) {
|
|
794
|
+
const { data } = await request(
|
|
795
|
+
this._httpConfig,
|
|
796
|
+
"GET",
|
|
797
|
+
`/helpers/models/${modelType}`
|
|
798
|
+
);
|
|
799
|
+
return data;
|
|
800
|
+
}
|
|
801
|
+
/** List all available AI models (summary). Returns only id, name, type, and tags. */
|
|
802
|
+
async listModelsSummary() {
|
|
803
|
+
const { data } = await request(
|
|
804
|
+
this._httpConfig,
|
|
805
|
+
"GET",
|
|
806
|
+
"/helpers/models-summary"
|
|
807
|
+
);
|
|
808
|
+
return data;
|
|
809
|
+
}
|
|
810
|
+
/** List AI models (summary) filtered by type. */
|
|
811
|
+
async listModelsSummaryByType(modelType) {
|
|
812
|
+
const { data } = await request(
|
|
813
|
+
this._httpConfig,
|
|
814
|
+
"GET",
|
|
815
|
+
`/helpers/models-summary/${modelType}`
|
|
816
|
+
);
|
|
817
|
+
return data;
|
|
818
|
+
}
|
|
819
|
+
// -------------------------------------------------------------------------
|
|
820
|
+
// Helper methods — OAuth connectors & connections
|
|
821
|
+
// -------------------------------------------------------------------------
|
|
822
|
+
/**
|
|
823
|
+
* List available OAuth connector services (Slack, Google, HubSpot, etc.).
|
|
824
|
+
*
|
|
825
|
+
* These are third-party integrations from the MindStudio Connector Registry.
|
|
826
|
+
* For most tasks, use actions directly instead.
|
|
827
|
+
*/
|
|
828
|
+
async listConnectors() {
|
|
829
|
+
const { data } = await request(
|
|
830
|
+
this._httpConfig,
|
|
831
|
+
"GET",
|
|
832
|
+
"/helpers/connectors"
|
|
833
|
+
);
|
|
834
|
+
return data;
|
|
835
|
+
}
|
|
836
|
+
/** Get details for a single OAuth connector service. */
|
|
837
|
+
async getConnector(serviceId) {
|
|
838
|
+
const { data } = await request(
|
|
839
|
+
this._httpConfig,
|
|
840
|
+
"GET",
|
|
841
|
+
`/helpers/connectors/${serviceId}`
|
|
842
|
+
);
|
|
843
|
+
return data;
|
|
844
|
+
}
|
|
845
|
+
/** Get the full configuration for an OAuth connector action, including input fields. */
|
|
846
|
+
async getConnectorAction(serviceId, actionId) {
|
|
847
|
+
const { data } = await request(
|
|
848
|
+
this._httpConfig,
|
|
849
|
+
"GET",
|
|
850
|
+
`/helpers/connectors/${serviceId}/${actionId}`
|
|
851
|
+
);
|
|
852
|
+
return data;
|
|
853
|
+
}
|
|
854
|
+
/** List OAuth connections for the organization. These are authenticated third-party service links. */
|
|
855
|
+
async listConnections() {
|
|
856
|
+
const { data } = await request(
|
|
857
|
+
this._httpConfig,
|
|
858
|
+
"GET",
|
|
859
|
+
"/helpers/connections"
|
|
860
|
+
);
|
|
861
|
+
return data;
|
|
862
|
+
}
|
|
863
|
+
// -------------------------------------------------------------------------
|
|
864
|
+
// Helper methods — cost estimation
|
|
865
|
+
// -------------------------------------------------------------------------
|
|
866
|
+
/** Estimate the cost of executing an action before running it. */
|
|
867
|
+
async estimateStepCost(stepType, step, options) {
|
|
868
|
+
const { data } = await request(this._httpConfig, "POST", "/helpers/step-cost-estimate", {
|
|
869
|
+
step: { type: stepType, ...step },
|
|
870
|
+
...options
|
|
871
|
+
});
|
|
872
|
+
return data;
|
|
873
|
+
}
|
|
874
|
+
// -------------------------------------------------------------------------
|
|
875
|
+
// Account methods
|
|
876
|
+
// -------------------------------------------------------------------------
|
|
877
|
+
/** Update the display name of the authenticated user/agent. */
|
|
878
|
+
async changeName(displayName) {
|
|
879
|
+
await request(this._httpConfig, "POST", "/account/change-name", {
|
|
880
|
+
name: displayName
|
|
881
|
+
});
|
|
882
|
+
}
|
|
883
|
+
/** Update the profile picture of the authenticated user/agent. */
|
|
884
|
+
async changeProfilePicture(url) {
|
|
885
|
+
await request(this._httpConfig, "POST", "/account/change-profile-picture", {
|
|
886
|
+
url
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* Upload a file to the MindStudio CDN.
|
|
891
|
+
*
|
|
892
|
+
* Gets a signed upload URL, PUTs the file content, and returns the
|
|
893
|
+
* permanent public URL.
|
|
894
|
+
*/
|
|
895
|
+
async uploadFile(content, options) {
|
|
896
|
+
const { data } = await request(
|
|
897
|
+
this._httpConfig,
|
|
898
|
+
"POST",
|
|
899
|
+
"/account/upload",
|
|
900
|
+
{
|
|
901
|
+
extension: options.extension,
|
|
902
|
+
...options.type != null && { type: options.type }
|
|
903
|
+
}
|
|
904
|
+
);
|
|
905
|
+
const buf = content.buffer.slice(
|
|
906
|
+
content.byteOffset,
|
|
907
|
+
content.byteOffset + content.byteLength
|
|
908
|
+
);
|
|
909
|
+
const res = await fetch(data.uploadUrl, {
|
|
910
|
+
method: "PUT",
|
|
911
|
+
body: buf,
|
|
912
|
+
headers: options.type ? { "Content-Type": options.type } : {}
|
|
913
|
+
});
|
|
914
|
+
if (!res.ok) {
|
|
915
|
+
throw new MindStudioError(
|
|
916
|
+
`Upload failed: ${res.status} ${res.statusText}`,
|
|
917
|
+
"upload_error",
|
|
918
|
+
res.status
|
|
919
|
+
);
|
|
920
|
+
}
|
|
921
|
+
return { url: data.url };
|
|
922
|
+
}
|
|
816
923
|
};
|
|
817
924
|
function sleep2(ms) {
|
|
818
925
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
819
926
|
}
|
|
820
927
|
applyStepMethods(MindStudioAgent);
|
|
821
|
-
applyHelperMethods(MindStudioAgent);
|
|
822
928
|
function resolveToken(provided, config) {
|
|
823
929
|
if (provided) return { token: provided, authType: "apiKey" };
|
|
824
930
|
if (process.env.MINDSTUDIO_API_KEY)
|