@team-agent/installer 0.5.100 → 0.5.102

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 (63) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/crates/team-agent/src/cli/diagnose.rs +29 -7
  4. package/crates/team-agent/src/cli/mod.rs +24 -8
  5. package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -74
  6. package/crates/team-agent/src/compiler/tests.rs +20 -23
  7. package/crates/team-agent/src/compiler.rs +52 -65
  8. package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +16 -48
  9. package/crates/team-agent/src/leader/start.rs +1 -14
  10. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +211 -16
  11. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +1 -0
  12. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +15 -5
  13. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +89 -6
  14. package/crates/team-agent/src/lifecycle/launch/role_source.rs +168 -32
  15. package/crates/team-agent/src/lifecycle/launch/spawn.rs +1 -1
  16. package/crates/team-agent/src/lifecycle/launch.rs +11 -3
  17. package/crates/team-agent/src/lifecycle/profile_launch.rs +23 -8
  18. package/crates/team-agent/src/lifecycle/restart/agent.rs +2 -2
  19. package/crates/team-agent/src/lifecycle/restart/avatar.rs +1806 -0
  20. package/crates/team-agent/src/lifecycle/restart/common.rs +115 -2
  21. package/crates/team-agent/src/lifecycle/restart/rebuild.rs +8 -2
  22. package/crates/team-agent/src/lifecycle/restart/selection.rs +14 -2
  23. package/crates/team-agent/src/lifecycle/restart.rs +11 -4
  24. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -28
  25. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +11 -9
  26. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +8 -401
  27. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +2 -2
  28. package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +1398 -0
  29. package/crates/team-agent/src/lifecycle/tests.rs +1 -0
  30. package/crates/team-agent/src/lifecycle/types.rs +10 -2
  31. package/crates/team-agent/src/lifecycle/worker_command_context.rs +22 -8
  32. package/crates/team-agent/src/mcp_server/helpers.rs +0 -16
  33. package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +2 -7
  34. package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +1 -127
  35. package/crates/team-agent/src/mcp_server/mod.rs +7 -12
  36. package/crates/team-agent/src/mcp_server/tests/scoped.rs +1 -132
  37. package/crates/team-agent/src/mcp_server/tests/send.rs +1 -93
  38. package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -61
  39. package/crates/team-agent/src/mcp_server/tests/wire.rs +6 -51
  40. package/crates/team-agent/src/mcp_server/tests.rs +4 -200
  41. package/crates/team-agent/src/mcp_server/tools.rs +5 -396
  42. package/crates/team-agent/src/mcp_server/types.rs +3 -36
  43. package/crates/team-agent/src/mcp_server/wire.rs +2 -223
  44. package/crates/team-agent/src/messaging/leader_receiver.rs +1 -1
  45. package/crates/team-agent/src/messaging/mod.rs +2 -2
  46. package/crates/team-agent/src/messaging/scheduler.rs +2 -205
  47. package/crates/team-agent/src/messaging/tests/basic.rs +0 -31
  48. package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -73
  49. package/crates/team-agent/src/messaging/tests/runtime.rs +0 -26
  50. package/crates/team-agent/src/messaging/types.rs +0 -20
  51. package/crates/team-agent/src/model/spec.rs +15 -18
  52. package/crates/team-agent/src/provider/types.rs +2 -0
  53. package/crates/team-agent/src/state/persist.rs +58 -2
  54. package/crates/team-agent/src/state/projection.rs +5 -1
  55. package/crates/team-agent/src/state/repository/tests.rs +1 -16
  56. package/crates/team-agent/src/state/repository.rs +126 -37
  57. package/crates/team-agent/src/transport/test_support.rs +23 -3
  58. package/package.json +4 -4
  59. package/skills/team-agent/SKILL.md +18 -47
  60. package/skills/team-agent/command-coverage.json +7 -0
  61. package/skills/team-agent/references/team-agent-operator.md +28 -118
  62. package/skills/team-agent/references/team-in-team.md +4 -19
  63. package/crates/team-agent/src/mcp_server/lifecycle_tools/agent_ops.rs +0 -484
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-agent/installer",
3
- "version": "0.5.100",
3
+ "version": "0.5.102",
4
4
  "description": "npx installer for Team Agent",
5
5
  "keywords": [
6
6
  "codex",
@@ -20,9 +20,9 @@
20
20
  "team-agent-installer": "npm/install.mjs"
21
21
  },
