An agent framework, the way I'd build it.
Write the agent. Give it tools. Set the limits. Ship code you can actually read. B4.run adds file-system routes, generated types, workspaces, sandbox execution, and approval around LangGraph.js. Keep your application code in TypeScript.
Get started · Migrate from LangGraph.js · Documentation · Discussions
npm create b4-app@latest my-agenttake2.mp4
The 50-second demo shows one agent file, weather and performance subagents, a
computed navlog, approval-gated filing, memory, and a conversation restored
after a reload. Model turns are scripted and the weather API is stubbed, so the
video rebuilds offline. Build the same app with
npm create b4-app@latest my-navlog -- --template navlog.
Read the navlog demo transcript.
Requires Node.js 24 or later and npm 11. No API key needed:
npm create b4-app@latest my-agent
cd my-agent
npm install
npm testnpm test runs the starter's fixture-backed test offline — no API key, no
model calls.
- Author the application shape, not route wiring. Put one supported entry in
a route's
src/app/**/index.ts; B4.run discovers the route. Shared tools live insrc/tools/, while route-local tools can live beside the route and remain subject to its runtime policy. - Let generated types follow the route. B4.run generates TypeScript route, parameter, state, and tool declarations during typegen and build. State types are emitted when the discovered state schema supplies valid defaults.
- Make the normal test loop deterministic. Fixture-backed tests replay committed responses and fail on an unmatched interaction instead of silently calling a provider. Live and recording modes remain explicit opt-ins.
- Carry one project from local state to build artifacts. Default
SQLite-backed state can survive a
b4 devrestart when the app root and its SQLite files persist. The default build emits a runnable Node server, Dockerfile, and LangSmith graph artifacts; validate the runtime, storage, auth, and provider boundary for the deployment target you choose. - Set the limits in the route.
tools.denyremoves a tool from a route, andtools.approvepauses a call until a person answers, with each answer spending a single-use approval grant. Permissions gate shell commands and file paths outside the workspace, an opt-in sandbox isolates the workspace tools, and the security architecture covers the authentication you put in front of the runtime.
The navlog template's whole agent is one route file:
// server/src/app/navlog/index.ts (description and system prompt abbreviated)
import { agent } from "@b4run/sdk"
export default agent({
model: "gpt-5-mini",
recursionLimit: 100,
description: "A VFR flight planner for a Cessna 172N…",
tools: { deny: ["runBash"], approve: [{ tool: "fileFlightPlan", allowAlways: false }] },
systemPrompt: "You are a VFR flight-planning assistant for a Cessna 172N…",
})| Layer | Role |
|---|---|
| LangChain | Remains available. B4.run's built-in agent() uses LangChain integrations; raw graph and chain routes keep their own imports and providers. |
| LangGraph.js | The graph runtime, required by B4.run. B4.run adds application conventions around it rather than replacing it. |
| B4.run | Supplies file-system routing, generated types, local test and development conventions, persistence primitives, and build targets around LangGraph.js. |
| Deployment and observability choices | Model providers and LangSmith stay external. B4.run emits a Node server and LangSmith artifacts by default, with other targets opt-in; it does not provision infrastructure, host the app, or manage secrets. |
| You author | B4.run discovers or emits |
|---|---|
One agent, workflow, graph, or chain entry in a route's index.ts |
The route identity and runtime entry |
Shared tools in src/tools/ and optional route-local tools in the route's tools/ directory |
The tool set available at that route, subject to tool policy and runtime constraints |
| Optional state schemas and typed tool signatures | Regenerated route, route-parameter, state, and tool declarations; state exports require discoverable defaults |
| Fixture-backed tests and application configuration | A deterministic replay path for those fixtures; live and recording paths stay explicit |
| Application source | A runnable Node server, Dockerfile, and LangSmith graph artifacts from the default build |
Already have a graph? Keep its nodes, edges, and imports, expose it as a raw
graph route, and validate invocation and checkpointer behavior for each target.
The full migration guide
covers that incremental path.
Start with the flight planner, a
VFR flight planner for a Cessna 172N: live weather tools, a navlog computed in
code from the POH, weather and performance subagents, memory, planning, and
flight-plan filing behind approval. Scaffold it with
npm create b4-app@latest my-navlog -- --template navlog.
- Developer agent: reproduces a historical defect, repairs it in an isolated workspace, verifies the patch independently, and asks before exporting it (code walkthrough)
- Flight planner example source
- Chat and workspace assistant
- Memory-backed agent
- Routes and workflows guide
- A good fit: a TypeScript team wants LangGraph.js with file-system routes, generated types, a local test and development loop, persistence primitives, and build targets. Some capabilities vary by build target.
- Stay with raw LangGraph.js: if you do not want B4.run's application conventions, or if your project requires Python. B4.run requires LangGraph.js and targets TypeScript and Node.js.
- Bring the ecosystem with you: existing raw LangGraph.js graphs can migrate
incrementally as
graphroutes. LangChain remains usable, and CopilotKit composes with B4.run through AG-UI. Check a migrated graph's checkpointer behavior on each deployment target.
B4.run is not a hosted AI platform or an infrastructure provisioner. You operate the emitted application or deploy it through a separate platform.
Give your coding agent the framework sources before it writes a route.
Copy this prompt
Scaffold a new B4.run app and help me build an agent. B4.run is the TypeScript meta-framework for LangGraph — agents and workflows are file-system routes with route-local tools, generated types, and durable threads. Run `npm create b4-app@latest my-agent` to scaffold, then read https://b4.run/AGENTS.md and https://b4.run/llms-full.txt for the full framework reference before writing any routes.
Credentials are provider-specific: the navlog starter's OpenAI live
path requires OPENAI_API_KEY, while a local Ollama route requires no provider
key.
Scaffold the navlog flight planner, a two-package npm workspace with a B4.run server and the B4.run Workbench, then add your key and check the app:
npm create b4-app@latest my-navlog -- --template navlog
cd my-navlog
npm install
cp server/.env.example server/.env # then set OPENAI_API_KEY in server/.env
npm run verifyStart the server:
npm run dev:serverIn a second terminal, start the Workbench:
npm run dev:webThe server listens on port 3002 and the Workbench on port 3010. The basic
starter runs live with npm run dev on port 3000 once OPENAI_API_KEY is set
in your shell.
The navlog root workspace defines the production build and start scripts:
npm run build
npm startChoose and validate the deployment boundary that matches your application: Node, LangSmith, edge targets, Vercel, or Kubernetes. B4.run emits the artifacts; it does not provision infrastructure, host the application, or manage its secrets.
B4.run is pre-1.0 and its API surface is moving. Pin versions and read the release notes and upgrade guide. Supported means documented public surfaces on the current release line, not a 1.0 stability or long-term support guarantee.
- Follow SUPPORT.md for support routes. Ask usage questions in GitHub Discussions and report defects in GitHub Issues.
- Report security issues through the process in SECURITY.md.
- See CONTRIBUTING.md and CONTRIBUTORS.md before contributing.
- Follow the Code of Conduct.
Ready to start?
npm create b4-app@latest my-agentMIT. See LICENSE.