| 178 | } |
| 179 | |
| 180 | private async sendToRemoteServer(level: string, message: string, ...args: unknown[]): Promise<void> { |
| 181 | if (!this.dangerouslyUnencryptedServerLoggingUrl) return |
| 182 | |
| 183 | try { |
| 184 | await fetch(this.dangerouslyUnencryptedServerLoggingUrl + '/logs-combined-from-cli-and-mobile-for-simple-ai-debugging', { |
| 185 | method: 'POST', |
| 186 | headers: { 'Content-Type': 'application/json' }, |
| 187 | body: JSON.stringify({ |
| 188 | timestamp: new Date().toISOString(), |
| 189 | level, |
| 190 | message: `${message} ${args.map(a => |
| 191 | typeof a === 'object' ? JSON.stringify(a, null, 2) : String(a) |
| 192 | ).join(' ')}`, |
| 193 | source: 'cli', |
| 194 | platform: process.platform |
| 195 | }) |
| 196 | }) |
| 197 | } catch (error) { |
| 198 | // Silently fail to avoid disrupting the session |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | private logToFile(prefix: string, message: string, ...args: unknown[]): void { |
| 203 | const logLine = `${prefix} ${message} ${args.map(arg => |