@victor-software-house/pi-multicodex 2.0.12 → 2.0.13

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/package.json +1 -1
  2. package/provider.ts +17 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@victor-software-house/pi-multicodex",
3
- "version": "2.0.12",
3
+ "version": "2.0.13",
4
4
  "description": "Codex account rotation extension for pi",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/provider.ts CHANGED
@@ -42,6 +42,22 @@ export function getOpenAICodexMirror(): {
42
42
  };
43
43
  }
44
44
 
45
+ function getActiveApiKey(accountManager: AccountManager): string {
46
+ const active = accountManager.getActiveAccount();
47
+ if (active && !active.needsReauth) {
48
+ return active.accessToken;
49
+ }
50
+ // Fallback: first available account with a valid token.
51
+ for (const account of accountManager.getAccounts()) {
52
+ if (!account.needsReauth && account.accessToken) {
53
+ return account.accessToken;
54
+ }
55
+ }
56
+ // Placeholder — AuthStorage will override on every actual API call
57
+ // as long as auth.json has valid tokens.
58
+ return "pending-login";
59
+ }
60
+
45
61
  export function buildMulticodexProviderConfig(accountManager: AccountManager) {
46
62
  const mirror = getOpenAICodexMirror();
47
63
  const baseProvider = getApiProvider("openai-codex-responses");
@@ -53,7 +69,7 @@ export function buildMulticodexProviderConfig(accountManager: AccountManager) {
53
69
 
54
70
  return {
55
71
  baseUrl: mirror.baseUrl,
56
- apiKey: "managed-by-extension",
72
+ apiKey: getActiveApiKey(accountManager),
57
73
  api: "openai-codex-responses" as const,
58
74
  streamSimple: createStreamWrapper(accountManager, baseProvider),
59
75
  models: mirror.models,