Skip to content
Ask
Overview

@inbrowser/agent

Agent runtime plus an agent-friendly CLI: AgentSession, AgentStrategy, ToolRegistry, ModelClient, and an `agent` binary.

Agent runtime + agent-friendly CLI in one package. Three consumer surfaces:

  • Libraryimport { createAgentSession, createToolRegistry, ... }. Pure TypeScript, no React, no DOM, no fetch. The playground UI consumes the same primitives.
  • CLI — the agent binary. NDJSON output by default, --json stdin, --dry-run, schema introspection, automatic session logs.
  • MCP serveragent serve exposes agent tools over stdio so external LLM hosts (Claude Desktop, others) can drive them as MCP tools.

The library is browser-safe; the CLI and MCP server are Node-only.

Install

TERMINAL
bun add @inbrowser/agent
# or
npm install @inbrowser/agent

The agent binary lands in ./node_modules/.bin/.

A 30-second example

Library

TS
import {
  createAgentSession,
  createReactLoopStrategy,
  createToolRegistry,
  createDispatch,
  createMetricsCollector,
} from '@inbrowser/agent';

const session = createAgentSession({
  strategy: createReactLoopStrategy(),
  llm: yourModelClient,
  tools: createDispatch(createToolRegistry()),
  toolContext: () => ({ workspace, runtime, sandbox, lint, signal: new AbortController().signal }),
  metrics: createMetricsCollector(),
  history: [],
  id: 'sess-1',
  systemPromptBuilder: (workspace, runtime) => '…',
});

for await (const event of session.submit('hello')) {
  // SessionEvent stream — apply to your store / UI / log
}

CLI

TERMINAL
# Headless single session — text in TTY, NDJSON when piped.
agent run "build a chess rule set"

# JSON payload via stdin.
echo '{"prompt": "reset rules"}' | agent run --json -

# 10 isolated sessions in parallel.
agent fleet --size 10

MCP server

TERMINAL
# Expose agent tools over stdio for an external host.
agent serve --project my-project

CLI commands

CommandPurpose
runHeadless single session — text in a TTY, NDJSON when piped
fleetRun N isolated sessions in parallel
serveExpose agent tools over MCP stdio
eventsInspect a session’s event log
undoRoll back the last mutating operation via the event log
describePrint tool schemas / session metadata
schemaEmit machine-readable schema introspection
migrateMigrate session logs / event-log format
version, helpVersion string and usage

Subpath exports

EntrySurface
@inbrowser/agentBrowser-safe library — createAgentSession, createToolRegistry, strategies, metrics, storage adapters, event utilities
@inbrowser/agent/cliNode-only CLI internals — main, command handlers, arg parsing, the CLI_SPEC
@inbrowser/agent/nodeNode-only event-log writer — openEventLog, buildRollbackEvent, id generation

Where to go next

Documentation is organised under docs/ following the Diataxis framework:

If you want toRead
Follow a complete lessonTutorials
Accomplish a specific taskHow-to guides
Look up a function, event, or CLI flagReference
Understand the design choicesExplanation

Starting points by role

Position in the stack

@inbrowser/agent is the agent runtime — independent of domain packages. Hosts compose it with their own AgentDefinitions; the bare CLI ships zero built-ins.

See Inference vs inverse architectures for the two distinct consumer modes.

Licence

Same as the parent workspace.