opencode-auto-resume 1.0.20 → 1.0.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/index.js +24 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12700,6 +12700,14 @@ var AutoResumePlugin = async (ctx, options) => {
12700
12700
  }
12701
12701
  async function checkSessionHasActiveTool(sid) {
12702
12702
  try {
12703
+ const listResponse = await ctx.client.session.list();
12704
+ const sessions2 = extractMessages(listResponse);
12705
+ const currentSession = sessions2.find((s) => s.id === sid);
12706
+ const status = currentSession?.status;
12707
+ if (status === "busy") {
12708
+ await log("debug", `Session ${short(sid)} is busy, likely executing a tool`);
12709
+ return true;
12710
+ }
12703
12711
  const response = await ctx.client.session.messages({ path: { id: sid } });
12704
12712
  const messages = extractMessages(response);
12705
12713
  const lastMsg = messages[messages.length - 1];
@@ -13028,6 +13036,11 @@ var AutoResumePlugin = async (ctx, options) => {
13028
13036
  return;
13029
13037
  }
13030
13038
  if (isHallucinationLoop(sid)) {
13039
+ const hasActiveTool = await checkSessionHasActiveTool(sid);
13040
+ if (hasActiveTool) {
13041
+ await log("debug", `Session ${short(sid)} has active tool, skipping hallucination abort`);
13042
+ return;
13043
+ }
13031
13044
  await log("warn", `Hallucination loop detected on ${short(sid)} \u2014 aborting instead`);
13032
13045
  await tryAbortAndResume(sid, w);
13033
13046
  } else {
@@ -13093,6 +13106,12 @@ var AutoResumePlugin = async (ctx, options) => {
13093
13106
  if (w.lastRetryAt > 0 && elapsedSinceRetry < requiredBackoff)
13094
13107
  return false;
13095
13108
  if (isHallucinationLoop(sid)) {
13109
+ const hasActiveTool = await checkSessionHasActiveTool(sid);
13110
+ if (hasActiveTool) {
13111
+ await log("debug", `Session ${short(sid)} has active tool, skipping hallucination abort`);
13112
+ w.lastRetryAt = now;
13113
+ return false;
13114
+ }
13096
13115
  await log("warn", `Hallucination loop on ${short(sid)}! Aborting...`);
13097
13116
  return await tryAbortAndResume(sid, w);
13098
13117
  }
@@ -13212,7 +13231,11 @@ var AutoResumePlugin = async (ctx, options) => {
13212
13231
  }
13213
13232
  const idle = now - w.lastActivityAt;
13214
13233
  if (idle >= chunkTimeoutMs + gracePeriodMs) {
13215
- if (w.resumeAttempts < maxRetries) {
13234
+ const hasActiveTool = await checkSessionHasActiveTool(sid);
13235
+ if (hasActiveTool) {
13236
+ await log("debug", `Session ${short(sid)} has active tool call, skipping stall recovery`);
13237
+ w.lastSubagentCheckAt = now;
13238
+ } else if (w.resumeAttempts < maxRetries) {
13216
13239
  tryResume(sid, w, "Stream stall");
13217
13240
  } else if (!w.gaveUp) {
13218
13241
  w.gaveUp = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-auto-resume",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "OpenCode plugin that automatically resumes stalled LLM sessions when thinking/streaming freezes mid-generation.",
5
5
  "keywords": [
6
6
  "opencode",