Environment:AI QL Tuui Electron Main Process
| Knowledge Sources | |
|---|---|
| Domains | Electron, Node.js, Desktop |
| Last Updated | 2026-10-24 20:38 GMT |
Overview
Node.js runtime environment for the Electron main process, providing system-level access to IPC, file system, child processes, and platform automation.
Description
The Electron main process runs in Node.js and has full access to the operating system. In tuui it manages window creation (splash, main, error), IPC handler registration, MCP server lifecycle (stdio client spawning), config file loading with file watching, system tray, global shortcut registration, and platform automation (nut-js, AppleScript, VBScript). It uses the electron npm package (>= 42.0.1) and Node.js >= 22.12.0.
Usage
Use this environment for all code running in src/main/. Any implementation that imports from electron, spawns child processes, accesses the file system directly, or registers IPC handlers requires this environment.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | macOS, Windows, or Linux | Platform-specific automators dispatch at runtime |
| Runtime | Node.js >= 22.12.0 | Specified in engines field of package.json
|
| Disk | 500MB SSD | For electron binary, dependencies, and bundled assets |
| Memory | 512MB RAM minimum | MCP server child processes add overhead |
Dependencies
NPM Packages
- `electron` >= 42.0.1
- `@modelcontextprotocol/sdk` >= 1.29.0
- `@anthropic-ai/mcpb` >= 2.1.2
- `@nut-tree-fork/nut-js` >= 4.2.6
- `applescript` >= 1.0.0 (macOS only, dynamic import)
- `@el3um4s/run-vbs` >= 1.1.2 (Windows only)
- `uuid` >= 14.0.0
- `lodash` >= 4.17.x (debounce utility)
System Packages
- Node.js runtime (>= 22.12.0)
- Platform-specific automation runtime (see Environment:AI_QL_Tuui_Nut_JS)
Credentials
No credentials required for the main process itself. MCP server configs may define environment variables per-server via the env field in mcp.json.
Quick Install
npm install electron@^42.0.1 @modelcontextprotocol/sdk@^1.29.0 @anthropic-ai/mcpb@^2.1.2 @nut-tree-fork/nut-js@^4.2.6 uuid@^14.0.0 lodash
Code Evidence
Node.js engine constraint from `package.json:46-48`:
"engines": {
"node": ">=22.12.0"
}
Platform detection from `src/main/utils/Constants.ts:44`:
static IS_MAC = process.platform === 'darwin'
Electron app lifecycle from `src/main/index.ts:59-70`:
app.on('ready', async () => {
createWindow()
registerShortcuts()
})
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `Unknown ipc channel name` | Channel not whitelisted in preload | Add channel to mainAvailChannels or rendererAvailChannels in preload
|
| `Failed to connect to MCP server` | Server command not found or crashed | Check mcp.json command/args paths
|
| `Nut Automator cannot be initiated` | nut-js native module missing | Run npm install to rebuild native deps
|
Compatibility Notes
- macOS: Uses AppleScript for window management and nut-js for keyboard simulation. Mac App Store (MAS) builds disable automation (shows dialog instead).
- Windows: Uses VBScript (
@el3um4s/run-vbs) for app activation and nut-js for keyboard simulation. - Linux: Uses nut-js only;
getForemostAppnot implemented (returns null). - MAS builds:
process.masis checked in Commander to disable the command picker.
Related Pages
- Implementation:AI_QL_Tuui_loadConfigFile
- Implementation:AI_QL_Tuui_IPCs
- Implementation:AI_QL_Tuui_initializeClient
- Implementation:AI_QL_Tuui_connect_disconnect
- Implementation:AI_QL_Tuui_dxt_bundle_ops
- Implementation:AI_QL_Tuui_initClients
- Implementation:AI_QL_Tuui_main_transfer_invoke
- Implementation:AI_QL_Tuui_openCommandPicker
- Implementation:AI_QL_Tuui_registerShortcuts
- Implementation:AI_QL_Tuui_aid_createWindow
- Implementation:AI_QL_Tuui_Commander
- Implementation:AI_QL_Tuui_Automation_grabSelectedText
- Implementation:AI_QL_Tuui_MainRunner