@mindstudio-ai/agent 0.1.175 → 0.1.177

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/analytics/index.d.ts +384 -0
  3. package/dist/auth/index.d.ts +113 -0
  4. package/dist/browser/index.d.ts +332 -0
  5. package/dist/cli.js +52 -33
  6. package/dist/client.d.ts +767 -0
  7. package/dist/config.d.ts +13 -0
  8. package/dist/context.d.ts +125 -0
  9. package/dist/datasources/index.d.ts +52 -0
  10. package/dist/datasources/source.d.ts +1074 -0
  11. package/dist/db/aggregate.d.ts +101 -0
  12. package/dist/db/index.d.ts +280 -0
  13. package/dist/db/mutation.d.ts +65 -0
  14. package/dist/db/predicate.d.ts +85 -0
  15. package/dist/db/query.d.ts +233 -0
  16. package/dist/db/raw.d.ts +36 -0
  17. package/dist/db/readBatching.d.ts +36 -0
  18. package/dist/db/scanHints.d.ts +8 -0
  19. package/dist/db/sql.d.ts +136 -0
  20. package/dist/db/table.d.ts +146 -0
  21. package/dist/db/time.d.ts +17 -0
  22. package/dist/db/types.d.ts +237 -0
  23. package/dist/db-ws.d.ts +35 -0
  24. package/dist/email/index.d.ts +396 -0
  25. package/dist/errors.d.ts +34 -0
  26. package/dist/events/index.d.ts +127 -0
  27. package/dist/files/index.d.ts +62 -0
  28. package/dist/files/store.d.ts +244 -0
  29. package/dist/generated/metadata.d.ts +8 -0
  30. package/dist/generated/snippets.d.ts +8 -0
  31. package/dist/generated/steps.d.ts +2745 -0
  32. package/dist/generated/types.d.ts +4234 -0
  33. package/dist/http.d.ts +22 -0
  34. package/dist/index.d.ts +59 -13323
  35. package/dist/index.js +39 -20
  36. package/dist/index.js.map +7 -1
  37. package/dist/jewel/index.d.ts +325 -0
  38. package/dist/mapper/index.d.ts +229 -0
  39. package/dist/rate-limit.d.ts +25 -0
  40. package/dist/reader/index.d.ts +170 -0
  41. package/dist/respond.d.ts +68 -0
  42. package/dist/task/index.d.ts +18 -0
  43. package/dist/task/local.d.ts +48 -0
  44. package/dist/task/schema.d.ts +120 -0
  45. package/dist/task/types.d.ts +203 -0
  46. package/dist/types.d.ts +591 -0
  47. package/dist/voice/index.d.ts +87 -0
  48. package/llms.txt +1 -1
  49. package/package.json +6 -12
  50. package/dist/postinstall.js +0 -12096
