@chankov/agent-fleet 0.0.1 → 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 (65) 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/model-profiles.yaml +12 -12
  6. package/.pi/agents/peers.yaml +26 -22
  7. package/.pi/agents/teams.yaml +2 -2
  8. package/.pi/harnesses/agent-hub/README.md +57 -4
  9. package/.pi/harnesses/agent-hub/index.ts +236 -80
  10. package/.pi/harnesses/agent-hub/research-retention.js +34 -0
  11. package/.pi/harnesses/ask-user-remote/README.md +8 -0
  12. package/.pi/harnesses/ask-user-remote/index.ts +41 -1
  13. package/.pi/harnesses/coms/README.md +11 -0
  14. package/.pi/prompts/doctor-agent-fleet.md +1 -1
  15. package/.pi/prompts/setup-agent-fleet.md +4 -4
  16. package/README.md +133 -354
  17. package/agents/architect.md +4 -2
  18. package/agents/bowser.md +2 -1
  19. package/agents/builder.md +3 -2
  20. package/agents/code-reviewer.md +7 -7
  21. package/agents/deep-researcher.md +3 -3
  22. package/agents/documenter.md +3 -1
  23. package/agents/orchestrator.md +5 -3
  24. package/agents/plan-reviewer.md +5 -5
  25. package/agents/planner.md +7 -7
  26. package/agents/releaser.md +3 -1
  27. package/agents/researcher.md +3 -3
  28. package/agents/security-auditor.md +7 -7
  29. package/agents/test-engineer.md +5 -5
  30. package/agents/web-debugger.md +3 -3
  31. package/agents/web-performance-auditor.md +3 -3
  32. package/bin/snapshot-version.js +17 -1
  33. package/codex/CONDUCTOR.md +148 -0
  34. package/docs/ARCHITECTURE.md +165 -0
  35. package/docs/agent-fleet-setup.md +1 -0
  36. package/docs/claude-code-coms-bridge.md +10 -0
  37. package/docs/codex-remote-conductor.md +170 -0
  38. package/docs/coms-hermes-bridge.md +121 -0
  39. package/docs/getting-started.md +14 -0
  40. package/docs/npm-install.md +2 -0
  41. package/docs/pi-extensions.md +16 -0
  42. package/docs/pi-setup.md +2 -0
  43. package/hermes/README.md +48 -0
  44. package/hermes/skills/hub-conductor/SKILL.md +84 -0
  45. package/hermes/skills/hub-liaison/SKILL.md +84 -0
  46. package/justfile +132 -15
  47. package/package.json +10 -3
  48. package/scripts/codex-conductor.ts +41 -0
  49. package/scripts/codex-remote-control.ts +167 -0
  50. package/scripts/coms-cli.ts +311 -199
  51. package/scripts/coms-hermes-bridge.ts +8 -4
  52. package/scripts/lib/codex-conductor.ts +88 -0
  53. package/scripts/lib/codex-remote-control.ts +480 -0
  54. package/scripts/lib/coms-envelope.ts +51 -6
  55. package/scripts/lib/herdr-layout.ts +35 -7
  56. package/scripts/lib/hermes-bridge-core.ts +4 -4
  57. package/scripts/lib/spawn-stagger.ts +101 -0
  58. package/scripts/lib/team-project.ts +112 -3
  59. package/scripts/lib/team-snapshot.ts +3 -2
  60. package/scripts/team-snapshot.ts +23 -6
  61. package/scripts/team-up.ts +106 -18
  62. package/skills/guided-workspace-setup/SKILL.md +123 -97
  63. package/skills/guided-workspace-setup/companion-manifest.json +33 -0
  64. package/skills/peer-coms/SKILL.md +9 -0
  65. package/systemd/user/agent-fleet-codex-remote-control.service.in +23 -0
