@mindstudio-ai/agent 0.0.20 → 0.1.1

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 CHANGED
@@ -1,8 +1,10 @@
1
1
  # @mindstudio-ai/agent
2
2
 
3
- TypeScript SDK, CLI, and MCP server for executing [MindStudio](https://mindstudio.ai) workflow steps directly.
3
+ Every AI model. Every integration. One SDK.
4
4
 
5
- Call any of MindStudio's 120+ built-in actions AI models, image/video generation, web scraping, integrations, and more with fully typed inputs and outputs. Use from TypeScript, the command line, or any MCP-compatible AI agent.
5
+ [MindStudio](https://mindstudio.ai) gives you direct access to 200+ AI models and [1,000+ integrations](https://github.com/mindstudio-ai/mscr) no separate API keys, no setup, no friction. This package is the developer toolkit: a TypeScript SDK, CLI, and MCP server that puts the entire platform at your fingertips.
6
+
7
+ Generate text, images, video, and audio. Scrape the web. Search Google. Post to Slack. Read from Airtable. Send emails. Process media. Run any of 850+ connector actions across third-party services. All with one API key, fully typed, and ready to use from code, the command line, or any MCP-compatible AI agent.
6
8
 
7
9
  ## Install
8
10
 
@@ -21,27 +23,24 @@ import { MindStudioAgent } from '@mindstudio-ai/agent';
21
23
 
22
24
  const agent = new MindStudioAgent({ apiKey: 'your-api-key' });
23
25
 
24
- // Generate text with an AI model
26
+ // Generate text with any AI model — OpenAI, Anthropic, Google, and more
25
27
  const { content } = await agent.generateText({
26
28
  message: 'Summarize this article: ...',
27
29
  });
28
- console.log(content);
29
30
 
30
31
  // Generate an image
31
32
  const { imageUrl } = await agent.generateImage({
32
33
  prompt: 'A mountain landscape at sunset',
33
34
  });
34
- console.log(imageUrl);
35
35
 
36
36
  // Search Google
37
37
  const { results } = await agent.searchGoogle({
38
38
  query: 'TypeScript best practices',
39
39
  exportType: 'json',
40
40
  });
41
- console.log(results);
42
41
  ```
43
42
 
44
- Every method is fully typed — your editor will autocomplete available parameters, show enum options, and infer the output shape. Results are returned flat for easy destructuring.
43
+ Every method is fully typed — your editor will autocomplete parameters, show enum options, and infer the output shape. Results are returned flat for easy destructuring.
45
44
 
46
45
  ### CLI
47
46
 
@@ -49,13 +48,13 @@ Every method is fully typed — your editor will autocomplete available paramete
49
48
  # Authenticate (opens browser, saves key locally)
50
49
  mindstudio login
51
50
 
52
- # Execute a step with named flags
51
+ # Execute with named flags
53
52
  mindstudio generate-image --prompt "A mountain landscape at sunset"
54
53
 
55
- # Or with JSON input (JSON5-tolerant: unquoted keys, single quotes, trailing commas)
54
+ # Or with JSON input (JSON5-tolerant)
56
55
  mindstudio generate-image '{prompt: "A mountain landscape at sunset"}'
57
56
 
58
- # Just the image URL, no metadata
57
+ # Extract a single output field
59
58
  mindstudio generate-image --prompt "A sunset" --output-key imageUrl
60
59
 
61
60
  # List all available methods
@@ -68,7 +67,7 @@ mindstudio info generate-image
68
67
  echo '{"query": "TypeScript best practices"}' | mindstudio search-google
69
68
  ```
70
69
 
71
- Run via `npx` without installing globally:
70
+ Run via `npx` without installing:
72
71
 
73
72
  ```bash
74
73
  npx @mindstudio-ai/agent generate-text --message "Hello"
@@ -92,19 +91,19 @@ Add to your MCP client config (Claude Code, Cursor, VS Code, etc.):
92
91
  }
93
92
  ```
94
93
 
95
- All 120+ step methods are exposed as MCP tools with full JSON Schema input definitions, so your AI agent can discover and call them directly. The MCP server also exposes `listAgents` and `runAgent` tools for running pre-built agents.
94
+ Every action is exposed as an MCP tool with full JSON Schema definitions your AI agent can discover and call any of them directly.
96
95
 
97
96
  ## Authentication
98
97
 
99
- The fastest way to authenticate is the interactive login:
98
+ The fastest way to get started:
100
99
 
101
100
  ```bash
102
101
  mindstudio login
103
102
  ```
104
103
 
105
- This opens your browser, authenticates with MindStudio, and saves your API key to `~/.mindstudio/config.json`. All subsequent CLI and SDK usage will pick it up automatically.
104
+ Opens your browser, authenticates with MindStudio, and saves your API key to `~/.mindstudio/config.json`. All subsequent usage picks it up automatically.
106
105
 
107
- You can also authenticate via environment variable or constructor parameter:
106
+ You can also authenticate via environment variable or constructor:
108
107
 
109
108
  ```typescript
110
109
  // Pass directly
@@ -115,88 +114,76 @@ const agent = new MindStudioAgent({ apiKey: 'your-api-key' });
115
114
  const agent = new MindStudioAgent();
116
115
  ```
117
116
 
118
- MindStudio routes to the correct AI provider (OpenAI, Google, Anthropic, etc.) server-side — you do not need separate provider API keys.
117
+ One API key is all you need. MindStudio routes to the correct AI provider (OpenAI, Google, Anthropic, Meta, xAI, DeepSeek, etc.) server-side — no separate provider keys required.
119
118
 
120
119
  Other auth commands:
121
120
 
122
121
  ```bash
123
- # Check current auth status and verify credentials
124
- mindstudio whoami
125
-
126
- # Clear stored credentials
127
- mindstudio logout
122
+ mindstudio whoami # Check current auth status
123
+ mindstudio logout # Clear stored credentials
128
124
  ```
129
125
 
130
126
  Resolution order: constructor `apiKey` > `MINDSTUDIO_API_KEY` env > `~/.mindstudio/config.json` > `CALLBACK_TOKEN` env.
131
127
 
132
- ## Thread persistence
128
+ ## 200+ AI models
133
129
 
134
- Steps execute within threads. Pass `$threadId` and `$appId` from a previous call to maintain state across calls:
130
+ Direct access to models from every major provider all through a single API key, billed at cost with no markups.
135
131
 
136
132
  ```typescript
137
- const r1 = await agent.generateText({
138
- message: 'My name is Alice',
139
- });
140
-
141
- // The model remembers the conversation
142
- const r2 = await agent.generateText(
143
- { message: 'What is my name?' },
144
- { threadId: r1.$threadId, appId: r1.$appId },
145
- );
146
- ```
133
+ // Browse available models
134
+ const { models } = await agent.listModelsSummary();
147
135
 
148
- ### Automatic thread reuse
149
-
150
- For local debugging or scripts where you want all calls to share a single thread (similar to how MindStudio custom function sandboxes work), enable `reuseThreadId`:
151
-
152
- ```typescript
153
- const agent = new MindStudioAgent({ reuseThreadId: true });
136
+ // Filter by type
137
+ const { models: imageModels } = await agent.listModelsSummaryByType('image_generation');
154
138
 
155
- // Or set the environment variable
156
- // MINDSTUDIO_REUSE_THREAD_ID=true
139
+ // Use a specific model
140
+ const { models: chatModels } = await agent.listModelsByType('llm_chat');
141
+ const gemini = chatModels.find(m => m.name.includes('Gemini'));
157
142
 
158
- await agent.generateText({ message: 'My name is Alice' }); // creates a thread
159
- await agent.generateText({ message: 'What is my name?' }); // reuses the same thread automatically
143
+ const { content } = await agent.generateText({
144
+ message: 'Hello',
145
+ modelOverride: {
146
+ model: gemini.id,
147
+ temperature: 0.7,
148
+ maxResponseTokens: 1024,
149
+ },
150
+ });
160
151
  ```
161
152
 
162
- The thread ID from the first response is captured and sent with all subsequent calls. You can still override it per-call by passing an explicit `threadId` in the options.
163
-
164
- ## Rate limiting
165
-
166
- Rate limiting is handled automatically:
153
+ Model types: `llm_chat`, `image_generation`, `video_generation`, `video_analysis`, `text_to_speech`, `vision`, `transcription`.
167
154
 
168
- - **Concurrency queue** — requests beyond the server's concurrent limit are queued and proceed as slots open up (10 for internal tokens, 20 for API keys)
169
- - **Auto-retry on 429** — rate-limited responses are retried automatically using the `Retry-After` header (default: 3 retries, configurable via `maxRetries`)
170
- - **Call cap** — internal tokens are capped at 500 calls per execution; the SDK throws `MindStudioError` with code `call_cap_exceeded` rather than sending requests that will fail
155
+ ## 1,000+ integrations
171
156
 
172
- Every result includes `$rateLimitRemaining` so you can throttle proactively:
157
+ 850+ connector actions from the open-source [MindStudio Connector Registry (MSCR)](https://github.com/mindstudio-ai/mscr) — across services like ActiveCampaign, Airtable, Apollo, Canva, ElevenLabs, MailChimp, Notion, and more — alongside 140+ built-in actions for AI, media, web, and data processing.
173
158
 
174
159
  ```typescript
175
- const result = await agent.generateText({ message: 'Hello' });
176
- console.log(result.$rateLimitRemaining); // calls remaining in window
177
- ```
160
+ // Browse connectors and their actions
161
+ const { services } = await agent.listConnectors();
162
+ const { action } = await agent.getConnectorAction('slack', 'slack/send-message');
178
163
 
179
- ## Billing
164
+ // Check which services are connected in your org
165
+ const { connections } = await agent.listConnections();
180
166
 
181
- Every result includes optional billing metadata:
182
-
183
- ```typescript
184
- const result = await agent.generateImage({ prompt: 'A sunset' });
185
- console.log(result.$billingCost); // cost in credits for this call
186
- console.log(result.$billingEvents); // itemized billing events
167
+ // Execute a connector action
168
+ const result = await agent.runFromConnectorRegistry({
169
+ serviceId: 'slack',
170
+ actionId: 'slack/send-message',
171
+ connectionId: 'your-connection-id',
172
+ // ... action-specific fields from getConnectorAction()
173
+ });
187
174
  ```
188
175
 
189
- These fields are `undefined` when the server does not return billing headers.
176
+ Connectors require the user to connect to the third-party service in MindStudio before use. Use `listConnections()` to check what's available.
190
177
 
191
- ## Available steps
178
+ ## Built-in actions
192
179
 
193
- Every step has a dedicated typed method. A few highlights:
180
+ Every action has a dedicated typed method. A few highlights:
194
181
 
195
182
  | Method | Description |
196
183
  | --- | --- |
197
- | `generateText()` | Send a message to an AI model |
198
- | `generateImage()` | Generate an image from a text prompt |
199
- | `generateVideo()` | Generate a video from a text prompt |
184
+ | `generateText()` | Send a message to any AI model |
185
+ | `generateImage()` | Generate an image from a prompt |
186
+ | `generateVideo()` | Generate a video from a prompt |
200
187
  | `generateAsset()` | Generate an HTML/PDF/PNG/video asset |
201
188
  | `analyzeImage()` | Analyze an image with a vision model |
202
189
  | `textToSpeech()` | Convert text to speech |
@@ -206,9 +193,9 @@ Every step has a dedicated typed method. A few highlights:
206
193
  | `httpRequest()` | Make an HTTP request |
207
194
  | `sendEmail()` | Send an email |
208
195
  | `postToSlackChannel()` | Post to a Slack channel |
209
- | `runWorkflow()` | Run another MindStudio workflow |
196
+ | `runPackagedWorkflow()` | Run another MindStudio workflow |
210
197
 
211
- ...and 100+ more for Google Docs/Sheets/Calendar, YouTube, LinkedIn, HubSpot, Airtable, Notion, Coda, Telegram, media processing, PII detection, and more.
198
+ ...and 130+ more for Google Docs/Sheets/Calendar, YouTube, LinkedIn, HubSpot, Airtable, Notion, Coda, Telegram, media processing, PII detection, and more.
212
199
 
213
200
  All methods show full documentation in your editor's IntelliSense — hover any method to see usage notes, parameter descriptions, and enum options.
214
201
 
@@ -239,19 +226,35 @@ const result = await agent.runAgent({
239
226
  });
240
227
  ```
241
228
 
242
- `runAgent()` always uses async mode internally — it submits the run, then polls for the result until it completes or fails. The poll interval defaults to 1 second and can be configured with `pollIntervalMs`.
229
+ `runAgent()` uses async polling internally — it submits the run, then polls until complete or failed. The poll interval defaults to 1 second and can be configured with `pollIntervalMs`.
243
230
 
244
- ## Helpers
231
+ ## Thread persistence
232
+
233
+ Steps execute within threads. Pass `$threadId` and `$appId` from a previous call to maintain state:
245
234
 
246
235
  ```typescript
247
- // List all available AI models
248
- const { models } = await agent.listModels();
236
+ const r1 = await agent.generateText({
237
+ message: 'My name is Alice',
238
+ });
249
239
 
250
- // Filter by type
251
- const { models: chatModels } = await agent.listModelsByType('llm_chat');
240
+ // The model remembers the conversation
241
+ const r2 = await agent.generateText(
242
+ { message: 'What is my name?' },
243
+ { threadId: r1.$threadId, appId: r1.$appId },
244
+ );
245
+ ```
252
246
 
253
- // List available connector services
254
- const { services } = await agent.listConnectors();
247
+ ### Automatic thread reuse
248
+
249
+ For scripts where all calls should share a single thread:
250
+
251
+ ```typescript
252
+ const agent = new MindStudioAgent({ reuseThreadId: true });
253
+
254
+ // Or set MINDSTUDIO_REUSE_THREAD_ID=true
255
+
256
+ await agent.generateText({ message: 'My name is Alice' }); // creates a thread
257
+ await agent.generateText({ message: 'What is my name?' }); // reuses it automatically
255
258
  ```
256
259
 
257
260
  ## Configuration
@@ -274,19 +277,54 @@ const agent = new MindStudioAgent({
274
277
  });
275
278
  ```
276
279
 
280
+ ## Rate limiting
281
+
282
+ Handled automatically:
283
+
284
+ - **Concurrency queue** — requests beyond the server's concurrent limit are queued and proceed as slots open up
285
+ - **Auto-retry on 429** — rate-limited responses are retried using the `Retry-After` header (default: 3 retries, configurable via `maxRetries`)
286
+ - **Call cap** — internal tokens are capped at 500 calls per execution
287
+
288
+ Every result includes `$rateLimitRemaining` so you can throttle proactively.
289
+
290
+ ## Billing
291
+
292
+ Every result includes optional billing metadata:
293
+
294
+ ```typescript
295
+ const result = await agent.generateImage({ prompt: 'A sunset' });
296
+ console.log(result.$billingCost); // cost in credits for this call
297
+ console.log(result.$billingEvents); // itemized billing events
298
+ ```
299
+
300
+ ## Error handling
301
+
302
+ ```typescript
303
+ import { MindStudioAgent, MindStudioError } from '@mindstudio-ai/agent';
304
+
305
+ try {
306
+ await agent.generateImage({ prompt: '...' });
307
+ } catch (err) {
308
+ if (err instanceof MindStudioError) {
309
+ console.error(err.message); // Human-readable message
310
+ console.error(err.code); // "invalid_step_config", "api_error", "call_cap_exceeded", etc.
311
+ console.error(err.status); // HTTP status (400, 401, 429, etc.)
312
+ console.error(err.details); // Raw API error body
313
+ }
314
+ }
315
+ ```
316
+
277
317
  ## Low-level access
278
318
 
279
- For step types not yet in the generated methods, use `executeStep()` directly:
319
+ For step types not yet in the generated methods:
280
320
 
281
321
  ```typescript
282
- const result = await agent.executeStep('someNewStep', {
283
- param1: 'value',
284
- });
322
+ const result = await agent.executeStep('someNewStep', { param1: 'value' });
285
323
  ```
286
324
 
287
325
  ## Types
288
326
 
289
- All input/output types are exported for use in your own code:
327
+ All input/output types are exported:
290
328
 
291
329
  ```typescript
292
330
  import type {
@@ -408,7 +446,7 @@ mindstudio generate-text --message "What is my name?" \
408
446
 
409
447
  ## MCP server
410
448
 
411
- The package includes a built-in [MCP](https://modelcontextprotocol.io) (Model Context Protocol) server. It exposes all step methods and helpers as tools, so any MCP-compatible AI agent (Claude Code, Cursor, Windsurf, VS Code Copilot, etc.) can discover and call them.
449
+ The package includes a built-in [MCP](https://modelcontextprotocol.io) (Model Context Protocol) server. It exposes every action, helper, and agent tool so any MCP-compatible AI agent (Claude Code, Cursor, Windsurf, VS Code Copilot, etc.) can discover and use the full platform.
412
450
 
413
451
  Start manually:
414
452
 
@@ -456,24 +494,7 @@ The raw OpenAPI spec that this SDK is generated from is available at:
456
494
  https://v1.mindstudio-api.com/developer/v2/steps/openapi.json
457
495
  ```
458
496
 
459
- This contains full JSON Schema definitions for every step's input and output, descriptions, and usage notes. Useful if you want to build your own tooling, code generators, or integrations.
460
-
461
- ## Error handling
462
-
463
- ```typescript
464
- import { MindStudioAgent, MindStudioError } from '@mindstudio-ai/agent';
465
-
466
- try {
467
- await agent.generateImage({ prompt: '...' });
468
- } catch (err) {
469
- if (err instanceof MindStudioError) {
470
- console.error(err.message); // Human-readable message
471
- console.error(err.code); // Machine-readable code (e.g. "invalid_step_config")
472
- console.error(err.status); // HTTP status (e.g. 400)
473
- console.error(err.details); // Raw API error body
474
- }
475
- }
476
- ```
497
+ Full JSON Schema definitions for every step's input and output. Useful for building your own tooling, code generators, or integrations.
477
498
 
478
499
  ## License
479
500