@team-agent/installer 0.5.128 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (436) hide show
  1. package/README.md +4 -4
  2. package/README.zh.md +1 -1
  3. package/package.json +4 -8
  4. package/skills/team-agent/SKILL.md +37 -20
  5. package/skills/team-agent/command-coverage.json +169 -183
  6. package/skills/team-agent/docs/reference/team-agent-operator.md +64 -30
  7. package/skills/team-agent/references/recovery-runbook.md +1 -1
  8. package/skills/team-agent/references/team-agent-operator.md +64 -30
  9. package/templates/team_state.md +1 -1
  10. package/Cargo.lock +0 -1063
  11. package/Cargo.toml +0 -36
  12. package/crates/team-agent/Cargo.toml +0 -69
  13. package/crates/team-agent/src/app_server_test_support.rs +0 -258
  14. package/crates/team-agent/src/cli/adapters.rs +0 -1288
  15. package/crates/team-agent/src/cli/arguments.rs +0 -405
  16. package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
  17. package/crates/team-agent/src/cli/diagnose.rs +0 -1721
  18. package/crates/team-agent/src/cli/emit.rs +0 -2930
  19. package/crates/team-agent/src/cli/grok_slot.rs +0 -384
  20. package/crates/team-agent/src/cli/helpers.rs +0 -91
  21. package/crates/team-agent/src/cli/intent/runtime.rs +0 -1216
  22. package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -912
  23. package/crates/team-agent/src/cli/intent/tests.rs +0 -689
  24. package/crates/team-agent/src/cli/intent.rs +0 -664
  25. package/crates/team-agent/src/cli/leader.rs +0 -300
  26. package/crates/team-agent/src/cli/leader_prompt.rs +0 -261
  27. package/crates/team-agent/src/cli/leaders.rs +0 -418
  28. package/crates/team-agent/src/cli/mod.rs +0 -6545
  29. package/crates/team-agent/src/cli/models.rs +0 -1206
  30. package/crates/team-agent/src/cli/named_address.rs +0 -1651
  31. package/crates/team-agent/src/cli/profile.rs +0 -342
  32. package/crates/team-agent/src/cli/route.rs +0 -212
  33. package/crates/team-agent/src/cli/schedule.rs +0 -175
  34. package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
  35. package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
  36. package/crates/team-agent/src/cli/send/persist.rs +0 -156
  37. package/crates/team-agent/src/cli/send/presentation.rs +0 -370
  38. package/crates/team-agent/src/cli/send/resolve.rs +0 -573
  39. package/crates/team-agent/src/cli/send.rs +0 -199
  40. package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
  41. package/crates/team-agent/src/cli/spec.rs +0 -165
  42. package/crates/team-agent/src/cli/status.rs +0 -280
  43. package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
  44. package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
  45. package/crates/team-agent/src/cli/status_port/brief.rs +0 -1981
  46. package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
  47. package/crates/team-agent/src/cli/status_port/format.rs +0 -146
  48. package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
  49. package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
  50. package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
  51. package/crates/team-agent/src/cli/status_port/store.rs +0 -416
  52. package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
  53. package/crates/team-agent/src/cli/status_port.rs +0 -92
  54. package/crates/team-agent/src/cli/tests/base.rs +0 -885
  55. package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
  56. package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
  57. package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -322
  58. package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
  59. package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
  60. package/crates/team-agent/src/cli/tests/mod.rs +0 -137
  61. package/crates/team-agent/src/cli/tests/named_address.rs +0 -761
  62. package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
  63. package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -484
  64. package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
  65. package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
  66. package/crates/team-agent/src/cli/tests/status_send.rs +0 -888
  67. package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
  68. package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
  69. package/crates/team-agent/src/cli/triage.rs +0 -234
  70. package/crates/team-agent/src/cli/types.rs +0 -591
  71. package/crates/team-agent/src/codex_app_server.rs +0 -546
  72. package/crates/team-agent/src/communication_mode/mod.rs +0 -56
  73. package/crates/team-agent/src/compiler/tests.rs +0 -827
  74. package/crates/team-agent/src/compiler.rs +0 -890
  75. package/crates/team-agent/src/conpty/backend.rs +0 -829
  76. package/crates/team-agent/src/conpty/mod.rs +0 -33
  77. package/crates/team-agent/src/contract_runtime/backend.rs +0 -1744
  78. package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
  79. package/crates/team-agent/src/contract_runtime/config.rs +0 -364
  80. package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -76
  81. package/crates/team-agent/src/contract_runtime/discovery.rs +0 -449
  82. package/crates/team-agent/src/contract_runtime/fork.rs +0 -361
  83. package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
  84. package/crates/team-agent/src/contract_runtime/framework.rs +0 -367
  85. package/crates/team-agent/src/contract_runtime/mcp.rs +0 -394
  86. package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
  87. package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
  88. package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
  89. package/crates/team-agent/src/contract_runtime/registry.rs +0 -553
  90. package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
  91. package/crates/team-agent/src/coordinator/backoff.rs +0 -741
  92. package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
  93. package/crates/team-agent/src/coordinator/health.rs +0 -1185
  94. package/crates/team-agent/src/coordinator/mod.rs +0 -119
  95. package/crates/team-agent/src/coordinator/orphan.rs +0 -110
  96. package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
  97. package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
  98. package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
  99. package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
  100. package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
  101. package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
  102. package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
  103. package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
  104. package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
  105. package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
  106. package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
  107. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -300
  108. package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
  109. package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
  110. package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
  111. package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -503
  112. package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
  113. package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
  114. package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
  115. package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
  116. package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
  117. package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
  118. package/crates/team-agent/src/coordinator/tick.rs +0 -3024
  119. package/crates/team-agent/src/coordinator/types.rs +0 -540
  120. package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
  121. package/crates/team-agent/src/db/message_store.rs +0 -1527
  122. package/crates/team-agent/src/db/migration.rs +0 -984
  123. package/crates/team-agent/src/db/mod.rs +0 -26
  124. package/crates/team-agent/src/db/schema.rs +0 -663
  125. package/crates/team-agent/src/diagnose/comms.rs +0 -242
  126. package/crates/team-agent/src/diagnose/mod.rs +0 -44
  127. package/crates/team-agent/src/diagnose/orphans.rs +0 -889
  128. package/crates/team-agent/src/direct_delivery.rs +0 -368
  129. package/crates/team-agent/src/event_log.rs +0 -502
  130. package/crates/team-agent/src/fake_worker.rs +0 -303
  131. package/crates/team-agent/src/inbox_store.rs +0 -169
  132. package/crates/team-agent/src/kill_audit.rs +0 -106
  133. package/crates/team-agent/src/layout/manager.rs +0 -248
  134. package/crates/team-agent/src/layout/mod.rs +0 -36
  135. package/crates/team-agent/src/layout/overlay.rs +0 -134
  136. package/crates/team-agent/src/layout/placement.rs +0 -52
  137. package/crates/team-agent/src/layout/recovery.rs +0 -106
  138. package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
  139. package/crates/team-agent/src/layout/sessions.rs +0 -294
  140. package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
  141. package/crates/team-agent/src/layout/worker_env.rs +0 -721
  142. package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
  143. package/crates/team-agent/src/leader/helpers.rs +0 -178
  144. package/crates/team-agent/src/leader/incident.rs +0 -6
  145. package/crates/team-agent/src/leader/lease.rs +0 -3356
  146. package/crates/team-agent/src/leader/mod.rs +0 -104
  147. package/crates/team-agent/src/leader/owner_bind.rs +0 -400
  148. package/crates/team-agent/src/leader/prompt.rs +0 -905
  149. package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
  150. package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
  151. package/crates/team-agent/src/leader/rediscover.rs +0 -1192
  152. package/crates/team-agent/src/leader/registry.rs +0 -888
  153. package/crates/team-agent/src/leader/start.rs +0 -4501
  154. package/crates/team-agent/src/leader/takeover.rs +0 -65
  155. package/crates/team-agent/src/leader/tests/basics.rs +0 -337
  156. package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
  157. package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
  158. package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
  159. package/crates/team-agent/src/leader/tests/identity.rs +0 -465
  160. package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
  161. package/crates/team-agent/src/leader/tests/idle.rs +0 -113
  162. package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
  163. package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
  164. package/crates/team-agent/src/leader/tests/mod.rs +0 -106
  165. package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -268
  166. package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
  167. package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
  168. package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
  169. package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
  170. package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
  171. package/crates/team-agent/src/leader/types.rs +0 -534
  172. package/crates/team-agent/src/lib.rs +0 -147
  173. package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
  174. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -881
  175. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -598
  176. package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
  177. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -204
  178. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -107
  179. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -144
  180. package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
  181. package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
  182. package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
  183. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -160
  184. package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
  185. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -899
  186. package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -225
  187. package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
  188. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5200
  189. package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
  190. package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
  191. package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
  192. package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -473
  193. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
  194. package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
  195. package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
  196. package/crates/team-agent/src/lifecycle/launch.rs +0 -557
  197. package/crates/team-agent/src/lifecycle/lock.rs +0 -350
  198. package/crates/team-agent/src/lifecycle/mod.rs +0 -79
  199. package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
  200. package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -1067
  201. package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
  202. package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2199
  203. package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1798
  204. package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +0 -163
  205. package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2362
  206. package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
  207. package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
  208. package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
  209. package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
  210. package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
  211. package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
  212. package/crates/team-agent/src/lifecycle/restart.rs +0 -227
  213. package/crates/team-agent/src/lifecycle/role_config.rs +0 -1230
  214. package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
  215. package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
  216. package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
  217. package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
  218. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
  219. package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
  220. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -447
  221. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1638
  222. package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
  223. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -770
  224. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -419
  225. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2035
  226. package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1327
  227. package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
  228. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
  229. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
  230. package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -72
  231. package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
  232. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
  233. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -512
  234. package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
  235. package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
  236. package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
  237. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3983
  238. package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
  239. package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
  240. package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
  241. package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
  242. package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
  243. package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
  244. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -164
  245. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -200
  246. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
  247. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -527
  248. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -1062
  249. package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1419
  250. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -98
  251. package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -550
  252. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -226
  253. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -332
  254. package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
  255. package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
  256. package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
  257. package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
  258. package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
  259. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
  260. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
  261. package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
  262. package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
  263. package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
  264. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
  265. package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
  266. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -342
  267. package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
  268. package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
  269. package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
  270. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
  271. package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
  272. package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
  273. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
  274. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -995
  275. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -836
  276. package/crates/team-agent/src/lifecycle/tests.rs +0 -105
  277. package/crates/team-agent/src/lifecycle/types.rs +0 -877
  278. package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -363
  279. package/crates/team-agent/src/main.rs +0 -52
  280. package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
  281. package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
  282. package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
  283. package/crates/team-agent/src/mcp_server/mod.rs +0 -119
  284. package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
  285. package/crates/team-agent/src/mcp_server/readiness.rs +0 -527
  286. package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -348
  287. package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
  288. package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
  289. package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -158
  290. package/crates/team-agent/src/mcp_server/tests/send.rs +0 -353
  291. package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -341
  292. package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
  293. package/crates/team-agent/src/mcp_server/tests.rs +0 -43
  294. package/crates/team-agent/src/mcp_server/tools.rs +0 -889
  295. package/crates/team-agent/src/mcp_server/types.rs +0 -396
  296. package/crates/team-agent/src/mcp_server/wire.rs +0 -867
  297. package/crates/team-agent/src/messaging/activity.rs +0 -461
  298. package/crates/team-agent/src/messaging/address.rs +0 -87
  299. package/crates/team-agent/src/messaging/delivery.rs +0 -3727
  300. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
  301. package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
  302. package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
  303. package/crates/team-agent/src/messaging/helpers.rs +0 -336
  304. package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
  305. package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
  306. package/crates/team-agent/src/messaging/mod.rs +0 -167
  307. package/crates/team-agent/src/messaging/persist.rs +0 -377
  308. package/crates/team-agent/src/messaging/presentation.rs +0 -417
  309. package/crates/team-agent/src/messaging/reminders.rs +0 -316
  310. package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
  311. package/crates/team-agent/src/messaging/results.rs +0 -1415
  312. package/crates/team-agent/src/messaging/scheduler.rs +0 -223
  313. package/crates/team-agent/src/messaging/selftest.rs +0 -315
  314. package/crates/team-agent/src/messaging/send.rs +0 -981
  315. package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
  316. package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -657
  317. package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
  318. package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
  319. package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
  320. package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
  321. package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
  322. package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3549
  323. package/crates/team-agent/src/messaging/tests/spine.rs +0 -853
  324. package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
  325. package/crates/team-agent/src/messaging/trust.rs +0 -215
  326. package/crates/team-agent/src/messaging/types.rs +0 -472
  327. package/crates/team-agent/src/messaging/wait.rs +0 -366
  328. package/crates/team-agent/src/messaging/watchers.rs +0 -916
  329. package/crates/team-agent/src/model/enums.rs +0 -356
  330. package/crates/team-agent/src/model/errors.rs +0 -18
  331. package/crates/team-agent/src/model/ids.rs +0 -165
  332. package/crates/team-agent/src/model/mod.rs +0 -29
  333. package/crates/team-agent/src/model/name_similarity.rs +0 -252
  334. package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
  335. package/crates/team-agent/src/model/paths.rs +0 -257
  336. package/crates/team-agent/src/model/routing.rs +0 -387
  337. package/crates/team-agent/src/model/spec.rs +0 -1184
  338. package/crates/team-agent/src/model/task_graph.rs +0 -321
  339. package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
  340. package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
  341. package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
  342. package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
  343. package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
  344. package/crates/team-agent/src/model/yaml/tests.rs +0 -188
  345. package/crates/team-agent/src/model/yaml.rs +0 -802
  346. package/crates/team-agent/src/os_probe.rs +0 -280
  347. package/crates/team-agent/src/packaging/install.rs +0 -219
  348. package/crates/team-agent/src/packaging/migrate.rs +0 -38
  349. package/crates/team-agent/src/packaging/mod.rs +0 -91
  350. package/crates/team-agent/src/packaging/repair.rs +0 -33
  351. package/crates/team-agent/src/packaging/tests.rs +0 -822
  352. package/crates/team-agent/src/packaging/types.rs +0 -417
  353. package/crates/team-agent/src/platform/argv.rs +0 -331
  354. package/crates/team-agent/src/platform/errors.rs +0 -104
  355. package/crates/team-agent/src/platform/file_lock.rs +0 -279
  356. package/crates/team-agent/src/platform/mod.rs +0 -5
  357. package/crates/team-agent/src/platform/process.rs +0 -545
  358. package/crates/team-agent/src/provider/adapter.rs +0 -1150
  359. package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
  360. package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
  361. package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
  362. package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
  363. package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
  364. package/crates/team-agent/src/provider/adapters/mod.rs +0 -30
  365. package/crates/team-agent/src/provider/adapters/pi.rs +0 -106
  366. package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
  367. package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
  368. package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
  369. package/crates/team-agent/src/provider/argv_route.rs +0 -405
  370. package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
  371. package/crates/team-agent/src/provider/classify.rs +0 -708
  372. package/crates/team-agent/src/provider/command_helpers.rs +0 -45
  373. package/crates/team-agent/src/provider/faults.rs +0 -165
  374. package/crates/team-agent/src/provider/helpers.rs +0 -52
  375. package/crates/team-agent/src/provider/mod.rs +0 -78
  376. package/crates/team-agent/src/provider/model_catalog.rs +0 -910
  377. package/crates/team-agent/src/provider/session/capture.rs +0 -2731
  378. package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
  379. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -172
  380. package/crates/team-agent/src/provider/session/context_fork.rs +0 -396
  381. package/crates/team-agent/src/provider/session/mod.rs +0 -36
  382. package/crates/team-agent/src/provider/session/resume.rs +0 -269
  383. package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
  384. package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
  385. package/crates/team-agent/src/provider/session_scan/common.rs +0 -654
  386. package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
  387. package/crates/team-agent/src/provider/session_scan/pi.rs +0 -185
  388. package/crates/team-agent/src/provider/session_scan.rs +0 -71
  389. package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
  390. package/crates/team-agent/src/provider/submit_now.rs +0 -71
  391. package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
  392. package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
  393. package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
  394. package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
  395. package/crates/team-agent/src/provider/tests/adapter.rs +0 -441
  396. package/crates/team-agent/src/provider/tests/classify.rs +0 -148
  397. package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -35
  398. package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
  399. package/crates/team-agent/src/provider/tests/faults.rs +0 -200
  400. package/crates/team-agent/src/provider/tests/idle.rs +0 -177
  401. package/crates/team-agent/src/provider/tests/wire.rs +0 -213
  402. package/crates/team-agent/src/provider/tests.rs +0 -32
  403. package/crates/team-agent/src/provider/types.rs +0 -529
  404. package/crates/team-agent/src/provider/wire.rs +0 -394
  405. package/crates/team-agent/src/redaction.rs +0 -259
  406. package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
  407. package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
  408. package/crates/team-agent/src/state/identity.rs +0 -914
  409. package/crates/team-agent/src/state/identity_keys.rs +0 -132
  410. package/crates/team-agent/src/state/mod.rs +0 -74
  411. package/crates/team-agent/src/state/owner_gate.rs +0 -482
  412. package/crates/team-agent/src/state/ownership.rs +0 -563
  413. package/crates/team-agent/src/state/paths.rs +0 -395
  414. package/crates/team-agent/src/state/persist.rs +0 -3811
  415. package/crates/team-agent/src/state/projection.rs +0 -1508
  416. package/crates/team-agent/src/state/repository/intent.rs +0 -14
  417. package/crates/team-agent/src/state/repository/tests.rs +0 -184
  418. package/crates/team-agent/src/state/repository.rs +0 -866
  419. package/crates/team-agent/src/state/selector.rs +0 -160
  420. package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
  421. package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
  422. package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
  423. package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
  424. package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
  425. package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
  426. package/crates/team-agent/src/tmux_backend/tests.rs +0 -4103
  427. package/crates/team-agent/src/tmux_backend.rs +0 -4492
  428. package/crates/team-agent/src/topology.rs +0 -537
  429. package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
  430. package/crates/team-agent/src/transport/native_input.rs +0 -491
  431. package/crates/team-agent/src/transport/test_support.rs +0 -743
  432. package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
  433. package/crates/team-agent/src/transport/tests/mod.rs +0 -194
  434. package/crates/team-agent/src/transport/tests/wire.rs +0 -574
  435. package/crates/team-agent/src/transport.rs +0 -1655
  436. package/crates/team-agent/src/transport_factory.rs +0 -819
