Skip to main content

nexor-runner

Hosts and runs AI coding agents (Claude Code, OpenCode) in tmux sessions on one Linux machine. It owns a dedicated tmux server, keeps a state file so sessions can be restored after a restart, starts every agent with a minimal environment, and exposes a small local HTTP API.

Python 3.11+, no runtime dependencies.

Install

From PyPI, no repository access needed:

pipx install nexor-runner            # or: pip install --user nexor-runner
nexor-runner --version

Install it, do not pipx run it: the systemd units point at the interpreter that runs install-service, and pipx run uses a temporary environment that is garbage-collected, which would leave the units pointing at a path that no longer exists.

Known limits: units are written under $XDG_CONFIG_HOME (or ~/.config), where systemd looks only if that is its user config directory; --no-agora does not remove an agora unit installed earlier (uninstall-service does).

Requirements: tmux (3.x; 3.2+ for the browser terminal), the agent CLIs you want to run (claude, codex, opencode), and systemd --user for the units (loginctl enable-linger $USER keeps them alive after logout). nexor-runner and runner are the same command; python -m nexor_runner works too.

Quick start on Linux (one command)

The owner first creates the runner in the hub (Settings -> Runners: a name and a one-time nxr_ token). The token is not the Agora connector's delegation token (nxad_): the hub refuses that one on every runner endpoint. Save it in a file with mode 0600, then:

nexor-runner install-service --hub https://hub.example.com --token-file ~/runner-token
# or: printf '%s' "$TOKEN" | nexor-runner install-service --hub https://hub.example.com --token-stdin
# or: NEXOR_RUNNER_HUB_TOKEN=... NEXOR_RUNNER_HUB=https://hub.example.com nexor-runner install-service
nexor-runner doctor

install-service writes the three systemd --user units (nexor-runner-tmux, nexor-runner-api, nexor-runner-agora) pointing at the interpreter the package is installed in, creates the config directory (0700) and the API token (0600), links the runner to the hub (validating the token), and enables and starts everything. The hub token is copied to ~/.config/nexor-runner/hub-token (0600) when it comes from stdin or the environment; it is never printed, logged, put on a command line or in a unit. Without --hub the agora unit is skipped (add it later by re-running with --hub); other flags: --no-agora, --no-api (both remembered in service.json, so an update keeps those units out; --agora / --api or an explicit --hub bring them back), --port, --extra-path, --cards-dir, --host, --host-id, --no-auto-update, --no-cards-sync, --dry-run (print the units, change nothing). The directories of the claude, codex and opencode binaries your login shell finds (nvm included) are added to the units. It also writes and enables nexor-runner-update.timer (see Automatic updates below).

One machine, several people. Each user has their own runner and their own API on 127.0.0.1, so the API port cannot be the same for everybody. A new install without --port takes a port derived from the user id in 7800-7999 (uid 1000 gets 7800, uid 1003 7803, ...) and, when that one is taken, the first free port after it; it prints which one it picked and keeps it in service.json. An existing install never changes its port on its own (an update re-runs install-service with no flags); to move it, nexor-runner install-service --port <free port>. doctor checks that the process answering GET /health on the port is this user's runner (it asks GET /whoami with the user's own API token, and sends the token only to a process it knows is this user's: another owner fails, an owner it cannot determine is a warning) and, if it is not, fails with the install-service --port <free port> to run. The runner name (nexor-runner link, the Runners page of the hub) follows the team convention <host>-<initials>, for example srv-gc and srv-ec on the host srv: the first part is the runner's host id (see Handles). install-service --host-id <id> saves it explicitly.

Automatic updates. A runner installed with install-service updates itself: a systemd --user timer (nexor-runner-update.timer) runs nexor-runner self-update about ten minutes after boot and then daily, with a random delay of up to 30 minutes so two runners do not update at the same moment (Persistent=true: a run missed while the machine was off happens at the next start). Nothing to do, nothing to remember.

nexor-runner self-update --check     # is there a newer release? (changes nothing)
nexor-runner self-update --dry-run   # what an update would do
nexor-runner self-update             # update now (what the timer runs); --json for scripts
nexor-runner install-service --no-auto-update   # opt out: removes the timer, remembered
nexor-runner install-service --auto-update      # opt back in

Cards clone. If your agent cards live in a git repository cloned on this machine and used as the cards directory (cards-dir in config.json, else ~/.config/nexor-runner/cards), self-update keeps that clone fresh too: after the package step, also when the package is already up to date and also when that step failed, it runs git pull --ff-only there, with GIT_TERMINAL_PROMPT=0 (and ssh in batch mode, unless you set GIT_SSH_COMMAND) and a 60 second limit, so a credential question can never hang a run. It does nothing, silently, when there is no such directory, it is not inside a git work tree or its branch has no upstream. It never merges, rebases or forces: a clone with uncommitted changes to tracked files is skipped (one log line), a diverged clone fails the fast-forward and stays as it is (untracked files, such as a card you are drafting, do not stop it; git itself refuses to overwrite one). A cards failure, with or without network, never fails the update and never triggers the rollback. Each run adds one line, cards-synced, cards-current, cards-skipped or cards-failed, to update.log. Turn it off with nexor-runner self-update --no-cards-sync, with nexor-runner install-service --no-cards-sync (remembered in service.json, so the timer honours it; --cards-sync turns it back on) or with NEXOR_RUNNER_CARDS_SYNC=0. --check never touches the cards and --dry-run only looks (would: git -C <dir> pull --ff-only).

The cards that changed go to the hub. When the pull brought new commits and the runner is linked to a hub, the runner sends each *.md card of the cards directory that changed in those commits. It uses its own token (PUT /api/v1/runner-hosts/{name}/charters/{handle}). The hub only updates an agent that already exists and belongs to the runner's owner, and only from the owner's charter_source (Settings, owner/repo:path/). A new agent is still created once, by hand, with nexor-agora charters push.

