pleach

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-plantool-loopsynthesizepost-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. Carries tenantId, toolName, subagentDepth, modelId, and tokenUsage. 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-loopsynthesize 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.

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.

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, a field name in the AuditableCall row, a verdict in the stream-observer ladder), the README wins.

On this page