# Pleach (/docs)



Pleach is a TypeScript agent runtime. Every LLM call, tool
dispatch, and subagent spawn writes one row keyed by `turnId` —
joinable to your billing or compliance schema in a single
`GROUP BY`. Use it as the substrate under your product's agent
loop, or as the backbone an agent harness builds on.

The name is horticultural. **Pleaching** weaves living branches
into one load-bearing hedge. ai-sdk and LangChain hand you a pot
and a few stakes — enough to keep one branch upright. Pleach
hands you the lattice: every addressable event the agent
produces — each LLM call, tool dispatch, subagent spawn — lands
as a branch, woven into a structure you can query, prune, and
replay. The four stages are the trellis; the audit row is the
weave. Full entry in the [glossary](/docs/glossary#p).

## The three concepts [#the-three-concepts]

Everything else on this site reduces to these.

* **Session.** Long-lived state for one user × one product
  surface. Channels, storage, family-lock, and the event log all
  hang off it. Mint one with `runtime.sessions.create()`; resume
  by id across processes and clients via version-vector sync. See
  [SessionRuntime](/docs/session-runtime).
* **Turn.** One user-message-in / one-answer-out cycle. Walks the
  four-stage lattice — `anchor-plan` → `tool-loop` ⇄ `synthesize`
  → `post-turn` — under singleton-synthesize discipline so exactly
  one final answer fires per turn. See [Turn lifecycle](/docs/turn-lifecycle).
* **AuditableCall row.** One append-only typed row per LLM call,
  keyed by `turnId`. Carries `tenantId`, `toolName`,
  `subagentDepth`, `modelId`, and `tokenUsage`. The grain every
  cost rollup, compliance query, and replay reads from. See
  [The AuditableCall row](/docs/auditable-call-row).

Sessions hold turns; turns produce rows. From those three:
per-tenant cost in one `GROUP BY turn_id`, compliance review in
SQL, and replay-deterministic regression against fingerprints.

The full concept map — seven cluster triplets at four depths — is
at [Concept clusters](/docs/concept-clusters).

## The shape, in one paragraph [#the-shape-in-one-paragraph]

A session holds the state. A turn drives one user-message-in /
one-answer-out cycle through the four stages — `anchor-plan` sets
intent, `tool-loop` ⇄ `synthesize` iterates until the answer is
ready, `post-turn` finalizes. Every addressable decision in that
loop — a tool call, a subagent spawn, a model invocation, an
interrupt — writes one row to the ledger, keyed by the same
`turnId`. See [overview](/docs/overview) for the diagrams and
[turn-lifecycle](/docs/turn-lifecycle) for the walk-through.

## What ships today [#what-ships-today]

All `@pleach/*` packages ship under **FSL-1.1-Apache-2.0**
(Functional Source License with Apache 2.0 as the future license,
auto-transitions to Apache 2.0 two years after first stable publish).

The first-wave publish ceremony cuts 14 packages at `0.1.0`
uniformly: `@pleach/core`, `@pleach/tools`, `@pleach/react`,
`@pleach/base-tools`, `@pleach/replay`, `@pleach/sandbox`,
`@pleach/langchain`, `@pleach/compliance`,
`@pleach/compliance-contract`, `@pleach/eval`, `@pleach/gateway`,
`@pleach/mcp`, `@pleach/coding-agent`, and `@pleach/recipes`. Pin
exactly — `^0.1.0` will not pick up later `0.x` releases. Two names
aren't in the wave yet: `@pleach/observe` is scoped at
`0.1.0-alpha.0` (not on npm; next publish), and `@pleach/trust-pack`
is a reserved name at `0.0.1 · UNLICENSED`. See
[Packages](/docs/packages) for the canonical per-SKU status table.

## Start here [#start-here]

Pick the closest; the sidebar carries the rest.

<Cards>
  <Card title="Try it in 5 lines" href="/docs/getting-started" description="One install, one route handler, one component. Streaming chat against your chosen provider in ~5 minutes." />

  <Card title="Which SKU do I need?" href="/docs/which-sku" description="14 published packages, but most projects need 3 or 4. The shortest install list for what you're building — keyed by use case, not by SKU." />

  <Card title="Decide if Pleach fits" href="/docs/comparison" description="Where Pleach overlaps with AI SDK, LangChain, LlamaIndex, Mastra, and the dev harnesses — and where the audit ledger and four-stage lattice change the shape." />

  <Card title="Adopt for audit, cost rollup, and compliance" href="/docs/audit-ledger" description="The AuditableCall row, per-turn cost attribution, scrubbers, the hash chain, and the CI gates that hold it." />
</Cards>

## Already on Anthropic Enterprise or OpenAI Enterprise? [#already-on-anthropic-enterprise-or-openai-enterprise]

Pleach composes underneath the vendor contract — it does not
replace it. SSO/SAML, ZDR, Workspaces or Projects, the Admin /
Usage API, dedicated capacity, prompt caching, and snapshot
pinning stay where they are. The runtime adds per-axis cost
rollup inside one Workspace or Project (your end customers in a
SaaS, or your employees / teams / cost centers when the lab is
used internally), a hash-chained `AuditableCall` row in your own
Postgres, and replay-determinism across snapshots. No new vendor,
no new SOC 2 boundary.

<Cards>
  <Card title="Migrating from Anthropic Enterprise" href="/docs/migrating-from-anthropic-enterprise" description="Keep SSO, ZDR, Workspaces, the Admin API. The three downstream walls the contract doesn't cover, and how the AuditableCall row closes each one." />

  <Card title="Migrating from OpenAI Enterprise" href="/docs/migrating-from-openai-enterprise" description="Keep SSO/SCIM, ZDR, Projects, the Usage API. The three downstream walls the contract doesn't cover, and how the AuditableCall row closes each one." />
</Cards>

## Read next [#read-next]

<Cards>
  <Card title="Overview" href="/docs/overview" description="The runtime in pictures — session, turn, the four stages, and the ledger row that closes the loop." />

  <Card title="Architecture" href="/docs/architecture" description="Six pieces, one runtime — SessionRuntime, CompiledGraph, Channels, Seams, the AuditableCall ledger, and the event log." />

  <Card title="Concept clusters" href="/docs/concept-clusters" description="Seven cluster triplets at four depths — the full concept map of the substrate, from session/turn/row down through routing, audit, and persistence." />

  <Card title="Turn lifecycle" href="/docs/turn-lifecycle" description="One user message in, one answer out — what the runtime, the client, and the ledger each see, in order." />

  <Card title="Glossary" href="/docs/glossary" description="Canonical terms — anchor-plan, CallClass, family-lock, seam, and the rest of the vocabulary." />
</Cards>

## What this site is not [#what-this-site-is-not]

* Not where the package source lives. `@pleach/core` is published from
  the upstream repository at `github.com/pleachhq/core` and consumed
  here as a documentation target — the version of `@pleach/core`
  rendered against this site is whatever the package manifest pins.
* Not the canonical reference for any individual package — each
  package's README on npm is. If this site disagrees with a published
  README (a row in the [model resolution matrix](/docs/model-resolution-matrix),
  a field name in the [AuditableCall row](/docs/auditable-call-row),
  a verdict in the [stream-observer ladder](/docs/architecture#3-seams)),
  the README wins.
