@@ -15,6 +15,7 @@ import * as CodexErrors from "effect-codex-app-server/errors";
1515
1616import type {
1717 CodexSettings ,
18+ CustomModelSetting ,
1819 ServerProvider ,
1920 ServerProviderState ,
2021 ModelCapabilities ,
@@ -24,7 +25,7 @@ import type {
2425} from "@t3tools/contracts" ;
2526import { PREFERRED_DEFAULT_CODEX_MODELS , ServerSettingsError } from "@t3tools/contracts" ;
2627
27- import { createModelCapabilities } from "@t3tools/shared/model" ;
28+ import { createModelCapabilities , readCustomModelEntries } from "@t3tools/shared/model" ;
2829import { resolveSpawnCommand } from "@t3tools/shared/shell" ;
2930import { codexAppServerArgs , resolveCodexLaunchArgs } from "./codexLaunchArgs.ts" ;
3031import {
@@ -244,9 +245,14 @@ export function applyPreferredCodexDefaultModel(
244245 } ) ;
245246}
246247
248+ /**
249+ * Codex has no static default capability set, so a bare custom slug borrows
250+ * the first built-in's descriptors; an entry with its own capabilities keeps
251+ * them.
252+ */
247253function appendCustomCodexModels (
248254 models : ReadonlyArray < ServerProviderModel > ,
249- customModels : ReadonlyArray < string > ,
255+ customModels : ReadonlyArray < CustomModelSetting > ,
250256) : ReadonlyArray < ServerProviderModel > {
251257 if ( customModels . length === 0 ) {
252258 return models ;
@@ -255,17 +261,16 @@ function appendCustomCodexModels(
255261 const seen = new Set ( models . map ( ( model ) => model . slug ) ) ;
256262 const fallbackCapabilities = models . find ( ( model ) => model . capabilities ) ?. capabilities ?? null ;
257263 const customEntries : ServerProviderModel [ ] = [ ] ;
258- for ( const rawModel of customModels ) {
259- const slug = rawModel . trim ( ) ;
260- if ( ! slug || seen . has ( slug ) ) {
264+ for ( const entry of readCustomModelEntries ( customModels ) ) {
265+ if ( seen . has ( entry . slug ) ) {
261266 continue ;
262267 }
263- seen . add ( slug ) ;
268+ seen . add ( entry . slug ) ;
264269 customEntries . push ( {
265- slug,
266- name : slug ,
270+ slug : entry . slug ,
271+ name : entry . name ,
267272 isCustom : true ,
268- capabilities : fallbackCapabilities ,
273+ capabilities : entry . capabilities ?? fallbackCapabilities ,
269274 } ) ;
270275 }
271276 return customEntries . length === 0 ? models : [ ...models , ...customEntries ] ;
@@ -399,7 +404,7 @@ const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(fun
399404 readonly homePath ?: string ;
400405 readonly launchArgs ?: string ;
401406 readonly cwd : string ;
402- readonly customModels ?: ReadonlyArray < string > ;
407+ readonly customModels ?: ReadonlyArray < CustomModelSetting > ;
403408 readonly environment ?: NodeJS . ProcessEnv ;
404409} ) {
405410 const { client, initialize } = yield * withCodexAppServerClient ( input ) ;
@@ -470,21 +475,8 @@ export const probeCodexSkillsForCwd = Effect.fn("probeCodexSkillsForCwd")(functi
470475 return parseCodexSkillsListResponse ( skillsResponse , input . cwd ) ;
471476} ) ;
472477
473- const emptyCodexModelsFromSettings = ( codexSettings : CodexSettings ) : ServerProvider [ "models" ] => {
474- const models = new Set < string > ( ) ;
475- for ( const model of codexSettings . customModels ) {
476- const trimmed = model . trim ( ) ;
477- if ( trimmed . length > 0 ) {
478- models . add ( trimmed ) ;
479- }
480- }
481- return Array . from ( models , ( model ) => ( {
482- slug : model ,
483- name : model ,
484- isCustom : true ,
485- capabilities : null ,
486- } ) ) ;
487- } ;
478+ const emptyCodexModelsFromSettings = ( codexSettings : CodexSettings ) : ServerProvider [ "models" ] =>
479+ appendCustomCodexModels ( [ ] , codexSettings . customModels ) ;
488480
489481const makePendingCodexProvider = (
490482 codexSettings : CodexSettings ,
@@ -562,7 +554,7 @@ export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(fu
562554 readonly homePath ?: string ;
563555 readonly launchArgs ?: string ;
564556 readonly cwd : string ;
565- readonly customModels : ReadonlyArray < string > ;
557+ readonly customModels : ReadonlyArray < CustomModelSetting > ;
566558 readonly environment ?: NodeJS . ProcessEnv ;
567559 } ) => Effect . Effect <
568560 CodexAppServerProviderSnapshot ,
0 commit comments