22
22
  "optionalDependencies": {
23
- "@team-agent/cli-darwin-arm64": "0.5.100",
24
- "@team-agent/cli-darwin-x64": "0.5.100",
25
- "@team-agent/cli-linux-x64": "0.5.100"
23
+ "@team-agent/cli-darwin-arm64": "0.5.102",
24
+ "@team-agent/cli-darwin-x64": "0.5.102",
25
+ "@team-agent/cli-linux-x64": "0.5.102"
26
26
  },
27
27
  "scripts": {
28
28
  "postinstall": "node npm/bincheck.mjs",
@@ -4,65 +4,36 @@ description: Use only when the user explicitly asks to start, operate, inspect,
4
4
  requires_team_agent: ">=0.5.0"
5
5
  last_verified_against: "0.5.66"
6
6
  ---
7
-
8
7
  # Team Agent
9
-
10
8
  Sealed appliance for someone who just got the CLI. Operator handbook (permissions, models, routing, recovery): `references/team-agent-operator.md`.
11
-
12
- If `team-agent --version` does not match `last_verified_against`, do not copy examples as current truth. Learn from the live CLI:
13
-
9
+ If `team-agent --version` differs from `last_verified_against`, learn from the live CLI before copying examples:
14
10
  ```bash
15
11
  team-agent --version
16
12
  team-agent --help
17
13
  team-agent doctor --help
18
14
  ```
19
-
20
- **Launch** from a tmux-addressable pane: `team-agent claude` or `team-agent codex`, then `team-agent quick-start .team/current`. Do not start a real team from a naked terminal. Workers always run in independent background windows on the workspace-scoped tmux server.
21
-
15
+ **Launch** from a tmux-addressable pane: `team-agent claude` or `team-agent codex`, then `team-agent quick-start .team/current`. For a plain-text team directory, use `team-agent quick-start <plain-text-team-dir>`. Do not start a real team from a naked terminal; workers use independent background windows on the workspace-scoped tmux server.
22
16
  **Operate**
23
-
24
- - Dispatch: `team-agent send TO MESSAGE` (positional TO; `--watch-result` is deprecated). After success, do not poll with `sleep` / `status` / `inbox` / `collect`.
25
- TO has two co-equal logical forms: an **in-team short name** (`team-agent send reviewer "..."`) and a fully qualified `<workspace>::<team>/<agent>`. Use the qualified form across workspaces.
26
- - Inspect: `team-agent status` / `status --json`. `ok: true` plus `ready: false` is not a crash.
27
- - Lifecycle: `restart .` resumes a stopped team; `add-agent NAME --role-file FILE` adds or `--force` recreates one worker; `shutdown --workspace .` stops. Do not shutdown the whole team to add a worker.
28
- - Roles: every `agents/*.md` must declare boolean `dangerously_skip_permissions`. Never rewrite a user-supplied model id. Never read `.env` files.
29
-
30
- **On failure:** if the CLI prints a structured `action`, run that `action` first, then stop. Do not guess flags. `coordinator.session_missing` is a self-healing transient — re-check `status --json`; do not shutdown because of it.
31
-
32
- The current user-facing agent is the leader (orchestrate only). Workers call `report_result` exactly once. Nested teams: `references/team-in-team.md`.
33
-
17
+ - Dispatch: `team-agent send TO MESSAGE` (positional TO; `--watch-result` is deprecated). After success, do not poll with `sleep` / `status` / `inbox` / `collect`. TO has two co-equal logical forms: an in-team short name (`team-agent send reviewer "..."`) and a fully qualified `<workspace>::<team>/<agent>`. Use the qualified form across workspaces.
18
+ - Inspect: `team-agent status` / `status --json`; `ok: true` plus `ready: false` is not a crash.
19
+ - Lifecycle: `restart .` resumes a stopped team; `add-agent NAME --role-file FILE` adds or `--force` recreates one worker; `shutdown --workspace .` stops. Do not shutdown the team to add a worker.
20
+ - Documents: `TEAM.md` and `agents/*.md` may be plain text/Markdown with no frontmatter; the whole team body is its objective and the whole role body is the prompt. Default worker id is the filename stem, provider `pi`, model `openai-codex/gpt-6-luna`, effort `max`, and bypass enabled. Valid optional frontmatter can override supported metadata.
21
+ - On a structured failure `action`, run that action first, then stop. Do not guess flags. `coordinator.session_missing` is self-healing; re-check `status --json`, do not shutdown.
22
+ The current user-facing agent is the leader (orchestrate only). Worker MCP exposes exactly `send_message`, `report_result`, and optional `get_team_status`; lifecycle management stays on the authorized native CLI. Workers call `report_result` exactly once. Nested teams: `references/team-in-team.md`.
34
23
  ## Provider Capability Matrix
35
-
36
- Claude / Codex / Copilot / Gemini / fake: `references/team-agent-operator.md`. These two are in the runtime but were missing from that table:
37
- `quick-start` / `restart` / `claim-leader` JSON is compact by default (`ok`, `status`/`reason`, next action, attach/send, and `readiness.all_workers_spawned`); pass `--detail` only for internal diagnostics.
38
-
39
- | Provider | Resume | Turn-state detection | Per-worker model override | Native session fork |
24
+ See `references/team-agent-operator.md` for Claude / Codex / Copilot / Gemini / fake. `quick-start` / `restart` / `claim-leader` JSON is compact by default; pass `--detail` only for internal diagnostics.
25
+ | Provider | Resume | Turn-state detection | Per-worker model override | Team Agent fork |
40
26
  |---|---|---|---|---|
41
27
  | `grok` | yes (`--resume <id>`, archive-gated) | no | yes (role `model` required) | yes (`--fork-session` + new `--session-id`) |
42
- | `cursor_agent` | yes (argv `--resume <chatId>`, archive-gated) | no | required on role; same-family catalog id can take effect; unknown id silent-fallback; pane chrome ≠ proven live | **no — `CapabilityUnsupported`** |
43
-
44
- Grok / `cursor_agent` have no JSONL turn-state reader (classify → Unknown).
45
-
28
+ | `cursor_agent` | yes (`--resume <chatId>`, archive-gated) | no | required on role; same-family catalog id may take effect; unknown id silent-fallback; pane chrome ≠ proof | **no — `CapabilityUnsupported`** |
29
+ | `pi` | yes (exact `--session <backing-path>`, not selector/continue) | Unknown (no JSONL turn-state reader) | yes (role `model` / `effort`, catalog-validated) | yes (full snapshot into separate seat/session; exact backing resume) |
30
+ Grok / `cursor_agent` have no JSONL turn-state reader (classify → Unknown). Pi `fork-agent SOURCE --as TARGET` requires a captured Pi subscription source and reports both session ids plus the target backing path; it does not mutate the source session.
46
31
  ## Provider Prep
47
-
48
32
  ### Cursor provider notes
49
-
50
- Frontmatter: `provider: cursor_agent` (not `cursor`; launcher verb is `team-agent cursor`), `auth_mode: subscription`, `name:` required (omit → `missing front matter field name`). Also required: `role:`, `tools:`, `dangerously_skip_permissions:` (bool). Subscription needs no `profile`.
51
-
52
- `model:` is required (omit compile-fails; blocks a silent builtin `sonnet-4-thinking`). The flag stays on argv. Same-family catalog ids can change pane chrome. An id not in that provider's catalog silent-falls back (landing not stable; no events/stderr/pane warning). Pick names from the catalog; after spawn, `capture-pane` once for chrome. Do not treat the role field or pane chrome as proof of the live model.
53
-
54
- One `cursor_agent` per workspace. A second seat (including `add-agent --force` of a different id) fail-closes:
55
-
56
- ```
57
- error: cursor_agent seat already occupies this workspace
58
- reason: <workspace>/.cursor/mcp.json is directory-scoped; a second seat overwrites TEAM_AGENT_ID (last-writer)
59
- action: do not add another CursorAgent in this workspace until per-seat MCP identity is isolated
60
- ```
61
-
62
- Several cursor seats → one workspace directory each. Same seat, fresh context → `reset-agent --discard-session`.
63
-
64
- `clone-agent` copies the source role (provider unchanged). Runtime add: `clone-agent` → `stop-agent` → `remove-agent --confirm` (deletes `.team/dynamic-role-files/`) → write the role file → `add-agent --role-file` → dispatch.
65
-
66
- - Restart emits `--resume <chatId>` when `store.db`/`meta.json` exist; the gate does not read chat text. Persist anything that must survive restart.
33
+ To opt into Cursor, use optional frontmatter with `provider: cursor_agent` (not `cursor`; launcher verb `team-agent cursor`) and `auth_mode: subscription`; no profile or bypass field is required. `agent_id` (legacy `name`) and `role` can be omitted, but Cursor still requires an explicit `model:`.
34
+ The model flag stays on argv; same-family catalog ids can change pane chrome, while unknown ids silent-fallback without warning. Pick a catalog id; after spawn, `capture-pane` once for chrome. Pane chrome does not prove the live model.
35
+ One `cursor_agent` per workspace; a second seat fail-closes because `.cursor/mcp.json` is directory-scoped and overwrites `TEAM_AGENT_ID`. Several Cursor seats need separate workspace directories. Same seat, fresh context: `reset-agent --discard-session`.
36
+ `clone-agent` copies the source role but starts fresh. Runtime role replacement: `clone-agent` → `stop-agent` → `remove-agent --confirm` (deletes `.team/dynamic-role-files/`) → write role file → `add-agent --role-file` → dispatch.
37
+ - Restart emits `--resume <chatId>` when `store.db` / `meta.json` exist; the gate does not read chat text. Persist anything that must survive restart.
67
38
  - Delivery sends one Enter; a second Enter interrupts the turn.
68
39
  - After spawn, the pane footer should show `Cursor Agent v<version>`. Do not use `strings` to probe the binary.
@@ -261,6 +261,13 @@
261
261
  }
