Dispatch

The cross-machine work bus — a GitHub issue is a task, and any coding agent on any machine can claim and run it

Dispatch

One bus for every coding agent on every machine. A task is an issue in the repo where the work happens (databayt/kun when no work repo is named). A small runner on each machine claims the issues addressed to it, runs the agent headless and posts the result on the issue. GitHub is the queue; there is no server.

Not to be confused with Anthropic's Dispatch app, which sends a task from the phone to Claude Desktop (see Cowork).

Send a task

kun-dispatch "Reply with PONG" --to claude --machine abdout
kun-dispatch "Refactor the table atom" --to codex --repo codebase --lane build --timeout 45
kun-dispatch "Fix the billing test" --in databayt/hogwarts --repo hogwarts
kun-dispatch "Follow up twenty:company:3f2b8c1e-9d4a-4b6e-8a1f-5c7d2e9b0a14" --private

kun-dispatch is ~/.claude/bin/kun-dispatch. It ensures the labels exist in the target repo and prints the issue URL.

FlagWhere the issue is filed
--privateThe private repo (engine.json dispatch.private_repo). Adds data:private and forces --to claude. Refused when the key is empty
--in databayt/<repo>That repo. Must be a databayt repo
--repo <name>When <name> is a known databayt repo (the repo registry), that repo, and the run happens in its folder
anything elsedatabayt/kun. A local folder name or an absolute path in --repo still says where the run happens; it does not choose the issue's home

Before anything is created in a repo other than the private one, the brief goes through the public guard. A phone number, a private email, a key, a quoted chat or commission terms refuse the send: nothing is created, not even a label. Name a client by CRM record id only (twenty:company:<uuid>). Hermes does the same when you ask for real work in chat (Chat).

The protocol

A task is an issue with these labels.

LabelMeaning
dispatchMarks a bus task (required)
to:<agent>claude, codex, opencode, agy, hermes, fcc, a web seat (web, chatgpt, deepseek, glm, gemini) or any (never a web seat)
machine:<login>Only this machine's GitHub login may run it. Absent means any machine
data:privatePrivate data: runs only on claude. In a work repo its output is never posted (see below)
rate:<n>Points weight of a video work order, for the ledger
lane:<name>Optional (build, research, mechanical, ...): picks the model
claimed:<host>A runner took it
done / failedFinal state

The body is the brief in Markdown plus an optional fenced yaml block:

Fix the failing test in the billing block and push to main.
 
```yaml
repo: hogwarts        # a folder under ~, ~/oss or ~/Documents, or an absolute path
cwd: /abs/path        # used when repo is absent; default is the kun checkout
timeout_min: 30
model: sonnet
```

States. open, then claimed:<host>, then done (issue closed) or failed (issue stays open). The result is one comment: status, agent, host, the last 3,500 characters of output and the ledger run id (the output rules are below). A timeout, a missing repo or a refused model is a failed with the reason.

Claiming. Runners race safely without a lock service: a runner adds claimed:<host> and assigns itself, then reads the issue's label events. The earliest claimed:* event wins; the loser removes its own label. Each machine runs at most one task per agent at a time (a lock file in ~/.kun/dispatch/).

Which repos a machine reads

A runner reads databayt/kun, then the repos in this machine's profile, then the private repo. Never the whole org. The profile is machines/<login>.json in the kun checkout, where login is the one the Kun app saved in ~/.kun/machine/settings.json, or, on a machine with none there, its GitHub login. With no profile for either, the list is databayt/kun and the private repo.

Who may start a run

Anyone can open an issue in a public repo, so the runner checks the author first. It asks GitHub for the author's permission on that repo (repos/<repo>/collaborators/<login>/permission). Only admin, maintain or write may start a run. The answer is cached for the pass. An error, or an issue with no readable author, counts as no.

