@team-agent/installer 0.5.127 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (421) hide show
  1. package/README.md +15 -4
  2. package/README.zh.md +1 -1
  3. package/package.json +4 -8
  4. package/skills/team-agent/SKILL.md +41 -26
  5. package/skills/team-agent/command-coverage.json +170 -184
  6. package/skills/team-agent/docs/reference/team-agent-operator.md +66 -32
  7. package/skills/team-agent/references/recovery-runbook.md +1 -1
  8. package/skills/team-agent/references/team-agent-operator.md +66 -32
  9. package/templates/team_state.md +1 -1
  10. package/Cargo.lock +0 -1063
  11. package/Cargo.toml +0 -36
  12. package/crates/team-agent/Cargo.toml +0 -69
  13. package/crates/team-agent/src/app_server_test_support.rs +0 -258
  14. package/crates/team-agent/src/cli/adapters.rs +0 -1298
  15. package/crates/team-agent/src/cli/arguments.rs +0 -401
  16. package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
  17. package/crates/team-agent/src/cli/diagnose.rs +0 -1675
  18. package/crates/team-agent/src/cli/emit.rs +0 -2898
  19. package/crates/team-agent/src/cli/grok_slot.rs +0 -384
  20. package/crates/team-agent/src/cli/helpers.rs +0 -91
  21. package/crates/team-agent/src/cli/intent/runtime.rs +0 -1189
  22. package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -821
  23. package/crates/team-agent/src/cli/intent/tests.rs +0 -691
  24. package/crates/team-agent/src/cli/intent.rs +0 -664
  25. package/crates/team-agent/src/cli/leader.rs +0 -300
  26. package/crates/team-agent/src/cli/leader_prompt.rs +0 -261
  27. package/crates/team-agent/src/cli/leaders.rs +0 -418
  28. package/crates/team-agent/src/cli/mod.rs +0 -6528
  29. package/crates/team-agent/src/cli/models.rs +0 -449
  30. package/crates/team-agent/src/cli/named_address.rs +0 -1651
  31. package/crates/team-agent/src/cli/profile.rs +0 -342
  32. package/crates/team-agent/src/cli/route.rs +0 -212
  33. package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
  34. package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
  35. package/crates/team-agent/src/cli/send/persist.rs +0 -192
  36. package/crates/team-agent/src/cli/send/presentation.rs +0 -370
  37. package/crates/team-agent/src/cli/send/resolve.rs +0 -573
  38. package/crates/team-agent/src/cli/send.rs +0 -201
  39. package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
  40. package/crates/team-agent/src/cli/spec.rs +0 -159
  41. package/crates/team-agent/src/cli/status.rs +0 -280
  42. package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
  43. package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
  44. package/crates/team-agent/src/cli/status_port/brief.rs +0 -2043
  45. package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
  46. package/crates/team-agent/src/cli/status_port/format.rs +0 -146
  47. package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
  48. package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
  49. package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
  50. package/crates/team-agent/src/cli/status_port/store.rs +0 -416
  51. package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
  52. package/crates/team-agent/src/cli/status_port.rs +0 -92
  53. package/crates/team-agent/src/cli/tests/base.rs +0 -885
  54. package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
  55. package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
  56. package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -372
  57. package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
  58. package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
  59. package/crates/team-agent/src/cli/tests/mod.rs +0 -137
  60. package/crates/team-agent/src/cli/tests/named_address.rs +0 -760
  61. package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
  62. package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -481
  63. package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
  64. package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
  65. package/crates/team-agent/src/cli/tests/status_send.rs +0 -1091
  66. package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
  67. package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
  68. package/crates/team-agent/src/cli/triage.rs +0 -234
  69. package/crates/team-agent/src/cli/types.rs +0 -591
  70. package/crates/team-agent/src/codex_app_server.rs +0 -546
  71. package/crates/team-agent/src/communication_mode/mod.rs +0 -56
  72. package/crates/team-agent/src/compiler/tests.rs +0 -842
  73. package/crates/team-agent/src/compiler.rs +0 -691
  74. package/crates/team-agent/src/conpty/backend.rs +0 -829
  75. package/crates/team-agent/src/conpty/mod.rs +0 -33
  76. package/crates/team-agent/src/contract_runtime/backend.rs +0 -1610
  77. package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
  78. package/crates/team-agent/src/contract_runtime/config.rs +0 -354
  79. package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -56
  80. package/crates/team-agent/src/contract_runtime/discovery.rs +0 -438
  81. package/crates/team-agent/src/contract_runtime/fork.rs +0 -368
  82. package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
  83. package/crates/team-agent/src/contract_runtime/framework.rs +0 -350
  84. package/crates/team-agent/src/contract_runtime/mcp.rs +0 -399
  85. package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
  86. package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
  87. package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
  88. package/crates/team-agent/src/contract_runtime/registry.rs +0 -589
  89. package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
  90. package/crates/team-agent/src/coordinator/backoff.rs +0 -741
  91. package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
  92. package/crates/team-agent/src/coordinator/health.rs +0 -1185
  93. package/crates/team-agent/src/coordinator/mod.rs +0 -119
  94. package/crates/team-agent/src/coordinator/orphan.rs +0 -110
  95. package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
  96. package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
  97. package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
  98. package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
  99. package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
  100. package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
  101. package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
  102. package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
  103. package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
  104. package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
  105. package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
  106. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -338
  107. package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
  108. package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
  109. package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
  110. package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -461
  111. package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
  112. package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
  113. package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
  114. package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
  115. package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
  116. package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
  117. package/crates/team-agent/src/coordinator/tick.rs +0 -3112
  118. package/crates/team-agent/src/coordinator/types.rs +0 -540
  119. package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
  120. package/crates/team-agent/src/db/message_store.rs +0 -1585
  121. package/crates/team-agent/src/db/migration.rs +0 -984
  122. package/crates/team-agent/src/db/mod.rs +0 -26
  123. package/crates/team-agent/src/db/schema.rs +0 -663
  124. package/crates/team-agent/src/diagnose/comms.rs +0 -242
  125. package/crates/team-agent/src/diagnose/mod.rs +0 -44
  126. package/crates/team-agent/src/diagnose/orphans.rs +0 -889
  127. package/crates/team-agent/src/event_log.rs +0 -502
  128. package/crates/team-agent/src/fake_worker.rs +0 -303
  129. package/crates/team-agent/src/kill_audit.rs +0 -106
  130. package/crates/team-agent/src/layout/manager.rs +0 -248
  131. package/crates/team-agent/src/layout/mod.rs +0 -36
  132. package/crates/team-agent/src/layout/overlay.rs +0 -134
  133. package/crates/team-agent/src/layout/placement.rs +0 -52
  134. package/crates/team-agent/src/layout/recovery.rs +0 -106
  135. package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
  136. package/crates/team-agent/src/layout/sessions.rs +0 -294
  137. package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
  138. package/crates/team-agent/src/layout/worker_env.rs +0 -721
  139. package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
  140. package/crates/team-agent/src/leader/helpers.rs +0 -178
  141. package/crates/team-agent/src/leader/incident.rs +0 -6
  142. package/crates/team-agent/src/leader/lease.rs +0 -3356
  143. package/crates/team-agent/src/leader/mod.rs +0 -104
  144. package/crates/team-agent/src/leader/owner_bind.rs +0 -400
  145. package/crates/team-agent/src/leader/prompt.rs +0 -905
  146. package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
  147. package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
  148. package/crates/team-agent/src/leader/rediscover.rs +0 -1192
  149. package/crates/team-agent/src/leader/registry.rs +0 -883
  150. package/crates/team-agent/src/leader/start.rs +0 -4500
  151. package/crates/team-agent/src/leader/takeover.rs +0 -65
  152. package/crates/team-agent/src/leader/tests/basics.rs +0 -337
  153. package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
  154. package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
  155. package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
  156. package/crates/team-agent/src/leader/tests/identity.rs +0 -465
  157. package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
  158. package/crates/team-agent/src/leader/tests/idle.rs +0 -113
  159. package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
  160. package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
  161. package/crates/team-agent/src/leader/tests/mod.rs +0 -106
  162. package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -267
  163. package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
  164. package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
  165. package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
  166. package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
  167. package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
  168. package/crates/team-agent/src/leader/types.rs +0 -534
  169. package/crates/team-agent/src/lib.rs +0 -145
  170. package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
  171. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -848
  172. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -393
  173. package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
  174. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -178
  175. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -82
  176. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -63
  177. package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
  178. package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
  179. package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
  180. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -152
  181. package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
  182. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -629
  183. package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -226
  184. package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
  185. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5176
  186. package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
  187. package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
  188. package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
  189. package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -450
  190. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
  191. package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
  192. package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
  193. package/crates/team-agent/src/lifecycle/launch.rs +0 -534
  194. package/crates/team-agent/src/lifecycle/lock.rs +0 -350
  195. package/crates/team-agent/src/lifecycle/mod.rs +0 -79
  196. package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
  197. package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -757
  198. package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
  199. package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2198
  200. package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2052
  201. package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
  202. package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
  203. package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
  204. package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
  205. package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
  206. package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
  207. package/crates/team-agent/src/lifecycle/restart.rs +0 -223
  208. package/crates/team-agent/src/lifecycle/role_config.rs +0 -1205
  209. package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
  210. package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
  211. package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
  212. package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
  213. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
  214. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -135
  215. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1415
  216. package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
  217. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -396
  218. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -418
  219. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2039
  220. package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1298
  221. package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
  222. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
  223. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
  224. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -71
  225. package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
  226. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
  227. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -472
  228. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
  229. package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
  230. package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
  231. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3981
  232. package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
  233. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
  234. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
  235. package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
  236. package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
  237. package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
  238. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -152
  239. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -182
  240. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -374
  241. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -546
  242. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -31
  243. package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -528
  244. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -134
  245. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -333
  246. package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
  247. package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
  248. package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
  249. package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
  250. package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
  251. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
  252. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
  253. package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
  254. package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
  255. package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
  256. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
  257. package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
  258. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -90
  259. package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
  260. package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
  261. package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
  262. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
  263. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
  264. package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
  265. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
  266. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -996
  267. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -827
  268. package/crates/team-agent/src/lifecycle/tests.rs +0 -102
  269. package/crates/team-agent/src/lifecycle/types.rs +0 -861
  270. package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -370
  271. package/crates/team-agent/src/main.rs +0 -52
  272. package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
  273. package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
  274. package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
  275. package/crates/team-agent/src/mcp_server/mod.rs +0 -119
  276. package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
  277. package/crates/team-agent/src/mcp_server/readiness.rs +0 -546
  278. package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -369
  279. package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
  280. package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
  281. package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -168
  282. package/crates/team-agent/src/mcp_server/tests/send.rs +0 -388
  283. package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -343
  284. package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
  285. package/crates/team-agent/src/mcp_server/tests.rs +0 -43
  286. package/crates/team-agent/src/mcp_server/tools.rs +0 -1015
  287. package/crates/team-agent/src/mcp_server/types.rs +0 -396
  288. package/crates/team-agent/src/mcp_server/wire.rs +0 -867
  289. package/crates/team-agent/src/messaging/activity.rs +0 -461
  290. package/crates/team-agent/src/messaging/address.rs +0 -87
  291. package/crates/team-agent/src/messaging/delivery.rs +0 -3785
  292. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
  293. package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
  294. package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
  295. package/crates/team-agent/src/messaging/helpers.rs +0 -354
  296. package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
  297. package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
  298. package/crates/team-agent/src/messaging/mod.rs +0 -166
  299. package/crates/team-agent/src/messaging/persist.rs +0 -377
  300. package/crates/team-agent/src/messaging/presentation.rs +0 -417
  301. package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
  302. package/crates/team-agent/src/messaging/results.rs +0 -1415
  303. package/crates/team-agent/src/messaging/scheduler.rs +0 -217
  304. package/crates/team-agent/src/messaging/selftest.rs +0 -315
  305. package/crates/team-agent/src/messaging/send.rs +0 -981
  306. package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
  307. package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -551
  308. package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
  309. package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
  310. package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
  311. package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
  312. package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
  313. package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3655
  314. package/crates/team-agent/src/messaging/tests/spine.rs +0 -837
  315. package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
  316. package/crates/team-agent/src/messaging/trust.rs +0 -215
  317. package/crates/team-agent/src/messaging/types.rs +0 -471
  318. package/crates/team-agent/src/messaging/wait.rs +0 -366
  319. package/crates/team-agent/src/messaging/watchers.rs +0 -916
  320. package/crates/team-agent/src/model/enums.rs +0 -356
  321. package/crates/team-agent/src/model/errors.rs +0 -18
  322. package/crates/team-agent/src/model/ids.rs +0 -165
  323. package/crates/team-agent/src/model/mod.rs +0 -29
  324. package/crates/team-agent/src/model/name_similarity.rs +0 -252
  325. package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
  326. package/crates/team-agent/src/model/paths.rs +0 -257
  327. package/crates/team-agent/src/model/routing.rs +0 -387
  328. package/crates/team-agent/src/model/spec.rs +0 -1184
  329. package/crates/team-agent/src/model/task_graph.rs +0 -321
  330. package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
  331. package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
  332. package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
  333. package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
  334. package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
  335. package/crates/team-agent/src/model/yaml/tests.rs +0 -188
  336. package/crates/team-agent/src/model/yaml.rs +0 -802
  337. package/crates/team-agent/src/os_probe.rs +0 -280
  338. package/crates/team-agent/src/packaging/install.rs +0 -219
  339. package/crates/team-agent/src/packaging/migrate.rs +0 -38
  340. package/crates/team-agent/src/packaging/mod.rs +0 -91
  341. package/crates/team-agent/src/packaging/repair.rs +0 -33
  342. package/crates/team-agent/src/packaging/tests.rs +0 -822
  343. package/crates/team-agent/src/packaging/types.rs +0 -417
  344. package/crates/team-agent/src/platform/argv.rs +0 -331
  345. package/crates/team-agent/src/platform/errors.rs +0 -104
  346. package/crates/team-agent/src/platform/file_lock.rs +0 -279
  347. package/crates/team-agent/src/platform/mod.rs +0 -5
  348. package/crates/team-agent/src/platform/process.rs +0 -545
  349. package/crates/team-agent/src/provider/adapter.rs +0 -898
  350. package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
  351. package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
  352. package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
  353. package/crates/team-agent/src/provider/adapters/mod.rs +0 -28
  354. package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
  355. package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
  356. package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
  357. package/crates/team-agent/src/provider/argv_route.rs +0 -405
  358. package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
  359. package/crates/team-agent/src/provider/classify.rs +0 -773
  360. package/crates/team-agent/src/provider/command_helpers.rs +0 -45
  361. package/crates/team-agent/src/provider/faults.rs +0 -165
  362. package/crates/team-agent/src/provider/helpers.rs +0 -52
  363. package/crates/team-agent/src/provider/mod.rs +0 -78
  364. package/crates/team-agent/src/provider/model_catalog.rs +0 -722
  365. package/crates/team-agent/src/provider/session/capture.rs +0 -2631
  366. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -168
  367. package/crates/team-agent/src/provider/session/context_fork.rs +0 -264
  368. package/crates/team-agent/src/provider/session/mod.rs +0 -36
  369. package/crates/team-agent/src/provider/session/resume.rs +0 -269
  370. package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
  371. package/crates/team-agent/src/provider/session_scan/common.rs +0 -618
  372. package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
  373. package/crates/team-agent/src/provider/session_scan/pi.rs +0 -152
  374. package/crates/team-agent/src/provider/session_scan.rs +0 -61
  375. package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
  376. package/crates/team-agent/src/provider/submit_now.rs +0 -71
  377. package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
  378. package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
  379. package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
  380. package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
  381. package/crates/team-agent/src/provider/tests/adapter.rs +0 -354
  382. package/crates/team-agent/src/provider/tests/classify.rs +0 -201
  383. package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -26
  384. package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
  385. package/crates/team-agent/src/provider/tests/faults.rs +0 -200
  386. package/crates/team-agent/src/provider/tests/idle.rs +0 -140
  387. package/crates/team-agent/src/provider/tests/wire.rs +0 -213
  388. package/crates/team-agent/src/provider/tests.rs +0 -32
  389. package/crates/team-agent/src/provider/types.rs +0 -529
  390. package/crates/team-agent/src/provider/wire.rs +0 -406
  391. package/crates/team-agent/src/redaction.rs +0 -259
  392. package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
  393. package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
  394. package/crates/team-agent/src/state/identity.rs +0 -914
  395. package/crates/team-agent/src/state/identity_keys.rs +0 -132
  396. package/crates/team-agent/src/state/mod.rs +0 -74
  397. package/crates/team-agent/src/state/owner_gate.rs +0 -482
  398. package/crates/team-agent/src/state/ownership.rs +0 -563
  399. package/crates/team-agent/src/state/paths.rs +0 -395
  400. package/crates/team-agent/src/state/persist.rs +0 -3811
  401. package/crates/team-agent/src/state/projection.rs +0 -1508
  402. package/crates/team-agent/src/state/repository/intent.rs +0 -14
  403. package/crates/team-agent/src/state/repository/tests.rs +0 -184
  404. package/crates/team-agent/src/state/repository.rs +0 -866
  405. package/crates/team-agent/src/state/selector.rs +0 -160
  406. package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
  407. package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
  408. package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
  409. package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
  410. package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
  411. package/crates/team-agent/src/tmux_backend/tests.rs +0 -4254
  412. package/crates/team-agent/src/tmux_backend.rs +0 -4527
  413. package/crates/team-agent/src/topology.rs +0 -537
  414. package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
  415. package/crates/team-agent/src/transport/native_input.rs +0 -491
  416. package/crates/team-agent/src/transport/test_support.rs +0 -743
  417. package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
  418. package/crates/team-agent/src/transport/tests/mod.rs +0 -194
  419. package/crates/team-agent/src/transport/tests/wire.rs +0 -574
  420. package/crates/team-agent/src/transport.rs +0 -1655
  421. package/crates/team-agent/src/transport_factory.rs +0 -819
