peen

module
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT

README

peen

CI coverage version license Docker Pulls

Peen puts a coding agent in a real working directory and keeps the whole job alive after the first response. Connect a client over WebSocket, give it a task, and it can read code, edit files, run commands, use skills, launch child agents, and follow the rules sitting beside the project.

Every conversation, tool call, agent event, context snapshot, compaction, and provider exchange lands in SQLite. Model records keep the request and response, thinking, usage, retries, cost, model identity, and connection name, never the provider credential. Reconnect after a restart and the history is still there. Every connected client receives the live feed for every session, then renders the conversations it wants from each event's session ID.

One host runs one control plane. It owns SQLite, the API, and the event feed, and it starts a separate worker process per session to run that session's turns. Which environment a worker gets, a child process or its own container, is an operator decision. See Architecture.

Peen ships its own browser control surface at the controller's root URL. It is one client among many, so a terminal client, bot, or your own application can watch the same live work and use the same durable records.

Contents

Install

The normal install is the published Docker image:

docker pull psyb0t/peen:latest

The image starts Peen's control plane by default. You need Docker and a provider API key. The next section creates the configuration and starts it.

If you want a native binary instead, use the installer:

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

Read install.sh before piping it into a shell. Deployment covers native installs, source builds, and running Peen under a process manager.

Run it

Run Peen in Docker first. Pick a workspace you are happy to hand to an agent. Do not mount your whole home directory just because it is convenient.

You need Docker and a provider API key. Pick three host directories: one for trusted configuration, one for Peen's database and logs, and one workspace for the agent. Download the example configuration beside them:

root="$HOME/.local/share/peen"
config="$root/config"
state="$root/state"
workspace="$HOME/work/peen-workspace"
mkdir -p "$config" "$state" "$workspace"
curl -fsSLo "$root/.env" https://raw.githubusercontent.com/psyb0t/peen/main/.env.example
${EDITOR:-vi} "$root/.env"

The example has AIGate and Z.ai entries. Keep the provider you use, set its model ID, and put its key in the named environment variable. For an OpenAI-compatible AIGate setup, the important lines look like this:

PEEN_CONFIG_DIR=/absolute/path/to/peen/config
PEEN_STATE_DIR=/absolute/path/to/peen/state
PEEN_UPSTREAMS=[{"name":"aigate","type":"openai","baseUrl":"https://aigate.example/v1","apiKeyEnv":"AIGATE_TOKEN"}]
PEEN_DEFAULT_MODEL=aigate/your-model-id
PEEN_COMPACTION_MODEL=aigate/your-model-id
AIGATE_TOKEN=your-token-here
PEEN_API_TOKEN=

Set the provider URL, model IDs, and the named API-key environment variable in $root/.env. PEEN_CONFIG_DIR and PEEN_STATE_DIR are separate on purpose. Workers get the first one read-only and never get the second. Peen refuses to start if one sits inside the other.

The file is a Docker --env-file, so leave the JSON unquoted. For a server outside your own machine, set PEEN_API_TOKEN to a real secret before starting it.

Mount each directory at its literal host path. Literal paths matter when the controller starts Docker workers. Docker resolves worker mounts on the host, not inside the controller container.

docker run --rm \
  --user "$(id -u):$(id -g)" \
  --env-file "$root/.env" \
  -e PEEN_CONFIG_DIR="$config" \
  -e PEEN_STATE_DIR="$state" \
  -e PEEN_HOST_USERNAME="$(id -un)" \
  -e PEEN_HOST_HOME="$HOME" \
  -p 8080:8080 \
  -v "$config:$config" \
  -v "$state:$state" \
  -v "$workspace:$workspace" \
  -w "$workspace" \
  psyb0t/peen:latest

