@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,757 +0,0 @@
1
- //!
2
- //! codex startup-prompt recognizer — workspace-trust + update-skip screen detection.
3
- //!
4
- //! Golden (READ-ONLY truth `team-agent-public` v0.2.11): `provider_cli/codex.py`
5
- //! - `CodexAdapter.handle_startup_prompts` (:142-182)
6
- //! - `maybe_skip_update_prompt` (:262-268)
7
- //!
8
- //! recognizer-class (Gap 29 — burned 4 Mac minis): a NAIVE substring port gets the RECENCY命门 wrong.
9
- //! A prompt is acted on ONLY when its `rfind` position is GREATER than the ready marker's `rfind`
10
- //! position (i.e. it appears LATER / more recently in the captured scrollback). A stale prompt ABOVE an
11
- //! already-ready marker is left alone — ready wins and polling stops. RED-first skeleton; porter-d
12
- //! implements GREEN black-box against golden codex.py.
13
-
14
- use std::time::Duration;
15
-
16
- use crate::transport::{CaptureRange, Key, Target, Transport};
17
-
18
- const TRUST_MARKERS: &[&str] = &[
19
- "Do you trust the contents of this directory?",
20
- "Do you trust the files in this folder?",
21
- "Do you trust this folder?",
22
- ];
23
- const UPDATE_MARKERS: &[&str] = &["Update available!", "Update now"];
24
- const CLAUDE_TRUST_MARKERS: &[&str] = &[
25
- "Quick safety check",
26
- "Is this a project you created or one you trust?",
27
- "Yes, I trust this folder",
28
- "No, exit",
29
- "Enter to confirm",
30
- ];
31
- const CLAUDE_READY_MARKERS: &[&str] = &["Claude Code"];
32
- pub const COPILOT_TRUST_PROMPT_MARKER: &str = include_str!("testdata/copilot-trust-prompt.txt");
33
- pub const COPILOT_READY_MARKER: &str = include_str!("testdata/copilot-ready-marker.txt");
34
- const COPILOT_TRUST_MARKERS: &[&str] = &[COPILOT_TRUST_PROMPT_MARKER];
35
- const COPILOT_READY_MARKERS: &[&str] = &[COPILOT_READY_MARKER];
36
- const COPILOT_TRUST_TITLE: &str = "Confirm folder trust";
37
- const COPILOT_TRUST_QUESTION: &str = "Do you trust the files in this folder?";
38
- const COPILOT_TRUST_YES_SESSION: &str = "❯ 1. Yes";
39
- const COPILOT_TRUST_REMEMBER: &str = "2. Yes, and remember this folder for future sessions";
40
- const COPILOT_TRUST_NO: &str = "3. No (Esc)";
41
- const COPILOT_READY_FOOTER: &str = " / commands · ? help";
42
- /// Plain ready markers (not the bare `›` glyph — that glyph also indicates a
43
- /// numbered-menu selector and is handled by [`rightmost_input_prompt_glyph`] with
44
- /// shape gating per N15 / CR-063: detect by SHAPE, not a single Unicode codepoint).
45
- const READY_MARKERS: &[&str] = &["OpenAI Codex", "codex>"];
46
-
47
- /// Per-poll decision for the codex startup screen. Golden order each iteration (codex.py:160-181):
48
- /// update-skip is checked FIRST, then workspace-trust, then ready (stop), else keep polling.
49
- #[derive(Debug, Clone, Copy, PartialEq, Eq)]
50
- pub enum StartupScreenDecision {
51
- /// `maybe_skip_update_prompt` matched: update_pos >= 0 && update_pos > ready_pos (codex.py:262-267).
52
- SkipUpdatePrompt,
53
- /// workspace-trust: trust_pos >= 0 && trust_pos > ready_pos (codex.py:166-174).
54
- AnswerWorkspaceTrust,
55
- /// ready_pos >= 0 with no actionable prompt above it (codex.py:178) -> stop polling.
56
- Ready,
57
- /// none of the above (codex.py:180) -> sleep + keep polling.
58
- KeepPolling,
59
- }
60
-
61
- /// One handled startup prompt — an entry of golden's `handled` list.
62
- #[derive(Debug, Clone, PartialEq, Eq)]
63
- pub struct HandledPrompt {
64
- pub prompt: String,
65
- pub action: String,
66
- }
67
-
68
- /// PURE recognizer (codex.py:160-181 + maybe_skip_update_prompt :262-268): captured scrollback ->
69
- /// decision. NO IO. The RECENCY命门: a prompt is acted on ONLY when its `rfind` position is strictly
70
- /// GREATER than the ready marker's `rfind` position. update is evaluated before trust.
71
- /// trust strings (rfind max of): "Do you trust the contents of this directory?" /
72
- /// "Do you trust the files in this folder?" / "Do you trust this folder?"
73
- /// update strings (rfind max of): "Update available!" / "Update now"
74
- /// ready markers (rfind max of): "OpenAI Codex" / "›" / "codex>"
75
- pub fn classify_codex_startup_screen(output: &str) -> StartupScreenDecision {
76
- // CR-063 / subroot real-machine residual: actionable-shape override BEFORE recency.
77
- // The recency model ("prompt above ready = stale-scrolled, ignore") assumes the
78
- // active state is the LATEST byte on screen. Real Codex breaks that assumption:
79
- // while a trust modal is still active, Codex pre-renders the Update box, the
80
- // OpenAI Codex banner, AND a bottom `› Find and fix a bug…` input-prompt indicator
81
- // BELOW the trust menu — so recency would mark the screen Ready and the trust
82
- // menu would never be answered. When the captured text has the actionable trust
83
- // shape (`Do you trust …` phrase + a `› <digit>. ` numbered-menu line, N15),
84
- // the modal IS the live state regardless of what comes after it. Return early.
85
- if has_actionable_trust_shape(output) {
86
- return StartupScreenDecision::AnswerWorkspaceTrust;
87
- }
88
- // N15/CR-063 root-cause (recency lane): the bare `›` glyph is BOTH the Codex
89
- // input-prompt indicator AND the numbered-menu selector on a real trust pane
90
- // (`› 1. Yes, continue`). Detect by SHAPE: `›` is a ready marker only when its
91
- // tail is NOT a `<digit>. ` menu item.
92
- let ready_pos = max_two(
93
- max_rfind(output, READY_MARKERS),
94
- rightmost_input_prompt_glyph(output),
95
- );
96
- if is_more_recent(max_rfind(output, UPDATE_MARKERS), ready_pos) {
97
- return StartupScreenDecision::SkipUpdatePrompt;
98
- }
99
- if is_more_recent(max_rfind(output, TRUST_MARKERS), ready_pos) {
100
- return StartupScreenDecision::AnswerWorkspaceTrust;
101
- }
102
- if ready_pos.is_some() {
103
- StartupScreenDecision::Ready
104
- } else {
105
- StartupScreenDecision::KeepPolling
106
- }
107
- }
108
-
109
- pub fn classify_claude_startup_screen(output: &str) -> StartupScreenDecision {
110
- if has_active_claude_yes_trust_shape(output) {
111
- return StartupScreenDecision::AnswerWorkspaceTrust;
112
- }
113
- if has_claude_ready_shape(output) {
114
- StartupScreenDecision::Ready
115
- } else {
116
- StartupScreenDecision::KeepPolling
117
- }
118
- }
119
-
120
- pub fn classify_copilot_startup_screen(output: &str) -> StartupScreenDecision {
121
- let ready_pos = copilot_ready_pos(output);
122
- if has_active_copilot_trust_shape(output)
123
- && is_more_recent(copilot_trust_pos(output), ready_pos)
124
- {
125
- return StartupScreenDecision::AnswerWorkspaceTrust;
126
- }
127
- if ready_pos.is_some() {
128
- StartupScreenDecision::Ready
129
- } else {
130
- StartupScreenDecision::KeepPolling
131
- }
132
- }
133
-
134
- /// Actionable trust shape (N15): the captured text contains a trust phrase AND a
135
- /// numbered-menu selector line `› <digit>. `. This is the modal-still-active signal
136
- /// that survives Codex's pre-rendering of the banner/input prompt below the menu.
137
- /// Does NOT match a single-screen "trust phrase + bare `›`" (e.g. plain Ready
138
- /// follow-up text), so historical "trust ABOVE ready" recency tests keep passing
139
- /// — those fixtures do not include a `› <digit>. ` menu line.
140
- fn has_actionable_trust_shape(output: &str) -> bool {
141
- if !TRUST_MARKERS.iter().any(|marker| output.contains(marker)) {
142
- return false;
143
- }
144
- contains_numbered_menu_glyph(output)
145
- }
146
-
147
- /// `true` iff any `›` in the output is followed by a numbered-menu selector
148
- /// (` <digit>. `). The shape pairs the glyph with a digit-dot line item — the
149
- /// Codex trust/update menu printing convention.
150
- fn contains_numbered_menu_glyph(output: &str) -> bool {
151
- let glyph = '›';
152
- let glyph_len = glyph.len_utf8();
153
- let mut start = 0;
154
- while let Some(rel) = output[start..].find(glyph) {
155
- let abs = start + rel;
156
- let tail_start = abs + glyph_len;
157
- if tail_start > output.len() {
158
- break;
159
- }
160
- if is_numbered_menu_tail(&output[tail_start..]) {
161
- return true;
162
- }
163
- start = tail_start;
164
- }
165
- false
166
- }
167
-
168
- fn has_active_claude_yes_trust_shape(output: &str) -> bool {
169
- if !CLAUDE_TRUST_MARKERS
170
- .iter()
171
- .all(|marker| output.contains(marker))
172
- {
173
- return false;
174
- }
175
- output.lines().map(str::trim_start).any(|line| {
176
- line == "❯ 1. Yes, I trust this folder" || line == "> 1. Yes, I trust this folder"
177
- })
178
- }
179
-
180
- fn has_claude_ready_shape(output: &str) -> bool {
181
- max_rfind(output, CLAUDE_READY_MARKERS).is_some()
182
- && rightmost_claude_input_prompt_glyph(output).is_some()
183
- }
184
-
185
- fn has_active_copilot_trust_shape(output: &str) -> bool {
186
- if max_rfind(output, COPILOT_TRUST_MARKERS).is_some() {
187
- return true;
188
- }
189
- [
190
- COPILOT_TRUST_TITLE,
191
- COPILOT_TRUST_QUESTION,
192
- COPILOT_TRUST_YES_SESSION,
193
- COPILOT_TRUST_REMEMBER,
194
- COPILOT_TRUST_NO,
195
- ]
196
- .iter()
197
- .all(|marker| output.contains(marker))
198
- }
199
-
200
- fn copilot_trust_pos(output: &str) -> Option<usize> {
201
- max_two(
202
- max_rfind(output, COPILOT_TRUST_MARKERS),
203
- max_rfind(output, &[COPILOT_TRUST_TITLE, COPILOT_TRUST_QUESTION]),
204
- )
205
- }
206
-
207
- fn copilot_ready_pos(output: &str) -> Option<usize> {
208
- let fixture_pos = max_rfind(output, COPILOT_READY_MARKERS);
209
- let footer_pos = output.rfind(COPILOT_READY_FOOTER);
210
- let prompt_pos = rightmost_copilot_input_prompt_glyph(output);
211
- if footer_pos.is_some() && prompt_pos.is_some() {
212
- max_two(fixture_pos, max_two(footer_pos, prompt_pos))
213
- } else {
214
- fixture_pos
215
- }
216
- }
217
-
218
- fn rightmost_copilot_input_prompt_glyph(output: &str) -> Option<usize> {
219
- let mut best = None;
220
- let mut offset = 0;
221
- for line in output.split_inclusive('\n') {
222
- if line.trim() == "❯" {
223
- if let Some(idx) = line.find('❯') {
224
- best = Some(offset + idx);
225
- }
226
- }
227
- offset += line.len();
228
- }
229
- best
230
- }
231
-
232
- fn rightmost_claude_input_prompt_glyph(output: &str) -> Option<usize> {
233
- let mut best = rightmost_input_prompt_for_glyph(output, '❯');
234
- best = max_two(best, rightmost_input_prompt_for_glyph(output, '>'));
235
- best
236
- }
237
-
238
- fn rightmost_input_prompt_for_glyph(output: &str, glyph: char) -> Option<usize> {
239
- let glyph_len = glyph.len_utf8();
240
- let mut best = None;
241
- let mut start = 0;
242
- while let Some(rel) = output[start..].find(glyph) {
243
- let abs = start + rel;
244
- let tail_start = abs + glyph_len;
245
- if tail_start <= output.len() && !is_numbered_menu_tail(&output[tail_start..]) {
246
- best = Some(abs);
247
- }
248
- start = tail_start;
249
- if start > output.len() {
250
- break;
251
- }
252
- }
253
- best
254
- }
255
-
256
- /// Rightmost `›` whose tail is NOT a numbered-menu selector (` <digit>. `). A bare
257
- /// `›` followed by free text or whitespace is the Codex main-input prompt indicator;
258
- /// a `›` followed by `1. Yes, continue` is part of the trust/update menu and is NOT
259
- /// a ready signal.
260
- fn rightmost_input_prompt_glyph(output: &str) -> Option<usize> {
261
- let glyph = '›';
262
- let glyph_len = glyph.len_utf8();
263
- let mut best = None;
264
- let bytes = output.as_bytes();
265
- let mut start = 0;
266
- while let Some(rel) = output[start..].find(glyph) {
267
- let abs = start + rel;
268
- let tail_start = abs + glyph_len;
269
- if tail_start <= bytes.len() && !is_numbered_menu_tail(&output[tail_start..]) {
270
- best = Some(abs);
271
- }
272
- start = tail_start;
273
- if start > output.len() {
274
- break;
275
- }
276
- }
277
- best
278
- }
279
-
280
- fn is_numbered_menu_tail(tail: &str) -> bool {
281
- let trimmed = tail.trim_start_matches(' ');
282
- let mut chars = trimmed.chars();
283
- matches!(
284
- (chars.next(), chars.next()),
285
- (Some(d), Some('.')) if d.is_ascii_digit()
286
- )
287
- }
288
-
289
- fn max_two(a: Option<usize>, b: Option<usize>) -> Option<usize> {
290
- match (a, b) {
291
- (Some(x), Some(y)) => Some(x.max(y)),
292
- (Some(x), None) | (None, Some(x)) => Some(x),
293
- (None, None) => None,
294
- }
295
- }
296
-
297
- /// Capture-poll loop (codex.py:142-182) over the `transport.capture()` seam (NOT a raw subprocess, so
298
- /// it stays unit-testable). On `AnswerWorkspaceTrust` -> send `Enter` + push
299
- /// {prompt:"codex_workspace_trust", action:"sent_enter"}; on `SkipUpdatePrompt` -> send `Down`,`Enter`
300
- /// + push {prompt:"codex_update_available", action:"sent_skip"}; on `Ready` -> stop. Loops up to
301
- /// `checks` (golden default 30), `sleep_s` (golden 0.5) between iterations. Returns the ordered
302
- /// `handled` list. Capture is full scrollback (golden `tmux capture-pane -p -S - -t <target>`).
303
- /// swallow batch 2 ② (A1): the structured startup-prompt outcome — `handled` keeps the
304
- /// Python golden list shape; `capture_error` carries the FIRST capture failure so the
305
- /// caller can surface it (an unobservable pane must never be silently treated as
306
- /// "no prompts to handle").
307
- #[derive(Debug, Clone, Default)]
308
- pub struct StartupPromptOutcome {
309
- pub handled: Vec<HandledPrompt>,
310
- pub capture_error: Option<String>,
311
- }
312
-
313
- pub fn codex_handle_startup_prompts(
314
- transport: &dyn Transport,
315
- target: &Target,
316
- checks: usize,
317
- sleep_s: f64,
318
- ) -> StartupPromptOutcome {
319
- let mut handled = Vec::new();
320
- let mut capture_error: Option<String> = None;
321
- for _ in 0..checks {
322
- let screen = match transport.capture(target, CaptureRange::Full) {
323
- Ok(captured) => captured.text,
324
- Err(error) => {
325
- capture_error.get_or_insert_with(|| error.to_string());
326
- String::new()
327
- }
328
- };
329
- match classify_codex_startup_screen(&screen) {
330
- StartupScreenDecision::SkipUpdatePrompt => {
331
- let _ = transport.send_keys(target, &[Key::Down, Key::Enter]);
332
- handled.push(HandledPrompt {
333
- prompt: "codex_update_available".to_string(),
334
- action: "sent_skip".to_string(),
335
- });
336
- sleep_between_polls(sleep_s);
337
- }
338
- StartupScreenDecision::AnswerWorkspaceTrust => {
339
- let _ = transport.send_keys(target, &[Key::Enter]);
340
- handled.push(HandledPrompt {
341
- prompt: "codex_workspace_trust".to_string(),
342
- action: "sent_enter".to_string(),
343
- });
344
- sleep_between_polls(sleep_s);
345
- }
346
- StartupScreenDecision::Ready => break,
347
- StartupScreenDecision::KeepPolling => sleep_between_polls(sleep_s),
348
- }
349
- }
350
- StartupPromptOutcome {
351
- handled,
352
- capture_error,
353
- }
354
- }
355
-
356
- pub fn claude_handle_startup_prompts(
357
- transport: &dyn Transport,
358
- target: &Target,
359
- checks: usize,
360
- sleep_s: f64,
361
- ) -> StartupPromptOutcome {
362
- let mut handled = Vec::new();
363
- let mut capture_error: Option<String> = None;
364
- for _ in 0..checks {
365
- let screen = match transport.capture(target, CaptureRange::Full) {
366
- Ok(captured) => captured.text,
367
- Err(error) => {
368
- capture_error.get_or_insert_with(|| error.to_string());
369
- String::new()
370
- }
371
- };
372
- match classify_claude_startup_screen(&screen) {
373
- StartupScreenDecision::AnswerWorkspaceTrust => {
374
- let _ = transport.send_keys(target, &[Key::Enter]);
375
- handled.push(HandledPrompt {
376
- prompt: "claude_workspace_trust".to_string(),
377
- action: "sent_enter".to_string(),
378
- });
379
- sleep_between_polls(sleep_s);
380
- }
381
- StartupScreenDecision::Ready => break,
382
- StartupScreenDecision::SkipUpdatePrompt | StartupScreenDecision::KeepPolling => {
383
- sleep_between_polls(sleep_s);
384
- }
385
- }
386
- }
387
- StartupPromptOutcome {
388
- handled,
389
- capture_error,
390
- }
391
- }
392
-
393
- pub fn copilot_handle_startup_prompts(
394
- transport: &dyn Transport,
395
- target: &Target,
396
- checks: usize,
397
- sleep_s: f64,
398
- ) -> StartupPromptOutcome {
399
- let mut handled = Vec::new();
400
- let mut capture_error: Option<String> = None;
401
- for _ in 0..checks {
402
- let screen = match transport.capture(target, CaptureRange::Full) {
403
- Ok(captured) => captured.text,
404
- Err(error) => {
405
- capture_error.get_or_insert_with(|| error.to_string());
406
- String::new()
407
- }
408
- };
409
- match classify_copilot_startup_screen(&screen) {
410
- StartupScreenDecision::AnswerWorkspaceTrust => {
411
- let _ = transport.send_keys(target, &[Key::Enter]);
412
- handled.push(HandledPrompt {
413
- prompt: "copilot_workspace_trust".to_string(),
414
- action: "sent_enter_yes_session".to_string(),
415
- });
416
- sleep_between_polls(sleep_s);
417
- }
418
- StartupScreenDecision::Ready => break,
419
- StartupScreenDecision::SkipUpdatePrompt | StartupScreenDecision::KeepPolling => {
420
- sleep_between_polls(sleep_s);
421
- }
422
- }
423
- }
424
- StartupPromptOutcome {
425
- handled,
426
- capture_error,
427
- }
428
- }
429
-
430
- fn max_rfind(output: &str, needles: &[&str]) -> Option<usize> {
431
- needles
432
- .iter()
433
- .filter_map(|needle| output.rfind(needle))
434
- .max()
435
- }
436
-
437
- fn is_more_recent(prompt_pos: Option<usize>, ready_pos: Option<usize>) -> bool {
438
- match (prompt_pos, ready_pos) {
439
- (Some(prompt), Some(ready)) => prompt > ready,
440
- (Some(_), None) => true,
441
- _ => false,
442
- }
443
- }
444
-
445
- fn sleep_between_polls(sleep_s: f64) {
446
- let millis = (sleep_s * 1000.0).round();
447
- if millis.is_finite() && millis > 0.0 && millis <= u64::MAX as f64 {
448
- std::thread::sleep(Duration::from_millis(millis as u64));
449
- }
450
- }
451
-
452
- #[cfg(test)]
453
- mod tests {
454
- #![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
455
- use super::*;
456
- use crate::model::enums::PaneLiveness;
457
- use crate::transport::{
458
- AttachOutcome, BackendKind, CaptureRange, CapturedText, InjectPayload, InjectReport, Key,
459
- PaneField, PaneId, PaneInfo, SessionName, SetEnvOutcome, SpawnResult, Target,
460
- TransportError, WindowName,
461
- };
462
- use std::collections::BTreeMap;
463
- use std::path::Path;
464
- use std::sync::Mutex;
465
-
466
- // ── EXACT golden strings (provider_cli/codex.py). Do not paraphrase — recognizer-class. ──────────
467
- const TRUST_DIR: &str = "Do you trust the contents of this directory?";
468
- const TRUST_FILES: &str = "Do you trust the files in this folder?";
469
- const TRUST_FOLDER: &str = "Do you trust this folder?";
470
- const UPDATE_AVAIL: &str = "Update available!";
471
- const UPDATE_NOW: &str = "Update now";
472
- const READY_BANNER: &str = "OpenAI Codex";
473
- const READY_PROMPT: &str = "›"; // U+203A
474
- const READY_BARE: &str = "codex>";
475
-
476
- // ── ① + ② RED核心 — workspace-trust MORE RECENT than ready -> answer it ──────────────────────────
477
- #[test]
478
- fn trust_more_recent_than_ready_answers_workspace_trust() {
479
- // ready banner appears early; the trust prompt appears LATER; no ready marker after it
480
- // => trust_pos > ready_pos => answer.
481
- let screen = format!("{READY_BANNER} v1.2\nwelcome\n\n{TRUST_DIR}\n hit enter ");
482
- assert_eq!(
483
- classify_codex_startup_screen(&screen),
484
- StartupScreenDecision::AnswerWorkspaceTrust
485
- );
486
- }
487
-
488
- // ── ② 命门 CORE — a STALE trust prompt ABOVE the ready marker is NOT answered (ready wins) ────────
489
- #[test]
490
- fn stale_trust_above_ready_is_not_answered_ready_wins() {
491
- // trust prompt FIRST, then a ready marker LATER => trust_pos < ready_pos => do NOT answer.
492
- // This is the positional-recency命门 a naive substring port gets wrong (would re-send Enter).
493
- let screen =
494
- format!("{TRUST_DIR}\n[trusted earlier]\n{READY_BANNER} ready\n{READY_PROMPT} ");
495
- assert_eq!(
496
- classify_codex_startup_screen(&screen),
497
- StartupScreenDecision::Ready,
498
- "RECENCY命门: a trust prompt ABOVE the ready marker is stale; ready wins, NO Enter sent"
499
- );
500
- }
501
-
502
- #[test]
503
- fn each_trust_string_recognized_when_more_recent() {
504
- for s in [TRUST_DIR, TRUST_FILES, TRUST_FOLDER] {
505
- let screen = format!("{READY_BANNER}\n...banner...\n{s}\n");
506
- assert_eq!(
507
- classify_codex_startup_screen(&screen),
508
- StartupScreenDecision::AnswerWorkspaceTrust,
509
- "trust string {s:?} after ready must answer"
510
- );
511
- }
512
- }
513
-
514
- // ── ③ sibling — update-skip recognizer (maybe_skip_update_prompt), same recency命门 ──────────────
515
- #[test]
516
- fn update_more_recent_than_ready_skips_update() {
517
- for s in [UPDATE_AVAIL, UPDATE_NOW] {
518
- let screen = format!("{READY_BANNER}\nblah\n{s}\n");
519
- assert_eq!(
520
- classify_codex_startup_screen(&screen),
521
- StartupScreenDecision::SkipUpdatePrompt,
522
- "update string {s:?} after ready must skip"
523
- );
524
- }
525
- }
526
-
527
- #[test]
528
- fn stale_update_above_ready_is_not_skipped_ready_wins() {
529
- let screen = format!("{UPDATE_AVAIL}\n{READY_BANNER}\n{READY_PROMPT} ");
530
- assert_eq!(
531
- classify_codex_startup_screen(&screen),
532
- StartupScreenDecision::Ready
533
- );
534
- }
535
-
536
- // ── golden ORDER — update is checked BEFORE trust (both more recent) -> SkipUpdatePrompt wins ─────
537
- #[test]
538
- fn update_checked_before_trust() {
539
- // both update + trust appear after the ready marker; golden runs maybe_skip_update_prompt
540
- // FIRST each iteration -> the screen resolves to SkipUpdatePrompt, not AnswerWorkspaceTrust.
541
- let screen = format!("{READY_BANNER}\n{TRUST_DIR}\n{UPDATE_AVAIL}\n");
542
- assert_eq!(
543
- classify_codex_startup_screen(&screen),
544
- StartupScreenDecision::SkipUpdatePrompt
545
- );
546
- }
547
-
548
- // ── ready-only / neither ─────────────────────────────────────────────────────────────────────────
549
- #[test]
550
- fn each_ready_marker_alone_is_ready() {
551
- for m in [READY_BANNER, READY_PROMPT, READY_BARE] {
552
- let screen = format!("booting...\n{m} ");
553
- assert_eq!(
554
- classify_codex_startup_screen(&screen),
555
- StartupScreenDecision::Ready,
556
- "ready marker {m:?} alone must be Ready"
557
- );
558
- }
559
- }
560
-
561
- #[test]
562
- fn no_prompt_no_ready_keeps_polling() {
563
- assert_eq!(
564
- classify_codex_startup_screen("loading spinner...\nstill starting\n"),
565
- StartupScreenDecision::KeepPolling
566
- );
567
- }
568
-
569
- #[test]
570
- fn copilot_trust_fixture_answers_yes_for_this_session() {
571
- assert_eq!(
572
- classify_copilot_startup_screen(COPILOT_TRUST_PROMPT_MARKER),
573
- StartupScreenDecision::AnswerWorkspaceTrust
574
- );
575
- assert!(
576
- COPILOT_TRUST_PROMPT_MARKER.contains(COPILOT_TRUST_YES_SESSION),
577
- "copilot trust default must remain option 1, not persistent option 2"
578
- );
579
- }
580
-
581
- #[test]
582
- fn copilot_trust_prompt_tolerates_path_variation() {
583
- let dir_b = COPILOT_TRUST_PROMPT_MARKER.replace("/dir-a", "/dir-b");
584
- assert_eq!(
585
- classify_copilot_startup_screen(&dir_b),
586
- StartupScreenDecision::AnswerWorkspaceTrust
587
- );
588
- }
589
-
590
- #[test]
591
- fn copilot_ready_fixture_is_ready_without_trust_prompt() {
592
- assert_eq!(
593
- classify_copilot_startup_screen(COPILOT_READY_MARKER),
594
- StartupScreenDecision::Ready
595
- );
596
- }
597
-
598
- #[test]
599
- fn copilot_ready_after_stale_trust_wins() {
600
- let screen = format!("{COPILOT_TRUST_PROMPT_MARKER}\n{COPILOT_READY_MARKER}");
601
- assert_eq!(
602
- classify_copilot_startup_screen(&screen),
603
- StartupScreenDecision::Ready
604
- );
605
- }
606
-
607
- // ── ④ transport.capture() SEAM — the loop answers trust then breaks on ready, via the seam ───────
608
- /// Scripted transport: `capture` pops the next canned screen; `send_keys` records the keys. All
609
- /// other methods are unreachable by the startup-prompt loop.
610
- struct ScriptedTransport {
611
- screens: Mutex<Vec<String>>,
612
- sent: Mutex<Vec<Vec<Key>>>,
613
- }
614
- impl Transport for ScriptedTransport {
615
- fn kind(&self) -> BackendKind {
616
- BackendKind::Tmux
617
- }
618
- fn spawn_first(
619
- &self,
620
- _s: &SessionName,
621
- _w: &WindowName,
622
- _a: &[String],
623
- _c: &Path,
624
- _e: &BTreeMap<String, String>,
625
- ) -> Result<SpawnResult, TransportError> {
626
- unimplemented!("not reached by startup-prompt loop")
627
- }
628
- fn spawn_into(
629
- &self,
630
- _s: &SessionName,
631
- _w: &WindowName,
632
- _a: &[String],
633
- _c: &Path,
634
- _e: &BTreeMap<String, String>,
635
- ) -> Result<SpawnResult, TransportError> {
636
- unimplemented!("not reached by startup-prompt loop")
637
- }
638
- fn inject(
639
- &self,
640
- _t: &Target,
641
- _p: &InjectPayload,
642
- _submit: Key,
643
- _b: bool,
644
- ) -> Result<InjectReport, TransportError> {
645
- unimplemented!("not reached")
646
- }
647
- fn send_keys(&self, _t: &Target, keys: &[Key]) -> Result<(), TransportError> {
648
- self.sent.lock().unwrap().push(keys.to_vec());
649
- Ok(())
650
- }
651
- fn capture(
652
- &self,
653
- _t: &Target,
654
- range: CaptureRange,
655
- ) -> Result<CapturedText, TransportError> {
656
- let mut q = self.screens.lock().unwrap();
657
- let text = if q.is_empty() {
658
- String::new()
659
- } else {
660
- q.remove(0)
661
- };
662
- Ok(CapturedText { text, range })
663
- }
664
- fn query(&self, _t: &Target, _f: PaneField) -> Result<Option<String>, TransportError> {
665
- Ok(None)
666
- }
667
- fn liveness(&self, _p: &PaneId) -> Result<PaneLiveness, TransportError> {
668
- unimplemented!("not reached")
669
- }
670
- fn list_targets(&self) -> Result<Vec<PaneInfo>, TransportError> {
671
- unimplemented!("not reached")
672
- }
673
- fn has_session(&self, _s: &SessionName) -> Result<bool, TransportError> {
674
- Ok(true)
675
- }
676
- fn list_windows(&self, _s: &SessionName) -> Result<Vec<WindowName>, TransportError> {
677
- unimplemented!("not reached")
678
- }
679
- fn set_session_env(
680
- &self,
681
- _s: &SessionName,
682
- _k: &str,
683
- _v: &str,
684
- ) -> Result<SetEnvOutcome, TransportError> {
685
- unimplemented!("not reached")
686
- }
687
- fn kill_session(&self, _s: &SessionName) -> Result<(), TransportError> {
688
- unimplemented!("not reached")
689
- }
690
- fn kill_window(&self, _t: &Target) -> Result<(), TransportError> {
691
- unimplemented!("not reached")
692
- }
693
- fn attach_session(&self, _s: &SessionName) -> Result<AttachOutcome, TransportError> {
694
- unimplemented!("not reached")
695
- }
696
- }
697
-
698
- #[test]
699
- fn loop_answers_trust_then_breaks_on_ready_via_capture_seam() {
700
- let t = ScriptedTransport {
701
- screens: Mutex::new(vec![
702
- // iter 1: trust prompt more recent than ready -> answer (send Enter) + continue.
703
- format!("{READY_BANNER}\n{TRUST_DIR}\n"),
704
- // iter 2: ready marker, no actionable prompt above it -> break.
705
- format!("{READY_BANNER} ready\n{READY_PROMPT} "),
706
- ]),
707
- sent: Mutex::new(Vec::new()),
708
- };
709
- let target = Target::Pane(PaneId::new("%1"));
710
-
711
- let handled = codex_handle_startup_prompts(&t, &target, 5, 0.0).handled;
712
-
713
- assert_eq!(
714
- handled,
715
- vec![HandledPrompt {
716
- prompt: "codex_workspace_trust".to_string(),
717
- action: "sent_enter".to_string(),
718
- }],
719
- "the loop must answer the workspace-trust prompt exactly once, then break on ready"
720
- );
721
- let sent = t.sent.lock().unwrap();
722
- assert!(
723
- sent.iter().any(|keys| keys.as_slice() == [Key::Enter]),
724
- "on workspace-trust the loop must send Enter via the transport.capture() seam; got {sent:?}"
725
- );
726
- }
727
-
728
- #[test]
729
- fn copilot_loop_answers_trust_then_breaks_on_ready_via_capture_seam() {
730
- let t = ScriptedTransport {
731
- screens: Mutex::new(vec![
732
- COPILOT_TRUST_PROMPT_MARKER.to_string(),
733
- COPILOT_READY_MARKER.to_string(),
734
- ]),
735
- sent: Mutex::new(Vec::new()),
736
- };
737
- let target = Target::Pane(PaneId::new("%1"));
738
-
739
- let handled = copilot_handle_startup_prompts(&t, &target, 5, 0.0).handled;
740
-
741
- assert_eq!(
742
- handled,
743
- vec![HandledPrompt {
744
- prompt: "copilot_workspace_trust".to_string(),
745
- action: "sent_enter_yes_session".to_string(),
746
- }]
747
- );
748
- let sent = t.sent.lock().unwrap();
749
- assert_eq!(
750
- sent.iter()
751
- .filter(|keys| keys.as_slice() == [Key::Enter])
752
- .count(),
753
- 1,
754
- "copilot trust prompt must choose option 1 with one Enter; got {sent:?}"
755
- );
756
- }
757
- }