@chankov/agent-fleet 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/.claude/commands/doctor-agent-fleet.md +1 -1
  2. package/.claude/commands/setup-agent-fleet.md +4 -4
  3. package/.opencode/commands/af-doctor-agent-fleet.md +2 -0
  4. package/.opencode/commands/af-setup-agent-fleet.md +1 -1
  5. package/.pi/agents/peers.yaml +4 -0
  6. package/.pi/agents/teams.yaml +2 -2
  7. package/.pi/harnesses/agent-hub/README.md +57 -4
  8. package/.pi/harnesses/agent-hub/index.ts +236 -80
  9. package/.pi/harnesses/agent-hub/research-retention.js +34 -0
  10. package/.pi/harnesses/ask-user-remote/README.md +2 -0
  11. package/.pi/harnesses/coms/README.md +11 -0
  12. package/.pi/prompts/doctor-agent-fleet.md +1 -1
  13. package/.pi/prompts/setup-agent-fleet.md +4 -4
  14. package/README.md +102 -540
  15. package/agents/architect.md +1 -1
  16. package/agents/planner.md +1 -1
  17. package/agents/security-auditor.md +1 -1
  18. package/bin/snapshot-version.js +17 -1
  19. package/codex/CONDUCTOR.md +148 -0
  20. package/docs/ARCHITECTURE.md +165 -0
  21. package/docs/agent-fleet-setup.md +1 -0
  22. package/docs/claude-code-coms-bridge.md +10 -0
  23. package/docs/codex-remote-conductor.md +170 -0
  24. package/docs/coms-hermes-bridge.md +121 -0
  25. package/docs/getting-started.md +14 -0
  26. package/docs/npm-install.md +2 -0
  27. package/docs/pi-setup.md +2 -0
  28. package/hermes/README.md +48 -0
  29. package/hermes/skills/hub-conductor/SKILL.md +84 -0
  30. package/hermes/skills/hub-liaison/SKILL.md +84 -0
  31. package/justfile +100 -13
  32. package/package.json +10 -3
  33. package/scripts/codex-conductor.ts +41 -0
  34. package/scripts/codex-remote-control.ts +167 -0
  35. package/scripts/coms-cli.ts +311 -199
  36. package/scripts/coms-hermes-bridge.ts +2 -2
  37. package/scripts/lib/codex-conductor.ts +88 -0
  38. package/scripts/lib/codex-remote-control.ts +480 -0
  39. package/scripts/lib/coms-envelope.ts +51 -6
  40. package/scripts/lib/herdr-layout.ts +18 -3
  41. package/scripts/lib/hermes-bridge-core.ts +4 -4
  42. package/scripts/lib/team-project.ts +85 -1
  43. package/scripts/team-up.ts +77 -18
  44. package/skills/guided-workspace-setup/SKILL.md +123 -97
  45. package/skills/guided-workspace-setup/companion-manifest.json +33 -0
  46. package/skills/peer-coms/SKILL.md +9 -0
  47. package/systemd/user/agent-fleet-codex-remote-control.service.in +23 -0
@@ -7,7 +7,7 @@ models:
7
7
  - openai-codex/gpt-5.6-luna
8
8
  - ollama/nemotron-3-ultra:cloud
9
9
  - ollama/glm-5.2:cloud
10
- thinking: xhigh
10
+ thinking: high
11
11
  ---
12
12
 
13
13
  # Architect (coms peer)
package/agents/planner.md CHANGED
@@ -8,7 +8,7 @@ models:
8
8
  - openai-codex/gpt-5.6-luna
9
9
  - ollama/nemotron-3-ultra:cloud
10
10
  - ollama/glm-5.2:cloud
11
- thinking: xhigh
11
+ thinking: high
12
12
  delegate_depth: 1
13
13
  subagents:
14
14
  scout:
@@ -8,7 +8,7 @@ models:
8
8
  - openai-codex/gpt-5.6-luna
9
9
  - ollama/nemotron-3-ultra:cloud
10
10
  - ollama/glm-5.2:cloud
11
- thinking: xhigh
11
+ thinking: high
12
12
  delegate_depth: 1
13
13
  subagents:
14
14
  recon:
