pyrycode

module
v0.41.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2026 License: MIT

README

Pyrycode

A process supervisor and runtime for Claude Code. Run pyry instead of claude to get a long-lived, self-healing host for your AI assistant — with a control socket for status, logs, graceful shutdown, and detach/reattach from any shell.

Status

Daily-driver-grade and actively shipping. Latest release: v0.15.0 (2026-07-03). Foreground mode is a drop-in claude wrapper with auto-restart. Service mode runs pyry under launchd or systemd and exposes a Unix-socket control plane. Since v0.13.0 pyrybox runs claude under systemd via the public install path described below, replacing the prior tmux + bash restart-loop setup.

Shipped since Phase 0: multi-session routing (a single pyry hosts N UUID-addressed claude sessions, pyry sessions new/list/rm/rename), pyry agent-run (an SDK-consumer runner), and remote access: the Pyrycode-Relay is live at pyrycode-relay.pyryco.de (binary↔relay WSS, Noise_IK E2E crypto, QR pairing). The companion mobile client has held a stable v2 session against the live relay since 2026-07-03.

There is one way to drive claude, and it is stream-json. The terminal-driving path was deleted in #1348 (2026-08-16) on both surfaces. It had not been exercised since the fleet moved off it on 2026-07-25, and by then it did not work: all four of its live gates failed on clean main, and an agent run on it produced no turns at all. PYRY_USE_STREAMJSON is no longer read, so a fork that still sets it is unaffected. interactive_runner accepts "" or "stream-json"; the removed "pty" value fails loudly rather than silently selecting something else.

Still on the roadmap: Channels integration (pyrycode-owned Discord/Telegram) and voice (see docs/plan.md).

What it does

  • Supervises claude in a pseudo-terminal with crash recovery and exponential backoff.
  • Resumes the previous session on every restart so conversation history survives crashes.
  • Two modes from one binary. Run from a TTY for interactive development; run under a service manager (no TTY) for production. The same binary auto-detects and adapts.
  • Control plane on a Unix socket. Query state, stream logs, request shutdown, attach a terminal — all from any shell, with single-user filesystem permissions as the security boundary.
  • CLI transparency. Anything pyry doesn't recognise is forwarded to claude verbatim. Pyry's own flags use a -pyry-* prefix so they never collide.

Platforms

Linux and macOS, including Apple Silicon (arm64) — prebuilt darwin_arm64 binaries ship with every release. Windows is out of scope (different PTY backend, different signal model).

Install

Universal one-liner (Linux / macOS, amd64 / arm64):

curl -fsSL https://raw.githubusercontent.com/pyrycode/pyrycode/main/install.sh | bash

Drops pyry in ~/.local/bin/. Set PYRY_VERSION=v0.13.0 to pin a release; set PYRY_INSTALL_DIR=/usr/local/bin (run with sudo bash) for a system-wide install.

Homebrew (macOS, Linuxbrew):

brew install pyrycode/tap/pyry

Go-native (any platform Go supports):

go install github.com/pyrycode/pyrycode/cmd/pyry@latest

From source:

git clone https://github.com/pyrycode/pyrycode
cd pyrycode
make build           # ./pyry — current platform
make install         # build HEAD, swap it into ~/.local/bin/pyry, restart the daemon
make linux           # cross-compile dist/pyry-linux-amd64
make dist            # adds darwin × {amd64, arm64}

Requires a working claude binary on PATH to actually do anything useful. Building from source needs Go 1.26.2 or later.

Quickstart

Foreground (development). Run pyry instead of claude:

pyry "summarize foo.md"           # forwarded as claude's initial prompt
pyry --model sonnet -p "..."      # any claude flag passes through

If claude exits, pyry restarts it with --continue so you keep your session.

Service mode (production). Two commands. pyry install-service writes a systemd unit (Linux) or launchd plist (macOS), inheriting your shell's $PATH so nvm / pyenv / brew tools come along automatically:

pyry install-service -- \
  --dangerously-skip-permissions \
  --channels plugin:discord@claude-plugins-official

