@mindstudio-ai/agent 0.1.174 → 0.1.175

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/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ What changed in `@mindstudio-ai/agent`, newest first, each version under its own
4
4
 
5
5
  Versions before 0.1.163 aren't recorded here.
6
6
 
7
+ ## 0.1.175
8
+
9
+ ### New
10
+
11
+ - `defineTable` takes `indexes`: column groups, each a plain (non-unique) index for the columns the table's queries filter or sort by, like `indexes: [['status'], ['customerId', 'createdAt']]`. The platform adds and drops them in place as the list changes, without rebuilding the table. A table can declare up to 16. Check: a table whose queries filter a column that isn't the first of a `unique` group reads every row; declaring an index on it makes those lookups.
12
+ - A query that took a while because it read every row of a table logs `[mindstudio] A query read every row of '<table>' (<n> ms)…`, from the platform's plan of it, at most once per statement shape every 15 minutes. An index on the columns it filters or sorts by makes it a lookup.
13
+
7
14
  ## 0.1.174
8
15
 
9
16
  ### New
package/dist/cli.js CHANGED
@@ -1368,6 +1368,26 @@ var init_context = __esm({
1368
1368
  }
1369
1369
  });
1370
1370
 
1371
+ // src/db/scanHints.ts
1372
+ function warnTableScans(scans) {
1373
+ if (!Array.isArray(scans)) {
1374
+ return;
1375
+ }
1376
+ for (const scan of scans) {
1377
+ if (typeof scan?.table !== "string" || typeof scan?.ms !== "number" || !Number.isFinite(scan.ms)) {
1378
+ continue;
1379
+ }
1380
+ console.warn(
1381
+ `[mindstudio] A query read every row of '${scan.table}' (${Math.round(scan.ms)} ms). An index on the columns it filters or sorts by (defineTable's indexes) would make it a lookup.`
1382
+ );
1383
+ }
1384
+ }
1385
+ var init_scanHints = __esm({
1386
+ "src/db/scanHints.ts"() {
1387
+ "use strict";
1388
+ }
1389
+ });
1390
+
1371
1391
  // src/db-ws.ts
1372
1392
  function isReadOnlySql(sql) {
1373
1393
  const head = sql.trimStart().slice(0, 8).toUpperCase();
@@ -1435,6 +1455,7 @@ function deliver(self, msg) {
1435
1455
  )
1436
1456
  );
1437
1457
  } else {
1458
+ warnTableScans(msg.scans);
1438
1459
  p.resolve(msg.results);
1439
1460
  }
1440
1461
  }
