Every page, by package
Grouped by package and by what you need: a tutorial to learn, a how-to to get something done, reference for facts, explanation to understand. Or just ask on the home page.
Overview
Overview
- inbrowser
The inbrowser monorepo: a resumable job engine, an inference relay, an agent runtime, and an on-device model engine.
Agent Context
- Agent context for the inbrowser monorepo
Repo shape, conventions, and invariants for agents working across the monorepo.
@inbrowser/agent
Overview
- @inbrowser/agent
Agent runtime plus an agent-friendly CLI: AgentSession, AgentStrategy, ToolRegistry, ModelClient, and an `agent` binary.
Tutorial
- Tutorial: Drive A Session From Your Code
Build a complete agent session in TypeScript with a scripted LLM (no API key or network) that calls a tool then writes a reply.
- Tutorial: Run The Agent CLI
Drive the `agent` binary: discover its schema, run a scripted scenario, read the NDJSON event stream, and find the durable session log.
- Tutorial: Serve Agents Over MCP
Expose your own tools to an external host over MCP: define an agent, stand up an MCP stdio server, and point a host at it.
How-To
- How to implement a custom ModelClient
Plug an upstream LLM API into a session by implementing the narrow `ModelClient.chat()` async generator and mapping its stream to ModelEvents.
- How to consume an external MCP server
Give an agent the tools from an external MCP server with `connectMcpTools`, so the session calls them through the same in-process loop.
- How to define and register tools
Define a ToolHandler, register it in a ToolRegistry, and dispatch it, including mutating session state and marking read-only tools parallel-safe.
- How to inspect and undo with the event log
Audit what an agent did to a project and reverse a mutating commit using the `agent` CLI against the per-project append-only event log.
Reference
- Library Reference
The public library surface of `@inbrowser/agent`, exposed across three import subpaths.
- CLI Reference
The `agent` binary, derived from CLI_SPEC, the single source of truth the parser and the schema/describe commands surface verbatim.
- Event Reference
The three discriminated-union event streams in `@inbrowser/agent`, each a typed AsyncIterable consumed at a different layer.
Explanation
- Inference vs Inverse: The Two Consumer Modes
The two ways to consume the package come down to who owns the loop, the single most important mental model for working with it.
- How the ReAct Loop Works
What createReactLoopStrategy() is, why it is shaped that way, and the trade-offs baked into its two optional behaviours.
Agent Context
- AGENTS.md — @inbrowser/agent
Invariants, anti-patterns, and workflow patterns for driving the agent runtime and CLI.
Skill
- Skill: drive the agent CLI
Step-by-step skill for running sessions, fleets, event-sourced audit/undo, and forward replay through the CLI.
@inbrowser/workspace
Overview
- @inbrowser/workspace
Browser-native workspace runtime: OPFS/memory files, esbuild preview compilation, jailed browser shell, isomorphic-git, package import maps, and optional agent tool adapters.
Tutorial
- Tutorial: Create A Browser Workspace
Create a browser workspace, write a tiny React app into /work, and prepare file, shell, and git services for an app-builder agent.
How-To
- How To Preview A React App Without A Dev Server
Preview a React/TSX app by compiling the workspace entry module and evaluating it with host-provided React modules.
Reference
- API Reference
The public surface of @inbrowser/workspace: workspace creation, file systems, preview, shell, git, packages, and agent tools.
Explanation
- Why This Is Not Browser Node
Why the workspace runtime chooses compile-and-mount preview, host modules, structured shell/git/package services, and explicit limits over a partial browser Node illusion.
@inbrowser/sandbox
Overview
- @inbrowser/sandbox
Sandbox orchestration above @inbrowser/workspace: runtime events, standard agent tools, checkpoints, and a workspace adapter for browser-native app builders.
How-To
- How To Wire A Sandbox Into An Agent
Expose browser workspace tools to an @inbrowser/agent session with @inbrowser/sandbox and the @inbrowser/agent/sandbox bridge.
- How To Manage Checkpoint History
Create, restore, query, and prune sandbox checkpoints with turn, message, and tool-call metadata for agent-session restore flows.
Reference
- API Reference
The public surface of @inbrowser/sandbox: sandbox contracts, workspace adapter, standard tools, checkpoints, events, and the agent bridge.
Explanation
- Sandbox Architecture Overview
How @inbrowser/sandbox absorbs Piebox-shaped orchestration into the inbrowser package suite while keeping runtime substrate, workspace services, and agent loops separate.
- Remote Container Bridge
How Apple container, WSL containers, and similar remote Linux runtimes fit into the sandbox boundary while the browser renders results.
- Why Sandbox Tools And Agent Tools Are Separate
Why sandbox side effects stay on the sandbox, agent policy stays in @inbrowser/agent, and createSandboxAgentTools adapts between them.
Agent Context
- AGENTS.md — @inbrowser/sandbox
Package invariants for sandbox tools, events, checkpoints, and workspace adapters.
@inbrowser/relay
Overview
- @inbrowser/relay
Resumable LLM inference relay: a pure transport that serves ModelClient factories from @inbrowser/model over HTTP, plus a reconnecting browser client.
Tutorial
- Tutorial: Create A Relay With A Fake Provider
Build a relay over a memory store and a fake provider, start a job, stream it, and resume from an offset.
How-To
- How To Wire A Web App
Mount the relay in Astro, Express, or any Web-standard runtime, and consume the stream from the browser.
- How To Write A Provider
Implement a ModelClient for an upstream LLM: parse SSE upstreams, emit ModelEvent tool calls, and register it as a ModelClientFactory.
- How To Use A Subscription Claude Provider
Reach Claude through a subscription with no API key, using the claude-code (Agent SDK) or claude-cli (claude -p) providers.
Reference
- API Reference
createRelay, NormalizedRequest, the re-exported ModelEvent/ModelClient contract types, ModelClientFactory, the handlers, adapters, SSE helpers, and the client.
Explanation
- How The Relay Works
The job lifecycle, why providers and adapters are separate, what is stored, and offset-based replay.
@inbrowser/resumable
Overview
- @inbrowser/resumable
Resumable streaming-job engine: a pluggable JobStore plus a JobEngine that streams events into a durable, tailable log.
Tutorial
- Tutorial: Build A Resumable Stream
Create the engine, start a producer, read the stream, replay from an offset, and stop cleanly.
How-To
- How To Use RTDB For Durable Jobs
Configure the Firebase RTDB store, add the sweep index, use a service-account token provider, and verify durability.
Reference
- API Reference
createJobEngine, the producer surface, subscription events, the JobStore contract, memory + RTDB stores, and sweeps.
Explanation
- How Resumable Jobs Work
Engine and store, sequence numbers as the resume contract, terminal state vs events, and TTL retention.
@inbrowser/model
Overview
- @inbrowser/model
The model layer: the lightweight ModelClient contract at the root, cloud providers under @inbrowser/model/providers/<name>, and an opt-in on-device LLM engine under @inbrowser/model/local.
Tutorial
- Tutorial: Run A Model In The Browser
Load a small language model into a browser tab and stream its reply token by token, with no server, API key, or cloud inference.
- Tutorial: Run The Model In A Worker
Move the same engine into a Web Worker so the model loads and decodes off the main thread and the page stays responsive.
How-To
- How To Choose A Preset
Pick the bundled ModelPreset whose declared capabilities and download cost match what your app needs, or define your own.
- How To Use A Local Model In Relay
Wrap an on-device engine as a ModelClient with createEngineModelClient, then expose it through a relay provider factory.
- How To Use A Local Model In The Agent
Wrap an on-device engine with createEngineModelClient and pass it directly as an agent session's llm.
- How To Handle Thinking And Tool Calls
Separate a model's reasoning trace and tool-call envelopes out of the raw token stream so you can route them to different surfaces.
Reference
- Engine Reference
The @inbrowser/model/local export: the engine factory, the Engine surface, the event vocabulary, and the stream transformers.
- Presets Reference
The @inbrowser/model/local export: the bundled ModelPreset values and the static types they carry.
- Worker Reference
The worker helpers in @inbrowser/model/local that host an Engine in a Web Worker and connect to it behind the same Engine surface.
- Gateway Provider Reference
OpenRouter and Requesty configuration, attribution headers, reasoning controls, usage telemetry, and shared OpenAI tool encoding.
Explanation
- Why The Engine Is Shaped This Way
The load-bearing decisions behind the small Engine surface and the trade-offs each one accepts.
- On-Device Inference
The stack that makes running an LLM in a browser tab possible, the constraints it imposes, and why you would choose it over the cloud.
Agent Context
- Agent context for @inbrowser/model
Purpose, layering invariants, and vocabulary for the on-device model engine.