omp-multi-auth 1.2.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 +6 -4
- package/extensions/lib/providers.ts +63 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -77,6 +77,9 @@ Create `.omp/multi-auth.json` in a project to restrict which subscription provid
|
|
|
77
77
|
| `google-antigravity` | Antigravity |
|
|
78
78
|
| `kimi-code` | Kimi Code |
|
|
79
79
|
| `xai-oauth` | xAI Grok OAuth |
|
|
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.
|
|
80
83
|
|
|
81
84
|
### API key
|
|
82
85
|
|
|
@@ -96,14 +99,13 @@ Create `.omp/multi-auth.json` in a project to restrict which subscription provid
|
|
|
96
99
|
| `zai` | Z.AI (GLM) |
|
|
97
100
|
| `minimax` | MiniMax (Global) |
|
|
98
101
|
| `minimax-cn` | MiniMax (China) |
|
|
102
|
+
| `cursor` | Cursor (dashboard API key `crsr_...` / `cursor_...` or browser sign-in) |
|
|
99
103
|
|
|
100
104
|
API-key providers support full multi-account operation. Add an account with `/multi-auth add`, select the provider, then authenticate via `/multi-auth login` (or `/login <name>`) and paste your API key when prompted. Each account stores its own key independently in OMP auth storage.
|
|
101
105
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
GitLab Duo requires custom handlers and is not exposed.
|
|
106
|
+
For `cursor`, `/multi-auth login` prompts for a dashboard API key (`crsr_...`/`cursor_...`). Submit a key to use token exchange, or leave it blank to sign in via browser PKCE OAuth. Both methods refresh automatically.
|
|
105
107
|
|
|
106
|
-
## Built-in
|
|
108
|
+
## Built-in quotas
|
|
107
109
|
|
|
108
110
|
Run `/multi-auth limits` to inspect quota and usage information for supported providers. This currently includes built-in quota checks for Codex and Google providers. Results depend on provider availability and authenticated account state.
|
|
109
111
|
|
|
@@ -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 };
|
|
@@ -118,19 +121,31 @@ async function exchangeCursorApiKey(apiKey: string, signal?: AbortSignal): Promi
|
|
|
118
121
|
return { access: data.accessToken, refresh: apiKey, expires: cursorJwtExpiryMs(data.accessToken) };
|
|
119
122
|
}
|
|
120
123
|
|
|
121
|
-
|
|
124
|
+
const CURSOR_API_KEY_PREFIXES = ["crsr_", "cursor_"];
|
|
125
|
+
|
|
126
|
+
export function buildCursorOAuth(index: number): ProviderOAuth {
|
|
127
|
+
const definition = requireOAuthDefinition("cursor");
|
|
122
128
|
return {
|
|
123
129
|
name: `Cursor #${index}`,
|
|
124
130
|
async login(callbacks: OAuthLoginCallbacks): Promise<OAuthCredentials> {
|
|
125
131
|
const apiKey = (await callbacks.onPrompt({
|
|
126
|
-
message: "Paste your Cursor API key (crsr_...):",
|
|
127
|
-
placeholder: "crsr_...",
|
|
132
|
+
message: "Paste your Cursor API key (crsr_...), or leave blank to sign in with your browser:",
|
|
133
|
+
placeholder: "crsr_... (blank = browser sign-in)",
|
|
134
|
+
allowEmpty: true,
|
|
128
135
|
})).trim();
|
|
129
|
-
if (
|
|
130
|
-
|
|
136
|
+
if (apiKey) return exchangeCursorApiKey(apiKey, callbacks.signal);
|
|
137
|
+
const credentials = await definition.login(callbacks);
|
|
138
|
+
if (typeof credentials === "string") {
|
|
139
|
+
throw new Error(`Cursor #${index} browser login did not return renewable credentials`);
|
|
140
|
+
}
|
|
141
|
+
return credentials;
|
|
131
142
|
},
|
|
132
|
-
async refreshToken(credentials: OAuthCredentials): Promise<OAuthCredentials> {
|
|
133
|
-
|
|
143
|
+
async refreshToken(credentials: OAuthCredentials, signal?: AbortSignal): Promise<OAuthCredentials> {
|
|
144
|
+
const refresh = credentials.refresh || credentials.access;
|
|
145
|
+
if (CURSOR_API_KEY_PREFIXES.some((prefix) => refresh.startsWith(prefix))) {
|
|
146
|
+
return exchangeCursorApiKey(refresh, signal);
|
|
147
|
+
}
|
|
148
|
+
return definition.refreshToken(credentials, signal);
|
|
134
149
|
},
|
|
135
150
|
getApiKey(credentials: OAuthCredentials): string {
|
|
136
151
|
return credentials.access;
|
|
@@ -370,9 +385,9 @@ export const PROVIDER_TEMPLATES: Record<string, ProviderTemplate> = {
|
|
|
370
385
|
},
|
|
371
386
|
|
|
372
387
|
cursor: {
|
|
373
|
-
displayName: "Cursor
|
|
388
|
+
displayName: "Cursor",
|
|
374
389
|
buildOAuth(index: number) {
|
|
375
|
-
return
|
|
390
|
+
return buildCursorOAuth(index);
|
|
376
391
|
},
|
|
377
392
|
},
|
|
378
393
|
|
|
@@ -431,11 +446,49 @@ export function cloneModels(originalProvider: string, index: number): ProviderMo
|
|
|
431
446
|
// Register a single subscription as a provider
|
|
432
447
|
// ==========================================================================
|
|
433
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
|
+
|
|
434
483
|
export function registerSub(pi: ExtensionAPI, entry: SubEntry): void {
|
|
435
484
|
const template = PROVIDER_TEMPLATES[entry.provider];
|
|
436
485
|
if (!template) return;
|
|
437
486
|
const name = subProviderName(entry);
|
|
438
487
|
const oauth = template.buildOAuth?.(entry.index);
|
|
488
|
+
if (entry.provider === "openai-codex" && oauth) {
|
|
489
|
+
registerCodexSub(pi, name, entry.index, oauth);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
439
492
|
const modifyModels = template.buildModifyModels?.(name);
|
|
440
493
|
|
|
441
494
|
const builtinModels = getModels(entry.provider);
|
package/package.json
CHANGED