/kolu:kolufrom kolu
Spawns and drives a Claude Code / Codex / opencode session from another AI agent via kolu's PTY terminals. Uses MCP tools (lifecycle_create, agent_say, wait_outputSettled) or CLI fallback for agent-to-agent supervision loops.
Ships in kolu. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Run a coding agent inside a kolu-owned PTY and steer it from outside. Use the
kolu MCP tools first (mcp__kolu__*, wired in this repo's .mcp.json; other
hosts: claude mcp add kolu -- kolu mcp) — structured results, typed refusals,
no quoting hazards. Fall back to the kolu CLI's verbs (last section) when no
MCP is connected. Both faces are pure padi clients driving the same daemon, so
every discipline here applies to both.
lifecycle_create { placement: {kind: "toplevel"}, → { id }
intent: "🔧 parser refactor", cwd: "/abs/repo" }
agent_say { id, text: "refactor the parser to use a lexer" } # say it — kolu
# presses the keys
wait_outputSettled { id, idleMs: 800, screenTail: 40, # let its turn finish
timeoutMs: 600000 } # AND read the screen
screenTail is why there is no follow-up read: the screen comes back on the
met, read inside the wait. A separate screen_text is a second call the
terminal can move under — that gap is a race, not a formality.
lifecycle_create spawns a padi-tracked canvas tile. placement is
REQUIRED and has no default — {kind: "toplevel"} for a tile of its own, or
{kind: "child-of", parentId: <id>} to open it as a split INSIDE that
tile; a call that omits it is refused, naming both spellings. Decide it per
spawn: the canvas and the Dock read that edge as who-works-for-whom, so a
worker you supervise belongs under you rather than beside you by accident.
intent labels it, cwd sets the directory. repo + worktree cut a fresh git worktree at
<repo>/.worktrees/<name> and open the terminal IN it, and run types a
command line at the first shell prompt (submitted with Enter) — the whole
kolu create --toplevel --repo … --worktree … -- <agent> in ONE call. It spawns a
shell — to say something to the agent that comes up in it, wait for it to be
up (wait_agentState { until: ["fresh"] }), then use agent_say.lifecycle_sendInput writes text OR one named key, never both —
{ text, key } together is a typed hard error. Keys: Enter, Escape,
Tab, arrows, Home/End, Backspace, Space, Shift-Tab,
C-<char>/M-<char>. Unknown key names error loudly. Multiline text goes
as one bracketed paste.wait_outputSettled / wait_agentState return a uniform frame —
{ result: "met", met: {…} } or { result: "timeout" | "gone" | "closed" }.
Read result; never guess from silence.screen_text { tail: N } reads the last N content lines; omit tail for the
whole scrollback; screen_history pages older output.lifecycle_kill { id } — kill exactly the terminals you created.terminals resource (surface://collections/terminals) is the live
roster; each id's record carries intent, cwd, agent kind + state, parentId.
surface://cells/urgency lists terminals whose agent awaits a human.{ key: "Escape" } (stop Claude Code
mid-stream), { key: "C-c" } (SIGINT).agent_say { id, text } — the way to speak to an AGENT. It reads which
agent is there and whether it is working, types the text, waits a hard-capped
settle, and presses that agent's own submit keys — you never send an Enter
yourself, and you never need to know one agent's submit ritual from
another's. The answer says what happened: delivery is "submitted" (it was
idle, the words start a turn), "steer" (they join the turn that is running
at its next step — codex, omp, pi, xyne) or "queue" (they wait for the
current turn to end — claude-code, opencode, grok, antigravity); and took says whether it
landed — "began-working" (its transcript started a turn), "submit-landed"
(an agent that had written nothing yet: kolu saw the Enter reach it; its reply
comes later — do not say it again), or "did-not-begin" within a few
seconds, in which case read the screen rather than saying it again. A
steer to omp or pi answers "landed" (the running turn's transcript gained a
prompt carrying those exact words), "held" (in its steering pane until a
long tool call ends — it is delivered then on its own; never press Enter to
hurry it, which in omp kills the running tool), "did-not-land" (kolu read
both an empty-of-them pane and a transcript without them — read the screen),
"cannot-tell" (one of those two could not be read; what became of the words
is unknown, so read the screen and never resend blind) or "lost-sight" (the
terminal went away after the keys). It
REFUSES rather than guessing: a terminal with no agent (a plain shell), an
agent still starting (its screen is being drawn — wait for fresh), an
agent with no verified recipe, a terminal that is asleep, empty text.
lifecycle_sendInput is for shells, menus, dialogs and interrupts.agent_say is the verb for anything kolu detects as an agent. When the target
is a bare shell or a TUI kolu does not know you drive the submit yourself,
and it is three calls, never two:
lifecycle_sendInput{ id, text: "nix build" } # 1. the text (no Enter)
wait_outputSettled { id, idleMs: 300, timeoutMs: 15000 } # 2. observe the settle
lifecycle_sendInput{ id, key: "Enter" } # 3. submit (its own call)
An Enter sent in the same breath as the text races the TUI's bracketed-paste
handling and is silently dropped — the prompt sits staged on the ❯ line
while the send reports success (the #1 cause of "the turn never started";
screen_text will show it). The daemon can't observe the settle, so you do.
That whole ritual, plus the per-agent keys, is what agent_say performs for
you — which is why it is the verb for an agent and this is the fallback.
Multi-line pastes don't submit (#1702),
agent_sayincluded — it is the same paste: past a handful of lines, Claude Code folds the paste into a[Pasted text]placeholder that Enter does not reliably submit. For any message beyond a couple of lines, write it to a file and send a short pointer prompt instead (read /tmp/brief.md and carry it out).
On the manual path, step 2's idle fires only when the agent is at the prompt. Against a busy, mid-turn agent the wait times out — treat that
timeoutas "target busy": send the Enter anyway (it buffers and submits when the turn ends), thenscreen_textto confirm.result: "gone"is real — the terminal died; surface it.
wait_outputSettled { idleMs, timeoutMs } — raw output quiescence,
agent-agnostic. 800 is a good default. It can't tell "finished" from
"blocked asking you" — read the screen before responding.wait_agentState { until: […], timeoutMs } — padi's detected state:
working, awaiting (asking you), waiting (post-turn lull), and for an
agent not yet prompted at all, starting (its screen is still being drawn)
then fresh (up, nothing said to it — the moment to brief one you launched).
An agent is detected from its process the moment it starts, before it writes
anything, and it reads working from the instant a prompt is submitted to it,
before it has written a word of transcript. It matches the state the
instant it connects, so right after a
submit it can return on the previous turn's waiting — wait in two phases:
until: ["working"], then until: ["awaiting","waiting"].Both take two modifiers, and both exist because the thing they close is a race between calls that no caller can close from outside:
settledMs — a conjunct, not a second wait. The met needs the condition
to hold AND no output byte for that long; bytes still moving keep the wait
open, and a bucket that drops back to working re-enters it. This is the fix
for the failure that reads as a finished agent: a main loop that ends its turn
while an async subagent is three minutes into a deliberate plan is waiting
within milliseconds. 15000 is the field-calibrated value.screenTail: N — the met carries the last N screen lines, read inside the
same wait, so nothing can move between the signal and the read.The debrief call. wait_agentState { until: ["awaiting","waiting"], settledMs: 15000, screenTail: 40 } is "is this worker's turn really over, and
what did it say?" in one race-free call — the same protocol kolu debrief
spells on the CLI. Prefer it to the three-call version whenever you are driving
an agent rather than a bare shell.
Always pass timeoutMs, and keep it under your own harness's per-call cap
(most MCP hosts kill a tool call at ~1–2 min) — for a long turn, poll in
bounded slices, treating each timeout as "still busy".
Only result: "gone" means the terminal died. closed is a dropped
subscription over a live terminal — retry it; never report a worker dead off a
closed, and never bolt on a verify-with-screen_text rule to compensate.
The waits above are edge-triggered on a live call: they observe only while
open, so anything between two waits is unobservable. Driving several workers off
them means one wait per worker, kept armed by hand — and every gap is a hole a
report falls through. Do not hand-roll that layer (background watcher agents
looping waits and reporting back); it drops reports at four seams and it is what
watch_* exists to retire.
// once — omit `ids` to watch every terminal. The three state knobs are what
// make an ignored terminal come BACK instead of being reported once and lost.
// ignoreSelf keeps YOUR house out of the feed (the terminal this MCP server
// is running inside). ignoreIds mutes known terminals; a stale id costs nothing.
watch_open { name: "campaign", states: ["awaiting", "waiting"],
heldForMs: 60000, nagMs: 300000, ignoreSelf: true }
watch_next { name: "campaign", timeoutMs: 60000 } // first call
watch_next { name: "campaign", after: <ackAfter>, timeoutMs: … } // then ACK the last batch each time
watch_close { name: "campaign" } // when the campaign ends
watch_next are buffered in
padi, so the gap between calls is not a blind spot.ackAfter back as the next after.
Unacknowledged events are handed over again, so a reply you never received is
never lost — dedupe on each event's seq if you see one twice.watch_open the SAME
name after either to reattach; a new name starts empty. A padi restart
(upgrade) clears subscriptions — watch_next then FAILS naming the
subscription rather than reporting quiet, so re-watch_open and continue.states picks the buckets (default
awaiting+waiting), heldForMs waits for the state to hold (so an agent
handed more work inside the window is never reported), and nagMs re-reports
it every interval it keeps holding. It also hands over the currently-matching
set on every (re)open, so reattaching after a restart shows you what is
STANDING, not just what changed since.{ id, kind, at, parentId?, intent? }. kind depends on how you
opened it — one subscription is fed by one of the two, never both:
asking (blocked on input) · finished (turn ended AND
output settled) · gone (the terminal no longer exists — stop waiting on it).snapshot (already in that state when you opened) ·
transition (entered it and held for heldForMs) · nag (still in it,
nagMs later). These also carry state and since, so at - since is how
long it has been sitting there.heldForMs times the state and not the output.gone — it is a level, so a terminal that disappears
just stops being reported and nothing is left waiting on it. If you need to
hear about a terminal DYING, keep a second watch_open without the knobs, or
re-read the terminals resource. And re-opening a name with DIFFERENT knobs
starts its queue over (those events answer the question you stopped asking);
re-opening with the SAME knobs — the ordinary restart — keeps it.timeout and closed both lose nothing — the queue is still there next call.
Neither means a terminal died. A nonzero dropped means you were away long
enough to overflow the 512-event queue; re-read the terminals resource to
reconcile rather than trusting the delta.ids list: a kaval recycle retires
every active terminal id, so a frozen id list ages out where "all" does not.
Mute with ignoreIds / ignoreSelf instead of enumerating who to watch —
a mute fails open (new terminals are always watched; a stale id is inert),
an id watch-list fails closed.git.worktreeCreate is a named
denial) — kolu create --toplevel --repo /abs/repo --worktree my-branch -- claude --dangerously-skip-permissions, then drive the returned id over MCP.create returning ≠ ready: a first-run agent may sit on a one-time
dialog needing its own Enter. Drive every boot step by reading the screen.claude --dangerously-skip-permissions) and confirm from the footer via
screen_text before dispatching./exit) with agent_say
(or the three-step submit if nothing is detected in there), confirm the shell
prompt, relaunch.terminals resource and
comes back under the SAME id (parked while kaval is down, live again after the
restore). A padi or kolu-server restart keeps the shells too. So a cached id
does not go stale on a restart — but it can name a terminal that is parked
rather than running, so READ THE STATE before you drive it, and set intent
at create anyway: it is how a human (and you, later) tells the terminals apart.kolu CLIkolu is the ONE terminal CLI: the same verbs, spelled for a shell. Full
treatment (three-step submit in CLI form, --file, exit codes, endpoint flags,
worktree provisioning, the interim agent-spawn doctrine): TUI.md.
The verb map:
| MCP | CLI |
|---|---|
lifecycle_create (placement REQUIRED) | kolu create (--toplevel | --parent <id>) [--intent …] [--repo … --worktree …] -- <agent> |
agent_say { id, text } | kolu surface agent_say "$id" --text '…' — kolu presses that agent's own submit keys; the verb to speak to an agent on either face |
lifecycle_sendInput { text } | kolu send "$id" "text" (--file <path> for tricky payloads) — a shell, a menu, a TUI kolu does not know |
lifecycle_sendInput { key: "Enter" } | kolu send "$id" --key Enter |
wait_outputSettled | kolu wait "$id" --until idle:<ms> --timeout <ms> (also --until match:'<regex>') |
wait_agentState | kolu wait "$id" --until working · --until awaiting,waiting |
{ settledMs, screenTail } on either wait | --settled <ms> · --snapshot <N> on kolu wait |
wait_agentState { until: ["awaiting","waiting"], settledMs: 15000, screenTail: 40 } | kolu debrief "$id" — the same protocol either way, and what you should reach for when driving an agent: turn over AND output quiet, then the screen, in one call. |
screen_text { tail } | kolu snapshot "$id" [--tail N] (never bare snapshot | tail — that's the buffer bottom incl. trailing blanks; --tail drops them) |
screen_history | kolu history "$id" [--lines N] |
terminals resource | kolu ls [--json] · kolu watch [id] for the live feed |
lifecycle_kill | kolu kill "$id" |
Every verb takes the same endpoint flags — --socket <path> ·
--state-root <dir> · --host <ssh>, mutually exclusive, and accepted on
either side of the verb (kolu --host box create ≡ kolu create --host box). Inside a kolu terminal $PADI_SOCKET is already stamped, so you pass
none. Ids accept any unique prefix.
agent_say (never a hand-rolled Enter); at a plain
shell, submitted with a separate Enter after an observed settle.did-not-begin was followed by a screen read, not by
saying it again.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub juspay/kolu --plugin koluOther plugins' skills for the same job