@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.
- package/dist/cli.js +79 -39
- package/dist/index.d.ts +2 -0
- package/dist/index.js +73 -33
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +79 -39
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -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.
|
|
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
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
|
|
3874
|
-
|
|
3875
|
-
|
|
3876
|
-
|
|
3877
|
-
|
|
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
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
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
|
-
|
|
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
|
-
|
|
3892
|
-
|
|
3935
|
+
billingCost: r.billingCost,
|
|
3936
|
+
error: r.error
|
|
3893
3937
|
};
|
|
3894
|
-
}
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
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.
|
|
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
|
});
|
|
@@ -6166,7 +6206,7 @@ function isNewerVersion(current, latest) {
|
|
|
6166
6206
|
return false;
|
|
6167
6207
|
}
|
|
6168
6208
|
async function checkForUpdate() {
|
|
6169
|
-
const currentVersion = "0.1.
|
|
6209
|
+
const currentVersion = "0.1.45";
|
|
6170
6210
|
if (!currentVersion) return null;
|
|
6171
6211
|
try {
|
|
6172
6212
|
const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
@@ -6195,7 +6235,7 @@ async function checkForUpdate() {
|
|
|
6195
6235
|
}
|
|
6196
6236
|
}
|
|
6197
6237
|
function printUpdateNotice(latestVersion) {
|
|
6198
|
-
const currentVersion = "0.1.
|
|
6238
|
+
const currentVersion = "0.1.45";
|
|
6199
6239
|
process.stderr.write(
|
|
6200
6240
|
`
|
|
6201
6241
|
${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
|
|
@@ -6208,7 +6248,7 @@ function isStandaloneBinary() {
|
|
|
6208
6248
|
return !argv1.includes("node_modules");
|
|
6209
6249
|
}
|
|
6210
6250
|
async function cmdUpdate() {
|
|
6211
|
-
const currentVersion = "0.1.
|
|
6251
|
+
const currentVersion = "0.1.45";
|
|
6212
6252
|
process.stderr.write(
|
|
6213
6253
|
` ${ansi2.gray("Current version:")} ${currentVersion}
|
|
6214
6254
|
`
|
|
@@ -6343,7 +6383,7 @@ async function cmdLogin(options) {
|
|
|
6343
6383
|
process.stderr.write("\n");
|
|
6344
6384
|
printLogo();
|
|
6345
6385
|
process.stderr.write("\n");
|
|
6346
|
-
const ver = "0.1.
|
|
6386
|
+
const ver = "0.1.45";
|
|
6347
6387
|
process.stderr.write(
|
|
6348
6388
|
` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
|
|
6349
6389
|
`
|
|
@@ -6670,7 +6710,7 @@ async function main() {
|
|
|
6670
6710
|
try {
|
|
6671
6711
|
if (command === "version" || command === "-v") {
|
|
6672
6712
|
process.stdout.write(
|
|
6673
|
-
"0.1.
|
|
6713
|
+
"0.1.45\n"
|
|
6674
6714
|
);
|
|
6675
6715
|
return;
|
|
6676
6716
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -375,6 +375,8 @@ interface ExecuteStepBatchOptions {
|
|
|
375
375
|
appId?: string;
|
|
376
376
|
/** Thread ID for state persistence. If omitted, an ephemeral thread is created. */
|
|
377
377
|
threadId?: string;
|
|
378
|
+
/** Progress callback, called on each poll while the batch is running. */
|
|
379
|
+
onProgress?: (completedSteps: number, totalSteps: number) => void;
|
|
378
380
|
}
|
|
379
381
|
/** Result of {@link MindStudioAgent.executeStepBatch}. */
|
|
380
382
|
interface ExecuteStepBatchResult {
|
package/dist/index.js
CHANGED
|
@@ -3690,52 +3690,92 @@ var MindStudioAgent = class {
|
|
|
3690
3690
|
*/
|
|
3691
3691
|
async executeStepBatch(steps, options) {
|
|
3692
3692
|
const threadId = options?.threadId ?? (this._reuseThreadId && !getRequestContext() ? this._threadId : void 0);
|
|
3693
|
-
const { data } = await request(this.
|
|
3693
|
+
const { data: asyncData } = await request(this._currentHttpConfig, "POST", "/steps/execute-batch-async", {
|
|
3694
3694
|
steps: steps.map((s) => ({ ...s, stepType: resolveStepType(s.stepType) })),
|
|
3695
3695
|
...options?.appId != null && { appId: options.appId },
|
|
3696
3696
|
...threadId != null && { threadId }
|
|
3697
3697
|
});
|
|
3698
|
-
const
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3698
|
+
const pollUrl = `${this._currentHttpConfig.baseUrl}/developer/v2/steps/execute-batch-async/poll/${asyncData.batchToken}`;
|
|
3699
|
+
let pollDelay = 300;
|
|
3700
|
+
while (true) {
|
|
3701
|
+
await sleep2(pollDelay);
|
|
3702
|
+
pollDelay = Math.min(pollDelay * 1.5, 3e3);
|
|
3703
|
+
const res = await fetch(pollUrl, {
|
|
3704
|
+
headers: { "User-Agent": "@mindstudio-ai/agent" }
|
|
3705
|
+
});
|
|
3706
|
+
if (res.status === 404) {
|
|
3707
|
+
throw new MindStudioError(
|
|
3708
|
+
"Batch poll token not found or expired.",
|
|
3709
|
+
"poll_token_expired",
|
|
3710
|
+
404
|
|
3711
|
+
);
|
|
3712
|
+
}
|
|
3713
|
+
if (!res.ok) {
|
|
3714
|
+
const errorBody = await res.json().catch(() => ({}));
|
|
3715
|
+
throw new MindStudioError(
|
|
3716
|
+
errorBody.message ?? errorBody.error ?? `Batch poll failed: ${res.status} ${res.statusText}`,
|
|
3717
|
+
errorBody.code ?? "poll_error",
|
|
3718
|
+
res.status,
|
|
3719
|
+
errorBody
|
|
3720
|
+
);
|
|
3721
|
+
}
|
|
3722
|
+
const poll = await res.json();
|
|
3723
|
+
if (poll.status === "pending") {
|
|
3724
|
+
if (options?.onProgress && poll.totalSteps != null && poll.completedSteps != null) {
|
|
3725
|
+
options.onProgress(poll.completedSteps, poll.totalSteps);
|
|
3707
3726
|
}
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3727
|
+
continue;
|
|
3728
|
+
}
|
|
3729
|
+
if (poll.status === "error") {
|
|
3730
|
+
throw new MindStudioError(
|
|
3731
|
+
poll.error ?? "Batch execution failed.",
|
|
3732
|
+
"batch_execution_error",
|
|
3733
|
+
500
|
|
3734
|
+
);
|
|
3735
|
+
}
|
|
3736
|
+
const results = await Promise.all(
|
|
3737
|
+
poll.results.map(async (r) => {
|
|
3738
|
+
if (r.output != null) {
|
|
3739
|
+
return {
|
|
3740
|
+
stepType: r.stepType,
|
|
3741
|
+
output: r.output,
|
|
3742
|
+
billingCost: r.billingCost,
|
|
3743
|
+
error: r.error
|
|
3744
|
+
};
|
|
3745
|
+
}
|
|
3746
|
+
if (r.outputUrl) {
|
|
3747
|
+
const s3Res = await fetch(r.outputUrl);
|
|
3748
|
+
if (!s3Res.ok) {
|
|
3749
|
+
return {
|
|
3750
|
+
stepType: r.stepType,
|
|
3751
|
+
error: `Failed to fetch output from S3: ${s3Res.status} ${s3Res.statusText}`
|
|
3752
|
+
};
|
|
3753
|
+
}
|
|
3754
|
+
const envelope = await s3Res.json();
|
|
3711
3755
|
return {
|
|
3712
3756
|
stepType: r.stepType,
|
|
3713
|
-
|
|
3757
|
+
output: envelope.value,
|
|
3758
|
+
billingCost: r.billingCost
|
|
3714
3759
|
};
|
|
3715
3760
|
}
|
|
3716
|
-
const envelope = await res.json();
|
|
3717
3761
|
return {
|
|
3718
3762
|
stepType: r.stepType,
|
|
3719
|
-
|
|
3720
|
-
|
|
3763
|
+
billingCost: r.billingCost,
|
|
3764
|
+
error: r.error
|
|
3721
3765
|
};
|
|
3722
|
-
}
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3766
|
+
})
|
|
3767
|
+
);
|
|
3768
|
+
const resultThreadId = poll.threadId ?? asyncData.threadId;
|
|
3769
|
+
if (this._reuseThreadId && resultThreadId && !getRequestContext()) {
|
|
3770
|
+
this._threadId = resultThreadId;
|
|
3771
|
+
}
|
|
3772
|
+
return {
|
|
3773
|
+
results,
|
|
3774
|
+
totalBillingCost: poll.totalBillingCost,
|
|
3775
|
+
appId: poll.appId,
|
|
3776
|
+
threadId: resultThreadId
|
|
3777
|
+
};
|
|
3732
3778
|
}
|
|
3733
|
-
return {
|
|
3734
|
-
results,
|
|
3735
|
-
totalBillingCost: data.totalBillingCost,
|
|
3736
|
-
appId: data.appId,
|
|
3737
|
-
threadId: data.threadId
|
|
3738
|
-
};
|
|
3739
3779
|
}
|
|
3740
3780
|
/**
|
|
3741
3781
|
* Get the authenticated user's identity and organization info.
|