262
262
  }
263
263
  },
264
+ {
265
+ "command": "team-agent quick-start <plain-text-team-dir>",
266
+ "bucket": "declared_gap",
267
+ "covered": false,
268
+ "owner": "runtime-owner:lifecycle",
269
+ "plan": "Run exact argv team-agent quick-start <plain-text-team-dir> in an isolated workspace with plain-text TEAM.md and agents/<stem>.md; bind successful compilation, objective, filename-derived id, and default provider/model/effort/bypass in the generated spec."
270
+ },
264
271
  {
265
272
  "command": "team-agent remove-agent <agent> --workspace . --confirm",
266
273
  "bucket": "declared_gap",
@@ -45,7 +45,7 @@ team-agent claude
45
45
 
46
46
  Pass provider flags after the provider name, for example `team-agent codex --dangerously-bypass-approvals-and-sandbox`. Run `team-agent quick-start` 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
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).
48
+ Leader `--dangerously-*` flags do not determine worker bypass. Worker bypass defaults to enabled in compiled role specs; no bypass field needs to be written (see Document Format and Permissions).
49
49
 
50
50
  ## Leader Role
51
51
 
@@ -55,48 +55,22 @@ When the user has been communicating in Chinese throughout the conversation, all
55
55
 
56
56
  ## Minimal Copy-Paste Team