Some cards never leave the machine:

  • a personal card (scope p: by the handle letter, the frontmatter scope: or the charter's scope.kind);
  • a card of a hosted person of the registry. If there is no registry, or it cannot be read, the runner sends nothing;
  • a dormant card (status: dormiente), a README.md, a card the runner cannot read (not UTF-8, no JSON block), anything that is not a regular file in the commit (a symlink is never followed).

What is sent is the card as it is in the pulled commit, never the file on disk.

The run adds one line to update.log: cards-push-pushed, cards-push-failed (a refusal or the hub unreachable, with the reason), or cards-push-off (the hub has no charter source for you). All the hub calls of a run share a 120 second budget. The push stops at the first unreachable call. It never fails the update. Turn it off and keep the pull with NEXOR_RUNNER_CARDS_PUSH=0.

Changes made in Agora are written into the cards. When the owner changes an agent's projects on the hub's map, the hub keeps the change until the runner writes it. The linked runner asks every minute (GET /api/v1/runner-hosts/{name}/card-edits) and, for each change, in its cards clone:

  1. checks that the clone is the repo the card was pushed from and the file is the same path, that the card is a tracked file with no local changes, and that it may leave the machine (the same rule as the push above);
  2. runs git pull --ff-only, then rewrites project: in the frontmatter (one name alone, several as [First, Second], the line removed when the list is empty). The rest of the file, line endings included, is left as it is;
  3. commits only that file (card: <handle> projects -> ... (from Agora)) and pushes. If the remote moved meanwhile, it merges (git pull --no-rebase) and pushes once more; a merge that conflicts is aborted. It never rebases and never forces. A commit an earlier try could not push is pushed first;
  4. pushes the card to the hub, which closes the change, and reports applied with the commit.

If a step fails, the runner reports failed with the reason, and the owner sees it on the map. The clone is left as it was: the file is restored if the commit fails. A commit that could not be pushed stays in the clone, and the report says so. NEXOR_RUNNER_CARDS_PUSH=0 also turns this off. A hub without the endpoint is asked again only once an hour.

What an update does: takes a lock for the whole run (two runs never overlap), reads the newest release from PyPI (pre-releases and yanked ones are ignored; stdlib only, no new dependency); if it is newer than the installed one, pip install --upgrade nexor-runner==<latest> with the interpreter the runner runs in (a venv and pipx alike), runs install-service with no flags (the link, port and extra path are kept; it restarts the API and agora units) and then doctor, both from the new code. The version is read again once the lock is held (a run that waited never repeats or undoes another run's update), and a doctor taken before the update is the baseline: if it gives no usable answer the update is postponed. A check that passed before the update and fails after it (the API gets about 30 seconds to come back) puts the previous version back and exits 1. A pip failure, for instance PyPI listing a release whose files are not served yet, changes nothing and exits 1; the timer tries again the next day. Because a pip that is killed halfway (its 10 minute limit) may have written part of the package, the installed version is checked after every pip failure and the previous one is put back whenever it is not what was installed before (if even that fails, the JSON says what is installed, or unknown). A lock that cannot be taken (for example a filesystem without flock) is a failure, not a skipped run. It never restarts or stops nexor-runner-tmux and never touches the tmux server: the sessions go on. An install that is not from PyPI (a clone with pip install -e, a local path, a URL) or a development version is left alone. One line per run goes to ~/.local/state/nexor-runner/update.log (kept to the last 100 lines past 64 KiB), and doctor warns when the timer is absent or the last run failed (the cards line does not count as that). The hub sees the new version at its next heartbeat: nothing about the hub protocol changes. To set the timer's schedule by hand, edit ~/.config/systemd/user/nexor-runner-update.timer; the next install-service run puts the default back. NEXOR_RUNNER_PYPI_URL points the version lookup at another JSON index (https, or http on loopback); it never changes where pip downloads from.

Upgrading by hand (also when auto-update is off): pipx upgrade nexor-runner && nexor-runner install-service (no flags: the link, the port and the extra path you installed with are kept in ~/.config/nexor-runner/service.json; an explicit --port / --extra-path overrides and becomes the new value; an install that never wrote service.json keeps the --port of its API unit). Or just nexor-runner self-update, which does this with the checks and the rollback. It is idempotent and restarts the API and agora units, which are stateless. It never restarts or stops nexor-runner-tmux: that unit hosts your running sessions. If its unit file changed, the new one applies the next time you restart it yourself, between sessions.

nexor-runner doctor [--json] checks tmux, the agent CLIs, linger, the three units, the update timer, the last update run, GET /health (and that it is this user's runner that answers), the host id (a warning with nexor-runner config set host-id <id> when it is unset or not one of the registry's hosts) and the hub link (exit 1 when something fails, a missing individual agent CLI or update timer is only a warning). nexor-runner uninstall-service removes the API and agora units (and the update timer) and leaves tmux running; --include-tmux removes that one too (ending every session). By default config, tokens and the hub link are kept. --unlink also forgets the hub link (agora.json; the token file you provided is never touched). --purge-config also deletes config.json, the API token, the copied hub-token and agora.json (it implies --unlink), then the config directory if it is empty; the cards directory and the session state are never touched, and tmux.conf goes only together with --include-tmux.

Plain-http hub (trusted network only). The hub URL must be https:// (http only for loopback). If your hub is plain http on a trusted network such as the VPN, opt in explicitly: --allow-insecure-hub on link and install-service, or NEXOR_RUNNER_ALLOW_INSECURE_HUB=1. Each use prints WARNING: plain http: token and traffic are not encrypted; use only on a trusted network such as the VPN (on stderr; the token is never printed). The choice is stored as "insecure": true in agora.json, so the agora unit and doctor keep working and later install-service runs need no flag. runner link is safe to re-run: it validates the token and rewrites agora.json with the same content, touching nothing else.

macOS and Windows: there is no service installer (systemd is Linux only) and install-service exits 3 after printing this. Run the pieces in the foreground, each in its own terminal: nexor-runner serve --init-token, nexor-runner link --hub https://<hub> --token-file <file>, nexor-runner agora. tmux is required, so on Windows the runner does not work.

Install from a clone (development)

git clone https://github.com/nexorhq/nexor-runner.git ~/dev/nexor-runner
cd ~/dev/nexor-runner
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"

Manual setup of the units

The three sections below are what install-service does, one unit at a time (useful to tune a unit by hand).

1. The tmux server unit

runner systemd install --dry-run    # print the unit and tmux.conf
runner systemd install              # write them
systemctl --user daemon-reload
systemctl --user enable --now nexor-runner-tmux.service

The unit runs tmux -L nexor-runner -f <conf> -D with an explicit minimal environment. Sessions live in this server (socket nexor-runner), separate from your default tmux server.

2. The API unit (optional)

runner serve --init-token           # creates ~/.config/nexor-runner/token (0600); stop it with Ctrl-C
runner systemd install --api --extra-path "$HOME/.nvm/versions/node/<version>/bin" --dry-run
runner systemd install --api --extra-path "$HOME/.nvm/versions/node/<version>/bin"
systemctl --user daemon-reload
systemctl --user enable --now nexor-runner-api.service
curl http://127.0.0.1:7800/health

--init-token creates the token file if it does not exist (random, mode 0600). The API unit requires the tmux unit. Options: --port (default 7800; on a machine several people share use install-service, which picks a port per user), --token-file, --runner-bin, --tmux-bin.

Connect the runner to an agora hub: the hub records intents (launch, kill, restore, remote-control, stop-scope), the runner connects outbound (no inbound port), reports its sessions and cards, executes the intents and reports the result. The hub never executes anything.

runner link --hub https://hub.example.com --token-file ~/.config/nexor-runner/hub-token
runner systemd install --agora --dry-run
runner systemd install --agora
systemctl --user daemon-reload
systemctl --user enable --now nexor-runner-agora.service

The owner creates the runner (name plus a one-time nxr_ token) in the hub's Settings -> Runners and saves the token in a file with mode 0600. runner link validates it with GET /self and writes ~/.config/nexor-runner/agora.json (0600: hub URL, token-file path, runner name); the token is never on the command line and never logged. The hub URL must be https (http only for loopback). runner unlink removes the link. The unit requires the tmux unit; runner agora runs the same loop in the foreground.

The loop: heartbeat every ~30 s; the full snapshot (sessions and cards) on start and whenever it changes, at most every 10 s; long-poll for intents, claim (a 409 is skipped), execute through the same code as the local API, report done or failed with a short message (the dead-pane tail on a failed start). Hub errors back off from 1 s to 60 s and never stop the loop.

Chat and terminal channel

Next to the intent loop, runner agora keeps ONE more outbound connection to the hub: a WebSocket (wss://<hub>/api/v1/runner-hosts/<name>/channel, same nxr_ bearer token, sent in the upgrade request). The hub cannot reach this machine (it may run in a container, or the runner on a laptop), so the browser's streams are multiplexed over this connection. The runner still opens no port. It reconnects with a 1 s to 60 s backoff and never stops the intent loop; an older hub without the endpoint answers 404 and the runner retries every two minutes. NEXOR_RUNNER_CHANNEL=0 turns the channel off.

Two kinds of stream, each opened by the hub for one browser pane:

  • chat (OpenCode sessions only): the message history (paged), live events (text and reasoning deltas, tool calls, status, approval prompts), send a prompt, interrupt, answer a permission. The adapter (oc_chat.py) is a whitelist, not a proxy: it can only call GET /api/session/{id}/message, GET /api/event, GET /api/session/active, GET|POST /api/session/{id}/permission[/{request}/reply], POST /api/session/{id}/prompt, POST /api/session/{id}/interrupt and two read-only lookups, GET /api/session (find the engine session titled with a handle) and GET /api/session/{id}/message/{message} (the finished copy of one message), on engine session ids it validated (ses_...). Engine calls go straight to loopback: no proxy from the environment and no redirects, so the Basic credentials cannot be sent elsewhere. The engine's filesystem and shell endpoints are unreachable from a browser. The engine session of a runner session is the session_id the runner stored (see "Stable Agora handles for OpenCode sessions"), else the newest engine session titled with the handle; with neither, the session is terminal-only. The engine is only ever contacted on loopback, with the password from its own service.json, never logged.
  • terminal (ANY runner tmux session, so Claude and Codex sessions too). Off by default: turn it on for this runner with NEXOR_RUNNER_TERMINAL=1 or runner config set terminal on (independent of chat; while it is off the terminal capability is not advertised and an open is refused with terminal_disabled). A browser terminal is a SHELL-LEVEL capability on this machine (whatever the agent's program can do, the owner's browser can type), so it is the owner's explicit choice, and the hub audits every one that is opened. The viewer is tmux -L nexor-runner attach-session -r -t =<name> in a PTY: a read-only tmux client, so it can only show the screen. Keystrokes from the browser are NOT typed into that client; they are delivered with tmux send-keys -t =<name>: -H <hex bytes> (validated, at most 64 KiB per frame, 4096 bytes per command), which writes the bytes to the program in the pane and never touches tmux's key table. Consequently prefix+c (new window, i.e. a shell), prefix+: (command prompt), kill-server, switch-client and mouse bindings are out of reach from the browser: they arrive in the pane as plain text. Requires tmux 3.2 or newer. Before send-keys, the runner drops what the browser's xterm.js answers to tmux's attach-time questions (device attributes, XTVERSION, colour and mode reports, DECXCPR) and the mouse and focus reports; everything else is typing and is delivered untouched, Shift/Alt/Ctrl+F3 (ESC [ 1 ; <mod> R) included. Keyboard modes follow tmux, not the pane: measured on tmux 3.4, an attach client switches the outer terminal to application cursor keys, application keypad and bracketed paste whatever the pane asked for, so arrows arrive as ESC O A and a paste is wrapped in ESC [ 200~ ... ESC [ 201~ (Claude Code reads both arrow forms and consumes the paste markers). Swallowing those modes in the browser would unwrap pastes for agents that asked for bracketed paste, so it is not done.

Capabilities per session, announced to the hub in a sessions frame (every 10 s when changed): {read, send, approve, interrupt, terminal_only, terminal}. OpenCode sessions with an engine session get chat (terminal_only: false) and a terminal; everything else is terminal_only.

The browser terminal does not resize the real session, unless a viewer asks for Fit pane (see below). Measured on tmux 3.4: ignore-size alone is not enough, because when the browser is the only client tmux still sizes the window to it and keeps that size afterwards. So while a browser watches a session the runner pins every window of it to its current size (resize-window -x W -y H, which makes tmux treat the size as manual, plus a @nxr_pin window marker that remembers the previous window-size). The PTY is opened at the window's size; a plain browser resize {cols, rows} only changes the PTY (the part of the window the client shows). When the last stream of the session closes, the previous setting is restored; a runner that died while pinned undoes the pins at its next start. While a browser is attached, a human who attaches with a real terminal sees the pinned size. A window created while a browser watches (the agent or a human runs new-window) is sized by tmux to the browser at first: the runner checks the windows of watched sessions every ~2 s and puts a new one back to the size the session's windows had. The pin is held until the attach client of a stream has started, even if the stream is closed in that moment. Closing a stream hangs up the PTY (the tmux client detaches); the session itself is never killed.

Fit pane: resize {cols, rows, window: true} does resize the window. The web's default mode asks the runner to make the REAL tmux window of the session as large as the viewer's pane, so the agent's TUI fills it (with a read-only client tmux never shows more than the window holds). What the runner does, with tmux commands on its own socket and argv lists only:

  • resize-window -t <active window id> -x C -y R, with C x R clamped to 40..300 x 10..100. Only the session's ACTIVE window, only while a browser stream holds the pin. No server-wide option (window-size, aggressive-resize, ...) is ever changed, no other session is touched.
  • Before the first fit the window's size is saved (memory + window option @nxr_orig = WxH) and restored with resize-window -x W -y H (the saved dimensions, not resize-window -A: -A recomputes the size from the attached clients under the window-size policy, which with read-only clients is the unpredictable size the pin exists to prevent). It is restored when the last fitting viewer of the session closes, disconnects, or sends resize ... window: false (back to Scale), when the hub link drops, and at runner stop (close_all); a runner that died is cleaned by the start-up sweep (reads @nxr_orig). Several viewers: the last resize wins; when one leaves the window follows the most recent one still fitting.
  • If the session has a client that is not read-only (list-clients -F '#{client_readonly}', i.e. someone attached with a real terminal) the window is NOT resized (the viewer still fits its own PTY), so a human's view is never shrunk. A human attaching AFTER the fit sees the fitted size.
  • The agent inside the session gets SIGWINCH and redraws, which is expected. The idle gate (pane_free, read_input_line, ghost-suggestion) does not assume a width (edges are 3+ rule characters, the prompt is found by shape); a test covers 45, 200 and 300 columns. Not measured against a real tmux in CI: the restore after a SIGKILL of the runner, and resize-window behaviour on tmux versions other than the tested 3.4.

After a reconnect the hub may reuse a stream id while a slow open of the old connection is still running: a stream only ever removes the chat subscription it registered itself, and one that was closed registers none.

Limits: at most 32 open streams per runner, 1 MiB per WebSocket message, 64 KiB per terminal input frame, 32,000 characters per chat prompt, snapshot frames trimmed to about 600 KB. The protocol is specified in the hub's docs/chat.md.

Remote Control

Claude: every session the runner starts or restores runs claude --remote-control <handle> (a --resumed one too): Remote Control is on from the first seconds, named like the session, with no keystroke at all. Measured on Claude Code 2.1.305 in tmux: about two seconds after start the screen shows /remote-control is active · Continue here, on your phone, or at with the https://claude.ai/code/session_... URL under it, and the footer ends with /rc. The runner only looks for that URL on the screen (rc_status ok, URL in remote_url). The flag is always given the handle as its value: a bare --remote-control would take the next argument, the prompt, for a name. The row records how the run was started (rc_native). On by default; NEXOR_RUNNER_REMOTE_CONTROL=0 disables it, and remote_control: true|false in the POST /sessions / POST /restore body overrides it per call (runner new --no-remote-control for the CLI). runner new itself never waits: it marks the row pending, and the agora unit or runner serve picks the URL up. Exactly one live process owns that watch: both compete for a leadership flock on <state dir>/locks/rc-owner.lock, the holder ticks every second while a session is pending (every ~5 s otherwise) and the other stands by. A pending row is given up when the session is gone, 30 minutes after arming with no sign of Remote Control (re-armed while the session is alive, then tried every 30 s), or 24 h after arming. The outcome is stored on the session row as rc_status and reported in every session of the agora snapshot and in GET /sessions, next to rc_attention:

rc_status meaning
null not asked (disabled, or not a Claude session)
pending waiting for Remote Control to show up (or, in the typed fallback, for an idle prompt)
sent Remote Control is on, the URL has not been seen yet (still looked for)
ok the Remote Control URL was captured (remote_url)
gave_up the session ended, no sign of Remote Control for 24 h, the session was not started with Remote Control and typing is off, or /rc failed survived 3 re-arms (rc_attention says what to do)

What the watch reads. Only the visible screen (capture-pane, no scrollback), and it sends no key at all (no Escape either). The URL is read only from the line(s) right under the newest /remote-control is active banner and must be https://claude.ai/code/session_<id>: the hyperlink target of the line (OSC 8) is preferred, else the text, joined with the next line when it reaches the right edge (a wrapped URL). A URL quoted in the transcript, an older banner, or the URL of the run before the last restore (kept aside in the row as rc_prev_url before the launch, remote_url cleared) is not taken from a leftover banner; but a resumed session re-uses its URL, so the same URL is accepted once the footer shows the live /rc (the proof that this run is connected). /rc counts as the footer only under the input box's bottom edge. A session that shows no URL two minutes after it was armed gets rc_attention (Remote Control may not be connecting: check the session and the account's policy); the note goes away with the URL. runner restore arms this watch like POST /restore does.

After a reboot. A session restored before the network is up starts Remote Control offline: the footer says /rc failed and no URL ever comes. runner restore therefore waits up to 5 minutes (--wait-network SECONDS, NEXOR_RUNNER_NET_WAIT, 0 = do not wait) until claude.ai:443 resolves and accepts a connection (a bare probe: no credentials, no payload), logs what it waited for, then restores (also when the time ran out). As a second line of defence the leader process runs a watchdog over the rows in pending/sent with no URL: 3 minutes after arming (NEXOR_RUNNER_RC_REARM_AFTER, seconds) a row whose footer ends with /rc failed is re-armed by typing /remote-control, only if the same snapshot shows an empty input box (a faint suggestion is not text), no dialog (folder trust, Remote Control modal, numbered options) and no esc to interrupt, and the screen stayed unchanged for 10 s (NEXOR_RUNNER_RC_REARM_IDLE); the typing is the read-back-then-Enter one below, under the session's typing lock. A draft in the box, a busy session or a dialog means nothing is typed and no attempt is used. Three attempts at +3, +10 and +30 minutes; if the footer still says /rc failed 3 minutes after the last one the row is gave_up and rc_attention says Remote Control failed to connect and re-arming did not help: open the session and run /remote-control, or restart it. It works for rows started with the flag; for the others (imported, not started by the runner) only with rc-typing on, like any typed /remote-control.

Restore at boot. install-service also writes and enables (never starts) nexor-runner-restore.service, a oneshot that runs runner restore when the user manager starts, so with linger (loginctl enable-linger $USER) every agent session comes back after a reboot with no human action. It is ordered after nexor-runner-tmux.service (and the API/agora units when installed), waits up to 30 s for the tmux socket, and gives the restore itself up to 15 minutes (the network wait above is part of that). It is not started by install-service, so neither an install nor the daily self-update relaunches sessions during the day. Existing hosts get it from the next self-update (which re-runs install-service), within a day. Opt out with install-service --no-restore-on-boot (remembered; --restore-on-boot turns it back on, and uninstall-service removes it); doctor reports it as restore-on-boot. Personal-scope sessions stay skipped, as with a manual restore: set NEXOR_RUNNER_RESTORE_PERSONAL=1 in the unit (a drop-in: systemctl --user edit nexor-runner-restore.service) to bring them back too.

Folder-trust dialog. A session started in a folder Claude has not been trusted in stops at Quick safety check: Is this a project you created or one you trust?. Measured on Claude Code 2.1.305: the options are ❯ No, exit and Yes, I trust this folder, No, exit is pre-selected (an Enter exits the session), Down/Up toggle the two and number keys do nothing. The runner never sends a key to it: it only recognises it, by its structure on the visible screen (no input box on the screen, the footer Enter to confirm · Esc to cancel as the last non-empty line, a contiguous block of Yes/No options right above it, the question under a column-0 rule above them), so a quoted dialog in the transcript or a draft saying "yes, i trust this folder" is not one. The row stays pending and rc_attention (in GET /sessions and the agora snapshot) says folder trust needed — open the session and accept; once a person answers, Remote Control (already asked for by the flag) comes up by itself and the note goes away. The typed fallback stops at the dialog too (nothing typed).

Typed fallback (off by default). For a session the runner did not start itself (one imported from a foreign tmux and still running, or a row armed by an older runner) there is no flag to give. NEXOR_RUNNER_RC_TYPING=1 or runner config set rc-typing on (an empty variable defers to the config file) lets the runner type /remote-control into such a session once its input box is idle, as before. Without it such a row is not armed and not watched: the next retry gives it up (gave_up) with rc_attention not started with Remote Control: restart it with Remote Control (runner restore) or enable rc-typing (runner restore relaunches it with the flag). It is the old, careful path: the input box may hold a prompt suggestion or text somebody typed, so the runner never presses Enter blindly: it clears the input line (C-u), types /remote-control, reads the input line back from the pane, and sends Enter only if the line is exactly /remote-control. Any other line is cleared again, nothing is submitted, the attempt is retried later (not before 5 s, kept on the row) and a line without the text itself goes to the log; after 20 wrong lines it gives up at the deadline. A session that is working (its footer says it can be interrupted) is not typed into, and a typing lock (flock on <state dir>/locks/<session>.lock) keeps two processes from interleaving keystrokes. The read-back uses capture-pane -e of the visible screen only (no scrollback): a trailing faint (SGR 2) prompt suggestion, a reverse-video trailing space (the cursor) and the NBSP Claude Code draws after ❯ are ignored; text on continuation lines of a multi-line draft counts as text (only plain spaces are blank, and a | or │ is text), and a pane showing a numbered-option dialog is never typed into. The box is located from what only the program draws, in column 0 (everything a user types, continuation and wrapped lines included, is indented by two spaces; measured on Claude Code 2.1.305): the bottom border is the last line starting with a run of ─ (a hint in it is fine), the box's top edge is the nearest such line above it with a ❯ line right below (a title with the session name is fine), and a bordered │ ❯ ... │ box needs both side borders. A draft that imitates a border or a ❯ /remote-control line is therefore read as a draft, never as the bare command, and neither a stale frame higher up nor the suggestion list drawn under the box confuses it.

OpenCode: sessions connect to the machine's always-on opencode service engine (the runner ensures it is up before launch and before issuing a ticket). There is no automatic step: GET /sessions/{ref}/remote-control (or a remote-control intent from the linked agora hub) issues a fresh pairing ticket with opencode pair --remote --yes — a one-time link, valid five minutes, through the OpenTunnel public address. Opening it shows the engine's web UI, where the session can be prompted and its permission requests answered, like the terminal does. The ticket is returned to the caller and stored as the session's remote_url (the last one issued); it is never logged. The engine is per-user and the ticket reaches every session on it, so keep the runner user's account the only one running agents on the machine.

Remote access security

OpenCode remote control goes through the engine's public tunnel (OpenTunnel), which stays on whenever the engine runs. What protects it:

  • The engine has one fixed password (service.json, key password). It also works over the public address (Basic opencode:<password>), so treat it like a root credential.
  • A pairing ticket (opencode pair --remote --yes, what Remote Control issues) is one-time and valid 5 minutes. Opening it hands the device a token valid for 30 days. Tokens are signed and stateless: OpenCode has no per-device revocation. The only way to invalidate them is to change the engine password.
  • The runner therefore rotates the password. runner opencode rotate-password (or POST /opencode/rotate-password, {"rotated": true}) sets a new random 43-character secret with the official opencode service set password <value>, then starts the engine again. If that CLI key is missing or does not persist the value, it falls back to rewriting password in service.json (atomic, mode 0600, other keys kept) while the engine is stopped. The secret is never printed or logged. Before anything is touched, service.json is copied to service.json.bak-<UTC timestamp> (mode 0600, the newest three are kept); a numeric suffix (-001, -002, ...) keeps rotations of the same second apart.
  • Weekly rotation: runner systemd install --rotate [--extra-path DIRS], then systemctl --user daemon-reload && systemctl --user enable --now nexor-runner-rotate.timer (OnCalendar=weekly, Persistent=true). It is opt-in; turn it off with systemctl --user disable --now nexor-runner-rotate.timer. Every rotation invalidates all paired devices: open Remote again to pair them.
  • Lost or stolen phone: run runner opencode rotate-password now; do not wait for the timer.
  • Never send a ticket through chat apps or any shared channel: whoever opens it first gets a 30-day token.

The engine daemonizes inside the cgroup of whoever starts it, so a unit that starts it would kill it when that unit stops. The runner starts the engine (rotation and ensure_running, also from the API unit) through systemd-run --user --scope when it runs inside a unit, so restarting nexor-runner-api or the end of the rotate oneshot does not take the engine down; the rotate unit also sets KillMode=process as a second guard.

Effect on running sessions: the password change stops and restarts the engine process. Sessions started with --standalone run their own server and are not touched. Sessions the runner launched attach to the engine (opencode --session <id>); expect them to lose their connection while the engine is down, and run runner restore for any that do not come back (the state file keeps the session id, so the conversation resumes). Long-running work in the engine itself is interrupted by the restart, so rotate between tasks when possible.

Stable Agora handles for OpenCode sessions

The Agora connector gives every OpenCode session its own identity, taken from the session id on each tool call. So that a runner-launched session acts under its stable handle (gc-oc-agora, not a per-session one), the runner keeps a map {"ses_...": "<handle>"} in ~/.config/nexor-agora/opencode-sessions.json (override: NEXOR_AGORA_OC_HANDLES), which the connector re-reads whenever it changes.

  • Where the session id comes from. The runner chooses it: oc sessions are launched as opencode --session ses_<random> and the id is kept in the state file, so the entry is written right after the tmux session is created, before the first prompt is handled. restore and POST /restore rewrite it; kill removes it. When a launch replaces a stale row (its tmux session had disappeared), the entry is written again in the same state-lock hold that commits the new row: a reconcile during the startup settle still sees the old row and would otherwise leave the old id mapped until the next one.
  • Ids not known yet (rows from runner import, older state files): the agora loop reconciles every 30 s (and runner opencode map --sync on demand). It lists the engine's sessions (GET /api/session, password from service.json), picks the newest one titled with the handle (the runner titles its sessions that way) that no other row owns, stores the id in the state file and maps it. An unreachable engine only leaves those rows unmapped.
  • Rules. One handle maps to at most one session id (the newest wins and the old entry is dropped); entries for handles the runner does not know are kept; the file is written atomically (temp file plus os.replace, mode 0600, directory 0700) under a lock shared by the API unit, the agora unit and the CLI. A file that cannot be read is never overwritten; one that is not a JSON object is kept as <file>.invalid and rebuilt. Map errors are logged and never fail a launch.
runner opencode map [--sync] [--json]   # print the map (session ids and handles, no secrets)

CLIs installed with nvm

The session environment is an allow-list, so nvm directories are not on PATH. The runner resolves each client binary to an absolute path at launch, in this order:

  1. NEXOR_RUNNER_CLAUDE_BIN / NEXOR_RUNNER_OPENCODE_BIN (absolute path);
  2. NEXOR_RUNNER_EXTRA_PATH (colon-separated directories, e.g. ~/.nvm/versions/node/<v>/bin; runner systemd install --api --extra-path writes it into the API unit);
  3. the login shell (bash -lc 'command -v claude', once, cached).

The binary's directory is prepended to the session PATH so npm-installed CLIs find node. --dry-run on runner systemd install prints the detected paths.

Runner config

One file, ~/.config/nexor-runner/config.json, holds the settings every entry point shares, so the CLI in a shell, runner serve and the agora unit cannot disagree (the unit needs no environment variable for them):

runner config set cards-dir /srv/agent-cards   # where the agent cards live
runner config set host my-box                  # the name cards' home.host is compared with
runner config set host-id srv                  # the 3-letter id the handle grammar checks (or: install-service --host-id)
runner config show [--json]                    # effective values and where each comes from
runner config unset cards-dir
runner systemd install --agora --cards-dir /srv/agent-cards   # writes the same file

Precedence, highest first: the flag (--cards-dir), the environment variable (NEXOR_RUNNER_CARDS_DIR, NEXOR_RUNNER_HOST, NEXOR_RUNNER_HOST_ID), config.json, then the default (cards in ~/.config/nexor-runner/cards; host from the agora link name, else the system hostname; the host id as described under Handles). When the cards directory does not exist, runner new / runner cards say so and print how to set it.

Other variables: NEXOR_RUNNER_RESTORE_PERSONAL (restore personal sessions too), NEXOR_RUNNER_REMOTE_CONTROL, NEXOR_RUNNER_HANDLE_PREFIX, NEXOR_RUNNER_CARDS_DIR (cards directory), NEXOR_RUNNER_HOST (see Cards), NEXOR_RUNNER_HOST_ID (see Handles), NEXOR_RUNNER_TOKEN / NEXOR_RUNNER_TOKEN_FILE, NEXOR_RUNNER_CLAUDE_SESSIONS (where runner import looks for Claude session files).

Handles and renaming

One name everywhere: handle = tmux session name (cc-<handle>) = claude --name = Remote Control name = Claude session title. The grammar (src/nexor_runner/handles.py):

<initials>-<scope>-<client>-<host>-<description>[--<filone>]
gc-w-cld-srv-agora        gc-p-cld-srv-home--artifact

initials exactly 2 lowercase letters (the person); scope p (personal) or w (work); client cld (Claude Code), cdx (Codex) or opc (OpenCode); host exactly 3 lowercase letters (a hardware id); description and filone 1-20 chars of [a-z0-9] with single inner dashes; at most 64 chars in all. state_key is <initials>-<scope>-<description>. dev-<slug> free sessions are exempt, and the older <prefix>-<cld|oc|cdx>-<topic> handles keep working (card lookup, filoni count, restore) while you migrate.

The values come from the owner's registry, registry.yaml, in the cards directory or its parent (or the file NEXOR_RUNNER_REGISTRY names):

version: 1
people:
  - {initials: gc, agora_handle: owner}   # the owner (an Agora account)
  - {initials: tc, name: Tess}       # a hosted person (no Agora account)
hosts:
  srv: "the build server"
  lap: "laptop"

This is the file nexor-agora cards init writes and the hub validates: people is a non-empty list (at most 20) of {initials, agora_handle} or {initials, name} with distinct 2-letter initials; the runner reads the same shape, inline {...} entries and hosts: {srv: "..."} included, and accepts a handle whose initials are any listed person's. The older single person: block (initials, agora_handle) is still read (as a one-person list); having both person: and people: is an error.

NEXOR_RUNNER_HANDLE_GRAMMAR=off|warn|enforce (default warn) decides what a launch does (runner new, POST /sessions, the agora launch intent, restore):

  • warn: a handle that breaks the grammar or the registry is logged ([handles] warning: ...) and started anyway.
  • enforce: it is refused (400; restore leaves the row in the state file and skips it). The runner's own host id must be a 3-letter id listed in the registry hosts, and the handle's host segment must equal it: a card whose handle says lap is refused on the srv runner. The host id is, in order: NEXOR_RUNNER_HOST_ID; host-id in config.json (runner config set host-id srv, or install-service --host-id srv); the host part of the runner name when it is <host>-<initials> (^[a-z]{3}-[a-z]{2}$, so srv-ec is on srv; ec-srv is not); the registry's host when it lists exactly one; and, for an install that predates the id, the host name below when that is itself a 3-letter id. Otherwise there is none (runner config show says where the value came from, doctor warns). It is separate from the host name that a card's home.host is compared with, so a machine called my-box can have the id srv. The initials must be the registry person's, and the card's scope: must agree with the handle's scope letter (in warn and enforce, GET /cards flags a disagreeing card with handle_problems). A registry that cannot be read (not UTF-8, a duplicate top-level key, a wrong shape) never stops a restore or a launch in warn and off: it is logged and the launch goes on; in enforce it refuses.
  • off: no check.

runner rename <old> <new> [--dry-run] [--force] (POST /sessions/{ref}/rename {new_handle, force?, dry_run?, thread_id?}) gives a session a new handle and preserves its conversation. For Claude Code and OpenCode:

  1. checks: <old> is the session's handle or tmux name, exactly (a fragment matches nothing); the new handle is valid for the mode, the initials, the scope and the client do not change, a base session does not become a filone (--) or the other way round, the name is not used by a state row, a live tmux session or a foreign tmux server, the row has a session id, and the runner's tmux answers cleanly (an error is a 503, never "no sessions"); the session must be idle and free: the activity (the transcript) says idle, AND one styled snapshot of its pane shows nothing still running. The transcript alone is not enough, because background work writes no turn: a pane that shows esc to interrupt, a footer under the input box with a count and a kind (1 shell, 2 background tasks, 1 local agent, 1 monitor, in the background, ↓ to manage), a numbered approval menu (❯ 1. Yes) or text in the input box is refused with 409 and the reason; so is a pane that cannot be read or shows no input box (fail closed). --force renames anyway, with a warning, and cuts whatever runs short;
  2. stops the tmux session with tmux kill-session only: the state row is not deleted;
  3. updates the row under the state lock (and only if the old session has not been started again meanwhile, e.g. by a restore): handle, name cc-<new>; session_id, cwd, model, scope kept; the Remote Control fields reset and the old URL set aside in rc_prev_url, as a restore does (a resumed session may re-show the previous run's banner: without the live /rc footer it is never taken for the new run); rename_from=<old> until the session runs again. An error here, after step 2, says the old session was stopped and to run runner restore;
  4. resumes it: claude --resume <session_id> --name <new> --remote-control <new> with NEXOR_AGORA_HANDLE=<new> (OpenCode: opencode --session <id>, then the engine title and the handle map are updated), then waits for the Remote Control URL like restore does (the CLI only arms the watch). The transcript title follows because --name on --resume appends a new custom-title record (measured on Claude Code 2.1.252); the runner reads it back and warns if it is not there;
  5. syncs the server-side title: a resumed session re-uses the same Remote Control session on claude.ai, so the title shown by the desktop app and claude.ai/code would stay the old handle. The API types /rename <new> into the new session, ONLY through the safe typing gate: under the per-session typing lock, when one styled snapshot of the pane shows the session idle with nothing running and an empty input box (pane_free), with the command read back from the pane before Enter, a few bounded retries (the resumed TUI needs a moment). If the gate never opens the rename still succeeds and answers title_sync: "pending" with a warning; nothing is ever typed blindly. The CLI does not wait: it answers pending, run runner retitle later.

runner retitle <handle|all> [--dry-run] (POST /sessions/{ref}/retitle, ref a handle, tmux name or all; body {dry_run?}) does step 5 for sessions already running, for example ones renamed before it existed: it types /rename <handle> through the same gate and reports per session done | busy | skipped (ready in a dry run, which types nothing). It is idempotent (typing the same title again changes nothing). all tries every live Claude session once and reports the busy ones; a single handle retries a few times. dev-*, closed Claude sessions and half-renamed sessions are skipped. For tracked Codex threads it updates the stored title by ID.

It is idempotent and safe to re-run after a crash: before step 3 the row still has the old name, after it the new one with rename_from set, and the same command does what is left (a re-run of a finished rename is a no-op, but only while the renamed session is alive: otherwise it is a 409 telling you to runner restore; runner new <new> is refused while a half-done rename owns that name, so its row and session id are not replaced). --dry-run validates and prints the steps, writing nothing. dev-* sessions cannot be renamed.

Codex. If its runner terminal is open, copy the session ID from /status if needed, then use /exit. Start with runner rename OLD NEW --dry-run. If the ID is missing from runner state, add --thread-id ID (API field thread_id). The runner checks the thread's project and refuses IDs already linked to another row. Remove --dry-run to update both names. The native conversation and history stay with the same ID. The runner removes the closed tmux pane and leaves the thread available in Codex Remote. Use runner retitle HANDLE if only the displayed title needs repair. Refresh the Remote chat list if it already showed the old title.

An Agorà identity rename or adoption has its own permissions and history. Use the stable handle you intend to operate under. The runner command updates the runner and Codex only. If you want to reopen a renamed thread in tmux, choose that session in the restore API or use runner restore --only HANDLE. A regular or boot restore skips it, and runner new refuses to overwrite its handle.

Session activity

Every session row carries what the agent is doing right now, so a dashboard can tell a busy agent from a parked one without opening its terminal:

Field Values
activity working (a turn is running), idle (waiting for the next prompt), waiting (blocked on a permission/approval prompt or a question), unknown (no readable source)
activity_since ISO 8601 UTC (2026-10-19T10:00:09.000Z) of the last change of activity, or null when unknown
last_turn_end ISO 8601 UTC of the last finished turn, or null when none is known

It is in GET /sessions, in the agora snapshot (sessions[]) and in runner ls (a column, and the three fields in --json). It is computed on every listing and every agora report tick (5 s), read-only, and bounded: an unchanged transcript costs one stat, an engine answer is reused for 3 s, a pane is captured only for a session that looks busy (or has no other source) and at most once per 2 s. A source that fails makes that row unknown; it never fails a listing.

Client Source Rule
Claude Code ~/.claude/projects/<cwd-slug>/<session-id>.jsonl (CLAUDE_CONFIG_DIR moves ~/.claude), tail only, incremental system/turn_duration, an assistant entry with stop_reason: end_turn or an interrupt notice = idle. A prompt, a tool_result or an assistant entry with stop_reason: tool_use = working. Sub-agent (isSidechain) entries, slash-command output, compaction summaries and non-conversation records are ignored. A fresh session with no conversation yet is idle
Codex ~/.codex/sessions/YYYY/MM/DD/rollout-<ts>-<thread-id>.jsonl (CODEX_HOME), tail only, incremental event_msg task_started = working; task_complete or turn_aborted = idle. Rollouts whose thread_source is guardian_review (the approval reviewer's own thread) are never used
OpenCode the local engine, GET only: /api/session/active, /api/session/<id>, /api/session/<id>/permission, /api/session/<id>/form id in the active set = working; a pending permission request or form = waiting; else idle. last_turn_end is the session's time.idle
any, fallback tmux capture-pane, last 30 lines a numbered approval menu (1. Yes) = waiting (also upgrades a Claude/Codex working); esc to interrupt = working; any other readable screen = idle (also downgrades a Claude/Codex transcript working older than 30 s)

Notes and gaps:

  • OpenCode sessions are looked up by the row's session_id; when the engine does not know it the newest engine session titled with the handle is used (the same rule as the handle map).
  • Codex allocates its own thread ID. Until that ID is known to the runner, activity uses pane heuristics and automatic restore skips the session. Use Codex's own resume picker to recover it; the runner never guesses with resume --last.
  • waiting for Claude Code and Codex comes from the screen only: neither writes the pending approval to its transcript. The menu patterns are heuristics; an unrecognised prompt keeps the row working.
  • When the source gives no timestamp (pane fallback, OpenCode working/waiting), activity_since is the moment this runner first saw the new activity.
  • A transcript whose last conversation entry is a prompt or a tool result is working even if the client died mid-turn; the session disappears from the list when its tmux pane does.

Concepts

Handle. A session's identity (the current grammar is under Handles and renaming; this is the older form, still accepted): <prefix>-<client>-<topic>[--<stream>], where prefix is 2-4 lowercase letters (the owner's initials; set NEXOR_RUNNER_HANDLE_PREFIX to let cld-<topic> be shorthand for <prefix>-cld-<topic>) and client is cld (Claude Code), oc (OpenCode) or cdx (Codex). Examples: jd-cld-api, jd-oc-api, jd-cld-api--auth. The tmux session is named cc-<handle> and the handle is exported to the agent as NEXOR_AGORA_HANDLE. At most 3 streams (--<stream>) per topic; a stream session defaults to a smaller model than the main one.

Claude Code and Codex use the same Linux runner service and Agorà runner token. Install the clients you plan to run under the Linux account that owns the service. For Codex:

  1. Sign in with codex login and configure the Agorà MCP server for Codex under that account.
  2. Run nexor-runner doctor and check codex, codex-launch and hub. If Codex is missing from the service PATH, rerun install-service --extra-path /path/to/bin with the absolute directory that contains it. The existing hub link and port are kept.
  3. Check that the runner is online in Agorà Agents. Use tmux or the runner browser terminal to start a Codex session.

For mobile access, pair the host's Codex Remote daemon with the ChatGPT app once, under the same Linux account as the runner. With the daemon connected and a Codex CLI that supports codex resume --remote, starting a Codex card creates a chat named after the card and attaches tmux to the same chat. Select the host in the phone's Codex view to write through Codex Remote without VPN. Keep the terminal open if you also use it locally. The runner sends the card's initial prompt, or a short readiness prompt when none was supplied, so the new chat is listed. The Agorà MCP connector must support native runner card binding to retain the card's identity in Agorà.

Hosts without Codex Remote use the standalone terminal launch (--no-daemon). If the daemon is enabled but offline, reconnect it before launching. A launch that has already recorded a native thread can be recovered with runner restore. With a standalone launch, if the phone can read the thread but cannot send, close the terminal owning it with /exit and retry on the phone.

Codex uses its configured model unless a model is supplied.

Card. <handle>.md in the cards directory (--cards-dir, NEXOR_RUNNER_CARDS_DIR or runner config set cards-dir, see Runner config): YAML-like frontmatter plus one fenced JSON block. home.cwd is the working directory, shared by every client and stream of a topic (the card is always the cld one, <prefix>-cld-<topic>.md). home.host must equal this machine's name or host id, ignoring case (My-Box is my-box), or, as a list ("host": ["my-box", "lap"]), any one of its entries must; otherwise runner new refuses unless you pass --force; a card without home.host runs anywhere. The name is NEXOR_RUNNER_HOST, else host in config.json, else the runner name from agora.json (see below), else the system hostname. The cards directory defaults to ~/.config/nexor-runner/cards.

Scope. A card may declare scope: personal or scope: p in its frontmatter (work / w is the default when the key is absent; case and surrounding blanks are ignored, anything else is work). It marks agents the owner wants kept apart from work ones. When the handle conforms to the grammar its scope letter (-p- / -w-) is authoritative: a card can never downgrade a -p- handle to work, and when the two disagree the more private one wins (a -w- handle whose card says personal is personal too). The disagreement is reported as handle_problems in GET /cards and refused at launch when the grammar is enforced. Older handles and dev-* use the card alone. The scope is stored on the session row at new / launch / import / restore and is re-read from the card whenever it matters (snapshot, restore, bulk stop), so editing a card takes effect without relaunching. Free (dev-*) sessions and sessions without a readable card are work.

  • runner restore skips personal rows (reported as skipped (personal) <name> on stderr; the rows stay in the state file). Pass --include-personal, or set NEXOR_RUNNER_RESTORE_PERSONAL=1, to restore them too. The CLI is the only bulk restore path (no unit restores at boot by itself); restoring one session explicitly (hub Resume, POST /restore with targets) is never filtered.
  • runner kill --scope personal|work stops every live session of that scope (the same through POST /sessions/stop-scope {"scope": "personal"} and the agora intent stop-scope).
  • The agora snapshot carries scope on every session and every card.

Free sessions. Handle dev-<slug> needs no card but needs -C <dir>; names are unique (cc-dev-<slug>-<n>) and never refused as duplicates.

Environment. Sessions start with env -i plus an allow-list (PATH, HOME, LANG, TERM, NEXOR_AGORA_*, XDG_CONFIG_HOME, ...). Variables matching *API_KEY* and ANTHROPIC_AUTH_TOKEN are refused even when requested: agents run on the subscription login.

State. ~/.local/state/nexor-runner/sessions.json. Claude sessions are started with --session-id <uuid> (stored); restore runs claude --resume <uuid>, the exact conversation. Rows without an id, and OpenCode, use --continue.

CLI reference

runner ls [--json]                         list sessions (with their activity)
runner cards [--json] [--cards-dir D]      list agent cards and whether they run
runner new <handle> ["task"] [-f FILE]     start a session
        [--model M] [-C DIR] [--cards-dir D] [--force] [--no-remote-control] [--dry-run]
runner rename <old> <new> [--dry-run] [--force] [--thread-id ID] [--cards-dir D]
                                           give a session a new handle (see Handles and renaming)
runner retitle <handle|all> [--dry-run] [--cards-dir D]
                                           sync the claude.ai / desktop title to the handle
runner attach <index|name|fragment>        attach to a session
runner kill <index|name|fragment>          kill a session
runner kill --scope work|personal          kill every live session of a scope
runner restore [--dry-run] [--include-personal] [--only HANDLE] [--cards-dir D]
               [--wait-network SECONDS]
                                           re-create sessions the tmux server lost
runner import [--from-tmux default|SOCKET] [--cards-dir D] [--dry-run]
              [--only GLOB]... [--exclude GLOB]... [--prefix PREFIX]...
runner serve [--host H] [--port 7800] [--token-file F] [--init-token] [--cards-dir D]
runner link --hub URL --token-file F       link this runner to an agora hub
runner unlink                              forget the link
runner agora [--cards-dir D]               outbound loop: report to the hub, run its intents
runner opencode rotate-password            new OpenCode engine password (revokes paired devices)
runner opencode map [--sync] [--json]       session id -> handle map read by the Agora connector
runner systemd install [--api|--agora|--rotate] [--dry-run] [--tmux-bin P] [--runner-bin P]
        [--port N] [--token-file F] [--extra-path DIRS] [--cards-dir D] [--host NAME]
runner config show [--json]                print the effective settings and their source
runner config set cards-dir|host|host-id|terminal|rc-typing VALUE
                                           save a setting in config.json
runner config unset cards-dir|host|host-id|terminal|rc-typing
                                           remove it
  • new: the first task is the optional positional prompt (or -f FILE). cld runs claude --model M --name <handle> ["<task>"]. oc runs opencode --standalone [--prompt "<task>"]: the model comes from the OpenCode config (a requested model is ignored); point it at another config with XDG_CONFIG_HOME. --dry-run prints the launch command without starting anything.
  • attach / kill accept an index (order of runner ls), an exact name or a unique fragment.
  • restore skips rows whose name (or imported origin) is still alive in another tmux server, so two clients never share one conversation.
  • import is described under Migration.

API reference

Loopback only (127.0.0.1, ::1, localhost; any other --host is refused), JSON in and out, no access log. Every endpoint except GET /health needs Authorization: Bearer <token>. ref is an index, exact name or unique fragment, as in the CLI (index follows GET /sessions); POST /sessions/{ref}/rename takes only the exact handle or tmux name. Errors are {"error": "..."} with 400/401/404/405/409/413/501.

Endpoint Body / query Response
GET /health (no auth) {ok, version}
GET /whoami {ok, version}; needs the token, so doctor can tell this user's runner from another process on the same port
GET /sessions {sessions:[{name, uid, tmux, title, state, session_id, handle, client, model, project, command, created, last_active, port, url, activity, activity_since, last_turn_end}], count}
POST /sessions {handle, prompt?, model?, cwd?, force?, remote_control?} (cwd skips the card; dev-<slug> needs cwd; cwd must be inside the runner user's home: relative paths like dev/my-project resolve against it, ~/absolute accepted if inside, symlinks resolved, home itself refused) 201 {status:"spawned", name, uid, tmux, handle, client, model, project, port:null, url:"", message}; 409 if already running
GET /cards {cards:[{handle, mission, status, home, model, local, running, where, session, filoni} | {handle, error}], count}; sorted by handle; running is true when cc-<handle> is alive in the runner's tmux or in a foreign one (where: runner, foreign, or null); local = the card's home.host is this machine (or it has none); a card that fails to parse is {handle, error}, never a 500
GET /sessions/{ref} one session row
DELETE /sessions/{ref} (or POST /sessions/{ref}/kill) {status:"killed", name, title, known}; an unknown ref gives known:false with 200
GET /restore?query=&limit= {status:"listed", total, candidates:[{session_id, title, project, last_active, repeats}]}
POST /restore {targets?:[uuid|name|index], query?, limit?, dry_run?, remote_control?} without targets as above; with targets {status:"restored", restored:[{session_id, status, name, title, url}]}
POST /sessions/stop-scope {scope: "work"|"personal"} {status:"stopped", scope, stopped:[name], count}; idempotent; 400 for any other scope
POST /sessions/{ref}/rename {new_handle, force?, dry_run?, thread_id?} {status:"renamed"|"resumed"|"unchanged"|"dry-run", from, to, name, session_id, title, title_sync:"done"|"pending"|null, warnings, steps}; 409 when busy or the name is taken, 404 unknown session, 502 if client restart or Codex title update fails
POST /sessions/{ref}/retitle {dry_run?} (ref: handle, tmux name or all) {status:"retitled"|"dry-run", results:[{handle, name, state:"done"|"ready"|"busy"|"skipped", why}], counts}; 404 unknown session
GET /sessions/{ref}/attach {name, socket, argv, command, ssh}
GET /sessions/{ref}/remote-control Claude: {supported, automatic, mechanism, typing_fallback, keys, note} (describes how Remote Control is started: the launch flag, and the typed fallback with its keys). OpenCode: issues a fresh pair ticket and answers {supported, automatic:false, mechanism, remote_url, one_time:true, expires_in:300, note}; 502 when the engine is unavailable. 501 for Codex
POST /opencode/rotate-password {rotated: true}; 502 when the engine cannot be restarted (see Remote access security)
GET /sessions/{ref}/ttyd 501 (not implemented)

state is always running; what the agent is doing is activity (see Session activity); session_id is the Claude conversation id or the OpenCode ses_ session id (empty only for rows the runner did not launch); remote_url is the Remote Control URL (Claude) or the last pair ticket issued (OpenCode, one-time, five minutes); rc_status is the Remote Control outcome (see Remote Control: pending, sent, ok, gave_up, or null) and rc_attention says why a person has to look at the session (a folder-trust dialog waiting for an answer, no Remote Control URL after two minutes, a session not started with Remote Control; null when nothing is needed); last_active is null; url and port are empty (no web terminal).

Security model

  • Own tmux server and a dedicated systemd --user unit with env -i, an explicit PATH/HOME/LANG and UnsetEnvironment for API keys. Restarting another service cannot touch the sessions; restarting the runner's own unit does, and runner restore brings them back.
  • Sessions start from the allow-list only. *API_KEY* and ANTHROPIC_AUTH_TOKEN are never passed.
  • The API listens on loopback only, with no unix socket and no TLS: put anything that must reach it from outside behind your own authenticated proxy.
  • The bearer token is read from NEXOR_RUNNER_TOKEN, else from a file (--token-file, NEXOR_RUNNER_TOKEN_FILE, default ~/.config/nexor-runner/token) that must be mode 0600 and at least 16 characters. It is never accepted on the command line.
  • import only reads the source tmux (list-panes) and Claude session files; it never starts, kills or renames a session.

Migrating from an existing tmux-based launcher

Sessions started by an older launcher live in the default tmux server. The runner's sessions live in its own server, so the two coexist.

Old sessions stay where they are; new ones are born in the runner; agent sessions are moved one at a time.

  1. Install the runner and both units (above). Start new sessions with runner new or POST /sessions from now on.
  2. To move one agent session:
    1. runner import --dry-run and check the table (handle, cwd, model, session id).
    2. runner import records the live sessions in the state file. Nothing is started or touched, and re-running adds nothing.
    3. Close the old session (exit the client, or kill that tmux session in the default server).
    4. runner restore --dry-run, then runner restore: the session comes back in the runner with claude --resume <exact session id> and the model it was using.
    5. Remote access is re-enabled automatically (see Remote Control below).
  3. Repeat for the next session whenever convenient. restore refuses a session that is still alive in the old server, so you cannot end up with two clients on one conversation.

Agents still running in the old server

While agents are not moved yet, the runner also watches the foreign tmux servers listed in NEXOR_RUNNER_FOREIGN_TMUX (comma-separated socket names; default = the default server, which is also the default value; empty = none). GET /cards, runner cards and the agora report show a card as running when cc-<handle> is alive in the runner's server or in a foreign one (where: "runner" | "foreign" | null). Launching such a handle (POST /sessions, runner new, an agora launch intent) is refused with 409 ("already running outside the runner; move it with import+restore") unless force: true / --force (agora intents cannot force). If a foreign server cannot be probed (anything but "no server running"), launch fails closed with 503 and the card reports where: null. Filoni counting only looks at the runner's server.

Alternative: one shot

  1. runner import --dry-run, then runner import (all live sessions).
  2. Stop whatever owns the default tmux server (this kills every session in it).
  3. runner restore --dry-run, then runner restore.
  4. Remote access is re-enabled automatically in each restored Claude session.

What runner import does

runner import [--from-tmux default|<-L socket>] reads the source tmux and ~/.claude/sessions/<pid>.json (pid, sessionId, cwd, name, tmux; matched on the pane PID or one of its descendants, else on the file whose tmux names the session with a live pid). Per live claude/opencode session: handle = the session name minus cc- when it is a <prefix>- handle whose card exists, else dev-<slug> from the tmux name; cwd = pane cwd; the original tmux name is kept as origin. Claude sessions without an id are skipped with a warning; OpenCode needs a cc-<prefix>-oc-<topic> name. The model is read from the last assistant entry of ~/.claude/projects/<cwd-slug>/<sessionId>.jsonl and passed to --model on resume (opus when the transcript has none).

Filtering. --only HANDLE_OR_GLOB and --exclude HANDLE_OR_GLOB (both repeatable) are matched with case-sensitive fnmatch against the resulting agent handle (e.g. --exclude 'tc-*'); --prefix P is shorthand for --only 'P-*'. --exclude wins over --only. Non-matching sessions are reported as excluded (also with --dry-run) and are neither recorded nor counted as imported. Empty patterns are rejected; when nothing matches, a message says so and the exit code stays 0. Sessions skipped with a warning have no handle yet and are not filtered. The HTTP API does not expose import, so there is no API counterpart.

Development

pip install -e ".[dev]" && ruff check . && pytest

Metadata

Release files for nexor-runner 0.9.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nexor-runner 0.9.0
File Size Uploaded Provenance Actions
nexor_runner-0.9.0.tar.gz 357.4 kB With provenance Details for nexor_runner-0.9.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nexor-runner 0.9.0
File Interpreter ABI Platform Actions
nexor_runner-0.9.0-py3-none-any.whl Python 3 none any Details for nexor_runner-0.9.0-py3-none-any.whl

Total release size: 562.3 kB

Release files / nexor_runner-0.9.0.tar.gz

Download URL nexor_runner-0.9.0.tar.gz
Size 357.4 kB
Tags Source
SHA-256 checksum
How to use checksums
37cd3d7e673e1775bab87e2ef820861f91843a23461373fbf4a20f79e264aa8b
BLAKE2b-256 checksum
How to use checksums
c86bd5e1018bf99022f791133f99b0745dec9d5478ae316d03e8f0b00a9fe908
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / nexor_runner-0.9.0-py3-none-any.whl

Download URL nexor_runner-0.9.0-py3-none-any.whl
Size 204.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03346007a1a4989783a6c4322b74109d973716c8e92050a34860c257aa30432c
BLAKE2b-256 checksum
How to use checksums
2ce3b3ba9b3f6b4a4530cd782c98d87bcafd59cb352ebf5c5bb6e71b8298c859
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Security for nexor-runner 0.9.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nexor_runner-0.9.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page