@mindstudio-ai/agent 0.1.46 → 0.1.47
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 +45 -14
- package/dist/index.d.ts +17 -5
- package/dist/index.js +38 -8
- package/dist/index.js.map +1 -1
- package/dist/postinstall.js +45 -14
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1242,9 +1242,9 @@ async function requestWithRetry(config, method, url, body, attempt) {
|
|
|
1242
1242
|
body: body != null ? JSON.stringify(body) : void 0
|
|
1243
1243
|
});
|
|
1244
1244
|
config.rateLimiter.updateFromHeaders(res.headers);
|
|
1245
|
-
if (res.status === 429
|
|
1245
|
+
if (attempt < config.maxRetries && (res.status === 429 || res.status === 502 || res.status === 503 || res.status === 504)) {
|
|
1246
1246
|
const retryAfter = res.headers.get("retry-after");
|
|
1247
|
-
const waitMs = retryAfter ? parseFloat(retryAfter) * 1e3 : 1e3;
|
|
1247
|
+
const waitMs = retryAfter ? parseFloat(retryAfter) * 1e3 : Math.min(1e3 * Math.pow(2, attempt), 1e4);
|
|
1248
1248
|
await sleep(waitMs);
|
|
1249
1249
|
return requestWithRetry(config, method, url, body, attempt + 1);
|
|
1250
1250
|
}
|
|
@@ -3006,7 +3006,7 @@ function buildTaskRequestBody(options) {
|
|
|
3006
3006
|
prompt: options.prompt,
|
|
3007
3007
|
input: options.input,
|
|
3008
3008
|
tools: mapTools(options.tools),
|
|
3009
|
-
structuredOutputExample: options.structuredOutputExample,
|
|
3009
|
+
structuredOutputExample: typeof options.structuredOutputExample === "string" ? options.structuredOutputExample : JSON.stringify(options.structuredOutputExample),
|
|
3010
3010
|
model: options.model,
|
|
3011
3011
|
...options.maxTurns != null && { maxTurns: options.maxTurns },
|
|
3012
3012
|
...options.appId != null && { appId: options.appId },
|
|
@@ -3016,6 +3016,16 @@ function buildTaskRequestBody(options) {
|
|
|
3016
3016
|
function sleep2(ms) {
|
|
3017
3017
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
3018
3018
|
}
|
|
3019
|
+
function isDevMode() {
|
|
3020
|
+
return !!(process.env.CALLBACK_TOKEN || getRequestContext()?.callbackToken);
|
|
3021
|
+
}
|
|
3022
|
+
function logTaskResult(result) {
|
|
3023
|
+
if (!isDevMode()) return;
|
|
3024
|
+
const toolSummary = result.toolCalls.map((tc) => `${tc.name} (${tc.durationMs}ms) ${tc.success ? "\u2713" : "\u2717"}`).join(", ");
|
|
3025
|
+
console.log(
|
|
3026
|
+
`[task] ${result.turns} turn${result.turns === 1 ? "" : "s"}` + (toolSummary ? `: ${toolSummary}` : "") + ` | ${result.parsedSuccessfully ? "output OK" : "\u26A0 output not valid JSON"} | cost: ${result.usage.totalBillingCost}`
|
|
3027
|
+
);
|
|
3028
|
+
}
|
|
3019
3029
|
async function runTaskPoll(httpConfig, body) {
|
|
3020
3030
|
const { data } = await request(
|
|
3021
3031
|
httpConfig,
|
|
@@ -3031,6 +3041,7 @@ async function runTaskPoll(httpConfig, body) {
|
|
|
3031
3041
|
const res = await fetch(pollUrl, {
|
|
3032
3042
|
headers: { "User-Agent": "@mindstudio-ai/agent" }
|
|
3033
3043
|
});
|
|
3044
|
+
if (res.status === 502 || res.status === 503 || res.status === 504) continue;
|
|
3034
3045
|
if (res.status === 404) {
|
|
3035
3046
|
throw new MindStudioError(
|
|
3036
3047
|
"Task poll token not found or expired.",
|
|
@@ -3048,7 +3059,12 @@ async function runTaskPoll(httpConfig, body) {
|
|
|
3048
3059
|
);
|
|
3049
3060
|
}
|
|
3050
3061
|
const poll = await res.json();
|
|
3051
|
-
if (poll.status === "pending")
|
|
3062
|
+
if (poll.status === "pending") {
|
|
3063
|
+
if (isDevMode() && poll.currentTurn != null) {
|
|
3064
|
+
console.log(`[task] running... turn ${poll.currentTurn}/${poll.maxTurns ?? "?"}`);
|
|
3065
|
+
}
|
|
3066
|
+
continue;
|
|
3067
|
+
}
|
|
3052
3068
|
if (poll.status === "error") {
|
|
3053
3069
|
throw new MindStudioError(
|
|
3054
3070
|
poll.error ?? "Task execution failed.",
|
|
@@ -3056,11 +3072,16 @@ async function runTaskPoll(httpConfig, body) {
|
|
|
3056
3072
|
500
|
|
3057
3073
|
);
|
|
3058
3074
|
}
|
|
3059
|
-
|
|
3075
|
+
const result = {
|
|
3060
3076
|
output: poll.output,
|
|
3077
|
+
outputRaw: poll.outputRaw ?? "",
|
|
3078
|
+
parsedSuccessfully: poll.parsedSuccessfully ?? true,
|
|
3061
3079
|
turns: poll.turns ?? 0,
|
|
3062
|
-
usage: poll.usage ?? { inputTokens: 0, outputTokens: 0, totalBillingCost: 0 }
|
|
3080
|
+
usage: poll.usage ?? { inputTokens: 0, outputTokens: 0, totalBillingCost: 0 },
|
|
3081
|
+
toolCalls: poll.toolCalls ?? []
|
|
3063
3082
|
};
|
|
3083
|
+
logTaskResult(result);
|
|
3084
|
+
return result;
|
|
3064
3085
|
}
|
|
3065
3086
|
}
|
|
3066
3087
|
async function runTaskStream(httpConfig, body, onEvent) {
|
|
@@ -3120,12 +3141,15 @@ async function runTaskStream(httpConfig, body, onEvent) {
|
|
|
3120
3141
|
if (event.type === "done") {
|
|
3121
3142
|
result = {
|
|
3122
3143
|
output: event.output,
|
|
3144
|
+
outputRaw: event.outputRaw ?? "",
|
|
3145
|
+
parsedSuccessfully: event.parsedSuccessfully ?? true,
|
|
3123
3146
|
turns: event.turns ?? 0,
|
|
3124
3147
|
usage: event.usage ?? {
|
|
3125
3148
|
inputTokens: 0,
|
|
3126
3149
|
outputTokens: 0,
|
|
3127
3150
|
totalBillingCost: 0
|
|
3128
|
-
}
|
|
3151
|
+
},
|
|
3152
|
+
toolCalls: event.toolCalls ?? []
|
|
3129
3153
|
};
|
|
3130
3154
|
}
|
|
3131
3155
|
} catch (err) {
|
|
@@ -3147,12 +3171,15 @@ async function runTaskStream(httpConfig, body, onEvent) {
|
|
|
3147
3171
|
if (event.type === "done") {
|
|
3148
3172
|
result = {
|
|
3149
3173
|
output: event.output,
|
|
3174
|
+
outputRaw: event.outputRaw ?? "",
|
|
3175
|
+
parsedSuccessfully: event.parsedSuccessfully ?? true,
|
|
3150
3176
|
turns: event.turns ?? 0,
|
|
3151
3177
|
usage: event.usage ?? {
|
|
3152
3178
|
inputTokens: 0,
|
|
3153
3179
|
outputTokens: 0,
|
|
3154
3180
|
totalBillingCost: 0
|
|
3155
|
-
}
|
|
3181
|
+
},
|
|
3182
|
+
toolCalls: event.toolCalls ?? []
|
|
3156
3183
|
};
|
|
3157
3184
|
}
|
|
3158
3185
|
} catch (err) {
|
|
@@ -3166,6 +3193,7 @@ async function runTaskStream(httpConfig, body, onEvent) {
|
|
|
3166
3193
|
500
|
|
3167
3194
|
);
|
|
3168
3195
|
}
|
|
3196
|
+
logTaskResult(result);
|
|
3169
3197
|
return result;
|
|
3170
3198
|
}
|
|
3171
3199
|
var init_task = __esm({
|
|
@@ -3173,6 +3201,7 @@ var init_task = __esm({
|
|
|
3173
3201
|
"use strict";
|
|
3174
3202
|
init_http();
|
|
3175
3203
|
init_errors();
|
|
3204
|
+
init_context();
|
|
3176
3205
|
init_metadata();
|
|
3177
3206
|
}
|
|
3178
3207
|
});
|
|
@@ -4065,6 +4094,7 @@ var init_client = __esm({
|
|
|
4065
4094
|
const res = await fetch(pollUrl, {
|
|
4066
4095
|
headers: { "User-Agent": "@mindstudio-ai/agent" }
|
|
4067
4096
|
});
|
|
4097
|
+
if (res.status === 502 || res.status === 503 || res.status === 504) continue;
|
|
4068
4098
|
if (res.status === 404) {
|
|
4069
4099
|
throw new MindStudioError(
|
|
4070
4100
|
"Batch poll token not found or expired.",
|
|
@@ -4228,6 +4258,7 @@ var init_client = __esm({
|
|
|
4228
4258
|
const res = await fetch(pollUrl, {
|
|
4229
4259
|
headers: { "User-Agent": "@mindstudio-ai/agent" }
|
|
4230
4260
|
});
|
|
4261
|
+
if (res.status === 502 || res.status === 503 || res.status === 504) continue;
|
|
4231
4262
|
if (res.status === 404) {
|
|
4232
4263
|
throw new MindStudioError(
|
|
4233
4264
|
"Poll token not found or expired.",
|
|
@@ -5494,7 +5525,7 @@ async function startMcpServer(options) {
|
|
|
5494
5525
|
capabilities: { tools: {} },
|
|
5495
5526
|
serverInfo: {
|
|
5496
5527
|
name: "mindstudio-agent",
|
|
5497
|
-
version: "0.1.
|
|
5528
|
+
version: "0.1.47"
|
|
5498
5529
|
},
|
|
5499
5530
|
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.'
|
|
5500
5531
|
});
|
|
@@ -6451,7 +6482,7 @@ function isNewerVersion(current, latest) {
|
|
|
6451
6482
|
return false;
|
|
6452
6483
|
}
|
|
6453
6484
|
async function checkForUpdate() {
|
|
6454
|
-
const currentVersion = "0.1.
|
|
6485
|
+
const currentVersion = "0.1.47";
|
|
6455
6486
|
if (!currentVersion) return null;
|
|
6456
6487
|
try {
|
|
6457
6488
|
const { loadConfig: loadConfig2, saveConfig: saveConfig2 } = await Promise.resolve().then(() => (init_config(), config_exports));
|
|
@@ -6480,7 +6511,7 @@ async function checkForUpdate() {
|
|
|
6480
6511
|
}
|
|
6481
6512
|
}
|
|
6482
6513
|
function printUpdateNotice(latestVersion) {
|
|
6483
|
-
const currentVersion = "0.1.
|
|
6514
|
+
const currentVersion = "0.1.47";
|
|
6484
6515
|
process.stderr.write(
|
|
6485
6516
|
`
|
|
6486
6517
|
${ansi2.cyanBright("Update available")} ${ansi2.gray(currentVersion + " \u2192")} ${ansi2.cyanBold(latestVersion)}
|
|
@@ -6493,7 +6524,7 @@ function isStandaloneBinary() {
|
|
|
6493
6524
|
return !argv1.includes("node_modules");
|
|
6494
6525
|
}
|
|
6495
6526
|
async function cmdUpdate() {
|
|
6496
|
-
const currentVersion = "0.1.
|
|
6527
|
+
const currentVersion = "0.1.47";
|
|
6497
6528
|
process.stderr.write(
|
|
6498
6529
|
` ${ansi2.gray("Current version:")} ${currentVersion}
|
|
6499
6530
|
`
|
|
@@ -6628,7 +6659,7 @@ async function cmdLogin(options) {
|
|
|
6628
6659
|
process.stderr.write("\n");
|
|
6629
6660
|
printLogo();
|
|
6630
6661
|
process.stderr.write("\n");
|
|
6631
|
-
const ver = "0.1.
|
|
6662
|
+
const ver = "0.1.47";
|
|
6632
6663
|
process.stderr.write(
|
|
6633
6664
|
` ${ansi2.bold("MindStudio Agent")} ${ver ? " " + ansi2.gray("v" + ver) : ""}
|
|
6634
6665
|
`
|
|
@@ -6955,7 +6986,7 @@ async function main() {
|
|
|
6955
6986
|
try {
|
|
6956
6987
|
if (command === "version" || command === "-v") {
|
|
6957
6988
|
process.stdout.write(
|
|
6958
|
-
"0.1.
|
|
6989
|
+
"0.1.47\n"
|
|
6959
6990
|
);
|
|
6960
6991
|
return;
|
|
6961
6992
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1159,11 +1159,11 @@ interface RunTaskOptions {
|
|
|
1159
1159
|
input: Record<string, unknown>;
|
|
1160
1160
|
/** SDK method names to make available as tools, with optional default overrides. */
|
|
1161
1161
|
tools: TaskToolConfig[];
|
|
1162
|
-
/** JSON string
|
|
1163
|
-
structuredOutputExample: string
|
|
1162
|
+
/** Expected output shape. Pass a JSON string or an object (will be stringified automatically). */
|
|
1163
|
+
structuredOutputExample: string | Record<string, unknown>;
|
|
1164
1164
|
/** Model ID for the task agent. Must support tool use. */
|
|
1165
1165
|
model: string;
|
|
1166
|
-
/** Max loop iterations before forcing final output. Default
|
|
1166
|
+
/** Max loop iterations before forcing final output. Default 20, max 100. */
|
|
1167
1167
|
maxTurns?: number;
|
|
1168
1168
|
/** App ID to execute within. */
|
|
1169
1169
|
appId?: string;
|
|
@@ -1178,9 +1178,15 @@ interface RunTaskOptions {
|
|
|
1178
1178
|
}
|
|
1179
1179
|
/** An event from a streaming task agent execution. */
|
|
1180
1180
|
interface TaskEvent {
|
|
1181
|
-
type: 'text' | '
|
|
1181
|
+
type: 'text' | 'thinking' | 'thinking_complete' | 'tool_use' | 'tool_input_delta' | 'tool_input_args' | 'tool_call_start' | 'tool_call_result' | 'error' | 'done';
|
|
1182
1182
|
[key: string]: unknown;
|
|
1183
1183
|
}
|
|
1184
|
+
/** Summary of a single tool call within a task execution. */
|
|
1185
|
+
interface TaskToolCall {
|
|
1186
|
+
name: string;
|
|
1187
|
+
success: boolean;
|
|
1188
|
+
durationMs: number;
|
|
1189
|
+
}
|
|
1184
1190
|
/** Usage stats from a task agent execution. */
|
|
1185
1191
|
interface TaskUsage {
|
|
1186
1192
|
inputTokens: number;
|
|
@@ -1191,10 +1197,16 @@ interface TaskUsage {
|
|
|
1191
1197
|
interface RunTaskResult<T = unknown> {
|
|
1192
1198
|
/** Structured output from the task agent, parsed as JSON. */
|
|
1193
1199
|
output: T;
|
|
1200
|
+
/** Raw model text before JSON parse. Useful for debugging when output is garbage. */
|
|
1201
|
+
outputRaw: string;
|
|
1202
|
+
/** Whether the output was valid JSON. When false, `output` is the raw string. */
|
|
1203
|
+
parsedSuccessfully: boolean;
|
|
1194
1204
|
/** Number of loop iterations used. */
|
|
1195
1205
|
turns: number;
|
|
1196
1206
|
/** Token and cost usage. */
|
|
1197
1207
|
usage: TaskUsage;
|
|
1208
|
+
/** Summary of every tool call made during execution. */
|
|
1209
|
+
toolCalls: TaskToolCall[];
|
|
1198
1210
|
}
|
|
1199
1211
|
|
|
1200
1212
|
/**
|
|
@@ -8206,4 +8218,4 @@ declare const stream: (data: string | Record<string, unknown>) => Promise<void>;
|
|
|
8206
8218
|
*/
|
|
8207
8219
|
declare const resolveUser: (userId: string) => Promise<ResolvedUser | null>;
|
|
8208
8220
|
|
|
8209
|
-
export { type Accessor, type ActiveCampaignAddNoteStepInput, type ActiveCampaignAddNoteStepOutput, type ActiveCampaignCreateContactStepInput, type ActiveCampaignCreateContactStepOutput, type AddSubtitlesToVideoStepInput, type AddSubtitlesToVideoStepOutput, type AgentInfo, type AgentOptions, type AirtableCreateUpdateRecordStepInput, type AirtableCreateUpdateRecordStepOutput, type AirtableDeleteRecordStepInput, type AirtableDeleteRecordStepOutput, type AirtableGetRecordStepInput, type AirtableGetRecordStepOutput, type AirtableGetTableRecordsStepInput, type AirtableGetTableRecordsStepOutput, type AnalyzeImageStepInput, type AnalyzeImageStepOutput, type AnalyzeVideoStepInput, type AnalyzeVideoStepOutput, type AppAuthContext, type AppContextResult, type AppDatabase, type AppDatabaseColumnSchema, type AppDatabaseTable, type AppRoleAssignment, AuthContext, type AuthTableConfig, type BatchStepInput, type BatchStepResult, type CaptureThumbnailStepInput, type CaptureThumbnailStepOutput, type CheckAppRoleStepInput, type CheckAppRoleStepOutput, type CodaCreateUpdatePageStepInput, type CodaCreateUpdatePageStepOutput, type CodaCreateUpdateRowStepInput, type CodaCreateUpdateRowStepOutput, type CodaFindRowStepInput, type CodaFindRowStepOutput, type CodaGetPageStepInput, type CodaGetPageStepOutput, type CodaGetTableRowsStepInput, type CodaGetTableRowsStepOutput, type Connection, type ConnectorActionDetail, type ConnectorService, type ConvertPdfToImagesStepInput, type ConvertPdfToImagesStepOutput, type CreateDataSourceStepInput, type CreateDataSourceStepOutput, type CreateGmailDraftStepInput, type CreateGmailDraftStepOutput, type CreateGoogleCalendarEventStepInput, type CreateGoogleCalendarEventStepOutput, type CreateGoogleDocStepInput, type CreateGoogleDocStepOutput, type CreateGoogleSheetStepInput, type CreateGoogleSheetStepOutput, type Db, type DefineTableOptions, type DeleteDataSourceDocumentStepInput, type DeleteDataSourceDocumentStepOutput, type DeleteDataSourceStepInput, type DeleteDataSourceStepOutput, type DeleteGmailEmailStepInput, type DeleteGmailEmailStepOutput, type DeleteGoogleCalendarEventStepInput, type DeleteGoogleCalendarEventStepOutput, type DeleteGoogleSheetRowsStepInput, type DeleteGoogleSheetRowsStepOutput, type DetectChangesStepInput, type DetectChangesStepOutput, type DetectPIIStepInput, type DetectPIIStepOutput, type DiscordEditMessageStepInput, type DiscordEditMessageStepOutput, type DiscordSendFollowUpStepInput, type DiscordSendFollowUpStepOutput, type DiscordSendMessageStepInput, type DiscordSendMessageStepOutput, type DownloadVideoStepInput, type DownloadVideoStepOutput, type EnhanceImageGenerationPromptStepInput, type EnhanceImageGenerationPromptStepOutput, type EnhanceVideoGenerationPromptStepInput, type EnhanceVideoGenerationPromptStepOutput, type EnrichPersonStepInput, type EnrichPersonStepOutput, type ExecuteStepBatchOptions, type ExecuteStepBatchResult, type ExtractAudioFromVideoStepInput, type ExtractAudioFromVideoStepOutput, type ExtractTextStepInput, type ExtractTextStepOutput, type FetchDataSourceDocumentStepInput, type FetchDataSourceDocumentStepOutput, type FetchGoogleDocStepInput, type FetchGoogleDocStepOutput, type FetchGoogleSheetStepInput, type FetchGoogleSheetStepOutput, type FetchSlackChannelHistoryStepInput, type FetchSlackChannelHistoryStepOutput, type FetchYoutubeCaptionsStepInput, type FetchYoutubeCaptionsStepOutput, type FetchYoutubeChannelStepInput, type FetchYoutubeChannelStepOutput, type FetchYoutubeCommentsStepInput, type FetchYoutubeCommentsStepOutput, type FetchYoutubeVideoStepInput, type FetchYoutubeVideoStepOutput, type GenerateAssetStepInput, type GenerateAssetStepOutput, type GenerateChartStepInput, type GenerateChartStepOutput, type GenerateImageStepInput, type GenerateImageStepOutput, type GenerateLipsyncStepInput, type GenerateLipsyncStepOutput, type GenerateMusicStepInput, type GenerateMusicStepOutput, type GeneratePdfStepInput, type GeneratePdfStepOutput, type GenerateStaticVideoFromImageStepInput, type GenerateStaticVideoFromImageStepOutput, type GenerateTextStepInput, type GenerateTextStepOutput, type GenerateVideoStepInput, type GenerateVideoStepOutput, type GetGmailAttachmentsStepInput, type GetGmailAttachmentsStepOutput, type GetGmailDraftStepInput, type GetGmailDraftStepOutput, type GetGmailEmailStepInput, type GetGmailEmailStepOutput, type GetGmailUnreadCountStepInput, type GetGmailUnreadCountStepOutput, type GetGoogleCalendarEventStepInput, type GetGoogleCalendarEventStepOutput, type GetGoogleDriveFileStepInput, type GetGoogleDriveFileStepOutput, type GetGoogleSheetInfoStepInput, type GetGoogleSheetInfoStepOutput, type GetMediaMetadataStepInput, type GetMediaMetadataStepOutput, type HttpRequestStepInput, type HttpRequestStepOutput, type HubspotCreateCompanyStepInput, type HubspotCreateCompanyStepOutput, type HubspotCreateContactStepInput, type HubspotCreateContactStepOutput, type HubspotGetCompanyStepInput, type HubspotGetCompanyStepOutput, type HubspotGetContactStepInput, type HubspotGetContactStepOutput, type HunterApiCompanyEnrichmentStepInput, type HunterApiCompanyEnrichmentStepOutput, type HunterApiDomainSearchStepInput, type HunterApiDomainSearchStepOutput, type HunterApiEmailFinderStepInput, type HunterApiEmailFinderStepOutput, type HunterApiEmailVerificationStepInput, type HunterApiEmailVerificationStepOutput, type HunterApiPersonEnrichmentStepInput, type HunterApiPersonEnrichmentStepOutput, type ImageFaceSwapStepInput, type ImageFaceSwapStepOutput, type ImageRemoveWatermarkStepInput, type ImageRemoveWatermarkStepOutput, type InsertVideoClipsStepInput, type InsertVideoClipsStepOutput, type ListAgentsResult, type ListDataSourcesStepInput, type ListDataSourcesStepOutput, type ListGmailDraftsStepInput, type ListGmailDraftsStepOutput, type ListGmailLabelsStepInput, type ListGmailLabelsStepOutput, type ListGoogleCalendarEventsStepInput, type ListGoogleCalendarEventsStepOutput, type ListGoogleDriveFilesStepInput, type ListGoogleDriveFilesStepOutput, type ListRecentGmailEmailsStepInput, type ListRecentGmailEmailsStepOutput, type LogicStepInput, type LogicStepOutput, type MakeDotComRunScenarioStepInput, type MakeDotComRunScenarioStepOutput, type MergeAudioStepInput, type MergeAudioStepOutput, type MergeVideosStepInput, type MergeVideosStepOutput, MindStudioAgent, MindStudioError, type MindStudioModel, type MindStudioModelSummary, type MixAudioIntoVideoStepInput, type MixAudioIntoVideoStepOutput, type ModelType, type MonacoSnippet, type MonacoSnippetField, type MonacoSnippetFieldType, type MuteVideoStepInput, type MuteVideoStepOutput, type N8nRunNodeStepInput, type N8nRunNodeStepOutput, type NotionCreatePageStepInput, type NotionCreatePageStepOutput, type NotionUpdatePageStepInput, type NotionUpdatePageStepOutput, type PeopleSearchStepInput, type PeopleSearchStepOutput, type PostToLinkedInStepInput, type PostToLinkedInStepOutput, type PostToSlackChannelStepInput, type PostToSlackChannelStepOutput, type PostToXStepInput, type PostToXStepOutput, type PostToZapierStepInput, type PostToZapierStepOutput, type Predicate, type PushInput, Query, type QueryAppDatabaseStepInput, type QueryAppDatabaseStepOutput, type QueryDataSourceStepInput, type QueryDataSourceStepOutput, type QueryExternalDatabaseStepInput, type QueryExternalDatabaseStepOutput, type RedactPIIStepInput, type RedactPIIStepOutput, type RemoveBackgroundFromImageStepInput, type RemoveBackgroundFromImageStepOutput, type ReplyToGmailEmailStepInput, type ReplyToGmailEmailStepOutput, type RequestContext, type ResizeVideoStepInput, type ResizeVideoStepOutput, type ResolvedUser, Roles, type RunAgentOptions, type RunAgentResult, type RunFromConnectorRegistryStepInput, type RunFromConnectorRegistryStepOutput, type RunPackagedWorkflowStepInput, type RunPackagedWorkflowStepOutput, type RunTaskOptions, type RunTaskResult, type ScrapeFacebookPageStepInput, type ScrapeFacebookPageStepOutput, type ScrapeFacebookPostsStepInput, type ScrapeFacebookPostsStepOutput, type ScrapeInstagramCommentsStepInput, type ScrapeInstagramCommentsStepOutput, type ScrapeInstagramMentionsStepInput, type ScrapeInstagramMentionsStepOutput, type ScrapeInstagramPostsStepInput, type ScrapeInstagramPostsStepOutput, type ScrapeInstagramProfileStepInput, type ScrapeInstagramProfileStepOutput, type ScrapeInstagramReelsStepInput, type ScrapeInstagramReelsStepOutput, type ScrapeLinkedInCompanyStepInput, type ScrapeLinkedInCompanyStepOutput, type ScrapeLinkedInProfileStepInput, type ScrapeLinkedInProfileStepOutput, type ScrapeMetaThreadsProfileStepInput, type ScrapeMetaThreadsProfileStepOutput, type ScrapeUrlStepInput, type ScrapeUrlStepOutput, type ScrapeXPostStepInput, type ScrapeXPostStepOutput, type ScrapeXProfileStepInput, type ScrapeXProfileStepOutput, type ScreenshotUrlStepInput, type ScreenshotUrlStepOutput, type SearchGmailEmailsStepInput, type SearchGmailEmailsStepOutput, type SearchGoogleCalendarEventsStepInput, type SearchGoogleCalendarEventsStepOutput, type SearchGoogleDriveStepInput, type SearchGoogleDriveStepOutput, type SearchGoogleImagesStepInput, type SearchGoogleImagesStepOutput, type SearchGoogleNewsStepInput, type SearchGoogleNewsStepOutput, type SearchGoogleStepInput, type SearchGoogleStepOutput, type SearchGoogleTrendsStepInput, type SearchGoogleTrendsStepOutput, type SearchPerplexityStepInput, type SearchPerplexityStepOutput, type SearchXPostsStepInput, type SearchXPostsStepOutput, type SearchYoutubeStepInput, type SearchYoutubeStepOutput, type SearchYoutubeTrendsStepInput, type SearchYoutubeTrendsStepOutput, type SendEmailStepInput, type SendEmailStepOutput, type SendGmailDraftStepInput, type SendGmailDraftStepOutput, type SendGmailMessageStepInput, type SendGmailMessageStepOutput, type SendSMSStepInput, type SendSMSStepOutput, type SendSlackDirectMessageStepInput, type SendSlackDirectMessageStepOutput, type SetGmailReadStatusStepInput, type SetGmailReadStatusStepOutput, type SetRunTitleStepInput, type SetRunTitleStepOutput, type SetVariableStepInput, type SetVariableStepOutput, type StepCostEstimateEntry, type StepExecutionMeta, type StepExecutionOptions, type StepExecutionResult, type StepInputMap, type StepLogEvent, type StepMetadata, type StepMethods, type StepName, type StepOutputMap, type SystemFields, Table, type TaskEvent, type TaskToolConfig, type TaskUsage, type TelegramEditMessageStepInput, type TelegramEditMessageStepOutput, type TelegramReplyToMessageStepInput, type TelegramReplyToMessageStepOutput, type TelegramSendAudioStepInput, type TelegramSendAudioStepOutput, type TelegramSendFileStepInput, type TelegramSendFileStepOutput, type TelegramSendImageStepInput, type TelegramSendImageStepOutput, type TelegramSendMessageStepInput, type TelegramSendMessageStepOutput, type TelegramSendVideoStepInput, type TelegramSendVideoStepOutput, type TelegramSetTypingStepInput, type TelegramSetTypingStepOutput, type TextToSpeechStepInput, type TextToSpeechStepOutput, type TranscribeAudioStepInput, type TranscribeAudioStepOutput, type TrimMediaStepInput, type TrimMediaStepOutput, type UpdateGmailLabelsStepInput, type UpdateGmailLabelsStepOutput, type UpdateGoogleCalendarEventStepInput, type UpdateGoogleCalendarEventStepOutput, type UpdateGoogleDocStepInput, type UpdateGoogleDocStepOutput, type UpdateGoogleSheetStepInput, type UpdateGoogleSheetStepOutput, type UpdateInput, type UploadDataSourceDocumentStepInput, type UploadDataSourceDocumentStepOutput, type UploadFileResult, type UpscaleImageStepInput, type UpscaleImageStepOutput, type UpscaleVideoStepInput, type UpscaleVideoStepOutput, type User, type UserInfoResult, type UserMessageStepInput, type UserMessageStepOutput, type VideoFaceSwapStepInput, type VideoFaceSwapStepOutput, type VideoRemoveBackgroundStepInput, type VideoRemoveBackgroundStepOutput, type VideoRemoveWatermarkStepInput, type VideoRemoveWatermarkStepOutput, type WatermarkImageStepInput, type WatermarkImageStepOutput, type WatermarkVideoStepInput, type WatermarkVideoStepOutput, auth, blockTypeAliases, db, mindstudio as default, getRequestContext, mindstudio, monacoSnippets, resolveUser, runWithContext, stepMetadata, stream };
|
|
8221
|
+
export { type Accessor, type ActiveCampaignAddNoteStepInput, type ActiveCampaignAddNoteStepOutput, type ActiveCampaignCreateContactStepInput, type ActiveCampaignCreateContactStepOutput, type AddSubtitlesToVideoStepInput, type AddSubtitlesToVideoStepOutput, type AgentInfo, type AgentOptions, type AirtableCreateUpdateRecordStepInput, type AirtableCreateUpdateRecordStepOutput, type AirtableDeleteRecordStepInput, type AirtableDeleteRecordStepOutput, type AirtableGetRecordStepInput, type AirtableGetRecordStepOutput, type AirtableGetTableRecordsStepInput, type AirtableGetTableRecordsStepOutput, type AnalyzeImageStepInput, type AnalyzeImageStepOutput, type AnalyzeVideoStepInput, type AnalyzeVideoStepOutput, type AppAuthContext, type AppContextResult, type AppDatabase, type AppDatabaseColumnSchema, type AppDatabaseTable, type AppRoleAssignment, AuthContext, type AuthTableConfig, type BatchStepInput, type BatchStepResult, type CaptureThumbnailStepInput, type CaptureThumbnailStepOutput, type CheckAppRoleStepInput, type CheckAppRoleStepOutput, type CodaCreateUpdatePageStepInput, type CodaCreateUpdatePageStepOutput, type CodaCreateUpdateRowStepInput, type CodaCreateUpdateRowStepOutput, type CodaFindRowStepInput, type CodaFindRowStepOutput, type CodaGetPageStepInput, type CodaGetPageStepOutput, type CodaGetTableRowsStepInput, type CodaGetTableRowsStepOutput, type Connection, type ConnectorActionDetail, type ConnectorService, type ConvertPdfToImagesStepInput, type ConvertPdfToImagesStepOutput, type CreateDataSourceStepInput, type CreateDataSourceStepOutput, type CreateGmailDraftStepInput, type CreateGmailDraftStepOutput, type CreateGoogleCalendarEventStepInput, type CreateGoogleCalendarEventStepOutput, type CreateGoogleDocStepInput, type CreateGoogleDocStepOutput, type CreateGoogleSheetStepInput, type CreateGoogleSheetStepOutput, type Db, type DefineTableOptions, type DeleteDataSourceDocumentStepInput, type DeleteDataSourceDocumentStepOutput, type DeleteDataSourceStepInput, type DeleteDataSourceStepOutput, type DeleteGmailEmailStepInput, type DeleteGmailEmailStepOutput, type DeleteGoogleCalendarEventStepInput, type DeleteGoogleCalendarEventStepOutput, type DeleteGoogleSheetRowsStepInput, type DeleteGoogleSheetRowsStepOutput, type DetectChangesStepInput, type DetectChangesStepOutput, type DetectPIIStepInput, type DetectPIIStepOutput, type DiscordEditMessageStepInput, type DiscordEditMessageStepOutput, type DiscordSendFollowUpStepInput, type DiscordSendFollowUpStepOutput, type DiscordSendMessageStepInput, type DiscordSendMessageStepOutput, type DownloadVideoStepInput, type DownloadVideoStepOutput, type EnhanceImageGenerationPromptStepInput, type EnhanceImageGenerationPromptStepOutput, type EnhanceVideoGenerationPromptStepInput, type EnhanceVideoGenerationPromptStepOutput, type EnrichPersonStepInput, type EnrichPersonStepOutput, type ExecuteStepBatchOptions, type ExecuteStepBatchResult, type ExtractAudioFromVideoStepInput, type ExtractAudioFromVideoStepOutput, type ExtractTextStepInput, type ExtractTextStepOutput, type FetchDataSourceDocumentStepInput, type FetchDataSourceDocumentStepOutput, type FetchGoogleDocStepInput, type FetchGoogleDocStepOutput, type FetchGoogleSheetStepInput, type FetchGoogleSheetStepOutput, type FetchSlackChannelHistoryStepInput, type FetchSlackChannelHistoryStepOutput, type FetchYoutubeCaptionsStepInput, type FetchYoutubeCaptionsStepOutput, type FetchYoutubeChannelStepInput, type FetchYoutubeChannelStepOutput, type FetchYoutubeCommentsStepInput, type FetchYoutubeCommentsStepOutput, type FetchYoutubeVideoStepInput, type FetchYoutubeVideoStepOutput, type GenerateAssetStepInput, type GenerateAssetStepOutput, type GenerateChartStepInput, type GenerateChartStepOutput, type GenerateImageStepInput, type GenerateImageStepOutput, type GenerateLipsyncStepInput, type GenerateLipsyncStepOutput, type GenerateMusicStepInput, type GenerateMusicStepOutput, type GeneratePdfStepInput, type GeneratePdfStepOutput, type GenerateStaticVideoFromImageStepInput, type GenerateStaticVideoFromImageStepOutput, type GenerateTextStepInput, type GenerateTextStepOutput, type GenerateVideoStepInput, type GenerateVideoStepOutput, type GetGmailAttachmentsStepInput, type GetGmailAttachmentsStepOutput, type GetGmailDraftStepInput, type GetGmailDraftStepOutput, type GetGmailEmailStepInput, type GetGmailEmailStepOutput, type GetGmailUnreadCountStepInput, type GetGmailUnreadCountStepOutput, type GetGoogleCalendarEventStepInput, type GetGoogleCalendarEventStepOutput, type GetGoogleDriveFileStepInput, type GetGoogleDriveFileStepOutput, type GetGoogleSheetInfoStepInput, type GetGoogleSheetInfoStepOutput, type GetMediaMetadataStepInput, type GetMediaMetadataStepOutput, type HttpRequestStepInput, type HttpRequestStepOutput, type HubspotCreateCompanyStepInput, type HubspotCreateCompanyStepOutput, type HubspotCreateContactStepInput, type HubspotCreateContactStepOutput, type HubspotGetCompanyStepInput, type HubspotGetCompanyStepOutput, type HubspotGetContactStepInput, type HubspotGetContactStepOutput, type HunterApiCompanyEnrichmentStepInput, type HunterApiCompanyEnrichmentStepOutput, type HunterApiDomainSearchStepInput, type HunterApiDomainSearchStepOutput, type HunterApiEmailFinderStepInput, type HunterApiEmailFinderStepOutput, type HunterApiEmailVerificationStepInput, type HunterApiEmailVerificationStepOutput, type HunterApiPersonEnrichmentStepInput, type HunterApiPersonEnrichmentStepOutput, type ImageFaceSwapStepInput, type ImageFaceSwapStepOutput, type ImageRemoveWatermarkStepInput, type ImageRemoveWatermarkStepOutput, type InsertVideoClipsStepInput, type InsertVideoClipsStepOutput, type ListAgentsResult, type ListDataSourcesStepInput, type ListDataSourcesStepOutput, type ListGmailDraftsStepInput, type ListGmailDraftsStepOutput, type ListGmailLabelsStepInput, type ListGmailLabelsStepOutput, type ListGoogleCalendarEventsStepInput, type ListGoogleCalendarEventsStepOutput, type ListGoogleDriveFilesStepInput, type ListGoogleDriveFilesStepOutput, type ListRecentGmailEmailsStepInput, type ListRecentGmailEmailsStepOutput, type LogicStepInput, type LogicStepOutput, type MakeDotComRunScenarioStepInput, type MakeDotComRunScenarioStepOutput, type MergeAudioStepInput, type MergeAudioStepOutput, type MergeVideosStepInput, type MergeVideosStepOutput, MindStudioAgent, MindStudioError, type MindStudioModel, type MindStudioModelSummary, type MixAudioIntoVideoStepInput, type MixAudioIntoVideoStepOutput, type ModelType, type MonacoSnippet, type MonacoSnippetField, type MonacoSnippetFieldType, type MuteVideoStepInput, type MuteVideoStepOutput, type N8nRunNodeStepInput, type N8nRunNodeStepOutput, type NotionCreatePageStepInput, type NotionCreatePageStepOutput, type NotionUpdatePageStepInput, type NotionUpdatePageStepOutput, type PeopleSearchStepInput, type PeopleSearchStepOutput, type PostToLinkedInStepInput, type PostToLinkedInStepOutput, type PostToSlackChannelStepInput, type PostToSlackChannelStepOutput, type PostToXStepInput, type PostToXStepOutput, type PostToZapierStepInput, type PostToZapierStepOutput, type Predicate, type PushInput, Query, type QueryAppDatabaseStepInput, type QueryAppDatabaseStepOutput, type QueryDataSourceStepInput, type QueryDataSourceStepOutput, type QueryExternalDatabaseStepInput, type QueryExternalDatabaseStepOutput, type RedactPIIStepInput, type RedactPIIStepOutput, type RemoveBackgroundFromImageStepInput, type RemoveBackgroundFromImageStepOutput, type ReplyToGmailEmailStepInput, type ReplyToGmailEmailStepOutput, type RequestContext, type ResizeVideoStepInput, type ResizeVideoStepOutput, type ResolvedUser, Roles, type RunAgentOptions, type RunAgentResult, type RunFromConnectorRegistryStepInput, type RunFromConnectorRegistryStepOutput, type RunPackagedWorkflowStepInput, type RunPackagedWorkflowStepOutput, type RunTaskOptions, type RunTaskResult, type ScrapeFacebookPageStepInput, type ScrapeFacebookPageStepOutput, type ScrapeFacebookPostsStepInput, type ScrapeFacebookPostsStepOutput, type ScrapeInstagramCommentsStepInput, type ScrapeInstagramCommentsStepOutput, type ScrapeInstagramMentionsStepInput, type ScrapeInstagramMentionsStepOutput, type ScrapeInstagramPostsStepInput, type ScrapeInstagramPostsStepOutput, type ScrapeInstagramProfileStepInput, type ScrapeInstagramProfileStepOutput, type ScrapeInstagramReelsStepInput, type ScrapeInstagramReelsStepOutput, type ScrapeLinkedInCompanyStepInput, type ScrapeLinkedInCompanyStepOutput, type ScrapeLinkedInProfileStepInput, type ScrapeLinkedInProfileStepOutput, type ScrapeMetaThreadsProfileStepInput, type ScrapeMetaThreadsProfileStepOutput, type ScrapeUrlStepInput, type ScrapeUrlStepOutput, type ScrapeXPostStepInput, type ScrapeXPostStepOutput, type ScrapeXProfileStepInput, type ScrapeXProfileStepOutput, type ScreenshotUrlStepInput, type ScreenshotUrlStepOutput, type SearchGmailEmailsStepInput, type SearchGmailEmailsStepOutput, type SearchGoogleCalendarEventsStepInput, type SearchGoogleCalendarEventsStepOutput, type SearchGoogleDriveStepInput, type SearchGoogleDriveStepOutput, type SearchGoogleImagesStepInput, type SearchGoogleImagesStepOutput, type SearchGoogleNewsStepInput, type SearchGoogleNewsStepOutput, type SearchGoogleStepInput, type SearchGoogleStepOutput, type SearchGoogleTrendsStepInput, type SearchGoogleTrendsStepOutput, type SearchPerplexityStepInput, type SearchPerplexityStepOutput, type SearchXPostsStepInput, type SearchXPostsStepOutput, type SearchYoutubeStepInput, type SearchYoutubeStepOutput, type SearchYoutubeTrendsStepInput, type SearchYoutubeTrendsStepOutput, type SendEmailStepInput, type SendEmailStepOutput, type SendGmailDraftStepInput, type SendGmailDraftStepOutput, type SendGmailMessageStepInput, type SendGmailMessageStepOutput, type SendSMSStepInput, type SendSMSStepOutput, type SendSlackDirectMessageStepInput, type SendSlackDirectMessageStepOutput, type SetGmailReadStatusStepInput, type SetGmailReadStatusStepOutput, type SetRunTitleStepInput, type SetRunTitleStepOutput, type SetVariableStepInput, type SetVariableStepOutput, type StepCostEstimateEntry, type StepExecutionMeta, type StepExecutionOptions, type StepExecutionResult, type StepInputMap, type StepLogEvent, type StepMetadata, type StepMethods, type StepName, type StepOutputMap, type SystemFields, Table, type TaskEvent, type TaskToolCall, type TaskToolConfig, type TaskUsage, type TelegramEditMessageStepInput, type TelegramEditMessageStepOutput, type TelegramReplyToMessageStepInput, type TelegramReplyToMessageStepOutput, type TelegramSendAudioStepInput, type TelegramSendAudioStepOutput, type TelegramSendFileStepInput, type TelegramSendFileStepOutput, type TelegramSendImageStepInput, type TelegramSendImageStepOutput, type TelegramSendMessageStepInput, type TelegramSendMessageStepOutput, type TelegramSendVideoStepInput, type TelegramSendVideoStepOutput, type TelegramSetTypingStepInput, type TelegramSetTypingStepOutput, type TextToSpeechStepInput, type TextToSpeechStepOutput, type TranscribeAudioStepInput, type TranscribeAudioStepOutput, type TrimMediaStepInput, type TrimMediaStepOutput, type UpdateGmailLabelsStepInput, type UpdateGmailLabelsStepOutput, type UpdateGoogleCalendarEventStepInput, type UpdateGoogleCalendarEventStepOutput, type UpdateGoogleDocStepInput, type UpdateGoogleDocStepOutput, type UpdateGoogleSheetStepInput, type UpdateGoogleSheetStepOutput, type UpdateInput, type UploadDataSourceDocumentStepInput, type UploadDataSourceDocumentStepOutput, type UploadFileResult, type UpscaleImageStepInput, type UpscaleImageStepOutput, type UpscaleVideoStepInput, type UpscaleVideoStepOutput, type User, type UserInfoResult, type UserMessageStepInput, type UserMessageStepOutput, type VideoFaceSwapStepInput, type VideoFaceSwapStepOutput, type VideoRemoveBackgroundStepInput, type VideoRemoveBackgroundStepOutput, type VideoRemoveWatermarkStepInput, type VideoRemoveWatermarkStepOutput, type WatermarkImageStepInput, type WatermarkImageStepOutput, type WatermarkVideoStepInput, type WatermarkVideoStepOutput, auth, blockTypeAliases, db, mindstudio as default, getRequestContext, mindstudio, monacoSnippets, resolveUser, runWithContext, stepMetadata, stream };
|
package/dist/index.js
CHANGED
|
@@ -42,9 +42,9 @@ async function requestWithRetry(config, method, url, body, attempt) {
|
|
|
42
42
|
body: body != null ? JSON.stringify(body) : void 0
|
|
43
43
|
});
|
|
44
44
|
config.rateLimiter.updateFromHeaders(res.headers);
|
|
45
|
-
if (res.status === 429
|
|
45
|
+
if (attempt < config.maxRetries && (res.status === 429 || res.status === 502 || res.status === 503 || res.status === 504)) {
|
|
46
46
|
const retryAfter = res.headers.get("retry-after");
|
|
47
|
-
const waitMs = retryAfter ? parseFloat(retryAfter) * 1e3 : 1e3;
|
|
47
|
+
const waitMs = retryAfter ? parseFloat(retryAfter) * 1e3 : Math.min(1e3 * Math.pow(2, attempt), 1e4);
|
|
48
48
|
await sleep(waitMs);
|
|
49
49
|
return requestWithRetry(config, method, url, body, attempt + 1);
|
|
50
50
|
}
|
|
@@ -2884,7 +2884,7 @@ function buildTaskRequestBody(options) {
|
|
|
2884
2884
|
prompt: options.prompt,
|
|
2885
2885
|
input: options.input,
|
|
2886
2886
|
tools: mapTools(options.tools),
|
|
2887
|
-
structuredOutputExample: options.structuredOutputExample,
|
|
2887
|
+
structuredOutputExample: typeof options.structuredOutputExample === "string" ? options.structuredOutputExample : JSON.stringify(options.structuredOutputExample),
|
|
2888
2888
|
model: options.model,
|
|
2889
2889
|
...options.maxTurns != null && { maxTurns: options.maxTurns },
|
|
2890
2890
|
...options.appId != null && { appId: options.appId },
|
|
@@ -2894,6 +2894,16 @@ function buildTaskRequestBody(options) {
|
|
|
2894
2894
|
function sleep2(ms) {
|
|
2895
2895
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2896
2896
|
}
|
|
2897
|
+
function isDevMode() {
|
|
2898
|
+
return !!(process.env.CALLBACK_TOKEN || getRequestContext()?.callbackToken);
|
|
2899
|
+
}
|
|
2900
|
+
function logTaskResult(result) {
|
|
2901
|
+
if (!isDevMode()) return;
|
|
2902
|
+
const toolSummary = result.toolCalls.map((tc) => `${tc.name} (${tc.durationMs}ms) ${tc.success ? "\u2713" : "\u2717"}`).join(", ");
|
|
2903
|
+
console.log(
|
|
2904
|
+
`[task] ${result.turns} turn${result.turns === 1 ? "" : "s"}` + (toolSummary ? `: ${toolSummary}` : "") + ` | ${result.parsedSuccessfully ? "output OK" : "\u26A0 output not valid JSON"} | cost: ${result.usage.totalBillingCost}`
|
|
2905
|
+
);
|
|
2906
|
+
}
|
|
2897
2907
|
async function runTaskPoll(httpConfig, body) {
|
|
2898
2908
|
const { data } = await request(
|
|
2899
2909
|
httpConfig,
|
|
@@ -2909,6 +2919,7 @@ async function runTaskPoll(httpConfig, body) {
|
|
|
2909
2919
|
const res = await fetch(pollUrl, {
|
|
2910
2920
|
headers: { "User-Agent": "@mindstudio-ai/agent" }
|
|
2911
2921
|
});
|
|
2922
|
+
if (res.status === 502 || res.status === 503 || res.status === 504) continue;
|
|
2912
2923
|
if (res.status === 404) {
|
|
2913
2924
|
throw new MindStudioError(
|
|
2914
2925
|
"Task poll token not found or expired.",
|
|
@@ -2926,7 +2937,12 @@ async function runTaskPoll(httpConfig, body) {
|
|
|
2926
2937
|
);
|
|
2927
2938
|
}
|
|
2928
2939
|
const poll = await res.json();
|
|
2929
|
-
if (poll.status === "pending")
|
|
2940
|
+
if (poll.status === "pending") {
|
|
2941
|
+
if (isDevMode() && poll.currentTurn != null) {
|
|
2942
|
+
console.log(`[task] running... turn ${poll.currentTurn}/${poll.maxTurns ?? "?"}`);
|
|
2943
|
+
}
|
|
2944
|
+
continue;
|
|
2945
|
+
}
|
|
2930
2946
|
if (poll.status === "error") {
|
|
2931
2947
|
throw new MindStudioError(
|
|
2932
2948
|
poll.error ?? "Task execution failed.",
|
|
@@ -2934,11 +2950,16 @@ async function runTaskPoll(httpConfig, body) {
|
|
|
2934
2950
|
500
|
|
2935
2951
|
);
|
|
2936
2952
|
}
|
|
2937
|
-
|
|
2953
|
+
const result = {
|
|
2938
2954
|
output: poll.output,
|
|
2955
|
+
outputRaw: poll.outputRaw ?? "",
|
|
2956
|
+
parsedSuccessfully: poll.parsedSuccessfully ?? true,
|
|
2939
2957
|
turns: poll.turns ?? 0,
|
|
2940
|
-
usage: poll.usage ?? { inputTokens: 0, outputTokens: 0, totalBillingCost: 0 }
|
|
2958
|
+
usage: poll.usage ?? { inputTokens: 0, outputTokens: 0, totalBillingCost: 0 },
|
|
2959
|
+
toolCalls: poll.toolCalls ?? []
|
|
2941
2960
|
};
|
|
2961
|
+
logTaskResult(result);
|
|
2962
|
+
return result;
|
|
2942
2963
|
}
|
|
2943
2964
|
}
|
|
2944
2965
|
async function runTaskStream(httpConfig, body, onEvent) {
|
|
@@ -2998,12 +3019,15 @@ async function runTaskStream(httpConfig, body, onEvent) {
|
|
|
2998
3019
|
if (event.type === "done") {
|
|
2999
3020
|
result = {
|
|
3000
3021
|
output: event.output,
|
|
3022
|
+
outputRaw: event.outputRaw ?? "",
|
|
3023
|
+
parsedSuccessfully: event.parsedSuccessfully ?? true,
|
|
3001
3024
|
turns: event.turns ?? 0,
|
|
3002
3025
|
usage: event.usage ?? {
|
|
3003
3026
|
inputTokens: 0,
|
|
3004
3027
|
outputTokens: 0,
|
|
3005
3028
|
totalBillingCost: 0
|
|
3006
|
-
}
|
|
3029
|
+
},
|
|
3030
|
+
toolCalls: event.toolCalls ?? []
|
|
3007
3031
|
};
|
|
3008
3032
|
}
|
|
3009
3033
|
} catch (err) {
|
|
@@ -3025,12 +3049,15 @@ async function runTaskStream(httpConfig, body, onEvent) {
|
|
|
3025
3049
|
if (event.type === "done") {
|
|
3026
3050
|
result = {
|
|
3027
3051
|
output: event.output,
|
|
3052
|
+
outputRaw: event.outputRaw ?? "",
|
|
3053
|
+
parsedSuccessfully: event.parsedSuccessfully ?? true,
|
|
3028
3054
|
turns: event.turns ?? 0,
|
|
3029
3055
|
usage: event.usage ?? {
|
|
3030
3056
|
inputTokens: 0,
|
|
3031
3057
|
outputTokens: 0,
|
|
3032
3058
|
totalBillingCost: 0
|
|
3033
|
-
}
|
|
3059
|
+
},
|
|
3060
|
+
toolCalls: event.toolCalls ?? []
|
|
3034
3061
|
};
|
|
3035
3062
|
}
|
|
3036
3063
|
} catch (err) {
|
|
@@ -3044,6 +3071,7 @@ async function runTaskStream(httpConfig, body, onEvent) {
|
|
|
3044
3071
|
500
|
|
3045
3072
|
);
|
|
3046
3073
|
}
|
|
3074
|
+
logTaskResult(result);
|
|
3047
3075
|
return result;
|
|
3048
3076
|
}
|
|
3049
3077
|
|
|
@@ -3884,6 +3912,7 @@ var MindStudioAgent = class {
|
|
|
3884
3912
|
const res = await fetch(pollUrl, {
|
|
3885
3913
|
headers: { "User-Agent": "@mindstudio-ai/agent" }
|
|
3886
3914
|
});
|
|
3915
|
+
if (res.status === 502 || res.status === 503 || res.status === 504) continue;
|
|
3887
3916
|
if (res.status === 404) {
|
|
3888
3917
|
throw new MindStudioError(
|
|
3889
3918
|
"Batch poll token not found or expired.",
|
|
@@ -4047,6 +4076,7 @@ var MindStudioAgent = class {
|
|
|
4047
4076
|
const res = await fetch(pollUrl, {
|
|
4048
4077
|
headers: { "User-Agent": "@mindstudio-ai/agent" }
|
|
4049
4078
|
});
|
|
4079
|
+
if (res.status === 502 || res.status === 503 || res.status === 504) continue;
|
|
4050
4080
|
if (res.status === 404) {
|
|
4051
4081
|
throw new MindStudioError(
|
|
4052
4082
|
"Poll token not found or expired.",
|