For an author without write access the runner adds failed, posts one comment ("Skipped: the author of this issue has no write access to this repository, so no machine will run it. A maintainer can file it again.") and moves on. The issue is never claimed. The same check guards a long loop when it starts or resumes.

Private data

Where the issue isWhat a run may post
The private repoThe output, as above
Any other repo, labelled data:privateStatus, agent, host and seconds only, plus "Output withheld: this run read private data. It is in the local journal on <host>." The output goes to ~/.kun/dispatch/task-<n>.log
Any other repoThe output after the public guard reads it. If the guard objects, the comment carries the same withheld line with the guard's reason

A data:private task runs only on claude; any other agent is refused with a failed comment, and to:any never picks another one for it.

Billing. Subscription only. A task whose model or lane is fable, mythos or escalate is refused with a failed comment. With no model, the lane's model from engine.json is used (default lane build).

What runs

AgentHeadless command
claudekun-claude.sh -p <brief> --dangerously-skip-permissions --model <lane model>
fcckun-free.sh -p <brief> (Claude Code on the Pool)
codexcodex exec --dangerously-bypass-approvals-and-sandbox -C <cwd> <brief>
opencodeopencode run --dir <cwd> <brief>
agyagy -p <brief> --dangerously-skip-permissions
hermeshermes -z <brief>
webweb.mjs ask auto <brief>: the first free web seat, text only
chatgpt deepseek glm geminiweb.mjs ask <seat> <brief>: that one seat

A runner offers only the agents installed on its machine (launchers.json plus which); the web seats are offered wherever the kun checkout has scripts/web/web.mjs and the vault Chrome is up. A web task's comment is the answer; exit 75 (every seat capped, signed out or limited) is a failed with the reason, and the issue stays open so another agent can take it. Own data only: a web seat never gets client data or secrets.

Run the runner

I=.claude/scripts/dispatch/install.mjs
node $I install               # write the unit file only; does not load it (same as kun-dispatch install)
node $I install --load        # write it and switch it on
node $I uninstall             # switch it off and remove it
node $I install --dry-run     # print what would happen, run nothing (also on uninstall)
node $I status --json         # is it installed, is it loaded
kun-dispatch run              # one runner pass, by hand
kun-dispatch heartbeat        # write this machine's status

status --json prints one line: {"os":"mac","supported":true,"installed":true,"loaded":true,"label":"com.databayt.dispatch-runner","interval":120}. installed means the unit file or the scheduled task exists. loaded means the system will actually run it: launchd has the job on macOS, the systemd timer is enabled on Linux, the task exists on Windows.

The runner starts every 120 seconds and logs to ~/.kun/dispatch/runner.log.

Systeminstall --loaduninstall
macOSwrites ~/Library/LaunchAgents/com.databayt.dispatch-runner.plist, then launchctl bootout and launchctl bootstrap gui/<uid>launchctl bootout, removes the plist
Linuxwrites kun-dispatch.service and .timer under ~/.config/systemd/user, then systemctl --user daemon-reload and enable --nowdisable --now, removes both files
Windowswrites ~/.kun/dispatch/runner.cmd (it sets KUN_DIR and runs the runner), then schtasks /Create for the per-user task Kun dispatch runnerschtasks /Delete /F, removes the .cmd

On Windows the task runs every 2 minutes, stores no password and runs only while you are logged on. Creating the task is what switches it on.

Switching it on lets this computer take labelled tasks from GitHub and run them unattended, with permissions bypassed. The Kun app's Settings switch, "take tasks while the screen is dark", calls these same verbs. It is off by default. Run uninstall to switch it off.

heartbeat writes .claude/state/machines/<login>.json: agents and versions, the last pass and the queue depth. The Memory sync lane picks it up.

Code: .claude/scripts/dispatch/ (send, runner, install, heartbeat, lib, tests) and .claude/bin/kun-dispatch.

Long jobs

A task that needs hours, not minutes, is long mode: the same bus, a long label, and a loop that runs the goal one step at a time with every step on the issue.