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

# Configuration

> Models, storage, logging, and identity

## Lifecycle

```ts theme={null}
await RunAnywhere.initialize(options?: InitializeOptions);
await RunAnywhere.reset();
await RunAnywhere.capabilities();
await RunAnywhere.componentLifecycleSnapshot(component);
```

| Accessor      | Type                              | Note                                    |
| ------------- | --------------------------------- | --------------------------------------- |
| `isReady`     | `boolean`                         |                                         |
| `version`     | `string`                          | **Empty** until `initialize()` resolves |
| `deviceId`    | `string`                          | **Empty** until `initialize()` resolves |
| `environment` | `Environment`                     |                                         |
| `events`      | `AsyncIterableIterator<SdkEvent>` |                                         |

`componentLifecycleSnapshot` treats an unloaded component as an answer rather than a failure:
it comes back with `COMPONENT_LIFECYCLE_STATE_NOT_LOADED` and no model id.

## Hugging Face token

```ts theme={null}
await RunAnywhere.setHfToken(token) // null to fall back, '' to clear
```

This one has behaviour worth knowing:

* `null` falls back to the environment lookup the core resolves: `HF_TOKEN`, then
  `$HF_TOKEN_PATH`, then `$HF_HOME/token`, then `~/.cache/huggingface/token`. That is the order
  `huggingface_hub` uses, so `hf auth login` is honoured.
* An empty string clears the token **and** disables that fallback.
* The token lives in the platform secure store, not in settings, and is re-applied on the next
  `initialize()` so a gated model still downloads after a cold start.
* It is attached only to https requests whose host is exactly `huggingface.co` or `hf.co`,
  never to a CDN or LFS redirect target.

## Models

```ts theme={null}
await RunAnywhere.models.list(filter?);
await RunAnywhere.models.get(id);
await RunAnywhere.models.register(model);
await RunAnywhere.models.unregister(id);
await RunAnywhere.models.refresh(options?);
await RunAnywhere.models.delete(id);
await RunAnywhere.models.load(id, options?);
await RunAnywhere.models.unload(id);
```

### Download control

```ts theme={null}
for await (const event of RunAnywhere.models.download(id)) {
  /* … */
}

await RunAnywhere.models.pause(id)
await RunAnywhere.models.resume(id)
await RunAnywhere.models.cancel(id)
await RunAnywhere.models.interrupted() // ids left half-downloaded
await RunAnywhere.models.isResumable(id)
```

`interrupted()` after a crash or a forced quit tells you what to offer resuming, which is the
difference between a user losing a 4GB download and not.

## Storage

```ts theme={null}
await RunAnywhere.storage.info(request?);
await RunAnywhere.storage.availability(request);
await RunAnywhere.storage.deletePlan(request?);
await RunAnywhere.storage.delete(request);
await RunAnywhere.storage.clearCache();
await RunAnywhere.storage.cleanTempFiles();
```

`deletePlan` is a dry run. Call it before `delete` and show the user exactly what is about to
go, rather than deleting and reporting afterwards.

`availability` answers "will this fit" before a download starts.

## Logging

```ts theme={null}
await RunAnywhere.logging.configure(config)
await RunAnywhere.logging.configuration()
await RunAnywhere.logging.setLevel(level)
await RunAnywhere.logging.level()
await RunAnywhere.logging.setLocalEnabled(enabled)
await RunAnywhere.logging.setDebugMode(enabled)
await RunAnywhere.logging.flush()

const unsubscribe = await RunAnywhere.logging.addDestination(destination)
unsubscribe()

for await (const entry of RunAnywhere.logging.records()) {
  console.log(entry)
}
```

`addDestination` returns an unsubscribe function rather than taking a removal call.
`records()` is a live stream, which is what a debug pane in the app can render directly.

## LoRA

Electron carries the full catalog surface, not the short form:

```ts theme={null}
await RunAnywhere.lora.apply(adapterId, scale?);
await RunAnywhere.lora.remove(adapterId?);
await RunAnywhere.lora.removeAll();
await RunAnywhere.lora.list();
await RunAnywhere.lora.state();
await RunAnywhere.lora.checkCompatibility(config);
await RunAnywhere.lora.register(entry);
await RunAnywhere.lora.registerArtifact(/* … */);
await RunAnywhere.lora.download(/* … */);
await RunAnywhere.lora.importAdapter(sourcePath);
await RunAnywhere.lora.listCatalog(query?);
await RunAnywhere.lora.queryCatalog(query);
```

## Embeddings helpers

```ts theme={null}
const vectors = await RunAnywhere.embeddings.embed(texts, options?);
const similarity = await RunAnywhere.embeddings.cosineSimilarity(a, b);
const norm = await RunAnywhere.embeddings.computeNorm(vector);
```

`cosineSimilarity` and `computeNorm` on the namespace are Electron-only.

## Identity and telemetry

```ts theme={null}
RunAnywhere.auth // control-plane identity
RunAnywhere.secure // platform secure store
RunAnywhere.telemetry // telemetry controls
```

These become meaningful only once the SDK is initialized with control-plane credentials. In
keyless local mode they report an unauthenticated state rather than throwing.

## Model residency

```ts theme={null}
import { ResidencyPolicy } from '@runanywhere/electron'
```

`ResidencyPolicy`, `ResidencyDecision`, `ResidencySlots`, and `ResidentModel` control which
models stay loaded when memory is contended. On a desktop with several models in play, this is
what stops a voice session evicting the chat model on every turn.
