@gajae-code/ai 0.16.1 → 0.16.4
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/CHANGELOG.md +25 -0
- package/dist/types/auth-gateway/server.d.ts +4 -2
- package/dist/types/bedrock-claude-cache-policy.d.ts +21 -0
- package/dist/types/openai-completions-compat.d.ts +22 -0
- package/dist/types/providers/amazon-bedrock.d.ts +17 -2
- package/dist/types/providers/anthropic.d.ts +1 -0
- package/dist/types/providers/openai-completions-compat.d.ts +1 -1
- package/dist/types/providers/opencode-go-session.d.ts +5 -0
- package/dist/types/types.d.ts +7 -0
- package/dist/types/utils/codex-entitlement.d.ts +22 -0
- package/package.json +3 -3
- package/src/auth-gateway/server.ts +5 -0
- package/src/auth-storage.ts +31 -8
- package/src/bedrock-claude-cache-policy.d.ts +21 -0
- package/src/bedrock-claude-cache-policy.ts +68 -0
- package/src/model-pricing.ts +11 -0
- package/src/model-thinking.ts +31 -7
- package/src/models.json +37 -0
- package/src/openai-completions-compat.d.ts +22 -0
- package/src/openai-completions-compat.ts +77 -3
- package/src/providers/amazon-bedrock.d.ts +17 -2
- package/src/providers/amazon-bedrock.ts +9 -9
- package/src/providers/anthropic.d.ts +1 -0
- package/src/providers/anthropic.ts +38 -21
- package/src/providers/cursor.ts +12 -6
- package/src/providers/openai-codex/response-handler.ts +1 -1
- package/src/providers/openai-codex-responses.ts +14 -5
- package/src/providers/openai-completions-compat.d.ts +1 -1
- package/src/providers/openai-completions-compat.ts +8 -1
- package/src/providers/openai-completions.ts +14 -1
- package/src/providers/openai-responses.ts +11 -1
- package/src/providers/opencode-go-session.d.ts +5 -0
- package/src/providers/opencode-go-session.ts +57 -0
- package/src/stream.ts +1 -0
- package/src/types.d.ts +7 -0
- package/src/types.ts +7 -0
- package/src/utils/codex-entitlement.d.ts +22 -0
- package/src/utils/codex-entitlement.ts +57 -0
- package/src/utils/discovery/antigravity.ts +2 -1
- package/src/utils/discovery/gemini.ts +2 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model entitlement facts shared by Codex credential selection and provider
|
|
3
|
+
* error presentation.
|
|
4
|
+
*
|
|
5
|
+
* GPT-5.6 Sol is a Pro-tier ChatGPT Codex model. The usage endpoint is the
|
|
6
|
+
* authority for the account tier; this module only names the model policy and
|
|
7
|
+
* keeps the provider's deterministic rejection wording in one place.
|
|
8
|
+
*/
|
|
9
|
+
export type OpenAICodexProEntitlement = "entitled" | "denied" | "unknown";
|
|
10
|
+
/**
|
|
11
|
+
* Classify a ChatGPT `plan_type` for strict Pro-tier Codex models.
|
|
12
|
+
*
|
|
13
|
+
* The usage endpoint remains authoritative: only exact, documented tier names
|
|
14
|
+
* are classified. Known Free/Plus tiers can be rejected locally, while missing
|
|
15
|
+
* or unfamiliar values stay unknown and reach the provider instead of being
|
|
16
|
+
* guessed from a substring.
|
|
17
|
+
*/
|
|
18
|
+
export declare function classifyOpenAICodexProEntitlement(planType: string | undefined): OpenAICodexProEntitlement;
|
|
19
|
+
export declare function requiresOpenAICodexProModel(provider: string, modelId: string | undefined): boolean;
|
|
20
|
+
export declare function requiresStrictOpenAICodexProModel(provider: string, modelId: string | undefined): boolean;
|
|
21
|
+
export declare function isOpenAICodexChatGPTEntitlementError(message: string | undefined, code?: string): boolean;
|
|
22
|
+
export declare function formatOpenAICodexChatGPTEntitlementError(modelId: string | undefined): string;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model entitlement facts shared by Codex credential selection and provider
|
|
3
|
+
* error presentation.
|
|
4
|
+
*
|
|
5
|
+
* GPT-5.6 Sol is a Pro-tier ChatGPT Codex model. The usage endpoint is the
|
|
6
|
+
* authority for the account tier; this module only names the model policy and
|
|
7
|
+
* keeps the provider's deterministic rejection wording in one place.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const OPENAI_CODEX_PRO_ENTITLED_PLAN_TYPES = new Set(["pro", "business", "enterprise", "team"]);
|
|
11
|
+
const OPENAI_CODEX_PRO_DENIED_PLAN_TYPES = new Set(["free", "plus"]);
|
|
12
|
+
|
|
13
|
+
export type OpenAICodexProEntitlement = "entitled" | "denied" | "unknown";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Classify a ChatGPT `plan_type` for strict Pro-tier Codex models.
|
|
17
|
+
*
|
|
18
|
+
* The usage endpoint remains authoritative: only exact, documented tier names
|
|
19
|
+
* are classified. Known Free/Plus tiers can be rejected locally, while missing
|
|
20
|
+
* or unfamiliar values stay unknown and reach the provider instead of being
|
|
21
|
+
* guessed from a substring.
|
|
22
|
+
*/
|
|
23
|
+
export function classifyOpenAICodexProEntitlement(planType: string | undefined): OpenAICodexProEntitlement {
|
|
24
|
+
const normalized = planType?.trim().toLowerCase();
|
|
25
|
+
if (!normalized) return "unknown";
|
|
26
|
+
if (OPENAI_CODEX_PRO_ENTITLED_PLAN_TYPES.has(normalized)) return "entitled";
|
|
27
|
+
if (OPENAI_CODEX_PRO_DENIED_PLAN_TYPES.has(normalized)) return "denied";
|
|
28
|
+
return "unknown";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function requiresOpenAICodexProModel(provider: string, modelId: string | undefined): boolean {
|
|
32
|
+
return (
|
|
33
|
+
provider === "openai-codex" &&
|
|
34
|
+
typeof modelId === "string" &&
|
|
35
|
+
(modelId.toLowerCase().includes("-spark") || modelId.toLowerCase() === "gpt-5.6-sol")
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function requiresStrictOpenAICodexProModel(provider: string, modelId: string | undefined): boolean {
|
|
40
|
+
return provider === "openai-codex" && modelId?.toLowerCase() === "gpt-5.6-sol";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function isOpenAICodexChatGPTEntitlementError(message: string | undefined, code?: string): boolean {
|
|
44
|
+
return (
|
|
45
|
+
/\bnot supported when using codex with a chatgpt account\b/i.test(message ?? "") &&
|
|
46
|
+
(code === undefined || code.toLowerCase() === "invalid_request_error")
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function formatOpenAICodexChatGPTEntitlementError(modelId: string | undefined): string {
|
|
51
|
+
const safeModelId = modelId
|
|
52
|
+
?.replace(/[\x00-\x1f\x7f-\x9f]+/gu, " ")
|
|
53
|
+
.trim()
|
|
54
|
+
.slice(0, 128);
|
|
55
|
+
const model = safeModelId ? ` model "${safeModelId}"` : " model";
|
|
56
|
+
return `This ChatGPT Codex account cannot use${model}. Select a model available to this ChatGPT account, such as "gpt-5.5", or use an API-key credential that supports the model.`;
|
|
57
|
+
}
|
|
@@ -180,6 +180,7 @@ export async function fetchAntigravityDiscoveryModels(
|
|
|
180
180
|
options: FetchAntigravityDiscoveryModelsOptions,
|
|
181
181
|
): Promise<Model<"google-gemini-cli">[] | null> {
|
|
182
182
|
const fetcher = options.fetcher ?? fetch;
|
|
183
|
+
const signal = options.signal ?? AbortSignal.timeout(5_000);
|
|
183
184
|
const targetProvider = options.targetProvider ?? "google-antigravity";
|
|
184
185
|
const endpoints = options.endpoint
|
|
185
186
|
? [trimTrailingSlashes(options.endpoint)]
|
|
@@ -196,7 +197,7 @@ export async function fetchAntigravityDiscoveryModels(
|
|
|
196
197
|
"User-Agent": options.userAgent ?? getAntigravityUserAgent(),
|
|
197
198
|
},
|
|
198
199
|
body: JSON.stringify({}),
|
|
199
|
-
signal
|
|
200
|
+
signal,
|
|
200
201
|
});
|
|
201
202
|
} catch {
|
|
202
203
|
continue;
|
|
@@ -72,6 +72,7 @@ export async function fetchGeminiModels(
|
|
|
72
72
|
const baseUrl = normalizeBaseUrl(options.baseUrl);
|
|
73
73
|
const pageSize = normalizePositiveInt(options.pageSize, DEFAULT_PAGE_SIZE);
|
|
74
74
|
const maxPages = normalizePositiveInt(options.maxPages, DEFAULT_MAX_PAGES);
|
|
75
|
+
const signal = options.signal ?? AbortSignal.timeout(5_000);
|
|
75
76
|
|
|
76
77
|
const bundledById = new Map(
|
|
77
78
|
getBundledModels("google").map(model => [model.id, model as Model<"google-generative-ai">]),
|
|
@@ -86,7 +87,7 @@ export async function fetchGeminiModels(
|
|
|
86
87
|
try {
|
|
87
88
|
response = await fetchImpl(requestUrl, {
|
|
88
89
|
method: "GET",
|
|
89
|
-
signal
|
|
90
|
+
signal,
|
|
90
91
|
});
|
|
91
92
|
} catch {
|
|
92
93
|
return null;
|