@team-agent/installer 0.5.61 → 0.5.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/Cargo.lock +1 -1
  2. package/Cargo.toml +1 -1
  3. package/crates/team-agent/src/cli/adapters.rs +5 -2
  4. package/crates/team-agent/src/cli/attach_app_server_leader.rs +1 -0
  5. package/crates/team-agent/src/cli/diagnose.rs +1 -0
  6. package/crates/team-agent/src/cli/emit.rs +41 -7
  7. package/crates/team-agent/src/cli/helpers.rs +1 -0
  8. package/crates/team-agent/src/cli/leader.rs +6 -1
  9. package/crates/team-agent/src/cli/leaders.rs +2 -0
  10. package/crates/team-agent/src/cli/mod.rs +33 -3
  11. package/crates/team-agent/src/cli/named_address.rs +8 -1
  12. package/crates/team-agent/src/cli/profile.rs +2 -1
  13. package/crates/team-agent/src/cli/send/coordinator.rs +1 -0
  14. package/crates/team-agent/src/cli/send/mailbox.rs +3 -0
  15. package/crates/team-agent/src/cli/send/persist.rs +1 -0
  16. package/crates/team-agent/src/cli/send/presentation.rs +1 -0
  17. package/crates/team-agent/src/cli/send/resolve.rs +206 -1
  18. package/crates/team-agent/src/cli/send.rs +2 -1
  19. package/crates/team-agent/src/cli/spec.rs +1 -0
  20. package/crates/team-agent/src/cli/status.rs +2 -1
  21. package/crates/team-agent/src/cli/status_port/compact.rs +1 -0
  22. package/crates/team-agent/src/cli/status_port/format.rs +1 -0
  23. package/crates/team-agent/src/cli/status_port/inbox.rs +1 -0
  24. package/crates/team-agent/src/cli/tests/verb_profile.rs +38 -0
  25. package/crates/team-agent/src/cli/types.rs +3 -2
  26. package/crates/team-agent/src/communication_mode/mod.rs +1 -0
  27. package/crates/team-agent/src/compiler.rs +1 -0
  28. package/crates/team-agent/src/conpty/backend.rs +1 -0
  29. package/crates/team-agent/src/conpty/mod.rs +1 -0
  30. package/crates/team-agent/src/coordinator/backoff.rs +5 -8
  31. package/crates/team-agent/src/coordinator/conpty_shim.rs +3 -2
  32. package/crates/team-agent/src/coordinator/health.rs +1 -0
  33. package/crates/team-agent/src/coordinator/mod.rs +2 -2
  34. package/crates/team-agent/src/coordinator/orphan.rs +4 -116
  35. package/crates/team-agent/src/coordinator/runtime_detectors.rs +1 -0
  36. package/crates/team-agent/src/coordinator/runtime_observation.rs +1 -0
  37. package/crates/team-agent/src/coordinator/steps/abnormal.rs +15 -866
  38. package/crates/team-agent/src/coordinator/steps/delivery.rs +1 -0
  39. package/crates/team-agent/src/coordinator/steps/health_sync.rs +1 -0
  40. package/crates/team-agent/src/coordinator/steps/mod.rs +2 -0
  41. package/crates/team-agent/src/coordinator/steps/persist.rs +1 -0
  42. package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +1 -0
  43. package/crates/team-agent/src/coordinator/steps/session_gate.rs +1 -0
  44. package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -174
  45. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +139 -375
  46. package/crates/team-agent/src/coordinator/tests/basics.rs +0 -184
  47. package/crates/team-agent/src/coordinator/tests/mod.rs +2 -17
  48. package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -49
  49. package/crates/team-agent/src/coordinator/tick.rs +23 -40
  50. package/crates/team-agent/src/coordinator/types.rs +3 -176
  51. package/crates/team-agent/src/db/agent_health_capture.rs +1 -0
  52. package/crates/team-agent/src/db/message_store.rs +2 -1
  53. package/crates/team-agent/src/db/migration.rs +5 -4
  54. package/crates/team-agent/src/db/mod.rs +1 -0
  55. package/crates/team-agent/src/db/schema.rs +1 -0
  56. package/crates/team-agent/src/diagnose/comms.rs +2 -1
  57. package/crates/team-agent/src/diagnose/mod.rs +1 -0
  58. package/crates/team-agent/src/diagnose/orphans.rs +1 -0
  59. package/crates/team-agent/src/layout/manager.rs +3 -7
  60. package/crates/team-agent/src/layout/mod.rs +2 -2
  61. package/crates/team-agent/src/layout/overlay.rs +6 -1
  62. package/crates/team-agent/src/layout/placement.rs +1 -0
  63. package/crates/team-agent/src/layout/recovery.rs +3 -0
  64. package/crates/team-agent/src/layout/runtime_sessions.rs +8 -3
  65. package/crates/team-agent/src/layout/sessions.rs +8 -1
  66. package/crates/team-agent/src/layout/tmux_endpoint.rs +3 -0
  67. package/crates/team-agent/src/layout/worker_env.rs +3 -0
  68. package/crates/team-agent/src/layout/worker_window_helpers.rs +2 -0
  69. package/crates/team-agent/src/leader/helpers.rs +1 -0
  70. package/crates/team-agent/src/leader/incident.rs +1 -0
  71. package/crates/team-agent/src/leader/lease.rs +27 -22
  72. package/crates/team-agent/src/leader/mod.rs +2 -3
  73. package/crates/team-agent/src/leader/owner_bind.rs +13 -3
  74. package/crates/team-agent/src/leader/provider_attribution.rs +1 -0
  75. package/crates/team-agent/src/leader/rediscover.rs +4 -17
  76. package/crates/team-agent/src/leader/registry.rs +3 -15
  77. package/crates/team-agent/src/leader/start.rs +373 -125
  78. package/crates/team-agent/src/leader/takeover.rs +10 -232
  79. package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +544 -0
  80. package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +624 -0
  81. package/crates/team-agent/src/leader/tests/identity.rs +7 -2
  82. package/crates/team-agent/src/leader/tests/idle.rs +0 -193
  83. package/crates/team-agent/src/leader/tests/lease_api.rs +0 -45
  84. package/crates/team-agent/src/leader/tests/mod.rs +4 -41
  85. package/crates/team-agent/src/leader/tests/rehomed_env.rs +83 -0
  86. package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +1273 -0
  87. package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +417 -0
  88. package/crates/team-agent/src/leader/tests/wake_start_owner.rs +22 -103
  89. package/crates/team-agent/src/leader/types.rs +1 -28
  90. package/crates/team-agent/src/lib.rs +3 -0
  91. package/crates/team-agent/src/lifecycle/display.rs +7 -1
  92. package/crates/team-agent/src/lifecycle/helpers.rs +3 -1
  93. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +2 -2
  94. package/crates/team-agent/src/lifecycle/launch/fork_agent/completion.rs +1 -0
  95. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +1 -0
  96. package/crates/team-agent/src/lifecycle/launch/fork_finalize.rs +1 -0
  97. package/crates/team-agent/src/lifecycle/launch/plan.rs +2 -2
  98. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +4 -26
  99. package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -27
  100. package/crates/team-agent/src/lifecycle/launch/spawn.rs +1 -27
  101. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +4 -32
  102. package/crates/team-agent/src/lifecycle/launch/state_projection.rs +1 -0
  103. package/crates/team-agent/src/lifecycle/launch.rs +11 -12
  104. package/crates/team-agent/src/lifecycle/mod.rs +2 -1
  105. package/crates/team-agent/src/lifecycle/restart/agent.rs +3 -66
  106. package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +2 -2
  107. package/crates/team-agent/src/lifecycle/restart/rebuild.rs +13 -5
  108. package/crates/team-agent/src/lifecycle/restart/remove.rs +1 -1
  109. package/crates/team-agent/src/lifecycle/restart/selection.rs +3 -3
  110. package/crates/team-agent/src/lifecycle/restart.rs +13 -15
  111. package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +1007 -0
  112. package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +265 -0
  113. package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +459 -0
  114. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +849 -0
  115. package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +323 -0
  116. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +423 -0
  117. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +737 -0
  118. package/crates/team-agent/src/lifecycle/tests/codex_mcp_approval_inheritance_red.rs +1187 -0
  119. package/crates/team-agent/src/lifecycle/tests/codex_weak_window_attribution_red.rs +683 -0
  120. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +394 -0
  121. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +1856 -0
  122. package/crates/team-agent/src/lifecycle/tests/core_034_real_red.rs +917 -0
  123. package/crates/team-agent/src/lifecycle/tests/display_adaptive_red.rs +481 -0
  124. package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +301 -0
  125. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +516 -0
  126. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +986 -0
  127. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +651 -0
  128. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +2 -0
  129. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +332 -0
  130. package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +846 -0
  131. package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +648 -0
  132. package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +910 -0
  133. package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +630 -0
  134. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +1083 -0
  135. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +1677 -0
  136. package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +410 -0
  137. package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +428 -0
  138. package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +1032 -0
  139. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +869 -0
  140. package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +1249 -0
  141. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +342 -0
  142. package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +542 -0
  143. package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +1103 -0
  144. package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +1276 -0
  145. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +145 -0
  146. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +603 -0
  147. package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +837 -0
  148. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +928 -0
  149. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +951 -0
  150. package/crates/team-agent/src/lifecycle/tests/worker_dangerous_bypass_argv_red.rs +327 -0
  151. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +760 -0
  152. package/crates/team-agent/src/lifecycle/tests.rs +59 -0
  153. package/crates/team-agent/src/lifecycle/types.rs +0 -9
  154. package/crates/team-agent/src/mcp_server/helpers.rs +1 -0
  155. package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +1 -0
  156. package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +1 -0
  157. package/crates/team-agent/src/mcp_server/mod.rs +1 -0
  158. package/crates/team-agent/src/mcp_server/normalize.rs +4 -3
  159. package/crates/team-agent/src/mcp_server/tools.rs +1 -0
  160. package/crates/team-agent/src/mcp_server/types.rs +1 -18
  161. package/crates/team-agent/src/mcp_server/wire.rs +5 -5
  162. package/crates/team-agent/src/messaging/activity.rs +1 -0
  163. package/crates/team-agent/src/messaging/address.rs +1 -0
  164. package/crates/team-agent/src/messaging/delivery.rs +4 -3
  165. package/crates/team-agent/src/messaging/helpers.rs +2 -1
  166. package/crates/team-agent/src/messaging/leader_channel.rs +1 -0
  167. package/crates/team-agent/src/messaging/leader_receiver.rs +2 -1
  168. package/crates/team-agent/src/messaging/mod.rs +10 -14
  169. package/crates/team-agent/src/messaging/peers.rs +2 -0
  170. package/crates/team-agent/src/messaging/persist.rs +3 -1
  171. package/crates/team-agent/src/messaging/presentation.rs +2 -1
  172. package/crates/team-agent/src/messaging/results.rs +1 -0
  173. package/crates/team-agent/src/messaging/scheduler.rs +1 -0
  174. package/crates/team-agent/src/messaging/selftest.rs +1 -1
  175. package/crates/team-agent/src/messaging/send.rs +41 -8
  176. package/crates/team-agent/src/messaging/tests/mod.rs +5 -0
  177. package/crates/team-agent/src/messaging/types.rs +2 -2
  178. package/crates/team-agent/src/messaging/watchers.rs +19 -13
  179. package/crates/team-agent/src/model/enums.rs +1 -0
  180. package/crates/team-agent/src/model/errors.rs +1 -0
  181. package/crates/team-agent/src/model/ids.rs +1 -0
  182. package/crates/team-agent/src/model/mod.rs +1 -0
  183. package/crates/team-agent/src/model/name_similarity.rs +1 -0
  184. package/crates/team-agent/src/model/pane_authority_refusal.rs +1 -0
  185. package/crates/team-agent/src/model/paths.rs +1 -0
  186. package/crates/team-agent/src/model/permissions.rs +3 -2
  187. package/crates/team-agent/src/model/routing.rs +1 -0
  188. package/crates/team-agent/src/model/spec.rs +1 -0
  189. package/crates/team-agent/src/model/task_graph.rs +1 -0
  190. package/crates/team-agent/src/model/yaml/tests.rs +1 -0
  191. package/crates/team-agent/src/model/yaml.rs +1 -0
  192. package/crates/team-agent/src/packaging/install.rs +9 -147
  193. package/crates/team-agent/src/packaging/migrate.rs +2 -0
  194. package/crates/team-agent/src/packaging/mod.rs +1 -0
  195. package/crates/team-agent/src/packaging/repair.rs +2 -0
  196. package/crates/team-agent/src/packaging/tests.rs +29 -218
  197. package/crates/team-agent/src/packaging/types.rs +8 -15
  198. package/crates/team-agent/src/platform/argv.rs +4 -0
  199. package/crates/team-agent/src/platform/errors.rs +10 -1
  200. package/crates/team-agent/src/platform/file_lock.rs +4 -157
  201. package/crates/team-agent/src/platform/mod.rs +0 -61
  202. package/crates/team-agent/src/platform/process.rs +1 -0
  203. package/crates/team-agent/src/provider/adapter.rs +1 -0
  204. package/crates/team-agent/src/provider/adapters/claude.rs +1 -0
  205. package/crates/team-agent/src/provider/adapters/claude_fork.rs +1 -0
  206. package/crates/team-agent/src/provider/adapters/codex.rs +1 -0
  207. package/crates/team-agent/src/provider/adapters/copilot.rs +1 -0
  208. package/crates/team-agent/src/provider/adapters/copilot_fork.rs +1 -0
  209. package/crates/team-agent/src/provider/adapters/fake.rs +1 -0
  210. package/crates/team-agent/src/provider/adapters/mod.rs +1 -0
  211. package/crates/team-agent/src/provider/approvals/mod.rs +1 -0
  212. package/crates/team-agent/src/provider/approvals/parsing.rs +2 -5
  213. package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +6 -5
  214. package/crates/team-agent/src/provider/classify.rs +1 -0
  215. package/crates/team-agent/src/provider/faults.rs +1 -26
  216. package/crates/team-agent/src/provider/helpers.rs +1 -0
  217. package/crates/team-agent/src/provider/mod.rs +1 -1
  218. package/crates/team-agent/src/provider/session/capture.rs +1 -4
  219. package/crates/team-agent/src/provider/session/context_fork/claude.rs +1 -0
  220. package/crates/team-agent/src/provider/session/context_fork/codex.rs +1 -0
  221. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +1 -0
  222. package/crates/team-agent/src/provider/session/context_fork.rs +1 -0
  223. package/crates/team-agent/src/provider/session/mod.rs +2 -4
  224. package/crates/team-agent/src/provider/session/resume.rs +2 -209
  225. package/crates/team-agent/src/provider/session_scan/claude.rs +1 -0
  226. package/crates/team-agent/src/provider/session_scan/codex.rs +1 -0
  227. package/crates/team-agent/src/provider/session_scan/common.rs +1 -0
  228. package/crates/team-agent/src/provider/session_scan/copilot.rs +1 -0
  229. package/crates/team-agent/src/provider/session_scan.rs +1 -42
  230. package/crates/team-agent/src/provider/startup_prompt.rs +1 -0
  231. package/crates/team-agent/src/provider/types.rs +1 -0
  232. package/crates/team-agent/src/provider/wire.rs +1 -0
  233. package/crates/team-agent/src/state/identity.rs +16 -5
  234. package/crates/team-agent/src/state/identity_keys.rs +1 -0
  235. package/crates/team-agent/src/state/mod.rs +2 -0
  236. package/crates/team-agent/src/state/owner_gate.rs +5 -0
  237. package/crates/team-agent/src/state/ownership.rs +10 -4
  238. package/crates/team-agent/src/state/paths.rs +12 -0
  239. package/crates/team-agent/src/state/persist.rs +9 -3
  240. package/crates/team-agent/src/state/projection.rs +15 -2
  241. package/crates/team-agent/src/state/repository/intent.rs +1 -0
  242. package/crates/team-agent/src/state/repository/tests.rs +1 -0
  243. package/crates/team-agent/src/state/repository.rs +7 -13
  244. package/crates/team-agent/src/state/selector.rs +1 -0
  245. package/crates/team-agent/src/tmux_backend/tests.rs +39 -0
  246. package/crates/team-agent/src/tmux_backend.rs +63 -0
  247. package/crates/team-agent/src/transport.rs +15 -0
  248. package/package.json +4 -4
  249. package/crates/team-agent/src/leader/inject.rs +0 -33
  250. package/crates/team-agent/src/provider/command.rs +0 -80
