@team-agent/installer 0.5.127 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (421) hide show
  1. package/README.md +15 -4
  2. package/README.zh.md +1 -1
  3. package/package.json +4 -8
  4. package/skills/team-agent/SKILL.md +41 -26
  5. package/skills/team-agent/command-coverage.json +170 -184
  6. package/skills/team-agent/docs/reference/team-agent-operator.md +66 -32
  7. package/skills/team-agent/references/recovery-runbook.md +1 -1
  8. package/skills/team-agent/references/team-agent-operator.md +66 -32
  9. package/templates/team_state.md +1 -1
  10. package/Cargo.lock +0 -1063
  11. package/Cargo.toml +0 -36
  12. package/crates/team-agent/Cargo.toml +0 -69
  13. package/crates/team-agent/src/app_server_test_support.rs +0 -258
  14. package/crates/team-agent/src/cli/adapters.rs +0 -1298
  15. package/crates/team-agent/src/cli/arguments.rs +0 -401
  16. package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
  17. package/crates/team-agent/src/cli/diagnose.rs +0 -1675
  18. package/crates/team-agent/src/cli/emit.rs +0 -2898
  19. package/crates/team-agent/src/cli/grok_slot.rs +0 -384
  20. package/crates/team-agent/src/cli/helpers.rs +0 -91
  21. package/crates/team-agent/src/cli/intent/runtime.rs +0 -1189
  22. package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -821
  23. package/crates/team-agent/src/cli/intent/tests.rs +0 -691
  24. package/crates/team-agent/src/cli/intent.rs +0 -664
  25. package/crates/team-agent/src/cli/leader.rs +0 -300
  26. package/crates/team-agent/src/cli/leader_prompt.rs +0 -261
  27. package/crates/team-agent/src/cli/leaders.rs +0 -418
  28. package/crates/team-agent/src/cli/mod.rs +0 -6528
  29. package/crates/team-agent/src/cli/models.rs +0 -449
  30. package/crates/team-agent/src/cli/named_address.rs +0 -1651
  31. package/crates/team-agent/src/cli/profile.rs +0 -342
  32. package/crates/team-agent/src/cli/route.rs +0 -212
  33. package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
  34. package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
  35. package/crates/team-agent/src/cli/send/persist.rs +0 -192
  36. package/crates/team-agent/src/cli/send/presentation.rs +0 -370
  37. package/crates/team-agent/src/cli/send/resolve.rs +0 -573
  38. package/crates/team-agent/src/cli/send.rs +0 -201
  39. package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
  40. package/crates/team-agent/src/cli/spec.rs +0 -159
  41. package/crates/team-agent/src/cli/status.rs +0 -280
  42. package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
  43. package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
  44. package/crates/team-agent/src/cli/status_port/brief.rs +0 -2043
  45. package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
  46. package/crates/team-agent/src/cli/status_port/format.rs +0 -146
  47. package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
  48. package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
  49. package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
  50. package/crates/team-agent/src/cli/status_port/store.rs +0 -416
  51. package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
  52. package/crates/team-agent/src/cli/status_port.rs +0 -92
  53. package/crates/team-agent/src/cli/tests/base.rs +0 -885
  54. package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
  55. package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
  56. package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -372
  57. package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
  58. package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
  59. package/crates/team-agent/src/cli/tests/mod.rs +0 -137
  60. package/crates/team-agent/src/cli/tests/named_address.rs +0 -760
  61. package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
  62. package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -481
  63. package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
  64. package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
  65. package/crates/team-agent/src/cli/tests/status_send.rs +0 -1091
  66. package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
  67. package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
  68. package/crates/team-agent/src/cli/triage.rs +0 -234
  69. package/crates/team-agent/src/cli/types.rs +0 -591
  70. package/crates/team-agent/src/codex_app_server.rs +0 -546
  71. package/crates/team-agent/src/communication_mode/mod.rs +0 -56
  72. package/crates/team-agent/src/compiler/tests.rs +0 -842
  73. package/crates/team-agent/src/compiler.rs +0 -691
  74. package/crates/team-agent/src/conpty/backend.rs +0 -829
  75. package/crates/team-agent/src/conpty/mod.rs +0 -33
  76. package/crates/team-agent/src/contract_runtime/backend.rs +0 -1610
  77. package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
  78. package/crates/team-agent/src/contract_runtime/config.rs +0 -354
  79. package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -56
  80. package/crates/team-agent/src/contract_runtime/discovery.rs +0 -438
  81. package/crates/team-agent/src/contract_runtime/fork.rs +0 -368
  82. package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
  83. package/crates/team-agent/src/contract_runtime/framework.rs +0 -350
  84. package/crates/team-agent/src/contract_runtime/mcp.rs +0 -399
  85. package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
  86. package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
  87. package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
  88. package/crates/team-agent/src/contract_runtime/registry.rs +0 -589
  89. package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
  90. package/crates/team-agent/src/coordinator/backoff.rs +0 -741
  91. package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
  92. package/crates/team-agent/src/coordinator/health.rs +0 -1185
  93. package/crates/team-agent/src/coordinator/mod.rs +0 -119
  94. package/crates/team-agent/src/coordinator/orphan.rs +0 -110
  95. package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
  96. package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
  97. package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
  98. package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
  99. package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
  100. package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
  101. package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
  102. package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
  103. package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
  104. package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
  105. package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
  106. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -338
  107. package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
  108. package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
  109. package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
  110. package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -461
  111. package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
  112. package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
  113. package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
  114. package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
  115. package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
  116. package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
  117. package/crates/team-agent/src/coordinator/tick.rs +0 -3112
  118. package/crates/team-agent/src/coordinator/types.rs +0 -540
  119. package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
  120. package/crates/team-agent/src/db/message_store.rs +0 -1585
  121. package/crates/team-agent/src/db/migration.rs +0 -984
  122. package/crates/team-agent/src/db/mod.rs +0 -26
  123. package/crates/team-agent/src/db/schema.rs +0 -663
  124. package/crates/team-agent/src/diagnose/comms.rs +0 -242
  125. package/crates/team-agent/src/diagnose/mod.rs +0 -44
  126. package/crates/team-agent/src/diagnose/orphans.rs +0 -889
  127. package/crates/team-agent/src/event_log.rs +0 -502
  128. package/crates/team-agent/src/fake_worker.rs +0 -303
  129. package/crates/team-agent/src/kill_audit.rs +0 -106
  130. package/crates/team-agent/src/layout/manager.rs +0 -248
  131. package/crates/team-agent/src/layout/mod.rs +0 -36
  132. package/crates/team-agent/src/layout/overlay.rs +0 -134
  133. package/crates/team-agent/src/layout/placement.rs +0 -52
  134. package/crates/team-agent/src/layout/recovery.rs +0 -106
  135. package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
  136. package/crates/team-agent/src/layout/sessions.rs +0 -294
  137. package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
  138. package/crates/team-agent/src/layout/worker_env.rs +0 -721
  139. package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
  140. package/crates/team-agent/src/leader/helpers.rs +0 -178
  141. package/crates/team-agent/src/leader/incident.rs +0 -6
  142. package/crates/team-agent/src/leader/lease.rs +0 -3356
  143. package/crates/team-agent/src/leader/mod.rs +0 -104
  144. package/crates/team-agent/src/leader/owner_bind.rs +0 -400
  145. package/crates/team-agent/src/leader/prompt.rs +0 -905
  146. package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
  147. package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
  148. package/crates/team-agent/src/leader/rediscover.rs +0 -1192
  149. package/crates/team-agent/src/leader/registry.rs +0 -883
  150. package/crates/team-agent/src/leader/start.rs +0 -4500
  151. package/crates/team-agent/src/leader/takeover.rs +0 -65
  152. package/crates/team-agent/src/leader/tests/basics.rs +0 -337
  153. package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
  154. package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
  155. package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
  156. package/crates/team-agent/src/leader/tests/identity.rs +0 -465
  157. package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
  158. package/crates/team-agent/src/leader/tests/idle.rs +0 -113
  159. package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
  160. package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
  161. package/crates/team-agent/src/leader/tests/mod.rs +0 -106
  162. package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -267
  163. package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
  164. package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
  165. package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
  166. package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
  167. package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
  168. package/crates/team-agent/src/leader/types.rs +0 -534
  169. package/crates/team-agent/src/lib.rs +0 -145
  170. package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
  171. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -848
  172. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -393
  173. package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
  174. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -178
  175. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -82
  176. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -63
  177. package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
  178. package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
  179. package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
  180. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -152
  181. package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
  182. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -629
  183. package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -226
  184. package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
  185. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5176
  186. package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
  187. package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
  188. package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
  189. package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -450
  190. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
  191. package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
  192. package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
  193. package/crates/team-agent/src/lifecycle/launch.rs +0 -534
  194. package/crates/team-agent/src/lifecycle/lock.rs +0 -350
  195. package/crates/team-agent/src/lifecycle/mod.rs +0 -79
  196. package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
  197. package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -757
  198. package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
  199. package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2198
  200. package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2052
  201. package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
  202. package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
  203. package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
  204. package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
  205. package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
  206. package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
  207. package/crates/team-agent/src/lifecycle/restart.rs +0 -223
  208. package/crates/team-agent/src/lifecycle/role_config.rs +0 -1205
  209. package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
  210. package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
  211. package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
  212. package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
  213. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
  214. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -135
  215. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1415
  216. package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
  217. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -396
  218. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -418
  219. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2039
  220. package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1298
  221. package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
  222. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
  223. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
  224. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -71
  225. package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
  226. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
  227. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -472
  228. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
  229. package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
  230. package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
  231. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3981
  232. package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
  233. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
  234. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
  235. package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
  236. package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
  237. package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
  238. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -152
  239. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -182
  240. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -374
  241. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -546
  242. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -31
  243. package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -528
  244. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -134
  245. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -333
  246. package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
  247. package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
  248. package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
  249. package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
  250. package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
  251. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
  252. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
  253. package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
  254. package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
  255. package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
  256. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
  257. package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
  258. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -90
  259. package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
  260. package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
  261. package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
  262. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
  263. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
  264. package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
  265. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
  266. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -996
  267. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -827
  268. package/crates/team-agent/src/lifecycle/tests.rs +0 -102
  269. package/crates/team-agent/src/lifecycle/types.rs +0 -861
  270. package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -370
  271. package/crates/team-agent/src/main.rs +0 -52
  272. package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
  273. package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
  274. package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
  275. package/crates/team-agent/src/mcp_server/mod.rs +0 -119
  276. package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
  277. package/crates/team-agent/src/mcp_server/readiness.rs +0 -546
  278. package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -369
  279. package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
  280. package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
  281. package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -168
  282. package/crates/team-agent/src/mcp_server/tests/send.rs +0 -388
  283. package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -343
  284. package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
  285. package/crates/team-agent/src/mcp_server/tests.rs +0 -43
  286. package/crates/team-agent/src/mcp_server/tools.rs +0 -1015
  287. package/crates/team-agent/src/mcp_server/types.rs +0 -396
  288. package/crates/team-agent/src/mcp_server/wire.rs +0 -867
  289. package/crates/team-agent/src/messaging/activity.rs +0 -461
  290. package/crates/team-agent/src/messaging/address.rs +0 -87
  291. package/crates/team-agent/src/messaging/delivery.rs +0 -3785
  292. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
  293. package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
  294. package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
  295. package/crates/team-agent/src/messaging/helpers.rs +0 -354
  296. package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
  297. package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
  298. package/crates/team-agent/src/messaging/mod.rs +0 -166
  299. package/crates/team-agent/src/messaging/persist.rs +0 -377
  300. package/crates/team-agent/src/messaging/presentation.rs +0 -417
  301. package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
  302. package/crates/team-agent/src/messaging/results.rs +0 -1415
  303. package/crates/team-agent/src/messaging/scheduler.rs +0 -217
  304. package/crates/team-agent/src/messaging/selftest.rs +0 -315
  305. package/crates/team-agent/src/messaging/send.rs +0 -981
  306. package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
  307. package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -551
  308. package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
  309. package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
  310. package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
  311. package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
  312. package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
  313. package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3655
  314. package/crates/team-agent/src/messaging/tests/spine.rs +0 -837
  315. package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
  316. package/crates/team-agent/src/messaging/trust.rs +0 -215
  317. package/crates/team-agent/src/messaging/types.rs +0 -471
  318. package/crates/team-agent/src/messaging/wait.rs +0 -366
  319. package/crates/team-agent/src/messaging/watchers.rs +0 -916
  320. package/crates/team-agent/src/model/enums.rs +0 -356
  321. package/crates/team-agent/src/model/errors.rs +0 -18
  322. package/crates/team-agent/src/model/ids.rs +0 -165
  323. package/crates/team-agent/src/model/mod.rs +0 -29
  324. package/crates/team-agent/src/model/name_similarity.rs +0 -252
  325. package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
  326. package/crates/team-agent/src/model/paths.rs +0 -257
  327. package/crates/team-agent/src/model/routing.rs +0 -387
  328. package/crates/team-agent/src/model/spec.rs +0 -1184
  329. package/crates/team-agent/src/model/task_graph.rs +0 -321
  330. package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
  331. package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
  332. package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
  333. package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
  334. package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
  335. package/crates/team-agent/src/model/yaml/tests.rs +0 -188
  336. package/crates/team-agent/src/model/yaml.rs +0 -802
  337. package/crates/team-agent/src/os_probe.rs +0 -280
  338. package/crates/team-agent/src/packaging/install.rs +0 -219
  339. package/crates/team-agent/src/packaging/migrate.rs +0 -38
  340. package/crates/team-agent/src/packaging/mod.rs +0 -91
  341. package/crates/team-agent/src/packaging/repair.rs +0 -33
  342. package/crates/team-agent/src/packaging/tests.rs +0 -822
  343. package/crates/team-agent/src/packaging/types.rs +0 -417
  344. package/crates/team-agent/src/platform/argv.rs +0 -331
  345. package/crates/team-agent/src/platform/errors.rs +0 -104
  346. package/crates/team-agent/src/platform/file_lock.rs +0 -279
  347. package/crates/team-agent/src/platform/mod.rs +0 -5
  348. package/crates/team-agent/src/platform/process.rs +0 -545
  349. package/crates/team-agent/src/provider/adapter.rs +0 -898
  350. package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
  351. package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
  352. package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
  353. package/crates/team-agent/src/provider/adapters/mod.rs +0 -28
  354. package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
  355. package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
  356. package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
  357. package/crates/team-agent/src/provider/argv_route.rs +0 -405
  358. package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
  359. package/crates/team-agent/src/provider/classify.rs +0 -773
  360. package/crates/team-agent/src/provider/command_helpers.rs +0 -45
  361. package/crates/team-agent/src/provider/faults.rs +0 -165
  362. package/crates/team-agent/src/provider/helpers.rs +0 -52
  363. package/crates/team-agent/src/provider/mod.rs +0 -78
  364. package/crates/team-agent/src/provider/model_catalog.rs +0 -722
  365. package/crates/team-agent/src/provider/session/capture.rs +0 -2631
  366. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -168
  367. package/crates/team-agent/src/provider/session/context_fork.rs +0 -264
  368. package/crates/team-agent/src/provider/session/mod.rs +0 -36
  369. package/crates/team-agent/src/provider/session/resume.rs +0 -269
  370. package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
  371. package/crates/team-agent/src/provider/session_scan/common.rs +0 -618
  372. package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
  373. package/crates/team-agent/src/provider/session_scan/pi.rs +0 -152
  374. package/crates/team-agent/src/provider/session_scan.rs +0 -61
  375. package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
  376. package/crates/team-agent/src/provider/submit_now.rs +0 -71
  377. package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
  378. package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
  379. package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
  380. package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
  381. package/crates/team-agent/src/provider/tests/adapter.rs +0 -354
  382. package/crates/team-agent/src/provider/tests/classify.rs +0 -201
  383. package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -26
  384. package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
  385. package/crates/team-agent/src/provider/tests/faults.rs +0 -200
  386. package/crates/team-agent/src/provider/tests/idle.rs +0 -140
  387. package/crates/team-agent/src/provider/tests/wire.rs +0 -213
  388. package/crates/team-agent/src/provider/tests.rs +0 -32
  389. package/crates/team-agent/src/provider/types.rs +0 -529
  390. package/crates/team-agent/src/provider/wire.rs +0 -406
  391. package/crates/team-agent/src/redaction.rs +0 -259
  392. package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
  393. package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
  394. package/crates/team-agent/src/state/identity.rs +0 -914
  395. package/crates/team-agent/src/state/identity_keys.rs +0 -132
  396. package/crates/team-agent/src/state/mod.rs +0 -74
  397. package/crates/team-agent/src/state/owner_gate.rs +0 -482
  398. package/crates/team-agent/src/state/ownership.rs +0 -563
  399. package/crates/team-agent/src/state/paths.rs +0 -395
  400. package/crates/team-agent/src/state/persist.rs +0 -3811
  401. package/crates/team-agent/src/state/projection.rs +0 -1508
  402. package/crates/team-agent/src/state/repository/intent.rs +0 -14
  403. package/crates/team-agent/src/state/repository/tests.rs +0 -184
  404. package/crates/team-agent/src/state/repository.rs +0 -866
  405. package/crates/team-agent/src/state/selector.rs +0 -160
  406. package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
  407. package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
  408. package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
  409. package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
  410. package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
  411. package/crates/team-agent/src/tmux_backend/tests.rs +0 -4254
  412. package/crates/team-agent/src/tmux_backend.rs +0 -4527
  413. package/crates/team-agent/src/topology.rs +0 -537
  414. package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
  415. package/crates/team-agent/src/transport/native_input.rs +0 -491
  416. package/crates/team-agent/src/transport/test_support.rs +0 -743
  417. package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
  418. package/crates/team-agent/src/transport/tests/mod.rs +0 -194
  419. package/crates/team-agent/src/transport/tests/wire.rs +0 -574
  420. package/crates/team-agent/src/transport.rs +0 -1655
  421. package/crates/team-agent/src/transport_factory.rs +0 -819
