thepopebot 1.2.41 → 1.2.42

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.
Files changed (2) hide show
  1. package/lib/cron.js +16 -10
  2. package/package.json +1 -1
package/lib/cron.js CHANGED
@@ -1,16 +1,21 @@
1
1
  import cron from 'node-cron';
2
2
  import fs from 'fs';
3
- import { fileURLToPath } from 'url';
4
- import { dirname, join } from 'path';
3
+ import path from 'path';
5
4
  import { cronsFile, cronDir } from './paths.js';
6
5
  import { executeAction } from './actions.js';
7
6
 
8
- // Read installed version once at module load (doesn't change while server runs)
9
- const __filename = fileURLToPath(import.meta.url);
10
- const __dirname = dirname(__filename);
11
- const _installedVersion = JSON.parse(
12
- fs.readFileSync(join(__dirname, '..', 'package.json'), 'utf8')
13
- ).version;
7
+ // Installed version resolved lazily on first version check.
8
+ // Can't read at module scope because webpack bakes in the build-time path
9
+ // (e.g. /Users/dev/project/...) which doesn't exist at runtime in Docker.
10
+ let _installedVersion = null;
11
+
12
+ function getInstalledVersion() {
13
+ if (!_installedVersion) {
14
+ const pkgPath = path.join(process.cwd(), 'node_modules', 'thepopebot', 'package.json');
15
+ _installedVersion = JSON.parse(fs.readFileSync(pkgPath, 'utf8')).version;
16
+ }
17
+ return _installedVersion;
18
+ }
14
19
 
15
20
  // In-memory flag for available update (read by sidebar, written by cron)
16
21
  let _updateAvailable = null;
@@ -62,8 +67,9 @@ async function runVersionCheck() {
62
67
  const data = await res.json();
63
68
  const latest = data.version;
64
69
 
65
- if (isVersionNewer(latest, _installedVersion)) {
66
- console.log(`[version check] update available: ${_installedVersion} → ${latest}`);
70
+ const installed = getInstalledVersion();
71
+ if (isVersionNewer(latest, installed)) {
72
+ console.log(`[version check] update available: ${installed} → ${latest}`);
67
73
  setUpdateAvailable(latest);
68
74
  // Persist to DB
69
75
  const { setAvailableVersion } = await import('./db/update-check.js');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thepopebot",
3
- "version": "1.2.41",
3
+ "version": "1.2.42",
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": {