@team-agent/installer 0.5.128 → 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.
- package/README.md +4 -4
- package/README.zh.md +1 -1
- package/package.json +4 -8
- package/skills/team-agent/SKILL.md +37 -20
- package/skills/team-agent/command-coverage.json +169 -183
- package/skills/team-agent/docs/reference/team-agent-operator.md +64 -30
- package/skills/team-agent/references/recovery-runbook.md +1 -1
- package/skills/team-agent/references/team-agent-operator.md +64 -30
- package/templates/team_state.md +1 -1
- package/Cargo.lock +0 -1063
- package/Cargo.toml +0 -36
- package/crates/team-agent/Cargo.toml +0 -69
- package/crates/team-agent/src/app_server_test_support.rs +0 -258
- package/crates/team-agent/src/cli/adapters.rs +0 -1288
- package/crates/team-agent/src/cli/arguments.rs +0 -405
- package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
- package/crates/team-agent/src/cli/diagnose.rs +0 -1721
- package/crates/team-agent/src/cli/emit.rs +0 -2930
- package/crates/team-agent/src/cli/grok_slot.rs +0 -384
- package/crates/team-agent/src/cli/helpers.rs +0 -91
- package/crates/team-agent/src/cli/intent/runtime.rs +0 -1216
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -912
- package/crates/team-agent/src/cli/intent/tests.rs +0 -689
- package/crates/team-agent/src/cli/intent.rs +0 -664
- package/crates/team-agent/src/cli/leader.rs +0 -300
- package/crates/team-agent/src/cli/leader_prompt.rs +0 -261
- package/crates/team-agent/src/cli/leaders.rs +0 -418
- package/crates/team-agent/src/cli/mod.rs +0 -6545
- package/crates/team-agent/src/cli/models.rs +0 -1206
- package/crates/team-agent/src/cli/named_address.rs +0 -1651
- package/crates/team-agent/src/cli/profile.rs +0 -342
- package/crates/team-agent/src/cli/route.rs +0 -212
- package/crates/team-agent/src/cli/schedule.rs +0 -175
- package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
- package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
- package/crates/team-agent/src/cli/send/persist.rs +0 -156
- package/crates/team-agent/src/cli/send/presentation.rs +0 -370
- package/crates/team-agent/src/cli/send/resolve.rs +0 -573
- package/crates/team-agent/src/cli/send.rs +0 -199
- package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
- package/crates/team-agent/src/cli/spec.rs +0 -165
- package/crates/team-agent/src/cli/status.rs +0 -280
- package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
- package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
- package/crates/team-agent/src/cli/status_port/brief.rs +0 -1981
- package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
- package/crates/team-agent/src/cli/status_port/format.rs +0 -146
- package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
- package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
- package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
- package/crates/team-agent/src/cli/status_port/store.rs +0 -416
- package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
- package/crates/team-agent/src/cli/status_port.rs +0 -92
- package/crates/team-agent/src/cli/tests/base.rs +0 -885
- package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
- package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
- package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -322
- package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
- package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
- package/crates/team-agent/src/cli/tests/mod.rs +0 -137
- package/crates/team-agent/src/cli/tests/named_address.rs +0 -761
- package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
- package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -484
- package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
- package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
- package/crates/team-agent/src/cli/tests/status_send.rs +0 -888
- package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
- package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
- package/crates/team-agent/src/cli/triage.rs +0 -234
- package/crates/team-agent/src/cli/types.rs +0 -591
- package/crates/team-agent/src/codex_app_server.rs +0 -546
- package/crates/team-agent/src/communication_mode/mod.rs +0 -56
- package/crates/team-agent/src/compiler/tests.rs +0 -827
- package/crates/team-agent/src/compiler.rs +0 -890
- package/crates/team-agent/src/conpty/backend.rs +0 -829
- package/crates/team-agent/src/conpty/mod.rs +0 -33
- package/crates/team-agent/src/contract_runtime/backend.rs +0 -1744
- package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
- package/crates/team-agent/src/contract_runtime/config.rs +0 -364
- package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -76
- package/crates/team-agent/src/contract_runtime/discovery.rs +0 -449
- package/crates/team-agent/src/contract_runtime/fork.rs +0 -361
- package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
- package/crates/team-agent/src/contract_runtime/framework.rs +0 -367
- package/crates/team-agent/src/contract_runtime/mcp.rs +0 -394
- package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
- package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
- package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
- package/crates/team-agent/src/contract_runtime/registry.rs +0 -553
- package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
- package/crates/team-agent/src/coordinator/backoff.rs +0 -741
- package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
- package/crates/team-agent/src/coordinator/health.rs +0 -1185
- package/crates/team-agent/src/coordinator/mod.rs +0 -119
- package/crates/team-agent/src/coordinator/orphan.rs +0 -110
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
- package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
- package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
- package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
- package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
- package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -300
- package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
- package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
- package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -503
- package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
- package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
- package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
- package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
- package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
- package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
- package/crates/team-agent/src/coordinator/tick.rs +0 -3024
- package/crates/team-agent/src/coordinator/types.rs +0 -540
- package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
- package/crates/team-agent/src/db/message_store.rs +0 -1527
- package/crates/team-agent/src/db/migration.rs +0 -984
- package/crates/team-agent/src/db/mod.rs +0 -26
- package/crates/team-agent/src/db/schema.rs +0 -663
- package/crates/team-agent/src/diagnose/comms.rs +0 -242
- package/crates/team-agent/src/diagnose/mod.rs +0 -44
- package/crates/team-agent/src/diagnose/orphans.rs +0 -889
- package/crates/team-agent/src/direct_delivery.rs +0 -368
- package/crates/team-agent/src/event_log.rs +0 -502
- package/crates/team-agent/src/fake_worker.rs +0 -303
- package/crates/team-agent/src/inbox_store.rs +0 -169
- package/crates/team-agent/src/kill_audit.rs +0 -106
- package/crates/team-agent/src/layout/manager.rs +0 -248
- package/crates/team-agent/src/layout/mod.rs +0 -36
- package/crates/team-agent/src/layout/overlay.rs +0 -134
- package/crates/team-agent/src/layout/placement.rs +0 -52
- package/crates/team-agent/src/layout/recovery.rs +0 -106
- package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
- package/crates/team-agent/src/layout/sessions.rs +0 -294
- package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
- package/crates/team-agent/src/layout/worker_env.rs +0 -721
- package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
- package/crates/team-agent/src/leader/helpers.rs +0 -178
- package/crates/team-agent/src/leader/incident.rs +0 -6
- package/crates/team-agent/src/leader/lease.rs +0 -3356
- package/crates/team-agent/src/leader/mod.rs +0 -104
- package/crates/team-agent/src/leader/owner_bind.rs +0 -400
- package/crates/team-agent/src/leader/prompt.rs +0 -905
- package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
- package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
- package/crates/team-agent/src/leader/rediscover.rs +0 -1192
- package/crates/team-agent/src/leader/registry.rs +0 -888
- package/crates/team-agent/src/leader/start.rs +0 -4501
- package/crates/team-agent/src/leader/takeover.rs +0 -65
- package/crates/team-agent/src/leader/tests/basics.rs +0 -337
- package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
- package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
- package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
- package/crates/team-agent/src/leader/tests/identity.rs +0 -465
- package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
- package/crates/team-agent/src/leader/tests/idle.rs +0 -113
- package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
- package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
- package/crates/team-agent/src/leader/tests/mod.rs +0 -106
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -268
- package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
- package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
- package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
- package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
- package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
- package/crates/team-agent/src/leader/types.rs +0 -534
- package/crates/team-agent/src/lib.rs +0 -147
- package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -881
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -598
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -204
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -107
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -144
- package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
- package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
- package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -160
- package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -899
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -225
- package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5200
- package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
- package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
- package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -473
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
- package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
- package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
- package/crates/team-agent/src/lifecycle/launch.rs +0 -557
- package/crates/team-agent/src/lifecycle/lock.rs +0 -350
- package/crates/team-agent/src/lifecycle/mod.rs +0 -79
- package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
- package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -1067
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
- package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2199
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1798
- package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +0 -163
- package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2362
- package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
- package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
- package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
- package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
- package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
- package/crates/team-agent/src/lifecycle/restart.rs +0 -227
- package/crates/team-agent/src/lifecycle/role_config.rs +0 -1230
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
- package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
- package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -447
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1638
- package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -770
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -419
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2035
- package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1327
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -72
- package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -512
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
- package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3983
- package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
- package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
- package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -164
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -200
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -527
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -1062
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1419
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -98
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -550
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -226
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -332
- package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
- package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
- package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
- package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -342
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
- package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -995
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -836
- package/crates/team-agent/src/lifecycle/tests.rs +0 -105
- package/crates/team-agent/src/lifecycle/types.rs +0 -877
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -363
- package/crates/team-agent/src/main.rs +0 -52
- package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
- package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
- package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
- package/crates/team-agent/src/mcp_server/mod.rs +0 -119
- package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
- package/crates/team-agent/src/mcp_server/readiness.rs +0 -527
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -348
- package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
- package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -158
- package/crates/team-agent/src/mcp_server/tests/send.rs +0 -353
- package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -341
- package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
- package/crates/team-agent/src/mcp_server/tests.rs +0 -43
- package/crates/team-agent/src/mcp_server/tools.rs +0 -889
- package/crates/team-agent/src/mcp_server/types.rs +0 -396
- package/crates/team-agent/src/mcp_server/wire.rs +0 -867
- package/crates/team-agent/src/messaging/activity.rs +0 -461
- package/crates/team-agent/src/messaging/address.rs +0 -87
- package/crates/team-agent/src/messaging/delivery.rs +0 -3727
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
- package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
- package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
- package/crates/team-agent/src/messaging/helpers.rs +0 -336
- package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
- package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
- package/crates/team-agent/src/messaging/mod.rs +0 -167
- package/crates/team-agent/src/messaging/persist.rs +0 -377
- package/crates/team-agent/src/messaging/presentation.rs +0 -417
- package/crates/team-agent/src/messaging/reminders.rs +0 -316
- package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
- package/crates/team-agent/src/messaging/results.rs +0 -1415
- package/crates/team-agent/src/messaging/scheduler.rs +0 -223
- package/crates/team-agent/src/messaging/selftest.rs +0 -315
- package/crates/team-agent/src/messaging/send.rs +0 -981
- package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -657
- package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
- package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
- package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
- package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
- package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3549
- package/crates/team-agent/src/messaging/tests/spine.rs +0 -853
- package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
- package/crates/team-agent/src/messaging/trust.rs +0 -215
- package/crates/team-agent/src/messaging/types.rs +0 -472
- package/crates/team-agent/src/messaging/wait.rs +0 -366
- package/crates/team-agent/src/messaging/watchers.rs +0 -916
- package/crates/team-agent/src/model/enums.rs +0 -356
- package/crates/team-agent/src/model/errors.rs +0 -18
- package/crates/team-agent/src/model/ids.rs +0 -165
- package/crates/team-agent/src/model/mod.rs +0 -29
- package/crates/team-agent/src/model/name_similarity.rs +0 -252
- package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
- package/crates/team-agent/src/model/paths.rs +0 -257
- package/crates/team-agent/src/model/routing.rs +0 -387
- package/crates/team-agent/src/model/spec.rs +0 -1184
- package/crates/team-agent/src/model/task_graph.rs +0 -321
- package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
- package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
- package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
- package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
- package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
- package/crates/team-agent/src/model/yaml/tests.rs +0 -188
- package/crates/team-agent/src/model/yaml.rs +0 -802
- package/crates/team-agent/src/os_probe.rs +0 -280
- package/crates/team-agent/src/packaging/install.rs +0 -219
- package/crates/team-agent/src/packaging/migrate.rs +0 -38
- package/crates/team-agent/src/packaging/mod.rs +0 -91
- package/crates/team-agent/src/packaging/repair.rs +0 -33
- package/crates/team-agent/src/packaging/tests.rs +0 -822
- package/crates/team-agent/src/packaging/types.rs +0 -417
- package/crates/team-agent/src/platform/argv.rs +0 -331
- package/crates/team-agent/src/platform/errors.rs +0 -104
- package/crates/team-agent/src/platform/file_lock.rs +0 -279
- package/crates/team-agent/src/platform/mod.rs +0 -5
- package/crates/team-agent/src/platform/process.rs +0 -545
- package/crates/team-agent/src/provider/adapter.rs +0 -1150
- package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
- package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
- package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
- package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
- package/crates/team-agent/src/provider/adapters/mod.rs +0 -30
- package/crates/team-agent/src/provider/adapters/pi.rs +0 -106
- package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
- package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
- package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
- package/crates/team-agent/src/provider/argv_route.rs +0 -405
- package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
- package/crates/team-agent/src/provider/classify.rs +0 -708
- package/crates/team-agent/src/provider/command_helpers.rs +0 -45
- package/crates/team-agent/src/provider/faults.rs +0 -165
- package/crates/team-agent/src/provider/helpers.rs +0 -52
- package/crates/team-agent/src/provider/mod.rs +0 -78
- package/crates/team-agent/src/provider/model_catalog.rs +0 -910
- package/crates/team-agent/src/provider/session/capture.rs +0 -2731
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -172
- package/crates/team-agent/src/provider/session/context_fork.rs +0 -396
- package/crates/team-agent/src/provider/session/mod.rs +0 -36
- package/crates/team-agent/src/provider/session/resume.rs +0 -269
- package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
- package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
- package/crates/team-agent/src/provider/session_scan/common.rs +0 -654
- package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
- package/crates/team-agent/src/provider/session_scan/pi.rs +0 -185
- package/crates/team-agent/src/provider/session_scan.rs +0 -71
- package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
- package/crates/team-agent/src/provider/submit_now.rs +0 -71
- package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
- package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
- package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
- package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
- package/crates/team-agent/src/provider/tests/adapter.rs +0 -441
- package/crates/team-agent/src/provider/tests/classify.rs +0 -148
- package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -35
- package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
- package/crates/team-agent/src/provider/tests/faults.rs +0 -200
- package/crates/team-agent/src/provider/tests/idle.rs +0 -177
- package/crates/team-agent/src/provider/tests/wire.rs +0 -213
- package/crates/team-agent/src/provider/tests.rs +0 -32
- package/crates/team-agent/src/provider/types.rs +0 -529
- package/crates/team-agent/src/provider/wire.rs +0 -394
- package/crates/team-agent/src/redaction.rs +0 -259
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
- package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
- package/crates/team-agent/src/state/identity.rs +0 -914
- package/crates/team-agent/src/state/identity_keys.rs +0 -132
- package/crates/team-agent/src/state/mod.rs +0 -74
- package/crates/team-agent/src/state/owner_gate.rs +0 -482
- package/crates/team-agent/src/state/ownership.rs +0 -563
- package/crates/team-agent/src/state/paths.rs +0 -395
- package/crates/team-agent/src/state/persist.rs +0 -3811
- package/crates/team-agent/src/state/projection.rs +0 -1508
- package/crates/team-agent/src/state/repository/intent.rs +0 -14
- package/crates/team-agent/src/state/repository/tests.rs +0 -184
- package/crates/team-agent/src/state/repository.rs +0 -866
- package/crates/team-agent/src/state/selector.rs +0 -160
- package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
- package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
- package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
- package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
- package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
- package/crates/team-agent/src/tmux_backend/tests.rs +0 -4103
- package/crates/team-agent/src/tmux_backend.rs +0 -4492
- package/crates/team-agent/src/topology.rs +0 -537
- package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
- package/crates/team-agent/src/transport/native_input.rs +0 -491
- package/crates/team-agent/src/transport/test_support.rs +0 -743
- package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
- package/crates/team-agent/src/transport/tests/mod.rs +0 -194
- package/crates/team-agent/src/transport/tests/wire.rs +0 -574
- package/crates/team-agent/src/transport.rs +0 -1655
- package/crates/team-agent/src/transport_factory.rs +0 -819
|
@@ -1,1288 +0,0 @@
|
|
|
1
|
-
//!
|
|
2
|
-
//! cli · adapters — 每子命令的薄壳 `cmd_*`(commands.py)。委派 status/lifecycle/diagnose/
|
|
3
|
-
//! leader/messaging port,把委派结果包成 [`CmdResult`]。含逻辑的:`cmd_status`(三态互斥)、
|
|
4
|
-
//! `cmd_doctor`(gate/comms/fix-schema/cleanup-orphans 分派)。
|
|
5
|
-
|
|
6
|
-
use super::*;
|
|
7
|
-
|
|
8
|
-
/// `cmd_quick_start`(`commands.py:18`)。`--json` 或 `!ok` → 整 dict;否则 `result["summary"]`。
|
|
9
|
-
pub fn cmd_quick_start(args: &QuickStartArgs) -> Result<CmdResult, CliError> {
|
|
10
|
-
#[cfg(unix)]
|
|
11
|
-
crate::contract_runtime::config::read_team(args)
|
|
12
|
-
.map_err(|error| CliError::Runtime(error.to_string()))?;
|
|
13
|
-
let mut value = lifecycle_port::quick_start(
|
|
14
|
-
&args.workspace,
|
|
15
|
-
&args.agents_dir,
|
|
16
|
-
args.name.as_deref(),
|
|
17
|
-
args.team_id.as_deref(),
|
|
18
|
-
args.yes,
|
|
19
|
-
args.backend.as_deref(),
|
|
20
|
-
)?;
|
|
21
|
-
if let Some(result) = quick_start_config_guidance(&mut value, args) {
|
|
22
|
-
return Ok(result);
|
|
23
|
-
}
|
|
24
|
-
append_send_guidance(&mut value, &args.workspace, args.team_id.as_deref());
|
|
25
|
-
finish_quick_start(value, args)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
fn finish_quick_start(mut value: Value, args: &QuickStartArgs) -> Result<CmdResult, CliError> {
|
|
29
|
-
let readiness = value.get("readiness").and_then(Value::as_object);
|
|
30
|
-
let all_resumable_have_session = readiness
|
|
31
|
-
.and_then(|readiness| readiness.get("all_resumable_have_session"))
|
|
32
|
-
.and_then(Value::as_bool)
|
|
33
|
-
.unwrap_or(true);
|
|
34
|
-
let session_capture_incomplete = readiness
|
|
35
|
-
.and_then(|readiness| readiness.get("session_capture_incomplete"))
|
|
36
|
-
.and_then(Value::as_bool)
|
|
37
|
-
.unwrap_or(!all_resumable_have_session);
|
|
38
|
-
let readiness_ready = readiness
|
|
39
|
-
.and_then(|readiness| readiness.get("ready"))
|
|
40
|
-
.and_then(Value::as_bool)
|
|
41
|
-
.unwrap_or(true);
|
|
42
|
-
let status = value
|
|
43
|
-
.get("status")
|
|
44
|
-
.and_then(Value::as_str)
|
|
45
|
-
.map(str::to_string);
|
|
46
|
-
if !args.detail && value.get("ok").and_then(Value::as_bool) != Some(false) {
|
|
47
|
-
lifecycle_port::compact_quick_start_value(&mut value);
|
|
48
|
-
}
|
|
49
|
-
if args.json
|
|
50
|
-
|| value.get("ok").and_then(Value::as_bool) == Some(false)
|
|
51
|
-
|| session_capture_incomplete
|
|
52
|
-
|| !readiness_ready
|
|
53
|
-
{
|
|
54
|
-
let mut result = CmdResult::from_json(value, args.json);
|
|
55
|
-
if status.as_deref() == Some("pending_tool_load") {
|
|
56
|
-
result.exit = ExitCode::Ok;
|
|
57
|
-
}
|
|
58
|
-
if !args.json {
|
|
59
|
-
if let CmdOutput::Json(value) = &result.output {
|
|
60
|
-
// Typed refusals often have no `error`. Preserve the complete
|
|
61
|
-
// report instead of replacing its reason/actions with a guess.
|
|
62
|
-
let safe = crate::redaction::redact_external_value(value);
|
|
63
|
-
result.output = CmdOutput::Human(format!(
|
|
64
|
-
"quick-start report:\n{}",
|
|
65
|
-
serde_json::to_string_pretty(&safe)?
|
|
66
|
-
));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
Ok(result)
|
|
70
|
-
} else {
|
|
71
|
-
// E13:happy 人类路径必须带 attach_commands(json 路径 cli/mod.rs:1775 已有)。
|
|
72
|
-
Ok(CmdResult::human(&quickstart_human(&value)))
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Project only an actual compiler rejection; never reject a valid lifecycle fallback.
|
|
77
|
-
fn quick_start_config_guidance(value: &mut Value, args: &QuickStartArgs) -> Option<CmdResult> {
|
|
78
|
-
if value.get("ok").and_then(Value::as_bool) != Some(false) {
|
|
79
|
-
return None;
|
|
80
|
-
}
|
|
81
|
-
let error = value.get("error")?.as_str()?;
|
|
82
|
-
let compile = error.strip_prefix("spec compile failed: ")?;
|
|
83
|
-
let detail = compile
|
|
84
|
-
.strip_prefix("validation error: ")
|
|
85
|
-
.unwrap_or(compile);
|
|
86
|
-
let team_path = args.agents_dir.join("TEAM.md");
|
|
87
|
-
let agents_path = args.agents_dir.join("agents");
|
|
88
|
-
let missing_team = detail == format!("{}: missing TEAM.md", team_path.display())
|
|
89
|
-
&& team_path.try_exists().ok() == Some(false);
|
|
90
|
-
let missing_roles = detail == format!("{}: missing agents directory", agents_path.display())
|
|
91
|
-
|| detail == format!("{}: no role docs found", agents_path.display());
|
|
92
|
-
let missing_field = detail.split_once(": ").is_some_and(|(path, reason)| {
|
|
93
|
-
Path::new(path).parent() == Some(agents_path.as_path())
|
|
94
|
-
&& (reason.contains("missing required field") || reason.contains("is required"))
|
|
95
|
-
});
|
|
96
|
-
if !missing_team && !(team_path.is_file() && (missing_roles || missing_field)) {
|
|
97
|
-
return None;
|
|
98
|
-
}
|
|
99
|
-
let role_path = agents_path.join("worker.md");
|
|
100
|
-
let mut retry = format!(
|
|
101
|
-
"team-agent quick-start {} --workspace {}",
|
|
102
|
-
shell_quote(&args.agents_dir.to_string_lossy()),
|
|
103
|
-
shell_quote(&args.workspace.to_string_lossy())
|
|
104
|
-
);
|
|
105
|
-
if let Some(team) = args.team_id.as_deref() {
|
|
106
|
-
retry.push_str(&format!(" --team {}", shell_quote(team)));
|
|
107
|
-
}
|
|
108
|
-
if let Some(name) = args.name.as_deref() {
|
|
109
|
-
retry.push_str(&format!(" --name {}", shell_quote(name)));
|
|
110
|
-
}
|
|
111
|
-
if let Some(backend) = args.backend.as_deref() {
|
|
112
|
-
retry.push_str(&format!(" --backend {}", shell_quote(backend)));
|
|
113
|
-
}
|
|
114
|
-
if args.yes {
|
|
115
|
-
retry.push_str(" --yes");
|
|
116
|
-
}
|
|
117
|
-
if args.detail {
|
|
118
|
-
retry.push_str(" --detail");
|
|
119
|
-
}
|
|
120
|
-
if args.json {
|
|
121
|
-
retry.push_str(" --json");
|
|
122
|
-
}
|
|
123
|
-
let explanation = if missing_team {
|
|
124
|
-
format!("Team configuration is missing: {}. No workers were started. Create the two files below; this command did not write them. Error: {error}", team_path.display())
|
|
125
|
-
} else {
|
|
126
|
-
format!("Worker configuration is incomplete: {detail}. Add the role directory or required fields. The examples below do not overwrite existing files. Error: {error}")
|
|
127
|
-
};
|
|
128
|
-
let next = format!("Check that Pi is installed and signed in; verify the model with team-agent models --provider pi.\nRun team-agent pi, then execute this command in that leader's tool context:\n{retry}");
|
|
129
|
-
let mut templates =
|
|
130
|
-
vec![serde_json::json!({"path": role_path, "content": super::emit::WORKER_TEMPLATE})];
|
|
131
|
-
let mut human = explanation.clone();
|
|
132
|
-
if missing_team {
|
|
133
|
-
templates.insert(
|
|
134
|
-
0,
|
|
135
|
-
serde_json::json!({"path": team_path, "content": super::emit::TEAM_TEMPLATE}),
|
|
136
|
-
);
|
|
137
|
-
human.push_str(&format!(
|
|
138
|
-
"\n\n{}:\n{}",
|
|
139
|
-
team_path.display(),
|
|
140
|
-
super::emit::TEAM_TEMPLATE
|
|
141
|
-
));
|
|
142
|
-
}
|
|
143
|
-
human.push_str(&format!(
|
|
144
|
-
"\n\n{}:\n{}\nNext steps:\n{next}",
|
|
145
|
-
role_path.display(),
|
|
146
|
-
super::emit::WORKER_TEMPLATE
|
|
147
|
-
));
|
|
148
|
-
value["action"] = serde_json::json!(explanation);
|
|
149
|
-
value["next_actions"] =
|
|
150
|
-
serde_json::json!(["team-agent models --provider pi", "team-agent pi", retry]);
|
|
151
|
-
value["templates"] = serde_json::json!(templates);
|
|
152
|
-
if args.json {
|
|
153
|
-
Some(CmdResult::from_json(value.clone(), true))
|
|
154
|
-
} else {
|
|
155
|
-
let mut result = CmdResult::human(&human);
|
|
156
|
-
result.exit = ExitCode::Error;
|
|
157
|
-
Some(result)
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/// E13:quick-start "team 起了" 人类输出 = summary + attach 块。所有成功出口共用(别每分支手拷)。
|
|
162
|
-
/// attach_commands 缺/空 → 只 summary(向后兼容)。
|
|
163
|
-
fn quickstart_human(value: &Value) -> String {
|
|
164
|
-
let summary = value
|
|
165
|
-
.get("summary")
|
|
166
|
-
.and_then(Value::as_str)
|
|
167
|
-
.unwrap_or("Team started.");
|
|
168
|
-
let attach: Vec<&str> = value
|
|
169
|
-
.get("attach_commands")
|
|
170
|
-
.and_then(Value::as_array)
|
|
171
|
-
.map(|items| items.iter().filter_map(Value::as_str).collect())
|
|
172
|
-
.unwrap_or_default();
|
|
173
|
-
let sends: Vec<&str> = value
|
|
174
|
-
.get("send_commands")
|
|
175
|
-
.and_then(Value::as_array)
|
|
176
|
-
.map(|items| items.iter().filter_map(Value::as_str).collect())
|
|
177
|
-
.unwrap_or_default();
|
|
178
|
-
let mut out = String::from(summary);
|
|
179
|
-
if !attach.is_empty() {
|
|
180
|
-
out.push_str("\n\nConnect to the team:");
|
|
181
|
-
for cmd in attach {
|
|
182
|
-
out.push_str("\n ");
|
|
183
|
-
out.push_str(cmd);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
if !sends.is_empty() {
|
|
187
|
-
out.push_str("\n\nSend a task (replace the example message):");
|
|
188
|
-
for cmd in sends {
|
|
189
|
-
out.push_str("\n ");
|
|
190
|
-
out.push_str(cmd);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
append_reminder(out, crate::cli::QUICK_START_REMINDER)
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
pub(crate) fn append_send_guidance(value: &mut Value, workspace: &Path, team: Option<&str>) {
|
|
197
|
-
let existing = value.get("summary").and_then(Value::as_str) == Some("existing runtime");
|
|
198
|
-
if value.get("ok").and_then(Value::as_bool) != Some(true) && !existing {
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
let team = value
|
|
202
|
-
.get("team")
|
|
203
|
-
.and_then(Value::as_str)
|
|
204
|
-
.filter(|team| !team.is_empty())
|
|
205
|
-
.map(str::to_string)
|
|
206
|
-
.or_else(|| team.map(str::to_string));
|
|
207
|
-
let team = team.as_deref();
|
|
208
|
-
let agents = value
|
|
209
|
-
.get("agent_ids")
|
|
210
|
-
.and_then(Value::as_array)
|
|
211
|
-
.cloned()
|
|
212
|
-
.unwrap_or_default();
|
|
213
|
-
let commands: Vec<Value> = agents
|
|
214
|
-
.iter()
|
|
215
|
-
.filter_map(Value::as_str)
|
|
216
|
-
.filter_map(|agent| send_command(agent, workspace, team).map(Value::String))
|
|
217
|
-
.collect();
|
|
218
|
-
if !commands.is_empty() {
|
|
219
|
-
if let Some(object) = value.as_object_mut() {
|
|
220
|
-
object.insert("send_commands".to_string(), Value::Array(commands));
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
#[cfg(test)]
|
|
226
|
-
pub(crate) fn split_shell_argv(command: &str) -> Vec<String> {
|
|
227
|
-
let mut argv = Vec::new();
|
|
228
|
-
let mut current = String::new();
|
|
229
|
-
let mut chars = command.chars().peekable();
|
|
230
|
-
let mut quote: Option<char> = None;
|
|
231
|
-
while let Some(ch) = chars.next() {
|
|
232
|
-
match (quote, ch) {
|
|
233
|
-
(None, '\'') | (None, '"') => quote = Some(ch),
|
|
234
|
-
(Some(q), c) if c == q => quote = None,
|
|
235
|
-
(None, c) if c.is_whitespace() => {
|
|
236
|
-
if !current.is_empty() {
|
|
237
|
-
argv.push(std::mem::take(&mut current));
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
(_, c) => current.push(c),
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
if !current.is_empty() {
|
|
244
|
-
argv.push(current);
|
|
245
|
-
}
|
|
246
|
-
argv
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
pub(crate) fn send_command(agent: &str, workspace: &Path, team: Option<&str>) -> Option<String> {
|
|
250
|
-
let workspace = workspace.to_str()?;
|
|
251
|
-
let mut command = format!(
|
|
252
|
-
"team-agent send {} {} --workspace {}",
|
|
253
|
-
shell_quote(agent),
|
|
254
|
-
shell_quote("Complete the task and reply to the leader."),
|
|
255
|
-
shell_quote(workspace)
|
|
256
|
-
);
|
|
257
|
-
if let Some(team) = team {
|
|
258
|
-
command.push_str(" --team ");
|
|
259
|
-
command.push_str(&shell_quote(team));
|
|
260
|
-
}
|
|
261
|
-
Some(command)
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
pub(crate) fn shell_quote(value: &str) -> String {
|
|
265
|
-
if value.bytes().all(|byte| {
|
|
266
|
-
byte.is_ascii_alphanumeric() || matches!(byte, b'/' | b'.' | b'_' | b'-' | b':')
|
|
267
|
-
}) {
|
|
268
|
-
value.to_string()
|
|
269
|
-
} else {
|
|
270
|
-
format!("'{}'", value.replace('\'', "'\\''"))
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
fn append_reminder(text: String, reminder: &str) -> String {
|
|
275
|
-
if text.is_empty() {
|
|
276
|
-
reminder.to_string()
|
|
277
|
-
} else {
|
|
278
|
-
format!("{text}\n{reminder}")
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/// `cmd_status`(`commands.py:90`)。CLI status 统一为只读九字段 brief;
|
|
283
|
-
/// `--json` 与人读路径共享 native tmux/process projection;`--summary`/`--detail` 保留参数兼容性但不暴露诊断。
|
|
284
|
-
#[cfg(test)]
|
|
285
|
-
pub(crate) fn cmd_status(args: &StatusArgs) -> Result<CmdResult, CliError> {
|
|
286
|
-
cmd_status_for_team(args, args.team.as_deref())
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
pub fn cmd_status_for_team(args: &StatusArgs, team: Option<&str>) -> Result<CmdResult, CliError> {
|
|
290
|
-
if args.summary && args.json {
|
|
291
|
-
return Err(CliError::Runtime(
|
|
292
|
-
"--summary and --json are mutually exclusive".to_string(),
|
|
293
|
-
));
|
|
294
|
-
}
|
|
295
|
-
if args.summary && args.agent.is_some() {
|
|
296
|
-
return Err(CliError::Runtime(
|
|
297
|
-
"status --summary does not accept an agent argument".to_string(),
|
|
298
|
-
));
|
|
299
|
-
}
|
|
300
|
-
// S4QR-001 (0.4.8): selected-team ambiguity gate. status is a selected-team
|
|
301
|
-
// command: when the workspace has 2+ alive teams and no --team was passed,
|
|
302
|
-
// refuse instead of silently defaulting to the active team. Uses the
|
|
303
|
-
// read-only CommandScope helper so the gate cannot migrate/write state.
|
|
304
|
-
if team.is_none() {
|
|
305
|
-
let scope = crate::state::paths::CommandScope::resolve_readonly(&args.workspace, None);
|
|
306
|
-
if scope.is_ambiguous() {
|
|
307
|
-
let candidates: Vec<String> = scope.candidates().to_vec();
|
|
308
|
-
let message = format!(
|
|
309
|
-
"status: workspace has multiple alive teams ({}); pass `--team <key>` to choose one",
|
|
310
|
-
candidates.join(", ")
|
|
311
|
-
);
|
|
312
|
-
return Err(CliError::Usage(message));
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
let selected = crate::state::selector::resolve_active_team_readonly(
|
|
316
|
-
&args.workspace,
|
|
317
|
-
team,
|
|
318
|
-
crate::state::selector::SelectorMode::RuntimeOnly,
|
|
319
|
-
)?;
|
|
320
|
-
if let Some(agent) = args.agent.as_deref() {
|
|
321
|
-
if !status_port::registered_agent_exists(&selected.state, agent) {
|
|
322
|
-
return Err(CliError::Runtime(format!("unknown agent id: {agent}")));
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
// Status brief is deliberately independent of the legacy RuntimeSnapshot:
|
|
326
|
-
// it performs one native tmux/process sample and exposes exactly nine
|
|
327
|
-
// fields. `--summary` and `--detail` remain parser-compatible but do not
|
|
328
|
-
// re-enable history, runtime diagnostics, or reminder text.
|
|
329
|
-
if args.json {
|
|
330
|
-
return Ok(CmdResult::from_json(
|
|
331
|
-
status_port::status_brief_scoped(
|
|
332
|
-
&selected.run_workspace,
|
|
333
|
-
&selected.state,
|
|
334
|
-
args.agent.as_deref(),
|
|
335
|
-
),
|
|
336
|
-
true,
|
|
337
|
-
));
|
|
338
|
-
}
|
|
339
|
-
Ok(CmdResult::human(status_port::format_status_brief(
|
|
340
|
-
&selected.run_workspace,
|
|
341
|
-
&selected.state,
|
|
342
|
-
args.agent.as_deref(),
|
|
343
|
-
)))
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
pub fn cmd_wait(args: &WaitArgs) -> Result<CmdResult, CliError> {
|
|
347
|
-
let result = messaging::wait_for_result(&args.workspace, &args.task_id)?;
|
|
348
|
-
Ok(CmdResult::from_json(result.to_json(), args.json))
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
/// `cmd_approvals`(`commands.py:112`)。
|
|
352
|
-
pub fn cmd_approvals(args: &ApprovalsArgs) -> Result<CmdResult, CliError> {
|
|
353
|
-
let selected = crate::state::selector::resolve_active_team(
|
|
354
|
-
&args.workspace,
|
|
355
|
-
args.team.as_deref(),
|
|
356
|
-
crate::state::selector::SelectorMode::RuntimeOnly,
|
|
357
|
-
)
|
|
358
|
-
.map_err(|e| CliError::Runtime(e.to_string()))?;
|
|
359
|
-
let value = status_port::approvals_scoped(
|
|
360
|
-
&selected.run_workspace,
|
|
361
|
-
&selected.state,
|
|
362
|
-
args.agent.as_deref(),
|
|
363
|
-
args.json,
|
|
364
|
-
)?;
|
|
365
|
-
if args.json {
|
|
366
|
-
Ok(CmdResult::from_json(value, true))
|
|
367
|
-
} else {
|
|
368
|
-
Ok(CmdResult::human(status_port::format_approvals(&value)))
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/// `cmd_inbox`(`commands.py:137`)。
|
|
373
|
-
pub fn cmd_inbox(args: &InboxArgs) -> Result<CmdResult, CliError> {
|
|
374
|
-
let value = crate::inbox_store::read(&args.workspace, &args.agent, args.limit, args.team.as_deref())
|
|
375
|
-
.map_err(CliError::Usage)?;
|
|
376
|
-
if args.json {
|
|
377
|
-
Ok(CmdResult::from_json(value, true))
|
|
378
|
-
} else {
|
|
379
|
-
Ok(CmdResult::human(format_inbox_human(&args.agent, &value)))
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
const INBOX_LINE_LIMIT_BYTES: usize = 160;
|
|
384
|
-
|
|
385
|
-
fn clean_inbox_field(value: &str) -> String {
|
|
386
|
-
value.chars().filter(|ch| !ch.is_control()).collect()
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
fn truncate_inbox_line(line: &str) -> String {
|
|
390
|
-
if line.len() <= INBOX_LINE_LIMIT_BYTES {
|
|
391
|
-
return line.to_string();
|
|
392
|
-
}
|
|
393
|
-
let budget = INBOX_LINE_LIMIT_BYTES.saturating_sub("…".len());
|
|
394
|
-
let mut end = 0;
|
|
395
|
-
for (index, ch) in line.char_indices() {
|
|
396
|
-
let next = index + ch.len_utf8();
|
|
397
|
-
if next > budget {
|
|
398
|
-
break;
|
|
399
|
-
}
|
|
400
|
-
end = next;
|
|
401
|
-
}
|
|
402
|
-
format!("{}…", &line[..end])
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
fn format_inbox_human(agent: &str, value: &Value) -> String {
|
|
406
|
-
let messages = value
|
|
407
|
-
.get("messages")
|
|
408
|
-
.and_then(Value::as_array)
|
|
409
|
-
.cloned()
|
|
410
|
-
.unwrap_or_default();
|
|
411
|
-
if messages.is_empty() {
|
|
412
|
-
return format!("{agent}: no messages");
|
|
413
|
-
}
|
|
414
|
-
messages
|
|
415
|
-
.iter()
|
|
416
|
-
.map(|message| {
|
|
417
|
-
let id = clean_inbox_field(
|
|
418
|
-
message
|
|
419
|
-
.get("message_id")
|
|
420
|
-
.and_then(Value::as_str)
|
|
421
|
-
.unwrap_or("-"),
|
|
422
|
-
);
|
|
423
|
-
let sender =
|
|
424
|
-
clean_inbox_field(message.get("sender").and_then(Value::as_str).unwrap_or("-"));
|
|
425
|
-
let recipient = clean_inbox_field(
|
|
426
|
-
message
|
|
427
|
-
.get("recipient")
|
|
428
|
-
.and_then(Value::as_str)
|
|
429
|
-
.unwrap_or("-"),
|
|
430
|
-
);
|
|
431
|
-
let status =
|
|
432
|
-
clean_inbox_field(message.get("status").and_then(Value::as_str).unwrap_or("-"));
|
|
433
|
-
let time = clean_inbox_field(
|
|
434
|
-
message
|
|
435
|
-
.get("created_at")
|
|
436
|
-
.and_then(Value::as_str)
|
|
437
|
-
.unwrap_or("-"),
|
|
438
|
-
);
|
|
439
|
-
let summary =
|
|
440
|
-
clean_inbox_field(message.get("summary").or_else(|| message.get("content")).and_then(Value::as_str).unwrap_or(""));
|
|
441
|
-
truncate_inbox_line(&format!(
|
|
442
|
-
"[{id}] [{sender} -> {recipient}] [{status}] [{time}] [{summary}]"
|
|
443
|
-
))
|
|
444
|
-
})
|
|
445
|
-
.collect::<Vec<_>>()
|
|
446
|
-
.join("\n")
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
/// `cmd_takeover`(`commands.py:152`)。
|
|
450
|
-
pub fn cmd_takeover(args: &TakeoverArgs) -> Result<CmdResult, CliError> {
|
|
451
|
-
Ok(CmdResult::from_json(
|
|
452
|
-
leader_port::takeover(&args.workspace, args.team.as_deref(), args.confirm)?,
|
|
453
|
-
args.json,
|
|
454
|
-
))
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
/// `cmd_claim_leader`(`commands.py:156`)。
|
|
458
|
-
pub fn cmd_claim_leader(args: &ClaimLeaderArgs) -> Result<CmdResult, CliError> {
|
|
459
|
-
let mut value = leader_port::claim_leader(&args.workspace, args.team.as_deref(), args.confirm)?;
|
|
460
|
-
if !args.detail {
|
|
461
|
-
leader_port::compact_lease_value(&mut value);
|
|
462
|
-
}
|
|
463
|
-
Ok(CmdResult::from_json(value, args.json))
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/// `cmd_shutdown`(`commands.py:340`)。
|
|
467
|
-
pub fn cmd_shutdown(args: &ShutdownArgs) -> Result<CmdResult, CliError> {
|
|
468
|
-
Ok(CmdResult::from_json(
|
|
469
|
-
lifecycle_port::shutdown(&args.workspace, args.keep_logs, args.team.as_deref())?,
|
|
470
|
-
args.json,
|
|
471
|
-
))
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
/// `cmd_restart`(`commands.py:344`)。
|
|
475
|
-
pub fn cmd_restart(args: &RestartArgs) -> Result<CmdResult, CliError> {
|
|
476
|
-
let mut value = lifecycle_port::restart(
|
|
477
|
-
&args.workspace,
|
|
478
|
-
args.allow_fresh,
|
|
479
|
-
args.team.as_deref(),
|
|
480
|
-
args.session_converge_deadline_ms,
|
|
481
|
-
)?;
|
|
482
|
-
if !args.detail {
|
|
483
|
-
lifecycle_port::compact_restart_value(&mut value);
|
|
484
|
-
}
|
|
485
|
-
Ok(CmdResult::from_json(value, args.json))
|
|
486
|
-
}
|
|
487
|
-
|
|
488
|
-
/// `cmd_start_agent`(`commands.py:348`)。
|
|
489
|
-
pub fn cmd_start_agent(args: &StartAgentArgs) -> Result<CmdResult, CliError> {
|
|
490
|
-
let mut value = lifecycle_port::start_agent(
|
|
491
|
-
&args.workspace,
|
|
492
|
-
&args.agent,
|
|
493
|
-
args.force,
|
|
494
|
-
args.allow_fresh,
|
|
495
|
-
args.team.as_deref(),
|
|
496
|
-
&args.role_config,
|
|
497
|
-
)?;
|
|
498
|
-
if value.get("agent_ids").is_none() {
|
|
499
|
-
if let Some(object) = value.as_object_mut() {
|
|
500
|
-
object.insert("agent_ids".to_string(), json!([args.agent.as_str()]));
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
append_send_guidance(&mut value, &args.workspace, args.team.as_deref());
|
|
504
|
-
Ok(CmdResult::from_json(value, args.json))
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
/// `cmd_stop_agent`(`commands.py:359`)。
|
|
508
|
-
pub fn cmd_stop_agent(args: &StopAgentArgs) -> Result<CmdResult, CliError> {
|
|
509
|
-
Ok(CmdResult::from_json(
|
|
510
|
-
lifecycle_port::stop_agent(&args.workspace, &args.agent, args.team.as_deref())?,
|
|
511
|
-
args.json,
|
|
512
|
-
))
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/// `cmd_reset_agent`(`commands.py:363`)。
|
|
516
|
-
pub fn cmd_reset_agent(args: &ResetAgentArgs) -> Result<CmdResult, CliError> {
|
|
517
|
-
Ok(CmdResult::from_json(
|
|
518
|
-
lifecycle_port::reset_agent(
|
|
519
|
-
&args.workspace,
|
|
520
|
-
&args.agent,
|
|
521
|
-
args.discard_session,
|
|
522
|
-
args.team.as_deref(),
|
|
523
|
-
)?,
|
|
524
|
-
args.json,
|
|
525
|
-
))
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
/// `cmd_add_agent`(`commands.py:373`)。
|
|
529
|
-
pub fn cmd_add_agent(args: &AddAgentArgs) -> Result<CmdResult, CliError> {
|
|
530
|
-
let mut value = lifecycle_port::add_agent(
|
|
531
|
-
&args.workspace,
|
|
532
|
-
&args.agent,
|
|
533
|
-
&args.role_file,
|
|
534
|
-
args.team.as_deref(),
|
|
535
|
-
args.force,
|
|
536
|
-
&args.role_config,
|
|
537
|
-
)?;
|
|
538
|
-
if value.get("agent_ids").is_none() {
|
|
539
|
-
if let Some(object) = value.as_object_mut() {
|
|
540
|
-
object.insert("agent_ids".to_string(), json!([args.agent.as_str()]));
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
append_send_guidance(&mut value, &args.workspace, args.team.as_deref());
|
|
544
|
-
Ok(CmdResult::from_json(value, args.json))
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
/// `cmd_fork_agent`(`commands.py:383`)。
|
|
548
|
-
pub fn cmd_fork_agent(args: &ForkAgentArgs) -> Result<CmdResult, CliError> {
|
|
549
|
-
Ok(CmdResult::from_json(
|
|
550
|
-
lifecycle_port::fork_agent(
|
|
551
|
-
&args.workspace,
|
|
552
|
-
&args.source_agent,
|
|
553
|
-
&args.as_agent,
|
|
554
|
-
args.label.as_deref(),
|
|
555
|
-
args.team.as_deref(),
|
|
556
|
-
)?,
|
|
557
|
-
args.json,
|
|
558
|
-
))
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
pub fn cmd_clone_agent(args: &CloneAgentArgs) -> Result<CmdResult, CliError> {
|
|
562
|
-
Ok(CmdResult::from_json(
|
|
563
|
-
lifecycle_port::clone_agent(
|
|
564
|
-
&args.workspace,
|
|
565
|
-
&args.source_agent,
|
|
566
|
-
&args.as_agent,
|
|
567
|
-
args.label.as_deref(),
|
|
568
|
-
args.team.as_deref(),
|
|
569
|
-
)?,
|
|
570
|
-
args.json,
|
|
571
|
-
))
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
/// `cmd_remove_agent`(`commands.py:394`)。
|
|
575
|
-
pub fn cmd_remove_agent(args: &RemoveAgentArgs) -> Result<CmdResult, CliError> {
|
|
576
|
-
Ok(CmdResult::from_json(
|
|
577
|
-
lifecycle_port::remove_agent(
|
|
578
|
-
&args.workspace,
|
|
579
|
-
&args.agent,
|
|
580
|
-
args.from_spec,
|
|
581
|
-
args.confirm,
|
|
582
|
-
args.force,
|
|
583
|
-
args.team.as_deref(),
|
|
584
|
-
)?,
|
|
585
|
-
args.json,
|
|
586
|
-
))
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
/// `doctor` is the single health/diagnostic pipeline.
|
|
590
|
-
pub fn cmd_doctor(args: &DoctorArgs) -> Result<CmdResult, CliError> {
|
|
591
|
-
if let Some(DoctorGate::Unknown(raw)) = &args.gate {
|
|
592
|
-
let value = json!({
|
|
593
|
-
"ok": false,
|
|
594
|
-
"issues": ["unknown_gate"],
|
|
595
|
-
"suggested_repairs": [{"action": "use --gate orphans or --gate comms", "issue": "unknown_gate"}],
|
|
596
|
-
"status": "unknown_gate",
|
|
597
|
-
"gate": raw,
|
|
598
|
-
});
|
|
599
|
-
return Ok(crate::cli::triage::report(value, args.json, "doctor"));
|
|
600
|
-
}
|
|
601
|
-
if args.fix && args.gate.is_none() {
|
|
602
|
-
let value = json!({
|
|
603
|
-
"ok": false,
|
|
604
|
-
"error": "--fix requires --gate",
|
|
605
|
-
"issues": ["fix_requires_gate"],
|
|
606
|
-
"suggested_repairs": [{"issue": "fix_requires_gate", "action": "add --gate orphans|comms"}],
|
|
607
|
-
});
|
|
608
|
-
return Ok(crate::cli::triage::report(value, args.json, "doctor"));
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
let explicit_comms = args.comms || matches!(args.gate, Some(DoctorGate::Comms));
|
|
612
|
-
let default_report =
|
|
613
|
-
!explicit_comms && args.gate.is_none() && !args.cleanup_orphans && !args.fix_schema;
|
|
614
|
-
let mut value = if explicit_comms {
|
|
615
|
-
crate::diagnose::comms::doctor_comms_json(
|
|
616
|
-
&args.workspace,
|
|
617
|
-
args.team.as_deref(),
|
|
618
|
-
Some("comms"),
|
|
619
|
-
)?
|
|
620
|
-
} else if matches!(args.gate, Some(DoctorGate::Orphans)) {
|
|
621
|
-
crate::diagnose::orphans::orphan_gate_json(&args.workspace, args.fix, args.confirm)?
|
|
622
|
-
} else if args.cleanup_orphans {
|
|
623
|
-
crate::diagnose::orphans::cleanup_orphans_json(&args.workspace, args.confirm)?
|
|
624
|
-
} else if args.fix_schema {
|
|
625
|
-
diagnose_port::fix_schema(&args.workspace)?
|
|
626
|
-
} else {
|
|
627
|
-
let value = diagnose_port::doctor(&args.workspace, args.spec.as_deref())?;
|
|
628
|
-
unified_default_doctor_report(args, value)
|
|
629
|
-
};
|
|
630
|
-
|
|
631
|
-
if explicit_comms {
|
|
632
|
-
if let Some(object) = value.as_object_mut() {
|
|
633
|
-
// The comms probe uses a random run id internally for its disposable
|
|
634
|
-
// fixture; the public doctor/diagnose report must be alias-stable.
|
|
635
|
-
object.insert("run_id".to_string(), Value::String("doctor".to_string()));
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
if !default_report {
|
|
639
|
-
finalize_doctor_report(&mut value, false);
|
|
640
|
-
}
|
|
641
|
-
let result = crate::cli::triage::report(value, args.json, "doctor");
|
|
642
|
-
Ok(result)
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
fn unified_default_doctor_report(args: &DoctorArgs, mut value: Value) -> Value {
|
|
646
|
-
let team_key = args
|
|
647
|
-
.team
|
|
648
|
-
.as_deref()
|
|
649
|
-
.filter(|team| !team.is_empty())
|
|
650
|
-
.unwrap_or("current");
|
|
651
|
-
let requested_workspace = args.workspace.to_string_lossy().to_string();
|
|
652
|
-
let mut runtime = json!({
|
|
653
|
-
"status": "not_present",
|
|
654
|
-
"workspace": requested_workspace,
|
|
655
|
-
"run_workspace": Value::Null,
|
|
656
|
-
"team_key": team_key,
|
|
657
|
-
"session_name": Value::Null,
|
|
658
|
-
"leader_receiver": Value::Null,
|
|
659
|
-
"agent_count": 0,
|
|
660
|
-
"message_count": 0,
|
|
661
|
-
"result_count": 0,
|
|
662
|
-
});
|
|
663
|
-
// Resolve explicit selectors and nested team directories before deciding
|
|
664
|
-
// that runtime inspection is inapplicable.
|
|
665
|
-
let selected = crate::state::selector::resolve_active_team_readonly(
|
|
666
|
-
&args.workspace,
|
|
667
|
-
args.team.as_deref(),
|
|
668
|
-
crate::state::selector::SelectorMode::RuntimeOnly,
|
|
669
|
-
);
|
|
670
|
-
let run_workspace = selected
|
|
671
|
-
.as_ref()
|
|
672
|
-
.map(|selected| selected.run_workspace.clone())
|
|
673
|
-
.unwrap_or_else(|_| {
|
|
674
|
-
crate::model::paths::canonical_run_workspace(&args.workspace)
|
|
675
|
-
.unwrap_or_else(|_| args.workspace.clone())
|
|
676
|
-
});
|
|
677
|
-
let runtime_present = selected.as_ref().is_ok_and(|selected| {
|
|
678
|
-
crate::cli::diagnose::workspace_has_existing_team_runtime(
|
|
679
|
-
&selected.run_workspace,
|
|
680
|
-
&selected.team_key,
|
|
681
|
-
)
|
|
682
|
-
});
|
|
683
|
-
let db_present = crate::model::paths::runtime_dir(&run_workspace)
|
|
684
|
-
.join("team.db")
|
|
685
|
-
.exists();
|
|
686
|
-
// One read-only observation supplies both issue classification and details.
|
|
687
|
-
// A physical database must be checked even before state.json is created.
|
|
688
|
-
let health = (runtime_present || db_present).then(|| {
|
|
689
|
-
crate::coordinator::coordinator_health_read_only(&crate::coordinator::WorkspacePath::new(
|
|
690
|
-
run_workspace.clone(),
|
|
691
|
-
))
|
|
692
|
-
});
|
|
693
|
-
match selected {
|
|
694
|
-
Ok(selected) => {
|
|
695
|
-
if let Some(health) = health.as_ref().filter(|_| runtime_present) {
|
|
696
|
-
let state = selected.state;
|
|
697
|
-
let backend: Box<dyn crate::transport::Transport> =
|
|
698
|
-
match crate::transport_factory::resolve_read_only_transport(
|
|
699
|
-
&selected.run_workspace,
|
|
700
|
-
Some(&state),
|
|
701
|
-
crate::transport_factory::TransportPurpose::Diagnose,
|
|
702
|
-
) {
|
|
703
|
-
Ok(resolved) => resolved.backend,
|
|
704
|
-
Err(_) => Box::new(crate::tmux_backend::TmuxBackend::for_workspace(
|
|
705
|
-
&selected.run_workspace,
|
|
706
|
-
)),
|
|
707
|
-
};
|
|
708
|
-
let (issues, repairs) = crate::cli::diagnose::diagnose_runtime_for_workspace(
|
|
709
|
-
&selected.run_workspace,
|
|
710
|
-
&state,
|
|
711
|
-
backend.as_ref(),
|
|
712
|
-
Some(selected.team_key.as_str()),
|
|
713
|
-
health,
|
|
714
|
-
);
|
|
715
|
-
merge_report_array(&mut value, "issues", &issues);
|
|
716
|
-
merge_report_array(&mut value, "suggested_repairs", &repairs);
|
|
717
|
-
let brief = crate::cli::status_port::status_brief_scoped(
|
|
718
|
-
&selected.run_workspace, &state, None,
|
|
719
|
-
);
|
|
720
|
-
let observations = brief["nodes"].as_array().into_iter().flatten()
|
|
721
|
-
.filter(|node| node.get("observation_reason").is_some()).cloned().collect::<Vec<_>>();
|
|
722
|
-
let run_workspace = selected.run_workspace.to_string_lossy().to_string();
|
|
723
|
-
runtime = json!({
|
|
724
|
-
"status": "present",
|
|
725
|
-
"workspace": args.workspace.to_string_lossy().to_string(),
|
|
726
|
-
"run_workspace": run_workspace,
|
|
727
|
-
"team_key": selected.team_key,
|
|
728
|
-
"session_name": state.get("session_name").cloned().unwrap_or(Value::Null),
|
|
729
|
-
"leader_receiver": state.get("leader_receiver").cloned().unwrap_or(Value::Null),
|
|
730
|
-
"agent_count": state.get("agents").and_then(Value::as_object).map_or(0, serde_json::Map::len),
|
|
731
|
-
"observations": observations,
|
|
732
|
-
"message_count": count_dir_entries(&selected.run_workspace.join(".team").join("messages")),
|
|
733
|
-
"result_count": count_dir_entries(&selected.run_workspace.join(".team").join("results")),
|
|
734
|
-
});
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
Err(error) => {
|
|
738
|
-
runtime["status"] = Value::String("unresolved".to_string());
|
|
739
|
-
runtime["observation_reason"] = json!("runtime_selection_failed");
|
|
740
|
-
runtime["next_action"] = json!(format!(
|
|
741
|
-
"team-agent status --workspace {} --team {} --json; verify the intended workspace/team selector before lifecycle changes",
|
|
742
|
-
shell_quote(&requested_workspace), shell_quote(team_key),
|
|
743
|
-
));
|
|
744
|
-
append_issue_repair(
|
|
745
|
-
&mut value,
|
|
746
|
-
"runtime_selection_failed",
|
|
747
|
-
format!("unable to select runtime team: {error}"),
|
|
748
|
-
);
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
if let Some(health) = health {
|
|
752
|
-
if db_present && !health.schema.ok {
|
|
753
|
-
append_issue_repair(
|
|
754
|
-
&mut value,
|
|
755
|
-
"coordinator_schema_incompatible",
|
|
756
|
-
"team-agent doctor --fix-schema --json".to_string(),
|
|
757
|
-
);
|
|
758
|
-
}
|
|
759
|
-
value["coordinator"] = diagnose_port::coordinator_health_value(health);
|
|
760
|
-
}
|
|
761
|
-
if let Some(object) = value.as_object_mut() {
|
|
762
|
-
object.insert("runtime".to_string(), runtime);
|
|
763
|
-
object.insert(
|
|
764
|
-
"event_log".to_string(),
|
|
765
|
-
Value::String(
|
|
766
|
-
run_workspace
|
|
767
|
-
.join(".team")
|
|
768
|
-
.join("logs")
|
|
769
|
-
.join("events.jsonl")
|
|
770
|
-
.to_string_lossy()
|
|
771
|
-
.to_string(),
|
|
772
|
-
),
|
|
773
|
-
);
|
|
774
|
-
}
|
|
775
|
-
finalize_doctor_report(&mut value, true);
|
|
776
|
-
value
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
fn merge_report_array(report: &mut Value, key: &str, incoming: &Value) {
|
|
780
|
-
let Some(items) = incoming.as_array() else {
|
|
781
|
-
return;
|
|
782
|
-
};
|
|
783
|
-
let Some(object) = report.as_object_mut() else {
|
|
784
|
-
return;
|
|
785
|
-
};
|
|
786
|
-
let target = object
|
|
787
|
-
.entry(key.to_string())
|
|
788
|
-
.or_insert_with(|| Value::Array(Vec::new()));
|
|
789
|
-
if !target.is_array() {
|
|
790
|
-
*target = Value::Array(Vec::new());
|
|
791
|
-
}
|
|
792
|
-
let target = target
|
|
793
|
-
.as_array_mut()
|
|
794
|
-
.expect("report array normalized before merge");
|
|
795
|
-
for item in items {
|
|
796
|
-
let identity = report_item_identity(item);
|
|
797
|
-
if !target
|
|
798
|
-
.iter()
|
|
799
|
-
.any(|existing| report_item_identity(existing) == identity)
|
|
800
|
-
{
|
|
801
|
-
target.push(item.clone());
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
fn report_item_identity(item: &Value) -> String {
|
|
807
|
-
if let Some(text) = item.as_str() {
|
|
808
|
-
return text.to_string();
|
|
809
|
-
}
|
|
810
|
-
let primary = ["id", "code", "issue", "action", "reason", "message"]
|
|
811
|
-
.iter()
|
|
812
|
-
.find_map(|key| item.get(*key).and_then(Value::as_str));
|
|
813
|
-
let scope = ["workspace", "team", "agent", "path", "rule"]
|
|
814
|
-
.iter()
|
|
815
|
-
.filter_map(|key| item.get(*key).and_then(Value::as_str))
|
|
816
|
-
.collect::<Vec<_>>();
|
|
817
|
-
let line = item.get("line").and_then(Value::as_u64);
|
|
818
|
-
if primary.is_some() || !scope.is_empty() || line.is_some() {
|
|
819
|
-
if scope.is_empty() && line.is_none() {
|
|
820
|
-
return primary.unwrap_or("object").to_string();
|
|
821
|
-
}
|
|
822
|
-
return format!(
|
|
823
|
-
"{}|{}|{}",
|
|
824
|
-
primary.unwrap_or("object"),
|
|
825
|
-
scope.join("|"),
|
|
826
|
-
line.map_or_else(String::new, |line| line.to_string())
|
|
827
|
-
);
|
|
828
|
-
}
|
|
829
|
-
item.to_string()
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
fn append_issue_repair(report: &mut Value, issue: &str, repair: String) {
|
|
833
|
-
merge_report_array(report, "issues", &json!([issue]));
|
|
834
|
-
merge_report_array(
|
|
835
|
-
report,
|
|
836
|
-
"suggested_repairs",
|
|
837
|
-
&json!([{"issue": issue, "action": repair}]),
|
|
838
|
-
);
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
fn finalize_doctor_report(report: &mut Value, default_report: bool) {
|
|
842
|
-
let Some(object) = report.as_object_mut() else {
|
|
843
|
-
*report = json!({
|
|
844
|
-
"ok": false,
|
|
845
|
-
"issues": ["invalid_doctor_report"],
|
|
846
|
-
"suggested_repairs": [{"issue": "invalid_doctor_report"}],
|
|
847
|
-
});
|
|
848
|
-
return;
|
|
849
|
-
};
|
|
850
|
-
let runtime_status = object
|
|
851
|
-
.get("runtime")
|
|
852
|
-
.and_then(|runtime| runtime.get("status"))
|
|
853
|
-
.and_then(Value::as_str)
|
|
854
|
-
.unwrap_or("not_run")
|
|
855
|
-
.to_string();
|
|
856
|
-
let mut issues = object
|
|
857
|
-
.remove("issues")
|
|
858
|
-
.and_then(|value| value.as_array().cloned())
|
|
859
|
-
.unwrap_or_default();
|
|
860
|
-
let mut repairs = object
|
|
861
|
-
.remove("suggested_repairs")
|
|
862
|
-
.and_then(|value| value.as_array().cloned())
|
|
863
|
-
.unwrap_or_default();
|
|
864
|
-
let mut add = |issue: Value, repair: Option<Value>| {
|
|
865
|
-
if !issues
|
|
866
|
-
.iter()
|
|
867
|
-
.any(|existing| report_item_identity(existing) == report_item_identity(&issue))
|
|
868
|
-
{
|
|
869
|
-
issues.push(issue);
|
|
870
|
-
}
|
|
871
|
-
if let Some(repair) = repair {
|
|
872
|
-
if !repairs
|
|
873
|
-
.iter()
|
|
874
|
-
.any(|existing| report_item_identity(existing) == report_item_identity(&repair))
|
|
875
|
-
{
|
|
876
|
-
repairs.push(repair);
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
};
|
|
880
|
-
|
|
881
|
-
if !default_report && object.get("ok").and_then(Value::as_bool) == Some(false) {
|
|
882
|
-
let status = object
|
|
883
|
-
.get("status")
|
|
884
|
-
.and_then(Value::as_str)
|
|
885
|
-
.or_else(|| object.get("reason").and_then(Value::as_str))
|
|
886
|
-
.unwrap_or("doctor_failed");
|
|
887
|
-
let issue = if status == "failed" {
|
|
888
|
-
object.get("gate").and_then(Value::as_str).map_or_else(
|
|
889
|
-
|| "doctor_failed".to_string(),
|
|
890
|
-
|gate| format!("{gate}_failed"),
|
|
891
|
-
)
|
|
892
|
-
} else if status.ends_with("_failed") || status == "refused" {
|
|
893
|
-
status.to_string()
|
|
894
|
-
} else {
|
|
895
|
-
format!("{status}_failed")
|
|
896
|
-
};
|
|
897
|
-
let repair = object
|
|
898
|
-
.get("action")
|
|
899
|
-
.or_else(|| object.get("next_action"))
|
|
900
|
-
.or_else(|| object.get("reason"))
|
|
901
|
-
.cloned();
|
|
902
|
-
add(
|
|
903
|
-
Value::String(issue),
|
|
904
|
-
repair.map(|value| json!({"action": value})),
|
|
905
|
-
);
|
|
906
|
-
}
|
|
907
|
-
if object
|
|
908
|
-
.get("workspace")
|
|
909
|
-
.and_then(Value::as_str)
|
|
910
|
-
.is_some_and(|workspace| !std::path::Path::new(workspace).is_dir())
|
|
911
|
-
{
|
|
912
|
-
add(
|
|
913
|
-
json!("invalid_workspace"),
|
|
914
|
-
Some(json!({"issue": "invalid_workspace", "action": "use an existing workspace"})),
|
|
915
|
-
);
|
|
916
|
-
}
|
|
917
|
-
if let Some(profile) = object.get("profile_smoke") {
|
|
918
|
-
if profile.get("ok").and_then(Value::as_bool) == Some(false)
|
|
919
|
-
&& profile.get("status").and_then(Value::as_str) != Some("legacy_team_invalid")
|
|
920
|
-
{
|
|
921
|
-
add(
|
|
922
|
-
json!("profile_smoke_failed"),
|
|
923
|
-
profile
|
|
924
|
-
.get("next_action")
|
|
925
|
-
.cloned()
|
|
926
|
-
.map(|action| json!({"issue": "profile_smoke_failed", "action": action})),
|
|
927
|
-
);
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
if let Some(grok) = object.get("grok_slot") {
|
|
931
|
-
if grok.get("readable").and_then(Value::as_bool) == Some(false)
|
|
932
|
-
|| grok.get("consistent").and_then(Value::as_bool) == Some(false)
|
|
933
|
-
{
|
|
934
|
-
add(
|
|
935
|
-
json!("grok_slot_mismatch"),
|
|
936
|
-
grok.get("reason")
|
|
937
|
-
.cloned()
|
|
938
|
-
.map(|reason| json!({"issue": "grok_slot_mismatch", "action": reason})),
|
|
939
|
-
);
|
|
940
|
-
}
|
|
941
|
-
}
|
|
942
|
-
if let Some(findings) = object
|
|
943
|
-
.get("secret_scan")
|
|
944
|
-
.and_then(|scan| scan.get("findings"))
|
|
945
|
-
.and_then(Value::as_array)
|
|
946
|
-
{
|
|
947
|
-
for finding in findings {
|
|
948
|
-
let Some(finding_object) = finding.as_object() else {
|
|
949
|
-
continue;
|
|
950
|
-
};
|
|
951
|
-
let Some(rule) = finding_object.get("rule").and_then(Value::as_str) else {
|
|
952
|
-
continue;
|
|
953
|
-
};
|
|
954
|
-
let path = finding_object
|
|
955
|
-
.get("path")
|
|
956
|
-
.and_then(Value::as_str)
|
|
957
|
-
.unwrap_or("unknown");
|
|
958
|
-
let line = finding_object
|
|
959
|
-
.get("line")
|
|
960
|
-
.and_then(Value::as_u64)
|
|
961
|
-
.unwrap_or(0);
|
|
962
|
-
let issue = json!({
|
|
963
|
-
"id": "secret_scan_finding",
|
|
964
|
-
"rule": rule,
|
|
965
|
-
"path": path,
|
|
966
|
-
"line": line,
|
|
967
|
-
});
|
|
968
|
-
add(
|
|
969
|
-
issue,
|
|
970
|
-
Some(json!({
|
|
971
|
-
"issue": "secret_scan_finding",
|
|
972
|
-
"rule": rule,
|
|
973
|
-
"path": path,
|
|
974
|
-
"line": line,
|
|
975
|
-
"action": format!("remove secret finding at {path}:{line}"),
|
|
976
|
-
})),
|
|
977
|
-
);
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
if runtime_status == "unresolved" {
|
|
981
|
-
add(
|
|
982
|
-
json!("runtime_selection_failed"),
|
|
983
|
-
Some(
|
|
984
|
-
json!({"issue": "runtime_selection_failed", "action": "select an existing Team runtime"}),
|
|
985
|
-
),
|
|
986
|
-
);
|
|
987
|
-
}
|
|
988
|
-
if runtime_status == "present"
|
|
989
|
-
&& object
|
|
990
|
-
.get("coordinator")
|
|
991
|
-
.and_then(|coordinator| coordinator.get("ok"))
|
|
992
|
-
.and_then(Value::as_bool)
|
|
993
|
-
== Some(false)
|
|
994
|
-
{
|
|
995
|
-
let reason = object
|
|
996
|
-
.get("coordinator")
|
|
997
|
-
.and_then(|coordinator| coordinator.get("metadata_mismatch_reason"))
|
|
998
|
-
.cloned()
|
|
999
|
-
.unwrap_or_else(|| json!("coordinator unavailable"));
|
|
1000
|
-
add(
|
|
1001
|
-
json!("coordinator_unavailable"),
|
|
1002
|
-
Some(json!({"issue": "coordinator_unavailable", "action": reason})),
|
|
1003
|
-
);
|
|
1004
|
-
}
|
|
1005
|
-
object.insert("issues".to_string(), Value::Array(issues.clone()));
|
|
1006
|
-
object.insert("suggested_repairs".to_string(), Value::Array(repairs));
|
|
1007
|
-
object.insert("ok".to_string(), Value::Bool(issues.is_empty()));
|
|
1008
|
-
}
|
|
1009
|
-
|
|
1010
|
-
#[cfg(test)]
|
|
1011
|
-
mod tests {
|
|
1012
|
-
#![allow(clippy::unwrap_used, clippy::panic)]
|
|
1013
|
-
|
|
1014
|
-
use super::{
|
|
1015
|
-
append_send_guidance, finish_quick_start, format_inbox_human, quickstart_human,
|
|
1016
|
-
send_command, split_shell_argv,
|
|
1017
|
-
};
|
|
1018
|
-
use crate::cli::{CmdOutput, ExitCode, QuickStartArgs};
|
|
1019
|
-
use serde_json::{json, Value};
|
|
1020
|
-
use std::path::{Path, PathBuf};
|
|
1021
|
-
|
|
1022
|
-
#[test]
|
|
1023
|
-
fn inbox_human_output_sanitizes_controls_and_caps_each_line() {
|
|
1024
|
-
let value = json!({
|
|
1025
|
-
"messages": [{
|
|
1026
|
-
"message_id": "msg-\u{001b}[31m".repeat(20),
|
|
1027
|
-
"sender": "sender\t\u{001b}[2J".repeat(20),
|
|
1028
|
-
"recipient": "worker".repeat(20),
|
|
1029
|
-
"status": "delivered",
|
|
1030
|
-
"created_at": "2026-09-19T00:00:00Z",
|
|
1031
|
-
"summary": "中".repeat(120)
|
|
1032
|
-
}]
|
|
1033
|
-
});
|
|
1034
|
-
let output = format_inbox_human("worker", &value);
|
|
1035
|
-
for line in output.lines() {
|
|
1036
|
-
assert!(line.len() <= 160, "line is {} bytes: {line:?}", line.len());
|
|
1037
|
-
assert!(
|
|
1038
|
-
!line.chars().any(char::is_control),
|
|
1039
|
-
"controls leaked: {line:?}"
|
|
1040
|
-
);
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
// E13:happy 人类输出必须带 attach 块(此前 else 分支只打 summary 丢 attach_commands)。
|
|
1045
|
-
#[test]
|
|
1046
|
-
fn e13_quickstart_human_includes_attach_commands() {
|
|
1047
|
-
let value = json!({
|
|
1048
|
-
"summary": "team started",
|
|
1049
|
-
"attach_commands": [
|
|
1050
|
-
"tmux -S /tmp/ta-x attach -t team-y:w1",
|
|
1051
|
-
"tmux -S /tmp/ta-x attach -t team-y:w2",
|
|
1052
|
-
],
|
|
1053
|
-
});
|
|
1054
|
-
let out = quickstart_human(&value);
|
|
1055
|
-
assert!(
|
|
1056
|
-
out.contains("team started"),
|
|
1057
|
-
"must show startup summary; got {out}"
|
|
1058
|
-
);
|
|
1059
|
-
assert!(
|
|
1060
|
-
out.contains("Connect to the team:"),
|
|
1061
|
-
"must render attach block; got {out}"
|
|
1062
|
-
);
|
|
1063
|
-
assert!(
|
|
1064
|
-
out.contains("team-y:w1") && out.contains("team-y:w2"),
|
|
1065
|
-
"must list each attach cmd; got {out}"
|
|
1066
|
-
);
|
|
1067
|
-
assert!(
|
|
1068
|
-
out.ends_with(crate::cli::QUICK_START_REMINDER),
|
|
1069
|
-
"must append harness reminder; got {out}"
|
|
1070
|
-
);
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
#[test]
|
|
1074
|
-
fn reminders_only_recommend_supported_result_commands() {
|
|
1075
|
-
let reminder = crate::cli::QUICK_START_REMINDER;
|
|
1076
|
-
assert!(reminder.contains("team-agent status"));
|
|
1077
|
-
assert!(reminder.contains("team-agent inbox"));
|
|
1078
|
-
for text in [
|
|
1079
|
-
reminder,
|
|
1080
|
-
crate::cli::STATUS_REMINDER,
|
|
1081
|
-
crate::cli::SEND_REMINDER,
|
|
1082
|
-
&quickstart_human(&json!({"summary": "team started"})),
|
|
1083
|
-
] {
|
|
1084
|
-
for hidden in ["collect", "team-agent results", "team-agent wait"] {
|
|
1085
|
-
assert!(
|
|
1086
|
-
!text.contains(hidden),
|
|
1087
|
-
"private/removed CLI command leaked: {text}"
|
|
1088
|
-
);
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
#[test]
|
|
1094
|
-
fn e13_quickstart_human_summary_only_when_no_attach() {
|
|
1095
|
-
let value = json!({"summary": "quick-start complete"});
|
|
1096
|
-
assert_eq!(
|
|
1097
|
-
quickstart_human(&value),
|
|
1098
|
-
format!("quick-start complete\n{}", crate::cli::QUICK_START_REMINDER)
|
|
1099
|
-
);
|
|
1100
|
-
// 空数组也只显示人类摘要与下一步,不凭空编造连接方式。
|
|
1101
|
-
let value2 = json!({"summary": "s", "attach_commands": []});
|
|
1102
|
-
assert_eq!(
|
|
1103
|
-
quickstart_human(&value2),
|
|
1104
|
-
format!("s\n{}", crate::cli::QUICK_START_REMINDER)
|
|
1105
|
-
);
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
#[test]
|
|
1109
|
-
fn send_command_message_is_one_argv_token() {
|
|
1110
|
-
let command = send_command(
|
|
1111
|
-
"worker name; echo unsafe",
|
|
1112
|
-
Path::new("/tmp/my workspace"),
|
|
1113
|
-
Some("team-a"),
|
|
1114
|
-
)
|
|
1115
|
-
.unwrap();
|
|
1116
|
-
let argv = split_shell_argv(&command);
|
|
1117
|
-
assert_eq!(
|
|
1118
|
-
argv,
|
|
1119
|
-
[
|
|
1120
|
-
"team-agent",
|
|
1121
|
-
"send",
|
|
1122
|
-
"worker name; echo unsafe",
|
|
1123
|
-
"Complete the task and reply to the leader.",
|
|
1124
|
-
"--workspace",
|
|
1125
|
-
"/tmp/my workspace",
|
|
1126
|
-
"--team",
|
|
1127
|
-
"team-a"
|
|
1128
|
-
]
|
|
1129
|
-
);
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
#[test]
|
|
1133
|
-
fn send_guidance_is_copyable_and_preserves_explicit_scope() {
|
|
1134
|
-
let command = send_command(
|
|
1135
|
-
"worker name; echo unsafe",
|
|
1136
|
-
Path::new("/tmp/my workspace"),
|
|
1137
|
-
Some("team-a"),
|
|
1138
|
-
)
|
|
1139
|
-
.unwrap();
|
|
1140
|
-
assert_eq!(
|
|
1141
|
-
command,
|
|
1142
|
-
"team-agent send 'worker name; echo unsafe' 'Complete the task and reply to the leader.' --workspace '/tmp/my workspace' --team team-a"
|
|
1143
|
-
);
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
#[cfg(unix)]
|
|
1147
|
-
#[test]
|
|
1148
|
-
fn non_utf8_workspace_fails_closed_without_send_guidance() {
|
|
1149
|
-
use std::ffi::OsString;
|
|
1150
|
-
use std::os::unix::ffi::OsStringExt;
|
|
1151
|
-
|
|
1152
|
-
let workspace = PathBuf::from(OsString::from_vec(b"/tmp/workspace-\xff".to_vec()));
|
|
1153
|
-
assert!(send_command("worker", &workspace, None).is_none());
|
|
1154
|
-
let mut value = json!({"ok": true, "agent_ids": ["worker"]});
|
|
1155
|
-
append_send_guidance(&mut value, &workspace, None);
|
|
1156
|
-
assert!(value.get("send_commands").is_none());
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
#[test]
|
|
1160
|
-
fn quick_start_guidance_lists_every_known_agent_without_guessing() {
|
|
1161
|
-
let mut value = json!({"ok": true, "agent_ids": ["sol", "luna"]});
|
|
1162
|
-
append_send_guidance(&mut value, Path::new("/tmp/ws"), Some("team"));
|
|
1163
|
-
let commands = value
|
|
1164
|
-
.get("send_commands")
|
|
1165
|
-
.and_then(|v| v.as_array())
|
|
1166
|
-
.unwrap();
|
|
1167
|
-
assert_eq!(commands.len(), 2);
|
|
1168
|
-
assert!(commands[0].as_str().unwrap().contains("send sol"));
|
|
1169
|
-
assert!(commands[1].as_str().unwrap().contains("send luna"));
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
#[test]
|
|
1173
|
-
fn error_results_do_not_get_send_guidance() {
|
|
1174
|
-
let mut value = json!({"ok": false, "agent_ids": ["worker"]});
|
|
1175
|
-
append_send_guidance(&mut value, Path::new("/tmp/ws"), None);
|
|
1176
|
-
assert!(value.get("send_commands").is_none());
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
#[test]
|
|
1180
|
-
fn existing_runtime_gets_canonical_send_guidance() {
|
|
1181
|
-
let mut value = json!({
|
|
1182
|
-
"ok": false,
|
|
1183
|
-
"summary": "existing runtime",
|
|
1184
|
-
"agent_ids": ["worker"]
|
|
1185
|
-
});
|
|
1186
|
-
append_send_guidance(&mut value, Path::new("/tmp/ws"), Some("team-a"));
|
|
1187
|
-
let command = value
|
|
1188
|
-
.pointer("/send_commands/0")
|
|
1189
|
-
.and_then(Value::as_str)
|
|
1190
|
-
.unwrap();
|
|
1191
|
-
assert!(command.contains("send worker"));
|
|
1192
|
-
assert!(command.contains("--team team-a"));
|
|
1193
|
-
assert_eq!(
|
|
1194
|
-
split_shell_argv(command),
|
|
1195
|
-
[
|
|
1196
|
-
"team-agent",
|
|
1197
|
-
"send",
|
|
1198
|
-
"worker",
|
|
1199
|
-
"Complete the task and reply to the leader.",
|
|
1200
|
-
"--workspace",
|
|
1201
|
-
"/tmp/ws",
|
|
1202
|
-
"--team",
|
|
1203
|
-
"team-a",
|
|
1204
|
-
]
|
|
1205
|
-
);
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
fn quick_start_args(as_json: bool) -> QuickStartArgs {
|
|
1209
|
-
QuickStartArgs {
|
|
1210
|
-
workspace: PathBuf::from("/tmp/first-launch"),
|
|
1211
|
-
agents_dir: PathBuf::from("/tmp/first-launch/.team/current"),
|
|
1212
|
-
name: None,
|
|
1213
|
-
team_id: None,
|
|
1214
|
-
yes: true,
|
|
1215
|
-
json: as_json,
|
|
1216
|
-
detail: false,
|
|
1217
|
-
backend: None,
|
|
1218
|
-
}
|
|
1219
|
-
}
|
|
1220
|
-
|
|
1221
|
-
#[test]
|
|
1222
|
-
fn quick_start_human_preserves_typed_refusals_without_error_field() {
|
|
1223
|
-
for status in [
|
|
1224
|
-
"existing_runtime",
|
|
1225
|
-
"preflight_blocked",
|
|
1226
|
-
"leader_binding_refused",
|
|
1227
|
-
] {
|
|
1228
|
-
let value = json!({
|
|
1229
|
-
"ok": false,
|
|
1230
|
-
"status": status,
|
|
1231
|
-
"reason": "the exact underlying refusal",
|
|
1232
|
-
"summary": "creation refused",
|
|
1233
|
-
"blockers": [{"stage": "identity", "reason": "owner mismatch"}],
|
|
1234
|
-
"next_actions": ["team-agent restart --workspace /tmp/first-launch --team current"],
|
|
1235
|
-
"state_path": "/tmp/first-launch/.team/runtime/state.json",
|
|
1236
|
-
"readiness": {"reason": "underlying readiness evidence"}
|
|
1237
|
-
});
|
|
1238
|
-
let result = finish_quick_start(value.clone(), &quick_start_args(false)).unwrap();
|
|
1239
|
-
assert_eq!(result.exit, ExitCode::Error);
|
|
1240
|
-
let CmdOutput::Human(text) = result.output else {
|
|
1241
|
-
panic!("expected human report")
|
|
1242
|
-
};
|
|
1243
|
-
let rendered: Value =
|
|
1244
|
-
serde_json::from_str(text.strip_prefix("quick-start report:\n").unwrap()).unwrap();
|
|
1245
|
-
assert_eq!(rendered, value, "human projection lost fields for {status}");
|
|
1246
|
-
assert!(
|
|
1247
|
-
!text.contains("team-agent doctor"),
|
|
1248
|
-
"must not replace actual actions"
|
|
1249
|
-
);
|
|
1250
|
-
let json_result = finish_quick_start(value.clone(), &quick_start_args(true)).unwrap();
|
|
1251
|
-
assert_eq!(json_result.exit, ExitCode::Error);
|
|
1252
|
-
assert_eq!(json_result.output, CmdOutput::Json(value));
|
|
1253
|
-
}
|
|
1254
|
-
}
|
|
1255
|
-
|
|
1256
|
-
#[test]
|
|
1257
|
-
fn quick_start_human_preserves_original_error_and_actions() {
|
|
1258
|
-
let value = json!({
|
|
1259
|
-
"ok": false,
|
|
1260
|
-
"error": "database initialization failed at /tmp/first-launch/.team/team.db: permission denied",
|
|
1261
|
-
"action": "repair directory permissions",
|
|
1262
|
-
"next_actions": ["inspect the exact database path"]
|
|
1263
|
-
});
|
|
1264
|
-
let result = finish_quick_start(value.clone(), &quick_start_args(false)).unwrap();
|
|
1265
|
-
assert_eq!(result.exit, ExitCode::Error);
|
|
1266
|
-
let CmdOutput::Human(text) = result.output else {
|
|
1267
|
-
panic!("expected human report")
|
|
1268
|
-
};
|
|
1269
|
-
let rendered: Value =
|
|
1270
|
-
serde_json::from_str(text.strip_prefix("quick-start report:\n").unwrap()).unwrap();
|
|
1271
|
-
assert_eq!(rendered, value);
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
#[test]
|
|
1275
|
-
fn pending_tool_load_is_not_reported_as_failed_team_creation() {
|
|
1276
|
-
for as_json in [false, true] {
|
|
1277
|
-
let value = json!({
|
|
1278
|
-
"ok": true,
|
|
1279
|
-
"status": "pending_tool_load",
|
|
1280
|
-
"summary": "Team started; worker tool loading is not yet verified",
|
|
1281
|
-
"readiness": {"ready": false},
|
|
1282
|
-
"next_actions": ["send a task and wait for the actual reply"]
|
|
1283
|
-
});
|
|
1284
|
-
let result = finish_quick_start(value, &quick_start_args(as_json)).unwrap();
|
|
1285
|
-
assert_eq!(result.exit, ExitCode::Ok);
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
}
|