@team-agent/installer 0.5.61 → 0.5.62

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 (250) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/crates/team-agent/src/cli/adapters.rs +5 -2
  4. package/crates/team-agent/src/cli/attach_app_server_leader.rs +1 -0
  5. package/crates/team-agent/src/cli/diagnose.rs +1 -0
  6. package/crates/team-agent/src/cli/emit.rs +41 -7
  7. package/crates/team-agent/src/cli/helpers.rs +1 -0
  8. package/crates/team-agent/src/cli/leader.rs +6 -1
  9. package/crates/team-agent/src/cli/leaders.rs +2 -0
  10. package/crates/team-agent/src/cli/mod.rs +33 -3
  11. package/crates/team-agent/src/cli/named_address.rs +8 -1
  12. package/crates/team-agent/src/cli/profile.rs +2 -1
  13. package/crates/team-agent/src/cli/send/coordinator.rs +1 -0
  14. package/crates/team-agent/src/cli/send/mailbox.rs +3 -0
  15. package/crates/team-agent/src/cli/send/persist.rs +1 -0
  16. package/crates/team-agent/src/cli/send/presentation.rs +1 -0
  17. package/crates/team-agent/src/cli/send/resolve.rs +206 -1
  18. package/crates/team-agent/src/cli/send.rs +2 -1
  19. package/crates/team-agent/src/cli/spec.rs +1 -0
  20. package/crates/team-agent/src/cli/status.rs +2 -1
  21. package/crates/team-agent/src/cli/status_port/compact.rs +1 -0
  22. package/crates/team-agent/src/cli/status_port/format.rs +1 -0
  23. package/crates/team-agent/src/cli/status_port/inbox.rs +1 -0
  24. package/crates/team-agent/src/cli/tests/verb_profile.rs +38 -0
  25. package/crates/team-agent/src/cli/types.rs +3 -2
  26. package/crates/team-agent/src/communication_mode/mod.rs +1 -0
  27. package/crates/team-agent/src/compiler.rs +1 -0
  28. package/crates/team-agent/src/conpty/backend.rs +1 -0
  29. package/crates/team-agent/src/conpty/mod.rs +1 -0
  30. package/crates/team-agent/src/coordinator/backoff.rs +5 -8
  31. package/crates/team-agent/src/coordinator/conpty_shim.rs +3 -2
  32. package/crates/team-agent/src/coordinator/health.rs +1 -0
  33. package/crates/team-agent/src/coordinator/mod.rs +2 -2
  34. package/crates/team-agent/src/coordinator/orphan.rs +4 -116
  35. package/crates/team-agent/src/coordinator/runtime_detectors.rs +1 -0
  36. package/crates/team-agent/src/coordinator/runtime_observation.rs +1 -0
  37. package/crates/team-agent/src/coordinator/steps/abnormal.rs +6 -5
  38. package/crates/team-agent/src/coordinator/steps/delivery.rs +1 -0
  39. package/crates/team-agent/src/coordinator/steps/health_sync.rs +1 -0
  40. package/crates/team-agent/src/coordinator/steps/mod.rs +2 -0
  41. package/crates/team-agent/src/coordinator/steps/persist.rs +1 -0
  42. package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +1 -0
  43. package/crates/team-agent/src/coordinator/steps/session_gate.rs +1 -0
  44. package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -174
  45. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -9
  46. package/crates/team-agent/src/coordinator/tests/basics.rs +0 -184
  47. package/crates/team-agent/src/coordinator/tests/mod.rs +2 -17
  48. package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -42
  49. package/crates/team-agent/src/coordinator/tick.rs +24 -28
  50. package/crates/team-agent/src/coordinator/types.rs +3 -176
  51. package/crates/team-agent/src/db/agent_health_capture.rs +1 -0
  52. package/crates/team-agent/src/db/message_store.rs +2 -1
  53. package/crates/team-agent/src/db/migration.rs +5 -4
  54. package/crates/team-agent/src/db/mod.rs +1 -0
  55. package/crates/team-agent/src/db/schema.rs +1 -0
  56. package/crates/team-agent/src/diagnose/comms.rs +2 -1
  57. package/crates/team-agent/src/diagnose/mod.rs +1 -0
  58. package/crates/team-agent/src/diagnose/orphans.rs +1 -0
  59. package/crates/team-agent/src/layout/manager.rs +3 -7
  60. package/crates/team-agent/src/layout/mod.rs +2 -2
  61. package/crates/team-agent/src/layout/overlay.rs +6 -1
  62. package/crates/team-agent/src/layout/placement.rs +1 -0
  63. package/crates/team-agent/src/layout/recovery.rs +3 -0
  64. package/crates/team-agent/src/layout/runtime_sessions.rs +8 -3
  65. package/crates/team-agent/src/layout/sessions.rs +8 -1
  66. package/crates/team-agent/src/layout/tmux_endpoint.rs +3 -0
  67. package/crates/team-agent/src/layout/worker_env.rs +3 -0
  68. package/crates/team-agent/src/layout/worker_window_helpers.rs +2 -0
  69. package/crates/team-agent/src/leader/helpers.rs +1 -0
  70. package/crates/team-agent/src/leader/incident.rs +1 -0
  71. package/crates/team-agent/src/leader/lease.rs +27 -22
  72. package/crates/team-agent/src/leader/mod.rs +2 -3
  73. package/crates/team-agent/src/leader/owner_bind.rs +13 -3
  74. package/crates/team-agent/src/leader/provider_attribution.rs +1 -0
  75. package/crates/team-agent/src/leader/rediscover.rs +4 -17
  76. package/crates/team-agent/src/leader/registry.rs +3 -15
  77. package/crates/team-agent/src/leader/start.rs +373 -125
  78. package/crates/team-agent/src/leader/takeover.rs +10 -232
  79. package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +544 -0
  80. package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +624 -0
  81. package/crates/team-agent/src/leader/tests/identity.rs +7 -2
  82. package/crates/team-agent/src/leader/tests/idle.rs +0 -193
  83. package/crates/team-agent/src/leader/tests/lease_api.rs +0 -45
  84. package/crates/team-agent/src/leader/tests/mod.rs +4 -41
  85. package/crates/team-agent/src/leader/tests/rehomed_env.rs +83 -0
  86. package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +1273 -0
  87. package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +417 -0
  88. package/crates/team-agent/src/leader/tests/wake_start_owner.rs +22 -103
  89. package/crates/team-agent/src/leader/types.rs +1 -28
  90. package/crates/team-agent/src/lib.rs +3 -0
  91. package/crates/team-agent/src/lifecycle/display.rs +7 -1
  92. package/crates/team-agent/src/lifecycle/helpers.rs +3 -1
  93. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +2 -2
  94. package/crates/team-agent/src/lifecycle/launch/fork_agent/completion.rs +1 -0
  95. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +1 -0
  96. package/crates/team-agent/src/lifecycle/launch/fork_finalize.rs +1 -0
  97. package/crates/team-agent/src/lifecycle/launch/plan.rs +2 -2
  98. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +4 -26
  99. package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -27
  100. package/crates/team-agent/src/lifecycle/launch/spawn.rs +1 -27
  101. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +4 -32
  102. package/crates/team-agent/src/lifecycle/launch/state_projection.rs +1 -0
  103. package/crates/team-agent/src/lifecycle/launch.rs +11 -12
  104. package/crates/team-agent/src/lifecycle/mod.rs +2 -1
  105. package/crates/team-agent/src/lifecycle/restart/agent.rs +3 -3
  106. package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +2 -2
  107. package/crates/team-agent/src/lifecycle/restart/rebuild.rs +13 -5
  108. package/crates/team-agent/src/lifecycle/restart/remove.rs +1 -1
  109. package/crates/team-agent/src/lifecycle/restart/selection.rs +3 -3
  110. package/crates/team-agent/src/lifecycle/restart.rs +13 -11
  111. package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +1007 -0
  112. package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +265 -0
  113. package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +459 -0
  114. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +849 -0
  115. package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +323 -0
  116. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +423 -0
  117. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +737 -0
  118. package/crates/team-agent/src/lifecycle/tests/codex_mcp_approval_inheritance_red.rs +1187 -0
  119. package/crates/team-agent/src/lifecycle/tests/codex_weak_window_attribution_red.rs +683 -0
  120. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +394 -0
  121. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +1856 -0
  122. package/crates/team-agent/src/lifecycle/tests/core_034_real_red.rs +917 -0
  123. package/crates/team-agent/src/lifecycle/tests/display_adaptive_red.rs +481 -0
  124. package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +301 -0
  125. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +516 -0
  126. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +986 -0
  127. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +651 -0
  128. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +2 -0
  129. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +332 -0
  130. package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +846 -0
  131. package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +648 -0
  132. package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +910 -0
  133. package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +630 -0
  134. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +1083 -0
  135. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +1677 -0
  136. package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +410 -0
  137. package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +428 -0
  138. package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +1032 -0
  139. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +869 -0
  140. package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +1249 -0
  141. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +342 -0
  142. package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +542 -0
  143. package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +1103 -0
  144. package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +1276 -0
  145. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +145 -0
  146. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +603 -0
  147. package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +837 -0
  148. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +928 -0
  149. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +951 -0
  150. package/crates/team-agent/src/lifecycle/tests/worker_dangerous_bypass_argv_red.rs +327 -0
  151. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +760 -0
  152. package/crates/team-agent/src/lifecycle/tests.rs +59 -0
  153. package/crates/team-agent/src/lifecycle/types.rs +0 -9
  154. package/crates/team-agent/src/mcp_server/helpers.rs +1 -0
  155. package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +1 -0
  156. package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +1 -0
  157. package/crates/team-agent/src/mcp_server/mod.rs +1 -0
  158. package/crates/team-agent/src/mcp_server/normalize.rs +4 -3
  159. package/crates/team-agent/src/mcp_server/tools.rs +1 -0
  160. package/crates/team-agent/src/mcp_server/types.rs +1 -18
  161. package/crates/team-agent/src/mcp_server/wire.rs +5 -5
  162. package/crates/team-agent/src/messaging/activity.rs +1 -0
  163. package/crates/team-agent/src/messaging/address.rs +1 -0
  164. package/crates/team-agent/src/messaging/delivery.rs +4 -3
  165. package/crates/team-agent/src/messaging/helpers.rs +2 -1
  166. package/crates/team-agent/src/messaging/leader_channel.rs +1 -0
  167. package/crates/team-agent/src/messaging/leader_receiver.rs +2 -1
  168. package/crates/team-agent/src/messaging/mod.rs +10 -14
  169. package/crates/team-agent/src/messaging/peers.rs +2 -0
  170. package/crates/team-agent/src/messaging/persist.rs +3 -1
  171. package/crates/team-agent/src/messaging/presentation.rs +2 -1
  172. package/crates/team-agent/src/messaging/results.rs +1 -0
  173. package/crates/team-agent/src/messaging/scheduler.rs +1 -0
  174. package/crates/team-agent/src/messaging/selftest.rs +1 -1
  175. package/crates/team-agent/src/messaging/send.rs +41 -8
  176. package/crates/team-agent/src/messaging/tests/mod.rs +5 -0
  177. package/crates/team-agent/src/messaging/types.rs +2 -2
  178. package/crates/team-agent/src/messaging/watchers.rs +19 -13
  179. package/crates/team-agent/src/model/enums.rs +1 -0
  180. package/crates/team-agent/src/model/errors.rs +1 -0
  181. package/crates/team-agent/src/model/ids.rs +1 -0
  182. package/crates/team-agent/src/model/mod.rs +1 -0
  183. package/crates/team-agent/src/model/name_similarity.rs +1 -0
  184. package/crates/team-agent/src/model/pane_authority_refusal.rs +1 -0
  185. package/crates/team-agent/src/model/paths.rs +1 -0
  186. package/crates/team-agent/src/model/permissions.rs +3 -2
  187. package/crates/team-agent/src/model/routing.rs +1 -0
  188. package/crates/team-agent/src/model/spec.rs +1 -0
  189. package/crates/team-agent/src/model/task_graph.rs +1 -0
  190. package/crates/team-agent/src/model/yaml/tests.rs +1 -0
  191. package/crates/team-agent/src/model/yaml.rs +1 -0
  192. package/crates/team-agent/src/packaging/install.rs +9 -147
  193. package/crates/team-agent/src/packaging/migrate.rs +2 -0
  194. package/crates/team-agent/src/packaging/mod.rs +1 -0
  195. package/crates/team-agent/src/packaging/repair.rs +2 -0
  196. package/crates/team-agent/src/packaging/tests.rs +29 -218
  197. package/crates/team-agent/src/packaging/types.rs +8 -15
  198. package/crates/team-agent/src/platform/argv.rs +4 -0
  199. package/crates/team-agent/src/platform/errors.rs +10 -1
  200. package/crates/team-agent/src/platform/file_lock.rs +4 -157
  201. package/crates/team-agent/src/platform/mod.rs +0 -61
  202. package/crates/team-agent/src/platform/process.rs +1 -0
  203. package/crates/team-agent/src/provider/adapter.rs +1 -0
  204. package/crates/team-agent/src/provider/adapters/claude.rs +1 -0
  205. package/crates/team-agent/src/provider/adapters/claude_fork.rs +1 -0
  206. package/crates/team-agent/src/provider/adapters/codex.rs +1 -0
  207. package/crates/team-agent/src/provider/adapters/copilot.rs +1 -0
  208. package/crates/team-agent/src/provider/adapters/copilot_fork.rs +1 -0
  209. package/crates/team-agent/src/provider/adapters/fake.rs +1 -0
  210. package/crates/team-agent/src/provider/adapters/mod.rs +1 -0
  211. package/crates/team-agent/src/provider/approvals/mod.rs +1 -0
  212. package/crates/team-agent/src/provider/approvals/parsing.rs +2 -5
  213. package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +6 -5
  214. package/crates/team-agent/src/provider/classify.rs +1 -0
  215. package/crates/team-agent/src/provider/faults.rs +1 -26
  216. package/crates/team-agent/src/provider/helpers.rs +1 -0
  217. package/crates/team-agent/src/provider/mod.rs +1 -1
  218. package/crates/team-agent/src/provider/session/capture.rs +1 -4
  219. package/crates/team-agent/src/provider/session/context_fork/claude.rs +1 -0
  220. package/crates/team-agent/src/provider/session/context_fork/codex.rs +1 -0
  221. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +1 -0
  222. package/crates/team-agent/src/provider/session/context_fork.rs +1 -0
  223. package/crates/team-agent/src/provider/session/mod.rs +2 -4
  224. package/crates/team-agent/src/provider/session/resume.rs +2 -209
  225. package/crates/team-agent/src/provider/session_scan/claude.rs +1 -0
  226. package/crates/team-agent/src/provider/session_scan/codex.rs +1 -0
  227. package/crates/team-agent/src/provider/session_scan/common.rs +1 -0
  228. package/crates/team-agent/src/provider/session_scan/copilot.rs +1 -0
  229. package/crates/team-agent/src/provider/session_scan.rs +1 -42
  230. package/crates/team-agent/src/provider/startup_prompt.rs +1 -0
  231. package/crates/team-agent/src/provider/types.rs +1 -0
  232. package/crates/team-agent/src/provider/wire.rs +1 -0
  233. package/crates/team-agent/src/state/identity.rs +16 -5
  234. package/crates/team-agent/src/state/identity_keys.rs +1 -0
  235. package/crates/team-agent/src/state/mod.rs +2 -0
  236. package/crates/team-agent/src/state/owner_gate.rs +5 -0
  237. package/crates/team-agent/src/state/ownership.rs +10 -4
  238. package/crates/team-agent/src/state/paths.rs +12 -0
  239. package/crates/team-agent/src/state/persist.rs +9 -3
  240. package/crates/team-agent/src/state/projection.rs +15 -2
  241. package/crates/team-agent/src/state/repository/intent.rs +1 -0
  242. package/crates/team-agent/src/state/repository/tests.rs +1 -0
  243. package/crates/team-agent/src/state/repository.rs +7 -0
  244. package/crates/team-agent/src/state/selector.rs +1 -0
  245. package/crates/team-agent/src/tmux_backend/tests.rs +39 -0
  246. package/crates/team-agent/src/tmux_backend.rs +63 -0
  247. package/crates/team-agent/src/transport.rs +15 -0
  248. package/package.json +4 -4
  249. package/crates/team-agent/src/leader/inject.rs +0 -33
  250. package/crates/team-agent/src/provider/command.rs +0 -80
