opencode-immune 1.0.51 → 1.0.53

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/plugin.js +29 -4
  2. package/package.json +1 -1
package/dist/plugin.js CHANGED
@@ -11,7 +11,7 @@ import { execFile } from "child_process";
11
11
  // ═══════════════════════════════════════════════════════════════════════════════
12
12
  // PLUGIN VERSION CHECK
13
13
  // ═══════════════════════════════════════════════════════════════════════════════
14
- const PLUGIN_VERSION = "1.0.51";
14
+ const PLUGIN_VERSION = "1.0.53";
15
15
  const PLUGIN_PACKAGE_NAME = "opencode-immune";
16
16
  const PLUGIN_DIRNAME = dirname(fileURLToPath(import.meta.url));
17
17
  /**
@@ -122,6 +122,7 @@ const DIAGNOSTIC_LOG_MAX_BYTES = 5 * 1024 * 1024;
122
122
  let activeLogDirectory = null;
123
123
  const MANAGED_SESSION_TTL_MS = 7 * 24 * 60 * 60 * 1000;
124
124
  const PROVIDER_RETRY_WATCHDOG_MS = 30_000;
125
+ const RETRY_PROMPT_DELIVERY_ATTEMPTS = 3;
125
126
  const CHILD_FALLBACK_REQUEST_TTL_MS = 10 * 60 * 1000;
126
127
  const RATE_LIMIT_FALLBACK_MODEL = {
127
128
  providerID: "codexsale",
@@ -147,6 +148,9 @@ async function createManagedUltraworkSession(state, title) {
147
148
  title,
148
149
  permission: ULTRAWORK_SESSION_PERMISSION,
149
150
  });
151
+ if (result.error || !result.response.ok) {
152
+ throw new Error(`session.create failed with status ${result.response.status}: ${JSON.stringify(result.error ?? null)}`);
153
+ }
150
154
  const sessionID = result?.data?.id;
151
155
  if (!sessionID)
152
156
  return null;
@@ -154,7 +158,7 @@ async function createManagedUltraworkSession(state, title) {
154
158
  return sessionID;
155
159
  }
156
160
  async function promptManagedSession(state, sessionID, text, options = {}) {
157
- await state.client.session.promptAsync({
161
+ const result = await state.client.session.promptAsync({
158
162
  directory: state.input.directory,
159
163
  sessionID,
160
164
  ...(options.model ? { model: options.model } : {}),
@@ -166,6 +170,9 @@ async function promptManagedSession(state, sessionID, text, options = {}) {
166
170
  },
167
171
  ],
168
172
  });
173
+ if (result.error || !result.response.ok) {
174
+ throw new Error(`prompt_async failed with status ${result.response.status}: ${JSON.stringify(result.error ?? null)}`);
175
+ }
169
176
  }
170
177
  async function abortManagedSession(state, sessionID) {
171
178
  await state.client.session.abort({
@@ -673,12 +680,30 @@ function scheduleManagedSessionRetry(state, sessionID, options) {
673
680
  abortBeforePrompt: options.abortBeforePrompt,
674
681
  });
675
682
  }
676
- catch {
683
+ catch (err) {
677
684
  if (options.countAgainstBudget) {
678
685
  state.sessionErrorRetryCount.set(sessionID, Math.max((state.sessionErrorRetryCount.get(sessionID) ?? 1) - 1, 0));
679
686
  }
687
+ const deliveryAttempt = options.deliveryAttempt ?? 1;
688
+ await writeDiagnosticLog(state, "session-retry:prompt-delivery-failed", {
689
+ sessionID,
690
+ reason: options.reason,
691
+ deliveryAttempt,
692
+ error: err instanceof Error ? err.message : String(err),
693
+ });
680
694
  writePluginLog(state, "warn", `[opencode-immune] Retry prompt failed for session ${sessionID}. ` +
681
- `Will wait for the next retry signal.`);
695
+ (deliveryAttempt < RETRY_PROMPT_DELIVERY_ATTEMPTS
696
+ ? `Retrying delivery attempt ${deliveryAttempt + 1}/${RETRY_PROMPT_DELIVERY_ATTEMPTS}.`
697
+ : `Delivery attempts exhausted; will wait for the next retry signal.`));
698
+ if (deliveryAttempt < RETRY_PROMPT_DELIVERY_ATTEMPTS) {
699
+ scheduleManagedSessionRetry(state, sessionID, {
700
+ ...options,
701
+ delayMs: Math.min(options.delayMs * 2, 15_000),
702
+ countAgainstBudget: false,
703
+ abortBeforePrompt: false,
704
+ deliveryAttempt: deliveryAttempt + 1,
705
+ });
706
+ }
682
707
  }
683
708
  }, options.delayMs);
684
709
  state.sessionRetryTimers.set(sessionID, timer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-immune",
3
- "version": "1.0.51",
3
+ "version": "1.0.53",
4
4
  "type": "module",
5
5
  "description": "OpenCode plugin: session recovery, auto-retry, multi-cycle automation, context monitoring",
6
6
  "exports": {