systemctl --user daemon-reload
systemctl --user enable --now pyry

(macOS: launchctl load ~/Library/LaunchAgents/dev.pyrycode.pyry.plist in place of the systemctl lines.)

The supervised claude has no terminal of its own, and since #1348 there is no way to borrow it: pyry attach was removed along with the terminal path it read from. Watch a live session from the desktop or mobile client instead.

pyry status, pyry logs, pyry stop, pyry channel new, pyry conversation new, and pyry conversation post work from any shell, talking to the daemon over its Unix socket at ~/.pyry/pyry.sock.

pyry channel new, run inside a project folder, creates a channel — a long-lived conversation — whose workspace is that folder, and prints its conversation id. It exists because a client's workspace picker only offers folders that have already hosted a conversation, so a folder that merely exists on the host could not be chosen from a phone at all; your shell is already standing in the right place. --name <label> overrides the default name (the folder's own). The folder must be under $HOME.

pyry conversation new [--type chat|channel] [--name LABEL] [--model MODEL] [--effort EFFORT] creates a Claude conversation without requiring a configured relay or paired client. The default type is an unpromoted chat in the client's Chats section; --type channel creates a promoted channel. Its workspace is the shell's current folder, resolved through symlinks and confined to $HOME. An omitted or empty name leaves chats unnamed and gives channels the resolved folder's base name; a nonempty --name names either type. Creation binds a session immediately; Claude starts on the first message.

The daemon checks model/effort syntax. Nonempty models must appear in its retained published model menu; nonempty efforts use the effective model's allowed levels, including the same fallback rules as paired clients. An explicitly requested nonempty model is refused if the menu is unavailable. Omitted settings inherit the daemon's mint defaults; --model= or --effort= resets only that field to Claude's own default. Success prints only the new conversation id followed by a newline:

cd "$HOME/projects/example"
chat_id=$(pyry conversation new --name "Planning" --model sonnet --effort low) &&
  pyry conversation post --id "$chat_id" --text "Review this project's README and suggest a plan."
channel_id=$(pyry conversation new --type channel)

pyry conversation post --id ID (--text TEXT | --file PATH) submits a user turn to an existing chat or channel, starting its bound session with the creation-time model/effort when idle. Success exits 0 silently once accepted into the ordinary inbound queue, without waiting for model completion; a later turn failure does not change that result. The CLI makes one submission attempt and does not automatically resubmit after a transport failure. Unknown ids never create a conversation. Existing pyry channel post --name publishes host-authored assistant content and creates a channel on a name miss.

Text is preserved without trimming; empty content and content above 64 KiB (65,536 UTF-8 bytes) are refused. --file reads are bounded to that cap plus one byte to detect overflow.

Instance/socket selectors precede new or post, for example pyry conversation -pyry-name=work new. Bad syntax exits 2; settings, workspace, cwd lookup, file/content or daemon/transport failures exit 1 with an error on stderr and no stdout.

For the full walkthrough — multi-instance, troubleshooting, hooks under service-mode PATH, boot persistence — see docs/guide.md and docs/deployment.md.

Documentation

Development

make check           # vet + race-enabled tests + staticcheck + substrate-guard + fake-daemon e2e suite
make build           # ./pyry
make install         # build HEAD as dev-<sha>, swap into ~/.local/bin/pyry, restart the daemon
make rollback        # put ~/.local/bin/pyry.prev back and restart
make linux           # cross-compile for Linux

CODING-STYLE.md covers Go conventions used in the repo.

License

MIT — see LICENSE.

Directories