@@ -0,0 +1,84 @@
1
+ ---
2
+ name: hub-conductor
3
+ description: Conducts local pi hub-team peers from Hermes through coms-cli list/send --await, while preserving no-herdr and pool-scope damage-control boundaries.
4
+ ---
5
+
6
+ # Hub Conductor
7
+
8
+ ## Overview
9
+
10
+ You are the human-facing conductor for a local pi coms pool. Your job is to decompose the human's request, discover live hub-team peers, delegate bounded tasks through `scripts/coms-cli.ts`, wait for results, and synthesize a final answer.
11
+
12
+ This is conductor-side orchestration only: the existing coms CLI is the bridge. You do not need a daemon or standing Hermes peer to ask pi peers for work.
13
+
14
+ ## When to Use
15
+
16
+ Use this skill when:
17
+
18
+ - the human asks Hermes to coordinate pi hub-team peers;
19
+ - a task benefits from parallel specialist work such as research, implementation, docs, review, or testing;
20
+ - you need to inspect which local peers are alive before deciding who should do what;
21
+ - a previous peer response needs follow-up, retry, or synthesis.
22
+
23
+ Do not use it for single-step work Hermes can safely complete alone without peer help.
24
+
25
+ ## Process
26
+
27
+ 1. Identify the repository root and set a shell variable for it when useful:
28
+
29
+ ```bash
30
+ REPO=/home/nchankov/repos/agent-fleet
31
+ ```
32
+
33
+ 2. Discover live peers in the current coms project:
34
+
35
+ ```bash
36
+ node --experimental-strip-types "$REPO/scripts/coms-cli.ts" list
37
+ ```
38
+
39
+ Use `--project <name>` when the human or launch recipe specifies a non-default project.
40
+
41
+ 3. Choose peers by their listed name and purpose. Send bounded, self-contained prompts that include the expected deliverable and any acceptance assertions the peer must prove.
42
+
43
+ 4. Delegate with an explicit timeout and wait for the response:
44
+
45
+ ```bash
46
+ node --experimental-strip-types "$REPO/scripts/coms-cli.ts" send <peer-name> \
47
+ "<bounded task; include required output and evidence>" \
48
+ --await --timeout 300000
49
+ ```
50
+
51
+ Use a longer timeout for build/test/review tasks when needed. Every `send --await` must include `--timeout <ms>`.
52
+
53
+ 5. If a peer times out or is missing, retry at most once when the task still matters. Otherwise report that peer as unavailable and continue with the best available evidence.
54
+
55
+ 6. Synthesize peer outputs for the human. Name which peers were asked, what each returned, what evidence supports the result, and what remains unproven.
56
+
57
+ 7. For inbound conversational requests, answer directly in chat after any peer delegation; keep the final response self-contained because the human sees your synthesis, not the peer transcript.
58
+
59
+ ## Hard Boundaries
60
+
61
+ - **Advisory contract only.** This skill runs in an external Hermes process. Pi damage-control wraps Pi tool calls, not Hermes; this contract and any human confirmation reduce risk but do not provide an OS command allowlist or technical enforcement.
62
+ - **No herdr driving.** Do not run `herdr pane`, `herdr workspace`, pane lifecycle commands, workspace lifecycle commands, or any command that creates, closes, restarts, or drives panes. Rationale: fleet lifecycle belongs to the human/orchestrator so the `.pi/damage-control-rules.yaml` model remains intact and Hermes cannot accidentally destroy or commandeer active work.
63
+ - **Pool scope only.** Operate only through peers visible in the current project coms pool (`coms-cli list`, then `coms-cli send ... --await`). Do not widen to unrelated projects, global registries, hidden explicit peers, or external agent pools unless the human explicitly starts that topology and names the target project. Rationale: coms pool boundaries keep delegation auditable and prevent cross-project leakage.
64
+ - **No secret or bulk-data relay.** Send bounded prompts and path references, not secrets or whole-file dumps. Rationale: peers need task context, not uncontrolled data replication.
65
+
66
+ ## Red Flags
67
+
68
+ - Running or proposing `herdr` pane/workspace commands yourself.
69
+ - Sending to a peer that was not shown by `coms-cli list` for the intended project.
70
+ - Omitting `--await` or `--timeout` for delegated work that the human expects you to synthesize.
71
+ - Retrying repeatedly after a timeout instead of one retry then reporting the gap.
72
+ - Treating a peer's prose success claim as proof when it lacks named evidence.
73
+ - Expanding beyond the repository/project pool without explicit human direction.
74
+
75
+ ## Verification
76
+
77
+ Before reporting done, check:
78
+
79
+ - [ ] `coms-cli list` was run for the intended project and the selected peers were visible.
80
+ - [ ] Every delegated task used `coms-cli send <peer> ... --await --timeout <ms>`.
81
+ - [ ] Peer responses were synthesized with named evidence and unresolved gaps.
82
+ - [ ] At most one retry was used for any timeout or missing peer.
83
+ - [ ] No `herdr` command was run or requested by Hermes.
84
+ - [ ] No delegation crossed outside the intended project coms pool.
@@ -0,0 +1,84 @@
1
+ ---
2
+ name: hub-liaison
3
+ description: On any Telegram HUB-Q reply ALWAYS write the pi hub bridge answer file — even when the thread shows cancel/closed/timeout notes; the bridge classifies late answers itself. Use when a Telegram message replies to or contains a [HUB-Q:<qid>] marker.
4
+ ---
5
+
6
+ # Hub Liaison
7
+
8
+ ## Overview
9
+
10
+ You are the gateway-side liaison between a human Telegram reply and the pi `user-remote` coms peer. When a Telegram message correlates to a hub question marker, write one answer file for the bridge. Do not answer by paraphrasing in chat only; the bridge only consumes the file.
11
+
12
+ ## When to Use
13
+
14
+ Use this skill when an incoming Telegram message either:
15
+
16
+ - replies to a message that contains `[HUB-Q:<qid>]`, or
17
+ - contains the explicit prefix `HUB-Q:<qid>:`.
18
+
19
+ `<qid>` must be a 26-character Crockford ULID matching:
20
+
21
+ ```text
22
+ ^[0-9A-HJKMNP-TV-Z]{26}$
23
+ ```
24
+
25
+ Ignore non-matching messages. If a message is ambiguous and there is more than one plausible question marker, ask the human to reply to the original question or use `HUB-Q:<qid>: <answer>`.
26
+
27
+ ## Correlation Rules
28
+
29
+ 1. Prefer the qid from the replied-to message marker: `[HUB-Q:<qid>]`.
30
+ 2. If there is no replied-to marker, accept a message prefix exactly shaped as `HUB-Q:<qid>: <answer>`.
31
+ 3. The answer text is the Telegram reply body, except for prefix-form messages where the answer text is everything after `HUB-Q:<qid>:`.
32
+ 4. Preserve the human's answer text exactly except for trimming leading/trailing whitespace around the extracted answer.
33
+ 5. Never invent or alter the qid. If the qid does not match the regex above, do not write a file.
34
+ 6. If a human message contains or replies to a `[HUB-Q:<qid>]` question, write the answer file even when the thread also contains a cancel/closed note or the user appears to be answering after cancellation. Do not decide whether the question is still open; the bridge validates pending vs. late and sends the appropriate polite closed note.
35
+
36
+ ## Process
37
+
38
+ 1. Extract `<qid>` and `<answer>` using the correlation rules.
39
+ 2. Confirm `<answer>` is non-empty. If it is empty, ask the human for the answer text.
40
+ 3. Do not suppress the write because the question appears canceled, closed, timed out, or answered locally. That state belongs to the bridge, not this skill.
41
+ 4. Write exactly this file path, replacing `<qid>` with the extracted qid:
42
+
43
+ ```text
44
+ ~/.pi/coms/hermes-bridge/questions/<qid>.answer.json
45
+ ```
46
+
47
+ 5. The JSON content must use exactly these fields:
48
+
49
+ ```json
50
+ {
51
+ "qid": "<qid>",
52
+ "answer": "<answer>",
53
+ "answered_by": "telegram:<user>",
54
+ "at": "<ISO timestamp>"
55
+ }
56
+ ```
57
+
58
+ - `qid`: the extracted 26-character qid.
59
+ - `answer`: the extracted answer text.
60
+ - `answered_by`: `telegram:<user>`, using the Telegram username/handle when available; otherwise use a stable Telegram sender identifier.
61
+ - `at`: the current ISO-8601 timestamp.
62
+
63
+ 6. After writing the file, briefly confirm to the human that the answer was delivered for `HUB-Q:<qid>`; if it was late, the bridge will handle the closed-question response.
64
+
65
+ ## Write Boundary
66
+
67
+ Hard rule: never write outside `~/.pi/coms/hermes-bridge/questions/` for this skill. Do not create, edit, or delete files elsewhere. The bridge validates and consumes only `~/.pi/coms/hermes-bridge/questions/<qid>.answer.json`; any other path is outside the private wire contract.
68
+
69
+ ## Red Flags
70
+
71
+ - A message has no `[HUB-Q:<qid>]` marker and no `HUB-Q:<qid>:` prefix.
72
+ - The qid fails `^[0-9A-HJKMNP-TV-Z]{26}$`.
73
+ - The answer text is empty after extraction.
74
+ - The requested write path is not under `~/.pi/coms/hermes-bridge/questions/`.
75
+ - The human asks you to modify bridge logs, registry files, or any unrelated project files.
76
+ - Suppressing an otherwise correlated answer because a cancel/closed note is visible in the thread.
77
+
78
+ ## Verification
79
+
80
+ - [ ] The qid came from `[HUB-Q:<qid>]` or `HUB-Q:<qid>:` and matches the regex.
81
+ - [ ] The answer file path is exactly `~/.pi/coms/hermes-bridge/questions/<qid>.answer.json`.
82
+ - [ ] The JSON has exactly `qid`, `answer`, `answered_by`, and `at` with an ISO timestamp.
83
+ - [ ] No file outside `~/.pi/coms/hermes-bridge/questions/` was written.
84
+ - [ ] Correlated late/canceled answers were still written for the bridge to classify.
package/justfile CHANGED
@@ -20,6 +20,14 @@
20
20
  # >>> agent-fleet:harnesses — managed region (regenerated on upgrade; edits inside are overwritten) >>>
