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

# Hello World

> Prove the SDK is installed. A scripted model runs one tool and returns a stored result.

This path checks that the development build can open the runtime. It does not download a model, create a Cloud account, or start a remote server.

`scriptedModel` replays responses you write in the source. It demonstrates the runtime. It is not AI inference. The same `createRuntime`, `defineTool`, and `agent.start` calls are what a Cactus agent uses later.

**1. Open a runtime**

`sqlite()` with no path stores `larkx.db` in the application documents directory.

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

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

**2. Define one local tool and a scripted agent**

The tool is `pure`, so an interrupted attempt may run again. The model asks for `read_notes`, then returns one sentence.

```typescript theme={"dark"}
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."] }),
    }),
  ],
});
```

**3. Start the run and read the result**

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

## Expected output

`result.message` is `"Seal needs service."` and `result.finish` is `"stop"`.

`agent.start` stores the run and starts its driver. `run.result()` waits for that driver. It does not start a second one. `close()` waits for in-flight steps and releases ownership. Do not call `close()` from an engine hook, and do not use that same runtime object after it resolves.

## What this does not show

The sentence came from the script, not from a model download. A killed process does not keep running. To reopen the same database and see that the committed tool call is not repeated, follow [Crash recovery](https://docs.larkx.ai/concepts/crash-recovery.md). That page creates a new runtime. It does not reuse the runtime you just closed.

Next, run a real local model in [Your first on-device agent](https://docs.larkx.ai/getting-started/on-device-agent.md).


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