@@ -1,1053 +0,0 @@
1
- //! 0.5.40 RED contract: restart builds replacement workers before destroying
2
- //! the live worker session.
3
- //!
4
- //! Reference: `.team/artifacts/tmux-server-death-locate.md` §7 Slice 3.
5
-
6
- #![cfg(unix)]
7
- #![allow(clippy::expect_used, clippy::panic, clippy::unwrap_used)]
8
-
9
- #[path = "../../../tests/support/hermetic.rs"]
10
- mod hermetic_guard;
11
- #[allow(dead_code)]
12
- fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
13
-
14
- use std::collections::{BTreeMap, BTreeSet};
15
- use std::fs;
16
- use std::path::{Path, PathBuf};
17
- use std::process::Command;
18
- use std::sync::{Arc, Mutex};
19
-
20
- use serde_json::{json, Value};
21
- use serial_test::serial;
22
- use team_agent::coordinator::{MetadataSource, Pid, WorkspacePath};
23
- use team_agent::event_log::EventLog;
24
- use team_agent::lifecycle::{
25
- restart_with_transport, restart_with_transport_with_readiness_deadline, RestartReport,
26
- };
27
- use team_agent::message_store::MessageStore;
28
- use team_agent::model::paths::{runtime_dir, runtime_spec_path};
29
- use team_agent::state::persist::{load_runtime_state, save_runtime_state};
30
- use team_agent::transport::{
31
- AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
32
- InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, PaneLiveness, SessionName,
33
- SessionOwner, SetEnvOutcome, SpawnResult, SubmitVerification, Target, Transport, TransportError,
34
- TurnVerification, WindowName,
35
- };
36
-
37
- const TEAM: &str = "current";
38
- const TEAM_SESSION: &str = "team-current";
39
- const TMUX_ENDPOINT: &str = "/Volumes/nvme/tmp/ta-0540-build-before-destroy.sock";
40
-
41
- #[test]
42
- #[serial(env)]
43
- fn recording_restart_failure_does_not_kill_live_session_before_replacement_is_viable() {
44
- let case = RestartCase::new(
45
- "recording-no-teardown-first",
46
- worker_ids(3),
47
- ProviderShape::Fake,
48
- );
49
- let transport = BuildBeforeDestroyTransport::recording(worker_ids(3))
50
- .with_spawn_failure("w1", "injected replacement spawn failure");
51
-
52
- let report = restart_with_transport(&case.workspace, true, Some(TEAM), &transport)
53
- .expect("restart should return a typed report");
54
-
55
- assert_restart_did_not_succeed(&report);
56
- assert_no_original_session_kill(
57
- &transport.ops(),
58
- "R1: restart must not destroy the live worker session before a replacement cohort is minimally viable",
59
- );
60
- }
61
-
62
- #[test]
63
- #[serial(env)]
64
- fn real_tmux_restart_failure_keeps_original_session_windows_and_panes_injectable() {
65
- let case =
66
- RestartCase::new_unseeded("real-tmux-preserve-old", worker_ids(3), ProviderShape::Fake);
67
- let tmux = RealTmuxTeam::start(case.env.root(), worker_ids(3));
68
- case.seed_state_with_panes(ProviderShape::Fake, &tmux.panes_by_worker());
69
- let transport = BuildBeforeDestroyTransport::real_tmux(tmux.socket.clone(), worker_ids(3))
70
- .with_spawn_failure("w1", "injected replacement spawn failure");
71
-
72
- let result = restart_with_transport_with_readiness_deadline(
73
- &case.workspace,
74
- true,
75
- Some(TEAM),
76
- &transport,
77
- Some(1),
78
- );
79
- if let Ok(report) = result.as_ref() {
80
- assert_restart_did_not_succeed(report);
81
- }
82
- tmux.assert_original_windows_present(&["w1", "w2", "w3"]);
83
- tmux.assert_original_panes_injectable("TA0540_ORIGINAL_PANE_STILL_INJECTABLE");
84
- assert_no_original_session_kill(
85
- &transport.ops(),
86
- "R2: even with real tmux, a failed replacement spawn must leave the original session untouched",
87
- );
88
- assert!(
89
- result.is_ok(),
90
- "R2: failed replacement build should return a typed failed/refused report after preserving the original session, not an unstructured readiness error; result={result:?}"
91
- );
92
- }
93
-
94
- #[test]
95
- #[serial(env)]
96
- fn server_exited_during_replacement_spawn_does_not_cascade_session_disappeared_against_old_team() {
97
- let case = RestartCase::new(
98
- "case-b-no-second-cascade",
99
- worker_ids(2),
100
- ProviderShape::CopilotResumable,
101
- );
102
- let transport =
103
- BuildBeforeDestroyTransport::recording(worker_ids(2)).with_server_exit_after_first_spawn();
104
-
105
- let report = restart_with_transport(&case.workspace, false, Some(TEAM), &transport)
106
- .expect("restart should return a typed report");
107
-
108
- assert_restart_did_not_succeed(&report);
109
- let report_text = format!("{report:?}");
110
- let events = case.events_text();
111
- assert!(
112
- !report_text.contains("session_disappeared_after_spawn")
113
- && !events.contains("session_disappeared_after_spawn"),
114
- "R3: server_exited during replacement build should return failed/refused directly, not a second session_disappeared_after_spawn cascade; report={report_text} events={events}"
115
- );
116
- assert_no_original_session_kill(
117
- &transport.ops(),
118
- "R3: server_exited during replacement build must not first destroy the original session",
119
- );
120
- let state = case.read_state();
121
- assert_eq!(
122
- state.pointer("/agents/w1/status").and_then(Value::as_str),
123
- Some("running"),
124
- "R3: failed replacement build must leave old worker state authoritative; state={state}"
125
- );
126
- assert_eq!(
127
- state.pointer("/agents/w1/pane_id").and_then(Value::as_str),
128
- Some("%old-w1"),
129
- "R3: failed replacement build must not overwrite the old worker pane binding; state={state}"
130
- );
131
- }
132
-
133
- #[test]
134
- #[serial(env)]
135
- fn scoped_shutdown_after_restart_refreshes_owner_and_preserves_sibling() {
136
- let case = RestartCase::new("restart-shutdown-owner", worker_ids(2), ProviderShape::Fake);
137
- let transport = BuildBeforeDestroyTransport::recording(worker_ids(2));
138
- for pane in transport.state.lock().unwrap().panes.values_mut() {
139
- pane.current_path = Some(case.workspace.clone());
140
- pane.pane_pid = None;
141
- }
142
- let session = SessionName::new(TEAM_SESSION);
143
- let sibling_session = SessionName::new("team-sibling");
144
- let mut state = case.read_state();
145
- // Host and worker tmux servers may allocate the same pane ID. The host
146
- // receiver must not protect the replacement worker on this transport.
147
- state["leader_receiver"] = json!({
148
- "pane_id": "%new-1", "tmux_socket": "/tmp/s4-host-only.sock"
149
- });
150
- state["team_owner"] = json!({"pane_id": "%new-1"});
151
- state["teams"][TEAM]["leader_receiver"] = state["leader_receiver"].clone();
152
- state["teams"][TEAM]["team_owner"] = state["team_owner"].clone();
153
- state["teams"]["sibling"] = json!({
154
- "team_key": "sibling",
155
- "session_name": sibling_session.as_str(),
156
- "tmux_socket": TMUX_ENDPOINT,
157
- "agents": {
158
- "sibling-worker": {
159
- "provider": "fake", "status": "running", "pane_id": "%sibling",
160
- "spawned_at": "sibling-generation"
161
- }
162
- }
163
- });
164
- save_runtime_state(&case.workspace, &state).unwrap();
165
- let sibling_before = case.read_state()["teams"]["sibling"].clone();
166
- let mut sibling_pane = pane_info(
167
- sibling_session.clone(), WindowName::new("sibling-worker"), PaneId::new("%sibling"),
168
- );
169
- sibling_pane.current_path = Some(case.workspace.clone());
170
- sibling_pane.pane_pid = None;
171
- transport.state.lock().unwrap().panes.insert("%sibling".to_string(), sibling_pane.clone());
172
- transport.set_session_owner_with_generation(
173
- &session, &case.workspace, TEAM, "2026-07-14T00:00:00+00:00",
174
- ).unwrap();
175
- transport.set_session_owner_with_generation(
176
- &sibling_session, &case.workspace, "sibling", "sibling-generation",
177
- ).unwrap();
178
- let sibling_owner = transport.session_owner(&sibling_session).unwrap();
179
-
180
- let report = restart_with_transport(&case.workspace, true, Some(TEAM), &transport).unwrap();
181
- assert!(matches!(report, RestartReport::Restarted { .. }), "{report:?}");
182
- let state = case.read_state();
183
- let expected_generation = "2026-07-14T00:00:00+00:00";
184
- assert_ne!(state["teams"][TEAM]["agents"]["w1"]["spawned_at"], expected_generation);
185
- assert_eq!(state["generation"], expected_generation);
186
- assert_eq!(state["teams"][TEAM]["generation"], expected_generation);
187
- let owner = transport.session_owner(&session).unwrap().unwrap();
188
- assert_eq!(owner.workspace, case.workspace.canonicalize().unwrap().to_string_lossy());
189
- assert_eq!(owner.team, TEAM);
190
- assert_eq!(owner.generation, expected_generation);
191
- assert_no_original_session_kill(&transport.ops(), "restart retains the session");
192
-
193
- let out = team_agent::cli::lifecycle_port::shutdown_with_transport(
194
- &case.workspace, true, Some(TEAM), &transport,
195
- ).unwrap();
196
- assert_eq!(out["ok"], true, "{out}");
197
- assert_eq!(out["session_killed"], true, "{out}");
198
- assert_eq!(out["spared_sessions"], json!([]), "{out}");
199
- assert_eq!(out["coordinator_stop_reason"], "scoped_live_sibling_present", "{out}");
200
- assert!(!transport.has_session(&session).unwrap());
201
- assert!(transport.has_session(&sibling_session).unwrap());
202
- assert_eq!(transport.session_owner(&sibling_session).unwrap(), sibling_owner);
203
- assert_eq!(case.read_state()["teams"]["sibling"], sibling_before);
204
- assert_eq!(transport.state.lock().unwrap().panes.get("%sibling"), Some(&sibling_pane));
205
- }
206
-
207
- #[test]
208
- #[serial(env)]
209
- fn failed_replacement_preserves_original_session_owner() {
210
- let case = RestartCase::new("failed-restart-owner", worker_ids(1), ProviderShape::Fake);
211
- let transport = BuildBeforeDestroyTransport::recording(worker_ids(1))
212
- .with_spawn_failure("w1", "injected replacement spawn failure");
213
- let session = SessionName::new(TEAM_SESSION);
214
- transport.set_session_owner_with_generation(
215
- &session, &case.workspace, TEAM, "2026-07-14T00:00:00+00:00",
216
- ).unwrap();
217
- let owner_before = transport.session_owner(&session).unwrap();
218
- let generation_before = case.read_state().get("generation").cloned();
219
- let report = restart_with_transport(&case.workspace, true, Some(TEAM), &transport).unwrap();
220
- assert_restart_did_not_succeed(&report);
221
- assert_eq!(case.read_state().get("generation").cloned(), generation_before);
222
- assert_eq!(transport.session_owner(&session).unwrap(), owner_before);
223
- assert_eq!(transport.ops().iter().filter(|op| op.starts_with("set_session_owner:")).count(), 1);
224
- }
225
-
226
- struct RestartCase {
227
- env: hermetic_guard::HermeticTestEnv,
228
- workspace: PathBuf,
229
- workers: Vec<String>,
230
- }
231
-
232
- impl RestartCase {
233
- fn new(tag: &str, workers: Vec<String>, provider: ProviderShape) -> Self {
234
- let case = Self::new_unseeded(tag, workers, provider);
235
- let panes = case
236
- .workers
237
- .iter()
238
- .map(|worker| (worker.clone(), format!("%old-{worker}")))
239
- .collect::<BTreeMap<_, _>>();
240
- case.seed_state_with_panes(provider, &panes);
241
- case
242
- }
243
-
244
- fn new_unseeded(tag: &str, workers: Vec<String>, provider: ProviderShape) -> Self {
245
- let env = hermetic_guard::HermeticTestEnv::enter(tag);
246
- env.scrub_tmux();
247
- env.assert_no_real_tmux();
248
- let workspace = env.workspace(tag);
249
- write_team_docs(&workspace, &workers, provider);
250
- write_runtime_spec(&workspace, &workspace);
251
- Self {
252
- env,
253
- workspace,
254
- workers,
255
- }
256
- }
257
-
258
- fn seed_state_with_panes(&self, provider: ProviderShape, panes: &BTreeMap<String, String>) {
259
- seed_restart_state(&self.workspace, &self.workers, provider, panes);
260
- if matches!(provider, ProviderShape::CopilotResumable) {
261
- seed_copilot_session_store(self.env.home(), &self.workers);
262
- }
263
- seed_healthy_coordinator(&self.workspace);
264
- }
265
-
266
- fn read_state(&self) -> Value {
267
- load_runtime_state(&self.workspace).expect("load runtime state")
268
- }
269
-
270
- fn events_text(&self) -> String {
271
- EventLog::new(&self.workspace)
272
- .tail(0)
273
- .expect("read events")
274
- .into_iter()
275
- .map(|event| event.to_string())
276
- .collect::<Vec<_>>()
277
- .join("\n")
278
- }
279
- }
280
-
281
- #[derive(Clone, Copy)]
282
- enum ProviderShape {
283
- Fake,
284
- CopilotResumable,
285
- }
286
-
287
- impl ProviderShape {
288
- fn provider(self) -> &'static str {
289
- match self {
290
- Self::Fake => "fake",
291
- Self::CopilotResumable => "copilot",
292
- }
293
- }
294
-
295
- fn model(self) -> &'static str {
296
- match self {
297
- Self::Fake => "fake",
298
- Self::CopilotResumable => "gpt-5",
299
- }
300
- }
301
- }
302
-
303
- fn write_team_docs(team_dir: &Path, workers: &[String], provider: ProviderShape) {
304
- fs::create_dir_all(team_dir.join("agents")).expect("create agents dir");
305
- fs::write(
306
- team_dir.join("TEAM.md"),
307
- format!(
308
- "---\nname: {TEAM}\nobjective: Restart build-before-destroy contract.\nprovider: {}\n---\n\nTeam.\n",
309
- provider.provider()
310
- ),
311
- )
312
- .expect("write TEAM.md");
313
- for worker in workers {
314
- fs::write(
315
- team_dir.join("agents").join(format!("{worker}.md")),
316
- format!(
317
- "---\nname: {worker}\nrole: Worker {worker}\nprovider: {}\nmodel: {}\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\n{worker}.\n",
318
- provider.provider(),
319
- provider.model()
320
- ),
321
- )
322
- .expect("write role doc");
323
- }
324
- }
325
-
326
- fn write_runtime_spec(workspace: &Path, team_dir: &Path) {
327
- let spec = team_agent::compiler::compile_team(team_dir).expect("compile team");
328
- let spec_text = team_agent::model::yaml::dumps(&spec);
329
- fs::write(team_dir.join("team.spec.yaml"), &spec_text).expect("write legacy spec");
330
- let runtime_spec = runtime_spec_path(workspace, TEAM);
331
- fs::create_dir_all(runtime_spec.parent().expect("runtime spec parent"))
332
- .expect("create runtime spec dir");
333
- fs::write(runtime_spec, spec_text).expect("write runtime spec");
334
- }
335
-
336
- fn seed_restart_state(
337
- workspace: &Path,
338
- workers: &[String],
339
- provider: ProviderShape,
340
- panes: &BTreeMap<String, String>,
341
- ) {
342
- let agents = workers
343
- .iter()
344
- .map(|worker| {
345
- let mut row = json!({
346
- "status": "running",
347
- "provider": provider.provider(),
348
- "agent_id": worker,
349
- "role": format!("Worker {worker}"),
350
- "model": provider.model(),
351
- "auth_mode": "subscription",
352
- "tools": ["mcp_team"],
353
- "window": worker,
354
- "pane_id": panes.get(worker).cloned().unwrap_or_else(|| format!("%old-{worker}")),
355
- "owner_team_id": TEAM,
356
- "spawn_epoch": 0,
357
- "spawn_cwd": workspace.to_string_lossy(),
358
- "spawned_at": "2026-07-14T00:00:00+00:00",
359
- });
360
- if matches!(provider, ProviderShape::CopilotResumable) {
361
- let rollout = workspace.join(format!("{worker}.jsonl"));
362
- fs::write(&rollout, "{}\n").expect("write rollout fixture");
363
- let row_obj = row.as_object_mut().expect("agent row object");
364
- row_obj.insert("session_id".to_string(), json!(format!("session-{worker}")));
365
- row_obj.insert(
366
- "rollout_path".to_string(),
367
- json!(rollout.to_string_lossy().to_string()),
368
- );
369
- row_obj.insert(
370
- "first_send_at".to_string(),
371
- json!("2026-07-14T00:01:00+00:00"),
372
- );
373
- }
374
- (worker.clone(), row)
375
- })
376
- .collect::<serde_json::Map<String, Value>>();
377
- let spec_path = runtime_spec_path(workspace, TEAM);
378
- save_runtime_state(
379
- workspace,
380
- &json!({
381
- "active_team_key": TEAM,
382
- "team_key": TEAM,
383
- "workspace": workspace.to_string_lossy(),
384
- "team_dir": workspace.to_string_lossy(),
385
- "spec_path": spec_path.to_string_lossy(),
386
- "session_name": TEAM_SESSION,
387
- "tmux_endpoint": TMUX_ENDPOINT,
388
- "tmux_socket": TMUX_ENDPOINT,
389
- "agents": Value::Object(agents.clone()),
390
- "teams": {
391
- TEAM: {
392
- "team_key": TEAM,
393
- "workspace": workspace.to_string_lossy(),
394
- "team_dir": workspace.to_string_lossy(),
395
- "spec_path": spec_path.to_string_lossy(),
396
- "session_name": TEAM_SESSION,
397
- "tmux_endpoint": TMUX_ENDPOINT,
398
- "tmux_socket": TMUX_ENDPOINT,
399
- "agents": Value::Object(agents),
400
- }
401
- }
402
- }),
403
- )
404
- .expect("seed runtime state");
405
- }
406
-
407
- /// Copilot resume backing is the `sessions` row in the hermetic
408
- /// `$HOME/.copilot/session-store.db`.
409
- fn seed_copilot_session_store(home: &Path, workers: &[String]) {
410
- let db = home.join(".copilot").join("session-store.db");
411
- fs::create_dir_all(db.parent().expect("copilot store parent")).expect("create copilot dir");
412
- let conn = rusqlite::Connection::open(db).expect("open copilot session store");
413
- conn.execute_batch(
414
- "create table if not exists sessions (id text primary key, cwd text, created_at text);",
415
- )
416
- .expect("create copilot sessions table");
417
- for worker in workers {
418
- conn.execute(
419
- "insert or replace into sessions(id, cwd, created_at) values (?1, ?2, '2026-07-14T00:00:00Z')",
420
- rusqlite::params![format!("session-{worker}"), home.to_string_lossy()],
421
- )
422
- .expect("seed copilot session row");
423
- }
424
- }
425
-
426
- fn seed_healthy_coordinator(workspace: &Path) {
427
- fs::create_dir_all(runtime_dir(workspace)).expect("create runtime dir");
428
- let _store = MessageStore::open(workspace).expect("create message store schema");
429
- let wp = WorkspacePath::new(workspace.to_path_buf());
430
- let pid = Pid::new(std::process::id());
431
- team_agent::coordinator::write_coordinator_metadata(&wp, pid, MetadataSource::Boot)
432
- .expect("write coordinator metadata");
433
- fs::write(
434
- team_agent::coordinator::coordinator_pid_path(&wp),
435
- pid.to_string(),
436
- )
437
- .expect("write coordinator pid");
438
- }
439
-
440
- fn worker_ids(count: usize) -> Vec<String> {
441
- (1..=count).map(|index| format!("w{index}")).collect()
442
- }
443
-
444
- fn assert_restart_did_not_succeed(report: &RestartReport) {
445
- assert!(
446
- !matches!(report, RestartReport::Restarted { .. }),
447
- "fixture injects replacement failure; restart must not report success: {report:?}"
448
- );
449
- }
450
-
451
- fn assert_no_original_session_kill(ops: &[String], context: &str) {
452
- let forbidden = format!("kill_session:{TEAM_SESSION}");
453
- assert!(
454
- !ops.iter().any(|op| op == &forbidden),
455
- "{context}; ops={ops:?}"
456
- );
457
- }
458
-
459
- #[derive(Clone)]
460
- struct BuildBeforeDestroyTransport {
461
- state: Arc<Mutex<TransportState>>,
462
- real_socket: Option<PathBuf>,
463
- fail_agent: Option<String>,
464
- server_exit_after_first_spawn: bool,
465
- }
466
-
467
- #[derive(Default)]
468
- struct TransportState {
469
- session_present: bool,
470
- ops: Vec<String>,
471
- panes: BTreeMap<String, PaneInfo>,
472
- owners: BTreeMap<String, SessionOwner>,
473
- next_pane: usize,
474
- spawns: usize,
475
- }
476
-
477
- impl BuildBeforeDestroyTransport {
478
- fn recording(workers: Vec<String>) -> Self {
479
- Self {
480
- state: Arc::new(Mutex::new(TransportState {
481
- session_present: true,
482
- panes: pane_infos_from_ids(
483
- workers
484
- .into_iter()
485
- .map(|worker| (worker.clone(), format!("%old-{worker}")))
486
- .collect(),
487
- ),
488
- next_pane: 1,
489
- ..TransportState::default()
490
- })),
491
- real_socket: None,
492
- fail_agent: None,
493
- server_exit_after_first_spawn: false,
494
- }
495
- }
496
-
497
- fn real_tmux(socket: PathBuf, workers: Vec<String>) -> Self {
498
- Self {
499
- state: Arc::new(Mutex::new(TransportState {
500
- session_present: true,
501
- panes: pane_infos_from_ids(
502
- workers
503
- .into_iter()
504
- .map(|worker| (worker.clone(), format!("%old-{worker}")))
505
- .collect(),
506
- ),
507
- next_pane: 1,
508
- ..TransportState::default()
509
- })),
510
- real_socket: Some(socket),
511
- fail_agent: None,
512
- server_exit_after_first_spawn: false,
513
- }
514
- }
515
-
516
- fn with_spawn_failure(mut self, agent: &str, message: &str) -> Self {
517
- self.fail_agent = Some(format!("{agent}:{message}"));
518
- self
519
- }
520
-
521
- fn with_server_exit_after_first_spawn(mut self) -> Self {
522
- self.server_exit_after_first_spawn = true;
523
- self
524
- }
525
-
526
- fn ops(&self) -> Vec<String> {
527
- self.state.lock().unwrap().ops.clone()
528
- }
529
-
530
- fn spawn(
531
- &self,
532
- kind: &'static str,
533
- session: &SessionName,
534
- window: &WindowName,
535
- cwd: &Path,
536
- ) -> Result<SpawnResult, TransportError> {
537
- let mut state = self.state.lock().unwrap();
538
- state
539
- .ops
540
- .push(format!("{kind}:{}:{}", session.as_str(), window.as_str()));
541
- state.spawns += 1;
542
- if let Some(failure) = self.fail_agent.as_deref() {
543
- if failure.starts_with(&format!("{}:", window.as_str())) {
544
- return Err(TransportError::Subprocess {
545
- argv: vec!["tmux".to_string(), kind.to_string()],
546
- code: Some(1),
547
- stderr: failure.to_string(),
548
- });
549
- }
550
- }
551
- let pane_id = PaneId::new(format!("%new-{}", state.next_pane));
552
- state.next_pane += 1;
553
- state.session_present = true;
554
- let mut pane = pane_info(session.clone(), window.clone(), pane_id.clone());
555
- pane.current_path = Some(cwd.to_path_buf());
556
- pane.pane_pid = None;
557
- state.panes.insert(pane_id.as_str().to_string(), pane);
558
- if self.server_exit_after_first_spawn && state.spawns == 1 {
559
- state.session_present = false;
560
- }
561
- Ok(SpawnResult {
562
- pane_id,
563
- session: session.clone(),
564
- window: window.clone(),
565
- child_pid: None,
566
- })
567
- }
568
-
569
- fn real_tmux_has_session(&self, session: &SessionName) -> Result<bool, TransportError> {
570
- let Some(socket) = self.real_socket.as_ref() else {
571
- let state = self.state.lock().unwrap();
572
- return Ok(if session.as_str() == TEAM_SESSION {
573
- state.session_present
574
- } else {
575
- state.panes.values().any(|pane| pane.session == *session)
576
- });
577
- };
578
- Ok(Command::new("tmux")
579
- .args([
580
- "-S",
581
- socket.to_str().unwrap(),
582
- "has-session",
583
- "-t",
584
- session.as_str(),
585
- ])
586
- .output()
587
- .map_err(|error| TransportError::MuxUnavailable {
588
- backend: BackendKind::Tmux,
589
- detail: error.to_string(),
590
- })?
591
- .status
592
- .success())
593
- }
594
-
595
- fn real_tmux_list_panes(&self) -> Result<Vec<PaneInfo>, TransportError> {
596
- let Some(socket) = self.real_socket.as_ref() else {
597
- return Ok(self.state.lock().unwrap().panes.values().cloned().collect());
598
- };
599
- let output = Command::new("tmux")
600
- .args([
601
- "-S",
602
- socket.to_str().unwrap(),
603
- "list-panes",
604
- "-a",
605
- "-F",
606
- "#{session_name}\t#{window_name}\t#{pane_id}\t#{pane_pid}",
607
- ])
608
- .output()
609
- .map_err(|error| TransportError::MuxUnavailable {
610
- backend: BackendKind::Tmux,
611
- detail: error.to_string(),
612
- })?;
613
- if !output.status.success() {
614
- return Ok(Vec::new());
615
- }
616
- let text = String::from_utf8_lossy(&output.stdout);
617
- Ok(text
618
- .lines()
619
- .filter_map(|line| {
620
- let mut fields = line.split('\t');
621
- let session = fields.next()?;
622
- let window = fields.next()?;
623
- let pane = fields.next()?;
624
- let pid = fields.next().and_then(|raw| raw.parse::<u32>().ok());
625
- Some(PaneInfo {
626
- pane_id: PaneId::new(pane),
627
- session: SessionName::new(session),
628
- window_index: None,
629
- window_name: Some(WindowName::new(window)),
630
- pane_index: None,
631
- tty: None,
632
- current_command: None,
633
- current_path: None,
634
- active: true,
635
- pane_pid: pid,
636
- leader_env: BTreeMap::new(),
637
- })
638
- })
639
- .collect())
640
- }
641
- }
642
-
643
- impl Transport for BuildBeforeDestroyTransport {
644
- fn kind(&self) -> BackendKind {
645
- BackendKind::Tmux
646
- }
647
-
648
- fn tmux_endpoint(&self) -> Option<String> {
649
- self.real_socket
650
- .as_ref()
651
- .map(|socket| socket.to_string_lossy().to_string())
652
- .or_else(|| Some(TMUX_ENDPOINT.to_string()))
653
- }
654
-
655
- fn spawn_first(
656
- &self,
657
- session: &SessionName,
658
- window: &WindowName,
659
- _argv: &[String],
660
- cwd: &Path,
661
- _env: &BTreeMap<String, String>,
662
- ) -> Result<SpawnResult, TransportError> {
663
- self.spawn("spawn_first", session, window, cwd)
664
- }
665
-
666
- fn spawn_into(
667
- &self,
668
- session: &SessionName,
669
- window: &WindowName,
670
- _argv: &[String],
671
- cwd: &Path,
672
- _env: &BTreeMap<String, String>,
673
- ) -> Result<SpawnResult, TransportError> {
674
- self.spawn("spawn_into", session, window, cwd)
675
- }
676
-
677
- fn inject(
678
- &self,
679
- _target: &Target,
680
- _payload: &InjectPayload,
681
- _submit: Key,
682
- _bracketed: bool,
683
- ) -> Result<InjectReport, TransportError> {
684
- Ok(inject_report())
685
- }
686
-
687
- fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> {
688
- Ok(())
689
- }
690
-
691
- fn capture(
692
- &self,
693
- _target: &Target,
694
- range: CaptureRange,
695
- ) -> Result<CapturedText, TransportError> {
696
- Ok(CapturedText {
697
- text: String::new(),
698
- range,
699
- })
700
- }
701
-
702
- fn query(&self, _target: &Target, field: PaneField) -> Result<Option<String>, TransportError> {
703
- Ok(match field {
704
- PaneField::PaneId => Some("%new-1".to_string()),
705
- PaneField::SessionName => Some(TEAM_SESSION.to_string()),
706
- _ => None,
707
- })
708
- }
709
-
710
- fn liveness(&self, pane: &PaneId) -> Result<PaneLiveness, TransportError> {
711
- Ok(
712
- if self
713
- .real_tmux_list_panes()?
714
- .iter()
715
- .any(|info| info.pane_id.as_str() == pane.as_str())
716
- || self.state.lock().unwrap().panes.contains_key(pane.as_str())
717
- {
718
- PaneLiveness::Live
719
- } else {
720
- PaneLiveness::Dead
721
- },
722
- )
723
- }
724
-
725
- fn has_pane(&self, pane: &PaneId) -> Result<Option<bool>, TransportError> {
726
- Ok(Some(
727
- self.real_tmux_list_panes()?
728
- .iter()
729
- .any(|info| info.pane_id.as_str() == pane.as_str())
730
- || self.state.lock().unwrap().panes.contains_key(pane.as_str()),
731
- ))
732
- }
733
-
734
- fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
735
- self.real_tmux_list_panes()
736
- }
737
-
738
- fn has_session(&self, session: &SessionName) -> Result<bool, TransportError> {
739
- let live = self.real_tmux_has_session(session)?;
740
- self.state
741
- .lock()
742
- .unwrap()
743
- .ops
744
- .push(format!("has_session:{}={live}", session.as_str()));
745
- Ok(live)
746
- }
747
-
748
- fn list_windows(&self, session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
749
- if self.real_socket.is_some() {
750
- let mut windows = BTreeSet::new();
751
- for pane in self.real_tmux_list_panes()? {
752
- if pane.session.as_str() == session.as_str() {
753
- if let Some(window) = pane.window_name {
754
- windows.insert(window);
755
- }
756
- }
757
- }
758
- return Ok(windows.into_iter().collect());
759
- }
760
- let state = self.state.lock().unwrap();
761
- if !state.session_present {
762
- return Ok(Vec::new());
763
- }
764
- let mut windows = BTreeSet::new();
765
- for pane in state.panes.values() {
766
- if let Some(window) = pane.window_name.as_ref() {
767
- windows.insert(window.clone());
768
- }
769
- }
770
- Ok(windows.into_iter().collect())
771
- }
772
-
773
- fn set_session_owner_with_generation(
774
- &self,
775
- session: &SessionName,
776
- workspace: &Path,
777
- team: &str,
778
- generation: &str,
779
- ) -> Result<(), TransportError> {
780
- let mut state = self.state.lock().unwrap();
781
- state.ops.push(format!("set_session_owner:{}", session.as_str()));
782
- state.owners.insert(session.as_str().to_string(), SessionOwner {
783
- workspace: workspace.canonicalize().unwrap().to_string_lossy().into_owned(),
784
- team: team.to_string(),
785
- generation: generation.to_string(),
786
- });
787
- Ok(())
788
- }
789
-
790
- fn session_owner(&self, session: &SessionName) -> Result<Option<SessionOwner>, TransportError> {
791
- Ok(self.state.lock().unwrap().owners.get(session.as_str()).cloned())
792
- }
793
-
794
- fn set_session_env(
795
- &self,
796
- _session: &SessionName,
797
- _key: &str,
798
- _value: &str,
799
- ) -> Result<SetEnvOutcome, TransportError> {
800
- Ok(SetEnvOutcome::Applied)
801
- }
802
-
803
- fn kill_session(&self, session: &SessionName) -> Result<(), TransportError> {
804
- self.state
805
- .lock()
806
- .unwrap()
807
- .ops
808
- .push(format!("kill_session:{}", session.as_str()));
809
- if session.as_str() == TEAM_SESSION {
810
- self.state.lock().unwrap().session_present = false;
811
- self.state.lock().unwrap().panes.retain(|_, pane| pane.session != *session);
812
- if let Some(socket) = self.real_socket.as_ref() {
813
- let status = Command::new("tmux")
814
- .args([
815
- "-S",
816
- socket.to_str().unwrap(),
817
- "kill-session",
818
- "-t",
819
- session.as_str(),
820
- ])
821
- .status()
822
- .map_err(|error| TransportError::MuxUnavailable {
823
- backend: BackendKind::Tmux,
824
- detail: error.to_string(),
825
- })?;
826
- if !status.success() {
827
- return Err(TransportError::Subprocess {
828
- argv: vec![
829
- "tmux".to_string(),
830
- "-S".to_string(),
831
- socket.to_string_lossy().to_string(),
832
- "kill-session".to_string(),
833
- "-t".to_string(),
834
- session.as_str().to_string(),
835
- ],
836
- code: status.code(),
837
- stderr: "kill-session failed".to_string(),
838
- });
839
- }
840
- }
841
- }
842
- Ok(())
843
- }
844
-
845
- fn kill_window(&self, target: &Target) -> Result<(), TransportError> {
846
- if let Target::Pane(pane) = target {
847
- self.state.lock().unwrap().panes.remove(pane.as_str());
848
- }
849
- Ok(())
850
- }
851
-
852
- fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> {
853
- Ok(AttachOutcome::Attached)
854
- }
855
- }
856
-
857
- fn pane_infos_from_ids(ids: BTreeMap<String, String>) -> BTreeMap<String, PaneInfo> {
858
- ids.into_iter()
859
- .map(|(worker, pane)| {
860
- let pane_id = PaneId::new(pane);
861
- (
862
- pane_id.as_str().to_string(),
863
- pane_info(
864
- SessionName::new(TEAM_SESSION),
865
- WindowName::new(worker),
866
- pane_id,
867
- ),
868
- )
869
- })
870
- .collect()
871
- }
872
-
873
- fn pane_info(session: SessionName, window: WindowName, pane_id: PaneId) -> PaneInfo {
874
- PaneInfo {
875
- pane_id,
876
- session,
877
- window_index: None,
878
- window_name: Some(window),
879
- pane_index: None,
880
- tty: None,
881
- current_command: Some("team-agent-worker".to_string()),
882
- current_path: None,
883
- active: true,
884
- pane_pid: Some(10_000),
885
- leader_env: BTreeMap::new(),
886
- }
887
- }
888
-
889
- fn inject_report() -> InjectReport {
890
- InjectReport {
891
- stage_reached: InjectStage::Submit,
892
- inject_verification: InjectVerification::NoToken,
893
- submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck,
894
- turn_verification: TurnVerification::NotRequired,
895
- attempts: 1,
896
- submit_diagnostics: None,
897
- }
898
- }
899
-
900
- struct RealTmuxTeam {
901
- socket: PathBuf,
902
- panes: BTreeMap<String, String>,
903
- }
904
-
905
- impl RealTmuxTeam {
906
- fn start(root: &Path, workers: Vec<String>) -> Self {
907
- // 0.5.43 debt-sweep (§4.2): use the short_tmux_socket helper
908
- // so tests stay green when TMPDIR is macOS default
909
- // /var/folders/... > 104 bytes. `root` is kept as the parameter
910
- // shape but is intentionally unused now — the socket lives at
911
- // /private/tmp/ta43-*.sock and its Drop cleans it up.
912
- let _ = root;
913
- let socket = hermetic_guard::short_tmux_socket("0540-real-tmux");
914
- let _ = Command::new("tmux")
915
- .args(["-S", socket.to_str().unwrap(), "kill-server"])
916
- .output();
917
- let mut iter = workers.into_iter();
918
- let first = iter.next().expect("at least one worker");
919
- run_tmux(
920
- &socket,
921
- &[
922
- "new-session",
923
- "-d",
924
- "-s",
925
- TEAM_SESSION,
926
- "-n",
927
- &first,
928
- "while :; do sleep 60; done",
929
- ],
930
- );
931
- for worker in iter {
932
- run_tmux(
933
- &socket,
934
- &[
935
- "new-window",
936
- "-t",
937
- TEAM_SESSION,
938
- "-n",
939
- &worker,
940
- "while :; do sleep 60; done",
941
- ],
942
- );
943
- }
944
- let panes = list_tmux_panes_by_worker(&socket);
945
- Self { socket, panes }
946
- }
947
-
948
- fn panes_by_worker(&self) -> BTreeMap<String, String> {
949
- self.panes.clone()
950
- }
951
-
952
- fn assert_original_windows_present(&self, expected: &[&str]) {
953
- let output = Command::new("tmux")
954
- .args([
955
- "-S",
956
- self.socket.to_str().unwrap(),
957
- "list-windows",
958
- "-t",
959
- TEAM_SESSION,
960
- "-F",
961
- "#{window_name}",
962
- ])
963
- .output()
964
- .expect("list real tmux windows");
965
- assert!(
966
- output.status.success(),
967
- "original tmux session must still exist after failed restart; stderr={}",
968
- String::from_utf8_lossy(&output.stderr)
969
- );
970
- let actual = String::from_utf8_lossy(&output.stdout)
971
- .lines()
972
- .map(str::to_string)
973
- .collect::<BTreeSet<_>>();
974
- for window in expected {
975
- assert!(
976
- actual.contains(*window),
977
- "original tmux window `{window}` missing after failed restart; actual={actual:?}"
978
- );
979
- }
980
- }
981
-
982
- fn assert_original_panes_injectable(&self, token: &str) {
983
- for (worker, pane) in &self.panes {
984
- let status = Command::new("tmux")
985
- .args([
986
- "-S",
987
- self.socket.to_str().unwrap(),
988
- "send-keys",
989
- "-t",
990
- pane,
991
- &format!("printf {token}_{worker}"),
992
- "Enter",
993
- ])
994
- .status()
995
- .expect("send keys to original pane");
996
- assert!(
997
- status.success(),
998
- "original pane {pane} for {worker} must remain addressable/injectable"
999
- );
1000
- }
1001
- }
1002
- }
1003
-
1004
- impl Drop for RealTmuxTeam {
1005
- fn drop(&mut self) {
1006
- let _ = Command::new("tmux")
1007
- .args(["-S", self.socket.to_str().unwrap(), "kill-server"])
1008
- .output();
1009
- let _ = fs::remove_file(&self.socket);
1010
- }
1011
- }
1012
-
1013
- fn run_tmux(socket: &Path, args: &[&str]) {
1014
- let output = Command::new("tmux")
1015
- .arg("-S")
1016
- .arg(socket)
1017
- .args(args)
1018
- .output()
1019
- .expect("run tmux");
1020
- assert!(
1021
- output.status.success(),
1022
- "tmux {:?} failed: stdout={} stderr={}",
1023
- args,
1024
- String::from_utf8_lossy(&output.stdout),
1025
- String::from_utf8_lossy(&output.stderr)
1026
- );
1027
- }
1028
-
1029
- fn list_tmux_panes_by_worker(socket: &Path) -> BTreeMap<String, String> {
1030
- let output = Command::new("tmux")
1031
- .args([
1032
- "-S",
1033
- socket.to_str().unwrap(),
1034
- "list-panes",
1035
- "-a",
1036
- "-F",
1037
- "#{window_name}\t#{pane_id}",
1038
- ])
1039
- .output()
1040
- .expect("list tmux panes");
1041
- assert!(
1042
- output.status.success(),
1043
- "list-panes failed: stderr={}",
1044
- String::from_utf8_lossy(&output.stderr)
1045
- );
1046
- String::from_utf8_lossy(&output.stdout)
1047
- .lines()
1048
- .filter_map(|line| {
1049
- let mut fields = line.split('\t');
1050
- Some((fields.next()?.to_string(), fields.next()?.to_string()))
1051
- })
1052
- .collect()
1053
- }