@team-agent/installer 0.5.128 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/README.zh.md +1 -1
- package/package.json +4 -8
- package/skills/team-agent/SKILL.md +37 -20
- package/skills/team-agent/command-coverage.json +169 -183
- package/skills/team-agent/docs/reference/team-agent-operator.md +64 -30
- package/skills/team-agent/references/recovery-runbook.md +1 -1
- package/skills/team-agent/references/team-agent-operator.md +64 -30
- package/templates/team_state.md +1 -1
- package/Cargo.lock +0 -1063
- package/Cargo.toml +0 -36
- package/crates/team-agent/Cargo.toml +0 -69
- package/crates/team-agent/src/app_server_test_support.rs +0 -258
- package/crates/team-agent/src/cli/adapters.rs +0 -1288
- package/crates/team-agent/src/cli/arguments.rs +0 -405
- package/crates/team-agent/src/cli/attach_app_server_leader.rs +0 -98
- package/crates/team-agent/src/cli/diagnose.rs +0 -1721
- package/crates/team-agent/src/cli/emit.rs +0 -2930
- package/crates/team-agent/src/cli/grok_slot.rs +0 -384
- package/crates/team-agent/src/cli/helpers.rs +0 -91
- package/crates/team-agent/src/cli/intent/runtime.rs +0 -1216
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -912
- package/crates/team-agent/src/cli/intent/tests.rs +0 -689
- package/crates/team-agent/src/cli/intent.rs +0 -664
- package/crates/team-agent/src/cli/leader.rs +0 -300
- package/crates/team-agent/src/cli/leader_prompt.rs +0 -261
- package/crates/team-agent/src/cli/leaders.rs +0 -418
- package/crates/team-agent/src/cli/mod.rs +0 -6545
- package/crates/team-agent/src/cli/models.rs +0 -1206
- package/crates/team-agent/src/cli/named_address.rs +0 -1651
- package/crates/team-agent/src/cli/profile.rs +0 -342
- package/crates/team-agent/src/cli/route.rs +0 -212
- package/crates/team-agent/src/cli/schedule.rs +0 -175
- package/crates/team-agent/src/cli/send/coordinator.rs +0 -164
- package/crates/team-agent/src/cli/send/mailbox.rs +0 -145
- package/crates/team-agent/src/cli/send/persist.rs +0 -156
- package/crates/team-agent/src/cli/send/presentation.rs +0 -370
- package/crates/team-agent/src/cli/send/resolve.rs +0 -573
- package/crates/team-agent/src/cli/send.rs +0 -199
- package/crates/team-agent/src/cli/shutdown_socket.rs +0 -288
- package/crates/team-agent/src/cli/spec.rs +0 -165
- package/crates/team-agent/src/cli/status.rs +0 -280
- package/crates/team-agent/src/cli/status_port/agents.rs +0 -358
- package/crates/team-agent/src/cli/status_port/approvals.rs +0 -79
- package/crates/team-agent/src/cli/status_port/brief.rs +0 -1981
- package/crates/team-agent/src/cli/status_port/compact.rs +0 -240
- package/crates/team-agent/src/cli/status_port/format.rs +0 -146
- package/crates/team-agent/src/cli/status_port/inbox.rs +0 -62
- package/crates/team-agent/src/cli/status_port/runtime.rs +0 -197
- package/crates/team-agent/src/cli/status_port/snapshot.rs +0 -208
- package/crates/team-agent/src/cli/status_port/store.rs +0 -416
- package/crates/team-agent/src/cli/status_port/tests.rs +0 -90
- package/crates/team-agent/src/cli/status_port.rs +0 -92
- package/crates/team-agent/src/cli/tests/base.rs +0 -885
- package/crates/team-agent/src/cli/tests/divergence.rs +0 -518
- package/crates/team-agent/src/cli/tests/lane_c.rs +0 -453
- package/crates/team-agent/src/cli/tests/leader_watch.rs +0 -322
- package/crates/team-agent/src/cli/tests/main_preserved.rs +0 -430
- package/crates/team-agent/src/cli/tests/missing_subcommands.rs +0 -336
- package/crates/team-agent/src/cli/tests/mod.rs +0 -137
- package/crates/team-agent/src/cli/tests/named_address.rs +0 -761
- package/crates/team-agent/src/cli/tests/parser_safety.rs +0 -383
- package/crates/team-agent/src/cli/tests/run_delegation.rs +0 -484
- package/crates/team-agent/src/cli/tests/shutdown_kill_plan.rs +0 -2179
- package/crates/team-agent/src/cli/tests/status_brief.rs +0 -1514
- package/crates/team-agent/src/cli/tests/status_send.rs +0 -888
- package/crates/team-agent/src/cli/tests/verb_install_skill.rs +0 -93
- package/crates/team-agent/src/cli/tests/verb_profile.rs +0 -392
- package/crates/team-agent/src/cli/triage.rs +0 -234
- package/crates/team-agent/src/cli/types.rs +0 -591
- package/crates/team-agent/src/codex_app_server.rs +0 -546
- package/crates/team-agent/src/communication_mode/mod.rs +0 -56
- package/crates/team-agent/src/compiler/tests.rs +0 -827
- package/crates/team-agent/src/compiler.rs +0 -890
- package/crates/team-agent/src/conpty/backend.rs +0 -829
- package/crates/team-agent/src/conpty/mod.rs +0 -33
- package/crates/team-agent/src/contract_runtime/backend.rs +0 -1744
- package/crates/team-agent/src/contract_runtime/commands.rs +0 -671
- package/crates/team-agent/src/contract_runtime/config.rs +0 -364
- package/crates/team-agent/src/contract_runtime/config_tests.rs +0 -76
- package/crates/team-agent/src/contract_runtime/discovery.rs +0 -449
- package/crates/team-agent/src/contract_runtime/fork.rs +0 -361
- package/crates/team-agent/src/contract_runtime/forward.rs +0 -288
- package/crates/team-agent/src/contract_runtime/framework.rs +0 -367
- package/crates/team-agent/src/contract_runtime/mcp.rs +0 -394
- package/crates/team-agent/src/contract_runtime/mod.rs +0 -17
- package/crates/team-agent/src/contract_runtime/prompt.rs +0 -216
- package/crates/team-agent/src/contract_runtime/pump.rs +0 -271
- package/crates/team-agent/src/contract_runtime/registry.rs +0 -553
- package/crates/team-agent/src/contract_runtime/workspace.rs +0 -228
- package/crates/team-agent/src/coordinator/backoff.rs +0 -741
- package/crates/team-agent/src/coordinator/conpty_shim.rs +0 -805
- package/crates/team-agent/src/coordinator/health.rs +0 -1185
- package/crates/team-agent/src/coordinator/mod.rs +0 -119
- package/crates/team-agent/src/coordinator/orphan.rs +0 -110
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -798
- package/crates/team-agent/src/coordinator/runtime_observation.rs +0 -84
- package/crates/team-agent/src/coordinator/steps/abnormal.rs +0 -2309
- package/crates/team-agent/src/coordinator/steps/delivery.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/health_sync.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/mod.rs +0 -126
- package/crates/team-agent/src/coordinator/steps/persist.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/runtime_prompts.rs +0 -15
- package/crates/team-agent/src/coordinator/steps/session_gate.rs +0 -16
- package/crates/team-agent/src/coordinator/tests/a0_lostupdate.rs +0 -158
- package/crates/team-agent/src/coordinator/tests/abnormal.rs +0 -312
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +0 -300
- package/crates/team-agent/src/coordinator/tests/basics.rs +0 -211
- package/crates/team-agent/src/coordinator/tests/daemon.rs +0 -514
- package/crates/team-agent/src/coordinator/tests/energy.rs +0 -549
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -503
- package/crates/team-agent/src/coordinator/tests/main_preserved.rs +0 -186
- package/crates/team-agent/src/coordinator/tests/mod.rs +0 -295
- package/crates/team-agent/src/coordinator/tests/s3_bounded.rs +0 -207
- package/crates/team-agent/src/coordinator/tests/spine.rs +0 -308
- package/crates/team-agent/src/coordinator/tests/takeover.rs +0 -286
- package/crates/team-agent/src/coordinator/tests/tick_core.rs +0 -237
- package/crates/team-agent/src/coordinator/tick.rs +0 -3024
- package/crates/team-agent/src/coordinator/types.rs +0 -540
- package/crates/team-agent/src/db/agent_health_capture.rs +0 -126
- package/crates/team-agent/src/db/message_store.rs +0 -1527
- package/crates/team-agent/src/db/migration.rs +0 -984
- package/crates/team-agent/src/db/mod.rs +0 -26
- package/crates/team-agent/src/db/schema.rs +0 -663
- package/crates/team-agent/src/diagnose/comms.rs +0 -242
- package/crates/team-agent/src/diagnose/mod.rs +0 -44
- package/crates/team-agent/src/diagnose/orphans.rs +0 -889
- package/crates/team-agent/src/direct_delivery.rs +0 -368
- package/crates/team-agent/src/event_log.rs +0 -502
- package/crates/team-agent/src/fake_worker.rs +0 -303
- package/crates/team-agent/src/inbox_store.rs +0 -169
- package/crates/team-agent/src/kill_audit.rs +0 -106
- package/crates/team-agent/src/layout/manager.rs +0 -248
- package/crates/team-agent/src/layout/mod.rs +0 -36
- package/crates/team-agent/src/layout/overlay.rs +0 -134
- package/crates/team-agent/src/layout/placement.rs +0 -52
- package/crates/team-agent/src/layout/recovery.rs +0 -106
- package/crates/team-agent/src/layout/runtime_sessions.rs +0 -317
- package/crates/team-agent/src/layout/sessions.rs +0 -294
- package/crates/team-agent/src/layout/tmux_endpoint.rs +0 -165
- package/crates/team-agent/src/layout/worker_env.rs +0 -721
- package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -37
- package/crates/team-agent/src/leader/helpers.rs +0 -178
- package/crates/team-agent/src/leader/incident.rs +0 -6
- package/crates/team-agent/src/leader/lease.rs +0 -3356
- package/crates/team-agent/src/leader/mod.rs +0 -104
- package/crates/team-agent/src/leader/owner_bind.rs +0 -400
- package/crates/team-agent/src/leader/prompt.rs +0 -905
- package/crates/team-agent/src/leader/provider_attribution.rs +0 -247
- package/crates/team-agent/src/leader/rediscover/tests.rs +0 -689
- package/crates/team-agent/src/leader/rediscover.rs +0 -1192
- package/crates/team-agent/src/leader/registry.rs +0 -888
- package/crates/team-agent/src/leader/start.rs +0 -4501
- package/crates/team-agent/src/leader/takeover.rs +0 -65
- package/crates/team-agent/src/leader/tests/basics.rs +0 -337
- package/crates/team-agent/src/leader/tests/byte_findings.rs +0 -355
- package/crates/team-agent/src/leader/tests/claim_leader_mailbox_flush_contract.rs +0 -544
- package/crates/team-agent/src/leader/tests/historical_inventory_upgrade_gate_red.rs +0 -624
- package/crates/team-agent/src/leader/tests/identity.rs +0 -465
- package/crates/team-agent/src/leader/tests/identity_session_names.rs +0 -42
- package/crates/team-agent/src/leader/tests/idle.rs +0 -113
- package/crates/team-agent/src/leader/tests/lease_api.rs +0 -520
- package/crates/team-agent/src/leader/tests/lease_claim.rs +0 -629
- package/crates/team-agent/src/leader/tests/mod.rs +0 -106
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +0 -268
- package/crates/team-agent/src/leader/tests/rediscover.rs +0 -403
- package/crates/team-agent/src/leader/tests/rehomed_env.rs +0 -83
- package/crates/team-agent/src/leader/tests/team_in_team_state_scope_red.rs +0 -1273
- package/crates/team-agent/src/leader/tests/terminal_and_replay_vs_rerender_invariants_red.rs +0 -417
- package/crates/team-agent/src/leader/tests/wake_start_owner.rs +0 -168
- package/crates/team-agent/src/leader/types.rs +0 -534
- package/crates/team-agent/src/lib.rs +0 -147
- package/crates/team-agent/src/lifecycle/helpers.rs +0 -212
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +0 -881
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +0 -598
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -332
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +0 -204
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -107
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +0 -144
- package/crates/team-agent/src/lifecycle/launch/identity.rs +0 -674
- package/crates/team-agent/src/lifecycle/launch/layout.rs +0 -350
- package/crates/team-agent/src/lifecycle/launch/leader_context.rs +0 -589
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +0 -160
- package/crates/team-agent/src/lifecycle/launch/ownership.rs +0 -105
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +0 -899
- package/crates/team-agent/src/lifecycle/launch/pi_mcp_extension.js +0 -225
- package/crates/team-agent/src/lifecycle/launch/plan.rs +0 -269
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -5200
- package/crates/team-agent/src/lifecycle/launch/quick_start_transport.rs +0 -368
- package/crates/team-agent/src/lifecycle/launch/readiness.rs +0 -519
- package/crates/team-agent/src/lifecycle/launch/role_source.rs +0 -287
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -473
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -801
- package/crates/team-agent/src/lifecycle/launch/state_projection.rs +0 -624
- package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -558
- package/crates/team-agent/src/lifecycle/launch.rs +0 -557
- package/crates/team-agent/src/lifecycle/lock.rs +0 -350
- package/crates/team-agent/src/lifecycle/mod.rs +0 -79
- package/crates/team-agent/src/lifecycle/pane_input_lock.rs +0 -239
- package/crates/team-agent/src/lifecycle/profile_launch.rs +0 -1067
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +0 -557
- package/crates/team-agent/src/lifecycle/restart/agent.rs +0 -2199
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1798
- package/crates/team-agent/src/lifecycle/restart/claude_fork.rs +0 -163
- package/crates/team-agent/src/lifecycle/restart/common.rs +0 -2362
- package/crates/team-agent/src/lifecycle/restart/orchestrator.rs +0 -65
- package/crates/team-agent/src/lifecycle/restart/preflight.rs +0 -113
- package/crates/team-agent/src/lifecycle/restart/rebuild.rs +0 -5135
- package/crates/team-agent/src/lifecycle/restart/remove.rs +0 -1504
- package/crates/team-agent/src/lifecycle/restart/selection.rs +0 -559
- package/crates/team-agent/src/lifecycle/restart/team_state.rs +0 -329
- package/crates/team-agent/src/lifecycle/restart.rs +0 -227
- package/crates/team-agent/src/lifecycle/role_config.rs +0 -1230
- package/crates/team-agent/src/lifecycle/tests/acceptance_b_batch_red.rs +0 -1021
- package/crates/team-agent/src/lifecycle/tests/agent_ops.rs +0 -1205
- package/crates/team-agent/src/lifecycle/tests/b0_legacy_snapshot_nonauthority_contract.rs +0 -265
- package/crates/team-agent/src/lifecycle/tests/b0_reader_hideone_audit_contract.rs +0 -490
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +0 -656
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +0 -447
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +0 -1638
- package/crates/team-agent/src/lifecycle/tests/clone_agent_preserves_source_tools.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +0 -770
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +0 -419
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +0 -2035
- package/crates/team-agent/src/lifecycle/tests/core.rs +0 -1327
- package/crates/team-agent/src/lifecycle/tests/f032_startup_prompt_best_effort_red.rs +0 -315
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_g0.stdout.txt +0 -222
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_list_models_spaced_ids.stdout.txt +0 -9
- package/crates/team-agent/src/lifecycle/tests/fixtures/pi_native_mcp_host.mjs +0 -72
- package/crates/team-agent/src/lifecycle/tests/gate_fixtures.rs +0 -562
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +0 -110
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +0 -512
- package/crates/team-agent/src/lifecycle/tests/host_cotenant_death_p0_contract.rs +0 -921
- package/crates/team-agent/src/lifecycle/tests/issue238_codex_effort_contract.rs +0 -68
- package/crates/team-agent/src/lifecycle/tests/lane_ops.rs +0 -1851
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +0 -3983
- package/crates/team-agent/src/lifecycle/tests/lifecycle_lock.rs +0 -339
- package/crates/team-agent/src/lifecycle/tests/lifecycle_rollback_red.rs +0 -596
- package/crates/team-agent/src/lifecycle/tests/main_preserved.rs +0 -513
- package/crates/team-agent/src/lifecycle/tests/mcp_tool_name_format_red.rs +0 -69
- package/crates/team-agent/src/lifecycle/tests/phase_b_contracts.rs +0 -824
- package/crates/team-agent/src/lifecycle/tests/phase_golden.rs +0 -723
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +0 -164
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +0 -200
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +0 -527
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +0 -1062
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1419
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +0 -98
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +0 -550
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +0 -226
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +0 -332
- package/crates/team-agent/src/lifecycle/tests/realmachine_clusters_1_6_red.rs +0 -786
- package/crates/team-agent/src/lifecycle/tests/realmachine_residual_g1_g4_red.rs +0 -648
- package/crates/team-agent/src/lifecycle/tests/restart.rs +0 -185
- package/crates/team-agent/src/lifecycle/tests/restart_build_before_destroy_0540_contract.rs +0 -1053
- package/crates/team-agent/src/lifecycle/tests/restart_liveness_red.rs +0 -679
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1126
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +0 -153
- package/crates/team-agent/src/lifecycle/tests/resume_recover_red.rs +0 -427
- package/crates/team-agent/src/lifecycle/tests/stale_team_saveconflict_contract.rs +0 -431
- package/crates/team-agent/src/lifecycle/tests/startup_latency_contract.rs +0 -1066
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +0 -876
- package/crates/team-agent/src/lifecycle/tests/subprep_codex_trust_roundtrip_red.rs +0 -1026
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +0 -342
- package/crates/team-agent/src/lifecycle/tests/team_in_team_identity_scope_red.rs +0 -543
- package/crates/team-agent/src/lifecycle/tests/team_in_team_sibling_quick_start_red.rs +0 -1103
- package/crates/team-agent/src/lifecycle/tests/team_in_team_state_scope_red.rs +0 -1276
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_roster_red.rs +0 -145
- package/crates/team-agent/src/lifecycle/tests/team_key_retirement_txn_red.rs +0 -603
- package/crates/team-agent/src/lifecycle/tests/test_isolation_escape_contract.rs +0 -936
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +0 -970
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +0 -995
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -836
- package/crates/team-agent/src/lifecycle/tests.rs +0 -105
- package/crates/team-agent/src/lifecycle/types.rs +0 -877
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +0 -363
- package/crates/team-agent/src/main.rs +0 -52
- package/crates/team-agent/src/mcp_server/helpers.rs +0 -510
- package/crates/team-agent/src/mcp_server/lifecycle_tools/mod.rs +0 -6
- package/crates/team-agent/src/mcp_server/lifecycle_tools/state_status.rs +0 -43
- package/crates/team-agent/src/mcp_server/mod.rs +0 -119
- package/crates/team-agent/src/mcp_server/normalize.rs +0 -485
- package/crates/team-agent/src/mcp_server/readiness.rs +0 -527
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +0 -348
- package/crates/team-agent/src/mcp_server/tests/golden.rs +0 -285
- package/crates/team-agent/src/mcp_server/tests/normalize.rs +0 -247
- package/crates/team-agent/src/mcp_server/tests/scoped.rs +0 -158
- package/crates/team-agent/src/mcp_server/tests/send.rs +0 -353
- package/crates/team-agent/src/mcp_server/tests/tools.rs +0 -341
- package/crates/team-agent/src/mcp_server/tests/wire.rs +0 -254
- package/crates/team-agent/src/mcp_server/tests.rs +0 -43
- package/crates/team-agent/src/mcp_server/tools.rs +0 -889
- package/crates/team-agent/src/mcp_server/types.rs +0 -396
- package/crates/team-agent/src/mcp_server/wire.rs +0 -867
- package/crates/team-agent/src/messaging/activity.rs +0 -461
- package/crates/team-agent/src/messaging/address.rs +0 -87
- package/crates/team-agent/src/messaging/delivery.rs +0 -3727
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +0 -234
- package/crates/team-agent/src/messaging/enter_rescue.rs +0 -362
- package/crates/team-agent/src/messaging/enter_rescue_tests.rs +0 -633
- package/crates/team-agent/src/messaging/helpers.rs +0 -336
- package/crates/team-agent/src/messaging/leader_channel.rs +0 -287
- package/crates/team-agent/src/messaging/leader_receiver.rs +0 -786
- package/crates/team-agent/src/messaging/mod.rs +0 -167
- package/crates/team-agent/src/messaging/persist.rs +0 -377
- package/crates/team-agent/src/messaging/presentation.rs +0 -417
- package/crates/team-agent/src/messaging/reminders.rs +0 -316
- package/crates/team-agent/src/messaging/results/collection_tests.rs +0 -719
- package/crates/team-agent/src/messaging/results.rs +0 -1415
- package/crates/team-agent/src/messaging/scheduler.rs +0 -223
- package/crates/team-agent/src/messaging/selftest.rs +0 -315
- package/crates/team-agent/src/messaging/send.rs +0 -981
- package/crates/team-agent/src/messaging/tests/basic.rs +0 -346
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +0 -657
- package/crates/team-agent/src/messaging/tests/e23.rs +0 -49
- package/crates/team-agent/src/messaging/tests/leader_channel.rs +0 -169
- package/crates/team-agent/src/messaging/tests/leader_inject_acceptance.rs +0 -817
- package/crates/team-agent/src/messaging/tests/main_preserved.rs +0 -85
- package/crates/team-agent/src/messaging/tests/mod.rs +0 -306
- package/crates/team-agent/src/messaging/tests/runtime.rs +0 -3549
- package/crates/team-agent/src/messaging/tests/spine.rs +0 -853
- package/crates/team-agent/src/messaging/tests/wave2.rs +0 -381
- package/crates/team-agent/src/messaging/trust.rs +0 -215
- package/crates/team-agent/src/messaging/types.rs +0 -472
- package/crates/team-agent/src/messaging/wait.rs +0 -366
- package/crates/team-agent/src/messaging/watchers.rs +0 -916
- package/crates/team-agent/src/model/enums.rs +0 -356
- package/crates/team-agent/src/model/errors.rs +0 -18
- package/crates/team-agent/src/model/ids.rs +0 -165
- package/crates/team-agent/src/model/mod.rs +0 -29
- package/crates/team-agent/src/model/name_similarity.rs +0 -252
- package/crates/team-agent/src/model/pane_authority_refusal.rs +0 -359
- package/crates/team-agent/src/model/paths.rs +0 -257
- package/crates/team-agent/src/model/routing.rs +0 -387
- package/crates/team-agent/src/model/spec.rs +0 -1184
- package/crates/team-agent/src/model/task_graph.rs +0 -321
- package/crates/team-agent/src/model/testdata/fuzz.golden.yaml +0 -43
- package/crates/team-agent/src/model/testdata/fuzz.yaml +0 -43
- package/crates/team-agent/src/model/testdata/spec_invalid_a.yaml +0 -209
- package/crates/team-agent/src/model/testdata/team.spec.golden.yaml +0 -208
- package/crates/team-agent/src/model/testdata/team.spec.yaml +0 -208
- package/crates/team-agent/src/model/yaml/tests.rs +0 -188
- package/crates/team-agent/src/model/yaml.rs +0 -802
- package/crates/team-agent/src/os_probe.rs +0 -280
- package/crates/team-agent/src/packaging/install.rs +0 -219
- package/crates/team-agent/src/packaging/migrate.rs +0 -38
- package/crates/team-agent/src/packaging/mod.rs +0 -91
- package/crates/team-agent/src/packaging/repair.rs +0 -33
- package/crates/team-agent/src/packaging/tests.rs +0 -822
- package/crates/team-agent/src/packaging/types.rs +0 -417
- package/crates/team-agent/src/platform/argv.rs +0 -331
- package/crates/team-agent/src/platform/errors.rs +0 -104
- package/crates/team-agent/src/platform/file_lock.rs +0 -279
- package/crates/team-agent/src/platform/mod.rs +0 -5
- package/crates/team-agent/src/platform/process.rs +0 -545
- package/crates/team-agent/src/provider/adapter.rs +0 -1150
- package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
- package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
- package/crates/team-agent/src/provider/adapters/copilot.rs +0 -75
- package/crates/team-agent/src/provider/adapters/copilot_fork.rs +0 -307
- package/crates/team-agent/src/provider/adapters/fake.rs +0 -18
- package/crates/team-agent/src/provider/adapters/mod.rs +0 -30
- package/crates/team-agent/src/provider/adapters/pi.rs +0 -106
- package/crates/team-agent/src/provider/approvals/mod.rs +0 -3
- package/crates/team-agent/src/provider/approvals/parsing.rs +0 -586
- package/crates/team-agent/src/provider/approvals/runtime_prompts.rs +0 -205
- package/crates/team-agent/src/provider/argv_route.rs +0 -405
- package/crates/team-agent/src/provider/bypass_flags.rs +0 -116
- package/crates/team-agent/src/provider/classify.rs +0 -708
- package/crates/team-agent/src/provider/command_helpers.rs +0 -45
- package/crates/team-agent/src/provider/faults.rs +0 -165
- package/crates/team-agent/src/provider/helpers.rs +0 -52
- package/crates/team-agent/src/provider/mod.rs +0 -78
- package/crates/team-agent/src/provider/model_catalog.rs +0 -910
- package/crates/team-agent/src/provider/session/capture.rs +0 -2731
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -172
- package/crates/team-agent/src/provider/session/context_fork.rs +0 -396
- package/crates/team-agent/src/provider/session/mod.rs +0 -36
- package/crates/team-agent/src/provider/session/resume.rs +0 -269
- package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
- package/crates/team-agent/src/provider/session_scan/common/tests.rs +0 -316
- package/crates/team-agent/src/provider/session_scan/common.rs +0 -654
- package/crates/team-agent/src/provider/session_scan/copilot.rs +0 -280
- package/crates/team-agent/src/provider/session_scan/pi.rs +0 -185
- package/crates/team-agent/src/provider/session_scan.rs +0 -71
- package/crates/team-agent/src/provider/startup_prompt.rs +0 -757
- package/crates/team-agent/src/provider/submit_now.rs +0 -71
- package/crates/team-agent/src/provider/testdata/copilot-ready-marker.txt +0 -5
- package/crates/team-agent/src/provider/testdata/copilot-trust-prompt.txt +0 -19
- package/crates/team-agent/src/provider/testdata/grok-models-authenticated.stdout +0 -9
- package/crates/team-agent/src/provider/testdata/grok-models-unauthenticated.stdout +0 -7
- package/crates/team-agent/src/provider/tests/adapter.rs +0 -441
- package/crates/team-agent/src/provider/tests/classify.rs +0 -148
- package/crates/team-agent/src/provider/tests/command_helpers.rs +0 -35
- package/crates/team-agent/src/provider/tests/copilot_fork.rs +0 -191
- package/crates/team-agent/src/provider/tests/faults.rs +0 -200
- package/crates/team-agent/src/provider/tests/idle.rs +0 -177
- package/crates/team-agent/src/provider/tests/wire.rs +0 -213
- package/crates/team-agent/src/provider/tests.rs +0 -32
- package/crates/team-agent/src/provider/types.rs +0 -529
- package/crates/team-agent/src/provider/wire.rs +0 -394
- package/crates/team-agent/src/redaction.rs +0 -259
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +0 -248
- package/crates/team-agent/src/state/abnormal_watch.rs +0 -144
- package/crates/team-agent/src/state/identity.rs +0 -914
- package/crates/team-agent/src/state/identity_keys.rs +0 -132
- package/crates/team-agent/src/state/mod.rs +0 -74
- package/crates/team-agent/src/state/owner_gate.rs +0 -482
- package/crates/team-agent/src/state/ownership.rs +0 -563
- package/crates/team-agent/src/state/paths.rs +0 -395
- package/crates/team-agent/src/state/persist.rs +0 -3811
- package/crates/team-agent/src/state/projection.rs +0 -1508
- package/crates/team-agent/src/state/repository/intent.rs +0 -14
- package/crates/team-agent/src/state/repository/tests.rs +0 -184
- package/crates/team-agent/src/state/repository.rs +0 -866
- package/crates/team-agent/src/state/selector.rs +0 -160
- package/crates/team-agent/src/state/testdata/state-rich.canonical.json +0 -133
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
- package/crates/team-agent/src/tmux_backend/enter_rescue.rs +0 -325
- package/crates/team-agent/src/tmux_backend/enter_rescue_tests.rs +0 -432
- package/crates/team-agent/src/tmux_backend/native_input.rs +0 -513
- package/crates/team-agent/src/tmux_backend/native_input_tests.rs +0 -742
- package/crates/team-agent/src/tmux_backend/tests.rs +0 -4103
- package/crates/team-agent/src/tmux_backend.rs +0 -4492
- package/crates/team-agent/src/topology.rs +0 -537
- package/crates/team-agent/src/transport/enter_rescue.rs +0 -166
- package/crates/team-agent/src/transport/native_input.rs +0 -491
- package/crates/team-agent/src/transport/test_support.rs +0 -743
- package/crates/team-agent/src/transport/tests/behavior.rs +0 -326
- package/crates/team-agent/src/transport/tests/mod.rs +0 -194
- package/crates/team-agent/src/transport/tests/wire.rs +0 -574
- package/crates/team-agent/src/transport.rs +0 -1655
- package/crates/team-agent/src/transport_factory.rs +0 -819
|
@@ -1,1067 +0,0 @@
|
|
|
1
|
-
//! ---
|
|
2
|
-
//! purpose: 由 agent 的 profile 声明推出 provider 启动所需的环境覆盖、环境清除与命令覆写
|
|
3
|
-
//! contract:
|
|
4
|
-
//! provides:
|
|
5
|
-
//! - name: prepare_provider_profile_launch
|
|
6
|
-
//! what: 从 YAML agent 节点算出 ProviderProfileLaunch
|
|
7
|
-
//! - name: prepare_provider_profile_launch_from_json
|
|
8
|
-
//! what: 从 runtime state 的 JSON agent 节点算出同一结果
|
|
9
|
-
//! - name: load_profile
|
|
10
|
-
//! what: 按查找顺序找到 profile env 文件并解析成键值
|
|
11
|
-
//! - name: provider_env_unsets
|
|
12
|
-
//! what: 该 provider 与 auth_mode 下必须清除的环境变量集,worker 与 leader 共用这一份
|
|
13
|
-
//! - name: profile_proxy_mode
|
|
14
|
-
//! what: 读出 profile 的代理模式,缺省 inherit
|
|
15
|
-
//! - name: parse_auth_mode
|
|
16
|
-
//! what: 把 auth_mode 字符串解析成枚举,未知值返回 None
|
|
17
|
-
//! depends:
|
|
18
|
-
//! - crate::provider
|
|
19
|
-
//! - crate::model::enums
|
|
20
|
-
//! - std::fs
|
|
21
|
-
//! boundary:
|
|
22
|
-
//! - 只读 profile 文件,不改写也不创建 profile
|
|
23
|
-
//! - 不把密钥值写进事件或错误消息
|
|
24
|
-
//! - provider 的环境清除集只此一份,leader 侧不得另建
|
|
25
|
-
//! maturity: wired
|
|
26
|
-
//! ---
|
|
27
|
-
use std::collections::{BTreeMap, BTreeSet};
|
|
28
|
-
use std::path::{Path, PathBuf};
|
|
29
|
-
|
|
30
|
-
use crate::lifecycle::LifecycleError;
|
|
31
|
-
use crate::model::enums::{AuthMode, Provider};
|
|
32
|
-
use crate::model::yaml::Value as YamlValue;
|
|
33
|
-
use crate::provider::{McpConfig, ProviderCommandOverrides, ProviderProfileLaunch};
|
|
34
|
-
use crate::provider::command_helpers::append_env_pair;
|
|
35
|
-
|
|
36
|
-
const COMPATIBLE_NETWORK_ENV_KEYS: &[&str] = &[
|
|
37
|
-
"HTTPS_PROXY",
|
|
38
|
-
"HTTP_PROXY",
|
|
39
|
-
"ALL_PROXY",
|
|
40
|
-
"https_proxy",
|
|
41
|
-
"http_proxy",
|
|
42
|
-
"all_proxy",
|
|
43
|
-
"NO_PROXY",
|
|
44
|
-
"no_proxy",
|
|
45
|
-
"NODE_EXTRA_CA_CERTS",
|
|
46
|
-
"SSL_CERT_FILE",
|
|
47
|
-
"REQUESTS_CA_BUNDLE",
|
|
48
|
-
];
|
|
49
|
-
|
|
50
|
-
#[derive(Debug, Clone)]
|
|
51
|
-
pub(crate) struct ProfileValues {
|
|
52
|
-
pub(crate) path: PathBuf,
|
|
53
|
-
pub(crate) values: BTreeMap<String, String>,
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
#[derive(Debug, Clone)]
|
|
57
|
-
struct AgentProfileInput {
|
|
58
|
-
id: String,
|
|
59
|
-
provider: Provider,
|
|
60
|
-
auth_mode: AuthMode,
|
|
61
|
-
profile: Option<String>,
|
|
62
|
-
profile_dir: Option<PathBuf>,
|
|
63
|
-
model: Option<String>,
|
|
64
|
-
model_source: Option<String>,
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/// ---
|
|
68
|
-
/// purpose: 从 YAML agent 节点准备 provider 启动参数,profile 目录用默认查找顺序
|
|
69
|
-
/// params:
|
|
70
|
-
/// agent_id: agent 节点没写 id 时的兜底 id
|
|
71
|
-
/// mcp_config: 需要托管 MCP 配置时传入,否则 None
|
|
72
|
-
/// returns: 环境覆盖、环境清除、命令覆写与 claude 配置目录
|
|
73
|
-
/// errors: profile 找不到、必填键缺失或写 runtime env 文件失败时返回 LifecycleError
|
|
74
|
-
/// contract_id: lifecycle.profile_launch.prepare
|
|
75
|
-
/// ---
|
|
76
|
-
pub(crate) fn prepare_provider_profile_launch(
|
|
77
|
-
workspace: &Path,
|
|
78
|
-
agent_id: &str,
|
|
79
|
-
agent: &YamlValue,
|
|
80
|
-
mcp_config: Option<&McpConfig>,
|
|
81
|
-
) -> Result<ProviderProfileLaunch, LifecycleError> {
|
|
82
|
-
prepare_provider_profile_launch_with_profile_dir(workspace, agent_id, agent, None, mcp_config)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/// ---
|
|
86
|
-
/// purpose: 同上,但允许指定优先查找的 profile 目录
|
|
87
|
-
/// params:
|
|
88
|
-
/// profile_dir: 优先查找目录;agent 节点里的 _profile_dir 优先于它
|
|
89
|
-
/// returns: 环境覆盖、环境清除、命令覆写与 claude 配置目录
|
|
90
|
-
/// errors: 同 prepare_provider_profile_launch
|
|
91
|
-
/// contract_id: lifecycle.profile_launch.prepare
|
|
92
|
-
/// ---
|
|
93
|
-
pub(crate) fn prepare_provider_profile_launch_with_profile_dir(
|
|
94
|
-
workspace: &Path,
|
|
95
|
-
agent_id: &str,
|
|
96
|
-
agent: &YamlValue,
|
|
97
|
-
profile_dir: Option<&Path>,
|
|
98
|
-
mcp_config: Option<&McpConfig>,
|
|
99
|
-
) -> Result<ProviderProfileLaunch, LifecycleError> {
|
|
100
|
-
if let Some(retired) = agent.get("provider").and_then(YamlValue::as_str).filter(|provider| crate::provider::wire::is_retired_provider(provider)) {
|
|
101
|
-
return Err(LifecycleError::Provider(crate::provider::wire::retired_provider_error(retired).into()));
|
|
102
|
-
}
|
|
103
|
-
let input = AgentProfileInput {
|
|
104
|
-
id: agent
|
|
105
|
-
.get("id")
|
|
106
|
-
.and_then(YamlValue::as_str)
|
|
107
|
-
.unwrap_or(agent_id)
|
|
108
|
-
.to_string(),
|
|
109
|
-
provider: agent
|
|
110
|
-
.get("provider")
|
|
111
|
-
.and_then(YamlValue::as_str)
|
|
112
|
-
.and_then(parse_provider)
|
|
113
|
-
.unwrap_or(Provider::Codex),
|
|
114
|
-
auth_mode: agent
|
|
115
|
-
.get("auth_mode")
|
|
116
|
-
.and_then(YamlValue::as_str)
|
|
117
|
-
.and_then(parse_auth_mode)
|
|
118
|
-
.unwrap_or(AuthMode::Subscription),
|
|
119
|
-
profile: agent
|
|
120
|
-
.get("profile")
|
|
121
|
-
.and_then(YamlValue::as_str)
|
|
122
|
-
.filter(|value| !value.is_empty())
|
|
123
|
-
.map(str::to_string),
|
|
124
|
-
profile_dir: agent
|
|
125
|
-
.get("_profile_dir")
|
|
126
|
-
.and_then(YamlValue::as_str)
|
|
127
|
-
.filter(|value| !value.is_empty())
|
|
128
|
-
.map(PathBuf::from)
|
|
129
|
-
.or_else(|| profile_dir.map(Path::to_path_buf)),
|
|
130
|
-
model: agent
|
|
131
|
-
.get("model")
|
|
132
|
-
.and_then(YamlValue::as_str)
|
|
133
|
-
.filter(|value| !value.is_empty())
|
|
134
|
-
.map(str::to_string),
|
|
135
|
-
model_source: agent
|
|
136
|
-
.get("model_source")
|
|
137
|
-
.and_then(YamlValue::as_str)
|
|
138
|
-
.filter(|value| !value.is_empty())
|
|
139
|
-
.map(str::to_string),
|
|
140
|
-
};
|
|
141
|
-
prepare_profile_launch(workspace, input, mcp_config)
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/// ---
|
|
145
|
-
/// purpose: 从 runtime state 的 JSON agent 节点准备 provider 启动参数
|
|
146
|
-
/// returns: 环境覆盖、环境清除、命令覆写与 claude 配置目录
|
|
147
|
-
/// errors: 同 prepare_provider_profile_launch
|
|
148
|
-
/// contract_id: lifecycle.profile_launch.prepare
|
|
149
|
-
/// ---
|
|
150
|
-
pub(crate) fn prepare_provider_profile_launch_from_json(
|
|
151
|
-
workspace: &Path,
|
|
152
|
-
agent_id: &str,
|
|
153
|
-
agent: &serde_json::Value,
|
|
154
|
-
mcp_config: Option<&McpConfig>,
|
|
155
|
-
) -> Result<ProviderProfileLaunch, LifecycleError> {
|
|
156
|
-
if let Some(retired) = agent.get("provider").and_then(serde_json::Value::as_str).filter(|provider| crate::provider::wire::is_retired_provider(provider)) {
|
|
157
|
-
return Err(LifecycleError::Provider(crate::provider::wire::retired_provider_error(retired).into()));
|
|
158
|
-
}
|
|
159
|
-
let input = AgentProfileInput {
|
|
160
|
-
id: agent
|
|
161
|
-
.get("id")
|
|
162
|
-
.and_then(serde_json::Value::as_str)
|
|
163
|
-
.unwrap_or(agent_id)
|
|
164
|
-
.to_string(),
|
|
165
|
-
provider: agent
|
|
166
|
-
.get("provider")
|
|
167
|
-
.and_then(serde_json::Value::as_str)
|
|
168
|
-
.and_then(parse_provider)
|
|
169
|
-
.unwrap_or(Provider::Codex),
|
|
170
|
-
auth_mode: agent
|
|
171
|
-
.get("auth_mode")
|
|
172
|
-
.and_then(serde_json::Value::as_str)
|
|
173
|
-
.and_then(parse_auth_mode)
|
|
174
|
-
.unwrap_or(AuthMode::Subscription),
|
|
175
|
-
profile: agent
|
|
176
|
-
.get("profile")
|
|
177
|
-
.and_then(serde_json::Value::as_str)
|
|
178
|
-
.filter(|value| !value.is_empty())
|
|
179
|
-
.map(str::to_string),
|
|
180
|
-
profile_dir: agent
|
|
181
|
-
.get("_profile_dir")
|
|
182
|
-
.and_then(serde_json::Value::as_str)
|
|
183
|
-
.filter(|value| !value.is_empty())
|
|
184
|
-
.map(PathBuf::from),
|
|
185
|
-
model: agent
|
|
186
|
-
.get("model")
|
|
187
|
-
.and_then(serde_json::Value::as_str)
|
|
188
|
-
.filter(|value| !value.is_empty())
|
|
189
|
-
.map(str::to_string),
|
|
190
|
-
model_source: agent
|
|
191
|
-
.get("model_source")
|
|
192
|
-
.and_then(serde_json::Value::as_str)
|
|
193
|
-
.filter(|value| !value.is_empty())
|
|
194
|
-
.map(str::to_string),
|
|
195
|
-
};
|
|
196
|
-
prepare_profile_launch(workspace, input, mcp_config)
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
fn prepare_profile_launch(
|
|
200
|
-
workspace: &Path,
|
|
201
|
-
agent: AgentProfileInput,
|
|
202
|
-
mcp_config: Option<&McpConfig>,
|
|
203
|
-
) -> Result<ProviderProfileLaunch, LifecycleError> {
|
|
204
|
-
let Some(profile) = agent.profile.as_deref() else {
|
|
205
|
-
return Ok(ProviderProfileLaunch::default());
|
|
206
|
-
};
|
|
207
|
-
let Some(path) = find_profile_file(workspace, profile, agent.profile_dir.as_deref()) else {
|
|
208
|
-
if agent.provider == Provider::Pi && agent.auth_mode == AuthMode::Subscription {
|
|
209
|
-
return Ok(ProviderProfileLaunch::default());
|
|
210
|
-
}
|
|
211
|
-
return Err(profile_not_found(profile));
|
|
212
|
-
};
|
|
213
|
-
let loaded = read_profile_file(path)?;
|
|
214
|
-
validate_profile(&agent, profile, &loaded)?;
|
|
215
|
-
|
|
216
|
-
let mut env_overlay = provider_env_exports(agent.provider, agent.auth_mode, &loaded.values);
|
|
217
|
-
let mut env_unset = provider_env_unsets(agent.provider, agent.auth_mode);
|
|
218
|
-
let mut claude_config_dir = None;
|
|
219
|
-
let mut claude_projects_root = None;
|
|
220
|
-
let mut managed_mcp_config = false;
|
|
221
|
-
|
|
222
|
-
if matches!(agent.provider, Provider::Claude | Provider::ClaudeCode)
|
|
223
|
-
&& agent.auth_mode == AuthMode::CompatibleApi
|
|
224
|
-
{
|
|
225
|
-
let dir = compatible_claude_config_dir(workspace, &agent.id)?;
|
|
226
|
-
if let Some(config) = mcp_config {
|
|
227
|
-
ensure_compatible_claude_mcp_config(&dir, workspace, config)?;
|
|
228
|
-
managed_mcp_config = true;
|
|
229
|
-
}
|
|
230
|
-
let projects_root = dir.join("projects");
|
|
231
|
-
env_overlay.insert(
|
|
232
|
-
"CLAUDE_CONFIG_DIR".to_string(),
|
|
233
|
-
dir.to_string_lossy().to_string(),
|
|
234
|
-
);
|
|
235
|
-
claude_projects_root = Some(projects_root);
|
|
236
|
-
claude_config_dir = Some(dir);
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
env_overlay.extend(compatible_api_network_exports(
|
|
240
|
-
agent.auth_mode,
|
|
241
|
-
&loaded.values,
|
|
242
|
-
));
|
|
243
|
-
if agent.auth_mode == AuthMode::CompatibleApi && profile_proxy_mode(&loaded.values) == "direct"
|
|
244
|
-
{
|
|
245
|
-
for key in COMPATIBLE_NETWORK_ENV_KEYS {
|
|
246
|
-
env_unset.insert((*key).to_string());
|
|
247
|
-
env_overlay.remove(*key);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
let command_overrides = provider_command_overrides(&agent, &loaded.values);
|
|
251
|
-
write_runtime_env_file(workspace, &agent.id, &env_overlay, &env_unset)?;
|
|
252
|
-
|
|
253
|
-
Ok(ProviderProfileLaunch {
|
|
254
|
-
env_overlay,
|
|
255
|
-
env_unset,
|
|
256
|
-
command_overrides,
|
|
257
|
-
claude_config_dir,
|
|
258
|
-
claude_projects_root,
|
|
259
|
-
managed_mcp_config,
|
|
260
|
-
})
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
/// ---
|
|
264
|
-
/// purpose: 按查找目录顺序定位 profile env 文件并解析成键值表
|
|
265
|
-
/// params:
|
|
266
|
-
/// name: profile 名,先找 name.env 再找 name.example.env
|
|
267
|
-
/// profile_dir: 优先查找目录,None 表示只用默认顺序
|
|
268
|
-
/// returns: 命中的文件路径与解析出的键值
|
|
269
|
-
/// errors: 所有目录都没命中返回 RequirementUnmet,读文件失败返回 StatePersist
|
|
270
|
-
/// ---
|
|
271
|
-
pub(crate) fn load_profile(
|
|
272
|
-
workspace: &Path,
|
|
273
|
-
name: &str,
|
|
274
|
-
profile_dir: Option<&Path>,
|
|
275
|
-
) -> Result<ProfileValues, LifecycleError> {
|
|
276
|
-
let path =
|
|
277
|
-
find_profile_file(workspace, name, profile_dir).ok_or_else(|| profile_not_found(name))?;
|
|
278
|
-
read_profile_file(path)
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
fn find_profile_file(workspace: &Path, name: &str, profile_dir: Option<&Path>) -> Option<PathBuf> {
|
|
282
|
-
let dirs = profile_lookup_dirs(workspace, profile_dir);
|
|
283
|
-
dirs.iter()
|
|
284
|
-
.map(|directory| directory.join(format!("{name}.env")))
|
|
285
|
-
.find(|path| path.exists())
|
|
286
|
-
.or_else(|| {
|
|
287
|
-
dirs.iter()
|
|
288
|
-
.map(|directory| directory.join(format!("{name}.example.env")))
|
|
289
|
-
.find(|path| path.exists())
|
|
290
|
-
})
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
fn profile_not_found(name: &str) -> LifecycleError {
|
|
294
|
-
LifecycleError::RequirementUnmet(format!(
|
|
295
|
-
"profile {name} not found; run team-agent profile init {name} --auth-mode subscription"
|
|
296
|
-
))
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
fn read_profile_file(path: PathBuf) -> Result<ProfileValues, LifecycleError> {
|
|
300
|
-
let text = std::fs::read_to_string(&path)
|
|
301
|
-
.map_err(|e| LifecycleError::StatePersist(format!("{}: {e}", path.display())))?;
|
|
302
|
-
Ok(ProfileValues {
|
|
303
|
-
path,
|
|
304
|
-
values: parse_env_text(&text),
|
|
305
|
-
})
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
fn profile_lookup_dirs(workspace: &Path, profile_dir: Option<&Path>) -> Vec<PathBuf> {
|
|
309
|
-
let mut dirs = Vec::new();
|
|
310
|
-
if let Some(dir) = profile_dir {
|
|
311
|
-
push_unique_path(&mut dirs, dir.to_path_buf());
|
|
312
|
-
}
|
|
313
|
-
push_unique_path(&mut dirs, workspace.join(".team/current/profiles"));
|
|
314
|
-
push_unique_path(&mut dirs, workspace.join("profiles"));
|
|
315
|
-
push_unique_path(&mut dirs, workspace.join(".team/profiles"));
|
|
316
|
-
if workspace.file_name().and_then(|name| name.to_str()) == Some(".team") {
|
|
317
|
-
push_unique_path(&mut dirs, workspace.join("current/profiles"));
|
|
318
|
-
}
|
|
319
|
-
dirs
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
fn push_unique_path(paths: &mut Vec<PathBuf>, path: PathBuf) {
|
|
323
|
-
if !paths.iter().any(|existing| existing == &path) {
|
|
324
|
-
paths.push(path);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
pub(crate) fn parse_env_text(text: &str) -> BTreeMap<String, String> {
|
|
329
|
-
let mut values = BTreeMap::new();
|
|
330
|
-
for raw in text.lines() {
|
|
331
|
-
let mut line = raw.trim();
|
|
332
|
-
if line.is_empty() || line.starts_with('#') {
|
|
333
|
-
continue;
|
|
334
|
-
}
|
|
335
|
-
if let Some(rest) = line.strip_prefix("export ") {
|
|
336
|
-
line = rest.trim();
|
|
337
|
-
}
|
|
338
|
-
let Some((key, value)) = line.split_once('=') else {
|
|
339
|
-
continue;
|
|
340
|
-
};
|
|
341
|
-
let key = key.trim();
|
|
342
|
-
if !is_profile_key(key) {
|
|
343
|
-
continue;
|
|
344
|
-
}
|
|
345
|
-
values.insert(key.to_string(), strip_env_value(value.trim()));
|
|
346
|
-
}
|
|
347
|
-
values
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
fn strip_env_value(raw: &str) -> String {
|
|
351
|
-
let value = raw.trim();
|
|
352
|
-
if value.len() >= 2 {
|
|
353
|
-
if let Some(inner) = value.strip_prefix('"').and_then(|v| v.strip_suffix('"')) {
|
|
354
|
-
return inner.to_string();
|
|
355
|
-
}
|
|
356
|
-
if let Some(inner) = value.strip_prefix('\'').and_then(|v| v.strip_suffix('\'')) {
|
|
357
|
-
return inner.to_string();
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
value.to_string()
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
fn is_profile_key(key: &str) -> bool {
|
|
364
|
-
let mut chars = key.chars();
|
|
365
|
-
match chars.next() {
|
|
366
|
-
Some(c) if c.is_ascii_alphabetic() || c == '_' => {}
|
|
367
|
-
_ => return false,
|
|
368
|
-
}
|
|
369
|
-
chars.all(|c| c.is_ascii_alphanumeric() || c == '_')
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
fn validate_profile(
|
|
373
|
-
agent: &AgentProfileInput,
|
|
374
|
-
profile: &str,
|
|
375
|
-
loaded: &ProfileValues,
|
|
376
|
-
) -> Result<(), LifecycleError> {
|
|
377
|
-
let proxy_mode = profile_proxy_mode(&loaded.values);
|
|
378
|
-
if !matches!(proxy_mode.as_str(), "direct" | "inherit") {
|
|
379
|
-
return Err(LifecycleError::RequirementUnmet(format!(
|
|
380
|
-
"profile {profile} has invalid proxy mode {proxy_mode}; expected direct|inherit"
|
|
381
|
-
)));
|
|
382
|
-
}
|
|
383
|
-
if loaded
|
|
384
|
-
.values
|
|
385
|
-
.get("AUTH_MODE")
|
|
386
|
-
.is_some_and(|mode| parse_auth_mode(mode) != Some(agent.auth_mode))
|
|
387
|
-
{
|
|
388
|
-
return Err(LifecycleError::RequirementUnmet(format!(
|
|
389
|
-
"profile {profile} AUTH_MODE does not match agent auth_mode"
|
|
390
|
-
)));
|
|
391
|
-
}
|
|
392
|
-
if agent.auth_mode == AuthMode::CompatibleApi
|
|
393
|
-
&& matches!(agent.model_source.as_deref(), Some("role" | "team"))
|
|
394
|
-
{
|
|
395
|
-
let profile_model = profile_model(&loaded.values);
|
|
396
|
-
if let Some(profile_model) = profile_model {
|
|
397
|
-
if agent
|
|
398
|
-
.model
|
|
399
|
-
.as_deref()
|
|
400
|
-
.is_some_and(|model| model != profile_model)
|
|
401
|
-
{
|
|
402
|
-
return Err(LifecycleError::RequirementUnmet(format!(
|
|
403
|
-
"role/team model does not match profile MODEL in {}",
|
|
404
|
-
loaded.path.display()
|
|
405
|
-
)));
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
let mut missing: Vec<&str> = Vec::new();
|
|
410
|
-
for key in required_profile_keys(agent.provider, agent.auth_mode) {
|
|
411
|
-
if key == &"API_KEY" {
|
|
412
|
-
continue;
|
|
413
|
-
}
|
|
414
|
-
if !profile_value_or_alternate(&loaded.values, key).is_some_and(|value| !value.is_empty()) {
|
|
415
|
-
missing.push(*key);
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
if agent.auth_mode == AuthMode::CompatibleApi
|
|
419
|
-
&& effective_profile_or_agent_model(agent, &loaded.values).is_none()
|
|
420
|
-
{
|
|
421
|
-
missing.push("MODEL");
|
|
422
|
-
}
|
|
423
|
-
if !missing.is_empty() {
|
|
424
|
-
return Err(LifecycleError::RequirementUnmet(format!(
|
|
425
|
-
"profile {profile} missing required values: {}",
|
|
426
|
-
missing.join(", ")
|
|
427
|
-
)));
|
|
428
|
-
}
|
|
429
|
-
Ok(())
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
fn provider_env_exports(
|
|
433
|
-
provider: Provider,
|
|
434
|
-
auth_mode: AuthMode,
|
|
435
|
-
values: &BTreeMap<String, String>,
|
|
436
|
-
) -> BTreeMap<String, String> {
|
|
437
|
-
let mut exports = BTreeMap::new();
|
|
438
|
-
if auth_mode == AuthMode::Subscription {
|
|
439
|
-
return exports;
|
|
440
|
-
}
|
|
441
|
-
match provider {
|
|
442
|
-
Provider::Claude | Provider::ClaudeCode => {
|
|
443
|
-
append_env_pair(&mut exports, "ANTHROPIC_BASE_URL", value_or_alternate(values, "ANTHROPIC_BASE_URL", "BASE_URL"));
|
|
444
|
-
if auth_mode == AuthMode::OfficialApi {
|
|
445
|
-
append_env_pair(&mut exports, "ANTHROPIC_API_KEY", value_or_alternate(values, "ANTHROPIC_API_KEY", "API_KEY"));
|
|
446
|
-
}
|
|
447
|
-
append_env_pair(&mut exports, "ANTHROPIC_AUTH_TOKEN", value_or_alternate(values, "ANTHROPIC_AUTH_TOKEN", "AUTH_TOKEN")
|
|
448
|
-
.or_else(|| {
|
|
449
|
-
(auth_mode == AuthMode::CompatibleApi)
|
|
450
|
-
.then(|| value_or_alternate(values, "ANTHROPIC_API_KEY", "API_KEY"))
|
|
451
|
-
.flatten()
|
|
452
|
-
}));
|
|
453
|
-
append_env_pair(&mut exports, "ANTHROPIC_MODEL", profile_model(values));
|
|
454
|
-
}
|
|
455
|
-
Provider::GeminiCli => {
|
|
456
|
-
append_env_pair(&mut exports, "GEMINI_API_KEY", value_or_alternate(values, "GEMINI_API_KEY", "API_KEY"));
|
|
457
|
-
}
|
|
458
|
-
// C-A-4 cr verdict v2 — copilot BYOK(== compatible_api 档,help-providers 原文
|
|
459
|
-
// "GitHub authentication is not required" when COPILOT_PROVIDER_BASE_URL set):
|
|
460
|
-
// profile 值经 env_overlay 落 COPILOT_PROVIDER_BASE_URL/TYPE/API_KEY/WIRE_API
|
|
461
|
-
// + COPILOT_MODEL。BYOK 必须含 MODEL("A model is required for BYOK")—
|
|
462
|
-
// 这一硬性校验在 launch 路径处理(profile compile 时无法判别 model 来源)。
|
|
463
|
-
// Subscription/OfficialApi 不导出 COPILOT_PROVIDER_*(避免误改 auth 通道)。
|
|
464
|
-
Provider::Copilot => {
|
|
465
|
-
if auth_mode == AuthMode::CompatibleApi {
|
|
466
|
-
for (key, alternate) in [
|
|
467
|
-
("COPILOT_PROVIDER_BASE_URL", "BASE_URL"),
|
|
468
|
-
("COPILOT_PROVIDER_TYPE", "PROVIDER_TYPE"),
|
|
469
|
-
("COPILOT_PROVIDER_API_KEY", "API_KEY"),
|
|
470
|
-
("COPILOT_PROVIDER_WIRE_API", "WIRE_API"),
|
|
471
|
-
("COPILOT_MODEL", "MODEL"),
|
|
472
|
-
] {
|
|
473
|
-
append_env_pair(&mut exports, key, value_or_alternate(values, key, alternate));
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
// Codex and Grok workers run only through their subscription-only
|
|
478
|
-
// contract leaves; Pi retains its native subscription credentials.
|
|
479
|
-
Provider::Codex | Provider::Grok | Provider::Pi => {}
|
|
480
|
-
Provider::Fake => {}
|
|
481
|
-
}
|
|
482
|
-
exports
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
#[cfg(test)]
|
|
486
|
-
mod append_env_contract {
|
|
487
|
-
use super::*;
|
|
488
|
-
|
|
489
|
-
#[test]
|
|
490
|
-
fn profile_append_keeps_native_keys_alternates_and_auth_gates() {
|
|
491
|
-
let values: BTreeMap<String, String> = [
|
|
492
|
-
("API_KEY", "dummy"), ("BASE_URL", " raw\nbase "),
|
|
493
|
-
("AUTH_TOKEN", "dummy-token"), ("MODEL", " raw model "),
|
|
494
|
-
("PROVIDER_TYPE", "custom"), ("WIRE_API", "responses"),
|
|
495
|
-
("OPENAI_API_KEY", "native-dummy"),
|
|
496
|
-
].into_iter().map(|(k, v)| (k.to_string(), v.to_string())).collect();
|
|
497
|
-
let map = |pairs: &[(&str, &str)]| -> BTreeMap<String, String> {
|
|
498
|
-
pairs.iter().map(|(k, v)| (k.to_string(), v.to_string())).collect()
|
|
499
|
-
};
|
|
500
|
-
for provider in [Provider::Codex, Provider::Grok, Provider::Pi] {
|
|
501
|
-
assert!(provider_env_exports(provider, AuthMode::OfficialApi, &values).is_empty());
|
|
502
|
-
assert!(provider_env_exports(provider, AuthMode::CompatibleApi, &values).is_empty());
|
|
503
|
-
}
|
|
504
|
-
for provider in [Provider::Claude, Provider::ClaudeCode] {
|
|
505
|
-
assert_eq!(provider_env_exports(provider, AuthMode::OfficialApi, &values), map(&[
|
|
506
|
-
("ANTHROPIC_BASE_URL", " raw\nbase "), ("ANTHROPIC_API_KEY", "dummy"),
|
|
507
|
-
("ANTHROPIC_AUTH_TOKEN", "dummy-token"), ("ANTHROPIC_MODEL", " raw model "),
|
|
508
|
-
]));
|
|
509
|
-
}
|
|
510
|
-
assert_eq!(provider_env_exports(Provider::GeminiCli, AuthMode::OfficialApi, &values), map(&[("GEMINI_API_KEY", "dummy")]));
|
|
511
|
-
assert_eq!(provider_env_exports(Provider::Copilot, AuthMode::CompatibleApi, &values), map(&[
|
|
512
|
-
("COPILOT_PROVIDER_BASE_URL", " raw\nbase "), ("COPILOT_PROVIDER_TYPE", "custom"),
|
|
513
|
-
("COPILOT_PROVIDER_API_KEY", "dummy"), ("COPILOT_PROVIDER_WIRE_API", "responses"),
|
|
514
|
-
("COPILOT_MODEL", " raw model "),
|
|
515
|
-
]));
|
|
516
|
-
assert!(provider_env_exports(Provider::Copilot, AuthMode::OfficialApi, &values).is_empty());
|
|
517
|
-
for provider in crate::provider::wire::all_providers() {
|
|
518
|
-
assert!(provider_env_exports(*provider, AuthMode::Subscription, &values).is_empty());
|
|
519
|
-
assert!(provider_env_exports(*provider, AuthMode::CompatibleApi, &BTreeMap::new()).is_empty());
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
/// ---
|
|
525
|
-
/// purpose: 给出该 provider 与 auth_mode 下必须从子进程环境里清掉的变量名集
|
|
526
|
-
/// returns: 变量名集合;claude 系清掉会让子进程并入父会话的那组标识
|
|
527
|
-
/// ---
|
|
528
|
-
/// 0.4.x (CR C-1): exposed as `pub(crate)` so the leader launcher
|
|
529
|
-
/// (leader/start.rs) can reuse the SAME Claude/Codex/Copilot env-unset set
|
|
530
|
-
/// used by worker spawn. Single source of truth — adding a new provider env
|
|
531
|
-
/// var to clean up means changing this one function. Audit grep guard in
|
|
532
|
-
/// `crates/team-agent/src/leader/start.rs::leader_env_unset_for_provider`
|
|
533
|
-
/// confirms the leader path imports from here and does not maintain its own
|
|
534
|
-
/// duplicate list.
|
|
535
|
-
pub(crate) fn provider_env_unsets(provider: Provider, auth_mode: AuthMode) -> BTreeSet<String> {
|
|
536
|
-
let mut unsets = BTreeSet::new();
|
|
537
|
-
match provider {
|
|
538
|
-
Provider::Claude | Provider::ClaudeCode => {
|
|
539
|
-
// E57 (0.3.27 P0): unset CLAUDE_CODE_SESSION_ID inherited from the
|
|
540
|
-
// leader's environment. When a Claude leader spawns a Claude worker,
|
|
541
|
-
// the worker inherits the leader's CLAUDE_CODE_SESSION_ID; Claude
|
|
542
|
-
// Code then routes the worker's transcript to the leader's session
|
|
543
|
-
// file (~/.claude/projects/<hash>/<leader-session-uuid>.jsonl),
|
|
544
|
-
// corrupting attribution and transcripts. Always unset so Claude
|
|
545
|
-
// Code generates a fresh session id per worker.
|
|
546
|
-
//
|
|
547
|
-
// S1-CAPTURE (0.4.x P0): also unset the rest of the Claude Code
|
|
548
|
-
// child/team env block. These variables make the spawned process
|
|
549
|
-
// believe it is a CHILD of the parent Claude (CLAUDE_CODE_CHILD_SESSION),
|
|
550
|
-
// a TEAM member (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS), or otherwise
|
|
551
|
-
// inherit the parent's invocation identity (ENTRYPOINT / EXECPATH /
|
|
552
|
-
// CLAUDECODE marker). Without unsetting these, a Claude worker
|
|
553
|
-
// spawned from a Claude leader is not an INDEPENDENT process — it
|
|
554
|
-
// joins the leader's session tree and its transcript / state /
|
|
555
|
-
// billing are attributed to the leader. CLAUDE_EFFORT is preserved
|
|
556
|
-
// (effort preference does not affect session attribution).
|
|
557
|
-
unsets.insert("CLAUDE_CODE_SESSION_ID".to_string());
|
|
558
|
-
unsets.insert("CLAUDE_CODE_CHILD_SESSION".to_string());
|
|
559
|
-
unsets.insert("CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS".to_string());
|
|
560
|
-
unsets.insert("CLAUDE_CODE_ENTRYPOINT".to_string());
|
|
561
|
-
unsets.insert("CLAUDE_CODE_EXECPATH".to_string());
|
|
562
|
-
unsets.insert("CLAUDECODE".to_string());
|
|
563
|
-
if auth_mode == AuthMode::CompatibleApi {
|
|
564
|
-
unsets.insert("ANTHROPIC_API_KEY".to_string());
|
|
565
|
-
}
|
|
566
|
-
if auth_mode == AuthMode::OfficialApi {
|
|
567
|
-
unsets.insert("ANTHROPIC_AUTH_TOKEN".to_string());
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
Provider::Codex => {
|
|
571
|
-
if auth_mode == AuthMode::CompatibleApi {
|
|
572
|
-
unsets.insert("OPENAI_API_KEY".to_string());
|
|
573
|
-
unsets.insert("OPENAI_BASE_URL".to_string());
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
Provider::GeminiCli => {
|
|
577
|
-
if auth_mode == AuthMode::CompatibleApi {
|
|
578
|
-
unsets.insert("GEMINI_API_KEY".to_string());
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
// C-7-1 cr verdict: 一期 subscription-only(已登录态),exports/unsets 空;
|
|
582
|
-
// BYOK(COPILOT_PROVIDER_*)二期立项时单独 cr verdict 再开。
|
|
583
|
-
Provider::Copilot => {}
|
|
584
|
-
// Grok has no provider-specific environment to unset.
|
|
585
|
-
Provider::Grok => {}
|
|
586
|
-
Provider::Pi => {}
|
|
587
|
-
Provider::Fake => {}
|
|
588
|
-
}
|
|
589
|
-
unsets
|
|
590
|
-
}
|
|
591
|
-
|
|
592
|
-
fn provider_command_overrides(
|
|
593
|
-
agent: &AgentProfileInput,
|
|
594
|
-
values: &BTreeMap<String, String>,
|
|
595
|
-
) -> ProviderCommandOverrides {
|
|
596
|
-
let model = match agent.model_source.as_deref() {
|
|
597
|
-
Some("role" | "team") => agent.model.clone(),
|
|
598
|
-
Some("default") => profile_model(values)
|
|
599
|
-
.map(str::to_string)
|
|
600
|
-
.or_else(|| agent.model.clone()),
|
|
601
|
-
_ if agent.model.is_some() => agent.model.clone(),
|
|
602
|
-
_ => profile_model(values).map(str::to_string),
|
|
603
|
-
};
|
|
604
|
-
ProviderCommandOverrides { model }
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
fn write_runtime_env_file(
|
|
608
|
-
workspace: &Path,
|
|
609
|
-
agent_id: &str,
|
|
610
|
-
exports: &BTreeMap<String, String>,
|
|
611
|
-
unsets: &BTreeSet<String>,
|
|
612
|
-
) -> Result<(), LifecycleError> {
|
|
613
|
-
if exports.is_empty() && unsets.is_empty() {
|
|
614
|
-
return Ok(());
|
|
615
|
-
}
|
|
616
|
-
let dir = workspace.join(".team/runtime/provider-env");
|
|
617
|
-
std::fs::create_dir_all(&dir)
|
|
618
|
-
.map_err(|e| LifecycleError::StatePersist(format!("{}: {e}", dir.display())))?;
|
|
619
|
-
let path = dir.join(format!("{agent_id}.env"));
|
|
620
|
-
let mut lines = Vec::new();
|
|
621
|
-
for key in unsets {
|
|
622
|
-
lines.push(format!("unset {key}"));
|
|
623
|
-
}
|
|
624
|
-
for (key, value) in exports {
|
|
625
|
-
lines.push(format!("export {key}={}", shell_quote(value)));
|
|
626
|
-
}
|
|
627
|
-
std::fs::write(&path, format!("{}\n", lines.join("\n")))
|
|
628
|
-
.map_err(|e| LifecycleError::StatePersist(format!("{}: {e}", path.display())))?;
|
|
629
|
-
set_owner_only_permissions(&path)?;
|
|
630
|
-
Ok(())
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
#[cfg(unix)]
|
|
634
|
-
fn set_owner_only_permissions(path: &Path) -> Result<(), LifecycleError> {
|
|
635
|
-
use std::os::unix::fs::PermissionsExt;
|
|
636
|
-
|
|
637
|
-
std::fs::set_permissions(path, std::fs::Permissions::from_mode(0o600))
|
|
638
|
-
.map_err(|e| LifecycleError::StatePersist(format!("{}: {e}", path.display())))
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
#[cfg(not(unix))]
|
|
642
|
-
fn set_owner_only_permissions(path: &Path) -> Result<(), LifecycleError> {
|
|
643
|
-
let _ = path;
|
|
644
|
-
Ok(())
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
fn shell_quote(value: &str) -> String {
|
|
648
|
-
if value.is_empty() {
|
|
649
|
-
return "''".to_string();
|
|
650
|
-
}
|
|
651
|
-
if value
|
|
652
|
-
.chars()
|
|
653
|
-
.all(|c| c.is_ascii_alphanumeric() || "-_./:@%+=".contains(c))
|
|
654
|
-
{
|
|
655
|
-
return value.to_string();
|
|
656
|
-
}
|
|
657
|
-
format!("'{}'", value.replace('\'', "'\"'\"'"))
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
fn compatible_claude_config_dir(
|
|
661
|
-
workspace: &Path,
|
|
662
|
-
agent_id: &str,
|
|
663
|
-
) -> Result<PathBuf, LifecycleError> {
|
|
664
|
-
let dir = workspace
|
|
665
|
-
.join(".team/runtime/provider-config")
|
|
666
|
-
.join(agent_id)
|
|
667
|
-
.join("claude");
|
|
668
|
-
std::fs::create_dir_all(&dir)
|
|
669
|
-
.map_err(|e| LifecycleError::StatePersist(format!("{}: {e}", dir.display())))?;
|
|
670
|
-
ensure_compatible_claude_config(&dir, workspace)?;
|
|
671
|
-
Ok(dir)
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
fn ensure_compatible_claude_config(dir: &Path, workspace: &Path) -> Result<(), LifecycleError> {
|
|
675
|
-
let settings_path = dir.join("settings.json");
|
|
676
|
-
let mut settings = read_json_object(&settings_path)?;
|
|
677
|
-
insert_if_missing(&mut settings, "theme", serde_json::json!("auto"));
|
|
678
|
-
insert_if_missing(
|
|
679
|
-
&mut settings,
|
|
680
|
-
"skipDangerousModePermissionPrompt",
|
|
681
|
-
serde_json::json!(true),
|
|
682
|
-
);
|
|
683
|
-
settings.insert(
|
|
684
|
-
"hasCompletedOnboarding".to_string(),
|
|
685
|
-
serde_json::json!(true),
|
|
686
|
-
);
|
|
687
|
-
settings.insert(
|
|
688
|
-
"hasTrustDialogAccepted".to_string(),
|
|
689
|
-
serde_json::json!(true),
|
|
690
|
-
);
|
|
691
|
-
insert_if_missing(
|
|
692
|
-
&mut settings,
|
|
693
|
-
"lastOnboardingVersion",
|
|
694
|
-
serde_json::json!("2.1.0"),
|
|
695
|
-
);
|
|
696
|
-
insert_if_missing(
|
|
697
|
-
&mut settings,
|
|
698
|
-
"firstStartTime",
|
|
699
|
-
serde_json::json!("1970-01-01T00:00:00.000Z"),
|
|
700
|
-
);
|
|
701
|
-
insert_if_missing(&mut settings, "numStartups", serde_json::json!(0));
|
|
702
|
-
insert_if_missing(
|
|
703
|
-
&mut settings,
|
|
704
|
-
"projectOnboardingSeenCount",
|
|
705
|
-
serde_json::json!(1),
|
|
706
|
-
);
|
|
707
|
-
write_json_object(&settings_path, &settings)?;
|
|
708
|
-
|
|
709
|
-
let state_path = dir.join(".claude.json");
|
|
710
|
-
let mut state = read_json_object(&state_path)?;
|
|
711
|
-
state.insert(
|
|
712
|
-
"hasCompletedOnboarding".to_string(),
|
|
713
|
-
serde_json::json!(true),
|
|
714
|
-
);
|
|
715
|
-
insert_if_missing(
|
|
716
|
-
&mut state,
|
|
717
|
-
"lastOnboardingVersion",
|
|
718
|
-
serde_json::json!("2.1.0"),
|
|
719
|
-
);
|
|
720
|
-
insert_if_missing(
|
|
721
|
-
&mut state,
|
|
722
|
-
"firstStartTime",
|
|
723
|
-
serde_json::json!("1970-01-01T00:00:00.000Z"),
|
|
724
|
-
);
|
|
725
|
-
insert_if_missing(&mut state, "numStartups", serde_json::json!(0));
|
|
726
|
-
ensure_claude_projects(&mut state, workspace, None);
|
|
727
|
-
write_json_object(&state_path, &state)
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
fn ensure_compatible_claude_mcp_config(
|
|
731
|
-
dir: &Path,
|
|
732
|
-
workspace: &Path,
|
|
733
|
-
mcp_config: &McpConfig,
|
|
734
|
-
) -> Result<(), LifecycleError> {
|
|
735
|
-
let state_path = dir.join(".claude.json");
|
|
736
|
-
let mut state = read_json_object(&state_path)?;
|
|
737
|
-
state.insert(
|
|
738
|
-
"hasCompletedOnboarding".to_string(),
|
|
739
|
-
serde_json::json!(true),
|
|
740
|
-
);
|
|
741
|
-
state.insert(
|
|
742
|
-
"hasTrustDialogAccepted".to_string(),
|
|
743
|
-
serde_json::json!(true),
|
|
744
|
-
);
|
|
745
|
-
insert_if_missing(
|
|
746
|
-
&mut state,
|
|
747
|
-
"projectOnboardingSeenCount",
|
|
748
|
-
serde_json::json!(1),
|
|
749
|
-
);
|
|
750
|
-
state.insert("mcpServers".to_string(), mcp_config.raw.clone());
|
|
751
|
-
state.insert(
|
|
752
|
-
"enabledMcpjsonServers".to_string(),
|
|
753
|
-
serde_json::json!(mcp_server_names(&mcp_config.raw)),
|
|
754
|
-
);
|
|
755
|
-
ensure_claude_projects(&mut state, workspace, Some(&mcp_config.raw));
|
|
756
|
-
write_json_object(&state_path, &state)
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
fn ensure_claude_projects(
|
|
760
|
-
state: &mut serde_json::Map<String, serde_json::Value>,
|
|
761
|
-
workspace: &Path,
|
|
762
|
-
mcp_servers: Option<&serde_json::Value>,
|
|
763
|
-
) {
|
|
764
|
-
if !state
|
|
765
|
-
.get("projects")
|
|
766
|
-
.is_some_and(serde_json::Value::is_object)
|
|
767
|
-
{
|
|
768
|
-
state.insert("projects".to_string(), serde_json::json!({}));
|
|
769
|
-
}
|
|
770
|
-
let Some(projects) = state
|
|
771
|
-
.get_mut("projects")
|
|
772
|
-
.and_then(serde_json::Value::as_object_mut)
|
|
773
|
-
else {
|
|
774
|
-
return;
|
|
775
|
-
};
|
|
776
|
-
for key in claude_project_keys(workspace) {
|
|
777
|
-
let entry = projects.entry(key).or_insert_with(|| serde_json::json!({}));
|
|
778
|
-
if !entry.is_object() {
|
|
779
|
-
*entry = serde_json::json!({});
|
|
780
|
-
}
|
|
781
|
-
let Some(project) = entry.as_object_mut() else {
|
|
782
|
-
continue;
|
|
783
|
-
};
|
|
784
|
-
project.insert(
|
|
785
|
-
"hasTrustDialogAccepted".to_string(),
|
|
786
|
-
serde_json::json!(true),
|
|
787
|
-
);
|
|
788
|
-
insert_if_missing(project, "projectOnboardingSeenCount", serde_json::json!(1));
|
|
789
|
-
if let Some(mcp_servers) = mcp_servers {
|
|
790
|
-
insert_if_missing(project, "allowedTools", serde_json::json!([]));
|
|
791
|
-
insert_if_missing(project, "mcpContextUris", serde_json::json!([]));
|
|
792
|
-
project.insert(
|
|
793
|
-
"enabledMcpjsonServers".to_string(),
|
|
794
|
-
serde_json::json!(mcp_server_names(mcp_servers)),
|
|
795
|
-
);
|
|
796
|
-
insert_if_missing(project, "disabledMcpjsonServers", serde_json::json!([]));
|
|
797
|
-
insert_if_missing(
|
|
798
|
-
project,
|
|
799
|
-
"hasClaudeMdExternalIncludesApproved",
|
|
800
|
-
serde_json::json!(false),
|
|
801
|
-
);
|
|
802
|
-
insert_if_missing(
|
|
803
|
-
project,
|
|
804
|
-
"hasClaudeMdExternalIncludesWarningShown",
|
|
805
|
-
serde_json::json!(false),
|
|
806
|
-
);
|
|
807
|
-
if !project
|
|
808
|
-
.get("mcpServers")
|
|
809
|
-
.is_some_and(serde_json::Value::is_object)
|
|
810
|
-
{
|
|
811
|
-
project.insert("mcpServers".to_string(), serde_json::json!({}));
|
|
812
|
-
}
|
|
813
|
-
if let Some(existing) = project
|
|
814
|
-
.get_mut("mcpServers")
|
|
815
|
-
.and_then(serde_json::Value::as_object_mut)
|
|
816
|
-
{
|
|
817
|
-
if let Some(servers) = mcp_servers.as_object() {
|
|
818
|
-
existing.extend(servers.clone());
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
fn mcp_server_names(mcp_servers: &serde_json::Value) -> Vec<String> {
|
|
826
|
-
mcp_servers
|
|
827
|
-
.as_object()
|
|
828
|
-
.map(|servers| servers.keys().cloned().collect())
|
|
829
|
-
.unwrap_or_default()
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
/// swallow batch 4 C1-C4 (MUST-NOT-9/13): a CORRUPT provider-config JSON fails
|
|
833
|
-
/// EXPLICITLY — the old `unwrap_or_default` turned a parse failure into an empty map
|
|
834
|
-
/// that the subsequent write flattened back over the user's file (silent destructive
|
|
835
|
-
/// rewrite). A missing file stays Ok(empty) — only an existing-but-unparseable file
|
|
836
|
-
/// errors, naming the path + parse detail + next action; the file is never touched.
|
|
837
|
-
fn read_json_object(
|
|
838
|
-
path: &Path,
|
|
839
|
-
) -> Result<serde_json::Map<String, serde_json::Value>, LifecycleError> {
|
|
840
|
-
let text = match std::fs::read_to_string(path) {
|
|
841
|
-
Ok(text) => text,
|
|
842
|
-
Err(error) if error.kind() == std::io::ErrorKind::NotFound => {
|
|
843
|
-
return Ok(serde_json::Map::new());
|
|
844
|
-
}
|
|
845
|
-
Err(error) => {
|
|
846
|
-
return Err(LifecycleError::RequirementUnmet(format!(
|
|
847
|
-
"profile_invalid_json: {} could not be read: {error}; fix or remove the file (or restore a backup) and relaunch",
|
|
848
|
-
path.display()
|
|
849
|
-
)));
|
|
850
|
-
}
|
|
851
|
-
};
|
|
852
|
-
match serde_json::from_str::<serde_json::Value>(&text) {
|
|
853
|
-
Ok(serde_json::Value::Object(map)) => Ok(map),
|
|
854
|
-
Ok(other) => Err(LifecycleError::RequirementUnmet(format!(
|
|
855
|
-
"profile_invalid_json: {} is not a JSON object (found {}); fix or remove the file (or restore a backup) and relaunch",
|
|
856
|
-
path.display(),
|
|
857
|
-
json_kind(&other)
|
|
858
|
-
))),
|
|
859
|
-
Err(error) => Err(LifecycleError::RequirementUnmet(format!(
|
|
860
|
-
"profile_invalid_json: {} could not be parsed: {error}; fix or remove the file (or restore a backup) and relaunch",
|
|
861
|
-
path.display()
|
|
862
|
-
))),
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
fn json_kind(value: &serde_json::Value) -> &'static str {
|
|
867
|
-
match value {
|
|
868
|
-
serde_json::Value::Null => "null",
|
|
869
|
-
serde_json::Value::Bool(_) => "a boolean",
|
|
870
|
-
serde_json::Value::Number(_) => "a number",
|
|
871
|
-
serde_json::Value::String(_) => "a string",
|
|
872
|
-
serde_json::Value::Array(_) => "an array",
|
|
873
|
-
serde_json::Value::Object(_) => "an object",
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
fn write_json_object(
|
|
878
|
-
path: &Path,
|
|
879
|
-
value: &serde_json::Map<String, serde_json::Value>,
|
|
880
|
-
) -> Result<(), LifecycleError> {
|
|
881
|
-
if let Some(parent) = path.parent() {
|
|
882
|
-
std::fs::create_dir_all(parent)
|
|
883
|
-
.map_err(|e| LifecycleError::StatePersist(format!("{}: {e}", parent.display())))?;
|
|
884
|
-
}
|
|
885
|
-
let body = serde_json::to_string_pretty(value)
|
|
886
|
-
.map_err(|e| LifecycleError::StatePersist(format!("serialize {}: {e}", path.display())))?;
|
|
887
|
-
std::fs::write(path, format!("{body}\n"))
|
|
888
|
-
.map_err(|e| LifecycleError::StatePersist(format!("{}: {e}", path.display())))?;
|
|
889
|
-
set_owner_only_permissions(path)
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
fn insert_if_missing(
|
|
893
|
-
map: &mut serde_json::Map<String, serde_json::Value>,
|
|
894
|
-
key: &str,
|
|
895
|
-
value: serde_json::Value,
|
|
896
|
-
) {
|
|
897
|
-
map.entry(key.to_string()).or_insert(value);
|
|
898
|
-
}
|
|
899
|
-
|
|
900
|
-
fn claude_project_keys(workspace: &Path) -> Vec<String> {
|
|
901
|
-
let mut keys = vec![workspace.to_string_lossy().to_string()];
|
|
902
|
-
if let Ok(resolved) = workspace.canonicalize() {
|
|
903
|
-
let resolved = resolved.to_string_lossy().to_string();
|
|
904
|
-
if !keys.iter().any(|key| key == &resolved) {
|
|
905
|
-
keys.push(resolved);
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
for key in keys.clone() {
|
|
909
|
-
if let Some(stripped) = key.strip_prefix("/private/var/") {
|
|
910
|
-
push_unique_string(&mut keys, format!("/var/{stripped}"));
|
|
911
|
-
} else if let Some(stripped) = key.strip_prefix("/var/") {
|
|
912
|
-
push_unique_string(&mut keys, format!("/private/var/{stripped}"));
|
|
913
|
-
}
|
|
914
|
-
}
|
|
915
|
-
keys
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
fn push_unique_string(values: &mut Vec<String>, value: String) {
|
|
919
|
-
if !values.iter().any(|existing| existing == &value) {
|
|
920
|
-
values.push(value);
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
fn compatible_api_network_exports(
|
|
925
|
-
auth_mode: AuthMode,
|
|
926
|
-
values: &BTreeMap<String, String>,
|
|
927
|
-
) -> BTreeMap<String, String> {
|
|
928
|
-
if auth_mode != AuthMode::CompatibleApi || profile_proxy_mode(values) == "direct" {
|
|
929
|
-
return BTreeMap::new();
|
|
930
|
-
}
|
|
931
|
-
COMPATIBLE_NETWORK_ENV_KEYS
|
|
932
|
-
.iter()
|
|
933
|
-
.filter_map(|key| {
|
|
934
|
-
values
|
|
935
|
-
.get(*key)
|
|
936
|
-
.filter(|value| !value.is_empty())
|
|
937
|
-
.map(|value| ((*key).to_string(), value.clone()))
|
|
938
|
-
})
|
|
939
|
-
.collect()
|
|
940
|
-
}
|
|
941
|
-
|
|
942
|
-
/// ---
|
|
943
|
-
/// purpose: 读出 profile 声明的代理模式
|
|
944
|
-
/// params:
|
|
945
|
-
/// values: 已解析的 profile 键值,先看 PROXY_MODE 再看 NETWORK_MODE
|
|
946
|
-
/// returns: 小写去空白后的模式串,两个键都没有时为 inherit
|
|
947
|
-
/// ---
|
|
948
|
-
pub(crate) fn profile_proxy_mode(values: &BTreeMap<String, String>) -> String {
|
|
949
|
-
values
|
|
950
|
-
.get("PROXY_MODE")
|
|
951
|
-
.or_else(|| values.get("NETWORK_MODE"))
|
|
952
|
-
.map(|value| value.trim().to_ascii_lowercase())
|
|
953
|
-
.unwrap_or_else(|| "inherit".to_string())
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
fn required_profile_keys(provider: Provider, auth_mode: AuthMode) -> &'static [&'static str] {
|
|
957
|
-
if auth_mode == AuthMode::Subscription {
|
|
958
|
-
return &[];
|
|
959
|
-
}
|
|
960
|
-
match provider {
|
|
961
|
-
Provider::Claude | Provider::ClaudeCode => match auth_mode {
|
|
962
|
-
AuthMode::OfficialApi => &["API_KEY"],
|
|
963
|
-
AuthMode::CompatibleApi => &["BASE_URL", "API_KEY"],
|
|
964
|
-
AuthMode::Subscription => &[],
|
|
965
|
-
},
|
|
966
|
-
Provider::GeminiCli => &["API_KEY"],
|
|
967
|
-
// C-7-1 cr verdict: copilot 一期 subscription-only,无 BYOK required key 集合;
|
|
968
|
-
// 二期 BYOK 立项时填(向后兼容字段保留)。
|
|
969
|
-
Provider::Copilot => &[],
|
|
970
|
-
// Codex/Grok worker 只走 subscription-only contract leaf;Pi 一期无 BYOK
|
|
971
|
-
// required key 集合 (同 copilot 精神)。
|
|
972
|
-
Provider::Codex | Provider::Grok | Provider::Pi => &[],
|
|
973
|
-
Provider::Fake => &[],
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
/// ---
|
|
978
|
-
/// purpose: 取 profile 里某个规范键,取不到时按该键的已知别名回退
|
|
979
|
-
/// params:
|
|
980
|
-
/// key: 规范键名,API_KEY BASE_URL MODEL 各有一组别名,其余键不回退
|
|
981
|
-
/// returns: 命中的非空值
|
|
982
|
-
/// ---
|
|
983
|
-
pub(crate) fn profile_value_or_alternate<'a>(
|
|
984
|
-
values: &'a BTreeMap<String, String>,
|
|
985
|
-
key: &str,
|
|
986
|
-
) -> Option<&'a str> {
|
|
987
|
-
values
|
|
988
|
-
.get(key)
|
|
989
|
-
.filter(|value| !value.is_empty())
|
|
990
|
-
.map(String::as_str)
|
|
991
|
-
.or_else(|| {
|
|
992
|
-
match key {
|
|
993
|
-
"API_KEY" => values
|
|
994
|
-
.get("ANTHROPIC_API_KEY")
|
|
995
|
-
.or_else(|| values.get("ANTHROPIC_AUTH_TOKEN"))
|
|
996
|
-
.or_else(|| values.get("AUTH_TOKEN"))
|
|
997
|
-
.or_else(|| values.get("CLAUDE_API_KEY"))
|
|
998
|
-
.or_else(|| values.get("CLAUDE_AUTH_TOKEN"))
|
|
999
|
-
.or_else(|| values.get("BEARER_TOKEN"))
|
|
1000
|
-
.or_else(|| values.get("TEAM_AGENT_PROVIDER_API_KEY"))
|
|
1001
|
-
.or_else(|| values.get("OPENAI_API_KEY")),
|
|
1002
|
-
"BASE_URL" => values
|
|
1003
|
-
.get("ANTHROPIC_BASE_URL")
|
|
1004
|
-
.or_else(|| values.get("OPENAI_BASE_URL")),
|
|
1005
|
-
"MODEL" => values.get("ANTHROPIC_MODEL"),
|
|
1006
|
-
_ => None,
|
|
1007
|
-
}
|
|
1008
|
-
.filter(|value| !value.is_empty())
|
|
1009
|
-
.map(String::as_str)
|
|
1010
|
-
})
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
/// ---
|
|
1014
|
-
/// purpose: 在两个显式给定的键之间取第一个非空值
|
|
1015
|
-
/// returns: 命中的非空值,两个都空则 None
|
|
1016
|
-
/// ---
|
|
1017
|
-
pub(crate) fn value_or_alternate<'a>(
|
|
1018
|
-
values: &'a BTreeMap<String, String>,
|
|
1019
|
-
primary: &str,
|
|
1020
|
-
alternate: &str,
|
|
1021
|
-
) -> Option<&'a str> {
|
|
1022
|
-
values
|
|
1023
|
-
.get(primary)
|
|
1024
|
-
.filter(|value| !value.is_empty())
|
|
1025
|
-
.or_else(|| values.get(alternate).filter(|value| !value.is_empty()))
|
|
1026
|
-
.map(String::as_str)
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
/// ---
|
|
1030
|
-
/// purpose: 取 profile 里声明的模型名
|
|
1031
|
-
/// returns: MODEL 的非空值,没有时取 ANTHROPIC_MODEL
|
|
1032
|
-
/// ---
|
|
1033
|
-
pub(crate) fn profile_model(values: &BTreeMap<String, String>) -> Option<&str> {
|
|
1034
|
-
values
|
|
1035
|
-
.get("MODEL")
|
|
1036
|
-
.filter(|value| !value.is_empty())
|
|
1037
|
-
.or_else(|| {
|
|
1038
|
-
values
|
|
1039
|
-
.get("ANTHROPIC_MODEL")
|
|
1040
|
-
.filter(|value| !value.is_empty())
|
|
1041
|
-
})
|
|
1042
|
-
.map(String::as_str)
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
fn effective_profile_or_agent_model<'a>(
|
|
1046
|
-
agent: &'a AgentProfileInput,
|
|
1047
|
-
values: &'a BTreeMap<String, String>,
|
|
1048
|
-
) -> Option<&'a str> {
|
|
1049
|
-
agent.model.as_deref().or_else(|| profile_model(values))
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
pub(crate) use crate::provider::wire::parse_provider;
|
|
1053
|
-
|
|
1054
|
-
/// ---
|
|
1055
|
-
/// purpose: 把 auth_mode 字符串解析成枚举
|
|
1056
|
-
/// params:
|
|
1057
|
-
/// raw: 只接受 subscription、official_api、compatible_api
|
|
1058
|
-
/// returns: 对应枚举;未知取值返回 None,由调用方决定兜底
|
|
1059
|
-
/// ---
|
|
1060
|
-
pub(crate) fn parse_auth_mode(raw: &str) -> Option<AuthMode> {
|
|
1061
|
-
match raw {
|
|
1062
|
-
"subscription" => Some(AuthMode::Subscription),
|
|
1063
|
-
"official_api" => Some(AuthMode::OfficialApi),
|
|
1064
|
-
"compatible_api" => Some(AuthMode::CompatibleApi),
|
|
1065
|
-
_ => None,
|
|
1066
|
-
}
|
|
1067
|
-
}
|