ai-agentmanager 0.0.0-stage → 1.0.0

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 (58) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/README.md +767 -2
  4. package/SECURITY.md +44 -0
  5. package/bin/agentmgr-hub.js +16 -0
  6. package/bin/agentmgr.js +4 -0
  7. package/docs/architecture.md +67 -0
  8. package/docs/distributed.md +147 -0
  9. package/docs/engines.md +177 -0
  10. package/docs/images/agents.jpg +0 -0
  11. package/docs/images/conflict-radar.jpg +0 -0
  12. package/docs/plugins.md +81 -0
  13. package/package.json +56 -4
  14. package/public/app.js +3083 -0
  15. package/public/hub/hub.css +230 -0
  16. package/public/hub/hub.js +766 -0
  17. package/public/hub/index.html +146 -0
  18. package/public/hub/term.js +147 -0
  19. package/public/index.html +342 -0
  20. package/public/share.html +34 -0
  21. package/public/share.js +41 -0
  22. package/public/style.css +541 -0
  23. package/public/touchscroll.js +73 -0
  24. package/public/transport.js +78 -0
  25. package/scripts/build-release.sh +58 -0
  26. package/scripts/fix-pty.js +15 -0
  27. package/src/backlog.js +413 -0
  28. package/src/brief.js +512 -0
  29. package/src/cli.js +1447 -0
  30. package/src/client.js +49 -0
  31. package/src/config.js +109 -0
  32. package/src/conflicts.js +105 -0
  33. package/src/engines/antigravity.js +296 -0
  34. package/src/engines/claude.js +98 -0
  35. package/src/engines/codex.js +331 -0
  36. package/src/engines/index.js +37 -0
  37. package/src/fleet.js +176 -0
  38. package/src/git.js +340 -0
  39. package/src/hub.js +857 -0
  40. package/src/hubactions.js +107 -0
  41. package/src/hubbacklog.js +373 -0
  42. package/src/hublink.js +437 -0
  43. package/src/inbox.js +94 -0
  44. package/src/judge.js +278 -0
  45. package/src/livebrowser.js +637 -0
  46. package/src/manager.js +2554 -0
  47. package/src/notify.js +284 -0
  48. package/src/plugins.js +119 -0
  49. package/src/preview.js +334 -0
  50. package/src/races.js +192 -0
  51. package/src/remote.js +284 -0
  52. package/src/server.js +759 -0
  53. package/src/service.js +150 -0
  54. package/src/sessions.js +160 -0
  55. package/src/store.js +104 -0
  56. package/src/stuck.js +160 -0
  57. package/src/tracker.js +311 -0
  58. package/src/trust.js +44 -0
