thepopebot 1.2.78-beta.2 → 1.2.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -95,6 +95,10 @@ the agent already knows what you were just talking about.
95
95
 
96
96
  ## Install
97
97
 
98
+ Prefer to follow along on video? 👇
99
+
100
+ > ### 📺 <a href="https://youtu.be/xmxEEAXFtm8" target="_blank" rel="noopener"><strong>Install Video (click here)</strong></a>
101
+
98
102
  ### Prerequisites
99
103
 
100
104
  | Requirement | Install |
package/api/index.js CHANGED
@@ -16,15 +16,8 @@ import { setAgentJobSecret } from '../lib/db/config.js';
16
16
  // ── Per-key lock for OAuth token refresh ────────────────────────────
17
17
  const _refreshLocks = new Map();
18
18
 
19
- // Bot token — resolved from DB/env
20
- let telegramBotToken = null;
21
-
22
-
23
19
  function getTelegramBotToken() {
24
- if (!telegramBotToken) {
25
- telegramBotToken = getConfig('TELEGRAM_BOT_TOKEN') || null;
26
- }
27
- return telegramBotToken;
20
+ return getConfig('TELEGRAM_BOT_TOKEN') || null;
28
21
  }
29
22
 
30
23
 
@@ -287,9 +287,7 @@ export async function createOAuthToken(tokenType, name, token) {
287
287
  const user = await requireAdmin();
288
288
  try {
289
289
  const { createOAuthToken: dbCreate } = await import('../db/oauth-tokens.js');
290
- const { invalidateConfigCache } = await import('../config.js');
291
290
  const result = dbCreate(tokenType, name || 'OAuth Token', token, user.id);
292
- invalidateConfigCache();
293
291
  return result;
294
292
  } catch (err) {
295
293
  console.error('Failed to create OAuth token:', err);
@@ -322,9 +320,7 @@ export async function deleteOAuthToken(id) {
322
320
  await requireAdmin();
323
321
  try {
324
322
  const { deleteOAuthTokenById } = await import('../db/oauth-tokens.js');
325
- const { invalidateConfigCache } = await import('../config.js');
326
323
  deleteOAuthTokenById(id);
327
- invalidateConfigCache();
328
324
  return { success: true };
329
325
  } catch (err) {
330
326
  console.error('Failed to delete OAuth token:', err);
@@ -793,7 +789,6 @@ export async function updateCodingAgentConfig(agent, config) {
793
789
  await requireAdmin();
794
790
  try {
795
791
  const { setConfigValue } = await import('../db/config.js');
796
- const { invalidateConfigCache } = await import('../config.js');
797
792
 
798
793
  if (agent === 'claude-code') {
799
794
  if (config.enabled !== undefined) setConfigValue('CODING_AGENT_CLAUDE_CODE_ENABLED', String(config.enabled));
@@ -823,7 +818,6 @@ export async function updateCodingAgentConfig(agent, config) {
823
818
  return { error: 'Invalid agent' };
824
819
  }
825
820
 
826
- invalidateConfigCache();
827
821
  if (agent === 'claude-code' && config.backend !== undefined) {
828
822
  await syncLitellmConfig();
829
823
  }
@@ -842,9 +836,7 @@ export async function setCodingAgentDefault(agent) {
842
836
  await requireAdmin();
843
837
  try {
844
838
  const { setConfigValue } = await import('../db/config.js');
845
- const { invalidateConfigCache } = await import('../config.js');
846
839
  setConfigValue('CODING_AGENT', agent);
847
- invalidateConfigCache();
848
840
  return { success: true };
849
841
  } catch (err) {
850
842
  console.error('Failed to set default coding agent:', err);
@@ -893,9 +885,7 @@ export async function setModeDefault(mode, field, value) {
893
885
  const stored = field === 'autoRun' ? (value ? 'true' : 'false') : value;
894
886
 
895
887
  const { setConfigValue } = await import('../db/config.js');
896
- const { invalidateConfigCache } = await import('../config.js');
897
888
  setConfigValue(key, stored);
898
- invalidateConfigCache();
899
889
  return { success: true };
900
890
  } catch (err) {
901
891
  console.error('Failed to set mode default:', err);
@@ -937,9 +927,7 @@ export async function updateGeneralSetting(key, value) {
937
927
  }
938
928
  try {
939
929
  const { setConfigValue } = await import('../db/config.js');
940
- const { invalidateConfigCache } = await import('../config.js');
941
930
  setConfigValue(key, value);
942
- invalidateConfigCache();
943
931
  return { success: true };
944
932
  } catch (err) {
945
933
  console.error('Failed to update general setting:', err);
@@ -985,7 +973,6 @@ export async function updateApiKeySetting(key, value) {
985
973
  }
986
974
  try {
987
975
  const { setConfigSecret, deleteConfigSecret } = await import('../db/config.js');
988
- const { invalidateConfigCache } = await import('../config.js');
989
976
 
990
977
  if (value) {
991
978
  setConfigSecret(key, value, user.id);
@@ -993,7 +980,6 @@ export async function updateApiKeySetting(key, value) {
993
980
  deleteConfigSecret(key);
994
981
  }
995
982
 
996
- invalidateConfigCache();
997
983
  return { success: true };
998
984
  } catch (err) {
999
985
  console.error('Failed to update API key setting:', err);
@@ -1013,9 +999,7 @@ export async function regenerateWebhookSecret(key) {
1013
999
  const { randomBytes } = await import('crypto');
1014
1000
  const secret = randomBytes(32).toString('hex');
1015
1001
  const { setConfigSecret } = await import('../db/config.js');
1016
- const { invalidateConfigCache } = await import('../config.js');
1017
1002
  setConfigSecret(key, secret, user.id);
1018
- invalidateConfigCache();
1019
1003
  return { success: true };
1020
1004
  } catch (err) {
1021
1005
  console.error('Failed to regenerate webhook secret:', err);
@@ -1100,7 +1084,7 @@ export async function registerTelegramWebhook() {
1100
1084
  const user = await requireAdmin();
1101
1085
  try {
1102
1086
  const { getConfigSecret, setConfigSecret } = await import('../db/config.js');
1103
- const { invalidateConfigCache, getConfig } = await import('../config.js');
1087
+ const { getConfig } = await import('../config.js');
1104
1088
  const { setTelegramWebhook, generateWebhookSecret } = await import('../tools/telegram.js');
1105
1089
 
1106
1090
  const botToken = getConfigSecret('TELEGRAM_BOT_TOKEN');
@@ -1112,7 +1096,6 @@ export async function registerTelegramWebhook() {
1112
1096
  const webhookUrl = `${appUrl.replace(/\/$/, '')}/api/telegram/webhook`;
1113
1097
  const secret = generateWebhookSecret();
1114
1098
  setConfigSecret('TELEGRAM_WEBHOOK_SECRET', secret, user.id);
1115
- invalidateConfigCache();
1116
1099
 
1117
1100
  const result = await setTelegramWebhook(botToken, webhookUrl, secret);
1118
1101
  if (!result.ok) {
@@ -1180,13 +1163,11 @@ export async function updateProviderCredential(credentialKey, value) {
1180
1163
  return { error: 'Invalid credential key' };
1181
1164
  }
1182
1165
  const { setConfigSecret, deleteConfigSecret } = await import('../db/config.js');
1183
- const { invalidateConfigCache } = await import('../config.js');
1184
1166
  if (value) {
1185
1167
  setConfigSecret(credentialKey, value, user.id);
1186
1168
  } else {
1187
1169
  deleteConfigSecret(credentialKey);
1188
1170
  }
1189
- invalidateConfigCache();
1190
1171
  await syncLitellmConfig();
1191
1172
  return { success: true };
1192
1173
  } catch (err) {
@@ -1257,11 +1238,9 @@ export async function addCustomProvider(config) {
1257
1238
  const user = await requireAdmin();
1258
1239
  try {
1259
1240
  const { setCustomProvider } = await import('../db/config.js');
1260
- const { invalidateConfigCache } = await import('../config.js');
1261
1241
  // Generate slug from name
1262
1242
  const slug = config.name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
1263
1243
  setCustomProvider(slug, config, user.id);
1264
- invalidateConfigCache();
1265
1244
  await syncLitellmConfig();
1266
1245
  return { success: true, key: slug };
1267
1246
  } catch (err) {
@@ -1277,9 +1256,7 @@ export async function updateCustomProvider(key, config) {
1277
1256
  const user = await requireAdmin();
1278
1257
  try {
1279
1258
  const { setCustomProvider } = await import('../db/config.js');
1280
- const { invalidateConfigCache } = await import('../config.js');
1281
1259
  setCustomProvider(key, config, user.id);
1282
- invalidateConfigCache();
1283
1260
  await syncLitellmConfig();
1284
1261
  return { success: true };
1285
1262
  } catch (err) {
@@ -1295,9 +1272,7 @@ export async function removeCustomProvider(key) {
1295
1272
  const user = await requireAdmin();
1296
1273
  try {
1297
1274
  const { deleteCustomProvider } = await import('../db/config.js');
1298
- const { invalidateConfigCache } = await import('../config.js');
1299
1275
  deleteCustomProvider(key);
1300
- invalidateConfigCache();
1301
1276
  await syncLitellmConfig();
1302
1277
  return { success: true };
1303
1278
  } catch (err) {
@@ -1313,11 +1288,9 @@ export async function setActiveLlm(provider, model, maxTokens) {
1313
1288
  const user = await requireAdmin();
1314
1289
  try {
1315
1290
  const { setConfigValue } = await import('../db/config.js');
1316
- const { invalidateConfigCache } = await import('../config.js');
1317
1291
  setConfigValue('LLM_PROVIDER', provider, user.id);
1318
1292
  setConfigValue('LLM_MODEL', model, user.id);
1319
1293
  if (maxTokens) setConfigValue('LLM_MAX_TOKENS', maxTokens, user.id);
1320
- invalidateConfigCache();
1321
1294
  return { success: true };
1322
1295
  } catch (err) {
1323
1296
  console.error('Failed to set active LLM:', err);
package/lib/config.js CHANGED
@@ -87,23 +87,12 @@ const DEFAULTS = {
87
87
  CODE_MODE_AUTO_RUN: 'false',
88
88
  };
89
89
 
90
- // In-memory cache on globalThis to survive Next.js webpack chunk duplication.
91
- // Server actions and route handlers may be bundled into separate chunks, each
92
- // with their own copy of module-level variables. globalThis is shared across all chunks.
93
- const _cache = (globalThis.__popebotConfigCache ??= new Map());
94
-
95
90
  /**
96
91
  * Get a config value. Resolution: DB → default.
97
92
  * @param {string} key
98
93
  * @returns {string|undefined}
99
94
  */
100
95
  export function getConfig(key) {
101
- // Check cache first
102
- const cached = _cache.get(key);
103
- if (cached) {
104
- return cached.value;
105
- }
106
-
107
96
  let value;
108
97
 
109
98
  // OAuth tokens: multi-token support with LRU rotation
@@ -154,14 +143,5 @@ export function getConfig(key) {
154
143
  value = getDefaultModel(provider);
155
144
  }
156
145
 
157
- // Cache and return
158
- _cache.set(key, { value });
159
146
  return value;
160
147
  }
161
-
162
- /**
163
- * Invalidate the config cache. Call after any config write.
164
- */
165
- export function invalidateConfigCache() {
166
- _cache.clear();
167
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thepopebot",
3
- "version": "1.2.78-beta.2",
3
+ "version": "1.2.81",
4
4
  "type": "module",
5
5
  "description": "Create autonomous AI agents with a two-layer architecture: Next.js Event Handler + Docker Agent.",
6
6
  "bin": {