@@ -7,10 +7,8 @@ import { ChildProcessSpawner } from "effect/unstable/process";
77import {
88 checkClaudeProviderStatus ,
99 checkCodexProviderStatus ,
10- hasCustomModelProvider ,
1110 parseAuthStatusFromOutput ,
1211 parseClaudeAuthStatusFromOutput ,
13- readCodexConfigModelProvider ,
1412} from "./ProviderHealth" ;
1513
1614// ── Test helpers ────────────────────────────────────────────────────
@@ -237,53 +235,44 @@ it.layer(NodeServices.layer)("ProviderHealth", (it) => {
237235 ) ;
238236 } ) ;
239237
240- // ── Custom model provider: checkCodexProviderStatus integration ───
241-
242- describe ( "checkCodexProviderStatus with custom model provider" , ( ) => {
243- it . effect ( "skips auth probe and returns ready when a custom model provider is configured" , ( ) =>
244- Effect . gen ( function * ( ) {
245- yield * withTempCodexHome (
246- [
247- 'model_provider = "portkey"' ,
248- "" ,
249- "[model_providers.portkey]" ,
250- 'base_url = "https://api.portkey.ai/v1"' ,
251- 'env_key = "PORTKEY_API_KEY"' ,
252- ] . join ( "\n" ) ,
253- ) ;
254- const status = yield * checkCodexProviderStatus ;
255- assert . strictEqual ( status . provider , "codex" ) ;
256- assert . strictEqual ( status . status , "ready" ) ;
257- assert . strictEqual ( status . available , true ) ;
258- assert . strictEqual ( status . authStatus , "unknown" ) ;
259- assert . strictEqual (
260- status . message ,
261- "Using a custom Codex model provider; OpenAI login check skipped." ,
262- ) ;
263- } ) . pipe (
264- Effect . provide (
265- // The spawner only handles --version; if the test attempts
266- // "login status" the throw proves the auth probe was NOT skipped.
267- mockSpawnerLayer ( ( args ) => {
268- const joined = args . join ( " " ) ;
269- if ( joined === "--version" ) return { stdout : "codex 1.0.0\n" , stderr : "" , code : 0 } ;
270- throw new Error ( `Auth probe should have been skipped but got args: ${ joined } ` ) ;
271- } ) ,
238+ // ── Codex backend auth probing ────────────────────────────────────
239+
240+ describe ( "checkCodexProviderStatus backend auth probing" , ( ) => {
241+ const skippedBackends = [
242+ { id : "ollama" , label : "built-in ollama" } ,
243+ { id : "lmstudio" , label : "built-in lmstudio" } ,
244+ { id : "portkey" , label : "curated portkey" } ,
245+ { id : "azure" , label : "curated azure" } ,
246+ ] as const ;
247+
248+ for ( const backend of skippedBackends ) {
249+ it . effect ( `skips the OpenAI login probe for ${ backend . label } ` , ( ) =>
250+ Effect . gen ( function * ( ) {
251+ yield * withTempCodexHome ( `model_provider = "${ backend . id } "\n` ) ;
252+ const status = yield * checkCodexProviderStatus ;
253+ assert . strictEqual ( status . provider , "codex" ) ;
254+ assert . strictEqual ( status . status , "ready" ) ;
255+ assert . strictEqual ( status . available , true ) ;
256+ assert . strictEqual ( status . authStatus , "unknown" ) ;
257+ assert . strictEqual (
258+ status . message ,
259+ `Codex is configured to use backend '${ backend . id } '; OpenAI login check skipped.` ,
260+ ) ;
261+ } ) . pipe (
262+ Effect . provide (
263+ mockSpawnerLayer ( ( args ) => {
264+ const joined = args . join ( " " ) ;
265+ if ( joined === "--version" ) return { stdout : "codex 1.0.0\n" , stderr : "" , code : 0 } ;
266+ throw new Error ( `Auth probe should have been skipped but got args: ${ joined } ` ) ;
267+ } ) ,
268+ ) ,
272269 ) ,
273- ) ,
274- ) ;
270+ ) ;
271+ }
275272
276- it . effect ( "still reports error when codex CLI is missing even with custom provider " , ( ) =>
273+ it . effect ( "still reports error when codex CLI is missing even with a non-OpenAI backend " , ( ) =>
277274 Effect . gen ( function * ( ) {
278- yield * withTempCodexHome (
279- [
280- 'model_provider = "portkey"' ,
281- "" ,
282- "[model_providers.portkey]" ,
283- 'base_url = "https://api.portkey.ai/v1"' ,
284- 'env_key = "PORTKEY_API_KEY"' ,
285- ] . join ( "\n" ) ,
286- ) ;
275+ yield * withTempCodexHome ( 'model_provider = "portkey"\n' ) ;
287276 const status = yield * checkCodexProviderStatus ;
288277 assert . strictEqual ( status . status , "error" ) ;
289278 assert . strictEqual ( status . available , false ) ;
@@ -343,130 +332,6 @@ it.layer(NodeServices.layer)("ProviderHealth", (it) => {
343332 } ) ;
344333 } ) ;
345334
346- // ── readCodexConfigModelProvider tests ─────────────────────────────
347-
348- describe ( "readCodexConfigModelProvider" , ( ) => {
349- it . effect ( "returns undefined when config file does not exist" , ( ) =>
350- Effect . gen ( function * ( ) {
351- yield * withTempCodexHome ( ) ;
352- assert . strictEqual ( yield * readCodexConfigModelProvider , undefined ) ;
353- } ) ,
354- ) ;
355-
356- it . effect ( "returns undefined when config has no model_provider key" , ( ) =>
357- Effect . gen ( function * ( ) {
358- yield * withTempCodexHome ( 'model = "gpt-5-codex"\n' ) ;
359- assert . strictEqual ( yield * readCodexConfigModelProvider , undefined ) ;
360- } ) ,
361- ) ;
362-
363- it . effect ( "returns the provider when model_provider is set at top level" , ( ) =>
364- Effect . gen ( function * ( ) {
365- yield * withTempCodexHome ( 'model = "gpt-5-codex"\nmodel_provider = "portkey"\n' ) ;
366- assert . strictEqual ( yield * readCodexConfigModelProvider , "portkey" ) ;
367- } ) ,
368- ) ;
369-
370- it . effect ( "returns openai when model_provider is openai" , ( ) =>
371- Effect . gen ( function * ( ) {
372- yield * withTempCodexHome ( 'model_provider = "openai"\n' ) ;
373- assert . strictEqual ( yield * readCodexConfigModelProvider , "openai" ) ;
374- } ) ,
375- ) ;
376-
377- it . effect ( "ignores model_provider inside section headers" , ( ) =>
378- Effect . gen ( function * ( ) {
379- yield * withTempCodexHome (
380- [
381- 'model = "gpt-5-codex"' ,
382- "" ,
383- "[model_providers.portkey]" ,
384- 'base_url = "https://api.portkey.ai/v1"' ,
385- 'model_provider = "should-be-ignored"' ,
386- "" ,
387- ] . join ( "\n" ) ,
388- ) ;
389- assert . strictEqual ( yield * readCodexConfigModelProvider , undefined ) ;
390- } ) ,
391- ) ;
392-
393- it . effect ( "handles comments and whitespace" , ( ) =>
394- Effect . gen ( function * ( ) {
395- yield * withTempCodexHome (
396- [
397- "# This is a comment" ,
398- "" ,
399- ' model_provider = "azure" ' ,
400- "" ,
401- "[profiles.deep-review]" ,
402- 'model = "gpt-5-pro"' ,
403- ] . join ( "\n" ) ,
404- ) ;
405- assert . strictEqual ( yield * readCodexConfigModelProvider , "azure" ) ;
406- } ) ,
407- ) ;
408-
409- it . effect ( "handles single-quoted values in TOML" , ( ) =>
410- Effect . gen ( function * ( ) {
411- yield * withTempCodexHome ( "model_provider = 'mistral'\n" ) ;
412- assert . strictEqual ( yield * readCodexConfigModelProvider , "mistral" ) ;
413- } ) ,
414- ) ;
415- } ) ;
416-
417- // ── hasCustomModelProvider tests ───────────────────────────────────
418-
419- describe ( "hasCustomModelProvider" , ( ) => {
420- it . effect ( "returns false when no config file exists" , ( ) =>
421- Effect . gen ( function * ( ) {
422- yield * withTempCodexHome ( ) ;
423- assert . strictEqual ( yield * hasCustomModelProvider , false ) ;
424- } ) ,
425- ) ;
426-
427- it . effect ( "returns false when model_provider is not set" , ( ) =>
428- Effect . gen ( function * ( ) {
429- yield * withTempCodexHome ( 'model = "gpt-5-codex"\n' ) ;
430- assert . strictEqual ( yield * hasCustomModelProvider , false ) ;
431- } ) ,
432- ) ;
433-
434- it . effect ( "returns false when model_provider is openai" , ( ) =>
435- Effect . gen ( function * ( ) {
436- yield * withTempCodexHome ( 'model_provider = "openai"\n' ) ;
437- assert . strictEqual ( yield * hasCustomModelProvider , false ) ;
438- } ) ,
439- ) ;
440-
441- it . effect ( "returns true when model_provider is portkey" , ( ) =>
442- Effect . gen ( function * ( ) {
443- yield * withTempCodexHome ( 'model_provider = "portkey"\n' ) ;
444- assert . strictEqual ( yield * hasCustomModelProvider , true ) ;
445- } ) ,
446- ) ;
447-
448- it . effect ( "returns true when model_provider is azure" , ( ) =>
449- Effect . gen ( function * ( ) {
450- yield * withTempCodexHome ( 'model_provider = "azure"\n' ) ;
451- assert . strictEqual ( yield * hasCustomModelProvider , true ) ;
452- } ) ,
453- ) ;
454-
455- it . effect ( "returns true when model_provider is ollama" , ( ) =>
456- Effect . gen ( function * ( ) {
457- yield * withTempCodexHome ( 'model_provider = "ollama"\n' ) ;
458- assert . strictEqual ( yield * hasCustomModelProvider , true ) ;
459- } ) ,
460- ) ;
461-
462- it . effect ( "returns true when model_provider is a custom proxy" , ( ) =>
463- Effect . gen ( function * ( ) {
464- yield * withTempCodexHome ( 'model_provider = "my-company-proxy"\n' ) ;
465- assert . strictEqual ( yield * hasCustomModelProvider , true ) ;
466- } ) ,
467- ) ;
468- } ) ;
469-
470335 // ── checkClaudeProviderStatus tests ──────────────────────────
471336
472337 describe ( "checkClaudeProviderStatus" , ( ) => {
0 commit comments