package/Cargo.lock CHANGED
@@ -575,7 +575,7 @@ dependencies = [
575
575
 
576
576
  [[package]]
577
577
  name = "team-agent"
578
- version = "0.5.61"
578
+ version = "0.5.62"
579
579
  dependencies = [
580
580
  "anyhow",
581
581
  "chrono",
package/Cargo.toml CHANGED
@@ -9,7 +9,7 @@ members = ["crates/team-agent", "crates/win-conpty-phase0", "crates/conpty-trans
9
9
 
10
10
  [workspace.package]
11
11
  edition = "2021"
12
- version = "0.5.61"
12
+ version = "0.5.62"
13
13
  license = "AGPL-3.0"
14
14
  rust-version = "1.95"
15
15
 
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! cli · adapters — 每子命令的薄壳 `cmd_*`(commands.py)。委派 status/lifecycle/diagnose/
2
3
  //! leader/messaging port,把委派结果包成 [`CmdResult`]。含逻辑的:`cmd_status`(三态互斥)、
3
4
  //! `cmd_doctor`(gate/comms/fix-schema/cleanup-orphans 分派)。
@@ -221,7 +222,8 @@ fn warn_ignored_owner_team_id(team_dir: &std::path::Path) {
221
222
 
222
223
  /// `cmd_status`(`commands.py:90`)。三态:`--summary`(xor json,xor agent)→五行文本;
223
224
  /// `--json`→`status_port::status(compact=!detail)`;else→`status_port::format_status(agent)`。
224
- pub fn cmd_status(args: &StatusArgs) -> Result<CmdResult, CliError> {
225
+ #[cfg(test)]
226
+ pub(crate) fn cmd_status(args: &StatusArgs) -> Result<CmdResult, CliError> {
225
227
  cmd_status_for_team(args, args.team.as_deref())
226
228
  }
227
229
 
@@ -408,7 +410,8 @@ pub fn cmd_sessions(args: &SessionsArgs) -> Result<CmdResult, CliError> {
408
410
  }
409
411
 
410
412
  /// `cmd_collect`(`parser.py:292`)。
411
- pub fn cmd_collect(args: &CollectArgs) -> Result<CmdResult, CliError> {
413
+ #[cfg(test)]
414
+ pub(crate) fn cmd_collect(args: &CollectArgs) -> Result<CmdResult, CliError> {
412
415
  cmd_collect_for_team(args, args.team.as_deref())
413
416
  }
414
417
 
@@ -1,3 +1,4 @@
1
+ //!
1
2
  use super::*;
2
3
 
3
4
  /// `team-agent attach-app-server-leader` writes a typed codex_app_server
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! diagnose/preflight/wait-ready CLI helpers.
2
3
  use super::*;
3
4
  use crate::model::pane_authority_refusal::{
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! cli · emit — `emit`(--json vs 人读 dict 逐键)+ 顶层 `run` 调度(parser.py `main`)+
2
3
  //! 人读标量/集合渲染(`human_value` / `json_dumps_like`)。
3
4
 
@@ -5,6 +6,7 @@ use super::spec::{command_spec, CommandKind, CommandTier, ALL_DISPATCH_KINDS, CO
5
6
  use super::*;
6
7
  use std::io::{ErrorKind, Write as _};
7
8
 
9
+ ///
8
10
  /// `emit`(`helpers.py:12-23`):`--json`→`json.dumps(indent=2, ensure_ascii=False, sort_keys=True)`;
9
11
  /// 否则 dict 逐键 `key: value`(嵌套 dict/list 内联 compact json,`ensure_ascii=False`)、非 dict 直接 print。
10
12
  /// 返回应打印到 stdout 的字符串(bin main 负责实际 println)。
@@ -42,6 +44,7 @@ fn emit_with_json_order(
42
44
  }
43
45
  }
44
46
 
47
+ ///
45
48
  /// `main(argv)`(`parser.py:84`):**CLI 唯一进程入口**。codex/claude/copilot passthrough 早返回 →
46
49
  /// 解析 argv 到 subcommand → 调对应 handler → 异常落盘 + 信封 + `ExitCode::Error` →
47
50
  /// `consume_leader_inbox_summary` → `emit` → `result.ok is False ? Error : Ok`。
@@ -333,6 +336,7 @@ fn compat_hidden_help(command: &str, usage: &str) -> String {
333
336
  format!("{usage}\n\nstatus: hidden compatibility command\nsunset: {sunset}\naction: {action}")
334
337
  }
335
338
 
339
+ ///
336
340
  /// Test-only public accessor for `command_help` — allows integration
337
341
  /// tests to grep the help copy without depending on internal parser
338
342
  /// machinery.
@@ -340,6 +344,7 @@ pub fn __test_command_help(command: Option<&str>) -> String {
340
344
  command_help(command)
341
345
  }
342
346
 
347
+ ///
343
348
  /// Test-only public accessor for `quick_start_args` — allows
344
349
  /// integration tests to exercise the parser without going through
345
350
  /// stdio + the full `main` entrypoint.
@@ -1094,6 +1099,7 @@ fn send_args(args: &[String], cwd: &Path) -> Result<SendArgs, CliError> {
1094
1099
  };
1095
1100
  let message_start = usize::from(target.is_some());
1096
1101
  let workspace = workspace(&parsed, cwd);
1102
+ let sender = trusted_cli_sender(&workspace, parsed.team.as_deref())?;
1097
1103
  let presentation_value = if parsed.presentation_sink.is_some()
1098
1104
  || parsed.message_class.is_some()
1099
1105
  || parsed.case_id.is_some()
@@ -1127,7 +1133,7 @@ fn send_args(args: &[String], cwd: &Path) -> Result<SendArgs, CliError> {
1127
1133
  workspace,
1128
1134
  team: parsed.team,
1129
1135
  task: None,
1130
- sender: trusted_cli_sender(),
1136
+ sender,
1131
1137
  no_ack: false,
1132
1138
  no_wait: true,
1133
1139
  watch_result: false,
@@ -1142,14 +1148,42 @@ fn send_args(args: &[String], cwd: &Path) -> Result<SendArgs, CliError> {
1142
1148
  })
1143
1149
  }
1144
1150
 
1145
- fn trusted_cli_sender() -> TrustedSender {
1146
- std::env::var("TEAM_AGENT_ID")
1151
+ fn trusted_cli_sender(workspace: &Path, team: Option<&str>) -> Result<TrustedSender, CliError> {
1152
+ let agent_id = std::env::var("TEAM_AGENT_ID")
1147
1153
  .ok()
1148
1154
  .map(|value| value.trim().to_string())
1149
- .filter(|value| !value.is_empty())
1150
- .map(crate::model::ids::AgentId::new)
1151
- .map(TrustedSender::from_runtime_identity)
1152
- .unwrap_or_else(TrustedSender::leader)
1155
+ .filter(|value| !value.is_empty());
1156
+ let worker_context = ["TEAM_AGENT_OWNER_TEAM_ID", "TEAM_AGENT_AGENT_ID"]
1157
+ .into_iter()
1158
+ .any(|key| {
1159
+ std::env::var(key)
1160
+ .ok()
1161
+ .is_some_and(|value| !value.trim().is_empty())
1162
+ });
1163
+ let Some(agent_id) = agent_id else {
1164
+ if worker_context {
1165
+ return Err(CliError::Usage(
1166
+ "send requires framework-injected TEAM_AGENT_ID; refusing leader identity fallback"
1167
+ .to_string(),
1168
+ ));
1169
+ }
1170
+ return Ok(TrustedSender::leader());
1171
+ };
1172
+ let source_workspace = std::env::var("TEAM_AGENT_WORKSPACE")
1173
+ .ok()
1174
+ .filter(|value| !value.trim().is_empty())
1175
+ .unwrap_or_else(|| workspace.display().to_string());
1176
+ let source_team = std::env::var("TEAM_AGENT_OWNER_TEAM_ID")
1177
+ .ok()
1178
+ .or_else(|| std::env::var("TEAM_AGENT_TEAM_ID").ok())
1179
+ .or_else(|| team.map(ToOwned::to_owned))
1180
+ .filter(|value| !value.trim().is_empty())
1181
+ .unwrap_or_else(|| "unknown".to_string());
1182
+ Ok(TrustedSender::from_runtime_identity_with_source(
1183
+ crate::model::ids::AgentId::new(agent_id),
1184
+ source_workspace,
1185
+ &source_team,
1186
+ ))
1153
1187
  }
1154
1188
 
1155
1189
  fn warn_send_legacy_delivery_flags(args: &[String]) {
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! cli · helpers — 跨子模块共用的小工具:tmux 冲突解析、Python 真值/falsy-or 语义、
2
3
  //! 字符级截断、相对 age 文本、稳定 key-sorted JSON。
3
4
 
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! cli · leader — `codex`/`claude`/`copilot` passthrough(`cmd_leader_passthrough` + `_provider_args` /
2
3
  //! `_leader_launcher_args`)+ leader fallback inbox 摘要(`consume_leader_inbox_summary` 及
3
4
  //! `_leader_inbox_entries` / `_leader_inbox_summary` / `_leader_inbox_entry_title`)。
@@ -8,6 +9,7 @@ use super::*;
8
9
  // `codex`/`claude` passthrough 解析(helpers.py `_provider_args`/`_leader_launcher_args`)
9
10
  // =============================================================================
10
11
 
12
+ ///
11
13
  /// `_provider_args`(`helpers.py:190-193`):剥掉前导 `--`(REMAINDER 第一个 token)。
12
14
  pub fn provider_args(values: &[String]) -> Vec<String> {
13
15
  match values.first().map(String::as_str) {
@@ -16,8 +18,9 @@ pub fn provider_args(values: &[String]) -> Vec<String> {
16
18
  }
17
19
  }
18
20
 
21
+ ///
19
22
  /// `_leader_launcher_args`(`helpers.py:196-226`):解析 attach 旗标;`--attach-session` 缺值 → Err。
20
- pub fn leader_launcher_args(values: &[String]) -> Result<LeaderLauncherArgs, CliError> {
23
+ pub(super) fn leader_launcher_args(values: &[String]) -> Result<LeaderLauncherArgs, CliError> {
21
24
  let mut out = LeaderLauncherArgs::default();
22
25
  let mut idx = 0;
23
26
  while idx < values.len() {
@@ -92,6 +95,7 @@ fn without_leader_json(values: &[String]) -> Vec<String> {
92
95
  out
93
96
  }
94
97
 
98
+ ///
95
99
  /// `codex`/`claude`/`copilot` passthrough(`parser.py:86`/`_run_leader_passthrough`):leader 早返回,
96
100
  /// **不**进 subparser。`-h`/`--help` 打 usage 直接返回 [`CmdResult::none`]。否则解析 attach
97
101
  /// 旗标 + `lifecycle_port::start_leader`。`command` ∈ {codex, claude, copilot}。
@@ -120,6 +124,7 @@ pub(crate) fn leader_passthrough_provider(command: &str) -> crate::model::enums:
120
124
  // leader fallback inbox 摘要(helpers.py `consume_leader_inbox_summary`)
121
125
  // =============================================================================
122
126
 
127
+ ///
123
128
  /// `consume_leader_inbox_summary`(`helpers.py:26-55`):每条命令后读
124
129
  /// `.team/runtime/leader-inbox.log`,从游标 `.cursor` 起读新增字节,渲染 N 条 fallback 条目摘要
125
130
  /// (`_leader_inbox_summary`,字节预算 budget=500 截断 + `Hint: team-agent inbox leader`),
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! E7 (0.5.9 host-leader-registry-design §4.1): `team-agent leaders` command.
2
3
  //!
3
4
  //! Enumerates entries under `~/.team-agent/leaders`, re-validates each
@@ -13,6 +14,7 @@
13
14
  use super::{types::LeadersArgs, CliError, CmdResult};
14
15
  use serde_json::{json, Value};
15
16
 
17
+ ///
16
18
  /// E7 CLI entry point (E7 test 2 marker: `cmd_leaders`).
17
19
  ///
18
20
  /// Reads registry entries, canonical-validates each, and groups by
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! step 14b · cli — `team-agent <subcommand>` clap 命令面(真相源 `cli/`)。
2
3
  //!
3
4
  //! Card: `docs/phase0/subsystems/14-mcp_cli.md`(CLI 半边)。
@@ -78,6 +79,7 @@ pub use send::*;
78
79
  pub use status::*;
79
80
  pub use types::*;
80
81
 
82
+ ///
81
83
  /// Public `attach-leader` CLI handler. It consumes the typed pane/provider args and
82
84
  /// writes/returns a `leader_receiver` binding via the leader lease port.
83
85
  pub fn cmd_attach_leader(args: &AttachLeaderArgs) -> Result<CmdResult, CliError> {
@@ -117,6 +119,7 @@ pub mod lifecycle_port {
117
119
  use super::*;
118
120
  use crate::model::enums::Provider;
119
121
 
122
+ ///
120
123
  /// `runtime.quick_start`(`cmd_quick_start` 委派)。返回 `{ok, summary, ...}` 稳定形状。
121
124
  pub fn quick_start(
122
125
  workspace: &Path,
@@ -140,6 +143,7 @@ pub mod lifecycle_port {
140
143
  Err(e) => Ok(error_value(e)),
141
144
  }
142
145
  }
146
+ ///
143
147
  /// `runtime.start_leader`(`codex`/`claude` passthrough + `cmd_codex`/`cmd_claude`)。
144
148
  pub fn start_leader(
145
149
  provider: Provider,
@@ -456,6 +460,7 @@ pub mod lifecycle_port {
456
460
  let window = plan.leader_window.as_ref()?;
457
461
  crate::tmux_backend::attach_command_for_workspace(cwd, session, window.as_str())
458
462
  }
463
+ ///
459
464
  /// `runtime.shutdown`(`cmd_shutdown`)。
460
465
  ///
461
466
  /// 0.5.x Phase 1d Batch 5: the workspace-transport branch now routes
@@ -547,6 +552,7 @@ pub mod lifecycle_port {
547
552
  },
548
553
  }
549
554
 
555
+ ///
550
556
  /// E12 纯决策(单测下沉):spare = `anchor_sessions` ∪ `team-agent-leader-*` 前缀(并集,锚优先)。
551
557
  /// 全部 session 都不 spare 且非空 → `KillServerExclusive`(独享 socket 兜底);否则逐 session
552
558
  /// kill 非 spare 的(共享 socket / leader 在 → 绝不整 server 拆)。空 session 集 → 逐 kill(no-op)。
@@ -2019,6 +2025,7 @@ pub mod lifecycle_port {
2019
2025
  }
2020
2026
  }
2021
2027
 
2028
+ ///
2022
2029
  /// E4 真机 grounded(任何 team 的 shutdown 都不杀任何 team 的 leader 锚 pane):
2023
2030
  /// 扫 state.json 收集所有 leader-anchor pane_id(top-level team_owner /
2024
2031
  /// leader_receiver + teams[<key>].* 嵌套形态)。返非空 BTreeSet 给
@@ -2230,6 +2237,7 @@ pub mod lifecycle_port {
2230
2237
  protected
2231
2238
  }
2232
2239
 
2240
+ ///
2233
2241
  /// B5/F2 + E4 真机 grounded(任何 team 的 shutdown 都不杀任何 team 的 leader 锚 pane):
2234
2242
  /// the leader terminal's pane process tree joins the protected set (same set, same
2235
2243
  /// mechanism as the invoker ancestry) so the workspace residual sweep's cmdline/cwd
@@ -2595,6 +2603,7 @@ pub mod lifecycle_port {
2595
2603
  let root = root.canonicalize().unwrap_or_else(|_| root.to_path_buf());
2596
2604
  path == root || path.starts_with(root)
2597
2605
  }
2606
+ ///
2598
2607
  /// `runtime.restart`(`cmd_restart`)。
2599
2608
  pub fn restart(
2600
2609
  workspace: &Path,
@@ -2612,6 +2621,7 @@ pub mod lifecycle_port {
2612
2621
  Err(e) => Ok(error_value(e)),
2613
2622
  }
2614
2623
  }
2624
+ ///
2615
2625
  /// `runtime.start_agent`(`cmd_start_agent`)。
2616
2626
  pub fn start_agent(
2617
2627
  workspace: &Path,
@@ -2636,6 +2646,7 @@ pub mod lifecycle_port {
2636
2646
  Err(e) => Ok(error_value(e)),
2637
2647
  }
2638
2648
  }
2649
+ ///
2639
2650
  /// `runtime.stop_agent`(`cmd_stop_agent`)。
2640
2651
  pub fn stop_agent(
2641
2652
  workspace: &Path,
@@ -2648,6 +2659,7 @@ pub mod lifecycle_port {
2648
2659
  Err(e) => Ok(error_value(e)),
2649
2660
  }
2650
2661
  }
2662
+ ///
2651
2663
  /// `runtime.reset_agent`(`cmd_reset_agent`;`--discard-session` 必需)。
2652
2664
  pub fn reset_agent(
2653
2665
  workspace: &Path,
@@ -2698,6 +2710,7 @@ pub mod lifecycle_port {
2698
2710
  Err(e) => Ok(error_value(e)),
2699
2711
  }
2700
2712
  }
2713
+ ///
2701
2714
  /// `runtime.add_agent`(`cmd_add_agent`;`--role-file` 必需)。
2702
2715
  pub fn add_agent(
2703
2716
  workspace: &Path,
@@ -2724,6 +2737,7 @@ pub mod lifecycle_port {
2724
2737
  Err(e) => Ok(error_value(e)),
2725
2738
  }
2726
2739
  }
2740
+ ///
2727
2741
  /// `runtime.fork_agent`(`cmd_fork_agent`;`--as` 必需)。
2728
2742
  pub fn fork_agent(
2729
2743
  workspace: &Path,
@@ -2771,6 +2785,7 @@ pub mod lifecycle_port {
2771
2785
  Err(error) => Ok(error_value(error)),
2772
2786
  }
2773
2787
  }
2788
+ ///
2774
2789
  /// `runtime.remove_agent`(`cmd_remove_agent`;`--from-spec` 须配 `--confirm`)。
2775
2790
  pub fn remove_agent(
2776
2791
  workspace: &Path,
@@ -2942,6 +2957,7 @@ pub mod lifecycle_port {
2942
2957
  format!("'{}'", raw.replace('\'', "'\\''"))
2943
2958
  }
2944
2959
  }
2960
+ ///
2945
2961
  /// `runtime.acknowledge_idle`(`cmd_acknowledge_idle`)。
2946
2962
  pub fn acknowledge_idle(workspace: &Path, team: Option<&str>) -> Result<Value, CliError> {
2947
2963
  let mut state = crate::state::persist::load_runtime_state(workspace)
@@ -4067,6 +4083,7 @@ pub mod lifecycle_port {
4067
4083
  pub mod diagnose_port {
4068
4084
  use super::*;
4069
4085
 
4086
+ ///
4070
4087
  /// `runtime.doctor(spec)` + schema 注入(`cmd_doctor` 默认分支)。
4071
4088
  pub fn doctor(workspace: &Path, spec: Option<&Path>) -> Result<Value, CliError> {
4072
4089
  let tmux_path = which_path("tmux");
@@ -4334,8 +4351,10 @@ pub mod diagnose_port {
4334
4351
  }
4335
4352
  }
4336
4353
  }
4354
+ ///
4337
4355
  /// `run_comms_selftest`(`--comms`/`--gate comms`)。**纯 state-read,零 token**(MUST-NOT-13)。
4338
- pub fn comms_selftest(
4356
+ #[cfg(test)]
4357
+ pub(super) fn comms_selftest(
4339
4358
  workspace: &Path,
4340
4359
  team: Option<&str>,
4341
4360
  gate: Option<&str>,
@@ -4343,14 +4362,19 @@ pub mod diagnose_port {
4343
4362
  crate::diagnose::comms::doctor_comms_json(workspace, team, gate)
4344
4363
  }
4345
4364
 
4365
+ ///
4346
4366
  /// `orphan_gate(fix, confirm)`(`--gate orphans`)。CI gate。
4347
- pub fn orphan_gate(workspace: &Path, fix: bool, confirm: bool) -> Result<Value, CliError> {
4367
+ #[cfg(test)]
4368
+ pub(super) fn orphan_gate(workspace: &Path, fix: bool, confirm: bool) -> Result<Value, CliError> {
4348
4369
  crate::diagnose::orphans::orphan_gate_json(workspace, fix, confirm)
4349
4370
  }
4371
+ ///
4350
4372
  /// `cleanup_orphan_coordinators(confirm)`(`--cleanup-orphans`;dry-run unless `--confirm`)。
4351
- pub fn cleanup_orphans(workspace: &Path, confirm: bool) -> Result<Value, CliError> {
4373
+ #[cfg(test)]
4374
+ pub(super) fn cleanup_orphans(workspace: &Path, confirm: bool) -> Result<Value, CliError> {
4352
4375
  crate::diagnose::orphans::cleanup_orphans_json(workspace, confirm)
4353
4376
  }
4377
+ ///
4354
4378
  /// `fix_schema_layout`(`--fix-schema`)/`schema_diagnosis`。
4355
4379
  pub fn fix_schema(workspace: &Path) -> Result<Value, CliError> {
4356
4380
  let db_path = workspace.join(".team").join("runtime").join("team.db");
@@ -4520,6 +4544,7 @@ pub mod diagnose_port {
4520
4544
  pub mod leader_port {
4521
4545
  use super::*;
4522
4546
 
4547
+ ///
4523
4548
  /// `runtime.takeover(workspace, team, confirm)` 的 CLI `--json` 投影。
4524
4549
  pub fn takeover(
4525
4550
  workspace: &Path,
@@ -4575,6 +4600,7 @@ pub mod leader_port {
4575
4600
  }
4576
4601
  Ok(value)
4577
4602
  }
4603
+ ///
4578
4604
  /// `runtime.claim_leader(...)` 的 CLI `--json` 投影(`cmd_claim_leader`;含 inbox_hint)。
4579
4605
  pub fn claim_leader(
4580
4606
  workspace: &Path,
@@ -4624,6 +4650,7 @@ pub mod leader_port {
4624
4650
  Ok(value)
4625
4651
  }
4626
4652
 
4653
+ ///
4627
4654
  /// `runtime.attach_leader(...)` 的 CLI `--json` 投影。
4628
4655
  pub fn attach_leader(
4629
4656
  workspace: &Path,
@@ -4651,6 +4678,7 @@ pub mod leader_port {
4651
4678
  Ok(value)
4652
4679
  }
4653
4680
 
4681
+ ///
4654
4682
  /// `runtime.leader_identity(workspace, team)`(`cmd_identity`)。
4655
4683
  pub fn leader_identity(workspace: &Path, team: Option<&str>) -> Result<Value, CliError> {
4656
4684
  crate::leader::leader_identity(workspace, team)
@@ -4720,6 +4748,7 @@ pub mod leader_port {
4720
4748
  );
4721
4749
  }
4722
4750
 
4751
+ ///
4723
4752
  /// E7 GC hook: called from shutdown/unbind success paths.
4724
4753
  pub(crate) fn unregister_after_shutdown_success(
4725
4754
  workspace: &Path,
@@ -4991,6 +5020,7 @@ pub mod leader_port {
4991
5020
  Ok(json!([]))
4992
5021
  }
4993
5022
 
5023
+ ///
4994
5024
  /// R8 D6 (decoupled for offline byte-lock — c-lite): project the requeued-exhausted event into the
4995
5025
  /// CLI `requeued_exhausted_watchers` return. golden (leader/__init__.py:56): the `watcher_ids`
4996
5026
  /// STRING list. (Current divergent body — the `requeued` Vec<WatcherNotice> objects — kept until
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! CLI-local stable name resolver for `team-agent send --to-name`.
2
3
 
3
4
  use std::path::{Path, PathBuf};
@@ -193,6 +194,7 @@ impl NamedAddressError {
193
194
  self.with_scoped_suggestions(requested_display, candidate_values, best)
194
195
  }
195
196
 
197
+ ///
196
198
  /// 0.5.45 naming-addressing (design §3.3/§3.4): attach an
197
199
  /// advisory suggestion payload. `requested` is the original typo
198
200
  /// (surfaced verbatim in JSON + N38 Action); `ranked_candidates`
@@ -469,6 +471,7 @@ fn normalize_bare_with_team_scope(
469
471
  }
470
472
  }
471
473
 
474
+ ///
472
475
  /// E6 wiring helper (`cli::send::maybe_enqueue_offline_leader_mailbox`):
473
476
  /// re-parse a `<workspace>::<team>/leader` name and return the resolved
474
477
  /// target workspace + canonical team_key so send.rs can enqueue the
@@ -500,10 +503,14 @@ struct ParsedNamedAddress {
500
503
 
501
504
  impl ParsedNamedAddress {
502
505
  fn display_name(&self) -> String {
503
- match &self.target {
506
+ let target = match &self.target {
504
507
  ParsedTarget::BareAgent(agent) => agent.clone(),
505
508
  ParsedTarget::TeamEntity { team, entity } => format!("{team}/{entity}"),
506
509
  ParsedTarget::SessionWindow { session, window } => format!("{session}:{window}"),
510
+ };
511
+ match &self.workspace {
512
+ Some(workspace) => format!("{}::{target}", workspace.display()),
513
+ None => target,
507
514
  }
508
515
  }
509
516
  }
@@ -1,3 +1,4 @@
1
+ //!
1
2
  //! `profile {init,doctor,show}` CLI verb.
2
3
 
3
4
  use super::*;
@@ -159,7 +160,7 @@ fn validate_auth_mode(auth_mode: &str) -> Result<(), CliError> {
159
160
  fn profile_template(name: &str, auth_mode: &str) -> String {
160
161
  match auth_mode {
161
162
  "compatible_api" | "official_api" => {
162
- format!("AUTH_MODE={auth_mode}\nPROFILE_NAME={name}\nAPI_KEY=\nMODEL=\n")
163
+ format!("AUTH_MODE={auth_mode}\nPROFILE_NAME={name}\nBASE_URL=\nAPI_KEY=\nMODEL=\n")
163
164
  }
164
165
  _ => format!("AUTH_MODE=subscription\nPROFILE_NAME={name}\n"),
165
166
  }
@@ -1,3 +1,4 @@
1
+ //!
1
2
  use super::*;
2
3
 
3
4
  pub(super) fn dirty_topology_refusal_value(
@@ -1,3 +1,4 @@
1
+ //!
1
2
  use super::*;
2
3
 
3
4
  pub(super) fn maybe_enqueue_offline_leader_mailbox(
@@ -64,6 +65,7 @@ pub(super) fn maybe_enqueue_offline_leader_mailbox(
64
65
  "to_name": to_name,
65
66
  "target_workspace": target_workspace.display().to_string(),
66
67
  "team_key": team_key,
68
+ "sender": sender,
67
69
  "recipient": "leader",
68
70
  "leader_attached": false,
69
71
  "message_id": message_id,
@@ -78,6 +80,7 @@ pub(super) fn maybe_enqueue_offline_leader_mailbox(
78
80
  "to_name": to_name,
79
81
  "target_workspace": target_workspace.display().to_string(),
80
82
  "team_key": team_key,
83
+ "sender": sender,
81
84
  "recipient": "leader",
82
85
  "leader_attached": false,
83
86
  "message_id": message_id,
@@ -1,3 +1,4 @@
1
+ //!
1
2
  use super::coordinator::{
2
3
  append_loud_ensure_fields, dirty_topology_refusal_value, loud_ensure_coordinator,
3
4
  target_has_known_worker,
@@ -1,3 +1,4 @@
1
+ //!
1
2
  use crate::cli::{CliError, CmdOutput, CmdResult, ExitCode};
2
3
  use crate::messaging::{
3
4
  DeliveryOutcome, DeliveryRefusal, DeliveryStage, DeliveryStatus, MessageTarget, SendOptions,