57
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; the values are configuration fallbacks.
58
+ `TEAM.md` and `agents/*.md` are plain text/Markdown; YAML frontmatter is optional. The whole `TEAM.md` body becomes the team objective, and the whole role body becomes the worker prompt. A default role uses its filename stem as its id, provider `pi`, model `openai-codex/gpt-6-luna`, effort `max`, and bypass enabled. Valid optional frontmatter may still override supported metadata.
59
59
 
60
60
  ```bash
61
61
  mkdir -p .team/current/agents
62
- team-agent profile init codex-default --auth-mode subscription --workspace .
63
62
  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.
63
+ A small team for bounded implementation tasks. Workers report progress to the leader and return a concise result.
76
64
  EOF
77
65
  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.
66
+ # Implementation Worker
67
+
68
+ Handle one bounded task at a time. Send progress or blockers to the leader with `send_message`, and report completion exactly once with `report_result`.
95
69
  EOF
96
70
  team-agent quick-start .team/current
97
71
  ```
98
72
 
99
- YAML lists must be block style. Use `tools:\n - fs_read`; do not use `tools: [fs_read, mcp_team]`.
73
+ The MCP surface is exactly `send_message`, `report_result`, and `get_team_status`; status is optional, not a prerequisite. Agent/team lifecycle management remains on the separately authorized native CLI.
100
74
 
101
75
  Workers always run headlessly in independent windows on the per-workspace tmux server. No GUI display backend is configured in `TEAM.md`.
102
76
 
@@ -122,24 +96,26 @@ Run `claim-leader` only from the **leader** pane. From a worker pane it refuses
122
96
 
123
97
  ## Provider Capability Matrix
124
98
 
