> ## 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 open-source execution infrastructure for on-device AI agents. It is not an inference engine, an LLM wrapper, a cloud-only agent framework, or a replacement for LangGraph or Cactus.
> Install the public SDK with npm install @larkxai/react-native. The published version is the sdkVersion variable on the Installation page. Import createRuntime, defineTool, scriptedModel, sqlite, remoteAgent, and larkxCloud from @larkxai/react-native. Import cactusModel from @larkxai/react-native/cactus only when the app uses local inference.
> Do not import @larkxai/node, @larkxai/host, @larkxai/protocol, @larkxai/telemetry, or @larkxai/cactus. Those packages are private. Swift and Kotlin SDKs are not published.
> Hello World uses scriptedModel and does not download a model or need Cloud. A Cactus agent needs cactus-react-native 1.13.1, react-native-nitro-modules 0.33.9 or newer, download(), and init() before start. Expo Go cannot load the native module.
> Recovery opens a new createRuntime on the same SQLite file, registers the same agent name and version, then calls resume. Do not call resume on a runtime that has already been closed. Do not describe external effects as exactly-once. A killed process does not keep running.
> Cloud telemetry is optional. Pass larkxCloud({ projectId, apiKey }) only after a local run already works. The key must start with lkx_ing_.

# 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={"dark"}
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.