@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,240 +0,0 @@
1
- //!
2
- use super::*;
3
-
4
- pub(super) fn compact_status(full: Value) -> Value {
5
- let not_ready = compact_not_ready(&full);
6
- let ready = compact_ready(&full, &not_ready);
7
- let grok_slot = full.get("grok_slot").cloned().unwrap_or(Value::Null);
8
- let grok_identity_slot_ok = grok_slot.get("consistent").and_then(Value::as_bool) == Some(true)
9
- && grok_slot.get("readable").and_then(Value::as_bool) == Some(true);
10
- json!({
11
- "ok": true,
12
- "team": full.get("team").cloned().unwrap_or(Value::Null),
13
- "session_name": full.get("session_name").cloned().unwrap_or(Value::Null),
14
- "leader_attach_command": full.get("leader_attach_command").cloned().unwrap_or(Value::Null),
15
- "ready": ready,
16
- "not_ready": not_ready,
17
- "grok_slot": grok_slot,
18
- "grok_identity_slot_ok": grok_identity_slot_ok,
19
- "agents": compact_agents(full.get("agents")),
20
- })
21
- }
22
-
23
- /// Synthesized readiness boolean for the slim payload. Stricter than the
24
- /// raw `readiness.ready` because it also folds in coordinator + schema +
25
- /// tmux session presence so operators don't need to read separate booleans.
26
- pub(super) fn compact_ready(full: &Value, not_ready: &Value) -> bool {
27
- not_ready.is_null()
28
- && full
29
- .get("readiness")
30
- .and_then(|r| r.get("ready"))
31
- .and_then(Value::as_bool)
32
- .unwrap_or(false)
33
- && full
34
- .get("coordinator")
35
- .and_then(|c| c.get("status"))
36
- .and_then(Value::as_str)
37
- .is_some_and(|s| s == "running" || s == "ok")
38
- && full
39
- .get("coordinator")
40
- .and_then(|c| c.get("schema_ok"))
41
- .and_then(Value::as_bool)
42
- .unwrap_or(true)
43
- }
44
-
45
- /// Returns `Value::Null` when fully ready, otherwise an object:
46
- /// `{"reasons": [...], "agents": [...]}` listing every gating issue.
47
- pub(super) fn compact_not_ready(full: &Value) -> Value {
48
- let reasons = not_ready_reasons(full);
49
- if reasons.is_empty() {
50
- return Value::Null;
51
- }
52
- let agents = full
53
- .get("incomplete_session_capture_agents")
54
- .and_then(Value::as_array)
55
- .cloned()
56
- .or_else(|| {
57
- full.get("pending_session_agent_ids")
58
- .and_then(Value::as_array)
59
- .cloned()
60
- })
61
- .unwrap_or_default();
62
- let mut obj = Map::new();
63
- obj.insert(
64
- "reasons".to_string(),
65
- Value::Array(reasons.into_iter().map(Value::String).collect()),
66
- );
67
- obj.insert("agents".to_string(), Value::Array(agents));
68
- if let Some(next_action) = full
69
- .pointer("/readiness/next_action")
70
- .and_then(Value::as_str)
71
- {
72
- let truly_unbound = full.pointer("/readiness/state").and_then(Value::as_str)
73
- == Some("leader_receiver_unbound");
74
- if !next_action.contains("claim-leader") || truly_unbound {
75
- obj.insert(
76
- "next_action".to_string(),
77
- Value::String(next_action.to_string()),
78
- );
79
- }
80
- }
81
- Value::Object(obj)
82
- }
83
-
84
- pub(super) fn not_ready_reasons(full: &Value) -> Vec<String> {
85
- let mut reasons = Vec::new();
86
- let coord = full.get("coordinator");
87
- let coord_status = coord
88
- .and_then(|c| c.get("status"))
89
- .and_then(Value::as_str)
90
- .unwrap_or("");
91
- if coord_status != "running" && coord_status != "ok" {
92
- reasons.push("coordinator_not_running".to_string());
93
- }
94
- if coord
95
- .and_then(|c| c.get("schema_ok"))
96
- .and_then(Value::as_bool)
97
- == Some(false)
98
- {
99
- reasons.push("coordinator_schema_not_ok".to_string());
100
- }
101
- if full.get("tmux_session_present").and_then(Value::as_bool) == Some(false) {
102
- reasons.push("tmux_session_missing".to_string());
103
- }
104
- let readiness = full.get("readiness");
105
- if readiness
106
- .and_then(|r| r.get("all_spawned"))
107
- .and_then(Value::as_bool)
108
- == Some(false)
109
- {
110
- reasons.push("workers_not_spawned".to_string());
111
- }
112
- if readiness
113
- .and_then(|r| r.get("all_attached_receiver"))
114
- .and_then(Value::as_bool)
115
- == Some(false)
116
- {
117
- reasons.push("leader_receiver_unbound".to_string());
118
- }
119
- if readiness
120
- .and_then(|r| r.get("session_capture_complete"))
121
- .and_then(Value::as_bool)
122
- == Some(false)
123
- {
124
- reasons.push("session_capture_incomplete".to_string());
125
- }
126
- if readiness
127
- .and_then(|r| r.get("awaiting_trust_prompt"))
128
- .and_then(Value::as_bool)
129
- == Some(true)
130
- {
131
- reasons.push("awaiting_trust_prompt".to_string());
132
- }
133
- let grok_slot = full.get("grok_slot");
134
- let grok_readable = grok_slot
135
- .and_then(|slot| slot.get("readable"))
136
- .and_then(Value::as_bool);
137
- let grok_consistent = grok_slot
138
- .and_then(|slot| slot.get("consistent"))
139
- .and_then(Value::as_bool);
140
- if grok_readable != Some(true) || grok_consistent != Some(true) {
141
- if grok_readable == Some(false) || grok_slot.is_none() || grok_slot == Some(&Value::Null) {
142
- reasons.push("grok_slot_unjudgeable".to_string());
143
- } else {
144
- reasons.push("grok_slot_mismatch".to_string());
145
- }
146
- }
147
- reasons
148
- }
149
-
150
- pub(super) fn compact_agents(value: Option<&Value>) -> Value {
151
- let Some(Value::Object(input)) = value else {
152
- return json!({});
153
- };
154
- let mut out = Map::new();
155
- for (agent_id, agent) in input {
156
- out.insert(agent_id.clone(), compact_agent_state(agent_id, agent));
157
- }
158
- Value::Object(out)
159
- }
160
-
161
- /// 0.4.x: agent rows in the slim payload have exactly 4 fields. agent_id
162
- /// is no longer copied in — the map key already carries it. Diagnostic
163
- /// fields (model, tmux_window_present, session_id, captured_via,
164
- /// attribution_confidence, display, interacted) move to `--detail`.
165
- /// `activity` + `last_output_at` are preserved (RM-039-STAT-001).
166
- pub(super) fn compact_agent_state(_agent_id: &str, agent: &Value) -> Value {
167
- let Some(input) = agent.as_object() else {
168
- return json!({});
169
- };
170
- let mut out = Map::new();
171
- // 0.4.x Phase 1: add `worker_state` (canonical 5-state product
172
- // surface). `activity` is preserved alongside as the deprecated
173
- // legacy classifier output (CR R3 same-source contract).
174
- for key in [
175
- "status",
176
- "provider",
177
- "worker_state",
178
- "activity",
179
- "last_output_at",
180
- "stale",
181
- "stale_reason",
182
- ] {
183
- if let Some(value) = input.get(key) {
184
- out.insert(key.to_string(), value.clone());
185
- }
186
- }
187
- Value::Object(out)
188
- }
189
-
190
- pub(super) fn compact_tasks(value: Option<&Value>) -> Value {
191
- let Some(Value::Array(tasks)) = value else {
192
- return json!([]);
193
- };
194
- Value::Array(
195
- tasks
196
- .iter()
197
- .map(|task| {
198
- compact_object(
199
- Some(task),
200
- &[
201
- "id",
202
- "title",
203
- "status",
204
- "assignee",
205
- "type",
206
- "accepted_result_id",
207
- ],
208
- )
209
- })
210
- .collect(),
211
- )
212
- }
213
-
214
- pub(super) fn compact_object(value: Option<&Value>, keys: &[&str]) -> Value {
215
- let Some(Value::Object(input)) = value else {
216
- return json!({});
217
- };
218
- let mut out = Map::new();
219
- for key in keys {
220
- if let Some(value) = input.get(*key) {
221
- out.insert((*key).to_string(), value.clone());
222
- }
223
- }
224
- Value::Object(out)
225
- }
226
-
227
- pub(super) fn take_array(value: Option<&Value>, limit: usize) -> Value {
228
- let Some(Value::Array(items)) = value else {
229
- return json!([]);
230
- };
231
- Value::Array(items.iter().take(limit).cloned().collect())
232
- }
233
-
234
- pub(super) fn take_array_tail(value: Option<&Value>, limit: usize) -> Value {
235
- let Some(Value::Array(items)) = value else {
236
- return json!([]);
237
- };
238
- let start = items.len().saturating_sub(limit);
239
- Value::Array(items.iter().skip(start).cloned().collect())
240
- }
@@ -1,146 +0,0 @@
1
- //!
2
- use crate::cli::CliError;
3
- use serde_json::{json, Value};
4
-
5
- /// `format_status` agent 分支(`queries.py:135-162`)。
6
- pub(super) fn format_agent_status(
7
- status: &Value,
8
- agent_id: &str,
9
- inbox_rows: &[Value],
10
- ) -> Result<String, CliError> {
11
- ensure_agent_known(status, agent_id)?;
12
- let agents = status.get("agents").and_then(Value::as_object);
13
- let health = status.get("agent_health").and_then(Value::as_object);
14
- let empty = json!({});
15
- let agent = agents.and_then(|map| map.get(agent_id)).unwrap_or(&empty);
16
- let row = health.and_then(|map| map.get(agent_id)).unwrap_or(&empty);
17
- let status_text = row
18
- .get("status")
19
- .and_then(Value::as_str)
20
- .map(str::to_string)
21
- .unwrap_or_else(|| {
22
- agent_health_status_text(agent.get("status").and_then(Value::as_str).unwrap_or(""))
23
- });
24
- let tasks = status
25
- .get("tasks")
26
- .and_then(Value::as_array)
27
- .cloned()
28
- .unwrap_or_default();
29
- let task_id = current_task_for_agent(&tasks, agent_id).unwrap_or_else(|| "-".to_string());
30
- let mut lines = vec![
31
- format!("{agent_id} {status_text}"),
32
- format!(" provider: {}", py_get(agent, "provider")),
33
- format!(" model: {}", py_get(agent, "model")),
34
- format!(" profile: {}", py_get(agent, "profile")),
35
- format!(" session_id: {}", py_get_or_dash(agent, "session_id")),
36
- format!(" captured_via: {}", py_get_or_dash(agent, "captured_via")),
37
- format!(
38
- " attribution_confidence: {}",
39
- py_get_or_dash(agent, "attribution_confidence")
40
- ),
41
- format!(" task: {task_id}"),
42
- format!(" handoff: {}", py_get(agent, "handoff_path")),
43
- " recent messages:".to_string(),
44
- ];
45
- if inbox_rows.is_empty() {
46
- lines.push(" none".to_string());
47
- } else {
48
- for item in inbox_rows {
49
- let content = item.get("content").and_then(Value::as_str).unwrap_or("");
50
- let content: String = content.chars().take(120).collect();
51
- lines.push(format!(
52
- " {} {} -> {} {}: {content}",
53
- py_get_or_dash(item, "created_at"),
54
- py_get_or_dash(item, "sender"),
55
- py_get_or_dash(item, "recipient"),
56
- py_get_or_dash(item, "status"),
57
- ));
58
- }
59
- }
60
- Ok(lines.join("\n"))
61
- }
62
-
63
- pub(super) fn ensure_agent_known(status: &Value, agent_id: &str) -> Result<(), CliError> {
64
- let agents = status.get("agents").and_then(Value::as_object);
65
- let health = status.get("agent_health").and_then(Value::as_object);
66
- let known = agents.is_some_and(|map| map.contains_key(agent_id))
67
- || health.is_some_and(|map| map.contains_key(agent_id));
68
- if !known {
69
- return Err(CliError::Runtime(format!("unknown agent id: {agent_id}")));
70
- }
71
- Ok(())
72
- }
73
-
74
- /// `current_task_for_agent`(`approvals/status.py:127-132`)。
75
- pub(super) fn current_task_for_agent(tasks: &[Value], agent_id: &str) -> Option<String> {
76
- const ACTIVE: [&str; 5] = ["pending", "ready", "running", "blocked", "needs_retry"];
77
- for task in tasks.iter().rev() {
78
- let assignee = task.get("assignee").and_then(Value::as_str);
79
- let status = task
80
- .get("status")
81
- .and_then(Value::as_str)
82
- .unwrap_or("pending");
83
- if assignee == Some(agent_id) && ACTIVE.contains(&status) {
84
- return task.get("id").and_then(Value::as_str).map(str::to_string);
85
- }
86
- }
87
- None
88
- }
89
-
90
- pub(super) fn agent_health_status_text(status: &str) -> String {
91
- serde_json::to_value(crate::provider::agent_health_status(status))
92
- .ok()
93
- .and_then(|v| v.as_str().map(str::to_string))
94
- .unwrap_or_else(|| "-".to_string())
95
- }
96
-
97
- /// Python `agent.get(key, '-')`:键缺失 → `-`;键存在但为 null → 打印 `None`。
98
- pub(super) fn py_get(agent: &Value, key: &str) -> String {
99
- match agent.get(key) {
100
- None => "-".to_string(),
101
- Some(Value::Null) => "None".to_string(),
102
- Some(Value::String(s)) => s.clone(),
103
- Some(other) => other.to_string(),
104
- }
105
- }
106
-
107
- /// Python `agent.get(key) or '-'`:缺失/null/空串都落 `-`。
108
- pub(super) fn py_get_or_dash(agent: &Value, key: &str) -> String {
109
- match agent.get(key) {
110
- Some(Value::String(s)) if !s.is_empty() => s.clone(),
111
- Some(Value::Number(n)) => n.to_string(),
112
- _ => "-".to_string(),
113
- }
114
- }
115
-
116
- /// `status.approvals(workspace, agent_id)`(JSON)/`format_approvals`(人读)。
117
- pub fn format_approvals(value: &Value) -> String {
118
- let approvals = value
119
- .get("approvals")
120
- .and_then(Value::as_array)
121
- .map(Vec::as_slice)
122
- .unwrap_or(&[]);
123
- if approvals.is_empty() {
124
- return "No pending approvals.".to_string();
125
- }
126
- approvals
127
- .iter()
128
- .map(|approval| {
129
- let agent = approval
130
- .get("agent_id")
131
- .and_then(Value::as_str)
132
- .unwrap_or("-");
133
- let kind = approval
134
- .get("kind")
135
- .and_then(Value::as_str)
136
- .unwrap_or("unknown");
137
- let prompt = approval
138
- .get("prompt")
139
- .and_then(Value::as_str)
140
- .or_else(|| approval.get("subject").and_then(Value::as_str))
141
- .unwrap_or("-");
142
- format!("{agent}: {kind} {prompt}")
143
- })
144
- .collect::<Vec<_>>()
145
- .join("\n")
146
- }
@@ -1,62 +0,0 @@
1
- //!
2
- use super::*;
3
-
4
- const SUMMARY_LIMIT: usize = 120;
5
-
6
- fn clean_text(text: &str) -> String {
7
- text.chars().filter(|ch| !ch.is_control()).collect()
8
- }
9
-
10
- fn compact_field(value: Option<&Value>) -> Value {
11
- value
12
- .and_then(Value::as_str)
13
- .map(|text| Value::String(clean_text(text)))
14
- .unwrap_or(Value::Null)
15
- }
16
-
17
- pub fn inbox(
18
- workspace: &Path,
19
- agent: &str,
20
- limit: usize,
21
- owner_team_id: Option<&str>,
22
- ) -> Result<Value, CliError> {
23
- let store = crate::message_store::MessageStore::open(workspace)
24
- .map_err(|e| CliError::Runtime(e.to_string()))?;
25
- let messages = store
26
- .inbox(agent, limit, owner_team_id)
27
- .map_err(|e| CliError::Runtime(e.to_string()))?
28
- .into_iter()
29
- .map(compact_message)
30
- .collect::<Vec<_>>();
31
- Ok(json!({
32
- "ok": true,
33
- "agent_id": agent,
34
- "messages": messages,
35
- }))
36
- }
37
-
38
- fn compact_message(message: Value) -> Value {
39
- json!({
40
- "message_id": compact_field(message.get("message_id")),
41
- "sender": compact_field(message.get("sender")),
42
- "recipient": compact_field(message.get("recipient")),
43
- "status": compact_field(message.get("status")),
44
- "created_at": compact_field(message.get("created_at")),
45
- "summary": compact_summary(message.get("content").and_then(Value::as_str).unwrap_or("")),
46
- })
47
- }
48
-
49
- fn compact_summary(content: &str) -> String {
50
- let summary = content
51
- .lines()
52
- .map(|line| clean_text(line).trim().to_string())
53
- .find(|line| !line.is_empty())
54
- .unwrap_or_default();
55
- let mut chars = summary.chars();
56
- let truncated = chars.by_ref().take(SUMMARY_LIMIT).collect::<String>();
57
- if chars.next().is_some() {
58
- format!("{truncated}…")
59
- } else {
60
- truncated
61
- }
62
- }
@@ -1,197 +0,0 @@
1
- use super::*;
2
-
3
- /// 0.5.41 Slice 3 (fault-invisibility-locate.md §5): single-source
4
- /// runtime freshness projection consumed by status/diagnose. Read-
5
- /// only over existing sources (`coordinator_health`, heartbeat
6
- /// sidecar, watch state); computes NO transport calls of its own.
7
- #[derive(Default, Clone)]
8
- pub(crate) struct RuntimeFreshness {
9
- pub coordinator_service_available: bool,
10
- pub host_boot_stale: bool,
11
- pub host_boot_recorded: Option<String>,
12
- pub host_boot_current: Option<String>,
13
- pub provider_exited_agents: std::collections::BTreeSet<String>,
14
- }
15
-
16
- impl RuntimeFreshness {
17
- pub(super) fn host_boot_stale_reason(&self) -> Option<&'static str> {
18
- self.host_boot_stale.then_some("host_boot_mismatch")
19
- }
20
- }
21
-
22
- pub(crate) fn compute_runtime_freshness(
23
- workspace: &Path,
24
- state: &Value,
25
- health: &crate::coordinator::HealthReport,
26
- ) -> RuntimeFreshness {
27
- let workspace_path = crate::coordinator::WorkspacePath::new(workspace.to_path_buf());
28
- let heartbeat = crate::coordinator::read_coordinator_heartbeat(&workspace_path);
29
- let host_boot_recorded = heartbeat
30
- .as_ref()
31
- .and_then(|hb| hb.get("host_boot_id"))
32
- .and_then(Value::as_str)
33
- .filter(|s| !s.is_empty() && *s != "unknown")
34
- .map(str::to_string);
35
- let host_boot_current = crate::coordinator::probe_host_boot_id();
36
- let host_boot_stale = match (host_boot_recorded.as_deref(), host_boot_current.as_deref()) {
37
- (Some(recorded), Some(current)) => recorded != current,
38
- _ => false,
39
- };
40
- // Collect worker-provider-exited agents from the coordinator
41
- // abnormal_exit_watch payload. Only the typed positive provider-exit
42
- // marker participates here: generic process/pane death diagnostics are
43
- // not proof that the provider exited. Read from top-level
44
- // `coordinator.abnormal_exit_watch`
45
- // OR the team-scoped mirror `teams.<key>.coordinator...`.
46
- let mut provider_exited_agents = std::collections::BTreeSet::new();
47
- for path in [
48
- "/coordinator/abnormal_exit_watch",
49
- &format!(
50
- "/teams/{}/coordinator/abnormal_exit_watch",
51
- state
52
- .get("active_team_key")
53
- .and_then(Value::as_str)
54
- .unwrap_or("")
55
- ),
56
- ] {
57
- if let Some(watch) = state.pointer(path).and_then(Value::as_object) {
58
- for (agent_id, entry) in watch {
59
- let exited =
60
- entry.get("worker_provider_exited").and_then(Value::as_bool) == Some(true);
61
- if exited
62
- && crate::state::abnormal_watch::matches_observation(state, agent_id, entry)
63
- {
64
- provider_exited_agents.insert(agent_id.clone());
65
- }
66
- }
67
- }
68
- }
69
- RuntimeFreshness {
70
- coordinator_service_available: health.service_available,
71
- host_boot_stale,
72
- host_boot_recorded,
73
- host_boot_current,
74
- provider_exited_agents,
75
- }
76
- }
77
-
78
- pub(super) fn build_runtime_status_block(
79
- coordinator_running: bool,
80
- undelivered: i64,
81
- tmux_session_missing: bool,
82
- freshness: &RuntimeFreshness,
83
- ) -> Value {
84
- let mut runtime = serde_json::Map::new();
85
- runtime.insert(
86
- "coordinator".to_string(),
87
- json!({"ok": coordinator_running}),
88
- );
89
- runtime.insert("undelivered".to_string(), json!(undelivered));
90
- // 0.5.41 Slice 3 (fault-invisibility-locate.md §5/§6.3): expose
91
- // typed issues on the runtime block so `status --json --detail`
92
- // can be scanned for `runtime_bindings_stale_after_boot` the
93
- // same way `diagnose` surfaces it. Hint precedence: session-
94
- // missing > host-boot-stale > coordinator-not-running-with-
95
- // backlog — most-actionable-first.
96
- let mut issues: Vec<Value> = Vec::new();
97
- if freshness.host_boot_stale {
98
- issues.push(json!({
99
- "id": "runtime_bindings_stale_after_boot",
100
- "recorded_host_boot_id": freshness.host_boot_recorded,
101
- "current_host_boot_id": freshness.host_boot_current,
102
- }));
103
- }
104
- if !issues.is_empty() {
105
- runtime.insert("issues".to_string(), Value::Array(issues));
106
- }
107
- if tmux_session_missing {
108
- runtime.insert(
109
- "hint".to_string(),
110
- json!("tmux session missing — run team-agent restart"),
111
- );
112
- } else if freshness.host_boot_stale {
113
- runtime.insert(
114
- "hint".to_string(),
115
- json!("runtime_bindings_stale_after_boot — run team-agent restart"),
116
- );
117
- } else if !coordinator_running && undelivered > 0 {
118
- runtime.insert(
119
- "hint".to_string(),
120
- json!(format!(
121
- "coordinator not running with {undelivered} undelivered — run team-agent restart"
122
- )),
123
- );
124
- }
125
- Value::Object(runtime)
126
- }
127
-
128
- /// Whether the coordinator HealthReport reflects a running tick loop. Used by the
129
- /// runtime block + the hint gate.
130
- pub(super) fn coordinator_status_running(health: &crate::coordinator::HealthReport) -> bool {
131
- // 0.5.41 Slice 3 (fault-invisibility-locate.md §5/§6.3): runtime
132
- // service predicate is `service_available`, not any-`Running` pid.
133
- // A stale-pid daemon is CoordinatorHealthStatus::Stale (or Running
134
- // with metadata_ok=false); a service-compatible newer daemon is
135
- // Running + service_available=true — send/diagnose already use
136
- // this same truth source, and status must agree.
137
- health.service_available
138
- }
139
-
140
- /// Count of messages currently sitting in delivery-able backlog
141
- /// (accepted/pending/queued forms — not delivered / not failed / not refused).
142
- /// owner_team_id scope honored when present.
143
- pub(super) fn coordinator_health_value(health: crate::coordinator::HealthReport) -> Value {
144
- let expose_binary_drift = health.service_available && !health.metadata_ok;
145
- let binary_identity_relation = health.binary_identity_relation.as_str();
146
- let mut value = json!({
147
- "ok": health.ok,
148
- "status": coordinator_status_wire(health.status),
149
- "pid": health.pid.map(|p| p.get()),
150
- "metadata": health.metadata.map(|m| json!({
151
- "pid": m.pid.get(),
152
- "protocol_version": m.protocol_version,
153
- "message_store_schema_version": m.message_store_schema_version,
154
- "binary_path": m.binary_path,
155
- "binary_version": m.binary_version,
156
- "source": m.source,
157
- "updated_at": m.updated_at,
158
- })),
159
- "metadata_ok": health.metadata_ok,
160
- "metadata_mismatch_reason": health.metadata_mismatch_reason,
161
- "binary_path": health.current_binary_identity.binary_path,
162
- "binary_version": health.current_binary_identity.binary_version,
163
- "schema_ok": health.schema.ok,
164
- "schema_error": health.schema.error.map(|e| format!("{e:?}")),
165
- "schema": {
166
- "message_store_schema_version": health.schema.schema_version,
167
- },
168
- // 0.5.41 Slice 3 (fault-invisibility-locate.md §5/§6.3):
169
- // `service_available` is now always exposed alongside `ok`
170
- // and `status` so status/diagnose consumers can share one
171
- // service-availability truth without keying on the legacy
172
- // `expose_binary_drift` conditional (that path only fired
173
- // for the newer-daemon-preserved shape). `binary_identity_
174
- // relation` moves to always-on for the same reason — RED3
175
- // scans the summary for `daemon_newer_than_caller`.
176
- "service_available": health.service_available,
177
- "binary_identity_relation": binary_identity_relation,
178
- });
179
- if expose_binary_drift {
180
- if let Some(obj) = value.as_object_mut() {
181
- obj.insert("wire_metadata_ok".to_string(), Value::Bool(true));
182
- obj.insert("binary_identity_ok".to_string(), Value::Bool(false));
183
- }
184
- }
185
- value
186
- }
187
-
188
- pub(super) fn coordinator_status_wire(
189
- status: crate::coordinator::CoordinatorHealthStatus,
190
- ) -> &'static str {
191
- match status {
192
- crate::coordinator::CoordinatorHealthStatus::Missing => "missing",
193
- crate::coordinator::CoordinatorHealthStatus::InvalidPid => "invalid_pid",
194
- crate::coordinator::CoordinatorHealthStatus::Running => "running",
195
- crate::coordinator::CoordinatorHealthStatus::Stale => "stale",
196
- }
197
- }