@@ -0,0 +1,332 @@
1
+ /**
2
+ * The `browser` namespace — a real Chrome your app drives.
3
+ *
4
+ * `browser.open()` starts a session: one browser with one page, which stays
5
+ * open while you use it. It closes itself after `idleTimeoutSeconds` with no
6
+ * action (5 minutes by default), and at most an hour after it opens. Every
7
+ * action answers with the page as it is afterward: its URL, its title, and a
8
+ * snapshot, a compact outline of the page in which everything you can act on
9
+ * carries a ref (`[ref=e12]`) to name it by next.
10
+ *
11
+ * ```ts
12
+ * import { browser } from '@mindstudio-ai/agent';
13
+ * import { Shots } from './files/shots';
14
+ *
15
+ * export async function captureDashboard() {
16
+ * const session = await browser.open({ url: 'https://app.example.com/login' });
17
+ * await session.type({ label: 'Email' }, process.env.DEMO_EMAIL!);
18
+ * await session.type({ label: 'Password' }, process.env.DEMO_PASSWORD!, { submit: true });
19
+ * await session.waitFor('Dashboard');
20
+ * const shot = await session.screenshot();
21
+ * const file = await Shots.put(shot.data, { contentType: shot.contentType });
22
+ * await session.close();
23
+ * return { url: file.url };
24
+ * }
25
+ * ```
26
+ *
27
+ * To let a model drive instead, hand a task agent the session's tools:
28
+ * `mindstudio.runTask({ ..., tools: session.tools() })`.
29
+ *
30
+ * Elements are named by a ref from the latest snapshot, or by how a person
31
+ * would describe them: `{ text: 'Sign in' }`, `{ role: 'button', text: 'Save' }`,
32
+ * `{ label: 'Email' }`, or a CSS `{ selector }`. A ref is only good until the
33
+ * next snapshot; every action takes one, so use the refs from the latest.
34
+ *
35
+ * Clicks, taps and typing are the browser's own input events, as a person's
36
+ * would be. A password field's value never appears in a snapshot.
37
+ */
38
+ import type { Store, StoredFile } from '../files/store.js';
39
+ import type { TaskToolConfig } from '../task/types.js';
40
+ /** @internal Transport provided by the client (POST /_internal/v2/browser/<op>). */
41
+ export type BrowserTransport = (op: string, body: unknown) => Promise<any>;
42
+ /** @internal The client's `executeStep`, for the screenshot tool's description (`analyzeImage`). */
43
+ export type BrowserStepRunner = (stepType: string, step: Record<string, unknown>) => Promise<any>;
44
+ /**
45
+ * Which element an action is about: a ref from the latest snapshot (`'e12'`),
46
+ * or a description of it.
47
+ */
48
+ export type BrowserTarget = string | {
49
+ /** A ref from the latest snapshot. */
50
+ ref?: string;
51
+ /** The element's accessible name or visible text. */
52
+ text?: string;
53
+ /** With `text`, only elements of this role (`button`, `link`, `textbox`…). */
54
+ role?: string;
55
+ /** A form control, by its label. */
56
+ label?: string;
57
+ /** A CSS selector, for when nothing else names it. */
58
+ selector?: string;
59
+ };
60
+ export interface BrowserViewport {
61
+ width: number;
62
+ height: number;
63
+ deviceScaleFactor: number;
64
+ mobile: boolean;
65
+ }
66
+ export interface BrowserOpenOptions {
67
+ /** A page to open straight away, as `goto(url)` would. */
68
+ url?: string;
69
+ /**
70
+ * `'desktop'` (1280×800, the default), `'mobile'` (390×844 at 2×, with a
71
+ * phone's user agent, touch, and taps for clicks), or an exact size in
72
+ * pixels.
73
+ */
74
+ viewport?: 'desktop' | 'mobile' | {
75
+ width: number;
76
+ height: number;
77
+ };
78
+ /**
79
+ * How long the session waits for its next action before closing itself.
80
+ * 5 minutes by default; at least 30 seconds, at most 30 minutes.
81
+ */
82
+ idleTimeoutSeconds?: number;
83
+ }
84
+ /** The page after an action. */
85
+ export interface BrowserPage {
86
+ url: string;
87
+ title: string;
88
+ /**
89
+ * The page as a compact outline: one line per element worth knowing about
90
+ * (`button "Sign in" [ref=e4]`), indented by nesting, with a ref on
91
+ * everything that can be acted on.
92
+ */
93
+ snapshot: string;
94
+ /** Alerts and confirms the page opened since the last action. Each was accepted. */
95
+ dialogs?: {
96
+ type: string;
97
+ message: string;
98
+ }[];
99
+ }
100
+ /** Where an element is, in CSS pixels: of the viewport for an action, of the shot for a screenshot's `boxes`. */
101
+ export interface BrowserBox {
102
+ x: number;
103
+ y: number;
104
+ width: number;
105
+ height: number;
106
+ }
107
+ /** The page after an action on an element, and which element it was. */
108
+ export interface BrowserElementResult extends BrowserPage {
109
+ /** The element as the snapshot names it (`button "Sign in" [ref=e4]`). */
110
+ matched: string;
111
+ /**
112
+ * Where it was in the viewport when the action landed. A page can move after
113
+ * (a banner arriving pushes everything down), so to highlight an element on
114
+ * a screenshot, ask the screenshot where it is (`boxes`).
115
+ */
116
+ box: BrowserBox;
117
+ }
118
+ export interface BrowserScreenshot {
119
+ data: Buffer;
120
+ contentType: 'image/png';
121
+ /** In CSS pixels. The image is `deviceScaleFactor` times this. */
122
+ width: number;
123
+ height: number;
124
+ deviceScaleFactor: number;
125
+ /**
126
+ * With `boxes`, where each element named is in the shot, in its CSS pixels,
127
+ * in the order named: `null` for one the page didn't have. Absent on older
128
+ * platform versions.
129
+ */
130
+ boxes?: (BrowserBox | null)[];
131
+ }
132
+ /** A screenshot saved straight into a store: the stored file, and the page's size it was taken at. */
133
+ export type BrowserStoredScreenshot = StoredFile & {
134
+ /** In CSS pixels. The image is `deviceScaleFactor` times this. */
135
+ width: number;
136
+ height: number;
137
+ deviceScaleFactor: number;
138
+ /**
139
+ * With `boxes`, where each element named is in the shot, in its CSS pixels,
140
+ * in the order named: `null` for one the page didn't have. Absent on older
141
+ * platform versions.
142
+ */
143
+ boxes?: (BrowserBox | null)[];
144
+ };
145
+ export interface BrowserToolsOptions {
146
+ /**
147
+ * Values the model may type without ever seeing them, by name:
148
+ * `{ password: process.env.APP_PASSWORD! }` lets a `type` step name
149
+ * "password" for a field it chooses, in place of the text.
150
+ */
151
+ secrets?: Record<string, string>;
152
+ /**
153
+ * A store for the screenshots the model takes. With one, the model also
154
+ * gets `browser_screenshot`, which saves a screenshot here and answers with
155
+ * a written description of it (an `analyzeImage` call), so it can see what
156
+ * the page's outline doesn't say. Every shot is kept, and its key is in the
157
+ * answer.
158
+ */
159
+ screenshots?: Store;
160
+ }
161
+ interface SessionInfo {
162
+ id: string;
163
+ viewport: BrowserViewport;
164
+ expiresAt: number;
165
+ }
166
+ /** One open browser session. Get one from `browser.open()` or `browser.session(id)`. */
167
+ export declare class BrowserSession {
168
+ private readonly call;
169
+ private readonly steps;
170
+ /** Pass to `browser.session(id)` from a later call to pick this session up again. */
171
+ readonly id: string;
172
+ readonly viewport: BrowserViewport;
173
+ /** When the session closes, however busy it is. Milliseconds since epoch. */
174
+ readonly expiresAt: number;
175
+ /** @internal Use `browser.open()`. */
176
+ constructor(info: SessionInfo, call: BrowserTransport, steps: BrowserStepRunner);
177
+ /** Every action so far, chained: see `run`. */
178
+ private queue;
179
+ /**
180
+ * One action at a time, in the order they were called. A session has one
181
+ * page, so actions started together (a `Promise.all`, or a task agent's
182
+ * tools from one turn, which run concurrently) would otherwise reach it in
183
+ * whatever order their requests landed: a click on Submit before the field
184
+ * it submits was typed.
185
+ */
186
+ private run;
187
+ /**
188
+ * One action's request, asked again under the same id when the answer
189
+ * didn't get back (a dropped connection, an api pod rolling). The platform
190
+ * runs an id once, so asking again waits on the action already under way
191
+ * rather than clicking twice.
192
+ */
193
+ private send;
194
+ /** Open a URL and wait for it to load. */
195
+ goto(url: string): Promise<BrowserPage>;
196
+ /** The page as it is now. */
197
+ snapshot(): Promise<BrowserPage>;
198
+ /** Click an element (tap, on a mobile viewport), and wait for what it started to settle. */
199
+ click(target: BrowserTarget): Promise<BrowserElementResult>;
200
+ /**
201
+ * Click into a field and type. `clear` replaces what's there; `submit`
202
+ * presses Enter after.
203
+ */
204
+ type(target: BrowserTarget, text: string, options?: {
205
+ clear?: boolean;
206
+ submit?: boolean;
207
+ }): Promise<BrowserElementResult>;
208
+ /** Choose an option of a `<select>`, by its text, value or label. */
209
+ select(target: BrowserTarget, option: string): Promise<BrowserElementResult>;
210
+ /**
211
+ * Press a key on whatever has focus: `Enter`, `Tab`, `Escape`, `Backspace`,
212
+ * `Delete`, the arrows, `PageUp`, `PageDown`, `Home`, `End`, `' '`, or any
213
+ * single character.
214
+ */
215
+ press(key: string): Promise<BrowserPage>;
216
+ /** Scroll an element into view, or the page by `by` pixels (most of a screen, by default). */
217
+ scroll(options?: {
218
+ to?: BrowserTarget;
219
+ by?: number;
220
+ }): Promise<BrowserPage>;
221
+ /** Wait for text to appear on the page. Throws once `timeoutSeconds` (15 by default) pass without it. */
222
+ waitFor(text: string, options?: {
223
+ timeoutSeconds?: number;
224
+ }): Promise<BrowserPage>;
225
+ /**
226
+ * A PNG of the viewport, or of the whole page with `fullPage`. With a
227
+ * `store` it goes straight into that store, under `key` or a new one, and
228
+ * you get the stored file back; without, you get the bytes, which a full
229
+ * page past a few megabytes is too large for. The cursor is left out unless
230
+ * `cursor` keeps it in, for a shot that shows where the last action landed.
231
+ * `boxes` names elements, as an action does, and the shot says where each
232
+ * one is in it, measured as it's taken, for drawing highlights on it.
233
+ *
234
+ * ```ts
235
+ * const shot = await session.screenshot({ store: Shots, boxes: ['e12'] });
236
+ * await Steps.push({ screenshot: shot.key, highlight: shot.boxes?.[0] });
237
+ * await session.click('e12');
238
+ * ```
239
+ */
240
+ screenshot(options?: {
241
+ fullPage?: boolean;
242
+ cursor?: boolean;
243
+ boxes?: BrowserTarget[];
244
+ }): Promise<BrowserScreenshot>;
245
+ screenshot(options: {
246
+ fullPage?: boolean;
247
+ cursor?: boolean;
248
+ boxes?: BrowserTarget[];
249
+ store: Store;
250
+ key?: string;
251
+ }): Promise<BrowserStoredScreenshot>;
252
+ /**
253
+ * Run a function in the page and get back what it returns (as JSON). The
254
+ * function is sent as source, so it can't use variables from your code:
255
+ * pass what it needs as `arg`.
256
+ *
257
+ * ```ts
258
+ * const prices = await session.evaluate(
259
+ * (selector) => [...document.querySelectorAll(selector)].map((el) => el.textContent),
260
+ * '.price',
261
+ * );
262
+ * ```
263
+ */
264
+ evaluate<R, A = undefined>(fn: (arg: A) => R, arg?: A): Promise<Awaited<R>>;
265
+ /**
266
+ * A tool for `mindstudio.runTask()` that drives this session, so a model can
267
+ * browse. It takes a list of steps (open a URL, read the page, click, type,
268
+ * choose an option, press a key, scroll, wait for text), runs them in order,
269
+ * stops at the first that fails, and answers with each step's outcome and
270
+ * the page after the last one. A model plans "fill the form and submit it"
271
+ * as one call rather than one turn a field. Only the latest page stays in
272
+ * the task's transcript (`supersedes`), so a long walk doesn't fill it.
273
+ *
274
+ * With `screenshots`, a second tool, `browser_screenshot`, lets the model
275
+ * see the page: each shot goes into that store and the model reads a
276
+ * description of it. Those answers all stay in the transcript, since each
277
+ * names a kept file.
278
+ */
279
+ tools(options?: BrowserToolsOptions): TaskToolConfig[];
280
+ /**
281
+ * The screenshot tool: the shot into the store, then a vision model's
282
+ * description of it. A description that fails still answers with the kept
283
+ * shot's key, so the model can name it.
284
+ */
285
+ private describeScreen;
286
+ /** The tool's steps, in order, stopping at the first that fails. */
287
+ private runSteps;
288
+ private runStep;
289
+ /**
290
+ * A grant to watch this session live, for your frontend: return it from a
291
+ * method and hand its `token` to `browser.view()` in
292
+ * `@mindstudio-ai/interface`. Whoever holds it sees the page until it
293
+ * expires, so check your own access first, as for `events.grant()`.
294
+ * `ttlSeconds` is clamped to 60 through 3600 (900 by default); the frontend
295
+ * asks again through your method when it runs out.
296
+ *
297
+ * ```ts
298
+ * export async function watchRun({ runId }: { runId: string }) {
299
+ * auth.requireRole('admin');
300
+ * const run = await Runs.get(runId);
301
+ * const session = await browser.session(run.browserSessionId);
302
+ * return session.grantView();
303
+ * }
304
+ * ```
305
+ */
306
+ grantView(options?: {
307
+ ttlSeconds?: number;
308
+ }): Promise<{
309
+ token: string;
310
+ expiresAt: number;
311
+ ttlSeconds: number;
312
+ }>;
313
+ /** Close the session and its browser. */
314
+ close(): Promise<void>;
315
+ }
316
+ /** The `browser` namespace object. */
317
+ export interface Browser {
318
+ /**
319
+ * Start a browser session, and wait for its browser to be ready: seconds
320
+ * when one starts on a warm host, longer when it's the first in a while.
321
+ */
322
+ open(options?: BrowserOpenOptions): Promise<BrowserSession>;
323
+ /**
324
+ * Pick up a session an earlier call opened, by its `id`: a run that spans
325
+ * several calls, or a cron that resumes where the last one stopped. Throws
326
+ * `browser_session_not_found` once it has closed.
327
+ */
328
+ session(id: string): Promise<BrowserSession>;
329
+ }
330
+ /** @internal Factory used by the client; import the `browser` singleton instead. */
331
+ export declare function createBrowser(call: BrowserTransport, steps: BrowserStepRunner): Browser;
332
+ export {};
package/dist/cli.js CHANGED
@@ -15,7 +15,7 @@ var __export = (target, all) => {
15
15
  };
