@team-agent/installer 0.5.128 → 0.6.1

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 (436) hide show
  1. package/README.md +4 -4
  2. package/README.zh.md +1 -1
  3. package/package.json +4 -8
  4. package/skills/team-agent/SKILL.md +37 -20
  5. package/skills/team-agent/command-coverage.json +169 -183
  6. package/skills/team-agent/docs/reference/team-agent-operator.md +64 -30
  7. package/skills/team-agent/references/recovery-runbook.md +1 -1
  8. package/skills/team-agent/references/team-agent-operator.md +64 -30
  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 -1288
  15. package/crates/team-agent/src/cli/arguments.rs +0 -405
  16. package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
  17. package/crates/team-agent/src/cli/diagnose.rs +0 -1721
  18. package/crates/team-agent/src/cli/emit.rs +0 -2930
  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 -1216
  22. package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -912
  23. package/crates/team-agent/src/cli/intent/tests.rs +0 -689
  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 -6545
  29. package/crates/team-agent/src/cli/models.rs +0 -1206
  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/schedule.rs +0 -175
  34. package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
  35. package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
  36. package/crates/team-agent/src/cli/send/persist.rs +0 -156
  37. package/crates/team-agent/src/cli/send/presentation.rs +0 -370
  38. package/crates/team-agent/src/cli/send/resolve.rs +0 -573
  39. package/crates/team-agent/src/cli/send.rs +0 -199
  40. package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
  41. package/crates/team-agent/src/cli/spec.rs +0 -165
  42. package/crates/team-agent/src/cli/status.rs +0 -280
  43. package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
  44. package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
  45. package/crates/team-agent/src/cli/status_port/brief.rs +0 -1981
  46. package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
  47. package/crates/team-agent/src/cli/status_port/format.rs +0 -146
  48. package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
  49. package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
  50. package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
  51. package/crates/team-agent/src/cli/status_port/store.rs +0 -416
  52. package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
  53. package/crates/team-agent/src/cli/status_port.rs +0 -92
  54. package/crates/team-agent/src/cli/tests/base.rs +0 -885
  55. package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
  56. package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
  57. package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -322
  58. package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
  59. package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
  60. package/crates/team-agent/src/cli/tests/mod.rs +0 -137
  61. package/crates/team-agent/src/cli/tests/named_address.rs +0 -761
  62. package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
  63. package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -484
  64. package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
  65. package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
  66. package/crates/team-agent/src/cli/tests/status_send.rs +0 -888
  67. package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
  68. package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
  69. package/crates/team-agent/src/cli/triage.rs +0 -234
  70. package/crates/team-agent/src/cli/types.rs +0 -591
  71. package/crates/team-agent/src/codex_app_server.rs +0 -546
  72. package/crates/team-agent/src/communication_mode/mod.rs +0 -56
  73. package/crates/team-agent/src/compiler/tests.rs +0 -827
  74. package/crates/team-agent/src/compiler.rs +0 -890
  75. package/crates/team-agent/src/conpty/backend.rs +0 -829
  76. package/crates/team-agent/src/conpty/mod.rs +0 -33
  77. package/crates/team-agent/src/contract_runtime/backend.rs +0 -1744
  78. package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
  79. package/crates/team-agent/src/contract_runtime/config.rs +0 -364
  80. package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -76
  81. package/crates/team-agent/src/contract_runtime/discovery.rs +0 -449
  82. package/crates/team-agent/src/contract_runtime/fork.rs +0 -361
  83. package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
  84. package/crates/team-agent/src/contract_runtime/framework.rs +0 -367
  85. package/crates/team-agent/src/contract_runtime/mcp.rs +0 -394
  86. package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
  87. package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
  88. package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
  89. package/crates/team-agent/src/contract_runtime/registry.rs +0 -553
  90. package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
  91. package/crates/team-agent/src/coordinator/backoff.rs +0 -741
  92. package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
  93. package/crates/team-agent/src/coordinator/health.rs +0 -1185
  94. package/crates/team-agent/src/coordinator/mod.rs +0 -119
  95. package/crates/team-agent/src/coordinator/orphan.rs +0 -110
  96. package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
  97. package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
  98. package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
  99. package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
  100. package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
  101. package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
  102. package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
  103. package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
  104. package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
  105. package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
  106. package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
  107. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -300
  108. package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
  109. package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
  110. package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
  111. package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -503
  112. package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
  113. package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
  114. package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
  115. package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
  116. package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
  117. package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
  118. package/crates/team-agent/src/coordinator/tick.rs +0 -3024
  119. package/crates/team-agent/src/coordinator/types.rs +0 -540
  120. package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
  121. package/crates/team-agent/src/db/message_store.rs +0 -1527
  122. package/crates/team-agent/src/db/migration.rs +0 -984
  123. package/crates/team-agent/src/db/mod.rs +0 -26
  124. package/crates/team-agent/src/db/schema.rs +0 -663
  125. package/crates/team-agent/src/diagnose/comms.rs +0 -242
  126. package/crates/team-agent/src/diagnose/mod.rs +0 -44
  127. package/crates/team-agent/src/diagnose/orphans.rs +0 -889
  128. package/crates/team-agent/src/direct_delivery.rs +0 -368
  129. package/crates/team-agent/src/event_log.rs +0 -502
  130. package/crates/team-agent/src/fake_worker.rs +0 -303
  131. package/crates/team-agent/src/inbox_store.rs +0 -169
  132. package/crates/team-agent/src/kill_audit.rs +0 -106
  133. package/crates/team-agent/src/layout/manager.rs +0 -248
  134. package/crates/team-agent/src/layout/mod.rs +0 -36
  135. package/crates/team-agent/src/layout/overlay.rs +0 -134
  136. package/crates/team-agent/src/layout/placement.rs +0 -52
  137. package/crates/team-agent/src/layout/recovery.rs +0 -106
  138. package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
  139. package/crates/team-agent/src/layout/sessions.rs +0 -294
  140. package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
  141. package/crates/team-agent/src/layout/worker_env.rs +0 -721
  142. package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
  143. package/crates/team-agent/src/leader/helpers.rs +0 -178
  144. package/crates/team-agent/src/leader/incident.rs +0 -6
  145. package/crates/team-agent/src/leader/lease.rs +0 -3356
  146. package/crates/team-agent/src/leader/mod.rs +0 -104
  147. package/crates/team-agent/src/leader/owner_bind.rs +0 -400
  148. package/crates/team-agent/src/leader/prompt.rs +0 -905
  149. package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
  150. package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
  151. package/crates/team-agent/src/leader/rediscover.rs +0 -1192
  152. package/crates/team-agent/src/leader/registry.rs +0 -888
  153. package/crates/team-agent/src/leader/start.rs +0 -4501
  154. package/crates/team-agent/src/leader/takeover.rs +0 -65
  155. package/crates/team-agent/src/leader/tests/basics.rs +0 -337
  156. package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
  157. package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
  158. package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
  159. package/crates/team-agent/src/leader/tests/identity.rs +0 -465
  160. package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
  161. package/crates/team-agent/src/leader/tests/idle.rs +0 -113
  162. package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
  163. package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
  164. package/crates/team-agent/src/leader/tests/mod.rs +0 -106
  165. package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -268
  166. package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
  167. package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
  168. package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
  169. package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
  170. package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
  171. package/crates/team-agent/src/leader/types.rs +0 -534
  172. package/crates/team-agent/src/lib.rs +0 -147
  173. package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
  174. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -881
  175. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -598
  176. package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
  177. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -204
  178. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -107
  179. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -144
  180. package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
  181. package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
  182. package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
  183. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -160
  184. package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
  185. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -899
  186. package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -225
  187. package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
  188. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5200
  189. package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
  190. package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
  191. package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
  192. package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -473
  193. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
  194. package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
  195. package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
  196. package/crates/team-agent/src/lifecycle/launch.rs +0 -557
  197. package/crates/team-agent/src/lifecycle/lock.rs +0 -350
  198. package/crates/team-agent/src/lifecycle/mod.rs +0 -79
  199. package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
  200. package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -1067
  201. package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
  202. package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2199
  203. package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1798
  204. package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +0 -163
  205. package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2362
  206. package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
  207. package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
  208. package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
  209. package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
  210. package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
  211. package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
  212. package/crates/team-agent/src/lifecycle/restart.rs +0 -227
  213. package/crates/team-agent/src/lifecycle/role_config.rs +0 -1230
  214. package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
  215. package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
  216. package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
  217. package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
  218. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
  219. package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
  220. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -447
  221. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1638
  222. package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
  223. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -770
  224. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -419
  225. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2035
  226. package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1327
  227. package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
  228. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
  229. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
  230. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -72
  231. package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
  232. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
  233. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -512
  234. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
  235. package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
  236. package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
  237. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3983
  238. package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
  239. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
  240. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
  241. package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
  242. package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
  243. package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
  244. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -164
  245. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -200
  246. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
  247. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -527
  248. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -1062
  249. package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1419
  250. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -98
  251. package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -550
  252. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -226
  253. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -332
  254. package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
  255. package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
  256. package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
  257. package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
  258. package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
  259. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
  260. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
  261. package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
  262. package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
  263. package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
  264. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
  265. package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
  266. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -342
  267. package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
  268. package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
  269. package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
  270. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
  271. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
  272. package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
  273. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
  274. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -995
  275. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -836
  276. package/crates/team-agent/src/lifecycle/tests.rs +0 -105
  277. package/crates/team-agent/src/lifecycle/types.rs +0 -877
  278. package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -363
  279. package/crates/team-agent/src/main.rs +0 -52
  280. package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
  281. package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
  282. package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
  283. package/crates/team-agent/src/mcp_server/mod.rs +0 -119
  284. package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
  285. package/crates/team-agent/src/mcp_server/readiness.rs +0 -527
  286. package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -348
  287. package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
  288. package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
  289. package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -158
  290. package/crates/team-agent/src/mcp_server/tests/send.rs +0 -353
  291. package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -341
  292. package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
  293. package/crates/team-agent/src/mcp_server/tests.rs +0 -43
  294. package/crates/team-agent/src/mcp_server/tools.rs +0 -889
  295. package/crates/team-agent/src/mcp_server/types.rs +0 -396
  296. package/crates/team-agent/src/mcp_server/wire.rs +0 -867
  297. package/crates/team-agent/src/messaging/activity.rs +0 -461
  298. package/crates/team-agent/src/messaging/address.rs +0 -87
  299. package/crates/team-agent/src/messaging/delivery.rs +0 -3727
  300. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
  301. package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
  302. package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
  303. package/crates/team-agent/src/messaging/helpers.rs +0 -336
  304. package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
  305. package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
  306. package/crates/team-agent/src/messaging/mod.rs +0 -167
  307. package/crates/team-agent/src/messaging/persist.rs +0 -377
  308. package/crates/team-agent/src/messaging/presentation.rs +0 -417
  309. package/crates/team-agent/src/messaging/reminders.rs +0 -316
  310. package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
  311. package/crates/team-agent/src/messaging/results.rs +0 -1415
  312. package/crates/team-agent/src/messaging/scheduler.rs +0 -223
  313. package/crates/team-agent/src/messaging/selftest.rs +0 -315
  314. package/crates/team-agent/src/messaging/send.rs +0 -981
  315. package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
  316. package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -657
  317. package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
  318. package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
  319. package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
  320. package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
  321. package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
  322. package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3549
  323. package/crates/team-agent/src/messaging/tests/spine.rs +0 -853
  324. package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
  325. package/crates/team-agent/src/messaging/trust.rs +0 -215
  326. package/crates/team-agent/src/messaging/types.rs +0 -472
  327. package/crates/team-agent/src/messaging/wait.rs +0 -366
  328. package/crates/team-agent/src/messaging/watchers.rs +0 -916
  329. package/crates/team-agent/src/model/enums.rs +0 -356
  330. package/crates/team-agent/src/model/errors.rs +0 -18
  331. package/crates/team-agent/src/model/ids.rs +0 -165
  332. package/crates/team-agent/src/model/mod.rs +0 -29
  333. package/crates/team-agent/src/model/name_similarity.rs +0 -252
  334. package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
  335. package/crates/team-agent/src/model/paths.rs +0 -257
  336. package/crates/team-agent/src/model/routing.rs +0 -387
  337. package/crates/team-agent/src/model/spec.rs +0 -1184
  338. package/crates/team-agent/src/model/task_graph.rs +0 -321
  339. package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
  340. package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
  341. package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
  342. package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
  343. package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
  344. package/crates/team-agent/src/model/yaml/tests.rs +0 -188
  345. package/crates/team-agent/src/model/yaml.rs +0 -802
  346. package/crates/team-agent/src/os_probe.rs +0 -280
  347. package/crates/team-agent/src/packaging/install.rs +0 -219
  348. package/crates/team-agent/src/packaging/migrate.rs +0 -38
  349. package/crates/team-agent/src/packaging/mod.rs +0 -91
  350. package/crates/team-agent/src/packaging/repair.rs +0 -33
  351. package/crates/team-agent/src/packaging/tests.rs +0 -822
  352. package/crates/team-agent/src/packaging/types.rs +0 -417
  353. package/crates/team-agent/src/platform/argv.rs +0 -331
  354. package/crates/team-agent/src/platform/errors.rs +0 -104
  355. package/crates/team-agent/src/platform/file_lock.rs +0 -279
  356. package/crates/team-agent/src/platform/mod.rs +0 -5
  357. package/crates/team-agent/src/platform/process.rs +0 -545
  358. package/crates/team-agent/src/provider/adapter.rs +0 -1150
  359. package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
  360. package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
  361. package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
  362. package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
  363. package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
  364. package/crates/team-agent/src/provider/adapters/mod.rs +0 -30
  365. package/crates/team-agent/src/provider/adapters/pi.rs +0 -106
  366. package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
  367. package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
  368. package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
  369. package/crates/team-agent/src/provider/argv_route.rs +0 -405
  370. package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
  371. package/crates/team-agent/src/provider/classify.rs +0 -708
  372. package/crates/team-agent/src/provider/command_helpers.rs +0 -45
  373. package/crates/team-agent/src/provider/faults.rs +0 -165
  374. package/crates/team-agent/src/provider/helpers.rs +0 -52
  375. package/crates/team-agent/src/provider/mod.rs +0 -78
  376. package/crates/team-agent/src/provider/model_catalog.rs +0 -910
  377. package/crates/team-agent/src/provider/session/capture.rs +0 -2731
  378. package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
  379. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -172
  380. package/crates/team-agent/src/provider/session/context_fork.rs +0 -396
  381. package/crates/team-agent/src/provider/session/mod.rs +0 -36
  382. package/crates/team-agent/src/provider/session/resume.rs +0 -269
  383. package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
  384. package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
  385. package/crates/team-agent/src/provider/session_scan/common.rs +0 -654
  386. package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
  387. package/crates/team-agent/src/provider/session_scan/pi.rs +0 -185
  388. package/crates/team-agent/src/provider/session_scan.rs +0 -71
  389. package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
  390. package/crates/team-agent/src/provider/submit_now.rs +0 -71
  391. package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
  392. package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
  393. package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
  394. package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
  395. package/crates/team-agent/src/provider/tests/adapter.rs +0 -441
  396. package/crates/team-agent/src/provider/tests/classify.rs +0 -148
  397. package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -35
  398. package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
  399. package/crates/team-agent/src/provider/tests/faults.rs +0 -200
  400. package/crates/team-agent/src/provider/tests/idle.rs +0 -177
  401. package/crates/team-agent/src/provider/tests/wire.rs +0 -213
  402. package/crates/team-agent/src/provider/tests.rs +0 -32
  403. package/crates/team-agent/src/provider/types.rs +0 -529
  404. package/crates/team-agent/src/provider/wire.rs +0 -394
  405. package/crates/team-agent/src/redaction.rs +0 -259
  406. package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
  407. package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
  408. package/crates/team-agent/src/state/identity.rs +0 -914
  409. package/crates/team-agent/src/state/identity_keys.rs +0 -132
  410. package/crates/team-agent/src/state/mod.rs +0 -74
  411. package/crates/team-agent/src/state/owner_gate.rs +0 -482
  412. package/crates/team-agent/src/state/ownership.rs +0 -563
  413. package/crates/team-agent/src/state/paths.rs +0 -395
  414. package/crates/team-agent/src/state/persist.rs +0 -3811
  415. package/crates/team-agent/src/state/projection.rs +0 -1508
  416. package/crates/team-agent/src/state/repository/intent.rs +0 -14
  417. package/crates/team-agent/src/state/repository/tests.rs +0 -184
  418. package/crates/team-agent/src/state/repository.rs +0 -866
  419. package/crates/team-agent/src/state/selector.rs +0 -160
  420. package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
  421. package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
  422. package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
  423. package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
  424. package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
  425. package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
  426. package/crates/team-agent/src/tmux_backend/tests.rs +0 -4103
  427. package/crates/team-agent/src/tmux_backend.rs +0 -4492
  428. package/crates/team-agent/src/topology.rs +0 -537
  429. package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
  430. package/crates/team-agent/src/transport/native_input.rs +0 -491
  431. package/crates/team-agent/src/transport/test_support.rs +0 -743
  432. package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
  433. package/crates/team-agent/src/transport/tests/mod.rs +0 -194
  434. package/crates/team-agent/src/transport/tests/wire.rs +0 -574
  435. package/crates/team-agent/src/transport.rs +0 -1655
  436. package/crates/team-agent/src/transport_factory.rs +0 -819
