diff options
Diffstat (limited to 'modules/core/module-world-model.js')
| -rw-r--r-- | modules/core/module-world-model.js | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/modules/core/module-world-model.js b/modules/core/module-world-model.js index b7bb28f..e8e3405 100644 --- a/modules/core/module-world-model.js +++ b/modules/core/module-world-model.js @@ -33,13 +33,21 @@ class WorldModelModule { init(terminal) { this.terminal = terminal; this._loadFromVFS(); + // Deferred initial synthesis — wait for ext modules (SkillPackCore etc) to fully load + setTimeout(() => { + this._synthesize(); + this.terminal.print('🌐 World Model synthesized — system self-awareness active', 'info'); + // Second pass after ext modules definitely finished loading + setTimeout(() => { + this._synthesize(); + this.terminal.print('🌐 World Model refresh — full module load confirmed', 'info'); + }, 7000); + }, 5000); // Auto-refresh on a timer this._refreshTimer = setInterval(() => { const age = Date.now() - (this._lastRefresh ? new Date(this._lastRefresh).getTime() : 0); if (age > this._REFRESH_INTERVAL) this._synthesize(); }, this._REFRESH_INTERVAL); - // Initial synthesis - this._synthesize(); this.terminal.print('🌐 World Model loaded — system self-awareness active', 'info'); } @@ -50,15 +58,22 @@ class WorldModelModule { const fs = this.terminal.fs; if (!fs) return; + // Derive version from actual system state — no hardcoded strings + const mInfo = this._gatherModuleInfo(); + const agentInfo = this._gatherAgentInfo(); + const fileInfo = this._gatherFileInfo(fs); + const skillInfo = this._gatherSkillInfo(fs); + const liveVersion = this._deriveVersion(mInfo); + const model = { - version: 'v4.4', + version: liveVersion, synthesized: new Date().toISOString(), - system: this._gatherSystemInfo(fs), - modules: this._gatherModuleInfo(), - files: this._gatherFileInfo(fs), - skills: this._gatherSkillInfo(fs), + system: this._gatherSystemInfo(fs, mInfo.loaded, liveVersion), + modules: mInfo, + files: fileInfo, + skills: skillInfo, memory: this._gatherMemoryInfo(), - agents: this._gatherAgentInfo(), + agents: agentInfo, telemetry: this._gatherTelemetry(fs), projects: this._gatherProjects(fs), recent: this._gatherRecent(fs) @@ -78,11 +93,30 @@ class WorldModelModule { } } - _gatherSystemInfo(fs) { + _deriveVersion(mInfo) { + // Single source of truth: the constant set at bootstrap + if (window.NEWOS4_VERSION) return window.NEWOS4_VERSION; + // No fallback version string — if the constant is missing, report unknown + return 'v?'; + } + + _getTotalModules() { + try { + const mm = this.terminal?.moduleManager; + if (!mm) return 0; + // Count registry entries (all known modules) vs loaded + const registry = mm.moduleRegistry || []; + return registry.length || Object.keys(mm.modules || {}).length + 5; // +5 for expected unloaded + } catch (e) { + return Object.keys(this.terminal?.moduleManager?.modules || {}).length || 0; + } + } + + _gatherSystemInfo(fs, moduleCount, version) { const healthData = fs.fsReadJSON('/system/metrics/health.json'); return { - version: 'newOS4 v4.4', - modules: Object.keys(this.terminal?.moduleManager?.modules || {}).length || 0, + version: `newOS4 ${version}`, + modules: moduleCount || Object.keys(this.terminal?.moduleManager?.modules || {}).length || 0, vfsSize: JSON.stringify(fs?.root || {}).length, online: typeof navigator !== 'undefined' ? navigator.onLine : true, memory: typeof performance !== 'undefined' && performance.memory @@ -109,7 +143,7 @@ class WorldModelModule { : []; return { loaded: modules.length, - total: 49, + total: this._getTotalModules(), modules, modified, modifiedCount: modified.length |