Chore/build npm (#9)

Co-authored-by: DigHuang <114602213+DigHuang@users.noreply.github.com>
Co-authored-by: Felix <24791380+vcfgv@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Haze
2026-02-09 15:10:08 +08:00
committed by GitHub
Unverified
parent 0b7f1c700e
commit de445ae3d5
37 changed files with 7359 additions and 1586 deletions

View File

@@ -10,6 +10,7 @@ import { createTray } from './tray';
import { createMenu } from './menu';
import { appUpdater, registerUpdateHandlers } from './updater';
import { logger } from '../utils/logger';
// Disable GPU acceleration for better compatibility
app.disableHardwareAcceleration();
@@ -69,6 +70,17 @@ function createWindow(): BrowserWindow {
* Initialize the application
*/
async function initialize(): Promise<void> {
// Initialize logger first
logger.init();
logger.info('=== ClawX Application Starting ===');
logger.info(`Platform: ${process.platform}, Arch: ${process.arch}`);
logger.info(`Electron: ${process.versions.electron}, Node: ${process.versions.node}`);
logger.info(`App path: ${app.getAppPath()}`);
logger.info(`User data: ${app.getPath('userData')}`);
logger.info(`Is packaged: ${app.isPackaged}`);
logger.info(`Resources path: ${process.resourcesPath}`);
logger.info(`Exec path: ${process.execPath}`);
// Set application menu
createMenu();
@@ -129,10 +141,11 @@ async function initialize(): Promise<void> {
// Start Gateway automatically (optional based on settings)
try {
logger.info('Auto-starting Gateway...');
await gatewayManager.start();
console.log('Gateway started successfully');
logger.info('Gateway auto-start succeeded');
} catch (error) {
console.error('Failed to start Gateway:', error);
logger.error('Gateway auto-start failed:', error);
// Notify renderer about the error
mainWindow?.webContents.send('gateway:error', String(error));
}

View File

@@ -20,9 +20,10 @@ import {
isEncryptionAvailable,
type ProviderConfig,
} from '../utils/secure-storage';
import { getOpenClawStatus } from '../utils/paths';
import { getOpenClawStatus, getOpenClawDir } from '../utils/paths';
import { getSetting } from '../utils/store';
import { saveProviderKeyToOpenClaw, setOpenClawDefaultModel } from '../utils/openclaw-auth';
import { logger } from '../utils/logger';
import {
saveChannelConfig,
getChannelConfig,
@@ -68,6 +69,9 @@ export function registerIpcHandlers(
// UV handlers
registerUvHandlers();
// Log handlers (for UI to read gateway/app logs)
registerLogHandlers();
// Skill config handlers (direct file access, no Gateway RPC)
registerSkillConfigHandlers();
@@ -306,6 +310,37 @@ function registerUvHandlers(): void {
});
}
/**
* Log-related IPC handlers
* Allows the renderer to read application logs for diagnostics
*/
function registerLogHandlers(): void {
// Get recent logs from memory ring buffer
ipcMain.handle('log:getRecent', async (_, count?: number) => {
return logger.getRecentLogs(count);
});
// Read log file content (last N lines)
ipcMain.handle('log:readFile', async (_, tailLines?: number) => {
return logger.readLogFile(tailLines);
});
// Get log file path (so user can open in file explorer)
ipcMain.handle('log:getFilePath', async () => {
return logger.getLogFilePath();
});
// Get log directory path
ipcMain.handle('log:getDir', async () => {
return logger.getLogDir();
});
// List all log files
ipcMain.handle('log:listFiles', async () => {
return logger.listLogFiles();
});
}
/**
* Gateway-related IPC handlers
*/
@@ -433,19 +468,26 @@ function registerGatewayHandlers(
/**
* OpenClaw-related IPC handlers
* For checking submodule status and channel configuration
* For checking package status and channel configuration
*/
function registerOpenClawHandlers(): void {
// Get OpenClaw submodule status
// Get OpenClaw package status
ipcMain.handle('openclaw:status', () => {
return getOpenClawStatus();
const status = getOpenClawStatus();
logger.info('openclaw:status IPC called', status);
return status;
});
// Check if OpenClaw is ready (submodule present and dependencies installed)
// Check if OpenClaw is ready (package present)
ipcMain.handle('openclaw:isReady', () => {
const status = getOpenClawStatus();
return status.submoduleExists && status.isInstalled;
return status.packageExists;
});
// Get the resolved OpenClaw directory path (for diagnostics)
ipcMain.handle('openclaw:getDir', () => {
return getOpenClawDir();
});
// ==================== Channel Configuration Handlers ====================