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

# Runtime

> The runtime owns the SQLite file, the registered agents, and the host driver.

`createRuntime` opens one SQLite database and one native session. The C++ runtime decides the next step. The host driver performs the model call, tool call, or remote request the runtime asked for and submits the result. The host does not plan the next step and it does not keep a second database.

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

const runtime = await createRuntime({
  storage: sqlite(),
  ownerId: "notes",
});
```

`ownerId` is the ownership name for this process. Ownership writes carry an epoch. A stale owner cannot commit.

## What the runtime stores

The database is the execution record. The runtime stamps SQLite `application_id` `LXRT` (`0x4C585254`) on files it creates. A file with any other id, including a database written by the removed TypeScript engine, is rejected and left unchanged. There is no migration. Open a new file.

`sqlite("/path/to/agent.db")` chooses the file. `sqlite()` with no argument uses the application document directory.

## What the runtime does not do

* It does not download or run a model unless you pass one.
* It does not send telemetry unless you pass `larkxCloud` or another exporter.
* It does not call a remote agent unless that agent is registered on the local agent.
* It does not follow the application into the background by itself. Bind the app state when you want suspension to pause execution. See [Lifecycle and recovery](https://docs.larkx.ai/react-native/lifecycle.md).

Call `runtime.close()` when the process is done. It waits for in-flight steps and releases ownership.


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