Pleach
A typed agent runtime where every tool call and subagent spawn rolls up to the turn — joinable to billing or compliance in one GROUP BY.
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.
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. - 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. - AuditableCall row. One append-only typed row per LLM call,
keyed by
turnId. CarriestenantId,toolName,subagentDepth,modelId, andtokenUsage. The grain every cost rollup, compliance query, and replay reads from. See The AuditableCall 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.
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 for the diagrams and
turn-lifecycle for the walk-through.
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 for the canonical per-SKU status table.
Start here
Pick the closest; the sidebar carries the rest.
Try it in 5 lines
One install, one route handler, one component. Streaming chat against your chosen provider in ~5 minutes.
Which SKU do I need?
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.
Decide if Pleach fits
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.
Adopt for audit, cost rollup, and compliance
The AuditableCall row, per-turn cost attribution, scrubbers, the hash chain, and the CI gates that hold it.
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.
Migrating from Anthropic Enterprise
Keep SSO, ZDR, Workspaces, the Admin API. The three downstream walls the contract doesn't cover, and how the AuditableCall row closes each one.
Migrating from OpenAI Enterprise
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.
Read next
Overview
The runtime in pictures — session, turn, the four stages, and the ledger row that closes the loop.
Architecture
Six pieces, one runtime — SessionRuntime, CompiledGraph, Channels, Seams, the AuditableCall ledger, and the event log.
Concept clusters
Seven cluster triplets at four depths — the full concept map of the substrate, from session/turn/row down through routing, audit, and persistence.
Turn lifecycle
One user message in, one answer out — what the runtime, the client, and the ledger each see, in order.
Glossary
Canonical terms — anchor-plan, CallClass, family-lock, seam, and the rest of the vocabulary.
What this site is not
- Not where the package source lives.
@pleach/coreis published from the upstream repository atgithub.com/pleachhq/coreand consumed here as a documentation target — the version of@pleach/corerendered 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, a field name in the AuditableCall row, a verdict in the stream-observer ladder), the README wins.