({
env,
defaultProviderProfileId,
}: {
env: NodeJS.ProcessEnv;
defaultProviderProfileId: string | null;
})
| 1000 | } |
| 1001 | |
| 1002 | function resolveEmbeddedCodexNativeApiOptions({ |
| 1003 | env, |
| 1004 | defaultProviderProfileId, |
| 1005 | }: { |
| 1006 | env: NodeJS.ProcessEnv; |
| 1007 | defaultProviderProfileId: string | null; |
| 1008 | }): EmbeddedCodexNativeApiOptions { |
| 1009 | const enabled = parseBooleanEnv(env.CODEX_NATIVE_API_ENABLE, true); |
| 1010 | const host = normalizeCliString(env.CODEX_NATIVE_API_HOST) ?? DEFAULT_CODEX_NATIVE_API_HOST; |
| 1011 | const port = parseOptionalNonNegativeInt(env.CODEX_NATIVE_API_PORT) ?? DEFAULT_CODEX_NATIVE_API_PORT; |
| 1012 | const preferredCodexProviderProfileId = defaultProviderProfileId === 'openai-default' |
| 1013 | ? defaultProviderProfileId |
| 1014 | : null; |
| 1015 | const providerProfileId = preferredCodexProviderProfileId |
| 1016 | ?? 'openai-default'; |
| 1017 | return { |
| 1018 | enabled, |
| 1019 | host, |
| 1020 | port, |
| 1021 | providerProfileId, |
| 1022 | authToken: normalizeCliString(env.CODEX_NATIVE_API_AUTH_TOKEN), |
| 1023 | defaultModel: normalizeCliString(env.CODEX_NATIVE_API_DEFAULT_MODEL), |
| 1024 | requestTitlePrefix: normalizeCliString(env.CODEX_NATIVE_API_TITLE_PREFIX), |
| 1025 | }; |
| 1026 | } |
| 1027 | |
| 1028 | function parseOptionalNonNegativeInt(value: unknown): number | null { |
| 1029 | const parsed = Number.parseInt(String(value ?? ''), 10); |
no test coverage detected