@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,819 +0,0 @@
1
- //! 0.5.x Phase 1d Batch 0: backend assembly factory.
2
- //!
3
- //! Truth sources (READ-ONLY):
4
- //! - Design: `.team/artifacts/0.5.x-backend-assembly-factory-design.md`
5
- //! - CR verdict: `.team/artifacts/0.5.x-backend-factory-cr-verdict.md`
6
- //! (6 constraints; every one anchors into this module)
7
- //!
8
- //! ## Scope of Batch 0 (this commit)
9
- //!
10
- //! - Add the factory type + resolver ONLY. Zero caller migration.
11
- //! - Ship the 5 independent tests the design lists (§Batch 0
12
- //! Verification) + the C-1 grep guard (resolver has no
13
- //! `if conpty|pty { .. tmux .. }` fallback branch) + the C-5 grep
14
- //! guard (this file must never call `kill_server`, emit stale
15
- //! events, or start a shim).
16
- //! - C-6 gate: Batch 0 tests + guards must be GREEN before Batch 1
17
- //! moves callers. This commit is the Batch 0 half; the very next
18
- //! commit is Batch 1.
19
- //!
20
- //! ## CR anchors
21
- //!
22
- //! - **C-1** fail-closed × 2:
23
- //! ① explicit `conpty` on an unsupported host / missing shim
24
- //! surfaces `MuxUnavailable` — NEVER silent-downgrade to tmux.
25
- //! ② `spec.runtime.backend = "pty"` returns
26
- //! `UnsupportedSpecBackendLiteral` — NEVER auto-map ConPTY.
27
- //! - **C-2** CLI override vs `state.transport.kind`: if both are set
28
- //! and disagree, the factory REFUSES with `BackendConflict` (unless
29
- //! fresh_switch is explicitly true — the caller path threads this
30
- //! through when the user passes `--fresh`).
31
- //! - **C-3** two-source conflict N38 events: when the resolver chooses
32
- //! a backend and there's a shadow source that was ignored, the
33
- //! `ResolvedTransport.notices` list carries structured entries the
34
- //! caller emits into `events.jsonl`. Emission happens at the caller
35
- //! boundary (not here) because the factory itself must have zero
36
- //! side effects (C-5).
37
- //! - **C-4** compact-status JSON stability is a separate grep-guard
38
- //! test (`transport_factory_compact_status_guard.rs`); this module
39
- //! just declares which fields are `--detail`-only.
40
- //! - **C-5** factory purity: this file NEVER calls
41
- //! `transport.kill_server(...)`, NEVER writes to `event_log`, NEVER
42
- //! opens a pipe, NEVER starts a shim, NEVER rotates a token. Guard
43
- //! test greps this file for those calls.
44
- //! - **C-6** Batch 0 gate: the 5 core resolver tests + both C-1 grep
45
- //! guards + the C-5 grep guard must pass before Batch 1's caller
46
- //! migration begins. Enforced by CI + local test order.
47
-
48
- use std::path::Path;
49
-
50
- use crate::conpty::ConPtyBackend;
51
- use crate::tmux_backend::TmuxBackend;
52
- use crate::transport::{BackendKind, Transport};
53
-
54
- #[cfg(test)]
55
- thread_local! {
56
- static LEADER_ENDPOINT_TRANSPORT_OVERRIDE: std::cell::RefCell<
57
- Option<(String, crate::transport::test_support::OfflineTransport)>,
58
- > = std::cell::RefCell::new(None);
59
- }
60
-
61
- /// Production live-probe transport for a recorded leader endpoint.
62
- /// `classify_leader_binding`, restart `transport_for_receiver`, and
63
- /// `attach_leader_targets` all go through this function.
64
- pub fn leader_endpoint_transport(endpoint: &str) -> Box<dyn Transport> {
65
- #[cfg(test)]
66
- if let Some(injected) = LEADER_ENDPOINT_TRANSPORT_OVERRIDE.with(|slot| {
67
- slot.borrow().as_ref().and_then(|(expected, transport)| {
68
- (expected == endpoint).then(|| Box::new(transport.clone()) as Box<dyn Transport>)
69
- })
70
- }) {
71
- return injected;
72
- }
73
- if endpoint.is_empty() || endpoint == "default" {
74
- Box::new(tmux_default_transport())
75
- } else {
76
- Box::new(tmux_endpoint_transport(endpoint))
77
- }
78
- }
79
-
80
- #[cfg(test)]
81
- struct LeaderEndpointTransportGuard {
82
- previous: Option<(String, crate::transport::test_support::OfflineTransport)>,
83
- }
84
-
85
- #[cfg(test)]
86
- impl Drop for LeaderEndpointTransportGuard {
87
- fn drop(&mut self) {
88
- LEADER_ENDPOINT_TRANSPORT_OVERRIDE.with(|slot| {
89
- *slot.borrow_mut() = self.previous.take();
90
- });
91
- }
92
- }
93
-
94
- #[cfg(test)]
95
- pub fn with_leader_endpoint_transport<T>(
96
- endpoint: &str,
97
- transport: crate::transport::test_support::OfflineTransport,
98
- f: impl FnOnce() -> T,
99
- ) -> T {
100
- let previous = LEADER_ENDPOINT_TRANSPORT_OVERRIDE.with(|slot| {
101
- slot.replace(Some((endpoint.to_string(), transport)))
102
- });
103
- let _guard = LeaderEndpointTransportGuard { previous };
104
- f()
105
- }
106
-
107
- /// User-visible backend selector on the CLI (`--backend tmux|conpty`).
108
- #[derive(Debug, Clone, Copy, PartialEq, Eq)]
109
- pub enum RequestedTransportBackend {
110
- Tmux,
111
- ConPty,
112
- }
113
-
114
- impl RequestedTransportBackend {
115
- pub fn parse_literal(s: &str) -> Option<Self> {
116
- match s.trim().to_ascii_lowercase().as_str() {
117
- "tmux" => Some(Self::Tmux),
118
- "conpty" => Some(Self::ConPty),
119
- _ => None,
120
- }
121
- }
122
-
123
- pub fn as_wire(self) -> &'static str {
124
- match self {
125
- Self::Tmux => "tmux",
126
- Self::ConPty => "conpty",
127
- }
128
- }
129
- }
130
-
131
- /// Which lifecycle site is asking the factory to resolve a transport.
132
- /// Passed through so events + coordinator boot metadata can attribute
133
- /// which caller made the choice. This has no effect on resolution
134
- /// itself; it exists only for observability + C-3 event payloads.
135
- #[derive(Debug, Clone, Copy, PartialEq, Eq)]
136
- pub enum TransportPurpose {
137
- Launch,
138
- LifecycleWorker,
139
- Coordinator,
140
- Status,
141
- Diagnose,
142
- Shutdown,
143
- MessageDelivery,
144
- }
145
-
146
- /// Factory input. Every field except `workspace` and `purpose` is
147
- /// optional; the resolution order (§Factory Design:141-149) picks the
148
- /// first source that fires.
149
- ///
150
- /// The lifetimes tie each borrowed value to the caller so the factory
151
- /// is a pure function of its inputs.
152
- #[derive(Debug, Clone, Copy)]
153
- pub struct TransportFactoryInput<'a> {
154
- pub workspace: &'a Path,
155
- pub team_key: Option<&'a str>,
156
- pub state: Option<&'a serde_json::Value>,
157
- pub spec_backend_literal: Option<&'a str>,
158
- pub explicit_backend: Option<RequestedTransportBackend>,
159
- pub purpose: TransportPurpose,
160
- /// True only when the caller has confirmed the switch (via
161
- /// `--fresh` or a similar explicit gate). Used to allow C-2's
162
- /// otherwise-refuse path.
163
- pub allow_backend_switch: bool,
164
- }
165
-
166
- impl<'a> TransportFactoryInput<'a> {
167
- pub fn new(workspace: &'a Path, purpose: TransportPurpose) -> Self {
168
- Self {
169
- workspace,
170
- team_key: None,
171
- state: None,
172
- spec_backend_literal: None,
173
- explicit_backend: None,
174
- purpose,
175
- allow_backend_switch: false,
176
- }
177
- }
178
-
179
- pub fn with_team_key(mut self, team_key: Option<&'a str>) -> Self {
180
- self.team_key = team_key;
181
- self
182
- }
183
-
184
- pub fn with_state(mut self, state: Option<&'a serde_json::Value>) -> Self {
185
- self.state = state;
186
- self
187
- }
188
-
189
- pub fn with_spec_backend_literal(mut self, literal: Option<&'a str>) -> Self {
190
- self.spec_backend_literal = literal;
191
- self
192
- }
193
-
194
- pub fn with_explicit_backend(mut self, override_: Option<RequestedTransportBackend>) -> Self {
195
- self.explicit_backend = override_;
196
- self
197
- }
198
-
199
- pub fn allow_backend_switch(mut self, allow: bool) -> Self {
200
- self.allow_backend_switch = allow;
201
- self
202
- }
203
- }
204
-
205
- /// One-line trace of what the factory resolved and why. Emitted by the
206
- /// caller (never by the factory itself — C-5) as
207
- /// `transport.backend_selected`.
208
- ///
209
- /// The `source` field is a stable wire string so telemetry can pivot
210
- /// on it. Values: `"cli"`, `"state.transport.kind"`,
211
- /// `"legacy_tmux_endpoint"`, `"spec.runtime.backend"`, `"default"`.
212
- ///
213
- /// No `Clone` — the boxed `Transport` trait object is not cloneable.
214
- pub struct ResolvedTransport {
215
- pub backend: Box<dyn Transport>,
216
- pub kind: BackendKind,
217
- pub source: &'static str,
218
- pub tmux_endpoint_used: Option<String>,
219
- pub team_key: Option<String>,
220
- /// N38 交底: extra events the caller should emit next to
221
- /// `transport.backend_selected` so users can explain WHY a shadow
222
- /// source was ignored (C-3).
223
- pub notices: Vec<TransportNotice>,
224
- }
225
-
226
- impl std::fmt::Debug for ResolvedTransport {
227
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
228
- f.debug_struct("ResolvedTransport")
229
- .field("kind", &self.kind)
230
- .field("source", &self.source)
231
- .field("tmux_endpoint_used", &self.tmux_endpoint_used)
232
- .field("team_key", &self.team_key)
233
- .field("notices", &self.notices)
234
- .field("backend", &"<dyn Transport>")
235
- .finish()
236
- }
237
- }
238
-
239
- /// A single N38-style notice the caller should emit into events.jsonl
240
- /// after choosing a backend. The factory returns them; it never emits
241
- /// (C-5).
242
- #[derive(Debug, Clone, PartialEq, Eq)]
243
- pub struct TransportNotice {
244
- pub event: &'static str,
245
- pub payload: serde_json::Value,
246
- }
247
-
248
- /// Every way the factory can refuse honestly (MUST-NOT-13 + C-1/C-2).
249
- #[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
250
- pub enum TransportFactoryError {
251
- /// C-1 ①: explicit `conpty` was requested but a required precondition
252
- /// isn't met (missing `team_key`, non-Windows host with no shim
253
- /// wired, etc.). Callers MUST surface this as
254
- /// `TransportError::MuxUnavailable` — NEVER silent-downgrade to
255
- /// tmux.
256
- #[error("conpty backend requires {reason}")]
257
- ConPtyPreconditionUnmet { reason: String },
258
-
259
- /// C-1 ②: `spec.runtime.backend = "pty"` was seen. The MVP does not
260
- /// auto-map `pty` to ConPTY (design §Non-Goals:370). Callers must
261
- /// treat this as a hard error.
262
- #[error("unsupported spec.runtime.backend literal {literal:?}; only tmux|conpty are supported in Phase 1d")]
263
- UnsupportedSpecBackendLiteral { literal: String },
264
-
265
- /// C-2: CLI `--backend X` and `state.transport.kind=Y` disagree and
266
- /// the caller did not pass `allow_backend_switch=true` (i.e. no
267
- /// `--fresh`). Refuse rather than orphan existing workers whose
268
- /// `pane_id` prefix matches the OTHER backend.
269
- #[error(
270
- "backend conflict: CLI requested {cli:?} but state.transport.kind={state:?}; \
271
- switching would abandon existing {state:?} workers — pass --fresh to switch"
272
- )]
273
- BackendConflict {
274
- cli: RequestedTransportBackend,
275
- state: BackendKind,
276
- },
277
- }
278
-
279
- /// Resolve a transport per the 5-layer order:
280
- ///
281
- /// 1. Explicit CLI override.
282
- /// 2. `state.transport.kind`.
283
- /// 3. Legacy `state.tmux_endpoint` / `state.tmux_socket` → tmux.
284
- /// 4. Spec `runtime.backend` literal (`tmux` / `conpty`; `pty`
285
- /// explicitly unsupported).
286
- /// 5. Default → tmux workspace socket.
287
- ///
288
- /// The function returns `ResolvedTransport` for the success path or
289
- /// `TransportFactoryError` for any refusal. **Never silently downgrades
290
- /// conpty → tmux, never auto-maps pty → conpty, never runs
291
- /// side-effects (open pipe, kill server, rotate token, emit event —
292
- /// see C-5 guard test).**
293
- pub fn resolve_transport(
294
- input: TransportFactoryInput<'_>,
295
- ) -> Result<ResolvedTransport, TransportFactoryError> {
296
- let state_kind = input
297
- .state
298
- .and_then(|s| s.pointer("/transport/kind"))
299
- .and_then(|v| v.as_str())
300
- .and_then(RequestedTransportBackend::parse_literal);
301
- // ── C-2 ────────────────────────────────────────────────────────
302
- // If CLI override disagrees with state.transport.kind, refuse
303
- // unless the caller opted-in via allow_backend_switch (--fresh).
304
- // This is fail-closed BEFORE we build any backend so no side effect
305
- // leaks.
306
- if let (Some(cli), Some(state)) = (input.explicit_backend, state_kind) {
307
- if cli != state && !input.allow_backend_switch {
308
- return Err(TransportFactoryError::BackendConflict {
309
- cli,
310
- state: requested_to_kind(state),
311
- });
312
- }
313
- }
314
- // ── Layer 1: CLI override ─────────────────────────────────────
315
- if let Some(requested) = input.explicit_backend {
316
- return build_selected(&input, requested, "cli");
317
- }
318
- // ── Layer 2: state.transport.kind ─────────────────────────────
319
- if let Some(requested) = state_kind {
320
- return build_selected(&input, requested, "state.transport.kind");
321
- }
322
- // ── Layer 3: legacy tmux endpoint / socket ────────────────────
323
- if let Some((_, _)) = crate::tmux_backend::runtime_tmux_endpoint_from_state_pub(input.state) {
324
- return build_selected(
325
- &input,
326
- RequestedTransportBackend::Tmux,
327
- "legacy_tmux_endpoint",
328
- );
329
- }
330
- // ── Layer 4: spec.runtime.backend literal ─────────────────────
331
- if let Some(literal) = input.spec_backend_literal {
332
- match literal.trim().to_ascii_lowercase().as_str() {
333
- "tmux" => {
334
- return build_selected(
335
- &input,
336
- RequestedTransportBackend::Tmux,
337
- "spec.runtime.backend",
338
- );
339
- }
340
- "conpty" => {
341
- return build_selected(
342
- &input,
343
- RequestedTransportBackend::ConPty,
344
- "spec.runtime.backend",
345
- );
346
- }
347
- other => {
348
- // C-1 ②: `pty` (and everything else) is NOT auto-mapped
349
- // to ConPTY. Fail closed with a typed error.
350
- return Err(TransportFactoryError::UnsupportedSpecBackendLiteral {
351
- literal: other.to_string(),
352
- });
353
- }
354
- }
355
- }
356
- // ── Layer 5: default → tmux workspace ─────────────────────────
357
- build_selected(&input, RequestedTransportBackend::Tmux, "default")
358
- }
359
-
360
- fn requested_to_kind(r: RequestedTransportBackend) -> BackendKind {
361
- match r {
362
- RequestedTransportBackend::Tmux => BackendKind::Tmux,
363
- RequestedTransportBackend::ConPty => BackendKind::ConPty,
364
- }
365
- }
366
-
367
- fn build_selected(
368
- input: &TransportFactoryInput<'_>,
369
- requested: RequestedTransportBackend,
370
- source: &'static str,
371
- ) -> Result<ResolvedTransport, TransportFactoryError> {
372
- match requested {
373
- RequestedTransportBackend::Tmux => Ok(build_tmux(input, source)),
374
- RequestedTransportBackend::ConPty => build_conpty(input, source),
375
- }
376
- }
377
-
378
- fn build_tmux(input: &TransportFactoryInput<'_>, source: &'static str) -> ResolvedTransport {
379
- // Preserve the existing runtime endpoint / workspace fallback shape
380
- // so tmux callers see byte-equivalent behavior.
381
- let selection = crate::tmux_backend::tmux_backend_for_runtime_state_or_workspace(
382
- input.workspace,
383
- input.state,
384
- );
385
- // C-3: if we chose tmux because of `state.transport.kind = tmux`
386
- // OR `spec.runtime.backend = tmux` OR `default`, but a legacy tmux
387
- // endpoint is *also* present, that is not a conflict (they
388
- // agree). The conflict scenario in design §Two-Source Conflict
389
- // Scene C is `legacy tmux + spec conpty` — order 3 wins, spec is
390
- // ignored. Callers of the `spec.runtime.backend` path with a
391
- // legacy tmux endpoint present take a different code path (they
392
- // hit layer 3 first). So there is no notice to emit for tmux.
393
- ResolvedTransport {
394
- kind: BackendKind::Tmux,
395
- source,
396
- tmux_endpoint_used: selection.tmux_endpoint_used,
397
- team_key: input.team_key.map(str::to_string),
398
- backend: Box::new(selection.backend),
399
- notices: Vec::new(),
400
- }
401
- }
402
-
403
- fn build_conpty(
404
- input: &TransportFactoryInput<'_>,
405
- source: &'static str,
406
- ) -> Result<ResolvedTransport, TransportFactoryError> {
407
- // C-1 fail-closed: ConPTY needs a team_key. Missing → refuse.
408
- // NEVER silent-downgrade to tmux; that would violate MUST-NOT-13.
409
- let Some(team_key) = input.team_key else {
410
- return Err(TransportFactoryError::ConPtyPreconditionUnmet {
411
- reason: "team_key required for conpty (design §Factory Design:159-163)".to_string(),
412
- });
413
- };
414
- // Build a workspace hash from the canonical workspace path using
415
- // the same source of truth the tmux short-socket derivation uses,
416
- // so the shim + tmux socket see identical workspace identity.
417
- let workspace_hash = crate::tmux_backend::workspace_short_hash_pub(input.workspace);
418
- // `mut` because the Windows branch below may reassign after a
419
- // successful pipe connect + `with_pipe_client` handshake. On
420
- // Unix the binding stays as-constructed.
421
- #[cfg_attr(not(windows), allow(unused_mut))]
422
- let mut backend = ConPtyBackend::new(workspace_hash.clone(), team_key);
423
- let mut notices = Vec::new();
424
- // 0.5.x CR C-5 fix (leader msg_a89b5a03bbf0): factory returns to
425
- // pure assembly. `build_conpty` used to call
426
- // `NamedPipeClient::connect(_, 2000)` inline when
427
- // `conpty_pipe_ready(input)` said state hinted the shim was up.
428
- // That was a real CR C-5 violation — every `status`/`diagnose`
429
- // resolve on Windows could block 2 seconds probing a
430
- // non-existent pipe.
431
- //
432
- // Post-fix: the factory only STASHES the pipe hint via
433
- // `ConPtyBackend::with_pipe_hint(pipe_name)`. The backend's
434
- // `ensure_pipe_client` performs the connect + Hello lazily on
435
- // the first Op that needs the pipe. Callers that don't need
436
- // the pipe (status, resolve-only paths) never pay the connect
437
- // cost.
438
- //
439
- // The Batch 6 direct-handoff path (`lifecycle/launch.rs`
440
- // quick-start conpty) stays byte-compatible: it hands its
441
- // Hello-connected client to `with_pipe_client` AFTER
442
- // `resolve_transport` returns, and the client just becomes the
443
- // backend's initial cache value so lazy connect is a no-op on
444
- // the first Op.
445
- #[cfg(windows)]
446
- {
447
- if let Some(state) = input.state {
448
- if let Some(pipe_name) = state
449
- .pointer("/transport/shim/pipe_name")
450
- .and_then(|v| v.as_str())
451
- {
452
- backend = backend.with_pipe_hint(pipe_name);
453
- }
454
- }
455
- // Non-state env override still respected (test/diagnostic
456
- // path). When set, derive the hint from workspace_hash +
457
- // team_key so `dispatch` can lazily connect the first Op.
458
- if std::env::var("TEAM_AGENT_FORCE_CONPTY_PIPE_CONNECT")
459
- .map(|v| v == "1")
460
- .unwrap_or(false)
461
- && backend.pipe_hint_ref().is_none()
462
- {
463
- let pipe_name = conpty_transport::pipe_name_for(&workspace_hash, team_key);
464
- backend = backend.with_pipe_hint(pipe_name);
465
- }
466
- }
467
- // Suppress unused warnings on Unix where the cfg(windows) block
468
- // above compiles to nothing.
469
- #[cfg(not(windows))]
470
- {
471
- let _ = &workspace_hash;
472
- }
473
- // C-3: if state has BOTH `transport.kind=conpty` and a legacy
474
- // `tmux_endpoint`, tell the caller so they emit
475
- // `transport.legacy_tmux_endpoint_ignored`. Same shape for the
476
- // Scene C case (legacy tmux + spec conpty): if we're on the spec
477
- // path we would have hit the legacy branch first, so this only
478
- // fires when `state.transport.kind=conpty` explicitly overrode
479
- // the legacy fields.
480
- if let Some(state) = input.state {
481
- if source == "state.transport.kind" {
482
- if let Some(legacy) = state.get("tmux_endpoint").and_then(|v| v.as_str()) {
483
- notices.push(TransportNotice {
484
- event: "transport.legacy_tmux_endpoint_ignored",
485
- payload: serde_json::json!({
486
- "chosen_backend": "conpty",
487
- "legacy_tmux_endpoint": legacy,
488
- "reason": "state.transport.kind=conpty explicitly overrides legacy tmux endpoint",
489
- }),
490
- });
491
- }
492
- }
493
- }
494
- Ok(ResolvedTransport {
495
- kind: BackendKind::ConPty,
496
- source,
497
- tmux_endpoint_used: None,
498
- team_key: Some(team_key.to_string()),
499
- backend: Box::new(backend),
500
- notices,
501
- })
502
- }
503
-
504
- // ─────────────────────────────────────────────────────────────────────────
505
- // Tmux channel helpers.
506
- //
507
- // These are intentional tmux-specific entrypoints for callers that
508
- // target a KNOWN tmux socket (external leader panes, orphan diagnosis,
509
- // managed leader launcher). They are NOT part of the team backend
510
- // selection surface. Callers grep for these names to signal intent.
511
- // ─────────────────────────────────────────────────────────────────────────
512
-
513
- /// 0.5.x Phase 1d Batch 3 read-path convenience: build a
514
- /// `ResolvedTransport` for a plain workspace + optional state pair.
515
- ///
516
- /// This is the single entrypoint the coordinator boot / status /
517
- /// diagnose read-only paths use. It follows the same 5-layer resolution
518
- /// order as `resolve_transport`; it does NOT accept a CLI backend
519
- /// override (read paths don't have one) — that avoids accidentally
520
- /// widening the CLI surface at every reader.
521
- ///
522
- /// On `Err`, callers should fall back to a tmux workspace transport
523
- /// (byte-equivalent to today's shape) and record the refusal so
524
- /// telemetry stays honest.
525
- pub fn resolve_read_only_transport(
526
- workspace: &Path,
527
- state: Option<&serde_json::Value>,
528
- purpose: TransportPurpose,
529
- ) -> Result<ResolvedTransport, TransportFactoryError> {
530
- let input = TransportFactoryInput::new(workspace, purpose)
531
- .with_state(state)
532
- // Read paths never pass a team_key — they use whatever state
533
- // says. If `state.transport.kind = conpty` but there is no
534
- // team_key, factory refuses (C-1 ①), which is the same honest
535
- // signal we want to surface to the coordinator/status reader.
536
- .with_team_key(
537
- state
538
- .and_then(|s| s.get("teams"))
539
- .and_then(|t| t.as_object())
540
- .and_then(|obj| obj.keys().next().map(String::as_str)),
541
- );
542
- resolve_transport(input)
543
- }
544
-
545
- /// Tmux transport for a caller-supplied tmux endpoint literal. Used by
546
- /// leader launcher, diagnose/orphans, and external leader pane
547
- /// discovery — NOT for worker/team selection.
548
- pub fn tmux_endpoint_transport(endpoint: &str) -> TmuxBackend {
549
- TmuxBackend::for_tmux_endpoint(endpoint)
550
- }
551
-
552
- /// Tmux transport for the default (shared) socket. Same intent as
553
- /// above — used by leader-side channel operations, never worker/team
554
- /// selection.
555
- pub fn tmux_default_transport() -> TmuxBackend {
556
- TmuxBackend::new()
557
- }
558
-
559
- /// Tmux transport for the per-workspace socket. This is what the tmux
560
- /// launch path uses when there is no persisted endpoint. Not for
561
- /// generic worker/team selection — that goes through
562
- /// `resolve_transport`.
563
- pub fn tmux_workspace_transport(workspace: &Path) -> TmuxBackend {
564
- TmuxBackend::for_workspace(workspace)
565
- }
566
-
567
- /// Tmux transport for a specific named tmux socket (e.g.
568
- /// `ta-abcdef012345`). Used by orphan-scanner and diagnose paths that
569
- /// intentionally enumerate the tmux socket roots — NOT for team
570
- /// backend selection.
571
- pub fn tmux_socket_name_transport(socket: &str) -> TmuxBackend {
572
- TmuxBackend::for_socket_name(socket)
573
- }
574
-
575
- // ─────────────────────────────────────────────────────────────────────────
576
- // Tests (§Batch 0 Verification, design.md:220-224).
577
- // ─────────────────────────────────────────────────────────────────────────
578
- #[cfg(test)]
579
- mod tests {
580
- use super::*;
581
- use std::path::PathBuf;
582
-
583
- fn ws() -> PathBuf {
584
- std::env::temp_dir().join("ta-phase1d-factory-tests")
585
- }
586
-
587
- // Test #1 — no state/spec/override → tmux workspace backend.
588
- #[test]
589
- fn no_input_resolves_to_default_tmux_workspace_backend() {
590
- let workspace = ws();
591
- let input = TransportFactoryInput::new(&workspace, TransportPurpose::Launch);
592
- let resolved = resolve_transport(input).expect("default path must succeed");
593
- assert_eq!(resolved.kind, BackendKind::Tmux);
594
- assert_eq!(resolved.source, "default");
595
- assert!(resolved.notices.is_empty());
596
- }
597
-
598
- // Test #2 — legacy `state.tmux_endpoint` → tmux endpoint (order 3).
599
- #[test]
600
- fn legacy_tmux_endpoint_resolves_to_tmux_endpoint_backend() {
601
- let workspace = ws();
602
- let state = serde_json::json!({ "tmux_endpoint": "default" });
603
- let input = TransportFactoryInput::new(&workspace, TransportPurpose::LifecycleWorker)
604
- .with_state(Some(&state));
605
- let resolved = resolve_transport(input).expect("legacy path must succeed");
606
- assert_eq!(resolved.kind, BackendKind::Tmux);
607
- assert_eq!(resolved.source, "legacy_tmux_endpoint");
608
- }
609
-
610
- // Test #3 — explicit conpty (via CLI) with team_key → ConPty.
611
- #[test]
612
- fn explicit_conpty_with_team_key_resolves_to_conpty() {
613
- let workspace = ws();
614
- let input = TransportFactoryInput::new(&workspace, TransportPurpose::LifecycleWorker)
615
- .with_team_key(Some("team-a"))
616
- .with_explicit_backend(Some(RequestedTransportBackend::ConPty));
617
- let resolved =
618
- resolve_transport(input).expect("explicit conpty must succeed with team_key");
619
- assert_eq!(resolved.kind, BackendKind::ConPty);
620
- assert_eq!(resolved.source, "cli");
621
- assert_eq!(resolved.team_key.as_deref(), Some("team-a"));
622
- }
623
-
624
- // Test #4 — explicit conpty WITHOUT team_key → refusal (C-1 ①).
625
- #[test]
626
- fn explicit_conpty_without_team_key_refuses_no_silent_fallback() {
627
- let workspace = ws();
628
- let input = TransportFactoryInput::new(&workspace, TransportPurpose::LifecycleWorker)
629
- .with_explicit_backend(Some(RequestedTransportBackend::ConPty));
630
- let err = resolve_transport(input).expect_err("conpty without team_key must refuse");
631
- match err {
632
- TransportFactoryError::ConPtyPreconditionUnmet { reason } => {
633
- assert!(
634
- reason.contains("team_key"),
635
- "reason must mention team_key: {reason}"
636
- );
637
- }
638
- other => panic!("expected ConPtyPreconditionUnmet, got {other:?}"),
639
- }
640
- }
641
-
642
- // Test #5 — `pty` literal is NOT silently mapped to ConPTY (C-1 ②).
643
- #[test]
644
- fn pty_literal_is_not_silently_mapped_to_conpty() {
645
- let workspace = ws();
646
- let input = TransportFactoryInput::new(&workspace, TransportPurpose::Launch)
647
- .with_team_key(Some("team-a"))
648
- .with_spec_backend_literal(Some("pty"));
649
- let err =
650
- resolve_transport(input).expect_err("pty literal must be refused, not auto-mapped");
651
- match err {
652
- TransportFactoryError::UnsupportedSpecBackendLiteral { literal } => {
653
- assert_eq!(literal, "pty");
654
- }
655
- other => panic!("expected UnsupportedSpecBackendLiteral, got {other:?}"),
656
- }
657
- }
658
-
659
- // C-2 supplementary — CLI override vs state disagreement refuses.
660
- #[test]
661
- fn cli_override_disagreeing_with_state_kind_refuses_unless_fresh() {
662
- let workspace = ws();
663
- let state = serde_json::json!({ "transport": { "kind": "conpty" } });
664
- let input = TransportFactoryInput::new(&workspace, TransportPurpose::LifecycleWorker)
665
- .with_team_key(Some("team-a"))
666
- .with_state(Some(&state))
667
- .with_explicit_backend(Some(RequestedTransportBackend::Tmux));
668
- let err = resolve_transport(input).expect_err("disagreement must refuse");
669
- match err {
670
- TransportFactoryError::BackendConflict { cli, state } => {
671
- assert_eq!(cli, RequestedTransportBackend::Tmux);
672
- assert_eq!(state, BackendKind::ConPty);
673
- }
674
- other => panic!("expected BackendConflict, got {other:?}"),
675
- }
676
- // With allow_backend_switch=true (== --fresh), the same input succeeds.
677
- let input_fresh = TransportFactoryInput::new(&workspace, TransportPurpose::LifecycleWorker)
678
- .with_team_key(Some("team-a"))
679
- .with_state(Some(&state))
680
- .with_explicit_backend(Some(RequestedTransportBackend::Tmux))
681
- .allow_backend_switch(true);
682
- let ok = resolve_transport(input_fresh).expect("--fresh must allow switch");
683
- assert_eq!(ok.kind, BackendKind::Tmux);
684
- assert_eq!(ok.source, "cli");
685
- }
686
-
687
- // C-3 supplementary — state kind=conpty + legacy tmux endpoint emits
688
- // a `legacy_tmux_endpoint_ignored` notice.
689
- #[test]
690
- fn state_conpty_with_legacy_tmux_endpoint_emits_ignored_notice() {
691
- let workspace = ws();
692
- let state = serde_json::json!({
693
- "transport": { "kind": "conpty" },
694
- "tmux_endpoint": "default",
695
- });
696
- let input = TransportFactoryInput::new(&workspace, TransportPurpose::LifecycleWorker)
697
- .with_team_key(Some("team-a"))
698
- .with_state(Some(&state));
699
- let resolved = resolve_transport(input).expect("must succeed");
700
- assert_eq!(resolved.kind, BackendKind::ConPty);
701
- assert_eq!(resolved.source, "state.transport.kind");
702
- // N38: one notice emitted.
703
- assert_eq!(resolved.notices.len(), 1);
704
- assert_eq!(
705
- resolved.notices[0].event,
706
- "transport.legacy_tmux_endpoint_ignored"
707
- );
708
- assert_eq!(
709
- resolved.notices[0].payload["legacy_tmux_endpoint"],
710
- serde_json::json!("default")
711
- );
712
- assert_eq!(
713
- resolved.notices[0].payload["chosen_backend"],
714
- serde_json::json!("conpty")
715
- );
716
- }
717
-
718
- // C-3 also — pure conpty state (no legacy) emits zero notices.
719
- #[test]
720
- fn state_conpty_without_legacy_emits_no_notice() {
721
- let workspace = ws();
722
- let state = serde_json::json!({ "transport": { "kind": "conpty" } });
723
- let input = TransportFactoryInput::new(&workspace, TransportPurpose::LifecycleWorker)
724
- .with_team_key(Some("team-a"))
725
- .with_state(Some(&state));
726
- let resolved = resolve_transport(input).expect("must succeed");
727
- assert_eq!(resolved.kind, BackendKind::ConPty);
728
- assert!(resolved.notices.is_empty());
729
- }
730
-
731
- // 0.5.x Windows portability Batch 5: pipe_ready gate — without a
732
- // shim.pipe_ready hint (or the force-env override) the factory
733
- // must NOT attempt a connect. Cross-platform test — the
734
- // `conpty_pipe_ready` gate is only referenced inside cfg(windows)
735
- // but the observable behavior (no notice, no wired client) is
736
- // identical on Unix.
737
- #[test]
738
- fn conpty_without_pipe_ready_hint_emits_no_pipe_client_notice() {
739
- let workspace = ws();
740
- let state = serde_json::json!({ "transport": { "kind": "conpty" } });
741
- let input = TransportFactoryInput::new(&workspace, TransportPurpose::LifecycleWorker)
742
- .with_team_key(Some("team-a"))
743
- .with_state(Some(&state));
744
- let resolved = resolve_transport(input).expect("must succeed");
745
- assert_eq!(resolved.kind, BackendKind::ConPty);
746
- // No pipe-client notice must appear regardless of platform:
747
- // on Unix the block is cfg'd out; on Windows the gate is
748
- // closed because no `transport.shim.pipe_ready = true` in
749
- // state.
750
- for notice in &resolved.notices {
751
- assert_ne!(
752
- notice.event, "transport.conpty_pipe_client_unwired",
753
- "no pipe-client notice without a pipe_ready hint"
754
- );
755
- }
756
- }
757
-
758
- // 0.5.x CR C-5 fix (leader msg_a89b5a03bbf0): factory returns to
759
- // pure assembly. The `transport.conpty_pipe_client_unwired`
760
- // notice is REMOVED from `build_conpty` — connect is deferred to
761
- // the backend's `ensure_pipe_client` lazy path, which surfaces
762
- // failures as `TransportError::MuxUnavailable` at Op call time
763
- // (not at resolve time).
764
- //
765
- // Cross-platform: resolve NEVER emits pipe-client notices on
766
- // either platform now. This test locks that invariant so a
767
- // future revert would fire loudly.
768
- #[test]
769
- fn conpty_resolve_emits_no_pipe_client_notice_after_c5_fix() {
770
- let workspace = ws();
771
- let state = serde_json::json!({
772
- "transport": {
773
- "kind": "conpty",
774
- "shim": {
775
- "pipe_name": r"\\.\pipe\team-agent-conpty-test-team-a",
776
- "pipe_ready": true
777
- },
778
- }
779
- });
780
- let input = TransportFactoryInput::new(&workspace, TransportPurpose::LifecycleWorker)
781
- .with_team_key(Some("team-a"))
782
- .with_state(Some(&state));
783
- let resolved = resolve_transport(input).expect("must succeed");
784
- assert_eq!(resolved.kind, BackendKind::ConPty);
785
- let pipe_notices: Vec<_> = resolved
786
- .notices
787
- .iter()
788
- .filter(|n| n.event == "transport.conpty_pipe_client_unwired")
789
- .collect();
790
- assert!(
791
- pipe_notices.is_empty(),
792
- "CR C-5 fix: resolve must not emit pipe-client notices \
793
- (connect deferred to backend lazy path). Found: {:?}",
794
- pipe_notices.iter().map(|n| &n.event).collect::<Vec<_>>()
795
- );
796
- }
797
-
798
- // Wire-string invariants for RequestedTransportBackend so a rename
799
- // in Rust cannot silently drift the CLI accept-list.
800
- #[test]
801
- fn requested_backend_wire_strings_are_pinned() {
802
- assert_eq!(RequestedTransportBackend::Tmux.as_wire(), "tmux");
803
- assert_eq!(RequestedTransportBackend::ConPty.as_wire(), "conpty");
804
- assert_eq!(
805
- RequestedTransportBackend::parse_literal("tmux"),
806
- Some(RequestedTransportBackend::Tmux)
807
- );
808
- assert_eq!(
809
- RequestedTransportBackend::parse_literal("conpty"),
810
- Some(RequestedTransportBackend::ConPty)
811
- );
812
- // pty is deliberately NOT parsed as ConPty at the wire level
813
- // either. The spec.runtime.backend layer handles the typed
814
- // refusal for the spec case; here we just prove the CLI
815
- // literal parser rejects it.
816
- assert_eq!(RequestedTransportBackend::parse_literal("pty"), None);
817
- assert_eq!(RequestedTransportBackend::parse_literal("nonsense"), None);
818
- }
819
- }