()
| 43 | } |
| 44 | |
| 45 | export function readCodexAccessToken(): string | undefined { |
| 46 | const explicit = process.env.ELECTRIC_CODEX_ACCESS_TOKEN?.trim() |
| 47 | if (explicit) return explicit |
| 48 | if (process.env.ELECTRIC_CODEX_REQUIRE_OPT_IN === `1`) return undefined |
| 49 | try { |
| 50 | const raw = readFileSync(codexAuthPath(), `utf-8`) |
| 51 | const data = JSON.parse(raw) as { |
| 52 | auth_mode?: string |
| 53 | tokens?: { access_token?: string } |
| 54 | } |
| 55 | if (data.auth_mode !== `chatgpt`) return undefined |
| 56 | return data.tokens?.access_token?.trim() || undefined |
| 57 | } catch { |
| 58 | return undefined |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | export type AvailableProvider = |
| 63 | | `anthropic` |
no test coverage detected