@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/dist/index.js ADDED
@@ -0,0 +1,483 @@
1
+ // src/errors.ts
2
+ var MindStudioError = class extends Error {
3
+ constructor(message, code, status, details) {
4
+ super(message);
5
+ this.code = code;
6
+ this.status = status;
7
+ this.details = details;
8
+ }
9
+ name = "MindStudioError";
10
+ };
11
+
12
+ // src/http.ts
13
+ async function request(config, method, path, body) {
14
+ const url = `${config.baseUrl}/developer/v2${path}`;
15
+ const res = await fetch(url, {
16
+ method,
17
+ headers: {
18
+ Authorization: `Bearer ${config.token}`,
19
+ "Content-Type": "application/json",
20
+ "User-Agent": "@mindstudio-ai/agent"
21
+ },
22
+ body: body != null ? JSON.stringify(body) : void 0
23
+ });
24
+ if (!res.ok) {
25
+ const errorBody = await res.json().catch(() => ({}));
26
+ throw new MindStudioError(
27
+ errorBody.message || `${res.status} ${res.statusText}`,
28
+ errorBody.code || "api_error",
29
+ res.status,
30
+ errorBody
31
+ );
32
+ }
33
+ const data = await res.json();
34
+ return { data, headers: res.headers };
35
+ }
36
+
37
+ // src/generated/steps.ts
38
+ function applyStepMethods(AgentClass) {
39
+ const proto = AgentClass.prototype;
40
+ proto.activeCampaignAddNote = function(step, options) {
41
+ return this.executeStep("activeCampaignAddNote", step, options);
42
+ };
43
+ proto.activeCampaignCreateContact = function(step, options) {
44
+ return this.executeStep("activeCampaignCreateContact", step, options);
45
+ };
46
+ proto.addSubtitlesToVideo = function(step, options) {
47
+ return this.executeStep("addSubtitlesToVideo", step, options);
48
+ };
49
+ proto.airtableCreateUpdateRecord = function(step, options) {
50
+ return this.executeStep("airtableCreateUpdateRecord", step, options);
51
+ };
52
+ proto.airtableDeleteRecord = function(step, options) {
53
+ return this.executeStep("airtableDeleteRecord", step, options);
54
+ };
55
+ proto.airtableGetRecord = function(step, options) {
56
+ return this.executeStep("airtableGetRecord", step, options);
57
+ };
58
+ proto.airtableGetTableRecords = function(step, options) {
59
+ return this.executeStep("airtableGetTableRecords", step, options);
60
+ };
61
+ proto.analyzeImage = function(step, options) {
62
+ return this.executeStep("analyzeImage", step, options);
63
+ };
64
+ proto.analyzeVideo = function(step, options) {
65
+ return this.executeStep("analyzeVideo", step, options);
66
+ };
67
+ proto.captureThumbnail = function(step, options) {
68
+ return this.executeStep("captureThumbnail", step, options);
69
+ };
70
+ proto.codaCreateUpdatePage = function(step, options) {
71
+ return this.executeStep("codaCreateUpdatePage", step, options);
72
+ };
73
+ proto.codaCreateUpdateRow = function(step, options) {
74
+ return this.executeStep("codaCreateUpdateRow", step, options);
75
+ };
76
+ proto.codaFindRow = function(step, options) {
77
+ return this.executeStep("codaFindRow", step, options);
78
+ };
79
+ proto.codaGetPage = function(step, options) {
80
+ return this.executeStep("codaGetPage", step, options);
81
+ };
82
+ proto.codaGetTableRows = function(step, options) {
83
+ return this.executeStep("codaGetTableRows", step, options);
84
+ };
85
+ proto.convertPdfToImages = function(step, options) {
86
+ return this.executeStep("convertPdfToImages", step, options);
87
+ };
88
+ proto.createGoogleCalendarEvent = function(step, options) {
89
+ return this.executeStep("createGoogleCalendarEvent", step, options);
90
+ };
91
+ proto.createGoogleDoc = function(step, options) {
92
+ return this.executeStep("createGoogleDoc", step, options);
93
+ };
94
+ proto.createGoogleSheet = function(step, options) {
95
+ return this.executeStep("createGoogleSheet", step, options);
96
+ };
97
+ proto.deleteGoogleCalendarEvent = function(step, options) {
98
+ return this.executeStep("deleteGoogleCalendarEvent", step, options);
99
+ };
100
+ proto.detectPII = function(step, options) {
101
+ return this.executeStep("detectPII", step, options);
102
+ };
103
+ proto.downloadVideo = function(step, options) {
104
+ return this.executeStep("downloadVideo", step, options);
105
+ };
106
+ proto.enhanceImageGenerationPrompt = function(step, options) {
107
+ return this.executeStep("enhanceImageGenerationPrompt", step, options);
108
+ };
109
+ proto.enhanceVideoGenerationPrompt = function(step, options) {
110
+ return this.executeStep("enhanceVideoGenerationPrompt", step, options);
111
+ };
112
+ proto.enrichPerson = function(step, options) {
113
+ return this.executeStep("enrichPerson", step, options);
114
+ };
115
+ proto.extractAudioFromVideo = function(step, options) {
116
+ return this.executeStep("extractAudioFromVideo", step, options);
117
+ };
118
+ proto.extractText = function(step, options) {
119
+ return this.executeStep("extractText", step, options);
120
+ };
121
+ proto.fetchGoogleDoc = function(step, options) {
122
+ return this.executeStep("fetchGoogleDoc", step, options);
123
+ };
124
+ proto.fetchGoogleSheet = function(step, options) {
125
+ return this.executeStep("fetchGoogleSheet", step, options);
126
+ };
127
+ proto.fetchSlackChannelHistory = function(step, options) {
128
+ return this.executeStep("fetchSlackChannelHistory", step, options);
129
+ };
130
+ proto.fetchYoutubeCaptions = function(step, options) {
131
+ return this.executeStep("fetchYoutubeCaptions", step, options);
132
+ };
133
+ proto.fetchYoutubeChannel = function(step, options) {
134
+ return this.executeStep("fetchYoutubeChannel", step, options);
135
+ };
136
+ proto.fetchYoutubeComments = function(step, options) {
137
+ return this.executeStep("fetchYoutubeComments", step, options);
138
+ };
139
+ proto.fetchYoutubeVideo = function(step, options) {
140
+ return this.executeStep("fetchYoutubeVideo", step, options);
141
+ };
142
+ proto.generateChart = function(step, options) {
143
+ return this.executeStep("generateChart", step, options);
144
+ };
145
+ proto.generateImage = function(step, options) {
146
+ return this.executeStep("generateImage", step, options);
147
+ };
148
+ proto.generateLipsync = function(step, options) {
149
+ return this.executeStep("generateLipsync", step, options);
150
+ };
151
+ proto.generateMusic = function(step, options) {
152
+ return this.executeStep("generateMusic", step, options);
153
+ };
154
+ proto.generatePdf = function(step, options) {
155
+ return this.executeStep("generatePdf", step, options);
156
+ };
157
+ proto.generateStaticVideoFromImage = function(step, options) {
158
+ return this.executeStep("generateStaticVideoFromImage", step, options);
159
+ };
160
+ proto.generateVideo = function(step, options) {
161
+ return this.executeStep("generateVideo", step, options);
162
+ };
163
+ proto.getGoogleCalendarEvent = function(step, options) {
164
+ return this.executeStep("getGoogleCalendarEvent", step, options);
165
+ };
166
+ proto.getMediaMetadata = function(step, options) {
167
+ return this.executeStep("getMediaMetadata", step, options);
168
+ };
169
+ proto.httpRequest = function(step, options) {
170
+ return this.executeStep("httpRequest", step, options);
171
+ };
172
+ proto.hubspotCreateCompany = function(step, options) {
173
+ return this.executeStep("hubspotCreateCompany", step, options);
174
+ };
175
+ proto.hubspotCreateContact = function(step, options) {
176
+ return this.executeStep("hubspotCreateContact", step, options);
177
+ };
178
+ proto.hubspotGetCompany = function(step, options) {
179
+ return this.executeStep("hubspotGetCompany", step, options);
180
+ };
181
+ proto.hubspotGetContact = function(step, options) {
182
+ return this.executeStep("hubspotGetContact", step, options);
183
+ };
184
+ proto.hunterApiCompanyEnrichment = function(step, options) {
185
+ return this.executeStep("hunterApiCompanyEnrichment", step, options);
186
+ };
187
+ proto.hunterApiDomainSearch = function(step, options) {
188
+ return this.executeStep("hunterApiDomainSearch", step, options);
189
+ };
190
+ proto.hunterApiEmailFinder = function(step, options) {
191
+ return this.executeStep("hunterApiEmailFinder", step, options);
192
+ };
193
+ proto.hunterApiEmailVerification = function(step, options) {
194
+ return this.executeStep("hunterApiEmailVerification", step, options);
195
+ };
196
+ proto.hunterApiPersonEnrichment = function(step, options) {
197
+ return this.executeStep("hunterApiPersonEnrichment", step, options);
198
+ };
199
+ proto.imageFaceSwap = function(step, options) {
200
+ return this.executeStep("imageFaceSwap", step, options);
201
+ };
202
+ proto.imageRemoveWatermark = function(step, options) {
203
+ return this.executeStep("imageRemoveWatermark", step, options);
204
+ };
205
+ proto.insertVideoClips = function(step, options) {
206
+ return this.executeStep("insertVideoClips", step, options);
207
+ };
208
+ proto.listGoogleCalendarEvents = function(step, options) {
209
+ return this.executeStep("listGoogleCalendarEvents", step, options);
210
+ };
211
+ proto.logic = function(step, options) {
212
+ return this.executeStep("logic", step, options);
213
+ };
214
+ proto.makeDotComRunScenario = function(step, options) {
215
+ return this.executeStep("makeDotComRunScenario", step, options);
216
+ };
217
+ proto.mergeAudio = function(step, options) {
218
+ return this.executeStep("mergeAudio", step, options);
219
+ };
220
+ proto.mergeVideos = function(step, options) {
221
+ return this.executeStep("mergeVideos", step, options);
222
+ };
223
+ proto.mixAudioIntoVideo = function(step, options) {
224
+ return this.executeStep("mixAudioIntoVideo", step, options);
225
+ };
226
+ proto.muteVideo = function(step, options) {
227
+ return this.executeStep("muteVideo", step, options);
228
+ };
229
+ proto.n8nRunNode = function(step, options) {
230
+ return this.executeStep("n8nRunNode", step, options);
231
+ };
232
+ proto.notionCreatePage = function(step, options) {
233
+ return this.executeStep("notionCreatePage", step, options);
234
+ };
235
+ proto.notionUpdatePage = function(step, options) {
236
+ return this.executeStep("notionUpdatePage", step, options);
237
+ };
238
+ proto.peopleSearch = function(step, options) {
239
+ return this.executeStep("peopleSearch", step, options);
240
+ };
241
+ proto.postToLinkedIn = function(step, options) {
242
+ return this.executeStep("postToLinkedIn", step, options);
243
+ };
244
+ proto.postToSlackChannel = function(step, options) {
245
+ return this.executeStep("postToSlackChannel", step, options);
246
+ };
247
+ proto.postToX = function(step, options) {
248
+ return this.executeStep("postToX", step, options);
249
+ };
250
+ proto.postToZapier = function(step, options) {
251
+ return this.executeStep("postToZapier", step, options);
252
+ };
253
+ proto.queryDataSource = function(step, options) {
254
+ return this.executeStep("queryDataSource", step, options);
255
+ };
256
+ proto.queryExternalDatabase = function(step, options) {
257
+ return this.executeStep("queryExternalDatabase", step, options);
258
+ };
259
+ proto.redactPII = function(step, options) {
260
+ return this.executeStep("redactPII", step, options);
261
+ };
262
+ proto.removeBackgroundFromImage = function(step, options) {
263
+ return this.executeStep("removeBackgroundFromImage", step, options);
264
+ };
265
+ proto.resizeVideo = function(step, options) {
266
+ return this.executeStep("resizeVideo", step, options);
267
+ };
268
+ proto.runPackagedWorkflow = function(step, options) {
269
+ return this.executeStep("runPackagedWorkflow", step, options);
270
+ };
271
+ proto.runWorkflow = function(step, options) {
272
+ return this.executeStep("runWorkflow", step, options);
273
+ };
274
+ proto.scrapeFacebookPage = function(step, options) {
275
+ return this.executeStep("scrapeFacebookPage", step, options);
276
+ };
277
+ proto.scrapeFacebookPosts = function(step, options) {
278
+ return this.executeStep("scrapeFacebookPosts", step, options);
279
+ };
280
+ proto.scrapeInstagramComments = function(step, options) {
281
+ return this.executeStep("scrapeInstagramComments", step, options);
282
+ };
283
+ proto.scrapeInstagramMentions = function(step, options) {
284
+ return this.executeStep("scrapeInstagramMentions", step, options);
285
+ };
286
+ proto.scrapeInstagramPosts = function(step, options) {
287
+ return this.executeStep("scrapeInstagramPosts", step, options);
288
+ };
289
+ proto.scrapeInstagramProfile = function(step, options) {
290
+ return this.executeStep("scrapeInstagramProfile", step, options);
291
+ };
292
+ proto.scrapeInstagramReels = function(step, options) {
293
+ return this.executeStep("scrapeInstagramReels", step, options);
294
+ };
295
+ proto.scrapeLinkedInCompany = function(step, options) {
296
+ return this.executeStep("scrapeLinkedInCompany", step, options);
297
+ };
298
+ proto.scrapeLinkedInProfile = function(step, options) {
299
+ return this.executeStep("scrapeLinkedInProfile", step, options);
300
+ };
301
+ proto.scrapeMetaThreadsProfile = function(step, options) {
302
+ return this.executeStep("scrapeMetaThreadsProfile", step, options);
303
+ };
304
+ proto.scrapeUrl = function(step, options) {
305
+ return this.executeStep("scrapeUrl", step, options);
306
+ };
307
+ proto.scrapeXPost = function(step, options) {
308
+ return this.executeStep("scrapeXPost", step, options);
309
+ };
310
+ proto.scrapeXProfile = function(step, options) {
311
+ return this.executeStep("scrapeXProfile", step, options);
312
+ };
313
+ proto.searchGoogle = function(step, options) {
314
+ return this.executeStep("searchGoogle", step, options);
315
+ };
316
+ proto.searchGoogleImages = function(step, options) {
317
+ return this.executeStep("searchGoogleImages", step, options);
318
+ };
319
+ proto.searchGoogleNews = function(step, options) {
320
+ return this.executeStep("searchGoogleNews", step, options);
321
+ };
322
+ proto.searchGoogleTrends = function(step, options) {
323
+ return this.executeStep("searchGoogleTrends", step, options);
324
+ };
325
+ proto.searchPerplexity = function(step, options) {
326
+ return this.executeStep("searchPerplexity", step, options);
327
+ };
328
+ proto.searchXPosts = function(step, options) {
329
+ return this.executeStep("searchXPosts", step, options);
330
+ };
331
+ proto.searchYoutube = function(step, options) {
332
+ return this.executeStep("searchYoutube", step, options);
333
+ };
334
+ proto.searchYoutubeTrends = function(step, options) {
335
+ return this.executeStep("searchYoutubeTrends", step, options);
336
+ };
337
+ proto.sendEmail = function(step, options) {
338
+ return this.executeStep("sendEmail", step, options);
339
+ };
340
+ proto.sendSMS = function(step, options) {
341
+ return this.executeStep("sendSMS", step, options);
342
+ };
343
+ proto.setRunTitle = function(step, options) {
344
+ return this.executeStep("setRunTitle", step, options);
345
+ };
346
+ proto.setVariable = function(step, options) {
347
+ return this.executeStep("setVariable", step, options);
348
+ };
349
+ proto.telegramSendAudio = function(step, options) {
350
+ return this.executeStep("telegramSendAudio", step, options);
351
+ };
352
+ proto.telegramSendFile = function(step, options) {
353
+ return this.executeStep("telegramSendFile", step, options);
354
+ };
355
+ proto.telegramSendImage = function(step, options) {
356
+ return this.executeStep("telegramSendImage", step, options);
357
+ };
358
+ proto.telegramSendMessage = function(step, options) {
359
+ return this.executeStep("telegramSendMessage", step, options);
360
+ };
361
+ proto.telegramSendVideo = function(step, options) {
362
+ return this.executeStep("telegramSendVideo", step, options);
363
+ };
364
+ proto.telegramSetTyping = function(step, options) {
365
+ return this.executeStep("telegramSetTyping", step, options);
366
+ };
367
+ proto.textToSpeech = function(step, options) {
368
+ return this.executeStep("textToSpeech", step, options);
369
+ };
370
+ proto.transcribeAudio = function(step, options) {
371
+ return this.executeStep("transcribeAudio", step, options);
372
+ };
373
+ proto.trimMedia = function(step, options) {
374
+ return this.executeStep("trimMedia", step, options);
375
+ };
376
+ proto.updateGoogleCalendarEvent = function(step, options) {
377
+ return this.executeStep("updateGoogleCalendarEvent", step, options);
378
+ };
379
+ proto.updateGoogleDoc = function(step, options) {
380
+ return this.executeStep("updateGoogleDoc", step, options);
381
+ };
382
+ proto.updateGoogleSheet = function(step, options) {
383
+ return this.executeStep("updateGoogleSheet", step, options);
384
+ };
385
+ proto.upscaleImage = function(step, options) {
386
+ return this.executeStep("upscaleImage", step, options);
387
+ };
388
+ proto.upscaleVideo = function(step, options) {
389
+ return this.executeStep("upscaleVideo", step, options);
390
+ };
391
+ proto.userMessage = function(step, options) {
392
+ return this.executeStep("userMessage", step, options);
393
+ };
394
+ proto.videoFaceSwap = function(step, options) {
395
+ return this.executeStep("videoFaceSwap", step, options);
396
+ };
397
+ proto.videoRemoveBackground = function(step, options) {
398
+ return this.executeStep("videoRemoveBackground", step, options);
399
+ };
400
+ proto.videoRemoveWatermark = function(step, options) {
401
+ return this.executeStep("videoRemoveWatermark", step, options);
402
+ };
403
+ proto.watermarkImage = function(step, options) {
404
+ return this.executeStep("watermarkImage", step, options);
405
+ };
406
+ proto.watermarkVideo = function(step, options) {
407
+ return this.executeStep("watermarkVideo", step, options);
408
+ };
409
+ }
410
+
411
+ // src/generated/helpers.ts
412
+ function applyHelperMethods(AgentClass) {
413
+ const proto = AgentClass.prototype;
414
+ proto.listModels = function() {
415
+ return this._request("GET", "/helpers/models").then((r) => r.data);
416
+ };
417
+ proto.listModelsByType = function(modelType) {
418
+ return this._request("GET", `/helpers/models/${modelType}`).then((r) => r.data);
419
+ };
420
+ proto.listConnectors = function() {
421
+ return this._request("GET", "/helpers/connectors").then((r) => r.data);
422
+ };
423
+ proto.getConnector = function(serviceId) {
424
+ return this._request("GET", `/helpers/connectors/${serviceId}`).then((r) => r.data);
425
+ };
426
+ }
427
+
428
+ // src/client.ts
429
+ var DEFAULT_BASE_URL = "https://v1.mindstudio-api.com";
430
+ var MindStudioAgent = class {
431
+ /** @internal */
432
+ _httpConfig;
433
+ constructor(options = {}) {
434
+ const token = resolveToken(options.apiKey);
435
+ const baseUrl = options.baseUrl ?? process.env.MINDSTUDIO_BASE_URL ?? process.env.REMOTE_HOSTNAME ?? DEFAULT_BASE_URL;
436
+ this._httpConfig = { baseUrl, token };
437
+ }
438
+ /**
439
+ * Execute any step by its type name. This is the low-level method that all
440
+ * typed step methods delegate to. Use it as an escape hatch for step types
441
+ * not yet covered by the generated methods.
442
+ *
443
+ * ```ts
444
+ * const result = await agent.executeStep("generateImage", { prompt: "hello", mode: "background" });
445
+ * ```
446
+ */
447
+ async executeStep(stepType, step, options) {
448
+ const { data, headers } = await request(this._httpConfig, "POST", `/steps/${stepType}/execute`, {
449
+ step,
450
+ ...options?.appId != null && { appId: options.appId },
451
+ ...options?.threadId != null && { threadId: options.threadId }
452
+ });
453
+ return {
454
+ output: data.output,
455
+ outputUrl: data.outputUrl,
456
+ appId: headers.get("x-mindstudio-app-id") ?? "",
457
+ threadId: headers.get("x-mindstudio-thread-id") ?? ""
458
+ };
459
+ }
460
+ /** @internal Used by generated helper methods. */
461
+ _request(method, path, body) {
462
+ return request(this._httpConfig, method, path, body);
463
+ }
464
+ };
465
+ applyStepMethods(MindStudioAgent);
466
+ applyHelperMethods(MindStudioAgent);
467
+ function resolveToken(provided) {
468
+ if (provided) return provided;
469
+ if (process.env.MINDSTUDIO_API_KEY) return process.env.MINDSTUDIO_API_KEY;
470
+ if (process.env.CALLBACK_TOKEN) return process.env.CALLBACK_TOKEN;
471
+ throw new MindStudioError(
472
+ "No API key provided. Pass `apiKey` to the MindStudioAgent constructor, or set the MINDSTUDIO_API_KEY environment variable.",
473
+ "missing_api_key",
474
+ 401
475
+ );
476
+ }
477
+ export {
478
+ MindStudioAgent,
479
+ MindStudioError,
480
+ applyHelperMethods,
481
+ applyStepMethods
482
+ };
483
+ //# sourceMappingURL=index.js.map