opencode-auto-resume 1.0.12 → 1.0.14

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 +13 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12512,7 +12512,11 @@ var AutoResumePlugin = async (ctx, options) => {
12512
12512
  }
12513
12513
  function getSid(ev) {
12514
12514
  const props = ev.properties;
12515
- return ev.sessionID ?? props?.sessionID ?? props?.part?.sessionID ?? props?.info?.sessionID;
12515
+ const sid = ev.sessionID ?? props?.sessionID ?? props?.part?.sessionID ?? props?.info?.sessionID;
12516
+ if (sid && typeof sid === "string" && sid.startsWith("ses_")) {
12517
+ return sid;
12518
+ }
12519
+ return;
12516
12520
  }
12517
12521
  function getError(ev) {
12518
12522
  const props = ev.properties;
@@ -12792,10 +12796,10 @@ var AutoResumePlugin = async (ctx, options) => {
12792
12796
  if (!hasOpenTodos && todos.length > 0) {
12793
12797
  w.todoCheckAttempts++;
12794
12798
  if (w.todoCheckAttempts >= 2) {
12795
- await log("info", `${short(sid)} - todos completed but agent hasn't closed them. Sending reminder...`);
12799
+ await log("info", `${short(sid)} - todos completed but agent hasn't closed them. Sending continue...`);
12796
12800
  const candidate2 = {
12797
- prompt: "Please close all completed todos and finish your message.",
12798
- source: "todo-reminder",
12801
+ prompt: "continue",
12802
+ source: "todo-completed-continue",
12799
12803
  priority: 1
12800
12804
  };
12801
12805
  if (!bestCandidate || candidate2.priority < bestCandidate.priority) {
@@ -12858,15 +12862,17 @@ var AutoResumePlugin = async (ctx, options) => {
12858
12862
  }
12859
12863
  }
12860
12864
  async function tryAbortAndResume(sid, w) {
12861
- if (typeof sid !== "string" || !sid)
12865
+ if (typeof sid !== "string" || !sid || !sid.startsWith("ses_")) {
12866
+ await log("warn", `Invalid sid for abort: ${sid} (must start with "ses_")`);
12862
12867
  return false;
12868
+ }
12863
12869
  if (w.aborting)
12864
12870
  return false;
12865
12871
  w.aborting = true;
12866
12872
  const idleSec = Math.round((Date.now() - (w.orphanWatchStartAt ?? w.lastActivityAt)) / 1000);
12867
12873
  await log("info", `Abort+Resume on ${short(sid)} (${idleSec}s idle). Aborting...`);
12868
12874
  try {
12869
- await ctx.client.session.abort({ sessionID: sid });
12875
+ await ctx.client.session.abort({ path: { id: sid } });
12870
12876
  await log("info", `${short(sid)} - abort OK`);
12871
12877
  } catch (err) {
12872
12878
  const errMsg = err instanceof Error ? err.message : String(err);
@@ -12925,7 +12931,7 @@ var AutoResumePlugin = async (ctx, options) => {
12925
12931
  const list = extractMessages(response);
12926
12932
  for (const s of list) {
12927
12933
  const sid = s.id;
12928
- if (sid) {
12934
+ if (sid && typeof sid === "string" && sid.startsWith("ses_")) {
12929
12935
  const isNew = !sessions.has(sid);
12930
12936
  ensureWatch(sid);
12931
12937
  const status = s.status;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-auto-resume",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "OpenCode plugin that automatically resumes stalled LLM sessions when thinking/streaming freezes mid-generation.",
5
5
  "keywords": [
6
6
  "opencode",