@mindstudio-ai/agent 0.0.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 ADDED
@@ -0,0 +1,183 @@
1
+ # @mindstudio-ai/agent
2
+
3
+ TypeScript SDK for executing [MindStudio](https://mindstudio.ai) workflow steps directly.
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.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @mindstudio-ai/agent
11
+ ```
12
+
13
+ Requires Node.js 18+.
14
+
15
+ ## Quick start
16
+
17
+ ```typescript
18
+ import { MindStudioAgent } from '@mindstudio-ai/agent';
19
+
20
+ const agent = new MindStudioAgent({ apiKey: 'your-api-key' });
21
+
22
+ // Generate an image
23
+ const { output } = await agent.generateImage({
24
+ prompt: 'A mountain landscape at sunset',
25
+ mode: 'background',
26
+ });
27
+ console.log(output.imageUrl);
28
+
29
+ // Send a message to an AI model
30
+ const { output: chat } = await agent.userMessage({
31
+ message: 'Summarize this article: ...',
32
+ source: 'user',
33
+ });
34
+ console.log(chat.content);
35
+
36
+ // Search Google
37
+ const { output: search } = await agent.searchGoogle({
38
+ query: 'TypeScript best practices 2025',
39
+ exportType: 'json',
40
+ });
41
+ console.log(search.results);
42
+ ```
43
+
44
+ Every method is fully typed — your editor will autocomplete available parameters, show enum options, and infer the output shape.
45
+
46
+ ## Authentication
47
+
48
+ The SDK supports two authentication modes:
49
+
50
+ **API Key** — for external apps, scripts, and CLI usage:
51
+
52
+ ```typescript
53
+ // Pass directly
54
+ const agent = new MindStudioAgent({ apiKey: 'your-api-key' });
55
+
56
+ // Or set the environment variable
57
+ // MINDSTUDIO_API_KEY=your-api-key
58
+ const agent = new MindStudioAgent();
59
+ ```
60
+
61
+ **Managed mode** — automatically available inside MindStudio custom functions:
62
+
63
+ ```typescript
64
+ // Inside a MindStudio custom function, auth and base URL are automatic
65
+ // (CALLBACK_TOKEN and REMOTE_HOSTNAME are set by the runtime)
66
+ const agent = new MindStudioAgent();
67
+ ```
68
+
69
+ Resolution order: constructor `apiKey` > `MINDSTUDIO_API_KEY` env > `CALLBACK_TOKEN` env.
70
+
71
+ ## Thread persistence
72
+
73
+ Steps execute within threads. Pass `threadId` and `appId` from a previous call to maintain state across calls:
74
+
75
+ ```typescript
76
+ const r1 = await agent.userMessage({
77
+ message: 'My name is Alice',
78
+ source: 'user',
79
+ });
80
+
81
+ // The model remembers the conversation
82
+ const r2 = await agent.userMessage(
83
+ { message: 'What is my name?', source: 'user' },
84
+ { threadId: r1.threadId, appId: r1.appId },
85
+ );
86
+ ```
87
+
88
+ ## Available steps
89
+
90
+ Every step has a dedicated typed method. A few highlights:
91
+
92
+ | Method | Description |
93
+ | --- | --- |
94
+ | `userMessage()` | Send a message to an AI model |
95
+ | `generateImage()` | Generate an image from a text prompt |
96
+ | `generateVideo()` | Generate a video from a text prompt |
97
+ | `analyzeImage()` | Analyze an image with a vision model |
98
+ | `textToSpeech()` | Convert text to speech |
99
+ | `transcribeAudio()` | Transcribe audio to text |
100
+ | `scrapeUrl()` | Scrape a web page |
101
+ | `searchGoogle()` | Search Google |
102
+ | `httpRequest()` | Make an HTTP request |
103
+ | `sendEmail()` | Send an email |
104
+ | `postToSlackChannel()` | Post to a Slack channel |
105
+ | `runWorkflow()` | Run another MindStudio workflow |
106
+
107
+ ...and 100+ more for Google Docs/Sheets/Calendar, YouTube, LinkedIn, HubSpot, Airtable, Notion, Coda, Telegram, media processing, PII detection, and more.
108
+
109
+ All methods show full documentation in your editor's IntelliSense — hover any method to see usage notes, parameter descriptions, and enum options.
110
+
111
+ ## Helpers
112
+
113
+ ```typescript
114
+ // List all available AI models
115
+ const { models } = await agent.listModels();
116
+
117
+ // Filter by type
118
+ const { models: chatModels } = await agent.listModelsByType('llm_chat');
119
+
120
+ // List available connector services
121
+ const { services } = await agent.listConnectors();
122
+ ```
123
+
124
+ ## Configuration
125
+
126
+ ```typescript
127
+ const agent = new MindStudioAgent({
128
+ // API key (or set MINDSTUDIO_API_KEY env var)
129
+ apiKey: 'your-api-key',
130
+
131
+ // Base URL (or set MINDSTUDIO_BASE_URL env var)
132
+ // Defaults to https://v1.mindstudio-api.com
133
+ baseUrl: 'http://localhost:3129',
134
+ });
135
+ ```
136
+
137
+ ## Low-level access
138
+
139
+ For step types not yet in the generated methods, use `executeStep()` directly:
140
+
141
+ ```typescript
142
+ const result = await agent.executeStep('someNewStep', {
143
+ param1: 'value',
144
+ });
145
+ ```
146
+
147
+ ## Types
148
+
149
+ All input/output types are exported for use in your own code:
150
+
151
+ ```typescript
152
+ import type {
153
+ GenerateImageStepInput,
154
+ GenerateImageStepOutput,
155
+ UserMessageStepInput,
156
+ StepName,
157
+ StepInputMap,
158
+ StepOutputMap,
159
+ } from '@mindstudio-ai/agent';
160
+ ```
161
+
162
+ `StepName` is a union of all available step type names. `StepInputMap` and `StepOutputMap` map step names to their input/output types, which is useful for building generic utilities.
163
+
164
+ ## Error handling
165
+
166
+ ```typescript
167
+ import { MindStudioAgent, MindStudioError } from '@mindstudio-ai/agent';
168
+
169
+ try {
170
+ await agent.generateImage({ prompt: '...', mode: 'background' });
171
+ } catch (err) {
172
+ if (err instanceof MindStudioError) {
173
+ console.error(err.message); // Human-readable message
174
+ console.error(err.code); // Machine-readable code (e.g. "invalid_step_config")
175
+ console.error(err.status); // HTTP status (e.g. 400)
176
+ console.error(err.details); // Raw API error body
177
+ }
178
+ }
179
+ ```
180
+
181
+ ## License
182
+
183
+ MIT