From 6e1da30ed71362d5deb61d8fcb3e48d03c8b7b7e Mon Sep 17 00:00:00 2001 From: tbxark Date: Wed, 28 Aug 2024 15:21:21 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20USER=5FCONFIG=E4=BF=9D=E5=AD=98KV?= =?UTF-8?q?=E5=89=8D=E8=A3=81=E5=89=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/buildinfo.json | 2 +- dist/index.js | 12 ++++++------ dist/timestamp | 2 +- src/telegram/command/system.ts | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/dist/buildinfo.json b/dist/buildinfo.json index b094dbd7..0ecf6f03 100644 --- a/dist/buildinfo.json +++ b/dist/buildinfo.json @@ -1 +1 @@ -{"sha":"839f57f","timestamp":1724829364} \ No newline at end of file +{"sha":"ef4e54b","timestamp":1724829578} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 02398a8b..cbdcb083 100644 --- a/dist/index.js +++ b/dist/index.js @@ -212,8 +212,8 @@ const ENV_KEY_MAPPER = { WORKERS_AI_MODEL: "WORKERS_CHAT_MODEL" }; class Environment extends EnvironmentConfig { - BUILD_TIMESTAMP = 1724829364 ; - BUILD_VERSION = "839f57f" ; + BUILD_TIMESTAMP = 1724829578 ; + BUILD_VERSION = "ef4e54b" ; I18N = loadI18n(); PLUGINS_ENV = {}; USER_CONFIG = createAgentUserConfig(); @@ -2063,7 +2063,7 @@ class SetEnvCommandHandler { console.log("Update user config: ", key, context.USER_CONFIG[key]); await ENV.DATABASE.put( context.SHARE_CONTEXT.configStoreKey, - JSON.stringify(context.USER_CONFIG) + JSON.stringify(ConfigMerger.trim(context.USER_CONFIG, ENV.LOCK_USER_CONFIG_KEYS)) ); return sender.sendPlainText("Update user config success"); } catch (e) { @@ -2097,7 +2097,7 @@ class SetEnvsCommandHandler { context.USER_CONFIG.DEFINE_KEYS = Array.from(new Set(context.USER_CONFIG.DEFINE_KEYS)); await ENV.DATABASE.put( context.SHARE_CONTEXT.configStoreKey, - JSON.stringify(context.USER_CONFIG) + JSON.stringify(ConfigMerger.trim(context.USER_CONFIG, ENV.LOCK_USER_CONFIG_KEYS)) ); return sender.sendPlainText("Update user config success"); } catch (e) { @@ -2119,7 +2119,7 @@ class DelEnvCommandHandler { context.USER_CONFIG.DEFINE_KEYS = context.USER_CONFIG.DEFINE_KEYS.filter((key) => key !== subcommand); await ENV.DATABASE.put( context.SHARE_CONTEXT.configStoreKey, - JSON.stringify(context.USER_CONFIG) + JSON.stringify(ConfigMerger.trim(context.USER_CONFIG, ENV.LOCK_USER_CONFIG_KEYS)) ); return sender.sendPlainText("Delete user config success"); } catch (e) { @@ -2199,7 +2199,7 @@ class SystemCommandHandler { context.USER_CONFIG.MISTRAL_API_KEY = "******"; context.USER_CONFIG.COHERE_API_KEY = "******"; context.USER_CONFIG.ANTHROPIC_API_KEY = "******"; - const config = context.USER_CONFIG; + const config = ConfigMerger.trim(context.USER_CONFIG, ENV.LOCK_USER_CONFIG_KEYS); msg = `
 ${msg}`;
       msg += `USER_CONFIG: ${JSON.stringify(config, null, 2)}
diff --git a/dist/timestamp b/dist/timestamp
index 362f97a6..2d3f5c29 100644
--- a/dist/timestamp
+++ b/dist/timestamp
@@ -1 +1 @@
-1724829364
\ No newline at end of file
+1724829578
\ No newline at end of file
diff --git a/src/telegram/command/system.ts b/src/telegram/command/system.ts
index e735d591..464d9d53 100644
--- a/src/telegram/command/system.ts
+++ b/src/telegram/command/system.ts
@@ -152,7 +152,7 @@ export class SetEnvCommandHandler implements CommandHandler {
             console.log('Update user config: ', key, context.USER_CONFIG[key]);
             await ENV.DATABASE.put(
                 context.SHARE_CONTEXT.configStoreKey,
-                JSON.stringify(context.USER_CONFIG),
+                JSON.stringify(ConfigMerger.trim(context.USER_CONFIG, ENV.LOCK_USER_CONFIG_KEYS)),
             );
             return sender.sendPlainText('Update user config success');
         } catch (e) {
@@ -187,7 +187,7 @@ export class SetEnvsCommandHandler implements CommandHandler {
             context.USER_CONFIG.DEFINE_KEYS = Array.from(new Set(context.USER_CONFIG.DEFINE_KEYS));
             await ENV.DATABASE.put(
                 context.SHARE_CONTEXT.configStoreKey,
-                JSON.stringify(context.USER_CONFIG),
+                JSON.stringify(ConfigMerger.trim(context.USER_CONFIG, ENV.LOCK_USER_CONFIG_KEYS)),
             );
             return sender.sendPlainText('Update user config success');
         } catch (e) {
@@ -210,7 +210,7 @@ export class DelEnvCommandHandler implements CommandHandler {
             context.USER_CONFIG.DEFINE_KEYS = context.USER_CONFIG.DEFINE_KEYS.filter(key => key !== subcommand);
             await ENV.DATABASE.put(
                 context.SHARE_CONTEXT.configStoreKey,
-                JSON.stringify(context.USER_CONFIG),
+                JSON.stringify(ConfigMerger.trim(context.USER_CONFIG, ENV.LOCK_USER_CONFIG_KEYS)),
             );
             return sender.sendPlainText('Delete user config success');
         } catch (e) {
@@ -292,7 +292,7 @@ export class SystemCommandHandler implements CommandHandler {
             context.USER_CONFIG.MISTRAL_API_KEY = '******';
             context.USER_CONFIG.COHERE_API_KEY = '******';
             context.USER_CONFIG.ANTHROPIC_API_KEY = '******';
-            const config = context.USER_CONFIG;
+            const config = ConfigMerger.trim(context.USER_CONFIG, ENV.LOCK_USER_CONFIG_KEYS);
             msg = `
\n${msg}`;
             msg += `USER_CONFIG: ${JSON.stringify(config, null, 2)}\n`;
             msg += `CHAT_CONTEXT: ${JSON.stringify(sender.context || {}, null, 2)}\n`;