Socket API

Namu exposes a newline-delimited JSON-RPC 2.0 API over a Unix domain socket. The default socket path is /tmp/namu.sock. Tagged debug builds use /tmp/namu-<tag>.sock.

Transport

Access Control Modes

ModeBehavior
offReject all connections
localOnlyAllow only child processes of Namu via PID ancestry checks
automationAllow local automation clients and mark the session as automation context
passwordRequire password authentication before commands are accepted. Password from --password, $NAMU_SOCKET_PASSWORD, or ~/.namu/socket-password
allowAllAllow any local connection

Request Example

{"jsonrpc":"2.0","id":"1","method":"system.ping","params":{}}

Response Example

{"jsonrpc":"2.0","id":"1","result":{"pong":true}}

Ref IDs in Responses

All responses that return an id (UUID) also include a ref field with the short form (workspace:1, pane:2, surface:3). Clients may send either form as input.

Core Namespaces

NamespaceExamples
workspace.*workspace.list, workspace.create, workspace.select, workspace.pin, workspace.color
pane.*pane.split, pane.focus, pane.equalize, pane.swap, pane.break, pane.pin, pane.new_browser_tab, pane.new_markdown_tab
surface.*surface.send_text, surface.send_key, surface.read_text, surface.reorder, surface.drag_to_split, surface.move
sidebar.*sidebar.set_status, sidebar.clear_status, sidebar.list_status, sidebar.set_progress, sidebar.clear_progress, sidebar.log, sidebar.clear_log, sidebar.list_log
window.*window.list, window.current, window.create, window.focus, window.close
notification.*notification.create, notification.list, notification.clear, notification.jump_to_unread
browser.*84 commands: navigation, DOM, JS eval, screenshots, tabs, history, profiles, cookies, find, performance, frames
system.*system.ping, system.identify, system.relay_status, system.render_stats, system.capabilities
debug.*debug.layout, debug.window.screenshot, debug.panel.snapshot, debug.flash.count, debug.underflow.count

Sidebar Status API

Status entries appear as colored pills in the workspace sidebar. Useful for build monitoring, CI/CD status, and agent coordination.

// Set a status entry
{"jsonrpc":"2.0","id":"1","method":"sidebar.set_status","params":{
  "key": "build",
  "value": "Tests passing",
  "icon": "checkmark.circle.fill",
  "color": "#34C759",
  "priority": 10
}}

// Set a progress bar
{"jsonrpc":"2.0","id":"2","method":"sidebar.set_progress","params":{
  "value": 0.75,
  "label": "Building (75%)"
}}

// Append a log entry
{"jsonrpc":"2.0","id":"3","method":"sidebar.log","params":{
  "message": "All tests passed",
  "level": "success",
  "source": "ci"
}}

Browser Commands (84 methods)

Server-Push Events

Subscribed clients receive JSON-RPC notifications for these event families:

TCP Relay Transport

Remote access uses an authenticated TCP relay with HMAC-SHA256 challenge-response authentication. The relay multiplexes requests to the local command dispatcher.

Relay security properties:
- HMAC-SHA256 authentication (CryptoKit constant-time comparison)
- Relay credential hex validation (malformed tokens rejected at parse time)
- Response size cap: 1MB
- Proxy header size cap: 64KB
- Cloud metadata SSRF blocking (169.254.169.254)
- Atomic metadata file writes (no partial-write races)

Use system.relay_status to inspect relay availability and health.

Environment Variables

VariablePurpose
NAMU_SOCKETUnix socket path override
NAMU_SOCKET_PASSWORDSocket password for password access mode
NAMU_SOCKET_MODESocket control mode
NAMU_SURFACE_IDUUID of the current pane surface (set per terminal)
NAMU_WORKSPACE_IDUUID of the current workspace
NAMU_PORTAllocated port start for this workspace
NAMU_PORT_ENDAllocated port end
NAMU_PORT_RANGEFull port range string
NAMU_TAGLaunch tag for debug builds (affects socket path)
NAMU_BUNDLE_IDApp bundle identifier
NAMU_BUNDLED_CLI_PATHPath to the bundled CLI binary
NAMU_CLAUDE_HOOKS_DISABLEDDisable Claude hook injection