Metadata-Version: 2.5
Name: hatchway
Version: 0.0.2
Summary: A narrow, logged opening through which an outside agent reaches your tools: an SSH forced command that runs only an allowlist kept as data
Project-URL: Homepage, https://github.com/thorwhalen/hatchway
Project-URL: Repository, https://github.com/thorwhalen/hatchway
Project-URL: Issues, https://github.com/thorwhalen/hatchway/issues
Author: Thor Whalen
License-Expression: MIT
License-File: LICENSE
Keywords: agents,allowlist,claude-code,forced-command,gateway,mcp,ssh
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security
Classifier: Topic :: Utilities
Requires-Python: >=3.11
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.1.0; extra == 'dev'
Description-Content-Type: text/markdown

# hatchway

A narrow, logged opening through which an outside agent reaches your tools.

```bash
pip install hatchway
hatchway authorize "ssh-ed25519 AAAA... my-agent" --agent assistant   # one confined key
hatchway check "crowsnest triage"                                     # what the gate would do
```

An agent that lives somewhere else (a personal assistant on its own cloud VM, another machine's scheduler, a phone shortcut) gets one SSH key. That key can do exactly one thing: run `hatchway gate`, which reads the requested command line, checks it against a **profile** (an allowlist kept as a TOML file), logs the call, and runs the allowed command directly, never through a shell. Anything not in the profile is refused with a reason.

It is the "reach in" half of connecting an outside agent to the tools on your machine, with no new server, no open port and no new dependency: OpenSSH already has forced commands, and hatchway is the policy and the bookkeeping around one.

## What you get

- **An allowlist as data.** A rule names the words the agent sends, the command that actually runs (with fixed arguments the agent cannot remove, such as `--no-verify`), and exactly which flags and names it may add. Names are checked against a pattern and passed after `--`, so they can never be read as options. Shell characters are refused outright.
- **A confined key.** `hatchway authorize` writes one `authorized_keys` line with `command="hatchway gate --agent NAME"`, `restrict` (no shell, no port, agent or X11 forwarding, no pty), and by default `from="100.64.0.0/10,fd7a:115c:a1e0::/48"`, so the key works only from a Tailscale tailnet even if sshd is reachable elsewhere. It keeps every other line, backs the file up first, and is idempotent. `hatchway revoke --agent NAME` takes it out.
- **A log of every call** in `~/.local/share/hatchway/calls.jsonl`: when, which agent, from where, what was asked, allowed or refused, exit status. Never the output. `hatchway log` shows the tail.
- **Gated classes.** A rule can belong to a class that stays off until a flag file exists. The bundled profile's `dispatch` class (starting a Claude Code session) needs both `~/.config/hatchway/allow-dispatch` and a list of directories it may start sessions in.
- **A snapshot for pulling instead of waiting.** `hatchway snapshot` runs the profile's snapshot requests (through the same allowlist) and writes the answers atomically to `~/.local/share/hatchway/out/`, with an `index.json`. The agent reads them through the gate (`snapshot triage.md`) without waiting for anything to run. `hatchway schedule --every 300` keeps them fresh with launchd (macOS) or a systemd user timer (Linux).
- **Skills for the agents that set it up.** `hatchway install-skills` links the bundled skills into one or more Claude Code homes.

## The bundled profile: `claude-fleet`

For a machine running Claude Code sessions watched by [crowsnest](https://github.com/thorwhalen/crowsnest) (live sessions) and [openloops](https://github.com/thorwhalen/openloops) (what sessions left owed or blocked). `hatchway help` prints it, and it is what the agent gets when it sends `help`:

| Request | Runs |
|---|---|
| `crowsnest [--brief\|--json]` | the roster across every configured Claude home |
| `crowsnest triage [-q] [--json]` | what needs you, what is safe to close, what is working |
| `crowsnest show\|turns\|recap\|brief NAME` | one session (show and turns quote its transcript) |
| `crowsnest ledger [NAME...]`, `groups`, `synopsis GROUP`, `questions`, `lineage`, `report` | the rest of crowsnest's read side |
| `ol`, `ol owed`, `ol blocked`, `ol dashboard` | openloops, always with `--no-verify` (verify predicates are commands taken from issue bodies, and a remote request never runs them) |
| `snapshot [FILE]` | list or print the snapshot files |
| `crowsnest spawn NAME --cwd DIR --prompt TEXT` | **gated**: starts a session on `sonnet`, in a directory under the dispatch roots |

Nothing in it kills, reaps, messages or writes into a running session.

To change it for one machine, copy `hatchway/data/profiles/claude-fleet.toml` to `~/.config/hatchway/profiles/<name>.toml`, edit it, and set `profile = "<name>"` in `~/.config/hatchway/config.toml` (or pass `--profile <name>` to `authorize`, which puts it in that key's forced command).

## Configuration

`~/.config/hatchway/config.toml`, every key optional:

```toml
profile = "claude-fleet"
path = ["~/.local/bin"]           # where the commands live (sshd's PATH is minimal)
timeout = 120
[roots]                           # extra directories file rules may serve, by name
[dispatch]
roots = ["~/projects"]            # where a gated spawn may start a session
[snapshot]
to = ""                           # optional private copy: a local dir or host:path
```

## The security model, in one paragraph

What the key can do is the profile, so read it before you authorise a key. Read commands still send what they read to wherever the agent runs: `crowsnest show` quotes your sessions' transcripts, so authorise only an agent you would show them to. Keep the `from=` restriction. If the agent joins your Tailscale tailnet, give it a policy that allows **only TCP port 22** to the machines it serves and **no Tailscale SSH rule**: Tailscale SSH authenticates by tailnet identity and never reads `authorized_keys`, so it would bypass the gate entirely. `100.64.0.0/10` is also ordinary carrier-grade NAT space, so once you know the agent's own tailnet address, narrow `--from` to it (`--from 100.x.y.z/32`). Leave dispatch off until you have watched the log for a while: a session it starts runs code as you. The bundled rule pins `--model sonnet` and `--permission-mode default` (the session asks before acting), refuses a prompt that starts with `-`, and starts sessions only under the directories you list.

Also built in: the commands run with an allowlisted environment (nothing the connecting client can set reaches them beyond `LANG`), in their own process group so a timeout stops their children too, one call at a time per agent (a concurrent call is refused with exit 75), and every allowed call is logged before it runs, so a dropped connection still leaves its line.

## Agents

- `hatchway` skill: install and verify a connection for an outside agent on this machine (the steps, the checks, the Tailscale policy).
- `hatchway-muse` skill: when a task would be better handed to a personal Muse agent (Meta), which integration pattern fits, and the exact prompt to give it.
