Overview#
Jungle Monkey is a self-hosted orchestrator for coding agents. You describe a change. It runs Claude Code, OpenAI Codex or Cursor in a sealed container, on a server, on one of your own computers or locally through npx jungle-monkey, and hands the work back as a pull request with its CI result or, for a repository on your disk, as a branch. It has a single owner by default, is open source under the MIT license, and is steered from a mobile-first web app, a desktop canvas of live tasks, or Telegram.
The agent writes the code. The server holds every key and performs every side effect.
- coding agents: Claude Code, Codex, Cursor
- 3
- runner protocol shared by all of them
- 1
- credentials inside the agent container
- 0
- hosts: the server plus your own computers
- N
Beyond a single task#
- Queue, costs and budgets. Tasks wait for a free slot on their host. Every run records its tokens and cost, and monthly caps per project, per schedule or overall hold new runs at 100%, with a notice at 80%.
- CI auto-fix. A failing check on a Jungle Monkey PR starts a minimal fix from the trimmed CI logs, within a few attempts and a budget. A fix that touches CI config or tests waits for approval.
- Schedules and loops. Tasks can run on a cron timetable with their own budget, or loop until a check such as
npm testpasses. The PR arrives once, at the end. - Checkpoints. Every step that changes files can be saved. Restore any step, add a new instruction, and the agent continues from there.
- MCP integrations. The agent reaches MCP servers such as Linear, Sentry or a database through a gateway that holds the credentials, enforces tool lists and call limits, and logs every call.
- Skills and subagents. Playbooks live as
SKILL.mdfolders chosen per project. Claude tasks can hand work to an explorer and a test runner on a cheap model, and to a reviewer that checks the diff. - Teams. Optional: invite links, admin, member and viewer roles, each person's own encrypted agent keys, costs and budgets per person, and an audit log.
- Ideas board. A kanban where voice notes, links and screenshots become cards, and a card can start a task and follow it to a merged PR.
Architecture#
A Go server is the control plane. It holds the API, the scheduler, Postgres, the GitHub App and every credential. The work runs in runner containers, one per task, on a host. A host is the server itself or a node: a computer the owner has paired with the server. The web client only sends tasks and answers, and watches progress.
server/is the Go service with the REST and WebSocket API, the scheduler, the publisher, the Telegram bot, the MCP gateway, maintenance jobs, and the Docker and GitHub integrations.agent/is the TypeScript runner that lives inside each task container and drives Claude Code, Codex or Cursor through their SDKs.- The node is a small Go binary that turns a Mac or Linux machine into an extra host.
web/is a React PWA and Telegram Mini App: a task board, live timelines and a desktop canvas with one live node per task, grouped by host.npm/packages local mode: one binary with the server, an embedded Postgres and the web app, started withnpx jungle-monkey.deploy/holds the installer, Docker Compose for production and development, cloud-init for Hetzner or DigitalOcean, and Caddy for automatic TLS.
One protocol, three agents#
The server and the runner talk in JSON Lines over the container's stdin and stdout, with no open ports. The server writes one run command and may then send answer, interrupt or cancel. The runner answers with typed events, and every agent is mapped onto the same events. Because of that, the scheduler, storage and UI don't need to know which agent did the work.
{"type":"run","task_id":42,"agent":"codex","prompt":"Add CSV export","limits":{"max_turns":150,"max_budget_usd":5,"max_duration_sec":7200}}
{"type":"started","seq":1,"session_id":"…","model":"default"}
{"type":"tool_use","seq":2,"tool":"Edit","summary":"Edit src/tables/export.ts"}
{"type":"usage","seq":3,"input_tokens":18400,"output_tokens":2100,"turns":4}
{"type":"committed","seq":4,"sha":"…","files_changed":3}
{"type":"done","seq":5,"summary":"…","no_changes":false}- Claude Code runs on the Claude Agent SDK. Its questions become
questionevents with answer buttons. Turns, budget and duration limits are enforced, and a tool policy blocks environment dumps. - OpenAI Codex runs on the Codex SDK, with the system prompt passed as developer instructions. It makes its own choices and lists open questions in its summary.
- Cursor runs on the Cursor SDK as a local agent, with
autoas the default model. Its API key is removed from the environment that its commands see.
The agent is chosen per project or per task, and DEFAULT_AGENT covers projects that don't pick one. Codex and Cursor run with their own sandboxes and approval prompts turned off, because the container is the sandbox.
Scheduling#
- queued
- preparing
- running
- waiting_input
- pr_open
- completed
- paused
- cancelled
- failed
A queued run is just a runs row that hasn't started. Create, resume, follow-up and retry all insert one, so the scheduler has a single path. Each host has its own concurrency limit (two tasks by default). Every run gets limits on turns, budget and duration. A run that hits a limit still commits its work in progress and opens or updates the PR, so a follow-up can pick it up. Messages sent during a run are queued and drained into the next run in the same transaction that ends the current one.
Remote nodes#
A task can run on the owner's own computer instead of the server, while login, history, GitHub and the task list stay on the server. The node only connects outwards, over a WebSocket, so it needs no open ports. It pairs like a TV sign-in, with a short code approved in the app. Agent keys stay in the Mac's Keychain, and the server sends a short-lived, single-repository GitHub token for each git command. If a node goes offline, its queued tasks wait, running containers keep going, and the event stream resumes from the last seq when the node reconnects.
Credentials and isolation#
- Context
- A coding agent runs arbitrary commands from a model's output. If it held a GitHub token or the Docker socket, one bad step could push to any repository or escape to the host.
- Choice
- The runner commits but never pushes. The server scans the diff with gitleaks, pushes the branch and opens the PR as the GitHub App. The scan fails closed: if the scanner is missing or errors, nothing is pushed.
- Trade-off
- Every side effect has to go through the server, so a new kind of action means new server code, not just a new prompt.
- Each task gets its own Docker network, with optional Postgres and Redis sidecars. Containers run as an unprivileged user, with all capabilities dropped and
no-new-privilegesset. - A project's network can be locked to an allowlist. The container's only way out is then an egress proxy that passes the listed hosts, and a blocked host shows up in the app with a one-tap "Allow".
- MCP credentials stay in the gateway, encrypted at rest. The agent only sees the tools the project allows.
- The server reaches Docker only through a socket proxy on a network with no egress.
- Before pushing, the server checks the diff: no changes to
.github/, size limits and a secrets scan. - GitHub installation tokens are minted for exactly one repository and passed to git for a single command. They are never written to disk.
- Before opening a PR, the publisher checks for an existing one, so a crash between the push and PR creation never leaves a duplicate.
- On a server, the owner signs in with a bcrypt-hashed password plus TOTP. Sign-in is rate-limited, and the session cookie is HMAC-signed. Locally, the CLI opens a one-time login link on
127.0.0.1.
Restart safety#
The runner also writes every event to events.jsonl in the workspace, with a sequence number that continues across runs. On startup the scheduler reattaches to live containers first and then replays the file. Duplicates are dropped by UNIQUE (run_id, seq). The scheduler also applies exits it missed, re-queues interrupted work and removes orphaned containers. Containers are cleaned up before a terminal status is written, so no finished task is left with live containers.
Three ways to install#
Local mode is npx jungle-monkey: one binary with the server, an embedded Postgres and the web app, running tasks in the computer's own Docker. It needs no domain, VPS, GitHub App or .env, keeps agent keys in the OS keychain, and works on folders on disk. GitHub is optional and only needed to push and open PRs.
- Context
- In local mode the repository is the user's working copy, with uncommitted changes and a checked-out branch they rely on.
- Choice
- The agent works in a local clone inside the data directory. Its commits come back as a separate jm/<task>-<slug> branch, and the user's branch, index and working tree are never touched. Merge, check out, discard or push as a PR are explicit actions, and merge is refused while there are uncommitted changes.
- Trade-off
- A clone per task costs disk and time, and the user has one more step to bring the work in. In return, an agent can never damage work in progress.
The server install runs 24/7 and adds phone and Telegram access, pull requests and CI. It needs a small Linux server, a domain, a key for at least one agent, and the owner's own GitHub App. One installer command sets up Docker if needed, asks for the domain, the agents and their keys, writes the config, starts the stack and prints a setup link; running it again updates the server. Everything runs as one Docker Compose stack with Caddy, which issues the TLS certificate automatically. Images are published to GHCR for amd64 and arm64, a GitHub Actions release builds only the images that changed and deploys them, and /metrics answers only private addresses. A fully manual self-hosted setup is the third path, and a fake agent lets the whole stack run locally without any agent account.
Stack#
- Server: Go, pgx and goose on Postgres 17 (embedded Postgres in local mode), the moby Docker client, go-github with ghinstallation, the MCP Go SDK, telego for Telegram, go-keyring, gitleaks and Prometheus.
- Runner: TypeScript on Node 24, with the Claude Agent SDK, Codex SDK, Cursor SDK and zod, running on a Playwright base image.
- Web: React 19, Vite, Tailwind CSS 4, shadcn/ui and TanStack Query, tested with MSW, Vitest and Playwright.
- Infra: Docker Compose, Caddy, cloud-init, GitHub Actions, GHCR and an npm package for local mode.
Discussion
Loading comments…