21
21
  set dotenv-load := true
22
22
 
23
+ # How recipes run the fleet TS scripts. The preserve-symlinks flags matter for
24
+ # symlink installs (guided-workspace-setup's `symlink` method): there
25
+ # scripts/*.ts are links whose realpath sits under .pi/npm/node_modules/, and
26
+ # Node refuses --experimental-strip-types for anything under node_modules once
27
+ # paths are realpath'd. Keeping symlink paths avoids that; copy installs are
28
+ # unaffected (the fleet scripts import only relative paths + node builtins).
29
+ node_ts := "node --experimental-strip-types --preserve-symlinks --preserve-symlinks-main"
30
+
23
31
  # List all recipes
24
32
  default:
25
33
  @just --list
@@ -67,65 +75,174 @@ hub-solo *args:
67
75
  # Internal helper for team-up: launch a reusable coms peer (coms + compact-and-continue + a persona).
68
76
  # Prints a colored identity banner (peer name + persona purpose) before pi starts,
69
77
  # so every pane announces who lives in it — works in any terminal, herdr or not.
78
+ # AGENT_FLEET_SPAWN_DELAY (set per pane by team-up when the stored pi OAuth token
79
+ # is stale) delays this pi's boot so a sibling pane can refresh the token first —
80
+ # simultaneous boots race on the auth.json lock and lose their logins.
70
81
  # Hidden from `just --list` because recipes prefixed with `_` are private.
71
82
  _peer persona name="" model="" session="" project="default":
72
- node --experimental-strip-types scripts/peer-banner.ts {{persona}} {{name}} 2>/dev/null || true; persona_path="agents/{{persona}}.md"; if [ ! -f "$persona_path" ]; then persona_path=".pi/agents/{{persona}}.md"; fi; pi -e .pi/harnesses/coms/index.ts -e .pi/extensions/compact-and-continue/index.ts --project {{project}} --append-system-prompt "$persona_path" {{ if name != "" { "--name " + name } else { "" } }} {{ if model != "" { "--model " + model } else { "" } }} {{ if session != "" { "--session " + session } else { "" } }}
83
+ d="${AGENT_FLEET_SPAWN_DELAY:-0}"; if [ "$d" != "0" ]; then echo "⏳ waiting ${d}s for the pi auth pre-warm (stale OAuth token)"; sleep "$d"; fi; {{node_ts}} scripts/peer-banner.ts {{persona}} {{name}} 2>/dev/null || true; persona_path="agents/{{persona}}.md"; if [ ! -f "$persona_path" ]; then persona_path=".pi/agents/{{persona}}.md"; fi; pi -e .pi/harnesses/coms/index.ts -e .pi/extensions/compact-and-continue/index.ts --project {{project}} --append-system-prompt "$persona_path" {{ if name != "" { "--name " + name } else { "" } }} {{ if model != "" { "--model " + model } else { "" } }} {{ if session != "" { "--session " + session } else { "" } }}
73
84
 
74
85
  # Like _peer, but also loads extra always-on extensions (comma-separated names under
75
86
  # .pi/extensions/) into the peer process — e.g. a chrome-devtools-mcp browser-debug peer
76
87
  # whose `chrome_devtools__*` tools a normal --no-extensions subagent could not get.
77
88
  _peer-plus extensions persona name="" model="" session="" project="default":
78
- node --experimental-strip-types scripts/peer-banner.ts {{persona}} {{name}} 2>/dev/null || true; persona_path="agents/{{persona}}.md"; if [ ! -f "$persona_path" ]; then persona_path=".pi/agents/{{persona}}.md"; fi; extra=""; old_ifs="$IFS"; IFS=','; for x in {{extensions}}; do x="$(echo "$x" | xargs)"; if [ -n "$x" ]; then extra="$extra -e .pi/extensions/$x/index.ts"; fi; done; IFS="$old_ifs"; pi -e .pi/harnesses/coms/index.ts -e .pi/extensions/compact-and-continue/index.ts $extra --project {{project}} --append-system-prompt "$persona_path" {{ if name != "" { "--name " + name } else { "" } }} {{ if model != "" { "--model " + model } else { "" } }} {{ if session != "" { "--session " + session } else { "" } }}
89
+ d="${AGENT_FLEET_SPAWN_DELAY:-0}"; if [ "$d" != "0" ]; then echo "⏳ waiting ${d}s for the pi auth pre-warm (stale OAuth token)"; sleep "$d"; fi; {{node_ts}} scripts/peer-banner.ts {{persona}} {{name}} 2>/dev/null || true; persona_path="agents/{{persona}}.md"; if [ ! -f "$persona_path" ]; then persona_path=".pi/agents/{{persona}}.md"; fi; extra=""; old_ifs="$IFS"; IFS=','; for x in {{extensions}}; do x="$(echo "$x" | xargs)"; if [ -n "$x" ]; then extra="$extra -e .pi/extensions/$x/index.ts"; fi; done; IFS="$old_ifs"; pi -e .pi/harnesses/coms/index.ts -e .pi/extensions/compact-and-continue/index.ts $extra --project {{project}} --append-system-prompt "$persona_path" {{ if name != "" { "--name " + name } else { "" } }} {{ if model != "" { "--model " + model } else { "" } }} {{ if session != "" { "--session " + session } else { "" } }}
79
90
 
80
91
  # Internal helper for team-up: a `runner: claude-code` peer — interactive
81
92
  # Claude Code plus its coms bridge (scripts/coms-claude-bridge.ts) in ONE pane.
82
93
  # The bridge registers the pane as coms peer <name>; the trailing session
83
94
  # positional maps to `claude --resume <id>` for team-resume.
84
95
  _claude-peer name model="" session="" project="default":
85
- node --experimental-strip-types scripts/coms-claude-bridge.ts --name {{name}} --project {{project}} & bridge_pid=$!; trap 'kill $bridge_pid 2>/dev/null' EXIT; claude {{ if model != "" { "--model " + model } else { "" } }} {{ if session != "" { "--resume " + session } else { "" } }}
96
+ {{node_ts}} scripts/coms-claude-bridge.ts --name {{name}} --project {{project}} & bridge_pid=$!; trap 'kill $bridge_pid 2>/dev/null' EXIT; claude {{ if model != "" { "--model " + model } else { "" } }} {{ if session != "" { "--resume " + session } else { "" } }}
97
+
98
+ # The team recipes below take the team as a positional arg (defaults to "full")
99
+ # and pass everything after it straight to the script.
100
+ #
101
+ # Herdr workspace labels are auto-scoped to the CHECKOUT: <worktree-tag>-<mode>-<team>
102
+ # where the tag is the last dot-segment of this directory's basename (main.wt2 →
103
+ # wt2, ringithub.end2 → end2, plain agent-fleet → agent-fleet). So the same team
104
+ # launched from different repos/worktrees gets its own workspace (wt2-hub-plan vs
105
+ # end2-hub-plan) instead of colliding on a shared label. This is not global
106
+ # uniqueness: unrelated checkouts with the same basename/final dot-segment can
107
+ # still collide. Existing-workspace refusal prevents clobbering; it does not
108
+ # prove the labels are unique.
109
+ #
110
+ # `--project <name>` is a SEPARATE axis: it scopes the coms peer POOL. Without it
111
+ # every peer lands in the shared "default" pool, where teams launched from OTHER
112
+ # repos collide (name suffixing like code-reviewer2, dispatches routed to the
113
+ # wrong repo's pane). IMPORTANT: the flag form is `--project af`; `project=af` is
114
+ # NOT a flag — just treats bare key=value args as variable overrides, so it is
115
+ # silently ignored and the team still joins the "default" pool.
86
116
 
87
117
  # Team up: spawn every peer of a team from .pi/agents/peers.yaml into a herdr
88
118
  # workspace (one tiled pane per peer). Requires a running herdr server.
89
- # Positional arg: team (defaults to "full"). e.g. just team-up full
119
+ # e.g. just team-up full
120
+ # just team-up review --project af
90
121
  team-up team="full" *args:
91
- node --experimental-strip-types scripts/team-up.ts --team {{team}} {{args}}
122
+ {{node_ts}} scripts/team-up.ts --team {{team}} {{args}}
92
123
 
93
124
  # Team up (dry run): print the resolved layout + per-peer commands without touching herdr.
94
- # e.g. just team-up-dry team="full"
125
+ # e.g. just team-up-dry full
126
+ # just team-up-dry review --project af
95
127
  team-up-dry team="full" *args:
96
- node --experimental-strip-types scripts/team-up.ts --team {{team}} --dry-run {{args}}
128
+ {{node_ts}} scripts/team-up.ts --team {{team}} --dry-run {{args}}
97
129
 
98
130
  # Hub + team in ONE herdr workspace: the guarded hub (`just hub`) in a larger
99
- # main pane, the team's peers tiled beside it. e.g. just hub-team docs
131
+ # main pane, the team's peers tiled beside it.
132
+ # e.g. just hub-team docs
133
+ # just hub-team review --project af
100
134
  hub-team team="full" *args:
101
- node --experimental-strip-types scripts/team-up.ts --team {{team}} --hub {{args}}
135
+ {{node_ts}} scripts/team-up.ts --team {{team}} --hub {{args}}
102
136
 
103
137
  # Hub + team (dry run): print the combined layout without touching herdr.
138
+ # e.g. just hub-team-dry review --project af
104
139
  hub-team-dry team="full" *args:
105
- node --experimental-strip-types scripts/team-up.ts --team {{team}} --hub --dry-run {{args}}
140
+ {{node_ts}} scripts/team-up.ts --team {{team}} --hub --dry-run {{args}}
106
141
 
107
142
  # Hermes conductor + team in ONE herdr workspace: Hermes dev profile in a conductor pane,
108
143
  # the team's peers tiled beside it. Hermes delegates via coms-cli and never drives herdr.
144
+ # e.g. just conductor docs --project af
109
145
  conductor team="full" *args:
110
- node --experimental-strip-types scripts/team-up.ts --team {{team}} --conductor {{args}}
146
+ {{node_ts}} scripts/team-up.ts --team {{team}} --conductor {{args}}
111
147
 
112
148
  # Hermes conductor + team (dry run): print the combined layout without touching herdr.
149
+ # e.g. just conductor-dry docs --project af
113
150
  conductor-dry team="full" *args:
114
- node --experimental-strip-types scripts/team-up.ts --team {{team}} --conductor --dry-run {{args}}
151
+ {{node_ts}} scripts/team-up.ts --team {{team}} --conductor --dry-run {{args}}
152
+
153
+ # Experimental Codex remote-control conductor lifecycle (verified with CLI
154
+ # 0.144.x). Pairing stays interactive and its short-lived code must never be
155
+ # captured. The user service is singleton across repos/projects.
156
+ # e.g. just conductor-codex-setup docs --project af
157
+ conductor-codex-setup team="full" *args:
158
+ {{node_ts}} scripts/codex-remote-control.ts setup-conductor --codex-bin "$(command -v codex)" --repo-root "$(pwd -P)" --coms-dir "$HOME/.pi/coms" --team "{{team}}" --timeout 300000 {{args}}
159
+
160
+ conductor-codex-reconfigure team="full" *args:
161
+ {{node_ts}} scripts/codex-remote-control.ts reconfigure-conductor --codex-bin "$(command -v codex)" --repo-root "$(pwd -P)" --coms-dir "$HOME/.pi/coms" --team "{{team}}" --timeout 300000 {{args}}
162
+
163
+ conductor-codex-pair:
164
+ {{node_ts}} scripts/codex-remote-control.ts pair
165
+
166
+ conductor-codex-start:
167
+ {{node_ts}} scripts/codex-remote-control.ts start
168
+
169
+ conductor-codex-status:
170
+ {{node_ts}} scripts/codex-remote-control.ts status
171
+
172
+ conductor-codex-stop:
173
+ {{node_ts}} scripts/codex-remote-control.ts stop
174
+
175
+ conductor-codex-recover:
176
+ {{node_ts}} scripts/codex-remote-control.ts recover --confirm operator-confirmed
177
+
178
+ conductor-codex-uninstall:
179
+ {{node_ts}} scripts/codex-remote-control.ts uninstall --confirm operator-confirmed
180
+
181
+ # Codex conductor + team in one workspace. The root is a requested-state
182
+ # control pane; systemd owns the remote-control daemon.
183
+ # e.g. just conductor-codex docs --project af
184
+ conductor-codex team="full" *args:
185
+ {{node_ts}} scripts/team-up.ts --team {{team}} --conductor codex {{args}}
186
+
187
+ conductor-codex-dry team="full" *args:
188
+ {{node_ts}} scripts/team-up.ts --team {{team}} --conductor codex --dry-run {{args}}
189
+
190
+ # Legacy pilot aliases retained for the 0.144.x experimental rollout.
191
+ # Setup/reconfigure resolve the selected binary and persist one validated
192
+ # repo/project/team/coms context.
193
+ # e.g. just conductor-codex-pilot-setup docs --project af
194
+ conductor-codex-pilot-setup team="full" *args:
195
+ {{node_ts}} scripts/codex-remote-control.ts setup-pilot --codex-bin "$(command -v codex)" --repo-root "$(pwd -P)" --coms-dir "$HOME/.pi/coms" --team "{{team}}" --timeout 300000 {{args}}
196
+
197
+ conductor-codex-pilot-reconfigure team="full" *args:
198
+ {{node_ts}} scripts/codex-remote-control.ts reconfigure-pilot --codex-bin "$(command -v codex)" --repo-root "$(pwd -P)" --coms-dir "$HOME/.pi/coms" --team "{{team}}" --timeout 300000 {{args}}
199
+
200
+ conductor-codex-pilot-pair:
201
+ {{node_ts}} scripts/codex-remote-control.ts pair
202
+
203
+ conductor-codex-pilot-start:
204
+ {{node_ts}} scripts/codex-remote-control.ts start
205
+
206
+ conductor-codex-pilot-status:
207
+ {{node_ts}} scripts/codex-remote-control.ts status
208
+
209
+ conductor-codex-pilot-stop:
210
+ {{node_ts}} scripts/codex-remote-control.ts stop
211
+
212
+ conductor-codex-pilot-recover:
213
+ {{node_ts}} scripts/codex-remote-control.ts recover --confirm operator-confirmed
214
+
215
+ conductor-codex-pilot-uninstall:
216
+ {{node_ts}} scripts/codex-remote-control.ts uninstall --confirm operator-confirmed
217
+
218
+ # Legacy pilot live aliases use the same verified implementation. The root pane
219
+ # is the lifecycle helper's foreground control pane, never a daemon command.
220
+ # e.g. just conductor-codex-pilot docs --project af
221
+ conductor-codex-pilot team="full" *args:
222
+ {{node_ts}} scripts/team-up.ts --team {{team}} --conductor codex {{args}}
223
+
224
+ # Legacy pilot dry-run alias.
225
+ # e.g. just conductor-codex-pilot-dry docs --project af
226
+ conductor-codex-pilot-dry team="full" *args:
227
+ {{node_ts}} scripts/team-up.ts --team {{team}} --conductor codex --dry-run {{args}}
115
228
 
