> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lynxhub.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Main process utilities

> Access host managers, database storage, and shell terminal helpers.

The `utils` parameter contains references to configuration managers, database layers, system trays, and terminal controllers.

***

## Storage database (`storage`)

A simple key-value database wrapper that reads and writes custom settings data:

* `get<T>(key: string): T` - Retrieves custom data values.
* `set<T>(key: string, data: T): void` - Saves custom configuration values.

```typescript theme={null}
// Read custom configuration
const apiKey = utils.storage.get('my-api-key');

// Save configuration updates
utils.storage.set('my-api-key', 'secure-key-string');
```

***

## Inter-process communication (`ipc`)

A simplified IPC utility to register listeners or emit events to the renderer process:

* `handle(channel: string, listener: (event: any, ...args: any[]) => any): void` - Registers an IPC invocation handler (equivalent to `ipcMain.handle`).
* `on(channel: string, listener: (event: any, ...args: any[]) => void): void` - Listens to events (equivalent to `ipcMain.on`).
* `send(channel: string, ...args: any[]): void` - Dispatches events directly to the frontend window.

```typescript theme={null}
// Handle frontend invocations
utils.ipc.handle('module:check-gpu', async () => {
  return {gpuAvailable: true};
});
```

***

## Pseudo-terminals (`pty`)

The `utils.pty` property exposes the native `node-pty` package directly. Use it to spawn sub-shells or python executors inside interactive terminal terminals:

```typescript theme={null}
const ptyProcess = utils.pty.spawn('python', ['app.py'], {
  name: 'xterm-color',
  cols: 80,
  rows: 24,
  cwd: '/project-dir',
});
```

***

## Directory resolution

* `getInstallDir(id: string): string | undefined` - Returns the absolute installation path of the card.
* `getConfigDir(): string | undefined` - Returns the main application configurations folder path.

***

## File and Git management

* `trashDir(dir: string): Promise<void>` - Moves a directory to the operating system recycle bin.
* `removeDir(dir: string): Promise<void>` - Deletes a directory permanently.
* `isPullAvailable(dir: string): Promise<boolean>` - Checks if a directory contains a valid Git repository with pull updates.
* `pullDir(dir: string, showTaskbarProgress?: boolean): Promise<void>` - Triggers a Git pull inside the target directory.

***

## Extension pre-commands compatibility

* `getExtensions_TerminalPreCommands(id: string): string[]` - Gathers startup shell commands (such as Conda activations or path configurations) registered by active extensions for the target card ID. Always prepend these commands to your execution array.
