B4.run: Build TypeScript Agents
B4.run is a framework for building TypeScript agents where tools, planning, memory, skills, subagents, and evals are organized as files. It provides workspaces, sandbox execution, and approval gates, and scaffolds an app with one command.
About this tool
B4.run is aimed at TypeScript developers and AI agent builders for building TypeScript agents. Its core idea is that files are features: tools, planning, memory, skills, subagents, and evals are all organized as files. Key capabilities include: - Tools: each tool is one file with a default-exported function that receives parsed args and a read-only ctx (toolName, routeId, threadId, signal, params), and can be async. - Routes and agents: define agents with the agent() descriptor, supporting four route kinds, and generate a type module .b4/b4.generated.d.ts that maps each route pathname to that route's tool signatures. - Workspaces and sandbox execution: supports workspaces and sandbox execution. - Approval gates: can ask a person before each call to certain tools. - Subagents: the parent gets the child's final text back as the tool result. - Retry and reasoning: supports retry configuration (e.g. maxAttempts, baseDelay) and reasoning effort (e.g. effort: high). - Recording and replay: supports recording and replaying model responses. - Offline agent test: provides an offline agent test. Usage: scaffold an app with npm create b4-app@latest my-agent. Running b4 run looks up the route's <routeId>#<kind> assistant id, creates a thread for the call, sends the input through Agent Protocol, and prints the final state. --dry-run creates no model and performs no write.