@yugimob/pi-opencode-go-rotation 1.6.1 → 1.6.2

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 +8 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -922,16 +922,13 @@ export function createOpencodeGoRotationExtension(options = {}) {
922
922
  const candidates = getQuotaBlockedTargets(config, currentTime, skipKeyIndex)
923
923
  .map((target) => captureSelectionSnapshot(config, currentTime, target.keyIndex))
924
924
  .filter((snapshot) => snapshot !== undefined);
925
- const recovered = [];
926
- for (const candidate of candidates) {
925
+ const results = await Promise.all(candidates.map(async (candidate) => {
927
926
  const usage = await fetchOpenCodeGoUsage(candidate, fetchApi, options.timers);
928
- if (hasConfirmedHeadroom(usage))
929
- recovered.push(candidate);
930
- // Keep the in-memory config aligned with writers active during the probes.
931
- if (!refreshConfig())
932
- break;
933
- }
934
- return recovered;
927
+ return hasConfirmedHeadroom(usage) ? candidate : undefined;
928
+ }));
929
+ if (!refreshConfig())
930
+ return [];
931
+ return results.filter((snapshot) => snapshot !== undefined);
935
932
  }
936
933
  function selectNextKey(mode, freshConfig, startIndex, currentTime) {
937
934
  return mode.kind === "quota"
@@ -1175,9 +1172,7 @@ export function createOpencodeGoRotationExtension(options = {}) {
1175
1172
  }
1176
1173
  // On reload: re-apply active key, skip auto-import
1177
1174
  if (event.reason === "reload") {
1178
- const keyName = applySynchronizedActiveKey(ctx);
1179
- if (keyName)
1180
- ctx.ui.notify(`OpenCode: Active key → ${keyName}`, "info");
1175
+ applySynchronizedActiveKey(ctx);
1181
1176
  syncUsageStatus(ctx, true);
1182
1177
  return;
1183
1178
  }
@@ -1197,9 +1192,7 @@ export function createOpencodeGoRotationExtension(options = {}) {
1197
1192
  return;
1198
1193
  }
1199
1194
  }
1200
- const keyName = applySynchronizedActiveKey(ctx);
1201
- if (keyName)
1202
- ctx.ui.notify(`OpenCode: Active key → ${keyName}`, "info");
1195
+ applySynchronizedActiveKey(ctx);
1203
1196
  syncUsageStatus(ctx, true);
1204
1197
  });
1205
1198
  pi.on("model_select", (_event, ctx) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yugimob/pi-opencode-go-rotation",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "Rotate between multiple OpenCode Go API keys with reactive 429, rate-limit, and watchdog stall detection, plus live footer usage for the active key",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",