ChainLayerTwo

The coding agent that stays in your terminal.

ChainLayerTwo reads, edits and runs code in your project from the command line. It works on the hosted gateway out of the box, on a model running on your own machine, or on DeepSeek, Kimi and Anthropic with your own key. Every turn is journalled while it runs, so a crash resumes instead of starting over.

Windows irm https://chainlayertwo.online/install.ps1 | iex
macOS and Linux curl -fsSL https://chainlayertwo.online/install.sh | sh

Needs Node 20 or newer. The installer checks the download against its SHA-256 and installs nothing if it disagrees. Already installed? Run chainlayertwo update, or type /update in the CLI.

chainlayertwo, after a turn on a local model
The ChainLayerTwo terminal: a shaded iron ball on a chain of interlocking links above the status line, which shows the local model ollama/qwen2.5-coder:0.5b, step 1 of 200, 0 of 500 tools and the RCP indicator.
hosted gateway uptime, 30 days /v1 requests, 24 hours models online Live from the public stats API. All stats

chainlayertwo updatenew in 0.5

Your own models, a controller that watches the run, and a faster CLI.

Release 0.5 changes what the agent can talk to and how you move around it. The full list ships with the CLI in its changelog.

/localmodel

Local models, one command

/localmodel (or /local) finds the models running on this machine under Ollama, llama.cpp or LM Studio and switches to the best one: a model that is already loaded first, then a coding model.

  • /localmodel hf coderSearch Hugging Face live for GGUF models.
  • /localmodel hf info <repo>The largest quant that fits your VRAM or RAM.
  • /localmodel pull <repo[:quant]>Download it. If Ollama refuses the hf.co redirect, the CLI fetches the file and imports it.
  • chainlayertwo --localStart a session on the best local model.

Direct providers work without the gateway in between: Ollama, llama.cpp, LM Studio, DeepSeek, Kimi and Anthropic. Switch mid-session with /provider use and the conversation is kept.

chainlayertwo localmodel setup
  1. Checks the hardware and local serverMemory, and whether a local server is running.
  2. Installs or starts OllamaOnly with your approval.
  3. Picks a model that fitsSized to the memory it found.
  4. Downloads itThrough Ollama, or directly from Hugging Face.
  5. Verifies it with a real tool-calling turnOne turn that has to call a tool.
  6. Saves it as the defaultWith the config diff shown first. Re-run it any time.
/rcp

The RCP meta-controller

The Recursive Cyclic Perceptron runs over every agent run, whichever model is active. We call it “him”. He reads each step through a ternary cube, an eleven-node wheel and a nine-by-nine lattice, learns online from outcomes, and by default adds a short grounding note. He does not generate text.

In steer mode, which you turn on yourself, he can compact context and move along a model ladder. He always asks before switching to a paid provider and never bypasses the approval, policy or budget gates. Open the /rcp panel to watch him.

The RCP pipeline: a three-face cube feeds an eleven-node wheel, which feeds a nine by nine lattice.+*Ω
3-face cube+ expansion, − contraction and * tension, meeting at the resolve vertex.
11-node wheelL, R and G quadrants, Ω synthesis at node 10 and the gate at node 11.
9×9 latticeThree scales (step, recent, session) by three channels (tools, model, context).

chainlayertwo doctora captured run

This is what it prints.

A real session, reproduced verbatim: the launcher brings up the local stack, health-checks both gateways, then runs doctor. Nothing here was written for the website.

chainlayer2 --doctorexit 0
   Node v24.13.0  (recommended)
   OmniRoute service key resolved
   MCP bearer token resolved

  Bringing up the local ChainLayer stack…
   OmniRoute (model gateway) already running — http://localhost:20128/v1 (reusing)
     hardened: no-key → 401, service-key → 200
   ChainLayer2 MCP (tool gateway) already running — http://localhost:8930/mcp (reusing)
     /health → 200, /mcp no-token → 401 (bearer-gated)

  ✓ Local ChainLayer stack is up.

  ▶ chainlayer doctor   (composition health)
  ────────────────────────────────────────────────────────────
