diff options
Diffstat (limited to 'modules/core/terminal.js')
| -rw-r--r-- | modules/core/terminal.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/modules/core/terminal.js b/modules/core/terminal.js index 10608d1..76406b5 100644 --- a/modules/core/terminal.js +++ b/modules/core/terminal.js @@ -2954,6 +2954,16 @@ } } log(level, source, message) { + // v4.6.60: an ERROR also goes to the DebugSupervisor DB, so the log is a + // human-readable MIRROR of one store instead of a second store that only one + // code path ever wrote to (packet §2: 0 / 18 / 11 in the same second). + if (String(level).toUpperCase() === 'ERROR') { + try { + const ds = this.moduleManager && this.moduleManager.modules + ? this.moduleManager.modules['DebugSupervisorModule'] : null; + if (ds && typeof ds._recordError === 'function') ds._recordError(String(message), String(source || 'terminal')); + } catch (e) { /* never let logging throw */ } + } const d = new Date(); const ts = d.toISOString().split('T')[1].split('.')[0]; const entry = `[${ts}][${level}][${source}] ${message}`; @@ -2972,6 +2982,28 @@ } } catch (e) {} } + // v4.6.59: ONE error counter. Three surfaces used to disagree because each + // tallied a different sink: `errors` scanned /logs/current.log (which only ever + // receives explicit terminal.log('ERROR') calls — one call site in the whole app), + // the dashboard added debug-DB + failed tool calls, and the world model read the + // debug DB alone. Measured: 0 / 18 / 11 in the same second (packet §2). + countLogErrors() { + try { + const c = this.fs.readFile('/logs/current.log') || ''; + return c.split('\n').filter(l => l.includes('[ERROR]')).length; + } catch (e) { return 0; } + } + countErrors() { + const mm = this.moduleManager; + const ds = mm && mm.modules ? mm.modules['DebugSupervisorModule'] : null; + const sm = mm && mm.modules ? mm.modules['ServerMonitorModule'] : null; + const debug = (ds && ds._errorDB && ds._errorDB.errors) + ? Object.keys(ds._errorDB.errors).length : 0; + const latency = (sm && Array.isArray(sm._latencyLog)) + ? sm._latencyLog.filter(e => e && e.error).length : 0; + const log = this.countLogErrors(); + return { debug: debug, latency: latency, log: log, total: debug + latency }; + } setAiBusy(busy) { this._aiBusy = !!busy; if (this._aiBusyInterval) { |