16
16
 
17
17
  // src/usageLog.ts
18
- import { appendFileSync } from "fs";
18
+ import { appendFileSync } from "node:fs";
19
19
  function logUsage(entry) {
20
20
  const file = process.env.MINDSTUDIO_USAGE_LOG;
21
21
  if (!file || typeof entry.billingCost !== "number") {
@@ -825,7 +825,7 @@ var init_metadata = __esm({
825
825
  "renderVideoFromHtmlComposition": {
826
826
  stepType: "renderVideoFromHtmlComposition",
827
827
  description: "Render an HTML composition (HTML, CSS, media and seekable animation on a timeline) to a video file",
828
- usageNotes: "- Renders an HTML composition in HyperFrames' format (https://hyperframes.heygen.com) with HyperFrames 0.8.148, in Chrome off the app's own sandbox; author for that version\n- Pass the composition as `html`, the page itself (up to 10 MB), or as `project`, the URL of a zip of a project's folder (`index.html` at its root, or the file `entryFile` names) or of one HTML file, up to 2 GiB: an app file or any public URL\n- `variables` overrides the composition's `data-composition-variables` defaults, which it reads with `window.__hyperframes.getVariables()`\n- Whatever the composition loads itself (fonts, scripts, images, video) is fetched as it renders, so each is in the project or at a public URL; a private app file needs a signed URL\n- fps 24, 30 or 60 (default 30); quality draft, standard or high (default standard); format mp4 (default), webm or mov (both keep transparency), or gif\n- An mp4, webm or mov renders in chunks of about 10 seconds side by side, so a long video takes little longer than a short one; a call finishes within about 30 minutes, and reports its progress as it goes. A gif renders whole, within 15 minutes\n- A composition HyperFrames can't render fails with HyperFrames' own reason",
828
+ usageNotes: "- Renders an HTML composition in HyperFrames' format (https://hyperframes.heygen.com) with HyperFrames 0.8.186, in Chrome off the app's own sandbox; author for that version\n- Pass the composition as `html`, the page itself (up to 10 MB), or as `project`, the URL of a zip of a project's folder (`index.html` at its root, or the file `entryFile` names) or of one HTML file, up to 2 GiB: an app file or any public URL\n- `variables` overrides the composition's `data-composition-variables` defaults, which it reads with `window.__hyperframes.getVariables()`\n- Whatever the composition loads itself (fonts, scripts, images, video) is fetched as it renders, so each is in the project or at a public URL; a private app file needs a signed URL\n- fps 24, 30 or 60 (default 30); quality draft, standard or high (default standard); format mp4 (default), webm or mov (both keep transparency), or gif\n- An mp4, webm or mov renders in chunks of about 10 seconds side by side, so a long video takes little longer than a short one; a call finishes within about 30 minutes, and reports its progress as it goes. A gif renders whole, within 15 minutes\n- A composition HyperFrames can't render fails with HyperFrames' own reason",
829
829
  inputSchema: { "type": "object", "properties": { "html": { "type": "string", "description": "The composition's HTML, up to 10 MB; give this or project" }, "project": { "type": "string", "description": "URL of a zip of the project's folder, or of one self-contained HTML file; give this or html" }, "entryFile": { "type": "string", "description": "The entry HTML inside the zip, relative to its root; index.html when omitted" }, "variables": { "type": "object", "properties": {}, "required": [], "description": "Values over the composition's declared variables" }, "fps": { "enum": [24, 30, 60], "type": "number", "description": "Frames per second: 24, 30 (default) or 60" }, "quality": { "enum": ["draft", "standard", "high"], "type": "string", "description": "Encode quality: draft, standard (default) or high" }, "format": { "enum": ["mp4", "webm", "mov", "gif"], "type": "string", "description": "mp4 (default), webm or mov (both keep transparency), or gif" }, "intermediateAsset": { "type": "boolean", "description": "When true, the asset is created but hidden from the user's gallery (tagged as intermediate)" } } },
830
830
  outputSchema: { "type": "object", "properties": { "videoUrl": { "type": "string", "description": "URL of the rendered video" }, "durationSec": { "type": "number", "description": "Its length in seconds" }, "frames": { "type": "number", "description": "How many frames it has" } }, "required": ["videoUrl", "durationSec", "frames"] }
831
831
  },
@@ -1360,7 +1360,7 @@ var init_context = __esm({
1360
1360
  als = noopAls;
1361
1361
  try {
1362
1362
  if (typeof process !== "undefined" && process.versions?.node) {
1363
- const mod = await import("async_hooks");
1363
+ const mod = await import("node:async_hooks");
1364
1364
  als = new mod.AsyncLocalStorage();
1365
1365
  }
1366
1366
  } catch {
@@ -1746,9 +1746,9 @@ __export(config_exports, {
1746
1746
  loadConfig: () => loadConfig,
1747
1747
  saveConfig: () => saveConfig
1748
1748
  });
1749
- import { readFileSync, writeFileSync, mkdirSync } from "fs";
1750
- import { join } from "path";
1751
- import { homedir } from "os";
1749
+ import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
1750
+ import { join } from "node:path";
1751
+ import { homedir } from "node:os";
1752
1752
  function configPaths() {
1753
1753
  const dir = join(homedir(), ".mindstudio");
1754
1754
  return { dir, file: join(dir, "config.json") };
@@ -4492,12 +4492,12 @@ var init_readBatching = __esm({
4492
4492
  });
4493
4493
 
4494
4494
  // src/files/store.ts
4495
- import { createHash, randomUUID } from "crypto";
4496
- import { createReadStream, createWriteStream } from "fs";
4497
- import { readFile, stat, writeFile } from "fs/promises";
4498
- import { basename } from "path";
4499
- import { Readable } from "stream";
4500
- import { pipeline } from "stream/promises";
4495
+ import { createHash, randomUUID } from "node:crypto";
4496
+ import { createReadStream, createWriteStream } from "node:fs";
4497
+ import { readFile, stat, writeFile } from "node:fs/promises";
4498
+ import { basename } from "node:path";
4499
+ import { Readable } from "node:stream";
4500
+ import { pipeline } from "node:stream/promises";
4501
4501
  function fileUrl(access, store, key) {
4502
4502
  const path = key.split("/").map(encodeURIComponent).join("/");
4503
4503
  return `/_/files/${access}/${store}/${path}`;
@@ -5058,7 +5058,7 @@ var init_files = __esm({
5058
5058
  });
5059
5059
 
5060
5060
  // src/datasources/source.ts
5061
- import { createHash as createHash2 } from "crypto";
5061
+ import { createHash as createHash2 } from "node:crypto";
5062
5062
  var DICTIONARY_PAGE_ENTRIES, DICTIONARY_PAGE_BYTES, REMOVE_WHERE_MAX_PAGES, DataSource;
5063
5063
  var init_source = __esm({
5064
5064
  "src/datasources/source.ts"() {
@@ -5770,7 +5770,7 @@ var init_events = __esm({
5770
5770
  });
5771
5771
 
5772
5772
  // src/browser/index.ts
5773
- import { randomUUID as randomUUID2 } from "crypto";
5773
+ import { randomUUID as randomUUID2 } from "node:crypto";
5774
5774
  function createBrowser(call, steps) {
5775
5775
  return {
5776
5776
  async open(options = {}) {
@@ -6495,7 +6495,7 @@ var init_schema = __esm({
6495
6495
  });
6496
6496
 
6497
6497
  // src/task/local.ts
6498
- import { randomUUID as randomUUID3 } from "crypto";
6498
+ import { randomUUID as randomUUID3 } from "node:crypto";
6499
6499
  function isPlainObject(value) {
6500
6500
  if (typeof value !== "object" || value === null || Array.isArray(value)) {
6501
6501
  return false;
@@ -7611,7 +7611,7 @@ function resolveToken(provided, config) {
7611
7611
  401
7612
7612
  );
7613
7613
  }
7614
- var DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, toStepLogEvent, stepFailure, MindStudioAgent;
7614
+ var DEFAULT_BASE_URL, DEFAULT_MAX_RETRIES, FILES_RATE_LIMIT_WAIT_MS, toStepLogEvent, stepFailure, MindStudioAgent;
7615
7615
  var init_client = __esm({
7616
7616
  async "src/client.ts"() {
7617
7617
  "use strict";
@@ -7639,6 +7639,7 @@ var init_client = __esm({
7639
7639
  init_metadata();
7640
7640
  DEFAULT_BASE_URL = "https://v1.mindstudio-api.com";
7641
7641
  DEFAULT_MAX_RETRIES = 3;
7642
+ FILES_RATE_LIMIT_WAIT_MS = 75e3;
7642
7643
  toStepLogEvent = (event) => ({
7643
7644
  value: event.value,
7644
7645
  tag: event.tag,
@@ -8902,12 +8903,30 @@ var init_client = __esm({
8902
8903
  /**
8903
8904
  * @internal Transport for the `files` namespace — POST /_internal/v2/files/<op>
8904
8905
  * with the raw hook token (mirrors `_executeDbBatch`).
8906
+ *
8907
+ * Waits out the platform's per-app limit on file calls: its 429 comes before
8908
+ * the call does anything, whatever the op, so the call is sent again every
8909
+ * few seconds for a little over the limit's one-minute window, and only then
8910
+ * throws `rate_limited`. An app moving files flat out runs at the limit
8911
+ * rather than failing past it.
8905
8912
  */
8906
8913
  async _filesRequest(op, body) {
8907
- return this._brokeredRequest("files", op, body, {
8908
- fallbackMessage: "File operation failed",
8909
- fallbackCode: "file_error"
8910
- });
8914
+ const giveUpAt = Date.now() + FILES_RATE_LIMIT_WAIT_MS;
8915
+ while (true) {
8916
+ try {
8917
+ return await this._brokeredRequest("files", op, body, {
8918
+ fallbackMessage: "File operation failed",
8919
+ fallbackCode: "file_error"
8920
+ });
8921
+ } catch (err) {
8922
+ if (!(err instanceof MindStudioError) || err.status !== 429 || Date.now() >= giveUpAt) {
8923
+ throw err;
8924
+ }
8925
+ await new Promise(
8926
+ (resolve) => setTimeout(resolve, 4e3 + Math.random() * 2e3)
8927
+ );
8928
+ }
8929
+ }
8911
8930
  }
8912
8931
  /**
8913
8932
  * @internal Transport for the `dataSources` namespace —
@@ -10012,9 +10031,9 @@ var mcp_exports = {};
10012
10031
  __export(mcp_exports, {
10013
10032
  startMcpServer: () => startMcpServer
10014
10033
  });
10015
- import { createInterface } from "readline";
10016
- import { readFileSync as readFileSync2 } from "fs";
10017
- import { basename as basename2, extname } from "path";
10034
+ import { createInterface } from "node:readline";
10035
+ import { readFileSync as readFileSync2 } from "node:fs";
10036
+ import { basename as basename2, extname } from "node:path";
10018
10037
  function send(message) {
10019
10038
  process.stdout.write(JSON.stringify(message) + "\n");
10020
10039
  }
@@ -10067,7 +10086,7 @@ async function startMcpServer(options) {
10067
10086
  capabilities: { tools: {} },
10068
10087
  serverInfo: {
10069
10088
  name: "mindstudio-agent",
10070
- version: "0.1.175"
10089
+ version: "0.1.177"
10071
10090
  },
10072
10091
  instructions: 'Welcome to MindStudio \u2014 a platform with 200+ AI models, 850+ third-party integrations, and pre-built agents.\n\nGetting started:\n1. Call `ask` with any question about the SDK \u2014 it knows every action, model, and connector and returns working code with real model IDs and config options. Examples: ask("generate an image with FLUX"), ask("what models support vision?"), ask("how do I send a Slack message?").\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, pass its public image URL to `changeProfilePicture`.\n4. For manual browsing, 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.'
10073
10092
  });
@@ -10519,10 +10538,10 @@ var init_mcp = __esm({
10519
10538
 
10520
10539
  // src/cli.ts
10521
10540
  init_usageLog();
10522
- import { parseArgs } from "util";
10523
- import { execSync } from "child_process";
10524
- import { readFileSync as readFileSync3 } from "fs";
10525
- import { basename as basename3, extname as extname2 } from "path";
10541
+ import { parseArgs } from "node:util";
10542
+ import { execSync } from "node:child_process";
10543
+ import { readFileSync as readFileSync3 } from "node:fs";
10544
+ import { basename as basename3, extname as extname2 } from "node:path";
10526
10545
  var HELP = `Usage: mindstudio <command> [options]
10527
10546
 
10528
10547
  Ask:
@@ -11107,7 +11126,7 @@ function isNewerVersion(current, latest) {
11107
11126
  return false;
11108
11127
  }
11109
11128
  async function checkForUpdate() {
11110
- const currentVersion = "0.1.175";
11129
+ const currentVersion = "0.1.177";
11111
11130
  if (!currentVersion || process.env.MINDSTUDIO_NO_UPDATE_CHECK) {
11112
11131
  return null;
11113
11132
  }
@@ -11142,7 +11161,7 @@ async function checkForUpdate() {
11142
11161
  }
11143
11162
  }
11144
11163
  function printUpdateNotice(latestVersion) {
11145
- const currentVersion = "0.1.175";
11164
+ const currentVersion = "0.1.177";
11146
11165
  process.stderr.write(
11147
11166
  `
11148
11167
  ${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
@@ -11155,7 +11174,7 @@ function isStandaloneBinary() {
11155
11174
  return !argv1.includes("node_modules");
11156
11175
  }
11157
11176
  async function cmdUpdate() {
11158
- const currentVersion = "0.1.175";
11177
+ const currentVersion = "0.1.177";
11159
11178
  process.stderr.write(
11160
11179
  ` ${ansi2.gray("Current version:")} ${currentVersion}
11161
11180
  `
@@ -11296,7 +11315,7 @@ async function cmdLogin(options) {
11296
11315
  process.stderr.write("\n");
11297
11316
  printLogo();
11298
11317
  process.stderr.write("\n");
11299
- const ver = "0.1.175";
11318
+ const ver = "0.1.177";
11300
11319
  process.stderr.write(
11301
11320
  ` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
11302
11321
  `
@@ -11624,7 +11643,7 @@ async function main() {
11624
11643
  const updatePromise = command !== "mcp" && command !== "login" && command !== "update" ? checkForUpdate() : Promise.resolve(null);
11625
11644
  try {
11626
11645
  if (command === "version" || command === "-v") {
11627
- process.stdout.write("0.1.175\n");
11646
+ process.stdout.write("0.1.177\n");
11628
11647
  return;
11629
11648
  }
11630
11649
  if (command === "login") {