RPC Server
Run CodeWork as a long-lived server that owns sessions and sandboxes, and drive it from the CLI or your own client.
codework serve starts a persistent server. Sessions, sandboxes, credentials, and plugins live in the server process. Work keeps running when a client disconnects, and several clients can share the same sessions.
Use it when you want CodeWork to outlive a terminal, to run it on another machine, or to build your own interface on top of it.
Start the server
codework serveThe server listens on ws://127.0.0.1:7433/rpc/v1 and logs the address when it’s ready.
| Flag | Description |
|---|---|
--host | Interface to bind (default 127.0.0.1) |
--port | Port to listen on, or 0 for any free port (default 7433) |
--service | Run as the background server, logging to <home>/log/server.log |
To run the server in the background instead of in a terminal, use codework service start. codework service stop ends it.
Pass --home, --database, and --user-config-dir to the server, not the client. The server looks up model credentials, plugins, and working directories on its own side.
When the server starts, it resumes the runs that a crash or shutdown cut off.
The RPC server is not secure yet: it has no authentication, so anyone who can reach the port can drive your sessions. It binds to loopback by default; don’t expose it on a public interface. Authentication will be added in a later release.
Use it from the CLI
run and auth work locally unless you pass --server:
codework run --server ws://127.0.0.1:7433/rpc/v1 "Inspect the failing tests"
codework run --server ws://127.0.0.1:7433/rpc/v1 --session <id> "Now fix them"
codework run --server ws://127.0.0.1:7433/rpc/v1 --session <id> --thread <thread-id> "Try OAuth instead"
codework auth login --openai-codex --server ws://127.0.0.1:7433/rpc/v1These commands need a running server. For them, --server defaults to ws://127.0.0.1:7433/rpc/v1:
| Command | What it does |
|---|---|
codework session link, relink | Change a session’s project folder or where it runs |
codework thread list, fork | List a session’s threads, or fork a new one |
codework plugin reload | Re-import configured plugins without a restart |
codework mcp reconnect, disconnect | Restart or close one thread’s MCP server |
A remote run doesn’t start the agent on your machine. Press ctrl-c to interrupt the thread on the server. If you disconnect without pressing it, the work keeps running.
Link a session to a project
A session remembers which project folder it belongs to, so it picks up that project’s settings and plugins wherever you continue it from. Change or clear that link with:
codework session link <session-id> ~/work/api
codework session link <session-id> --unlinkWithout a path, link uses the folder you run it from.
To change where the work runs instead, use relink. Add --thread to move only one thread:
codework session relink <session-id> -C ~/work/api
codework session relink <session-id> --thread <thread-id> --sandbox-id <sandbox-id>Protocol
The endpoint speaks Effect RPC over WebSocket at /rpc/v1, with newline-delimited JSON framing. The contract lives in packages/codework/src/server/contract.ts.
Sessions and threads
A session holds one or more threads. Each thread is a single conversation with its own model, thinking level, title, and usage. Every session starts with a main thread. thread.fork forks a new thread from a point in an existing one.
session.* methods act on the whole session. thread.* methods take { sessionId, threadId? }; without threadId they act on the session’s main thread.
Methods
| Group | Methods |
|---|---|
session | create, link, relink, delete, interrupt, log (stream) |
thread | list, info, history, queue, configure, fork, prompt, cancel, update, interrupt, message, wait |
model | list |
project | rename |
sandbox | drivers, list, create, register, stop |
mcp | connect, disconnect |
auth | save, status, refresh, logout |
plugin | reload |
server | info |
event | subscribe (stream) |
Events
event.subscribe streams every event the server publishes, live, starting with a server.connected frame. Pass threadId to get only that thread’s events. Live events are not replayed, so subscribe before you send a prompt.
session.log reads a session’s stored events, then sends a log.synced marker. With follow, it keeps streaming new events as they’re stored. Text and tool progress deltas are never stored, so they only arrive through event.subscribe.
Each stretch of work on a thread starts with session.execution.started and ends with exactly one of succeeded, failed, or interrupted. A failure carries a category such as provider-authentication-error or sandbox-mount-error. A run that can’t be resumed ends with session.run.failed. Plugins publish their own events under plugin.<plugin-id>.*. Clients skip event types they don’t recognize.
Lifecycle
thread.promptreturns as soon as the server accepts the prompt. Follow the event stream for the result. Itsdeliveryissteer(taken in at the agent’s next model request) orfollowUp(taken in after the current turn).thread.queuelists prompts waiting to join the conversation.thread.cancelwithdraws one, andthread.updatechanges its text or delivery.thread.interruptstops one thread;session.interruptstops every thread of the session. Both return as soon as the stop is accepted.thread.waitresolves when the thread has settled.- Managed sandboxes stay up until you stop them or the server shuts down. The server never stops external sandboxes.
RPC or ACP?
| RPC server | ACP | |
|---|---|---|
| Transport | WebSocket | stdio |
| Lifetime | Long-lived, outlives clients | One process per editor connection |
| Clients | CLI, your own tools | Editors such as Zed |
| Sandboxes | Create, share, and reuse across sessions | Local project folder only |