@azumag/opencode-rate-limit-fallback 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.
Files changed (2) hide show
  1. package/dist/index.js +6 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -316,25 +316,21 @@ export const RateLimitFallback = async ({ client, directory }) => {
316
316
  parts: parts,
317
317
  model: { providerID: nextModel.providerID, modelID: nextModel.modelID },
318
318
  };
319
- // CRITICAL PATH: abort → promptAsync with NO delay between them.
319
+ // abort → promptAsync: works in TUI, fails in headless (server disposes)
320
+ // promptAsync → abort: fails in TUI (abort kills the new prompt too)
320
321
  //
321
- // In headless mode (opencode run), the server disposes shortly after
322
- // session goes idle. Any delay (setTimeout, awaited toast, etc.) risks
323
- // promptAsync arriving after the server is dead.
322
+ // Use abort promptAsync as the primary path (TUI confirmed working).
323
+ // Headless mode (opencode run) is a known limitation the server
324
+ // dispose sequence interrupts the new prompt before it can complete.
324
325
  //
325
326
  // promptAsync: HTTP POST /session/{id}/prompt_async → 204 (SDK sdk.gen.js).
326
- // prompt (sync): blocks until generation completes → abort flag race in TUI,
327
- // server dispose in headless. Do NOT use.
328
327
  const t0 = Date.now();
329
328
  try {
330
329
  await client.session.abort({ path: { id: sessionID } });
331
330
  logToFile(`abort succeeded for session ${sessionID} (${Date.now() - t0}ms)`);
332
331
  }
333
332
  catch (abortErr) {
334
- // If abort fails, the session may still be in its retry loop.
335
- // We still send promptAsync as best-effort: when the retry loop eventually
336
- // completes (timeout or success), the queued prompt should be processed.
337
- logToFile(`abort failed (${Date.now() - t0}ms): ${abortErr} — sending promptAsync as best-effort`);
333
+ logToFile(`abort failed (${Date.now() - t0}ms): ${abortErr}`);
338
334
  }
339
335
  const t1 = Date.now();
340
336
  await client.session.promptAsync({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azumag/opencode-rate-limit-fallback",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "OpenCode plugin that automatically switches to fallback models when rate limited",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",