@mindstudio-ai/agent 0.1.11 → 0.1.13

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/cli.js CHANGED
@@ -1523,7 +1523,15 @@ var init_sql = __esm({
1523
1523
  "src/db/sql.ts"() {
1524
1524
  "use strict";
1525
1525
  USER_PREFIX = "@@user@@";
1526
- SYSTEM_COLUMNS = /* @__PURE__ */ new Set(["id", "createdAt", "updatedAt", "lastUpdatedBy"]);
1526
+ SYSTEM_COLUMNS = /* @__PURE__ */ new Set([
1527
+ "id",
1528
+ "created_at",
1529
+ "createdAt",
1530
+ "updated_at",
1531
+ "updatedAt",
1532
+ "last_updated_by",
1533
+ "lastUpdatedBy"
1534
+ ]);
1527
1535
  }
1528
1536
  });
1529
1537
 
@@ -3074,13 +3082,13 @@ function sleep2(ms) {
3074
3082
  return new Promise((resolve) => setTimeout(resolve, ms));
3075
3083
  }
3076
3084
  function resolveToken(provided, config) {
3085
+ if (process.env.CALLBACK_TOKEN)
3086
+ return { token: process.env.CALLBACK_TOKEN, authType: "internal" };
3077
3087
  if (provided) return { token: provided, authType: "apiKey" };
3078
3088
  if (process.env.MINDSTUDIO_API_KEY)
3079
3089
  return { token: process.env.MINDSTUDIO_API_KEY, authType: "apiKey" };
3080
3090
  if (config?.apiKey)
3081
3091
  return { token: config.apiKey, authType: "apiKey" };
3082
- if (process.env.CALLBACK_TOKEN)
3083
- return { token: process.env.CALLBACK_TOKEN, authType: "internal" };
3084
3092
  throw new MindStudioError(
3085
3093
  "No API key provided. Run `mindstudio login`, pass `apiKey` to the constructor, or set the MINDSTUDIO_API_KEY environment variable.",
3086
3094
  "missing_api_key",
@@ -3338,10 +3346,12 @@ var init_client = __esm({
3338
3346
  );
3339
3347
  }
3340
3348
  if (!res.ok) {
3349
+ const errorBody = await res.json().catch(() => ({}));
3341
3350
  throw new MindStudioError(
3342
- `Poll request failed: ${res.status} ${res.statusText}`,
3343
- "poll_error",
3344
- res.status
3351
+ errorBody.message ?? errorBody.error ?? `Poll request failed: ${res.status} ${res.statusText}`,
3352
+ errorBody.code ?? "poll_error",
3353
+ res.status,
3354
+ errorBody
3345
3355
  );
3346
3356
  }
3347
3357
  const poll = await res.json();
@@ -3606,12 +3616,24 @@ var init_client = __esm({
3606
3616
  });
3607
3617
  if (!res.ok) {
3608
3618
  let message = `Database query failed: ${res.status} ${res.statusText}`;
3619
+ let code = "db_query_error";
3609
3620
  try {
3610
- const body = await res.json();
3611
- if (body.error) message = body.error;
3621
+ const text = await res.text();
3622
+ try {
3623
+ const body = JSON.parse(text);
3624
+ const errMsg = body.error ?? body.message ?? body.details;
3625
+ if (errMsg) message = errMsg;
3626
+ if (body.code) code = body.code;
3627
+ } catch {
3628
+ if (text && text.length < 500) message = text;
3629
+ }
3612
3630
  } catch {
3613
3631
  }
3614
- throw new MindStudioError(message, "db_query_error", res.status);
3632
+ throw new MindStudioError(
3633
+ `[db] ${message}`,
3634
+ code,
3635
+ res.status
3636
+ );
3615
3637
  }
3616
3638
  const data = await res.json();
3617
3639
  return data.results;
@@ -3795,10 +3817,12 @@ var init_client = __esm({
3795
3817
  headers: options.type ? { "Content-Type": options.type } : {}
3796
3818
  });
3797
3819
  if (!res.ok) {
3820
+ const errorBody = await res.json().catch(() => ({}));
3798
3821
  throw new MindStudioError(
3799
- `Upload failed: ${res.status} ${res.statusText}`,
3800
- "upload_error",
3801
- res.status
3822
+ errorBody.message ?? errorBody.error ?? `Upload failed: ${res.status} ${res.statusText}`,
3823
+ errorBody.code ?? "upload_error",
3824
+ res.status,
3825
+ errorBody
3802
3826
  );
3803
3827
  }
3804
3828
  return { url: data.url };
@@ -3868,7 +3892,7 @@ async function startMcpServer(options) {
3868
3892
  capabilities: { tools: {} },
3869
3893
  serverInfo: {
3870
3894
  name: "mindstudio-agent",
3871
- version: "0.1.11"
3895
+ version: "0.1.13"
3872
3896
  },
3873
3897
  instructions: "Welcome to MindStudio \u2014 a platform with 200+ AI models, 850+ third-party integrations, and pre-built agents.\n\nGetting started:\n1. Call `listAgents` to verify your connection and see available agents.\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 or icon, call `uploadFile` to upload it, then `changeProfilePicture` with the returned URL. This helps users identify your requests in their logs.\n4. 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."
3874
3898
  });
@@ -4776,7 +4800,7 @@ function isNewerVersion(current, latest) {
4776
4800
  return false;
4777
4801
  }
4778
4802
  async function checkForUpdate() {
4779
- const currentVersion = "0.1.11";
4803
+ const currentVersion = "0.1.13";
4780
4804
  if (!currentVersion) return null;
4781
4805
  try {
4782
4806
  const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
@@ -4805,7 +4829,7 @@ async function checkForUpdate() {
4805
4829
  }
4806
4830
  }
4807
4831
  function printUpdateNotice(latestVersion) {
4808
- const currentVersion = "0.1.11";
4832
+ const currentVersion = "0.1.13";
4809
4833
  process.stderr.write(
4810
4834
  `
4811
4835
  ${ansi.cyanBright("Update available")} ${ansi.gray(currentVersion + " \u2192")} ${ansi.cyanBold(latestVersion)}
@@ -4880,7 +4904,7 @@ async function cmdLogin(options) {
4880
4904
  process.stderr.write("\n");
4881
4905
  printLogo();
4882
4906
  process.stderr.write("\n");
4883
- const ver = "0.1.11";
4907
+ const ver = "0.1.13";
4884
4908
  process.stderr.write(
4885
4909
  ` ${ansi.bold("MindStudio Agent")} ${ver ? " " + ansi.gray("v" + ver) : ""}
4886
4910
  `
package/dist/index.d.ts CHANGED
@@ -3,10 +3,12 @@ interface AgentOptions {
3
3
  /**
4
4
  * MindStudio API key. Used as a Bearer token for authentication.
5
5
  *
6
- * If omitted, the SDK checks (in order):
6
+ * Note: `CALLBACK_TOKEN` (auto-set inside MindStudio) always takes
7
+ * priority over all other auth sources when present.
8
+ *
9
+ * If omitted (and no CALLBACK_TOKEN), the SDK checks (in order):
7
10
  * 1. `MINDSTUDIO_API_KEY` environment variable
8
11
  * 2. `~/.mindstudio/config.json` (set via `mindstudio login`)
9
- * 3. `CALLBACK_TOKEN` environment variable (auto-set inside MindStudio custom functions)
10
12
  */
11
13
  apiKey?: string;
12
14
  /**
@@ -535,11 +537,14 @@ declare const Roles: Record<string, string>;
535
537
  * Names of columns that the platform manages automatically.
536
538
  *
537
539
  * - `id`: UUID primary key, generated on INSERT
538
- * - `createdAt`: unix timestamp (ms), set on INSERT
539
- * - `updatedAt`: unix timestamp (ms), set on INSERT and every UPDATE
540
- * - `lastUpdatedBy`: reference to the run ID that last wrote this row
540
+ * - `created_at`: unix timestamp (ms), set on INSERT
541
+ * - `updated_at`: unix timestamp (ms), set on INSERT and every UPDATE
542
+ * - `last_updated_by`: reference to the run ID that last wrote this row
543
+ *
544
+ * Both snake_case (platform convention) and camelCase (legacy) are
545
+ * stripped to support either naming convention in table interfaces.
541
546
  */
542
- type SystemFields = 'id' | 'createdAt' | 'updatedAt' | 'lastUpdatedBy';
547
+ type SystemFields = 'id' | 'created_at' | 'createdAt' | 'updated_at' | 'updatedAt' | 'last_updated_by' | 'lastUpdatedBy';
543
548
  /**
544
549
  * Input type for `Table.push()`. Excludes system-managed fields.
545
550
  * Optional fields in T remain optional.
@@ -921,10 +926,10 @@ interface Db {
921
926
  * ```
922
927
  *
923
928
  * Authentication is resolved in order:
924
- * 1. `apiKey` passed to the constructor
925
- * 2. `MINDSTUDIO_API_KEY` environment variable
926
- * 3. `~/.mindstudio/config.json` (set via `mindstudio login`)
927
- * 4. `CALLBACK_TOKEN` environment variable (auto-set inside MindStudio custom functions)
929
+ * 1. `CALLBACK_TOKEN` environment variable (auto-set inside MindStudio — always takes priority)
930
+ * 2. `apiKey` passed to the constructor
931
+ * 3. `MINDSTUDIO_API_KEY` environment variable
932
+ * 4. `~/.mindstudio/config.json` (set via `mindstudio login`)
928
933
  *
929
934
  * Base URL is resolved in order:
930
935
  * 1. `baseUrl` passed to the constructor
package/dist/index.js CHANGED
@@ -302,7 +302,15 @@ function buildDelete(table, where, whereParams) {
302
302
  if (where) sql += ` WHERE ${where}`;
303
303
  return { sql, params: whereParams?.length ? whereParams : void 0 };
304
304
  }
305
- var SYSTEM_COLUMNS = /* @__PURE__ */ new Set(["id", "createdAt", "updatedAt", "lastUpdatedBy"]);
305
+ var SYSTEM_COLUMNS = /* @__PURE__ */ new Set([
306
+ "id",
307
+ "created_at",
308
+ "createdAt",
309
+ "updated_at",
310
+ "updatedAt",
311
+ "last_updated_by",
312
+ "lastUpdatedBy"
313
+ ]);
306
314
  function stripSystemColumns(data) {
307
315
  const result = {};
308
316
  for (const [key, value] of Object.entries(data)) {
@@ -2050,10 +2058,12 @@ var MindStudioAgent = class {
2050
2058
  );
2051
2059
  }
2052
2060
  if (!res.ok) {
2061
+ const errorBody = await res.json().catch(() => ({}));
2053
2062
  throw new MindStudioError(
2054
- `Poll request failed: ${res.status} ${res.statusText}`,
2055
- "poll_error",
2056
- res.status
2063
+ errorBody.message ?? errorBody.error ?? `Poll request failed: ${res.status} ${res.statusText}`,
2064
+ errorBody.code ?? "poll_error",
2065
+ res.status,
2066
+ errorBody
2057
2067
  );
2058
2068
  }
2059
2069
  const poll = await res.json();
@@ -2318,12 +2328,24 @@ var MindStudioAgent = class {
2318
2328
  });
2319
2329
  if (!res.ok) {
2320
2330
  let message = `Database query failed: ${res.status} ${res.statusText}`;
2331
+ let code = "db_query_error";
2321
2332
  try {
2322
- const body = await res.json();
2323
- if (body.error) message = body.error;
2333
+ const text = await res.text();
2334
+ try {
2335
+ const body = JSON.parse(text);
2336
+ const errMsg = body.error ?? body.message ?? body.details;
2337
+ if (errMsg) message = errMsg;
2338
+ if (body.code) code = body.code;
2339
+ } catch {
2340
+ if (text && text.length < 500) message = text;
2341
+ }
2324
2342
  } catch {
2325
2343
  }
2326
- throw new MindStudioError(message, "db_query_error", res.status);
2344
+ throw new MindStudioError(
2345
+ `[db] ${message}`,
2346
+ code,
2347
+ res.status
2348
+ );
2327
2349
  }
2328
2350
  const data = await res.json();
2329
2351
  return data.results;
@@ -2507,10 +2529,12 @@ var MindStudioAgent = class {
2507
2529
  headers: options.type ? { "Content-Type": options.type } : {}
2508
2530
  });
2509
2531
  if (!res.ok) {
2532
+ const errorBody = await res.json().catch(() => ({}));
2510
2533
  throw new MindStudioError(
2511
- `Upload failed: ${res.status} ${res.statusText}`,
2512
- "upload_error",
2513
- res.status
2534
+ errorBody.message ?? errorBody.error ?? `Upload failed: ${res.status} ${res.statusText}`,
2535
+ errorBody.code ?? "upload_error",
2536
+ res.status,
2537
+ errorBody
2514
2538
  );
2515
2539
  }
2516
2540
  return { url: data.url };
@@ -2521,13 +2545,13 @@ function sleep2(ms) {
2521
2545
  }
2522
2546
  applyStepMethods(MindStudioAgent);
2523
2547
  function resolveToken(provided, config) {
2548
+ if (process.env.CALLBACK_TOKEN)
2549
+ return { token: process.env.CALLBACK_TOKEN, authType: "internal" };
2524
2550
  if (provided) return { token: provided, authType: "apiKey" };
2525
2551
  if (process.env.MINDSTUDIO_API_KEY)
2526
2552
  return { token: process.env.MINDSTUDIO_API_KEY, authType: "apiKey" };
2527
2553
  if (config?.apiKey)
2528
2554
  return { token: config.apiKey, authType: "apiKey" };
2529
- if (process.env.CALLBACK_TOKEN)
2530
- return { token: process.env.CALLBACK_TOKEN, authType: "internal" };
2531
2555
  throw new MindStudioError(
2532
2556
  "No API key provided. Run `mindstudio login`, pass `apiKey` to the constructor, or set the MINDSTUDIO_API_KEY environment variable.",
2533
2557
  "missing_api_key",