[PASS] omniroute.health        25ms  reachable at http://localhost:20128/v1 (HTTP 401)
[PASS] omniroute.auth          21ms  no key → 401, service key → 200
[PASS] omniroute.catalog       20ms  115 models (auto/best-coding, auto/best-reasoning, auto/best-fast, …)
[PASS] omniroute.completion  2384ms  auto/best-coding → "pong"
[PASS] mcp.health               2ms  http://localhost:8930/health → 200
[PASS] mcp.auth                 4ms  no token → 401, token → HTTP 200 (reaches init)
[PASS] mcp.initialize          15ms  initialized "chainlayer2-local" (http://localhost:8930/mcp)
[PASS] mcp.tools                0ms  12 tools (math_eval, math_simplify, math_derivative, math_solve, unit_convert, matrix_op, …)
[PASS] mcp.math_eval            3ms  math_eval(173 * 419) = 72487
[WARN] mcp.protocol_inspect     3ms  RE plane disabled / requires host binary (expected)
[WARN] unreal.availability      0ms  Unreal MCP not federated/reachable (expected in this deployment)

summary: 9 pass, 2 warn, 0 fail — OK (exit 0)
Captured on Windows 11 with Node v24.13.0 and NO_COLOR=1. Both services were already running, so the launcher reused them.

Why math_eval is the proof

173 × 419 = 72487 has no local shortcut. A correct answer means the call really crossed the MCP server the launcher had just checked.

Two warnings, on purpose

The reverse-engineering tools stay off until you set RE_ALLOWED_DIRS, and no Unreal MCP was connected. doctor exits 1 only on a real failure.

115 is a reading

The catalog count is what /v1/models returned on that machine. It moves with which providers are reachable.

So is the tool count

This capture predates the current MCP server, which registers 46 tools. tools/list on an endpoint is the only authority.

trace_idhow it fits together

Three planes on one chain, under one policy.

A task enters at the CLI, which mints one trace_id and carries it through every hop. The policy set at the top (sandbox, approval gate, budgets) is inherited by everything below it and never decided again.

chainlayertwo.online/v1, or 127.0.0.1:20128

OmniRoute, the model gateway

One OpenAI-compatible endpoint in front of many providers, with role routes such as auto/best-coding and provider fallback. It always needs a key.

127.0.0.1:8930/mcp, bearer

ChainLayer2 MCP, the tool gateway

One bearer-gated Model Context Protocol server with 46 tools for math, data, devtools, fetch and search, knowledge, re-grounding and authorized reverse engineering. The tool list

in the CLI

Parallel sub-agents

A journalled agent loop fans work out to 2 to 8 sandboxed sub-agents. Each inherits the same policy, all draw on one budget, and one fenced merger combines the results.

A separate control plane, the ChainLayer API, runs durable jobs on a crash-recoverable worker. It is deployed on its own and is not part of the one-line install.

--sandboxsafety by design

The guardrails are the product, not a setting.

No flag, mode or tool exists to weaken a safety control. The policy that governs one task governs every sub-agent it starts.

Sandbox and path confinement

A run's policy is frozen when it starts. --sandbox blocks writes and the shell, file tools stay in the working directory, and reverse-engineering tools stay inside allow-listed folders.

Approval that fails closed

Parallel runs use an approval gate with no interactive path: a request it cannot approve is rejected. No prompts pile up from sub-agents, and nothing is silently allowed.

Fan-out is one level deep

Sub-agents inherit the parent's policy and lose spawn_agents, so they cannot start agents of their own.

One shared budget

A task defaults to 200 steps and 500 tool calls, and --deadline adds a hard stop. Four sub-agents share one budget; they cannot spend four times as much.

Trusted models by default

The CLI classifies every backend before using it. Providers tiered experimental or anonymous are refused unless your policy names them.

Fenced writes, checked tokens

A superseded worker's write updates nothing and gets a typed stale_fence. Every MCP request is bearer-checked before dispatch; a missing or wrong token is always 401.

The objective is never dropped

Context fitting pins your original request and the latest summary. Long tool output is trimmed with a marker, and the conversation compacts at 70% of the window.

Turns survive a crash

Progress is written to a journal as the turn runs. After a crash or a closed terminal, the next launch offers /retry to resume it.

install.ps1, install.shinstall and update

One line. Then read what it tells you.

The installer chooses one of two paths and prints which one and why. They give you different things, so the difference is worth a minute.

Windows PowerShellirm https://chainlayertwo.online/install.ps1 | iex
macOS and Linuxcurl -fsSL https://chainlayertwo.online/install.sh | sh
Updatechainlayertwo update

Node.js 20+ on PATH (24 recommended). The installer downloads cli.js, checks it against the SHA-256 in version.json, and installs nothing if the digest disagrees. Inside a session, /update does the same as chainlayertwo update.

CLI only

default

What you get when nothing is serving 127.0.0.1:20128 and you did not ask for more.

  • The chainlayertwo command on your PATH
  • Pointed at the hosted gateway, https://chainlayertwo.online/v1
  • No account needed: the installer writes a shared public key into your config, so the first run works
  • About twenty seconds; nothing is cloned or compiled
  • No MCP tools. Add them with the full stack, or point mcpServers at an endpoint you hold a token for

Full stack

opt in

Chosen automatically when an OmniRoute checkout sits beside a ChainLayer checkout, or on request:

$env:CHAINLAYERTWO_FULL='1'; irm https://chainlayertwo.online/install.ps1 | iex
  • OmniRoute on 127.0.0.1:20128, started with REQUIRE_API_KEY=true, seeded with your local and keyed providers
  • ChainLayer2 MCP on 127.0.0.1:8930, with a bearer token minted on this machine
  • Both gateways health-checked before the installer reports success
  • Needs git, npm and a ChainLayer checkout; the first build takes 1 to 3 minutes

Commands to start with

  • chainlayertwoThe interactive session.
  • chainlayertwo "add tests to ./src"A one-shot task in the current folder.
  • chainlayertwo doctorA health report for every stage.
  • chainlayertwo --sandbox "…"Read-only: every tool that changes something is blocked.
  • chainlayertwo --deadline 5m "…"A hard stop on top of the step and tool budget.
  • /remotePair a phone to drive this session through the remote page.
install.ps1, CLI-only path (abridged)
> irm https://chainlayertwo.online/install.ps1 | iex

   Node v24.13.0
  Path: CLI-ONLY
    reason: no local stack was found and none was requested

  Fetching release manifest …
   chainlayertwo 0.5.1
  Downloading CLI bundle …
  ✓ Verified SHA-256 d3cca924c9f68071…
  ✓ Installed chainlayertwo 0.5.1
   Config written (baseUrl: https://chainlayertwo.online/v1)

  ChainLayerTwo 0.5.1 is installed and verified.

  TOOLS ARE NOT AVAILABLE on this install.
    no MCP tool server is configured, so file/shell tools are off.
The hash prefix and version are written from version.json when a release is built.

chainlayertwo loginaccounts, optional

An account is optional. The CLI signs in from the terminal.

The CLI and the hosted gateway both work without signing in. An account gives you your own daily quota and self-serve gateway keys: one on a free account, up to five on a privileged one. There is no password field in the CLI; chainlayertwo login uses a device code you approve in the browser.

  1. Run chainlayertwo loginThe CLI asks the account service for a short code and prints it.
  2. Approve it in the browserThe CLI opens the approval page. Sign in or create the account there, then approve the code you were shown.
  3. The CLI polls until you decideEvery five seconds. Deny, and it stops; wait fifteen minutes, and the code expires.
  4. One token, issued onceApproval mints a bearer token and burns the code in the same step. It is saved to ~/.chainlayer/credentials.json on your machine.
What the account service keeps

Only the SHA-256 of each device code, never the code itself. New accounts start as pending: they can sign in and approve devices straight away, and the gateway answers them once an admin approves.

Afterwards: chainlayertwo whoami, chainlayertwo logout. Compare the access tiers.

not shippedroadmap

Two agents the platform is being built to carry.

Everything above ships today. The two agents below do not: no code in the repository implements either one. They are here so you can tell what the product does from what it is aimed at.

planned

Game-playing agent

Would read the rendered frame as vision input through the gateway, plan toward a goal, act through tool calls, and at a fork try routes with parallel sub-agents. Scoped to automated playtesting, regression runs and research, always under a step and time budget.

planned

Reverse-engineering and coding agent

Would identify, disassemble and decompile an authorized target, inspect its wire format, then write the interop shim or test. The agent is planned; its guardrails already ship in the MCP server: an authorized: true attestation on every RE tool, RE_ALLOWED_DIRS, a denylist no flag overrides, and an audit log of every call.