The control process and workers run as your UID and GID, so files the agent creates stay yours. PEEN_HOST_USERNAME and PEEN_HOST_HOME let a Docker worker recreate that account inside its own image. config holds the trusted harness layer and workers receive it read-only. state holds the database, audit logs, and worker sockets and workers never receive it. workspace is the process working directory and agent workspace. Peen starts with no sessions and opens one when a client names that directory. It resumes the same session when it restarts with the same state directory and workspace. All three mounts survive a container restart.

Use the control surface

Open http://localhost:8080 after Peen starts. If PEEN_API_TOKEN is set, enter it in the connection form. The browser keeps it in page memory only. It does not put the token in a URL or browser storage.

Open an allowlisted workspace with an absolute path. Peen returns its existing session when that directory was opened before, otherwise it creates the one durable session for that workspace. Select a model for one message only when you need to override the session default, then send the work.

The socket receives the live feed for every session. The control surface keeps that global feed intact, but shows the selected session's events and durable records in its own tab. It also exposes cancellation, execution-profile changes, transcript messages, model runs, child agents, compactions, workers, jobs, and notices.

The browser control surface is embedded in the Peen binary. There is no frontend service or browser token persistence to operate. Build another client against the WebSocket and REST API guide when you need a different interface or automation.

Provider configuration

Give every provider a short local name. Models are then addressed as provider/model, for example aigate/your-model-id or zai/glm-5.3. Peen asks each configured provider which models it actually offers at startup. A misspelled or unavailable model fails early instead of burning a turn.

Each upstream also declares a type, which is the wire protocol it speaks rather than the vendor behind it. An OpenAI-compatible gateway is type: "openai" whoever runs it. The supported types are openai, anthropic, and zai-coding. zai-coding keeps Z.ai thinking state through tool rounds. A message.send can override the model for that one task. Peen never guesses task difficulty or silently switches models behind your back.

The full list of provider, context, tool, and event settings is in Configuration.

Make it understand your project

PEEN_CONFIG_DIR holds an optional trusted base harness. PEEN_STATE_DIR holds durable controller state and is never mounted into a worker. The workspace adds project-specific instructions:

workspace/
  AGENTS.md
  .claude/
    rules/<rule-name>.md
    skills/<skill-name>/SKILL.md
  .agents/
    rules/<rule-name>.md
    skills/<skill-name>/SKILL.md
    agents/<agent-name>.md
    events/<event-type>.md
    hooks.yaml

Write ordinary project rules in AGENTS.md. Split topic-specific always-on rules into Markdown files in .claude/rules/ or .agents/rules/. Add a skill when the agent needs a named procedure. Peen puts every skill name and description in the turn context. For an ordinary request, the model decides whether the task matches a skill, then calls use_skill to load it. Put a standalone :skill-name at the start of a message or after whitespace to require that exact effective skill for the turn. Peen validates it before contacting a provider and injects its full SKILL.md into the root and child-agent prompts. Add a named agent when it should delegate a bounded job. Use hooks when the harness itself must gate, annotate, or react to an action.

Peen resolves layers from the filesystem root down to the active workspace, so a repository can put broad rules at the top and narrow rules beside one component. The configuration directory can add a trusted base layer.

Full layering, event, and hook details: Configuration and Hooks.

See what happened

The WebSocket is for live work. REST is for durable reads and control. It never starts a turn.

curl "http://localhost:8080/v1/messages?limit=50&order=asc" \
  -H "X-Session-ID: <session-id>"

curl -X POST "http://localhost:8080/v1/session/cancel" \
  -H "X-Session-ID: <session-id>"

REST also lists session state, durable protocol events, outside notices, process output, child-agent runs, compaction history, and every model request and response. REST addresses a known session through X-Session-ID, so a client keeps the UUIDs for the conversations it owns. The API reference has every request and response.

Drive it from the command line

The same binary is also a local control client. Each command talks to a running controller over the control API. None of them opens the database or starts a second supervisor: when nothing is listening they start peen run and wait for it to answer.

peen control status
peen session open /srv/work/project
peen session list
peen session attach <session-id>
peen session stop <session-id>

