CodeWork
Integrations

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 serve

The server listens on ws://127.0.0.1:7433/rpc/v1 and logs the address when it’s ready.

FlagDescription
--hostInterface to bind (default 127.0.0.1)
--portPort to listen on, or 0 for any free port (default 7433)
--serviceRun 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/v1

These commands need a running server. For them, --server defaults to ws://127.0.0.1:7433/rpc/v1:

CommandWhat it does
codework session link, relinkChange a session’s project folder or where it runs
codework thread list, forkList a session’s threads, or fork a new one
codework plugin reloadRe-import configured plugins without a restart
codework mcp reconnect, disconnectRestart 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.

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> --unlink

Without 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

GroupMethods
sessioncreate, link, relink, delete, interrupt, log (stream)
threadlist, info, history, queue, configure, fork, prompt, cancel, update, interrupt, message, wait
modellist
projectrename
sandboxdrivers, list, create, register, stop
mcpconnect, disconnect
authsave, status, refresh, logout
pluginreload
serverinfo
eventsubscribe (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.prompt returns as soon as the server accepts the prompt. Follow the event stream for the result. Its delivery is steer (taken in at the agent’s next model request) or followUp (taken in after the current turn).
  • thread.queue lists prompts waiting to join the conversation. thread.cancel withdraws one, and thread.update changes its text or delivery.
  • thread.interrupt stops one thread; session.interrupt stops every thread of the session. Both return as soon as the stop is accepted. thread.wait resolves 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 serverACP
TransportWebSocketstdio
LifetimeLong-lived, outlives clientsOne process per editor connection
ClientsCLI, your own toolsEditors such as Zed
SandboxesCreate, share, and reuse across sessionsLocal project folder only