125
- | Provider | Resume | Turn-state detection | Per-worker model override | Native session fork |
99
+ | Provider | Resume | Turn-state detection | Per-worker model override | Team Agent fork |
126
100
  |---|---|---|---|---|
127
101
  | `claude` / `claude_code` | yes (`--resume <id>`, transcript-verified) | yes (JSONL stream) | yes (role `model` overrides `provider_models`) | yes (snapshot copy + only `--resume <snapshot-id>`) |
128
102
  | `codex` | yes (`codex resume <id>`, session-store-verified) | yes (turn JSONL) | yes (role `model`) | yes (`codex fork`) |
129
103
  | `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) |
104
+ | `pi` | yes (exact `--session <backing-path>`, not selector/continue) | Unknown (no JSONL turn-state reader) | yes (role `model` / `effort`, catalog-validated) | yes (full snapshot into separate seat/session; exact backing resume) |
130
105
  | `gemini_cli` | no | no | yes | no |
131
106
  | `fake` (testing only) | no | no | n/a | no |
132
107
 
133
108
  Notes:
134
- - 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.
109
+ - A plain-text/default role uses Pi with `openai-codex/gpt-6-luna` and `max` effort; valid optional role frontmatter can select a provider and override supported model settings. For provider paths using `provider_models`, an explicit role `model:` takes precedence.
135
110
  - 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.
136
111
  - 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.
112
+ - `pi` `fork-agent SOURCE --as TARGET` requires a captured Pi subscription source. It copies the complete JSONL history into a distinct target session with a new id and exact `--session <path>` resume; it does not alter the source file or fall back to a fresh session.
137
113
 
138
114
  ## Provider Prep
139
115
 
140
116
  ### Subscription auth (Codex / Claude account login)
141
117
 
142
- Before workers can use a subscription provider, create a named subscription profile in the workspace and reference it from role docs:
118
+ To opt a worker into Codex or Claude subscription providers, create a named subscription profile in the workspace and reference it from optional role frontmatter:
143
119
 
144
120
  ```bash
145
121
  team-agent profile init codex-default --auth-mode subscription --workspace .
@@ -172,7 +148,7 @@ codex debug models
172
148
 
173
149
  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.
174
150
 
175
- 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`** — the internal compiler fails closed.
151
+ A plain-text/default role compiles as provider `pi` with model `openai-codex/gpt-6-luna` and effort `max`. If valid optional frontmatter selects another provider, its established provider-specific model/profile resolution applies; Grok and Cursor roles retain their explicit model requirements. **Do not treat provider/team fill-ins as a validity catalog.**
176
152
 
177
153
  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`.
178
154
  Use `provider: claude` or `provider: claude_code` for Claude workers.
@@ -248,7 +224,7 @@ Observed (exit 1): `usage error: invalid --auth-mode: not-a-mode`. That is the l
248
224
 
249
225
  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.
250
226
 
251
- ## How role-doc frontmatter becomes live
227
+ ## How role documents become live
252
228
 
253
229
  ```bash
254
230
  team-agent restart --help
@@ -274,72 +250,15 @@ To apply a changed role file to an **existing** worker name, use `add-agent --fo
274
250
 
275
251
  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.
276
252
 
277
- ## Permissions (0.5.66)
278
-
279
- There is **no** `team-agent permission-modes` command.
280
-
281
- ```bash
282
- team-agent permission-modes
283
- ```
284
-
285
- Observed (exit 1): `invalid choice: 'permission-modes'`.
286
-
287
- `team-agent --help` does **not** list `permission_mode`, `TEAM_AGENT_LEADER_BYPASS`, or `dangerous_auto_approve`. Use `team-agent validate "$d" --json` with an existing spec file or team directory; it does not enumerate permission modes.
288
-
289
- ### Live control: role `dangerously_skip_permissions`
290
-
291
- Required boolean on every role doc. Missing or non-bool fails the internal compiler; this is checked again before lifecycle launch.
292
-
293
- For an existing spec file, the retained schema check is:
294
-
295
- ```bash
296
- team-agent validate "$d" --json
297
- ```
298
-
299
- With a team-directory input, `validate` internally compiles `TEAM.md` and `agents/*.md` and validates role-document completeness; with a file input, it runs schema structural validation. Neither input writes or exports a spec file. The internal compiler rejects non-bool (`dangerously_skip_permissions: bypass`) and accepts only boolean **`true`** or **`false`**.
300
-
301
- `true` is the per-worker bypass opt-in. `false` is the default you should copy unless the user explicitly wants prompts skipped.
253
+ ## Document Format and Permissions
302
254
 
