> ## 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.

# IPC routing and storage manager

> Operate the host database and access core IPC routing interfaces.

Extensions can access persistent databases and routing mechanisms. Use the `StorageManager` to query state, or the `mainIpc` parameter to invoke core app functions.

***

## Persistent storage manager

The `StorageManager` singleton controls database get/set operations, migrations, and encryption. Retrieve the storage manager during initialization:

```typescript theme={null}
const storageManager = await utils.getStorageManager();
```

***

### Custom data scopes

If your extension requires custom persistent key-value configuration data, use `getCustomData` and `setCustomData`.

If your key begins with a module identifier followed by double colons (e.g. `myModule::myKey`), the storage manager isolates this data in a dedicated configuration file: `myModule.config`.

```typescript theme={null}
// Retrieve custom values
const customVal = storageManager.getCustomData('myModule::api-key');

// Save and persist custom values
storageManager.setCustomData('myModule::api-key', 'secure-token');
```

***

### Core database configuration

You can read or update the host application's core settings (e.g., `app`, `terminal`, `browser`, `performance`, `plugin`, `cards`, `cardsConfig`):

```typescript theme={null}
// Read settings
const appSettings = storageManager.getData('app');
console.log('Is Dynamic Title Enabled:', appSettings.dynamicAppTitle);

// Update settings partially
storageManager.updateData('app', {dynamicAppTitle: false});

// Persist current settings state to disk
storageManager.write();
```

***

### Encrypted browser history

The application encrypts browser history entries on disk using Chromium's `safeStorage` API. You must decrypt browser records before reading them:

```typescript theme={null}
// Decrypt and load data into memory cache
storageManager.decryptBrowserData();

// Retrieve decrypted records cache
const history = storageManager.getBrowserDataSecurely();
console.log('Recent URL addresses:', history.recentAddress);

// Save updated records (the manager automatically encrypts values on disk)
storageManager.updateBrowserDataSecurely({
  recentAddress: [...history.recentAddress, 'https://lynxhub.app'],
});
```

***

### Card lifecycle management

Use the storage manager to update card registries, pinned lists, or terminal settings:

```typescript theme={null}
// Add card definitions to the registry
storageManager.addInstalledCard({id: 'my-card-id', dir: 'project-path'});

// Pin or unpin cards
storageManager.addPinnedCard('my-card-id');
storageManager.removePinnedCard('my-card-id');

// Clear card configurations and unassign card
storageManager.unassignCard('my-card-id', true);

// Set terminal commands running prior to card executions
storageManager.setCardTerminalPreCommands('my-card-id', ['echo "Setting env..."', 'conda activate env']);
```

***

## Core IPC namespaces (`mainIpc`)

The `mainIpc` parameter exposes direct wrappers to core application IPC channels. Use these namespaces to access background functionalities:

* `lynxIpc`: Main app configuration, plugin loading, and logger utilities.
* `application`: Window layout controls (minimize, maximize, close, relaunch).
* `browser`: Controls browser tabs, download panels, and navigation.
* `contextMenu`: Context menus and system tray options.
* `dialogWindow`: System alert dialog prompts and file selection panels.
* `downloadManager`: Queries download indicators and file sizes.
* `files`: File operations (validate directories, list paths, delete/trash).
* `git`: Git repository operations (shallow clone, pull, checkout branch).
* `pty`: PTY process spawning, input writing, resizing, and exit hooks.
* `storage`: Direct database operations.
* `storageUtils`: Storage helper operations.
* `user`: Retrives user profiles and options.
* `utils`: Executes shell commands, activates Conda, and validates Python.
