@team-agent/installer 0.5.89 → 0.5.91

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 (30) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/crates/team-agent/src/cli/adapters.rs +102 -162
  4. package/crates/team-agent/src/cli/emit.rs +12 -75
  5. package/crates/team-agent/src/cli/mod.rs +1 -1
  6. package/crates/team-agent/src/cli/spec.rs +1 -4
  7. package/crates/team-agent/src/cli/status_port/inbox.rs +42 -17
  8. package/crates/team-agent/src/cli/tests/lane_c.rs +34 -26
  9. package/crates/team-agent/src/cli/tests/main_preserved.rs +4 -70
  10. package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -68
  11. package/crates/team-agent/src/cli/types.rs +3 -16
  12. package/crates/team-agent/src/coordinator/tests/tick_core.rs +5 -6
  13. package/crates/team-agent/src/coordinator/tick.rs +1 -16
  14. package/crates/team-agent/src/coordinator/types.rs +1 -1
  15. package/crates/team-agent/src/db/message_store.rs +10 -5
  16. package/crates/team-agent/src/fake_worker.rs +4 -4
  17. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +2 -2
  18. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -10
  19. package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +2 -9
  20. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +1 -26
  21. package/crates/team-agent/src/main.rs +7 -2
  22. package/crates/team-agent/src/mcp_server/mod.rs +1 -1
  23. package/crates/team-agent/src/messaging/mod.rs +2 -2
  24. package/crates/team-agent/src/messaging/results.rs +234 -386
  25. package/crates/team-agent/src/messaging/tests/runtime.rs +91 -135
  26. package/crates/team-agent/src/messaging/watchers.rs +1 -1
  27. package/package.json +4 -4
  28. package/skills/team-agent/SKILL.md +3 -3
  29. package/skills/team-agent/command-coverage.json +2 -9
  30. package/skills/team-agent/references/team-agent-operator.md +661 -0
