@mindstudio-ai/agent 0.1.44 → 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.
@@ -3862,52 +3862,92 @@ var init_client = __esm({
3862
3862
  */
3863
3863
  async executeStepBatch(steps, options) {
3864
3864
  const threadId = options?.threadId ?? (this._reuseThreadId && !getRequestContext() ? this._threadId : void 0);
3865
- const { data } = await request(this._httpConfig, "POST", "/steps/execute-batch", {
3865
+ const { data: asyncData } = await request(this._currentHttpConfig, "POST", "/steps/execute-batch-async", {
3866
3866
  steps: steps.map((s) => ({ ...s, stepType: resolveStepType(s.stepType) })),
3867
3867
  ...options?.appId != null && { appId: options.appId },
3868
3868
  ...threadId != null && { threadId }
3869
3869
  });
3870
- const results = await Promise.all(
3871
- data.results.map(async (r) => {
3872
- if (r.output != null) {
3873
- return {
3874
- stepType: r.stepType,
3875
- output: r.output,
3876
- billingCost: r.billingCost,
3877
- error: r.error
3878
- };
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);
3879
3898
  }
3880
- if (r.outputUrl) {
3881
- const res = await fetch(r.outputUrl);
3882
- 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) {
3911
+ return {
3912
+ stepType: r.stepType,
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();
3883
3927
  return {
3884
3928
  stepType: r.stepType,
3885
- error: `Failed to fetch output from S3: ${res.status} ${res.statusText}`
3929
+ output: envelope.value,
3930
+ billingCost: r.billingCost
3886
3931
  };
3887
3932
  }
3888
- const envelope = await res.json();
3889
3933
  return {
3890
3934
  stepType: r.stepType,
3891
- output: envelope.value,
3892
- billingCost: r.billingCost
3935
+ billingCost: r.billingCost,
3936
+ error: r.error
3893
3937
  };
3894
- }
3895
- return {
3896
- stepType: r.stepType,
3897
- billingCost: r.billingCost,
3898
- error: r.error
3899
- };
3900
- })
3901
- );
3902
- if (this._reuseThreadId && data.threadId && !getRequestContext()) {
3903
- 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
+ };
3904
3950
  }
3905
- return {
3906
- results,
3907
- totalBillingCost: data.totalBillingCost,
3908
- appId: data.appId,
3909
- threadId: data.threadId
3910
- };
3911
3951
  }
3912
3952
  /**
3913
3953
  * Get the authenticated user's identity and organization info.
@@ -5209,7 +5249,7 @@ async function startMcpServer(options) {
5209
5249
  capabilities: { tools: {} },
5210
5250
  serverInfo: {
5211
5251
  name: "mindstudio-agent",
5212
- version: "0.1.44"
5252
+ version: "0.1.45"
5213
5253
  },
5214
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.'
5215
5255
  });
@@ -6070,7 +6110,7 @@ function isNewerVersion(current, latest) {
6070
6110
  return false;
6071
6111
  }
6072
6112
  async function checkForUpdate() {
6073
- const currentVersion = "0.1.44";
6113
+ const currentVersion = "0.1.45";
6074
6114
  if (!currentVersion) return null;
6075
6115
  try {
6076
6116
  const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
@@ -6099,7 +6139,7 @@ async function checkForUpdate() {
6099
6139
  }
6100
6140
  }
6101
6141
  function printUpdateNotice(latestVersion) {
6102
- const currentVersion = "0.1.44";
6142
+ const currentVersion = "0.1.45";
6103
6143
  process.stderr.write(
6104
6144
  `
6105
6145
  ${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
@@ -6112,7 +6152,7 @@ function isStandaloneBinary() {
6112
6152
  return !argv1.includes("node_modules");
6113
6153
  }
6114
6154
  async function cmdUpdate() {
6115
- const currentVersion = "0.1.44";
6155
+ const currentVersion = "0.1.45";
6116
6156
  process.stderr.write(
6117
6157
  ` ${ansi2.gray("Current version:")} ${currentVersion}
6118
6158
  `
@@ -6227,7 +6267,7 @@ async function cmdLogin(options) {
6227
6267
  process.stderr.write("\n");
6228
6268
  printLogo();
6229
6269
  process.stderr.write("\n");
6230
- const ver = "0.1.44";
6270
+ const ver = "0.1.45";
6231
6271
  process.stderr.write(
6232
6272
  ` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
6233
6273
  `
@@ -6538,7 +6578,7 @@ async function main() {
6538
6578
  try {
6539
6579
  if (command === "version" || command === "-v") {
6540
6580
  process.stdout.write(
6541
- "0.1.44\n"
6581
+ "0.1.45\n"
6542
6582
  );
6543
6583
  return;
6544
6584
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mindstudio-ai/agent",
3
- "version": "0.1.44",
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",