opencode-auto-resume 1.0.21 → 1.0.23

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 +39 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10745,7 +10745,7 @@ class JSONSchemaGenerator {
10745
10745
  if (val === undefined) {
10746
10746
  if (this.unrepresentable === "throw") {
10747
10747
  throw new Error("Literal `undefined` cannot be represented in JSON Schema");
10748
- } else {}
10748
+ }
10749
10749
  } else if (typeof val === "bigint") {
10750
10750
  if (this.unrepresentable === "throw") {
10751
10751
  throw new Error("BigInt literals cannot be represented in JSON Schema");
@@ -13036,6 +13036,11 @@ var AutoResumePlugin = async (ctx, options) => {
13036
13036
  return;
13037
13037
  }
13038
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
+ }
13039
13044
  await log("warn", `Hallucination loop detected on ${short(sid)} \u2014 aborting instead`);
13040
13045
  await tryAbortAndResume(sid, w);
13041
13046
  } else {
@@ -13101,6 +13106,12 @@ var AutoResumePlugin = async (ctx, options) => {
13101
13106
  if (w.lastRetryAt > 0 && elapsedSinceRetry < requiredBackoff)
13102
13107
  return false;
13103
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
+ }
13104
13115
  await log("warn", `Hallucination loop on ${short(sid)}! Aborting...`);
13105
13116
  return await tryAbortAndResume(sid, w);
13106
13117
  }
@@ -13151,6 +13162,17 @@ var AutoResumePlugin = async (ctx, options) => {
13151
13162
  const now = Date.now();
13152
13163
  const numBusy = busyCount();
13153
13164
  for (const [sid, w] of sessions) {
13165
+ try {
13166
+ const listResponse = await ctx.client.session.list();
13167
+ const allSessions = extractMessages(listResponse);
13168
+ const realSession2 = allSessions.find((s) => s.id === sid);
13169
+ const realStatus = realSession2?.status;
13170
+ if (realStatus && realStatus !== w.status) {
13171
+ w.status = realStatus;
13172
+ if (realStatus === "busy")
13173
+ w.idleSince = null;
13174
+ }
13175
+ } catch {}
13154
13176
  if (w.status !== "busy")
13155
13177
  continue;
13156
13178
  if (w.userCancelled)
@@ -13196,9 +13218,19 @@ var AutoResumePlugin = async (ctx, options) => {
13196
13218
  continue;
13197
13219
  w.lastSubagentCheckAt = now;
13198
13220
  if (w.lastActivityAt > 0 && now - w.lastActivityAt > subagentWaitMs) {
13221
+ try {
13222
+ const listResponse = await ctx.client.session.list();
13223
+ const allSessions = extractMessages(listResponse);
13224
+ const realStatus = realSession?.status;
13225
+ if (realStatus === "busy") {
13226
+ await log("debug", `Session ${short(sid)} is still busy (real status), skipping abort`);
13227
+ w.lastSubagentCheckAt = now;
13228
+ continue;
13229
+ }
13230
+ } catch {}
13199
13231
  const hasActiveTool = await checkSessionHasActiveTool(sid);
13200
13232
  if (hasActiveTool) {
13201
- await log("debug", `Parent ${short(sid)} has active tool call, skipping abort check`);
13233
+ await log("debug", `Session ${short(sid)} has active tool call, skipping abort check`);
13202
13234
  w.lastSubagentCheckAt = now;
13203
13235
  continue;
13204
13236
  }
@@ -13220,7 +13252,11 @@ var AutoResumePlugin = async (ctx, options) => {
13220
13252
  }
13221
13253
  const idle = now - w.lastActivityAt;
13222
13254
  if (idle >= chunkTimeoutMs + gracePeriodMs) {
13223
- if (w.resumeAttempts < maxRetries) {
13255
+ const hasActiveTool = await checkSessionHasActiveTool(sid);
13256
+ if (hasActiveTool) {
13257
+ await log("debug", `Session ${short(sid)} has active tool call, skipping stall recovery`);
13258
+ w.lastSubagentCheckAt = now;
13259
+ } else if (w.resumeAttempts < maxRetries) {
13224
13260
  tryResume(sid, w, "Stream stall");
13225
13261
  } else if (!w.gaveUp) {
13226
13262
  w.gaveUp = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-auto-resume",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "OpenCode plugin that automatically resumes stalled LLM sessions when thinking/streaming freezes mid-generation.",
5
5
  "keywords": [
6
6
  "opencode",