opencode-immune 1.0.51 → 1.0.52
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/plugin.js +26 -4
- 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.
|
|
14
|
+
const PLUGIN_VERSION = "1.0.52";
|
|
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",
|
|
@@ -154,7 +155,7 @@ async function createManagedUltraworkSession(state, title) {
|
|
|
154
155
|
return sessionID;
|
|
155
156
|
}
|
|
156
157
|
async function promptManagedSession(state, sessionID, text, options = {}) {
|
|
157
|
-
await state.client.session.promptAsync({
|
|
158
|
+
const result = await state.client.session.promptAsync({
|
|
158
159
|
directory: state.input.directory,
|
|
159
160
|
sessionID,
|
|
160
161
|
...(options.model ? { model: options.model } : {}),
|
|
@@ -166,6 +167,9 @@ async function promptManagedSession(state, sessionID, text, options = {}) {
|
|
|
166
167
|
},
|
|
167
168
|
],
|
|
168
169
|
});
|
|
170
|
+
if (result.error || !result.response.ok) {
|
|
171
|
+
throw new Error(`prompt_async failed with status ${result.response.status}: ${JSON.stringify(result.error ?? null)}`);
|
|
172
|
+
}
|
|
169
173
|
}
|
|
170
174
|
async function abortManagedSession(state, sessionID) {
|
|
171
175
|
await state.client.session.abort({
|
|
@@ -673,12 +677,30 @@ function scheduleManagedSessionRetry(state, sessionID, options) {
|
|
|
673
677
|
abortBeforePrompt: options.abortBeforePrompt,
|
|
674
678
|
});
|
|
675
679
|
}
|
|
676
|
-
catch {
|
|
680
|
+
catch (err) {
|
|
677
681
|
if (options.countAgainstBudget) {
|
|
678
682
|
state.sessionErrorRetryCount.set(sessionID, Math.max((state.sessionErrorRetryCount.get(sessionID) ?? 1) - 1, 0));
|
|
679
683
|
}
|
|
684
|
+
const deliveryAttempt = options.deliveryAttempt ?? 1;
|
|
685
|
+
await writeDiagnosticLog(state, "session-retry:prompt-delivery-failed", {
|
|
686
|
+
sessionID,
|
|
687
|
+
reason: options.reason,
|
|
688
|
+
deliveryAttempt,
|
|
689
|
+
error: err instanceof Error ? err.message : String(err),
|
|
690
|
+
});
|
|
680
691
|
writePluginLog(state, "warn", `[opencode-immune] Retry prompt failed for session ${sessionID}. ` +
|
|
681
|
-
|
|
692
|
+
(deliveryAttempt < RETRY_PROMPT_DELIVERY_ATTEMPTS
|
|
693
|
+
? `Retrying delivery attempt ${deliveryAttempt + 1}/${RETRY_PROMPT_DELIVERY_ATTEMPTS}.`
|
|
694
|
+
: `Delivery attempts exhausted; will wait for the next retry signal.`));
|
|
695
|
+
if (deliveryAttempt < RETRY_PROMPT_DELIVERY_ATTEMPTS) {
|
|
696
|
+
scheduleManagedSessionRetry(state, sessionID, {
|
|
697
|
+
...options,
|
|
698
|
+
delayMs: Math.min(options.delayMs * 2, 15_000),
|
|
699
|
+
countAgainstBudget: false,
|
|
700
|
+
abortBeforePrompt: false,
|
|
701
|
+
deliveryAttempt: deliveryAttempt + 1,
|
|
702
|
+
});
|
|
703
|
+
}
|
|
682
704
|
}
|
|
683
705
|
}, options.delayMs);
|
|
684
706
|
state.sessionRetryTimers.set(sessionID, timer);
|