peen control status reports reachability without starting anything, so it tells "not running" apart from "running". peen session open prints the session ID, its workspace, and whether the call created the session or resumed one. peen session attach streams that session's live events and starts no turn. peen session stop cancels the session's active turn and says when there was nothing running. The commands read the same PEEN_ configuration the controller does, so a command and its controller cannot disagree about the endpoint.

A native deployment currently reaches the controller over the configured loopback HTTP endpoint. Unix-domain-socket discovery is not implemented: the vendored HTTP server creates TCP listeners only and exposes no way to supply one, so it needs an upstream capability first.

Things worth knowing

Set PEEN_API_TOKEN and use wss:// outside local development. Browser WebSockets authenticate with subprotocols because browsers cannot attach an Authorization header. The API reference has the exact handshake.

Peen writes structured logs to stdout and keeps daily audit files under PEEN_STATE_DIR/logs by default. The active workspace is a default, not a containment boundary. An absolute tool path can still point outside it. Long conversations either drop old request context or replace it with a stored summary. Configuration covers all of this.

Security

Read this before you deploy Peen anywhere it can reach something you do not want touched.

A session's tools run in a worker process under the execution profile the operator picked for that session. On the default native profile that worker is a child of the controller, so run_command and the file tools have exactly the access of the operating-system user running Peen. There is no path allowlist, no secret-file denylist, and no approval or permission step before a tool runs. A file tool can read, write, or remove any path that user can touch, including .git/, .env, and SSH keys. run_command executes an arbitrary shell command immediately. That is deliberate: the product is a coding agent with real access.

A docker profile is the isolation boundary. It runs the worker in its own container with only the mounts, network, and capabilities the operator defined. A client picks a profile by name and never sends an image, mount, network setting, or capability, so the blast radius is an operator decision. If the controller cannot reach a Docker socket, a session on a Docker profile is refused rather than run on the host. See Configuration.

A worker container receives the workspace, PEEN_CONFIG_DIR read-only, its own session socket directory, and only the runtime configuration it needs, including the named provider credential for its model calls. It does not receive PEEN_STATE_DIR, the control API token, or the controller Docker socket. The provider credential is therefore available to the agent process. Treat it like any other secret exposed inside an agent workspace. Peen runs the image published alongside the running build unless PEEN_WORKER_IMAGE or the profile names another. The container starts as root and the Peen entrypoint drops it back to your host account, so an image without that entrypoint fails when the worker runs.

Tool calls and their results are recorded verbatim in the session transcript and sent live over the global WebSocket feed, exactly like any other message. If the agent reads a file containing a secret, or a command prints one to stdout, that secret now exists in the SQLite transcript and in every connected client unless it requested a server-side session filter. Peen does not scan for or redact secret-shaped content in tool output. Treat the transcript and the event stream at the same sensitivity level as the files and commands the agent can reach.

remove_path has exactly one built-in restriction, and it is a guard against a catastrophic typo, not a permission system: it refuses to remove the filesystem root or the session's own workspace directory. Every other path, including everything named above, is removable.

Run Peen as a non-root user, in a container, with only the mounts, network access, and capabilities the deployment actually needs. The production image does exactly this by default; see below.

Docker deployment

The Docker command above is the normal way to run Peen. The image has a real shell and the tools a coding agent uses. The command runs it as your UID and GID so controller and worker changes keep host ownership. For production mounts, networking, and container hardening, read Deployment.

Agent integrations

The peen agent skill teaches an agent how to configure and run Peen, send work over WebSocket, add workspace harness layers, and inspect durable state. It is documentation only. Installing it does not start a server, run a hook, or change a workspace.

After the next Peen release and its matching psyb0t/agents marketplace entry:

claude plugin marketplace add psyb0t/agents
claude plugin install peen@psyb0t

codex plugin marketplace add psyb0t/agents
codex plugin add peen@psyb0t

openclaw skills install @psyb0t/peen

Documentation