@@ -0,0 +1,661 @@
1
+ # Team Agent operator handbook
2
+
3
+ This is the long-form operator reference. The sealed CLI face is `skills/team-agent/SKILL.md` (≤60 lines). Do not drop the r13-corrected 0.5.66 facts below.
4
+
5
+
6
+ # Team Agent
7
+
8
+ Use this skill only for Team Agent operation. The leader is the current user-facing agent; do not create a `leader` worker. Worker role docs live in `<workspace>/agents/`; `TEAM.md` lives at `<workspace>/TEAM.md`.
9
+
10
+ If `team-agent --version` does not match `last_verified_against` in the frontmatter, **do not copy examples from this file as current truth**. Learn from the live CLI first:
11
+
12
+ ```bash
13
+ team-agent --version
14
+ team-agent --help
15
+ team-agent doctor --help
16
+ ```
17
+
18
+ Observed on the writing gauge: `team-agent 0.5.66` (exit 0); `doctor --help` prints `usage: team-agent doctor [SPEC] [--workspace WORKSPACE] [--team TEAM] [--gate orphans|comms] [--comms] [--fix] [--fix-schema] [--cleanup-orphans] [--confirm] [--json]` (exit 0).
19
+
20
+ This page documents **installed CLI 0.5.66**. Claims below are paired with a command you can re-run; do not fill gaps by `strings` on the binary. **Never rewrite a user-supplied model id.** Only verify and report.
21
+
22
+ Gauge used while writing (re-check on your machine):
23
+
24
+ ```text
25
+ /Users/alauda/.team-agent/runtime/0.5.66/bin/team-agent
26
+ md5=5dfc5fc770eb91d8104ab503704112ec
27
+ mtime=2026-08-20T03:06:49
28
+ team-agent 0.5.66
29
+ ```
30
+
31
+ ```bash
32
+ team-agent --version
33
+ ```
34
+
35
+ Observed: `team-agent 0.5.66` (exit 0).
36
+
37
+ ## Leader Requirement
38
+
39
+ Real Team Agent teams require the current leader to run inside a tmux-managed pane. Prefer the short launchers:
40
+
41
+ ```bash
42
+ team-agent codex
43
+ team-agent claude
44
+ ```
45
+
46
+ Pass provider flags after the provider name, for example `team-agent codex --dangerously-bypass-approvals-and-sandbox`. Existing tmux layouts are valid too, including Finder/Ghostty launchers, as long as `team-agent quick-start` is invoked from the leader's current tmux pane. Do not start a real team from a naked terminal that Team Agent cannot address through tmux.
47
+
48
+ **0.5.66:** leader `--dangerously-*` flags no longer inherit bypass to workers. Per-worker bypass is the role field `dangerously_skip_permissions` (see Permissions).
49
+
50
+ ## Leader Role
51
+
52
+ Invoking this skill turns the current agent into the team leader. The leader **orchestrates**: read reports, set direction, decompose work, dispatch tasks to teammates, review results, and decide. The leader does **not** execute hands-on work — no `cargo test`, no product-code edits, no `git push`, no build/verify cycles. Those belong to teammates. If the leader catches themselves running tests, editing source files, or pushing commits, they have stepped out of role; stop and re-dispatch.
53
+
54
+ When the user has been communicating in Chinese throughout the conversation, all leader↔teammate messaging (`send`, `report_result`, MCP messages, task descriptions) must also be in Chinese. The leader dispatches in Chinese, the worker reports back in Chinese. Switch back to the user's language only at the user-facing boundary.
55
+
56
+ ## Minimal Copy-Paste Team
57
+
58
+ `dangerously_skip_permissions` is **required** on every role doc (boolean). `TEAM.md` `dangerous_auto_approve` is **not** the 0.5.66 bypass switch (see Permissions). Values under `provider_models:` below are **fill-ins for omitted role `model`**, not a validity catalog (lookup: `team-agent compile --team <dir> --out /tmp/spec.yaml --json` and read the compiled agent `model`).
59
+
60
+ ```bash
61
+ mkdir -p .team/current/agents
62
+ team-agent profile init codex-default --auth-mode subscription --workspace .
63
+ cat > .team/current/TEAM.md <<'EOF'
64
+ ---
65
+ name: demo-team
66
+ objective: One worker handles bounded tasks and reports through Team Agent MCP.
67
+ dangerous_auto_approve: false
68
+ fast: false
69
+ provider_models:
70
+ codex: gpt-5.5
71
+ claude: claude-sonnet-4-6
72
+ claude_code: claude-sonnet-4-6
73
+ ---
74
+
75
+ Team config only. This is not a worker role.
76
+ EOF
77
+ cat > .team/current/agents/coder.md <<'EOF'
78
+ ---
79
+ name: coder
80
+ role: Implementation Worker
81
+ provider: codex
82
+ auth_mode: subscription
83
+ profile: codex-default
84
+ dangerously_skip_permissions: false
85
+ tools:
86
+ - fs_read
87
+ - fs_list
88
+ - fs_write
89
+ - execute_bash
90
+ - mcp_team
91
+ - provider_builtin
92
+ ---
93
+
94
+ Handle one bounded task at a time. Send progress to leader only when needed. Final completion must call report_result exactly once; MCP fills task ids and result envelope fields.
95
+ EOF
96
+ team-agent quick-start .team/current
97
+ ```
98
+
99
+ YAML lists must be block style. Use `tools:\n - fs_read`; do not use `tools: [fs_read, mcp_team]`.
100
+
101
+ Display choices (set `display_backend:` in `TEAM.md` to opt in):
102
+
103
+ - `none` (default): headless / no GUI window manager. The team runs entirely in the per-workspace tmux server; this is what the demo above uses.
104
+ - `adaptive`: framework picks an available GUI layout for the local platform.
105
+ - `ghostty_workspace`: one Ghostty window. Workers are shown in tmux tabs/windows, up to 3 side-by-side panes per tab. Four workers become `3 + 1`; eight become `3 + 3 + 2`.
106
+ - `ghostty_window`: one Ghostty window per worker.
107
+
108
+ **Omitting `display_backend` defaults to `none`** (changed in 0.3.4). Set `display_backend: adaptive` (or one of the explicit ghostty variants) in `TEAM.md` only when the user wants GUI windows.
109
+
110
+ ## Private Tmux Socket
111
+
112
+ Worker windows live on a private per-workspace tmux server, not the user's default socket. `tmux list-sessions` (no `-L`/`-S`) will not show them; that is expected, not a failure.
113
+
114
+ To attach manually, read `attach_commands` (or the `tmux` action printed near `ready:`) from `team-agent quick-start` / `team-agent restart` / `team-agent status --json` output. It is the canonical `tmux -L <socket-name> attach -t <session>` (or `-S <socket-path>`) line for the current team.
115
+
116
+ Use `team-agent attach-leader` / `team-agent claim-leader` to bind the leader pane to a team. Do not invent socket paths by hand.
117
+
118
+ ```bash
119
+ team-agent claim-leader --help
120
+ ```
121
+
122
+ Observed (exit 0):
123
+
124
+ ```text
125
+ usage: team-agent claim-leader [--workspace WORKSPACE] [--team TEAM] [--confirm] [--json]
126
+ ```
127
+
128
+ Run `claim-leader` only from the **leader** pane. From a worker pane it refuses and prints a structured `action` (see Failure Rules).
129
+
130
+ ## Provider Capability Matrix
131
+
132
+ | Provider | Resume | Turn-state detection | Per-worker model override | Native session fork |
133
+ |---|---|---|---|---|
134
+ | `claude` / `claude_code` | yes (`--resume <id>`, transcript-verified) | yes (JSONL stream) | yes (role `model` overrides `provider_models`) | yes (snapshot copy + only `--resume <snapshot-id>`) |
135
+ | `codex` | yes (`codex resume <id>`, session-store-verified) | yes (turn JSONL) | yes (role `model`) | yes (`codex fork`) |
136
+ | `copilot` | yes (`copilot --resume <id|name>`, sqlite `sessions` row) | not yet (phase 1: `provider.classify.unsupported` event) | yes (role `model`) | yes (isolated `COPILOT_HOME` store fork) |
137
+ | `gemini_cli` | no | no | yes | no |
138
+ | `fake` (testing only) | no | no | n/a | no |
139
+
140
+ Notes:
141
+ - Per-worker model override means a role-doc `model:` value wins over `TEAM.md` `provider_models.<provider>` at **compile** time; subscription defaults still fill blanks when there is no profile-deferred null.
142
+ - Copilot fork copies the source session into an isolated `COPILOT_HOME` and rekeys its SQLite session references atomically. Missing or incomplete backing fails closed; it never falls back to a fresh spawn.
143
+ - Copilot phase-1 idle/turn detection is intentionally Unknown; tick emits a single explicit `provider.classify.unsupported` event per state change (P4 dedup), never a silent default.
144
+
145
+ ## Provider Prep
146
+
147
+ ### Subscription auth (Codex / Claude account login)
148
+
149
+ Before workers can use a subscription provider, create a named subscription profile in the workspace and reference it from role docs:
150
+
151
+ ```bash
152
+ team-agent profile init codex-default --auth-mode subscription --workspace .
153
+ team-agent profile init claude-default --auth-mode subscription --workspace .
154
+ ```
155
+
156
+ Then in `agents/<role>.md` frontmatter, set `auth_mode: subscription` and `profile: codex-default` (or `claude-default`). The demo above uses `profile: codex-default`; that name only works after `profile init` has created it in the same workspace.
157
+
158
+ Common errors:
159
+
160
+ - `profile already exists`: a profile by that name is already in `.team/current/profiles/`. Either reuse it (skip `init`) or pick a new name.
161
+ - `profile not found` during quick-start: the role doc references a profile that was never `profile init`-ed in this workspace. Run `team-agent profile init <name> --auth-mode subscription --workspace .` and retry.
162
+
163
+ ### Codex provider notes
164
+
165
+ Codex: run `codex login` first. Optional `~/.codex/config.toml` profile:
166
+
167
+ ```toml
168
+ [profiles.team-agent]
169
+ model = "gpt-5.5"
170
+ approval_policy = "on-request"
171
+ sandbox_mode = "workspace-write"
172
+ ```
173
+
174
+ Use exact provider model ids, not display names. **Codex slug lookup is Codex-only** — do not apply it to `compatible_api` workers.
175
+
176
+ ```bash
177
+ codex debug models
178
+ ```
179
+
180
+ That command is the Codex catalog. This skill does **not** keep a model id list. If `codex` is not on PATH, the lookup is unavailable; do not invent slugs.
181
+
182
+ Role docs may omit `model` for non-grok subscription workers; compile then fills from `TEAM.md` `provider_models` or leaves `null` when a profile is present (see compatible_api). **Do not treat those fill-ins as a validity catalog.** **Grok roles cannot omit `model`** — compile fails closed (same `compile --team` command as below).
183
+
184
+ Claude: run `claude auth status`; if missing, run `claude auth login`. Team Agent stores Claude worker sessions by passing `--session-id` and resumes with `--resume`.
185
+ Use `provider: claude` or `provider: claude_code` for Claude workers.
186
+
187
+ Role `profile` values are secret-safe references. Do not put API keys in role docs or `TEAM.md`.
188
+ Never read raw provider profile files into model context. Do not use `Read`, `cat`, `sed`, `grep`, editors, or screenshots on `.team/current/profiles/*.env` or `.team/runtime/provider-env/*.env`. Those files may contain live API keys. Use only `team-agent profile show <name> --workspace . --json` or `team-agent profile doctor <name> --workspace . --json` for redacted diagnostics; if a value is missing, ask the human user to edit the local profile file.
189
+
190
+ ## compatible_api model rules
191
+
192
+ **Only verify. Only report. Never rewrite a user-explicit model id** (role `model` or profile `MODEL`). Do not keep a catalog of legal ids in this skill. Compatible-API ids are whatever the endpoint serves.
193
+
194
+ When the user asks for a third-party API, do not ask them to paste keys into the chat. Generate a local blank profile:
195
+
196
+ ```bash
197
+ team-agent profile init deepseek --auth-mode compatible_api --workspace .
198
+ ```
199
+
200
+ Tell the user to fill `.team/current/profiles/deepseek.env` locally (`AUTH_MODE`, `PROFILE_NAME`, `BASE_URL`, `API_KEY`, `MODEL`). Then reference `auth_mode: compatible_api` and `profile: deepseek` in the role doc.
201
+
202
+ Inspect without opening the `.env`:
203
+
204
+ ```bash
205
+ team-agent profile show deepseek --workspace . --json
206
+ ```
207
+
208
+ Observed on a freshly inited profile (exit 0): `ok: true`, `auth_mode: "compatible_api"`, `keys_present` includes `MODEL` and `BASE_URL`, `secret_values_printed: false`.
209
+
210
+ How to see whether the **endpoint** accepts the id (ask the human to run these with their `BASE_URL`; do not read the `.env` yourself):
211
+
212
+ ```bash
213
+ # 1) live catalog (OpenAI-shaped). Replace BASE_URL. Do not treat HTTP errors as "illegal id".
214
+ curl -sS --max-time 5 -H "Authorization: Bearer $API_KEY" "$BASE_URL/v1/models"
215
+ ```
216
+
217
+ Writing-gauge shape check without a real endpoint. `--noproxy '*'` pins a direct connect so ambient HTTP(S)_PROXY cannot rewrite the process exit. This is a **liveness probe of the lookup command**, not a model list:
218
+
219
+ ```bash
220
+ curl --noproxy '*' -sS --max-time 5 http://127.0.0.1:1/v1/models
221
+ ```
222
+
223
+ Observed (exit 7): stderr contains `Couldn't connect to server` / `Failed to connect to 127.0.0.1 port 1`. Gauge `/usr/bin/curl` (md5 `10a716a5b63881997d819ef693d4a802`). Port 1 is not a service.
224
+
225
+ Dropping `--noproxy` is a different environment: an intercepting proxy may return an HTML error page (a prior writing seat saw Squid `ERR_CONNECT_FAIL`) and the process exit can be 0. This turn did not re-measure that intercept. Do not record 0 as this `--noproxy` fence's expected exit.
226
+
227
+ If the endpoint has no `/v1/models`, probe with a 1-token completion (human runs this; this writing turn did **not** hit a live chat endpoint):
228
+
229
+ ```text
230
+ POST {BASE_URL}/v1/chat/completions
231
+ {"model":"<the user-supplied id>","messages":[{"role":"user","content":"ping"}],"max_tokens":1}
232
+ ```
233
+
234
+ Fail = report the HTTP/body. Success = leave the id alone. **Do not substitute a different id.**
235
+
236
+ How compile currently wires role `model` vs profile `MODEL` (not a validity list):
237
+
238
+ ```bash
239
+ team-agent compile --help
240
+ ```
241
+
242
+ Observed (exit 0): `usage: team-agent compile --team TEAM [--out FILE] [--json]`.
243
+
244
+ Recreate: `auth_mode: compatible_api` without `profile` → compile exit 1 `profile is required when auth_mode is 'compatible_api'`. Role `model:` set + `profile:` set → compiled agent `model` is the role string; profile `MODEL` is not read at compile. Role omits `model` + `profile:` → compiled `model: null`. Compile does **not** compare the two. Whether launch refuses a mismatch was **not** spawned-verified.
245
+
246
+ How to check `--auth-mode` literals (the CLI does not print an allow-list on this gauge):
247
+
248
+ ```bash
249
+ team-agent profile init x --auth-mode not-a-mode --workspace /tmp/ta-skill-no-runtime --json
250
+ ```
251
+
252
+ Observed (exit 1): `usage error: invalid --auth-mode: not-a-mode`. That is the lookup: try the value, read the error. Do not maintain a mode table here.
253
+
254
+ Team Agent loads the profile during quick-start, launch, restart, and start-agent. Compatible API workers inherit the current shell proxy/CA environment by default. Claude compatible API workers use Team Agent managed `CLAUDE_CONFIG_DIR` so user-level Claude subscription settings cannot re-inject Anthropic proxy variables into third-party API sessions. If quick-start reports an ambient proxy blocker, do not silently unset proxy for the whole team; tell the user to choose one path: fix that proxy for `BASE_URL`, put `HTTPS_PROXY=`/`HTTP_PROXY=` in the profile, or put `PROXY_MODE=direct` in the profile to bypass proxy only for that worker. Subscription workers keep their native provider settings and environment. Startup runs a redacted smoke check for compatible API profiles before worker windows are created, so a bad URL/key/model or proxy/base URL connectivity failure is reported to the leader command instead of producing idle workers.
255
+
256
+ ## How role-doc frontmatter becomes live
257
+
258
+ ```bash
259
+ team-agent restart --help
260
+ team-agent add-agent --help
261
+ team-agent shutdown --help
262
+ ```
263
+
264
+ Observed (all exit 0):
265
+
266
+ ```text
267
+ usage: team-agent restart [WORKSPACE] [--team TEAM] [--allow-fresh] [--session-converge-deadline SECONDS] [--json]
268
+ usage: team-agent add-agent AGENT --role-file FILE [--force] [--workspace WORKSPACE] [--team TEAM] [--no-display] [--json]
269
+ usage: team-agent shutdown [--workspace WORKSPACE] [--team TEAM] [--keep-logs] [--json]
270
+ ```
271
+
272
+ Top-level help names `add-agent` as **add or force-recreate a worker**. `restart` does **not** take `--role-file`. Editing `agents/*.md` then running `restart` is therefore not a documented reread path.
273
+
274
+ To apply a changed role file to an **existing** worker name, use `add-agent --force --role-file <file>` (the `--role-file` flag is the reread).
275
+
276
+ `shutdown` stops the selected team. `restart` restarts it. This pair was **not** live-verified as a frontmatter reread; do not assume it recompiles `agents/*.md`. Prefer `add-agent --force --role-file` when the help surface names `--role-file`.
277
+
278
+ `restart --force` is **not** listed in `--help`. Passing it to a workspace with no team is a team-select error, not a usage error — so the flag is accepted. Its live-team meaning is **unverified** on this gauge; do not invent it.
279
+
280
+ Do **not** shutdown/restart the whole team just to add a **new** worker (that drops other workers' resumable sessions). Use `add-agent` without `--force` for a new name.
281
+
282
+ ## Permissions (0.5.66)
283
+
284
+ There is **no** `team-agent permission-modes` command.
285
+
286
+ ```bash
287
+ team-agent permission-modes
288
+ ```
289
+
290
+ Observed (exit 1): `invalid choice: 'permission-modes'`.
291
+
292
+ `team-agent --help` does **not** list `permission_mode`, `TEAM_AGENT_LEADER_BYPASS`, or `dangerous_auto_approve`. Lookup is `team-agent compile` / `team-agent validate` on a throwaway team dir, not a flag enum.
293
+
294
+ ### Live control: role `dangerously_skip_permissions`
295
+
296
+ Required boolean on every role doc. Missing or non-bool fails compile.
297
+
298
+ Recreate:
299
+
300
+ ```bash
301
+ d=$(mktemp -d) && mkdir -p "$d/agents"
302
+ printf '%s\n' '---' 'name: t' 'objective: t' 'provider: fake' '---' 'x' > "$d/TEAM.md"
303
+ printf '%s\n' '---' 'name: coder' 'role: Worker' 'provider: fake' 'model: fake' 'auth_mode: subscription' 'tools:' ' - mcp_team' '---' 'b' > "$d/agents/coder.md"
304
+ team-agent compile --team "$d" --out /tmp/ta-compile-out.yaml --json
305
+ ```
306
+
307
+ Observed (exit 1): `missing front matter field dangerously_skip_permissions. This field must be declared explicitly; it controls whether the agent launches with permission prompts bypassed.` JSON also includes `"action": "run \`team-agent doctor\` or inspect the log path shown here"`.
308
+
309
+ Non-bool (`dangerously_skip_permissions: bypass`) observed (exit 1): `front matter field dangerously_skip_permissions must be a boolean.`
310
+
311
+ Legal values reachable from that error: **boolean `true` or `false`**. No other literals are accepted.
312
+
313
+ `true` is the per-worker bypass opt-in. `false` is the default you should copy unless the user explicitly wants prompts skipped.
314
+
315
+ ### `permission_mode` (historical, not consumed)
316
+
317
+ A role may still contain `permission_mode`. Compile **does not** validate it and **does not** copy it into the compiled spec.
318
+
319
+ Observed: `permission_mode: bypass` and `permission_mode: not-a-mode` both compiled `ok: true` (exit 0); the spec agent block had `dangerously_skip_permissions: false` and **no** `permission_mode` key.
320
+
321
+ Do not set `permission_mode: bypass` expecting 0.5.66 bypass. Use `dangerously_skip_permissions: true`.
322
+
323
+ ### `TEAM.md` `dangerous_auto_approve`
324
+
325
+ The demo `TEAM.md` still shows `dangerous_auto_approve: false`. Compile of a team with `dangerous_auto_approve: true` produced a spec **without** that key on the agent (only `dangerously_skip_permissions`). Treat it as leftover team YAML, not the bypass switch.
326
+
327
+ `dangerous_auto_approve` as a **tool sentinel** is internal (adapters). Operators do not configure it as a tools list item.
328
+
329
+ ### `TEAM_AGENT_LEADER_BYPASS`
330
+
331
+ Not in `team-agent --help`. Not a user-facing config key. Do not export it by hand. Worker env injection was **not** live-spawned on this gauge.
332
+
333
+ ### Leader argv bypass
334
+
335
+ Leader `--dangerously-*` is detected only as a **warning**, not as worker bypass (`detect_bypass_flag_in_argv` — "只做检测,不做行为决策"). Declare `dangerously_skip_permissions` per role.
336
+
337
+ ### Priority — 未找到单一裁决点
338
+
339
+ An external report ranked `permission_mode` > `TEAM_AGENT_LEADER_BYPASS` > `TEAM.md` `dangerous_auto_approve`. **That ranking is not in this tree.** Grep of `crates/` found **no** function that takes those three keys and picks a winner (search: `permission_mode.*TEAM_AGENT_LEADER_BYPASS` and the reverse: zero hits).
340
+
341
+ What the sources actually do (reader can re-open these files):
342
+
343
+ | Symbol | File | What it does |
344
+ |---|---|---|
345
+ | `required_dangerously_skip_permissions` | `crates/team-agent/src/compiler.rs` | Compile **requires** role `dangerously_skip_permissions` bool. This is the 0.5.66 worker bypass source. |
346
+ | `resolved_tool_strings_for_command` | `crates/team-agent/src/lifecycle/worker_command_context.rs` | `true` appends tool sentinel `dangerous_auto_approve`; comment: no longer consumes team/runtime/leader `DangerousApproval`. |
347
+ | `provider_bypass_flag` | `crates/team-agent/src/provider/bypass_flags.rs` | **唯一权威**: role `dangerously_skip_permissions: true` decides whether to add a provider bypass argv flag. Maps provider → flag string only. |
348
+ | spec allowed key `permission_mode` | `crates/team-agent/src/model/spec.rs` | Historical; **not consumed** by compiler (comment: 0.5.66 起不再被 compiler 消费). CLI compile of `permission_mode: bypass` and `permission_mode: not-a-mode` both `ok: true` with the key absent from spec. |
349
+ | `apply_mcp_auto_approval_env` | `crates/team-agent/src/lifecycle/launch/worker_env.rs` | Writes `TEAM_AGENT_LEADER_BYPASS` `1`/`0` from `DangerousApproval` when source is `LeaderProcess`. Separate from compile. |
350
+ | `worker_spawn_env` test | `crates/team-agent/src/layout/worker_env.rs` | **Strips** inherited `TEAM_AGENT_LEADER_BYPASS` from parent env. |
351
+ | `claude_dangerous_auto_approve` (and siblings) | `crates/team-agent/src/provider/adapters/*.rs` | Adapters look for tool name `dangerous_auto_approve`, not `TEAM.md`. |
352
+
353
+ **Do not copy a three-row priority table.** The live operator knob on this gauge is role `dangerously_skip_permissions`. The three names from the report still exist as strings; they are not one ranked merge.
354
+
355
+ ## Ignore vs handle (status / alerts)
356
+
357
+ ```bash
358
+ team-agent status --help
359
+ ```
360
+
361
+ Observed (exit 0):
362
+
363
+ ```text
364
+ usage: team-agent status [AGENT] [--workspace WORKSPACE] [--team TEAM] [--summary|--json] [--detail]
365
+ 默认输出: worker,空闲|工作|错误;错误细分走 status --summary
366
+ ```
367
+
368
+ ```bash
369
+ team-agent status --json --workspace /tmp/ta-skill-no-runtime
370
+ ```
371
+
372
+ On a directory with **no** running team, observed (exit 0): `"ok": true`, `"ready": false`, `not_ready.reasons` included `coordinator_not_running`, `tmux_session_missing`, `workers_not_spawned`, `leader_receiver_unbound`, `next_action: claim-leader`. Create the dir if needed: `mkdir -p /tmp/ta-skill-no-runtime`.
373
+
374
+ That combination is **not** a crash. `ok: true` with `ready: false` means the command ran and the team is not ready.
375
+
376
+ | Signal | Treat as | What to do |
377
+ |---|---|---|
378
+ | `ok: true` + `ready: true` | normal | continue |
379
+ | `ok: true` + `ready: false` + `tmux_session_missing` / `coordinator_not_running` on a workspace you did not start | expected empty workspace | start the team, or pick the right `--workspace` / `--team` |
380
+ | `coordinator.session_missing` then `status --json` shows `ready: true` or workers still `running` | self-healing transient | do **not** shutdown; wait and re-check `ready` |
381
+ | `auto_attach_leader` / `leader pane validation failed` while the command still reports `ok: true` | info for external-leader setups (report §3.6) | ignore the word `failed`; look at `ok`. **This exact stderr string was not reproduced on this gauge.** |
382
+ | `result_success_without_executed_tests` on a non-coding task | advisory | ignore |
383
+ | structured `ok: false` with `action` | handle | run the `action` (see Failure Rules) |
384
+ | `caller_not_leader_shaped` from `claim-leader` | handle | run `claim-leader` from the leader pane, not a worker pane |
385
+
386
+ ## coordinator.session_missing
387
+
388
+ `status --json` can list `tmux_session_missing` while `ok` is still true (observed on an empty workspace). For a **running** team, re-check:
389
+
390
+ ```bash
391
+ team-agent status --json
392
+ ```
393
+
394
+ If `ready` is true, or agents show `"status": "running"`, continue. Do not stop the team and wait for the user solely because a coordinator line said session missing.
395
+
396
+ Live-team sample on this writer seat (exit 0): agents including `developer-d108` with `"status": "running"`. That is the "still alive" side of the check.
397
+
398
+ ## `--watch-result` is deprecated
399
+
400
+ ```bash
401
+ team-agent send --help
402
+ ```
403
+
404
+ Observed (exit 0):
405
+
406
+ ```text
407
+ usage: team-agent send TO MESSAGE... [--workspace WORKSPACE] [--team TEAM] [--mailbox] [--json]
408
+
409
+ TO is a logical recipient; send returns after the message is persisted. --mailbox stores durably without live injection; omitted sends to the live conversation.
410
+ ```
411
+
412
+ `--watch-result` is **not** in that usage. Passing it still warns:
413
+
414
+ ```bash
415
+ mkdir -p /tmp/ta-skill-no-runtime
416
+ team-agent send --watch-result coder hello --workspace /tmp/ta-skill-no-runtime --json
417
+ ```
418
+
419
+ Observed stderr (exit is the send result, here 1 because the probe dir had no runtime state):
420
+
421
+ ```text
422
+ warning: --watch-result is deprecated; sunset: next compatibility release; action: use positional logical TO and the returned message id
423
+ ```
424
+
425
+ **New write:** positional logical TO, then use the returned `message_id` (and `team-agent results --case` / coordinator notify). Do not poll `sleep` / `status` / `inbox` after a successful send unless the user asked for diagnosis.
426
+
427
+ ```text
428
+ team-agent send coder "Do the bounded task"
429
+ team-agent send reviewer "Review this change"
430
+ team-agent send /full/path/to/workspace::team-name/agent-id "cross-workspace note"
431
+ ```
432
+
433
+ ```bash
434
+ team-agent results --help
435
+ ```
436
+
437
+ `results --help` observed (exit 0): `usage: team-agent results --case CASE_ID [--workspace WORKSPACE] [--team TEAM] [--json]`.
438
+
439
+ On success, `send --json` includes `message_id`. The deprecation warning itself does **not** print a full example (product backlog).
440
+
441
+ ## Commands
442
+
443
+ - `team-agent codex ...` starts or attaches a tmux-managed Codex leader in the current directory; arguments after `codex` pass through to Codex.
444
+ - `team-agent claude ...` starts or attaches a tmux-managed Claude leader in the current directory; arguments after `claude` pass through to Claude.
445
+ - `team-agent quick-start .team/current` starts workers from `TEAM.md` and `agents/*.md`. When it prints `ready:` and `ready_signal`, startup is complete; do not run sleep/status/wait loops afterward unless diagnosing a failure.
446
+ - For real workers, `quick-start` requires a current tmux leader pane. If it says the leader must run inside tmux, restart the leader with `team-agent codex`/`team-agent claude` or use an existing tmux-managed layout, then run quick-start again.
447
+ - Quick-start generated files stay inside the selected team directory, for example `.team/current/` or `.team/alpha/`; do not create or expect root `team.spec.yaml` or `team_state.md`.
448
+ - Use `team-agent quick-start ./roles --team-id alpha` to create a second generated team under `.team/alpha/`, or pass an existing team directory directly such as `team-agent quick-start .team/alpha`.
449
+ - `quick-start` is only for first-time team creation from role docs. If that team already has runtime state, use `team-agent restart . --team <session_name_or_team_name>` to resume it. If restart cannot recover context, explain the loss and wait for explicit user consent before using `team-agent restart . --allow-fresh`; never reset context through quick-start.
450
+ - If the user explicitly asks a worker to create or operate a nested child team, first read `references/team-in-team.md`. Child teams must use an independent child workspace, never the parent `.team/current`.
451
+ - `team-agent send coder "Do the bounded task"` persists a message for positional logical TO and returns. Prefer this over `--watch-result`.
452
+ - Positional `TO` has two co-equal forms: an in-team short name, for example `team-agent send reviewer "Review this change"`, and a fully-qualified logical name, `<workspace>::<team>/<agent>`. Use the fully-qualified form across workspaces or when the local team scope is ambiguous.
453
+ - Advanced orchestration callers may add `--presentation-sink leader|casefile|silent --message-class CLASS [--case-id CASE]`. All sinks remain durable and pullable; `casefile`/`silent` suppress only live leader injection. Missing presentation metadata preserves the normal leader-visible behavior.
454
+ - After `send` succeeds, do not run `sleep`, `status`, or `inbox` polling loops unless the user explicitly asks for diagnosis; results finalize automatically and the coordinator notifies the leader when a result arrives.
455
+ - `team-agent send --task task_initial "Start"` still parses but `--task` is a deprecated delivery flag (same warning family as `--watch-result`).
456
+ - `team-agent status` shows team, worker health, result-store counts, `session_id`, `captured_via`, and attribution confidence. `team-agent status --json` is compact and context-safe by default; use `team-agent status --detail --json` only for raw runtime-state diagnostics.
457
+ - `team-agent status coder` shows one worker.
458
+ - `team-agent approvals [coder]` shows structured pending approval prompts without copying worker terminal pages.
459
+ - `team-agent inbox coder -n 3` shows only compact message summaries. Final results are not in inbox.
460
+ - `team-agent shutdown --workspace . --keep-logs` stops the tmux session after a final session capture attempt.
461
+ - `team-agent restart .` restarts a stopped team from stored worker sessions. If one workspace has multiple restartable teams, use `team-agent restart . --team <session_name_or_team_name>`.
462
+ - `team-agent start-agent coder --workspace .` repairs one missing worker window without interrupting other workers.
463
+ - `team-agent doctor` checks local dependencies and provider auth hints.
464
+ - `team-agent results --case CASE_ID` reads reported results for a case.
465
+ - `team-agent compile` / `team-agent validate` are hidden from top-level `--help` but `--help` on those verbs works; use them to check role docs without launching.
466
+
467
+ <!-- command-coverage:normative-start -->
468
+ ### Normative command inventory
469
+
470
+ This inventory is the handbook authority for command coverage. Only the command
471
+ lines between the two `command-coverage:normative-*` markers are canonical
472
+ argv forms. Examples elsewhere in this handbook may be diagnostics, negative
473
+ probes, historical observations, or prose and are not part of the inventory.
474
+
475
+ ```text
476
+ team-agent add-agent <agent> --role-file <file>
477
+ team-agent add-agent reviewer --role-file .team/current/agents/reviewer.md --workspace .
478
+ team-agent approvals
479
+ team-agent approvals <agent_id>
480
+ team-agent approvals [coder]
481
+ team-agent attach-leader
482
+ team-agent claim-leader
483
+ team-agent claude
484
+ team-agent clone-agent <source> --as <new>
485
+ team-agent codex
486
+ team-agent codex --dangerously-bypass-approvals-and-sandbox
487
+ team-agent doctor
488
+ team-agent fork-agent <source> --as <new>
489
+ team-agent inbox <agent_id> -n 3
490
+ team-agent inbox coder -n 3
491
+ team-agent profile doctor <name> --workspace . --json
492
+ team-agent profile init <name> --auth-mode subscription --workspace .
493
+ team-agent profile init claude-default --auth-mode subscription --workspace .
494
+ team-agent profile init codex-default --auth-mode subscription --workspace .
495
+ team-agent profile init deepseek --auth-mode compatible_api --workspace .
496
+ team-agent profile show <name> --workspace . --json
497
+ team-agent profile show deepseek --workspace . --json
498
+ team-agent quick-start
499
+ team-agent quick-start ./roles --team-id alpha
500
+ team-agent quick-start .team/alpha
501
+ team-agent quick-start .team/current
502
+ team-agent quick-start <dir>
503
+ team-agent remove-agent <agent> --workspace . --confirm
504
+ team-agent reset-agent <agent> --discard-session
505
+ team-agent restart
506
+ team-agent restart .
507
+ team-agent restart . --allow-fresh
508
+ team-agent restart . --team <session_name_or_team_name>
509
+ team-agent send --task task_initial "Start"
510
+ team-agent send --watch-result
511
+ team-agent send --watch-result coder "Do the bounded task"
512
+ team-agent send TO MESSAGE
513
+ team-agent send reviewer "..."
514
+ team-agent send reviewer "Review this change"
515
+ team-agent shutdown --workspace . --keep-logs
516
+ team-agent start-agent <agent>
517
+ team-agent start-agent <agent_id> --workspace .
518
+ team-agent start-agent coder --workspace .
519
+ team-agent status
520
+ team-agent status --detail --json
521
+ team-agent status --json
522
+ team-agent status coder
523
+ ```
524
+
525
+ The exact frozen CLI root help is a complementary public-surface authority:
526
+ `team-agent --help` must expose the root verb for every canonical command that
527
+ is not otherwise documented as a compatibility or provider form. The command
528
+ coverage gate parses this output from the exact test binary; it never invokes a
529
+ provider or treats a diagnostic example as a command approval.
530
+
531
+ <!-- command-coverage:normative-end -->
532
+
533
+ ## Restart Semantics
534
+
535
+ `restart` takes one workspace argument. It preserves each worker's original provider. If a verified provider session exists, the worker resumes (`codex resume <id>` or `claude --resume <id>`). Claude sessions are considered resumable only after the provider has written a project transcript for that session; a freshly opened blank Claude window is not recorded as recovered context. If the stored id is stale, the runtime first tries to repair it from verified transcript history. If a stored session cannot be verified or repaired, restart fails closed instead of silently losing context; use `team-agent restart . --allow-fresh` only when the user explicitly accepts a fresh worker context. If multiple stopped teams in the same workspace have restart context, plain `team-agent restart .` fails and lists candidates; rerun with `--team <session_name_or_team_name>`. If no prior session id exists, that worker starts fresh and the event log records `restart.fresh_spawn`. Claude resume must run from the original cwd and the same provider transcript root; Team Agent stores `spawn_cwd` and compatible-API `claude_projects_root` for that.
536
+
537
+ `restart` `--help` does not mention rereading `agents/*.md`. See **How role-doc frontmatter becomes live**.
538
+
539
+ Startup trust prompts are handled by the runtime/coordinator with bounded probes; do not wait on raw worker screens or manually press Enter for routine startup trust prompts.
540
+
541
+ Use `team-agent start-agent <agent_id> --workspace .` only as a narrow repair when one worker window is missing after launch/restart/display failure. It preserves the worker provider, resumes from `session_id` when available, starts fresh when there is no prior session id, and does not restart the rest of the team. If an existing session id cannot resume, it fails closed unless the user explicitly passes `--allow-fresh`.
542
+
543
+ ## Adding A New Worker At Runtime
544
+
545
+ To add a new worker to a running team, write the role doc and run **one command** — do not shutdown/restart, do not regenerate the compiled spec, and do not quick-start an existing team:
546
+
547
+ ```bash
548
+ cat > .team/current/agents/reviewer.md <<'EOF'
549
+ ---
550
+ name: reviewer
551
+ role: Code Reviewer
552
+ provider: codex
553
+ auth_mode: subscription
554
+ profile: codex-default
555
+ dangerously_skip_permissions: false
556
+ tools:
557
+ - fs_read
558
+ - fs_list
559
+ - mcp_team
560
+ ---
561
+
562
+ Review changed files and report findings to leader.
563
+ EOF
564
+ team-agent add-agent reviewer --role-file .team/current/agents/reviewer.md --workspace .
565
+ ```
566
+
567
+ `add-agent` registers the new worker into the running team's state, launches its window on the existing tmux socket, and leaves every other worker untouched. **Do not shutdown/restart for adding a worker** — it loses every other worker's resumable session. If `add-agent` fails, surface the structured error to the user; do not fall back to shutdown.
568
+
569
+ To **recreate** an existing worker from an updated role file:
570
+
571
+ ```bash
572
+ team-agent add-agent reviewer --role-file .team/current/agents/reviewer.md --force --workspace .
573
+ ```
574
+
575
+ Missing `--role-file` observed (exit 1): `usage error: missing --role-file` plus a structured `action`.
576
+
577
+ Semantic distinction:
578
+
579
+ - `team-agent add-agent <agent> --role-file <file>` — add a **new** worker not yet in team state.
580
+ - `team-agent add-agent <agent> --role-file <file> --force` — force-recreate that worker from the role file.
581
+ - `team-agent clone-agent <source> --as <new>` — reread the source worker's latest role file and start a fresh provider seat. It never copies conversation context. Success is initially honest `capture_state: pending_first_turn` with `session_id`, `new_session_id`, and `backing_path` all null; after the first turn, canonical capture changes the state to `captured` and fills the backing tuple.
582
+ - `team-agent fork-agent <source> --as <new>` — reread the same latest role file and create a distinct, verified provider session that forks the source context. If the provider backing cannot be verified, the command fails and rolls back instead of silently cloning fresh.
583
+ - `team-agent start-agent <agent>` — (re)launch a worker that **already exists** in team state but whose window is missing.
584
+ - `team-agent reset-agent <agent> --discard-session` — keep the same seat and deliberately start it with fresh context.
585
+ - `team-agent restart .` — resume a fully **stopped** team from stored worker sessions.
586
+ - `team-agent quick-start <dir>` — first-time team creation from role docs; for existing teams use `restart`, and use `restart --allow-fresh` only after explicit user consent to discard context.
587
+
588
+ Clone/fork names are always explicit: run concurrent calls with a different `--as` value for each new seat. Fork success includes a verified new `session_id` and independent backing; a tmux window alone is not fork success. Clone success uses the honest `pending_first_turn` state above until first-turn capture, never a fabricated verified tuple. Updating the source role file affects the next clone/fork without requiring a full-team rebuild. Automatic knowledge write-back from a clone/fork into the source role file is not provided.
589
+
590
+ Removing a worker at runtime is the symmetric `team-agent remove-agent <agent> --workspace . --confirm`.
591
+
592
+ ## Worker Protocol
593
+
594
+ Workers normally do not run nested Team Agent teams. When the user or leader explicitly asks for a child team, follow `references/team-in-team.md`; otherwise workers only provide the target and content for progress, and a short completion summary at the end:
595
+
596
+ ```text
597
+ team_orchestrator.send_message(to="leader", content="short progress or blocker")
598
+ # to another teammate:
599
+ team_orchestrator.send_message(to="<agent_id>", content="short coordination note")
600
+ # to every other team member:
601
+ team_orchestrator.send_message(to="*", content="short broadcast")
602
+ team_orchestrator.report_result(summary="short completion", status="success", tests=[{"command":"command","status":"passed"}])
603
+ ```
604
+
605
+ For typed orchestration traffic, both `send_message` and `report_result` accept `presentation={"sink":"leader|casefile|silent","class":"message|progress|stage_result|stage_pass|bounce|blocking|final_review|timeout","case_id":"optional-case"}`. If the object is present, `sink` and `class` are required and unknown values fail closed. `casefile` and `silent` are durable-only, not deletion. The fixed critical classes `stage_pass`, `bounce`, `blocking`, `final_review`, and `timeout` always appear on the leader screen even when another sink is requested. Routing uses the typed class, never words in the content or summary.
606
+
607
+ Do not pass `sender`, `task_id`, `requires_ack`, `schema_version`, or `agent_id` unless doing a low-level compatibility diagnostic. The MCP runtime fills those fields and keeps delivery metadata in runtime state and event logs. If provider env loses the worker id, MCP infers it from active task/message state and falls back to an explicit `unknown` sender instead of treating the worker as leader.
608
+
609
+ Message targets are team-scoped. Use `leader`, another teammate agent id, or `*` for all other team members. The runtime excludes the sender from `*` broadcasts and never scans unrelated terminal windows for recipients.
610
+
611
+ `report_result` stores and finalizes completion atomically: the result row is closed, the task is marked done with its accepted result id, and the `collect.result` event is recorded. It does not create a LeaderNotification message; use `team-agent results --case` for final results and `team-agent inbox AGENT -n 3` only as a compact transport fallback. `acknowledged_count` only means prior task messages were acknowledged by the worker; it is not a missing-result signal.
612
+
613
+ For normal leader dispatch, prefer positional `team-agent send <TO> "..."` and the returned message id; do not use `--watch-result`.
614
+
615
+ For long processes, workers must write logs, keep a pid, provide a health check, and stop after a bounded number of retries. QA/reviewer roles must stay within their authorized files and stop on service unavailable, approval prompts, or repeated startup failure.
616
+
617
+ ## Failure Rules
618
+
619
+ For any non-zero `team-agent` exit, report the command, exit code, last about 20 stderr lines, and affected task or agent when known.
620
+
621
+ **If the error JSON/text includes a structured `action` field, run that `action` first.** This rule does not expire with skill versions.
622
+
623
+ Reproduce a structured `action` (missing `dangerously_skip_permissions` → compile JSON):
624
+
625
+ ```bash
626
+ d=$(mktemp -d) && mkdir -p "$d/agents"
627
+ printf '%s\n' '---' 'name: t' 'objective: t' 'provider: fake' '---' 'x' > "$d/TEAM.md"
628
+ printf '%s\n' '---' 'name: coder' 'role: Worker' 'provider: fake' 'model: fake' 'auth_mode: subscription' 'tools:' ' - mcp_team' '---' 'b' > "$d/agents/coder.md"
629
+ team-agent compile --team "$d" --out /tmp/ta-failure-rules-compile.yaml --json
630
+ ```
631
+
632
+ Observed (exit 1): JSON includes `"ok": false` and `"action": "run \`team-agent doctor\` or inspect the log path shown here"`, plus `missing front matter field dangerously_skip_permissions`. Prefer the `action` over guessing flags.
633
+
634
+ `coordinator.session_missing` is a self-healing transient: run `team-agent status --json`, if `ready` is true (or workers show `running`) continue; do not shutdown and wait.
635
+
636
+ `result_success_without_executed_tests` on a **non-coding** task (plain hello / status ping) is an advisory you may ignore. It is not a failed delivery.
637
+
638
+ Examples of `action` observed on this gauge:
639
+
640
+ - compile/add-agent usage failure: `"action": "run \`team-agent doctor\` or inspect the log path shown here"`
641
+ - send with no runtime: `"action": "Run team-agent quick-start/restart in the target workspace, or choose a workspace that has .team/runtime/state.json"`
642
+ - `claim-leader` from a worker pane: `"action": "pane %21 is registered as worker developer-d108; run claim-leader from the leader's own pane, not a worker pane"` (exit 1, `ok: false`, `reason: caller_not_leader_shaped`)
643
+
644
+ Do not retry with changed flags. Do not inspect source code or private runtime state. Do not operate tmux directly except when the user asks for a manual diagnostic. Do not answer provider approval prompts for the user.
645
+
646
+ If `quick-start` reports `tmux session already exists`, treat it as a team-name collision. The existing session may be an active team; do not terminate it and do not suggest `shutdown` as the normal fix. Change `name:` in `TEAM.md` so the next launch uses a different tmux session name, then run `team-agent quick-start .team/current` again.
647
+
648
+ Known Team Agent control-plane MCP prompts such as `team_orchestrator.report_result` and `team_orchestrator.send_message` are handled by the coordinator. It uses session-scoped approval, verifies the prompt cleared, retries boundedly, and logs the result. Do not ask the user to approve those routine internal prompts.
649
+
650
+ When `status` still shows `AWAITING_APPROVAL`, run `team-agent approvals <agent_id>`, show the structured prompt summary and choices, ask the user to decide, and wait.
651
+
652
+ Do not inspect raw worker terminal output during normal operation. Use `team-agent status`, `team-agent approvals`, `team-agent inbox AGENT -n 3`, `team-agent results --case`, and event logs instead. Raw-screen diagnostics are outside this skill's normal workflow, require explicit user authorization, and are guarded by the CLI; use them only as a one-shot bounded diagnostic, never as a routine workflow step.
653
+
654
+ Then stop and wait for the user **after** you have executed a provided `action` (or reported that it cannot be run from this pane).
655
+
656
+ For "worker reported but leader cannot see completion":
657
+
658
+ 1. Inspect `team-agent status --json` and `team-agent results --case` for the finalized result.
659
+ 2. If the result is absent, check `.team/logs/events.jsonl` for `mcp.report_result` and `collect.result` before sending another prompt to the worker.
660
+ 3. Use `team-agent inbox AGENT -n 3` only to inspect transport messages; it does not consume result rows.
661
+ 4. Do not loop on `team-agent inbox <agent_id> -n 3` or ack/status counts; that burns context and cannot consume final results.