@@ -119,6 +119,16 @@ const store = {
119119 services : { } as Record < string , Service >
120120}
121121
122+ /**
123+ * Gets the access key ID and secret key from environment variables.
124+ */
125+ function aksk ( ) {
126+ return {
127+ ak : process . env . VOLCENGINE_ACCESS_KEY ?? process . env . VOLC_ACCESS_KEY_ID ,
128+ sk : process . env . VOLCENGINE_SECRET_KEY ?? process . env . VOLC_ACCESS_KEY_SECRET ,
129+ }
130+ }
131+
122132/**
123133 * Generates the tool result by text.
124134 * @param value The input text to convert.
@@ -180,9 +190,10 @@ export function registerService(key: string | undefined, service: Service | Serv
180190 }
181191
182192 const obj = new Service ( service ) ;
183- if ( process . env . VOLC_ACCESS_KEY_ID && process . env . VOLC_ACCESS_KEY_SECRET ) {
184- obj . setAccessKeyId ( process . env . VOLC_ACCESS_KEY_ID ) ;
185- obj . setSecretKey ( process . env . VOLC_ACCESS_KEY_SECRET ) ;
193+ const { ak, sk } = aksk ( ) ;
194+ if ( ak && sk ) {
195+ obj . setAccessKeyId ( ak ) ;
196+ obj . setSecretKey ( sk ) ;
186197 }
187198
188199 store . services [ key ] = obj ;
@@ -194,13 +205,14 @@ export function registerService(key: string | undefined, service: Service | Serv
194205 * Update credential of each service.
195206 */
196207export function batchUpdateAccessKey ( ) {
197- if ( ! process . env . VOLC_ACCESS_KEY_ID || ! process . env . VOLC_ACCESS_KEY_SECRET ) return ;
208+ const { ak, sk } = aksk ( ) ;
209+ if ( ! ak || ! sk ) return ;
198210 for ( const key in store . services ) {
199211 if ( typeof key !== 'string' ) continue ;
200212 const service = store . services [ key ] ;
201213 if ( service instanceof Service ) {
202- service . setAccessKeyId ( process . env . VOLC_ACCESS_KEY_ID ) ;
203- service . setSecretKey ( process . env . VOLC_ACCESS_KEY_SECRET ) ;
214+ service . setAccessKeyId ( ak ) ;
215+ service . setSecretKey ( sk ) ;
204216 }
205217 }
206218}
0 commit comments