@mindstudio-ai/agent 0.1.102 → 0.1.104

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/llms.txt CHANGED
@@ -642,23 +642,6 @@ Send data to a Zapier Zap via webhook and return the response.
642
642
  - Input: `{ webhookUrl: string, input: object }`
643
643
  - Output: `{ data: unknown }`
644
644
 
645
- #### queryAppDatabase
646
- Execute a SQL query against the app managed database.
647
- - Executes raw SQL against a SQLite database managed by the app.
648
- - For SELECT queries, returns rows as JSON.
649
- - For INSERT/UPDATE/DELETE, returns the number of affected rows.
650
- - Use {{variables}} directly in your SQL. By default they are automatically extracted
651
- and passed as safe parameterized values (preventing SQL injection).
652
- Example: INSERT INTO contacts (name, comment) VALUES ({{name}}, {{comment}})
653
- - Full MindStudio handlebars syntax is supported, including helpers like {{json myVar}},
654
- {{get myVar "$.path"}}, {{global.orgName}}, etc.
655
- - Set parameterize to false for raw/dynamic SQL where variables are interpolated directly
656
- into the query string. Use this when another step generates full or partial SQL, e.g.
657
- a bulk INSERT with a precomputed VALUES list. The user is responsible for sanitization
658
- when parameterize is false.
659
- - Input: `{ databaseId: string, sql: string, parameterize?: boolean }`
660
- - Output: `{ rows: unknown[], changes: number }`
661
-
662
645
  #### queryDataSource
663
646
  Legacy v1 data sources. v2 apps should use `dataSources.defineDataSource()` from @mindstudio-ai/agent instead, which owns parsing, chunking, embedding and citations. Search a vector data source (RAG) and return relevant document chunks.
664
647
  - Queries a vectorized data source and returns the most relevant chunks.
@@ -776,8 +759,10 @@ Search the web using Google and return structured results.
776
759
  - Defaults to us/english, but can optionally specify country and/or language.
777
760
  - Defaults to any time, but can optionally specify last hour, last day, week, month, or year.
778
761
  - Defaults to top 30 results, but can specify 1 to 100 results to return.
779
- - Input: `{ query: string, exportType: "text" | "json", countryCode?: string, languageCode?: string, dateRange?: "hour" | "day" | "week" | "month" | "year" | "any", numResults?: number }`
780
- - Output: `{ results: { title: string, description: string, url: string }[] }`
762
+ - Set fetchTopN to also read the page content of the first N results in the same step, instead of following up with a separate Scrape URL step per result. Costs meaningfully more (each page is a full scrape), so ask for the fewest you need.
763
+ - Also returns Google's "people also ask" and related searches when available, which are useful for choosing a follow-up query.
764
+ - Input: `{ query: string, exportType: "text" | "json", countryCode?: string, languageCode?: string, dateRange?: "hour" | "day" | "week" | "month" | "year" | "any", numResults?: number, fetchTopN?: number }`
765
+ - Output: `{ results: { title: string, description: string, url: string, content?: string }[], peopleAlsoAsk?: { question?: string, snippet?: string, link?: string }[], relatedSearches?: string[] }`
781
766
 
782
767
  #### searchGoogleImages
783
768
  Search Google Images and return image results with URLs and metadata.
@@ -1852,6 +1837,42 @@ Generated assets: any action that produces a file (`generateImage`, `generateVid
1852
1837
  const { imageUrl } = await mindstudio.generateImage({ prompt: 'a red sneaker' }, { store: Assets });
1853
1838
  ```
1854
1839
 
1840
+ #### `db` — typed tables over the app's managed SQLite
1841
+
1842
+ Chainable, typed collection API over the app's managed databases. Define a table at module scope; every read/write is lazy until awaited, and reads/writes can be batched into one round trip with `db.batch()`.
1843
+ ```typescript
1844
+ import { db } from '@mindstudio-ai/agent';
1845
+
1846
+ export const Orders = db.defineTable<Order>('orders');
1847
+
1848
+ // Reads — filters compile to SQL WHERE when possible
1849
+ const recent = await Orders.filter(o => o.status === 'paid').sortBy(o => o.created_at).reverse().take(20);
1850
+ // Comparing to an outer-scope value? Use the bindings form so it compiles to SQL:
1851
+ const mine = await Orders.filter((o, $) => o.requestedBy === $.uid, { uid: auth.userId }); // bindings: lifts closure var so filter compiles to SQL
1852
+
1853
+ // Writes
1854
+ const order = await Orders.push({ item: 'Laptop', amount: 999, status: 'pending' });
1855
+ await Orders.update(order.id, { status: 'approved' });
1856
+ ```
1857
+
1858
+ Aggregation — `count()`, `sum(fn)`, `avg(fn)`, `countDistinct(fn)`, and `aggregate(spec)` compile to SQL aggregates (COUNT/TOTAL/AVG/GROUP BY); no rows are fetched, so they stay cheap at any table size. Never page a whole table into memory to compute a summary.
1859
+ ```typescript
1860
+ const top = await Answers
1861
+ .filter((a, $) => a.surveyId === $.surveyId, { surveyId }) // bindings: compiles to SQL
1862
+ .aggregate({
1863
+ by: ['questionId', 'dimension'],
1864
+ select: { n: { count: true }, total: { sum: 'score' }, avgScore: { avg: 'score' }, respondents: { countDistinct: 'responseId' } },
1865
+ orderBy: 'total', desc: true, limit: 20,
1866
+ });
1867
+ // Array<{ questionId, dimension, n: number, total: number, avgScore: number | null, respondents: number }>
1868
+ ```
1869
+ Select terms: `{ count: true }` · `{ sum: 'col' }` · `{ avg: 'col' }` · `{ min: 'col' }` · `{ max: 'col' }` · `{ countDistinct: 'col' }` (string column names). Omit `by` for whole-set aggregates (single object). Empty set: count/countDistinct 0, sum 0, avg/min/max null.
1870
+
1871
+ Raw SQL escape hatch — `db.sql<T>(query, params?, { database? })` runs read-only raw SQL (joins, subqueries, window functions) against the app's own managed database. SELECT/WITH only; writes throw — use Table methods. Lazy and batchable. Last resort: prefer the typed API (including `aggregate()`) whenever it can express the query; raw rows may not exactly match the typed API's value representations.
1872
+ ```typescript
1873
+ const rows = await db.sql<{ questionId: string; n: number }>('SELECT questionId, COUNT(*) AS n FROM answers WHERE surveyId = ? GROUP BY questionId', [surveyId]);
1874
+ ```
1875
+
1855
1876
  #### `dataSources` — searchable document corpora (RAG)
1856
1877
 
1857
1878
  Declare a data source at module scope and import the handle. The platform owns parsing, chunking, embedding, storage and tenant isolation; every hit returns a citation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindstudio-ai/agent",
3
- "version": "0.1.102",
3
+ "version": "0.1.104",
4
4
  "description": "TypeScript SDK for MindStudio direct step execution",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",