Path Synopsis
cmd
pyry command
Command pyry is the Pyrycode daemon — a process supervisor for Claude Code.
Command pyry is the Pyrycode daemon — a process supervisor for Claude Code.
substrate-guard command
Command substrate-guard fails the build if any claude-TUI substrate literal appears in pyrycode .go source outside an explicit allowlist.
Command substrate-guard fails the build if any claude-TUI substrate literal appears in pyrycode .go source outside an explicit allowlist.
internal
acp
Package acp is the inbound transport floor for the Agent Client Protocol (ACP, Zed-stewarded): line-delimited JSON-RPC 2.0 over an io.Reader (inbound) and io.Writer (outbound), plus a method dispatch table.
Package acp is the inbound transport floor for the Agent Client Protocol (ACP, Zed-stewarded): line-delimited JSON-RPC 2.0 over an io.Reader (inbound) and io.Writer (outbound), plus a method dispatch table.
agentrun/jsonl
Package jsonl parses claude session JSONL output into structured events, surfacing every line (assistant, user, tool_use, tool_result, system, attachment, or unrecognised) with its verbatim bytes, alongside a deterministic end-of-turn signal on assistant entries.
Package jsonl parses claude session JSONL output into structured events, surfacing every line (assistant, user, tool_use, tool_result, system, attachment, or unrecognised) with its verbatim bytes, alongside a deterministic end-of-turn signal on assistant entries.
agentrun/selfcheck
Package selfcheck implements the verification that the per-agent tool-allowlist enforcement contract still refuses tools NOT in permissions.allow when claude is spawned headlessly on the stream-json surface with a per-spawn deny-default settings file.
Package selfcheck implements the verification that the per-agent tool-allowlist enforcement contract still refuses tools NOT in permissions.allow when claude is spawned headlessly on the stream-json surface with a per-spawn deny-default settings file.
agentrun/settings
Package settings writes per-spawn deny-default permission JSON files for interactive claude spawned via PTY drive.
Package settings writes per-spawn deny-default permission JSON files for interactive claude spawned via PTY drive.
agentrun/streamrunner
Package streamrunner spawns claude with the stream-json input/output formats as a plain subprocess (no PTY), writes one user-turn JSON envelope to its stdin, forwards stdout/stderr to caller-supplied writers, and waits for the child to exit.
Package streamrunner spawns claude with the stream-json input/output formats as a plain subprocess (no PTY), writes one user-turn JSON envelope to its stdin, forwards stdout/stderr to caller-supplied writers, and waits for the child to exit.
agentrun/trust
Package trust pre-answers, in ~/.claude.json, the startup gates a headless claude child cannot answer for itself: the workspace-trust gate, which interactive claude renders as a modal, and the approval that lets a CLAUDE.md `@` import resolving outside the session's working directory expand.
Package trust pre-answers, in ~/.claude.json, the startup gates a headless claude child cannot answer for itself: the workspace-trust gate, which interactive claude renders as a modal, and the approval that lets a CLAUDE.md `@` import resolving outside the session's working directory expand.
apps
Package apps validates host-app manifests and persists independent registrations.
Package apps validates host-app manifests and persists independent registrations.
attachments
Package attachments holds one inbound attachment upload's chunks in memory while its attachment_chunk frames arrive, refuses a stream whose framing contradicts what the transfer declared, and yields the assembled bytes only once they match the size and the digest the transfer declared.
Package attachments holds one inbound attachment upload's chunks in memory while its attachment_chunk frames arrive, refuses a stream whose framing contradicts what the transfer declared, and yields the assembled bytes only once they match the size and the digest the transfer declared.
audit
Package audit is the forensic sink for remote-permission decisions: it writes exactly one structured record per decision the modal control loop (#703) resolves — which device, which modal, what outcome, from where.
Package audit is the forensic sink for remote-permission decisions: it writes exactly one structured record per decision the modal control loop (#703) resolves — which device, which modal, what outcome, from where.
brokenpyry command
Package main is a deliberately-broken pyry stand-in for the TestUpdate_BrokenNewBinary_E2E test.
Package main is a deliberately-broken pyry stand-in for the TestUpdate_BrokenNewBinary_E2E test.
canonicalpath
Package canonicalpath resolves filesystem paths to absolute, symlink-free paths with on-disk component casing.
Package canonicalpath resolves filesystem paths to absolute, symlink-free paths with on-disk component casing.
codexsup
Package codexsup drives `codex app-server` (target: Codex 0.156.1) over its stdio JSON-RPC connection: it starts the process, performs the handshake, and starts, resumes and interrupts turns on one Codex thread.
Package codexsup drives `codex app-server` (target: Codex 0.156.1) over its stdio JSON-RPC connection: it starts the process, performs the handshake, and starts, resumes and interrupts turns on one Codex thread.
config
Package config loads the on-disk Pyrycode configuration file.
Package config loads the on-disk Pyrycode configuration file.
contextwindow
Package contextwindow reports the active claude session's context-window occupancy from its resolved transcript, so a consumer (the screen_snapshot handler, and any future push path) can surface a "context window used" gauge without each consumer re-parsing the JSONL.
Package contextwindow reports the active claude session's context-window occupancy from its resolved transcript, so a consumer (the screen_snapshot handler, and any future push path) can surface a "context window used" gauge without each consumer re-parsing the JSONL.
control
Package control implements pyry's local control plane: a Unix domain socket that lets clients (such as `pyry status`) query the running daemon.
Package control implements pyry's local control plane: a Unix domain socket that lets clients (such as `pyry status`) query the running daemon.
conversations
Package conversations defines the Phase 3 Conversation entity: a long-lived thread that owns a sequence of underlying claude sessions and carries presentation metadata (name, promoted/unpromoted state).
Package conversations defines the Phase 3 Conversation entity: a long-lived thread that owns a sequence of underlying claude sessions and carries presentation metadata (name, promoted/unpromoted state).
debugbundle
Package debugbundle assembles a session's debug evidence — the most-recent terminal recording (when session capture was on) plus the recent daemon log ring — into a single in-memory tar+gzip archive with a content-free manifest.
Package debugbundle assembles a session's debug evidence — the most-recent terminal recording (when session capture was on) plus the recent daemon log ring — into a single in-memory tar+gzip archive with a content-free manifest.
devices
Package devices defines the on-disk Device type and the token hashing/verification primitives used by `pyry pair` and the mobile auth path.
Package devices defines the on-disk Device type and the token hashing/verification primitives used by `pyry pair` and the mobile auth path.
dispatch
Package dispatch routes a single inbound relay frame through a handler table.
Package dispatch routes a single inbound relay frame through a handler table.
e2e/internal/claudetape
Package claudetape validates and replays the Claude side of a test daemon's stream-json pipes.
Package claudetape validates and replays the Claude side of a test daemon's stream-json pipes.
e2e/internal/fakeclaude command
Command fakeclaude is a test-only stand-in for the real `claude` CLI used by Pyrycode's e2e harness.
Command fakeclaude is a test-only stand-in for the real `claude` CLI used by Pyrycode's e2e harness.
e2e/internal/fakecodex command
Command fakecodex is a test-only stand-in for `codex app-server` at Codex 0.156.1, the version pyrycode targets.
Command fakecodex is a test-only stand-in for `codex app-server` at Codex 0.156.1, the version pyrycode targets.
e2e/internal/fakephone
Package fakephone is an in-process WebSocket client that speaks the phone half of the mobile↔relay protocol (docs/protocol-mobile.md § Authentication, § Message envelope).
Package fakephone is an in-process WebSocket client that speaks the phone half of the mobile↔relay protocol (docs/protocol-mobile.md § Authentication, § Message envelope).
e2e/internal/fakerelay
Package fakerelay is an in-process WebSocket server that speaks the routing half of the mobile↔relay protocol (docs/protocol-mobile.md § Authentication, § Routing envelope).
Package fakerelay is an in-process WebSocket server that speaks the routing half of the mobile↔relay protocol (docs/protocol-mobile.md § Authentication, § Routing envelope).
e2e/internal/paireddevice
Package paireddevice seeds a valid phone credential in an isolated test home before an e2e daemon starts.
Package paireddevice seeds a valid phone credential in an isolated test home before an e2e daemon starts.
e2e/internal/scenario
Package scenario contains test-only daemon assertions shared by live and recorded tests.
Package scenario contains test-only daemon assertions shared by live and recorded tests.
eventring
Package eventring is the in-memory, daemon-resident store of recent structured turn events that the mid-turn-reconnect replay path (#647) reads to catch a returning phone up without a gap.
Package eventring is the in-memory, daemon-resident store of recent structured turn events that the mid-turn-reconnect replay path (#647) reads to catch a returning phone up without a gap.
history
Package history is the durable, append-only, per-conversation message log the daemon writes as it fans envelopes out, and the backward reader that serves a connecting client the messages that happened before it arrived.
Package history is the durable, append-only, per-conversation message log the daemon writes as it fans envelopes out, and the backward reader that serves a connecting client the messages that happened before it arrived.
identity
Package identity owns typed identifiers that span subsystems — server-id today; potential future device-id, paired-device-id — and the bootstrap of those identifiers from disk.
Package identity owns typed identifiers that span subsystems — server-id today; potential future device-id, paired-device-id — and the bootstrap of those identifiers from disk.
install
Package install writes service-manager unit files (systemd, launchd) for pyry.
Package install writes service-manager unit files (systemd, launchd) for pyry.
keys
Package keys owns the binary's persistent X25519 static keypair used by Mobile Protocol v2 (Noise_IK).
Package keys owns the binary's persistent X25519 static keypair used by Mobile Protocol v2 (Noise_IK).
memorycapture
Package memorycapture persists immutable capture inputs and caller-reported attempt evidence and acknowledged processing receipts.
Package memorycapture persists immutable capture inputs and caller-reported attempt evidence and acknowledged processing receipts.
memoryruntime
Package memoryruntime installs an isolated, pinned memory CLI.
Package memoryruntime installs an isolated, pinned memory CLI.
memorysearch
Package memorysearch reports search access for one selected agent and workspace.
Package memorysearch reports search access for one selected agent and workspace.
modalbridge
Package modalbridge turns a detected tui-driver permission/trust modal into a typed, phone-facing protocol.ModalShownPayload and records it in an outstanding-modal registry keyed by a one-time modal_id nonce.
Package modalbridge turns a detected tui-driver permission/trust modal into a typed, phone-facing protocol.ModalShownPayload and records it in an outstanding-modal registry keyed by a one-time modal_id nonce.
modelfamily
Package modelfamily maps a Claude model id to the family alias a pyry session follows, and reduces claude's published model list to one row per family.
Package modelfamily maps a Claude model id to the family alias a pyry session follows, and reduces claude's published model list to one row per family.
msgqueue
Package msgqueue is the in-memory, daemon-resident inbound backlog for phone-originated send_message turns.
Package msgqueue is the in-memory, daemon-resident inbound backlog for phone-originated send_message turns.
noise
Package noise wraps github.com/flynn/noise to expose a narrow, opinionated surface for the Noise_IK_25519_ChaChaPoly_BLAKE2s cipher suite used by Mobile Protocol v2 (see docs/protocol-mobile.md § End-to-end encryption and docs/knowledge/decisions/024-noise-ik-mobile-e2e.md).
Package noise wraps github.com/flynn/noise to expose a narrow, opinionated surface for the Noise_IK_25519_ChaChaPoly_BLAKE2s cipher suite used by Mobile Protocol v2 (see docs/protocol-mobile.md § End-to-end encryption and docs/knowledge/decisions/024-noise-ik-mobile-e2e.md).
pair
Package pair encodes the {server, relay, token, server_static_pubkey} tuple a paired mobile device needs to connect through the relay back to this binary, and decodes strings produced by the same encoder.
Package pair encodes the {server, relay, token, server_static_pubkey} tuple a paired mobile device needs to connect through the relay back to this binary, and decodes strings produced by the same encoder.
permbridge
Package permbridge is an in-memory registry of pending tool-approval requests for the Streamrunner interactive permission bridge.
Package permbridge is an in-memory registry of pending tool-approval requests for the Streamrunner interactive permission bridge.
protocol
Package protocol declares the wire-format types for pyrycode's mobile WebSocket protocol v1.
Package protocol declares the wire-format types for pyrycode's mobile WebSocket protocol v1.
questionbridge
Package questionbridge parses clarifying-question tool calls into bounded outbound payloads and records surfaced batches under daemon-minted identities.
Package questionbridge parses clarifying-question tool calls into bounded outbound payloads and records surfaced batches under daemon-minted identities.
relay
Package relay drives the binary's outbound long-lived connection to the relay: opens the WSS via internal/transport and exposes inbound frames as protocol.RoutingEnvelope values via Frames().
Package relay drives the binary's outbound long-lived connection to the relay: opens the WSS via internal/transport and exposes inbound frames as protocol.RoutingEnvelope values via Frames().
sessions
Package sessions owns the set of supervised claude instances managed by one pyry process.
Package sessions owns the set of supervised claude instances managed by one pyry process.
streamsup
Package streamsup supervises a long-lived headless claude child in stream-json mode: it spawns claude with --input-format stream-json --output-format stream-json --verbose, holds the child's stdin open across many turns, restarts the child on crash with an exponential-backoff-with-stability-reset ladder, resumes with --resume <id> (reusing the same on-disk session id, no fork), and shuts down cleanly (SIGTERM → SIGKILL grace plus a reap of claude's detached descendant Bash process groups).
Package streamsup supervises a long-lived headless claude child in stream-json mode: it spawns claude with --input-format stream-json --output-format stream-json --verbose, holds the child's stdin open across many turns, restarts the child on crash with an exponential-backoff-with-stability-reset ladder, resumes with --resume <id> (reusing the same on-disk session id, no fork), and shuts down cleanly (SIGTERM → SIGKILL grace plus a reap of claude's detached descendant Bash process groups).
thread
Package thread folds raw history facts into conversation-owned thread items.
Package thread folds raw history facts into conversation-owned thread items.
transcript
Package transcript owns probe-preferred resolution of claude's session transcripts (<uuid>.jsonl under ~/.claude/projects/<encoded-cwd>/) and the canonical UUID-stem / .jsonl constants.
Package transcript owns probe-preferred resolution of claude's session transcripts (<uuid>.jsonl under ~/.claude/projects/<encoded-cwd>/) and the canonical UUID-stem / .jsonl constants.
transport
Package transport provides a long-lived WSS client with automatic reconnect, exponential backoff with jitter, and native ping/pong heartbeat.
Package transport provides a long-lived WSS client with automatic reconnect, exponential backoff with jitter, and native ping/pong heartbeat.
turnbridge
Package turnbridge adapts the neutral internal turn-event model (internal/turnevent, #606) OUT to the v2 interactive wire payloads (#607): MapEvent shapes one turnevent.Event into a typed payload, and BuildTurnState shapes the turn_state payload the lifecycle machine drives.
Package turnbridge adapts the neutral internal turn-event model (internal/turnevent, #606) OUT to the v2 interactive wire payloads (#607): MapEvent shapes one turnevent.Event into a typed payload, and BuildTurnState shapes the turn_state payload the lifecycle machine drives.
turncommit
Package turncommit carries a "commit gate" alongside a delivery context.
Package turncommit carries a "commit gate" alongside a delivery context.
turnevent
Package turnevent defines the daemon-owned, neutral model of outbound turn events, plus the inbound commands in permission.go.
Package turnevent defines the daemon-owned, neutral model of outbound turn events, plus the inbound commands in permission.go.
update
Package update implements pyrycode's self-update logic: release manifest parsing, version comparison, fetch, and replace.
Package update implements pyrycode's self-update logic: release manifest parsing, version comparison, fetch, and replace.
scripts
daemon-test-inventory command
Command daemon-test-inventory reads Go syntax without compiling or running tests.
Command daemon-test-inventory reads Go syntax without compiling or running tests.
templates
hosted-app
Package hostedtemplate bundles the maintained source-only app scaffold.
Package hostedtemplate bundles the maintained source-only app scaffold.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL