Skip to content
Closed
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e7dbab2
feat(harness): add verified agy worker adapter with gemini-3.7-flash-…
brybrydataguy Aug 24, 2026
8592829
no-mistakes(review): Complete agy worker lifecycle integration
brybrydataguy Aug 24, 2026
cf32435
no-mistakes(review): Harden agy lifecycle plugin installation
brybrydataguy Aug 24, 2026
f21ea70
no-mistakes(review): Harden agy lifecycle and plugin cleanup
brybrydataguy Aug 24, 2026
3664236
no-mistakes(review): Harden agy ownership and abort recovery
brybrydataguy Aug 24, 2026
d110493
no-mistakes(review): Preflight agy worktrees before teardown
brybrydataguy Aug 24, 2026
4c36ea4
no-mistakes(review): Observe agy completion and harden teardown quies…
brybrydataguy Aug 24, 2026
dbd3aad
no-mistakes(review): Harden agy lifecycle and teardown confirmation
brybrydataguy Aug 24, 2026
910ca22
no-mistakes(review): Harden agy interrupts and teardown quiescence
brybrydataguy Aug 24, 2026
078b2ed
no-mistakes(review): Track agy process scopes across relaunch and tea…
brybrydataguy Aug 24, 2026
89c173a
no-mistakes(review): Anchor worker scopes across agy transitions
brybrydataguy Aug 24, 2026
9c1797b
no-mistakes(review): Harden scoped worker lifecycle containment
brybrydataguy Aug 24, 2026
9936fbd
no-mistakes(review): Preserve macOS workers with scoped agy transitio…
brybrydataguy Aug 24, 2026
5e4cf39
no-mistakes(review): Enforce worker-only boundaries for raw harness c…
brybrydataguy Aug 24, 2026
95cb5b6
no-mistakes(review): Align raw Muse identity with verified command sh…
brybrydataguy Aug 24, 2026
b92415b
no-mistakes(review): Require explicit identities for raw secondmate l…
brybrydataguy Aug 24, 2026
2837669
no-mistakes(document): Document agy adapter lifecycle limits
brybrydataguy Aug 24, 2026
d0d0d29
no-mistakes(review): Preserve agy workers across launches and teardow…
brybrydataguy Aug 25, 2026
0dcd74d
no-mistakes(review): Recover stale agy teardown locks before worker q…
brybrydataguy Aug 25, 2026
1a1a97d
no-mistakes(review): Recover stale locks around verified live agy scopes
brybrydataguy Aug 25, 2026
d887c7e
no-mistakes(review): Bind agy lock recovery to verified endpoints
brybrydataguy Aug 25, 2026
35d3ae4
no-mistakes(review): Preserve endpoint identity across empty process …
brybrydataguy Aug 25, 2026
46a36bf
no-mistakes(document): Align agy adapter documentation
brybrydataguy Aug 25, 2026
ae8b41a
no-mistakes(document): Consolidate agy documentation ownership
brybrydataguy Aug 25, 2026
e94527d
no-mistakes(document): Correct Antigravity verification evidence
brybrydataguy Aug 25, 2026
f991770
no-mistakes: apply CI fixes
brybrydataguy Aug 25, 2026
f2cb3e6
no-mistakes: apply CI fixes
brybrydataguy Aug 25, 2026
5157c00
no-mistakes: apply CI fixes
brybrydataguy Aug 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions .agents/skills/harness-adapters/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: harness-adapters
description: >-
Agent-only reference for firstmate harness operations.
Use before spawning or recovering a crewmate or secondmate, handling a trust dialog, sending a harness-specific skill invocation, interrupting or exiting an agent, resuming an exited agent, or verifying a new harness adapter.
Contains verified facts for claude, codex, opencode, pi, pi-signed, grok, kimi, cursor, and muse.
Contains verified facts for claude, codex, opencode, pi, pi-signed, grok, kimi, cursor, muse, and agy.
user-invocable: false
metadata:
internal: true
Expand Down Expand Up @@ -65,7 +65,8 @@ The primary integrations for `claude`, `codex`, `opencode`, `pi`, `pi-signed`, `
Grok selects native blocking or its pre-native bounded resume fallback from the exact running Stop payload; [`docs/turnend-guard.md`](../../../docs/turnend-guard.md) owns that contract.
Kimi is outside the primary turn-end guard scope, while `docs/turnend-guard.md` owns its separate guarded global hook for crew wake signals.
muse is CREWMATE/SCOUT ONLY and has no primary integration at all: its plugin engine (its only hook surface) is disabled in the default build, and its Claude-compatible hook dialect names `asyncRewake` and model reawakening as explicitly unsupported, which is exactly what a firstmate primary's turn-end supervision needs.
`bin/fm-spawn.sh` refuses a `--secondmate` launch on muse for that reason.
agy is also CREWMATE/SCOUT ONLY because no primary session-start, turn-end, or watcher supervision protocol has been verified for it.
`bin/fm-spawn.sh` refuses a `--secondmate` launch on either adapter for that reason.
cursor HAS a full hooks system: 20 lifecycle events configurable at project scope in `.cursor/hooks.json`, plus a Claude-Code compatibility name map that also loads `<project>/.claude/settings.json`.
Its `stop` step cannot block - exit 2 there is a silent no-op - so `bin/fm-turnend-guard-cursor.sh` parks the turn boundary on the watcher and returns one bounded `followup_message` instead.
Because Cursor loads the tracked Claude settings too, every Claude-shaped entrypoint whose event Cursor covers stands down on a Cursor-delivered payload.
Expand Down Expand Up @@ -133,6 +134,7 @@ The supported launch-profile flags below are verified locally; each row records
| kimi | `--model <model>` | none | Verified 2026-07-25 on Kimi Code CLI 0.29.1. |
| cursor | `--model <model>` | none | Verified 2026-08-11 on Cursor Agent CLI 2026.08.11-e8db854. No effort flag exists, so firstmate records the requested effort in task metadata and omits it from the launch. Validate ids against `cursor-agent --list-models` rather than assuming a low/medium/high family: the live catalog carries only `-high` Grok ids. |
| muse | `--model <model>` | `--reasoning-effort <low\|medium\|high\|xhigh>`, and `ultra` only for an explicit `max` | Verified 2026-08-05 on Muse Code 0.1.0-R708.1. The flag accepts `none\|minimal\|low\|medium\|high\|xhigh\|ultra` and defaults to `high`. `ultra` is muse's max-class level, so it is reachable only through an explicit captain `max`, never from the generic fallback; `none` and `minimal` sit below the shared vocabulary and stay unreachable. |
| agy | `--model <model>` | `--effort <low\|medium\|high>` | Verified 2026-08-24 on Antigravity CLI (`agy`) 1.1.19. [`docs/configuration.md`](../../../docs/configuration.md#harness-support) owns Firstmate's current default-model and effort-translation contract. |

The concrete `harness` field owns adapter identity independently of the model provider: `harness=pi` with `model=xai/grok-*` is Pi using xAI, not `harness=grok`, and does not require Grok CLI login; `harness=grok` remains the standalone Grok Build CLI adapter.
Likewise, `harness=cursor` with `model=cursor-grok-4.5-*` is Cursor Agent CLI routing a Grok model, not the xAI Grok Build `grok` harness.
Expand All @@ -152,13 +154,14 @@ Use the discovery surface in the current authenticated environment because suppo
| grok | Run `grok models`, which lists the models available to the current Grok installation and account. |
| kimi | Run `kimi provider list --json`, which lists the current provider and model configuration. |
| cursor | Run `cursor-agent --list-models` (or the legacy `agent --list-models`), which lists the ids available to the current Cursor account. `cursor` is not the CLI name. |
| agy | Run `agy models`, which lists the models available to the authenticated account. |

For an unfamiliar harness or model namespace, establish support and provider identity from that harness's authoritative CLI help, model listing, or current documentation rather than guessing from a name or prefix.
A listing that reaches the account and does not contain the model is concrete evidence the model is unsupported: block that candidate and quote the result.
A discovery surface you could not reach establishes nothing; report that as uncertainty rather than turning it into a supported or unsupported verdict.

When a requested effort value is outside the harness-specific accepted set, `fm-spawn` records the requested `effort=` in meta but emits no effort flag for that harness.
This preserves launch success instead of passing a known-bad value.
When a requested effort value has no verified adapter mapping, `fm-spawn` records the requested `effort=` in meta but emits no effort flag for that harness.
This preserves launch success instead of passing a known-bad value; [`docs/configuration.md`](../../../docs/configuration.md#harness-support) records deliberate translations such as agy's `xhigh` and `max` cap to `high`.
For Cursor, select the intended reasoning class through a model id the account's own `--list-models` actually returns, and leave the separate effort axis unset.

## no-mistakes skill invocation
Expand All @@ -173,6 +176,7 @@ Natural language is acceptable if uncertain.
- grok: `/<skill>`, for example `/no-mistakes` (same form as claude). Verified end to end: grok discovers the user-level `no-mistakes` skill, `/no-mistakes` invokes it, and grok drives a real `no-mistakes axi run`. Like codex's `$`/`/` popups, typing `/<skill>` opens grok's slash-autocomplete, so a too-fast Enter selects the popup entry instead of sending, and for an argument-taking command (like `/no-mistakes`'s optional task-first argument) that first Enter only expands the popup selection into an argument-hint placeholder rather than submitting - a genuine second Enter is required (see the grok section below for the 2026-07-03 incident and fix). `fm_tmux_submit_core`'s retried Enter (used by `fm-send` on the tmux backend) handles this through the shared structural composer classifier; the herdr backend needed a dedicated fix (`fm_backend_herdr_composer_state`, docs/herdr-backend.md) because its prior delta-based verification false-positived on that same popup-close content change.
- kimi: `/<skill>`, for example `/no-mistakes`.
- cursor: `/<skill>`, for example `/no-mistakes`. Cursor discovers firstmate's user-level skills. Its slash popup swallows the first Enter, so a genuine second Enter submits; the shared submit retry handles it.
- agy: `/<skill>`, for example `/no-mistakes`.

## Submission acknowledgement hazards

Expand Down Expand Up @@ -534,3 +538,29 @@ A teardown refusal naming muse scratch is therefore correct behavior: inspect it
muse is a day-0 `0.1.0` beta whose launcher polls a release channel hourly and can replace the running binary underneath the fleet, changing the process name with it.
The captain accepted that risk, so firstmate does NOT set `MUSE_NO_AUTO_UPDATE=1`; a fleet that later wants stability can set it in the launch environment without any adapter change.
Its plugin/hook engine reports `plugins are not available in this build` unless `MUSE_EXPERIMENTAL_PLUGINS=on`, which is why the busy source reads the session log instead of installing a hook.

## agy (VERIFIED CREWMATE/SCOUT 2026-08-24, Antigravity CLI 1.1.19)

Antigravity CLI launches from `PATH` (typically `/opt/homebrew/bin/agy`).
It is not verified for secondmate or primary work.

| Fact | Value |
|---|---|
| Binary | Executable `agy` from `PATH`; verified on version 1.1.19. |
| Process enclosure | [`docs/configuration.md`](../../../docs/configuration.md#harness-support) owns the supported host behavior and agy transition limit; never override a process-scope refusal. |
| Launch | `agy --dangerously-skip-permissions __MODELFLAG____EFFORTFLAG__--prompt-interactive "$(__OPINPUT__ encode launch-brief < __BRIEF__)"`; positional prompts are rejected with exit code 2. |
| Models | `gemini-3.7-flash-high`, `gemini-3.7-flash-medium`, `gemini-3.7-flash-low`, Pro models, and Claude Sonnet/Opus models were present in the verified catalog. Authoritative discovery: `agy models`; Firstmate's current default is owned by [`docs/configuration.md`](../../../docs/configuration.md#harness-support). |
| Busy state | Generated project plugin hooks `PreInvocation` and `Stop`; [architecture](../../../docs/architecture.md#busy-state-is-semantic-per-adapter) owns the verdict contract and [verification](../../../docs/verification/supervision.md#semantic-busy-state) owns active evidence. |
| Delivery busy token | `esc to cancel`, the live footer present only while a turn is running. |
| Exit command | `/exit` or `/quit` or `Ctrl+D` (exits cleanly with status 0). |
| Interrupt | Single Escape or `Ctrl+C` cancels active turn and returns to composer; Firstmate uses `Ctrl+C` so interrupt delivery works on every supported backend, including Orca. |
| Skill invocation | `/<skill>`, for example `/no-mistakes`; skills in `.agents/skills/` are discovered. Typing `/` opens the interactive autocomplete menu, and typing the full skill name with Enter submits and activates the skill directly. |
| Autonomy | `--dangerously-skip-permissions` auto-approves all tool permission requests without prompting once project trust is established. |
| Trust dialog | Interactive launches (`-i`) in untrusted workspaces display a project trust dialog (`Do you trust the contents of this project?`) with `Yes, I trust this folder` as default. Firstmate peek handles this with `fm-send.sh <window> --key Enter`. Trust persists per canonical path in `~/.gemini/antigravity-cli/settings.json` under `trustedWorkspaces`. |
| Hooks | Natively supports `.agents/hooks.json` and project plugin hooks including `Stop`, `PreToolUse`, `PostToolUse`, `PreInvocation`, `PostInvocation`. Project hooks are strictly gated on workspace trust. |
| Environment markers | Child tool processes receive `ANTIGRAVITY_LS_VERSION=cli-1.1.19` and `ANTIGRAVITY_SOURCE_METADATA`. |
| Composer | Horizontal rule borders (`───`) enclosing prompt glyph `>`. Bordered empty composer correctly classifies as `empty`. |
| Effort | The verified CLI accepts `--effort low\|medium\|high`; [`docs/configuration.md`](../../../docs/configuration.md#harness-support) owns Firstmate's translation from the shared effort vocabulary. |
| Resumption | Resumes prior conversations via `agy --conversation <id>` or `--continue` / `-c`. |

Antigravity CLI 1.1.9 and newer cap consecutive `decision: continue` responses, so Firstmate does not use continuation retries as completion state.
3 changes: 2 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ state/ runtime records and signals; gitignored
<id>.cursor-session cursor busy-source binding (projects root, task worktree, prior conversations) written by fm-spawn; removed by teardown
<id>.inbox/ durable steering inbox: sequenced firstmate instruction records the worker acknowledges by moving them into its handled/ subdirectory; written by fm-send, re-rung and escalated by the watcher, removed by teardown (bin/fm-task-inbox-lib.sh)
<id>.meta task metadata; each producer script's header owns its exact fields and mutation contract, with docs/configuration.md routing operator-facing backend and trace-context details
<id>.process-scope generation-bound worker process-ownership record used by lifecycle cleanup; bin/fm-task-process-lib.sh owns its format and mutation contract; never edit or remove it manually
<id>.herdr-presentation quarantinable attempt and restart-binding journal for Herdr's optional visual projection; never task or endpoint authority; see docs/herdr-backend.md "Presentation spaces"
<id>.check.sh authenticated slow poll; the watcher dispatches validated PR data and the byte-identified Relay shim through trusted repository scripts, runs registered custom checks from hash-validated private snapshots, and rejects every other state check without execution
<id>.check-trust private content binding created by fm-check-register.sh for an intentional custom check
Expand Down Expand Up @@ -192,7 +193,7 @@ A silent bootstrap section needs no action; for any printed actionable diagnosti
## 4. Harness and runtime dispatch

Load `harness-adapters` before every spawn or recovery and before trust handling, skill invocation, interrupt, exit, resume, or adapter verification.
The verified harnesses are `claude`, `codex`, `opencode`, `pi`, `pi-signed`, `grok`, `kimi`, and `cursor`, plus `muse` for crewmates and scouts only; never dispatch on an unverified adapter.
The verified harnesses are `claude`, `codex`, `opencode`, `pi`, `pi-signed`, `grok`, `kimi`, and `cursor`, plus `muse` and `agy` for crewmates and scouts only; never dispatch on an unverified adapter or outside an adapter's verified task kinds.
If static `config/crew-harness` or `config/secondmate-harness` names an unverified adapter, report it and fall back only to a verified adapter rather than launching it.

`docs/configuration.md` owns dispatch-profile and runtime-backend schemas, `bin/fm-harness.sh` owns static resolution, and `bin/fm-spawn.sh` owns launch flags and fail-closed validation.
Expand Down
38 changes: 38 additions & 0 deletions bin/backends/cmux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,44 @@ fm_backend_cmux_target_ready() { # <target> [expected-label]
fm_backend_cmux_surface_exists "$FM_BACKEND_CMUX_WORKSPACE" "$FM_BACKEND_CMUX_SURFACE"
}

fm_backend_cmux_target_presence_state() { # <target> [expected-label]
local target=$1 expected_label=${2:-} expected_title wins window_ids wid workspaces matches total=0
fm_backend_cmux_parse_target "$target" || { printf 'unknown'; return 0; }
if [ -n "$expected_label" ]; then
expected_title=$(fm_backend_cmux_scoped_title "$expected_label")
fi
wins=$(fm_backend_cmux_cli list-windows --json --id-format uuids 2>/dev/null) \
|| { printf 'unknown'; return 0; }
printf '%s' "$wins" | jq -e 'type == "array"' >/dev/null 2>&1 \
|| { printf 'unknown'; return 0; }
window_ids=$(printf '%s' "$wins" | jq -r '.[]? | .id // empty' 2>/dev/null) \
|| { printf 'unknown'; return 0; }
while IFS= read -r wid; do
[ -n "$wid" ] || continue
workspaces=$(fm_backend_cmux_cli workspace list --json --id-format uuids --window "$wid" 2>/dev/null) \
|| { printf 'unknown'; return 0; }
printf '%s' "$workspaces" | jq -e '(.workspaces | type) == "array"' >/dev/null 2>&1 \
|| { printf 'unknown'; return 0; }
if [ -n "$expected_title" ]; then
matches=$(printf '%s' "$workspaces" | jq -r --arg title "$expected_title" \
'[.workspaces[]? | select(.title == $title)] | length' 2>/dev/null) \
|| { printf 'unknown'; return 0; }
else
matches=$(printf '%s' "$workspaces" | jq -r --arg id "$FM_BACKEND_CMUX_WORKSPACE" \
'[.workspaces[]? | select(.id == $id)] | length' 2>/dev/null) \
|| { printf 'unknown'; return 0; }
fi
total=$((total + matches))
done <<EOF
$window_ids
EOF
case "$total" in
0) printf 'missing' ;;
1) printf 'present' ;;
*) printf 'unknown' ;;
esac
}

# fm_backend_cmux_current_path: the live foreground process's cwd, or empty on
# any error. Mirrors fm_backend_zellij_current_path's active pwd-marker-probe
# workaround (bin/backends/zellij.sh:306-347) verbatim in spirit.
Expand Down
30 changes: 30 additions & 0 deletions bin/backends/orca.sh
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,36 @@ fm_backend_orca_capture() { # <terminal-id> <lines>
fm_backend_orca_json_text "$out"
}

fm_backend_orca_target_presence_state() { # <terminal-id>
local terminal=$1 out status state
out=$(orca terminal read --terminal "$terminal" --limit 1 --json 2>/dev/null)
status=$?
state=$(printf '%s' "$out" | node -e '
const fs = require("fs");
let data;
try {
data = JSON.parse(fs.readFileSync(0, "utf8"));
} catch (_) {
process.stdout.write("unknown");
process.exit(0);
}
if (data.ok === false) {
process.stdout.write(data.error && data.error.code === "terminal_handle_stale" ? "missing" : "unknown");
} else if (data.ok === true || data.result) {
process.stdout.write("present");
} else {
process.stdout.write("unknown");
}
') || state=unknown
if [ "$state" = missing ]; then
printf 'missing'
elif [ "$status" -eq 0 ] && [ "$state" = present ]; then
printf 'present'
else
printf 'unknown'
fi
}

fm_backend_orca_json_text() { # <json>
printf '%s' "$1" | node -e '
const fs = require("fs");
Expand Down
2 changes: 2 additions & 0 deletions bin/backends/tmux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ fm_backend_tmux_classify_process_name() { # <path> [argv0] -> agent|shell|other
# cannot carry it either: ~/.local/bin/muse-bin-<version> has no `muse` path
# COMPONENT, so the fm_harness_path_name fallback below never fires for it.
muse|muse-bin-*) printf 'agent' ;;
agy) printf 'agent' ;;
*claude*|*codex*|*opencode*|*grok*|*kimi*|pi|pi-signed|pi-launcher|Pi) printf 'agent' ;;
zsh|bash|sh|dash|ash|ksh|mksh|tcsh|csh|fish) printf 'shell' ;;
*)
Expand Down Expand Up @@ -341,6 +342,7 @@ EOF
'') printf 'unreadable'; return 0 ;;
esac
case "$(fm_backend_tmux_classify_process_name "$comm")" in
agent) printf 'alive' ;;
shell) printf 'dead' ;;
*) printf 'ambiguous' ;;
esac
Expand Down
45 changes: 45 additions & 0 deletions bin/backends/zellij.sh
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,51 @@ fm_backend_zellij_target_ready() { # <target> [expected-label]
fm_backend_zellij_pane_exists "$FM_BACKEND_ZELLIJ_SESSION" "$FM_BACKEND_ZELLIJ_PANE"
}

fm_backend_zellij_target_presence_state() { # <target> [expected-label]
local target=$1 expected_label=${2:-} sessions tabs panes scoped scoped_count bare_count
fm_backend_zellij_parse_target "$target" || { printf 'unknown'; return 0; }
sessions=$(zellij list-sessions --short --no-formatting 2>/dev/null) \
|| { printf 'unknown'; return 0; }
if ! printf '%s\n' "$sessions" | grep -qxF "$FM_BACKEND_ZELLIJ_SESSION"; then
printf 'missing'
return 0
fi
if [ -n "$expected_label" ]; then
tabs=$(fm_backend_zellij_cli "$FM_BACKEND_ZELLIJ_SESSION" action list-tabs --json 2>/dev/null) \
|| { printf 'unknown'; return 0; }
printf '%s' "$tabs" | jq -e 'type == "array"' >/dev/null 2>&1 \
|| { printf 'unknown'; return 0; }
scoped=$(fm_backend_zellij_scoped_title "$expected_label")
scoped_count=$(printf '%s' "$tabs" | jq -r --arg want "$scoped" \
'[.[]? | select(.name == $want)] | length' 2>/dev/null) \
|| { printf 'unknown'; return 0; }
case "$scoped_count" in
1) printf 'present'; return 0 ;;
0) ;;
*) printf 'unknown'; return 0 ;;
esac
bare_count=$(printf '%s' "$tabs" | jq -r --arg want "$expected_label" \
'[.[]? | select(.name == $want)] | length' 2>/dev/null) \
|| { printf 'unknown'; return 0; }
case "$bare_count" in
0) printf 'missing' ;;
1) printf 'present' ;;
*) printf 'unknown' ;;
esac
return 0
fi
panes=$(fm_backend_zellij_cli "$FM_BACKEND_ZELLIJ_SESSION" action list-panes --json 2>/dev/null) \
|| { printf 'unknown'; return 0; }
printf '%s' "$panes" | jq -e 'type == "array"' >/dev/null 2>&1 \
|| { printf 'unknown'; return 0; }
if printf '%s' "$panes" | jq -e --argjson pane "$FM_BACKEND_ZELLIJ_PANE" \
'[.[]? | select(.id == $pane and .is_plugin == false)] | length == 1' >/dev/null 2>&1; then
printf 'present'
else
printf 'missing'
fi
}

# fm_backend_zellij_current_path: the live pane's cwd, or empty on any error.
# Mirrors tmux's pane_current_path poll used for worktree-path discovery after
# `treehouse get`.
Expand Down
Loading