opencode-auto-resume 1.0.17 → 1.0.19
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/index.js +37 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12489,7 +12489,8 @@ var AutoResumePlugin = async (ctx, options) => {
|
|
|
12489
12489
|
lastSubagentCheckAt: 0,
|
|
12490
12490
|
interruptedContinueCount: 0,
|
|
12491
12491
|
recentToolCalls: [],
|
|
12492
|
-
toolLoopAttempts: 0
|
|
12492
|
+
toolLoopAttempts: 0,
|
|
12493
|
+
isSubagent: false
|
|
12493
12494
|
};
|
|
12494
12495
|
sessions.set(sid, w);
|
|
12495
12496
|
}
|
|
@@ -12724,7 +12725,9 @@ var AutoResumePlugin = async (ctx, options) => {
|
|
|
12724
12725
|
w.gaveUp = false;
|
|
12725
12726
|
w.orphanWatchStartAt = null;
|
|
12726
12727
|
w.aborting = false;
|
|
12727
|
-
w.
|
|
12728
|
+
if (w.isSubagent) {
|
|
12729
|
+
w.toolTextRecovered = false;
|
|
12730
|
+
}
|
|
12728
12731
|
w.toolTextAttempts = 0;
|
|
12729
12732
|
w.continueTimestamps = [];
|
|
12730
12733
|
w.idleSince = null;
|
|
@@ -12875,6 +12878,22 @@ var AutoResumePlugin = async (ctx, options) => {
|
|
|
12875
12878
|
}
|
|
12876
12879
|
}
|
|
12877
12880
|
if (containsToolCallAsText(text)) {
|
|
12881
|
+
const toolMatch = text.match(/<function=([a-zA-Z_]+)/) || text.match(/<invoke\s+name=([a-zA-Z_]+)/) || text.match(/"name":\s*"([a-zA-Z_]+)/);
|
|
12882
|
+
if (toolMatch) {
|
|
12883
|
+
const toolName2 = toolMatch[1] || "unknown";
|
|
12884
|
+
const isLoop = trackToolCall(w, toolName2);
|
|
12885
|
+
if (isLoop && w.toolLoopAttempts < 2) {
|
|
12886
|
+
w.toolLoopAttempts++;
|
|
12887
|
+
const loopCandidate = {
|
|
12888
|
+
prompt: TOOL_LOOP_RECOVERY_PROMPT,
|
|
12889
|
+
source: "tool-text-loop",
|
|
12890
|
+
priority: 0
|
|
12891
|
+
};
|
|
12892
|
+
if (!bestCandidate || loopCandidate.priority < bestCandidate.priority) {
|
|
12893
|
+
bestCandidate = loopCandidate;
|
|
12894
|
+
}
|
|
12895
|
+
}
|
|
12896
|
+
}
|
|
12878
12897
|
const candidate = {
|
|
12879
12898
|
prompt: isReasoning ? THINKING_TOOL_RECOVERY_PROMPT : TOOL_TEXT_RECOVERY_PROMPT,
|
|
12880
12899
|
source: isReasoning ? "reasoning" : "text",
|
|
@@ -13182,11 +13201,20 @@ var AutoResumePlugin = async (ctx, options) => {
|
|
|
13182
13201
|
const lone = getLoneBusySession();
|
|
13183
13202
|
if (lone && lone.w.orphanWatchStartAt === null) {
|
|
13184
13203
|
lone.w.orphanWatchStartAt = Date.now();
|
|
13204
|
+
w.isSubagent = true;
|
|
13185
13205
|
log("info", `Subagent finished, parent ${short(lone.sid)} stuck. Orphan watch (${subagentWaitMs / 1000}s).`);
|
|
13186
13206
|
}
|
|
13187
13207
|
}
|
|
13188
13208
|
prevBusyCount = currentBusy;
|
|
13189
13209
|
log("debug", `${short(sid)} -> idle (${currentBusy})${statusType === "interrupted" ? " (interrupted)" : ""}`);
|
|
13210
|
+
if (!w.isSubagent) {
|
|
13211
|
+
const todos = w.todos || [];
|
|
13212
|
+
const hasOpenTodos = todos.some((t) => t.status === "pending" || t.status === "in_progress");
|
|
13213
|
+
if (hasOpenTodos && currentBusy === 1 && !w.toolTextRecovered) {
|
|
13214
|
+
await log("info", `${short(sid)} - idle with ${todos.filter((t) => t.status === "pending" || t.status === "in_progress").length} open todos. Sending continue...`);
|
|
13215
|
+
tryResume(sid, w, "Idle with open todos");
|
|
13216
|
+
}
|
|
13217
|
+
}
|
|
13190
13218
|
if (!w.toolTextRecovered && w.toolTextAttempts < maxRetries) {
|
|
13191
13219
|
if (w.toolTextTimer)
|
|
13192
13220
|
clearTimeout(w.toolTextTimer);
|
|
@@ -13315,12 +13343,14 @@ var AutoResumePlugin = async (ctx, options) => {
|
|
|
13315
13343
|
execute: async (_args, ctx2) => {
|
|
13316
13344
|
const w = sessions.get(ctx2.sessionID);
|
|
13317
13345
|
if (w) {
|
|
13318
|
-
w.
|
|
13319
|
-
|
|
13320
|
-
|
|
13321
|
-
|
|
13346
|
+
if (!w.isSubagent) {
|
|
13347
|
+
w.toolTextRecovered = true;
|
|
13348
|
+
if (w.toolTextTimer) {
|
|
13349
|
+
clearTimeout(w.toolTextTimer);
|
|
13350
|
+
w.toolTextTimer = null;
|
|
13351
|
+
}
|
|
13322
13352
|
}
|
|
13323
|
-
log("info", `${short(ctx2.sessionID)} - task_complete called, agent done`);
|
|
13353
|
+
log("info", `${short(ctx2.sessionID)} - task_complete called, ${w.isSubagent ? "subagent" : "agent"} done`);
|
|
13324
13354
|
}
|
|
13325
13355
|
return "Task completion acknowledged. No further continuation will be sent.";
|
|
13326
13356
|
}
|
package/package.json
CHANGED