micro-models-agent 0.43.0 → 0.43.1

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/main.js +51 -21
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -5697,12 +5697,17 @@ class ToolExecutor {
5697
5697
  toolCallId: call.id
5698
5698
  };
5699
5699
  }
5700
- for (const plugin of this.pluginManager.getAllPlugins()) {
5701
- if (plugin.onAfterTool) {
5702
- try {
5703
- await plugin.onAfterTool(this.ctx, call, result);
5704
- } catch (e) {
5705
- this.ctx.logger.warn(`Plugin onAfterTool error: ${e.message}`);
5700
+ if (signal?.aborted) {
5701
+ this.ctx.logger.debug(`Tool ${call.name}: abort, skipping onAfterTool plugins`);
5702
+ } else {
5703
+ const pluginCtx = signal ? { ...this.ctx, signal } : this.ctx;
5704
+ for (const plugin of this.pluginManager.getAllPlugins()) {
5705
+ if (plugin.onAfterTool) {
5706
+ try {
5707
+ await plugin.onAfterTool(pluginCtx, call, result);
5708
+ } catch (e) {
5709
+ this.ctx.logger.warn(`Plugin onAfterTool error: ${e.message}`);
5710
+ }
5706
5711
  }
5707
5712
  }
5708
5713
  }
@@ -11697,6 +11702,8 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
11697
11702
  slog.logToolCall(call, iteration);
11698
11703
  const tokensBeforeTool = contextManager.getEstimatedTokens();
11699
11704
  const result = await toolExecutor.execute(call, this.abortController?.signal);
11705
+ if (this.shutdownRequested)
11706
+ break;
11700
11707
  const duration = Date.now() - startTime;
11701
11708
  if (!result.success)
11702
11709
  anyToolFailed = true;
@@ -11775,6 +11782,8 @@ ${t("tool.truncated", { tokens: Math.ceil(removedChars / 2) })}`;
11775
11782
  }
11776
11783
  }
11777
11784
  }
11785
+ if (this.shutdownRequested)
11786
+ break;
11778
11787
  if (anyToolFailed) {
11779
11788
  consecutiveToolFailures++;
11780
11789
  } else {
@@ -16808,18 +16817,25 @@ class LintOnWritePlugin {
16808
16817
  const fullPath = resolve18(ctx.baseDir, path);
16809
16818
  if (!existsSync31(fullPath))
16810
16819
  return;
16820
+ const signal = ctx.signal;
16821
+ if (signal?.aborted)
16822
+ return;
16811
16823
  const ext = extname4(fullPath);
16812
- const syntaxError = await this.checkSyntax(fullPath, ext, ctx.baseDir);
16824
+ const syntaxError = await this.checkSyntax(fullPath, ext, ctx.baseDir, signal);
16825
+ if (signal?.aborted)
16826
+ return;
16813
16827
  if (syntaxError) {
16814
16828
  result.output += `
16815
16829
 
16816
16830
  [Syntax check failed]: ${syntaxError}`;
16817
16831
  return;
16818
16832
  }
16819
- await this.runProjectLint(ctx, result);
16820
- await this.runProjectTypeCheck(fullPath, ctx.baseDir, result);
16833
+ await this.runProjectLint(ctx, result, signal);
16834
+ if (signal?.aborted)
16835
+ return;
16836
+ await this.runProjectTypeCheck(fullPath, ctx.baseDir, result, signal);
16821
16837
  }
16822
- async checkSyntax(filePath, ext, baseDir) {
16838
+ async checkSyntax(filePath, ext, baseDir, signal) {
16823
16839
  if (ext === ".ts" || ext === ".tsx" || ext === ".cts" || ext === ".mts") {
16824
16840
  let content = "";
16825
16841
  try {
@@ -16833,7 +16849,9 @@ class LintOnWritePlugin {
16833
16849
  return cached.error;
16834
16850
  }
16835
16851
  try {
16836
- await runAsync(`bun build --no-bundle --target=bun "${filePath}"`, baseDir, 1e4);
16852
+ await runAsync(`bun build --no-bundle --target=bun "${filePath}"`, baseDir, 1e4, signal);
16853
+ if (signal?.aborted)
16854
+ return null;
16837
16855
  syntaxCache.set(filePath, { hash, error: null });
16838
16856
  return null;
16839
16857
  } catch (err) {
@@ -16849,7 +16867,7 @@ class LintOnWritePlugin {
16849
16867
  }
16850
16868
  if (ext === ".js" || ext === ".jsx" || ext === ".cjs" || ext === ".mjs") {
16851
16869
  try {
16852
- await runAsync(`node --check "${filePath}"`, baseDir, 5000);
16870
+ await runAsync(`node --check "${filePath}"`, baseDir, 5000, signal);
16853
16871
  return null;
16854
16872
  } catch (err) {
16855
16873
  const stderr = err.stderr?.toString() || "";
@@ -16860,7 +16878,7 @@ class LintOnWritePlugin {
16860
16878
  }
16861
16879
  return null;
16862
16880
  }
16863
- async runProjectLint(ctx, result) {
16881
+ async runProjectLint(ctx, result, signal) {
16864
16882
  try {
16865
16883
  const packageJsonPath = join25(ctx.baseDir, "package.json");
16866
16884
  if (!existsSync31(packageJsonPath)) {
@@ -16872,7 +16890,7 @@ class LintOnWritePlugin {
16872
16890
  return;
16873
16891
  }
16874
16892
  ctx.logger.debug(`Running lint: ${lintScript}`);
16875
- await runAsync(lintScript, ctx.baseDir, 30000);
16893
+ await runAsync(lintScript, ctx.baseDir, 30000, signal);
16876
16894
  ctx.logger.debug("Lint passed");
16877
16895
  } catch (err) {
16878
16896
  const stderr = (err.stderr?.toString?.() || "").trim();
@@ -16886,7 +16904,7 @@ class LintOnWritePlugin {
16886
16904
  [Project lint failed]: ${detail}`;
16887
16905
  }
16888
16906
  }
16889
- async runProjectTypeCheck(filePath, baseDir, result) {
16907
+ async runProjectTypeCheck(filePath, baseDir, result, signal) {
16890
16908
  const projectRoot = findProjectRoot(filePath, baseDir, ["tsconfig.json", "package.json"]);
16891
16909
  const tsconfigPath = join25(projectRoot, "tsconfig.json");
16892
16910
  if (!existsSync31(tsconfigPath)) {
@@ -16903,7 +16921,7 @@ class LintOnWritePlugin {
16903
16921
  return;
16904
16922
  }
16905
16923
  this._checkTimestamp = now;
16906
- this._checkPromise = this.runTscCheck(projectRoot);
16924
+ this._checkPromise = this.runTscCheck(projectRoot, signal);
16907
16925
  const error = await this._checkPromise;
16908
16926
  if (error) {
16909
16927
  result.output += `
@@ -16911,9 +16929,9 @@ class LintOnWritePlugin {
16911
16929
  [Project typecheck failed]: ${error}`;
16912
16930
  }
16913
16931
  }
16914
- async runTscCheck(baseDir) {
16932
+ async runTscCheck(baseDir, signal) {
16915
16933
  try {
16916
- await runAsync(`npx tsc --noEmit --skipLibCheck`, baseDir, 30000);
16934
+ await runAsync(`npx tsc --noEmit --skipLibCheck`, baseDir, 30000, signal);
16917
16935
  return null;
16918
16936
  } catch (err) {
16919
16937
  if (err.status === 127 || err.message.includes("not found") || err.message.includes("ENOENT")) {
@@ -16929,7 +16947,7 @@ class LintOnWritePlugin {
16929
16947
  }
16930
16948
  }
16931
16949
  }
16932
- function runAsync(command, cwd, timeoutMs) {
16950
+ function runAsync(command, cwd, timeoutMs, signal) {
16933
16951
  return new Promise((resolve19, reject) => {
16934
16952
  const child = spawn5(command, {
16935
16953
  cwd,
@@ -16950,15 +16968,27 @@ function runAsync(command, cwd, timeoutMs) {
16950
16968
  child.kill();
16951
16969
  reject(new Error(`Command timed out after ${timeoutMs}ms`));
16952
16970
  }, timeoutMs);
16971
+ const onAbort = () => child.kill();
16972
+ if (signal?.aborted) {
16973
+ child.kill();
16974
+ } else {
16975
+ signal?.addEventListener("abort", onAbort, { once: true });
16976
+ }
16953
16977
  child.on("error", (err) => {
16954
16978
  clearTimeout(timer);
16955
- reject(err);
16979
+ signal?.removeEventListener("abort", onAbort);
16980
+ if (signal?.aborted) {
16981
+ resolve19({ stdout, stderr });
16982
+ } else {
16983
+ reject(err);
16984
+ }
16956
16985
  });
16957
16986
  child.on("close", (code) => {
16958
16987
  clearTimeout(timer);
16988
+ signal?.removeEventListener("abort", onAbort);
16959
16989
  stdout += decoder.decode();
16960
16990
  stderr += decoder.decode();
16961
- if (code === 0) {
16991
+ if (signal?.aborted || code === 0) {
16962
16992
  resolve19({ stdout, stderr });
16963
16993
  } else {
16964
16994
  const err = new Error(`Command failed with exit code ${code}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "micro-models-agent",
3
- "version": "0.43.0",
3
+ "version": "0.43.1",
4
4
  "description": "Micro Models Agent (MMA) — LLM agent harness for small models (Qwen3.5-9B, 32K-64K context)",
5
5
  "type": "module",
6
6
  "bin": {