@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/cli.js
CHANGED
|
@@ -682,8 +682,8 @@ var init_metadata = __esm({
|
|
|
682
682
|
"postToX": {
|
|
683
683
|
stepType: "postToX",
|
|
684
684
|
description: "Create a post on X (Twitter) from the connected account.",
|
|
685
|
-
usageNotes: "- Requires an X OAuth connection (connectionId).\n-
|
|
686
|
-
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"] },
|
|
685
|
+
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.",
|
|
686
|
+
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"] },
|
|
687
687
|
outputSchema: { "description": "This step does not produce output data." }
|
|
688
688
|
},
|
|
689
689
|
"postToZapier": {
|
|
@@ -1806,67 +1806,6 @@ var init_steps = __esm({
|
|
|
1806
1806
|
}
|
|
1807
1807
|
});
|
|
1808
1808
|
|
|
1809
|
-
// src/generated/helpers.ts
|
|
1810
|
-
var helpers_exports = {};
|
|
1811
|
-
__export(helpers_exports, {
|
|
1812
|
-
applyHelperMethods: () => applyHelperMethods
|
|
1813
|
-
});
|
|
1814
|
-
function applyHelperMethods(AgentClass) {
|
|
1815
|
-
const proto = AgentClass.prototype;
|
|
1816
|
-
proto.listModels = function() {
|
|
1817
|
-
return this._request("GET", "/helpers/models").then((r) => r.data);
|
|
1818
|
-
};
|
|
1819
|
-
proto.listModelsByType = function(modelType) {
|
|
1820
|
-
return this._request("GET", `/helpers/models/${modelType}`).then((r) => r.data);
|
|
1821
|
-
};
|
|
1822
|
-
proto.listModelsSummary = function() {
|
|
1823
|
-
return this._request("GET", "/helpers/models-summary").then((r) => r.data);
|
|
1824
|
-
};
|
|
1825
|
-
proto.listModelsSummaryByType = function(modelType) {
|
|
1826
|
-
return this._request("GET", `/helpers/models-summary/${modelType}`).then((r) => r.data);
|
|
1827
|
-
};
|
|
1828
|
-
proto.listConnectors = function() {
|
|
1829
|
-
return this._request("GET", "/helpers/connectors").then((r) => r.data);
|
|
1830
|
-
};
|
|
1831
|
-
proto.getConnector = function(serviceId) {
|
|
1832
|
-
return this._request("GET", `/helpers/connectors/${serviceId}`).then((r) => r.data);
|
|
1833
|
-
};
|
|
1834
|
-
proto.getConnectorAction = function(serviceId, actionId) {
|
|
1835
|
-
return this._request("GET", `/helpers/connectors/${serviceId}/${actionId}`).then((r) => r.data);
|
|
1836
|
-
};
|
|
1837
|
-
proto.listConnections = function() {
|
|
1838
|
-
return this._request("GET", "/helpers/connections").then((r) => r.data);
|
|
1839
|
-
};
|
|
1840
|
-
proto.estimateStepCost = function(stepType, step, options) {
|
|
1841
|
-
return this._request("POST", "/helpers/step-cost-estimate", { step: { type: stepType, ...step }, ...options }).then((r) => r.data);
|
|
1842
|
-
};
|
|
1843
|
-
proto.changeName = function(displayName) {
|
|
1844
|
-
return this._request("POST", "/account/change-name", { displayName }).then(() => {
|
|
1845
|
-
});
|
|
1846
|
-
};
|
|
1847
|
-
proto.changeProfilePicture = function(profilePictureUrl) {
|
|
1848
|
-
return this._request("POST", "/account/change-profile-picture", { profilePictureUrl }).then(() => {
|
|
1849
|
-
});
|
|
1850
|
-
};
|
|
1851
|
-
proto.uploadFile = async function(content, options) {
|
|
1852
|
-
const { data } = await this._request("POST", "/account/upload", { extension: options.extension, ...options.type != null && { type: options.type } });
|
|
1853
|
-
const { uploadUrl, url } = data;
|
|
1854
|
-
const buf = content.buffer.slice(content.byteOffset, content.byteOffset + content.byteLength);
|
|
1855
|
-
const res = await fetch(uploadUrl, {
|
|
1856
|
-
method: "PUT",
|
|
1857
|
-
body: buf,
|
|
1858
|
-
headers: options.type ? { "Content-Type": options.type } : {}
|
|
1859
|
-
});
|
|
1860
|
-
if (!res.ok) throw new Error(`Upload failed: ${res.status} ${res.statusText}`);
|
|
1861
|
-
return { url };
|
|
1862
|
-
};
|
|
1863
|
-
}
|
|
1864
|
-
var init_helpers = __esm({
|
|
1865
|
-
"src/generated/helpers.ts"() {
|
|
1866
|
-
"use strict";
|
|
1867
|
-
}
|
|
1868
|
-
});
|
|
1869
|
-
|
|
1870
1809
|
// src/client.ts
|
|
1871
1810
|
var client_exports = {};
|
|
1872
1811
|
__export(client_exports, {
|
|
@@ -1898,7 +1837,6 @@ var init_client = __esm({
|
|
|
1898
1837
|
init_rate_limit();
|
|
1899
1838
|
init_config();
|
|
1900
1839
|
init_steps();
|
|
1901
|
-
init_helpers();
|
|
1902
1840
|
DEFAULT_BASE_URL = "https://v1.mindstudio-api.com";
|
|
1903
1841
|
DEFAULT_MAX_RETRIES = 3;
|
|
1904
1842
|
MindStudioAgent = class {
|
|
@@ -1969,6 +1907,85 @@ var init_client = __esm({
|
|
|
1969
1907
|
$billingEvents: billingEvents != null ? JSON.parse(billingEvents) : void 0
|
|
1970
1908
|
};
|
|
1971
1909
|
}
|
|
1910
|
+
/**
|
|
1911
|
+
* Execute multiple steps in parallel in a single request.
|
|
1912
|
+
*
|
|
1913
|
+
* All steps run in parallel on the server. Results are returned in the same
|
|
1914
|
+
* order as the input. Individual step failures do not affect other steps —
|
|
1915
|
+
* partial success is possible.
|
|
1916
|
+
*
|
|
1917
|
+
* ```ts
|
|
1918
|
+
* const { results } = await agent.executeStepBatch([
|
|
1919
|
+
* { stepType: 'generateImage', step: { prompt: 'a sunset' } },
|
|
1920
|
+
* { stepType: 'textToSpeech', step: { text: 'Hello world' } },
|
|
1921
|
+
* ]);
|
|
1922
|
+
* ```
|
|
1923
|
+
*/
|
|
1924
|
+
async executeStepBatch(steps, options) {
|
|
1925
|
+
const threadId = options?.threadId ?? (this._reuseThreadId ? this._threadId : void 0);
|
|
1926
|
+
const { data } = await request(this._httpConfig, "POST", "/steps/execute-batch", {
|
|
1927
|
+
steps,
|
|
1928
|
+
...options?.appId != null && { appId: options.appId },
|
|
1929
|
+
...threadId != null && { threadId }
|
|
1930
|
+
});
|
|
1931
|
+
const results = await Promise.all(
|
|
1932
|
+
data.results.map(async (r) => {
|
|
1933
|
+
if (r.output != null) {
|
|
1934
|
+
return {
|
|
1935
|
+
stepType: r.stepType,
|
|
1936
|
+
output: r.output,
|
|
1937
|
+
billingCost: r.billingCost,
|
|
1938
|
+
error: r.error
|
|
1939
|
+
};
|
|
1940
|
+
}
|
|
1941
|
+
if (r.outputUrl) {
|
|
1942
|
+
const res = await fetch(r.outputUrl);
|
|
1943
|
+
if (!res.ok) {
|
|
1944
|
+
return {
|
|
1945
|
+
stepType: r.stepType,
|
|
1946
|
+
error: `Failed to fetch output from S3: ${res.status} ${res.statusText}`
|
|
1947
|
+
};
|
|
1948
|
+
}
|
|
1949
|
+
const envelope = await res.json();
|
|
1950
|
+
return {
|
|
1951
|
+
stepType: r.stepType,
|
|
1952
|
+
output: envelope.value,
|
|
1953
|
+
billingCost: r.billingCost
|
|
1954
|
+
};
|
|
1955
|
+
}
|
|
1956
|
+
return {
|
|
1957
|
+
stepType: r.stepType,
|
|
1958
|
+
billingCost: r.billingCost,
|
|
1959
|
+
error: r.error
|
|
1960
|
+
};
|
|
1961
|
+
})
|
|
1962
|
+
);
|
|
1963
|
+
if (this._reuseThreadId && data.threadId) {
|
|
1964
|
+
this._threadId = data.threadId;
|
|
1965
|
+
}
|
|
1966
|
+
return {
|
|
1967
|
+
results,
|
|
1968
|
+
totalBillingCost: data.totalBillingCost,
|
|
1969
|
+
appId: data.appId,
|
|
1970
|
+
threadId: data.threadId
|
|
1971
|
+
};
|
|
1972
|
+
}
|
|
1973
|
+
/**
|
|
1974
|
+
* Get the authenticated user's identity and organization info.
|
|
1975
|
+
*
|
|
1976
|
+
* ```ts
|
|
1977
|
+
* const info = await agent.getUserInfo();
|
|
1978
|
+
* console.log(info.displayName, info.organizationName);
|
|
1979
|
+
* ```
|
|
1980
|
+
*/
|
|
1981
|
+
async getUserInfo() {
|
|
1982
|
+
const { data } = await request(
|
|
1983
|
+
this._httpConfig,
|
|
1984
|
+
"GET",
|
|
1985
|
+
"/account/userinfo"
|
|
1986
|
+
);
|
|
1987
|
+
return data;
|
|
1988
|
+
}
|
|
1972
1989
|
/**
|
|
1973
1990
|
* List all pre-built agents in the organization.
|
|
1974
1991
|
*
|
|
@@ -2045,13 +2062,155 @@ var init_client = __esm({
|
|
|
2045
2062
|
return poll.result;
|
|
2046
2063
|
}
|
|
2047
2064
|
}
|
|
2048
|
-
/** @internal Used by generated
|
|
2065
|
+
/** @internal Used by generated action methods. */
|
|
2049
2066
|
_request(method, path, body) {
|
|
2050
2067
|
return request(this._httpConfig, method, path, body);
|
|
2051
2068
|
}
|
|
2069
|
+
// -------------------------------------------------------------------------
|
|
2070
|
+
// Helper methods — models
|
|
2071
|
+
// -------------------------------------------------------------------------
|
|
2072
|
+
/** List all available AI models. */
|
|
2073
|
+
async listModels() {
|
|
2074
|
+
const { data } = await request(
|
|
2075
|
+
this._httpConfig,
|
|
2076
|
+
"GET",
|
|
2077
|
+
"/helpers/models"
|
|
2078
|
+
);
|
|
2079
|
+
return data;
|
|
2080
|
+
}
|
|
2081
|
+
/** List AI models filtered by type. */
|
|
2082
|
+
async listModelsByType(modelType) {
|
|
2083
|
+
const { data } = await request(
|
|
2084
|
+
this._httpConfig,
|
|
2085
|
+
"GET",
|
|
2086
|
+
`/helpers/models/${modelType}`
|
|
2087
|
+
);
|
|
2088
|
+
return data;
|
|
2089
|
+
}
|
|
2090
|
+
/** List all available AI models (summary). Returns only id, name, type, and tags. */
|
|
2091
|
+
async listModelsSummary() {
|
|
2092
|
+
const { data } = await request(
|
|
2093
|
+
this._httpConfig,
|
|
2094
|
+
"GET",
|
|
2095
|
+
"/helpers/models-summary"
|
|
2096
|
+
);
|
|
2097
|
+
return data;
|
|
2098
|
+
}
|
|
2099
|
+
/** List AI models (summary) filtered by type. */
|
|
2100
|
+
async listModelsSummaryByType(modelType) {
|
|
2101
|
+
const { data } = await request(
|
|
2102
|
+
this._httpConfig,
|
|
2103
|
+
"GET",
|
|
2104
|
+
`/helpers/models-summary/${modelType}`
|
|
2105
|
+
);
|
|
2106
|
+
return data;
|
|
2107
|
+
}
|
|
2108
|
+
// -------------------------------------------------------------------------
|
|
2109
|
+
// Helper methods — OAuth connectors & connections
|
|
2110
|
+
// -------------------------------------------------------------------------
|
|
2111
|
+
/**
|
|
2112
|
+
* List available OAuth connector services (Slack, Google, HubSpot, etc.).
|
|
2113
|
+
*
|
|
2114
|
+
* These are third-party integrations from the MindStudio Connector Registry.
|
|
2115
|
+
* For most tasks, use actions directly instead.
|
|
2116
|
+
*/
|
|
2117
|
+
async listConnectors() {
|
|
2118
|
+
const { data } = await request(
|
|
2119
|
+
this._httpConfig,
|
|
2120
|
+
"GET",
|
|
2121
|
+
"/helpers/connectors"
|
|
2122
|
+
);
|
|
2123
|
+
return data;
|
|
2124
|
+
}
|
|
2125
|
+
/** Get details for a single OAuth connector service. */
|
|
2126
|
+
async getConnector(serviceId) {
|
|
2127
|
+
const { data } = await request(
|
|
2128
|
+
this._httpConfig,
|
|
2129
|
+
"GET",
|
|
2130
|
+
`/helpers/connectors/${serviceId}`
|
|
2131
|
+
);
|
|
2132
|
+
return data;
|
|
2133
|
+
}
|
|
2134
|
+
/** Get the full configuration for an OAuth connector action, including input fields. */
|
|
2135
|
+
async getConnectorAction(serviceId, actionId) {
|
|
2136
|
+
const { data } = await request(
|
|
2137
|
+
this._httpConfig,
|
|
2138
|
+
"GET",
|
|
2139
|
+
`/helpers/connectors/${serviceId}/${actionId}`
|
|
2140
|
+
);
|
|
2141
|
+
return data;
|
|
2142
|
+
}
|
|
2143
|
+
/** List OAuth connections for the organization. These are authenticated third-party service links. */
|
|
2144
|
+
async listConnections() {
|
|
2145
|
+
const { data } = await request(
|
|
2146
|
+
this._httpConfig,
|
|
2147
|
+
"GET",
|
|
2148
|
+
"/helpers/connections"
|
|
2149
|
+
);
|
|
2150
|
+
return data;
|
|
2151
|
+
}
|
|
2152
|
+
// -------------------------------------------------------------------------
|
|
2153
|
+
// Helper methods — cost estimation
|
|
2154
|
+
// -------------------------------------------------------------------------
|
|
2155
|
+
/** Estimate the cost of executing an action before running it. */
|
|
2156
|
+
async estimateStepCost(stepType, step, options) {
|
|
2157
|
+
const { data } = await request(this._httpConfig, "POST", "/helpers/step-cost-estimate", {
|
|
2158
|
+
step: { type: stepType, ...step },
|
|
2159
|
+
...options
|
|
2160
|
+
});
|
|
2161
|
+
return data;
|
|
2162
|
+
}
|
|
2163
|
+
// -------------------------------------------------------------------------
|
|
2164
|
+
// Account methods
|
|
2165
|
+
// -------------------------------------------------------------------------
|
|
2166
|
+
/** Update the display name of the authenticated user/agent. */
|
|
2167
|
+
async changeName(displayName) {
|
|
2168
|
+
await request(this._httpConfig, "POST", "/account/change-name", {
|
|
2169
|
+
name: displayName
|
|
2170
|
+
});
|
|
2171
|
+
}
|
|
2172
|
+
/** Update the profile picture of the authenticated user/agent. */
|
|
2173
|
+
async changeProfilePicture(url) {
|
|
2174
|
+
await request(this._httpConfig, "POST", "/account/change-profile-picture", {
|
|
2175
|
+
url
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2178
|
+
/**
|
|
2179
|
+
* Upload a file to the MindStudio CDN.
|
|
2180
|
+
*
|
|
2181
|
+
* Gets a signed upload URL, PUTs the file content, and returns the
|
|
2182
|
+
* permanent public URL.
|
|
2183
|
+
*/
|
|
2184
|
+
async uploadFile(content, options) {
|
|
2185
|
+
const { data } = await request(
|
|
2186
|
+
this._httpConfig,
|
|
2187
|
+
"POST",
|
|
2188
|
+
"/account/upload",
|
|
2189
|
+
{
|
|
2190
|
+
extension: options.extension,
|
|
2191
|
+
...options.type != null && { type: options.type }
|
|
2192
|
+
}
|
|
2193
|
+
);
|
|
2194
|
+
const buf = content.buffer.slice(
|
|
2195
|
+
content.byteOffset,
|
|
2196
|
+
content.byteOffset + content.byteLength
|
|
2197
|
+
);
|
|
2198
|
+
const res = await fetch(data.uploadUrl, {
|
|
2199
|
+
method: "PUT",
|
|
2200
|
+
body: buf,
|
|
2201
|
+
headers: options.type ? { "Content-Type": options.type } : {}
|
|
2202
|
+
});
|
|
2203
|
+
if (!res.ok) {
|
|
2204
|
+
throw new MindStudioError(
|
|
2205
|
+
`Upload failed: ${res.status} ${res.statusText}`,
|
|
2206
|
+
"upload_error",
|
|
2207
|
+
res.status
|
|
2208
|
+
);
|
|
2209
|
+
}
|
|
2210
|
+
return { url: data.url };
|
|
2211
|
+
}
|
|
2052
2212
|
};
|
|
2053
2213
|
applyStepMethods(MindStudioAgent);
|
|
2054
|
-
applyHelperMethods(MindStudioAgent);
|
|
2055
2214
|
}
|
|
2056
2215
|
});
|
|
2057
2216
|
|
|
@@ -2115,9 +2274,9 @@ async function startMcpServer(options) {
|
|
|
2115
2274
|
capabilities: { tools: {} },
|
|
2116
2275
|
serverInfo: {
|
|
2117
2276
|
name: "mindstudio-agent",
|
|
2118
|
-
version: "0.1.
|
|
2277
|
+
version: "0.1.6"
|
|
2119
2278
|
},
|
|
2120
|
-
instructions: "Welcome to MindStudio \u2014 a platform with 200+ AI models, 850+ third-party integrations, and pre-built agents.\n\nGetting started:\n1. Call `listAgents` to verify your connection and see available agents.\n2. Call `changeName` to set your display name \u2014 use your name or whatever your user calls you. This is how you'll appear in MindStudio request logs.\n3. If you have a profile picture or icon, call `uploadFile` to upload it, then `changeProfilePicture` with the returned URL. This helps users identify your requests in their logs.\n4. Call `
|
|
2279
|
+
instructions: "Welcome to MindStudio \u2014 a platform with 200+ AI models, 850+ third-party integrations, and pre-built agents.\n\nGetting started:\n1. Call `listAgents` to verify your connection and see available agents.\n2. Call `changeName` to set your display name \u2014 use your name or whatever your user calls you. This is how you'll appear in MindStudio request logs.\n3. If you have a profile picture or icon, call `uploadFile` to upload it, then `changeProfilePicture` with the returned URL. This helps users identify your requests in their logs.\n4. Call `listActions` to discover all available actions.\n\nThen use the tools to generate text, images, video, audio, search the web, work with data sources, run agents, and more.\n\nImportant:\n- AI-powered actions (text generation, image generation, video, audio, etc.) cost money. Before running these, call `estimateActionCost` and confirm with the user before proceeding \u2014 unless they've explicitly told you to go ahead.\n- Not all agents from `listAgents` are configured for API use. Do not try to run an agent just because it appears in the list \u2014 it will likely fail. Only run agents the user specifically asks you to run."
|
|
2121
2280
|
});
|
|
2122
2281
|
break;
|
|
2123
2282
|
case "notifications/initialized":
|
|
@@ -2130,7 +2289,7 @@ async function startMcpServer(options) {
|
|
|
2130
2289
|
const args = params.arguments ?? {};
|
|
2131
2290
|
try {
|
|
2132
2291
|
let result;
|
|
2133
|
-
if (toolName === "
|
|
2292
|
+
if (toolName === "listActions") {
|
|
2134
2293
|
const meta = await getMetadata();
|
|
2135
2294
|
const summary = {};
|
|
2136
2295
|
for (const [name, step] of Object.entries(meta)) {
|
|
@@ -2167,7 +2326,7 @@ async function startMcpServer(options) {
|
|
|
2167
2326
|
);
|
|
2168
2327
|
} else if (toolName === "listConnections") {
|
|
2169
2328
|
result = await getAgent().listConnections();
|
|
2170
|
-
} else if (toolName === "
|
|
2329
|
+
} else if (toolName === "estimateActionCost") {
|
|
2171
2330
|
result = await getAgent().estimateStepCost(
|
|
2172
2331
|
args.stepType,
|
|
2173
2332
|
args.step,
|
|
@@ -2196,6 +2355,10 @@ async function startMcpServer(options) {
|
|
|
2196
2355
|
extension: ext,
|
|
2197
2356
|
...mimeType && { type: mimeType }
|
|
2198
2357
|
});
|
|
2358
|
+
} else if (toolName === "executeBatch") {
|
|
2359
|
+
result = await getAgent().executeStepBatch(
|
|
2360
|
+
args.steps
|
|
2361
|
+
);
|
|
2199
2362
|
} else if (toolName === "listAgents") {
|
|
2200
2363
|
result = await getAgent().listAgents();
|
|
2201
2364
|
} else if (toolName === "runAgent") {
|
|
@@ -2277,21 +2440,22 @@ var init_mcp = __esm({
|
|
|
2277
2440
|
listModelsByType: "List AI models filtered by type.",
|
|
2278
2441
|
listModelsSummary: "List all AI models (summary: id, name, type, tags).",
|
|
2279
2442
|
listModelsSummaryByType: "List AI models (summary) filtered by type.",
|
|
2280
|
-
listConnectors: "List available connector services
|
|
2281
|
-
getConnector: "Get details for
|
|
2282
|
-
getConnectorAction: "Get full configuration for
|
|
2283
|
-
listConnections: "List OAuth connections for the organization.",
|
|
2284
|
-
estimateStepCost: "Estimate the cost of executing
|
|
2443
|
+
listConnectors: "List available OAuth connector services (third-party integrations). For most tasks, use actions directly instead.",
|
|
2444
|
+
getConnector: "Get details for an OAuth connector service.",
|
|
2445
|
+
getConnectorAction: "Get full configuration for an OAuth connector action.",
|
|
2446
|
+
listConnections: "List OAuth connections for the organization (authenticated third-party service links).",
|
|
2447
|
+
estimateStepCost: "Estimate the cost of executing an action before running it.",
|
|
2285
2448
|
changeName: "Update the display name of the authenticated agent.",
|
|
2286
2449
|
changeProfilePicture: "Update the profile picture of the authenticated agent.",
|
|
2287
2450
|
uploadFile: "Upload a file to the MindStudio CDN.",
|
|
2288
2451
|
listAgents: "List all pre-built agents in the organization.",
|
|
2289
|
-
runAgent: "Run a pre-built agent and wait for the result."
|
|
2452
|
+
runAgent: "Run a pre-built agent and wait for the result.",
|
|
2453
|
+
executeBatch: "Execute multiple actions in parallel in a single request."
|
|
2290
2454
|
};
|
|
2291
2455
|
HELPER_TOOLS = [
|
|
2292
2456
|
{
|
|
2293
|
-
name: "
|
|
2294
|
-
description: "List all available
|
|
2457
|
+
name: "listActions",
|
|
2458
|
+
description: "List all available actions with their descriptions. Returns a compact { action: description } map. Call this to discover what actions are available, then call a specific action by name. Tip: if you haven't already, call `changeName` to set your display name first.",
|
|
2295
2459
|
inputSchema: { type: "object", properties: {} }
|
|
2296
2460
|
},
|
|
2297
2461
|
{
|
|
@@ -2350,12 +2514,12 @@ var init_mcp = __esm({
|
|
|
2350
2514
|
},
|
|
2351
2515
|
{
|
|
2352
2516
|
name: "listConnectors",
|
|
2353
|
-
description: "List available connector services (Slack, Google, HubSpot, etc.) and their actions.",
|
|
2517
|
+
description: "List available OAuth connector services (Slack, Google, HubSpot, etc.) and their actions. These are third-party integrations \u2014 for most tasks, use actions directly instead.",
|
|
2354
2518
|
inputSchema: { type: "object", properties: {} }
|
|
2355
2519
|
},
|
|
2356
2520
|
{
|
|
2357
2521
|
name: "getConnector",
|
|
2358
|
-
description: "Get details for a single connector service by ID.",
|
|
2522
|
+
description: "Get details for a single OAuth connector service by ID.",
|
|
2359
2523
|
inputSchema: {
|
|
2360
2524
|
type: "object",
|
|
2361
2525
|
properties: { serviceId: { type: "string" } },
|
|
@@ -2364,7 +2528,7 @@ var init_mcp = __esm({
|
|
|
2364
2528
|
},
|
|
2365
2529
|
{
|
|
2366
2530
|
name: "getConnectorAction",
|
|
2367
|
-
description: "Get the full configuration for
|
|
2531
|
+
description: "Get the full configuration for an OAuth connector action, including all input fields needed to call it via runFromConnectorRegistry.",
|
|
2368
2532
|
inputSchema: {
|
|
2369
2533
|
type: "object",
|
|
2370
2534
|
properties: {
|
|
@@ -2382,22 +2546,22 @@ var init_mcp = __esm({
|
|
|
2382
2546
|
},
|
|
2383
2547
|
{
|
|
2384
2548
|
name: "listConnections",
|
|
2385
|
-
description: "List OAuth connections for the organization. Use the returned connection IDs when calling connector actions.",
|
|
2549
|
+
description: "List OAuth connections for the organization (authenticated third-party service links). Use the returned connection IDs when calling OAuth connector actions.",
|
|
2386
2550
|
inputSchema: { type: "object", properties: {} }
|
|
2387
2551
|
},
|
|
2388
2552
|
{
|
|
2389
|
-
name: "
|
|
2390
|
-
description: "Estimate the cost of executing
|
|
2553
|
+
name: "estimateActionCost",
|
|
2554
|
+
description: "Estimate the cost of executing an action before running it. Pass the same config you would use for execution.",
|
|
2391
2555
|
inputSchema: {
|
|
2392
2556
|
type: "object",
|
|
2393
2557
|
properties: {
|
|
2394
2558
|
stepType: {
|
|
2395
2559
|
type: "string",
|
|
2396
|
-
description: 'The
|
|
2560
|
+
description: 'The action type name (e.g. "generateText").'
|
|
2397
2561
|
},
|
|
2398
2562
|
step: {
|
|
2399
2563
|
type: "object",
|
|
2400
|
-
description: "The
|
|
2564
|
+
description: "The action input parameters.",
|
|
2401
2565
|
additionalProperties: true
|
|
2402
2566
|
},
|
|
2403
2567
|
appId: {
|
|
@@ -2454,6 +2618,37 @@ var init_mcp = __esm({
|
|
|
2454
2618
|
required: ["filePath"]
|
|
2455
2619
|
}
|
|
2456
2620
|
},
|
|
2621
|
+
{
|
|
2622
|
+
name: "executeBatch",
|
|
2623
|
+
description: "Execute multiple actions in parallel in a single request. All steps run in parallel on the server. Results are returned in the same order as the input. Individual step failures do not affect other steps \u2014 partial success is possible. Maximum 50 steps per batch.",
|
|
2624
|
+
inputSchema: {
|
|
2625
|
+
type: "object",
|
|
2626
|
+
properties: {
|
|
2627
|
+
steps: {
|
|
2628
|
+
type: "array",
|
|
2629
|
+
description: "Array of steps to execute.",
|
|
2630
|
+
minItems: 1,
|
|
2631
|
+
maxItems: 50,
|
|
2632
|
+
items: {
|
|
2633
|
+
type: "object",
|
|
2634
|
+
properties: {
|
|
2635
|
+
stepType: {
|
|
2636
|
+
type: "string",
|
|
2637
|
+
description: 'The action type name (e.g. "generateImage", "textToSpeech").'
|
|
2638
|
+
},
|
|
2639
|
+
step: {
|
|
2640
|
+
type: "object",
|
|
2641
|
+
description: "Action input parameters.",
|
|
2642
|
+
additionalProperties: true
|
|
2643
|
+
}
|
|
2644
|
+
},
|
|
2645
|
+
required: ["stepType", "step"]
|
|
2646
|
+
}
|
|
2647
|
+
}
|
|
2648
|
+
},
|
|
2649
|
+
required: ["steps"]
|
|
2650
|
+
}
|
|
2651
|
+
},
|
|
2457
2652
|
{
|
|
2458
2653
|
name: "listAgents",
|
|
2459
2654
|
description: "List all pre-built agents in the organization along with org metadata.",
|
|
@@ -2495,44 +2690,66 @@ import { parseArgs } from "util";
|
|
|
2495
2690
|
import { execSync } from "child_process";
|
|
2496
2691
|
import { readFileSync as readFileSync3 } from "fs";
|
|
2497
2692
|
import { extname as extname2 } from "path";
|
|
2498
|
-
var HELP = `Usage: mindstudio <command
|
|
2693
|
+
var HELP = `Usage: mindstudio <command> [options]
|
|
2694
|
+
|
|
2695
|
+
Run actions:
|
|
2696
|
+
<action> [json | --flags] Run an action directly
|
|
2697
|
+
run <action> [json | --flags] Run an action (explicit form)
|
|
2698
|
+
estimate-cost <action> [json] Estimate cost before running
|
|
2699
|
+
|
|
2700
|
+
Discover:
|
|
2701
|
+
list-actions [--json] [--summary] List all available actions
|
|
2702
|
+
info <action> Show action details and parameters
|
|
2703
|
+
list-models [--type <t>] [--summary] List available AI models
|
|
2704
|
+
|
|
2705
|
+
Batch:
|
|
2706
|
+
batch [json] Execute multiple actions in parallel
|
|
2707
|
+
|
|
2708
|
+
Pre-built agents:
|
|
2709
|
+
agents [--json] List agents in your organization
|
|
2710
|
+
run-agent <appId> [json | --flags] Run an agent and wait for result
|
|
2711
|
+
|
|
2712
|
+
Account:
|
|
2713
|
+
login Authenticate with MindStudio
|
|
2714
|
+
logout Clear stored credentials
|
|
2715
|
+
whoami Show current user and organization
|
|
2716
|
+
change-name <name> Update your display name
|
|
2717
|
+
change-profile-picture <url> Update your profile picture
|
|
2718
|
+
upload <filepath> Upload a file to the MindStudio CDN
|
|
2499
2719
|
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
exec <method> [json | --flags] Execute a step method
|
|
2507
|
-
list [--json] [--summary] List available methods (--summary for compact JSON)
|
|
2508
|
-
info <method> Show method details (params, types, output)
|
|
2509
|
-
agents [--json] List pre-built agents in your organization
|
|
2510
|
-
run <appId> [json | --flags] Run a pre-built agent and wait for result
|
|
2511
|
-
mcp Start MCP server (JSON-RPC over stdio)
|
|
2720
|
+
OAuth integrations:
|
|
2721
|
+
list-connectors [<id> [<actionId>]] Browse OAuth connector services
|
|
2722
|
+
list-connections List your OAuth connections
|
|
2723
|
+
|
|
2724
|
+
Other:
|
|
2725
|
+
mcp Start MCP server (JSON-RPC over stdio)
|
|
2512
2726
|
|
|
2513
2727
|
Options:
|
|
2514
|
-
--api-key <key>
|
|
2515
|
-
--base-url <url>
|
|
2516
|
-
--app-id <id>
|
|
2517
|
-
--thread-id <id>
|
|
2518
|
-
--output-key <key>
|
|
2519
|
-
--no-meta
|
|
2520
|
-
--workflow <name>
|
|
2521
|
-
--version <ver>
|
|
2522
|
-
--json
|
|
2523
|
-
--
|
|
2728
|
+
--api-key <key> API key (or set MINDSTUDIO_API_KEY env var)
|
|
2729
|
+
--base-url <url> API base URL override
|
|
2730
|
+
--app-id <id> App ID for thread context
|
|
2731
|
+
--thread-id <id> Thread ID for state persistence
|
|
2732
|
+
--output-key <key> Extract a single field from the result
|
|
2733
|
+
--no-meta Strip $-prefixed metadata from output
|
|
2734
|
+
--workflow <name> Workflow to execute (run-agent only)
|
|
2735
|
+
--version <ver> App version, e.g. "draft" (run-agent only)
|
|
2736
|
+
--json Output as JSON
|
|
2737
|
+
--summary Compact output (list-actions, list-models)
|
|
2738
|
+
--type <type> Filter by model type (list-models)
|
|
2739
|
+
--help Show this help
|
|
2524
2740
|
|
|
2525
2741
|
Examples:
|
|
2526
|
-
mindstudio login
|
|
2527
2742
|
mindstudio generate-image --prompt "a sunset"
|
|
2528
|
-
mindstudio generate-image --prompt "a sunset" --output-key imageUrl
|
|
2529
2743
|
mindstudio generate-text --message "hello" --no-meta
|
|
2530
|
-
mindstudio generate-image '{"prompt":"a sunset"}'
|
|
2744
|
+
mindstudio generate-image '{"prompt":"a sunset"}' --output-key imageUrl
|
|
2531
2745
|
echo '{"query":"test"}' | mindstudio search-google
|
|
2746
|
+
mindstudio estimate-cost generate-image --prompt "a sunset"
|
|
2747
|
+
mindstudio list-actions --summary
|
|
2532
2748
|
mindstudio info generate-image
|
|
2533
|
-
mindstudio list --
|
|
2749
|
+
mindstudio list-models --type image_generation
|
|
2750
|
+
mindstudio batch '[{"stepType":"generateImage","step":{"prompt":"a cat"}}]'
|
|
2751
|
+
mindstudio run-agent <appId> --query "hello"
|
|
2534
2752
|
mindstudio agents
|
|
2535
|
-
mindstudio run <appId> --query "hello"
|
|
2536
2753
|
mindstudio mcp
|
|
2537
2754
|
`;
|
|
2538
2755
|
function camelToKebab(s) {
|
|
@@ -2586,6 +2803,10 @@ function fatal(message) {
|
|
|
2586
2803
|
process.stderr.write(JSON.stringify({ error: { message } }) + "\n");
|
|
2587
2804
|
process.exit(1);
|
|
2588
2805
|
}
|
|
2806
|
+
function usageBlock(lines) {
|
|
2807
|
+
process.stderr.write("\n" + lines.map((l) => " " + l).join("\n") + "\n\n");
|
|
2808
|
+
process.exit(1);
|
|
2809
|
+
}
|
|
2589
2810
|
async function readStdin() {
|
|
2590
2811
|
const chunks = [];
|
|
2591
2812
|
for await (const chunk of process.stdin) {
|
|
@@ -2593,19 +2814,6 @@ async function readStdin() {
|
|
|
2593
2814
|
}
|
|
2594
2815
|
return Buffer.concat(chunks).toString("utf-8").trim();
|
|
2595
2816
|
}
|
|
2596
|
-
var HELPER_NAMES = /* @__PURE__ */ new Set([
|
|
2597
|
-
"listModels",
|
|
2598
|
-
"listModelsByType",
|
|
2599
|
-
"listModelsSummary",
|
|
2600
|
-
"listModelsSummaryByType",
|
|
2601
|
-
"listConnectors",
|
|
2602
|
-
"getConnector",
|
|
2603
|
-
"getConnectorAction",
|
|
2604
|
-
"listConnections",
|
|
2605
|
-
"estimateStepCost",
|
|
2606
|
-
"changeName",
|
|
2607
|
-
"changeProfilePicture"
|
|
2608
|
-
]);
|
|
2609
2817
|
function resolveMethodOrFail(name, metadataKeys) {
|
|
2610
2818
|
if (metadataKeys.has(name)) return name;
|
|
2611
2819
|
const camel = kebabToCamel(name);
|
|
@@ -2622,36 +2830,18 @@ function resolveMethodOrFail(name, metadataKeys) {
|
|
|
2622
2830
|
}
|
|
2623
2831
|
const suggestion = bestDist <= 3 ? ` Did you mean '${bestMatch}'?` : "";
|
|
2624
2832
|
fatal(
|
|
2625
|
-
`Unknown
|
|
2833
|
+
`Unknown action: ${name}.${suggestion} Run 'mindstudio list-actions' to see available actions.`
|
|
2626
2834
|
);
|
|
2627
2835
|
}
|
|
2628
2836
|
async function getAllMethodKeys() {
|
|
2629
2837
|
const { stepMetadata: stepMetadata2 } = await Promise.resolve().then(() => (init_metadata(), metadata_exports));
|
|
2630
|
-
return
|
|
2838
|
+
return new Set(Object.keys(stepMetadata2));
|
|
2631
2839
|
}
|
|
2632
|
-
var HELPER_DESCRIPTIONS2 = {
|
|
2633
|
-
listModels: "List all available AI models.",
|
|
2634
|
-
listModelsByType: "List AI models filtered by type.",
|
|
2635
|
-
listModelsSummary: "List all AI models (summary: id, name, type, tags).",
|
|
2636
|
-
listModelsSummaryByType: "List AI models (summary) filtered by type.",
|
|
2637
|
-
listConnectors: "List available connector services and their actions.",
|
|
2638
|
-
getConnector: "Get details for a connector service.",
|
|
2639
|
-
getConnectorAction: "Get full configuration for a connector action.",
|
|
2640
|
-
listConnections: "List OAuth connections for the organization.",
|
|
2641
|
-
estimateStepCost: "Estimate the cost of executing a step before running it.",
|
|
2642
|
-
changeName: "Update the display name of the authenticated agent.",
|
|
2643
|
-
changeProfilePicture: "Update the profile picture of the authenticated agent.",
|
|
2644
|
-
listAgents: "List all pre-built agents in the organization.",
|
|
2645
|
-
runAgent: "Run a pre-built agent and wait for the result."
|
|
2646
|
-
};
|
|
2647
2840
|
function buildSummary(stepMetadata2) {
|
|
2648
2841
|
const summary = {};
|
|
2649
2842
|
for (const [name, meta] of Object.entries(stepMetadata2)) {
|
|
2650
2843
|
summary[name] = meta.description;
|
|
2651
2844
|
}
|
|
2652
|
-
for (const [name, desc] of Object.entries(HELPER_DESCRIPTIONS2)) {
|
|
2653
|
-
summary[name] = desc;
|
|
2654
|
-
}
|
|
2655
2845
|
return summary;
|
|
2656
2846
|
}
|
|
2657
2847
|
async function cmdList(asJson, asSummary) {
|
|
@@ -2686,79 +2876,6 @@ async function cmdList(asJson, asSummary) {
|
|
|
2686
2876
|
async function cmdInfo(rawMethod) {
|
|
2687
2877
|
const allKeys = await getAllMethodKeys();
|
|
2688
2878
|
const method = resolveMethodOrFail(rawMethod, allKeys);
|
|
2689
|
-
if (HELPER_NAMES.has(method)) {
|
|
2690
|
-
const helpers = {
|
|
2691
|
-
listModels: {
|
|
2692
|
-
desc: "List all available AI models.",
|
|
2693
|
-
input: "(none)",
|
|
2694
|
-
output: "{ models: MindStudioModel[] }"
|
|
2695
|
-
},
|
|
2696
|
-
listModelsByType: {
|
|
2697
|
-
desc: "List AI models filtered by type.",
|
|
2698
|
-
input: "modelType: string (required)",
|
|
2699
|
-
output: "{ models: MindStudioModel[] }"
|
|
2700
|
-
},
|
|
2701
|
-
listModelsSummary: {
|
|
2702
|
-
desc: "List all AI models (summary: id, name, type, tags).",
|
|
2703
|
-
input: "(none)",
|
|
2704
|
-
output: "{ models: MindStudioModelSummary[] }"
|
|
2705
|
-
},
|
|
2706
|
-
listModelsSummaryByType: {
|
|
2707
|
-
desc: "List AI models (summary) filtered by type.",
|
|
2708
|
-
input: "modelType: string (required)",
|
|
2709
|
-
output: "{ models: MindStudioModelSummary[] }"
|
|
2710
|
-
},
|
|
2711
|
-
listConnectors: {
|
|
2712
|
-
desc: "List available connector services and their actions.",
|
|
2713
|
-
input: "(none)",
|
|
2714
|
-
output: "{ services: ConnectorService[] }"
|
|
2715
|
-
},
|
|
2716
|
-
getConnector: {
|
|
2717
|
-
desc: "Get details for a connector service.",
|
|
2718
|
-
input: "serviceId: string (required)",
|
|
2719
|
-
output: "{ service: ConnectorService }"
|
|
2720
|
-
},
|
|
2721
|
-
getConnectorAction: {
|
|
2722
|
-
desc: "Get full configuration for a connector action.",
|
|
2723
|
-
input: "serviceId: string, actionId: string (both required)",
|
|
2724
|
-
output: "{ action: ConnectorActionDetail }"
|
|
2725
|
-
},
|
|
2726
|
-
listConnections: {
|
|
2727
|
-
desc: "List OAuth connections for the organization.",
|
|
2728
|
-
input: "(none)",
|
|
2729
|
-
output: "{ connections: Connection[] }"
|
|
2730
|
-
},
|
|
2731
|
-
estimateStepCost: {
|
|
2732
|
-
desc: "Estimate the cost of executing a step before running it.",
|
|
2733
|
-
input: "stepType: string (required), step: object, appId?: string, workflowId?: string",
|
|
2734
|
-
output: "{ costType?: string, estimates?: StepCostEstimateEntry[] }"
|
|
2735
|
-
},
|
|
2736
|
-
changeName: {
|
|
2737
|
-
desc: "Update the display name of the authenticated agent.",
|
|
2738
|
-
input: "displayName: string (required)",
|
|
2739
|
-
output: "(none)"
|
|
2740
|
-
},
|
|
2741
|
-
changeProfilePicture: {
|
|
2742
|
-
desc: "Update the profile picture of the authenticated agent.",
|
|
2743
|
-
input: "profilePictureUrl: string (required)",
|
|
2744
|
-
output: "(none)"
|
|
2745
|
-
}
|
|
2746
|
-
};
|
|
2747
|
-
const h = helpers[method];
|
|
2748
|
-
process.stderr.write(`
|
|
2749
|
-
${camelToKebab(method)}
|
|
2750
|
-
|
|
2751
|
-
`);
|
|
2752
|
-
process.stderr.write(` ${h.desc}
|
|
2753
|
-
|
|
2754
|
-
`);
|
|
2755
|
-
process.stderr.write(` Input: ${h.input}
|
|
2756
|
-
`);
|
|
2757
|
-
process.stderr.write(` Output: ${h.output}
|
|
2758
|
-
|
|
2759
|
-
`);
|
|
2760
|
-
return;
|
|
2761
|
-
}
|
|
2762
2879
|
const { stepMetadata: stepMetadata2 } = await Promise.resolve().then(() => (init_metadata(), metadata_exports));
|
|
2763
2880
|
const meta = stepMetadata2[method];
|
|
2764
2881
|
const out = [];
|
|
@@ -2814,61 +2931,21 @@ async function cmdExec(method, input, options) {
|
|
|
2814
2931
|
await Promise.resolve().then(() => (init_steps(), steps_exports)).then(
|
|
2815
2932
|
(m) => m.applyStepMethods(MindStudioAgent2)
|
|
2816
2933
|
);
|
|
2817
|
-
await Promise.resolve().then(() => (init_helpers(), helpers_exports)).then(
|
|
2818
|
-
(m) => m.applyHelperMethods(MindStudioAgent2)
|
|
2819
|
-
);
|
|
2820
2934
|
const agent = new MindStudioAgent2({
|
|
2821
2935
|
apiKey: options.apiKey,
|
|
2822
2936
|
baseUrl: options.baseUrl
|
|
2823
2937
|
});
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
} else if (method === "listModelsSummary") {
|
|
2830
|
-
result = await agent.listModelsSummary();
|
|
2831
|
-
} else if (method === "listModelsSummaryByType") {
|
|
2832
|
-
result = await agent.listModelsSummaryByType(input.modelType);
|
|
2833
|
-
} else if (method === "listConnectors") {
|
|
2834
|
-
result = await agent.listConnectors();
|
|
2835
|
-
} else if (method === "getConnector") {
|
|
2836
|
-
result = await agent.getConnector(input.serviceId);
|
|
2837
|
-
} else if (method === "getConnectorAction") {
|
|
2838
|
-
result = await agent.getConnectorAction(
|
|
2839
|
-
input.serviceId,
|
|
2840
|
-
input.actionId
|
|
2841
|
-
);
|
|
2842
|
-
} else if (method === "listConnections") {
|
|
2843
|
-
result = await agent.listConnections();
|
|
2844
|
-
} else if (method === "estimateStepCost") {
|
|
2845
|
-
result = await agent.estimateStepCost(
|
|
2846
|
-
input.stepType,
|
|
2847
|
-
input.step,
|
|
2848
|
-
{
|
|
2849
|
-
appId: input.appId,
|
|
2850
|
-
workflowId: input.workflowId
|
|
2851
|
-
}
|
|
2938
|
+
const { stepMetadata: stepMetadata2 } = await Promise.resolve().then(() => (init_metadata(), metadata_exports));
|
|
2939
|
+
const meta = stepMetadata2[method];
|
|
2940
|
+
if (!meta) {
|
|
2941
|
+
fatal(
|
|
2942
|
+
`Unknown action: ${method}. Run 'mindstudio list-actions' to see available actions.`
|
|
2852
2943
|
);
|
|
2853
|
-
} else if (method === "changeName") {
|
|
2854
|
-
await agent.changeName(input.displayName);
|
|
2855
|
-
result = { success: true };
|
|
2856
|
-
} else if (method === "changeProfilePicture") {
|
|
2857
|
-
await agent.changeProfilePicture(input.profilePictureUrl);
|
|
2858
|
-
result = { success: true };
|
|
2859
|
-
} else {
|
|
2860
|
-
const { stepMetadata: stepMetadata2 } = await Promise.resolve().then(() => (init_metadata(), metadata_exports));
|
|
2861
|
-
const meta = stepMetadata2[method];
|
|
2862
|
-
if (!meta) {
|
|
2863
|
-
fatal(
|
|
2864
|
-
`Unknown method: ${method}. Run 'mindstudio list' to see available methods.`
|
|
2865
|
-
);
|
|
2866
|
-
}
|
|
2867
|
-
result = await agent.executeStep(meta.stepType, input, {
|
|
2868
|
-
appId: options.appId,
|
|
2869
|
-
threadId: options.threadId
|
|
2870
|
-
});
|
|
2871
2944
|
}
|
|
2945
|
+
const result = await agent.executeStep(meta.stepType, input, {
|
|
2946
|
+
appId: options.appId,
|
|
2947
|
+
threadId: options.threadId
|
|
2948
|
+
});
|
|
2872
2949
|
if (options.outputKey) {
|
|
2873
2950
|
const val = result[options.outputKey];
|
|
2874
2951
|
if (typeof val === "string") {
|
|
@@ -2915,6 +2992,62 @@ async function cmdAgents(asJson, options) {
|
|
|
2915
2992
|
}
|
|
2916
2993
|
}
|
|
2917
2994
|
}
|
|
2995
|
+
function createAgent(options) {
|
|
2996
|
+
return Promise.resolve().then(() => (init_client(), client_exports)).then(
|
|
2997
|
+
({ MindStudioAgent: MindStudioAgent2 }) => new MindStudioAgent2({
|
|
2998
|
+
apiKey: options.apiKey,
|
|
2999
|
+
baseUrl: options.baseUrl
|
|
3000
|
+
})
|
|
3001
|
+
);
|
|
3002
|
+
}
|
|
3003
|
+
function jsonOut(data) {
|
|
3004
|
+
process.stdout.write(JSON.stringify(data, null, 2) + "\n");
|
|
3005
|
+
}
|
|
3006
|
+
async function cmdListModels(options) {
|
|
3007
|
+
const agent = await createAgent(options);
|
|
3008
|
+
if (options.summary) {
|
|
3009
|
+
const result = options.type ? await agent.listModelsSummaryByType(options.type) : await agent.listModelsSummary();
|
|
3010
|
+
jsonOut(result);
|
|
3011
|
+
} else {
|
|
3012
|
+
const result = options.type ? await agent.listModelsByType(options.type) : await agent.listModels();
|
|
3013
|
+
jsonOut(result);
|
|
3014
|
+
}
|
|
3015
|
+
}
|
|
3016
|
+
async function cmdListConnectors(args, options) {
|
|
3017
|
+
const agent = await createAgent(options);
|
|
3018
|
+
if (args.length >= 2) {
|
|
3019
|
+
const result = await agent.getConnectorAction(args[0], args[1]);
|
|
3020
|
+
jsonOut(result);
|
|
3021
|
+
} else if (args.length === 1) {
|
|
3022
|
+
const result = await agent.getConnector(args[0]);
|
|
3023
|
+
jsonOut(result);
|
|
3024
|
+
} else {
|
|
3025
|
+
const result = await agent.listConnectors();
|
|
3026
|
+
jsonOut(result);
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
3029
|
+
async function cmdListConnections(options) {
|
|
3030
|
+
const agent = await createAgent(options);
|
|
3031
|
+
const result = await agent.listConnections();
|
|
3032
|
+
jsonOut(result);
|
|
3033
|
+
}
|
|
3034
|
+
async function cmdEstimateStepCost(method, input, options) {
|
|
3035
|
+
const agent = await createAgent(options);
|
|
3036
|
+
const result = await agent.estimateStepCost(method, input);
|
|
3037
|
+
jsonOut(result);
|
|
3038
|
+
}
|
|
3039
|
+
async function cmdChangeName(name, options) {
|
|
3040
|
+
const agent = await createAgent(options);
|
|
3041
|
+
await agent.changeName(name);
|
|
3042
|
+
process.stderr.write(` Display name updated to: ${name}
|
|
3043
|
+
`);
|
|
3044
|
+
}
|
|
3045
|
+
async function cmdChangeProfilePicture(url, options) {
|
|
3046
|
+
const agent = await createAgent(options);
|
|
3047
|
+
await agent.changeProfilePicture(url);
|
|
3048
|
+
process.stderr.write(` Profile picture updated.
|
|
3049
|
+
`);
|
|
3050
|
+
}
|
|
2918
3051
|
async function cmdRun(appId, variables, options) {
|
|
2919
3052
|
const { MindStudioAgent: MindStudioAgent2 } = await Promise.resolve().then(() => (init_client(), client_exports));
|
|
2920
3053
|
const agent = new MindStudioAgent2({
|
|
@@ -2945,6 +3078,52 @@ async function cmdRun(appId, variables, options) {
|
|
|
2945
3078
|
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
2946
3079
|
}
|
|
2947
3080
|
}
|
|
3081
|
+
async function cmdBatch(input, options) {
|
|
3082
|
+
if (!Array.isArray(input)) {
|
|
3083
|
+
fatal(
|
|
3084
|
+
`Batch input must be a JSON array of { stepType, step } objects.
|
|
3085
|
+
Example: mindstudio batch '[{"stepType":"generateImage","step":{"prompt":"a cat"}}]'`
|
|
3086
|
+
);
|
|
3087
|
+
}
|
|
3088
|
+
for (let i = 0; i < input.length; i++) {
|
|
3089
|
+
const item = input[i];
|
|
3090
|
+
if (!item || typeof item !== "object" || !item.stepType || !item.step) {
|
|
3091
|
+
fatal(
|
|
3092
|
+
`Invalid step at index ${i}: each entry must have "stepType" and "step" fields.`
|
|
3093
|
+
);
|
|
3094
|
+
}
|
|
3095
|
+
}
|
|
3096
|
+
const { stepMetadata: stepMetadata2 } = await Promise.resolve().then(() => (init_metadata(), metadata_exports));
|
|
3097
|
+
const metaByName = new Map(
|
|
3098
|
+
Object.entries(stepMetadata2).map(([name, m]) => [name, m])
|
|
3099
|
+
);
|
|
3100
|
+
const steps = input.map(
|
|
3101
|
+
(item, i) => {
|
|
3102
|
+
let meta = metaByName.get(item.stepType);
|
|
3103
|
+
if (!meta) {
|
|
3104
|
+
const camel = item.stepType.replace(
|
|
3105
|
+
/-([a-z])/g,
|
|
3106
|
+
(_, c) => c.toUpperCase()
|
|
3107
|
+
);
|
|
3108
|
+
meta = metaByName.get(camel);
|
|
3109
|
+
}
|
|
3110
|
+
if (meta) {
|
|
3111
|
+
return { stepType: meta.stepType, step: item.step };
|
|
3112
|
+
}
|
|
3113
|
+
return { stepType: item.stepType, step: item.step };
|
|
3114
|
+
}
|
|
3115
|
+
);
|
|
3116
|
+
const agent = await createAgent(options);
|
|
3117
|
+
const result = await agent.executeStepBatch(steps, {
|
|
3118
|
+
appId: options.appId,
|
|
3119
|
+
threadId: options.threadId
|
|
3120
|
+
});
|
|
3121
|
+
if (options.noMeta) {
|
|
3122
|
+
process.stdout.write(JSON.stringify(result.results, null, 2) + "\n");
|
|
3123
|
+
} else {
|
|
3124
|
+
process.stdout.write(JSON.stringify(result, null, 2) + "\n");
|
|
3125
|
+
}
|
|
3126
|
+
}
|
|
2948
3127
|
var MIME_TYPES2 = {
|
|
2949
3128
|
png: "image/png",
|
|
2950
3129
|
jpg: "image/jpeg",
|
|
@@ -2967,9 +3146,6 @@ async function cmdUpload(filePath, options) {
|
|
|
2967
3146
|
const content = readFileSync3(filePath);
|
|
2968
3147
|
const mimeType = MIME_TYPES2[ext];
|
|
2969
3148
|
const { MindStudioAgent: MindStudioAgent2 } = await Promise.resolve().then(() => (init_client(), client_exports));
|
|
2970
|
-
await Promise.resolve().then(() => (init_helpers(), helpers_exports)).then(
|
|
2971
|
-
(m) => m.applyHelperMethods(MindStudioAgent2)
|
|
2972
|
-
);
|
|
2973
3149
|
const agent = new MindStudioAgent2({
|
|
2974
3150
|
apiKey: options.apiKey,
|
|
2975
3151
|
baseUrl: options.baseUrl
|
|
@@ -3003,7 +3179,7 @@ function isNewerVersion(current, latest) {
|
|
|
3003
3179
|
return false;
|
|
3004
3180
|
}
|
|
3005
3181
|
async function checkForUpdate() {
|
|
3006
|
-
const currentVersion = "0.1.
|
|
3182
|
+
const currentVersion = "0.1.6";
|
|
3007
3183
|
if (!currentVersion) return null;
|
|
3008
3184
|
try {
|
|
3009
3185
|
const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
@@ -3032,7 +3208,7 @@ async function checkForUpdate() {
|
|
|
3032
3208
|
}
|
|
3033
3209
|
}
|
|
3034
3210
|
function printUpdateNotice(latestVersion) {
|
|
3035
|
-
const currentVersion = "0.1.
|
|
3211
|
+
const currentVersion = "0.1.6";
|
|
3036
3212
|
process.stderr.write(
|
|
3037
3213
|
`
|
|
3038
3214
|
${ansi.cyanBright("Update available")} ${ansi.gray(currentVersion + " \u2192")} ${ansi.cyanBold(latestVersion)}
|
|
@@ -3103,10 +3279,11 @@ var SPINNER_FRAMES = [
|
|
|
3103
3279
|
];
|
|
3104
3280
|
async function cmdLogin(options) {
|
|
3105
3281
|
const baseUrl = options.baseUrl ?? process.env.MINDSTUDIO_BASE_URL ?? process.env.REMOTE_HOSTNAME ?? DEFAULT_BASE_URL2;
|
|
3282
|
+
process.stderr.write("\x1B[2J\x1B[H");
|
|
3106
3283
|
process.stderr.write("\n");
|
|
3107
3284
|
printLogo();
|
|
3108
3285
|
process.stderr.write("\n");
|
|
3109
|
-
const ver = "0.1.
|
|
3286
|
+
const ver = "0.1.6";
|
|
3110
3287
|
process.stderr.write(
|
|
3111
3288
|
` ${ansi.bold("MindStudio Agent")} ${ver ? " " + ansi.gray("v" + ver) : ""}
|
|
3112
3289
|
`
|
|
@@ -3255,11 +3432,62 @@ async function cmdWhoami(options) {
|
|
|
3255
3432
|
apiKey: options.apiKey,
|
|
3256
3433
|
baseUrl: options.baseUrl
|
|
3257
3434
|
});
|
|
3258
|
-
const
|
|
3435
|
+
const info = await agent.getUserInfo();
|
|
3436
|
+
process.stderr.write(
|
|
3437
|
+
`\r\x1B[K ${ansi.greenBold("\u25CF")} ${ansi.green("Connected")}
|
|
3438
|
+
|
|
3439
|
+
`
|
|
3440
|
+
);
|
|
3441
|
+
process.stderr.write(` ${ansi.bold("User")}
|
|
3442
|
+
`);
|
|
3443
|
+
process.stderr.write(
|
|
3444
|
+
` ${ansi.gray("Name:")} ${info.displayName}
|
|
3445
|
+
`
|
|
3446
|
+
);
|
|
3447
|
+
process.stderr.write(
|
|
3448
|
+
` ${ansi.gray("ID:")} ${ansi.gray(info.userId)}
|
|
3449
|
+
`
|
|
3450
|
+
);
|
|
3451
|
+
process.stderr.write(`
|
|
3452
|
+
${ansi.bold("Organization")}
|
|
3453
|
+
`);
|
|
3454
|
+
process.stderr.write(
|
|
3455
|
+
` ${ansi.gray("Name:")} ${info.organizationName}
|
|
3456
|
+
`
|
|
3457
|
+
);
|
|
3259
3458
|
process.stderr.write(
|
|
3260
|
-
|
|
3459
|
+
` ${ansi.gray("ID:")} ${ansi.gray(info.organizationId)}
|
|
3261
3460
|
`
|
|
3262
3461
|
);
|
|
3462
|
+
if (info.members && info.members.length > 0) {
|
|
3463
|
+
process.stderr.write(`
|
|
3464
|
+
${ansi.bold("Members")}
|
|
3465
|
+
`);
|
|
3466
|
+
const nameWidth = Math.max(
|
|
3467
|
+
4,
|
|
3468
|
+
...info.members.map((m) => m.displayName.length)
|
|
3469
|
+
);
|
|
3470
|
+
const roleWidth = Math.max(
|
|
3471
|
+
4,
|
|
3472
|
+
...info.members.map((m) => m.role.length)
|
|
3473
|
+
);
|
|
3474
|
+
process.stderr.write(
|
|
3475
|
+
` ${ansi.gray("Name".padEnd(nameWidth))} ${ansi.gray("Role".padEnd(roleWidth))} ${ansi.gray("Type")}
|
|
3476
|
+
`
|
|
3477
|
+
);
|
|
3478
|
+
process.stderr.write(
|
|
3479
|
+
` ${ansi.gray("\u2500".repeat(nameWidth))} ${ansi.gray("\u2500".repeat(roleWidth))} ${ansi.gray("\u2500".repeat(5))}
|
|
3480
|
+
`
|
|
3481
|
+
);
|
|
3482
|
+
for (const member of info.members) {
|
|
3483
|
+
const type = member.isAgent ? ansi.cyan("agent") : "user";
|
|
3484
|
+
process.stderr.write(
|
|
3485
|
+
` ${member.displayName.padEnd(nameWidth)} ${ansi.gray(member.role.padEnd(roleWidth))} ${type}
|
|
3486
|
+
`
|
|
3487
|
+
);
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
process.stderr.write("\n");
|
|
3263
3491
|
} catch (err) {
|
|
3264
3492
|
const message = err instanceof Error ? err.message : String(err);
|
|
3265
3493
|
process.stderr.write(
|
|
@@ -3290,15 +3518,15 @@ var GLOBAL_STRING_FLAGS = /* @__PURE__ */ new Set([
|
|
|
3290
3518
|
]);
|
|
3291
3519
|
function findMethodSplit(argv) {
|
|
3292
3520
|
let startIdx = 0;
|
|
3293
|
-
let
|
|
3521
|
+
let hasRun = false;
|
|
3294
3522
|
for (let i = 0; i < argv.length; i++) {
|
|
3295
3523
|
const arg = argv[i];
|
|
3296
3524
|
if (arg.startsWith("--")) {
|
|
3297
3525
|
if (GLOBAL_STRING_FLAGS.has(arg)) i++;
|
|
3298
3526
|
continue;
|
|
3299
3527
|
}
|
|
3300
|
-
if (arg === "
|
|
3301
|
-
|
|
3528
|
+
if (arg === "run") {
|
|
3529
|
+
hasRun = true;
|
|
3302
3530
|
startIdx = i + 1;
|
|
3303
3531
|
} else {
|
|
3304
3532
|
startIdx = i;
|
|
@@ -3311,7 +3539,7 @@ function findMethodSplit(argv) {
|
|
|
3311
3539
|
if (GLOBAL_STRING_FLAGS.has(arg)) i++;
|
|
3312
3540
|
continue;
|
|
3313
3541
|
}
|
|
3314
|
-
if (
|
|
3542
|
+
if (hasRun || i === startIdx) {
|
|
3315
3543
|
return { rawMethod: arg, stepArgv: argv.slice(i + 1) };
|
|
3316
3544
|
}
|
|
3317
3545
|
break;
|
|
@@ -3332,6 +3560,7 @@ async function main() {
|
|
|
3332
3560
|
"no-meta": { type: "boolean", default: false },
|
|
3333
3561
|
workflow: { type: "string" },
|
|
3334
3562
|
version: { type: "string" },
|
|
3563
|
+
type: { type: "string" },
|
|
3335
3564
|
json: { type: "boolean", default: false },
|
|
3336
3565
|
summary: { type: "boolean", default: false },
|
|
3337
3566
|
help: { type: "boolean", default: false }
|
|
@@ -3376,7 +3605,7 @@ async function main() {
|
|
|
3376
3605
|
});
|
|
3377
3606
|
return;
|
|
3378
3607
|
}
|
|
3379
|
-
if (command === "list") {
|
|
3608
|
+
if (command === "list-actions") {
|
|
3380
3609
|
await cmdList(values.json, values.summary);
|
|
3381
3610
|
return;
|
|
3382
3611
|
}
|
|
@@ -3387,11 +3616,83 @@ async function main() {
|
|
|
3387
3616
|
});
|
|
3388
3617
|
return;
|
|
3389
3618
|
}
|
|
3390
|
-
if (command === "
|
|
3619
|
+
if (command === "batch") {
|
|
3620
|
+
let input2;
|
|
3621
|
+
const firstArg = positionals[1];
|
|
3622
|
+
if (firstArg && firstArg.startsWith("[")) {
|
|
3623
|
+
try {
|
|
3624
|
+
input2 = parseJson5(firstArg);
|
|
3625
|
+
} catch {
|
|
3626
|
+
fatal(`Invalid JSON input: ${firstArg}`);
|
|
3627
|
+
}
|
|
3628
|
+
} else if (!process.stdin.isTTY) {
|
|
3629
|
+
const raw = (await readStdin()).trim();
|
|
3630
|
+
if (raw) {
|
|
3631
|
+
try {
|
|
3632
|
+
input2 = parseJson5(raw);
|
|
3633
|
+
} catch {
|
|
3634
|
+
fatal(`Invalid JSON on stdin: ${raw}`);
|
|
3635
|
+
}
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
if (input2 === void 0) {
|
|
3639
|
+
usageBlock([
|
|
3640
|
+
"batch \u2014 Execute multiple actions in parallel",
|
|
3641
|
+
"",
|
|
3642
|
+
"Usage:",
|
|
3643
|
+
` mindstudio batch '[{ "stepType": "<action>", "step": { ... } }, ...]'`,
|
|
3644
|
+
" cat steps.json | mindstudio batch",
|
|
3645
|
+
"",
|
|
3646
|
+
'Each entry needs "stepType" (action name) and "step" (input object).',
|
|
3647
|
+
"Maximum 50 steps per batch. Results come back in the same order.",
|
|
3648
|
+
"Individual failures don't affect other steps.",
|
|
3649
|
+
"",
|
|
3650
|
+
"Options:",
|
|
3651
|
+
" --app-id <id> App ID for thread context",
|
|
3652
|
+
" --thread-id <id> Thread ID for state persistence",
|
|
3653
|
+
" --no-meta Strip top-level metadata from output",
|
|
3654
|
+
"",
|
|
3655
|
+
"Examples:",
|
|
3656
|
+
" mindstudio batch '[",
|
|
3657
|
+
' { "stepType": "generateImage", "step": { "prompt": "a sunset" } },',
|
|
3658
|
+
' { "stepType": "textToSpeech", "step": { "text": "hello world" } }',
|
|
3659
|
+
" ]'",
|
|
3660
|
+
"",
|
|
3661
|
+
` echo '[{"stepType":"searchGoogle","step":{"query":"cats"}}]' | mindstudio batch`
|
|
3662
|
+
]);
|
|
3663
|
+
}
|
|
3664
|
+
await cmdBatch(input2, {
|
|
3665
|
+
apiKey: values["api-key"],
|
|
3666
|
+
baseUrl: values["base-url"],
|
|
3667
|
+
appId: values["app-id"],
|
|
3668
|
+
threadId: values["thread-id"],
|
|
3669
|
+
noMeta: values["no-meta"]
|
|
3670
|
+
});
|
|
3671
|
+
return;
|
|
3672
|
+
}
|
|
3673
|
+
if (command === "run-agent") {
|
|
3391
3674
|
const appId = positionals[1];
|
|
3392
3675
|
if (!appId)
|
|
3393
|
-
|
|
3394
|
-
|
|
3676
|
+
usageBlock([
|
|
3677
|
+
"run-agent \u2014 Run a pre-built agent and wait for the result",
|
|
3678
|
+
"",
|
|
3679
|
+
"Usage:",
|
|
3680
|
+
" mindstudio run-agent <appId> [json | --flags]",
|
|
3681
|
+
"",
|
|
3682
|
+
"Options:",
|
|
3683
|
+
" --workflow <name> Workflow to execute (default: app default)",
|
|
3684
|
+
' --version <ver> App version, e.g. "draft" (default: "live")',
|
|
3685
|
+
" --output-key <key> Extract a single field from the result",
|
|
3686
|
+
" --no-meta Strip metadata from output",
|
|
3687
|
+
"",
|
|
3688
|
+
"Examples:",
|
|
3689
|
+
' mindstudio run-agent abc123 --query "hello"',
|
|
3690
|
+
` mindstudio run-agent abc123 '{"query": "hello"}'`,
|
|
3691
|
+
" mindstudio run-agent abc123 --workflow summarize --version draft",
|
|
3692
|
+
"",
|
|
3693
|
+
'Tip: run "mindstudio agents" to list available agent IDs.'
|
|
3694
|
+
]);
|
|
3695
|
+
const runArgv = process.argv.slice(process.argv.indexOf("run-agent") + 2);
|
|
3395
3696
|
const stepArgs = [];
|
|
3396
3697
|
for (let i = 0; i < runArgv.length; i++) {
|
|
3397
3698
|
const arg = runArgv[i];
|
|
@@ -3439,13 +3740,145 @@ async function main() {
|
|
|
3439
3740
|
if (command === "upload") {
|
|
3440
3741
|
const filePath = positionals[1];
|
|
3441
3742
|
if (!filePath)
|
|
3442
|
-
|
|
3743
|
+
usageBlock([
|
|
3744
|
+
"upload \u2014 Upload a file to the MindStudio CDN",
|
|
3745
|
+
"",
|
|
3746
|
+
"Usage:",
|
|
3747
|
+
" mindstudio upload <filepath>",
|
|
3748
|
+
"",
|
|
3749
|
+
"Returns the permanent public URL for the uploaded file.",
|
|
3750
|
+
"",
|
|
3751
|
+
"Examples:",
|
|
3752
|
+
" mindstudio upload photo.png",
|
|
3753
|
+
" mindstudio upload /path/to/document.pdf"
|
|
3754
|
+
]);
|
|
3443
3755
|
await cmdUpload(filePath, {
|
|
3444
3756
|
apiKey: values["api-key"],
|
|
3445
3757
|
baseUrl: values["base-url"]
|
|
3446
3758
|
});
|
|
3447
3759
|
return;
|
|
3448
3760
|
}
|
|
3761
|
+
if (command === "list-models" || command === "list-models-by-type" || command === "list-models-summary" || command === "list-models-summary-by-type") {
|
|
3762
|
+
const authOpts = {
|
|
3763
|
+
apiKey: values["api-key"],
|
|
3764
|
+
baseUrl: values["base-url"]
|
|
3765
|
+
};
|
|
3766
|
+
let type;
|
|
3767
|
+
let summary = false;
|
|
3768
|
+
if (command === "list-models-by-type" || command === "list-models-summary-by-type") {
|
|
3769
|
+
type = positionals[1];
|
|
3770
|
+
if (!type)
|
|
3771
|
+
usageBlock([
|
|
3772
|
+
`${command} \u2014 List AI models filtered by type`,
|
|
3773
|
+
"",
|
|
3774
|
+
"Usage:",
|
|
3775
|
+
` mindstudio ${command} <type>`,
|
|
3776
|
+
"",
|
|
3777
|
+
"Types:",
|
|
3778
|
+
" llm_chat, image_generation, video_generation,",
|
|
3779
|
+
" video_analysis, text_to_speech, vision, transcription",
|
|
3780
|
+
"",
|
|
3781
|
+
"Examples:",
|
|
3782
|
+
` mindstudio ${command} image_generation`,
|
|
3783
|
+
` mindstudio ${command} llm_chat`
|
|
3784
|
+
]);
|
|
3785
|
+
}
|
|
3786
|
+
if (command === "list-models-summary" || command === "list-models-summary-by-type") {
|
|
3787
|
+
summary = true;
|
|
3788
|
+
}
|
|
3789
|
+
if (command === "list-models") {
|
|
3790
|
+
const typeFlag = values.type;
|
|
3791
|
+
if (typeFlag) type = typeFlag;
|
|
3792
|
+
if (values.summary) summary = true;
|
|
3793
|
+
}
|
|
3794
|
+
await cmdListModels({ ...authOpts, type, summary });
|
|
3795
|
+
return;
|
|
3796
|
+
}
|
|
3797
|
+
if (command === "list-connectors") {
|
|
3798
|
+
await cmdListConnectors(positionals.slice(1), {
|
|
3799
|
+
apiKey: values["api-key"],
|
|
3800
|
+
baseUrl: values["base-url"]
|
|
3801
|
+
});
|
|
3802
|
+
return;
|
|
3803
|
+
}
|
|
3804
|
+
if (command === "list-connections") {
|
|
3805
|
+
await cmdListConnections({
|
|
3806
|
+
apiKey: values["api-key"],
|
|
3807
|
+
baseUrl: values["base-url"]
|
|
3808
|
+
});
|
|
3809
|
+
return;
|
|
3810
|
+
}
|
|
3811
|
+
if (command === "estimate-cost") {
|
|
3812
|
+
const stepMethod = positionals[1];
|
|
3813
|
+
if (!stepMethod)
|
|
3814
|
+
usageBlock([
|
|
3815
|
+
"estimate-cost \u2014 Estimate the cost of an action before running it",
|
|
3816
|
+
"",
|
|
3817
|
+
"Usage:",
|
|
3818
|
+
" mindstudio estimate-cost <action> [json | --flags]",
|
|
3819
|
+
"",
|
|
3820
|
+
"Examples:",
|
|
3821
|
+
' mindstudio estimate-cost generate-image --prompt "a sunset"',
|
|
3822
|
+
` mindstudio estimate-cost generate-text '{"message": "hello"}'`,
|
|
3823
|
+
"",
|
|
3824
|
+
'Tip: run "mindstudio list-actions" to see available actions.'
|
|
3825
|
+
]);
|
|
3826
|
+
const costArgv = positionals.slice(2);
|
|
3827
|
+
let costInput;
|
|
3828
|
+
const firstArg = costArgv[0];
|
|
3829
|
+
if (firstArg && firstArg.startsWith("{")) {
|
|
3830
|
+
try {
|
|
3831
|
+
costInput = parseJson5(firstArg);
|
|
3832
|
+
} catch {
|
|
3833
|
+
fatal(`Invalid JSON input: ${firstArg}`);
|
|
3834
|
+
}
|
|
3835
|
+
} else {
|
|
3836
|
+
costInput = parseStepFlags(costArgv);
|
|
3837
|
+
}
|
|
3838
|
+
await cmdEstimateStepCost(stepMethod, costInput, {
|
|
3839
|
+
apiKey: values["api-key"],
|
|
3840
|
+
baseUrl: values["base-url"]
|
|
3841
|
+
});
|
|
3842
|
+
return;
|
|
3843
|
+
}
|
|
3844
|
+
if (command === "change-name") {
|
|
3845
|
+
const name = positionals[1];
|
|
3846
|
+
if (!name)
|
|
3847
|
+
usageBlock([
|
|
3848
|
+
"change-name \u2014 Update your display name",
|
|
3849
|
+
"",
|
|
3850
|
+
"Usage:",
|
|
3851
|
+
" mindstudio change-name <name>",
|
|
3852
|
+
"",
|
|
3853
|
+
"Examples:",
|
|
3854
|
+
' mindstudio change-name "My Agent"'
|
|
3855
|
+
]);
|
|
3856
|
+
await cmdChangeName(name, {
|
|
3857
|
+
apiKey: values["api-key"],
|
|
3858
|
+
baseUrl: values["base-url"]
|
|
3859
|
+
});
|
|
3860
|
+
return;
|
|
3861
|
+
}
|
|
3862
|
+
if (command === "change-profile-picture") {
|
|
3863
|
+
const url = positionals[1];
|
|
3864
|
+
if (!url)
|
|
3865
|
+
usageBlock([
|
|
3866
|
+
"change-profile-picture \u2014 Update your profile picture",
|
|
3867
|
+
"",
|
|
3868
|
+
"Usage:",
|
|
3869
|
+
" mindstudio change-profile-picture <url>",
|
|
3870
|
+
"",
|
|
3871
|
+
"Examples:",
|
|
3872
|
+
" mindstudio change-profile-picture https://example.com/avatar.png",
|
|
3873
|
+
"",
|
|
3874
|
+
'Tip: use "mindstudio upload" to host an image first.'
|
|
3875
|
+
]);
|
|
3876
|
+
await cmdChangeProfilePicture(url, {
|
|
3877
|
+
apiKey: values["api-key"],
|
|
3878
|
+
baseUrl: values["base-url"]
|
|
3879
|
+
});
|
|
3880
|
+
return;
|
|
3881
|
+
}
|
|
3449
3882
|
if (command === "mcp") {
|
|
3450
3883
|
const { startMcpServer: startMcpServer2 } = await Promise.resolve().then(() => (init_mcp(), mcp_exports));
|
|
3451
3884
|
await startMcpServer2({
|
|
@@ -3457,13 +3890,48 @@ async function main() {
|
|
|
3457
3890
|
if (command === "info") {
|
|
3458
3891
|
const rawMethod2 = positionals[1];
|
|
3459
3892
|
if (!rawMethod2)
|
|
3460
|
-
|
|
3893
|
+
usageBlock([
|
|
3894
|
+
"info \u2014 Show action details and parameters",
|
|
3895
|
+
"",
|
|
3896
|
+
"Usage:",
|
|
3897
|
+
" mindstudio info <action>",
|
|
3898
|
+
"",
|
|
3899
|
+
"Shows the description, input parameters (with types and",
|
|
3900
|
+
"defaults), and output fields for an action.",
|
|
3901
|
+
"",
|
|
3902
|
+
"Examples:",
|
|
3903
|
+
" mindstudio info generate-image",
|
|
3904
|
+
" mindstudio info search-google",
|
|
3905
|
+
"",
|
|
3906
|
+
'Tip: run "mindstudio list-actions" to see available actions.'
|
|
3907
|
+
]);
|
|
3461
3908
|
await cmdInfo(rawMethod2);
|
|
3462
3909
|
return;
|
|
3463
3910
|
}
|
|
3464
3911
|
const split = findMethodSplit(process.argv.slice(2));
|
|
3465
3912
|
if (!split)
|
|
3466
|
-
|
|
3913
|
+
usageBlock([
|
|
3914
|
+
"Run an action directly",
|
|
3915
|
+
"",
|
|
3916
|
+
"Usage:",
|
|
3917
|
+
" mindstudio <action> [json | --flags]",
|
|
3918
|
+
" mindstudio run <action> [json | --flags]",
|
|
3919
|
+
"",
|
|
3920
|
+
"Input can be inline JSON, --flags, or piped via stdin.",
|
|
3921
|
+
"",
|
|
3922
|
+
"Options:",
|
|
3923
|
+
" --app-id <id> App ID for thread context",
|
|
3924
|
+
" --thread-id <id> Thread ID for state persistence",
|
|
3925
|
+
" --output-key <key> Extract a single field from the result",
|
|
3926
|
+
" --no-meta Strip $-prefixed metadata from output",
|
|
3927
|
+
"",
|
|
3928
|
+
"Examples:",
|
|
3929
|
+
' mindstudio generate-image --prompt "a sunset"',
|
|
3930
|
+
` mindstudio search-google '{"query": "cats"}'`,
|
|
3931
|
+
` echo '{"message":"hello"}' | mindstudio generate-text`,
|
|
3932
|
+
"",
|
|
3933
|
+
'Tip: run "mindstudio list-actions" to see available actions.'
|
|
3934
|
+
]);
|
|
3467
3935
|
const { rawMethod, stepArgv } = split;
|
|
3468
3936
|
const allKeys = await getAllMethodKeys();
|
|
3469
3937
|
const method = resolveMethodOrFail(rawMethod, allKeys);
|