@@ -0,0 +1,301 @@
1
+ //! F032 regression contract: startup prompt handling is best-effort at lifecycle boundaries.
2
+ //!
3
+ //! Launch/restart may spawn a pane and then ask the provider adapter to handle startup prompts.
4
+ //! A provider-specific prompt handler panic must not unwind out of the user command and leave a
5
+ //! half-initialized runtime. The command should still complete once the pane has been spawned.
6
+
7
+ #[path = "../../../tests/support/hermetic.rs"]
8
+ mod hermetic_guard;
9
+ #[allow(dead_code)]
10
+ fn _hermetic_boundary_marker(_: &hermetic_guard::HermeticTestEnv) {}
11
+
12
+ use std::collections::BTreeMap;
13
+ use std::path::{Path, PathBuf};
14
+ use std::sync::atomic::{AtomicU32, Ordering};
15
+ use std::sync::Mutex;
16
+
17
+ use serde_json::json;
18
+ use team_agent::lifecycle::{launch_with_transport, restart_with_transport, RestartReport};
19
+ use team_agent::transport::{
20
+ AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport,
21
+ InjectStage, InjectVerification, Key, PaneField, PaneId, PaneInfo, SessionName, SetEnvOutcome,
22
+ SpawnResult, SubmitVerification, Target, Transport, TransportError, TurnVerification,
23
+ WindowName,
24
+ };
25
+
26
+ static SEQ: AtomicU32 = AtomicU32::new(0);
27
+
28
+ const TEAM_MD: &str =
29
+ "---\nname: f032team\nobjective: F032 lifecycle prompt fault probe.\nprovider: codex\n---\n\nF032.\n";
30
+ const ROLE_MD: &str = "---\nname: implementer\nrole: Implementation Engineer\nprovider: codex\nmodel: gpt-5.5\nauth_mode: subscription\ntools:\n - mcp_team\n---\n\nImplement.\n";
31
+
32
+ #[test]
33
+ fn f032_launch_spawn_path_treats_startup_prompt_panic_as_best_effort() {
34
+ let team = compiled_team_dir("launch");
35
+ let spec_path = team.join("team.spec.yaml");
36
+ let transport = PanicOnStartupPromptTransport::new();
37
+
38
+ let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
39
+ launch_with_transport(&spec_path, false, true, true, &transport)
40
+ }));
41
+
42
+ assert_eq!(
43
+ transport.spawn_count(),
44
+ 1,
45
+ "test fixture must prove the pane was spawned before the startup prompt handler faulted"
46
+ );
47
+ let report = assert_lifecycle_result_ok(result, "launch");
48
+ assert!(
49
+ !report.started.is_empty(),
50
+ "launch must keep the spawned pane in LaunchReport.started even if startup prompt handling panics"
51
+ );
52
+ }
53
+
54
+ #[test]
55
+ fn f032_restart_spawn_path_treats_startup_prompt_panic_as_best_effort() {
56
+ let workspace = restart_workspace("restart");
57
+ let transport = PanicOnStartupPromptTransport::new();
58
+
59
+ let result = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
60
+ restart_with_transport(&workspace, false, None, &transport)
61
+ }));
62
+
63
+ assert_eq!(
64
+ transport.spawn_count(),
65
+ 1,
66
+ "test fixture must prove restart spawned a pane before the startup prompt handler faulted"
67
+ );
68
+ let report = assert_lifecycle_result_ok(result, "restart");
69
+ assert!(
70
+ matches!(report, RestartReport::Restarted { .. }),
71
+ "restart must complete after degrading startup prompt handling best-effort; got {report:?}"
72
+ );
73
+ }
74
+
75
+ fn assert_lifecycle_result_ok<T>(
76
+ result: std::thread::Result<Result<T, team_agent::lifecycle::LifecycleError>>,
77
+ command: &str,
78
+ ) -> T {
79
+ match result {
80
+ Ok(Ok(report)) => report,
81
+ Ok(Err(err)) => panic!(
82
+ "{command} must not fail because startup prompt handling is best-effort; got error {err:?}"
83
+ ),
84
+ Err(_) => panic!(
85
+ "{command} must catch provider startup prompt panics at or below the lifecycle boundary"
86
+ ),
87
+ }
88
+ }
89
+
90
+ fn compiled_team_dir(label: &str) -> PathBuf {
91
+ let team = temp_ws(label).join("teamdir");
92
+ std::fs::create_dir_all(team.join("agents")).expect("create agents dir");
93
+ std::fs::write(team.join("TEAM.md"), TEAM_MD).expect("write TEAM.md");
94
+ std::fs::write(team.join("agents").join("implementer.md"), ROLE_MD).expect("write role");
95
+ let spec = team_agent::compiler::compile_team(&team).expect("compile team");
96
+ std::fs::write(
97
+ team.join("team.spec.yaml"),
98
+ team_agent::model::yaml::dumps(&spec),
99
+ )
100
+ .expect("write compiled spec");
101
+ team
102
+ }
103
+
104
+ fn restart_workspace(label: &str) -> PathBuf {
105
+ let ws = compiled_team_dir(label);
106
+ let rollout = ws.join("implementer-rollout.jsonl");
107
+ std::fs::write(&rollout, "{}\n").expect("seed rollout backing");
108
+ team_agent::state::persist::save_runtime_state(
109
+ &ws,
110
+ &json!({
111
+ "session_name": "team-f032team",
112
+ "agents": {
113
+ "implementer": {
114
+ "status": "running",
115
+ "provider": "codex",
116
+ "session_id": "sess-impl",
117
+ "rollout_path": rollout.to_string_lossy(),
118
+ "first_send_at": "2026-05-27T10:00:00+00:00"
119
+ }
120
+ }
121
+ }),
122
+ )
123
+ .expect("seed runtime state");
124
+ seed_healthy_coordinator(&ws);
125
+ ws
126
+ }
127
+
128
+ fn seed_healthy_coordinator(workspace: &Path) {
129
+ let workspace = team_agent::coordinator::WorkspacePath::new(workspace.to_path_buf());
130
+ std::fs::create_dir_all(team_agent::model::paths::runtime_dir(workspace.as_path()))
131
+ .expect("create runtime dir");
132
+ let _ = team_agent::message_store::MessageStore::open(workspace.as_path())
133
+ .expect("create message store schema");
134
+ let pid = team_agent::coordinator::Pid::new(std::process::id());
135
+ team_agent::coordinator::write_coordinator_metadata(
136
+ &workspace,
137
+ pid,
138
+ team_agent::coordinator::MetadataSource::Boot,
139
+ )
140
+ .expect("write coordinator metadata");
141
+ std::fs::write(
142
+ team_agent::coordinator::coordinator_pid_path(&workspace),
143
+ pid.to_string(),
144
+ )
145
+ .expect("write coordinator pid");
146
+ }
147
+
148
+ fn temp_ws(label: &str) -> PathBuf {
149
+ let n = SEQ.fetch_add(1, Ordering::Relaxed);
150
+ let ws = std::env::temp_dir().join(format!(
151
+ "ta_rs_f032_prompt_best_effort_{}_{}_{}",
152
+ std::process::id(),
153
+ label,
154
+ n
155
+ ));
156
+ std::fs::create_dir_all(&ws).expect("create temp workspace");
157
+ ws
158
+ }
159
+
160
+ #[derive(Debug, Default)]
161
+ struct PanicOnStartupPromptTransport {
162
+ spawns: Mutex<Vec<String>>,
163
+ }
164
+
165
+ impl PanicOnStartupPromptTransport {
166
+ fn new() -> Self {
167
+ Self::default()
168
+ }
169
+
170
+ fn spawn_count(&self) -> usize {
171
+ self.spawns.lock().expect("spawns lock").len()
172
+ }
173
+
174
+ fn spawn_result(
175
+ &self,
176
+ kind: &'static str,
177
+ session: &SessionName,
178
+ window: &WindowName,
179
+ ) -> SpawnResult {
180
+ let mut spawns = self.spawns.lock().expect("spawns lock");
181
+ let pane_index = spawns.len();
182
+ spawns.push(kind.to_string());
183
+ SpawnResult {
184
+ pane_id: PaneId::new(format!("%{pane_index}")),
185
+ session: session.clone(),
186
+ window: window.clone(),
187
+ child_pid: None,
188
+ }
189
+ }
190
+ }
191
+
192
+ impl Transport for PanicOnStartupPromptTransport {
193
+ fn kind(&self) -> BackendKind {
194
+ BackendKind::Tmux
195
+ }
196
+
197
+ fn spawn_first(
198
+ &self,
199
+ session: &SessionName,
200
+ window: &WindowName,
201
+ _argv: &[String],
202
+ _cwd: &Path,
203
+ _env: &BTreeMap<String, String>,
204
+ ) -> Result<SpawnResult, TransportError> {
205
+ Ok(self.spawn_result("spawn_first", session, window))
206
+ }
207
+
208
+ fn spawn_into(
209
+ &self,
210
+ session: &SessionName,
211
+ window: &WindowName,
212
+ _argv: &[String],
213
+ _cwd: &Path,
214
+ _env: &BTreeMap<String, String>,
215
+ ) -> Result<SpawnResult, TransportError> {
216
+ Ok(self.spawn_result("spawn_into", session, window))
217
+ }
218
+
219
+ fn inject(
220
+ &self,
221
+ _target: &Target,
222
+ _payload: &InjectPayload,
223
+ _submit: Key,
224
+ _bracketed: bool,
225
+ ) -> Result<InjectReport, TransportError> {
226
+ Ok(InjectReport {
227
+ stage_reached: InjectStage::Submit,
228
+ inject_verification: InjectVerification::CaptureContainsToken,
229
+ submit_verification: SubmitVerification::EnterSentWithoutPlaceholderCheck,
230
+ turn_verification: TurnVerification::NotYetObserved,
231
+ attempts: 1,
232
+ submit_diagnostics: None,
233
+ })
234
+ }
235
+
236
+ fn send_keys(&self, _target: &Target, _keys: &[Key]) -> Result<(), TransportError> {
237
+ Ok(())
238
+ }
239
+
240
+ fn capture(
241
+ &self,
242
+ _target: &Target,
243
+ _range: CaptureRange,
244
+ ) -> Result<CapturedText, TransportError> {
245
+ panic!("fault adapter: startup prompt capture panicked after spawn");
246
+ }
247
+
248
+ fn query(&self, _target: &Target, _field: PaneField) -> Result<Option<String>, TransportError> {
249
+ Ok(None)
250
+ }
251
+
252
+ fn liveness(
253
+ &self,
254
+ _pane: &PaneId,
255
+ ) -> Result<team_agent::transport::PaneLiveness, TransportError> {
256
+ Ok(team_agent::transport::PaneLiveness::Live)
257
+ }
258
+
259
+ fn has_pane(&self, pane: &PaneId) -> Result<Option<bool>, TransportError> {
260
+ let spawns = self.spawns.lock().expect("spawns lock");
261
+ Ok(Some(
262
+ spawns
263
+ .iter()
264
+ .enumerate()
265
+ .any(|(idx, _)| pane.as_str() == format!("%{idx}")),
266
+ ))
267
+ }
268
+
269
+ fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
270
+ Ok(Vec::new())
271
+ }
272
+
273
+ fn has_session(&self, _session: &SessionName) -> Result<bool, TransportError> {
274
+ Ok(!self.spawns.lock().expect("spawns lock").is_empty())
275
+ }
276
+
277
+ fn list_windows(&self, _session: &SessionName) -> Result<Vec<WindowName>, TransportError> {
278
+ Ok(Vec::new())
279
+ }
280
+
281
+ fn set_session_env(
282
+ &self,
283
+ _session: &SessionName,
284
+ _key: &str,
285
+ _value: &str,
286
+ ) -> Result<SetEnvOutcome, TransportError> {
287
+ Ok(SetEnvOutcome::Applied)
288
+ }
289
+
290
+ fn kill_session(&self, _session: &SessionName) -> Result<(), TransportError> {
291
+ Ok(())
292
+ }
293
+
294
+ fn kill_window(&self, _target: &Target) -> Result<(), TransportError> {
295
+ Ok(())
296
+ }
297
+
298
+ fn attach_session(&self, _session: &SessionName) -> Result<AttachOutcome, TransportError> {
299
+ Ok(AttachOutcome::Attached)
300
+ }
301
+ }