@azumag/opencode-rate-limit-fallback 1.0.11 → 1.0.12

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 +12 -20
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -306,29 +306,21 @@ export const RateLimitFallback = async ({ client, directory }) => {
306
306
  parts: parts,
307
307
  model: { providerID: nextModel.providerID, modelID: nextModel.modelID },
308
308
  };
309
- // Try promptAsync first (no abort needed works in both TUI and run modes)
309
+ // Abort first to cancel the retry loop, then promptAsync immediately
310
+ // The abort→promptAsync gap is minimal, so even in headless mode
311
+ // the server won't shut down before promptAsync fires
310
312
  try {
311
- await client.session.promptAsync({
312
- path: { id: sessionID },
313
- body: promptBody,
314
- });
315
- logToFile(`promptAsync sent successfully for session ${sessionID} with model ${nextModel.providerID}/${nextModel.modelID}`);
313
+ await client.session.abort({ path: { id: sessionID } });
314
+ logToFile(`abort succeeded for session ${sessionID}`);
316
315
  }
317
- catch (promptAsyncErr) {
318
- // promptAsync failed fall back to abort + promptAsync
319
- logToFile(`promptAsync failed (${promptAsyncErr}), falling back to abort + promptAsync`);
320
- try {
321
- await client.session.abort({ path: { id: sessionID } });
322
- }
323
- catch (abortErr) {
324
- logToFile(`abort also failed: ${abortErr}`);
325
- }
326
- await client.session.promptAsync({
327
- path: { id: sessionID },
328
- body: promptBody,
329
- });
330
- logToFile(`abort + promptAsync sent successfully for session ${sessionID}`);
316
+ catch (abortErr) {
317
+ logToFile(`abort failed (non-critical): ${abortErr}`);
331
318
  }
319
+ await client.session.promptAsync({
320
+ path: { id: sessionID },
321
+ body: promptBody,
322
+ });
323
+ logToFile(`promptAsync sent successfully for session ${sessionID} with model ${nextModel.providerID}/${nextModel.modelID}`);
332
324
  toast("Fallback Successful", `Now using ${nextModel.modelID}`, "success").catch(() => { });
333
325
  retryState.delete(stateKey);
334
326
  // Clear fallback flag to allow next fallback if needed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azumag/opencode-rate-limit-fallback",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "OpenCode plugin that automatically switches to fallback models when rate limited",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",