@team-agent/installer 0.5.128 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,473 +0,0 @@
|
|
|
1
|
-
//! ---
|
|
2
|
-
//! purpose: 冷启路径的 worker spawn 执行器,按 spec 逐个起席并汇总启动结果
|
|
3
|
-
//! contract:
|
|
4
|
-
//! provides:
|
|
5
|
-
//! - name: spawn_agents
|
|
6
|
-
//! what: 按 spec 顺序起各非 paused 席位,返回已起席位清单
|
|
7
|
-
//! - name: agent_id_spec_source_path
|
|
8
|
-
//! what: 尽力还原某席位角色文档的路径,用于审计事件
|
|
9
|
-
//! depends:
|
|
10
|
-
//! - crate::transport::Transport
|
|
11
|
-
//! - crate::provider
|
|
12
|
-
//! - crate::state::persist
|
|
13
|
-
//! - crate::lifecycle::profile_launch
|
|
14
|
-
//! - crate::lifecycle::worker_command_context
|
|
15
|
-
//! boundary:
|
|
16
|
-
//! - 只负责起席与收集结果,state 落盘由 state_projection 负责
|
|
17
|
-
//! - 启动提示按掉与 fast 模式启用都是尽力而为,失败不阻断
|
|
18
|
-
//! maturity: wired
|
|
19
|
-
//! ---
|
|
20
|
-
//!
|
|
21
|
-
//! unit-8 (Stage 3) — `lifecycle::launch::spawn` phase boundary.
|
|
22
|
-
//!
|
|
23
|
-
//! Dedicated home for the worker spawn executor. Future commits migrate
|
|
24
|
-
//! `spawn_first_with_env_unset` and `spawn_into_with_env_unset` from
|
|
25
|
-
//! launch.rs:376-405 here.
|
|
26
|
-
|
|
27
|
-
use std::collections::{BTreeMap, BTreeSet};
|
|
28
|
-
use std::path::{Path, PathBuf};
|
|
29
|
-
use std::process::Command;
|
|
30
|
-
|
|
31
|
-
use crate::lifecycle::profile_launch::parse_provider;
|
|
32
|
-
use crate::lifecycle::*;
|
|
33
|
-
use crate::model::enums::{AuthMode, PaneLiveness, Provider, ProviderEffort};
|
|
34
|
-
use crate::model::ids::AgentId;
|
|
35
|
-
use crate::model::yaml::{self, Value};
|
|
36
|
-
use crate::state::persist::load_runtime_state;
|
|
37
|
-
use crate::transport::{PaneId, SessionName, Target, Transport, WindowName};
|
|
38
|
-
|
|
39
|
-
use crate::lifecycle::lock::{acquire_agent_lifecycle_lock, LifecycleLockRequest};
|
|
40
|
-
|
|
41
|
-
use super::*;
|
|
42
|
-
|
|
43
|
-
/// ---
|
|
44
|
-
/// purpose: 按 spec 顺序起各席位
|
|
45
|
-
/// params:
|
|
46
|
-
/// spec_path: spec 路径,team 目录优先取 state 里的 team_dir
|
|
47
|
-
/// session_name: 目标 tmux session
|
|
48
|
-
/// returns: legacy 启动收据与独立 contract 已提交席位 ID;不为私有 socket 伪造 legacy pane
|
|
49
|
-
/// errors: 命令拼装或 transport spawn 失败时返回 LifecycleError
|
|
50
|
-
/// ---
|
|
51
|
-
pub(super) fn spawn_agents(
|
|
52
|
-
workspace: &Path,
|
|
53
|
-
spec_path: &Path,
|
|
54
|
-
spec: &Value,
|
|
55
|
-
session_name: &SessionName,
|
|
56
|
-
transport: &dyn Transport,
|
|
57
|
-
) -> Result<(Vec<StartedAgent>, Vec<AgentId>), LifecycleError> {
|
|
58
|
-
// E5 解耦:team_dir(角色定义 + profiles 所在)≠ spec_path.parent()(spec 已迁出到 .team/runtime)。
|
|
59
|
-
// 优先取 state.team_dir(角色目录),回落 spec_path.parent()(legacy 同目录布局)。
|
|
60
|
-
let team_dir_buf = crate::state::persist::load_runtime_state(workspace)
|
|
61
|
-
.ok()
|
|
62
|
-
.and_then(|state| {
|
|
63
|
-
state
|
|
64
|
-
.get("team_dir")
|
|
65
|
-
.and_then(serde_json::Value::as_str)
|
|
66
|
-
.filter(|s| !s.is_empty())
|
|
67
|
-
.map(PathBuf::from)
|
|
68
|
-
});
|
|
69
|
-
let team_dir = team_dir_buf
|
|
70
|
-
.as_deref()
|
|
71
|
-
.unwrap_or_else(|| spec_path.parent().unwrap_or_else(|| Path::new(".")));
|
|
72
|
-
let mut started = Vec::new();
|
|
73
|
-
#[cfg(unix)]
|
|
74
|
-
let mut contract_started = Vec::new();
|
|
75
|
-
#[cfg(not(unix))]
|
|
76
|
-
let contract_started = Vec::new();
|
|
77
|
-
let agents = spec_agent_values(spec);
|
|
78
|
-
#[cfg(unix)]
|
|
79
|
-
let has_contract = agents.iter().any(|agent| agent.get("provider").and_then(Value::as_str)
|
|
80
|
-
.is_some_and(|provider| crate::contract_runtime::registry::descriptor(provider).is_some()));
|
|
81
|
-
#[cfg(not(unix))]
|
|
82
|
-
let has_contract = false;
|
|
83
|
-
for agent in agents {
|
|
84
|
-
let Some(agent_id_raw) = agent.get("id").and_then(Value::as_str) else {
|
|
85
|
-
continue;
|
|
86
|
-
};
|
|
87
|
-
if agent_is_paused(agent) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
#[cfg(unix)]
|
|
91
|
-
if agent
|
|
92
|
-
.get("provider")
|
|
93
|
-
.and_then(Value::as_str)
|
|
94
|
-
.is_some_and(|provider| {
|
|
95
|
-
crate::contract_runtime::registry::descriptor(provider).is_some()
|
|
96
|
-
})
|
|
97
|
-
{
|
|
98
|
-
let team = runtime_team_key_for_spec(spec_path, spec, session_name);
|
|
99
|
-
crate::contract_runtime::framework::start_role(
|
|
100
|
-
workspace,
|
|
101
|
-
team_dir,
|
|
102
|
-
&team,
|
|
103
|
-
agent_id_raw,
|
|
104
|
-
)?;
|
|
105
|
-
contract_started.push(AgentId::new(agent_id_raw));
|
|
106
|
-
// No legacy target is manufactured for the private native socket.
|
|
107
|
-
// persist_spawn_agent_state projects the actual K3 seat separately.
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
// A pre-upgrade Codex or Grok worker spec has no legacy runtime left;
|
|
111
|
-
// refuse before any MCP file, profile or pane side effect.
|
|
112
|
-
if let Some(retired) = agent
|
|
113
|
-
.get("provider")
|
|
114
|
-
.and_then(Value::as_str)
|
|
115
|
-
.filter(|provider| crate::provider::wire::is_retired_provider(provider))
|
|
116
|
-
{
|
|
117
|
-
return Err(LifecycleError::Provider(
|
|
118
|
-
crate::provider::wire::retired_provider_error(retired).into(),
|
|
119
|
-
));
|
|
120
|
-
}
|
|
121
|
-
let agent_id = AgentId::new(agent_id_raw);
|
|
122
|
-
// No provider silently falls back to a legacy engine.
|
|
123
|
-
let raw_provider = agent.get("provider").and_then(Value::as_str).unwrap_or("");
|
|
124
|
-
let provider = parse_provider(raw_provider).ok_or_else(|| {
|
|
125
|
-
LifecycleError::Provider(format!("unknown worker provider {raw_provider:?}"))
|
|
126
|
-
})?;
|
|
127
|
-
let auth_mode = agent
|
|
128
|
-
.get("auth_mode")
|
|
129
|
-
.and_then(Value::as_str)
|
|
130
|
-
.and_then(parse_auth_mode)
|
|
131
|
-
.unwrap_or(AuthMode::Subscription);
|
|
132
|
-
let model = agent.get("model").and_then(Value::as_str);
|
|
133
|
-
let adapter = crate::provider::get_adapter(provider);
|
|
134
|
-
// Contract C / F6.4: pass the COMPILED agent context (resolved role/system prompt,
|
|
135
|
-
// tools list, per-worker MCP config) into command construction so a real worker
|
|
136
|
-
// has both the role instruction AND the callable Team Agent MCP capability.
|
|
137
|
-
// probe5 RED proved that `build_command(.., None, None, ..)` left the worker
|
|
138
|
-
// without `report_result`; placeholders are substituted at spawn time.
|
|
139
|
-
let command_agent =
|
|
140
|
-
crate::lifecycle::worker_command_context::WorkerCommandAgent::from_yaml(
|
|
141
|
-
agent,
|
|
142
|
-
Some(agent_id_raw),
|
|
143
|
-
provider,
|
|
144
|
-
)?;
|
|
145
|
-
let system_prompt =
|
|
146
|
-
crate::lifecycle::worker_command_context::compile_worker_system_prompt(&command_agent)?;
|
|
147
|
-
// 0.5.66 bypass 单源:per-agent safety 只服务 env 注入与审计,不参与 argv 决策。
|
|
148
|
-
let safety = effective_runtime_config_for_worker_spawn(agent, provider)?;
|
|
149
|
-
let mcp_team_id = runtime_team_key_for_spec(spec_path, spec, session_name);
|
|
150
|
-
let mcp_config = adapter
|
|
151
|
-
.mcp_config(auth_mode)
|
|
152
|
-
.map_err(|e| LifecycleError::Provider(e.to_string()))?;
|
|
153
|
-
let mcp_config = resolve_mcp_config(mcp_config, workspace, agent_id_raw, &mcp_team_id);
|
|
154
|
-
let mcp_config_path = if provider == Provider::Pi {
|
|
155
|
-
None
|
|
156
|
-
} else {
|
|
157
|
-
Some(write_worker_mcp_config_for_provider(
|
|
158
|
-
workspace,
|
|
159
|
-
agent_id_raw,
|
|
160
|
-
&mcp_config,
|
|
161
|
-
Some(provider),
|
|
162
|
-
)?)
|
|
163
|
-
};
|
|
164
|
-
let profile_dir = team_dir.join("profiles");
|
|
165
|
-
let profile_launch =
|
|
166
|
-
crate::lifecycle::profile_launch::prepare_provider_profile_launch_with_profile_dir(
|
|
167
|
-
workspace,
|
|
168
|
-
agent_id_raw,
|
|
169
|
-
agent,
|
|
170
|
-
Some(&profile_dir),
|
|
171
|
-
Some(&mcp_config),
|
|
172
|
-
)?;
|
|
173
|
-
let command_model = profile_launch.command_overrides.model.as_deref().or(model);
|
|
174
|
-
// 0.4.x provider effort MVP step 4 + 7: resolve effort and emit
|
|
175
|
-
// unsupported warning event when the spec asked for an effort the
|
|
176
|
-
// provider can't satisfy.
|
|
177
|
-
let agent_effort = provider_effort_for_spawn(agent, provider)?;
|
|
178
|
-
if let Some(event_value) = provider_effort_event_if_dropped(agent, provider, agent_id_raw) {
|
|
179
|
-
let _ = crate::event_log::EventLog::new(workspace)
|
|
180
|
-
.write("provider.effort_unsupported", event_value);
|
|
181
|
-
}
|
|
182
|
-
let command_context = crate::provider::ProviderCommandContext {
|
|
183
|
-
auth_mode,
|
|
184
|
-
mcp_config: Some(&mcp_config),
|
|
185
|
-
system_prompt: Some(system_prompt.as_str()),
|
|
186
|
-
model: command_model,
|
|
187
|
-
dangerously_skip_permissions: matches!(
|
|
188
|
-
agent.get("dangerously_skip_permissions"),
|
|
189
|
-
Some(Value::Bool(true))
|
|
190
|
-
),
|
|
191
|
-
profile_launch: Some(&profile_launch),
|
|
192
|
-
// Layer 1 self-healing (architect probe 2026-06-22): expose
|
|
193
|
-
// agent_id as a display-name hint so Claude / Copilot
|
|
194
|
-
// adapters can pass `--name <agent_id>`. Codex has no
|
|
195
|
-
// equivalent flag and ignores the hint.
|
|
196
|
-
agent_id_hint: Some(agent_id_raw),
|
|
197
|
-
effort: agent_effort,
|
|
198
|
-
};
|
|
199
|
-
let mut plan = if provider == Provider::Pi {
|
|
200
|
-
crate::lifecycle::launch::pi_mcp::materialize_pi_plan(
|
|
201
|
-
crate::lifecycle::launch::pi_mcp::PiMaterializeRequest {
|
|
202
|
-
workspace,
|
|
203
|
-
team_id: &mcp_team_id,
|
|
204
|
-
agent_id: agent_id_raw,
|
|
205
|
-
model: command_model,
|
|
206
|
-
effort: agent_effort,
|
|
207
|
-
system_prompt: &system_prompt,
|
|
208
|
-
team_mcp_tools: &["send_message", "report_result", "get_team_status"],
|
|
209
|
-
mcp_config: &mcp_config,
|
|
210
|
-
session_scope: crate::lifecycle::launch::pi_mcp::PiSessionScope::Isolated,
|
|
211
|
-
session_dir: None,
|
|
212
|
-
},
|
|
213
|
-
)
|
|
214
|
-
.map_err(|e| LifecycleError::Provider(e.to_string()))?
|
|
215
|
-
} else {
|
|
216
|
-
adapter
|
|
217
|
-
.build_command_plan(command_context)
|
|
218
|
-
.map_err(|e| LifecycleError::Provider(e.to_string()))?
|
|
219
|
-
};
|
|
220
|
-
if !plan.managed_mcp_config && !profile_launch.managed_mcp_config {
|
|
221
|
-
if let Some(mcp_config_path) = mcp_config_path.as_ref() {
|
|
222
|
-
point_native_mcp_config_at_file(&mut plan.argv, provider, mcp_config_path);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
// C-A-4 cr verdict v2 — Copilot BYOK(compatible_api)硬性校验:
|
|
226
|
-
// "A model is required for BYOK"(help-providers 原文)。检查 agent
|
|
227
|
-
// 的 model 来源:角色 spec.model > profile COPILOT_MODEL(经 env_overlay)
|
|
228
|
-
// > --model 旗(本 worker 路径不在 argv 后追加用户 --model)。三者全空 → 报错
|
|
229
|
-
// 含 "model" 字面,失败信息透传给 leader。
|
|
230
|
-
if matches!(provider, Provider::Copilot) && auth_mode == AuthMode::CompatibleApi {
|
|
231
|
-
let has_model = model.is_some_and(|s| !s.is_empty())
|
|
232
|
-
|| profile_launch
|
|
233
|
-
.command_overrides
|
|
234
|
-
.model
|
|
235
|
-
.as_deref()
|
|
236
|
-
.is_some_and(|s| !s.is_empty())
|
|
237
|
-
|| profile_launch
|
|
238
|
-
.env_overlay
|
|
239
|
-
.get("COPILOT_MODEL")
|
|
240
|
-
.is_some_and(|v| !v.is_empty());
|
|
241
|
-
if !has_model {
|
|
242
|
-
return Err(LifecycleError::RequirementUnmet(
|
|
243
|
-
"copilot BYOK profile requires a model (set COPILOT_MODEL, agent.model, or --model)"
|
|
244
|
-
.to_string(),
|
|
245
|
-
));
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
// §B1 + C-7-1 + C-6-2 + C-3-2 cr verdict v2 — Copilot launch-time argv 注入:
|
|
249
|
-
// -n <agent_id> 会话命名(main-help:104)→ resume-by-name + 人查 双键
|
|
250
|
-
// -C <workspace> 双保险 cwd(main-help:55-56),防 shell 包装意外
|
|
251
|
-
// --log-dir <path> per-worker 定向日志(help-logging)→ 故障期可读 + N18 隔离
|
|
252
|
-
// --log-level info 配套日志级别
|
|
253
|
-
// --disable-mcp-server <n>... C-3-2 残留 MCP server 按名禁(扫 mcp list)
|
|
254
|
-
if matches!(provider, Provider::Copilot) {
|
|
255
|
-
plan.argv.push("-n".to_string());
|
|
256
|
-
plan.argv.push(agent_id_raw.to_string());
|
|
257
|
-
plan.argv.push("-C".to_string());
|
|
258
|
-
plan.argv.push(workspace.to_string_lossy().to_string());
|
|
259
|
-
let log_dir = workspace
|
|
260
|
-
.join(".team")
|
|
261
|
-
.join("logs")
|
|
262
|
-
.join("copilot")
|
|
263
|
-
.join(agent_id_raw);
|
|
264
|
-
std::fs::create_dir_all(&log_dir)
|
|
265
|
-
.map_err(|e| LifecycleError::StatePersist(format!("{}: {e}", log_dir.display())))?;
|
|
266
|
-
plan.argv.push("--log-dir".to_string());
|
|
267
|
-
plan.argv.push(log_dir.to_string_lossy().to_string());
|
|
268
|
-
plan.argv.push("--log-level".to_string());
|
|
269
|
-
plan.argv.push("info".to_string());
|
|
270
|
-
// C-3-2/C-3-3 cr verdict v2 — spawn 前扫 `copilot mcp list` 找用户全局/
|
|
271
|
-
// workspace 的 MCP 残留,对每个非 team_orchestrator server 追加
|
|
272
|
-
// --disable-mcp-server <name>,并落 mcp-residual.txt + event。
|
|
273
|
-
apply_copilot_mcp_residual_disables(
|
|
274
|
-
&workspace,
|
|
275
|
-
agent_id_raw,
|
|
276
|
-
&mut plan.argv,
|
|
277
|
-
&log_dir,
|
|
278
|
-
)?;
|
|
279
|
-
}
|
|
280
|
-
fill_spawn_placeholders_full(&mut plan.argv, workspace, agent_id_raw, Some(&mcp_team_id));
|
|
281
|
-
let mut env = inherited_env_with_team_overrides(
|
|
282
|
-
workspace,
|
|
283
|
-
agent_id_raw,
|
|
284
|
-
Some(&mcp_team_id),
|
|
285
|
-
Some(auth_mode_env_value(auth_mode)),
|
|
286
|
-
);
|
|
287
|
-
apply_profile_launch_env(&mut env, &profile_launch);
|
|
288
|
-
apply_mcp_auto_approval_env(&mut env, &safety);
|
|
289
|
-
// Python providers.py:145 + launch/core.py:253 — fresh launch runs the worker
|
|
290
|
-
// with cwd=workspace, same as the RS fork/add and restart paths.
|
|
291
|
-
let env_unset = crate::layout::worker_env::isolate_worker_spawn_env(
|
|
292
|
-
provider,
|
|
293
|
-
&mut env,
|
|
294
|
-
extend_worker_env_unset_for_effort(
|
|
295
|
-
profile_launch.env_unset.iter().cloned().collect(),
|
|
296
|
-
provider,
|
|
297
|
-
agent_effort.is_some(),
|
|
298
|
-
),
|
|
299
|
-
);
|
|
300
|
-
// The provider is the final typed value after profile overlays. Keep it
|
|
301
|
-
// separate from inherited LEADER_* identity and let the tmux invocation
|
|
302
|
-
// boundary add the actual pane/socket only for the provider process.
|
|
303
|
-
crate::layout::worker_env::inject_current_caller_provider(&mut env, provider);
|
|
304
|
-
// BUG / C-1-2 / C-6-1 cr verdict — Copilot system_prompt 走 spawn env overlay +
|
|
305
|
-
// per-worker AGENTS.md(B2 灵魂件降级):写
|
|
306
|
-
// <workspace>/.team/runtime/copilot-instructions/<agent_id>/AGENTS.md
|
|
307
|
-
// 全文 == compile_worker_system_prompt 输出,并通过 spawn env
|
|
308
|
-
// `COPILOT_CUSTOM_INSTRUCTIONS_DIRS=<该目录>` 让 copilot CLI 加载。
|
|
309
|
-
// **禁** silent 写 ~/.copilot/AGENTS.md(C-1-2)+ **禁** -i 作首条消息(C-1-5)。
|
|
310
|
-
if matches!(provider, Provider::Copilot) {
|
|
311
|
-
apply_copilot_instructions_overlay(
|
|
312
|
-
workspace,
|
|
313
|
-
agent_id_raw,
|
|
314
|
-
system_prompt.as_str(),
|
|
315
|
-
&mut env,
|
|
316
|
-
)?;
|
|
317
|
-
// C-A-6 cr verdict v2 — Copilot worker env 全量继承下,用户 shell 的
|
|
318
|
-
// COPILOT_GITHUB_TOKEN / GH_TOKEN / GITHUB_TOKEN 会穿透 + 按 cmd-login 实证
|
|
319
|
-
// **优先于凭据库**(可能静默改变 auth 通道)。一期只观测不剥除(剥除是
|
|
320
|
-
// 行为变更,cr 裁);命中任一就发 warn event 让 user 可见。
|
|
321
|
-
let mut passthrough: Vec<String> = Vec::new();
|
|
322
|
-
for key in ["COPILOT_GITHUB_TOKEN", "GH_TOKEN", "GITHUB_TOKEN"] {
|
|
323
|
-
if env.get(key).is_some_and(|v| !v.is_empty()) {
|
|
324
|
-
passthrough.push(key.to_string());
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
if !passthrough.is_empty() {
|
|
328
|
-
let event_log = crate::event_log::EventLog::new(workspace);
|
|
329
|
-
let _ = event_log.write(
|
|
330
|
-
"provider.copilot.token_passthrough_warning",
|
|
331
|
-
serde_json::json!({
|
|
332
|
-
"agent_id": agent_id_raw,
|
|
333
|
-
"tokens": passthrough,
|
|
334
|
-
"reason": "user shell GITHUB_TOKEN family takes precedence over copilot credential store (cmd-login)",
|
|
335
|
-
}),
|
|
336
|
-
);
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
crate::provider::argv_route::apply(provider, &mut plan.argv)
|
|
340
|
-
.map_err(|error| LifecycleError::Provider(error.to_string()))?;
|
|
341
|
-
let spawn_epoch = u64::try_from(started.len()).unwrap_or(u64::MAX);
|
|
342
|
-
let spawned_at = spawn_timestamp_for_agent(u32::try_from(spawn_epoch).unwrap_or(u32::MAX));
|
|
343
|
-
// E6 层1 实证3 + 诊断留痕:落最终 worker argv(spawn 前的真实形态)。
|
|
344
|
-
// 任何"--session-id 预定 UUID 没生效"必须能从 events.jsonl 回答:argv 里到底有没有它。
|
|
345
|
-
// 抽出 --session-id 值单列,方便和盘上 ~/.claude/projects/<cwd> 实际落的 UUID 对账。
|
|
346
|
-
{
|
|
347
|
-
let session_id_in_argv = plan
|
|
348
|
-
.argv
|
|
349
|
-
.iter()
|
|
350
|
-
.position(|a| a == "--session-id")
|
|
351
|
-
.and_then(|i| plan.argv.get(i + 1))
|
|
352
|
-
.cloned();
|
|
353
|
-
let event_log = crate::event_log::EventLog::new(workspace);
|
|
354
|
-
let _ = event_log.write(
|
|
355
|
-
crate::event_log::PROVIDER_WORKER_SPAWN_ARGV,
|
|
356
|
-
crate::event_log::provider_worker_spawn_argv_fields(serde_json::json!({
|
|
357
|
-
"agent_id": agent_id_raw,
|
|
358
|
-
"provider": provider,
|
|
359
|
-
"argv": plan.argv,
|
|
360
|
-
"session_id_in_argv": session_id_in_argv,
|
|
361
|
-
"expected_session_id": plan.expected_session_id.as_ref().map(|s| s.as_str()),
|
|
362
|
-
"spawn_cwd": workspace.to_string_lossy(),
|
|
363
|
-
"spawned_at": spawned_at.as_str(),
|
|
364
|
-
"source": "launch",
|
|
365
|
-
"spawn_epoch": spawn_epoch,
|
|
366
|
-
})),
|
|
367
|
-
);
|
|
368
|
-
// 0.5.66 bypass 单源 §2.7:最终 argv 含 bypass flag → 审计留痕。
|
|
369
|
-
if matches!(
|
|
370
|
-
agent.get("dangerously_skip_permissions"),
|
|
371
|
-
Some(Value::Bool(true))
|
|
372
|
-
) {
|
|
373
|
-
let _ = event_log.write(
|
|
374
|
-
"worker.spawn_dangerously_skip_permissions",
|
|
375
|
-
serde_json::json!({
|
|
376
|
-
"agent_id": agent_id_raw,
|
|
377
|
-
"role": agent
|
|
378
|
-
.get("role")
|
|
379
|
-
.and_then(Value::as_str)
|
|
380
|
-
.unwrap_or_default(),
|
|
381
|
-
"provider": provider,
|
|
382
|
-
"trigger": "launch",
|
|
383
|
-
"spec_source_path": agent_id_spec_source_path(workspace, agent_id_raw),
|
|
384
|
-
}),
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
// One independent tmux window per worker; no GUI/display layout.
|
|
389
|
-
let window = WindowName::new(agent_id_raw);
|
|
390
|
-
let spawn = if started.is_empty() && contract_started.is_empty() {
|
|
391
|
-
transport.spawn_first_with_env_unset(
|
|
392
|
-
session_name,
|
|
393
|
-
&window,
|
|
394
|
-
&plan.argv,
|
|
395
|
-
workspace,
|
|
396
|
-
&env,
|
|
397
|
-
&env_unset,
|
|
398
|
-
)
|
|
399
|
-
} else {
|
|
400
|
-
transport.spawn_into_with_env_unset(
|
|
401
|
-
session_name,
|
|
402
|
-
&window,
|
|
403
|
-
&plan.argv,
|
|
404
|
-
workspace,
|
|
405
|
-
&env,
|
|
406
|
-
&env_unset,
|
|
407
|
-
)
|
|
408
|
-
}
|
|
409
|
-
.map_err(|e| LifecycleError::Transport(e.to_string()))?;
|
|
410
|
-
let _ = adapter.handle_startup_prompts(
|
|
411
|
-
transport,
|
|
412
|
-
&Target::Pane(spawn.pane_id.clone()),
|
|
413
|
-
30,
|
|
414
|
-
0.5,
|
|
415
|
-
);
|
|
416
|
-
if matches!(transport.liveness(&spawn.pane_id), Ok(PaneLiveness::Dead)) {
|
|
417
|
-
continue;
|
|
418
|
-
}
|
|
419
|
-
started.push(StartedAgent {
|
|
420
|
-
agent_id,
|
|
421
|
-
start_mode: StartMode::Fresh,
|
|
422
|
-
target: spawn.pane_id.as_str().to_string(),
|
|
423
|
-
spawned_at,
|
|
424
|
-
session_id: None,
|
|
425
|
-
rollout_path: None,
|
|
426
|
-
pending_session_id: plan.expected_session_id.clone(),
|
|
427
|
-
claude_config_dir: profile_launch.claude_config_dir.clone(),
|
|
428
|
-
provider_projects_root: plan
|
|
429
|
-
.provider_projects_root
|
|
430
|
-
.clone()
|
|
431
|
-
.or_else(|| profile_launch.claude_projects_root.clone()),
|
|
432
|
-
managed_mcp_config: plan.managed_mcp_config || profile_launch.managed_mcp_config,
|
|
433
|
-
});
|
|
434
|
-
if has_contract && contract_started.is_empty() && started.len() == 1 {
|
|
435
|
-
// A native seat following the first legacy seat must be able to
|
|
436
|
-
// verify the same session before borrowing it, not after the batch.
|
|
437
|
-
let selected = crate::state::selector::resolve_active_team_readonly(workspace,
|
|
438
|
-
Some(&mcp_team_id), crate::state::selector::SelectorMode::RuntimeOnly)
|
|
439
|
-
.map_err(|e| LifecycleError::TeamSelect(e.to_string()))?;
|
|
440
|
-
let generation = crate::state::projection::session_generation(&selected.state)
|
|
441
|
-
.unwrap_or(session_name.as_str());
|
|
442
|
-
transport.set_session_owner_with_generation(session_name, workspace, &mcp_team_id, generation)
|
|
443
|
-
.map_err(|e| LifecycleError::Transport(e.to_string()))?;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
Ok((started, contract_started))
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
/// ---
|
|
450
|
-
/// purpose: 尽力还原某席位角色文档的路径
|
|
451
|
-
/// returns: state 里有 team_dir 时用它下的 agents 目录,否则退到 workspace 下的当前团队目录
|
|
452
|
-
/// ---
|
|
453
|
-
/// 0.5.66 bypass 单源 §2.7:审计事件里角色 md 的 spec 来源路径(尽力解析,失败空串)。
|
|
454
|
-
pub(crate) fn agent_id_spec_source_path(workspace: &Path, agent_id: &str) -> String {
|
|
455
|
-
let team_dir = crate::state::persist::load_runtime_state(workspace)
|
|
456
|
-
.ok()
|
|
457
|
-
.and_then(|state| {
|
|
458
|
-
state
|
|
459
|
-
.get("team_dir")
|
|
460
|
-
.and_then(serde_json::Value::as_str)
|
|
461
|
-
.filter(|s| !s.is_empty())
|
|
462
|
-
.map(PathBuf::from)
|
|
463
|
-
});
|
|
464
|
-
team_dir
|
|
465
|
-
.map(|dir| dir.join("agents").join(format!("{agent_id}.md")))
|
|
466
|
-
.unwrap_or_else(|| {
|
|
467
|
-
workspace
|
|
468
|
-
.join(".team/current/agents")
|
|
469
|
-
.join(format!("{agent_id}.md"))
|
|
470
|
-
})
|
|
471
|
-
.display()
|
|
472
|
-
.to_string()
|
|
473
|
-
}
|