@menteeai/menteeswe 0.1.20 → 0.1.21
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 +24 -12
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -897,13 +897,15 @@ function isRateLimitError(error) {
|
|
|
897
897
|
}
|
|
898
898
|
return /\b429\b|max rpm|rate limit|too many requests/i.test(error.message);
|
|
899
899
|
}
|
|
900
|
-
async function generateWithRetry(provider, model, system, messages, tools, bus, onToken) {
|
|
900
|
+
async function generateWithRetry(provider, model, system, messages, tools, bus, onToken, signal) {
|
|
901
901
|
let lastError = null;
|
|
902
902
|
for (let attempt = 0; attempt <= RATE_LIMIT_MAX_ATTEMPTS; attempt++) {
|
|
903
|
+
if (signal?.aborted) throw new Error("Aborted by user");
|
|
903
904
|
try {
|
|
904
|
-
return await provider.generate({ system, messages, tools: tools.schemas(), onToken }, model);
|
|
905
|
+
return await provider.generate({ system, messages, tools: tools.schemas(), onToken, signal }, model);
|
|
905
906
|
} catch (error) {
|
|
906
907
|
lastError = error;
|
|
908
|
+
if (signal?.aborted) throw lastError;
|
|
907
909
|
if (attempt >= RATE_LIMIT_MAX_ATTEMPTS || !isRateLimitError(lastError)) {
|
|
908
910
|
throw lastError;
|
|
909
911
|
}
|
|
@@ -1045,9 +1047,13 @@ ${systemExtra}` : "");
|
|
|
1045
1047
|
};
|
|
1046
1048
|
let response;
|
|
1047
1049
|
try {
|
|
1048
|
-
response = await generateWithRetry(provider, model, system, messages, tools, bus, onToken);
|
|
1050
|
+
response = await generateWithRetry(provider, model, system, messages, tools, bus, onToken, signal);
|
|
1049
1051
|
} catch (error) {
|
|
1050
1052
|
flushThink();
|
|
1053
|
+
if (signal?.aborted) {
|
|
1054
|
+
finalText = "Task cancelled.";
|
|
1055
|
+
break;
|
|
1056
|
+
}
|
|
1051
1057
|
const message = error.message;
|
|
1052
1058
|
let hint = "";
|
|
1053
1059
|
if (/insufficient balance|no resource package|recharge/i.test(message)) {
|
|
@@ -1131,6 +1137,7 @@ Investigate the root cause, fix it, then finish with a final answer.`
|
|
|
1131
1137
|
bus.emit("info", response.content.trim().slice(0, 300));
|
|
1132
1138
|
}
|
|
1133
1139
|
for (const call of response.toolCalls) {
|
|
1140
|
+
if (signal?.aborted) break;
|
|
1134
1141
|
const tool = tools.get(call.function.name);
|
|
1135
1142
|
if (!tool) {
|
|
1136
1143
|
messages.push({
|
|
@@ -1299,7 +1306,7 @@ var init_loop = __esm({
|
|
|
1299
1306
|
var version;
|
|
1300
1307
|
var init_package = __esm({
|
|
1301
1308
|
"package.json"() {
|
|
1302
|
-
version = "0.1.
|
|
1309
|
+
version = "0.1.21";
|
|
1303
1310
|
}
|
|
1304
1311
|
});
|
|
1305
1312
|
|
|
@@ -2252,16 +2259,20 @@ var OpenAICompatProvider = class {
|
|
|
2252
2259
|
...request.temperature !== void 0 ? { temperature: request.temperature } : {},
|
|
2253
2260
|
...request.maxTokens ? { max_tokens: request.maxTokens } : {}
|
|
2254
2261
|
};
|
|
2262
|
+
const reqOptions = request.signal ? { signal: request.signal } : void 0;
|
|
2255
2263
|
if (!request.onToken) {
|
|
2256
|
-
const response2 = await this.client.chat.completions.create(baseParams);
|
|
2264
|
+
const response2 = await this.client.chat.completions.create(baseParams, reqOptions);
|
|
2257
2265
|
return parseResponse(response2);
|
|
2258
2266
|
}
|
|
2259
2267
|
const streamOnce = async (withUsage) => {
|
|
2260
|
-
const stream = await this.client.chat.completions.create(
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2268
|
+
const stream = await this.client.chat.completions.create(
|
|
2269
|
+
{
|
|
2270
|
+
...baseParams,
|
|
2271
|
+
stream: true,
|
|
2272
|
+
...withUsage ? { stream_options: { include_usage: true } } : {}
|
|
2273
|
+
},
|
|
2274
|
+
reqOptions
|
|
2275
|
+
);
|
|
2265
2276
|
let content = "";
|
|
2266
2277
|
let finishReason = "stop";
|
|
2267
2278
|
let usage;
|
|
@@ -2312,7 +2323,7 @@ var OpenAICompatProvider = class {
|
|
|
2312
2323
|
} catch {
|
|
2313
2324
|
}
|
|
2314
2325
|
}
|
|
2315
|
-
const response = await this.client.chat.completions.create(baseParams);
|
|
2326
|
+
const response = await this.client.chat.completions.create(baseParams, reqOptions);
|
|
2316
2327
|
const parsed = parseResponse(response);
|
|
2317
2328
|
if (parsed.content) {
|
|
2318
2329
|
for (let i = 0; i < parsed.content.length; i += 3) {
|
|
@@ -3893,7 +3904,8 @@ program.argument("[task...]", "the software task to perform (omit to type it int
|
|
|
3893
3904
|
yes: options.yes === true,
|
|
3894
3905
|
maxIterations
|
|
3895
3906
|
}
|
|
3896
|
-
)
|
|
3907
|
+
),
|
|
3908
|
+
{ exitOnCtrlC: false }
|
|
3897
3909
|
);
|
|
3898
3910
|
await waitUntilExit();
|
|
3899
3911
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@menteeai/menteeswe",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
4
4
|
"description": "MenteE SWE — a model-agnostic autonomous software-engineering agent CLI. Bring your own intelligence: Kimi, GLM/Z.ai, and more.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|