303
- ### `permission_mode` (historical, not consumed)
255
+ `TEAM.md` and `agents/*.md` accept ordinary text/Markdown without required YAML frontmatter. A valid optional frontmatter map may set supported metadata; absent, malformed, unterminated, or non-object frontmatter is treated as part of the document body, not a compile error. The entire TEAM body becomes `objective`; the role body is injected as the prompt.
304
256
 
305
- A role may still contain `permission_mode`. Compile **does not** validate it and **does not** copy it into the compiled spec.
257
+ For a role with no overrides, the filename stem supplies its id, and defaults are provider `pi`, model `openai-codex/gpt-6-luna`, effort `max`, and `dangerously_skip_permissions: true`. A valid `agent_id` (or legacy `name`) may override the filename-derived id. Supported valid frontmatter overrides remain available for existing roles; no permission field needs to be written. TEAM defaults are the workspace directory name, a 2-second tick, `leader_centric` communication, and `team-<workspace-name>` session.
306
258
 
307
- 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.
308
-
309
- Do not set `permission_mode: bypass` expecting 0.5.66 bypass. Use `dangerously_skip_permissions: true`.
310
-
311
- ### `TEAM.md` `dangerous_auto_approve`
312
-
313
- 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.
314
-
315
- `dangerous_auto_approve` as a **tool sentinel** is internal (adapters). Operators do not configure it as a tools list item.
316
-
317
- ### `TEAM_AGENT_LEADER_BYPASS`
318
-
319
- 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.
320
-
321
- ### Leader argv bypass
322
-
323
- Leader `--dangerously-*` is detected only as a **warning**, not as worker bypass (`detect_bypass_flag_in_argv` — "只做检测,不做行为决策"). Declare `dangerously_skip_permissions` per role.
324
-
325
- ### Priority — 未找到单一裁决点
326
-
327
- 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).
328
-
329
- What the sources actually do (reader can re-open these files):
330
-
331
- | Symbol | File | What it does |
332
- |---|---|---|
333
- | `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. |
334
- | `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`. |
335
- | `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. |
336
- | spec allowed key `permission_mode` | `crates/team-agent/src/model/spec.rs` | Historical; **not consumed** by compiler (comment: 0.5.66 起不再被 compiler 消费); the key is absent from the compiled agent spec. |
337
- | `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. |
338
- | `worker_spawn_env` test | `crates/team-agent/src/layout/worker_env.rs` | **Strips** inherited `TEAM_AGENT_LEADER_BYPASS` from parent env. |
339
- | `claude_dangerous_auto_approve` (and siblings) | `crates/team-agent/src/provider/adapters/*.rs` | Adapters look for tool name `dangerous_auto_approve`, not `TEAM.md`. |
340
-
341
- **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.
259
+ The generated spec still carries a boolean bypass value. Missing or malformed role metadata defaults to `true`; an explicit valid boolean is preserved. Provider adapters translate that value using the provider's own mechanism. Do not copy a Codex-only bypass flag into Pi or another provider's launch command.
342
260
 
261
+ `permission_mode`, `dangerous_auto_approve`, and leader environment switches are not required document fields. Keep provider-native bypass behavior inside the adapter; do not ask users to add a bypass toggle to `TEAM.md` or a plain-text role.
343
262
  ## Ignore vs handle (status / alerts)
344
263
 
345
264
  ```bash
@@ -522,7 +441,7 @@ provider or treats a diagnostic example as a command approval.
522
441
 
523
442
  `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.
524
443
 
525
- `restart` `--help` does not mention rereading `agents/*.md`. See **How role-doc frontmatter becomes live**.
444
+ `restart` `--help` does not mention rereading `agents/*.md`. See **How role documents become live**.
526
445
 
527
446
  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.
528
447
 
@@ -534,20 +453,9 @@ To add a new worker to a running team, write the role doc and run **one command*
534
453
 
535
454
  ```bash
536
455
  cat > .team/current/agents/reviewer.md <<'EOF'
537
- ---
538
- name: reviewer
539
- role: Code Reviewer
540
- provider: codex
541
- auth_mode: subscription
542
- profile: codex-default
543
- dangerously_skip_permissions: false
544
- tools:
545
- - fs_read
546
- - fs_list
547
- - mcp_team
548
- ---
549
-
550
- Review changed files and report findings to leader.
456
+ # Code Reviewer
457
+
458
+ Review changed files and report findings to the leader. Use `send_message` for progress and `report_result` exactly once for completion.
551
459
  EOF
552
460
  team-agent add-agent reviewer --role-file .team/current/agents/reviewer.md --workspace .
553
461
  ```
@@ -567,7 +475,7 @@ Semantic distinction:
567
475
  - `team-agent add-agent <agent> --role-file <file>` — add a **new** worker not yet in team state.
568
476
  - `team-agent add-agent <agent> --role-file <file> --force` — force-recreate that worker from the role file.
569
477
  - `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.
570
- - `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.
478
+ - `team-agent fork-agent <source> --as <new>` — reread the source's latest role file and create a distinct provider session carrying its context. Pi subscription forks a verified full snapshot into a separate target seat/backing and reports source id, target id, and backing path; supported non-Pi providers keep their existing fork behavior. Unverified backing fails closed instead of silently cloning fresh.
571
479
  - `team-agent start-agent <agent>` — (re)launch a worker that **already exists** in team state but whose window is missing.
572
480
  - `team-agent reset-agent <agent> --discard-session` — keep the same seat and deliberately start it with fresh context.
573
481
  - `team-agent restart .` — resume a fully **stopped** team from stored worker sessions.
@@ -579,6 +487,8 @@ Removing a worker at runtime is the symmetric `team-agent remove-agent <agent> -
579
487
 
580
488
  ## Worker Protocol
581
489
 
490
+ The Team Agent MCP surface is exactly `send_message`, `report_result`, and optional `get_team_status`. Status is self-inspection only, never a prerequisite; lifecycle management remains on the authorized native CLI.
491
+
582
492
  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:
583
493
 
584
494
  ```text
@@ -592,7 +502,7 @@ team_orchestrator.report_result(summary="short completion", status="success", te
592
502
 
593
503
  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.
594
504
 
595
- 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.
505
+ Do not pass `sender`, `task_id`, `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.
596
506
 
597
507
  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.
598
508
 
@@ -628,7 +538,7 @@ Examples of `action` observed on this gauge:
628
538
 
629
539
  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.
630
540
 
631
- 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.
541
+ 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. Choose a distinct workspace folder name or set an optional `name:` override in valid `TEAM.md` frontmatter, then retry `team-agent quick-start .team/current`.
632
542
 
633
543
  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.
634
544
 
@@ -9,7 +9,7 @@ This reference is for explicitly requested nested Team Agent teams. Use it only
9
9
  - Never edit, delete, or reuse files under the parent team's `.team/current`.
10
10
  - Never shut down a team just because `.team/current` is already occupied. In a nested setup, that is probably the parent team; shutting it down can kill the main node.
11
11
  - A child team needs its own workspace directory. The role-doc directory is not the child workspace.
12
- - MCP tools are team-scoped. A worker must not try to widen `team_orchestrator.send_message` to another team.
12
+ - The MCP surface is exactly `send_message`, `report_result`, and optional `get_team_status`; it is team-scoped. A worker must not try to widen `send_message` to another team. Lifecycle management uses the authorized native CLI.
13
13
 
14
14
  ## Child Workspace
15
15
 
@@ -34,29 +34,14 @@ Then create the child team's files inside the child workspace:
34
34
 
35
35
  ```bash
36
36
  cat > .team/current/TEAM.md <<'EOF'
37
- ---
38
- name: child-review-team
39
- objective: Run a bounded child-team task and report to the parent worker.
40
- dangerous_auto_approve: false
41
- fast: false
42
- ---
43
-
44
- Child team config only.
37
+ A bounded child team for reviewing the requested files and reporting findings.
45
38
  EOF
46
39
 
47
40
  cat > .team/current/agents/reviewer.md <<'EOF'
48
- ---
49
- name: reviewer
50
- role: Independent Reviewer
51
- provider: codex
52
- tools:
53
- - fs_read
54
- - fs_list
55
- - mcp_team
56
- ---
41
+ # Independent Reviewer
57
42
 
58
43
  Review only the files and instructions provided by the child-team leader.
59
- Report findings with team_orchestrator.report_result exactly once.
44
+ Use `send_message` for progress and report findings with `report_result` exactly once.
60
45
  EOF
61
46
 
62
47
  team-agent quick-start .team/current