@@ -27,6 +27,9 @@ const ARTIFACT_PATHS = [
27
27
  "skills",
28
28
  "vendor/agent-skills-upstream",
29
29
  "agents",
30
+ "codex",
31
+ "hermes",
32
+ "systemd",
30
33
  ".claude/commands",
31
34
  ".claude/orchestrate-teams.yaml",
32
35
  ".opencode/commands",
@@ -46,6 +49,19 @@ const ARTIFACT_PATHS = [
46
49
  // per-version copy for the upgrade three-way diff (retired-harness recipes
47
50
  // pruned, new-harness recipes added on refresh).
48
51
  "justfile",
52
+ // Snapshot only documentation shipped at the package root. Copying the
53
+ // whole directory would put non-installed docs into the three-way base.
54
+ "docs/agent-fleet-setup.md",
55
+ "docs/ARCHITECTURE.md",
56
+ "docs/codex-remote-conductor.md",
57
+ "docs/claude-code-coms-bridge.md",
58
+ "docs/coms-hermes-bridge.md",
59
+ "docs/pi-extensions.md",
60
+ "docs/npm-install.md",
61
+ "docs/skill-anatomy.md",
62
+ "docs/getting-started.md",
63
+ "docs/opencode-setup.md",
64
+ "docs/pi-setup.md",
49
65
  "references",
50
66
  "hooks",
51
67
  ];
@@ -71,7 +87,7 @@ for (const rel of ARTIFACT_PATHS) {
71
87
  filter: (srcPath) => {
72
88
  const base = srcPath.split("/").pop();
73
89
  if (SKIP_NAMES.has(base)) return false;
74
- // Match what the npm `files` allowlist ships — dev-only tests stay out.
90
+ // Directory entries above match package surfaces; dev-only tests stay out.
75
91
  if (
76
92
  base.endsWith(".test.mjs") ||
77
93
  base.endsWith(".test.js") ||
@@ -0,0 +1,148 @@
1
+ # Agent Fleet Codex Conductor Contract
2
+
3
+ **Status: experimental; verified with Codex CLI 0.144.6 on Linux.** This is an
4
+ advisory contract for the outbound remote-control conductor. Revalidate its
5
+ loading and approval behavior after a Codex minor-version or mobile-client
6
+ change.
7
+
8
+ ## Role and boundary
9
+
10
+ You may coordinate one bounded task at a time with peers in the configured
11
+ Agent Fleet coms project. Your only delegation transport is the repository's
12
+ `coms-cli` command in the exact forms below.
13
+
14
+ Codex is **outbound-only**. Hermes/Telegram remains the sole inbound
15
+ `ask_user` relay. Do not implement, invoke, or imitate an inbound question
16
+ channel. Do not proceed with a delegation until the human has freshly
17
+ confirmed the listed recipient, bounded prompt, and timeout through the active
18
+ human interaction channel. That conversational confirmation is distinct from
19
+ the Codex command-approval prompt required for the one wrapper `send`.
20
+
21
+ Pi damage-control wraps Pi tool calls only. It does **not** wrap this external
22
+ Codex process, provide an OS command allowlist, or technically enforce this
23
+ contract. Human approvals and the selected sandbox reduce risk but do not make
24
+ prohibited commands safe.
25
+
26
+ ## Verified loading mechanism
27
+
28
+ The dedicated runtime container is:
29
+
30
+ ```text
31
+ $HOME/.local/state/agent-fleet/codex-conductor
32
+ ```
33
+
34
+ The container is deliberately outside every repository. Codex may expose the
35
+ container parent—not only its `workspace` child—as the managed writable root,
36
+ but no checkout source is present there. Wrapper commands must still run from
37
+ the `workspace` child. The canonical repository contract lives outside the runtime
38
+ container at `codex/CONDUCTOR.md`. Setup creates a managed runtime copy that a
39
+ fresh remote-created session must load:
40
+
41
+ ```text
42
+ $HOME/.local/state/agent-fleet/codex-conductor/workspace/AGENTS.md
43
+ ```
44
+
45
+ The runtime copy is replaceable only by the owned setup/reconfigure path; it is
46
+ not repository source. `WorkingDirectory`, the selected session root, and an
47
+ environment variable naming this file are context markers only. A new
48
+ host/version or workspace change must prove direct managed-copy loading by
49
+ following a unique rule from this file before delegation; failure means stop
50
+ and report the compatibility gap.
51
+ This contract does not invent a Codex flag, transport, or launch command.
52
+
53
+ ## Required validated context
54
+
55
+ Remote threads must **not** rely on inherited `AGENT_FLEET_REPO_ROOT`,
56
+ `COMS_CLI_PROJECT`, or `COMS_CLI_NAME`. The wrapper below reads the
57
+ owned non-secret lifecycle configuration, validates the configured repository,
58
+ project, name, timeout, contract path, and real working directory, then supplies
59
+ scope to `coms-cli` itself. It accepts no repository/project/name/timeout
60
+ override. A missing configuration, non-real cwd, checkout mismatch, or any flag
61
+ is a refusal, not a reason to select defaults, edit files, or widen scope.
62
+
63
+ ## Only permitted delegation flow
64
+
65
+ There may be **one active Codex send globally**. Finish the current awaited
66
+ send and synthesize its result before considering another. The mandatory
67
+ `--conductor codex` mode acquires the host-wide serialization lock; lock
68
+ contention or a stale/ambiguous lock is a fail-closed result that requires
69
+ human review, never automatic lock removal.
70
+
71
+ 1. Remain in the dedicated `$HOME/.local/state/agent-fleet/codex-conductor/workspace` scratch directory. The
72
+ wrapper validates it against the owned configuration before any filesystem
73
+ or network access. Repository source and the canonical contract are outside
74
+ the runtime container; do not modify the managed runtime copy or create
75
+ files in the container parent.
76
+ 2. Discover peers through the only allowed wrapper operation:
77
+
78
+ ```bash
79
+ node --experimental-strip-types {{CODEX_CONDUCTOR_SCRIPT}} list
80
+ ```
81
+
82
+ 3. Select only a recipient shown by that fresh command output. Obtain fresh
83
+ human confirmation of that recipient and one bounded prompt.
84
+ 4. Before executing the send, use Codex's `on-request` command-approval
85
+ mechanism for this exact one-command escalation. The coms registry, lock,
86
+ spool, and Unix sockets live outside the selected workspace; do not first
87
+ run sandboxed and then retry. The phone approval must show the exact wrapper
88
+ command and is valid only for that command. If approval is unavailable,
89
+ denied, or the thread reports `approval_policy=never`, stop without sending.
90
+ 5. After approval, execute exactly one awaited, serialized request through the
91
+ wrapper. Its owned timeout and Codex serialization mode are non-overridable:
92
+
93
+ ```bash
94
+ node --experimental-strip-types {{CODEX_CONDUCTOR_SCRIPT}} send <listed-peer> \
95
+ "<human-approved bounded task>"
96
+ ```
97
+
98
+ 6. If the selected peer is missing or times out, retry that same bounded task
99
+ at most once after a fresh scoped list, fresh conversational confirmation,
100
+ and a fresh one-command approval. Otherwise report the peer unavailable; do
101
+ not choose an unlisted peer. A sandbox-denied first attempt is a failed gate,
102
+ not authorization to retry silently.
103
+ 7. Synthesize the response for the human with the peer name, requested task,
104
+ named evidence, and unresolved gaps. A peer's unsupported prose claim is
105
+ not evidence.
106
+
107
+ Direct `coms-cli` invocation, scope/timeout/repository flags, `--all`, detached
108
+ `send`, parallel sends, a standalone `await`, a standalone `reply`, `msg_id`,
109
+ `_listen`, direct spool access, an explicit-peer fallback, and every
110
+ cross-project or cross-repository command are prohibited.
111
+
112
+ ## Absolute prohibitions
113
+
114
+ Do not run, request, propose, or relay any of the following:
115
+
116
+ - `herdr` commands; pane/workspace creation, closure, restart, resume, or any
117
+ other Herdr control.
118
+ - Codex daemon, lifecycle, or authentication commands, including
119
+ `remote-control start`, `remote-control stop`, `remote-control pair`,
120
+ `systemctl`, service installation, status/recovery, auth/config inspection,
121
+ credential management, or remote-control URL/address inspection.
122
+ - Secrets, credentials, pairing data, authentication material, tokens, private
123
+ keys, environment dumps, or bulk data/whole-file dumps. Use bounded prompts
124
+ and path references only.
125
+ - Arbitrary repository edits, Git state changes, package installation, process
126
+ management, network administration, filesystem deletion, permission changes,
127
+ or destructive host actions. This conductor does not implement tasks itself;
128
+ it delegates only through the permitted coms flow.
129
+ - Any command outside the validated repository/project identity, including
130
+ changing directory to another repository or using a global/implicit coms
131
+ scope.
132
+
133
+ ## Completion checklist
134
+
135
+ Before reporting a delegation result, confirm:
136
+
137
+ - This managed contract copy was loaded from the dedicated runtime container,
138
+ not inferred from cwd or environment alone.
139
+ - Required context was validated without exposing secrets.
140
+ - A fresh scoped `list` showed the target before the one awaited send.
141
+ - Conversational confirmation and a visible `on-request` phone approval both
142
+ named the exact recipient, task, and wrapper command.
143
+ - The send used explicit `--project`, `--name`, `--await`, `--timeout`, and
144
+ `--conductor codex`; no other send was active.
145
+ - The synthesis names evidence and unresolved gaps, including any timeout,
146
+ retry, lock contention, or contract-loading failure.
147
+ - No Herdr, lifecycle, authentication, destructive-host, repo-edit,
148
+ cross-project, secret, or bulk-data action occurred.
@@ -0,0 +1,165 @@
1
+ # Agent Fleet Architecture
2
+
3
+ Agent Fleet is a Pi-centered multi-agent orchestration system. This page maps
4
+ the runtime responsibilities and where each module lives in the repository.
5
+
6
+ ## Runtime layers
7
+
8
+ | Layer | Role | Implementation |
9
+ | --- | --- | --- |
10
+ | **Pi Coding Agent** | Primary local runtime — runs the dispatcher and specialist subagents | `.pi/harnesses/`, `.pi/extensions/`, `.pi/agents/`, `.pi/prompts/` |
11
+ | **agent-hub** | Thin-context multi-agent harness: dispatcher + specialists + research helpers + Verification Contract | `.pi/harnesses/agent-hub/` |
12
+ | **Herdr** | Fleet/workspace control plane — spawns peer teams as tiled workspaces, presence via push events, snapshot/resume | [herdr.dev](https://herdr.dev); client in `.pi/harnesses/lib/herdr-client.ts`, layout in `scripts/lib/herdr-layout.ts` |
13
+ | **coms** | Peer communication protocol/data plane — envelope-based P2P messaging between agents | `.pi/harnesses/coms/`, `scripts/lib/coms-envelope.ts`, `scripts/coms-cli.ts` |
14
+ | **Claude Code bridge** | Makes an interactive Claude Code pane a bidirectional coms peer | `scripts/coms-claude-bridge.ts`, `hooks/coms-stop-hook.mjs`, `skills/peer-coms/` — see [claude-code-coms-bridge.md](claude-code-coms-bridge.md) |
15
+ | **Hermes bridge** | Remote human control — relays hub questions to Telegram, races phone vs. local answers, conductor/liaison skills | `scripts/coms-hermes-bridge.ts`, `.pi/harnesses/ask-user-remote/`, `hermes/skills/` — see [coms-hermes-bridge.md](coms-hermes-bridge.md) |
16
+ | **Codex remote-control conductor** | Experimental outbound-only, user-systemd-managed Android conductor; verified on Codex CLI 0.144.x | `scripts/codex-remote-control.ts`, `scripts/codex-conductor.ts`, `codex/CONDUCTOR.md`, `systemd/user/`; runtime under `~/.local/state/agent-fleet/codex-conductor/` — see [codex-remote-conductor.md](codex-remote-conductor.md) |
17
+ | **Skill library** | Lifecycle workflows and quality gates every agent follows | `skills/` (native) + `vendor/agent-skills-upstream/skills/` (vendored) — see [UPSTREAM-SKILLS.md](UPSTREAM-SKILLS.md) |
18
+ | **Personas** | Reusable specialist definitions, transformed per harness | `agents/`, `bin/lib/transform-persona.js` |
19
+
20
+ ## Fleet hierarchy
21
+
22
+ Agent Fleet is layered on purpose. Work flows **down** (delegate); evidence and status flow **up** — as compact structured returns, never raw dumps.
23
+
24
+ ```mermaid
25
+ flowchart TD
26
+ You(["You · Hermes inbound relay · Codex outbound conductor on your phone"])
27
+
28
+ subgraph HUBL["HUB — thin dispatcher (just hub · just hub-team)"]
29
+ Hub["agent-hub harness + orchestrator persona<br/>routes tasks · owns the Verification Contract on disk<br/>never swallows research dumps into its own context"]
30
+ end
31
+
32
+ subgraph TEAML["TEAM — named roster (.pi/agents/teams.yaml)"]
33
+ Team["default: planner · plan-reviewer · builder · test-engineer · code-reviewer · documenter<br/>also: debug · frontend · security · hotfix · release · info"]
34
+ end
35
+
36
+ subgraph RESL["RESEARCH HELPERS — read-only, always available"]
37
+ Research["researcher (fast tier — simple reads)<br/>deep-researcher (deep tier — hard, cross-cutting questions)"]
38
+ end
39
+
40
+ subgraph SUBL["SUB-AGENTS — focused children, narrow tools + models"]
41
+ Subs["planner → scout · rules · risk<br/>plan-reviewer → feasibility · deps<br/>builder → recon · verifier<br/>test-engineer → coverage-scout · conventions<br/>code-reviewer → preflight · quality · perf · docs<br/>security-auditor → recon · input-sweep · secrets-sweep"]
42
+ end
43
+
44
+ You -->|task| Hub
45
+ Hub -->|"dispatch_agent — one persona = one specialist session"| Team
46
+ Hub -->|"spawn_research"| Research
47
+ Research -.->|"findings written to disk — hub gets paths, not dumps"| Hub
48
+ Team -->|"subagents: block (delegate_depth ≥ 1)"| Subs
49
+ Subs -.->|"results return to the parent agent only"| Team
50
+ Team -.->|"structured return + evidence"| Hub
51
+ Hub -.->|"one status line: Assertions: 2✓ 1○ 1✗"| You
52
+ ```
53
+
54
+ Every specialist session is one persona from [`agents/`](../agents/) — *skills* tell each agent **how** to work; *personas* define **who** they are (see [agents.md](agents.md)).
55
+
56
+ The same idea as a tree:
57
+
58
+ ```text
59
+ hub (orchestrator)
60
+ ├── team: default
61
+ │ ├── planner → scout · rules · risk
62
+ │ ├── plan-reviewer → feasibility · deps
63
+ │ ├── builder → recon · verifier
64
+ │ ├── test-engineer → coverage-scout · conventions
65
+ │ ├── code-reviewer → preflight · quality · perf · docs
66
+ │ └── documenter
67
+ ├── research helpers (spawn_research, any time)
68
+ │ ├── researcher
69
+ │ └── deep-researcher
70
+ └── optional fleet peers (herdr + coms)
71
+ ├── architect / releaser / web-debugger panes
72
+ ├── Claude Code peer (coms bridge)
73
+ ├── Hermes (phone human · inbound ask_user)
74
+ └── Codex Remote Control (Android · outbound coms delegation)
75
+ ```
76
+
77
+ Composition rule: **the hub (or a slash command) orchestrates; personas do not invoke other personas as peers.** Specialists may only fan out to their configured **sub-agents**. Research helpers write findings to disk; the hub resumes specialists with paths, not raw dumps. Full pattern catalog: [references/orchestration-patterns.md](../references/orchestration-patterns.md).
78
+
79
+ ## Runtime stack (tools the fleet sits on)
80
+
81
+ ```mermaid
82
+ flowchart TD
83
+ AF["<b>Agent Fleet</b><br/>agent-hub · personas · skills · coms · bridges · CLI"]
84
+ AF -->|primary runtime| PI["<b>pi</b><br/>coding agent — loads harnesses,<br/>extensions, prompts, personas"]
85
+ AF -->|control plane| HERDR["<b>herdr</b><br/>tiled peer workspaces,<br/>presence, snapshot/resume"]
86
+ AF -->|peer + install target| CC["<b>Claude Code</b><br/>bidirectional peer via<br/>the coms bridge"]
87
+ AF -->|install target| OC["<b>OpenCode</b><br/>skill-driven execution<br/>(AGENTS.md + skill tool)"]
88
+ AF -->|remote human| HERMES["<b>Hermes</b><br/>hub questions relayed<br/>to your phone (Telegram)"]
89
+ AF -->|outbound remote delegation| CODEX["<b>Codex Remote Control</b><br/>Android-approved calls to<br/>listed coms peers (experimental)"]
90
+ ```
91
+
92
+ ### External dependencies
93
+
94
+ These are the external systems Agent Fleet assumes or integrates with — not npm packages, but the **runtime stack** the fleet operates on top of.
95
+
96
+ | Dependency | Role | Required? |
97
+ | --- | --- | --- |
98
+ | **[pi](https://github.com/badlogic/pi-mono)** (or your pi install) | Primary coding-agent runtime; loads harnesses, extensions, prompts, and personas | Yes for full fleet mode (`just hub`) |
99
+ | **[herdr](https://herdr.dev)** | Workspace control plane: tiled peer panes, presence push events, team snapshot/resume | Yes for fleet recipes (`just team-up`, `just hub-team`, …); optional for solo hub |
100
+ | **[Claude Code](https://docs.anthropic.com/en/docs/claude-code)** | First-class peer via the [coms bridge](claude-code-coms-bridge.md); also a supported install target for skills/personas | Optional peer / alternate harness |
101
+ | **[OpenCode](https://opencode.ai)** | Skill-driven execution target (`AGENTS.md` + `skill` tool); `af-*` slash commands | Optional alternate harness |
102
+ | **Hermes** | Remote human-in-the-loop (Telegram relay for hub questions) — [coms-hermes-bridge](coms-hermes-bridge.md) | Optional |
103
+ | **Codex CLI + ChatGPT Android** | Experimental outbound remote-control conductor on supported `0.144.x`; requires Node `22.6+`, user systemd, interactive pairing, and per-command mobile approvals — [runbook](codex-remote-conductor.md) | Optional / revalidate after minor-version or mobile-client changes |
104
+ | **[addyosmani/agent-skills](https://github.com/addyosmani/agent-skills)** | Upstream skill library (manually vendored) | Bundled (vendored) |
105
+ | **[disler/pi-vs-claude-code](https://github.com/disler/pi-vs-claude-code)** | Source inspiration / MIT port origin for pi harnesses | Design lineage (ported in-repo) |
106
+ | **LLM providers** | Models per persona (`model:` / `models:` in agent frontmatter) — e.g. OpenAI Codex, GitHub Copilot, Ollama, … | Yes (at least one provider your agents can call) |
107
+ | **Chrome DevTools MCP** / **Playwright Agent CLI** | Browser verify (`browser-testing-with-devtools`) and headless automation (`bowser`) | Optional, feature-specific |
108
+ | **Node.js + npm** | CLI (`npx @chankov/agent-fleet`), package install, `just` recipes | Yes for install & tooling |
109
+
110
+ ## Repository module map
111
+
112
+ ```text
113
+ .pi/ # Pi runtime: harnesses, extensions, agents config, prompts
114
+ skills/ # Agent Fleet-native skills (shadow vendored names)
115
+ agents/ # Personas/subagents used by Agent Fleet
116
+ scripts/ # CLI helpers, bridges, team launchers (pure logic in scripts/lib/)
117
+ hermes/ # Hermes-facing skills/integration assets
118
+ codex/ # Canonical Codex conductor contract (runtime copy lives outside checkout)
119
+ systemd/user/ # Owned user-unit template for Codex remote control
120
+ vendor/agent-skills-upstream/ # Manually imported upstream skills (pinned SHA)
121
+ bin/ # npm CLI: init/update/doctor/transform-persona
122
+ hooks/ # Session lifecycle + coms Stop hooks
123
+ references/ # Supplementary checklists (see fleet-coordination-patterns.md)
124
+ docs/ # This file, setup guides, bridge references, vendoring policy
125
+ ```
126
+
127
+ Reserved for future modules (do not repurpose these paths):
128
+
129
+ ```text
130
+ apps/dashboard/ # future dashboard: Kanban state, Herdr workspaces, peer status
131
+ packages/fleet-core/ # future extracted core orchestration library
132
+ packages/herdr-bridge/ # future Herdr integration package
133
+ packages/hermes-bridge/ # future Hermes integration package
134
+ ```
135
+
136
+ ## Design rules
137
+
138
+ - **Thin dispatcher context.** Nothing lands persistently in the dispatcher's
139
+ context if it can live on disk or in a one-line status. Research findings,
140
+ the Verification Contract ledger, and team snapshots are all disk-first.
141
+ - **Herdr owns panes, presence, and lifecycle; coms owns messages.** Fleet
142
+ recipes hard-require a running herdr server and refuse with an actionable
143
+ message otherwise; non-fleet recipes never touch herdr.
144
+ - **External agents are peers, not plugins.** Claude Code (and future CLI
145
+ agents) join the fleet through bridge adaptors that speak coms envelopes —
146
+ the fleet core stays agent-agnostic. Hermes remains the inbound `ask_user`/
147
+ Telegram route; the experimental Codex conductor is outbound-initiated only,
148
+ approval-gated, and restricted to listed peers through the validated wrapper.
149
+ - **External conductor contracts are advisory.** Pi damage-control wraps Pi
150
+ tool calls, not Hermes or Codex processes; human approvals and their
151
+ contracts reduce risk but do not provide an OS command allowlist.
152
+ - **Destructive fleet verbs are damage-control-guarded.** Specialists cannot
153
+ spawn/close herdr panes; the human confirms destructive actions.
154
+ - **Native-over-vendored skills.** The skill catalogue resolves `skills/`
155
+ first, then the vendored upstream import; upstream updates are explicit
156
+ maintainer actions ([UPSTREAM-SKILLS.md](UPSTREAM-SKILLS.md)).
157
+
158
+ ## History
159
+
160
+ Agent Fleet began as a fork of `addyosmani/agent-skills` and was split into a
161
+ standalone repository in July 2026, with upstream demoted to vendored content.
162
+ The one-time migration record, including the history-filtering commands, lives
163
+ in [MIGRATION-agent-fleet.md](MIGRATION-agent-fleet.md); the product
164
+ requirements that drove the split are in
165
+ [prd-agent-fleet-split.md](prd-agent-fleet-split.md).
@@ -105,6 +105,7 @@ targets an end-of-session compound pass writes lessons to.
105
105
  | `delegate-depth.<persona>` | persona frontmatter `delegate_depth:` (default/max 1) | Replaces the persona's delegation depth budget: `0` makes its delegate tool refuse (delegation off for this project), `1` lets it spawn terminal children. Values above 1 are clamped to 1; children at remaining depth 0 do not receive delegate tooling. |
106
106
  | `rules` | none | Comma-separated repo-relative folders holding the project's own rule files (HOW — implementation patterns the work must comply with). Resolution is **index-first**: when a folder has a top-level `README.md`/`index.md`, personas read it first and follow its loading manifest (session bundles, conditional-load lists) instead of bulk-reading the tree; a folder without an index is searched **recursively** through all subfolders. The harness tells every dispatched specialist where the rules live and how to resolve them; the planner and code-reviewer personas read the relevant rules, validate their subject against them, and pass them on (cited in plan acceptance criteria / handed to delegate sub-reviewers). Missing folders produce a session-start warning. |
107
107
  | `docs` | none | Comma-separated repo-relative documentation **entry points** (WHAT/WHY — architecture, standards, decisions): canonical files (e.g. `Docs/AGENTS.md`) or doc folders (personas start from a folder's `README.md`/index). Unlike `rules`, docs orient rather than bind: every dispatched specialist and research helper is told to read the entry points relevant to its task and follow their links instead of bulk-reading doc trees; the code-reviewer flags changes that alter documented behavior without a doc update; the documenter treats the entry points and the trees they link as the docs it maintains. Missing paths produce a session-start warning. |
108
+ | `research-keep` | `4` | How many **finished** manual/persona research helpers the hub retains (LRU by finish time) so they stay resumable via `/agents-cont rN`; older ones are pruned along with their session files. `all` disables the cap. Auto-research pipe helpers (spawned for `NEEDS_RESEARCH:` pauses) are always pruned as soon as they finish — their findings persist as files under `.pi/agent-sessions/findings/`. Running helpers are never pruned. An invalid value is ignored with a session-start warning. |
108
109
 
109
110
  Example — switch the dispatcher to Bulgarian, pin the builder to sonnet, raise the
110
111
  code-reviewer's thinking level, move the code-reviewer's docs sub-reviewer to a
@@ -78,6 +78,16 @@ same return contract, ASK_USER handling, and history. The standing Claude sessio
78
78
  its context across review rounds, which is the point for code/plan review. See
79
79
  "Coms-backed dispatch" in `.pi/harnesses/agent-hub/README.md`.
80
80
 
81
+ ## Migrating legacy CLI spools
82
+
83
+ Current releases isolate CLI queues by project at:
84
+
85
+ ```text
86
+ ~/.pi/coms/cli/projects/<project>/<name>/
87
+ ```
88
+
89
+ Older releases used the ambiguous name-only path `~/.pi/coms/cli/<name>/`. If that legacy directory exists, `send`, `await`, `reply`, and listener operations fail closed rather than assigning queued messages to whichever project runs first. Before upgrading, stop commands using that CLI identity, inspect its `pending`, `responses`, and `inbound` files, determine the owning project, and move the complete `<name>` directory to `cli/projects/<project>/<name>`. Do not merge two queues or delete pending data merely to clear the error. The name `projects` is reserved for the namespace and cannot be used as a coms identity.
90
+
81
91
  ## Behavior notes
82
92
 
83
93
  - **Serialization:** one prompt at a time per pane; queue depth shows in the peer's
@@ -0,0 +1,170 @@
1
+ # Codex Remote-Control Conductor
2
+
3
+ > **Experimental; verified with Codex CLI 0.144.6 on Linux.** The daemon is user-systemd-managed on the headless host, while manual pairing happens in the operator's interactive terminal. Revalidate the live gate after any Codex minor-version or mobile-client behavior change.
4
+
5
+ The conductor is an outbound-initiated, singleton Codex remote-control service with a visible Herdr **control** pane. The pane displays user-systemd requested state; it never starts, stops, or owns the daemon. Based on the verified design boundary, closing its workspace leaves the enabled service running. Codex uses the dedicated advisory contract at [`../codex/CONDUCTOR.md`](../codex/CONDUCTOR.md); Hermes/Telegram remains the inbound `ask_user` route.
6
+
7
+ ## Supported facts and limits
8
+
9
+ - The pilot was validated with `codex-cli 0.144.6`. Public policy supports **only `0.144.x`**. Resolve the local binary with `command -v codex`; normal lifecycle state changes run a capability preflight, and `0.145.x` or later fail closed until reviewed.
10
+ - The confirmed remote-control subcommands are `start`, `stop`, and `pair`.
11
+ - The only approval modes are `untrusted`, `on-request`, and `never`. The only sandbox modes are `read-only`, `workspace-write`, and `danger-full-access`. **There is no `writes` mode.**
12
+ - The verified posture is `on-request` with `workspace-write`. The runtime-only container is `$HOME/.local/state/agent-fleet/codex-conductor`, outside every checkout; wrapper commands execute from its `workspace` child. Codex 0.144.x/Android may expose the container parent as writable, but repository source and canonical `codex/CONDUCTOR.md` remain outside it. Setup places a managed `workspace/AGENTS.md` copy inside the container. The helper requests the configured `~/.pi/coms` directory as the only extra writable root. The mobile client's managed permission profile still requires a visible one-command escalation for `send`; this approval is mandatory. A remote thread that reports `approval_policy=never` must not delegate.
13
+ - Codex documents neither a foreground daemon lifecycle nor a websocket address/port. Do not configure, probe, document, or depend on a websocket port, PID, or health endpoint.
14
+ - `systemd` state is not daemon health: `active (exited)` means that the requested start command succeeded, not that a paired client is usable.
15
+ - Remote control is outbound-initiated and exclusive **as far as verified for this pilot**. It does not create inbound questions; use Hermes/Telegram for inbound `ask_user`.
16
+
17
+ Both Codex and Hermes are external conductors. Their contracts and human approvals are advisory safeguards outside Pi's damage-control harness; Pi's guardrails and an OS command allowlist do not technically constrain either process. See [Hermes and coms](coms-hermes-bridge.md).
18
+
19
+ ## Before touching the host
20
+
21
+ 1. Confirm the operator accepts the singleton/global-stop limitation: `stop` can affect the remote-control daemon rather than a process systemd can prove it owns.
22
+ 2. Use a Node runtime that supports `--experimental-strip-types` (Node `22.6+`) for these optional TypeScript recipes. Setup persists the exact `process.execPath` for systemd, and team-up passes the same absolute binary to the control pane.
23
+ 3. Close Codex Desktop, editor-owned Codex app servers, and interactive Codex sessions for this host before starting the headless service. The remote-control host is singleton; a desktop/app-server owner can make headless `start` fail with `connection is errored`. Do not mix Mode B with the community Linux desktop workaround.
24
+ 4. Set global `approval_policy = "on-request"` in `~/.codex/config.toml` after making a private backup. The Android client applies this global value to new threads and can override daemon-only config. This affects all local Codex sessions; the lifecycle preflight verifies the effective redacted `codex doctor --json` value and refuses `never`.
25
+ 5. Keep pairing codes, credentials, auth files, remote-control URLs, approval transcripts, and screenshots **out of Git, documentation, plans, test fixtures, and logs**. Pairing output stays in the operator's terminal.
26
+ 6. Run the non-mutating compatibility evidence. It confirms only advertised static capabilities and configured approval posture; it does not prove daemon ownership, pairing, session root, contract loading, approval delivery, or health.
27
+
28
+ ```bash
29
+ CODEX="$(command -v codex)"
30
+ "$CODEX" --version
31
+ "$CODEX" remote-control --help
32
+ "$CODEX" remote-control start --help
33
+ "$CODEX" remote-control stop --help
34
+ "$CODEX" remote-control pair --help
35
+ "$CODEX" doctor --json # redacted; preflight requires approval policy OnRequest
36
+ node --experimental-strip-types scripts/codex-remote-control.ts preflight --codex-bin "$CODEX"
37
+ ```
38
+
39
+ **Compatibility stop condition:** if the version is not `0.144.x`, a required subcommand is absent, or `on-request` plus `workspace-write` cannot be demonstrated for this remote-control path, stop. Do not use guessed flags, a port, or a fallback launcher.
40
+
41
+ The loading mechanism uses a managed runtime contract at `$HOME/.local/state/agent-fleet/codex-conductor/workspace/AGENTS.md`, copied from canonical `codex/CONDUCTOR.md`. A fresh thread must prove that managed copy was loaded and that any mobile writable root remains inside the external user-state runtime container; cwd and environment markers alone remain insufficient.
42
+
43
+ ## Lifecycle
44
+
45
+ Run these recipes from the repository root. The helper rejects unsafe scope, invalid paths, unsupported Codex versions, and mismatched singleton configuration.
46
+
47
+ ```bash
48
+ just conductor-codex-setup docs --project af
49
+ ```
50
+
51
+ The recipe resolves `codex`, the real repository root, and `$HOME/.pi/coms`, derives the isolated identity `codex-docs-conductor`, creates `$HOME/.local/state/agent-fleet/codex-conductor/workspace` outside the checkout and refreshes its owned contract copy with the absolute validated wrapper path. The lower-level `scripts/codex-remote-control.ts setup` command remains available for explicit integrations.
52
+
53
+ `setup` preflights, writes non-secret owned files, reloads user systemd, and enables the service. It does **not** pair or start it. The owned paths are:
54
+
55
+ - `~/.config/agent-fleet/codex-remote-control.json` (mode-restricted, non-secret configuration, including the external runtime directory)
56
+ - `~/.config/systemd/user/agent-fleet-codex-remote-control.service`
57
+ - `~/.local/state/agent-fleet/codex-conductor/workspace/AGENTS.md` (managed runtime copy)
58
+
59
+ The unit is `Type=oneshot` with `RemainAfterExit=yes`, has no `Restart=` policy, uses the dedicated scratch directory as daemon `WorkingDirectory` (the verified mobile client broadens its managed root only to the runtime-only parent container), and runs preflight immediately before `remote-control start`. Start passes the verified `approval_policy="on-request"`, `sandbox_mode="workspace-write"`, and one `sandbox_workspace_write.writable_roots` entry for the validated coms directory. `ExecStopPost` uses the capability-checked stop path even after a failed `ExecStart`. A mobile managed profile can remain narrower, so the exact wrapper `send` must request and receive phone approval before its first execution. The unit makes no foreground, PID, port, or readiness claim.
60
+
61
+ ### Pair — human interaction required
62
+
63
+ Pair the mobile client manually in an interactive operator TTY, after setup. Any displayed pairing code is short-lived secret material:
64
+
65
+ ```bash
66
+ just conductor-codex-pair
67
+ ```
68
+
69
+ Do not pipe, tee, capture, transcribe, screenshot, or commit the output. Never put pairing material or Codex credentials in the unit or config.
70
+
71
+ ### Start, status, and conductor launch
72
+
73
+ ```bash
74
+ just conductor-codex-start
75
+ just conductor-codex-status
76
+ just conductor-codex docs --project af
77
+ ```
78
+
79
+ `status` reports only requested systemd state. Actual usability must be checked from the paired client, without inventing a network probe. The control pane similarly reports requested state only. Legacy `conductor-codex-pilot*` aliases remain available for the initial 0.144.x rollout.
80
+
81
+ ### Use with `hub-team` and Android
82
+
83
+ The service does not start peers. Launch a hub/team in the exact project stored by setup:
84
+
85
+ ```bash
86
+ just hub-team docs --project af
87
+ ```
88
+
89
+ Do not also run `just conductor-codex docs --project af` for the same team unless a second peer set is intentional. `conductor-codex` is the alternative control-pane-plus-team layout when no hub is needed.
90
+
91
+ In ChatGPT Android, open the paired Remote Control host and create a fresh thread using:
92
+
93
+ ```text
94
+ $HOME/.local/state/agent-fleet/codex-conductor/workspace
95
+ ```
96
+
97
+ Do not start a local `codex` process as a substitute for the Android flow. Ask the thread to load its `AGENTS.md`, run one fresh wrapper list, and request approval once if needed. The managed contract contains the validated absolute wrapper path; do not reconstruct it or invoke `coms-cli` directly. For a send, first confirm the listed peer and exact bounded task conversationally, then approve the one displayed wrapper command. A denial stops without retry or side effect.
98
+
99
+ Example read-only delegation:
100
+
101
+ ```text
102
+ List peers once. If researcher is visible, ask me to confirm:
103
+ "Inspect the current implementation and return findings with file:line evidence; do not edit files."
104
+ After confirmation, request approval for the exact wrapper send once.
105
+ ```
106
+
107
+ ### Stop, recovery, and reconfiguration
108
+
109
+ ```bash
110
+ just conductor-codex-stop
111
+ just conductor-codex-recover
112
+ ```
113
+
114
+ Use recovery when the unit says `active (exited)` but the paired client is unavailable, or when an `ExecStart` failure left the unit in `failed`. It is an explicit operator-confirmed systemd stop/reset/preflight/start path, not a health probe. Plain `start` still refuses `failed` and directs the operator to recovery or uninstall. Stop and emergency stop safely clear a confirmed `failed` state; other ambiguous states refuse rather than guessing.
115
+
116
+ To change the configured scope—or to upgrade an earlier in-checkout pilot runtime to the external user-state boundary—use `reconfigure` with the complete validated setup arguments, then explicitly stop/start as required. Do not edit the unit or config by hand:
117
+
118
+ ```bash
119
+ just conductor-codex-reconfigure docs --project af
120
+ ```
121
+
122
+ ### Stale Codex send lock
123
+
124
+ A crash or `SIGKILL` can leave `~/.pi/coms/locks/codex-send.lock`. Automatic removal is intentionally forbidden because removing a live lock could permit concurrent sends. When the wrapper reports a held-or-stale lock:
125
+
126
+ 1. Do not retry or start another delegation.
127
+ 2. Inspect the non-secret JSON metadata (`started_at`, `project`, `name`, and advisory `pid`) without copying it into repository artifacts.
128
+ 3. Confirm in the mobile thread that no wrapper command is still running. A host-side `kill -0` check is insufficient because remote commands may use a different PID namespace.
129
+ 4. Wait beyond the configured send timeout. If ownership remains uncertain, stop the user service and confirm that no delegation is active.
130
+ 5. Only then remove that one exact lock file manually and restart/recover the service if it was stopped.
131
+
132
+ Never use a wildcard cleanup or remove project spools as part of lock recovery.
133
+
134
+ ### Version drift: emergency stop and uninstall
135
+
136
+ If normal preflight fails after Codex version/capability drift, normal start/stop/recovery remains blocked. The only exception is an explicit emergency stop, which first proves that the currently installed CLI still advertises the exact `remote-control stop` capability:
137
+
138
+ ```bash
139
+ node --experimental-strip-types scripts/codex-remote-control.ts emergency-stop \
140
+ --confirm emergency-stop-confirmed
141
+ ```
142
+
143
+ If that capability is absent, restore a supported `0.144.x` CLI before stopping or uninstalling. Never substitute a guessed stop command.
144
+
145
+ Uninstall is explicit, operates only on the owned unit/config, accepts and clears a confirmed `failed` state, resets the loaded unit before deleting it, disables the service, reloads user systemd, and leaves Codex authentication and pairing state untouched:
146
+
147
+ ```bash
148
+ just conductor-codex-uninstall
149
+ # After version drift, use the lower-level helper only if the exact current
150
+ # stop capability is proved:
151
+ node --experimental-strip-types scripts/codex-remote-control.ts uninstall \
152
+ --confirm operator-confirmed --emergency-confirm emergency-stop-confirmed
153
+ ```
154
+
155
+ Repository rollback does not stop or uninstall an already installed user service. If ownership is ambiguous, stop and review; do not remove files or use a broad manual cleanup. The scratch directory is retained if it contains operator-visible files; inspect it before removing it manually. After stopping/uninstalling the conductor, the operator may restore the private pre-change `config.toml` backup if `on-request` is not wanted for other Codex sessions.
156
+
157
+ ## Verified live behavior
158
+
159
+ The Linux/Android live gate passed with CLI `0.144.6`: the managed unit completed start/stop/restart, manual pairing connected the phone, a fresh mobile thread loaded the original parent contract before workspace isolation, and the wrapper listed the `af` pool despite the remote PID namespace. The human confirmed one bounded delegation and separately approved the exact elevated wrapper command; `documenter` replied `Pilot acknowledged. No files changed.` A second approval was denied, producing no researcher message and no lock. The lock was absent after completion, and closing the control workspace did not stop the service.
160
+
161
+ Post-review live hardening passed on Android: because Codex 0.144.x can broaden the managed root to the runtime container parent regardless of daemon cwd, the entire container now lives under user state outside the checkout. A fresh Android thread used `$HOME/.local/state/agent-fleet/codex-conductor/workspace`, loaded its managed `AGENTS.md`, requested one approval for the rendered absolute list wrapper, listed `documenter` and `researcher`, and performed no edit or send.
162
+
163
+ Remote threads use only `scripts/codex-conductor.ts` from the dedicated scratch workspace. It reads owned scope, pins the real coms directory, and refuses repository/project/name/timeout overrides. **Human interaction remains required** twice for every send: first to confirm the freshly listed recipient/task conversationally, then to approve the exact wrapper command through Codex's `on-request` approval. The command must request escalation before its first execution because coms state and Unix sockets are outside the selected workspace.
164
+
165
+ ## Related documentation
166
+
167
+ - [Experimental implementation plan](../plans/codex-remote-conductor.md) — gates and acceptance criteria.
168
+ - [Canonical Codex conductor contract](../codex/CONDUCTOR.md) — bounded outbound delegation rules.
169
+ - [Hermes/coms bridge](coms-hermes-bridge.md) — inbound human questions and Hermes conductor boundary.
170
+ - [Architecture](ARCHITECTURE.md) — ownership of Pi, Herdr, coms, and external conductors.