browser ──WebSocket / HTTP──▶ Studio (Laravel) ──HTTP──▶ bridge (in the workspace) ──stdin/stdout──▶ claude -p
▲ ▲ │
└──── Reverb broadcasts ───────┴──── POST /api/bridge/events ──┘ per-workspace callback token
Studio ──sudo──▶ studio-admin create sites and workspaces, deploy, start, stop (JSON in, JSON out)
Studio ──HTTPS──▶ <key>.<domain> GET /larapilot/api/specs, /metrics
Git host ──webhook──▶ Studio push on the deploy branch → deploy the site
studio-update (root) ──▶ /opt/studio the channel's newest build: system step, build, migrate, switch, or roll back
Caddy ──ask──▶ Studio may I issue a certificate for this host?
Caddy ──forward_auth──▶ Studio may this visitor open this site or preview? (projects with access rules)
Studio ──HTTPS──▶ MCP servers the Test button; the chats reach them from the workspace
Studio ──HTTPS──▶ git hosts, clouds Tools → Git, the Repository tab, Home's git cards; the connectors' pages
bridge ──stdio──▶ Playwright MCP the agent's browser, signed in to the preview with the person's passSends turns, permission answers and interrupts to the bridge, warms the process of the next turn, and tells it with every turn where to call back and with which token.
Turns the bridge's events into messages,
permission requests, status changes and ConversationUpdated broadcasts. text_delta is
broadcast only, never stored.
Picks the driver: LocalDriver
for development, NativeDriver for workspaces on this server through the helper.
The client of the helper, and the lifecycle of a project site: create, deploy, destroy, the push webhook.
GitHub, GitLab,
Bitbucket, AzureDevOps behind one GitProvider: who a token belongs to, where it
may create repositories, the repository itself, the push webhook and how its deliveries are verified, the git user
name and the variables the agent's CLI and Larapilot read.
A person's
role on a project (User::roleIn reads it, and says administrator for an administrator everywhere);
a connector's row attached to a project, with the roles that see it, the roles that act on it and the actions
handed over.
The infrastructure connectors and the git hosts behind one model: accounts, sections with their columns, filters and actions, and the API client that runs them; the same console draws a connector page, Tools → Git and a project's Repository tab.
A conversation's sandbox: the worktree the bridge makes, the helper's database, build and preview host, merge, push and removal.
Reads the updater's state for Administration → System and asks the helper to check, to start an update (forced or not), to switch the channel or the nightly timer.
The access rules of a host (always the Studio login, narrowed by address lists and branch overrides) and the one-time token and per-host pass that let a Studio member in.
The MCP
servers of a project, with their encrypted header and roles, and the initialize call behind
Test.
ProvisionWorkspace, StartWorkspace,
StopWorkspace, SendTurn, AnswerPermission, RefreshWorkspaces,
ProvisionProjectSite, DeployProjectSite, ConfigureProjectSite,
DestroyProjectSite, DestroyWorkspace, ProvisionSandbox,
RemoveSandbox, SyncWorkspaceCredentials on the database queue, so a clone or a build
never blocks a page.
Events the bridge sends#
| Event | Studio does |
|---|---|
init | Keeps the session id and the model; the conversation is working |
text_delta | Broadcasts the slice to the open chat; nothing stored |
text, thinking | Stores an assistant message (reasoning hidden unless Details is on) |
tool_use, tool_result | Stores the call and folds the result under it; images in a result are kept on Studio's disk for the chat |
task | A subagent started or finished: the status and times of its card |
permission_request | Creates the pending request; the conversation waits |
permission_resolved | Marks the request if it was still open; working again |
result | Idle (or failed), keeps cost and usage, closes dangling questions as denied |
error | A red notice; the conversation is failed until the next message |
status | Broadcast only (rate limits, background task notes) |
plan_usage | Keeps the plan's usage (five-hour window, week) on the Claude account |
| anything else | Stored raw and hidden, so a renderer added later can show it |
The bridge#
A zero-dependency Node service in bridge/. It starts, per conversation,
claude -p --output-format stream-json --input-format stream-json --include-partial-messages --verbose
--permission-mode <mode> --permission-prompt-tool stdio, keeps stdin open so the next turn is one more
line, and resumes with --resume <session> after the idle release. A control_request
of kind can_use_tool is held until Studio answers; the answer is written back as a
control_response.
| Method | Path | Body |
|---|---|---|
| GET | /health | open: version and uptime only |
| GET | /info | version, workspace directory, sessions |
| POST | /conversations/{key}/turns | {text, session_id?, permission_mode?, model?, effort?, auth?, account?, claude_dir? | api_key?, mcp_servers?, browser?, sandbox?, callback: {url, token}} → 202, or 409 while a turn is still running; mcp_servers is {name: {type: "http", url, headers}}, browser is {url, cookies} (the preview and the person's pass), sandbox the name of a sandbox to run in; a change of any of them starts a new process |
| DELETE | /conversations/{key} | stops its Claude Code and forgets it (a deleted conversation) |
| POST | /conversations/{key}/permissions/{request_id} | {behavior: allow|deny, message?} |
| POST | /conversations/{key}/interrupt | — |
| GET | /skills | custom skills from .larapilot/skills and .claude/skills |
| POST | /models | {agent: claude|cursor, cursor_dir?, api_key?, claude_dir?} → models for the chat picker (Cursor: agent models; Claude: Models API, gateway cache, or aliases) |
| POST | /sandboxes | {name, branch, base?} → 201: a git worktree of the workspace on a new branch |
| GET, DELETE | /sandboxes/{name} | its branch and state; remove it (its Claude Code stopped first, ?branch=1 deletes the branch too) |
| POST | /sandboxes/{name}/commit | {message} commits what the sandbox holds, before a merge |
| POST | /run | {command} → 202 with the run; refused with 422 when not on the allowlist (one-shot commands without a terminal, for scripts) |
| GET | /run, /run/{id} | recent runs, one run with its output so far |
| POST | /run/{id}/kill | stop a run |
| GET | /git | branch, status, stat, diff of the working tree |
| GET | /git/log?limit=, /git/branches, /git/commit/{sha} | history with parents and refs; local and remote branches; one commit with stat and patch |
| POST | /git/checkout, /git/fetch | {branch} switches the working tree; fetch with prune |
| POST | /git/commit, /git/discard, /git/stash | {message} stages everything and commits (concluding an open merge); {path} or nothing throws changes away; {pop} stashes or brings the newest stash back |
| POST | /git/pull, /git/push | pull with a merge; push, setting the upstream on origin the first time |
| POST | /git/merge, /git/merge/abort, /git/revert | {branch} merges into the current branch (a conflict leaves it open); abort it; {sha} adds a commit that undoes one |
| POST, DELETE | /git/branches | {branch, from} creates a branch and switches to it; ?branch= deletes a merged local branch |
| GET | /files?path=, /files/read?path= | one folder (folders first, .git hidden); a file's text with the hash of its bytes, or binary / too_large |
| PUT | /files | {path, content, hash} writes atomically; 409 when the file no longer matches hash |
| PUT | /files/upload?path= | the request body as a new file (the drive's Copy / Move into the workspace), &overwrite=1 to replace |
| POST | /files, /files/rename | {path, type} creates a file or folder; {from, to} renames or moves |
| GET | /files/download?path= | a file's bytes, streamed |
| POST | /files/zip, /files/unzip | {paths} zips items of one folder next to them; {path} extracts a zip next to it, over nothing that exists, within BRIDGE_UNZIP_MAX |
| GET | /shell?cols=&rows= | Upgrade: studio-shell → 101 and one socket of newline-delimited JSON (data, resize in; data, exit out): the login shell on a terminal, for the Terminal tab through the SSH gateway |
| DELETE | /files?path= | a file, or a folder with its contents; never the workspace itself |
Every route but /health wants Authorization: Bearer $BRIDGE_TOKEN. With an
X-Studio-Sandbox: <name> header, the /git, /files and /run
routes work in that sandbox instead of the workspace. Environment: BRIDGE_TOKEN,
BRIDGE_PORT (4455), BRIDGE_HOST (127.0.0.1), WORKSPACE_DIR,
CLAUDE_BIN, BRIDGE_IDLE_TTL (600 s), BRIDGE_FLUSH_MS (100),
BRIDGE_SANDBOX_ROOT (where sandboxes go), BRIDGE_BROWSER_MCP (the Playwright MCP command;
unset, no browser), BRIDGE_STUDIO_AGENTS (Studio's subagents and context, on by default), and the
terminal and file limits in Configuration.
The protocol follows Claude Code's stream-json as documented by Spatie's Bloom.
--permission-prompt-tool stdio is not in Anthropic's documentation: workspaces run Claude Code with
auto-update off, so it changes only when you update it, and the bridge's tests, part of CI, run against a stand-in
that speaks the protocol.