package/README.md CHANGED
@@ -1,3 +1,768 @@
1
- # Temporary Holding Version
1
+ # Agent Manager
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Run one background [Claude Code](https://claude.com/claude-code) agent per intent, and keep track of them from a web UI or the `agentmgr` CLI.
4
+
5
+ ![Agents grouped by project, with an agent's brief: results, problem, solution, a flow diagram and checks](docs/images/agents.jpg)
6
+
7
+ ![The conflict radar: two agents changed the same lines of README.md, with a suggested order to land them](docs/images/conflict-radar.jpg)
8
+
9
+ - **Intents in, agents out.** Give one intent or a list (one per line). Each becomes its own `claude` process.
10
+ - **Repo or folder.** Give a git URL (cloned once, then each agent gets its own worktree and branch) or a local folder.
11
+ - **Fast clones.** URLs are cloned as partial clones (`--filter=blob:none`): history now, file contents only for what's checked out.
12
+ - **Progress.** Clone and checkout progress shows in the UI and `agentmgr ls`.
13
+ - **Cancel and retry.** Deleting an agent during setup cancels the clone. A failed or interrupted setup can be retried.
14
+ - **Big repo you already have?** `-d <your clone> -w` gives each agent its own worktree of it in seconds.
15
+ - **Plan while it clones.** A planning session lets you talk the task through with Claude while the clone runs. The same session then moves into the repo with the whole conversation.
16
+ - **Background terminals.** Agents run inside the daemon's PTYs. Open any agent's live terminal in the browser (**Open terminal**) or in your shell (`agentmgr attach`). Closing the view leaves the agent running.
17
+ - **Session IDs are kept.** Each agent is started with a known `--session-id`. **Close session** stops the process but keeps the ID, and bringing it back runs `claude --resume <id>`. **New session** adds another ID to the agent's history; earlier ones stay resumable.
18
+ - **Tracking.** For each agent you see its session ID, working folder, repo, branch, head commit, uncommitted changes, PRs and bugs.
19
+ - **Results.** The end result at a glance: ✅ done, 🟡 partial, ⛔ blocked or 🔄 in progress, with what was delivered and what's blocking it.
20
+ - **Brief per agent.** Each agent keeps a living brief that the UI shows next to its terminal:
21
+ - **Problem**, **Solution**, a **design / flow diagram** (Mermaid) and **Checks** (passed / failed / running / pending);
22
+ - when the intent links a Jira issue, **References** with its **PRD** and **Tech Spec** links and the points that matter.
23
+ - **Projects.** The sidebar is a tree, project → agents, so you see how many projects are in flight and how many parallel sessions each has.
24
+ - **Project shortcuts.** Each project gets a short name, such as `cc` for cloud-console. Use it instead of the repo URL: `agentmgr add @cc "…"`, `agentmgr ls cc`, `@cc` in the UI filter.
25
+ - **Backlog.** Queue asks as work orders. Agents pick them up one by one, up to N in parallel per project, until each is done. You accept or reopen each one.
26
+ - **Slack alerts.** A message in your channel when an agent needs input, finishes a backlog item, or fails.
27
+ - **Priority.** Mark agents P0–P3. P0 and P1 are highlighted, and lists sort by priority.
28
+ - **Share for review.** One click writes an **Analysis**, **Design**, **Flow** or **Proposal** document from the agent's work. Copy it as Markdown, download it, or print it to PDF with diagrams.
29
+ - **Human vs AI.** It splits the open questions about the work into the top 5 that need your judgment and the ones a model can answer from the evidence. It answers those, then a second model double-checks every answer.
30
+ - **Plan review.** Optionally, the agent writes an implementation plan and waits for your approval before changing anything.
31
+ - **Insights.** Why, What, How and Now for any agent, three memorable points each.
32
+ - **Explain.** One click gives a plain-language explanation of the intent and the insight behind the problem and solution. It comes from a separate tool-less Claude call, so the agent isn't interrupted.
33
+ - **From your phone.** Turn on remote access (`agentmgr remote on`) for HTTPS access on your local network at a plain `https://<ip>:<port>`. Sign in with a QR code, and answer Claude's prompts with a key bar and reply box. Nothing to install.
34
+ - **Never loses state.** `agentmgr flush` (also every 30 s and on shutdown) saves session IDs, terminal scrollback and usage. `agentmgr restart` brings everything back.
35
+ - **Follows your conventions.** Before changing anything, agents review `CLAUDE.md` / `AGENTS.md`, skills, hooks and settings (repo and `~/.claude`), and follow them.
36
+ - **Tokens and cost.** Input, output and cache tokens are tracked per session, subagents included, alongside the cost Claude Code reports.
37
+ - **No trust prompt.** Folders agents run in are pre-trusted, so Claude's "trust this folder" prompt doesn't block them.
38
+ - **Survives restarts and reboots.** Agents that were running when the daemon stopped (restart, crash or reboot) are resumed with the same session IDs when it starts again. `agentmgr service install` starts the daemon at login.
39
+ - **Shells next to each agent.** **Open shell** gives a terminal in the agent's folder for running commands by hand. **+ Shell** opens as many more as you need, each in its own tab.
40
+ - **Browser tabs.** **+ Browser** opens a page as this machine sees it, in a tab next to the agent's terminals. That can be the agent's dev server on `localhost:5173`, a site on its network or VPN, or any address. Local addresses the agent prints are offered as suggestions. It works from your phone or laptop too (see below).
41
+ - **Live browser.** Browser tabs run a real Chrome on this machine and stream it into the tab: you see its screen and your clicks, scrolling, typing and paste go back to it, from the laptop or the phone. Because the page runs here, `localhost` is this machine, sites that refuse to be framed load normally, and popups (a sign-in window) open as tabs of their own and come back when they close. Chrome (or Chromium, Brave, Edge; `browserBin` in config.json picks one) runs headless with its own profile in `~/.agentmanager/browser-profile`, so sign-ins are remembered; it starts on the first view and stops after 15 minutes with nobody watching. Downloads go to `~/Downloads/agentmanager`. A site that still refuses it as a bot may accept `"browserHeadless": false`, which runs Chrome with a real window on this machine's screen. On Linux where Chrome's sandbox can't start (containers, Ubuntu 23.10+ user-namespace restrictions) the tab says so; `"browserNoSandbox": true` runs it without the sandbox, at your own risk. **Lite** on the bar switches a tab to the frame mode (the page loads in your own browser; quicker for a dev server).
42
+ - **CLI sign-in links.** When a terminal prints a sign-in link that returns to a port on this machine (`railway login`, `gh auth login --web`, `gcloud auth login`...), a bar above the terminal offers **Open sign-in**: the link opens in a live browser tab here, so the provider's redirect to `http://127.0.0.1:PORT/callback` reaches the waiting CLI by itself, from any device. It opens on its own if you just typed the command. Without a live browser, it opens a window on your device; from another device you then paste the address you land on (`127.0.0.1:PORT/callback…`) into the bar and Agent Manager delivers it to the CLI, only on the port the link named.
43
+ - **Attach files and screenshots.** Drop files on the terminal, paste a screenshot, or use **📎 Attach**. The file is saved on the daemon's machine and its path is pasted into the terminal, which is how Claude Code picks up images and files.
44
+ - **General sessions.** **Ask Claude** starts a session with no repo, folder or intent, for questions. It is tracked and resumable like any other agent.
45
+
46
+ New in 0.2, for running many agents at once:
47
+
48
+ - **Decision inbox.** One **Inbox** tab for everything waiting on you, across agents: prompts that need an answer (answer them with one click), questions agents ask without stopping, agents that seem stuck, and overlapping changes. Answers are typed into the agent's session for you.
49
+ - **Conflict radar.** Agents in the same repo that change the same files are flagged while they work, not at merge time, with "same lines" called out and a suggested merge order. **Tell both** lets each agent know.
50
+ - **Stuck detection.** Spots an agent going in circles (the same failure again and again, undoing its own edits, a long stretch with no file changed) and offers a ready-made nudge to send.
51
+ - **AI judge.** Rules only decide *when* to look; a fast model decides *what is going on*: whether a stuck-looking agent is really stuck (and a nudge specific to its problem), what an idle agent is asking when no known prompt matched, whether "done" work actually meets the intent, whether two agents' work will collide, what the backlog should start next, and which alerts are worth interrupting you for. It learns from how you react.
52
+ - **Checkpoints and forks.** The code (uncommitted work included) and the conversation are saved at the end of every turn. **Fork** starts a new agent from now or from any checkpoint, in its own worktree, to try another direction without losing the first.
53
+ - **Races.** Send one intent to several agents with different models or approaches. Compare their outcome, checks, size of change, cost and a test command run in each worktree, read their diffs side by side, then pick a winner and delete the rest.
54
+
55
+ ## Install
56
+
57
+ Runs on macOS and Linux; on Windows, use WSL2. Requires Node 20+, `git`, and the `claude` CLI, signed in (run `claude` once). Optional: `gh` (authenticated) for PR discovery by branch and PR state, Chrome (or Chromium, Brave, Edge) for live browser tabs, and Codex (`npm i -g @openai/codex`) as a second engine.
58
+
59
+ **Stable release (recommended).** Releases are tagged (`v1.0.0`, `v1.0.1`, …) and listed on the [Releases](https://github.com/jdmunta/ai-agentmanager-core/releases) page, with changes in [CHANGELOG.md](CHANGELOG.md).
60
+
61
+ ```sh
62
+ npm install -g ai-agentmanager # the latest release
63
+ npm install -g ai-agentmanager@1.0.0 # or a specific one
64
+ ```
65
+
66
+ Or from the repository, at a release tag:
67
+
68
+ ```sh
69
+ git clone --branch v1.0.0 --depth 1 https://github.com/jdmunta/ai-agentmanager-core.git
70
+ cd ai-agentmanager-core
71
+ npm install
72
+ npm link # optional: puts `agentmgr` on your PATH
73
+ ```
74
+
75
+ **Development version (`main`).** New features land on `main` first, before they're released, so it can be less stable.
76
+
77
+ ```sh
78
+ git clone https://github.com/jdmunta/ai-agentmanager-core.git
79
+ cd ai-agentmanager-core
80
+ npm install
81
+ npm link
82
+ ```
83
+
84
+ **Updating.** Use the command for how you installed, then run `agentmgr restart`. Running agents pause briefly and resume.
85
+
86
+ | Installed with | Update |
87
+ | --- | --- |
88
+ | npm | `npm install -g ai-agentmanager@latest` |
89
+ | A clone at a release tag | `git fetch --tags && git checkout v1.0.1 && npm install` (the tag you want) |
90
+ | A clone of `main` | `git pull && npm install` |
91
+
92
+ ## Quick start on a new computer
93
+
94
+ **A computer that runs agents.** After installing:
95
+
96
+ ```sh
97
+ agentmgr ui # starts the daemon, opens http://127.0.0.1:4717
98
+ agentmgr service install # optional: start the daemon at login, and bring agents back after a reboot
99
+ agentmgr remote on # optional: open it from your phone (prints the address and QR code)
100
+ ```
101
+
102
+ To update later: `git pull && npm install && agentmgr restart`. Running agents come back with the same sessions.
103
+
104
+ **Adding it to a hub.** If you already run a hub (see [Several machines: the hub](#several-machines-the-hub)), get a code where the hub runs, then join from the new computer:
105
+
106
+ ```sh
107
+ agentmgr hub invite # on the hub's machine (or anywhere with AGENTMGR_HUB_TOKEN set)
108
+ agentmgr join https://<hub-address> <CODE> --name laptop
109
+ agentmgr hub status # connected, and what the hub may do
110
+ ```
111
+
112
+ A new machine shares `view` only. To let the hub answer, control, start agents or open terminals, set `"hub": { "allow": [...] }` in `~/.agentmanager/config.json` and run `agentmgr restart` (permissions are in the hub section).
113
+
114
+ **A computer that runs the hub.** Pick a Mac that stays on (it can also run agents), on Tailscale so other machines reach it privately:
115
+
116
+ ```sh
117
+ nohup agentmgr hub serve >> ~/.agentmanager/hub.log 2>&1 &
118
+ grep 'sign in' ~/.agentmanager/hub.log # first start prints the sign-in link; later: agentmgr hub token
119
+ ```
120
+
121
+ The hub listens on port 4720, on this Mac and on its Tailscale address (`--host` picks one address instead). Sign in with that link; **Add machine** gives a join command with the Tailscale address, so it works from the other Macs. Its state (token, machines) is kept in `~/.agentmanager/hub/`, so a restart keeps everything joined. To run the hub on Railway instead, see "On Railway" in the hub section.
122
+
123
+ ## Use
124
+
125
+ ```sh
126
+ agentmgr ui # start the daemon and open http://127.0.0.1:4717
127
+ agentmgr service install # start the daemon at login (launchd / systemd --user)
128
+
129
+ agentmgr add "Fix the flaky login test" -d ~/src/app
130
+ agentmgr add -r https://github.com/org/repo.git \
131
+ "Add pagination to /users" "Investigate ABC-12345 and open a fix PR"
132
+ agentmgr add -f intents.txt -r git@github.com:org/repo.git -p acceptEdits
133
+ agentmgr add --plan -a -r https://github.com/org/big-repo.git "Fix ABC-123" # plan with Claude while it clones
134
+ agentmgr add -d ~/src/big-repo -w -b release-1 "Backport the fix" # worktree of your clone, branched from release-1
135
+
136
+ agentmgr ls [cc] # status, branch, PR/bug counts, session (optionally one project)
137
+ agentmgr add @cc "Fix the flaky test" # use a project shortcut instead of -r / -d
138
+ agentmgr project ls | add | rename | base | rm # manage project shortcuts
139
+ agentmgr show <agent> # everything tracked for one agent
140
+ agentmgr attach <agent> # live terminal here; Ctrl-] detaches (resumes a closed agent)
141
+ agentmgr shell <agent> [-n 2] # a shell in the agent's folder (-n picks another one); Ctrl-] detaches
142
+ agentmgr brief <agent> # print the agent's brief (Markdown)
143
+ agentmgr priority <agent> P0 # P0 urgent, P1 high, P2 normal (default), P3 low
144
+ agentmgr doc <agent> proposal -o p.md # analysis | design | flow | proposal, for stakeholders
145
+ agentmgr doc <agent> all --background # write all four in the background
146
+ agentmgr insights <agent> # Why / What / How / Now, three points each
147
+ agentmgr explain <agent> # full briefing: ask, status, plan, solution, conclusions, needs
148
+ agentmgr remote on | off | status | rotate # phone / remote access (see below)
149
+ agentmgr backlog add "ask" -r <repo> [-p 1] # queue work; also: ls, start, accept, reopen, move, limit, pause
150
+ agentmgr notify slack --webhook <url> # Slack alerts; also: test, status, on, off, event <name> on|off
151
+ agentmgr inbox # prompts, questions, stuck agents and overlaps waiting on you
152
+ agentmgr answer <agent> <question-id> "…" # answer a question from the inbox
153
+ agentmgr tell <agent> "…" # send a message into the session (when it's idle)
154
+ agentmgr fork <agent> [-c 3] [-m "…"] # new agent from now (or checkpoint 3), its own worktree
155
+ agentmgr checkpoints <agent> # snapshots saved at the end of each turn
156
+ agentmgr race start "intent" -v opus -v "sonnet|keep it small" -r <repo> -t "npm test"
157
+ agentmgr race show [race] | test <race> | pick <race> <agent> [--cleanup]
158
+ agentmgr flush # save session IDs, scrollback, usage and state now
159
+ agentmgr restart # flush, stop and start the daemon; agents resume
160
+ agentmgr plan <agent> # plan with Claude while the workspace is still being prepared
161
+ agentmgr handoff <agent> # move a planning session into its ready workspace now
162
+ agentmgr ask ["question"] # general session with no repo or folder
163
+ agentmgr stop <agent> | --all # close the session, keep its ID
164
+ agentmgr start <agent> [--fresh | -s <session>]
165
+ agentmgr sessions <agent> # every session ID this agent has used
166
+ agentmgr link <agent> --pr <url> --bug ABC-123
167
+ agentmgr rm <agent> [--delete-workspace]
168
+ agentmgr shutdown
169
+ agentmgr service status | uninstall
170
+ ```
171
+
172
+ `<agent>` can be the ID, a unique ID prefix, or the name. Every command starts the daemon if it isn't already running.
173
+
174
+ ### Statuses
175
+
176
+ | Status | Meaning |
177
+ | --- | --- |
178
+ | `preparing` | Cloning or checking out the worktree (with progress) |
179
+ | `planning` | A planning session is running while the workspace is prepared |
180
+ | `working` | Claude is producing output |
181
+ | `waiting` | Claude is idle, waiting for its next instruction |
182
+ | `needs input` | A trust or permission prompt is blocking the agent. Open its terminal to answer. |
183
+ | `stopped` | Closed by you or by a daemon restart. Resumable. |
184
+ | `exited` | Claude exited on its own (for example `/exit`). Resumable. |
185
+ | `error` | Workspace setup or launch failed. See the error message. If setup failed, **Retry setup** (or `agentmgr start <agent>`) runs it again. Setup interrupted by a daemon restart is retried automatically. |
186
+
187
+ Agent folders are pre-trusted (see below), so new agents don't stop at Claude's "trust this folder" prompt.
188
+
189
+ ## Sharing one big repo between agents
190
+
191
+ Every agent gets **its own worktree and its own branch** (`agent/<name>-<id>`) of one shared clone. Git history is stored once, and each agent only adds its checked-out files, so a new agent on a repo that's already there starts in seconds.
192
+
193
+ - **Repo URL** (`-r <url>`): the first agent clones it into `~/.agentmanager/repos/`. Later agents with the same URL reuse that clone after a quick fetch.
194
+ - **A clone you already have** (`-d <folder> -w`, or the folder field with the worktree box ticked, which is the UI default): agents get worktrees of your clone. Your own checkout and branch are never touched.
195
+
196
+ **Where branches start.** By default each agent branches from the repo's **default branch, freshly fetched** (`origin/HEAD`, usually `origin/main`). That holds even if your clone is checked out on another branch or is behind. To start somewhere else, use `--base <ref>` (or the **Base branch** field):
197
+
198
+ - a branch name such as `release-1`, which uses `origin/release-1` when the remote has it;
199
+ - a tag or a SHA;
200
+ - `HEAD` for the folder's current checkout.
201
+
202
+ **Other details:**
203
+
204
+ - **Offline.** If the fetch fails (offline, no access), the refs already present are used.
205
+ - **No upstream.** Agent branches are created without an upstream, so Claude's first `git push -u origin <branch>` sets the right one. They never accidentally track `origin/main`.
206
+ - **Where it shows.** The agent shows **Branched from** with the ref and commit it started at.
207
+
208
+ ## Continue sessions started in a terminal
209
+
210
+ **Import** (next to **Save now** in the agent list) lists the Claude Code sessions you started yourself with `claude` in a terminal on this machine, from the last 7, 30 or 90 days: grouped by folder, with title, first and last ask, branch, size and last activity. Headless runs (`claude -p`, the SDK) and Agent Manager's own agents are left out. Each one you pick becomes an agent in the same folder that continues the same conversation (`--resume`), with the brief, inbox, PRs and usage tracked from then on.
211
+
212
+ A session still open in a terminal is marked **open in a terminal** (a running `claude` names it) or **maybe open** (a `claude` runs in that folder and the session was active minutes ago). Two places writing one conversation would mix it up, so those continue as a **copy** under a new session ID and the terminal keeps the original. For the same reason, an agent that follows a `/clear` to a new session never picks up a headless run or a session a terminal has open in its folder.
213
+
214
+ ## Restarts and reboots
215
+
216
+ Every agent records whether you want it running:
217
+
218
+ - Starting or resuming it means **running**.
219
+ - **Close session** / `agentmgr stop`, or Claude exiting on its own (`/exit`), means **stopped**.
220
+ - A daemon restart, a crash or a reboot changes nothing.
221
+
222
+ When the daemon starts, it resumes every agent you left running with `claude --resume <session-id>`. Set `"autoResume": false` in the config to turn that off.
223
+
224
+ To have that happen after a reboot, install the login service once:
225
+
226
+ ```sh
227
+ agentmgr service install # macOS: ~/Library/LaunchAgents/com.agentmgr.daemon.plist
228
+ agentmgr service status
229
+ ```
230
+
231
+ - **Environment.** The service runs the daemon through your login and interactive shell (`$SHELL -l -i`), so agents see the same environment as your terminal, including tokens exported in `~/.zshrc` such as `GITHUB_TOKEN`.
232
+ - **Restarts.** launchd restarts the daemon if it crashes, but not after `agentmgr shutdown`.
233
+ - **Linux.** It installs a systemd user unit instead. Run `loginctl enable-linger $USER` if it should start at boot before you log in.
234
+
235
+ ## Where things come from
236
+
237
+ | Field | Source |
238
+ | --- | --- |
239
+ | Session ID | Assigned by agentmgr (`--session-id`). If Claude switches sessions mid-run (`/clear`), the new transcript in the agent's folder is adopted. |
240
+ | Folder / repo / branch | The workspace agentmgr prepared, plus `git` in that folder |
241
+ | PRs | `pr-link` records in the session transcript (PRs Claude created), `gh pr list --head <branch>`, PR URLs mentioned in the conversation, and links you add |
242
+ | Bugs | Refs in the intent and the conversation (Jira links with `/browse/KEY-1`, `?selectedIssue=KEY-1` or `/issues/KEY-1`; GitHub issue URLs), custom `bugPatterns`, and links you add |
243
+ | Title / cost | `ai-title` and `cost-state` records in the transcript |
244
+
245
+ Removing a detected link dismisses it, so it doesn't come back on the next scan.
246
+
247
+ ## Planning while a repo clones
248
+
249
+ Cloning a big repo can take a while. Tick **Plan with Claude while the repo clones** (the default in the UI), or use `add --plan`. For an agent that is already cloning, click **Plan while it clones** or run `agentmgr plan <agent>`.
250
+
251
+ 1. **Planning.** Claude runs in `~/.agentmanager/planning` with the agent's own session ID. It is told the repo isn't there yet and to clarify the task with you: ask questions, gather requirements, agree on a plan. It doesn't edit files.
252
+ 2. **Handoff.** When the workspace is ready, the session's transcript is copied into the repo folder and the same session resumes there (`claude --resume <id>`). Claude gets the message "The repository is ready … continue with the plan we agreed on" and has the whole planning conversation. The session ID doesn't change.
253
+ 3. **Timing.** It moves by itself once Claude has been idle for `handoffIdleSec` and no terminal is attached. If you have the terminal open, it waits for **Continue in repo** (or `agentmgr handoff <agent>`), so it never cuts you off mid-sentence.
254
+
255
+ If setup fails while you're planning, the planning session keeps running and **Retry setup** tries again.
256
+
257
+ ## The brief
258
+
259
+ Every task agent is told, on each launch, to keep a short brief in `~/.agentmanager/briefs/<id>/BRIEF.md`. The file is outside the repository, so it never gets committed. The sections are:
260
+
261
+ | Section | Contents |
262
+ | --- | --- |
263
+ | `## Problem` | What's wrong or needed, and why |
264
+ | `## Solution` | The approach and key changes, kept current |
265
+ | `## Diagram` | One ` ```mermaid ` block: flow, sequence or architecture |
266
+ | `## Checks` | `- [ ]` pending, `- [~]` running, `- [x]` passed, `- [!]` failed, with the command or evidence |
267
+ | `## Results` | `Outcome: in progress \| partial \| done \| blocked`, then `- Delivered: …` (PRs, commits, files, docs, answers) and `- Blocked by: … (needs: who/what)` |
268
+ | `## References` | Only when the intent links Jira issues. The agent looks them up with its own Jira / Atlassian tools (no credentials in agentmgr) and lists the **PRD** and **Tech Spec** fields as links with highlights, plus other design docs. Empty fields are listed as "none". |
269
+
270
+ How it behaves:
271
+
272
+ - **Display.** The UI shows the brief as a panel with a rendered diagram, check icons and highlighted PRD / Tech Spec links. The agent list shows check counts and PRD / Tech Spec chips. `agentmgr show` summarizes it, and `agentmgr brief <agent>` prints it.
273
+ - **Updates.** Changes show up within a second while the agent runs.
274
+ - **Planning.** Planning sessions start the brief too, so Problem, the proposed Solution and the References can be filled in before the clone finishes.
275
+ - **Permissions.** Claude gets `--add-dir` access plus `Write` / `Edit` permission rules for its brief folder only, so writing the brief never stops at a permission prompt. Everything else keeps your normal permission mode.
276
+ - **Safety.** Markdown is sanitized (DOMPurify) and diagrams render with Mermaid's `strict` security level.
277
+ - **Conventions.** With `reviewConventions` on (the default), agents are also told to read `CLAUDE.md` / `AGENTS.md`, the relevant skills (`.claude/skills`, `~/.claude/skills`), hooks and permissions (`.claude/settings*.json`, `~/.claude/settings.json`), and project commands and agents before working. They record what applies as the first check.
278
+ - **Off switch.** Set `"brief": false` or `"reviewConventions": false` to turn these off. Neither applies to general sessions.
279
+ - **Existing agents.** Agents started before this version pick it up on their next resume.
280
+
281
+ ## Priority
282
+
283
+ Every agent has a priority, **P0** (urgent) to **P3** (low). **P2** is the default.
284
+
285
+ - **Look.** P0 shows a solid red chip and a red bar on the agent. P1 shows a red outline chip, and P3 a muted chip. P2 shows nothing, to keep the list calm.
286
+ - **Ordering.** Within a project, agents sort by priority, then needs-input, then running. Projects holding a P0 or P1 agent move to the top and show the chip in their header.
287
+ - **Setting it.** Use the selector next to the agent's name, the New agents dialog, `add --priority P1`, or `agentmgr priority <agent> P0`.
288
+ - **Backlog.** Items use the same P0–P3 scale and pass it on to their agents.
289
+ - **Slack.** Alerts are tagged `[P0]` / `[P1]`.
290
+
291
+ ## Share for review: Analysis, Design, Flow, Proposal, Human vs AI
292
+
293
+ The Brief panel's **Share for review** buttons, or `agentmgr doc <agent> <kind>`, write a stakeholder document from the agent's live context: its ask, conversation and actions, repository changes and brief.
294
+
295
+ | Document | Sections |
296
+ | --- | --- |
297
+ | **Analysis** | Summary, context, findings, root cause, constraints and assumptions, options considered, open questions |
298
+ | **Design** | Summary, goals and non-goals, architecture (with a diagram), components and changes, interfaces and data, trade-offs, risks, testing and rollout |
299
+ | **Flow** | Summary, end-to-end flowchart with a step-by-step walk-through, key interactions as a sequence diagram, failure and edge cases |
300
+ | **Proposal** | Summary, problem, recommendation, scope, plan, effort and dependencies, risks, decisions needed |
301
+ | **Human vs AI** | Your top 5 decisions, each with why it needs you, the stakes, options and what the work suggests, plus a box for your answer. Up to 5 questions the AI answers, each with its confidence, evidence and how to check it. A second model's verdict on each. |
302
+
303
+ **Human vs AI.** This review takes two separate read-only calls.
304
+ 1. **The split.** The agent's engine splits the open questions. *For you to decide* covers judgment calls such as intent, priorities, risk appetite and trade-offs. *Answered by AI* covers reasoning and evaluation: correctness, edge cases, test coverage and what's left.
305
+ 2. **The second opinion.** Another model reviews that split against the same context. It marks each AI answer *agrees*, *partly* or *disagrees*, with a correction where needed. It marks each of your questions *keep*, *AI could answer* or *reword*, and lists questions both lists missed.
306
+
307
+ The second model is another installed engine by default (Codex or Antigravity for a Claude agent), because a different provider tends to catch different mistakes. Without one, it's Claude with a different model. Set `"critique": { "engine": "codex", "model": "…" }` in config.json to choose.
308
+
309
+ Type your answers in the viewer, or tap an option to fill one in. **Send my answers to the agent** passes them on, together with any AI conclusions the second model doubted, so the agent re-checks those.
310
+
311
+ **How they're written.** Documents name the real files, tickets and docs, separate facts from proposals, and say "To be confirmed" where the context doesn't. They're written for reviewers: no mention of the agent or its tools.
312
+
313
+ **Sharing.** Each document opens in a viewer:
314
+
315
+ - **Copy Markdown** pastes cleanly into Confluence, Google Docs, Slack or a PR.
316
+ - **Download .md** saves the file.
317
+ - **Print / PDF** opens a print-ready page with the Mermaid diagrams rendered. Use your browser's *Save as PDF*.
318
+
319
+ **In the background.**
320
+
321
+ - **Starting.** While a document is being written, **Continue in background** closes the viewer, and the writing carries on in the daemon. **Write all in background** starts every document that doesn't exist yet. You get a notification with an **Open** button as each one is ready.
322
+ - **CLI.** `agentmgr doc <agent> <kind|all> --background` returns at once. `agentmgr doc <agent> <kind> --cached` prints the result later.
323
+ - **Queueing.** At most `summaryConcurrency` (2) of these one-off Claude calls run at once, Explain and Insights included. The rest queue.
324
+
325
+ **Behaviour.** Documents are kept per agent and marked out of date when the brief changes. They come from the same separate, tool-less Claude call as Explain, so the agent isn't interrupted. On the phone link, the print page needs sign-in like everything else.
326
+
327
+ ## Plan review
328
+
329
+ Tick **Review the implementation plan first** in New agent (or the backlog), or press **Review its plan first** on a running agent. The agent investigates, writes `PLAN.md` (goal, approach, steps, files, tests, risks) next to its brief, and stops. It doesn't edit, commit or run anything that changes the repo until you approve.
330
+
331
+ - **Where it shows.** The plan appears in the inbox as **Plan review** and in the Brief panel, with a notification.
332
+ - **Approve and implement** sends it ahead, optionally with notes.
333
+ - **Request changes** sends your notes back. The agent revises the plan and waits again.
334
+ - **Skip review** stops waiting.
335
+ - **After approval**, edits to the plan count as progress updates and don't ask again. A restarted agent is told its plan was approved.
336
+ - **Default.** Set `"planReview": true` in config.json to turn it on for every new agent.
337
+
338
+ ## Insights
339
+
340
+ **Insights** in the Brief panel, or `agentmgr insights <agent>`, shows the agent's work as four cards built from its ask and live context:
341
+
342
+ | Card | Answers |
343
+ | --- | --- |
344
+ | 🎯 **Why** | Why it matters: the motivation, the need, or the root cause |
345
+ | 📦 **What** | What is being done or delivered: scope and outcome |
346
+ | 🛠 **How** | The approach, the key mechanism, the main changes |
347
+ | 📍 **Now** | Where it stands and the next step, including anything waiting on you |
348
+
349
+ Each card has at most **three points of about 12 words each**, so they're easy to remember and repeat. Insights uses the same context and the same separate, tool-less Claude call as Explain, so the agent isn't interrupted. Use Insights for a quick glance and Explain for the full briefing.
350
+
351
+ ## Results
352
+
353
+ The **Results** card is the first thing in the Brief panel, and `agentmgr show` lists it too. It shows:
354
+
355
+ - **The outcome:** ✅ Done, 🟡 Partial, ⛔ Blocked or 🔄 In progress.
356
+ - **Blockers first, in red.**
357
+ - **What was delivered.**
358
+
359
+ It combines what the agent wrote under `## Results` with what Agent Manager tracks itself:
360
+
361
+ - PRs (with their state).
362
+ - Failing checks.
363
+ - An unanswered prompt.
364
+ - A setup error.
365
+ - The brief's `Status:` line.
366
+
367
+ So agents that haven't written Results yet still get one. Blocked and done agents show ⛔ / ✅ in the agent list, and the **blocked** Slack alert (on by default) fires when an agent reports it's blocked.
368
+
369
+ ## Explain
370
+
371
+ **Explain** in the Brief panel, or `agentmgr explain <agent>`, briefs you on what the agent is doing, built from its live context.
372
+
373
+ **Context it reads:**
374
+
375
+ - **The conversation:** your requests and the agent's own replies.
376
+ - **Its actions:** commands run, files edited, questions asked, skills and subagents used, Jira and Drive calls.
377
+ - **The repository:** commits and changes since its base branch.
378
+ - **Live status:** working, waiting on you, or blocked.
379
+ - **The brief.**
380
+
381
+ **What it writes:**
382
+
383
+ | Section | Contents |
384
+ | --- | --- |
385
+ | The ask | What was requested, including later changes of direction |
386
+ | Where it stands | Phase (planning / investigating / implementing / testing / done / blocked), what it's doing now, whether it's waiting on you |
387
+ | Planned work | Checklist with ✅ done, 🔄 in progress, ⏳ next |
388
+ | Solution | The approach and the concrete changes so far (files, commits, PRs) |
389
+ | Conclusions so far | Findings, decisions, results |
390
+ | Needs from you | Questions or decisions it's waiting on, risks, blockers |
391
+
392
+ **How it runs:**
393
+
394
+ - **Separate call.** `claude -p --tools "" --strict-mcp-config --no-session-persistence`, with no tools and no MCP servers. It never runs inside the agent's session, so the agent isn't interrupted and its context doesn't grow.
395
+ - **Large sessions.** They are condensed to the first request plus the most recent activity, about 24k characters.
396
+ - **Stale flag.** The result is stored with the agent and marked out of date when the brief changes.
397
+ - **Model.** Set `"explainModel"` to pick one.
398
+
399
+ ## Projects
400
+
401
+ The sidebar groups agents into projects, shown as a tree:
402
+
403
+ - **How agents are grouped.**
404
+ - By repo: a URL and a local clone of the same repo land together.
405
+ - Otherwise by folder.
406
+ - General sessions under *General*, scratch work under *Other*.
407
+ - Set your own name with `--project` or the ✎ next to *Project* in the agent's Workspace card.
408
+ - **Counts.** Each project shows running/total agents and how many need input.
409
+ - **Shortcuts.** Every project gets a **shortcut**, shown as a badge in the tree.
410
+ - **Assignment:** from the name's initials (`cloud-console` → `cc`, `ai-gateway` → `ag`) or its first letters (`agentmanager` → `age`), with a number added when two would clash. Click the badge, or run `agentmgr project rename cc cbc`, to change it.
411
+ - **Where it works:**
412
+ - `agentmgr add @cc "…"` or `--project cc` uses the project's repo or clone and its default base branch. A local clone always gets a new worktree.
413
+ - `agentmgr ls cc` lists that project.
414
+ - Type `@cc` in the UI filter to show just it.
415
+ - The New agents **Project** field suggests your shortcuts.
416
+ - `backlog add --project cc` queues work for it.
417
+ - **Ahead of time:** register a project before it has agents with `agentmgr project add cc -r <url> [-b main]`. Set a default base branch with `agentmgr project base cc release-1`.
418
+ - **Ordering.** Projects needing you sort first. Collapsed projects stay collapsed.
419
+ - **CLI.** `agentmgr ls` groups by project too.
420
+
421
+ ## Backlog
422
+
423
+ Queue asks instead of starting them. Use **+ Add** in the Backlog tab, **Queue in backlog** in the New agents dialog, or `agentmgr backlog add`. Each item is one ask, plus where to do it (repo or folder, base branch, project) and a priority from P1 (high) to P3 (low).
424
+
425
+ **How items flow:**
426
+
427
+ 1. **Queued → active.** Items are picked up by priority, then queue order. Up to `backlogParallel` (2) items per project run at once, and `backlogMaxActive` (4) overall. Change a project's limit with "*N at a time* ✎" or `agentmgr backlog limit <project> <n>`. Each item gets its own agent, worktree and branch.
428
+ 2. **Active → review.** When the agent sets its brief's first line to `Status: done` (its checks pass), the item moves to **review** and frees its slot for the next one. An agent that exits or that you close also sends its item to review. Setup errors make it **blocked** (Retry restarts it).
429
+ 3. **Review → done.** **Accept** marks it done. **Reopen** types your note into the same agent session and puts the item back to work.
430
+
431
+ **Other controls:**
432
+
433
+ - **Pause / Resume** stops or restarts picking up new items. Active ones continue.
434
+ - **Start now** starts an item regardless of limits.
435
+ - **Reorder** with ▲▼, or `backlog move`. Click **P1–P3** to change priority.
436
+ - Deleting an agent cancels its item.
437
+
438
+ The backlog is saved with the rest of the state.
439
+
440
+ ## Decision inbox
441
+
442
+ The **Inbox** tab (and `agentmgr inbox`) lists what needs you, across all agents:
443
+
444
+ | Kind | What it is | How you answer |
445
+ | --- | --- | --- |
446
+ | Needs input | A permission prompt or question menu is open in the agent's terminal | Click a choice (1, 2, 3, Esc); no need to open the terminal |
447
+ | Waiting on you | The AI judge read an idle screen and saw a question (or an error) no rule recognized | Click a choice or type an answer; **Not waiting** if it misread |
448
+ | Question | The agent asked something without stopping | Click an option or type an answer |
449
+ | AI review | The agent said it was done and the judge checked the work against the intent and brief | **Send back to finish** (types the missing items in) or **Looks good** |
450
+ | Stuck? | The agent seems to be going in circles | Send the suggested nudge (edit it first if you like) or dismiss |
451
+ | Overlap | It changes the same files as another agent | Tell one or both agents; see the suggested merge order |
452
+
453
+ **Questions without stopping.** Task agents are told to write questions that don't block all their work to `QUESTIONS.md` next to their brief, with options and the default they'll assume meanwhile, and then keep going:
454
+
455
+ ```markdown
456
+ ## Postgres or SQLite for the cache?
457
+ Options: Postgres | SQLite
458
+ Default: SQLite
459
+ The data set is small.
460
+ ```
461
+
462
+ **How answers reach the agent.** Answers, nudges and overlap warnings go into a per-agent queue. Each message is typed into the session as if you sent it, once the agent is idle: not mid-turn, and with no prompt open. A closed agent is resumed first. `agentmgr tell <agent> "…"` uses the same queue.
463
+
464
+ ## Conflict radar
465
+
466
+ For each agent with its own branch, Agent Manager works out which files and line ranges its branch changed since it branched, including uncommitted and new files. Agents working in the same repository (the same shared clone or source folder) that touch the same file are flagged:
467
+
468
+ - **same lines**: both edit the same region, within a few lines (likely a merge conflict). Only judged when both branched from the same commit.
469
+ - **same file**: both edit the file, in different places.
470
+
471
+ The suggested merge order puts an agent whose PR is merged or open first; otherwise the smaller change lands first, so the other has less to rebase. **Tell** sends an agent a short note naming the other agent, the files and the order. Attempts in one race, and a fork and its source, are expected to overlap, so they aren't flagged.
472
+
473
+ ## Stuck detection
474
+
475
+ From the transcript, while an agent runs:
476
+
477
+ | Finding | Rule (defaults) |
478
+ | --- | --- |
479
+ | Same failure N× in a row | One command failing with the same output 3 times running |
480
+ | Undoing its own edits | 2 edits that put back what an earlier edit removed, or 10 edits to one file, within 45 minutes |
481
+ | N min without changing a file | 25+ actions over 20+ minutes since the last edit, while still active |
482
+
483
+ Each finding comes with a suggested nudge. Sending it also dismisses the finding; a dismissed finding comes back only if the agent gets stuck again. Tune the thresholds with `"stuck": { "repeatFailures": 3, "thrashReverts": 2, "thrashEdits": 10, "driftMinutes": 20, "driftActions": 25 }` in `config.json`.
484
+
485
+ With the AI judge on (the default), these rules are only the first look; see below.
486
+
487
+ ## AI judge
488
+
489
+ Fixed rules are cheap but miss context: three identical failures can be a converging debug loop, a long stretch of reading can be a big codebase, and a question in plain words matches no pattern. So the rules now decide **when** to look, and a model decides **what is going on**. Each judgment is one separate, tool-less call (the agent is not interrupted) that returns a verdict, a confidence and its reasons, shown with a 🤖 tag.
490
+
491
+ | Judgment | Triggered when | The model decides |
492
+ | --- | --- | --- |
493
+ | Stuck | A stuck rule fires, or a looser version of it (half the failures, fewer edits, half the time) | Whether the agent is really stuck. A rule's finding shows until the judge clears it; a looser candidate shows only when the judge confirms it. The judge's diagnosis and nudge replace the canned ones. |
494
+ | Waiting on you | An agent has been idle for 20 s and no known prompt matched its screen | Whether it is asking something (inbox item with the question and its choices), finished, broken, or just idle |
495
+ | AI review | The brief turns to `Status: done`, the screen judge reads "finished", or **Review with AI** | Whether the work meets the intent and brief: complete, partial or not done, with what is met, missing and risky. A backlog item moves to review when the agent says it finished even if it forgot the brief. |
496
+ | Collisions | Two agents in one repo change the same file (the conflict radar's rule) or files in the same folder | Whether their work really collides, textually or in meaning (the same API, schema or behavior changed in incompatible ways from different files), which should land first and one line of advice for each. A same-file overlap in different places is dropped when the judge says it is harmless; a collision the rule can't see is added. **Not a clash** hides a pair. |
497
+ | Backlog order | Queued items and a free slot | Within a priority (which always wins): what others depend on goes first, an item that waits for another open item or would collide with work in progress is held (🤖 Waits for …), and an item that bundles several tasks gets a split suggestion (**Split into N** / **Keep whole**). |
498
+ | Alerts | A stuck, overlap, idle, blocked or review alert is about to go to Slack | Now, in the next digest (one message every 60 minutes), or not at all. Prompts, questions and errors always go out at once. |
499
+
500
+ **It learns from you.** Dismissing a finding, sending or editing a nudge, saying **Not waiting**, answering, sending work back or accepting it, telling agents about a collision or saying **Not a clash**, and splitting or keeping an item whole are recorded (the last 60, in `~/.agentmanager/judge.json`) and shown to the judge as recent examples, so it calibrates to how you work: dismiss a kind of call often and it becomes more conservative about it.
501
+
502
+ **Cost and fallbacks.** By default the judge uses Claude's fast model (`haiku`); a call takes a few seconds. Each screen is judged once, each stuck finding at most every 15 minutes, each pair of agents when their changed files move (at most every 30 minutes), the backlog order when the queue changes, a review only when the work changed, at most 2 calls at a time and 300 a day. Calls run on your own Claude (or Codex) plan. When the judge is off, over budget, or a call fails, you get the rule-based result as before. The bottom of the **Inbox** shows today's calls with **Turn off** / **Turn on**, and so does `agentmgr judge [on|off]`. Configure it in `config.json`:
503
+
504
+ ```json
505
+ "judge": { "enabled": true, "engine": "claude", "model": "haiku", "dailyCalls": 300, "concurrency": 2, "idleSec": 20, "digestMin": 60 }
506
+ ```
507
+
508
+ `engine` can be any installed engine that makes one-shot calls (for example `codex`); `"enabled": false` brings back the purely rule-based behavior.
509
+
510
+ ## Checkpoints and forks
511
+
512
+ At the end of each turn, Agent Manager snapshots the agent's working tree as a commit under `refs/agentmgr/<agent>/<n>`. This doesn't touch the agent's branch, index or files. It records how far the conversation had got alongside. The last 40 are kept (`maxCheckpoints`); deleting the agent removes them.
513
+
514
+ **Fork** (or `agentmgr fork <agent> [-c n]`) creates a new agent:
515
+
516
+ - **Code:** a new worktree and branch at the same commit, with the same uncommitted changes as the source had at that point.
517
+ - **Conversation:** a copy of the transcript up to that point, under the fork's own session ID. The fork resumes it, so it knows everything the source knew.
518
+ - **Direction:** an optional first message, such as "try a different approach: …".
519
+
520
+ The source agent keeps running untouched.
521
+
522
+ ## Races
523
+
524
+ **+ New agents → Race variants** (or `agentmgr race start`) creates one agent per variant. Each runs in its own worktree. A variant is a model, an approach, or both: `opus`, `sonnet | keep the change minimal`, `| use a cache`. **Compare** opens the scoreboard:
525
+
526
+ - **Status and outcome**, from each agent's brief, plus its checks
527
+ - **Change**: files and lines added and removed, with the smallest marked
528
+ - **Tests**: the race's test command, run in every attempt's worktree two at a time (15-minute limit each)
529
+ - **Cost and time**
530
+ - **Diff**: each attempt's full changes against where it started
531
+
532
+ **Pick** marks the winner and can close and delete the other attempts, worktrees included.
533
+
534
+ ## Slack alerts
535
+
536
+ **Three ways to connect Slack:**
537
+
538
+ - **Workflow Builder.** Needs no app install, and can message you directly.
539
+ 1. In Slack, open *Workflows* (or *Automations*) and create a new workflow that starts **From a webhook**.
540
+ 2. Add **one variable**: name `text`, type *Text*.
541
+ 3. Add a step, **Send a message to a person** (yourself) or **…to a channel**, and insert the `text` variable as the message.
542
+ 4. Publish it and copy the web request URL (`https://hooks.slack.com/triggers/…`).
543
+ - **Incoming webhook.** Create an app at api.slack.com/apps → *Incoming Webhooks* → *Add New Webhook*, then pick a channel. Your workspace may require admin approval.
544
+ - **Bot token and channel.** If you already have a Slack app.
545
+
546
+ Then:
547
+
548
+ ```sh
549
+ agentmgr notify slack --webhook https://hooks.slack.com/triggers/… # Workflow Builder webhook
550
+ agentmgr notify slack --webhook https://hooks.slack.com/services/… # or an app's incoming webhook
551
+ agentmgr notify slack --token xoxb-… --channel '#agents' # or a bot token + channel
552
+ agentmgr notify test
553
+ ```
554
+
555
+ Or use **Alerts** in the header (on this computer only). Settings, including the webhook or token, are stored in `~/.agentmanager/notify.json` (mode 0600) and masked in the UI and API.
556
+
557
+ | Alert | Default | When |
558
+ | --- | --- | --- |
559
+ | needs input | on | A trust or permission prompt or a question menu is still unanswered after 60 s |
560
+ | review | on | A backlog item finished and is ready for your review |
561
+ | error | on | Workspace setup or launch failed |
562
+ | waiting | off | The agent finished its turn and has been idle 2 min |
563
+ | blocked | on | The agent reports it is blocked (brief status or Results outcome) |
564
+ | stuck | on | The agent seems to be going in circles (see Stuck detection) |
565
+ | conflict | on | It changes the same files as another agent in the same repo (sent once per pair) |
566
+ | question | on | It asked a question in the decision inbox |
567
+
568
+ **Message behaviour:**
569
+
570
+ - **Once per episode.** Each alert is sent once, and again only after the condition clears and comes back.
571
+ - **Skipped while watching.** Alerts are skipped while you have that agent's terminal open.
572
+ - **Contents.** Messages include the agent, project, the intent (optional) and a link. The link uses your phone address when remote access is on.
573
+
574
+ ## Phone and remote access
575
+
576
+ Remote access is **off until you turn it on**, because it opens this machine's terminals to your network (behind a sign-in). Each daemon listens on its local port + 1 (4717 → 4718). Installs from before 1.0, where it was on by default, keep it on.
577
+
578
+ ```sh
579
+ agentmgr remote on # turn it on
580
+ agentmgr remote status # prints https://<this-mac-ip>:4718/ and the sign-in QR code
581
+ agentmgr remote off # turn it off
582
+ ```
583
+
584
+ Or use **Remote access** in the header of the UI on this computer.
585
+
586
+ **Connecting a phone:**
587
+
588
+ 1. **Scan the QR code** with the phone camera. It opens the address and signs the phone in. The token rides in the `#fragment`, so it never reaches the server's logs, and the page removes it from the address bar.
589
+ 2. **Accept the certificate warning** on the first visit. The certificate is self-signed and generated with macOS's built-in `/usr/bin/openssl`. Check the SHA-256 fingerprint shown by `agentmgr remote status`, then use *Show Details → visit this website* in Safari or *Advanced → Proceed* in Chrome.
590
+ 3. **Use it.** On the phone, the terminal goes full screen with a key bar (Esc, Tab, ⇧Tab, arrows, Enter, ^C, 1–4 for Claude's menus) and a reply box. Agents that need input sort to the top, and the page title shows how many are waiting.
591
+
592
+ **Reachability.** Nothing extra is installed and no relay or tunnel is used, so the phone must be able to reach this computer directly:
593
+
594
+ - **Same network.** Use the same Wi-Fi, or join this computer to the phone's Personal Hotspot. Office Wi-Fi often blocks device-to-device traffic.
595
+ - **Corporate VPN.** A full-tunnel VPN usually routes even local-network traffic into the tunnel, so other devices can't reach the Mac while it's connected. If the phone can't load the page, disconnect the VPN (where policy allows) or use the hotspot.
596
+ - **Public IP.** A public address only works if your network forwards the port, which home routers can do and corporate networks won't. Ask IT before exposing it.
597
+
598
+ **Security.**
599
+
600
+ - **Separate listener.** Remote access is a second listener on HTTPS, all interfaces, with the local port + 1 by default. The local `127.0.0.1:4717` listener is unchanged. `AGENTMGR_REMOTE=1` (or `0`) in the environment sets the default for a daemon when you haven't chosen either way.
601
+ - **What needs sign-in.** Every API call except sign-in needs a device session (HttpOnly, Secure, SameSite=Strict cookie, 30 days, sliding). Only this machine's own addresses are accepted as `Host`, and cross-site origins are refused. Failed sign-ins are rate limited.
602
+ - **Local only.** Turning remote access on or off, the token and devices, and shutting down can only be done from this computer.
603
+ - **Devices.** `agentmgr remote rotate` (or **New access token**) signs every device out. Devices are listed with their address and last-seen time and can be signed out one by one.
604
+ - **Firewall.** If the macOS firewall is off, the port is open to your whole network while remote access is on. Turn it off when you don't need it.
605
+ - **Streaming.** The phone UI streams with Server-Sent Events plus plain HTTPS requests. iOS Safari doesn't apply an accepted self-signed certificate to WebSockets.
606
+
607
+ ## Engines: Claude Code, Codex and Antigravity
608
+
609
+ Agents run Claude Code by default. With OpenAI's Codex CLI installed (`npm i -g @openai/codex`, signed in), an agent can run Codex instead: `agentmgr add --engine codex …`, or the **Engine** picker in New agent (shown once a second engine is installed). Everything else works the same way: worktrees, the brief and questions, the inbox (Codex's approval menus included), token usage, stuck detection, PR tracking, Explain, the backlog and the hub. Codex records no cost, and planning while a repo clones and forks are Claude-only for now. Set `"engine": "codex"` in config.json to make it the default; `engines.codex.bin` points at another binary. On the hub, each machine reports the engines it has (`engine:codex`), so shared backlog work can ask for one. See [docs/engines.md](docs/engines.md).
610
+
611
+ Google's **Antigravity CLI** (`agy`, signed in with your Google account) works the same way: `--engine antigravity`. It replaced Gemini CLI for personal Google accounts in June 2026. Agent Manager adopts the conversation agy starts, resumes it with `--conversation`, reads token usage, commands and file writes from its transcript, shows its permission menus (commands, file changes, access outside the folder) in the inbox, pre-trusts agent folders in agy's settings, and runs Explain in agy's print mode. agy asks before writing the brief too, unless the agent runs in `acceptEdits` mode. `engines.antigravity.bin` points at another binary.
612
+
613
+ ## Several machines: the hub
614
+
615
+ With agents on more than one Mac, a **hub** shows all of them in one place: every machine's agents and one inbox of what needs you. Where a machine allows it, you can also act from the hub: answer, message, start and stop agents, start new ones, and open live terminals. Each Mac keeps running its own daemon. It connects out to the hub, so no ports need opening on it, and the hub's requests travel back over that same connection.
616
+
617
+ ```sh
618
+ # Where the hub runs (any Mac that stays on, or Railway):
619
+ agentmgr hub serve # this Mac and its Tailscale address; prints a sign-in link
620
+ agentmgr hub invite # one-time code, valid 10 minutes
621
+
622
+ # On each Mac to add:
623
+ agentmgr join http://<hub-tailscale-ip>:4720 ABCD-EFGH-JKLM --name laptop
624
+
625
+ agentmgr fleet # agents on every machine, and what needs you
626
+ agentmgr fleet answer laptop/3f2a1c q1 "Postgres"
627
+ agentmgr fleet tell laptop/3f2a1c "Also update the docs"
628
+ agentmgr fleet start laptop/3f2a1c # or stop
629
+ agentmgr fleet new laptop web "Add a dark mode toggle"
630
+ agentmgr fleet backlog add web "Fix the footer links" "Add a sitemap" # runs where there's room
631
+ agentmgr fleet backlog # shared backlog: where each item runs, what waits and why
632
+ agentmgr hub machines # online/offline, versions, what each allows
633
+ agentmgr hub status # this Mac's link to its hub
634
+ agentmgr leave # the hub forgets this Mac
635
+ ```
636
+
637
+ **Addresses.** Use `https://` for the hub, or plain `http://` only on this machine or over Tailscale, which already encrypts traffic. **Open** links go to each Mac's remote-access address, its Tailscale one first, so remote access must be on there (`agentmgr remote on`).
638
+
639
+ **Each Mac decides what the hub may do.** A new machine shares `view` only. More is opt-in, per machine, in its `~/.agentmanager/config.json` (restart its daemon after changing it):
640
+
641
+ ```json
642
+ { "hub": { "allow": ["view", "inbox", "control", "create", "terminal"], "projects": ["cc", "web"], "labels": ["gpu"], "maxAgents": 4, "perProject": 2 } }
643
+ ```
644
+
645
+ | Permission | The hub may |
646
+ | --- | --- |
647
+ | `view` | See agents (name, status, intent, branch, PRs, cost) and inbox items. Never code, transcripts or local paths. |
648
+ | `inbox` | Answer questions, pick a prompt's choice (this can approve a tool), send stuck nudges, warn about overlaps, answer what the AI judge read, handle AI reviews |
649
+ | `control` | Message an agent, start, stop, checkpoint, change priority |
650
+ | `create` | Start new agents in this machine's registered projects. Never with permission prompts skipped. |
651
+ | `terminal` | Open the live Claude terminal |
652
+ | `shell` | Open shells in an agent's folder. These run any command, so grant with care. |
653
+ | `signin` | Open this machine's own page already signed in: **Open on <machine>** asks for a one-time link (single use, valid for a minute) instead of the access token. That page has full control, beyond the rest of this policy, so grant it only on a hub that only you can sign in to. |
654
+
655
+ `projects` (names or shortcuts) limits all of it to those projects: other agents aren't shown and can't be touched. `"allow": []` stops sharing but stays joined. The machine checks every request itself, even if the hub thinks it's allowed, matches agents by exact ID, and only runs a fixed list of actions (deleting agents isn't one). Each request, and every refusal, is written to `~/.agentmanager/hub-audit.log`; the hub keeps its own `audit.log` too.
656
+
657
+ **The shared backlog.** Work you queue on the hub (the **Backlog** tab, or `agentmgr fleet backlog add`) starts on whichever machine can take it, one agent per item. Each item has to land on a machine that is online, allows `create` and shares the project, and that has every label the item asks for. Among those, it goes to one with room, preferring a machine that already has the repo cloned, then the least busy.
658
+
659
+ - **Projects across machines.** A project matches across machines by its repo, even under different shortcuts; projects without a remote repo match by name.
660
+ - **Room.** Each machine sets its own limits: `hub.maxAgents` in total (default `backlogMaxActive`, 4) and `hub.perProject` (default `backlogParallel`, 2). Items from its own local backlog count against them too.
661
+ - **Labels.** `os:mac` and `arch:arm64` come automatically, `machine:<name>` pins an item to one machine, and anything else comes from that machine's `hub.labels`, for example `["gpu", "fast-net"]`.
662
+ - **Review.** As with the local backlog, an agent whose brief says done moves to **review**: **Accept** finishes it, and **Reopen** sends a note back to the same agent (this needs `control` on that machine). An item waiting for room says why, for example `laptop is full (2/2 in this project)`.
663
+ - **When a machine drops mid-item.** Its item shows as **stalled** and isn't restarted elsewhere on its own, because the work in that machine's worktree would be lost or duplicated. Wait for the machine, or **Requeue** to start over on a different one.
664
+ - **Pausing.** `agentmgr fleet backlog pause` (or **Auto-start** off) stops new starts; **Start now** runs one item past the limits.
665
+
666
+ **How machines prove who they are.** Joining makes an Ed25519 key pair on the Mac. The private key stays in `~/.agentmanager/hub-link.json` (mode 600), and the hub keeps only the public key. Each connection signs a fresh challenge from the hub. Invite codes work once. **Remove** on the hub (or `agentmgr hub remove <machine>`) disconnects a machine, and it stops retrying until it joins again.
667
+
668
+ **Signing in with Google.** Set `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET` (a Web application OAuth client whose redirect URI is `<hub address>/api/auth/google/callback`) and `AGENTMGR_HUB_GOOGLE_EMAILS` (comma-separated accounts allowed in). The sign-in page then offers **Sign in with Google**, with the access token folded away below it. It uses the authorization code flow with PKCE, state and nonce, and accepts only verified emails on that list. Without the list, Google sign-in stays off.
669
+
670
+ **Signing in to the hub.** The hub has one access token: `AGENTMGR_HUB_TOKEN`, or one it generates and prints as a sign-in link (`agentmgr hub token` shows it again). Browsers get a 30-day session cookie. The CLI sends the token: on the hub's own Mac it is read from the hub's state, elsewhere set `AGENTMGR_HUB_TOKEN` and `AGENTMGR_HUB_URL`, or rely on the hub this Mac joined.
671
+
672
+ **On Railway.** `hub/Dockerfile` builds the hub alone, with no node-pty and no Claude. Set `RAILWAY_DOCKERFILE_PATH=hub/Dockerfile`, `AGENTMGR_HUB_TOKEN`, `AGENTMGR_HUB_URL` (its https address) and, for Google sign-in, the three variables above; add a volume at `/data` so enrollments survive redeploys, and join with the `https://…up.railway.app` address.
673
+
674
+ ## Saving state: flush and restart
675
+
676
+ - **What's saved immediately.** Agent records (session IDs, settings, links) are written to `state.json` on every change, fsynced, then atomically replaced. Claude writes each conversation to its own transcript as it goes.
677
+ - **What flush adds.** Each agent's terminal scrollback (restored into the terminal after a restart), session IDs Claude switched to mid-run (`/clear`), and token usage.
678
+ - **When it runs.** Every `flushSec` (30 s), on shutdown, and on demand: **Save now** in the agent list, or `agentmgr flush`.
679
+ - **Restart.** `agentmgr restart` flushes, stops the daemon (closing agents so Claude saves its sessions), and starts it again, through the login service when installed. Agents that were running resume with the same session IDs.
680
+
681
+ ## Folder trust
682
+
683
+ Before launching Claude in a folder, agentmgr marks that folder as trusted in Claude Code's config (`~/.claude.json`, `projects[<path>].hasTrustDialogAccepted`). That is the same record Claude writes when you choose "Yes, I trust this folder". It only does this for the folders agents run in: workspaces, the planning folder, general sessions and folders you pass with `-d`.
684
+
685
+ The first change keeps a backup at `~/.claude.json.agentmgr-backup`. Trusting a folder lets Claude load that repo's project settings and hooks without asking, so set `"trustAgentFolders": false` if you'd rather review repos first.
686
+
687
+ ## Tokens and cost
688
+
689
+ Usage comes from the session transcripts and is refreshed every few seconds while an agent runs:
690
+
691
+ - **Sources.** Input, output, cache-write and cache-read tokens for every API request, including the session's subagents.
692
+ - **Where it shows.** Per session in **Session history** and `agentmgr sessions`, and summed per agent in the list, the session card, `agentmgr ls` (TOKENS) and `agentmgr show`.
693
+ - **Cost.** The figure Claude Code records itself (`cost-state`), shown once it has written one.
694
+
695
+ ## Shell and general sessions
696
+
697
+ - **Open shell** (or `agentmgr shell <agent>`) starts `$SHELL -l` in the agent's working folder. It shows as a **Shell 1** tab next to the **Claude** tab in the terminal pane; **+ Shell** (or `agentmgr shell <agent> -n 2`) opens more, and **×** on a tab closes that shell. Shells live as long as the daemon and don't start Claude.
698
+ - **+ Browser** opens a tab on an address: a port (`5173`), a local address (`localhost:3000/app`), something on the machine's network (`10.0.0.7:8080`, `staging.internal`) or any site (`example.com`, which defaults to https). Tabs are kept with the agent, so every device sees them, and **×** closes one.
699
+ - **On this computer** the tab loads the address directly. Many public sites refuse to appear inside another page, so use **↗** for those.
700
+ - **From another device** (remote access), Agent Manager gives each site its own HTTPS port. That port relays to the site as the machine sees it, so you can check from your phone what the agent built or what the machine can reach. Absolute links, redirects and hot-reload WebSockets on the same site keep working, and the site's "don't show me in a frame" headers are dropped. A link or redirect to a different site leaves the relay.
701
+ - **Safety:** the relay serves only signed-in devices. It never relays to Agent Manager's own ports on any of the machine's addresses, and it removes Agent Manager's sign-in cookie before forwarding. Sites other than localhost must present a valid certificate. The relays close when remote access is turned off.
702
+ - If a tab stays blank on a device, open it once with **↗** and accept the certificate there.
703
+ - **Ask Claude** (or `agentmgr ask`) creates a `general` agent. All general sessions share `~/.agentmanager/general`, so Claude's folder-trust prompt only appears the first time.
704
+
705
+ ## Configuration
706
+
707
+ State lives in `~/.agentmanager/` (`state.json`, `daemon.log`, `repos/` for shared clones, `workspaces/` for worktrees). Set `AGENTMGR_HOME` or `AGENTMGR_PORT` to change the location or port. Optional `~/.agentmanager/config.json`:
708
+
709
+ ```json
710
+ {
711
+ "claudeArgs": ["--model", "opus"],
712
+ "permissionMode": "acceptEdits",
713
+ "bugPatterns": ["\\bABC-\\d+\\b"],
714
+ "gitRefreshSec": 15,
715
+ "prRefreshSec": 120,
716
+ "autoResume": true,
717
+ "trustAgentFolders": true,
718
+ "brief": true,
719
+ "explainModel": null,
720
+ "summaryConcurrency": 2,
721
+ "flushSec": 30,
722
+ "backlogParallel": 2,
723
+ "backlogMaxActive": 4,
724
+ "reviewConventions": true,
725
+ "handoffIdleSec": 5,
726
+ "cloneFilter": "blob:none",
727
+ "shell": "/bin/zsh",
728
+ "inbox": true,
729
+ "maxCheckpoints": 40,
730
+ "raceTestTimeoutSec": 900,
731
+ "conflictRefreshSec": 60,
732
+ "stuck": { "repeatFailures": 3, "thrashReverts": 2, "thrashEdits": 10, "driftMinutes": 20, "driftActions": 25 },
733
+ "judge": { "enabled": true, "model": "haiku", "dailyCalls": 300 },
734
+ "hub": { "allow": ["view"], "projects": ["*"] }
735
+ }
736
+ ```
737
+
738
+ ## Security
739
+
740
+ The daemon drives real terminals, so it is locked down to this machine:
741
+
742
+ - It listens on `127.0.0.1` only.
743
+ - It rejects requests whose `Host` is not loopback, which blocks DNS rebinding.
744
+ - It rejects browser requests from any other origin, which blocks cross-site WebSockets.
745
+ - Every write needs an `x-agentmgr` header, which browsers can't send cross-origin.
746
+
747
+ Anyone with a shell on the machine as your user can still use it.
748
+
749
+ ## Notes
750
+
751
+ - Agents live in the daemon process. A daemon restart closes them, saving their sessions, and resumes them when it starts again. The terminal scrollback starts fresh; Claude redraws the conversation when it resumes.
752
+ - Child `claude` processes get a clean environment. The markers a parent Claude Code session sets (such as `CLAUDE_CODE_CHILD_SESSION`) are removed, because inherited markers switch transcript saving off and then the session can't be resumed.
753
+ - `rm --delete-workspace` only deletes worktrees and folders agentmgr created, never a folder you passed with `-d`.
754
+
755
+ ## Development
756
+
757
+ ```sh
758
+ npm test # unit tests + end-to-end daemon tests against a stub claude (test/fake-claude.js)
759
+ ```
760
+
761
+ ## Contributing, security and license
762
+
763
+ - How the code fits together: [docs/architecture.md](docs/architecture.md). Extending it from a separate package (policies, audit, routes, engines, hub sign-in): [docs/plugins.md](docs/plugins.md). How to contribute: [CONTRIBUTING.md](CONTRIBUTING.md). Changes per release: [CHANGELOG.md](CHANGELOG.md).
764
+ - Security model and how to report a problem privately: [SECURITY.md](SECURITY.md).
765
+ - Agent Manager sends no telemetry.
766
+ - Agent Manager runs the agent CLIs you install and sign in to (Claude Code, Codex, Antigravity) with your own accounts. Use them within your provider's terms.
767
+ - Maintained in spare time. Issues and pull requests are welcome; replies may take a few days.
768
+ - Licensed under the [Apache License 2.0](LICENSE).