@@ -1,899 +0,0 @@
1
- //! ---
2
- //! purpose: Pi executable/catalog 验证、原生/公共 MCP 能力注册与共享启动计划物化
3
- //! contract:
4
- //! provides:
5
- //! - name: materialize_pi_plan
6
- //! what: 为 leader 与 TeamMate 生成同一来源的 Pi CommandPlan
7
- //! - name: write_pi_wrapper
8
- //! what: 原子写入 0600 per-seat runtime MCP registration extension
9
- //! boundary:
10
- //! - 不枚举 Pi session;resume 只重验调用方给出的 exact backing
11
- //! - 不投递消息、不执行 cleanup 或 doctor 判定
12
- //! - 仅读取 settings.json 的 sessionDir,不读取 credentials
13
- //! maturity: wired
14
- //! ---
15
-
16
- use std::collections::BTreeSet;
17
- use std::fs::OpenOptions;
18
- use std::io::Write;
19
- #[cfg(test)]
20
- use std::cell::RefCell;
21
- use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
22
- use std::path::{Path, PathBuf};
23
- use std::process::Command;
24
- use std::time::Duration;
25
-
26
- use sha2::{Digest, Sha256};
27
-
28
- use crate::model::enums::{Provider, ProviderEffort};
29
- use crate::provider::adapters::pi::{build_pi_command_argv, PiCommandRequest, PiSessionSelector};
30
- use crate::provider::{CommandPlan, McpConfig, ProviderError, SessionId};
31
-
32
- /// The first executable `pi` on PATH, exactly what the worker's bare `pi`
33
- /// runs: a wrapper, npm symlink or plain binary alike. No inner binary is probed.
34
- #[derive(Debug, Clone, PartialEq, Eq)]
35
- pub(crate) struct PiExecutableChain {
36
- pub path_entry: PathBuf,
37
- pub pi_version: String,
38
- pub catalog_sha256: String,
39
- }
40
-
41
- #[derive(Debug, Clone, PartialEq, Eq)]
42
- pub(crate) struct PiSeatPaths {
43
- pub runtime_root: PathBuf,
44
- pub wrapper: PathBuf,
45
- pub sessions: PathBuf,
46
- }
47
-
48
- #[derive(Debug, Clone, Copy, PartialEq, Eq)]
49
- pub(crate) enum PiCleanupAction {
50
- Stop,
51
- Remove,
52
- }
53
-
54
- #[derive(Debug, Clone, PartialEq, Eq)]
55
- pub(crate) struct PiCleanupPlan {
56
- pub delete_paths: Vec<PathBuf>,
57
- pub retain_paths: Vec<PathBuf>,
58
- pub process_name_scan: Option<String>,
59
- }
60
-
61
- /// ---
62
- /// purpose: 给 stop/remove 生成 Pi 席位 exact cleanup 计划
63
- /// returns: stop 全保留;remove 只删 wrapper 并保留 session backing
64
- /// ---
65
- pub(crate) fn pi_cleanup_plan(action: PiCleanupAction, paths: &PiSeatPaths) -> PiCleanupPlan {
66
- match action {
67
- PiCleanupAction::Stop => PiCleanupPlan {
68
- delete_paths: Vec::new(),
69
- retain_paths: vec![paths.wrapper.clone(), paths.sessions.clone()],
70
- process_name_scan: None,
71
- },
72
- PiCleanupAction::Remove => PiCleanupPlan {
73
- delete_paths: vec![paths.wrapper.clone()],
74
- retain_paths: vec![paths.sessions.clone()],
75
- process_name_scan: None,
76
- },
77
- }
78
- }
79
-
80
- /// ---
81
- /// purpose: 计算一个 Pi 席位唯一的 Team-owned runtime 路径
82
- /// returns: runtime root、wrapper 与 sessions 路径
83
- /// ---
84
- pub(crate) fn pi_seat_paths(workspace: &Path, team_id: &str, agent_id: &str) -> PiSeatPaths {
85
- let runtime_root = workspace
86
- .join(".team")
87
- .join("runtime")
88
- .join("pi")
89
- .join(team_id)
90
- .join(agent_id);
91
- let workspace = workspace
92
- .canonicalize()
93
- .unwrap_or_else(|_| workspace.to_path_buf());
94
- // Match Pi's getDefaultSessionDir: sessions/--<encoded absolute cwd>--.
95
- // Identity comes from --session-id, not a private per-seat directory.
96
- let sessions = if let Some(value) =
97
- std::env::var_os("PI_CODING_AGENT_SESSION_DIR").filter(|value| !value.is_empty())
98
- {
99
- resolve_pi_path(&workspace, Path::new(&value))
100
- } else {
101
- let agent_dir = std::env::var_os("PI_CODING_AGENT_DIR")
102
- .filter(|value| !value.is_empty())
103
- .map(PathBuf::from)
104
- .unwrap_or_else(|| std::env::home_dir().unwrap_or_default().join(".pi/agent"));
105
- let agent_dir = resolve_pi_path(&workspace, &agent_dir);
106
- // Pi reads sessionDir before project trust. A present project value
107
- // shadows the global value, including an empty/null value (default).
108
- let setting = [
109
- workspace.join(".pi/settings.json"),
110
- agent_dir.join("settings.json"),
111
- ]
112
- .into_iter()
113
- .find_map(|path| {
114
- let value: serde_json::Value =
115
- serde_json::from_slice(&std::fs::read(path).ok()?).ok()?;
116
- value.get("sessionDir").cloned()
117
- });
118
- if let Some(path) = setting
119
- .as_ref()
120
- .and_then(serde_json::Value::as_str)
121
- .filter(|path| !path.is_empty())
122
- {
123
- resolve_pi_path(&workspace, Path::new(path))
124
- } else {
125
- let encoded = workspace.to_string_lossy();
126
- let encoded = encoded
127
- .strip_prefix(['/', '\\'])
128
- .unwrap_or(&encoded)
129
- .replace(['/', '\\', ':'], "-");
130
- agent_dir.join("sessions").join(format!("--{encoded}--"))
131
- }
132
- };
133
- PiSeatPaths {
134
- wrapper: runtime_root.join("team-mcp.ts"),
135
- sessions,
136
- runtime_root,
137
- }
138
- }
139
-
140
- fn resolve_pi_path(workspace: &Path, path: &Path) -> PathBuf {
141
- let home = std::env::home_dir().unwrap_or_default();
142
- let path = path
143
- .strip_prefix("~")
144
- .map(|tail| home.join(tail))
145
- .unwrap_or_else(|_| path.to_path_buf());
146
- let path = if path.is_absolute() {
147
- path
148
- } else {
149
- workspace.join(path)
150
- };
151
- // Canonicalize existing parents too (e.g. macOS /var), even for new roots.
152
- if let Ok(canonical) = path.canonicalize() {
153
- return canonical;
154
- }
155
- path.ancestors()
156
- .skip(1)
157
- .find_map(|ancestor| {
158
- ancestor
159
- .canonicalize()
160
- .ok()
161
- .map(|base| base.join(path.strip_prefix(ancestor).expect("ancestor prefix")))
162
- })
163
- .unwrap_or(path)
164
- }
165
-
166
- /// ---
167
- /// purpose: 为 Pi fresh 启动生成框架预分配 UUID
168
- /// returns: 新 SessionId
169
- /// ---
170
- pub(crate) fn new_pi_session_id() -> SessionId {
171
- SessionId::new(crate::provider::adapter::next_session_token())
172
- }
173
-
174
- /// ---
175
- /// purpose: 解析 pi --list-models 未过滤表格为 provider/model exact ids
176
- /// returns: 保序且无重复的 exact ids
177
- /// errors: 非 UTF-8、header/row 异常、重复或空 catalog 时返回 ProviderError
178
- /// ---
179
- pub(crate) fn parse_pi_list_models_table(bytes: &[u8]) -> Result<Vec<String>, ProviderError> {
180
- crate::provider::model_catalog::parse_pi_catalog(bytes)
181
- .map(|records| records.into_iter().map(|record| record.id).collect())
182
- .map_err(|error| ProviderError::Command(error.pi_legacy_message()))
183
- }
184
-
185
- /// ---
186
- /// purpose: 在动态 catalog 中只接受一个字节精确的 qualified model
187
- /// returns: exact catalog id
188
- /// errors: 非 qualified、wildcard、缺失或重复时返回 ProviderError
189
- /// ---
190
- pub(crate) fn select_exact_pi_model(
191
- models: &[String],
192
- requested: &str,
193
- ) -> Result<String, ProviderError> {
194
- if requested.trim() != requested
195
- || requested.is_empty()
196
- || requested.contains('*')
197
- || !requested
198
- .split_once('/')
199
- .is_some_and(|(provider, model)| !provider.is_empty() && !model.is_empty())
200
- {
201
- return Err(ProviderError::Command(format!(
202
- "Pi model must be a qualified exact catalog id: {requested:?}"
203
- )));
204
- }
205
- let mut matches = models.iter().filter(|model| model.as_str() == requested);
206
- let selected = matches.next().ok_or_else(|| {
207
- ProviderError::Command(format!("Pi model is not in the live catalog: {requested}"))
208
- })?;
209
- if matches.next().is_some() {
210
- return Err(ProviderError::Command(format!(
211
- "Pi model catalog selection is ambiguous: {requested}"
212
- )));
213
- }
214
- Ok(selected.clone())
215
- }
216
-
217
- /// ---
218
- /// purpose: 对比选定与启动后客观观测到的 Pi model identity
219
- /// returns: 完全相等且非空时成功
220
- /// errors: 缺失或不匹配时返回 ProviderError
221
- /// ---
222
- pub(crate) fn verify_started_pi_model(selected: &str, observed: &str) -> Result<(), ProviderError> {
223
- if observed.is_empty() || selected != observed {
224
- return Err(ProviderError::Command(format!(
225
- "Pi started model mismatch: selected={selected:?} observed={observed:?}"
226
- )));
227
- }
228
- Ok(())
229
- }
230
-
231
- /// ---
232
- /// purpose: 校验 Pi PATH entry 与 live catalog;MCP 能力在实际 Pi context 验证
233
- /// returns: PATH entry 与 catalog receipt 完整时成功
234
- /// errors: 缺路径或 catalog receipt 时返回 ProviderError
235
- /// ---
236
- pub(crate) fn validate_pi_executable_chain(chain: &PiExecutableChain) -> Result<(), ProviderError> {
237
- if !chain.path_entry.is_absolute()
238
- || chain.path_entry.file_name().is_none_or(|name| name != "pi")
239
- || chain.catalog_sha256.len() != 64
240
- || !chain
241
- .catalog_sha256
242
- .bytes()
243
- .all(|byte| byte.is_ascii_hexdigit())
244
- || chain.catalog_sha256.bytes().all(|byte| byte == b'0')
245
- {
246
- return Err(ProviderError::Command(
247
- "Pi executable chain does not provide the required public protocol".to_string(),
248
- ));
249
- }
250
- Ok(())
251
- }
252
-
253
- pub(crate) struct PiWrapperRequest<'a> {
254
- pub destination: &'a Path,
255
- pub candidate_executable: &'a Path,
256
- pub mcp_config: &'a McpConfig,
257
- pub team_id: &'a str,
258
- pub agent_id: &'a str,
259
- pub workspace: &'a Path,
260
- pub include_tools: &'a [&'a str],
261
- }
262
-
263
- fn team_server(
264
- config: &McpConfig,
265
- ) -> Result<serde_json::Map<String, serde_json::Value>, ProviderError> {
266
- let server = config
267
- .raw
268
- .get("team_orchestrator")
269
- .or_else(|| config.raw.pointer("/mcpServers/team_orchestrator"))
270
- .and_then(serde_json::Value::as_object)
271
- .cloned()
272
- .ok_or_else(|| {
273
- ProviderError::Command("resolved MCP config is missing team_orchestrator".to_string())
274
- })?;
275
- Ok(server)
276
- }
277
-
278
- fn candidate_from_mcp_config(config: &McpConfig) -> Result<PathBuf, ProviderError> {
279
- let server = team_server(config)?;
280
- let command = server
281
- .get("command")
282
- .and_then(serde_json::Value::as_str)
283
- .filter(|value| !value.is_empty())
284
- .map(PathBuf::from)
285
- .ok_or_else(|| {
286
- ProviderError::Command("resolved team_orchestrator MCP command is missing".to_string())
287
- })?;
288
- if !command.is_absolute() {
289
- return Err(ProviderError::Command(
290
- "resolved team_orchestrator MCP command must be absolute".to_string(),
291
- ));
292
- }
293
- Ok(command)
294
- }
295
-
296
- fn render_pi_wrapper(request: &PiWrapperRequest<'_>) -> Result<String, ProviderError> {
297
- let allowed = request.include_tools.iter().copied().collect::<BTreeSet<_>>();
298
- if allowed.is_empty()
299
- || allowed.len() != request.include_tools.len()
300
- || allowed
301
- .iter()
302
- .any(|tool| !["send_message", "report_result", "get_team_status"].contains(tool))
303
- {
304
- return Err(ProviderError::Command(
305
- "Pi MCP tools must be a non-empty subset of the three Team tools".to_string(),
306
- ));
307
- }
308
- let configured_candidate = candidate_from_mcp_config(request.mcp_config)?;
309
- let expected = std::fs::canonicalize(request.candidate_executable)
310
- .unwrap_or_else(|_| request.candidate_executable.to_path_buf());
311
- let configured = std::fs::canonicalize(&configured_candidate).unwrap_or(configured_candidate);
312
- if configured != expected {
313
- return Err(ProviderError::Command(format!(
314
- "Pi wrapper candidate mismatch: expected {} got {}",
315
- expected.display(),
316
- configured.display()
317
- )));
318
- }
319
- let mut server = team_server(request.mcp_config)?;
320
- server.insert(
321
- "command".to_string(),
322
- serde_json::Value::String(expected.to_string_lossy().into_owned()),
323
- );
324
- server.insert(
325
- "includeTools".to_string(),
326
- serde_json::Value::Array(
327
- request
328
- .include_tools
329
- .iter()
330
- .map(|tool| serde_json::Value::String((*tool).to_string()))
331
- .collect(),
332
- ),
333
- );
334
- let env = server
335
- .entry("env".to_string())
336
- .or_insert_with(|| serde_json::Value::Object(serde_json::Map::new()))
337
- .as_object_mut()
338
- .ok_or_else(|| ProviderError::Command("Pi MCP server env must be an object".to_string()))?;
339
- env.insert(
340
- "TEAM_AGENT_WORKSPACE".to_string(),
341
- serde_json::Value::String(request.workspace.to_string_lossy().into_owned()),
342
- );
343
- env.insert(
344
- "TEAM_AGENT_ID".to_string(),
345
- serde_json::Value::String(request.agent_id.to_string()),
346
- );
347
- env.insert(
348
- "TEAM_AGENT_AGENT_ID".to_string(),
349
- serde_json::Value::String(request.agent_id.to_string()),
350
- );
351
- env.insert(
352
- "TEAM_AGENT_OWNER_TEAM_ID".to_string(),
353
- serde_json::Value::String(request.team_id.to_string()),
354
- );
355
- let definition = serde_json::to_string(&serde_json::Value::Object(server))
356
- .map_err(|error| ProviderError::Command(format!("serialize Pi MCP server: {error}")))?;
357
- let receipt_root = request
358
- .destination
359
- .parent()
360
- .filter(|path| path.is_absolute())
361
- .ok_or_else(|| {
362
- ProviderError::Command("Pi MCP wrapper requires an absolute seat directory".to_string())
363
- })?;
364
- let receipt_root = serde_json::to_string(&receipt_root.to_string_lossy())
365
- .map_err(|error| ProviderError::Command(format!("serialize Pi MCP seat directory: {error}")))?;
366
- Ok(format!(
367
- "const teamMcpDefinition = {definition};\nconst teamMcpReceiptRoot = {receipt_root};\n\n{}",
368
- include_str!("pi_mcp_extension.js")
369
- ))
370
- }
371
-
372
- /// ---
373
- /// purpose: 静态核对 wrapper 使用原生/公共 MCP 能力模板与指定 candidate
374
- /// returns: 模板完整且 candidate、seat 目录正确时成功
375
- /// errors: 模板、candidate 或 seat 目录不匹配时返回 ProviderError
376
- /// ---
377
- pub(crate) fn validate_pi_wrapper_source(
378
- source: &str,
379
- candidate_executable: &Path,
380
- ) -> Result<(), ProviderError> {
381
- let invalid = || {
382
- ProviderError::Command(
383
- "Pi wrapper source is not the owned MCP capability template".to_string(),
384
- )
385
- };
386
- let prefix = source
387
- .strip_suffix(include_str!("pi_mcp_extension.js"))
388
- .ok_or_else(invalid)?;
389
- let (definition, root) = prefix
390
- .strip_prefix("const teamMcpDefinition = ")
391
- .and_then(|value| value.split_once(";\nconst teamMcpReceiptRoot = "))
392
- .ok_or_else(invalid)?;
393
- let definition: serde_json::Value = serde_json::from_str(definition).map_err(|_| invalid())?;
394
- let command = definition
395
- .get("command")
396
- .and_then(serde_json::Value::as_str)
397
- .ok_or_else(invalid)?;
398
- let root: String = serde_json::from_str(root.strip_suffix(";\n\n").ok_or_else(invalid)?)
399
- .map_err(|_| invalid())?;
400
- let expected = std::fs::canonicalize(candidate_executable)
401
- .unwrap_or_else(|_| candidate_executable.to_path_buf());
402
- if Path::new(command) != expected || !Path::new(&root).is_absolute() {
403
- return Err(invalid());
404
- }
405
- Ok(())
406
- }
407
-
408
- /// ---
409
- /// purpose: 在 seat root 原子写入 mode 0600 的 runtime MCP registration extension
410
- /// returns: 最终 wrapper 路径
411
- /// errors: identity、序列化、目录、写盘或 rename 失败时返回 ProviderError
412
- /// ---
413
- pub(crate) fn write_pi_wrapper(request: PiWrapperRequest<'_>) -> Result<PathBuf, ProviderError> {
414
- write_pi_wrapper_with_publish(request, |from, to| std::fs::rename(from, to))
415
- }
416
-
417
- pub(crate) fn write_pi_wrapper_with_publish(
418
- request: PiWrapperRequest<'_>,
419
- publish: impl FnOnce(&Path, &Path) -> std::io::Result<()>,
420
- ) -> Result<PathBuf, ProviderError> {
421
- let source = render_pi_wrapper(&request)?;
422
- validate_pi_wrapper_source(&source, request.candidate_executable)?;
423
- let parent = request.destination.parent().ok_or_else(|| {
424
- ProviderError::Io("Pi wrapper destination has no parent directory".to_string())
425
- })?;
426
- std::fs::create_dir_all(parent).map_err(|error| {
427
- ProviderError::Io(format!(
428
- "Pi wrapper atomic write stage=create_parent path={}: {error}",
429
- parent.display()
430
- ))
431
- })?;
432
- let temp = parent.join(format!(".team-mcp.ts.{}.tmp", std::process::id()));
433
- let write_result = (|| {
434
- let mut file = OpenOptions::new()
435
- .create_new(true)
436
- .write(true)
437
- .mode(0o600)
438
- .open(&temp)
439
- .map_err(|error| {
440
- ProviderError::Io(format!(
441
- "Pi wrapper atomic write stage=open_temp path={}: {error}",
442
- temp.display()
443
- ))
444
- })?;
445
- file.write_all(source.as_bytes()).map_err(|error| {
446
- ProviderError::Io(format!(
447
- "Pi wrapper atomic write stage=write_temp path={}: {error}",
448
- temp.display()
449
- ))
450
- })?;
451
- file.set_permissions(std::fs::Permissions::from_mode(0o600))
452
- .map_err(|error| {
453
- ProviderError::Io(format!(
454
- "Pi wrapper atomic write stage=chmod_temp_fd path={}: {error}",
455
- temp.display()
456
- ))
457
- })?;
458
- file.sync_all().map_err(|error| {
459
- ProviderError::Io(format!(
460
- "Pi wrapper atomic write stage=fsync_temp path={}: {error}",
461
- temp.display()
462
- ))
463
- })?;
464
- publish(&temp, request.destination).map_err(|error| {
465
- ProviderError::Io(format!(
466
- "Pi wrapper atomic write stage=rename_publish from={} to={}: {error}",
467
- temp.display(),
468
- request.destination.display()
469
- ))
470
- })?;
471
- Ok(request.destination.to_path_buf())
472
- })();
473
- if write_result.is_err() {
474
- let _ = std::fs::remove_file(&temp);
475
- }
476
- write_result
477
- }
478
-
479
- #[derive(Debug, Clone, PartialEq, Eq)]
480
- pub(crate) struct PiLeaderArgs {
481
- pub model: Option<String>,
482
- pub effort: Option<ProviderEffort>,
483
- pub session_dir: Option<PathBuf>,
484
- }
485
-
486
- /// ---
487
- /// purpose: 解析 Pi leader 的 native model/thinking/session-dir 输入
488
- /// returns: 调用方显式给出的 qualified model、effort 与 session directory
489
- /// errors: 重复、未知或 materializer-owned flag 时返回 ProviderError
490
- /// ---
491
- pub(crate) fn parse_pi_leader_args(args: &[String]) -> Result<PiLeaderArgs, ProviderError> {
492
- let args = args.strip_prefix(&["--".to_string()]).unwrap_or(args);
493
- let mut model = None;
494
- let mut effort = None;
495
- let mut session_dir = None;
496
- let mut index = 0;
497
- while index < args.len() {
498
- let flag = args[index].as_str();
499
- let value = args.get(index + 1).ok_or_else(|| {
500
- ProviderError::Command(format!("Pi leader argument {flag} requires a value"))
501
- })?;
502
- match flag {
503
- "--model" if model.is_none() => model = Some(value.clone()),
504
- "--session-dir" if session_dir.is_none() && !value.is_empty() => {
505
- session_dir = Some(PathBuf::from(value));
506
- }
507
- "--thinking" if effort.is_none() => {
508
- let parsed = ProviderEffort::parse(value).ok_or_else(|| {
509
- ProviderError::Command(format!("unknown Pi thinking effort {value:?}"))
510
- })?;
511
- effort = parsed
512
- .resolve_for_provider(Provider::Pi)
513
- .map_err(|reason| ProviderError::Command(reason.to_string()))?;
514
- }
515
- _ => {
516
- return Err(ProviderError::Command(format!(
517
- "Pi leader accepts one --model, --thinking and --session-dir; got {flag:?}"
518
- )));
519
- }
520
- }
521
- index += 2;
522
- }
523
- if model.as_ref().is_some_and(|model| {
524
- model.contains('*')
525
- || !model
526
- .split_once('/')
527
- .is_some_and(|(provider, name)| !provider.is_empty() && !name.is_empty())
528
- }) {
529
- return Err(ProviderError::Command(
530
- "Pi leader --model must be a qualified exact id".to_string(),
531
- ));
532
- }
533
- Ok(PiLeaderArgs {
534
- model,
535
- effort,
536
- session_dir,
537
- })
538
- }
539
-
540
- fn sha256(bytes: &[u8]) -> String {
541
- format!("{:x}", Sha256::digest(bytes))
542
- }
543
-
544
- #[cfg(test)]
545
- #[derive(Debug, Default)]
546
- pub(crate) struct PiCatalogTestObservation {
547
- pub(crate) spawn_count: usize,
548
- pub(crate) argv: Vec<String>,
549
- pub(crate) parent_pid: Option<u32>,
550
- pub(crate) parent_exit_success: Option<bool>,
551
- pub(crate) parent_exit_code: Option<i32>,
552
- pub(crate) reader_timeout: bool,
553
- }
554
-
555
- #[cfg(test)]
556
- struct PiCatalogTestContext {
557
- receipt: PathBuf,
558
- helper_mode: Option<String>,
559
- observation: PiCatalogTestObservation,
560
- }
561
-
562
- #[cfg(test)]
563
- thread_local! {
564
- static PI_CATALOG_TEST_CONTEXT: RefCell<Option<PiCatalogTestContext>> = RefCell::new(None);
565
- }
566
-
567
- #[cfg(test)]
568
- pub(crate) fn with_pi_catalog_test_observation<T>(
569
- receipt: &Path,
570
- helper_mode: Option<&str>,
571
- action: impl FnOnce() -> T,
572
- ) -> (T, PiCatalogTestObservation) {
573
- PI_CATALOG_TEST_CONTEXT.with(|slot| {
574
- assert!(slot
575
- .replace(Some(PiCatalogTestContext {
576
- receipt: receipt.to_path_buf(),
577
- helper_mode: helper_mode.map(str::to_owned),
578
- observation: PiCatalogTestObservation::default(),
579
- }))
580
- .is_none());
581
- let result = action();
582
- let context = slot.take().expect("Pi catalog test context");
583
- (result, context.observation)
584
- })
585
- }
586
-
587
- #[cfg(test)]
588
- fn observe_pi_catalog_test(f: impl FnOnce(&mut PiCatalogTestContext)) {
589
- PI_CATALOG_TEST_CONTEXT.with(|slot| {
590
- if let Some(context) = slot.borrow_mut().as_mut() {
591
- f(context);
592
- }
593
- });
594
- }
595
-
596
- #[cfg(test)]
597
- pub(crate) fn run_pi_catalog_after_parent_exit_for_test(
598
- stdout: std::process::ChildStdout,
599
- parent_pid: u32,
600
- status: std::process::ExitStatus,
601
- timeout: Duration,
602
- max_bytes: u64,
603
- ) -> Result<Vec<u8>, String> {
604
- observe_pi_catalog_test(|context| {
605
- context.observation.parent_pid = Some(parent_pid);
606
- context.observation.parent_exit_success = Some(status.success());
607
- context.observation.parent_exit_code = status.code();
608
- });
609
- crate::provider::model_catalog::finish_stdout_after_exit(
610
- stdout, status, timeout, max_bytes, &mut PiCatalogObserver,
611
- )
612
- .map_err(|error| error.pi_legacy_message())
613
- }
614
-
615
- /// Shared bounded native-command runner; launch preflight keeps its exact model gate.
616
- pub(crate) fn run_pi_catalog(
617
- executable: &Path,
618
- timeout: Duration,
619
- max_bytes: u64,
620
- ) -> Result<Vec<u8>, String> {
621
- let mut extra_env = Vec::new();
622
- #[cfg(test)]
623
- observe_pi_catalog_test(|context| {
624
- context.observation.spawn_count += 1;
625
- context.observation.argv.push("--list-models".to_string());
626
- extra_env.push(("TEAM_AGENT_MODELS_TIMEOUT_RECEIPT".into(), context.receipt.as_os_str().into()));
627
- if let Some(mode) = context.helper_mode.as_deref() {
628
- extra_env.push(("TEAM_AGENT_MODELS_TIMEOUT_MODE".into(), mode.into()));
629
- }
630
- });
631
- crate::provider::model_catalog::run_command(
632
- executable, &["--list-models"], None, None, &[], &extra_env, timeout, max_bytes,
633
- &mut PiCatalogObserver,
634
- )
635
- .map_err(|error| error.pi_legacy_message())
636
- }
637
-
638
- struct PiCatalogObserver;
639
- impl crate::provider::model_catalog::CatalogObserver for PiCatalogObserver {
640
- #[cfg(test)]
641
- fn spawned(&mut self, pid: u32) {
642
- observe_pi_catalog_test(|context| context.observation.parent_pid = Some(pid));
643
- }
644
-
645
- #[cfg(test)]
646
- fn exited(&mut self, status: &std::process::ExitStatus) {
647
- observe_pi_catalog_test(|context| {
648
- context.observation.parent_exit_success = Some(status.success());
649
- context.observation.parent_exit_code = status.code();
650
- });
651
- }
652
-
653
- #[cfg(test)]
654
- fn output_timeout(&mut self) {
655
- observe_pi_catalog_test(|context| context.observation.reader_timeout = true);
656
- }
657
- }
658
-
659
- pub(crate) fn pi_model_candidates(requested: &str) -> Result<Vec<String>, ProviderError> {
660
- let executable = pi_path_entry()?;
661
- let catalog = run_pi_catalog(&executable, Duration::from_secs(10), 1024 * 1024)
662
- .map_err(ProviderError::Command)?;
663
- let models = parse_pi_list_models_table(&catalog)?;
664
- Ok(models
665
- .into_iter()
666
- .filter(|model| {
667
- model
668
- .rsplit_once('/')
669
- .is_some_and(|(_, name)| name == requested)
670
- })
671
- .collect())
672
- }
673
-
674
- /// The shell's own PATH choice: the first executable `pi`, kept as found.
675
- fn pi_path_entry() -> Result<PathBuf, ProviderError> {
676
- let path = std::env::var_os("PATH")
677
- .ok_or_else(|| ProviderError::Command("PATH is not set".to_string()))?;
678
- team_agent_contract::host::command::PublicCommand::resolve("pi", &path)
679
- .map(|command| command.entry)
680
- .map_err(|_| ProviderError::Command("Pi executable not found on PATH".to_string()))
681
- }
682
-
683
- fn command_stdout(executable: &Path, args: &[&str]) -> Result<Vec<u8>, ProviderError> {
684
- let output = Command::new(executable)
685
- .args(args)
686
- .output()
687
- .map_err(|error| {
688
- ProviderError::Io(format!(
689
- "{} {}: {error}",
690
- executable.display(),
691
- args.join(" ")
692
- ))
693
- })?;
694
- if !output.status.success() {
695
- return Err(ProviderError::Command(format!(
696
- "{} {} exited {}",
697
- executable.display(),
698
- args.join(" "),
699
- output.status
700
- )));
701
- }
702
- Ok(output.stdout)
703
- }
704
-
705
- /// ---
706
- /// purpose: 从当前 PATH 环境测量 Pi launch/real executable 与 live catalog,不检查 Pi packages
707
- /// returns: 已验证的 chain 与同次 live catalog exact ids
708
- /// errors: 缺失、命令失败或任一公共 protocol capability 缺失时返回 ProviderError
709
- /// ---
710
- pub(crate) fn resolve_pi_executable_chain(
711
- ) -> Result<(PiExecutableChain, Vec<String>), ProviderError> {
712
- // Probe through the PATH entry itself so a user wrapper sees every probe.
713
- let path_entry = pi_path_entry()?;
714
- let version =
715
- String::from_utf8(command_stdout(&path_entry, &["--version"])?).map_err(|error| {
716
- ProviderError::Command(format!("Pi version output is not UTF-8: {error}"))
717
- })?;
718
- let catalog = command_stdout(&path_entry, &["--list-models"])?;
719
- let models = parse_pi_list_models_table(&catalog)?;
720
- let chain = PiExecutableChain {
721
- path_entry,
722
- pi_version: version.trim().to_string(),
723
- catalog_sha256: sha256(&catalog),
724
- };
725
- validate_pi_executable_chain(&chain)?;
726
- Ok((chain, models))
727
- }
728
-
729
- #[derive(Debug, Clone, Copy, PartialEq, Eq)]
730
- pub(crate) enum PiSessionScope {
731
- Isolated,
732
- NativeDefault,
733
- }
734
-
735
- /// Zero-argument managed Pi is the interactive leader entry. Only that route
736
- /// may use Pi's cwd-keyed native session root; every explicit or worker route
737
- /// remains Team Agent session-isolated.
738
- pub(crate) fn pi_leader_session_scope(
739
- provider_args: &[String],
740
- external_path: bool,
741
- allow_nested_attach: bool,
742
- ) -> PiSessionScope {
743
- if provider_args.is_empty() && !external_path && !allow_nested_attach {
744
- PiSessionScope::NativeDefault
745
- } else {
746
- PiSessionScope::Isolated
747
- }
748
- }
749
-
750
- pub(crate) struct PiMaterializeRequest<'a> {
751
- pub workspace: &'a Path,
752
- pub team_id: &'a str,
753
- pub agent_id: &'a str,
754
- pub model: Option<&'a str>,
755
- pub effort: Option<ProviderEffort>,
756
- pub system_prompt: &'a str,
757
- pub team_mcp_tools: &'a [&'a str],
758
- pub mcp_config: &'a McpConfig,
759
- pub session_scope: PiSessionScope,
760
- /// Explicit native --session-dir, or the recorded root for exact resume.
761
- pub session_dir: Option<&'a Path>,
762
- }
763
-
764
- /// ---
765
- /// purpose: 共享物化 Pi leader 与 TeamMate 的 wrapper 和 CommandPlan
766
- /// returns: isolated seats use native --session-id for exact capture in shared native roots;
767
- /// the zero-argument interactive leader preserves Pi's defaults
768
- /// errors: resolver、exact model、wrapper 或 argv 构造失败时返回 ProviderError
769
- /// ---
770
- pub(crate) fn materialize_pi_plan(
771
- request: PiMaterializeRequest<'_>,
772
- ) -> Result<CommandPlan, ProviderError> {
773
- materialize_pi_plan_with_session(request, None)
774
- }
775
-
776
- /// ---
777
- /// purpose: 用上游已验证的 captured id/path 物化 Pi exact-path resume 计划
778
- /// returns: 与 fresh 共用 resolver/wrapper/argv builder,且不再生成 session id
779
- /// errors: backing 缺失、越出 recorded root 或 header id/cwd 不匹配时拒绝
780
- /// ---
781
- pub(crate) fn materialize_pi_resume_plan(
782
- request: PiMaterializeRequest<'_>,
783
- session_id: &SessionId,
784
- session_path: &Path,
785
- spawn_cwd: &Path,
786
- ) -> Result<CommandPlan, ProviderError> {
787
- materialize_pi_plan_with_session(request, Some((session_id, session_path, spawn_cwd)))
788
- }
789
-
790
- fn materialize_pi_plan_with_session(
791
- request: PiMaterializeRequest<'_>,
792
- resume: Option<(&SessionId, &Path, &Path)>,
793
- ) -> Result<CommandPlan, ProviderError> {
794
- let (_chain, catalog) = resolve_pi_executable_chain()?;
795
- let model = request
796
- .model
797
- .map(|model| select_exact_pi_model(&catalog, model))
798
- .transpose()?;
799
- let mut paths = pi_seat_paths(request.workspace, request.team_id, request.agent_id);
800
- if let Some(session_dir) = request.session_dir {
801
- paths.sessions = resolve_pi_path(request.workspace, session_dir);
802
- } else if resume
803
- .is_some_and(|(_, path, _)| path.starts_with(paths.runtime_root.join("sessions")))
804
- {
805
- // Older state may still point at the original Team-owned backing.
806
- paths.sessions = paths.runtime_root.join("sessions");
807
- }
808
- let session_dir = match request.session_scope {
809
- PiSessionScope::Isolated => Some(paths.sessions.as_path()),
810
- PiSessionScope::NativeDefault => None,
811
- };
812
- let resume = if let Some((session_id, session_path, spawn_cwd)) = resume {
813
- let session_dir = session_dir.ok_or_else(|| {
814
- ProviderError::ResumeUnavailable(format!(
815
- "Pi session root is unavailable {}",
816
- paths.sessions.display()
817
- ))
818
- })?;
819
- let session_root = std::fs::canonicalize(session_dir).map_err(|error| {
820
- ProviderError::ResumeUnavailable(format!(
821
- "Pi session root is unavailable {}: {error}",
822
- paths.sessions.display()
823
- ))
824
- })?;
825
- let exact_path = std::fs::canonicalize(session_path).map_err(|error| {
826
- ProviderError::ResumeUnavailable(format!(
827
- "Pi exact session backing is unavailable {}: {error}",
828
- session_path.display()
829
- ))
830
- })?;
831
- if !exact_path.starts_with(&session_root) {
832
- return Err(ProviderError::ResumeUnavailable(format!(
833
- "Pi exact session backing is outside the recorded seat root: {}",
834
- exact_path.display()
835
- )));
836
- }
837
- crate::provider::session_scan::pi::validate_exact_backing(
838
- &exact_path,
839
- session_id,
840
- spawn_cwd,
841
- )?;
842
- Some((session_id, exact_path))
843
- } else {
844
- if let Some(session_dir) = session_dir {
845
- if !session_dir.is_absolute() {
846
- return Err(ProviderError::Io(
847
- "Pi sessions require an absolute PI_CODING_AGENT_DIR or user home".to_string(),
848
- ));
849
- }
850
- std::fs::create_dir_all(session_dir).map_err(|error| {
851
- ProviderError::Io(format!("{}: {error}", session_dir.display()))
852
- })?;
853
- }
854
- None
855
- };
856
- let candidate = candidate_from_mcp_config(request.mcp_config)?;
857
- let wrapper = write_pi_wrapper(PiWrapperRequest {
858
- destination: &paths.wrapper,
859
- candidate_executable: &candidate,
860
- mcp_config: request.mcp_config,
861
- team_id: request.team_id,
862
- agent_id: request.agent_id,
863
- workspace: request.workspace,
864
- include_tools: request.team_mcp_tools,
865
- })?;
866
- let (argv, expected_session_id) = if let Some((_session_id, exact_path)) = resume {
867
- let argv = build_pi_command_argv(PiCommandRequest {
868
- extension: &wrapper,
869
- model: model.as_deref(),
870
- effort: request.effort,
871
- system_prompt: request.system_prompt,
872
- session_dir,
873
- session: PiSessionSelector::Resume { path: &exact_path },
874
- agent_id: request.agent_id,
875
- })?;
876
- (argv, None)
877
- } else {
878
- let session_id =
879
- (request.session_scope == PiSessionScope::Isolated).then(new_pi_session_id);
880
- let argv = build_pi_command_argv(PiCommandRequest {
881
- extension: &wrapper,
882
- model: model.as_deref(),
883
- effort: request.effort,
884
- system_prompt: request.system_prompt,
885
- session_dir,
886
- session: session_id.as_ref().map_or(PiSessionSelector::Fresh, |id| {
887
- PiSessionSelector::FreshWithId { id }
888
- }),
889
- agent_id: request.agent_id,
890
- })?;
891
- (argv, session_id)
892
- };
893
- Ok(CommandPlan {
894
- argv,
895
- expected_session_id,
896
- provider_projects_root: session_dir.map(Path::to_path_buf),
897
- managed_mcp_config: false,
898
- })
899
- }