@mindstudio-ai/agent 0.1.100 → 0.1.102
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 +60 -0
- package/dist/cli.js +113 -22
- package/dist/index.d.ts +395 -7
- package/dist/index.js +236 -14
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +113 -22
- package/llms.txt +15 -11
- package/package.json +1 -1
package/llms.txt
CHANGED
|
@@ -19,7 +19,7 @@ For specific use cases:
|
|
|
19
19
|
- **Pre-built agents**: Call `listAgents()` to see what's available → `runAgent({ appId })` to execute one. **Important:** Not all agents are configured for API use. Do not try to run an agent just because it appears in the list — only run agents the user specifically asks you to run.
|
|
20
20
|
- **Model selection**: Call `listModelsSummary()` or `listModelsSummaryByType("llm_chat")` to browse models, then pass the model ID as `modelOverride.model` to actions like `generateText`. Use the summary endpoints (not `listModels`) to keep token usage low.
|
|
21
21
|
- **Cost estimation**: AI-powered actions (text generation, image generation, video, audio, etc.) cost money. Call `estimateStepCost(stepType, stepInput)` before running these and confirm with the user before proceeding — unless they've explicitly given permission to go ahead. Non-AI actions (data lookups, OAuth connectors, etc.) are generally free.
|
|
22
|
-
- **Task agents**: For multi-step tasks that need autonomous tool use (research, content creation, data enrichment), use `runTask()`. Provide a prompt, input, tools, an output contract, and a tool-use model id. The SDK runs a tool-use loop — calling the model, executing tools, feeding results back — until structured output is produced. Tools are SDK action names and/or your own app methods, written as `{ appMethod: "
|
|
22
|
+
- **Task agents**: For multi-step tasks that need autonomous tool use (research, content creation, data enrichment), use `runTask()`. Provide a prompt, input, tools, an output contract, and a tool-use model id. The SDK runs a tool-use loop — calling the model, executing tools, feeding results back — until structured output is produced. Tools are SDK action names and/or your own app methods, written as `{ appMethod: "save-vendor", description: "when to use it" }`. App methods run as the user who invoked the method that started the task, with their roles, so the agent can read and write app state on their behalf. Prefer `outputSchema` for the output contract: plain JSON Schema (`type`/`properties`/`required`/`enum`/`items`; nullable via type arrays like `["string","null"]` — no `oneOf`/`$ref`/`nullable`). Output is validated every turn with automatic repair, `result.output` is fully typed from the schema (no generic argument, no `parsedSuccessfully` check), and the call throws `MindStudioError` code `task_output_schema_mismatch` if the agent cannot produce conforming output. Example: `runTask({ prompt: "Research this restaurant and save it", input: { name: "Tartine" }, tools: ["searchGoogle", "fetchUrl", { appMethod: "saveRestaurant", description: "Persist the researched restaurant." }], outputSchema: { type: "object", properties: { name: { type: "string" }, url: { type: ["string", "null"] } }, required: ["name"] }, model: yourModelId })`. The legacy `structuredOutputExample` option (an example object the model imitates) still works but is unvalidated — check `result.parsedSuccessfully` before using its output. Pass a current tool-use model id (call `listModels` or ask). Don't hardcode one.
|
|
23
23
|
|
|
24
24
|
## Install
|
|
25
25
|
|
|
@@ -729,31 +729,35 @@ Scrape public profile data from a LinkedIn profile page.
|
|
|
729
729
|
#### scrapeUrl
|
|
730
730
|
Extract text, HTML, or structured content from one or more web pages.
|
|
731
731
|
- Accepts a single URL or multiple URLs (as a JSON array, comma-separated, or newline-separated).
|
|
732
|
-
- Output format controls the result shape: "text" returns markdown, "html" returns raw HTML, "json" returns structured scraper data.
|
|
732
|
+
- Output format controls the result shape: "text" returns markdown, "html" returns raw HTML, "json" returns structured scraper data, "summary" returns a model-written summary and requires the "firecrawl" service.
|
|
733
733
|
- Can optionally capture a screenshot of each page.
|
|
734
|
-
-
|
|
735
|
-
-
|
|
734
|
+
- Handles bot protection automatically; no proxy or rendering configuration is needed.
|
|
735
|
+
- Input: `{ url: string, service?: "default" | "firecrawl", autoEnhance?: boolean, outputFormat?: "text" | "json" | "html" | "summary", pageOptions?: { onlyMainContent: boolean, screenshot: boolean, waitFor: number, replaceAllPathsWithAbsolutePaths: boolean, headers: object, removeTags: string[], mobile: boolean } }`
|
|
736
|
+
- Output: `{ content: string | string[] | { text: string, html: string, json?: object, screenshotUrl?: string, metadata?: { title: string, description: string, url: string, image: string }, error?: { code: string, message: string }, costUnits?: number } | { text: string, html: string, json?: object, screenshotUrl?: string, metadata?: { title: string, description: string, url: string, image: string }, error?: { code: string, message: string }, costUnits?: number }[], screenshot?: string | string[] }`
|
|
736
737
|
|
|
737
738
|
#### scrapeXPost
|
|
738
739
|
Scrape data from a single X (Twitter) post by URL.
|
|
739
740
|
- Returns structured post data (text, html, optional json/screenshot/metadata).
|
|
740
741
|
- Optionally saves the text content to a variable.
|
|
741
742
|
- Input: `{ url: string }`
|
|
742
|
-
- Output: `{ post: { text: string, html: string, json?: object, screenshotUrl?: string, metadata?: { title: string, description: string, url: string, image: string }, error?: { code: string, message: string } } }`
|
|
743
|
+
- Output: `{ post: { text: string, html: string, json?: object, screenshotUrl?: string, metadata?: { title: string, description: string, url: string, image: string }, error?: { code: string, message: string }, costUnits?: number } }`
|
|
743
744
|
|
|
744
745
|
#### scrapeXProfile
|
|
745
746
|
Scrape public profile data from an X (Twitter) account by URL.
|
|
746
747
|
- Returns structured profile data.
|
|
747
748
|
- Optionally saves the result to a variable.
|
|
748
749
|
- Input: `{ url: string }`
|
|
749
|
-
- Output: `{ profile: { text: string, html: string, json?: object, screenshotUrl?: string, metadata?: { title: string, description: string, url: string, image: string }, error?: { code: string, message: string } } }`
|
|
750
|
+
- Output: `{ profile: { text: string, html: string, json?: object, screenshotUrl?: string, metadata?: { title: string, description: string, url: string, image: string }, error?: { code: string, message: string }, costUnits?: number } }`
|
|
750
751
|
|
|
751
752
|
#### screenshotUrl
|
|
752
753
|
Capture a screenshot of a web page as a PNG image.
|
|
753
754
|
- Takes a viewport or full-page screenshot of the given URL.
|
|
754
755
|
- Returns a CDN-hosted PNG image URL.
|
|
755
|
-
- Viewport mode captures only the visible area; fullPage captures the entire scrollable page.
|
|
756
|
-
-
|
|
756
|
+
- Viewport mode captures only the visible area; fullPage captures the entire scrollable page, scrolling it first so lazy-loaded content is included.
|
|
757
|
+
- Works on sites behind bot protection (Cloudflare and similar).
|
|
758
|
+
- Cookie-consent banners and similar overlays are suppressed automatically.
|
|
759
|
+
- `width` and `height` are the exact output pixel dimensions.
|
|
760
|
+
- You can add a delay or wait for a CSS selector before capturing. A selector that never appears fails the step rather than capturing early.
|
|
757
761
|
- Input: `{ url: string, mode?: "viewport" | "fullPage", width?: number, height?: number, delay?: number, waitFor?: string }`
|
|
758
762
|
- Output: `{ screenshotUrl: string }`
|
|
759
763
|
|
|
@@ -1806,7 +1810,7 @@ const { url } = await mindstudio.uploadFile(readFileSync('photo.png'), { extensi
|
|
|
1806
1810
|
Output: `{ url: string }` — The permanent public CDN URL.
|
|
1807
1811
|
|
|
1808
1812
|
#### `files` — per-app file storage (private by default)
|
|
1809
|
-
Typed per-app file storage: user uploads, generated documents, images, marketing assets. Think of a store as a CDN-backed bucket the app talks to — NOT app-defined state like a `db` table. The API is *shaped* like the `db` namespace (define a store at module scope, then read/write), but its contents aren't modeled by code, and one store is shared across dev and prod (a file uploaded in the dev editor is already live in prod at the same URL). Creates are safe by default because keys default to unique (UUID, or a content-addressed hash); the operations to treat with care are `delete(key)` and overwriting a fixed key. Files are served on the app's own domain: private stores (the default) are signed / session-authorized; public stores are world-readable, CDN-served, and images resize via query params (e.g. `?w=400&h=300&fit=cover`). Prefer this over the deprecated `uploadFile()` for app storage.
|
|
1813
|
+
Typed per-app file storage: user uploads, generated documents, images, marketing assets. Think of a store as a CDN-backed bucket the app talks to — NOT app-defined state like a `db` table. The API is *shaped* like the `db` namespace (define a store at module scope, then read/write), but its contents aren't modeled by code, and one store is shared across dev and prod (a file uploaded in the dev editor is already live in prod at the same URL). Creates are safe by default because keys default to unique (UUID, or a content-addressed hash); the operations to treat with care are `delete(key)` and overwriting a fixed key. Public objects are CDN-cached per their `Cache-Control`, set at put time via `cacheControl`: auto-minted keys default to immutable (cache-forever — the key is never reused), and named keys default to `public, max-age=300`, so overwriting one propagates publicly within ~5 minutes; pass `cacheControl` to tune (e.g. `'public, max-age=60'` for near-live config, `'no-store'` to revalidate every read). Files are served on the app's own domain: private stores (the default) are signed / session-authorized; public stores are world-readable, CDN-served, and images resize via query params (e.g. `?w=400&h=300&fit=cover`). Prefer this over the deprecated `uploadFile()` for app storage.
|
|
1810
1814
|
|
|
1811
1815
|
```typescript
|
|
1812
1816
|
import { files } from '@mindstudio-ai/agent';
|
|
@@ -1822,7 +1826,7 @@ await file.shareUrl(); // absolute signed URL that works with NO session (email/
|
|
|
1822
1826
|
```
|
|
1823
1827
|
|
|
1824
1828
|
Store methods:
|
|
1825
|
-
- `put(content, { key?, contentType?, filename?, contentAddressed? })` → `StoredFile`. `content` is `Buffer | Uint8Array | string`. Omit `key` for a random UUID; `contentAddressed: true` derives an immutable `<sha256>.<ext>` key.
|
|
1829
|
+
- `put(content, { key?, contentType?, filename?, contentAddressed?, cacheControl? })` → `StoredFile`. `content` is `Buffer | Uint8Array | string`. Omit `key` for a random UUID; `contentAddressed: true` derives an immutable `<sha256>.<ext>` key. `cacheControl` sets the CDN caching of a public object (defaults: auto-minted keys immutable, named keys `public, max-age=300`).
|
|
1826
1830
|
- `get(key)` → `Buffer` · `head(key)` → `StoredFile` · `exists(key)` → `boolean`
|
|
1827
1831
|
- `list({ prefix?, cursor?, limit? })` → `{ files: StoredFile[]; cursor? }`
|
|
1828
1832
|
- `delete(key)` → `void`
|
|
@@ -1835,7 +1839,7 @@ Store methods:
|
|
|
1835
1839
|
User uploads (client-direct — bytes go straight to storage, never through the app backend): a backend method mints a token, the frontend submits it with `@mindstudio-ai/interface`.
|
|
1836
1840
|
```typescript
|
|
1837
1841
|
// backend method
|
|
1838
|
-
const token = await Uploads.createUploadToken({ contentType, maxSize: 25 * 1024 * 1024 });
|
|
1842
|
+
const token = await Uploads.createUploadToken({ contentType, maxSize: 25 * 1024 * 1024 }); // also accepts cacheControl
|
|
1839
1843
|
return token;
|
|
1840
1844
|
// frontend (@mindstudio-ai/interface)
|
|
1841
1845
|
import { platform } from '@mindstudio-ai/interface';
|