Hello Ledger Event
Append one event to the runtime ledger and read it back as durable truth.
What You Build
Section titled “What You Build”A local in-memory runtime proof that writes tutorial.hello.recorded and reads
the same event through Ledger.events.
Prerequisites
Section titled “Prerequisites”-
Create an in-memory backend state and runtime layer:
import { Effect } from "effect";import { Ledger } from "@agent-os/runtime";import { InMemoryBackendState, InMemoryLedgerLive } from "@agent-os/backend-in-memory";const scope = "tutorial:hello";const state = new InMemoryBackendState();const ledgerLayer = InMemoryLedgerLive(state); -
Append one domain event:
const program = Effect.gen(function* () {const ledger = yield* Ledger;yield* ledger.commit([{ kind: "tutorial.hello.recorded", payload: { message: "hello" }, scope },]);return yield* ledger.events(scope);}); -
Run the proof:
const events = await Effect.runPromise(program.pipe(Effect.provide(ledgerLayer))); -
Treat the returned rows as facts. Do not copy them into another mutable “current state” object.
Checkpoint
Section titled “Checkpoint”The readback contains exactly the event you appended:
events.map((event) => event.kind); // ["tutorial.hello.recorded"]events[0]?.payload; // { message: "hello" }The event is the source of truth. Any UI state or projection must be derived by folding the event list.
Let an LLM call a tool with weather tool LLM loop.