omp-multi-auth 1.3.0 → 1.3.1
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/README.md +3 -0
- package/extensions/lib/providers.ts +42 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -78,6 +78,9 @@ Create `.omp/multi-auth.json` in a project to restrict which subscription provid
|
|
|
78
78
|
| `kimi-code` | Kimi Code |
|
|
79
79
|
| `xai-oauth` | xAI Grok OAuth |
|
|
80
80
|
| `cursor` | Cursor (browser PKCE OAuth or API key) |
|
|
81
|
+
|
|
82
|
+
Each added Codex account (e.g. `openai-codex-2`) discovers its own model catalog using its own OAuth credentials. Run `omp models refresh` to check for newly available models. Account-specific selectors stay unchanged.
|
|
83
|
+
|
|
81
84
|
### API key
|
|
82
85
|
|
|
83
86
|
| Provider | Service |
|
|
@@ -5,7 +5,10 @@ import type { ExtensionAPI, ProviderConfig, ProviderModelConfig } from "@oh-my-p
|
|
|
5
5
|
import { getProviderDefinition } from "@oh-my-pi/pi-ai/registry";
|
|
6
6
|
import type { OAuthCredentials, OAuthLoginCallbacks } from "@oh-my-pi/pi-ai/oauth";
|
|
7
7
|
import { AssistantMessageEventStream, streamSimple, type Api, type AssistantMessageEvent, type Context, type Model, type SimpleStreamOptions } from "@oh-my-pi/pi-ai";
|
|
8
|
-
import {
|
|
8
|
+
import { buildModel } from "@oh-my-pi/pi-catalog/build";
|
|
9
|
+
import { fetchCodexModels } from "@oh-my-pi/pi-catalog/discovery/codex";
|
|
10
|
+
import { CODEX_BASE_URL, getCodexAccountId } from "@oh-my-pi/pi-catalog/wire/codex";
|
|
11
|
+
import { adaptAuthStorage, getModels, subProviderName, type SubEntry } from "./core.ts";
|
|
9
12
|
|
|
10
13
|
export type CopilotCredentials = OAuthCredentials & { enterpriseUrl?: string };
|
|
11
14
|
export type GeminiCredentials = OAuthCredentials & { projectId?: string };
|
|
@@ -443,11 +446,49 @@ export function cloneModels(originalProvider: string, index: number): ProviderMo
|
|
|
443
446
|
// Register a single subscription as a provider
|
|
444
447
|
// ==========================================================================
|
|
445
448
|
|
|
449
|
+
function registerCodexSub(pi: ExtensionAPI, name: string, index: number, oauth: ProviderOAuth): void {
|
|
450
|
+
pi.registerProvider(name, {
|
|
451
|
+
baseUrl: CODEX_BASE_URL,
|
|
452
|
+
api: "openai-codex-responses",
|
|
453
|
+
oauth,
|
|
454
|
+
async fetchDynamicModels(accessToken) {
|
|
455
|
+
// OMP peeks at this provider's credential without refreshing it.
|
|
456
|
+
if (!accessToken) {
|
|
457
|
+
const auth = await pi.pi.discoverAuthStorage();
|
|
458
|
+
try {
|
|
459
|
+
const storage = adaptAuthStorage(auth);
|
|
460
|
+
accessToken = (await storage.getOAuthAccess?.(name))?.accessToken;
|
|
461
|
+
if (!accessToken && storage.hasAuth(name)) throw new Error("Codex OAuth access unavailable");
|
|
462
|
+
} finally {
|
|
463
|
+
auth.close();
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
if (!accessToken) return [];
|
|
467
|
+
|
|
468
|
+
const result = await fetchCodexModels({ accessToken, accountId: getCodexAccountId(accessToken) });
|
|
469
|
+
// Throw on failure so OMP keeps this account's last good catalog.
|
|
470
|
+
if (!result) throw new Error("Codex model list unavailable");
|
|
471
|
+
if (result.rejectedStatus) throw new Error(`Codex model list rejected (HTTP ${result.rejectedStatus})`);
|
|
472
|
+
|
|
473
|
+
// Resolve native Codex capability and pricing rules before OMP assigns the
|
|
474
|
+
// synthetic provider name. Do not add bundled IDs the account didn't list.
|
|
475
|
+
return result.models.map(spec => {
|
|
476
|
+
const model = buildModel(spec);
|
|
477
|
+
return { ...model, name: `${model.name} (#${index})`, input: model.input as ("text" | "image")[] };
|
|
478
|
+
});
|
|
479
|
+
},
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
|
|
446
483
|
export function registerSub(pi: ExtensionAPI, entry: SubEntry): void {
|
|
447
484
|
const template = PROVIDER_TEMPLATES[entry.provider];
|
|
448
485
|
if (!template) return;
|
|
449
486
|
const name = subProviderName(entry);
|
|
450
487
|
const oauth = template.buildOAuth?.(entry.index);
|
|
488
|
+
if (entry.provider === "openai-codex" && oauth) {
|
|
489
|
+
registerCodexSub(pi, name, entry.index, oauth);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
451
492
|
const modifyModels = template.buildModifyModels?.(name);
|
|
452
493
|
|
|
453
494
|
const builtinModels = getModels(entry.provider);
|
package/package.json
CHANGED