Development & verification
Set up the workspace, run the verification suite, regenerate contracts, preview the docs site, and see how CI publishes releases.
This guide is for contributors. It covers how to set up a local development environment for Brain, run the full verification suite, regenerate the OpenAPI document and SDK wire types, preview the documentation site, and how CI tests and publishes each release.
Prerequisites
- Go
1.26+(go.moddeclaresgo 1.26.0) - Node.js
24+andnpm
Python 3.11+ must also be available as python for the sandbox execution fixture.
1. Install workspace dependencies
Install the locked dependencies for the three harness runners, TypeScript SDK, sandbox and browser services, documentation site, and dashboard:
node scripts/setup.mjsThe script installs each workspace lockfile and Chromium for the browser journeys. On Linux, install Chromium's OS dependencies with npm --prefix tools/browser exec -- playwright install-deps chromium.
To build BrainServer from the repository root, run:
npm run buildThis builds the Pi harness, TypeScript client, and Go executable together and writes npm archives to dist/server/. Use npm run build -- --all-platforms to cross-compile all six supported platforms.
2. Run all checks
Run node scripts/check.mjs before you commit:
node scripts/check.mjsIt runs these steps in order and stops at the first failure:
go run ./services/brain/cmd/generate -checkandnode clients/sdks/typescript/scripts/generate.mjs --check: verify the service OpenAPI contract, runtime protocol schema and TypeScript declarations against their Go sources.npm --prefix runtimes/pi run build: compiles Pi; Codex and OpenCode build commands validate their JavaScript entry points.npm --prefix clients/sdks/typescript run build: compiles the TypeScript SDK (clients/sdks/typescript/dist/).node scripts/package-sdks.mjs: packs and installs the npm package in an isolated consumer, then runs client tests, CLI help and a strict TypeScript consumer check. The suite also runsnpm run buildandnode --test tests/server-package.test.mjs. These build the server, Pi harness, and client together, install their npm archives outside the checkout, and exercise model calls, application tools, restart recovery, startup failures, and parent-exit cleanup. Linux CI cross-compiles the six platform executables into the tested server release artifact.go test -count=1 ./...: runs all Go unit and integration tests across the services, runtimes and shared packages.go vet ./...: runs Go static analysis.npm --prefix runtimes/pi test: runs the Pi runner unit and integration tests against a local recording provider.npm --prefix clients/sdks/typescript test: runs the TypeScript SDK test suite.- The sandbox and browser services run their test suites, including real Chromium network and cancellation checks.
- The three suites in
tests/journeys/run the end-to-end journeys through installed clients and all three native harnesses, including browser attachment and the remote service. node --test tests/platforms.test.mjs: validates the platform deployment examples underexamples/platforms/.node --test tests/registry-artifacts.test.mjs: tests the SDK release workflow's admission checks and registry publication, including partial uploads, registry outages, and version reuse.npm --prefix sites/docs run build: generates the derived docs pages and builds the static Next.js / Fumadocs export.npm --prefix sites/docs test: runssites/docs/scripts/site.test.mjs.npm --prefix sites/dashboard run buildandnpm --prefix sites/dashboard test: builds the dashboard and verifies authentication, session workflows, reconnects, usage accounting, and mobile navigation in Chromium.
3. Regenerate contracts and docs
When you edit Go route declarations, wire structs, or shared Markdown sources, regenerate the derived artifacts:
# Regenerate services/brain/api/openapi.json, runtimes/pi/src/generated.ts,
# clients/sdks/typescript/src/generated.ts, and runtimes/host/protocol.json
go run ./services/brain/cmd/generate
node clients/sdks/typescript/scripts/generate.mjs
# Regenerate sites/docs/content/docs/** generated pages and sites/docs/public/openapi.json
npm --prefix sites/docs run generate4. Preview the documentation site
Regenerate the derived pages and start the local Next.js development server:
npm --prefix sites/docs run devOpen http://127.0.0.1:3000/docs. To test the static production export locally, build it, run the site tests, and serve sites/docs/out on port 3000:
npm --prefix sites/docs run build
npm --prefix sites/docs test
npm --prefix sites/docs startWhere to edit what
The dashboard lives in sites/dashboard/. Build the TypeScript SDK, then run npm --prefix sites/dashboard run dev to open it on port 3100. See the dashboard guide for connecting to a deployment and using the session workspace.
Don't hand-edit generated files (services/brain/api/openapi.json, runtimes/pi/src/generated.ts, clients/sdks/typescript/src/generated.ts, sites/docs/public/openapi.json, or generated MDX pages). Edit the source of truth and run the corresponding generator:
| Area | Source of truth | Regenerate with |
|---|---|---|
| HTTP routes, summaries, and wire types | services/brain/internal/http/contract.go & services/brain/api/types.go | go run ./services/brain/cmd/generate, node clients/sdks/typescript/scripts/generate.mjs, then npm --prefix sites/docs run generate |
| Harness & storage Go interfaces | runtimes/host/harness.go, runtimes/host/process.go, services/storage/archive/*.go | npm --prefix sites/docs run generate |
| Model catalog | Pinned @earendil-works/pi-coding-agent in runtimes/pi/package.json (runtimes/pi/scripts/model-catalog.mjs) | npm --prefix sites/docs run generate |
| Persistence guide | docs/running-persistence.md | npm --prefix sites/docs run generate |
| Local tools walkthrough | examples/tools/README.md | npm --prefix sites/docs run generate |
| Sandbox service guide | tools/sandbox/README.md | npm --prefix sites/docs run generate |
| Resource service guide | tools/resources/README.md | npm --prefix sites/docs run generate |
| Platform examples guide | examples/platforms/README.md | npm --prefix sites/docs run generate |
| Roadmap | docs/roadmap.md | npm --prefix sites/docs run generate |
| Docs pages & guides | sites/docs/content/docs/**/*.mdx | npm --prefix sites/docs run build |
Follow the writing guide when you change the README, a docs page, or a shared Markdown source.
Repository ownership
services/<service>/cmd/<program>/contains Go executable startup and configuration. Each service owns itsapi/and privateinternal/packages.services/brain/api/openapi.jsonis generated from Brain's Go types and route declarations using Huma schemas.openapi-typescriptgenerates the TypeScript contract;openapi-fetchimplements typed SDK requests.clients/cli/uses Commander and the public SDK. Its build helper lives inclients/cli/scripts/; repository packaging and verification live in rootscripts/.runtimes/owns agent integrations and runnable payloads. The generic Sandbox service owns their environments and processes. See the runtime layout.services/storage/internal/dirlock/is Storage's private cross-platform directory ownership lock. Shared exporter configuration lives inservices/shared/telemetry/; service instruments stay beside their emitters.
Design documents
The roadmap lists release stages, planned work, and integration status, and links every design document. Start with the Brain intents for ownership boundaries and design decisions, and the implementation plan for how the work is split across runtime, persistence, harnesses, tools, API, and operations.
CI and releases
The CI workflow runs on every push and pull request, and weekly:
- Checks:
node scripts/check.mjson Linux and Windows. On Linux, the job also builds the Brain and sandbox tool images and smoke-tests both containers. - Race detection:
go test -race ./...on Linux. - PostgreSQL: the session index tests against a real PostgreSQL server.
- Docs: builds the site for its GitHub Pages path and runs the site tests.
- CodeQL: code scanning for Go, JavaScript/TypeScript, Python, and GitHub Actions.
Nothing publishes unless every job passes. After that, each push to main:
- Publishes the tested images to
ghcr.io/aexhq/brainandghcr.io/aexhq/brain-sandbox-tools, taggedsha-<commit>andmain, with build provenance attestations. - Deploys the tested docs site to GitHub Pages, then smoke-tests the published site.
- Starts the SDK release, which publishes the SDK archives tested on Linux to npm through registry trusted publishing, without rebuilding them, and attaches the same archives to a GitHub release.
SDK 2.1.0 is the client for the current server and replaces the predecessor's 0.x API. The server's routes and local state have no versioning or compatibility layer, so pin production images by digest and use the SDK version that matches your server commit. SDK delivery covers versioning, the release workflow, and registry setup.