mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-08 00:02:20 +03:00
fix(codex): accept auth.json without auth_mode field on import (#2536)
Integrated into release/v3.8.2
This commit is contained in:
@@ -88,9 +88,11 @@ export interface CreateConnectionOptions {
|
||||
export function parseAndValidateCodexAuth(raw: unknown): ParsedCodexAuth {
|
||||
const doc = toRecord(raw);
|
||||
|
||||
if (doc.auth_mode !== "chatgpt") {
|
||||
// Codex CLI no longer writes auth_mode in auth.json (only OmniRoute's own export
|
||||
// includes it). Accept both formats as long as the required tokens are present.
|
||||
if (doc.auth_mode !== undefined && doc.auth_mode !== null && doc.auth_mode !== "chatgpt") {
|
||||
throw new CodexAuthFileError(
|
||||
'Not a Codex auth.json — expected auth_mode: "chatgpt"',
|
||||
'Not a Codex auth.json — unexpected auth_mode value',
|
||||
400,
|
||||
"invalid_auth_file"
|
||||
);
|
||||
|
||||
@@ -393,30 +393,17 @@ export function getCacheStats() {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a request is cacheable for read (pre-request lookup).
|
||||
* Only non-streaming, deterministic (temperature=0) requests.
|
||||
* @deprecated Use isCacheableForRead instead.
|
||||
*/
|
||||
export function isCacheable(body, headers) {
|
||||
if ((getHeaderValue(headers, "x-omniroute-no-cache") || "").toLowerCase() === "true") {
|
||||
return false;
|
||||
}
|
||||
if (body.stream !== false) return false;
|
||||
if ((body.temperature ?? 0) !== 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a cached response can be served for this request.
|
||||
* Works for both streaming and non-streaming requests (cache hit returns JSON).
|
||||
* Omitted temperature defaults to 0 for read (matching existing cache entries).
|
||||
* Requires explicit numeric `temperature: 0` — omitted temperature is NOT cached
|
||||
* because the provider default may be non-deterministic (e.g. random/creative tasks).
|
||||
*/
|
||||
export function isCacheableForRead(body, headers) {
|
||||
if ((getHeaderValue(headers, "x-omniroute-no-cache") || "").toLowerCase() === "true") {
|
||||
return false;
|
||||
}
|
||||
if ((body.temperature ?? 0) !== 0) return false;
|
||||
if (typeof body.temperature !== "number" || body.temperature !== 0) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user