@mindstudio-ai/agent 0.1.42 → 0.1.44

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
@@ -1541,6 +1541,12 @@ function deserializeRow(row, columns) {
1541
1541
  } else if (col?.type === "number" && typeof value === "string") {
1542
1542
  const num = Number(value);
1543
1543
  result[key] = Number.isNaN(num) ? value : num;
1544
+ } else if (!col && typeof value === "string" && (value[0] === "[" || value[0] === "{")) {
1545
+ try {
1546
+ result[key] = JSON.parse(value);
1547
+ } catch {
1548
+ result[key] = value;
1549
+ }
1544
1550
  } else {
1545
1551
  result[key] = value;
1546
1552
  }
@@ -3489,6 +3495,9 @@ function resolveStepType(name) {
3489
3495
  return meta ? meta.stepType : name;
3490
3496
  }
3491
3497
  function resolveToken(provided, config) {
3498
+ const rctx = getRequestContext();
3499
+ if (rctx?.callbackToken)
3500
+ return { token: rctx.callbackToken, authType: "internal" };
3492
3501
  if (process.env.CALLBACK_TOKEN)
3493
3502
  return { token: process.env.CALLBACK_TOKEN, authType: "internal" };
3494
3503
  if (provided) return { token: provided, authType: "apiKey" };
@@ -3592,7 +3601,8 @@ var init_client = __esm({
3592
3601
  constructor(options = {}) {
3593
3602
  const config = loadConfig();
3594
3603
  const { token, authType } = resolveToken(options.apiKey, config);
3595
- const baseUrl = options.baseUrl ?? process.env.MINDSTUDIO_BASE_URL ?? process.env.REMOTE_HOSTNAME ?? config.baseUrl ?? DEFAULT_BASE_URL;
3604
+ const rctx = getRequestContext();
3605
+ const baseUrl = options.baseUrl ?? rctx?.remoteHostname ?? process.env.MINDSTUDIO_BASE_URL ?? process.env.REMOTE_HOSTNAME ?? config.baseUrl ?? DEFAULT_BASE_URL;
3596
3606
  this._reuseThreadId = options.reuseThreadId ?? /^(true|1)$/i.test(process.env.MINDSTUDIO_REUSE_THREAD_ID ?? "");
3597
3607
  this._appId = options.appId ?? process.env.MINDSTUDIO_APP_ID ?? void 0;
3598
3608
  this._authType = authType;
@@ -4398,6 +4408,12 @@ var init_client = __esm({
4398
4408
  (d) => d.tables.some((t) => t.name === name)
4399
4409
  );
4400
4410
  }
4411
+ if (tableConfig.columns.length === 0 && targetDb) {
4412
+ const tableSchema = targetDb.tables.find((t) => t.name === name);
4413
+ if (tableSchema) {
4414
+ tableConfig.columns = tableSchema.schema;
4415
+ }
4416
+ }
4401
4417
  const databaseId = targetDb?.id ?? databases[0]?.id ?? "";
4402
4418
  return agent._executeDbBatch(databaseId, queries);
4403
4419
  }
@@ -5193,7 +5209,7 @@ async function startMcpServer(options) {
5193
5209
  capabilities: { tools: {} },
5194
5210
  serverInfo: {
5195
5211
  name: "mindstudio-agent",
5196
- version: "0.1.42"
5212
+ version: "0.1.44"
5197
5213
  },
5198
5214
  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 or icon, call `uploadFile` to upload it, then `changeProfilePicture` with the returned URL.\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.'
5199
5215
  });
@@ -6150,7 +6166,7 @@ function isNewerVersion(current, latest) {
6150
6166
  return false;
6151
6167
  }
6152
6168
  async function checkForUpdate() {
6153
- const currentVersion = "0.1.42";
6169
+ const currentVersion = "0.1.44";
6154
6170
  if (!currentVersion) return null;
6155
6171
  try {
6156
6172
  const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
@@ -6179,7 +6195,7 @@ async function checkForUpdate() {
6179
6195
  }
6180
6196
  }
6181
6197
  function printUpdateNotice(latestVersion) {
6182
- const currentVersion = "0.1.42";
6198
+ const currentVersion = "0.1.44";
6183
6199
  process.stderr.write(
6184
6200
  `
6185
6201
  ${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
@@ -6192,7 +6208,7 @@ function isStandaloneBinary() {
6192
6208
  return !argv1.includes("node_modules");
6193
6209
  }
6194
6210
  async function cmdUpdate() {
6195
- const currentVersion = "0.1.42";
6211
+ const currentVersion = "0.1.44";
6196
6212
  process.stderr.write(
6197
6213
  ` ${ansi2.gray("Current version:")} ${currentVersion}
6198
6214
  `
@@ -6327,7 +6343,7 @@ async function cmdLogin(options) {
6327
6343
  process.stderr.write("\n");
6328
6344
  printLogo();
6329
6345
  process.stderr.write("\n");
6330
- const ver = "0.1.42";
6346
+ const ver = "0.1.44";
6331
6347
  process.stderr.write(
6332
6348
  ` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
6333
6349
  `
@@ -6654,7 +6670,7 @@ async function main() {
6654
6670
  try {
6655
6671
  if (command === "version" || command === "-v") {
6656
6672
  process.stdout.write(
6657
- "0.1.42\n"
6673
+ "0.1.44\n"
6658
6674
  );
6659
6675
  return;
6660
6676
  }
package/dist/index.js CHANGED
@@ -296,6 +296,12 @@ function deserializeRow(row, columns) {
296
296
  } else if (col?.type === "number" && typeof value === "string") {
297
297
  const num = Number(value);
298
298
  result[key] = Number.isNaN(num) ? value : num;
299
+ } else if (!col && typeof value === "string" && (value[0] === "[" || value[0] === "{")) {
300
+ try {
301
+ result[key] = JSON.parse(value);
302
+ } catch {
303
+ result[key] = value;
304
+ }
299
305
  } else {
300
306
  result[key] = value;
301
307
  }
@@ -3423,7 +3429,8 @@ var MindStudioAgent = class {
3423
3429
  constructor(options = {}) {
3424
3430
  const config = loadConfig();
3425
3431
  const { token, authType } = resolveToken(options.apiKey, config);
3426
- const baseUrl = options.baseUrl ?? process.env.MINDSTUDIO_BASE_URL ?? process.env.REMOTE_HOSTNAME ?? config.baseUrl ?? DEFAULT_BASE_URL;
3432
+ const rctx = getRequestContext();
3433
+ const baseUrl = options.baseUrl ?? rctx?.remoteHostname ?? process.env.MINDSTUDIO_BASE_URL ?? process.env.REMOTE_HOSTNAME ?? config.baseUrl ?? DEFAULT_BASE_URL;
3427
3434
  this._reuseThreadId = options.reuseThreadId ?? /^(true|1)$/i.test(process.env.MINDSTUDIO_REUSE_THREAD_ID ?? "");
3428
3435
  this._appId = options.appId ?? process.env.MINDSTUDIO_APP_ID ?? void 0;
3429
3436
  this._authType = authType;
@@ -4229,6 +4236,12 @@ var MindStudioAgent = class {
4229
4236
  (d) => d.tables.some((t) => t.name === name)
4230
4237
  );
4231
4238
  }
4239
+ if (tableConfig.columns.length === 0 && targetDb) {
4240
+ const tableSchema = targetDb.tables.find((t) => t.name === name);
4241
+ if (tableSchema) {
4242
+ tableConfig.columns = tableSchema.schema;
4243
+ }
4244
+ }
4232
4245
  const databaseId = targetDb?.id ?? databases[0]?.id ?? "";
4233
4246
  return agent._executeDbBatch(databaseId, queries);
4234
4247
  }
@@ -4406,6 +4419,9 @@ function resolveStepType(name) {
4406
4419
  return meta ? meta.stepType : name;
4407
4420
  }
4408
4421
  function resolveToken(provided, config) {
4422
+ const rctx = getRequestContext();
4423
+ if (rctx?.callbackToken)
4424
+ return { token: rctx.callbackToken, authType: "internal" };
4409
4425
  if (process.env.CALLBACK_TOKEN)
4410
4426
  return { token: process.env.CALLBACK_TOKEN, authType: "internal" };
4411
4427
  if (provided) return { token: provided, authType: "apiKey" };