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
- Protocol: JSON-RPC 2.0
- Socket type: Unix domain socket (local) or TCP with HMAC-SHA256 auth (remote relay)
- Framing: one JSON document per line
- Request IDs: string or number
- Notifications: request without an
id
Access Control Modes
| Mode | Behavior |
|---|---|
off | Reject all connections |
localOnly | Allow only child processes of Namu via PID ancestry checks |
automation | Allow local automation clients and mark the session as automation context |
password | Require password authentication before commands are accepted. Password from --password, $NAMU_SOCKET_PASSWORD, or ~/.namu/socket-password |
allowAll | Allow 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
| Namespace | Examples |
|---|---|
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)
- Navigation — navigate, back, forward, reload, stop, go
- DOM Interaction — click, type, hover, focus, blur, get-text, get-attr, get-property
- Screenshots & Images — screenshot, get-image, save-image
- JavaScript Execution — eval, eval-function, eval-async, eval-generator
- Tab Management — list-tabs, new-tab, close-tab, activate-tab, switch-tab
- History & Search — history, clear-history, find (with history scoring)
- Profile Management — list-profiles, create-profile, delete-profile, get-profile
- Cookie & Storage — get-cookies, set-cookies, clear-cookies, get-local-storage, set-local-storage
- Performance & Debugging — get-performance-metrics, enable-devtools, disable-devtools
- Window & Frame — get-window-size, set-window-size, list-frames, switch-frame
Server-Push Events
Subscribed clients receive JSON-RPC notifications for these event families:
process.exitoutput.matchport.changeshell.idleworkspace.change
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
| Variable | Purpose |
|---|---|
NAMU_SOCKET | Unix socket path override |
NAMU_SOCKET_PASSWORD | Socket password for password access mode |
NAMU_SOCKET_MODE | Socket control mode |
NAMU_SURFACE_ID | UUID of the current pane surface (set per terminal) |
NAMU_WORKSPACE_ID | UUID of the current workspace |
NAMU_PORT | Allocated port start for this workspace |
NAMU_PORT_END | Allocated port end |
NAMU_PORT_RANGE | Full port range string |
NAMU_TAG | Launch tag for debug builds (affects socket path) |
NAMU_BUNDLE_ID | App bundle identifier |
NAMU_BUNDLED_CLI_PATH | Path to the bundled CLI binary |
NAMU_CLAUDE_HOOKS_DISABLED | Disable Claude hook injection |