@@ -35,6 +35,10 @@ const mocks = vi.hoisted(() => ({
3535 loadAuthProfileStoreForRuntime : vi . fn ( ( ) => ( { profiles : { } , order : { } } ) ) ,
3636 listProfilesForProvider : vi . fn ( ( ) => [ ] ) ,
3737 resolveApiKeyForProvider : vi . fn ( ) ,
38+ loadManifestMetadataSnapshot : vi . fn ( ( ) => ( { manifestRegistry : { plugins : [ ] } } ) ) ,
39+ planEffectiveModelCatalogRows : vi . fn <
40+ typeof import ( "../model-catalog/index.js" ) . planEffectiveModelCatalogRows
41+ > ( ( ) => ( { rows : [ ] , entries : [ ] , conflicts : [ ] } ) ) ,
3842 resolveAgentDir : vi . fn ( ( _cfg : unknown , agentId : string ) => `/tmp/agent-${ agentId } ` ) ,
3943 updateAuthProfileStoreWithLock : vi . fn (
4044 async ( { updater } : { updater : ( store : any ) => boolean } ) => {
@@ -233,6 +237,14 @@ vi.mock("../config/config.js", () => ({
233237 mocks . setRuntimeConfigSnapshot as typeof import ( "../config/config.js" ) . setRuntimeConfigSnapshot ,
234238} ) ) ;
235239
240+ vi . mock ( "../model-catalog/index.js" , ( ) => ( {
241+ planEffectiveModelCatalogRows : mocks . planEffectiveModelCatalogRows ,
242+ } ) ) ;
243+
244+ vi . mock ( "../plugins/manifest-contract-eligibility.js" , ( ) => ( {
245+ loadManifestMetadataSnapshot : mocks . loadManifestMetadataSnapshot ,
246+ } ) ) ;
247+
236248vi . mock ( "./command-config-resolution.js" , ( ) => ( {
237249 resolveCommandConfigWithSecrets : mocks . resolveCommandConfigWithSecrets ,
238250} ) ) ;
@@ -385,6 +397,9 @@ vi.mock("../tts/tts.js", () => ({
385397vi . mock ( "../tts/provider-registry.js" , ( ) => ( {
386398 canonicalizeSpeechProviderId : vi . fn ( ( provider : string ) => provider ) ,
387399 listSpeechProviders : vi . fn ( ( ) => [ ] ) ,
400+ normalizeSpeechProviderId : vi . fn (
401+ ( provider : string | undefined ) => provider ?. trim ( ) . toLowerCase ( ) || undefined ,
402+ ) ,
388403} ) ) ;
389404
390405vi . mock ( "../web-search/runtime.js" , ( ) => ( {
@@ -494,6 +509,12 @@ describe("capability cli", () => {
494509 mocks . loadAuthProfileStoreForRuntime . mockReset ( ) . mockReturnValue ( { profiles : { } , order : { } } ) ;
495510 mocks . listProfilesForProvider . mockReset ( ) . mockReturnValue ( [ ] ) ;
496511 mocks . resolveApiKeyForProvider . mockReset ( ) . mockRejectedValue ( new Error ( "no auth profile" ) ) ;
512+ mocks . loadManifestMetadataSnapshot
513+ . mockReset ( )
514+ . mockReturnValue ( { manifestRegistry : { plugins : [ ] } } ) ;
515+ mocks . planEffectiveModelCatalogRows
516+ . mockReset ( )
517+ . mockReturnValue ( { rows : [ ] , entries : [ ] , conflicts : [ ] } ) ;
497518 mocks . resolveAgentDir . mockClear ( ) ;
498519 mocks . resolveTtsConfig . mockReset ( ) . mockReturnValue ( { } ) ;
499520 mocks . getRuntimeConfigSourceSnapshot . mockReset ( ) . mockReturnValue ( null ) ;
@@ -752,6 +773,61 @@ describe("capability cli", () => {
752773 expect ( ids ) . toContain ( "image.describe" ) ;
753774 } ) ;
754775
776+ it . each ( [
777+ [ "list" , [ ] ] ,
778+ [ "inspect" , [ "--model" , "openai/gpt-5.4" ] ] ,
779+ [ "providers" , [ ] ] ,
780+ ] as const ) ( "keeps model %s catalog inspection read-only" , async ( command , args ) => {
781+ await runCap ( "capability" , "model" , command , ...args , "--json" ) ;
782+
783+ expect ( mocks . loadModelCatalog ) . toHaveBeenCalledWith ( {
784+ config : mocks . loadConfig ( ) ,
785+ readOnly : true ,
786+ } ) ;
787+ } ) ;
788+
789+ it ( "reports model providers configured through their environment key" , async ( ) => {
790+ vi . stubEnv ( "OPENAI_API_KEY" , "test-openai-key" ) ;
791+
792+ await runCap ( "capability" , "model" , "providers" , "--json" ) ;
793+
794+ const providers = firstJsonOutput ( ) as unknown as Array < {
795+ configured ?: boolean ;
796+ provider ?: string ;
797+ } > ;
798+ expect ( providers ) . toContainEqual (
799+ expect . objectContaining ( { provider : "openai" , configured : true } ) ,
800+ ) ;
801+ expect ( mocks . getProviderEnvVars ) . toHaveBeenCalledWith ( "openai" ) ;
802+ } ) ;
803+
804+ it ( "inspects runtime-declared manifest models without live discovery" , async ( ) => {
805+ mocks . loadModelCatalog . mockResolvedValueOnce ( [ ] as never ) ;
806+ mocks . planEffectiveModelCatalogRows . mockReturnValueOnce ( {
807+ rows : [
808+ {
809+ provider : "openai" ,
810+ id : "gpt-5.6-sol" ,
811+ name : "GPT-5.6 Sol" ,
812+ ref : "openai/gpt-5.6-sol" ,
813+ mergeKey : "openai/gpt-5.6-sol" ,
814+ source : "manifest" ,
815+ input : [ "text" ] ,
816+ reasoning : true ,
817+ status : "available" ,
818+ } ,
819+ ] ,
820+ entries : [ ] ,
821+ conflicts : [ ] ,
822+ } ) ;
823+
824+ await runCap ( "capability" , "model" , "inspect" , "--model" , "openai/gpt-5.6-sol" , "--json" ) ;
825+
826+ expect ( firstJsonOutput ( ) ) . toEqual (
827+ expect . objectContaining ( { provider : "openai" , id : "gpt-5.6-sol" } ) ,
828+ ) ;
829+ } ) ;
830+
755831 it ( "defaults model run to local transport" , async ( ) => {
756832 await runCap ( "capability" , "model" , "run" , "--prompt" , "hello" , "--json" ) ;
757833
@@ -2674,6 +2750,62 @@ describe("capability cli", () => {
26742750 expect ( firstTextToSpeechCall ( ) ?. disableFallback ) . toBe ( true ) ;
26752751 } ) ;
26762752
2753+ it ( "selects a TTS provider without inventing a model override" , async ( ) => {
2754+ await runCap (
2755+ "capability" ,
2756+ "tts" ,
2757+ "convert" ,
2758+ "--text" ,
2759+ "hello" ,
2760+ "--provider" ,
2761+ "xiaomi" ,
2762+ "--json" ,
2763+ ) ;
2764+
2765+ expect ( mocks . resolveExplicitTtsOverrides ) . toHaveBeenCalledWith (
2766+ expect . objectContaining ( { provider : "xiaomi" , modelId : undefined } ) ,
2767+ ) ;
2768+ expect ( firstTextToSpeechCall ( ) ?. disableFallback ) . toBe ( true ) ;
2769+ } ) ;
2770+
2771+ it ( "rejects conflicting TTS provider and model selections" , async ( ) => {
2772+ await expect (
2773+ runCap (
2774+ "capability" ,
2775+ "tts" ,
2776+ "convert" ,
2777+ "--text" ,
2778+ "hello" ,
2779+ "--provider" ,
2780+ "xiaomi" ,
2781+ "--model" ,
2782+ "openai/gpt-4o-mini-tts" ,
2783+ "--json" ,
2784+ ) ,
2785+ ) . rejects . toThrow ( "exit 1" ) ;
2786+
2787+ expectRuntimeErrorContains ( "TTS --provider must match the provider in --model." ) ;
2788+ } ) ;
2789+
2790+ it ( "accepts equivalent TTS provider casing with a model selection" , async ( ) => {
2791+ await runCap (
2792+ "capability" ,
2793+ "tts" ,
2794+ "convert" ,
2795+ "--text" ,
2796+ "hello" ,
2797+ "--provider" ,
2798+ "OpenAI" ,
2799+ "--model" ,
2800+ "openai/gpt-4o-mini-tts" ,
2801+ "--json" ,
2802+ ) ;
2803+
2804+ expect ( mocks . resolveExplicitTtsOverrides ) . toHaveBeenCalledWith (
2805+ expect . objectContaining ( { provider : "openai" , modelId : "gpt-4o-mini-tts" } ) ,
2806+ ) ;
2807+ } ) ;
2808+
26772809 it ( "does not infer and forward a local provider guess for gateway TTS overrides" , async ( ) => {
26782810 await runCap (
26792811 "capability" ,
0 commit comments