@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,510 +0,0 @@
|
|
|
1
|
-
//!
|
|
2
|
-
//! step 14a · mcp_server::helpers — pure regularization + shared free helpers.
|
|
3
|
-
|
|
4
|
-
use std::io::Write as _;
|
|
5
|
-
use std::path::Path;
|
|
6
|
-
|
|
7
|
-
use rusqlite::{params, OptionalExtension};
|
|
8
|
-
use serde::Serialize;
|
|
9
|
-
use serde_json::Value;
|
|
10
|
-
|
|
11
|
-
use crate::messaging::{DeliveryOutcome, MessageTarget};
|
|
12
|
-
use crate::state::persist::load_runtime_state;
|
|
13
|
-
|
|
14
|
-
use super::types::{NormalizedReportEnvelope, ToolError, ToolErrorReason};
|
|
15
|
-
|
|
16
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
17
|
-
// MODULE HELPERS (tools.py:16-69) — pure regularization, contract-callable.
|
|
18
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
19
|
-
|
|
20
|
-
/// `_requires_ack_for_target` (`tools.py:16-19`): leader-only targets default to no
|
|
21
|
-
/// ack; any non-leader target → requires ack.
|
|
22
|
-
pub fn requires_ack_for_target(to: &MessageTarget) -> bool {
|
|
23
|
-
match to {
|
|
24
|
-
MessageTarget::Single(target) => !(target == "leader" || target == "Leader"),
|
|
25
|
-
MessageTarget::Broadcast => true,
|
|
26
|
-
MessageTarget::Fanout(targets) => targets
|
|
27
|
-
.iter()
|
|
28
|
-
.any(|target| !(target == "leader" || target == "Leader")),
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/// `_is_worker_recipient` (`tools.py:22-27`): a single string target that is not
|
|
33
|
-
/// `""`/`"*"`/`"leader"`/`"Leader"` → worker recipient (async accepted path).
|
|
34
|
-
pub fn is_worker_recipient(to: &MessageTarget) -> bool {
|
|
35
|
-
match to {
|
|
36
|
-
MessageTarget::Single(target) => {
|
|
37
|
-
!(target.is_empty() || target == "*" || target == "leader" || target == "Leader")
|
|
38
|
-
}
|
|
39
|
-
MessageTarget::Broadcast | MessageTarget::Fanout(_) => false,
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
pub(crate) fn tool_error_reason_wire(reason: ToolErrorReason) -> &'static str {
|
|
44
|
-
match reason {
|
|
45
|
-
ToolErrorReason::UnknownTool => "unknown_tool",
|
|
46
|
-
ToolErrorReason::InvalidToolArguments => "invalid_tool_arguments",
|
|
47
|
-
ToolErrorReason::InternalRuntimeError => "internal_runtime_error",
|
|
48
|
-
ToolErrorReason::PeerNotInScope => "peer_not_in_scope",
|
|
49
|
-
ToolErrorReason::McpScopeRefused => "mcp.scope_refused",
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
pub(crate) fn normalize_token(value: Option<&str>) -> String {
|
|
54
|
-
value
|
|
55
|
-
.unwrap_or("")
|
|
56
|
-
.trim()
|
|
57
|
-
.to_ascii_lowercase()
|
|
58
|
-
.replace(['-', ' '], "_")
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
pub(crate) fn text_field(value: &Value, key: &str) -> Option<String> {
|
|
62
|
-
value.get(key).and_then(text_of_value)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
pub(crate) fn text_of_value(value: &Value) -> Option<String> {
|
|
66
|
-
match value {
|
|
67
|
-
Value::Null => None,
|
|
68
|
-
Value::String(s) => non_empty_string(s).map(ToString::to_string),
|
|
69
|
-
Value::Number(n) => Some(n.to_string()),
|
|
70
|
-
Value::Bool(b) => Some(if *b { "True" } else { "False" }.to_string()),
|
|
71
|
-
Value::Array(_) | Value::Object(_) => None,
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
pub(crate) fn items_from_value(value: Option<&Value>) -> Vec<Value> {
|
|
76
|
-
match value {
|
|
77
|
-
Some(Value::Array(items)) => items.clone(),
|
|
78
|
-
Some(Value::Null) | None => Vec::new(),
|
|
79
|
-
Some(other) => vec![other.clone()],
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
pub(crate) fn non_empty_string(value: &str) -> Option<&str> {
|
|
84
|
-
let trimmed = value.trim();
|
|
85
|
-
if trimmed.is_empty() {
|
|
86
|
-
None
|
|
87
|
-
} else {
|
|
88
|
-
Some(trimmed)
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
pub(crate) fn enum_value<T: Serialize>(value: T) -> Value {
|
|
93
|
-
match serde_json::to_value(value) {
|
|
94
|
-
Ok(value) => value,
|
|
95
|
-
Err(_) => Value::Null,
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
pub(crate) fn json_dumps_default(value: &Value) -> String {
|
|
100
|
-
let mut bytes = Vec::new();
|
|
101
|
-
let mut ser = serde_json::Serializer::with_formatter(&mut bytes, PythonJsonFormatter);
|
|
102
|
-
if value.serialize(&mut ser).is_err() {
|
|
103
|
-
return "{}".to_string();
|
|
104
|
-
}
|
|
105
|
-
String::from_utf8(bytes).unwrap_or_else(|_| "{}".to_string())
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
struct PythonJsonFormatter;
|
|
109
|
-
|
|
110
|
-
impl serde_json::ser::Formatter for PythonJsonFormatter {
|
|
111
|
-
fn begin_array_value<W: ?Sized + std::io::Write>(
|
|
112
|
-
&mut self,
|
|
113
|
-
writer: &mut W,
|
|
114
|
-
first: bool,
|
|
115
|
-
) -> std::io::Result<()> {
|
|
116
|
-
if first {
|
|
117
|
-
Ok(())
|
|
118
|
-
} else {
|
|
119
|
-
writer.write_all(b", ")
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
fn begin_object_key<W: ?Sized + std::io::Write>(
|
|
124
|
-
&mut self,
|
|
125
|
-
writer: &mut W,
|
|
126
|
-
first: bool,
|
|
127
|
-
) -> std::io::Result<()> {
|
|
128
|
-
if first {
|
|
129
|
-
Ok(())
|
|
130
|
-
} else {
|
|
131
|
-
writer.write_all(b", ")
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
fn begin_object_value<W: ?Sized + std::io::Write>(
|
|
136
|
-
&mut self,
|
|
137
|
-
writer: &mut W,
|
|
138
|
-
) -> std::io::Result<()> {
|
|
139
|
-
writer.write_all(b": ")
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
pub(crate) fn normalized_envelope_value(env: &NormalizedReportEnvelope) -> Value {
|
|
144
|
-
match serde_json::to_value(env) {
|
|
145
|
-
Ok(value) => value,
|
|
146
|
-
Err(_) => serde_json::json!({
|
|
147
|
-
"schema_version": "result_envelope_v1",
|
|
148
|
-
"task_id": env.task_id.as_str(),
|
|
149
|
-
"agent_id": env.agent_id.as_str(),
|
|
150
|
-
"status": "success",
|
|
151
|
-
"summary": env.summary,
|
|
152
|
-
"changes": [], "tests": [], "risks": [], "artifacts": [], "next_actions": []
|
|
153
|
-
}),
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
pub(crate) fn ensure_object(value: &mut Value) {
|
|
158
|
-
if !value.is_object() {
|
|
159
|
-
*value = Value::Object(serde_json::Map::new());
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
pub(crate) fn insert_array(
|
|
164
|
-
obj: &mut serde_json::Map<String, Value>,
|
|
165
|
-
key: &str,
|
|
166
|
-
value: Option<&[Value]>,
|
|
167
|
-
) {
|
|
168
|
-
if let Some(items) = value {
|
|
169
|
-
obj.insert(key.to_string(), Value::Array(items.to_vec()));
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
pub(crate) fn tool_runtime_error(err: impl std::fmt::Display) -> ToolError {
|
|
174
|
-
ToolError::new(
|
|
175
|
-
ToolErrorReason::InternalRuntimeError,
|
|
176
|
-
ToolError::public_exception_message(&err.to_string(), "RuntimeError"),
|
|
177
|
-
"RuntimeError",
|
|
178
|
-
)
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
pub(crate) fn object_fields(value: Value) -> serde_json::Map<String, Value> {
|
|
182
|
-
match value {
|
|
183
|
-
Value::Object(map) => map,
|
|
184
|
-
other => {
|
|
185
|
-
let mut map = serde_json::Map::new();
|
|
186
|
-
map.insert("ok".to_string(), Value::Bool(true));
|
|
187
|
-
map.insert("value".to_string(), other);
|
|
188
|
-
map
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
pub(crate) fn delivery_outcome_value(out: &DeliveryOutcome) -> Value {
|
|
194
|
-
let mut value = serde_json::json!({
|
|
195
|
-
"ok": out.ok,
|
|
196
|
-
"status": enum_value(out.status),
|
|
197
|
-
"message_id": out.message_id,
|
|
198
|
-
"ack_forced_off": out.ack_forced_off,
|
|
199
|
-
});
|
|
200
|
-
if let Some(obj) = value.as_object_mut() {
|
|
201
|
-
if let Some(reason) = out.reason {
|
|
202
|
-
obj.insert("reason".to_string(), enum_value(reason));
|
|
203
|
-
}
|
|
204
|
-
if let Some(warning) = out.verification.as_deref() {
|
|
205
|
-
obj.insert("warning".to_string(), Value::String(warning.to_string()));
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
value
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/// Find the latest nonterminal task assigned to `agent_id`.
|
|
212
|
-
///
|
|
213
|
-
/// Blocker-1 (prerelease 0.4.0): scoped teams own their tasks under
|
|
214
|
-
/// `state.teams.<owner>.tasks`; top-level `state.tasks` is the legacy /
|
|
215
|
-
/// fallback list and is often stale or assigned to a different agent in
|
|
216
|
-
/// scoped-team workspaces. Search the scoped view first (when an owner team
|
|
217
|
-
/// is supplied), then fall back to top-level.
|
|
218
|
-
pub(crate) fn latest_task_for_assignee(
|
|
219
|
-
workspace: &Path,
|
|
220
|
-
agent_id: &str,
|
|
221
|
-
owner_team_id: Option<&str>,
|
|
222
|
-
) -> Option<String> {
|
|
223
|
-
let state = load_runtime_state(workspace).ok()?;
|
|
224
|
-
if let Some(owner) = owner_team_id.filter(|s| !s.is_empty()) {
|
|
225
|
-
if let Some(tasks) = state
|
|
226
|
-
.get("teams")
|
|
227
|
-
.and_then(|teams| teams.get(owner))
|
|
228
|
-
.and_then(|team| team.get("tasks"))
|
|
229
|
-
.and_then(Value::as_array)
|
|
230
|
-
{
|
|
231
|
-
if let Some(id) = find_latest_nonterminal_task_for(tasks, agent_id) {
|
|
232
|
-
return Some(id);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
let tasks = state.get("tasks").and_then(Value::as_array)?;
|
|
237
|
-
find_latest_nonterminal_task_for(tasks, agent_id)
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
fn find_latest_nonterminal_task_for(tasks: &[Value], agent_id: &str) -> Option<String> {
|
|
241
|
-
for task in tasks.iter().rev() {
|
|
242
|
-
let assignee = task.get("assignee").and_then(Value::as_str)?;
|
|
243
|
-
if assignee != agent_id {
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
let status = task
|
|
247
|
-
.get("status")
|
|
248
|
-
.and_then(Value::as_str)
|
|
249
|
-
.unwrap_or("")
|
|
250
|
-
.to_ascii_lowercase();
|
|
251
|
-
if matches!(
|
|
252
|
-
status.as_str(),
|
|
253
|
-
"done" | "success" | "failed" | "blocked" | "cancelled"
|
|
254
|
-
) {
|
|
255
|
-
continue;
|
|
256
|
-
}
|
|
257
|
-
if let Some(id) = task.get("id").and_then(text_of_value) {
|
|
258
|
-
return Some(id);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
None
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
pub(crate) fn latest_reportable_message_for(
|
|
265
|
-
workspace: &Path,
|
|
266
|
-
agent_id: &str,
|
|
267
|
-
owner_team_id: Option<&str>,
|
|
268
|
-
) -> Option<String> {
|
|
269
|
-
match direct_message_attribution_for(workspace, agent_id, owner_team_id) {
|
|
270
|
-
DirectMessageAttribution::Reportable(message_id) => Some(message_id),
|
|
271
|
-
DirectMessageAttribution::BlockedByNewer { .. } | DirectMessageAttribution::None => None,
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
pub(crate) fn current_reportable_message_for(
|
|
276
|
-
workspace: &Path,
|
|
277
|
-
agent_id: &str,
|
|
278
|
-
owner_team_id: Option<&str>,
|
|
279
|
-
) -> Option<String> {
|
|
280
|
-
use crate::db::message_store::MessageStore;
|
|
281
|
-
let store = MessageStore::open(workspace).ok()?;
|
|
282
|
-
let conn = crate::db::schema::open_db(store.db_path()).ok()?;
|
|
283
|
-
current_turn_message_for(workspace, &conn, agent_id, owner_team_id)
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
pub(crate) fn latest_delivered_direct_message_for(
|
|
287
|
-
workspace: &Path,
|
|
288
|
-
agent_id: &str,
|
|
289
|
-
owner_team_id: Option<&str>,
|
|
290
|
-
) -> Option<String> {
|
|
291
|
-
use crate::db::message_store::MessageStore;
|
|
292
|
-
let store = MessageStore::open(workspace).ok()?;
|
|
293
|
-
let conn = crate::db::schema::open_db(store.db_path()).ok()?;
|
|
294
|
-
latest_reportable_message_from_db(&conn, agent_id, owner_team_id)
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
298
|
-
pub(crate) enum DirectMessageAttribution {
|
|
299
|
-
Reportable(String),
|
|
300
|
-
BlockedByNewer {
|
|
301
|
-
message_id: String,
|
|
302
|
-
status: String,
|
|
303
|
-
error: Option<String>,
|
|
304
|
-
},
|
|
305
|
-
None,
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
pub(crate) fn direct_message_attribution_for(
|
|
309
|
-
workspace: &Path,
|
|
310
|
-
agent_id: &str,
|
|
311
|
-
owner_team_id: Option<&str>,
|
|
312
|
-
) -> DirectMessageAttribution {
|
|
313
|
-
use crate::db::message_store::MessageStore;
|
|
314
|
-
let Ok(store) = MessageStore::open(workspace) else {
|
|
315
|
-
return DirectMessageAttribution::None;
|
|
316
|
-
};
|
|
317
|
-
let Ok(conn) = crate::db::schema::open_db(store.db_path()) else {
|
|
318
|
-
return DirectMessageAttribution::None;
|
|
319
|
-
};
|
|
320
|
-
if let Some(message_id) = current_turn_message_for(workspace, &conn, agent_id, owner_team_id) {
|
|
321
|
-
return DirectMessageAttribution::Reportable(message_id);
|
|
322
|
-
}
|
|
323
|
-
match latest_direct_message_from_db(&conn, agent_id, owner_team_id) {
|
|
324
|
-
Some(candidate)
|
|
325
|
-
if reportable_message_status(&candidate.status, candidate.error.as_deref()) =>
|
|
326
|
-
{
|
|
327
|
-
DirectMessageAttribution::Reportable(candidate.message_id)
|
|
328
|
-
}
|
|
329
|
-
Some(candidate) if blocks_historical_fallback(&candidate.status) => {
|
|
330
|
-
DirectMessageAttribution::BlockedByNewer {
|
|
331
|
-
message_id: candidate.message_id,
|
|
332
|
-
status: candidate.status,
|
|
333
|
-
error: candidate.error,
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
Some(_) | None => DirectMessageAttribution::None,
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
fn current_turn_message_for(
|
|
341
|
-
workspace: &Path,
|
|
342
|
-
conn: &rusqlite::Connection,
|
|
343
|
-
agent_id: &str,
|
|
344
|
-
owner_team_id: Option<&str>,
|
|
345
|
-
) -> Option<String> {
|
|
346
|
-
let state = report_scope_state(workspace, owner_team_id)?;
|
|
347
|
-
current_turn_id_from_state(&state, agent_id)
|
|
348
|
-
.filter(|message_id| message_is_reportable(conn, message_id, agent_id, owner_team_id))
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
fn report_scope_state(workspace: &Path, owner_team_id: Option<&str>) -> Option<Value> {
|
|
352
|
-
let state = load_runtime_state(workspace).ok()?;
|
|
353
|
-
let Some(team) = owner_team_id.filter(|team| !team.is_empty()) else {
|
|
354
|
-
return Some(state);
|
|
355
|
-
};
|
|
356
|
-
let canonical = crate::state::projection::resolve_owner_team_id(&state, team)
|
|
357
|
-
.canonical_key()
|
|
358
|
-
.map(str::to_string)
|
|
359
|
-
.unwrap_or_else(|| team.to_string());
|
|
360
|
-
if let Some(projected) = state
|
|
361
|
-
.get("teams")
|
|
362
|
-
.and_then(Value::as_object)
|
|
363
|
-
.and_then(|teams| teams.get(&canonical))
|
|
364
|
-
.cloned()
|
|
365
|
-
{
|
|
366
|
-
Some(projected)
|
|
367
|
-
} else {
|
|
368
|
-
Some(state)
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
fn current_turn_id_from_state(state: &Value, agent_id: &str) -> Option<String> {
|
|
373
|
-
if let Some(turn) = state.get("coordinator").and_then(|v| v.get("turn_open")) {
|
|
374
|
-
let armed = turn.get("armed").and_then(Value::as_bool).unwrap_or(false);
|
|
375
|
-
let node_matches = turn
|
|
376
|
-
.get("node_id")
|
|
377
|
-
.and_then(Value::as_str)
|
|
378
|
-
.is_some_and(|node| node == agent_id);
|
|
379
|
-
if armed && node_matches {
|
|
380
|
-
if let Some(turn_id) = turn
|
|
381
|
-
.get("turn_id")
|
|
382
|
-
.and_then(Value::as_str)
|
|
383
|
-
.and_then(non_empty_string)
|
|
384
|
-
{
|
|
385
|
-
return Some(turn_id.to_string());
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
// Phase-DX E2: read the renamed `current_turn_message_id` (leader→worker turn
|
|
390
|
-
// proxy from `delivery::arm_turn_open`). Legacy state written by 0.5.x may
|
|
391
|
-
// still carry the pre-rename JSON key; the fallback keeps current-turn
|
|
392
|
-
// attribution stable during the transition. Neither field is treated as
|
|
393
|
-
// authoritative task state — that stays A1 territory (task FSM).
|
|
394
|
-
//
|
|
395
|
-
// The next line reads the pre-rename JSON key verbatim; that is deliberate
|
|
396
|
-
// and marked so the E2 grep guard admits it as a documented exception. The
|
|
397
|
-
// marker distinguishes a legitimate read-only backwards-compat bridge from
|
|
398
|
-
// an authority-consuming read (which the guard still forbids). Delete this
|
|
399
|
-
// fallback and its marker when the A1 task FSM lands (task attribution
|
|
400
|
-
// becomes authoritative and legacy state layouts are no longer produced).
|
|
401
|
-
let legacy_field = "current_task_id"; // ALLOWED-LEGACY-READ: backward-compat bridge for pre-rename key
|
|
402
|
-
state
|
|
403
|
-
.get("agents")
|
|
404
|
-
.and_then(|agents| agents.get(agent_id))
|
|
405
|
-
.and_then(|agent| {
|
|
406
|
-
agent
|
|
407
|
-
.get("current_turn_message_id")
|
|
408
|
-
.or_else(|| agent.get(legacy_field))
|
|
409
|
-
})
|
|
410
|
-
.and_then(Value::as_str)
|
|
411
|
-
.and_then(non_empty_string)
|
|
412
|
-
.map(ToString::to_string)
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
fn message_is_reportable(
|
|
416
|
-
conn: &rusqlite::Connection,
|
|
417
|
-
message_id: &str,
|
|
418
|
-
agent_id: &str,
|
|
419
|
-
owner_team_id: Option<&str>,
|
|
420
|
-
) -> bool {
|
|
421
|
-
conn.query_row(
|
|
422
|
-
"select 1 from messages m
|
|
423
|
-
where m.message_id = ?1
|
|
424
|
-
and m.recipient = ?2
|
|
425
|
-
and (?3 is null or m.owner_team_id = ?3)
|
|
426
|
-
and (m.task_id is null or m.task_id = '')
|
|
427
|
-
and m.status in ('delivered', 'target_resolved', 'submitted', 'injected', 'visible')
|
|
428
|
-
and (m.status = 'delivered' or m.error is null)
|
|
429
|
-
and m.created_at >= coalesce((
|
|
430
|
-
select max(r.created_at) from results r
|
|
431
|
-
where r.agent_id = m.recipient
|
|
432
|
-
and (?3 is null or r.owner_team_id = m.owner_team_id)
|
|
433
|
-
), '0000')
|
|
434
|
-
and not exists (
|
|
435
|
-
select 1 from results r
|
|
436
|
-
where r.task_id = m.message_id and r.agent_id = m.recipient
|
|
437
|
-
)
|
|
438
|
-
limit 1",
|
|
439
|
-
params![message_id, agent_id, owner_team_id],
|
|
440
|
-
|_| Ok(()),
|
|
441
|
-
)
|
|
442
|
-
.optional()
|
|
443
|
-
.ok()
|
|
444
|
-
.flatten()
|
|
445
|
-
.is_some()
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
fn latest_reportable_message_from_db(
|
|
449
|
-
conn: &rusqlite::Connection,
|
|
450
|
-
agent_id: &str,
|
|
451
|
-
owner_team_id: Option<&str>,
|
|
452
|
-
) -> Option<String> {
|
|
453
|
-
let candidate = latest_direct_message_from_db(conn, agent_id, owner_team_id)?;
|
|
454
|
-
if reportable_message_status(&candidate.status, candidate.error.as_deref()) {
|
|
455
|
-
Some(candidate.message_id)
|
|
456
|
-
} else {
|
|
457
|
-
None
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
struct DirectMessageCandidate {
|
|
462
|
-
message_id: String,
|
|
463
|
-
status: String,
|
|
464
|
-
error: Option<String>,
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
fn latest_direct_message_from_db(
|
|
468
|
-
conn: &rusqlite::Connection,
|
|
469
|
-
agent_id: &str,
|
|
470
|
-
owner_team_id: Option<&str>,
|
|
471
|
-
) -> Option<DirectMessageCandidate> {
|
|
472
|
-
conn.query_row(
|
|
473
|
-
"select m.message_id, m.status, m.error from messages m
|
|
474
|
-
where m.recipient = ?1
|
|
475
|
-
and (?2 is null or m.owner_team_id = ?2)
|
|
476
|
-
and (m.task_id is null or m.task_id = '')
|
|
477
|
-
and m.created_at >= coalesce((
|
|
478
|
-
select max(r.created_at) from results r
|
|
479
|
-
where r.agent_id = m.recipient
|
|
480
|
-
and (?2 is null or r.owner_team_id = m.owner_team_id)
|
|
481
|
-
), '0000')
|
|
482
|
-
and not exists (
|
|
483
|
-
select 1 from results r
|
|
484
|
-
where r.task_id = m.message_id and r.agent_id = m.recipient
|
|
485
|
-
)
|
|
486
|
-
order by m.created_at desc,
|
|
487
|
-
case when m.status = 'delivered' then 0 else 1 end
|
|
488
|
-
limit 1",
|
|
489
|
-
params![agent_id, owner_team_id],
|
|
490
|
-
|row| {
|
|
491
|
-
Ok(DirectMessageCandidate {
|
|
492
|
-
message_id: row.get::<_, String>(0)?,
|
|
493
|
-
status: row.get::<_, String>(1)?,
|
|
494
|
-
error: row.get::<_, Option<String>>(2)?,
|
|
495
|
-
})
|
|
496
|
-
},
|
|
497
|
-
)
|
|
498
|
-
.optional()
|
|
499
|
-
.ok()
|
|
500
|
-
.flatten()
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
fn reportable_message_status(status: &str, error: Option<&str>) -> bool {
|
|
504
|
-
matches!(status, "delivered" | "submitted" | "injected" | "visible")
|
|
505
|
-
&& (status == "delivered" || error.is_none())
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
fn blocks_historical_fallback(status: &str) -> bool {
|
|
509
|
-
matches!(status, "failed" | "refused" | "blocked")
|
|
510
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
//!
|
|
2
|
-
use std::path::Path;
|
|
3
|
-
|
|
4
|
-
use serde_json::Value;
|
|
5
|
-
|
|
6
|
-
use crate::model::ids::TeamKey;
|
|
7
|
-
|
|
8
|
-
use super::super::helpers::{object_fields, tool_runtime_error};
|
|
9
|
-
use super::super::{ToolOk, ToolResult};
|
|
10
|
-
|
|
11
|
-
pub(crate) fn get_team_status(workspace: &Path, owner_team: Option<&TeamKey>) -> ToolResult {
|
|
12
|
-
let selected = crate::state::selector::resolve_active_team(
|
|
13
|
-
workspace,
|
|
14
|
-
owner_team.map(TeamKey::as_str),
|
|
15
|
-
crate::state::selector::SelectorMode::RuntimeOnly,
|
|
16
|
-
)
|
|
17
|
-
.map_err(tool_runtime_error)?;
|
|
18
|
-
let status = crate::cli::status_port::status_scoped(
|
|
19
|
-
&selected.run_workspace,
|
|
20
|
-
&selected.state,
|
|
21
|
-
Some(selected.team_key.as_str()),
|
|
22
|
-
true,
|
|
23
|
-
false,
|
|
24
|
-
)
|
|
25
|
-
.map_err(tool_runtime_error)?;
|
|
26
|
-
let mut fields = object_fields(status);
|
|
27
|
-
fields
|
|
28
|
-
.entry("teams".to_string())
|
|
29
|
-
.or_insert_with(|| selected_team_only(&selected.state, &selected.team_key));
|
|
30
|
-
Ok(ToolOk { fields })
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
fn selected_team_only(state: &Value, team_key: &str) -> Value {
|
|
34
|
-
let mut teams = serde_json::Map::new();
|
|
35
|
-
if let Some(team) = state
|
|
36
|
-
.get("teams")
|
|
37
|
-
.and_then(Value::as_object)
|
|
38
|
-
.and_then(|all| all.get(team_key))
|
|
39
|
-
{
|
|
40
|
-
teams.insert(team_key.to_string(), team.clone());
|
|
41
|
-
}
|
|
42
|
-
Value::Object(teams)
|
|
43
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
//!
|
|
2
|
-
//! step 14a · mcp_server — stdio MCP server (`team_orchestrator`) over JSON-RPC 2.0.
|
|
3
|
-
//!
|
|
4
|
-
//! Card: `docs/phase0/subsystems/14-mcp_cli.md` (MCP half).
|
|
5
|
-
//! Truth source (READ-ONLY) `team-agent-public` @ v0.2.11 / `439bef8`:
|
|
6
|
-
//! - `mcp_server/server.py` — stdio loop + JSON-RPC route (`dispatch`/`handle_mcp`/`main`)
|
|
7
|
-
//! - `mcp_server/tools.py` — `TeamOrchestratorTools`: the three retained handlers
|
|
8
|
-
//! - `mcp_server/contracts.py` — retained tool names/descriptions/inputSchema
|
|
9
|
-
//! - `mcp_server/normalize.py` — result envelope / compact-result regularization
|
|
10
|
-
//! - `mcp_server/__init__.py` — package re-export surface locked by boundary tests
|
|
11
|
-
//!
|
|
12
|
-
//! SCOPE — this is the TYPE + BEHAVIORAL-ENTRY-FN layer so RED contracts can both
|
|
13
|
-
//! NAME the wire/envelope types AND CALL real handlers and assert against rich
|
|
14
|
-
//! return values. It is "the thinnest shell": it owns the wire protocol shape, the
|
|
15
|
-
//! tool-regularization rules, the error envelope, and identity/scope anchoring —
|
|
16
|
-
//! everything durable is delegated to step 5/6/7/11/13. Bodies are
|
|
17
|
-
//! `unimplemented!("step14 port: …")`.
|
|
18
|
-
//!
|
|
19
|
-
//! REUSE (do NOT redefine):
|
|
20
|
-
//! - [`EventLog`] (step 4) — retained message/result audit events.
|
|
21
|
-
//! - [`load_runtime_state`] (step 5 persist) — message scope and peer checks.
|
|
22
|
-
//! - [`messaging`] (step 11) — `send_message` and durable `report_result` delegation.
|
|
23
|
-
//! - [`crate::model::enums`] (step 2) — [`ResultStatus`] / [`ChangeKind`] /
|
|
24
|
-
//! [`TestStatus`] / [`RiskSeverity`] are the normalized result-envelope value
|
|
25
|
-
//! enums; this layer ONLY does string-alias regularization onto them.
|
|
26
|
-
//! - [`AgentId`] / [`TaskId`] / [`TeamKey`] (step 2 ids) — identity/scope anchors.
|
|
27
|
-
//!
|
|
28
|
-
//! 铁律 (card §11, Rust 绝不重蹈 Python 坑):
|
|
29
|
-
//! - **scope 锚 env, 禁候选扫描** (C13-C17/bug-064/082): sender identity =
|
|
30
|
-
//! spawn-time `TEAM_AGENT_ID`; scope = `TEAM_AGENT_OWNER_TEAM_ID`. `to="*"`
|
|
31
|
-
//! defaults to the sender team; worker-origin RPC arguments cannot widen
|
|
32
|
-
//! that scope. A peer not in scope → typed [`ToolError`] with
|
|
33
|
-
//! [`ToolErrorReason::PeerNotInScope`] — never leak other-team peer names.
|
|
34
|
-
//! - **错误信封冗余键** (server.py:98-106): `reason == error_code` and
|
|
35
|
-
//! `message == error` are byte-stable downstream contracts — preserved verbatim
|
|
36
|
-
//! in [`ToolError`]'s serialization, NOT "cleaned up".
|
|
37
|
-
//! - **notifications/* 不回包** (server.py:49-50): `notifications/*` → [`RpcMethod::
|
|
38
|
-
//! Notification`] → [`handle_mcp`] returns `None`; the loop `continue`s. Emitting
|
|
39
|
-
//! a frame here would corrupt the stdout JSON-RPC stream.
|
|
40
|
-
//! - **stdout 是传输通道** (server.py:135): every error is surfaced ON stdout as a
|
|
41
|
-
//! JSON-RPC frame; logs/warnings MUST go to stderr/file, never stdout.
|
|
42
|
-
//! - **worker-recipient 异步 accepted**: a worker recipient with a message_id →
|
|
43
|
-
//! [`SendOutcome::WorkerAccepted`]; leader/`*` → [`SendOutcome::Direct`].
|
|
44
|
-
//! - **兜底字符串字节级保留** (bug-085): `_infer_task_id` failure → `"manual"` (not
|
|
45
|
-
//! None); `_infer_agent_id` failure → `None` → caller routes to `"unknown"`.
|
|
46
|
-
//!
|
|
47
|
-
//! §10 deny: this subsystem is NOT a daemon/coordinator path, so the MCP shell does
|
|
48
|
-
//! not force top-level `#![deny(unwrap/expect/panic)]` (leader decides at
|
|
49
|
-
//! integration; card §109 carves out only `diagnose::comms::evaluate_idle_behavior`
|
|
50
|
-
//! and `diagnose::orphan::*`, which live in the CLI/diagnose lane, not here). All
|
|
51
|
-
//! fallible handlers return `Result<_, McpError>` regardless.
|
|
52
|
-
|
|
53
|
-
// ROUND-0 skeleton: fn bodies are all unimplemented!() so imports/fields/methods are
|
|
54
|
-
// not yet exercised; P2 porter removes this when implementing.
|
|
55
|
-
#![allow(
|
|
56
|
-
dead_code,
|
|
57
|
-
unused_imports,
|
|
58
|
-
unused_variables,
|
|
59
|
-
clippy::result_large_err,
|
|
60
|
-
clippy::doc_overindented_list_items,
|
|
61
|
-
clippy::doc_lazy_continuation,
|
|
62
|
-
clippy::io_other_error
|
|
63
|
-
)]
|
|
64
|
-
// §10:MCP stdio handlers 实现层禁 unwrap/expect/panic(unimplemented!() stub 不被拦);tests 子模块各自 allow。
|
|
65
|
-
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
66
|
-
|
|
67
|
-
use std::collections::BTreeSet;
|
|
68
|
-
use std::io::Write as _;
|
|
69
|
-
use std::path::{Path, PathBuf};
|
|
70
|
-
|
|
71
|
-
use serde::{Deserialize, Serialize};
|
|
72
|
-
use serde_json::Value;
|
|
73
|
-
use thiserror::Error;
|
|
74
|
-
|
|
75
|
-
// ── REUSE: step 2 model (ids + normalized-envelope value enums) ─────────────
|
|
76
|
-
use crate::model::enums::{ChangeKind, ResultStatus, RiskSeverity, TestStatus};
|
|
77
|
-
use crate::model::ids::{AgentId, TaskId, TeamKey};
|
|
78
|
-
|
|
79
|
-
// ── REUSE: step 4 event_log / step 7 message_store ──────────────────────────
|
|
80
|
-
use crate::event_log::EventLog;
|
|
81
|
-
use crate::message_store::MessageStore;
|
|
82
|
-
|
|
83
|
-
// ── REUSE: step 5 state persist / projection ────────────────────────────────
|
|
84
|
-
use crate::state::persist::load_runtime_state;
|
|
85
|
-
|
|
86
|
-
// ── REUSE: step 11 messaging delegate surface ───────────────────────────────
|
|
87
|
-
use crate::messaging::{self, DeliveryOutcome, MessageTarget, SendOptions, TrustedSender};
|
|
88
|
-
|
|
89
|
-
pub mod helpers;
|
|
90
|
-
pub(crate) mod lifecycle_tools;
|
|
91
|
-
pub mod normalize;
|
|
92
|
-
#[cfg(unix)]
|
|
93
|
-
pub(crate) mod readiness;
|
|
94
|
-
pub mod tools;
|
|
95
|
-
pub mod types;
|
|
96
|
-
pub mod wire;
|
|
97
|
-
|
|
98
|
-
// ── re-export: 保持 `crate::mcp_server::X` 与 test `super::X` 解析不变 ─────────
|
|
99
|
-
pub use helpers::*;
|
|
100
|
-
pub use normalize::*;
|
|
101
|
-
pub use tools::*;
|
|
102
|
-
pub use types::*;
|
|
103
|
-
pub use wire::*;
|
|
104
|
-
|
|
105
|
-
// pub(crate) 子项 (normalize 的 list helpers、wire 的 dispatch_tool 等) 经此再导出,
|
|
106
|
-
// 使 `#[cfg(test)] mod tests` 的 `use super::*` 与跨子模块引用解析不变。
|
|
107
|
-
pub(crate) use helpers::{
|
|
108
|
-
delivery_outcome_value, ensure_object, enum_value, insert_array, latest_reportable_message_for,
|
|
109
|
-
latest_task_for_assignee, non_empty_string, normalize_token, normalized_envelope_value,
|
|
110
|
-
object_fields, text_field, text_of_value, tool_error_reason_wire, tool_runtime_error,
|
|
111
|
-
};
|
|
112
|
-
pub(crate) use normalize::{
|
|
113
|
-
normalize_artifacts, normalize_changes, normalize_next_actions, normalize_risks,
|
|
114
|
-
normalize_tests,
|
|
115
|
-
};
|
|
116
|
-
pub(crate) use wire::dispatch_tool;
|
|
117
|
-
|
|
118
|
-
#[cfg(test)]
|
|
119
|
-
mod tests;
|