@mindstudio-ai/agent 0.1.43 → 0.1.45

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.
@@ -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
  }
@@ -3856,52 +3862,92 @@ var init_client = __esm({
3856
3862
  */
3857
3863
  async executeStepBatch(steps, options) {
3858
3864
  const threadId = options?.threadId ?? (this._reuseThreadId && !getRequestContext() ? this._threadId : void 0);
3859
- const { data } = await request(this._httpConfig, "POST", "/steps/execute-batch", {
3865
+ const { data: asyncData } = await request(this._currentHttpConfig, "POST", "/steps/execute-batch-async", {
3860
3866
  steps: steps.map((s) => ({ ...s, stepType: resolveStepType(s.stepType) })),
3861
3867
  ...options?.appId != null && { appId: options.appId },
3862
3868
  ...threadId != null && { threadId }
3863
3869
  });
3864
- const results = await Promise.all(
3865
- data.results.map(async (r) => {
3866
- if (r.output != null) {
3867
- return {
3868
- stepType: r.stepType,
3869
- output: r.output,
3870
- billingCost: r.billingCost,
3871
- error: r.error
3872
- };
3870
+ const pollUrl = `${this._currentHttpConfig.baseUrl}/developer/v2/steps/execute-batch-async/poll/${asyncData.batchToken}`;
3871
+ let pollDelay = 300;
3872
+ while (true) {
3873
+ await sleep2(pollDelay);
3874
+ pollDelay = Math.min(pollDelay * 1.5, 3e3);
3875
+ const res = await fetch(pollUrl, {
3876
+ headers: { "User-Agent": "@mindstudio-ai/agent" }
3877
+ });
3878
+ if (res.status === 404) {
3879
+ throw new MindStudioError(
3880
+ "Batch poll token not found or expired.",
3881
+ "poll_token_expired",
3882
+ 404
3883
+ );
3884
+ }
3885
+ if (!res.ok) {
3886
+ const errorBody = await res.json().catch(() => ({}));
3887
+ throw new MindStudioError(
3888
+ errorBody.message ?? errorBody.error ?? `Batch poll failed: ${res.status} ${res.statusText}`,
3889
+ errorBody.code ?? "poll_error",
3890
+ res.status,
3891
+ errorBody
3892
+ );
3893
+ }
3894
+ const poll = await res.json();
3895
+ if (poll.status === "pending") {
3896
+ if (options?.onProgress && poll.totalSteps != null && poll.completedSteps != null) {
3897
+ options.onProgress(poll.completedSteps, poll.totalSteps);
3873
3898
  }
3874
- if (r.outputUrl) {
3875
- const res = await fetch(r.outputUrl);
3876
- if (!res.ok) {
3899
+ continue;
3900
+ }
3901
+ if (poll.status === "error") {
3902
+ throw new MindStudioError(
3903
+ poll.error ?? "Batch execution failed.",
3904
+ "batch_execution_error",
3905
+ 500
3906
+ );
3907
+ }
3908
+ const results = await Promise.all(
3909
+ poll.results.map(async (r) => {
3910
+ if (r.output != null) {
3877
3911
  return {
3878
3912
  stepType: r.stepType,
3879
- error: `Failed to fetch output from S3: ${res.status} ${res.statusText}`
3913
+ output: r.output,
3914
+ billingCost: r.billingCost,
3915
+ error: r.error
3916
+ };
3917
+ }
3918
+ if (r.outputUrl) {
3919
+ const s3Res = await fetch(r.outputUrl);
3920
+ if (!s3Res.ok) {
3921
+ return {
3922
+ stepType: r.stepType,
3923
+ error: `Failed to fetch output from S3: ${s3Res.status} ${s3Res.statusText}`
3924
+ };
3925
+ }
3926
+ const envelope = await s3Res.json();
3927
+ return {
3928
+ stepType: r.stepType,
3929
+ output: envelope.value,
3930
+ billingCost: r.billingCost
3880
3931
  };
3881
3932
  }
3882
- const envelope = await res.json();
3883
3933
  return {
3884
3934
  stepType: r.stepType,
3885
- output: envelope.value,
3886
- billingCost: r.billingCost
3935
+ billingCost: r.billingCost,
3936
+ error: r.error
3887
3937
  };
3888
- }
3889
- return {
3890
- stepType: r.stepType,
3891
- billingCost: r.billingCost,
3892
- error: r.error
3893
- };
3894
- })
3895
- );
3896
- if (this._reuseThreadId && data.threadId && !getRequestContext()) {
3897
- this._threadId = data.threadId;
3938
+ })
3939
+ );
3940
+ const resultThreadId = poll.threadId ?? asyncData.threadId;
3941
+ if (this._reuseThreadId && resultThreadId && !getRequestContext()) {
3942
+ this._threadId = resultThreadId;
3943
+ }
3944
+ return {
3945
+ results,
3946
+ totalBillingCost: poll.totalBillingCost,
3947
+ appId: poll.appId,
3948
+ threadId: resultThreadId
3949
+ };
3898
3950
  }
3899
- return {
3900
- results,
3901
- totalBillingCost: data.totalBillingCost,
3902
- appId: data.appId,
3903
- threadId: data.threadId
3904
- };
3905
3951
  }
3906
3952
  /**
3907
3953
  * Get the authenticated user's identity and organization info.
@@ -4402,6 +4448,12 @@ var init_client = __esm({
4402
4448
  (d) => d.tables.some((t) => t.name === name)
4403
4449
  );
4404
4450
  }
4451
+ if (tableConfig.columns.length === 0 && targetDb) {
4452
+ const tableSchema = targetDb.tables.find((t) => t.name === name);
4453
+ if (tableSchema) {
4454
+ tableConfig.columns = tableSchema.schema;
4455
+ }
4456
+ }
4405
4457
  const databaseId = targetDb?.id ?? databases[0]?.id ?? "";
4406
4458
  return agent._executeDbBatch(databaseId, queries);
4407
4459
  }
@@ -5197,7 +5249,7 @@ async function startMcpServer(options) {
5197
5249
  capabilities: { tools: {} },
5198
5250
  serverInfo: {
5199
5251
  name: "mindstudio-agent",
5200
- version: "0.1.43"
5252
+ version: "0.1.45"
5201
5253
  },
5202
5254
  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.'
5203
5255
  });
@@ -6058,7 +6110,7 @@ function isNewerVersion(current, latest) {
6058
6110
  return false;
6059
6111
  }
6060
6112
  async function checkForUpdate() {
6061
- const currentVersion = "0.1.43";
6113
+ const currentVersion = "0.1.45";
6062
6114
  if (!currentVersion) return null;
6063
6115
  try {
6064
6116
  const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
@@ -6087,7 +6139,7 @@ async function checkForUpdate() {
6087
6139
  }
6088
6140
  }
6089
6141
  function printUpdateNotice(latestVersion) {
6090
- const currentVersion = "0.1.43";
6142
+ const currentVersion = "0.1.45";
6091
6143
  process.stderr.write(
6092
6144
  `
6093
6145
  ${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
@@ -6100,7 +6152,7 @@ function isStandaloneBinary() {
6100
6152
  return !argv1.includes("node_modules");
6101
6153
  }
6102
6154
  async function cmdUpdate() {
6103
- const currentVersion = "0.1.43";
6155
+ const currentVersion = "0.1.45";
6104
6156
  process.stderr.write(
6105
6157
  ` ${ansi2.gray("Current version:")} ${currentVersion}
6106
6158
  `
@@ -6215,7 +6267,7 @@ async function cmdLogin(options) {
6215
6267
  process.stderr.write("\n");
6216
6268
  printLogo();
6217
6269
  process.stderr.write("\n");
6218
- const ver = "0.1.43";
6270
+ const ver = "0.1.45";
6219
6271
  process.stderr.write(
6220
6272
  ` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
6221
6273
  `
@@ -6526,7 +6578,7 @@ async function main() {
6526
6578
  try {
6527
6579
  if (command === "version" || command === "-v") {
6528
6580
  process.stdout.write(
6529
- "0.1.43\n"
6581
+ "0.1.45\n"
6530
6582
  );
6531
6583
  return;
6532
6584
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindstudio-ai/agent",
3
- "version": "0.1.43",
3
+ "version": "0.1.45",
4
4
  "description": "TypeScript SDK for MindStudio direct step execution",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",