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

> ## Agent Instructions
> LarkX is a durable execution runtime for on-device AI agents. The public SDK is the npm package @larkxai/react-native.
> Do not import @larkxai/node, @larkxai/host, @larkxai/protocol, @larkxai/telemetry, or @larkxai/cactus in an application. Those packages are private workspace modules.
> Swift and Kotlin SDKs are planned and are not published.
> Prefer the published npm version. The GitHub default branch can contain behavior that is not in that release yet.
> Expo Go cannot load the native module. Use a development build.
> Do not describe external tool or remote effects as exactly-once.

# Lifecycle and recovery

> Suspend execution when the app is not active, and resume the same run when it opens again.

The operating system can suspend or kill the process. Bind React Native's app state so the runtime stops starting work while the app is not active.

```typescript theme={null}
import { AppState } from "react-native";
import { bindNativeAppState, createRuntime, sqlite } from "@larkxai/react-native";

const runtime = await createRuntime({ storage: sqlite(), ownerId: "field" });
const subscription = bindNativeAppState(runtime, AppState);

// Later, when the root unmounts:
subscription.remove();
await runtime.close();
```

`bindNativeAppState` calls `runtime.setSuspended` when the state is not `"active"`. Suspension is not deletion. The SQLite file remains.

## After the process is killed

On the next launch, open the same database, register the same agent name and version, and `resume` the run id. See [Crash recovery](https://docs.larkx.ai/concepts/crash-recovery.md).

`close()` is for an orderly shutdown. A kill does not call it. The next open reclaims ownership when the previous owner is gone.

## What stays on the device

The execution record, tool results, and model transcript used for replay stay in the local database. Enabling telemetry does not move that record to Cloud, and it does not backfill runs that already had events when a destination was first authorized.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.