@@ -3,6 +3,7 @@ import { readBundledWebUiScript, readProjectFile } from './helpers/web-ui-source
33
44const appSource = readBundledWebUiScript ( ) ;
55const claudeConfigModuleSource = readProjectFile ( 'web-ui/modules/app.methods.claude-config.mjs' ) ;
6+ const cliSource = readProjectFile ( 'cli.js' ) ;
67
78function escapeRegExp ( value ) {
89 return String ( value || '' ) . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) ;
@@ -1116,3 +1117,27 @@ test('loadClaudeModels skips remote fetch for external-credential config without
11161117 assert . strictEqual ( context . claudeModelsHasCurrent , true ) ;
11171118 assert . deepStrictEqual ( messages , [ ] ) ;
11181119} ) ;
1120+
1121+ test ( 'applyToClaudeSettings does not proxy chat completions through default Anthropic URL' , ( ) => {
1122+ const startIndex = cliSource . indexOf ( 'async function applyToClaudeSettings' ) ;
1123+ assert . notStrictEqual ( startIndex , - 1 ) ;
1124+ const endIndex = cliSource . indexOf ( 'async function cmdClaude' , startIndex ) ;
1125+ assert . notStrictEqual ( endIndex , - 1 ) ;
1126+ const source = cliSource . slice ( startIndex , endIndex ) ;
1127+ assert . match ( source , / c o n s t c o n f i g u r e d B a s e U r l = t y p e o f c o n f i g \. b a s e U r l = = = ' s t r i n g ' \? c o n f i g \. b a s e U r l \. t r i m \( \) : ' ' ; / ) ;
1128+ assert . match ( source , / t a r g e t A p i = = = ' c h a t _ c o m p l e t i o n s ' & & ! c o n f i g u r e d B a s e U r l & & ! u p s t r e a m P r o v i d e r N a m e / ) ;
1129+ assert . match ( source , / c h a t _ c o m p l e t i o n s 模 式 需 要 显 式 的 上 游 B a s e U R L 或 可 解 析 的 p r o v i d e r 名 称 / ) ;
1130+ assert . match ( source , / \. \. \. \( c o n f i g u r e d B a s e U r l \? \{ u p s t r e a m B a s e U r l : c o n f i g u r e d B a s e U r l \} : \{ \} \) / ) ;
1131+ } ) ;
1132+
1133+ test ( 'MCP Claude config schema allows Ollama without API key only for ollama target' , ( ) => {
1134+ const toolIndex = cliSource . indexOf ( "name: 'codexmate.claude.config.apply'" ) ;
1135+ assert . notStrictEqual ( toolIndex , - 1 ) ;
1136+ const schemaEnd = cliSource . indexOf ( 'handler: async (args = {}) => applyToClaudeSettings(args || {})' , toolIndex ) ;
1137+ assert . notStrictEqual ( schemaEnd , - 1 ) ;
1138+ const schemaSource = cliSource . slice ( toolIndex , schemaEnd ) ;
1139+ assert . match ( schemaSource , / a l l O f : \s * \[ \{ / ) ;
1140+ assert . match ( schemaSource , / p r o p e r t i e s : \s * \{ t a r g e t A p i : \s * \{ c o n s t : ' o l l a m a ' \} \} / ) ;
1141+ assert . match ( schemaSource , / t h e n : \s * \{ r e q u i r e d : \s * \[ ' a p i K e y ' \] \} / ) ;
1142+ assert . doesNotMatch ( schemaSource , / r e q u i r e d : \s * \[ ' a p i K e y ' \] , \s * a d d i t i o n a l P r o p e r t i e s / ) ;
1143+ } ) ;
0 commit comments