You want to Read
Start from zero Getting started
Configure providers, limits, logs, and harness layers Configuration
Build a WebSocket or REST client API reference
Add hard checks or model instructions around actions Hook configuration
Run it outside a local Docker command Deployment

What Peen is built with

Directories

Path Synopsis
cmd
repogen command
internal
app
pkg/agent
Package agent owns Peen's transport-independent agent runtime.
Package agent owns Peen's transport-independent agent runtime.
pkg/auditlog
Package auditlog adds a durable JSON sink beside the process logger.
Package auditlog adds a durable JSON sink beside the process logger.
pkg/config
Package config loads Peen's deployment configuration from PEEN_ variables.
Package config loads Peen's deployment configuration from PEEN_ variables.
pkg/control
Package control owns the control surface's workspace policy and session registry.
Package control owns the control surface's workspace policy and session registry.
pkg/control/client
Package client is the local control client behind Peen's CLI commands.
Package client is the local control client behind Peen's CLI commands.
pkg/db
Package db opens Peen's SQLite database, applies its embedded migrations, and wires the generated gorm/gen repositories.
Package db opens Peen's SQLite database, applies its embedded migrations, and wires the generated gorm/gen repositories.
pkg/events
Package events carries typed notices about things that happened which the agent did not directly ask about: a process job ended, a child agent finished, or something outside Peen reported a change.
Package events carries typed notices about things that happened which the agent did not directly ask about: a process job ended, a child agent finished, or something outside Peen reported a change.
pkg/hooks
Package hooks runs validated layered hook actions at agent lifecycle points.
Package hooks runs validated layered hook actions at agent lifecycle points.
pkg/http/api
Package api provides primitives to interact with the openapi HTTP API.
Package api provides primitives to interact with the openapi HTTP API.
pkg/http/server
Package server exposes Peen's client-facing Serbewr HTTP API.
Package server exposes Peen's client-facing Serbewr HTTP API.
pkg/metrics
Package metrics owns Peen's application Prometheus registry and its bounded runtime collectors.
Package metrics owns Peen's application Prometheus registry and its bounded runtime collectors.
pkg/services/control-api
Package controlapi serves the control surface that control-core opened.
Package controlapi serves the control surface that control-core opened.
pkg/services/control-core
Package controlcore opens the control surface's durable state and runtime.
Package controlcore opens the control surface's durable state and runtime.
pkg/session
Package session owns Peen's durable transport-neutral session transcript.
Package session owns Peen's durable transport-neutral session transcript.
pkg/worker
Package worker is the boundary between Peen's control plane and the session-bound processes that actually run work.
Package worker is the boundary between Peen's control plane and the session-bound processes that actually run work.
pkg/worker/docker
Package docker launches a session worker as a psyb0t/peen sibling container.
Package docker launches a session worker as a psyb0t/peen sibling container.
pkg/worker/native
Package native launches a session worker as a child process of the controller.
Package native launches a session worker as a child process of the controller.
pkg/worker/protocol
Package protocol carries Peen's private, session-bound worker protocol.
Package protocol carries Peen's private, session-bound worker protocol.
pkg/worker/run
Package run is the body of the internal `peen worker` command.
Package run is the body of the internal `peen worker` command.
pkg/worker/supervisor
Package supervisor owns the lifecycle of one controller's session workers.
Package supervisor owns the lifecycle of one controller's session workers.
pkg/worker/workerlog
Package workerlog carries a worker process's log records into the controller's own logging stack.
Package workerlog carries a worker process's log records into the controller's own logging stack.
pkg
http/api/client
Package client provides primitives to interact with the openapi HTTP API.
Package client provides primitives to interact with the openapi HTTP API.
peen
Package peen is Peen's stable, supported programmatic entry point.
Package peen is Peen's stable, supported programmatic entry point.
tests
testinfra
Package testinfra is the extendable integration-test harness for a servicepack app.
Package testinfra is the extendable integration-test harness for a servicepack app.

Jump to

Keyboard shortcuts

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