Skip to content

Agent App API

AgentMux exposes two layers of RPC surface: a high-level App API for agents and integrations, and a low-level command catalog for direct manipulation. Both transport over the same JSON-RPC 2.0 WebSocket and share the same auth.

The App API is what you should reach for first. It expresses intent (“open this agent in a pane, idempotently”) and orchestrates the underlying CreateBlock / SetMeta / ControllerResync calls. The low-level catalog is for cases that don’t fit the intent shape (tooling, testing, custom panes).

  • Protocol: WebSocket, JSON-RPC 2.0
  • Server: agentmux-srv (Rust, Tokio + Axum)
  • Client: RpcApi / TabRpcClient in the frontend (frontend/app/store/rpc-api.ts)
  • Auth: Token-based; pass via authenticate or authenticatetoken on connect

The host auto-spawns a sidecar per instance on a dynamic port; terminals opened inside AgentMux receive AGENTMUX_PORT and an auth token via the shell integration env block.

High-level commands defined in agentmux-srv/src/server/app_api.rs. Idempotent, intent-based.

CommandDescription
agent.openOpen an agent (from the agent-definition catalog) in a pane. Idempotent — if the agent already has a block in the target tab, returns it. Resolves provider, sets controller meta, registers the controller.
agent.sendSend a message to a running agent. Honors the agent’s CLI provider (Claude Code, Codex CLI, Gemini CLI, OpenClaw, Kimi Code CLI, GitHub Copilot CLI, Pi).
agent.stopCleanly stop an agent (asks the CLI to wrap up).
agent.statusQuery an agent’s current state — controller status, last activity, block id.
agent.listList every running agent across the workspace, with provider + status.
agent.outputFetch the last N lines of an agent’s terminal output (post-stream-buffer).
CommandDescription
agent.process-listList every OS process currently tracked for a given agent block (PIDs, RSS, command line).
agent.tracked-blocksList every block the process tracker is following — for the swarm aggregate view.
agent.kill-processTerminate one PID, only if it’s a tracked member of the named block (safety-checked).
agent.kill-treeTerminate the entire process tree for a given block.

The process tracker has three confidence levels (high, best_effort, none) that callers should respect when interpreting results.

CommandDescription
pane.openOpen a pane of one of the supported view types: editor (requires file), term, browser (requires url), sysinfo, or help. Returns the new block id.
CommandDescription
session:archiveArchive the current session state to a portable bundle.
session:restoreRestore a previously archived session into a fresh workspace.
session:exportExport a session digest (read-only, shareable).
session:digestCompute a digest of the current session for diff / hashing.

The primitives the App API is built on. These are stable but lower-level — most consumers should prefer the App API where one exists.

CommandDescription
createblockCreate a new block (pane) in a tab
createsubblockCreate a sub-block within a parent block
deleteblockDelete a block
deletesubblockDelete a sub-block
blockinfoGet block metadata and file info
blockslistList all blocks, optionally filtered by window or workspace
CommandDescription
controllerinputSend input to a block’s controller (terminal input, signals, resize)
controllerresyncResync or restart a block’s controller
controllerrestartRestart a block’s controller
controllerstopStop a block’s controller
captureblockscreenshotCapture a screenshot of a block’s content
CommandDescription
filereadRead a file’s contents
filewriteWrite contents to a file
filecreateCreate a new file
filedeleteDelete a file
fileappendAppend data to a file
filecopyCopy a file
filemoveMove/rename a file
filemkdirCreate a directory
filelistList files in a directory
fileliststreamStream a directory listing (for large directories)
filereadstreamStream file contents
filestreamtarStream a tar archive of files
fileinfoGet file metadata
filejoinJoin file paths
CommandDescription
eventpublishPublish an event to the event bus
eventrecvReceive/handle an event
eventsubSubscribe to events by type and scope
eventunsubUnsubscribe from a specific subscription
eventunsuballUnsubscribe from all subscriptions
eventreadhistoryRead historical events
CommandDescription
connconnectConnect to a remote host
conndisconnectDisconnect from a remote host
connensureEnsure a connection is established
connlistList active connections
connlistawsList available AWS connections
connstatusGet status of all connections
CommandDescription
getmetaGet metadata for a wave object
setmetaSet metadata on a wave object
setviewSet a block’s view type
getfullconfigGet the complete configuration
getvar / setvarGet / set a config variable
CommandDescription
authenticateAuthenticate with a token string
authenticatetokenAuthenticate with structured token data

A few commands return async streams instead of single responses:

  • fileliststream — directory entries progressively
  • filereadstream — file contents in chunks
  • filestreamtar — tar archive bytes

The frontend client surfaces these as AsyncGenerator objects; over the wire each chunk is a JSON-RPC notification on the same connection. For live agent output, subscribe to the relevant agent block via eventsub rather than polling agent.output.

Be aware of what the API currently does and does not enforce.

By the trust model, agent processes are sub-trusted: they run as the user but are not given the sidecar’s auth key. That’s the intended boundary. The Agent App API is the narrow surface across that boundary — the only RPC entry points an agent can reach.

In the current implementation, an agent that authenticates to the App API gets broad access to the workspace: spawn panes, mutate workspace state, send messages, read and write blocks. There is no per-tool permission scope, no allow-list of which RPCs a given agent may call, no rate limiting beyond what the underlying RPC machinery provides.

Concrete advice:

  • Treat the Agent App API as a privilege boundary you opt into per agent. An agent you don’t trust should not be given API access.
  • Default-deny in your own workflow: don’t enable the API for agents whose Memory bundle isn’t from a source you trust.
  • The audit endpoint logs every RPC call. If you’re running a less-trusted agent, watch the log.

A finer-grained permission model (per-agent allow-lists, scoped RPC capabilities) is on the roadmap. This page will be updated when it lands.