@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.
@@ -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- Posts are plain text. Maximum 280 characters.",
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 helper methods. */
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.4"
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 `listSteps` to discover all available step methods and helpers.\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 steps (text generation, image generation, video, audio, etc.) cost money. Before running these, call `estimateStepCost` 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."
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 === "listSteps") {
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 === "estimateStepCost") {
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 and their actions.",
2281
- getConnector: "Get details for a connector service.",
2282
- getConnectorAction: "Get full configuration for a connector action.",
2283
- listConnections: "List OAuth connections for the organization.",
2284
- estimateStepCost: "Estimate the cost of executing a step before running it.",
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: "listSteps",
2294
- description: "List all available methods with their descriptions. Returns a compact { method: description } map. Call this to discover what steps and helpers are available, then call a specific method by name. Tip: if you haven't already, call `changeName` to set your display name first.",
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 a connector action, including all input fields needed to call it via runFromConnectorRegistry.",
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: "estimateStepCost",
2390
- description: "Estimate the cost of executing a step before running it. Pass the same step config you would use for execution.",
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 step type name (e.g. "generateText").'
2560
+ description: 'The action type name (e.g. "generateText").'
2397
2561
  },
2398
2562
  step: {
2399
2563
  type: "object",
2400
- description: "The step input parameters.",
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.",
@@ -2547,6 +2742,10 @@ function fatal(message) {
2547
2742
  process.stderr.write(JSON.stringify({ error: { message } }) + "\n");
2548
2743
  process.exit(1);
2549
2744
  }
2745
+ function usageBlock(lines) {
2746
+ process.stderr.write("\n" + lines.map((l) => " " + l).join("\n") + "\n\n");
2747
+ process.exit(1);
2748
+ }
2550
2749
  async function readStdin() {
2551
2750
  const chunks = [];
2552
2751
  for await (const chunk of process.stdin) {
@@ -2570,21 +2769,18 @@ function resolveMethodOrFail(name, metadataKeys) {
2570
2769
  }
2571
2770
  const suggestion = bestDist <= 3 ? ` Did you mean '${bestMatch}'?` : "";
2572
2771
  fatal(
2573
- `Unknown method: ${name}.${suggestion} Run 'mindstudio list' to see available methods.`
2772
+ `Unknown action: ${name}.${suggestion} Run 'mindstudio list-actions' to see available actions.`
2574
2773
  );
2575
2774
  }
2576
2775
  async function getAllMethodKeys() {
2577
2776
  const { stepMetadata: stepMetadata2 } = await Promise.resolve().then(() => (init_metadata(), metadata_exports));
2578
- return /* @__PURE__ */ new Set([...Object.keys(stepMetadata2), ...HELPER_NAMES]);
2777
+ return new Set(Object.keys(stepMetadata2));
2579
2778
  }
2580
2779
  function buildSummary(stepMetadata2) {
2581
2780
  const summary = {};
2582
2781
  for (const [name, meta] of Object.entries(stepMetadata2)) {
2583
2782
  summary[name] = meta.description;
2584
2783
  }
2585
- for (const [name, desc] of Object.entries(HELPER_DESCRIPTIONS2)) {
2586
- summary[name] = desc;
2587
- }
2588
2784
  return summary;
2589
2785
  }
2590
2786
  async function cmdList(asJson, asSummary) {
@@ -2619,79 +2815,6 @@ async function cmdList(asJson, asSummary) {
2619
2815
  async function cmdInfo(rawMethod) {
2620
2816
  const allKeys = await getAllMethodKeys();
2621
2817
  const method = resolveMethodOrFail(rawMethod, allKeys);
2622
- if (HELPER_NAMES.has(method)) {
2623
- const helpers = {
2624
- listModels: {
2625
- desc: "List all available AI models.",
2626
- input: "(none)",
2627
- output: "{ models: MindStudioModel[] }"
2628
- },
2629
- listModelsByType: {
2630
- desc: "List AI models filtered by type.",
2631
- input: "modelType: string (required)",
2632
- output: "{ models: MindStudioModel[] }"
2633
- },
2634
- listModelsSummary: {
2635
- desc: "List all AI models (summary: id, name, type, tags).",
2636
- input: "(none)",
2637
- output: "{ models: MindStudioModelSummary[] }"
2638
- },
2639
- listModelsSummaryByType: {
2640
- desc: "List AI models (summary) filtered by type.",
2641
- input: "modelType: string (required)",
2642
- output: "{ models: MindStudioModelSummary[] }"
2643
- },
2644
- listConnectors: {
2645
- desc: "List available connector services and their actions.",
2646
- input: "(none)",
2647
- output: "{ services: ConnectorService[] }"
2648
- },
2649
- getConnector: {
2650
- desc: "Get details for a connector service.",
2651
- input: "serviceId: string (required)",
2652
- output: "{ service: ConnectorService }"
2653
- },
2654
- getConnectorAction: {
2655
- desc: "Get full configuration for a connector action.",
2656
- input: "serviceId: string, actionId: string (both required)",
2657
- output: "{ action: ConnectorActionDetail }"
2658
- },
2659
- listConnections: {
2660
- desc: "List OAuth connections for the organization.",
2661
- input: "(none)",
2662
- output: "{ connections: Connection[] }"
2663
- },
2664
- estimateStepCost: {
2665
- desc: "Estimate the cost of executing a step before running it.",
2666
- input: "stepType: string (required), step: object, appId?: string, workflowId?: string",
2667
- output: "{ costType?: string, estimates?: StepCostEstimateEntry[] }"
2668
- },
2669
- changeName: {
2670
- desc: "Update the display name of the authenticated agent.",
2671
- input: "displayName: string (required)",
2672
- output: "(none)"
2673
- },
2674
- changeProfilePicture: {
2675
- desc: "Update the profile picture of the authenticated agent.",
2676
- input: "profilePictureUrl: string (required)",
2677
- output: "(none)"
2678
- }
2679
- };
2680
- const h = helpers[method];
2681
- process.stderr.write(`
2682
- ${camelToKebab(method)}
2683
-
2684
- `);
2685
- process.stderr.write(` ${h.desc}
2686
-
2687
- `);
2688
- process.stderr.write(` Input: ${h.input}
2689
- `);
2690
- process.stderr.write(` Output: ${h.output}
2691
-
2692
- `);
2693
- return;
2694
- }
2695
2818
  const { stepMetadata: stepMetadata2 } = await Promise.resolve().then(() => (init_metadata(), metadata_exports));
2696
2819
  const meta = stepMetadata2[method];
2697
2820
  const out = [];
@@ -2747,61 +2870,21 @@ async function cmdExec(method, input, options) {
2747
2870
  await Promise.resolve().then(() => (init_steps(), steps_exports)).then(
2748
2871
  (m) => m.applyStepMethods(MindStudioAgent2)
2749
2872
  );
2750
- await Promise.resolve().then(() => (init_helpers(), helpers_exports)).then(
2751
- (m) => m.applyHelperMethods(MindStudioAgent2)
2752
- );
2753
2873
  const agent = new MindStudioAgent2({
2754
2874
  apiKey: options.apiKey,
2755
2875
  baseUrl: options.baseUrl
2756
2876
  });
2757
- let result;
2758
- if (method === "listModels") {
2759
- result = await agent.listModels();
2760
- } else if (method === "listModelsByType") {
2761
- result = await agent.listModelsByType(input.modelType);
2762
- } else if (method === "listModelsSummary") {
2763
- result = await agent.listModelsSummary();
2764
- } else if (method === "listModelsSummaryByType") {
2765
- result = await agent.listModelsSummaryByType(input.modelType);
2766
- } else if (method === "listConnectors") {
2767
- result = await agent.listConnectors();
2768
- } else if (method === "getConnector") {
2769
- result = await agent.getConnector(input.serviceId);
2770
- } else if (method === "getConnectorAction") {
2771
- result = await agent.getConnectorAction(
2772
- input.serviceId,
2773
- input.actionId
2774
- );
2775
- } else if (method === "listConnections") {
2776
- result = await agent.listConnections();
2777
- } else if (method === "estimateStepCost") {
2778
- result = await agent.estimateStepCost(
2779
- input.stepType,
2780
- input.step,
2781
- {
2782
- appId: input.appId,
2783
- workflowId: input.workflowId
2784
- }
2877
+ const { stepMetadata: stepMetadata2 } = await Promise.resolve().then(() => (init_metadata(), metadata_exports));
2878
+ const meta = stepMetadata2[method];
2879
+ if (!meta) {
2880
+ fatal(
2881
+ `Unknown action: ${method}. Run 'mindstudio list-actions' to see available actions.`
2785
2882
  );
2786
- } else if (method === "changeName") {
2787
- await agent.changeName(input.displayName);
2788
- result = { success: true };
2789
- } else if (method === "changeProfilePicture") {
2790
- await agent.changeProfilePicture(input.profilePictureUrl);
2791
- result = { success: true };
2792
- } else {
2793
- const { stepMetadata: stepMetadata2 } = await Promise.resolve().then(() => (init_metadata(), metadata_exports));
2794
- const meta = stepMetadata2[method];
2795
- if (!meta) {
2796
- fatal(
2797
- `Unknown method: ${method}. Run 'mindstudio list' to see available methods.`
2798
- );
2799
- }
2800
- result = await agent.executeStep(meta.stepType, input, {
2801
- appId: options.appId,
2802
- threadId: options.threadId
2803
- });
2804
2883
  }
2884
+ const result = await agent.executeStep(meta.stepType, input, {
2885
+ appId: options.appId,
2886
+ threadId: options.threadId
2887
+ });
2805
2888
  if (options.outputKey) {
2806
2889
  const val = result[options.outputKey];
2807
2890
  if (typeof val === "string") {
@@ -2848,6 +2931,62 @@ async function cmdAgents(asJson, options) {
2848
2931
  }
2849
2932
  }
2850
2933
  }
2934
+ function createAgent(options) {
2935
+ return Promise.resolve().then(() => (init_client(), client_exports)).then(
2936
+ ({ MindStudioAgent: MindStudioAgent2 }) => new MindStudioAgent2({
2937
+ apiKey: options.apiKey,
2938
+ baseUrl: options.baseUrl
2939
+ })
2940
+ );
2941
+ }
2942
+ function jsonOut(data) {
2943
+ process.stdout.write(JSON.stringify(data, null, 2) + "\n");
2944
+ }
2945
+ async function cmdListModels(options) {
2946
+ const agent = await createAgent(options);
2947
+ if (options.summary) {
2948
+ const result = options.type ? await agent.listModelsSummaryByType(options.type) : await agent.listModelsSummary();
2949
+ jsonOut(result);
2950
+ } else {
2951
+ const result = options.type ? await agent.listModelsByType(options.type) : await agent.listModels();
2952
+ jsonOut(result);
2953
+ }
2954
+ }
2955
+ async function cmdListConnectors(args, options) {
2956
+ const agent = await createAgent(options);
2957
+ if (args.length >= 2) {
2958
+ const result = await agent.getConnectorAction(args[0], args[1]);
2959
+ jsonOut(result);
2960
+ } else if (args.length === 1) {
2961
+ const result = await agent.getConnector(args[0]);
2962
+ jsonOut(result);
2963
+ } else {
2964
+ const result = await agent.listConnectors();
2965
+ jsonOut(result);
2966
+ }
2967
+ }
2968
+ async function cmdListConnections(options) {
2969
+ const agent = await createAgent(options);
2970
+ const result = await agent.listConnections();
2971
+ jsonOut(result);
2972
+ }
2973
+ async function cmdEstimateStepCost(method, input, options) {
2974
+ const agent = await createAgent(options);
2975
+ const result = await agent.estimateStepCost(method, input);
2976
+ jsonOut(result);
2977
+ }
2978
+ async function cmdChangeName(name, options) {
2979
+ const agent = await createAgent(options);
2980
+ await agent.changeName(name);
2981
+ process.stderr.write(` Display name updated to: ${name}
2982
+ `);
2983
+ }
2984
+ async function cmdChangeProfilePicture(url, options) {
2985
+ const agent = await createAgent(options);
2986
+ await agent.changeProfilePicture(url);
2987
+ process.stderr.write(` Profile picture updated.
2988
+ `);
2989
+ }
2851
2990
  async function cmdRun(appId, variables, options) {
2852
2991
  const { MindStudioAgent: MindStudioAgent2 } = await Promise.resolve().then(() => (init_client(), client_exports));
2853
2992
  const agent = new MindStudioAgent2({
@@ -2878,15 +3017,58 @@ async function cmdRun(appId, variables, options) {
2878
3017
  process.stdout.write(JSON.stringify(result, null, 2) + "\n");
2879
3018
  }
2880
3019
  }
3020
+ async function cmdBatch(input, options) {
3021
+ if (!Array.isArray(input)) {
3022
+ fatal(
3023
+ `Batch input must be a JSON array of { stepType, step } objects.
3024
+ Example: mindstudio batch '[{"stepType":"generateImage","step":{"prompt":"a cat"}}]'`
3025
+ );
3026
+ }
3027
+ for (let i = 0; i < input.length; i++) {
3028
+ const item = input[i];
3029
+ if (!item || typeof item !== "object" || !item.stepType || !item.step) {
3030
+ fatal(
3031
+ `Invalid step at index ${i}: each entry must have "stepType" and "step" fields.`
3032
+ );
3033
+ }
3034
+ }
3035
+ const { stepMetadata: stepMetadata2 } = await Promise.resolve().then(() => (init_metadata(), metadata_exports));
3036
+ const metaByName = new Map(
3037
+ Object.entries(stepMetadata2).map(([name, m]) => [name, m])
3038
+ );
3039
+ const steps = input.map(
3040
+ (item, i) => {
3041
+ let meta = metaByName.get(item.stepType);
3042
+ if (!meta) {
3043
+ const camel = item.stepType.replace(
3044
+ /-([a-z])/g,
3045
+ (_, c) => c.toUpperCase()
3046
+ );
3047
+ meta = metaByName.get(camel);
3048
+ }
3049
+ if (meta) {
3050
+ return { stepType: meta.stepType, step: item.step };
3051
+ }
3052
+ return { stepType: item.stepType, step: item.step };
3053
+ }
3054
+ );
3055
+ const agent = await createAgent(options);
3056
+ const result = await agent.executeStepBatch(steps, {
3057
+ appId: options.appId,
3058
+ threadId: options.threadId
3059
+ });
3060
+ if (options.noMeta) {
3061
+ process.stdout.write(JSON.stringify(result.results, null, 2) + "\n");
3062
+ } else {
3063
+ process.stdout.write(JSON.stringify(result, null, 2) + "\n");
3064
+ }
3065
+ }
2881
3066
  async function cmdUpload(filePath, options) {
2882
3067
  const ext = extname2(filePath).slice(1).toLowerCase();
2883
3068
  if (!ext) fatal("Cannot determine file extension. Please provide a file with an extension.");
2884
3069
  const content = readFileSync3(filePath);
2885
3070
  const mimeType = MIME_TYPES2[ext];
2886
3071
  const { MindStudioAgent: MindStudioAgent2 } = await Promise.resolve().then(() => (init_client(), client_exports));
2887
- await Promise.resolve().then(() => (init_helpers(), helpers_exports)).then(
2888
- (m) => m.applyHelperMethods(MindStudioAgent2)
2889
- );
2890
3072
  const agent = new MindStudioAgent2({
2891
3073
  apiKey: options.apiKey,
2892
3074
  baseUrl: options.baseUrl
@@ -2909,7 +3091,7 @@ function isNewerVersion(current, latest) {
2909
3091
  return false;
2910
3092
  }
2911
3093
  async function checkForUpdate() {
2912
- const currentVersion = "0.1.4";
3094
+ const currentVersion = "0.1.6";
2913
3095
  if (!currentVersion) return null;
2914
3096
  try {
2915
3097
  const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
@@ -2938,7 +3120,7 @@ async function checkForUpdate() {
2938
3120
  }
2939
3121
  }
2940
3122
  function printUpdateNotice(latestVersion) {
2941
- const currentVersion = "0.1.4";
3123
+ const currentVersion = "0.1.6";
2942
3124
  process.stderr.write(
2943
3125
  `
2944
3126
  ${ansi.cyanBright("Update available")} ${ansi.gray(currentVersion + " \u2192")} ${ansi.cyanBold(latestVersion)}
@@ -2989,10 +3171,11 @@ function maskKey(key) {
2989
3171
  }
2990
3172
  async function cmdLogin(options) {
2991
3173
  const baseUrl = options.baseUrl ?? process.env.MINDSTUDIO_BASE_URL ?? process.env.REMOTE_HOSTNAME ?? DEFAULT_BASE_URL2;
3174
+ process.stderr.write("\x1B[2J\x1B[H");
2992
3175
  process.stderr.write("\n");
2993
3176
  printLogo();
2994
3177
  process.stderr.write("\n");
2995
- const ver = "0.1.4";
3178
+ const ver = "0.1.6";
2996
3179
  process.stderr.write(
2997
3180
  ` ${ansi.bold("MindStudio Agent")} ${ver ? " " + ansi.gray("v" + ver) : ""}
2998
3181
  `
@@ -3141,11 +3324,62 @@ async function cmdWhoami(options) {
3141
3324
  apiKey: options.apiKey,
3142
3325
  baseUrl: options.baseUrl
3143
3326
  });
3144
- const result = await agent.listAgents();
3327
+ const info = await agent.getUserInfo();
3145
3328
  process.stderr.write(
3146
- `\r\x1B[K ${ansi.greenBold("\u25CF")} ${ansi.green("Connected")} ${ansi.gray("\u2014")} ${result.orgName} ${ansi.gray("(" + result.orgId + ")")}
3329
+ `\r\x1B[K ${ansi.greenBold("\u25CF")} ${ansi.green("Connected")}
3330
+
3147
3331
  `
3148
3332
  );
3333
+ process.stderr.write(` ${ansi.bold("User")}
3334
+ `);
3335
+ process.stderr.write(
3336
+ ` ${ansi.gray("Name:")} ${info.displayName}
3337
+ `
3338
+ );
3339
+ process.stderr.write(
3340
+ ` ${ansi.gray("ID:")} ${ansi.gray(info.userId)}
3341
+ `
3342
+ );
3343
+ process.stderr.write(`
3344
+ ${ansi.bold("Organization")}
3345
+ `);
3346
+ process.stderr.write(
3347
+ ` ${ansi.gray("Name:")} ${info.organizationName}
3348
+ `
3349
+ );
3350
+ process.stderr.write(
3351
+ ` ${ansi.gray("ID:")} ${ansi.gray(info.organizationId)}
3352
+ `
3353
+ );
3354
+ if (info.members && info.members.length > 0) {
3355
+ process.stderr.write(`
3356
+ ${ansi.bold("Members")}
3357
+ `);
3358
+ const nameWidth = Math.max(
3359
+ 4,
3360
+ ...info.members.map((m) => m.displayName.length)
3361
+ );
3362
+ const roleWidth = Math.max(
3363
+ 4,
3364
+ ...info.members.map((m) => m.role.length)
3365
+ );
3366
+ process.stderr.write(
3367
+ ` ${ansi.gray("Name".padEnd(nameWidth))} ${ansi.gray("Role".padEnd(roleWidth))} ${ansi.gray("Type")}
3368
+ `
3369
+ );
3370
+ process.stderr.write(
3371
+ ` ${ansi.gray("\u2500".repeat(nameWidth))} ${ansi.gray("\u2500".repeat(roleWidth))} ${ansi.gray("\u2500".repeat(5))}
3372
+ `
3373
+ );
3374
+ for (const member of info.members) {
3375
+ const type = member.isAgent ? ansi.cyan("agent") : "user";
3376
+ process.stderr.write(
3377
+ ` ${member.displayName.padEnd(nameWidth)} ${ansi.gray(member.role.padEnd(roleWidth))} ${type}
3378
+ `
3379
+ );
3380
+ }
3381
+ }
3382
+ process.stderr.write("\n");
3149
3383
  } catch (err) {
3150
3384
  const message = err instanceof Error ? err.message : String(err);
3151
3385
  process.stderr.write(
@@ -3167,15 +3401,15 @@ function parseStepFlags(argv) {
3167
3401
  }
3168
3402
  function findMethodSplit(argv) {
3169
3403
  let startIdx = 0;
3170
- let hasExec = false;
3404
+ let hasRun = false;
3171
3405
  for (let i = 0; i < argv.length; i++) {
3172
3406
  const arg = argv[i];
3173
3407
  if (arg.startsWith("--")) {
3174
3408
  if (GLOBAL_STRING_FLAGS.has(arg)) i++;
3175
3409
  continue;
3176
3410
  }
3177
- if (arg === "exec") {
3178
- hasExec = true;
3411
+ if (arg === "run") {
3412
+ hasRun = true;
3179
3413
  startIdx = i + 1;
3180
3414
  } else {
3181
3415
  startIdx = i;
@@ -3188,7 +3422,7 @@ function findMethodSplit(argv) {
3188
3422
  if (GLOBAL_STRING_FLAGS.has(arg)) i++;
3189
3423
  continue;
3190
3424
  }
3191
- if (hasExec || i === startIdx) {
3425
+ if (hasRun || i === startIdx) {
3192
3426
  return { rawMethod: arg, stepArgv: argv.slice(i + 1) };
3193
3427
  }
3194
3428
  break;
@@ -3209,6 +3443,7 @@ async function main() {
3209
3443
  "no-meta": { type: "boolean", default: false },
3210
3444
  workflow: { type: "string" },
3211
3445
  version: { type: "string" },
3446
+ type: { type: "string" },
3212
3447
  json: { type: "boolean", default: false },
3213
3448
  summary: { type: "boolean", default: false },
3214
3449
  help: { type: "boolean", default: false }
@@ -3253,7 +3488,7 @@ async function main() {
3253
3488
  });
3254
3489
  return;
3255
3490
  }
3256
- if (command === "list") {
3491
+ if (command === "list-actions") {
3257
3492
  await cmdList(values.json, values.summary);
3258
3493
  return;
3259
3494
  }
@@ -3264,11 +3499,83 @@ async function main() {
3264
3499
  });
3265
3500
  return;
3266
3501
  }
3267
- if (command === "run") {
3502
+ if (command === "batch") {
3503
+ let input2;
3504
+ const firstArg = positionals[1];
3505
+ if (firstArg && firstArg.startsWith("[")) {
3506
+ try {
3507
+ input2 = parseJson5(firstArg);
3508
+ } catch {
3509
+ fatal(`Invalid JSON input: ${firstArg}`);
3510
+ }
3511
+ } else if (!process.stdin.isTTY) {
3512
+ const raw = (await readStdin()).trim();
3513
+ if (raw) {
3514
+ try {
3515
+ input2 = parseJson5(raw);
3516
+ } catch {
3517
+ fatal(`Invalid JSON on stdin: ${raw}`);
3518
+ }
3519
+ }
3520
+ }
3521
+ if (input2 === void 0) {
3522
+ usageBlock([
3523
+ "batch \u2014 Execute multiple actions in parallel",
3524
+ "",
3525
+ "Usage:",
3526
+ ` mindstudio batch '[{ "stepType": "<action>", "step": { ... } }, ...]'`,
3527
+ " cat steps.json | mindstudio batch",
3528
+ "",
3529
+ 'Each entry needs "stepType" (action name) and "step" (input object).',
3530
+ "Maximum 50 steps per batch. Results come back in the same order.",
3531
+ "Individual failures don't affect other steps.",
3532
+ "",
3533
+ "Options:",
3534
+ " --app-id <id> App ID for thread context",
3535
+ " --thread-id <id> Thread ID for state persistence",
3536
+ " --no-meta Strip top-level metadata from output",
3537
+ "",
3538
+ "Examples:",
3539
+ " mindstudio batch '[",
3540
+ ' { "stepType": "generateImage", "step": { "prompt": "a sunset" } },',
3541
+ ' { "stepType": "textToSpeech", "step": { "text": "hello world" } }',
3542
+ " ]'",
3543
+ "",
3544
+ ` echo '[{"stepType":"searchGoogle","step":{"query":"cats"}}]' | mindstudio batch`
3545
+ ]);
3546
+ }
3547
+ await cmdBatch(input2, {
3548
+ apiKey: values["api-key"],
3549
+ baseUrl: values["base-url"],
3550
+ appId: values["app-id"],
3551
+ threadId: values["thread-id"],
3552
+ noMeta: values["no-meta"]
3553
+ });
3554
+ return;
3555
+ }
3556
+ if (command === "run-agent") {
3268
3557
  const appId = positionals[1];
3269
3558
  if (!appId)
3270
- fatal("Missing app ID. Usage: mindstudio run <appId> [json | --flags]");
3271
- const runArgv = process.argv.slice(process.argv.indexOf("run") + 2);
3559
+ usageBlock([
3560
+ "run-agent \u2014 Run a pre-built agent and wait for the result",
3561
+ "",
3562
+ "Usage:",
3563
+ " mindstudio run-agent <appId> [json | --flags]",
3564
+ "",
3565
+ "Options:",
3566
+ " --workflow <name> Workflow to execute (default: app default)",
3567
+ ' --version <ver> App version, e.g. "draft" (default: "live")',
3568
+ " --output-key <key> Extract a single field from the result",
3569
+ " --no-meta Strip metadata from output",
3570
+ "",
3571
+ "Examples:",
3572
+ ' mindstudio run-agent abc123 --query "hello"',
3573
+ ` mindstudio run-agent abc123 '{"query": "hello"}'`,
3574
+ " mindstudio run-agent abc123 --workflow summarize --version draft",
3575
+ "",
3576
+ 'Tip: run "mindstudio agents" to list available agent IDs.'
3577
+ ]);
3578
+ const runArgv = process.argv.slice(process.argv.indexOf("run-agent") + 2);
3272
3579
  const stepArgs = [];
3273
3580
  for (let i = 0; i < runArgv.length; i++) {
3274
3581
  const arg = runArgv[i];
@@ -3316,13 +3623,145 @@ async function main() {
3316
3623
  if (command === "upload") {
3317
3624
  const filePath = positionals[1];
3318
3625
  if (!filePath)
3319
- fatal("Missing file path. Usage: mindstudio upload <filepath>");
3626
+ usageBlock([
3627
+ "upload \u2014 Upload a file to the MindStudio CDN",
3628
+ "",
3629
+ "Usage:",
3630
+ " mindstudio upload <filepath>",
3631
+ "",
3632
+ "Returns the permanent public URL for the uploaded file.",
3633
+ "",
3634
+ "Examples:",
3635
+ " mindstudio upload photo.png",
3636
+ " mindstudio upload /path/to/document.pdf"
3637
+ ]);
3320
3638
  await cmdUpload(filePath, {
3321
3639
  apiKey: values["api-key"],
3322
3640
  baseUrl: values["base-url"]
3323
3641
  });
3324
3642
  return;
3325
3643
  }
3644
+ if (command === "list-models" || command === "list-models-by-type" || command === "list-models-summary" || command === "list-models-summary-by-type") {
3645
+ const authOpts = {
3646
+ apiKey: values["api-key"],
3647
+ baseUrl: values["base-url"]
3648
+ };
3649
+ let type;
3650
+ let summary = false;
3651
+ if (command === "list-models-by-type" || command === "list-models-summary-by-type") {
3652
+ type = positionals[1];
3653
+ if (!type)
3654
+ usageBlock([
3655
+ `${command} \u2014 List AI models filtered by type`,
3656
+ "",
3657
+ "Usage:",
3658
+ ` mindstudio ${command} <type>`,
3659
+ "",
3660
+ "Types:",
3661
+ " llm_chat, image_generation, video_generation,",
3662
+ " video_analysis, text_to_speech, vision, transcription",
3663
+ "",
3664
+ "Examples:",
3665
+ ` mindstudio ${command} image_generation`,
3666
+ ` mindstudio ${command} llm_chat`
3667
+ ]);
3668
+ }
3669
+ if (command === "list-models-summary" || command === "list-models-summary-by-type") {
3670
+ summary = true;
3671
+ }
3672
+ if (command === "list-models") {
3673
+ const typeFlag = values.type;
3674
+ if (typeFlag) type = typeFlag;
3675
+ if (values.summary) summary = true;
3676
+ }
3677
+ await cmdListModels({ ...authOpts, type, summary });
3678
+ return;
3679
+ }
3680
+ if (command === "list-connectors") {
3681
+ await cmdListConnectors(positionals.slice(1), {
3682
+ apiKey: values["api-key"],
3683
+ baseUrl: values["base-url"]
3684
+ });
3685
+ return;
3686
+ }
3687
+ if (command === "list-connections") {
3688
+ await cmdListConnections({
3689
+ apiKey: values["api-key"],
3690
+ baseUrl: values["base-url"]
3691
+ });
3692
+ return;
3693
+ }
3694
+ if (command === "estimate-cost") {
3695
+ const stepMethod = positionals[1];
3696
+ if (!stepMethod)
3697
+ usageBlock([
3698
+ "estimate-cost \u2014 Estimate the cost of an action before running it",
3699
+ "",
3700
+ "Usage:",
3701
+ " mindstudio estimate-cost <action> [json | --flags]",
3702
+ "",
3703
+ "Examples:",
3704
+ ' mindstudio estimate-cost generate-image --prompt "a sunset"',
3705
+ ` mindstudio estimate-cost generate-text '{"message": "hello"}'`,
3706
+ "",
3707
+ 'Tip: run "mindstudio list-actions" to see available actions.'
3708
+ ]);
3709
+ const costArgv = positionals.slice(2);
3710
+ let costInput;
3711
+ const firstArg = costArgv[0];
3712
+ if (firstArg && firstArg.startsWith("{")) {
3713
+ try {
3714
+ costInput = parseJson5(firstArg);
3715
+ } catch {
3716
+ fatal(`Invalid JSON input: ${firstArg}`);
3717
+ }
3718
+ } else {
3719
+ costInput = parseStepFlags(costArgv);
3720
+ }
3721
+ await cmdEstimateStepCost(stepMethod, costInput, {
3722
+ apiKey: values["api-key"],
3723
+ baseUrl: values["base-url"]
3724
+ });
3725
+ return;
3726
+ }
3727
+ if (command === "change-name") {
3728
+ const name = positionals[1];
3729
+ if (!name)
3730
+ usageBlock([
3731
+ "change-name \u2014 Update your display name",
3732
+ "",
3733
+ "Usage:",
3734
+ " mindstudio change-name <name>",
3735
+ "",
3736
+ "Examples:",
3737
+ ' mindstudio change-name "My Agent"'
3738
+ ]);
3739
+ await cmdChangeName(name, {
3740
+ apiKey: values["api-key"],
3741
+ baseUrl: values["base-url"]
3742
+ });
3743
+ return;
3744
+ }
3745
+ if (command === "change-profile-picture") {
3746
+ const url = positionals[1];
3747
+ if (!url)
3748
+ usageBlock([
3749
+ "change-profile-picture \u2014 Update your profile picture",
3750
+ "",
3751
+ "Usage:",
3752
+ " mindstudio change-profile-picture <url>",
3753
+ "",
3754
+ "Examples:",
3755
+ " mindstudio change-profile-picture https://example.com/avatar.png",
3756
+ "",
3757
+ 'Tip: use "mindstudio upload" to host an image first.'
3758
+ ]);
3759
+ await cmdChangeProfilePicture(url, {
3760
+ apiKey: values["api-key"],
3761
+ baseUrl: values["base-url"]
3762
+ });
3763
+ return;
3764
+ }
3326
3765
  if (command === "mcp") {
3327
3766
  const { startMcpServer: startMcpServer2 } = await Promise.resolve().then(() => (init_mcp(), mcp_exports));
3328
3767
  await startMcpServer2({
@@ -3334,13 +3773,48 @@ async function main() {
3334
3773
  if (command === "info") {
3335
3774
  const rawMethod2 = positionals[1];
3336
3775
  if (!rawMethod2)
3337
- fatal("Missing method name. Usage: mindstudio info <method>");
3776
+ usageBlock([
3777
+ "info \u2014 Show action details and parameters",
3778
+ "",
3779
+ "Usage:",
3780
+ " mindstudio info <action>",
3781
+ "",
3782
+ "Shows the description, input parameters (with types and",
3783
+ "defaults), and output fields for an action.",
3784
+ "",
3785
+ "Examples:",
3786
+ " mindstudio info generate-image",
3787
+ " mindstudio info search-google",
3788
+ "",
3789
+ 'Tip: run "mindstudio list-actions" to see available actions.'
3790
+ ]);
3338
3791
  await cmdInfo(rawMethod2);
3339
3792
  return;
3340
3793
  }
3341
3794
  const split = findMethodSplit(process.argv.slice(2));
3342
3795
  if (!split)
3343
- fatal("Missing method name. Usage: mindstudio <method> [json | --flags]");
3796
+ usageBlock([
3797
+ "Run an action directly",
3798
+ "",
3799
+ "Usage:",
3800
+ " mindstudio <action> [json | --flags]",
3801
+ " mindstudio run <action> [json | --flags]",
3802
+ "",
3803
+ "Input can be inline JSON, --flags, or piped via stdin.",
3804
+ "",
3805
+ "Options:",
3806
+ " --app-id <id> App ID for thread context",
3807
+ " --thread-id <id> Thread ID for state persistence",
3808
+ " --output-key <key> Extract a single field from the result",
3809
+ " --no-meta Strip $-prefixed metadata from output",
3810
+ "",
3811
+ "Examples:",
3812
+ ' mindstudio generate-image --prompt "a sunset"',
3813
+ ` mindstudio search-google '{"query": "cats"}'`,
3814
+ ` echo '{"message":"hello"}' | mindstudio generate-text`,
3815
+ "",
3816
+ 'Tip: run "mindstudio list-actions" to see available actions.'
3817
+ ]);
3344
3818
  const { rawMethod, stepArgv } = split;
3345
3819
  const allKeys = await getAllMethodKeys();
3346
3820
  const method = resolveMethodOrFail(rawMethod, allKeys);
@@ -3383,78 +3857,72 @@ async function main() {
3383
3857
  if (latestVersion) printUpdateNotice(latestVersion);
3384
3858
  }
3385
3859
  }
3386
- var HELP, HELPER_NAMES, HELPER_DESCRIPTIONS2, MIME_TYPES2, ansi, UPDATE_CHECK_INTERVAL, LOGO, DEFAULT_BASE_URL2, SPINNER_FRAMES, GLOBAL_STRING_FLAGS;
3860
+ var HELP, MIME_TYPES2, ansi, UPDATE_CHECK_INTERVAL, LOGO, DEFAULT_BASE_URL2, SPINNER_FRAMES, GLOBAL_STRING_FLAGS;
3387
3861
  var init_cli = __esm({
3388
3862
  "src/cli.ts"() {
3389
3863
  "use strict";
3390
- HELP = `Usage: mindstudio <command | method> [options]
3864
+ HELP = `Usage: mindstudio <command> [options]
3865
+
3866
+ Run actions:
3867
+ <action> [json | --flags] Run an action directly
3868
+ run <action> [json | --flags] Run an action (explicit form)
3869
+ estimate-cost <action> [json] Estimate cost before running
3870
+
3871
+ Discover:
3872
+ list-actions [--json] [--summary] List all available actions
3873
+ info <action> Show action details and parameters
3874
+ list-models [--type <t>] [--summary] List available AI models
3875
+
3876
+ Batch:
3877
+ batch [json] Execute multiple actions in parallel
3878
+
3879
+ Pre-built agents:
3880
+ agents [--json] List agents in your organization
3881
+ run-agent <appId> [json | --flags] Run an agent and wait for result
3882
+
3883
+ Account:
3884
+ login Authenticate with MindStudio
3885
+ logout Clear stored credentials
3886
+ whoami Show current user and organization
3887
+ change-name <name> Update your display name
3888
+ change-profile-picture <url> Update your profile picture
3889
+ upload <filepath> Upload a file to the MindStudio CDN
3890
+
3891
+ OAuth integrations:
3892
+ list-connectors [<id> [<actionId>]] Browse OAuth connector services
3893
+ list-connections List your OAuth connections
3391
3894
 
3392
- Commands:
3393
- login Authenticate with MindStudio (opens browser)
3394
- logout Clear stored credentials
3395
- whoami Show current authentication status
3396
- upload <filepath> Upload a file to the MindStudio CDN
3397
- <method> [json | --flags] Execute a step method (shorthand for exec)
3398
- exec <method> [json | --flags] Execute a step method
3399
- list [--json] [--summary] List available methods (--summary for compact JSON)
3400
- info <method> Show method details (params, types, output)
3401
- agents [--json] List pre-built agents in your organization
3402
- run <appId> [json | --flags] Run a pre-built agent and wait for result
3403
- mcp Start MCP server (JSON-RPC over stdio)
3895
+ Other:
3896
+ mcp Start MCP server (JSON-RPC over stdio)
3404
3897
 
3405
3898
  Options:
3406
- --api-key <key> API key (or set MINDSTUDIO_API_KEY env)
3407
- --base-url <url> API base URL
3408
- --app-id <id> App ID for thread context
3409
- --thread-id <id> Thread ID for state persistence
3410
- --output-key <key> Extract a single field from the result
3411
- --no-meta Strip $-prefixed metadata from output
3412
- --workflow <name> Workflow to execute (run command)
3413
- --version <ver> App version override, e.g. "draft" (run command)
3414
- --json Output as JSON (list/agents only)
3415
- --help Show this help
3899
+ --api-key <key> API key (or set MINDSTUDIO_API_KEY env var)
3900
+ --base-url <url> API base URL override
3901
+ --app-id <id> App ID for thread context
3902
+ --thread-id <id> Thread ID for state persistence
3903
+ --output-key <key> Extract a single field from the result
3904
+ --no-meta Strip $-prefixed metadata from output
3905
+ --workflow <name> Workflow to execute (run-agent only)
3906
+ --version <ver> App version, e.g. "draft" (run-agent only)
3907
+ --json Output as JSON
3908
+ --summary Compact output (list-actions, list-models)
3909
+ --type <type> Filter by model type (list-models)
3910
+ --help Show this help
3416
3911
 
3417
3912
  Examples:
3418
- mindstudio login
3419
3913
  mindstudio generate-image --prompt "a sunset"
3420
- mindstudio generate-image --prompt "a sunset" --output-key imageUrl
3421
3914
  mindstudio generate-text --message "hello" --no-meta
3422
- mindstudio generate-image '{"prompt":"a sunset"}'
3915
+ mindstudio generate-image '{"prompt":"a sunset"}' --output-key imageUrl
3423
3916
  echo '{"query":"test"}' | mindstudio search-google
3917
+ mindstudio estimate-cost generate-image --prompt "a sunset"
3918
+ mindstudio list-actions --summary
3424
3919
  mindstudio info generate-image
3425
- mindstudio list --json
3920
+ mindstudio list-models --type image_generation
3921
+ mindstudio batch '[{"stepType":"generateImage","step":{"prompt":"a cat"}}]'
3922
+ mindstudio run-agent <appId> --query "hello"
3426
3923
  mindstudio agents
3427
- mindstudio run <appId> --query "hello"
3428
3924
  mindstudio mcp
3429
3925
  `;
3430
- HELPER_NAMES = /* @__PURE__ */ new Set([
3431
- "listModels",
3432
- "listModelsByType",
3433
- "listModelsSummary",
3434
- "listModelsSummaryByType",
3435
- "listConnectors",
3436
- "getConnector",
3437
- "getConnectorAction",
3438
- "listConnections",
3439
- "estimateStepCost",
3440
- "changeName",
3441
- "changeProfilePicture"
3442
- ]);
3443
- HELPER_DESCRIPTIONS2 = {
3444
- listModels: "List all available AI models.",
3445
- listModelsByType: "List AI models filtered by type.",
3446
- listModelsSummary: "List all AI models (summary: id, name, type, tags).",
3447
- listModelsSummaryByType: "List AI models (summary) filtered by type.",
3448
- listConnectors: "List available connector services and their actions.",
3449
- getConnector: "Get details for a connector service.",
3450
- getConnectorAction: "Get full configuration for a connector action.",
3451
- listConnections: "List OAuth connections for the organization.",
3452
- estimateStepCost: "Estimate the cost of executing a step before running it.",
3453
- changeName: "Update the display name of the authenticated agent.",
3454
- changeProfilePicture: "Update the profile picture of the authenticated agent.",
3455
- listAgents: "List all pre-built agents in the organization.",
3456
- runAgent: "Run a pre-built agent and wait for the result."
3457
- };
3458
3926
  MIME_TYPES2 = {
3459
3927
  png: "image/png",
3460
3928
  jpg: "image/jpeg",