@@ -1629,6 +1650,7 @@ var DB_WS_SUBPROTOCOL, WS_ACK_TIMEOUT_MS, WS_IDLE_TIMEOUT_MS, WS_OPEN_TIMEOUT_MS
1629
1650
  var init_db_ws = __esm({
1630
1651
  "src/db-ws.ts"() {
1631
1652
  "use strict";
1653
+ init_scanHints();
1632
1654
  init_errors();
1633
1655
  DB_WS_SUBPROTOCOL = "ms-db-v2";
1634
1656
  WS_ACK_TIMEOUT_MS = 2e4;
@@ -7604,6 +7626,7 @@ var init_client = __esm({
7604
7626
  init_sql();
7605
7627
  init_time();
7606
7628
  init_readBatching();
7629
+ init_scanHints();
7607
7630
  init_files();
7608
7631
  init_datasources();
7609
7632
  init_voice();
@@ -9084,6 +9107,7 @@ var init_client = __esm({
9084
9107
  throw new MindStudioError(`[db] ${message}`, code, res.status);
9085
9108
  }
9086
9109
  const data = await res.json();
9110
+ warnTableScans(data.scans);
9087
9111
  return data.results;
9088
9112
  }
9089
9113
  /**
@@ -10043,7 +10067,7 @@ async function startMcpServer(options) {
10043
10067
  capabilities: { tools: {} },
10044
10068
  serverInfo: {
10045
10069
  name: "mindstudio-agent",
10046
- version: "0.1.174"
10070
+ version: "0.1.175"
10047
10071
  },
10048
10072
  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.'
10049
10073
  });
@@ -11083,7 +11107,7 @@ function isNewerVersion(current, latest) {
11083
11107
  return false;
11084
11108
  }
11085
11109
  async function checkForUpdate() {
11086
- const currentVersion = "0.1.174";
11110
+ const currentVersion = "0.1.175";
11087
11111
  if (!currentVersion || process.env.MINDSTUDIO_NO_UPDATE_CHECK) {
11088
11112
  return null;
11089
11113
  }
@@ -11118,7 +11142,7 @@ async function checkForUpdate() {
11118
11142
  }
11119
11143
  }
11120
11144
  function printUpdateNotice(latestVersion) {
11121
- const currentVersion = "0.1.174";
11145
+ const currentVersion = "0.1.175";
11122
11146
  process.stderr.write(
11123
11147
  `
11124
11148
  ${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
@@ -11131,7 +11155,7 @@ function isStandaloneBinary() {
11131
11155
  return !argv1.includes("node_modules");
11132
11156
  }
11133
11157
  async function cmdUpdate() {
11134
- const currentVersion = "0.1.174";
11158
+ const currentVersion = "0.1.175";
11135
11159
  process.stderr.write(
11136
11160
  ` ${ansi2.gray("Current version:")} ${currentVersion}
11137
11161
  `
@@ -11272,7 +11296,7 @@ async function cmdLogin(options) {
11272
11296
  process.stderr.write("\n");
11273
11297
  printLogo();
11274
11298
  process.stderr.write("\n");
11275
- const ver = "0.1.174";
11299
+ const ver = "0.1.175";
11276
11300
  process.stderr.write(
11277
11301
  ` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
11278
11302
  `
@@ -11600,7 +11624,7 @@ async function main() {
11600
11624
  const updatePromise = command !== "mcp" && command !== "login" && command !== "update" ? checkForUpdate() : Promise.resolve(null);
11601
11625
  try {
11602
11626
  if (command === "version" || command === "-v") {
11603
- process.stdout.write("0.1.174\n");
11627
+ process.stdout.write("0.1.175\n");
11604
11628
  return;
11605
11629
  }
11606
11630
  if (command === "login") {
package/dist/index.d.ts CHANGED
@@ -1860,6 +1860,23 @@ interface DefineTableOptions<T = unknown> {
1860
1860
  * ```
1861
1861
  */
1862
1862
  unique?: (keyof T & string)[][];
1863
+ /**
1864
+ * Indexes for the table, for the columns its queries filter or sort by.
1865
+ * Each entry is an array of column names, most selective first; the
1866
+ * platform creates a plain (non-unique) SQLite index for each, and adds or
1867
+ * drops one in place when the list changes, without rebuilding the table.
1868
+ * An index makes a lookup on its columns read a few rows rather than the
1869
+ * whole table, and costs a little on every write, so declare the ones the
1870
+ * app's queries use.
1871
+ *
1872
+ * @example
1873
+ * ```ts
1874
+ * db.defineTable<Order>('orders', {
1875
+ * indexes: [['status'], ['customerId', 'createdAt']],
1876
+ * });
1877
+ * ```
1878
+ */
1879
+ indexes?: (keyof T & string)[][];
1863
1880
  /**
1864
1881
  * Default values for columns, applied client-side in `push()` and
1865
1882
  * `upsert()`. Explicit values in the input override defaults.
package/dist/index.js CHANGED
@@ -125,6 +125,21 @@ function runWithContext(ctx, fn) {
125
125
  return als.run(ctx, fn);
126
126
  }
127
127
 
128
+ // src/db/scanHints.ts
129
+ function warnTableScans(scans) {
130
+ if (!Array.isArray(scans)) {
131
+ return;
132
+ }
133
+ for (const scan of scans) {
134
+ if (typeof scan?.table !== "string" || typeof scan?.ms !== "number" || !Number.isFinite(scan.ms)) {
135
+ continue;
136
+ }
137
+ console.warn(
138
+ `[mindstudio] A query read every row of '${scan.table}' (${Math.round(scan.ms)} ms). An index on the columns it filters or sorts by (defineTable's indexes) would make it a lookup.`
139
+ );
140
+ }
141
+ }
142
+
128
143
  // src/db-ws.ts
129
144
  var DB_WS_SUBPROTOCOL = "ms-db-v2";
130
145
  var WS_ACK_TIMEOUT_MS = 2e4;
@@ -210,6 +225,7 @@ function deliver(self, msg) {
210
225
  )
211
226
  );
212
227
  } else {
228
+ warnTableScans(msg.scans);
213
229
  p.resolve(msg.results);
214
230
  }
215
231
  }
@@ -8743,6 +8759,7 @@ var MindStudioAgent = class {
8743
8759
  throw new MindStudioError(`[db] ${message}`, code, res.status);
8744
8760
  }
8745
8761
  const data = await res.json();
8762
+ warnTableScans(data.scans);
8746
8763
  return data.results;
8747
8764
  }
8748
8765
  /**