The preview panel worked by proxying a dev server through OpenChamber's own origin and rewriting the HTML that came back. Anything the rewriter did not anticipate broke, and pages that refuse to be embedded never loaded at all. This deletes the proxy (-1604 lines and its tests) and merges the preview and browser panels into one surface backed by a real Chromium view. What the panel is now - A `<webview>` in its own session partition: logins and cookies persist, hot reload works because nothing is rewritten, DevTools are one click away. - Annotation: pick one element, drag a region, or draw freehand, write a note, and it reaches chat with a screenshot of the visible page with the marks on it. - Toolbar: hard reload, page zoom, device sizes, a light/dark switch that applies to the page rather than the app, and cookie/cache clearing scoped to the panel alone. - Several pages at once, each tab showing the page's own favicon, and an address bar that suggests pages already visited in this project. - Dev servers are listed from what is actually listening on the machine, checked against what a project announced, so a server is offered no matter how it was started. One that is still starting is waited for instead of failing. Remote dev servers The desktop app binds a local port and pipes raw bytes to the OpenChamber host over the existing authenticated connection, so the page keeps its own origin at the root of its own host. The reachable set is exactly what discovery reports and is re-checked per connection, so an authenticated client cannot dial arbitrary local services on the host. Links and redirects to another loopback port stay on the machine that served the page. A tunnel that cannot be opened is reported; it is never replaced by the plain loopback URL, which would answer from the user's own machine under a remote address. Agent control Browser actions are a separate `openchamber_web` tool: open, snapshot, click, type, scroll, inspect computed styles, resize between mobile/tablet/desktop, and capture a screenshot into `.openchamber/screenshots/` in the project. The existing `openchamber` tool keeps sessions, worktrees and scheduled tasks. Each has its own setting in the new Settings -> General -> OpenChamber Tools section, and the plugin is not injected at all when both are off. Capability belongs to the connected client, not to configuration: a client declares on its event stream that it can drive a page, which only a Chromium host does. Exactly one client performs each request — it claims the request before acting, and the first claim wins — because deciding by whose result arrives first would be too late for a click that already happened. No client listening is answered immediately with an explanation rather than a timeout. Runtime boundaries Web tabs get a plain iframe that can display a page but not inspect one. The VS Code extension no longer offers the surface at all, since nothing that makes the panel worth having works there. Mobile is unaffected. Native boundary Camera, microphone, location and device-picker requests from panel pages are denied — Electron grants them by default when no handler is set, and the panel loads whatever address the user types. Page capture, appearance emulation and storage clearing verify that their target belongs to the panel's own session instead of trusting a web-contents id from the renderer. Persisted state Stored `preview` tabs migrate to `browser` (v13 -> v14). Context panel tab limits are now per surface, so filling one surface no longer evicts another's tabs. Address history is stored per project and per runtime. Documentation `preview.mdx` and `desktop-browser.mdx` rewritten across all locales, the agent tool settings path corrected, new `DOCUMENTATION.md` for the browser-control broker and the dev tunnel, and the `ui-api-decoupling` skill updated where it still described the deleted proxy.
5.1 KiB
Managed OpenChamber Agent Tool
Purpose
This module exposes OpenChamber to agents as typed OpenCode custom tools. There are two, because controlling sessions and driving a page are separate intents the user can want independently:
openchamber— projects, sessions, worktrees, and scheduled tasks. Enabled while the persistedagentControlToolEnabledsetting is notfalse.openchamber_web— looking at and interacting with the page in OpenChamber's browser panel. Enabled whileagentWebToolEnabledis notfalse.
Both default to on, are toggled in Settings → General → OpenCode CLI, and apply
on the next managed OpenCode restart. Each tool carries only its own actions and
only the parameters those actions use, so turning one off removes its inputs
from the schema rather than leaving them visible. The plugin is injected only
when OpenChamber launches and owns the OpenCode process, and not at all when
both settings are false.
- The plugin accepts the action's inputs either inside
parametersor besideaction, because models produce both shapes; an explicitparametersobject wins on a conflict. Rejecting the flattened shape turned a call that plainly carried aurlinto "url is required", which reads as a broken tool rather than a malformed call.
Runtime flow
- The OpenChamber HTTP listener binds and publishes its authoritative port.
prepareManagedOpenCodeEnv()materializes the plugin under<openchamber-data-dir>/agent-tool/and appends itsfile://URL toOPENCODE_CONFIG_CONTENTwithout replacing existing plugin entries.- A random per-child token and loopback callback URL are added only to the managed OpenCode child environment.
- The plugin calls
POST /api/openchamber/agent-toolwith its typed input and OpenCode's authoritative session directory. - The route delegates the fixed action allowlist directly to the shared OpenChamber control service. The CLI uses the same service through its authenticated HTTP adapter, so Goal Mode ordering, wait behavior, partial-failure reporting, and scheduled-task contracts have one owner.
- Each action definition owns a short presentation title and a separate agent-facing description. The generated schema uses the description to state required inputs or one non-obvious behavior, while completed calls use the short title in native tool metadata.
Agent context budget
- The tool exposes one shared parameter object rather than repeating parameters in a large per-action union. Action descriptions carry only required inputs, defaults, or one non-obvious semantic detail.
- Obvious fields rely on their names and JSON types. Parameter descriptions are reserved for formats, dependencies, scope, and behavior that cannot be safely inferred from the field name.
- Session dispatches do not wait by default. Agents are told to set
waitonly when the user asks or the next step requires the completed result. - The tool exposes only agent-relevant actions
(
OPENCHAMBER_AGENT_TOOL_ACTIONS):schedule.statusstays CLI-only becauseschedule.listalready returns scheduler status, and enable/disable are oneschedule.toggleaction driven by thedisabledboolean. - The tool description frames intent: created sessions and scheduled tasks are user-facing work the user follows up with, never a channel for the agent to delegate parts of its own current task.
- Optional behavior switches (
worktree,goal,agent,variant,wait) state their default and an explicit "only when the user asks" rule so agents do not invent worktrees, goal mode, or waits the user never requested. - Detailed combination rules are enforced by the shared control service and returned as actionable usage errors only after an invalid call. Per-action examples and a repeated per-action parameter schema are intentionally omitted.
Security invariants
- The callback accepts loopback requests only and requires the current per-child bearer token using a timing-safe comparison.
- The token is never persisted, logged, returned to the UI, or written into the materialized plugin.
- Inputs map to a fixed action and parameter allowlist. There is no arbitrary CLI, shell, route, or URL forwarding.
- Session/worktree deletion and project-path registration are not exposed.
- An aborted tool request propagates an abort signal into the shared service.
Result contract
Every completed call returns JSON:
{
"schemaVersion": 1,
"ok": true,
"action": "session.create",
"data": {}
}
Command and operational failures use the same envelope with ok: false and
an error object. OpenCode-level cancellation can still produce a native tool
error state.
Runtime parity
- Web and Desktop managed OpenCode: injected automatically.
- External OpenCode selected with
OPENCODE_HOSTor skip-start: not injected, because OpenChamber does not control that process environment. - VS Code: not injected; the extension owns a separate OpenCode lifecycle.
- Hosted and Capacitor mobile clients use the server's managed OpenCode tool when connected to such a server; no tool runs in the client runtime.