@@ -50,12 +50,6 @@ function fixApiBase(base: string): string {
5050 return base . replace ( / \/ + $ / , '' ) ;
5151}
5252
53- export const ENV_KEY_MAPPER : Record < string , AgentUserConfigKey > = {
54- CHAT_MODEL : 'OPENAI_CHAT_MODEL' ,
55- API_KEY : 'OPENAI_API_KEY' ,
56- WORKERS_AI_MODEL : 'WORKERS_CHAT_MODEL' ,
57- } ;
58-
5953export type CustomMessageRender = ( mode : string | null , message : string ) => string ;
6054
6155class Environment extends EnvironmentConfig {
@@ -131,7 +125,6 @@ class Environment extends EnvironmentConfig {
131125 'API_GUARD' ,
132126 ] ) ;
133127 ConfigMerger . merge ( this . USER_CONFIG , source ) ;
134- this . migrateOldEnv ( source ) ;
135128 this . fixAgentUserConfigApiBase ( ) ;
136129 this . USER_CONFIG . DEFINE_KEYS = [ ] ;
137130 this . I18N = loadI18n ( this . LANGUAGE . toLowerCase ( ) ) ;
@@ -150,64 +143,6 @@ class Environment extends EnvironmentConfig {
150143 }
151144 }
152145
153- private migrateOldEnv ( source : any ) {
154- // 兼容旧版 TELEGRAM_TOKEN
155- if ( source . TELEGRAM_TOKEN && ! this . TELEGRAM_AVAILABLE_TOKENS . includes ( source . TELEGRAM_TOKEN ) ) {
156- if ( source . BOT_NAME && this . TELEGRAM_AVAILABLE_TOKENS . length === this . TELEGRAM_BOT_NAME . length ) {
157- this . TELEGRAM_BOT_NAME . push ( source . BOT_NAME ) ;
158- }
159- this . TELEGRAM_AVAILABLE_TOKENS . push ( source . TELEGRAM_TOKEN ) ;
160- }
161-
162- // 兼容旧版 OPENAI_API_DOMAIN
163- if ( source . OPENAI_API_DOMAIN && ! this . USER_CONFIG . OPENAI_API_BASE ) {
164- this . USER_CONFIG . OPENAI_API_BASE = `${ source . OPENAI_API_DOMAIN } /v1` ;
165- }
166-
167- // 兼容旧版 WORKERS_AI_MODEL
168- if ( source . WORKERS_AI_MODEL && ! this . USER_CONFIG . WORKERS_CHAT_MODEL ) {
169- this . USER_CONFIG . WORKERS_CHAT_MODEL = source . WORKERS_AI_MODEL ;
170- }
171-
172- // 兼容旧版API_KEY
173- if ( source . API_KEY && this . USER_CONFIG . OPENAI_API_KEY . length === 0 ) {
174- this . USER_CONFIG . OPENAI_API_KEY = source . API_KEY . split ( ',' ) ;
175- }
176-
177- // 兼容旧版CHAT_MODEL
178- if ( source . CHAT_MODEL && ! this . USER_CONFIG . OPENAI_CHAT_MODEL ) {
179- this . USER_CONFIG . OPENAI_CHAT_MODEL = source . CHAT_MODEL ;
180- }
181-
182- // 选择对应语言的SYSTEM_INIT_MESSAGE
183- // if (!this.USER_CONFIG.SYSTEM_INIT_MESSAGE) {
184- // this.USER_CONFIG.SYSTEM_INIT_MESSAGE = this.I18N?.env?.system_init_message || 'You are a helpful assistant';
185- // }
186- // 兼容旧版 GOOGLE_COMPLETIONS_API
187- if ( source . GOOGLE_COMPLETIONS_API && ! this . USER_CONFIG . GOOGLE_API_BASE ) {
188- this . USER_CONFIG . GOOGLE_API_BASE = source . GOOGLE_COMPLETIONS_API . replace ( / \/ m o d e l s \/ ? $ / , '' ) ;
189- }
190-
191- if ( source . GOOGLE_COMPLETIONS_MODEL && ! this . USER_CONFIG . GOOGLE_CHAT_MODEL ) {
192- this . USER_CONFIG . GOOGLE_CHAT_MODEL = source . GOOGLE_COMPLETIONS_MODEL ;
193- }
194-
195- // 兼容旧版 AZURE_COMPLETIONS_API
196- if ( source . AZURE_COMPLETIONS_API && ! this . USER_CONFIG . AZURE_CHAT_MODEL ) {
197- const url = new URL ( source . AZURE_COMPLETIONS_API ) ;
198- this . USER_CONFIG . AZURE_RESOURCE_NAME = url . hostname . split ( '.' ) . at ( 0 ) || null ;
199- this . USER_CONFIG . AZURE_CHAT_MODEL = url . pathname . split ( '/' ) . at ( 3 ) || 'gpt-5-mini' ;
200- this . USER_CONFIG . AZURE_API_VERSION = url . searchParams . get ( 'api-version' ) || '2024-06-01' ;
201- }
202- // 兼容旧版 AZURE_DALLE_API
203- if ( source . AZURE_DALLE_API && ! this . USER_CONFIG . AZURE_IMAGE_MODEL ) {
204- const url = new URL ( source . AZURE_DALLE_API ) ;
205- this . USER_CONFIG . AZURE_RESOURCE_NAME = url . hostname . split ( '.' ) . at ( 0 ) || null ;
206- this . USER_CONFIG . AZURE_IMAGE_MODEL = url . pathname . split ( '/' ) . at ( 3 ) || 'dall-e-3' ;
207- this . USER_CONFIG . AZURE_API_VERSION = url . searchParams . get ( 'api-version' ) || '2024-06-01' ;
208- }
209- }
210-
211146 private fixAgentUserConfigApiBase ( ) {
212147 const keys : AgentUserConfigKey [ ] = [
213148 'OPENAI_API_BASE' ,
0 commit comments