@team-agent/installer 0.5.127 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -4
- package/README.zh.md +1 -1
- package/package.json +4 -8
- package/skills/team-agent/SKILL.md +41 -26
- package/skills/team-agent/command-coverage.json +170 -184
- package/skills/team-agent/docs/reference/team-agent-operator.md +66 -32
- package/skills/team-agent/references/recovery-runbook.md +1 -1
- package/skills/team-agent/references/team-agent-operator.md +66 -32
- 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 -1298
- package/crates/team-agent/src/cli/arguments.rs +0 -401
- package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
- package/crates/team-agent/src/cli/diagnose.rs +0 -1675
- package/crates/team-agent/src/cli/emit.rs +0 -2898
- 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 -1189
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -821
- package/crates/team-agent/src/cli/intent/tests.rs +0 -691
- 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 -6528
- package/crates/team-agent/src/cli/models.rs +0 -449
- 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/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 -192
- 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 -201
- package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
- package/crates/team-agent/src/cli/spec.rs +0 -159
- 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 -2043
- 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 -372
- 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 -760
- package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
- package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -481
- 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 -1091
- 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 -842
- package/crates/team-agent/src/compiler.rs +0 -691
- 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 -1610
- package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
- package/crates/team-agent/src/contract_runtime/config.rs +0 -354
- package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -56
- package/crates/team-agent/src/contract_runtime/discovery.rs +0 -438
- package/crates/team-agent/src/contract_runtime/fork.rs +0 -368
- package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
- package/crates/team-agent/src/contract_runtime/framework.rs +0 -350
- package/crates/team-agent/src/contract_runtime/mcp.rs +0 -399
- 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 -589
- 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 -338
- 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 -461
- 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 -3112
- 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 -1585
- 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/event_log.rs +0 -502
- package/crates/team-agent/src/fake_worker.rs +0 -303
- 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 -883
- package/crates/team-agent/src/leader/start.rs +0 -4500
- 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 -267
- 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 -145
- package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -848
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -393
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -178
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -82
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -63
- 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 -152
- package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -629
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -226
- package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5176
- 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 -450
- 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 -534
- 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 -757
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
- package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2198
- package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2052
- 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 -223
- package/crates/team-agent/src/lifecycle/role_config.rs +0 -1205
- 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_profile_launch_red.rs +0 -135
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1415
- 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 -396
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -418
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2039
- package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1298
- 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 -71
- 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 -472
- 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 -3981
- 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 -152
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -182
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -374
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -546
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -31
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -528
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -134
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -333
- 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 -90
- 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 -996
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -827
- package/crates/team-agent/src/lifecycle/tests.rs +0 -102
- package/crates/team-agent/src/lifecycle/types.rs +0 -861
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -370
- 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 -546
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -369
- 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 -168
- package/crates/team-agent/src/mcp_server/tests/send.rs +0 -388
- package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -343
- 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 -1015
- 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 -3785
- 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 -354
- 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 -166
- 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/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 -217
- 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 -551
- 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 -3655
- package/crates/team-agent/src/messaging/tests/spine.rs +0 -837
- 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 -471
- 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 -898
- 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 -28
- 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 -773
- 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 -722
- package/crates/team-agent/src/provider/session/capture.rs +0 -2631
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -168
- package/crates/team-agent/src/provider/session/context_fork.rs +0 -264
- 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/common/tests.rs +0 -316
- package/crates/team-agent/src/provider/session_scan/common.rs +0 -618
- package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
- package/crates/team-agent/src/provider/session_scan/pi.rs +0 -152
- package/crates/team-agent/src/provider/session_scan.rs +0 -61
- 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 -354
- package/crates/team-agent/src/provider/tests/classify.rs +0 -201
- package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -26
- 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 -140
- 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 -406
- 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/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 -4254
- package/crates/team-agent/src/tmux_backend.rs +0 -4527
- 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,801 +0,0 @@
|
|
|
1
|
-
//! ---
|
|
2
|
-
//! purpose: spec 的读取改写与 runtime state 初值物化,含 quick-start 的 owner 种入
|
|
3
|
-
//! contract:
|
|
4
|
-
//! provides:
|
|
5
|
-
//! - name: initial_runtime_state
|
|
6
|
-
//! what: 由 spec 生成首份 runtime state 树,并种入 launched owner
|
|
7
|
-
//! - name: write_spec_atomic
|
|
8
|
-
//! what: 先写同目录临时文件再 rename,避免留下半截 spec
|
|
9
|
-
//! - name: spec_session_name
|
|
10
|
-
//! what: 取 runtime.session_name,缺省由 team 名派生
|
|
11
|
-
//! - name: spec_agents
|
|
12
|
-
//! what: 取 spec 里全部 agent id
|
|
13
|
-
//! - name: spec_routes
|
|
14
|
-
//! what: 对 spec 里每个 task 算出路由决策
|
|
15
|
-
//! - name: effective_runtime_config_for_worker_spawn
|
|
16
|
-
//! what: 由单个 agent 的 dangerously_skip_permissions 定出 bypass 审批结论
|
|
17
|
-
//! depends:
|
|
18
|
-
//! - crate::state::projection
|
|
19
|
-
//! - crate::state::identity
|
|
20
|
-
//! - crate::state::ownership
|
|
21
|
-
//! - crate::model::yaml
|
|
22
|
-
//! - crate::model::routing
|
|
23
|
-
//! - crate::provider::bypass_flags
|
|
24
|
-
//! - crate::lifecycle::launch::identity
|
|
25
|
-
//! - crate::lifecycle::launch::leader_context
|
|
26
|
-
//! - crate::lifecycle::launch::worker_env
|
|
27
|
-
//! boundary:
|
|
28
|
-
//! - 只生成与改写数据,不 spawn 进程也不开显示
|
|
29
|
-
//! - bypass 只认单个 agent 自己的声明,不从 runtime 配置或 leader argv 全队继承
|
|
30
|
-
//! - spec 写盘一律走原子替换,不做就地截断写
|
|
31
|
-
//! maturity: wired
|
|
32
|
-
//! ---
|
|
33
|
-
//!
|
|
34
|
-
//! unit-8 (Stage 3) — `lifecycle::launch::spec_state` phase boundary.
|
|
35
|
-
//!
|
|
36
|
-
//! The dedicated home for spec/runtime-path resolution and state-tree
|
|
37
|
-
//! materialization phases of `quick_start`. Lives in the
|
|
38
|
-
//! `lifecycle/launch/` submodule so future commits can migrate the
|
|
39
|
-
//! existing inline phase fns (launch.rs:2781-2906 and 1680-1756 ranges)
|
|
40
|
-
//! here in small, reviewable pieces.
|
|
41
|
-
//!
|
|
42
|
-
//! Established phases (canonical names — keep stable for future
|
|
43
|
-
//! migration):
|
|
44
|
-
//!
|
|
45
|
-
//! * `resolve_spec_paths` — `.team/runtime/<team>/team.spec.yaml`
|
|
46
|
-
//! resolution + workspace canonicalization
|
|
47
|
-
//! * `materialize_state` — T1 layer state.json initialization including
|
|
48
|
-
//! agent capture fields and `spawn_cwd`
|
|
49
|
-
//!
|
|
50
|
-
//! This commit lands the boundary + a marker enum so unit-8's adoption
|
|
51
|
-
//! sites can reference the phases by name. The phase fns themselves
|
|
52
|
-
//! remain in launch.rs until the next batch of relocations.
|
|
53
|
-
|
|
54
|
-
#[cfg(test)]
|
|
55
|
-
#[path = "../../../tests/support/hermetic.rs"]
|
|
56
|
-
mod hermetic;
|
|
57
|
-
|
|
58
|
-
use std::collections::{BTreeMap, BTreeSet};
|
|
59
|
-
use std::path::{Path, PathBuf};
|
|
60
|
-
use std::process::Command;
|
|
61
|
-
|
|
62
|
-
use crate::lifecycle::*;
|
|
63
|
-
use crate::model::enums::{AuthMode, PaneLiveness, Provider, ProviderEffort};
|
|
64
|
-
use crate::model::ids::AgentId;
|
|
65
|
-
use crate::model::yaml::{self, Value};
|
|
66
|
-
use crate::state::persist::load_runtime_state;
|
|
67
|
-
use crate::transport::{PaneId, SessionName, Target, Transport, WindowName};
|
|
68
|
-
|
|
69
|
-
use crate::lifecycle::lock::{acquire_agent_lifecycle_lock, LifecycleLockRequest};
|
|
70
|
-
|
|
71
|
-
use super::leader_context::{caller_provider_for_seed_with_lookup, seed_unbound_launched_owner};
|
|
72
|
-
use super::worker_env::spawn_timestamp;
|
|
73
|
-
|
|
74
|
-
/// ---
|
|
75
|
-
/// purpose: 由 spec 生成首份 runtime state 树
|
|
76
|
-
/// params:
|
|
77
|
-
/// team_key: 本团队的 runtime 键
|
|
78
|
-
/// scoped_endpoint: 本次起队已选中的 transport tmux endpoint,与 fresh bind 同源
|
|
79
|
-
/// returns: 含 spec_path、workspace、team_dir、session_name、leader、agents、tasks 的 state;随后按环境种入 launched owner,种不到则种一份 unbound owner
|
|
80
|
-
/// ---
|
|
81
|
-
pub(super) fn initial_runtime_state(
|
|
82
|
-
spec: &Value,
|
|
83
|
-
spec_path: &Path,
|
|
84
|
-
workspace: &Path,
|
|
85
|
-
team_dir: &Path,
|
|
86
|
-
team_key: &str,
|
|
87
|
-
scoped_endpoint: Option<&str>,
|
|
88
|
-
) -> serde_json::Value {
|
|
89
|
-
let mut agents = serde_json::Map::new();
|
|
90
|
-
for agent in spec_agent_values(spec) {
|
|
91
|
-
let Some(id) = agent.get("id").and_then(Value::as_str) else {
|
|
92
|
-
continue;
|
|
93
|
-
};
|
|
94
|
-
let provider = agent
|
|
95
|
-
.get("provider")
|
|
96
|
-
.and_then(Value::as_str)
|
|
97
|
-
.unwrap_or("codex");
|
|
98
|
-
let role = agent.get("role").and_then(Value::as_str).unwrap_or(id);
|
|
99
|
-
let model = agent.get("model").and_then(Value::as_str);
|
|
100
|
-
let auth_mode = agent.get("auth_mode").and_then(Value::as_str);
|
|
101
|
-
let mut value = serde_json::json!({
|
|
102
|
-
"provider": provider,
|
|
103
|
-
"role": role,
|
|
104
|
-
});
|
|
105
|
-
if let Some(obj) = value.as_object_mut() {
|
|
106
|
-
if let Some(model) = model {
|
|
107
|
-
obj.insert("model".to_string(), serde_json::json!(model));
|
|
108
|
-
}
|
|
109
|
-
if let Some(auth_mode) = auth_mode {
|
|
110
|
-
obj.insert("auth_mode".to_string(), serde_json::json!(auth_mode));
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
agents.insert(id.to_string(), value);
|
|
114
|
-
}
|
|
115
|
-
let mut state = serde_json::Map::new();
|
|
116
|
-
state.insert(
|
|
117
|
-
"spec_path".to_string(),
|
|
118
|
-
serde_json::json!(spec_path.to_string_lossy().to_string()),
|
|
119
|
-
);
|
|
120
|
-
state.insert(
|
|
121
|
-
"workspace".to_string(),
|
|
122
|
-
serde_json::json!(workspace.to_string_lossy().to_string()),
|
|
123
|
-
);
|
|
124
|
-
state.insert(
|
|
125
|
-
"team_dir".to_string(),
|
|
126
|
-
serde_json::json!(team_dir.to_string_lossy().to_string()),
|
|
127
|
-
);
|
|
128
|
-
state.insert("team_key".to_string(), serde_json::json!(team_key));
|
|
129
|
-
state.insert(
|
|
130
|
-
"session_name".to_string(),
|
|
131
|
-
serde_json::json!(spec_session_name(spec).as_str()),
|
|
132
|
-
);
|
|
133
|
-
state.insert(
|
|
134
|
-
"leader".to_string(),
|
|
135
|
-
spec.get("leader")
|
|
136
|
-
.map(yaml_value_to_json)
|
|
137
|
-
.unwrap_or(serde_json::Value::Null),
|
|
138
|
-
);
|
|
139
|
-
state.insert("agents".to_string(), serde_json::Value::Object(agents));
|
|
140
|
-
state.insert("tasks".to_string(), spec_tasks_json(spec));
|
|
141
|
-
state.insert("is_external_leader".to_string(), serde_json::json!(false));
|
|
142
|
-
let mut state = serde_json::Value::Object(state);
|
|
143
|
-
if !seed_launched_owner_from_env(&mut state, scoped_endpoint) {
|
|
144
|
-
let team_id = crate::state::projection::team_state_key(&state);
|
|
145
|
-
seed_unbound_launched_owner(&mut state, &team_id);
|
|
146
|
-
}
|
|
147
|
-
state
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/// ---
|
|
151
|
-
/// purpose: 从环境里的 caller 身份种入 launched owner
|
|
152
|
-
/// params:
|
|
153
|
-
/// state: 待改写的 state,成功时写入 owner 与 leader receiver
|
|
154
|
-
/// returns: true 表示已种入,取不到 caller 身份或无 pane 时为 false
|
|
155
|
-
/// ---
|
|
156
|
-
pub(super) fn seed_launched_owner_from_env(
|
|
157
|
-
state: &mut serde_json::Value,
|
|
158
|
-
scoped_endpoint: Option<&str>,
|
|
159
|
-
) -> bool {
|
|
160
|
-
let team_id = crate::state::projection::team_state_key(state);
|
|
161
|
-
let Ok(mut caller) = crate::state::identity::caller_identity_from_env(
|
|
162
|
-
Some(state),
|
|
163
|
-
&crate::state::identity::SystemEnv,
|
|
164
|
-
Some(&team_id),
|
|
165
|
-
None,
|
|
166
|
-
) else {
|
|
167
|
-
return false;
|
|
168
|
-
};
|
|
169
|
-
let current_pane = std::env::var("TMUX_PANE")
|
|
170
|
-
.ok()
|
|
171
|
-
.filter(|pane| !pane.is_empty());
|
|
172
|
-
let current_endpoint = crate::tmux_backend::socket_name_from_tmux_env();
|
|
173
|
-
match crate::layout::worker_env::caller_provider_resolution(
|
|
174
|
-
current_pane.as_deref(),
|
|
175
|
-
current_endpoint.as_deref(),
|
|
176
|
-
scoped_endpoint,
|
|
177
|
-
) {
|
|
178
|
-
crate::layout::worker_env::CallerProviderResolution::Invalid => return false,
|
|
179
|
-
crate::layout::worker_env::CallerProviderResolution::Valid(provider) => {
|
|
180
|
-
caller.provider = crate::provider::wire::provider_wire(provider).to_string();
|
|
181
|
-
}
|
|
182
|
-
crate::layout::worker_env::CallerProviderResolution::Absent => {}
|
|
183
|
-
}
|
|
184
|
-
// Absent keeps the existing explicit/direct pane path. Do not unbind a
|
|
185
|
-
// caller TMUX_PANE just because launcher context and LEADER_PROVIDER are
|
|
186
|
-
// both missing; that is the external-leader same-id-across-sockets case.
|
|
187
|
-
// Invalid already returned. Do not replace a missing provider with broad
|
|
188
|
-
// pane/process attribution.
|
|
189
|
-
seed_launched_owner_from_caller_with_provider_lookup(state, caller, |_| None)
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/// ---
|
|
193
|
-
/// purpose: 用给定的 caller 身份与 pane provider 查询函数种入 owner 与 leader receiver
|
|
194
|
-
/// params:
|
|
195
|
-
/// caller: 调用方身份,pane_id 为空则不种
|
|
196
|
-
/// lookup_pane_provider: 由 pane 反查 provider 的函数,便于测试替换
|
|
197
|
-
/// returns: true 表示已写入 owner 记录
|
|
198
|
-
/// ---
|
|
199
|
-
pub fn seed_launched_owner_from_caller_with_provider_lookup(
|
|
200
|
-
state: &mut serde_json::Value,
|
|
201
|
-
caller: crate::state::owner_gate::CallerIdentity,
|
|
202
|
-
lookup_pane_provider: impl Fn(&PaneId) -> Option<Provider>,
|
|
203
|
-
) -> bool {
|
|
204
|
-
if caller.pane_id.is_empty() {
|
|
205
|
-
return false;
|
|
206
|
-
}
|
|
207
|
-
let provider = caller_provider_for_seed_with_lookup(&caller, lookup_pane_provider);
|
|
208
|
-
let pane_id = caller.pane_id;
|
|
209
|
-
let owner_epoch = 1u64;
|
|
210
|
-
let mut owner = serde_json::json!({
|
|
211
|
-
"pane_id": pane_id,
|
|
212
|
-
"machine_fingerprint": caller.machine_fingerprint,
|
|
213
|
-
"leader_session_uuid": caller.leader_session_uuid,
|
|
214
|
-
"owner_epoch": owner_epoch,
|
|
215
|
-
"claimed_at": spawn_timestamp(),
|
|
216
|
-
"claimed_via": "quick-start",
|
|
217
|
-
"os_user": std::env::var("USER")
|
|
218
|
-
.or_else(|_| std::env::var("USERNAME"))
|
|
219
|
-
.unwrap_or_default(),
|
|
220
|
-
});
|
|
221
|
-
let mut receiver = serde_json::json!({
|
|
222
|
-
"mode": "direct_tmux",
|
|
223
|
-
"status": "pending",
|
|
224
|
-
"pane_id": owner.get("pane_id").cloned().unwrap_or(serde_json::Value::Null),
|
|
225
|
-
"pane": owner.get("pane_id").cloned().unwrap_or(serde_json::Value::Null),
|
|
226
|
-
"leader_session_uuid": owner.get("leader_session_uuid").cloned().unwrap_or(serde_json::Value::Null),
|
|
227
|
-
"owner_epoch": owner_epoch,
|
|
228
|
-
"discovery": "quick_start_seed",
|
|
229
|
-
});
|
|
230
|
-
if let Some(provider) = provider.as_ref() {
|
|
231
|
-
if let Some(owner) = owner.as_object_mut() {
|
|
232
|
-
owner.insert("provider".to_string(), serde_json::json!(provider));
|
|
233
|
-
}
|
|
234
|
-
if let Some(receiver) = receiver.as_object_mut() {
|
|
235
|
-
receiver.insert("provider".to_string(), serde_json::json!(provider));
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
if let (Some(receiver), Some(socket)) = (
|
|
239
|
-
receiver.as_object_mut(),
|
|
240
|
-
crate::tmux_backend::socket_name_from_tmux_env(),
|
|
241
|
-
) {
|
|
242
|
-
receiver.insert("tmux_socket".to_string(), serde_json::json!(socket));
|
|
243
|
-
}
|
|
244
|
-
// Stage 3a (identity-boundary unified plan, architect direction 2026-06-23):
|
|
245
|
-
// route quick-start attached-from-env seed through ownership repository.
|
|
246
|
-
let team_key = crate::state::projection::team_state_key(state);
|
|
247
|
-
let record = crate::state::ownership::OwnershipWrite::new()
|
|
248
|
-
.with_leader_receiver(receiver)
|
|
249
|
-
.with_team_owner(owner)
|
|
250
|
-
.with_owner_epoch(owner_epoch);
|
|
251
|
-
crate::state::ownership::write_owner(state, &team_key, record);
|
|
252
|
-
true
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
/// ---
|
|
256
|
-
/// purpose: 判断环境里是否带有任一 leader 身份变量
|
|
257
|
-
/// returns: pane id、session uuid、其 override 或 provider 任一非空即 true
|
|
258
|
-
/// ---
|
|
259
|
-
pub(super) fn has_positive_caller_leader_env() -> bool {
|
|
260
|
-
env_nonempty("TEAM_AGENT_LEADER_PANE_ID")
|
|
261
|
-
|| env_nonempty("TEAM_AGENT_LEADER_SESSION_UUID")
|
|
262
|
-
|| env_nonempty("TEAM_AGENT_LEADER_SESSION_UUID_OVERRIDE")
|
|
263
|
-
|| env_nonempty("TEAM_AGENT_LEADER_PROVIDER")
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/// ---
|
|
267
|
-
/// purpose: 判断某环境变量存在且非空
|
|
268
|
-
/// returns: 存在且非空为 true
|
|
269
|
-
/// ---
|
|
270
|
-
pub(super) fn env_nonempty(key: &str) -> bool {
|
|
271
|
-
std::env::var(key)
|
|
272
|
-
.ok()
|
|
273
|
-
.is_some_and(|value| !value.is_empty())
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/// ---
|
|
277
|
-
/// purpose: 把 spec 的 tasks 列表转成 JSON 数组
|
|
278
|
-
/// returns: 转换后的数组,没有 tasks 时为空数组
|
|
279
|
-
/// ---
|
|
280
|
-
pub(super) fn spec_tasks_json(spec: &Value) -> serde_json::Value {
|
|
281
|
-
spec.get("tasks")
|
|
282
|
-
.and_then(Value::as_list)
|
|
283
|
-
.map(|tasks| serde_json::Value::Array(tasks.iter().map(yaml_value_to_json).collect()))
|
|
284
|
-
.unwrap_or_else(|| serde_json::json!([]))
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/// ---
|
|
288
|
-
/// purpose: 把 YAML 值递归转成等价 JSON 值
|
|
289
|
-
/// returns: 结构与标量一一对应的 JSON
|
|
290
|
-
/// ---
|
|
291
|
-
pub(super) fn yaml_value_to_json(value: &Value) -> serde_json::Value {
|
|
292
|
-
match value {
|
|
293
|
-
Value::Null => serde_json::Value::Null,
|
|
294
|
-
Value::Bool(v) => serde_json::json!(v),
|
|
295
|
-
Value::Int(v) => serde_json::json!(v),
|
|
296
|
-
Value::Float(v) => serde_json::json!(v),
|
|
297
|
-
Value::Str(v) => serde_json::json!(v),
|
|
298
|
-
Value::List(values) => {
|
|
299
|
-
serde_json::Value::Array(values.iter().map(yaml_value_to_json).collect())
|
|
300
|
-
}
|
|
301
|
-
Value::Map(entries) => {
|
|
302
|
-
let mut out = serde_json::Map::new();
|
|
303
|
-
for (key, item) in entries {
|
|
304
|
-
out.insert(key.clone(), yaml_value_to_json(item));
|
|
305
|
-
}
|
|
306
|
-
serde_json::Value::Object(out)
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
/// ---
|
|
312
|
-
/// purpose: 原子写 spec,先写带进程号后缀的临时文件再 rename 覆盖
|
|
313
|
-
/// returns: 成功返回空值
|
|
314
|
-
/// errors: 建父目录、写临时文件或 rename 失败时返回 StatePersist;rename 失败会删掉临时文件且原 spec 不动
|
|
315
|
-
/// ---
|
|
316
|
-
///
|
|
317
|
-
/// Set `runtime.session_name` on the compiled spec to `session_name`, creating the
|
|
318
|
-
/// `runtime` map and/or the `session_name` entry if absent. Used by quick-start to
|
|
319
|
-
/// derive the tmux session from the REQUESTED team identity (CR-040/042) rather
|
|
320
|
-
/// than the template's compiled-in name.
|
|
321
|
-
/// E5 Bug2(atomic 真修):原子写 runtime spec —— 写 `<spec>.tmp-<pid>` 再 rename 覆盖,
|
|
322
|
-
/// 避免崩溃/并发留下半截 spec(plain fs::write 会 in-place truncate 后逐字节写)。
|
|
323
|
-
/// rename 失败时清理 tmp,原 spec(若有)不动。
|
|
324
|
-
pub(crate) fn write_spec_atomic(spec_path: &Path, spec: &Value) -> Result<(), LifecycleError> {
|
|
325
|
-
if let Some(parent) = spec_path.parent() {
|
|
326
|
-
std::fs::create_dir_all(parent)
|
|
327
|
-
.map_err(|e| LifecycleError::StatePersist(format!("{}: {e}", parent.display())))?;
|
|
328
|
-
}
|
|
329
|
-
let tmp = spec_path.with_extension(format!("tmp-{}", std::process::id()));
|
|
330
|
-
if let Err(e) = std::fs::write(&tmp, yaml::dumps(spec)) {
|
|
331
|
-
let _ = std::fs::remove_file(&tmp);
|
|
332
|
-
return Err(LifecycleError::StatePersist(format!(
|
|
333
|
-
"{}: {e}",
|
|
334
|
-
tmp.display()
|
|
335
|
-
)));
|
|
336
|
-
}
|
|
337
|
-
if let Err(e) = std::fs::rename(&tmp, spec_path) {
|
|
338
|
-
let _ = std::fs::remove_file(&tmp);
|
|
339
|
-
return Err(LifecycleError::StatePersist(format!(
|
|
340
|
-
"{}: {e}",
|
|
341
|
-
spec_path.display()
|
|
342
|
-
)));
|
|
343
|
-
}
|
|
344
|
-
Ok(())
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
/// ---
|
|
348
|
-
/// purpose: 就地把 spec 的 runtime.session_name 改成给定值
|
|
349
|
-
/// ---
|
|
350
|
-
pub(crate) fn override_spec_session_name(spec: &mut Value, session_name: &str) {
|
|
351
|
-
override_spec_runtime_str(spec, "session_name", session_name);
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/// ---
|
|
355
|
-
/// purpose: 就地把 spec 里 team.workspace 与各 agent 的 working_directory 改成给定路径
|
|
356
|
-
/// params:
|
|
357
|
-
/// spec: 非 Map 时不动;只改已存在的字段,不新建
|
|
358
|
-
/// ---
|
|
359
|
-
pub(crate) fn override_spec_workspace(spec: &mut Value, workspace: &Path) {
|
|
360
|
-
let workspace_s = workspace.to_string_lossy().to_string();
|
|
361
|
-
let Value::Map(root) = spec else { return };
|
|
362
|
-
if let Some((_, Value::Map(team))) = root.iter_mut().find(|(k, _)| k == "team") {
|
|
363
|
-
if let Some((_, value)) = team.iter_mut().find(|(k, _)| k == "workspace") {
|
|
364
|
-
*value = Value::Str(workspace_s.clone());
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
if let Some((_, Value::List(agents))) = root.iter_mut().find(|(k, _)| k == "agents") {
|
|
368
|
-
for agent in agents {
|
|
369
|
-
if let Value::Map(fields) = agent {
|
|
370
|
-
if let Some((_, value)) = fields.iter_mut().find(|(k, _)| k == "working_directory")
|
|
371
|
-
{
|
|
372
|
-
*value = Value::Str(workspace_s.clone());
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
/// ---
|
|
380
|
-
/// purpose: 就地写 spec 的 runtime 段下某个字符串字段
|
|
381
|
-
/// params:
|
|
382
|
-
/// spec: 非 Map 时不动
|
|
383
|
-
/// returns: runtime 段缺失则新建,已存在同名键则覆盖,runtime 是非 Map 值则整段替换
|
|
384
|
-
/// ---
|
|
385
|
-
pub(super) fn override_spec_runtime_str(spec: &mut Value, key: &str, value: &str) {
|
|
386
|
-
let Value::Map(root) = spec else { return };
|
|
387
|
-
let runtime_slot = root
|
|
388
|
-
.iter_mut()
|
|
389
|
-
.find(|(k, _)| k == "runtime")
|
|
390
|
-
.map(|(_, v)| v);
|
|
391
|
-
match runtime_slot {
|
|
392
|
-
Some(Value::Map(runtime)) => {
|
|
393
|
-
if let Some((_, existing)) = runtime.iter_mut().find(|(k, _)| k == key) {
|
|
394
|
-
*existing = Value::Str(value.to_string());
|
|
395
|
-
} else {
|
|
396
|
-
runtime.push((key.to_string(), Value::Str(value.to_string())));
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
Some(other) => {
|
|
400
|
-
*other = Value::Map(vec![(key.to_string(), Value::Str(value.to_string()))]);
|
|
401
|
-
}
|
|
402
|
-
None => {
|
|
403
|
-
root.push((
|
|
404
|
-
"runtime".to_string(),
|
|
405
|
-
Value::Map(vec![(key.to_string(), Value::Str(value.to_string()))]),
|
|
406
|
-
));
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
/// ---
|
|
412
|
-
/// purpose: 定出本 spec 的 tmux session 名
|
|
413
|
-
/// returns: runtime.session_name 的非空值;缺失时由 team.name 派生,team 名也缺失时用 agent 兜底
|
|
414
|
-
/// ---
|
|
415
|
-
pub(super) fn spec_session_name(spec: &Value) -> SessionName {
|
|
416
|
-
if let Some(name) = spec
|
|
417
|
-
.get("runtime")
|
|
418
|
-
.and_then(|v| v.get("session_name"))
|
|
419
|
-
.and_then(Value::as_str)
|
|
420
|
-
.filter(|name| !name.is_empty())
|
|
421
|
-
{
|
|
422
|
-
return SessionName::new(name);
|
|
423
|
-
}
|
|
424
|
-
// Python launch/core.py:56 — fallback derives from the team name, not a constant.
|
|
425
|
-
let team_name = spec
|
|
426
|
-
.get("team")
|
|
427
|
-
.and_then(|team| team.get("name"))
|
|
428
|
-
.and_then(Value::as_str)
|
|
429
|
-
.filter(|name| !name.is_empty())
|
|
430
|
-
.unwrap_or("agent");
|
|
431
|
-
SessionName::new(format!("team-{team_name}"))
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/// ---
|
|
435
|
-
/// purpose: 把 spec_session_name 以更宽可见性转出,供 layout 复用同一份实现
|
|
436
|
-
/// returns: 同 spec_session_name
|
|
437
|
-
/// ---
|
|
438
|
-
///
|
|
439
|
-
/// 0.3.28 layout step 1: pub re-export of `spec_session_name` for the new
|
|
440
|
-
/// `layout::sessions::worker_session_name` to delegate to. Single underlying
|
|
441
|
-
/// impl; this just widens visibility without duplicating logic.
|
|
442
|
-
pub fn worker_session_name_pub(spec: &Value) -> SessionName {
|
|
443
|
-
spec_session_name(spec)
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
#[cfg(test)]
|
|
447
|
-
mod claim_rework_seed_tests {
|
|
448
|
-
use super::*;
|
|
449
|
-
use crate::state::owner_gate::CallerIdentity;
|
|
450
|
-
|
|
451
|
-
#[test]
|
|
452
|
-
fn seed_writes_pending_receiver_not_attached() {
|
|
453
|
-
let mut state = serde_json::json!({
|
|
454
|
-
"session_name": "team-seed",
|
|
455
|
-
"workspace": "/tmp/claim-rework-seed"
|
|
456
|
-
});
|
|
457
|
-
let caller = CallerIdentity {
|
|
458
|
-
pane_id: "%1".to_string(),
|
|
459
|
-
provider: "codex".to_string(),
|
|
460
|
-
machine_fingerprint: "fp".to_string(),
|
|
461
|
-
leader_session_uuid: "uuid".to_string(),
|
|
462
|
-
leader_session_uuid_source: "env".to_string(),
|
|
463
|
-
};
|
|
464
|
-
assert!(seed_launched_owner_from_caller_with_provider_lookup(
|
|
465
|
-
&mut state,
|
|
466
|
-
caller,
|
|
467
|
-
|_| None
|
|
468
|
-
));
|
|
469
|
-
let status = state
|
|
470
|
-
.pointer("/teams/team-seed/leader_receiver/status")
|
|
471
|
-
.or_else(|| state.pointer("/leader_receiver/status"))
|
|
472
|
-
.and_then(serde_json::Value::as_str);
|
|
473
|
-
assert_eq!(status, Some("pending"));
|
|
474
|
-
assert_ne!(status, Some("attached"));
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
/// ---
|
|
479
|
-
/// purpose: 取出 spec 里全部 agent id
|
|
480
|
-
/// returns: 按 spec 顺序的 agent id,无 id 字段的条目被跳过
|
|
481
|
-
/// ---
|
|
482
|
-
pub(super) fn spec_agents(spec: &Value) -> Vec<AgentId> {
|
|
483
|
-
spec_agent_values(spec)
|
|
484
|
-
.into_iter()
|
|
485
|
-
.filter_map(|agent| agent.get("id").and_then(Value::as_str).map(AgentId::new))
|
|
486
|
-
.collect()
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
/// ---
|
|
490
|
-
/// purpose: 取出 spec 里全部 agent id 的集合,便于成员判定
|
|
491
|
-
/// returns: 有序集合
|
|
492
|
-
/// ---
|
|
493
|
-
///
|
|
494
|
-
/// Bug 1 (0.4.2): expose spec agent id set so the restart path can filter
|
|
495
|
-
/// state.agents to only the agents currently defined in the rebuilt spec.
|
|
496
|
-
/// Returns a `BTreeSet<String>` for O(log n) membership checks.
|
|
497
|
-
pub(crate) fn spec_agent_id_set(spec: &Value) -> std::collections::BTreeSet<String> {
|
|
498
|
-
spec_agent_values(spec)
|
|
499
|
-
.into_iter()
|
|
500
|
-
.filter_map(|agent| agent.get("id").and_then(Value::as_str).map(str::to_string))
|
|
501
|
-
.collect()
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
/// ---
|
|
505
|
-
/// purpose: 取出 spec 的 agents 列表原始节点
|
|
506
|
-
/// returns: 节点引用列表,字段缺失或类型不对时为空
|
|
507
|
-
/// ---
|
|
508
|
-
pub(super) fn spec_agent_values(spec: &Value) -> Vec<&Value> {
|
|
509
|
-
spec.get("agents")
|
|
510
|
-
.and_then(Value::as_list)
|
|
511
|
-
.map(|agents| agents.iter().collect())
|
|
512
|
-
.unwrap_or_default()
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/// ---
|
|
516
|
-
/// purpose: 对 spec 里每个 task 算出路由决策
|
|
517
|
-
/// returns: 每个 task 的选中 agent 与理由,manual_override 恒为 false
|
|
518
|
-
/// ---
|
|
519
|
-
pub(super) fn spec_routes(spec: &Value) -> Vec<RoutingDecision> {
|
|
520
|
-
spec.get("tasks")
|
|
521
|
-
.and_then(Value::as_list)
|
|
522
|
-
.map(|tasks| {
|
|
523
|
-
tasks
|
|
524
|
-
.iter()
|
|
525
|
-
.map(|task| {
|
|
526
|
-
let routed = crate::model::routing::route_task(spec, task);
|
|
527
|
-
RoutingDecision {
|
|
528
|
-
task_id: task.get("id").and_then(Value::as_str).map(str::to_string),
|
|
529
|
-
selected_agent: routed.agent_id,
|
|
530
|
-
reason: routed.reason,
|
|
531
|
-
manual_override: false,
|
|
532
|
-
}
|
|
533
|
-
})
|
|
534
|
-
.collect()
|
|
535
|
-
})
|
|
536
|
-
.unwrap_or_default()
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
/// ---
|
|
540
|
-
/// purpose: 定出默认承接人
|
|
541
|
-
/// returns: routing.default_assignee,缺失时取第一个 agent
|
|
542
|
-
/// ---
|
|
543
|
-
pub(super) fn spec_default_assignee(spec: &Value) -> Option<AgentId> {
|
|
544
|
-
spec.get("routing")
|
|
545
|
-
.and_then(|v| v.get("default_assignee"))
|
|
546
|
-
.and_then(Value::as_str)
|
|
547
|
-
.map(AgentId::new)
|
|
548
|
-
.or_else(|| spec_agents(spec).into_iter().next())
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
/// ---
|
|
552
|
-
/// purpose: 由单个 YAML agent 的 dangerously_skip_permissions 定出 bypass 审批结论
|
|
553
|
-
/// returns: 字段为 true 时 enabled 且来源记 RuntimeConfig,并带上该 provider 的 bypass argv;否则 Disabled
|
|
554
|
-
/// errors: 当前实现不产生 Err
|
|
555
|
-
/// contract_id: lifecycle.spec_state.effective_runtime_config
|
|
556
|
-
/// ---
|
|
557
|
-
/// 0.5.66 bypass 单源:从**单个 agent**(yaml spec)的 `dangerously_skip_permissions` 构造
|
|
558
|
-
/// `DangerousApproval`(取代旧"runtime config + leader argv"全队一份)。
|
|
559
|
-
/// true → source=RuntimeConfig(角色声明即用户明确同意,coordinator 的
|
|
560
|
-
/// `explicit_yes_confirmed` 自动放行);false → Disabled。
|
|
561
|
-
pub(crate) fn effective_runtime_config_for_worker_spawn(
|
|
562
|
-
agent: &Value,
|
|
563
|
-
provider: Provider,
|
|
564
|
-
) -> Result<DangerousApproval, LifecycleError> {
|
|
565
|
-
let enabled = matches!(
|
|
566
|
-
agent.get("dangerously_skip_permissions"),
|
|
567
|
-
Some(Value::Bool(true))
|
|
568
|
-
);
|
|
569
|
-
if !enabled {
|
|
570
|
-
return Ok(DangerousApproval {
|
|
571
|
-
enabled: false,
|
|
572
|
-
source: DangerousApprovalSource::Disabled,
|
|
573
|
-
inherited: false,
|
|
574
|
-
provider: None,
|
|
575
|
-
flag: None,
|
|
576
|
-
worker_capability_above_leader: false,
|
|
577
|
-
ancestry_binary_name: None,
|
|
578
|
-
unexpected_binary: false,
|
|
579
|
-
});
|
|
580
|
-
}
|
|
581
|
-
let flag = crate::provider::bypass_flags::provider_bypass_flag(provider);
|
|
582
|
-
Ok(DangerousApproval {
|
|
583
|
-
enabled: true,
|
|
584
|
-
source: DangerousApprovalSource::RuntimeConfig,
|
|
585
|
-
inherited: false,
|
|
586
|
-
provider: Some(provider_display_str(provider).to_string()),
|
|
587
|
-
flag: flag.map(str::to_string),
|
|
588
|
-
worker_capability_above_leader: false,
|
|
589
|
-
ancestry_binary_name: None,
|
|
590
|
-
unexpected_binary: false,
|
|
591
|
-
})
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
/// ---
|
|
595
|
-
/// purpose: 同上,但读的是 runtime state 里的 JSON agent 节点
|
|
596
|
-
/// returns: 同 YAML 版
|
|
597
|
-
/// errors: 当前实现不产生 Err
|
|
598
|
-
/// contract_id: lifecycle.spec_state.effective_runtime_config
|
|
599
|
-
/// ---
|
|
600
|
-
/// 0.5.66 bypass 单源:restart/state 路径的 serde_json 版(agent 来自 state JSON)。
|
|
601
|
-
pub(crate) fn effective_runtime_config_for_worker_spawn_json(
|
|
602
|
-
agent: &serde_json::Value,
|
|
603
|
-
provider: Provider,
|
|
604
|
-
) -> Result<DangerousApproval, LifecycleError> {
|
|
605
|
-
let enabled = agent
|
|
606
|
-
.get("dangerously_skip_permissions")
|
|
607
|
-
.and_then(serde_json::Value::as_bool)
|
|
608
|
-
.unwrap_or(false);
|
|
609
|
-
if !enabled {
|
|
610
|
-
return Ok(DangerousApproval {
|
|
611
|
-
enabled: false,
|
|
612
|
-
source: DangerousApprovalSource::Disabled,
|
|
613
|
-
inherited: false,
|
|
614
|
-
provider: None,
|
|
615
|
-
flag: None,
|
|
616
|
-
worker_capability_above_leader: false,
|
|
617
|
-
ancestry_binary_name: None,
|
|
618
|
-
unexpected_binary: false,
|
|
619
|
-
});
|
|
620
|
-
}
|
|
621
|
-
let flag = crate::provider::bypass_flags::provider_bypass_flag(provider);
|
|
622
|
-
Ok(DangerousApproval {
|
|
623
|
-
enabled: true,
|
|
624
|
-
source: DangerousApprovalSource::RuntimeConfig,
|
|
625
|
-
inherited: false,
|
|
626
|
-
provider: Some(provider_display_str(provider).to_string()),
|
|
627
|
-
flag: flag.map(str::to_string),
|
|
628
|
-
worker_capability_above_leader: false,
|
|
629
|
-
ancestry_binary_name: None,
|
|
630
|
-
unexpected_binary: false,
|
|
631
|
-
})
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
/// ---
|
|
635
|
-
/// purpose: 给出 provider 的稳定 wire 名
|
|
636
|
-
/// returns: 与 spec 写法一致的小写下划线名
|
|
637
|
-
/// ---
|
|
638
|
-
pub(crate) fn provider_display_str(provider: Provider) -> &'static str {
|
|
639
|
-
match provider {
|
|
640
|
-
Provider::Claude => "claude",
|
|
641
|
-
Provider::ClaudeCode => "claude_code",
|
|
642
|
-
Provider::Codex => "codex",
|
|
643
|
-
Provider::Copilot => "copilot",
|
|
644
|
-
Provider::GeminiCli => "gemini_cli",
|
|
645
|
-
Provider::Grok => "grok",
|
|
646
|
-
Provider::Pi => "pi",
|
|
647
|
-
Provider::Fake => "fake",
|
|
648
|
-
}
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
/// ---
|
|
652
|
-
/// purpose: 由 team 目录推出 workspace 根
|
|
653
|
-
/// returns: 解析成功用解析值,失败时退到 team 目录的父目录,没有父目录则用 team 目录本身
|
|
654
|
-
/// ---
|
|
655
|
-
pub(super) fn team_workspace(team_dir: &Path) -> PathBuf {
|
|
656
|
-
crate::model::paths::team_workspace(team_dir).unwrap_or_else(|_| {
|
|
657
|
-
team_dir
|
|
658
|
-
.parent()
|
|
659
|
-
.map(Path::to_path_buf)
|
|
660
|
-
.unwrap_or_else(|| team_dir.to_path_buf())
|
|
661
|
-
})
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
#[cfg(test)]
|
|
665
|
-
mod tests {
|
|
666
|
-
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
667
|
-
use super::*;
|
|
668
|
-
use crate::layout::worker_env::{CALLER_ENDPOINT_ENV, CALLER_PANE_ENV, CALLER_PROVIDER_ENV};
|
|
669
|
-
use crate::model::enums::Provider;
|
|
670
|
-
use serde_json::json;
|
|
671
|
-
|
|
672
|
-
use super::hermetic::HermeticTestEnv;
|
|
673
|
-
|
|
674
|
-
fn yaml_agent(bypass: bool) -> Value {
|
|
675
|
-
crate::model::yaml::loads(&format!(
|
|
676
|
-
"id: a\nrole: r\nprovider: codex\ndangerously_skip_permissions: {bypass}\n"
|
|
677
|
-
))
|
|
678
|
-
.unwrap()
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
// 0.5.66 bypass 单源 §4.1:true → enabled + source=runtime_config(角色声明即明确同意)。
|
|
682
|
-
#[test]
|
|
683
|
-
fn test_effective_safety_from_true_field() {
|
|
684
|
-
let safety =
|
|
685
|
-
effective_runtime_config_for_worker_spawn(&yaml_agent(true), Provider::Codex).unwrap();
|
|
686
|
-
assert!(safety.enabled);
|
|
687
|
-
assert_eq!(safety.source, DangerousApprovalSource::RuntimeConfig);
|
|
688
|
-
assert_eq!(
|
|
689
|
-
safety.flag.as_deref(),
|
|
690
|
-
Some("--dangerously-bypass-approvals-and-sandbox")
|
|
691
|
-
);
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
// 0.5.66 bypass 单源 §4.1:false → Disabled。
|
|
695
|
-
#[test]
|
|
696
|
-
fn test_effective_safety_from_false_field() {
|
|
697
|
-
let safety =
|
|
698
|
-
effective_runtime_config_for_worker_spawn(&yaml_agent(false), Provider::Codex).unwrap();
|
|
699
|
-
assert!(!safety.enabled);
|
|
700
|
-
assert_eq!(safety.source, DangerousApprovalSource::Disabled);
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
fn seed_state() -> serde_json::Value {
|
|
704
|
-
json!({
|
|
705
|
-
"team_key": "verify031",
|
|
706
|
-
"workspace": "/tmp/ws",
|
|
707
|
-
"session_name": "team-verify031",
|
|
708
|
-
"agents": {}
|
|
709
|
-
})
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
fn owner_pane(state: &serde_json::Value) -> Option<&str> {
|
|
713
|
-
state
|
|
714
|
-
.pointer("/teams/verify031/team_owner/pane_id")
|
|
715
|
-
.and_then(serde_json::Value::as_str)
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
fn owner_provider(state: &serde_json::Value) -> Option<&str> {
|
|
719
|
-
state
|
|
720
|
-
.pointer("/teams/verify031/team_owner/provider")
|
|
721
|
-
.and_then(serde_json::Value::as_str)
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
fn receiver_pane(state: &serde_json::Value) -> Option<&str> {
|
|
725
|
-
state
|
|
726
|
-
.pointer("/teams/verify031/leader_receiver/pane_id")
|
|
727
|
-
.and_then(serde_json::Value::as_str)
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
#[test]
|
|
731
|
-
#[serial_test::serial(env)]
|
|
732
|
-
fn seed_absent_caller_keeps_direct_tmux_pane_without_unbinding() {
|
|
733
|
-
let hermetic = HermeticTestEnv::enter("seed-absent-direct-pane");
|
|
734
|
-
let _tmux = hermetic.with_env("TMUX", "/tmp/default-tmux-socket,123,0");
|
|
735
|
-
let _pane = hermetic.with_env("TMUX_PANE", "%0");
|
|
736
|
-
let mut state = seed_state();
|
|
737
|
-
assert!(
|
|
738
|
-
seed_launched_owner_from_env(&mut state, Some("/tmp/product-team.sock")),
|
|
739
|
-
"Absent caller context must still seed the caller's TMUX_PANE; state={state}"
|
|
740
|
-
);
|
|
741
|
-
assert_eq!(owner_pane(&state), Some("%0"));
|
|
742
|
-
assert_eq!(receiver_pane(&state), Some("%0"));
|
|
743
|
-
assert!(
|
|
744
|
-
owner_provider(&state).is_none(),
|
|
745
|
-
"direct pane seed must not invent a provider; state={state}"
|
|
746
|
-
);
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
#[test]
|
|
750
|
-
#[serial_test::serial(env)]
|
|
751
|
-
fn seed_valid_caller_uses_typed_provider_and_same_scoped_endpoint() {
|
|
752
|
-
let hermetic = HermeticTestEnv::enter("seed-valid-scoped");
|
|
753
|
-
let _tmux = hermetic.with_env("TMUX", "/tmp/tmux.sock,1,0");
|
|
754
|
-
let _pane = hermetic.with_env("TMUX_PANE", "%1");
|
|
755
|
-
let _provider = hermetic.with_env(CALLER_PROVIDER_ENV, "pi");
|
|
756
|
-
let _caller_pane = hermetic.with_env(CALLER_PANE_ENV, "%1");
|
|
757
|
-
let _caller_endpoint = hermetic.with_env(CALLER_ENDPOINT_ENV, "/tmp/tmux.sock");
|
|
758
|
-
let mut state = seed_state();
|
|
759
|
-
assert!(seed_launched_owner_from_env(
|
|
760
|
-
&mut state,
|
|
761
|
-
Some("/tmp/tmux.sock")
|
|
762
|
-
));
|
|
763
|
-
assert_eq!(owner_pane(&state), Some("%1"));
|
|
764
|
-
assert_eq!(owner_provider(&state), Some("pi"));
|
|
765
|
-
assert_eq!(receiver_pane(&state), Some("%1"));
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
#[test]
|
|
769
|
-
#[serial_test::serial(env)]
|
|
770
|
-
fn seed_invalid_caller_does_not_fall_back_to_direct_pane() {
|
|
771
|
-
let hermetic = HermeticTestEnv::enter("seed-invalid-scoped");
|
|
772
|
-
let _tmux = hermetic.with_env("TMUX", "/tmp/tmux.sock,1,0");
|
|
773
|
-
let _pane = hermetic.with_env("TMUX_PANE", "%1");
|
|
774
|
-
let _provider = hermetic.with_env(CALLER_PROVIDER_ENV, "pi");
|
|
775
|
-
let _caller_pane = hermetic.with_env(CALLER_PANE_ENV, "%1");
|
|
776
|
-
let _caller_endpoint = hermetic.with_env(CALLER_ENDPOINT_ENV, "/tmp/tmux.sock");
|
|
777
|
-
let mut state = seed_state();
|
|
778
|
-
assert!(
|
|
779
|
-
!seed_launched_owner_from_env(&mut state, Some("/tmp/product.sock")),
|
|
780
|
-
"scoped endpoint mismatch must fail closed; state={state}"
|
|
781
|
-
);
|
|
782
|
-
assert!(owner_pane(&state).is_none(), "state={state}");
|
|
783
|
-
assert!(receiver_pane(&state).is_none(), "state={state}");
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
#[test]
|
|
787
|
-
#[serial_test::serial(env)]
|
|
788
|
-
fn seed_absent_keeps_explicit_leader_provider() {
|
|
789
|
-
let hermetic = HermeticTestEnv::enter("seed-absent-explicit");
|
|
790
|
-
let _tmux = hermetic.with_env("TMUX", "/tmp/tmux.sock,1,0");
|
|
791
|
-
let _pane = hermetic.with_env("TMUX_PANE", "%3");
|
|
792
|
-
let _leader = hermetic.with_env("TEAM_AGENT_LEADER_PROVIDER", "pi");
|
|
793
|
-
let mut state = seed_state();
|
|
794
|
-
assert!(seed_launched_owner_from_env(
|
|
795
|
-
&mut state,
|
|
796
|
-
Some("/tmp/tmux.sock")
|
|
797
|
-
));
|
|
798
|
-
assert_eq!(owner_pane(&state), Some("%3"));
|
|
799
|
-
assert_eq!(owner_provider(&state), Some("pi"));
|
|
800
|
-
}
|
|
801
|
-
}
|