@@ -1,1126 +0,0 @@
1
- //! #252 restart/rebind hotfix contracts.
2
- //!
3
- //! Local cargo/black-box contracts for the 0.3.3 hotfix surface. These avoid
4
- //! real provider subscriptions and pin the externally visible behavior around
5
- //! restart cwd, MCP owner scope, team-scoped coordinator writeback, pane identity,
6
- //! unbound leader delivery, SQLite contention, and coordinator shutdown.
7
-
8
- #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
9
-
10
- #[path = "../../../tests/support/hermetic.rs"]
11
- mod hermetic_guard;
12
- #[allow(dead_code)]
13
- fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
14
-
15
- use std::collections::BTreeMap;
16
- use std::io::Write as _;
17
- use std::path::{Path, PathBuf};
18
- use std::process::{Command, Stdio};
19
- use std::sync::atomic::{AtomicU64, Ordering};
20
- use std::sync::{Arc, Mutex};
21
- use std::time::Instant;
22
-
23
- use serde_json::{json, Value};
24
- use serial_test::serial;
25
- use team_agent::coordinator::{Coordinator, ProviderRegistry, WorkspacePath};
26
- use team_agent::db::schema::{initialize_schema, open_db};
27
- use team_agent::event_log::EventLog;
28
- use team_agent::lifecycle::{launch_with_transport_in_workspace, restart_with_transport};
29
- use team_agent::message_store::MessageStore;
30
- use team_agent::messaging::delivery::deliver_pending_message;
31
- use team_agent::model::enums::{AuthMode, Provider};
32
- use team_agent::provider::{
33
- AuthHintStatus, CaptureVia, CapturedSession, Confidence, HandledPrompt, McpConfig,
34
- ProviderAdapter, ProviderCaps, ProviderError, RolloutPath, SessionId, StatusPatterns,
35
- };
36
- use team_agent::state::persist::{load_runtime_state, save_runtime_state};
37
- use team_agent::transport::{
38
- AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
39
- InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, PaneLiveness, SessionName,
40
- SetEnvOutcome, SpawnResult, SubmitVerification, Target, Transport, TransportError,
41
- TurnVerification, WindowName,
42
- };
43
-
44
- const CURRENT: &str = "current";
45
- const SUB: &str = "sub";
46
-
47
- #[test]
48
- #[ignore = "real-machine: restart/rebind lifecycle gate"]
49
- #[serial(env)]
50
- fn restart_resume_spawns_worker_with_team_dir_cwd_matching_launch() {
51
- let case = HotfixCase::new("restart-cwd");
52
- case.write_team(CURRENT, "greeter", Provider::Copilot);
53
- case.seed_restart_state(CURRENT, "greeter", "sess-current", "handled");
54
- case.seed_healthy_coordinator();
55
- let _home = case.copilot_home_with_session("sess-current");
56
- let transport = RecordingTransport::new().with_session_present(false);
57
-
58
- restart_with_transport(&case.team_dir(CURRENT), false, Some(CURRENT), &transport)
59
- .expect("restart should resume the worker");
60
-
61
- let spawn = transport.single_spawn();
62
- assert_eq!(
63
- spawn.cwd,
64
- case.team_dir(CURRENT),
65
- "RC0: restart/resume must spawn the worker in the same team directory cwd used by first launch. \
66
- Passing the run workspace root makes the resumed provider see cwd != session cwd \
67
- (Codex showed a 'Choose working directory to resume this session' prompt). spawn={spawn:?}"
68
- );
69
- }
70
-
71
- #[test]
72
- #[ignore = "real-machine: restart/rebind lifecycle gate"]
73
- #[serial(env)]
74
- fn restart_resets_startup_prompt_state_for_respawn() {
75
- let case = HotfixCase::new("restart-startup-state");
76
- case.write_team(CURRENT, "greeter", Provider::Copilot);
77
- case.seed_restart_state(CURRENT, "greeter", "sess-current", "handled");
78
- case.seed_healthy_coordinator();
79
- let _home = case.copilot_home_with_session("sess-current");
80
- let transport = RecordingTransport::new().with_session_present(false);
81
-
82
- restart_with_transport(&case.team_dir(CURRENT), false, Some(CURRENT), &transport)
83
- .expect("restart should resume the worker");
84
- let state = load_runtime_state(&case.workspace).expect("state after restart");
85
- let agent = state
86
- .pointer("/teams/current/agents/greeter")
87
- .or_else(|| state.pointer("/agents/greeter"))
88
- .expect("greeter state exists");
89
- let status = agent.get("startup_prompts").and_then(Value::as_str);
90
-
91
- assert!(
92
- !matches!(status, Some("handled" | "complete")),
93
- "RC0 defense: a respawned worker is a new pane and must be eligible for startup prompt detection. \
94
- Restart must clear/version stale startup_prompts=handled instead of carrying it into the new process; state={state}"
95
- );
96
- }
97
-
98
- #[test]
99
- #[ignore = "real-machine: spawns team-agent mcp-server process"]
100
- #[serial(env)]
101
- fn report_result_respects_mcp_owner_team_env_when_active_team_differs() {
102
- let case = HotfixCase::new("mcp-report-owner");
103
- case.seed_dual_team_state(SUB, false);
104
- let output = run_mcp_report_result(
105
- &case.workspace,
106
- "greeter",
107
- CURRENT,
108
- "res-current-env",
109
- "current team result",
110
- );
111
- assert!(
112
- !output["result"]["isError"].as_bool().unwrap_or(true),
113
- "RC4 fixture sanity: real MCP tools/call report_result must not be an MCP error; frame={output}"
114
- );
115
-
116
- let conn = open_db(&case.db_path()).unwrap();
117
- let result_owner: Option<String> = conn
118
- .query_row(
119
- "select owner_team_id from results where task_id='task-current' and agent_id='greeter' order by created_at desc limit 1",
120
- [],
121
- |row| row.get(0),
122
- )
123
- .unwrap_or_else(|error| {
124
- let rows = db_rows(&conn, "results", "result_id, owner_team_id");
125
- panic!("RC4 fixture: report_result did not persist any greeter/task-current result row: error={error} frame={output} rows={rows:?}");
126
- });
127
- let leader_message_owner: Option<String> = conn
128
- .query_row(
129
- "select owner_team_id from messages where sender='greeter' and recipient='leader' order by created_at desc limit 1",
130
- [],
131
- |row| row.get(0),
132
- )
133
- .unwrap_or_else(|error| {
134
- let rows = db_rows(&conn, "messages", "message_id, owner_team_id, sender, recipient, status");
135
- panic!("RC4 fixture: report_result did not create expected leader message row: error={error} frame={output} rows={rows:?}");
136
- });
137
-
138
- assert_eq!(
139
- result_owner.as_deref(),
140
- Some(CURRENT),
141
- "RC4: MCP report_result must use TEAM_AGENT_OWNER_TEAM_ID=current even when raw state active_team_key=sub; frame={output}"
142
- );
143
- assert_eq!(
144
- leader_message_owner.as_deref(),
145
- Some(CURRENT),
146
- "RC4: report_result leader notification message must be queued under current, not active sub"
147
- );
148
- }
149
-
150
- #[test]
151
- #[serial(env)]
152
- fn coordinator_tick_saves_captured_session_into_nested_active_team() {
153
- let case = HotfixCase::new("tick-nested-session");
154
- case.seed_dual_team_state(SUB, false);
155
- let rollout = case.workspace.join("sub-rollout.jsonl");
156
- std::fs::write(&rollout, "{}").unwrap();
157
- let registry = StaticCaptureRegistry {
158
- session_id: "sess-sub-captured".to_string(),
159
- rollout_path: rollout,
160
- };
161
- let transport = RecordingTransport::new()
162
- .with_session_present(true)
163
- .with_windows(vec![WindowName::new("subgreeter")]);
164
- let coord = Coordinator::new(
165
- WorkspacePath::new(case.workspace.clone()),
166
- Box::new(registry),
167
- Box::new(transport),
168
- );
169
-
170
- coord.tick().expect("coordinator tick");
171
- let state = load_runtime_state(&case.workspace).expect("state after tick");
172
-
173
- assert_eq!(
174
- state.pointer("/teams/sub/agents/subgreeter/session_id").and_then(Value::as_str),
175
- Some("sess-sub-captured"),
176
- "RC1: coordinator tick must write captured provider session into the nested active team, not only the top-level projection; state={state}"
177
- );
178
- }
179
-
180
- #[test]
181
- #[serial(env)]
182
- fn launch_persists_agent_pane_id_and_pid() {
183
- let case = HotfixCase::new("launch-pane-id");
184
- case.write_team(CURRENT, "greeter", Provider::Fake);
185
- // 0.3.28 Step 4b: workers live in their own window named after the
186
- // agent_id, not the adaptive `team-w1` anchor.
187
- let transport = RecordingTransport::new()
188
- .with_targets(vec![pane_info("%7", "team-current", "greeter", Some(4242))])
189
- .with_windows(vec![WindowName::new("greeter")])
190
- .with_default_liveness(PaneLiveness::Live);
191
-
192
- launch_with_transport_in_workspace(
193
- &case.workspace,
194
- &case.team_dir(CURRENT).join("team.spec.yaml"),
195
- false,
196
- true,
197
- true,
198
- &transport,
199
- )
200
- .expect("launch should spawn fake worker");
201
- let state = load_runtime_state(&case.workspace).expect("state after launch");
202
- let agent = state
203
- .pointer("/teams/current/agents/greeter")
204
- .or_else(|| state.pointer("/agents/greeter"))
205
- .expect("greeter state");
206
-
207
- assert_eq!(
208
- agent.get("pane_id").and_then(Value::as_str),
209
- Some("%7"),
210
- "RC2: launch must persist the concrete tmux %pane_id returned by spawn/list_targets; state={state}"
211
- );
212
- assert_eq!(
213
- agent.get("pane_pid").and_then(Value::as_u64),
214
- Some(4242),
215
- "RC2: launch must continue persisting pane_pid alongside pane_id; state={state}"
216
- );
217
- }
218
-
219
- #[test]
220
- #[serial(env)]
221
- fn unbound_leader_receiver_is_not_attached_and_delivery_never_injects_sentinel() {
222
- let case = HotfixCase::new("unbound-leader");
223
- case.seed_unbound_leader_state();
224
- let store = MessageStore::open(&case.workspace).unwrap();
225
- let message_id = store
226
- .create_message(
227
- None,
228
- "subgreeter",
229
- "leader",
230
- "sentinel canary",
231
- None,
232
- false,
233
- Some(SUB),
234
- )
235
- .unwrap();
236
- let state = load_runtime_state(&case.workspace).unwrap();
237
- let transport = RecordingTransport::new().with_default_liveness(PaneLiveness::Live);
238
-
239
- let out = deliver_pending_message(
240
- &case.workspace,
241
- &store,
242
- &transport,
243
- &message_id,
244
- &EventLog::new(&case.workspace),
245
- &state,
246
- )
247
- .expect("delivery should return an explicit rebind outcome");
248
-
249
- assert!(
250
- !out.ok && out.channel.as_deref() == Some("rebind_required") && transport.inject_targets().is_empty(),
251
- "RC3: __team_agent_unbound__ is not an attached leader receiver; delivery must return rebind_required and never inject; outcome={out:?} targets={:?}",
252
- transport.inject_targets()
253
- );
254
- assert!(
255
- transport.inject_targets().is_empty(),
256
- "RC3: delivery must never physically inject/paste to the sentinel __team_agent_unbound__; outcome={out:?} targets={:?}",
257
- transport.inject_targets()
258
- );
259
- }
260
-
261
- #[test]
262
- #[serial(env)]
263
- fn sqlite_open_retries_under_concurrent_writer() {
264
- let case = HotfixCase::new("sqlite-lock");
265
- std::fs::create_dir_all(case.db_path().parent().unwrap()).unwrap();
266
- let holder = rusqlite::Connection::open(case.db_path()).unwrap();
267
- initialize_schema(&holder, Some(&case.db_path())).unwrap();
268
- holder.execute_batch("BEGIN EXCLUSIVE;").unwrap();
269
-
270
- let start = Instant::now();
271
- let result = MessageStore::open(&case.workspace);
272
- let elapsed = start.elapsed();
273
- holder.execute_batch("ROLLBACK;").unwrap();
274
-
275
- assert!(
276
- result.is_ok(),
277
- "RC5: opening/initializing team.db under a concurrent writer must retry/idempotently survive instead of surfacing database-is-locked. elapsed={elapsed:?} error={:?}",
278
- result.err()
279
- );
280
- }
281
-
282
- #[test]
283
- #[ignore = "real-machine: coordinator pidfile SIGTERM process gate"]
284
- #[serial(env)]
285
- fn shutdown_pidfile_sigterm_waits_and_normalizes() {
286
- let case = HotfixCase::new("shutdown-pidfile");
287
- let mut child = Command::new("sh")
288
- .arg("-c")
289
- .arg("trap 'sleep 2; exit 0' TERM; while true; do sleep 1; done")
290
- .stdin(Stdio::null())
291
- .stdout(Stdio::null())
292
- .stderr(Stdio::null())
293
- .spawn()
294
- .expect("spawn delayed SIGTERM child");
295
- case.write_coordinator_pid(child.id());
296
-
297
- let report =
298
- team_agent::coordinator::stop_coordinator(&WorkspacePath::new(case.workspace.clone()))
299
- .expect("stop coordinator");
300
- let still_running = process_running(child.id());
301
- if still_running {
302
- let _ = child.kill();
303
- }
304
- let _ = child.wait();
305
-
306
- assert!(
307
- report.ok && !still_running,
308
- "RC6: pidfile coordinator stop must wait until the SIGTERM target really exits before reporting ok/stopped and removing metadata. report={report:?} still_running={still_running}"
309
- );
310
- }
311
-
312
- #[derive(Debug)]
313
- struct HotfixCase {
314
- workspace: PathBuf,
315
- }
316
-
317
- impl HotfixCase {
318
- fn new(tag: &str) -> Self {
319
- let root = tmp_dir(tag);
320
- let workspace = root.join("ws");
321
- std::fs::create_dir_all(workspace.join(".team/runtime")).unwrap();
322
- Self { workspace }
323
- }
324
-
325
- fn team_dir(&self, team: &str) -> PathBuf {
326
- self.workspace.join(".team").join(team)
327
- }
328
-
329
- fn db_path(&self) -> PathBuf {
330
- self.workspace.join(".team/runtime/team.db")
331
- }
332
-
333
- /// Copilot resume backing is the `sessions` row in
334
- /// `$HOME/.copilot/session-store.db`; seed it under a fixture HOME and
335
- /// point HOME there for the guard's lifetime (callers are `serial(env)`).
336
- fn copilot_home_with_session(&self, session_id: &str) -> HomeGuard {
337
- let home = self.workspace.parent().unwrap().join("home");
338
- let db = home.join(".copilot").join("session-store.db");
339
- std::fs::create_dir_all(db.parent().unwrap()).unwrap();
340
- let conn = rusqlite::Connection::open(db).unwrap();
341
- conn.execute_batch(
342
- "create table if not exists sessions (id text primary key, cwd text, created_at text);",
343
- )
344
- .unwrap();
345
- conn.execute(
346
- "insert or replace into sessions(id, cwd, created_at) values (?1, ?2, '2026-06-07T01:00:00Z')",
347
- rusqlite::params![session_id, self.workspace.to_string_lossy()],
348
- )
349
- .unwrap();
350
- HomeGuard::set(&home)
351
- }
352
-
353
- fn write_team(&self, team: &str, agent_id: &str, provider: Provider) {
354
- let dir = self.team_dir(team);
355
- std::fs::create_dir_all(dir.join("agents")).unwrap();
356
- std::fs::write(
357
- dir.join("TEAM.md"),
358
- format!(
359
- "---\nname: {team}\nobjective: hotfix\nprovider: {}\n---\n\nTeam.\n",
360
- provider_name(provider)
361
- ),
362
- )
363
- .unwrap();
364
- std::fs::write(
365
- dir.join("agents").join(format!("{agent_id}.md")),
366
- format!(
367
- "---\nname: {agent_id}\nrole: Greeter\nprovider: {}\nmodel: test\nauth_mode: subscription\ndangerously_skip_permissions: false\ntools:\n - mcp_team\n---\n\nWorker.\n",
368
- provider_name(provider)
369
- ),
370
- )
371
- .unwrap();
372
- let spec = team_agent::compiler::compile_team(&dir).unwrap();
373
- std::fs::write(
374
- dir.join("team.spec.yaml"),
375
- team_agent::model::yaml::dumps(&spec),
376
- )
377
- .unwrap();
378
- }
379
-
380
- fn seed_restart_state(
381
- &self,
382
- team: &str,
383
- agent_id: &str,
384
- session_id: &str,
385
- startup_prompts: &str,
386
- ) {
387
- let team_dir = self.team_dir(team);
388
- let state = json!({
389
- "active_team_key": team,
390
- "team_dir": team_dir.to_string_lossy(),
391
- "spec_path": team_dir.join("team.spec.yaml").to_string_lossy(),
392
- "session_name": format!("team-{team}"),
393
- "agents": {
394
- agent_id: restart_agent(agent_id, team, &team_dir, session_id, startup_prompts)
395
- },
396
- "tasks": [],
397
- "teams": {
398
- team: {
399
- "status": "alive",
400
- "team_dir": team_dir.to_string_lossy(),
401
- "spec_path": team_dir.join("team.spec.yaml").to_string_lossy(),
402
- "session_name": format!("team-{team}"),
403
- "agents": {
404
- agent_id: restart_agent(agent_id, team, &team_dir, session_id, startup_prompts)
405
- },
406
- "tasks": []
407
- }
408
- }
409
- });
410
- save_runtime_state(&self.workspace, &state).unwrap();
411
- }
412
-
413
- fn seed_dual_team_state(&self, active: &str, with_leader_receivers: bool) {
414
- let current_dir = self.team_dir(CURRENT);
415
- let sub_dir = self.team_dir(SUB);
416
- std::fs::create_dir_all(&current_dir).unwrap();
417
- std::fs::create_dir_all(&sub_dir).unwrap();
418
- let current = team_state(CURRENT, "greeter", &current_dir, with_leader_receivers);
419
- let sub = team_state(SUB, "subgreeter", &sub_dir, with_leader_receivers);
420
- let mut state = if active == CURRENT {
421
- current.clone()
422
- } else {
423
- sub.clone()
424
- };
425
- let obj = state.as_object_mut().unwrap();
426
- obj.insert("active_team_key".to_string(), json!(active));
427
- obj.insert("teams".to_string(), json!({CURRENT: current, SUB: sub}));
428
- save_runtime_state(&self.workspace, &state).unwrap();
429
- let _ = MessageStore::open(&self.workspace).unwrap();
430
- }
431
-
432
- fn seed_unbound_leader_state(&self) {
433
- let sub_dir = self.team_dir(SUB);
434
- std::fs::create_dir_all(&sub_dir).unwrap();
435
- save_runtime_state(
436
- &self.workspace,
437
- &json!({
438
- "active_team_key": SUB,
439
- "session_name": "team-sub",
440
- "team_dir": sub_dir.to_string_lossy(),
441
- "spec_path": sub_dir.join("team.spec.yaml").to_string_lossy(),
442
- "leader_receiver": {
443
- "mode": "direct_tmux",
444
- "status": "attached",
445
- "pane_id": "__team_agent_unbound__"
446
- },
447
- "team_owner": {
448
- "status": "attached",
449
- "pane_id": "__team_agent_unbound__"
450
- },
451
- "agents": {
452
- "subgreeter": {"status": "running", "provider": "fake", "window": "subgreeter", "owner_team_id": SUB}
453
- },
454
- "teams": {
455
- SUB: {
456
- "status": "alive",
457
- "session_name": "team-sub",
458
- "team_dir": sub_dir.to_string_lossy(),
459
- "spec_path": sub_dir.join("team.spec.yaml").to_string_lossy(),
460
- "leader_receiver": {
461
- "mode": "direct_tmux",
462
- "status": "attached",
463
- "pane_id": "__team_agent_unbound__"
464
- },
465
- "team_owner": {
466
- "status": "attached",
467
- "pane_id": "__team_agent_unbound__"
468
- },
469
- "agents": {
470
- "subgreeter": {"status": "running", "provider": "fake", "window": "subgreeter", "owner_team_id": SUB}
471
- }
472
- }
473
- }
474
- }),
475
- )
476
- .unwrap();
477
- }
478
-
479
- fn seed_healthy_coordinator(&self) {
480
- let workspace = WorkspacePath::new(self.workspace.clone());
481
- let _ = MessageStore::open(workspace.as_path()).unwrap();
482
- let pid = team_agent::coordinator::Pid::new(std::process::id());
483
- team_agent::coordinator::write_coordinator_metadata(
484
- &workspace,
485
- pid,
486
- team_agent::coordinator::MetadataSource::Boot,
487
- )
488
- .unwrap();
489
- std::fs::write(
490
- team_agent::coordinator::coordinator_pid_path(&workspace),
491
- pid.to_string(),
492
- )
493
- .unwrap();
494
- }
495
-
496
- fn write_coordinator_pid(&self, pid: u32) {
497
- let workspace = WorkspacePath::new(self.workspace.clone());
498
- std::fs::create_dir_all(self.workspace.join(".team/runtime")).unwrap();
499
- std::fs::write(
500
- team_agent::coordinator::coordinator_pid_path(&workspace),
501
- pid.to_string(),
502
- )
503
- .unwrap();
504
- team_agent::coordinator::write_coordinator_metadata(
505
- &workspace,
506
- team_agent::coordinator::Pid::new(pid),
507
- team_agent::coordinator::MetadataSource::Start,
508
- )
509
- .unwrap();
510
- }
511
- }
512
-
513
- fn restart_agent(
514
- agent_id: &str,
515
- team: &str,
516
- team_dir: &Path,
517
- session_id: &str,
518
- startup_prompts: &str,
519
- ) -> Value {
520
- json!({
521
- "status": "running",
522
- "agent_id": agent_id,
523
- "provider": "copilot",
524
- "role": "Greeter",
525
- "tools": ["mcp_team"],
526
- "window": agent_id,
527
- "owner_team_id": team,
528
- "session_id": session_id,
529
- "first_send_at": "2026-06-07T01:00:00+00:00",
530
- "spawn_cwd": team_dir.to_string_lossy(),
531
- "startup_prompts": startup_prompts,
532
- "startup_prompt_status": startup_prompts
533
- })
534
- }
535
-
536
- fn team_state(team: &str, agent_id: &str, team_dir: &Path, with_leader_receiver: bool) -> Value {
537
- let mut state = json!({
538
- "status": "alive",
539
- "team_dir": team_dir.to_string_lossy(),
540
- "spec_path": team_dir.join("team.spec.yaml").to_string_lossy(),
541
- "session_name": format!("team-{team}"),
542
- "agents": {
543
- agent_id: {
544
- "status": "running",
545
- "provider": "copilot",
546
- "window": agent_id,
547
- "owner_team_id": team,
548
- "spawn_cwd": team_dir.to_string_lossy(),
549
- "session_id": null
550
- }
551
- },
552
- "tasks": [{"id": format!("task-{team}"), "assignee": agent_id, "status": "pending"}]
553
- });
554
- if with_leader_receiver {
555
- let obj = state.as_object_mut().unwrap();
556
- obj.insert(
557
- "leader_receiver".to_string(),
558
- json!({"mode": "direct_tmux", "status": "attached", "pane_id": format!("%leader-{team}")}),
559
- );
560
- obj.insert(
561
- "team_owner".to_string(),
562
- json!({"status": "attached", "pane_id": format!("%leader-{team}")}),
563
- );
564
- }
565
- state
566
- }
567
-
568
- fn run_mcp_report_result(
569
- workspace: &Path,
570
- agent_id: &str,
571
- owner_team_id: &str,
572
- result_id: &str,
573
- summary: &str,
574
- ) -> Value {
575
- let exe = crate::lifecycle::tests::test_binary_path();
576
- let mut child = Command::new(exe)
577
- .arg("mcp-server")
578
- .arg("--workspace")
579
- .arg(workspace)
580
- .env("TEAM_AGENT_WORKSPACE", workspace)
581
- .env("TEAM_AGENT_ID", agent_id)
582
- .env("TEAM_AGENT_OWNER_TEAM_ID", owner_team_id)
583
- .stdin(Stdio::piped())
584
- .stdout(Stdio::piped())
585
- .stderr(Stdio::piped())
586
- .spawn()
587
- .expect("spawn mcp-server");
588
- {
589
- let stdin = child.stdin.as_mut().expect("stdin");
590
- writeln!(stdin, r#"{{"jsonrpc":"2.0","id":1,"method":"initialize","params":{{"protocolVersion":"2024-11-05"}}}}"#).unwrap();
591
- writeln!(
592
- stdin,
593
- "{}",
594
- json!({
595
- "jsonrpc": "2.0",
596
- "id": 2,
597
- "method": "tools/call",
598
- "params": {
599
- "name": "report_result",
600
- "arguments": {
601
- "envelope": {
602
- "result_id": result_id,
603
- "task_id": "task-current",
604
- "agent_id": agent_id,
605
- "status": "success",
606
- "summary": summary,
607
- "changes": [], "tests": [], "risks": [], "artifacts": [], "next_actions": []
608
- }
609
- }
610
- }
611
- })
612
- )
613
- .unwrap();
614
- }
615
- let output = child.wait_with_output().expect("wait mcp-server");
616
- assert!(
617
- output.status.success(),
618
- "mcp-server exited unsuccessfully: status={:?} stderr={}",
619
- output.status.code(),
620
- String::from_utf8_lossy(&output.stderr)
621
- );
622
- let stdout = String::from_utf8(output.stdout).unwrap();
623
- stdout
624
- .lines()
625
- .filter_map(|line| serde_json::from_str::<Value>(line).ok())
626
- .find(|frame| frame["id"] == json!(2))
627
- .unwrap_or_else(|| panic!("missing tools/call response; stdout={stdout}"))
628
- }
629
-
630
- #[derive(Debug, Clone)]
631
- struct RecordedSpawn {
632
- argv: Vec<String>,
633
- cwd: PathBuf,
634
- env: BTreeMap<String, String>,
635
- pane_id: PaneId,
636
- }
637
-
638
- #[derive(Debug)]
639
- struct TransportState {
640
- spawns: Vec<RecordedSpawn>,
641
- injections: Vec<Target>,
642
- keys: Vec<Vec<Key>>,
643
- captures: Vec<String>,
644
- session_present: bool,
645
- windows: Vec<WindowName>,
646
- targets: Vec<PaneInfo>,
647
- default_liveness: PaneLiveness,
648
- liveness: BTreeMap<String, PaneLiveness>,
649
- }
650
-
651
- impl Default for TransportState {
652
- fn default() -> Self {
653
- Self {
654
- spawns: Vec::new(),
655
- injections: Vec::new(),
656
- keys: Vec::new(),
657
- captures: Vec::new(),
658
- session_present: false,
659
- windows: Vec::new(),
660
- targets: Vec::new(),
661
- default_liveness: PaneLiveness::Dead,
662
- liveness: BTreeMap::new(),
663
- }
664
- }
665
- }
666
-
667
- #[derive(Debug, Clone, Default)]
668
- struct RecordingTransport {
669
- state: Arc<Mutex<TransportState>>,
670
- }
671
-
672
- impl RecordingTransport {
673
- fn new() -> Self {
674
- Self::default()
675
- }
676
-
677
- fn with_session_present(self, present: bool) -> Self {
678
- self.state.lock().unwrap().session_present = present;
679
- self
680
- }
681
-
682
- fn with_windows(self, windows: Vec<WindowName>) -> Self {
683
- self.state.lock().unwrap().windows = windows;
684
- self
685
- }
686
-
687
- fn with_targets(self, targets: Vec<PaneInfo>) -> Self {
688
- self.state.lock().unwrap().targets = targets;
689
- self
690
- }
691
-
692
- fn with_default_liveness(self, liveness: PaneLiveness) -> Self {
693
- self.state.lock().unwrap().default_liveness = liveness;
694
- self
695
- }
696
-
697
- fn single_spawn(&self) -> RecordedSpawn {
698
- let state = self.state.lock().unwrap();
699
- assert_eq!(
700
- state.spawns.len(),
701
- 1,
702
- "expected one spawn; spawns={:?}",
703
- state.spawns
704
- );
705
- state.spawns[0].clone()
706
- }
707
-
708
- fn inject_targets(&self) -> Vec<Target> {
709
- self.state.lock().unwrap().injections.clone()
710
- }
711
-
712
- fn spawn_result(
713
- &self,
714
- session: &SessionName,
715
- window: &WindowName,
716
- argv: &[String],
717
- cwd: &Path,
718
- env: &BTreeMap<String, String>,
719
- ) -> SpawnResult {
720
- let mut state = self.state.lock().unwrap();
721
- let pane_id = state
722
- .targets
723
- .iter()
724
- .find(|pane| pane.session == *session && pane.window_name.as_ref() == Some(window))
725
- .or_else(|| {
726
- state
727
- .targets
728
- .iter()
729
- .find(|pane| pane.window_name.as_ref() == Some(window))
730
- })
731
- .map(|pane| pane.pane_id.clone())
732
- .unwrap_or_else(|| PaneId::new(format!("%{}", state.spawns.len() + 1)));
733
- let child_pid = state
734
- .targets
735
- .iter()
736
- .find(|pane| pane.pane_id == pane_id)
737
- .and_then(|pane| pane.pane_pid);
738
- state.spawns.push(RecordedSpawn {
739
- argv: argv.to_vec(),
740
- cwd: cwd.to_path_buf(),
741
- env: env.clone(),
742
- pane_id: pane_id.clone(),
743
- });
744
- SpawnResult {
745
- pane_id,
746
- session: session.clone(),
747
- window: window.clone(),
748
- child_pid,
749
- }
750
- }
751
- }
752
-
753
- impl Transport for RecordingTransport {
754
- fn kind(&self) -> BackendKind {
755
- BackendKind::Tmux
756
- }
757
-
758
- fn spawn_first(
759
- &self,
760
- session: &SessionName,
761
- window: &WindowName,
762
- argv: &[String],
763
- cwd: &Path,
764
- env: &BTreeMap<String, String>,
765
- ) -> Result<SpawnResult, TransportError> {
766
- Ok(self.spawn_result(session, window, argv, cwd, env))
767
- }
768
-
769
- fn spawn_into(
770
- &self,
771
- session: &SessionName,
772
- window: &WindowName,
773
- argv: &[String],
774
- cwd: &Path,
775
- env: &BTreeMap<String, String>,
776
- ) -> Result<SpawnResult, TransportError> {
777
- Ok(self.spawn_result(session, window, argv, cwd, env))
778
- }
779
-
780
- fn inject(
781
- &self,
782
- target: &Target,
783
- _payload: &InjectPayload,
784
- _submit: Key,
785
- _bracketed: bool,
786
- ) -> Result<InjectReport, TransportError> {
787
- self.state.lock().unwrap().injections.push(target.clone());
788
- Ok(InjectReport {
789
- stage_reached: InjectStage::Submit,
790
- inject_verification: InjectVerification::CaptureContainsToken,
791
- submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck,
792
- turn_verification: TurnVerification::NotYetObserved,
793
- attempts: 1,
794
- submit_diagnostics: None,
795
- })
796
- }
797
-
798
- fn send_keys(&self, _target: &Target, keys: &[Key]) -> Result<(), TransportError> {
799
- self.state.lock().unwrap().keys.push(keys.to_vec());
800
- Ok(())
801
- }
802
-
803
- fn capture(
804
- &self,
805
- _target: &Target,
806
- range: CaptureRange,
807
- ) -> Result<CapturedText, TransportError> {
808
- let text = self
809
- .state
810
- .lock()
811
- .unwrap()
812
- .captures
813
- .first()
814
- .cloned()
815
- .unwrap_or_default();
816
- Ok(CapturedText { text, range })
817
- }
818
-
819
- fn query(&self, _target: &Target, field: PaneField) -> Result<Option<String>, TransportError> {
820
- match field {
821
- PaneField::PaneWidth => Ok(Some("120".to_string())),
822
- _ => Ok(None),
823
- }
824
- }
825
-
826
- fn liveness(&self, pane: &PaneId) -> Result<PaneLiveness, TransportError> {
827
- let state = self.state.lock().unwrap();
828
- Ok(state
829
- .liveness
830
- .get(pane.as_str())
831
- .copied()
832
- .unwrap_or(state.default_liveness))
833
- }
834
-
835
- fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
836
- Ok(self.state.lock().unwrap().targets.clone())
837
- }
838
-
839
- fn has_session(&self, _session: &SessionName) -> Result<bool, TransportError> {
840
- Ok(self.state.lock().unwrap().session_present)
841
- }
842
-
843
- fn list_windows(&self, _session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
844
- Ok(self.state.lock().unwrap().windows.clone())
845
- }
846
-
847
- fn set_session_env(
848
- &self,
849
- _session: &SessionName,
850
- _key: &str,
851
- _value: &str,
852
- ) -> Result<SetEnvOutcome, TransportError> {
853
- Ok(SetEnvOutcome::Applied)
854
- }
855
-
856
- fn kill_session(&self, _session: &SessionName) -> Result<(), TransportError> {
857
- Ok(())
858
- }
859
-
860
- fn kill_window(&self, _target: &Target) -> Result<(), TransportError> {
861
- Ok(())
862
- }
863
-
864
- fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> {
865
- Ok(AttachOutcome::Attached)
866
- }
867
- }
868
-
869
- struct StaticCaptureRegistry {
870
- session_id: String,
871
- rollout_path: PathBuf,
872
- }
873
-
874
- impl ProviderRegistry for StaticCaptureRegistry {
875
- fn adapter_for(&self, provider: Provider) -> Box<dyn ProviderAdapter> {
876
- Box::new(StaticCaptureAdapter {
877
- provider,
878
- session_id: self.session_id.clone(),
879
- rollout_path: self.rollout_path.clone(),
880
- })
881
- }
882
- }
883
-
884
- struct StaticCaptureAdapter {
885
- provider: Provider,
886
- session_id: String,
887
- rollout_path: PathBuf,
888
- }
889
-
890
- impl ProviderAdapter for StaticCaptureAdapter {
891
- fn provider(&self) -> Provider {
892
- self.provider
893
- }
894
-
895
- fn caps(&self) -> ProviderCaps {
896
- ProviderCaps {
897
- resume: true,
898
- fork: false,
899
- native_mcp_config: false,
900
- writes_global_settings: false,
901
- }
902
- }
903
-
904
- fn is_installed(&self) -> bool {
905
- true
906
- }
907
-
908
- fn version(&self) -> Result<String, ProviderError> {
909
- Ok("test".to_string())
910
- }
911
-
912
- fn auth_hint(&self, _auth_mode: AuthMode) -> AuthHintStatus {
913
- AuthHintStatus::Unknown
914
- }
915
-
916
- fn build_command(
917
- &self,
918
- _auth_mode: AuthMode,
919
- _mcp_config: Option<&McpConfig>,
920
- _system_prompt: Option<&str>,
921
- _model: Option<&str>,
922
- ) -> Result<Vec<String>, ProviderError> {
923
- Ok(vec!["fake".to_string()])
924
- }
925
-
926
- fn build_command_with_permissions(
927
- &self,
928
- auth_mode: AuthMode,
929
- mcp_config: Option<&McpConfig>,
930
- system_prompt: Option<&str>,
931
- model: Option<&str>,
932
- _dangerously_skip_permissions: bool,
933
- ) -> Result<Vec<String>, ProviderError> {
934
- self.build_command(auth_mode, mcp_config, system_prompt, model)
935
- }
936
-
937
- fn capture_session_id(
938
- &self,
939
- _agent_id: &str,
940
- spawn_cwd: &Path,
941
- _timeout_s: u64,
942
- ) -> Result<Option<CapturedSession>, ProviderError> {
943
- Ok(Some(CapturedSession {
944
- session_id: Some(SessionId::new(self.session_id.clone())),
945
- rollout_path: Some(RolloutPath::new(self.rollout_path.clone())),
946
- captured_via: CaptureVia::FsWatch,
947
- attribution_confidence: Confidence::High,
948
- spawn_cwd: spawn_cwd.to_path_buf(),
949
- }))
950
- }
951
-
952
- fn recover_session_id(
953
- &self,
954
- _agent_id: &str,
955
- _spawn_cwd: &Path,
956
- ) -> Result<Option<SessionId>, ProviderError> {
957
- Ok(Some(SessionId::new(self.session_id.clone())))
958
- }
959
-
960
- fn session_is_resumable(
961
- &self,
962
- _session_id: Option<&SessionId>,
963
- _auth_mode: AuthMode,
964
- ) -> Result<bool, ProviderError> {
965
- Ok(true)
966
- }
967
-
968
- fn build_resume_command(
969
- &self,
970
- _session_id: Option<&SessionId>,
971
- _auth_mode: AuthMode,
972
- _mcp_config: Option<&McpConfig>,
973
- ) -> Result<Vec<String>, ProviderError> {
974
- Ok(vec!["fake".to_string(), "resume".to_string()])
975
- }
976
-
977
- fn build_resume_command_with_context(
978
- &self,
979
- session_id: Option<&SessionId>,
980
- auth_mode: AuthMode,
981
- mcp_config: Option<&McpConfig>,
982
- _system_prompt: Option<&str>,
983
- _model: Option<&str>,
984
- _dangerously_skip_permissions: bool,
985
- ) -> Result<Vec<String>, ProviderError> {
986
- self.build_resume_command(session_id, auth_mode, mcp_config)
987
- }
988
-
989
- fn fork(
990
- &self,
991
- _session_id: Option<&SessionId>,
992
- _auth_mode: AuthMode,
993
- _mcp_config: Option<&McpConfig>,
994
- ) -> Result<Vec<String>, ProviderError> {
995
- Ok(vec!["fake".to_string(), "fork".to_string()])
996
- }
997
-
998
- fn fork_with_context(
999
- &self,
1000
- session_id: Option<&SessionId>,
1001
- auth_mode: AuthMode,
1002
- mcp_config: Option<&McpConfig>,
1003
- _system_prompt: Option<&str>,
1004
- _model: Option<&str>,
1005
- _dangerously_skip_permissions: bool,
1006
- ) -> Result<Vec<String>, ProviderError> {
1007
- self.fork(session_id, auth_mode, mcp_config)
1008
- }
1009
-
1010
- fn mcp_config(&self, _auth_mode: AuthMode) -> Result<McpConfig, ProviderError> {
1011
- Ok(McpConfig { raw: json!({}) })
1012
- }
1013
-
1014
- fn install_mcp(&self, _config: &McpConfig) -> Result<(), ProviderError> {
1015
- Ok(())
1016
- }
1017
-
1018
- fn status_patterns(&self) -> Result<StatusPatterns, ProviderError> {
1019
- Ok(StatusPatterns {
1020
- idle: regex::Regex::new("idle").unwrap(),
1021
- processing: regex::Regex::new("processing").unwrap(),
1022
- error: regex::Regex::new("error").unwrap(),
1023
- })
1024
- }
1025
-
1026
- fn validate_model(&self, _model: &str) -> Result<bool, ProviderError> {
1027
- Ok(true)
1028
- }
1029
-
1030
- fn handle_startup_prompts(
1031
- &self,
1032
- _transport: &dyn Transport,
1033
- _target: &Target,
1034
- _checks: usize,
1035
- _sleep_s: f64,
1036
- ) -> Vec<HandledPrompt> {
1037
- Vec::new()
1038
- }
1039
- }
1040
-
1041
- struct HomeGuard(Option<std::ffi::OsString>);
1042
-
1043
- impl HomeGuard {
1044
- fn set(home: &Path) -> Self {
1045
- let previous = std::env::var_os("HOME");
1046
- std::env::set_var("HOME", home);
1047
- Self(previous)
1048
- }
1049
- }
1050
-
1051
- impl Drop for HomeGuard {
1052
- fn drop(&mut self) {
1053
- match self.0.take() {
1054
- Some(previous) => std::env::set_var("HOME", previous),
1055
- None => std::env::remove_var("HOME"),
1056
- }
1057
- }
1058
- }
1059
-
1060
- fn pane_info(pane_id: &str, session: &str, window: &str, pane_pid: Option<u32>) -> PaneInfo {
1061
- PaneInfo {
1062
- pane_id: PaneId::new(pane_id),
1063
- session: SessionName::new(session),
1064
- window_index: Some(0),
1065
- window_name: Some(WindowName::new(window)),
1066
- pane_index: Some(0),
1067
- tty: None,
1068
- current_command: Some("fake".to_string()),
1069
- current_path: None,
1070
- active: true,
1071
- pane_pid,
1072
- leader_env: BTreeMap::new(),
1073
- }
1074
- }
1075
-
1076
- fn process_running(pid: u32) -> bool {
1077
- // 0.5.x Windows portability Batch 5: route through
1078
- // `platform::process::pid_is_alive` so the helper compiles on
1079
- // both platforms. Unix behavior byte-equivalent (kill(pid, 0)
1080
- // via platform primitive).
1081
- team_agent::platform::process::pid_is_alive(pid)
1082
- }
1083
-
1084
- fn db_rows(conn: &rusqlite::Connection, table: &str, columns: &str) -> Vec<String> {
1085
- let mut stmt = conn
1086
- .prepare(&format!("select {columns} from {table}"))
1087
- .unwrap();
1088
- let column_count = stmt.column_count();
1089
- stmt.query_map([], |row| {
1090
- let values = (0..column_count)
1091
- .map(|idx| {
1092
- row.get::<_, Option<String>>(idx)
1093
- .unwrap_or(None)
1094
- .unwrap_or_else(|| "NULL".to_string())
1095
- })
1096
- .collect::<Vec<_>>();
1097
- Ok(values.join("|"))
1098
- })
1099
- .unwrap()
1100
- .collect::<Result<Vec<_>, _>>()
1101
- .unwrap()
1102
- }
1103
-
1104
- fn provider_name(provider: Provider) -> &'static str {
1105
- match provider {
1106
- Provider::Claude | Provider::ClaudeCode => "claude",
1107
- Provider::Codex => "codex",
1108
- Provider::Copilot => "copilot",
1109
- Provider::GeminiCli => "gemini",
1110
- Provider::Grok => "grok",
1111
- Provider::Pi => "pi",
1112
- Provider::Fake => "fake",
1113
- }
1114
- }
1115
-
1116
- fn tmp_dir(tag: &str) -> PathBuf {
1117
- static N: AtomicU64 = AtomicU64::new(0);
1118
- let dir = std::env::temp_dir().join(format!(
1119
- "ta-rs-252-{tag}-{}-{}",
1120
- std::process::id(),
1121
- N.fetch_add(1, Ordering::Relaxed)
1122
- ));
1123
- let _ = std::fs::remove_dir_all(&dir);
1124
- std::fs::create_dir_all(&dir).unwrap();
1125
- std::fs::canonicalize(dir).unwrap()
1126
- }