* Initialize the application
()
| 304 | * Initialize the application |
| 305 | */ |
| 306 | async function initialize(): Promise<void> { |
| 307 | // Initialize logger first |
| 308 | logger.init(); |
| 309 | logger.info('=== ClawX Application Starting ==='); |
| 310 | logger.debug( |
| 311 | `Runtime: platform=${process.platform}/${process.arch}, electron=${process.versions.electron}, node=${process.versions.node}, packaged=${app.isPackaged}, pid=${process.pid}, ppid=${process.ppid}` |
| 312 | ); |
| 313 | |
| 314 | if (!isE2EMode) { |
| 315 | // Warm up network optimization (non-blocking) |
| 316 | void warmupNetworkOptimization(); |
| 317 | |
| 318 | // Initialize Telemetry early |
| 319 | await initTelemetry(); |
| 320 | |
| 321 | // Apply persisted proxy settings before creating windows or network requests. |
| 322 | await applyProxySettings(); |
| 323 | await syncLaunchAtStartupSettingFromStore(); |
| 324 | } else { |
| 325 | logger.info('Running in E2E mode: startup side effects minimized'); |
| 326 | } |
| 327 | |
| 328 | // Set application menu |
| 329 | await createMenu(); |
| 330 | |
| 331 | // Create the main window |
| 332 | const window = createMainWindow(); |
| 333 | |
| 334 | // Create system tray |
| 335 | if (!isE2EMode) { |
| 336 | createTray(window); |
| 337 | } |
| 338 | |
| 339 | // Override security headers ONLY for the OpenClaw Gateway Control UI. |
| 340 | // The URL filter ensures this callback only fires for gateway requests, |
| 341 | // avoiding unnecessary overhead on every other HTTP response. |
| 342 | session.defaultSession.webRequest.onHeadersReceived( |
| 343 | { urls: ['http://127.0.0.1:18789/*', 'http://localhost:18789/*'] }, |
| 344 | (details, callback) => { |
| 345 | const headers = { ...details.responseHeaders }; |
| 346 | delete headers['X-Frame-Options']; |
| 347 | delete headers['x-frame-options']; |
| 348 | if (headers['Content-Security-Policy']) { |
| 349 | headers['Content-Security-Policy'] = headers['Content-Security-Policy'].map( |
| 350 | (csp) => csp.replace(/frame-ancestors\s+'none'/g, "frame-ancestors 'self' *") |
| 351 | ); |
| 352 | } |
| 353 | if (headers['content-security-policy']) { |
| 354 | headers['content-security-policy'] = headers['content-security-policy'].map( |
| 355 | (csp) => csp.replace(/frame-ancestors\s+'none'/g, "frame-ancestors 'self' *") |
| 356 | ); |
| 357 | } |
| 358 | callback({ responseHeaders: headers }); |
| 359 | }, |
| 360 | ); |
| 361 | |
| 362 | // Register IPC handlers |
| 363 | registerIpcHandlers(gatewayManager, clawHubService, window, hostApiRegistry); |
no test coverage detected