116
229
  # Snapshot a RUNNING team's session refs to ~/.pi/team-snapshots/<team>.json
117
230
  # (team keeps running — take one proactively so a crash is resumable).
231
+ # A team launched with --project must snapshot with the same --project.
232
+ # e.g. just team-snapshot review --project af
118
233
  team-snapshot team="full" *args:
119
- node --experimental-strip-types scripts/team-snapshot.ts snapshot {{team}} {{args}}
234
+ {{node_ts}} scripts/team-snapshot.ts snapshot {{team}} {{args}}
120
235
 
121
236
  # Snapshot, then close the team workspace cleanly (peers get SIGTERM).
237
+ # e.g. just team-down review --project af
122
238
  team-down team="full" *args:
123
- node --experimental-strip-types scripts/team-snapshot.ts down {{team}} {{args}}
239
+ {{node_ts}} scripts/team-snapshot.ts down {{team}} {{args}}
124
240
 
125
241
  # Rebuild a team from its snapshot — each pi peer resumes its previous
126
242
  # conversation (`pi --session <ref>`); peers whose ref is gone start fresh.
243
+ # e.g. just team-resume review --project af
127
244
  team-resume team="full" *args:
128
- node --experimental-strip-types scripts/team-snapshot.ts resume {{team}} {{args}}
245
+ {{node_ts}} scripts/team-snapshot.ts resume {{team}} {{args}}
129
246
 
130
247
  # ---------------------------------------------------------------- coms (Pi-to-Pi messaging)
131
248
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chankov/agent-fleet",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Multi-agent fleet orchestration for coding agents. Pi as the primary runtime, Herdr as the workspace control plane, coms as the peer data plane, and Hermes for remote control — plus skills, personas, harnesses, and a guided setup CLI.",
5
5
  "keywords": [
6
6
  "ai",
@@ -59,11 +59,17 @@
59
59
  ".pi/damage-control-rules.yaml",
60
60
  "scripts/*.ts",
61
61
  "scripts/lib/*.ts",
62
+ "codex/",
63
+ "hermes/",
64
+ "systemd/",
62
65
  "justfile",
63
66
  "references/",
64
67
  "hooks/",
65
68
  "docs/agent-fleet-setup.md",
69
+ "docs/ARCHITECTURE.md",
70
+ "docs/codex-remote-conductor.md",
66
71
  "docs/claude-code-coms-bridge.md",
72
+ "docs/coms-hermes-bridge.md",
67
73
  "docs/pi-extensions.md",
68
74
  "docs/npm-install.md",
69
75
  "docs/skill-anatomy.md",
@@ -88,7 +94,7 @@
88
94
  "access": "public"
89
95
  },
90
96
  "scripts": {
91
- "test": "node bin/cli.js --version && node bin/cli.js --help && node bin/cli.js transform-persona --list --agent claude-code && node --test \"bin/test/*.test.js\" \".pi/harnesses/lib/herdr-client.test.ts\" \".pi/harnesses/lib/herdr-presence.test.ts\" \"scripts/lib/team-project.test.ts\" \"scripts/lib/herdr-layout.test.ts\" \"scripts/lib/fleet-extras.test.ts\" \"scripts/lib/team-snapshot.test.ts\" \"scripts/lib/coms-envelope.test.ts\" \"scripts/lib/claude-bridge-core.test.ts\" \"scripts/lib/hermes-bridge-core.test.ts\" \"scripts/coms-hermes-bridge.test.ts\" \".pi/harnesses/ask-user-remote/race-core.test.js\" \".pi/harnesses/ask-user-remote/index.test.ts\" \".pi/extensions/btw/state.test.js\" \".pi/harnesses/agent-hub/return-contract.test.js\" \".pi/harnesses/agent-hub/backend-policy.test.js\" \".pi/harnesses/agent-hub/artifacts.test.js\" \".pi/harnesses/agent-hub/scope-gate.test.js\" \".pi/harnesses/agent-hub/evidence-rules.test.js\" \".pi/harnesses/damage-control/shared.test.js\" \".pi/harnesses/damage-control/herdr-rules.test.js\" \".pi/harnesses/damage-control-continue/exemptions.test.js\"",
97
+ "test": "node bin/cli.js --version && node bin/cli.js --help && node bin/cli.js transform-persona --list --agent claude-code && node --test \"bin/test/*.test.js\" \".pi/harnesses/lib/herdr-client.test.ts\" \".pi/harnesses/lib/herdr-presence.test.ts\" \"scripts/coms-cli.test.ts\" \"scripts/lib/codex-conductor.test.ts\" \"scripts/lib/codex-remote-control.test.ts\" \"scripts/lib/team-project.test.ts\" \"scripts/lib/herdr-layout.test.ts\" \"scripts/lib/spawn-stagger.test.ts\" \"scripts/lib/fleet-extras.test.ts\" \"scripts/lib/team-snapshot.test.ts\" \"scripts/lib/coms-envelope.test.ts\" \"scripts/lib/claude-bridge-core.test.ts\" \"scripts/lib/hermes-bridge-core.test.ts\" \"scripts/coms-hermes-bridge.test.ts\" \".pi/harnesses/ask-user-remote/race-core.test.js\" \".pi/harnesses/ask-user-remote/index.test.ts\" \".pi/extensions/btw/state.test.js\" \".pi/harnesses/agent-hub/return-contract.test.js\" \".pi/harnesses/agent-hub/backend-policy.test.js\" \".pi/harnesses/agent-hub/artifacts.test.js\" \".pi/harnesses/agent-hub/scope-gate.test.js\" \".pi/harnesses/agent-hub/evidence-rules.test.js\" \".pi/harnesses/agent-hub/research-retention.test.js\" \".pi/harnesses/damage-control/shared.test.js\" \".pi/harnesses/damage-control/herdr-rules.test.js\" \".pi/harnesses/damage-control-continue/exemptions.test.js\"",
92
98
  "pack:dry": "npm pack --dry-run",
93
99
  "changeset": "changeset",
94
100
  "version:changeset": "node bin/force-patch-changesets.js && changeset version && npm install --package-lock-only --ignore-scripts --no-audit --no-fund && node bin/snapshot-version.js",
@@ -116,6 +122,7 @@
116
122
  ],