@@ -1,721 +0,0 @@
1
- //!
2
- //! 0.3.28 layout step 3 — worker spawn env (inherit-then-strip) + worker
3
- //! spawn cwd (YAML-only).
4
- //!
5
- //! Python truth source actual behavior (`providers.py:130-145` + contract
6
- //! test `worker_spawn_env_red`): worker env INHERITS the parent
7
- //! `team-agent` process environment (proxy / CA / PATH / random user
8
- //! vars like `NODE_EXTRA_CA_CERTS`) just like the user typing `codex`
9
- //! in the same terminal, then OVERLAYS the Team Agent identity
10
- //! (`TEAM_AGENT_WORKSPACE`, `TEAM_AGENT_ID`, `TEAM_AGENT_AGENT_ID`,
11
- //! `TEAM_AGENT_OWNER_TEAM_ID`).
12
- //!
13
- //! The leader's identity-specific env vars (`TEAM_AGENT_LEADER_*`,
14
- //! `TEAM_AGENT_MACHINE_FINGERPRINT`, `TEAM_AGENT_TEAM_ID`,
15
- //! `COPILOT_DISABLE_TERMINAL_TITLE`, `TMUX`, `TMUX_PANE`) are STRIPPED
16
- //! to prevent E60 identity contamination.
17
- //!
18
- //! Pre-0.3.28-final used a WHITELIST (only specific keys pass through)
19
- //! which broke `worker_spawn_env_red` by dropping legitimate user env
20
- //! (`NODE_EXTRA_CA_CERTS`, etc.). Switched to inherit-then-strip per
21
- //! leader verdict.
22
- //!
23
- //! Python uses `workspace` as the spawn cwd unconditionally; no
24
- //! per-agent override field exists in the spec. Rust pre-0.3.28 honoured
25
- //! `agent.spawn_cwd` from STATE which drifts (E56). Step 3 reads only
26
- //! YAML `spec.agent.spawn_cwd` and falls through to `workspace`.
27
-
28
- use std::collections::BTreeMap;
29
- use std::path::{Path, PathBuf};
30
-
31
- use crate::model::yaml::Value as YamlValue;
32
- use crate::provider::wire::{parse_provider, provider_wire};
33
- use crate::provider::Provider;
34
-
35
- /// Current worker caller context is deliberately separate from `TEAM_AGENT_LEADER_*`.
36
- /// The launcher writes only the typed provider; the tmux invocation boundary adds the
37
- /// actual pane and socket for the provider command itself.
38
- pub(crate) const CALLER_CONTEXT_PREFIX: &str = "TEAM_AGENT_CALLER_";
39
- pub(crate) const CALLER_PROVIDER_ENV: &str = "TEAM_AGENT_CALLER_PROVIDER";
40
- pub(crate) const CALLER_PANE_ENV: &str = "TEAM_AGENT_CALLER_PANE_ID";
41
- pub(crate) const CALLER_ENDPOINT_ENV: &str = "TEAM_AGENT_CALLER_TMUX_ENDPOINT";
42
-
43
- #[derive(Debug, Clone, Copy, PartialEq, Eq)]
44
- pub(crate) enum CallerProviderResolution {
45
- Absent,
46
- Valid(Provider),
47
- Invalid,
48
- }
49
-
50
- /// Env-key PREFIXES that are stripped from the inherited parent env
51
- /// before worker spawn. These carry leader-process identity and must
52
- /// not leak into worker provider TUIs (E60 root cause).
53
- const STRIP_PREFIXES: &[&str] = &[
54
- "TEAM_AGENT_LEADER_",
55
- "TEAM_AGENT_LEADER_BYPASS",
56
- "TEAM_AGENT_MACHINE_FINGERPRINT",
57
- CALLER_CONTEXT_PREFIX,
58
- ];
59
-
60
- /// Exact env-keys stripped from the inherited parent env.
61
- const STRIP_EXACT: &[&str] = &[
62
- // The leader's team_id; the worker's TEAM_AGENT_OWNER_TEAM_ID overlay
63
- // re-supplies the relevant scope.
64
- "TEAM_AGENT_TEAM_ID",
65
- // Suppresses copilot's title-rewrite — must be re-injected by
66
- // `apply_copilot_instructions_overlay` based on per-agent provider,
67
- // not inherited from the leader's provider.
68
- "COPILOT_DISABLE_TERMINAL_TITLE",
69
- // TMUX env points at the leader's pane — would attach the worker to it.
70
- "TMUX",
71
- "TMUX_PANE",
72
- ];
73
-
74
- const WORKER_IDENTITY_EXACT: &[&str] = &["CLAUDECODE", "CLAUDE_EFFORT", "CODEX_THREAD_ID"];
75
-
76
- const WORKER_IDENTITY_PREFIXES: &[&str] = &["CLAUDE_CODE_"];
77
-
78
- ///
79
- /// Build the worker spawn env per Python inherit-then-strip semantics.
80
- ///
81
- /// Inputs:
82
- /// * `parent_env`: the team-agent process env (typically
83
- /// `std::env::vars()`). The whole env is inherited then filtered.
84
- /// * `workspace`: the team workspace root.
85
- /// * `agent_id`: this worker's agent_id.
86
- /// * `team_id`: optional owner team id.
87
- ///
88
- /// Output: a `BTreeMap` containing:
89
- /// * All POSIX-valid shell identifier keys from `parent_env` EXCEPT
90
- /// those matching `STRIP_PREFIXES` / `STRIP_EXACT`.
91
- /// * Overlay: `TEAM_AGENT_WORKSPACE`, `TEAM_AGENT_ID`,
92
- /// `TEAM_AGENT_AGENT_ID`, `TEAM_AGENT_OWNER_TEAM_ID` (when present),
93
- /// `TEAM_AGENT_AUTH_MODE` (when present).
94
- ///
95
- /// POSIX-validity filter: shell variable names must match
96
- /// `[A-Za-z_][A-Za-z0-9_]*`. Cargo's integration-test runner exports keys
97
- /// like `CARGO_BIN_EXE_team-agent` that contain a dash — those would
98
- /// break `sh -lc KEY=val` assignment and are dropped.
99
- pub fn worker_spawn_env<I>(
100
- parent_env: I,
101
- workspace: &Path,
102
- agent_id: &str,
103
- team_id: Option<&str>,
104
- auth_mode: Option<&str>,
105
- ) -> BTreeMap<String, String>
106
- where
107
- I: IntoIterator<Item = (String, String)>,
108
- {
109
- let mut env: BTreeMap<String, String> = BTreeMap::new();
110
- for (k, v) in parent_env {
111
- if is_stripped(&k) {
112
- continue;
113
- }
114
- if !is_posix_shell_identifier(&k) {
115
- continue;
116
- }
117
- env.insert(k, v);
118
- }
119
- env.insert(
120
- "TEAM_AGENT_WORKSPACE".to_string(),
121
- workspace.to_string_lossy().to_string(),
122
- );
123
- env.insert("TEAM_AGENT_ID".to_string(), agent_id.to_string());
124
- env.insert("TEAM_AGENT_AGENT_ID".to_string(), agent_id.to_string());
125
- if let Some(tid) = team_id.filter(|s| !s.is_empty()) {
126
- env.insert("TEAM_AGENT_OWNER_TEAM_ID".to_string(), tid.to_string());
127
- }
128
- if let Some(auth) = auth_mode.filter(|s| !s.is_empty()) {
129
- env.insert("TEAM_AGENT_AUTH_MODE".to_string(), auth.to_string());
130
- }
131
- env
132
- }
133
-
134
- /// Overlay the final typed provider after profile/env overlays. Any inherited or
135
- /// profile-supplied caller namespace is discarded before this fresh value is written.
136
- pub(crate) fn inject_current_caller_provider(
137
- env: &mut BTreeMap<String, String>,
138
- provider: Provider,
139
- ) {
140
- env.retain(|key, _| !key.starts_with(CALLER_CONTEXT_PREFIX));
141
- env.insert(
142
- CALLER_PROVIDER_ENV.to_string(),
143
- provider_wire(provider).to_string(),
144
- );
145
- }
146
-
147
- /// Resolve the narrow caller context used by both initial-state seeding and fresh bind.
148
- /// `current_*` come from the invoking process; `scoped_endpoint` comes from the selected
149
- /// transport. A partial, malformed, stale, or conflicting context is never downgraded to
150
- /// command attribution.
151
- pub(crate) fn caller_provider_resolution(
152
- current_pane: Option<&str>,
153
- current_endpoint: Option<&str>,
154
- scoped_endpoint: Option<&str>,
155
- ) -> CallerProviderResolution {
156
- let provider = std::env::var(CALLER_PROVIDER_ENV).ok();
157
- let context_pane = std::env::var(CALLER_PANE_ENV).ok();
158
- let context_endpoint = std::env::var(CALLER_ENDPOINT_ENV).ok();
159
- let explicit_provider = std::env::var("TEAM_AGENT_LEADER_PROVIDER").ok();
160
- let explicit_pane = std::env::var("TEAM_AGENT_LEADER_PANE_ID").ok();
161
- caller_provider_resolution_from_values(
162
- provider.as_deref(),
163
- context_pane.as_deref(),
164
- context_endpoint.as_deref(),
165
- explicit_provider.as_deref(),
166
- explicit_pane.as_deref(),
167
- current_pane,
168
- current_endpoint,
169
- scoped_endpoint,
170
- )
171
- }
172
-
173
- pub(crate) fn caller_provider_resolution_from_values(
174
- provider_raw: Option<&str>,
175
- context_pane: Option<&str>,
176
- context_endpoint: Option<&str>,
177
- explicit_provider: Option<&str>,
178
- explicit_pane: Option<&str>,
179
- current_pane: Option<&str>,
180
- current_endpoint: Option<&str>,
181
- scoped_endpoint: Option<&str>,
182
- ) -> CallerProviderResolution {
183
- if provider_raw.is_none() && context_pane.is_none() && context_endpoint.is_none() {
184
- return CallerProviderResolution::Absent;
185
- }
186
- let Some(provider_raw) = provider_raw.filter(|value| !value.is_empty()) else {
187
- return CallerProviderResolution::Invalid;
188
- };
189
- let Some(provider) = parse_provider(provider_raw) else {
190
- return CallerProviderResolution::Invalid;
191
- };
192
- let Some(context_pane) = context_pane.filter(|value| !value.is_empty()) else {
193
- return CallerProviderResolution::Invalid;
194
- };
195
- let Some(context_endpoint) = context_endpoint.filter(|value| !value.is_empty()) else {
196
- return CallerProviderResolution::Invalid;
197
- };
198
- if !valid_tmux_pane(context_pane)
199
- || !valid_tmux_endpoint(context_endpoint)
200
- || current_pane != Some(context_pane)
201
- || current_endpoint != Some(context_endpoint)
202
- || scoped_endpoint != Some(context_endpoint)
203
- {
204
- return CallerProviderResolution::Invalid;
205
- }
206
- if let Some(explicit) = explicit_provider.filter(|value| !value.is_empty()) {
207
- if parse_provider(explicit) != Some(provider) {
208
- return CallerProviderResolution::Invalid;
209
- }
210
- }
211
- if let Some(explicit_pane) = explicit_pane.filter(|value| !value.is_empty()) {
212
- if explicit_pane != context_pane {
213
- return CallerProviderResolution::Invalid;
214
- }
215
- }
216
- CallerProviderResolution::Valid(provider)
217
- }
218
-
219
- fn valid_tmux_pane(value: &str) -> bool {
220
- value.strip_prefix('%').is_some_and(|digits| {
221
- !digits.is_empty() && digits.bytes().all(|byte| byte.is_ascii_digit())
222
- })
223
- }
224
-
225
- fn valid_tmux_endpoint(value: &str) -> bool {
226
- value.starts_with('/') && !value.contains(',')
227
- }
228
-
229
- pub(crate) fn isolate_worker_spawn_env(
230
- _target_provider: Provider,
231
- env: &mut BTreeMap<String, String>,
232
- base_env_unset: impl IntoIterator<Item = String>,
233
- ) -> Vec<String> {
234
- let mut env_unset = base_env_unset
235
- .into_iter()
236
- .collect::<std::collections::BTreeSet<_>>();
237
- // Clear any stale values held by the tmux server before the scoped provider
238
- // invocation assigns the fresh context. The inert shell tail must not retain it.
239
- for key in [CALLER_PROVIDER_ENV, CALLER_PANE_ENV, CALLER_ENDPOINT_ENV] {
240
- env.remove(key);
241
- env_unset.insert(key.to_string());
242
- }
243
- for key in WORKER_IDENTITY_EXACT {
244
- env.remove(*key);
245
- env_unset.insert((*key).to_string());
246
- }
247
- let dynamic_keys = env
248
- .keys()
249
- .filter(|key| is_worker_identity_key(key))
250
- .cloned()
251
- .collect::<Vec<_>>();
252
- for key in dynamic_keys {
253
- env.remove(&key);
254
- env_unset.insert(key);
255
- }
256
- env_unset.into_iter().collect()
257
- }
258
-
259
- fn is_stripped(key: &str) -> bool {
260
- if STRIP_EXACT.iter().any(|exact| *exact == key) {
261
- return true;
262
- }
263
- if STRIP_PREFIXES.iter().any(|p| key.starts_with(p)) {
264
- return true;
265
- }
266
- false
267
- }
268
-
269
- fn is_worker_identity_key(key: &str) -> bool {
270
- WORKER_IDENTITY_PREFIXES
271
- .iter()
272
- .any(|prefix| key.starts_with(prefix))
273
- }
274
-
275
- fn is_posix_shell_identifier(s: &str) -> bool {
276
- let mut bytes = s.bytes();
277
- let Some(first) = bytes.next() else {
278
- return false;
279
- };
280
- if !(first.is_ascii_alphabetic() || first == b'_') {
281
- return false;
282
- }
283
- bytes.all(|b| b.is_ascii_alphanumeric() || b == b'_')
284
- }
285
-
286
- ///
287
- /// Compute worker spawn cwd per Python semantics: YAML
288
- /// `agent.spawn_cwd` if set, else `workspace`. The persisted-state
289
- /// `agent.spawn_cwd` override (the pre-0.3.28 Rust extension that caused
290
- /// E56 drift) is NOT consulted.
291
- pub fn worker_spawn_cwd(spec_agent: &YamlValue, workspace: &Path) -> PathBuf {
292
- spec_agent
293
- .get("spawn_cwd")
294
- .and_then(YamlValue::as_str)
295
- .filter(|s| !s.is_empty())
296
- .map(PathBuf::from)
297
- .unwrap_or_else(|| workspace.to_path_buf())
298
- }
299
-
300
- #[cfg(test)]
301
- mod tests {
302
- use super::*;
303
-
304
- fn make_parent_env(extras: &[(&str, &str)]) -> Vec<(String, String)> {
305
- let mut env = vec![
306
- ("PATH".to_string(), "/usr/bin:/bin".to_string()),
307
- ("HOME".to_string(), "/Users/test".to_string()),
308
- ("TERM".to_string(), "xterm-256color".to_string()),
309
- ("CLAUDE_API_KEY".to_string(), "sk-test".to_string()),
310
- ("OPENAI_API_KEY".to_string(), "sk-test".to_string()),
311
- ("COPILOT_TOKEN".to_string(), "tok".to_string()),
312
- // Leader identity — must be stripped.
313
- (
314
- "TEAM_AGENT_LEADER_PROVIDER".to_string(),
315
- "claude".to_string(),
316
- ),
317
- (
318
- "TEAM_AGENT_LEADER_SESSION_UUID".to_string(),
319
- "leader-uuid".to_string(),
320
- ),
321
- (
322
- "TEAM_AGENT_MACHINE_FINGERPRINT".to_string(),
323
- "fp".to_string(),
324
- ),
325
- ("TEAM_AGENT_TEAM_ID".to_string(), "alpha".to_string()),
326
- ("TEAM_AGENT_LEADER_BYPASS".to_string(), "1".to_string()),
327
- (
328
- "COPILOT_DISABLE_TERMINAL_TITLE".to_string(),
329
- "1".to_string(),
330
- ),
331
- // Random noise — non-whitelisted prefix.
332
- ("RANDOM_NOISE".to_string(), "x".to_string()),
333
- ("TMUX".to_string(), "leader-pane".to_string()),
334
- ("TMUX_PANE".to_string(), "%0".to_string()),
335
- ];
336
- for (k, v) in extras {
337
- env.push((k.to_string(), v.to_string()));
338
- }
339
- env
340
- }
341
-
342
- #[test]
343
- fn worker_spawn_env_strips_leader_identity_keys() {
344
- let env = worker_spawn_env(
345
- make_parent_env(&[]),
346
- Path::new("/ws"),
347
- "developer",
348
- Some("alpha"),
349
- None,
350
- );
351
- for stripped in [
352
- "TEAM_AGENT_LEADER_PROVIDER",
353
- "TEAM_AGENT_LEADER_SESSION_UUID",
354
- "TEAM_AGENT_MACHINE_FINGERPRINT",
355
- "TEAM_AGENT_TEAM_ID",
356
- "TEAM_AGENT_LEADER_BYPASS",
357
- "COPILOT_DISABLE_TERMINAL_TITLE",
358
- "TMUX",
359
- "TMUX_PANE",
360
- ] {
361
- assert!(
362
- !env.contains_key(stripped),
363
- "worker env must not contain leader identity key `{stripped}`; env={env:?}"
364
- );
365
- }
366
- }
367
-
368
- #[test]
369
- fn worker_spawn_env_injects_agent_workspace_and_team_keys() {
370
- let env = worker_spawn_env(
371
- make_parent_env(&[]),
372
- Path::new("/ws"),
373
- "developer",
374
- Some("alpha"),
375
- Some("subscription"),
376
- );
377
- assert_eq!(
378
- env.get("TEAM_AGENT_ID").map(String::as_str),
379
- Some("developer")
380
- );
381
- assert_eq!(
382
- env.get("TEAM_AGENT_AGENT_ID").map(String::as_str),
383
- Some("developer")
384
- );
385
- assert_eq!(
386
- env.get("TEAM_AGENT_WORKSPACE").map(String::as_str),
387
- Some("/ws")
388
- );
389
- assert_eq!(
390
- env.get("TEAM_AGENT_OWNER_TEAM_ID").map(String::as_str),
391
- Some("alpha")
392
- );
393
- assert_eq!(
394
- env.get("TEAM_AGENT_AUTH_MODE").map(String::as_str),
395
- Some("subscription")
396
- );
397
- }
398
-
399
- #[test]
400
- fn worker_spawn_env_inherits_parent_env_minus_strip_list() {
401
- let env = worker_spawn_env(
402
- make_parent_env(&[]),
403
- Path::new("/ws"),
404
- "developer",
405
- None,
406
- None,
407
- );
408
- // Inherit-then-strip: every parent key passes through EXCEPT the
409
- // strip list. PATH-like + provider creds + random user vars all
410
- // present.
411
- assert!(env.contains_key("PATH"));
412
- assert!(env.contains_key("HOME"));
413
- assert!(env.contains_key("TERM"));
414
- assert!(env.contains_key("CLAUDE_API_KEY"));
415
- assert!(env.contains_key("OPENAI_API_KEY"));
416
- // Random user env (e.g. NODE_EXTRA_CA_CERTS, TA_SPAWN_ENV_CANARY)
417
- // MUST pass through — this was the worker_spawn_env_red contract
418
- // that the pre-final whitelist approach broke.
419
- assert!(
420
- env.contains_key("RANDOM_NOISE"),
421
- "0.3.28 final: worker env inherits parent — random user vars \
422
- must pass through (NODE_EXTRA_CA_CERTS / TA_SPAWN_ENV_CANARY \
423
- contract). Got env={env:?}"
424
- );
425
- }
426
-
427
- #[test]
428
- fn worker_spawn_env_drops_posix_invalid_keys() {
429
- let parent = make_parent_env(&[("CARGO_BIN_EXE_team-agent", "/bin/x")]);
430
- let env = worker_spawn_env(parent, Path::new("/ws"), "developer", None, None);
431
- assert!(!env.contains_key("CARGO_BIN_EXE_team-agent"));
432
- }
433
-
434
- #[test]
435
- fn worker_spawn_env_strips_inherited_caller_context() {
436
- let parent = make_parent_env(&[
437
- (CALLER_PROVIDER_ENV, "claude"),
438
- (CALLER_PANE_ENV, "%1"),
439
- (CALLER_ENDPOINT_ENV, "/tmp/old-tmux.sock"),
440
- ]);
441
- let env = worker_spawn_env(parent, Path::new("/ws"), "developer", None, None);
442
- assert!(!env.keys().any(|key| key.starts_with(CALLER_CONTEXT_PREFIX)));
443
- }
444
-
445
- #[test]
446
- fn inject_current_caller_provider_overwrites_namespace_from_final_provider() {
447
- let mut env = BTreeMap::from([
448
- (CALLER_PROVIDER_ENV.to_string(), "claude".to_string()),
449
- (CALLER_PANE_ENV.to_string(), "%1".to_string()),
450
- ("PATH".to_string(), "/usr/bin".to_string()),
451
- ]);
452
- inject_current_caller_provider(&mut env, Provider::Pi);
453
- assert_eq!(env.get(CALLER_PROVIDER_ENV).map(String::as_str), Some("pi"));
454
- assert!(!env.contains_key(CALLER_PANE_ENV));
455
- assert_eq!(env.get("PATH").map(String::as_str), Some("/usr/bin"));
456
- }
457
-
458
- #[test]
459
- fn isolate_worker_spawn_env_clears_context_from_outer_shell() {
460
- let mut env = BTreeMap::from([(CALLER_PROVIDER_ENV.to_string(), "pi".to_string())]);
461
- let unset = isolate_worker_spawn_env(Provider::Pi, &mut env, Vec::<String>::new());
462
- assert!(!env.contains_key(CALLER_PROVIDER_ENV));
463
- assert!(unset.iter().any(|key| key == CALLER_PROVIDER_ENV));
464
- assert!(unset.iter().any(|key| key == CALLER_PANE_ENV));
465
- assert!(unset.iter().any(|key| key == CALLER_ENDPOINT_ENV));
466
- }
467
-
468
- #[test]
469
- fn caller_context_requires_exact_current_pane_and_endpoint() {
470
- let resolution = caller_provider_resolution_from_values(
471
- Some("pi"),
472
- Some("%1"),
473
- Some("/tmp/tmux.sock"),
474
- None,
475
- None,
476
- Some("%1"),
477
- Some("/tmp/tmux.sock"),
478
- Some("/tmp/tmux.sock"),
479
- );
480
- assert_eq!(resolution, CallerProviderResolution::Valid(Provider::Pi));
481
- assert_eq!(
482
- caller_provider_resolution_from_values(
483
- Some("pi"),
484
- Some("%1"),
485
- Some("/tmp/tmux.sock"),
486
- None,
487
- None,
488
- Some("%2"),
489
- Some("/tmp/tmux.sock"),
490
- Some("/tmp/tmux.sock"),
491
- ),
492
- CallerProviderResolution::Invalid
493
- );
494
- assert_eq!(
495
- caller_provider_resolution_from_values(
496
- Some("pi"),
497
- Some("%1"),
498
- Some("/tmp/tmux.sock"),
499
- Some("codex"),
500
- None,
501
- Some("%1"),
502
- Some("/tmp/tmux.sock"),
503
- Some("/tmp/tmux.sock"),
504
- ),
505
- CallerProviderResolution::Invalid
506
- );
507
- }
508
-
509
- #[test]
510
- fn caller_context_absent_empty_and_malformed_cases_are_distinct() {
511
- assert_eq!(
512
- caller_provider_resolution_from_values(
513
- None,
514
- None,
515
- None,
516
- None,
517
- None,
518
- Some("%1"),
519
- Some("/tmp/tmux.sock"),
520
- Some("/tmp/tmux.sock"),
521
- ),
522
- CallerProviderResolution::Absent
523
- );
524
- assert_eq!(
525
- caller_provider_resolution_from_values(
526
- Some(""),
527
- None,
528
- None,
529
- None,
530
- None,
531
- Some("%1"),
532
- Some("/tmp/tmux.sock"),
533
- Some("/tmp/tmux.sock"),
534
- ),
535
- CallerProviderResolution::Invalid
536
- );
537
- assert_eq!(
538
- caller_provider_resolution_from_values(
539
- Some("pi"),
540
- Some(""),
541
- Some("/tmp/tmux.sock"),
542
- None,
543
- None,
544
- Some("%1"),
545
- Some("/tmp/tmux.sock"),
546
- Some("/tmp/tmux.sock"),
547
- ),
548
- CallerProviderResolution::Invalid
549
- );
550
- assert_eq!(
551
- caller_provider_resolution_from_values(
552
- Some("pi"),
553
- Some("%1"),
554
- Some(""),
555
- None,
556
- None,
557
- Some("%1"),
558
- Some("/tmp/tmux.sock"),
559
- Some("/tmp/tmux.sock"),
560
- ),
561
- CallerProviderResolution::Invalid
562
- );
563
- assert_eq!(
564
- caller_provider_resolution_from_values(
565
- Some("not-a-provider"),
566
- Some("%1"),
567
- Some("/tmp/tmux.sock"),
568
- None,
569
- None,
570
- Some("%1"),
571
- Some("/tmp/tmux.sock"),
572
- Some("/tmp/tmux.sock"),
573
- ),
574
- CallerProviderResolution::Invalid
575
- );
576
- assert_eq!(
577
- caller_provider_resolution_from_values(
578
- Some("pi"),
579
- Some("1"),
580
- Some("/tmp/tmux.sock"),
581
- None,
582
- None,
583
- Some("1"),
584
- Some("/tmp/tmux.sock"),
585
- Some("/tmp/tmux.sock"),
586
- ),
587
- CallerProviderResolution::Invalid
588
- );
589
- assert_eq!(
590
- caller_provider_resolution_from_values(
591
- Some("pi"),
592
- Some("%1"),
593
- Some("tmux.sock"),
594
- None,
595
- None,
596
- Some("%1"),
597
- Some("tmux.sock"),
598
- Some("tmux.sock"),
599
- ),
600
- CallerProviderResolution::Invalid
601
- );
602
- assert_eq!(
603
- caller_provider_resolution_from_values(
604
- Some("pi"),
605
- Some("%1"),
606
- Some("/tmp/tmux.sock,0"),
607
- None,
608
- None,
609
- Some("%1"),
610
- Some("/tmp/tmux.sock,0"),
611
- Some("/tmp/tmux.sock,0"),
612
- ),
613
- CallerProviderResolution::Invalid
614
- );
615
- assert_eq!(
616
- caller_provider_resolution_from_values(
617
- Some("pi"),
618
- Some("%1"),
619
- Some("/tmp/tmux.sock"),
620
- None,
621
- None,
622
- Some("%1"),
623
- Some("/tmp/other.sock"),
624
- Some("/tmp/tmux.sock"),
625
- ),
626
- CallerProviderResolution::Invalid
627
- );
628
- assert_eq!(
629
- caller_provider_resolution_from_values(
630
- Some("pi"),
631
- Some("%1"),
632
- Some("/tmp/tmux.sock"),
633
- None,
634
- None,
635
- Some("%1"),
636
- Some("/tmp/tmux.sock"),
637
- Some("/tmp/product.sock"),
638
- ),
639
- CallerProviderResolution::Invalid
640
- );
641
- assert_eq!(
642
- caller_provider_resolution_from_values(
643
- Some("pi"),
644
- Some("%1"),
645
- Some("/tmp/tmux.sock"),
646
- None,
647
- None,
648
- Some("%1"),
649
- Some("/tmp/tmux.sock"),
650
- None,
651
- ),
652
- CallerProviderResolution::Invalid
653
- );
654
- assert_eq!(
655
- caller_provider_resolution_from_values(
656
- Some("pi"),
657
- Some("%1"),
658
- Some("/tmp/tmux.sock"),
659
- None,
660
- Some("%2"),
661
- Some("%1"),
662
- Some("/tmp/tmux.sock"),
663
- Some("/tmp/tmux.sock"),
664
- ),
665
- CallerProviderResolution::Invalid
666
- );
667
- assert_eq!(
668
- caller_provider_resolution_from_values(
669
- Some("pi"),
670
- Some("%1"),
671
- Some("/tmp/tmux.sock"),
672
- Some("pi"),
673
- Some("%1"),
674
- Some("%1"),
675
- Some("/tmp/tmux.sock"),
676
- Some("/tmp/tmux.sock"),
677
- ),
678
- CallerProviderResolution::Valid(Provider::Pi)
679
- );
680
- }
681
-
682
- #[test]
683
- fn worker_spawn_cwd_returns_workspace_when_no_spec_override() {
684
- // YAML agent with no spawn_cwd field.
685
- let agent = YamlValue::Map(vec![(
686
- "id".to_string(),
687
- YamlValue::Str("developer".to_string()),
688
- )]);
689
- assert_eq!(
690
- worker_spawn_cwd(&agent, Path::new("/ws")),
691
- PathBuf::from("/ws")
692
- );
693
- }
694
-
695
- #[test]
696
- fn worker_spawn_cwd_returns_yaml_override_when_present() {
697
- let agent = YamlValue::Map(vec![
698
- ("id".to_string(), YamlValue::Str("developer".to_string())),
699
- (
700
- "spawn_cwd".to_string(),
701
- YamlValue::Str("/explicit/cwd".to_string()),
702
- ),
703
- ]);
704
- assert_eq!(
705
- worker_spawn_cwd(&agent, Path::new("/ws")),
706
- PathBuf::from("/explicit/cwd")
707
- );
708
- }
709
-
710
- #[test]
711
- fn worker_spawn_cwd_returns_workspace_when_spec_override_is_empty() {
712
- let agent = YamlValue::Map(vec![
713
- ("id".to_string(), YamlValue::Str("developer".to_string())),
714
- ("spawn_cwd".to_string(), YamlValue::Str("".to_string())),
715
- ]);
716
- assert_eq!(
717
- worker_spawn_cwd(&agent, Path::new("/ws")),
718
- PathBuf::from("/ws")
719
- );
720
- }
721
- }