@menteeai/menteeswe 0.1.20 → 0.1.22

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.
Files changed (2) hide show
  1. package/dist/cli.js +41 -19
  2. 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.20";
1309
+ version = "0.1.22";
1303
1310
  }
1304
1311
  });
1305
1312
 
@@ -1633,10 +1640,10 @@ var App_exports = {};
1633
1640
  __export(App_exports, {
1634
1641
  App: () => App
1635
1642
  });
1636
- import { useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState3 } from "react";
1643
+ import { memo, useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState3 } from "react";
1637
1644
  import { Box as Box6, Static, Text as Text6, useApp, useInput as useInput4, useStdout } from "ink";
1638
1645
  import TextInput2 from "ink-text-input";
1639
- import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1646
+ import { Fragment, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1640
1647
  function App(props) {
1641
1648
  const { exit } = useApp();
1642
1649
  const { stdout } = useStdout();
@@ -1749,7 +1756,7 @@ function App(props) {
1749
1756
  unsubscribeLog();
1750
1757
  unsubscribeLog2();
1751
1758
  };
1752
- }, [bus, bridge, showDetails]);
1759
+ }, [bus, bridge]);
1753
1760
  useEffect2(() => {
1754
1761
  if (!running) return;
1755
1762
  const timer = setInterval(() => setFrame((f) => (f + 1) % SPINNER_FRAMES.length), 80);
@@ -2021,9 +2028,7 @@ function App(props) {
2021
2028
  return /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", children: [
2022
2029
  /* @__PURE__ */ jsx6(Static, { items: [{ key: "header", text: header }], children: (item) => /* @__PURE__ */ jsx6(Box6, { children: item.text }, item.key) }),
2023
2030
  /* @__PURE__ */ jsxs6(Box6, { flexDirection: "column", children: [
2024
- log.filter((l) => (showDetails || !l.noise) && (l.kind !== "patch" || showEdits)).map(
2025
- (line) => line.kind === "answer" ? /* @__PURE__ */ jsx6(AnswerBlock, { text: line.text }, line.id) : line.kind === "patch" && line.edit ? /* @__PURE__ */ jsx6(CurrentEditBox, { edit: line.edit }, line.id) : /* @__PURE__ */ jsx6(Text6, { children: line.text }, line.id)
2026
- ),
2031
+ /* @__PURE__ */ jsx6(LogList, { log, showDetails, showEdits }),
2027
2032
  finalPending !== null ? /* @__PURE__ */ jsx6(Box6, { marginTop: 1, flexDirection: "column", borderStyle: "round", borderColor: "green", paddingX: 1, children: /* @__PURE__ */ jsxs6(Text6, { color: "green", children: [
2028
2033
  typedText,
2029
2034
  typing ? "\u258C" : ""
@@ -2132,7 +2137,7 @@ function App(props) {
2132
2137
  ] })
2133
2138
  ] });
2134
2139
  }
2135
- var SPINNER_FRAMES, PHASE_LABEL, PROVIDER_NAMES, PROVIDER_DESCRIPTIONS, BANNER;
2140
+ var SPINNER_FRAMES, PHASE_LABEL, PROVIDER_NAMES, PROVIDER_DESCRIPTIONS, BANNER, MAX_RENDERED_LOG_LINES, LogList;
2136
2141
  var init_App = __esm({
2137
2142
  "src/tui/App.tsx"() {
2138
2143
  "use strict";
@@ -2177,6 +2182,18 @@ var init_App = __esm({
2177
2182
  | |
2178
2183
  MenteE SWE \u2014 https://menteeai.org
2179
2184
  Twitter: x.com/menteeaiorg`;
2185
+ MAX_RENDERED_LOG_LINES = 400;
2186
+ LogList = memo(function LogList2({
2187
+ log,
2188
+ showDetails,
2189
+ showEdits
2190
+ }) {
2191
+ const visible = log.filter((l) => (showDetails || !l.noise) && (l.kind !== "patch" || showEdits));
2192
+ const windowed = visible.length > MAX_RENDERED_LOG_LINES ? visible.slice(-MAX_RENDERED_LOG_LINES) : visible;
2193
+ return /* @__PURE__ */ jsx6(Fragment, { children: windowed.map(
2194
+ (line) => line.kind === "answer" ? /* @__PURE__ */ jsx6(AnswerBlock, { text: line.text }, line.id) : line.kind === "patch" && line.edit ? /* @__PURE__ */ jsx6(CurrentEditBox, { edit: line.edit }, line.id) : /* @__PURE__ */ jsx6(Text6, { children: line.text }, line.id)
2195
+ ) });
2196
+ });
2180
2197
  }
2181
2198
  });
2182
2199
 
@@ -2252,16 +2269,20 @@ var OpenAICompatProvider = class {
2252
2269
  ...request.temperature !== void 0 ? { temperature: request.temperature } : {},
2253
2270
  ...request.maxTokens ? { max_tokens: request.maxTokens } : {}
2254
2271
  };
2272
+ const reqOptions = request.signal ? { signal: request.signal } : void 0;
2255
2273
  if (!request.onToken) {
2256
- const response2 = await this.client.chat.completions.create(baseParams);
2274
+ const response2 = await this.client.chat.completions.create(baseParams, reqOptions);
2257
2275
  return parseResponse(response2);
2258
2276
  }
2259
2277
  const streamOnce = async (withUsage) => {
2260
- const stream = await this.client.chat.completions.create({
2261
- ...baseParams,
2262
- stream: true,
2263
- ...withUsage ? { stream_options: { include_usage: true } } : {}
2264
- });
2278
+ const stream = await this.client.chat.completions.create(
2279
+ {
2280
+ ...baseParams,
2281
+ stream: true,
2282
+ ...withUsage ? { stream_options: { include_usage: true } } : {}
2283
+ },
2284
+ reqOptions
2285
+ );
2265
2286
  let content = "";
2266
2287
  let finishReason = "stop";
2267
2288
  let usage;
@@ -2312,7 +2333,7 @@ var OpenAICompatProvider = class {
2312
2333
  } catch {
2313
2334
  }
2314
2335
  }
2315
- const response = await this.client.chat.completions.create(baseParams);
2336
+ const response = await this.client.chat.completions.create(baseParams, reqOptions);
2316
2337
  const parsed = parseResponse(response);
2317
2338
  if (parsed.content) {
2318
2339
  for (let i = 0; i < parsed.content.length; i += 3) {
@@ -3893,7 +3914,8 @@ program.argument("[task...]", "the software task to perform (omit to type it int
3893
3914
  yes: options.yes === true,
3894
3915
  maxIterations
3895
3916
  }
3896
- )
3917
+ ),
3918
+ { exitOnCtrlC: false }
3897
3919
  );
3898
3920
  await waitUntilExit();
3899
3921
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@menteeai/menteeswe",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
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",