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

# Quickstart

> Start a local agent with a scripted model and read the result from SQLite.

This example uses `scriptedModel` so it does not download a model. A device app uses the same runtime calls with [Cactus](https://docs.larkx.ai/integrations/cactus.md) or another `Model`.

The model replies with one tool call, then a final message. The tool is `pure`, so an interrupted attempt may run again.

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

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

const agent = runtime.createAgent({
  name: "notes",
  version: 1,
  instructions: "Read the note and answer in one line.",
  model: scriptedModel([
    {
      message: null,
      finish: "tool_calls",
      calls: [{ id: "call-1", name: "read_notes", arguments: {} }],
    },
    { message: "Seal needs service.", finish: "stop", calls: [] },
  ]),
  tools: [
    defineTool({
      name: "read_notes",
      description: "Read the local inspection notes.",
      effects: "pure",
      schema: { type: "object", properties: {} },
      handler: () => ({ notes: ["Seal weeps above 80 psi."] }),
    }),
  ],
});

const run = await agent.start({ message: "Inspect pump 12", runId: "notes-1" });
const result = await run.result();
console.log(result.message);
await runtime.close();
```

`agent.start` registers the agent, stores the run, and starts the driver. `run.result()` waits for the terminal message. It does not start a second driver. `sqlite()` with no path stores `larkx.db` in the application document directory.

`result.message` is `"Seal needs service."` when the scripted model runs both responses. `result.finish` is `"stop"`.

Close the runtime when the application is finished with it. `close()` waits for in-flight steps and releases ownership. Do not call it from an engine hook.

## Resume the same run

Recovery happens when the process opens the same database and the same agent name and version.

```typescript theme={null}
const saved = await runtime.listRuns();
const interrupted = saved.find((run) => run.runId === "notes-1");
if (interrupted !== undefined && interrupted.status !== "COMPLETED") {
  const run = await runtime.resume(interrupted.runId);
  console.log(await run.result());
}
```

A committed step is not executed again. See [Crash recovery](https://docs.larkx.ai/concepts/crash-recovery.md).


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