117
123
  "extensions": [
118
124
  "./.pi/harnesses/ask-user-remote/index.ts"
119
- ]
125
+ ],
126
+ "image": "https://raw.githubusercontent.com/chankov/agent-fleet/main/docs/assets/agent-hub-dashboard.png"
120
127
  }
121
128
  }
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env node
2
+ // Experimental external Codex conductor wrapper. It exposes no lifecycle,
3
+ // pairing, authentication, Herdr, or scope-override functionality.
4
+
5
+ import { spawnSync } from "node:child_process";
6
+ import * as fs from "node:fs";
7
+ import * as path from "node:path";
8
+ import { fileURLToPath } from "node:url";
9
+
10
+ import { buildConductorCommand, conductorProcessEnv, loadConductorContext, parseConductorArgs } from "./lib/codex-conductor.ts";
11
+ import { lifecyclePaths } from "./lib/codex-remote-control.ts";
12
+
13
+ function main(): void {
14
+ // Parse flags before config or filesystem access, then bind all scope from
15
+ // the owned configuration and the dedicated writable scratch directory.
16
+ const operation = parseConductorArgs(process.argv.slice(2));
17
+ const checkoutRoot = fs.realpathSync(path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."));
18
+ const context = loadConductorContext({
19
+ configPath: lifecyclePaths().configPath,
20
+ cwd: process.cwd(),
21
+ checkoutRoot,
22
+ });
23
+ const result = spawnSync(process.execPath, [
24
+ "--experimental-strip-types",
25
+ path.join(context.repoRoot, "scripts", "coms-cli.ts"),
26
+ ...buildConductorCommand(context, operation),
27
+ ], {
28
+ cwd: context.conductorCwd,
29
+ stdio: "inherit",
30
+ env: conductorProcessEnv(context),
31
+ });
32
+ if (result.error) throw result.error;
33
+ process.exitCode = result.status ?? 1;
34
+ }
35
+
36
+ try {
37
+ main();
38
+ } catch (error) {
39
+ console.error(error instanceof Error ? error.message : String(error));
40
+ process.exitCode = 1;
41
+ }
@@ -0,0 +1,167 @@
1
+ #!/usr/bin/env node
2
+ // Repository-side lifecycle CLI. It never pairs automatically and exposes no
3
+ // health, PID, or transport assumptions.
4
+
5
+ import * as os from "node:os";
6
+ import * as path from "node:path";
7
+
8
+ import {
9
+ CONFIG_MARKER,
10
+ EMERGENCY_STOP_CONFIRMATION,
11
+ emergencySystemdStop,
12
+ lifecyclePaths,
13
+ loadOwnedConfig,
14
+ preflight,
15
+ restart,
16
+ setup,
17
+ start,
18
+ status,
19
+ stop,
20
+ systemRunner,
21
+ uninstall,
22
+ unitStart,
23
+ unitStop,
24
+ validateConfig,
25
+ type LifecycleConfig,
26
+ } from "./lib/codex-remote-control.ts";
27
+
28
+ type Flag = "config" | "codex-bin" | "repo-root" | "coms-dir" | "project" | "team" | "name" | "timeout" | "home" | "confirm" | "emergency-confirm";
29
+ const FLAGS = new Set<Flag>(["config", "codex-bin", "repo-root", "coms-dir", "project", "team", "name", "timeout", "home", "confirm", "emergency-confirm"]);
30
+
31
+ function fail(message: string): never { throw new Error(message); }
32
+
33
+ function parse(argv: string[]): { command: string; flags: Map<Flag, string> } {
34
+ const command = argv[0];
35
+ if (!command) fail("Usage: codex-remote-control <preflight|setup|reconfigure|setup-conductor|reconfigure-conductor|setup-pilot|reconfigure-pilot|pair|start|stop|emergency-stop|status|restart|recover|uninstall|control-pane|unit-start|unit-stop>");
36
+ const flags = new Map<Flag, string>();
37
+ for (let i = 1; i < argv.length; i++) {
38
+ const raw = argv[i];
39
+ if (!raw.startsWith("--")) fail(`Unexpected argument: ${raw}`);
40
+ const flag = raw.slice(2) as Flag;
41
+ if (!FLAGS.has(flag)) fail(`Unknown flag: ${raw}`);
42
+ if (flags.has(flag)) fail(`${raw} may only be provided once`);
43
+ const value = argv[++i];
44
+ if (!value || value.startsWith("--")) fail(`${raw} requires a value`);
45
+ flags.set(flag, value);
46
+ }
47
+ return { command, flags };
48
+ }
49
+
50
+ function required(flags: Map<Flag, string>, flag: Flag): string {
51
+ return flags.get(flag) ?? fail(`--${flag} is required`);
52
+ }
53
+
54
+ function runtimeDir(flags: Map<Flag, string>): string {
55
+ return lifecyclePaths(flags.get("home")).runtimeDir;
56
+ }
57
+
58
+ function configFromFlags(flags: Map<Flag, string>): LifecycleConfig {
59
+ return validateConfig({
60
+ marker: CONFIG_MARKER,
61
+ codexBin: required(flags, "codex-bin"),
62
+ repoRoot: required(flags, "repo-root"),
63
+ runtimeDir: runtimeDir(flags),
64
+ comsDir: required(flags, "coms-dir"),
65
+ project: required(flags, "project"),
66
+ team: required(flags, "team"),
67
+ name: required(flags, "name"),
68
+ timeoutMs: Number(required(flags, "timeout")),
69
+ });
70
+ }
71
+
72
+ function conductorConfigFromFlags(flags: Map<Flag, string>): LifecycleConfig {
73
+ const team = required(flags, "team");
74
+ const project = flags.get("project") ?? "default";
75
+ return validateConfig({
76
+ marker: CONFIG_MARKER,
77
+ codexBin: required(flags, "codex-bin"),
78
+ repoRoot: required(flags, "repo-root"),
79
+ runtimeDir: runtimeDir(flags),
80
+ comsDir: required(flags, "coms-dir"),
81
+ project,
82
+ team,
83
+ name: `codex-${team}-conductor`,
84
+ timeoutMs: Number(required(flags, "timeout")),
85
+ });
86
+ }
87
+
88
+ function configPath(flags: Map<Flag, string>): string {
89
+ return flags.get("config") ?? lifecyclePaths(flags.get("home")).configPath;
90
+ }
91
+
92
+ function configured(flags: Map<Flag, string>): LifecycleConfig {
93
+ return loadOwnedConfig(configPath(flags));
94
+ }
95
+
96
+ function pair(config: LifecycleConfig): void {
97
+ const checked = preflight(config);
98
+ const result = systemRunner(checked.codexBin, ["remote-control", "pair"], { stdio: "inherit" });
99
+ if (result.code !== 0) fail(`codex remote-control pair failed (${result.code})`);
100
+ }
101
+
102
+ function controlPane(): void {
103
+ console.log("Codex control pane: displaying requested systemd state only; this is not daemon health.");
104
+ const report = () => console.log(status());
105
+ report();
106
+ const timer = setInterval(report, 5_000);
107
+ const close = () => clearInterval(timer);
108
+ process.once("SIGINT", close);
109
+ process.once("SIGTERM", close);
110
+ }
111
+
112
+ function main(): void {
113
+ const { command, flags } = parse(process.argv.slice(2));
114
+ switch (command) {
115
+ case "preflight": {
116
+ const config = flags.has("repo-root") ? configFromFlags(flags) : validateConfig({
117
+ marker: CONFIG_MARKER,
118
+ codexBin: required(flags, "codex-bin"),
119
+ repoRoot: process.cwd(), runtimeDir: lifecyclePaths().runtimeDir, comsDir: path.join(os.homedir(), ".pi", "coms"),
120
+ project: "default", team: "codex", name: "codex", timeoutMs: 300_000,
121
+ });
122
+ preflight(config);
123
+ console.log("Codex 0.144.x remote-control start|stop|pair preflight passed");
124
+ return;
125
+ }
126
+ case "setup":
127
+ case "reconfigure":
128
+ case "setup-conductor":
129
+ case "reconfigure-conductor":
130
+ case "setup-pilot":
131
+ case "reconfigure-pilot": {
132
+ const scoped = command.endsWith("-conductor") || command.endsWith("-pilot");
133
+ const paths = setup(scoped ? conductorConfigFromFlags(flags) : configFromFlags(flags), systemRunner, {
134
+ home: flags.get("home"),
135
+ reconfigure: command.startsWith("reconfigure"),
136
+ });
137
+ console.log(`${command} complete: ${paths.unitPath}`);
138
+ return;
139
+ }
140
+ case "pair": pair(configured(flags)); return;
141
+ case "start": console.log(start(configured(flags))); return;
142
+ case "stop": console.log(stop(configured(flags))); return;
143
+ case "emergency-stop": console.log(emergencySystemdStop(configured(flags), systemRunner, required(flags, "confirm"))); return;
144
+ case "status": console.log(status()); return;
145
+ case "control-pane": controlPane(); return;
146
+ case "restart":
147
+ case "recover": console.log(restart(configured(flags), systemRunner, required(flags, "confirm"))); return;
148
+ case "uninstall": {
149
+ const paths = lifecyclePaths(flags.get("home"));
150
+ uninstall(paths, systemRunner, {
151
+ confirmation: required(flags, "confirm"),
152
+ emergencyConfirmation: flags.get("emergency-confirm") === EMERGENCY_STOP_CONFIRMATION ? EMERGENCY_STOP_CONFIRMATION : undefined,
153
+ });
154
+ return;
155
+ }
156
+ case "unit-start": unitStart(configured(flags)); return;
157
+ case "unit-stop": unitStop(configured(flags)); return;
158
+ default: fail(`Unknown command: ${command}`);
159
+ }
160
+ }
161
+
162
+ try {
163
+ main();
164
+ } catch (error) {
165
+ console.error(error instanceof Error ? error.message : String(error));
166
+ process.exitCode = 1;
167
+ }