@omnicross/subscriptions 0.3.1 → 0.4.0
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/dist/chunk-L77HJY6V.js +1109 -0
- package/dist/chunk-QKWL53TJ.cjs +1109 -0
- package/dist/index.cjs +88 -8
- package/dist/index.d.cts +52 -2
- package/dist/index.d.ts +52 -2
- package/dist/index.js +86 -6
- package/dist/oauth.cjs +8 -2
- package/dist/oauth.d.cts +294 -1
- package/dist/oauth.d.ts +294 -1
- package/dist/oauth.js +7 -1
- package/package.json +3 -3
- package/dist/chunk-B2LHAP4F.cjs +0 -570
- package/dist/chunk-ZB3GA2Y2.js +0 -570
package/dist/index.cjs
CHANGED
|
@@ -4,7 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var _chunkQKWL53TJcjs = require('./chunk-QKWL53TJ.cjs');
|
|
8
17
|
|
|
9
18
|
|
|
10
19
|
|
|
@@ -128,14 +137,18 @@ var ACCOUNTS_KEY = {
|
|
|
128
137
|
codex: "codexAccounts",
|
|
129
138
|
gemini: "geminiAccounts",
|
|
130
139
|
opencodego: "opencodegoAccounts",
|
|
131
|
-
kimi: "kimiAccounts"
|
|
140
|
+
kimi: "kimiAccounts",
|
|
141
|
+
grok: "grokAccounts",
|
|
142
|
+
copilot: "copilotAccounts"
|
|
132
143
|
};
|
|
133
144
|
var ACTIVE_KEY = {
|
|
134
145
|
claude: "activeClaudeAccountId",
|
|
135
146
|
codex: "activeCodexAccountId",
|
|
136
147
|
gemini: "activeGeminiAccountId",
|
|
137
148
|
opencodego: "activeOpencodegoAccountId",
|
|
138
|
-
kimi: "activeKimiAccountId"
|
|
149
|
+
kimi: "activeKimiAccountId",
|
|
150
|
+
grok: "activeGrokAccountId",
|
|
151
|
+
copilot: "activeCopilotAccountId"
|
|
139
152
|
};
|
|
140
153
|
function gateSchedulable(accounts, providerId, health, now, resolvedModel, supportedModelsById) {
|
|
141
154
|
if (!health && !resolvedModel || accounts.length < 2) return accounts;
|
|
@@ -427,7 +440,10 @@ var OAuthBearerAuthStrategy = (_class2 = class {
|
|
|
427
440
|
headers["Authorization"] = `Bearer ${token}`;
|
|
428
441
|
if (this.providerId === "kimi") {
|
|
429
442
|
const deviceId = await this.resolveKimiDeviceId(_optionalChain([hints, 'optionalAccess', _29 => _29.sessionKey]));
|
|
430
|
-
Object.assign(headers,
|
|
443
|
+
Object.assign(headers, _chunkQKWL53TJcjs.kimiFingerprintHeaders.call(void 0, deviceId));
|
|
444
|
+
}
|
|
445
|
+
if (this.providerId === "copilot") {
|
|
446
|
+
Object.assign(headers, _chunkQKWL53TJcjs.COPILOT_API_HEADERS);
|
|
431
447
|
}
|
|
432
448
|
}
|
|
433
449
|
async onUnauthorized(sessionKey) {
|
|
@@ -485,6 +501,10 @@ var OAuthBearerAuthStrategy = (_class2 = class {
|
|
|
485
501
|
return this.tokens.refreshGeminiToken();
|
|
486
502
|
case "kimi":
|
|
487
503
|
return this.tokens.refreshKimiToken ? this.tokens.refreshKimiToken() : Promise.resolve(false);
|
|
504
|
+
case "grok":
|
|
505
|
+
return this.tokens.refreshGrokToken ? this.tokens.refreshGrokToken() : Promise.resolve(false);
|
|
506
|
+
case "copilot":
|
|
507
|
+
return this.tokens.refreshCopilotToken ? this.tokens.refreshCopilotToken() : Promise.resolve(false);
|
|
488
508
|
}
|
|
489
509
|
}
|
|
490
510
|
tokenBlock(config) {
|
|
@@ -495,6 +515,10 @@ var OAuthBearerAuthStrategy = (_class2 = class {
|
|
|
495
515
|
return config.gemini;
|
|
496
516
|
case "kimi":
|
|
497
517
|
return config.kimi;
|
|
518
|
+
case "grok":
|
|
519
|
+
return config.grok;
|
|
520
|
+
case "copilot":
|
|
521
|
+
return config.copilot;
|
|
498
522
|
}
|
|
499
523
|
}
|
|
500
524
|
/**
|
|
@@ -655,7 +679,9 @@ var DISPLAY_NAMES = {
|
|
|
655
679
|
codex: "Codex (ChatGPT OAuth)",
|
|
656
680
|
gemini: "Gemini (Google OAuth)",
|
|
657
681
|
opencodego: "OpenCodeGo (Bearer key)",
|
|
658
|
-
kimi: "Kimi Code (Moonshot OAuth)"
|
|
682
|
+
kimi: "Kimi Code (Moonshot OAuth)",
|
|
683
|
+
grok: "Grok (xAI SuperGrok OAuth)",
|
|
684
|
+
copilot: "Copilot (GitHub OAuth)"
|
|
659
685
|
};
|
|
660
686
|
var SubscriptionAccountService = (_class6 = class {
|
|
661
687
|
__init10() {this.mutex = new RefreshMutex()}
|
|
@@ -670,7 +696,9 @@ var SubscriptionAccountService = (_class6 = class {
|
|
|
670
696
|
["codex", new OAuthBearerAuthStrategy("codex", tokens, this.mutex, this.selector, health)],
|
|
671
697
|
["gemini", new OAuthBearerAuthStrategy("gemini", tokens, this.mutex, this.selector, health)],
|
|
672
698
|
["opencodego", new StaticBearerAuthStrategy(tokens, this.selector, health)],
|
|
673
|
-
["kimi", new OAuthBearerAuthStrategy("kimi", tokens, this.mutex, this.selector, health)]
|
|
699
|
+
["kimi", new OAuthBearerAuthStrategy("kimi", tokens, this.mutex, this.selector, health)],
|
|
700
|
+
["grok", new OAuthBearerAuthStrategy("grok", tokens, this.mutex, this.selector, health)],
|
|
701
|
+
["copilot", new OAuthBearerAuthStrategy("copilot", tokens, this.mutex, this.selector, health)]
|
|
674
702
|
]);
|
|
675
703
|
}
|
|
676
704
|
/** Returns the strategy bound to a subscription provider, or `null` for unknown ids. */
|
|
@@ -1121,7 +1149,9 @@ var SubscriptionProviderRegistry = (_class9 = class {
|
|
|
1121
1149
|
const gemini = this.accounts.getStrategy("gemini");
|
|
1122
1150
|
const opencodego = this.accounts.getStrategy("opencodego");
|
|
1123
1151
|
const kimi = this.accounts.getStrategy("kimi");
|
|
1124
|
-
|
|
1152
|
+
const grok = this.accounts.getStrategy("grok");
|
|
1153
|
+
const copilot = this.accounts.getStrategy("copilot");
|
|
1154
|
+
if (!claude || !codex || !gemini || !opencodego || !kimi || !grok || !copilot) {
|
|
1125
1155
|
throw new Error("[SubscriptionProviderRegistry] Missing strategy in SubscriptionAccountService");
|
|
1126
1156
|
}
|
|
1127
1157
|
this.profiles = /* @__PURE__ */ new Map([
|
|
@@ -1282,6 +1312,48 @@ var SubscriptionProviderRegistry = (_class9 = class {
|
|
|
1282
1312
|
providerTransformerNames: ["anthropic"],
|
|
1283
1313
|
modelTransformerNames: []
|
|
1284
1314
|
}
|
|
1315
|
+
],
|
|
1316
|
+
[
|
|
1317
|
+
"grok",
|
|
1318
|
+
{
|
|
1319
|
+
providerId: "grok",
|
|
1320
|
+
displayName: "Grok (xAI SuperGrok OAuth)",
|
|
1321
|
+
authStrategy: grok,
|
|
1322
|
+
mode: "transformer",
|
|
1323
|
+
// SuperGrok's subscription surface speaks the OpenAI Responses API at
|
|
1324
|
+
// `api.x.ai/v1/responses` with the OAuth access token as Bearer (the
|
|
1325
|
+
// same token shape the paid API-key product uses on this endpoint).
|
|
1326
|
+
// Mirrors the codex profile: Unified → Responses via the
|
|
1327
|
+
// `openai-response` encoder; effort negotiation is capability-driven
|
|
1328
|
+
// (the omit-effort grok models carry `thinkingLevels: ['none']` in the
|
|
1329
|
+
// canonical registry, so `reasoning.effort` is never sent to them).
|
|
1330
|
+
resolveUpstreamUrl: () => "https://api.x.ai/v1/responses",
|
|
1331
|
+
providerTransformerNames: ["openai-response"],
|
|
1332
|
+
modelTransformerNames: []
|
|
1333
|
+
}
|
|
1334
|
+
],
|
|
1335
|
+
[
|
|
1336
|
+
"copilot",
|
|
1337
|
+
{
|
|
1338
|
+
providerId: "copilot",
|
|
1339
|
+
displayName: "Copilot (GitHub OAuth)",
|
|
1340
|
+
authStrategy: copilot,
|
|
1341
|
+
mode: "transformer",
|
|
1342
|
+
// GitHub Copilot serves THREE wires on ONE host, per model (the
|
|
1343
|
+
// opencodego shape-seam pattern): the Claude family rides
|
|
1344
|
+
// anthropic-messages at `/v1/messages` (same-format verbatim relay
|
|
1345
|
+
// for Anthropic-shape clients), the GPT/Grok/mai-code families ride
|
|
1346
|
+
// Responses at `/v1/responses`, and the Gemini/Kimi/raptor families
|
|
1347
|
+
// ride chat-completions at `/v1/chat/completions`. The base honors
|
|
1348
|
+
// the account's discovered `apiEndpoint` (or GHE domain) via the
|
|
1349
|
+
// threaded config, defaulting to api.githubcopilot.com. The identity
|
|
1350
|
+
// header set (incl. X-GitHub-Api-Version, which unlocks long-context
|
|
1351
|
+
// tiers) is injected by the auth strategy.
|
|
1352
|
+
resolveUpstreamUrl: (model, config) => `${_chunkQKWL53TJcjs.copilotBaseUrl.call(void 0, config)}${_chunkQKWL53TJcjs.copilotPathFor.call(void 0, _chunkQKWL53TJcjs.copilotWireFor.call(void 0, model))}`,
|
|
1353
|
+
resolveProviderTransformerNames: (model) => _chunkQKWL53TJcjs.copilotTransformerNamesForWire.call(void 0, _chunkQKWL53TJcjs.copilotWireFor.call(void 0, model)),
|
|
1354
|
+
providerTransformerNames: ["openai-response"],
|
|
1355
|
+
modelTransformerNames: []
|
|
1356
|
+
}
|
|
1285
1357
|
]
|
|
1286
1358
|
]);
|
|
1287
1359
|
}
|
|
@@ -2614,4 +2686,12 @@ function createCodexImageLiveVerifier(options) {
|
|
|
2614
2686
|
|
|
2615
2687
|
|
|
2616
2688
|
|
|
2617
|
-
|
|
2689
|
+
|
|
2690
|
+
|
|
2691
|
+
|
|
2692
|
+
|
|
2693
|
+
|
|
2694
|
+
|
|
2695
|
+
|
|
2696
|
+
|
|
2697
|
+
exports.COPILOT_GITHUB_HEADERS = _chunkQKWL53TJcjs.COPILOT_GITHUB_HEADERS; exports.DEFAULT_ACCOUNT_PRIORITY = DEFAULT_ACCOUNT_PRIORITY; exports.LAST_USED_PERSIST_THROTTLE_MS = LAST_USED_PERSIST_THROTTLE_MS; exports.SESSION_AFFINITY_TTL_MS = SESSION_AFFINITY_TTL_MS; exports.SubscriptionAccountSelector = SubscriptionAccountSelector; exports.SubscriptionAccountService = SubscriptionAccountService; exports.SubscriptionDispatcher = SubscriptionDispatcher; exports.SubscriptionProviderRegistry = SubscriptionProviderRegistry; exports.claudeOAuth = _chunkQKWL53TJcjs.claude_exports; exports.codexOAuth = _chunkQKWL53TJcjs.codex_exports; exports.copilotBaseUrl = _chunkQKWL53TJcjs.copilotBaseUrl; exports.copilotGitHubApiBase = _chunkQKWL53TJcjs.copilotGitHubApiBase; exports.copilotOAuth = _chunkQKWL53TJcjs.copilot_exports; exports.copilotPathFor = _chunkQKWL53TJcjs.copilotPathFor; exports.copilotTransformerNamesForWire = _chunkQKWL53TJcjs.copilotTransformerNamesForWire; exports.copilotWireFor = _chunkQKWL53TJcjs.copilotWireFor; exports.createCodexImageLiveVerifier = createCodexImageLiveVerifier; exports.createCodexSubscriptionImageProvider = createCodexSubscriptionImageProvider; exports.geminiOAuth = _chunkQKWL53TJcjs.gemini_exports; exports.getSubscriptionAccountService = getSubscriptionAccountService; exports.getSubscriptionProviderRegistry = getSubscriptionProviderRegistry; exports.grokOAuth = _chunkQKWL53TJcjs.grok_exports; exports.kimiFingerprintHeaders = _chunkQKWL53TJcjs.kimiFingerprintHeaders; exports.kimiOAuth = _chunkQKWL53TJcjs.kimi_exports; exports.normalizeOpenCodeGoBaseUrl = normalizeOpenCodeGoBaseUrl; exports.setSubscriptionAccountService = setSubscriptionAccountService; exports.setSubscriptionProviderRegistry = setSubscriptionProviderRegistry;
|
package/dist/index.d.cts
CHANGED
|
@@ -9,7 +9,7 @@ import { TransformerChainExecutor } from '@omnicross/core/transformer/Transforme
|
|
|
9
9
|
import { TransformerService } from '@omnicross/core/transformer/TransformerService';
|
|
10
10
|
import { Transformer } from '@omnicross/core/transformer/types';
|
|
11
11
|
export { FetchLike } from '@omnicross/core/auth/GeminiCodeAssistProjectResolver';
|
|
12
|
-
export { claudeOAuth, codexOAuth, geminiOAuth, kimiFingerprintHeaders, kimiOAuth } from './oauth.cjs';
|
|
12
|
+
export { COPILOT_GITHUB_HEADERS, claudeOAuth, codexOAuth, copilotOAuth, geminiOAuth, grokOAuth, kimiFingerprintHeaders, kimiOAuth } from './oauth.cjs';
|
|
13
13
|
import { ImageProvider } from '@omnicross/core/image-generation';
|
|
14
14
|
import { ImageCapabilityEvidenceLayer, ImageQuality, ImageBackground, ImageOutputFormat, ImageModeration } from '@omnicross/contracts/image-generation-types';
|
|
15
15
|
|
|
@@ -55,6 +55,17 @@ interface SubscriptionCredentialStore {
|
|
|
55
55
|
* failed refresh) — the daemon's store implements it.
|
|
56
56
|
*/
|
|
57
57
|
refreshKimiToken?(): Promise<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* Force a Grok (xAI SuperGrok) OAuth token refresh; `true` on success.
|
|
60
|
+
* OPTIONAL for lightweight test doubles (the grok strategy catches its
|
|
61
|
+
* absence like a failed refresh) — the daemon's store implements it.
|
|
62
|
+
*/
|
|
63
|
+
refreshGrokToken?(): Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* "Refresh" a GitHub Copilot token — a LOCAL no-op (ghu_ tokens are
|
|
66
|
+
* long-lived with no exchange endpoint). OPTIONAL like the others.
|
|
67
|
+
*/
|
|
68
|
+
refreshCopilotToken?(): Promise<boolean>;
|
|
58
69
|
/** Current valid OpenCodeGo static API key; `null` if none. */
|
|
59
70
|
getValidOpenCodeGoApiKey(): Promise<string | null>;
|
|
60
71
|
/**
|
|
@@ -357,6 +368,45 @@ declare class SubscriptionDispatcher {
|
|
|
357
368
|
private buildRequestSummary;
|
|
358
369
|
}
|
|
359
370
|
|
|
371
|
+
/**
|
|
372
|
+
* GitHub Copilot model-wire map — which of the catalog's three wires each
|
|
373
|
+
* served model rides, and the per-wire upstream path + provider transformer
|
|
374
|
+
* chain. Verified ids/wires from the audit source's frozen census; models are
|
|
375
|
+
* grouped by wire exactly as `SUBSCRIPTION_MODEL_CATALOG.copilot` lists them.
|
|
376
|
+
*
|
|
377
|
+
* The three faces live on ONE host (the Copilot API base):
|
|
378
|
+
* - anthropic-messages → `/v1/messages` (Claude family; same-format relay
|
|
379
|
+
* for Anthropic-shape clients — the URL suffix is what the core plan
|
|
380
|
+
* builder keys same-format detection on)
|
|
381
|
+
* - openai-responses → `/v1/responses`
|
|
382
|
+
* - openai chat → `/v1/chat/completions`
|
|
383
|
+
*
|
|
384
|
+
* @module @omnicross/subscriptions/copilot/models
|
|
385
|
+
*/
|
|
386
|
+
/** The three Copilot wire shapes. */
|
|
387
|
+
type CopilotWire = 'anthropic' | 'responses' | 'chat';
|
|
388
|
+
/** Classify a resolved model id; UNKNOWN ids fall to the responses wire (the
|
|
389
|
+
* newest models land there first). */
|
|
390
|
+
declare function copilotWireFor(modelId: string): CopilotWire;
|
|
391
|
+
/** The per-wire upstream PATH under the Copilot API base. */
|
|
392
|
+
declare function copilotPathFor(wire: CopilotWire): string;
|
|
393
|
+
/** The per-wire provider transformer chain (mirrors the opencodego shape seam). */
|
|
394
|
+
declare function copilotTransformerNamesForWire(wire: CopilotWire): readonly string[];
|
|
395
|
+
/** Resolve the account-effective Copilot API base (discovered endpoint wins). */
|
|
396
|
+
declare function copilotBaseUrl(config: {
|
|
397
|
+
apiEndpoint?: string;
|
|
398
|
+
enterpriseUrl?: string;
|
|
399
|
+
} | undefined): string;
|
|
400
|
+
/**
|
|
401
|
+
* The GitHub REST base for an account (identity / quota / discovery probes).
|
|
402
|
+
* GHE domains route to `api.<domain>` — the data-residency plane convention
|
|
403
|
+
* (e.g. `company.ghe.com` → `api.company.ghe.com`); an explicit scheme or
|
|
404
|
+
* `api.` prefix is honored verbatim, personal accounts stay on api.github.com.
|
|
405
|
+
* Self-hosted GHES `/api/v3` path-style hosts are NOT derived here — pass the
|
|
406
|
+
* full `api.<host>` (or scheme-qualified) form via `enterpriseUrl`.
|
|
407
|
+
*/
|
|
408
|
+
declare function copilotGitHubApiBase(enterpriseUrl?: string): string;
|
|
409
|
+
|
|
360
410
|
/**
|
|
361
411
|
* Default OpenCodeGo upstream URLs (both provider halves).
|
|
362
412
|
*
|
|
@@ -468,4 +518,4 @@ interface CodexImageLiveVerifier {
|
|
|
468
518
|
}
|
|
469
519
|
declare function createCodexImageLiveVerifier(options: CodexImageLiveVerifierOptions): CodexImageLiveVerifier;
|
|
470
520
|
|
|
471
|
-
export { type CodexImageCapabilityEvidence, type CodexImageCapabilityEvidenceRequest, type CodexImageCapabilityEvidenceSource, type CodexImageCapabilityObservation, type CodexImageCapabilityObservedResponseFields, type CodexImageCapabilityTestedRequest, type CodexImageLiveVerificationRequest, type CodexImageLiveVerifier, type CodexImageLiveVerifierOptions, type CodexSubscriptionImageProviderOptions, DEFAULT_ACCOUNT_PRIORITY, type DispatchRequest, type DispatcherHooks, type ImageExecutionAccountKey, type ImageExecutionScheduler, type ImageExecutionSchedulerGrant, type ImageExecutionSchedulerRequest, LAST_USED_PERSIST_THROTTLE_MS, SESSION_AFFINITY_TTL_MS, type SchedulableAccount, type SelectInput, type SelectResult, SubscriptionAccountSelector, SubscriptionAccountService, type SubscriptionCredentialStore, SubscriptionDispatcher, SubscriptionProviderRegistry, createCodexImageLiveVerifier, createCodexSubscriptionImageProvider, getSubscriptionAccountService, getSubscriptionProviderRegistry, normalizeOpenCodeGoBaseUrl, setSubscriptionAccountService, setSubscriptionProviderRegistry };
|
|
521
|
+
export { type CodexImageCapabilityEvidence, type CodexImageCapabilityEvidenceRequest, type CodexImageCapabilityEvidenceSource, type CodexImageCapabilityObservation, type CodexImageCapabilityObservedResponseFields, type CodexImageCapabilityTestedRequest, type CodexImageLiveVerificationRequest, type CodexImageLiveVerifier, type CodexImageLiveVerifierOptions, type CodexSubscriptionImageProviderOptions, DEFAULT_ACCOUNT_PRIORITY, type DispatchRequest, type DispatcherHooks, type ImageExecutionAccountKey, type ImageExecutionScheduler, type ImageExecutionSchedulerGrant, type ImageExecutionSchedulerRequest, LAST_USED_PERSIST_THROTTLE_MS, SESSION_AFFINITY_TTL_MS, type SchedulableAccount, type SelectInput, type SelectResult, SubscriptionAccountSelector, SubscriptionAccountService, type SubscriptionCredentialStore, SubscriptionDispatcher, SubscriptionProviderRegistry, copilotBaseUrl, copilotGitHubApiBase, copilotPathFor, copilotTransformerNamesForWire, copilotWireFor, createCodexImageLiveVerifier, createCodexSubscriptionImageProvider, getSubscriptionAccountService, getSubscriptionProviderRegistry, normalizeOpenCodeGoBaseUrl, setSubscriptionAccountService, setSubscriptionProviderRegistry };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { TransformerChainExecutor } from '@omnicross/core/transformer/Transforme
|
|
|
9
9
|
import { TransformerService } from '@omnicross/core/transformer/TransformerService';
|
|
10
10
|
import { Transformer } from '@omnicross/core/transformer/types';
|
|
11
11
|
export { FetchLike } from '@omnicross/core/auth/GeminiCodeAssistProjectResolver';
|
|
12
|
-
export { claudeOAuth, codexOAuth, geminiOAuth, kimiFingerprintHeaders, kimiOAuth } from './oauth.js';
|
|
12
|
+
export { COPILOT_GITHUB_HEADERS, claudeOAuth, codexOAuth, copilotOAuth, geminiOAuth, grokOAuth, kimiFingerprintHeaders, kimiOAuth } from './oauth.js';
|
|
13
13
|
import { ImageProvider } from '@omnicross/core/image-generation';
|
|
14
14
|
import { ImageCapabilityEvidenceLayer, ImageQuality, ImageBackground, ImageOutputFormat, ImageModeration } from '@omnicross/contracts/image-generation-types';
|
|
15
15
|
|
|
@@ -55,6 +55,17 @@ interface SubscriptionCredentialStore {
|
|
|
55
55
|
* failed refresh) — the daemon's store implements it.
|
|
56
56
|
*/
|
|
57
57
|
refreshKimiToken?(): Promise<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* Force a Grok (xAI SuperGrok) OAuth token refresh; `true` on success.
|
|
60
|
+
* OPTIONAL for lightweight test doubles (the grok strategy catches its
|
|
61
|
+
* absence like a failed refresh) — the daemon's store implements it.
|
|
62
|
+
*/
|
|
63
|
+
refreshGrokToken?(): Promise<boolean>;
|
|
64
|
+
/**
|
|
65
|
+
* "Refresh" a GitHub Copilot token — a LOCAL no-op (ghu_ tokens are
|
|
66
|
+
* long-lived with no exchange endpoint). OPTIONAL like the others.
|
|
67
|
+
*/
|
|
68
|
+
refreshCopilotToken?(): Promise<boolean>;
|
|
58
69
|
/** Current valid OpenCodeGo static API key; `null` if none. */
|
|
59
70
|
getValidOpenCodeGoApiKey(): Promise<string | null>;
|
|
60
71
|
/**
|
|
@@ -357,6 +368,45 @@ declare class SubscriptionDispatcher {
|
|
|
357
368
|
private buildRequestSummary;
|
|
358
369
|
}
|
|
359
370
|
|
|
371
|
+
/**
|
|
372
|
+
* GitHub Copilot model-wire map — which of the catalog's three wires each
|
|
373
|
+
* served model rides, and the per-wire upstream path + provider transformer
|
|
374
|
+
* chain. Verified ids/wires from the audit source's frozen census; models are
|
|
375
|
+
* grouped by wire exactly as `SUBSCRIPTION_MODEL_CATALOG.copilot` lists them.
|
|
376
|
+
*
|
|
377
|
+
* The three faces live on ONE host (the Copilot API base):
|
|
378
|
+
* - anthropic-messages → `/v1/messages` (Claude family; same-format relay
|
|
379
|
+
* for Anthropic-shape clients — the URL suffix is what the core plan
|
|
380
|
+
* builder keys same-format detection on)
|
|
381
|
+
* - openai-responses → `/v1/responses`
|
|
382
|
+
* - openai chat → `/v1/chat/completions`
|
|
383
|
+
*
|
|
384
|
+
* @module @omnicross/subscriptions/copilot/models
|
|
385
|
+
*/
|
|
386
|
+
/** The three Copilot wire shapes. */
|
|
387
|
+
type CopilotWire = 'anthropic' | 'responses' | 'chat';
|
|
388
|
+
/** Classify a resolved model id; UNKNOWN ids fall to the responses wire (the
|
|
389
|
+
* newest models land there first). */
|
|
390
|
+
declare function copilotWireFor(modelId: string): CopilotWire;
|
|
391
|
+
/** The per-wire upstream PATH under the Copilot API base. */
|
|
392
|
+
declare function copilotPathFor(wire: CopilotWire): string;
|
|
393
|
+
/** The per-wire provider transformer chain (mirrors the opencodego shape seam). */
|
|
394
|
+
declare function copilotTransformerNamesForWire(wire: CopilotWire): readonly string[];
|
|
395
|
+
/** Resolve the account-effective Copilot API base (discovered endpoint wins). */
|
|
396
|
+
declare function copilotBaseUrl(config: {
|
|
397
|
+
apiEndpoint?: string;
|
|
398
|
+
enterpriseUrl?: string;
|
|
399
|
+
} | undefined): string;
|
|
400
|
+
/**
|
|
401
|
+
* The GitHub REST base for an account (identity / quota / discovery probes).
|
|
402
|
+
* GHE domains route to `api.<domain>` — the data-residency plane convention
|
|
403
|
+
* (e.g. `company.ghe.com` → `api.company.ghe.com`); an explicit scheme or
|
|
404
|
+
* `api.` prefix is honored verbatim, personal accounts stay on api.github.com.
|
|
405
|
+
* Self-hosted GHES `/api/v3` path-style hosts are NOT derived here — pass the
|
|
406
|
+
* full `api.<host>` (or scheme-qualified) form via `enterpriseUrl`.
|
|
407
|
+
*/
|
|
408
|
+
declare function copilotGitHubApiBase(enterpriseUrl?: string): string;
|
|
409
|
+
|
|
360
410
|
/**
|
|
361
411
|
* Default OpenCodeGo upstream URLs (both provider halves).
|
|
362
412
|
*
|
|
@@ -468,4 +518,4 @@ interface CodexImageLiveVerifier {
|
|
|
468
518
|
}
|
|
469
519
|
declare function createCodexImageLiveVerifier(options: CodexImageLiveVerifierOptions): CodexImageLiveVerifier;
|
|
470
520
|
|
|
471
|
-
export { type CodexImageCapabilityEvidence, type CodexImageCapabilityEvidenceRequest, type CodexImageCapabilityEvidenceSource, type CodexImageCapabilityObservation, type CodexImageCapabilityObservedResponseFields, type CodexImageCapabilityTestedRequest, type CodexImageLiveVerificationRequest, type CodexImageLiveVerifier, type CodexImageLiveVerifierOptions, type CodexSubscriptionImageProviderOptions, DEFAULT_ACCOUNT_PRIORITY, type DispatchRequest, type DispatcherHooks, type ImageExecutionAccountKey, type ImageExecutionScheduler, type ImageExecutionSchedulerGrant, type ImageExecutionSchedulerRequest, LAST_USED_PERSIST_THROTTLE_MS, SESSION_AFFINITY_TTL_MS, type SchedulableAccount, type SelectInput, type SelectResult, SubscriptionAccountSelector, SubscriptionAccountService, type SubscriptionCredentialStore, SubscriptionDispatcher, SubscriptionProviderRegistry, createCodexImageLiveVerifier, createCodexSubscriptionImageProvider, getSubscriptionAccountService, getSubscriptionProviderRegistry, normalizeOpenCodeGoBaseUrl, setSubscriptionAccountService, setSubscriptionProviderRegistry };
|
|
521
|
+
export { type CodexImageCapabilityEvidence, type CodexImageCapabilityEvidenceRequest, type CodexImageCapabilityEvidenceSource, type CodexImageCapabilityObservation, type CodexImageCapabilityObservedResponseFields, type CodexImageCapabilityTestedRequest, type CodexImageLiveVerificationRequest, type CodexImageLiveVerifier, type CodexImageLiveVerifierOptions, type CodexSubscriptionImageProviderOptions, DEFAULT_ACCOUNT_PRIORITY, type DispatchRequest, type DispatcherHooks, type ImageExecutionAccountKey, type ImageExecutionScheduler, type ImageExecutionSchedulerGrant, type ImageExecutionSchedulerRequest, LAST_USED_PERSIST_THROTTLE_MS, SESSION_AFFINITY_TTL_MS, type SchedulableAccount, type SelectInput, type SelectResult, SubscriptionAccountSelector, SubscriptionAccountService, type SubscriptionCredentialStore, SubscriptionDispatcher, SubscriptionProviderRegistry, copilotBaseUrl, copilotGitHubApiBase, copilotPathFor, copilotTransformerNamesForWire, copilotWireFor, createCodexImageLiveVerifier, createCodexSubscriptionImageProvider, getSubscriptionAccountService, getSubscriptionProviderRegistry, normalizeOpenCodeGoBaseUrl, setSubscriptionAccountService, setSubscriptionProviderRegistry };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
+
COPILOT_API_HEADERS,
|
|
3
|
+
COPILOT_GITHUB_HEADERS,
|
|
2
4
|
claude_exports,
|
|
3
5
|
codex_exports,
|
|
6
|
+
copilotBaseUrl,
|
|
7
|
+
copilotGitHubApiBase,
|
|
8
|
+
copilotPathFor,
|
|
9
|
+
copilotTransformerNamesForWire,
|
|
10
|
+
copilotWireFor,
|
|
11
|
+
copilot_exports,
|
|
4
12
|
gemini_exports,
|
|
13
|
+
grok_exports,
|
|
5
14
|
kimiFingerprintHeaders,
|
|
6
15
|
kimi_exports
|
|
7
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-L77HJY6V.js";
|
|
8
17
|
import {
|
|
9
18
|
accountSupportsModel,
|
|
10
19
|
remapReportForAccount
|
|
@@ -128,14 +137,18 @@ var ACCOUNTS_KEY = {
|
|
|
128
137
|
codex: "codexAccounts",
|
|
129
138
|
gemini: "geminiAccounts",
|
|
130
139
|
opencodego: "opencodegoAccounts",
|
|
131
|
-
kimi: "kimiAccounts"
|
|
140
|
+
kimi: "kimiAccounts",
|
|
141
|
+
grok: "grokAccounts",
|
|
142
|
+
copilot: "copilotAccounts"
|
|
132
143
|
};
|
|
133
144
|
var ACTIVE_KEY = {
|
|
134
145
|
claude: "activeClaudeAccountId",
|
|
135
146
|
codex: "activeCodexAccountId",
|
|
136
147
|
gemini: "activeGeminiAccountId",
|
|
137
148
|
opencodego: "activeOpencodegoAccountId",
|
|
138
|
-
kimi: "activeKimiAccountId"
|
|
149
|
+
kimi: "activeKimiAccountId",
|
|
150
|
+
grok: "activeGrokAccountId",
|
|
151
|
+
copilot: "activeCopilotAccountId"
|
|
139
152
|
};
|
|
140
153
|
function gateSchedulable(accounts, providerId, health, now, resolvedModel, supportedModelsById) {
|
|
141
154
|
if (!health && !resolvedModel || accounts.length < 2) return accounts;
|
|
@@ -429,6 +442,9 @@ var OAuthBearerAuthStrategy = class {
|
|
|
429
442
|
const deviceId = await this.resolveKimiDeviceId(hints?.sessionKey);
|
|
430
443
|
Object.assign(headers, kimiFingerprintHeaders(deviceId));
|
|
431
444
|
}
|
|
445
|
+
if (this.providerId === "copilot") {
|
|
446
|
+
Object.assign(headers, COPILOT_API_HEADERS);
|
|
447
|
+
}
|
|
432
448
|
}
|
|
433
449
|
async onUnauthorized(sessionKey) {
|
|
434
450
|
const byId = await refreshSelectedAccount(this.selector, this.tokens, this.mutex, this.providerId, sessionKey);
|
|
@@ -485,6 +501,10 @@ var OAuthBearerAuthStrategy = class {
|
|
|
485
501
|
return this.tokens.refreshGeminiToken();
|
|
486
502
|
case "kimi":
|
|
487
503
|
return this.tokens.refreshKimiToken ? this.tokens.refreshKimiToken() : Promise.resolve(false);
|
|
504
|
+
case "grok":
|
|
505
|
+
return this.tokens.refreshGrokToken ? this.tokens.refreshGrokToken() : Promise.resolve(false);
|
|
506
|
+
case "copilot":
|
|
507
|
+
return this.tokens.refreshCopilotToken ? this.tokens.refreshCopilotToken() : Promise.resolve(false);
|
|
488
508
|
}
|
|
489
509
|
}
|
|
490
510
|
tokenBlock(config) {
|
|
@@ -495,6 +515,10 @@ var OAuthBearerAuthStrategy = class {
|
|
|
495
515
|
return config.gemini;
|
|
496
516
|
case "kimi":
|
|
497
517
|
return config.kimi;
|
|
518
|
+
case "grok":
|
|
519
|
+
return config.grok;
|
|
520
|
+
case "copilot":
|
|
521
|
+
return config.copilot;
|
|
498
522
|
}
|
|
499
523
|
}
|
|
500
524
|
/**
|
|
@@ -655,7 +679,9 @@ var DISPLAY_NAMES = {
|
|
|
655
679
|
codex: "Codex (ChatGPT OAuth)",
|
|
656
680
|
gemini: "Gemini (Google OAuth)",
|
|
657
681
|
opencodego: "OpenCodeGo (Bearer key)",
|
|
658
|
-
kimi: "Kimi Code (Moonshot OAuth)"
|
|
682
|
+
kimi: "Kimi Code (Moonshot OAuth)",
|
|
683
|
+
grok: "Grok (xAI SuperGrok OAuth)",
|
|
684
|
+
copilot: "Copilot (GitHub OAuth)"
|
|
659
685
|
};
|
|
660
686
|
var SubscriptionAccountService = class {
|
|
661
687
|
mutex = new RefreshMutex();
|
|
@@ -670,7 +696,9 @@ var SubscriptionAccountService = class {
|
|
|
670
696
|
["codex", new OAuthBearerAuthStrategy("codex", tokens, this.mutex, this.selector, health)],
|
|
671
697
|
["gemini", new OAuthBearerAuthStrategy("gemini", tokens, this.mutex, this.selector, health)],
|
|
672
698
|
["opencodego", new StaticBearerAuthStrategy(tokens, this.selector, health)],
|
|
673
|
-
["kimi", new OAuthBearerAuthStrategy("kimi", tokens, this.mutex, this.selector, health)]
|
|
699
|
+
["kimi", new OAuthBearerAuthStrategy("kimi", tokens, this.mutex, this.selector, health)],
|
|
700
|
+
["grok", new OAuthBearerAuthStrategy("grok", tokens, this.mutex, this.selector, health)],
|
|
701
|
+
["copilot", new OAuthBearerAuthStrategy("copilot", tokens, this.mutex, this.selector, health)]
|
|
674
702
|
]);
|
|
675
703
|
}
|
|
676
704
|
/** Returns the strategy bound to a subscription provider, or `null` for unknown ids. */
|
|
@@ -1121,7 +1149,9 @@ var SubscriptionProviderRegistry = class {
|
|
|
1121
1149
|
const gemini = this.accounts.getStrategy("gemini");
|
|
1122
1150
|
const opencodego = this.accounts.getStrategy("opencodego");
|
|
1123
1151
|
const kimi = this.accounts.getStrategy("kimi");
|
|
1124
|
-
|
|
1152
|
+
const grok = this.accounts.getStrategy("grok");
|
|
1153
|
+
const copilot = this.accounts.getStrategy("copilot");
|
|
1154
|
+
if (!claude || !codex || !gemini || !opencodego || !kimi || !grok || !copilot) {
|
|
1125
1155
|
throw new Error("[SubscriptionProviderRegistry] Missing strategy in SubscriptionAccountService");
|
|
1126
1156
|
}
|
|
1127
1157
|
this.profiles = /* @__PURE__ */ new Map([
|
|
@@ -1282,6 +1312,48 @@ var SubscriptionProviderRegistry = class {
|
|
|
1282
1312
|
providerTransformerNames: ["anthropic"],
|
|
1283
1313
|
modelTransformerNames: []
|
|
1284
1314
|
}
|
|
1315
|
+
],
|
|
1316
|
+
[
|
|
1317
|
+
"grok",
|
|
1318
|
+
{
|
|
1319
|
+
providerId: "grok",
|
|
1320
|
+
displayName: "Grok (xAI SuperGrok OAuth)",
|
|
1321
|
+
authStrategy: grok,
|
|
1322
|
+
mode: "transformer",
|
|
1323
|
+
// SuperGrok's subscription surface speaks the OpenAI Responses API at
|
|
1324
|
+
// `api.x.ai/v1/responses` with the OAuth access token as Bearer (the
|
|
1325
|
+
// same token shape the paid API-key product uses on this endpoint).
|
|
1326
|
+
// Mirrors the codex profile: Unified → Responses via the
|
|
1327
|
+
// `openai-response` encoder; effort negotiation is capability-driven
|
|
1328
|
+
// (the omit-effort grok models carry `thinkingLevels: ['none']` in the
|
|
1329
|
+
// canonical registry, so `reasoning.effort` is never sent to them).
|
|
1330
|
+
resolveUpstreamUrl: () => "https://api.x.ai/v1/responses",
|
|
1331
|
+
providerTransformerNames: ["openai-response"],
|
|
1332
|
+
modelTransformerNames: []
|
|
1333
|
+
}
|
|
1334
|
+
],
|
|
1335
|
+
[
|
|
1336
|
+
"copilot",
|
|
1337
|
+
{
|
|
1338
|
+
providerId: "copilot",
|
|
1339
|
+
displayName: "Copilot (GitHub OAuth)",
|
|
1340
|
+
authStrategy: copilot,
|
|
1341
|
+
mode: "transformer",
|
|
1342
|
+
// GitHub Copilot serves THREE wires on ONE host, per model (the
|
|
1343
|
+
// opencodego shape-seam pattern): the Claude family rides
|
|
1344
|
+
// anthropic-messages at `/v1/messages` (same-format verbatim relay
|
|
1345
|
+
// for Anthropic-shape clients), the GPT/Grok/mai-code families ride
|
|
1346
|
+
// Responses at `/v1/responses`, and the Gemini/Kimi/raptor families
|
|
1347
|
+
// ride chat-completions at `/v1/chat/completions`. The base honors
|
|
1348
|
+
// the account's discovered `apiEndpoint` (or GHE domain) via the
|
|
1349
|
+
// threaded config, defaulting to api.githubcopilot.com. The identity
|
|
1350
|
+
// header set (incl. X-GitHub-Api-Version, which unlocks long-context
|
|
1351
|
+
// tiers) is injected by the auth strategy.
|
|
1352
|
+
resolveUpstreamUrl: (model, config) => `${copilotBaseUrl(config)}${copilotPathFor(copilotWireFor(model))}`,
|
|
1353
|
+
resolveProviderTransformerNames: (model) => copilotTransformerNamesForWire(copilotWireFor(model)),
|
|
1354
|
+
providerTransformerNames: ["openai-response"],
|
|
1355
|
+
modelTransformerNames: []
|
|
1356
|
+
}
|
|
1285
1357
|
]
|
|
1286
1358
|
]);
|
|
1287
1359
|
}
|
|
@@ -2595,6 +2667,7 @@ function createCodexImageLiveVerifier(options) {
|
|
|
2595
2667
|
return new DefaultCodexImageLiveVerifier(options);
|
|
2596
2668
|
}
|
|
2597
2669
|
export {
|
|
2670
|
+
COPILOT_GITHUB_HEADERS,
|
|
2598
2671
|
DEFAULT_ACCOUNT_PRIORITY,
|
|
2599
2672
|
LAST_USED_PERSIST_THROTTLE_MS,
|
|
2600
2673
|
SESSION_AFFINITY_TTL_MS,
|
|
@@ -2604,11 +2677,18 @@ export {
|
|
|
2604
2677
|
SubscriptionProviderRegistry,
|
|
2605
2678
|
claude_exports as claudeOAuth,
|
|
2606
2679
|
codex_exports as codexOAuth,
|
|
2680
|
+
copilotBaseUrl,
|
|
2681
|
+
copilotGitHubApiBase,
|
|
2682
|
+
copilot_exports as copilotOAuth,
|
|
2683
|
+
copilotPathFor,
|
|
2684
|
+
copilotTransformerNamesForWire,
|
|
2685
|
+
copilotWireFor,
|
|
2607
2686
|
createCodexImageLiveVerifier,
|
|
2608
2687
|
createCodexSubscriptionImageProvider,
|
|
2609
2688
|
gemini_exports as geminiOAuth,
|
|
2610
2689
|
getSubscriptionAccountService,
|
|
2611
2690
|
getSubscriptionProviderRegistry,
|
|
2691
|
+
grok_exports as grokOAuth,
|
|
2612
2692
|
kimiFingerprintHeaders,
|
|
2613
2693
|
kimi_exports as kimiOAuth,
|
|
2614
2694
|
normalizeOpenCodeGoBaseUrl,
|
package/dist/oauth.cjs
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkQKWL53TJcjs = require('./chunk-QKWL53TJ.cjs');
|
|
8
11
|
require('./chunk-75ZPJI57.cjs');
|
|
9
12
|
|
|
10
13
|
|
|
@@ -12,4 +15,7 @@ require('./chunk-75ZPJI57.cjs');
|
|
|
12
15
|
|
|
13
16
|
|
|
14
17
|
|
|
15
|
-
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
exports.COPILOT_GITHUB_HEADERS = _chunkQKWL53TJcjs.COPILOT_GITHUB_HEADERS; exports.claudeOAuth = _chunkQKWL53TJcjs.claude_exports; exports.codexOAuth = _chunkQKWL53TJcjs.codex_exports; exports.copilotOAuth = _chunkQKWL53TJcjs.copilot_exports; exports.geminiOAuth = _chunkQKWL53TJcjs.gemini_exports; exports.grokOAuth = _chunkQKWL53TJcjs.grok_exports; exports.kimiFingerprintHeaders = _chunkQKWL53TJcjs.kimiFingerprintHeaders; exports.kimiOAuth = _chunkQKWL53TJcjs.kimi_exports;
|