@team-agent/installer 0.5.124 → 0.5.126
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/Cargo.lock +1 -8
- package/Cargo.toml +1 -1
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/crates/team-agent/Cargo.toml +0 -1
- package/crates/team-agent/src/cli/diagnose.rs +39 -69
- package/crates/team-agent/src/cli/emit.rs +45 -15
- package/crates/team-agent/src/cli/intent/runtime.rs +5 -53
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +10 -130
- package/crates/team-agent/src/cli/leader.rs +2 -3
- package/crates/team-agent/src/cli/leader_prompt.rs +1 -1
- package/crates/team-agent/src/cli/mod.rs +28 -33
- package/crates/team-agent/src/cli/models.rs +44 -880
- package/crates/team-agent/src/cli/route.rs +1 -1
- package/crates/team-agent/src/cli/send/persist.rs +36 -0
- package/crates/team-agent/src/cli/send/presentation.rs +7 -1
- package/crates/team-agent/src/cli/send.rs +3 -1
- package/crates/team-agent/src/cli/spec.rs +1 -2
- package/crates/team-agent/src/cli/status_port/brief.rs +66 -0
- package/crates/team-agent/src/cli/tests/base.rs +4 -11
- package/crates/team-agent/src/cli/tests/mod.rs +1 -1
- package/crates/team-agent/src/cli/tests/run_delegation.rs +5 -4
- package/crates/team-agent/src/cli/tests/status_send.rs +17 -0
- package/crates/team-agent/src/compiler/tests.rs +39 -8
- package/crates/team-agent/src/compiler.rs +28 -204
- package/crates/team-agent/src/contract_runtime/backend.rs +79 -40
- package/crates/team-agent/src/contract_runtime/config.rs +37 -24
- package/crates/team-agent/src/contract_runtime/discovery.rs +33 -0
- package/crates/team-agent/src/contract_runtime/fork.rs +368 -0
- package/crates/team-agent/src/contract_runtime/framework.rs +87 -34
- package/crates/team-agent/src/contract_runtime/mod.rs +1 -0
- package/crates/team-agent/src/contract_runtime/registry.rs +299 -21
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -1
- package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +29 -8
- package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -42
- package/crates/team-agent/src/coordinator/tick.rs +89 -1
- package/crates/team-agent/src/db/message_store.rs +78 -3
- package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -1
- package/crates/team-agent/src/leader/prompt.rs +1 -2
- package/crates/team-agent/src/leader/provider_attribution.rs +0 -52
- package/crates/team-agent/src/leader/start.rs +1 -2
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +2 -3
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +91 -0
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +15 -195
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -9
- package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +11 -27
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +18 -29
- package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +6 -87
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +3 -11
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +74 -244
- package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -24
- package/crates/team-agent/src/lifecycle/launch/role_source.rs +5 -0
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +21 -61
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -1
- package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -108
- package/crates/team-agent/src/lifecycle/launch.rs +2 -43
- package/crates/team-agent/src/lifecycle/profile_launch.rs +21 -348
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +1 -2
- package/crates/team-agent/src/lifecycle/restart/common.rs +43 -378
- package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
- package/crates/team-agent/src/lifecycle/restart.rs +0 -2
- package/crates/team-agent/src/lifecycle/role_config.rs +42 -3
- package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +11 -6
- package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +8 -320
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +60 -145
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +8 -334
- package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +30 -11
- package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/core.rs +17 -16
- package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +12 -12
- package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +3 -51
- package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +26 -28
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +6 -18
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +52 -70
- package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +4 -157
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +10 -302
- package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +1 -68
- package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +1 -19
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +2 -100
- package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +11 -10
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1
- package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +2 -106
- package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +2 -2
- package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +2 -254
- package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +4 -4
- package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +6 -5
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +7 -153
- package/crates/team-agent/src/lifecycle/tests.rs +0 -6
- package/crates/team-agent/src/lifecycle/types.rs +2 -18
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +2 -4
- package/crates/team-agent/src/mcp_server/readiness.rs +148 -97
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +115 -16
- package/crates/team-agent/src/messaging/delivery.rs +185 -168
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
- package/crates/team-agent/src/messaging/enter_rescue_tests.rs +1 -1
- package/crates/team-agent/src/messaging/helpers.rs +19 -0
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +67 -5
- package/crates/team-agent/src/messaging/tests/runtime.rs +110 -4
- package/crates/team-agent/src/messaging/tests/spine.rs +46 -36
- package/crates/team-agent/src/model/enums.rs +1 -8
- package/crates/team-agent/src/provider/adapter.rs +33 -302
- package/crates/team-agent/src/provider/adapters/mod.rs +4 -5
- package/crates/team-agent/src/provider/argv_route.rs +1 -5
- package/crates/team-agent/src/provider/bypass_flags.rs +3 -11
- package/crates/team-agent/src/provider/classify.rs +68 -3
- package/crates/team-agent/src/provider/faults.rs +1 -1
- package/crates/team-agent/src/provider/model_catalog.rs +14 -273
- package/crates/team-agent/src/provider/session/capture.rs +7 -107
- package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -4
- package/crates/team-agent/src/provider/session/context_fork.rs +17 -109
- package/crates/team-agent/src/provider/session_scan/common.rs +11 -36
- package/crates/team-agent/src/provider/session_scan/pi.rs +1 -34
- package/crates/team-agent/src/provider/session_scan.rs +4 -14
- package/crates/team-agent/src/provider/submit_now.rs +5 -28
- package/crates/team-agent/src/provider/tests/adapter.rs +39 -275
- package/crates/team-agent/src/provider/tests/classify.rs +53 -0
- package/crates/team-agent/src/provider/tests/command_helpers.rs +3 -15
- package/crates/team-agent/src/provider/tests/idle.rs +0 -25
- package/crates/team-agent/src/provider/types.rs +1 -1
- package/crates/team-agent/src/provider/wire.rs +79 -11
- package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +1 -1
- package/crates/team-agent/src/state/persist.rs +6 -6
- package/crates/team-agent/src/state/repository/tests.rs +2 -2
- package/crates/team-agent/src/tmux_backend/native_input_tests.rs +2 -178
- package/crates/team-agent/src/tmux_backend/tests.rs +151 -0
- package/crates/team-agent/src/tmux_backend.rs +43 -8
- package/crates/team-agent/src/transport/native_input.rs +2 -231
- package/package.json +4 -4
- package/skills/team-agent/SKILL.md +7 -5
- package/skills/team-agent/command-coverage.json +15 -1
- package/skills/team-agent/docs/reference/team-agent-operator.md +5 -3
- package/skills/team-agent/references/team-agent-operator.md +5 -3
- package/crates/team-agent/src/lifecycle/launch/cursor_create_chat.rs +0 -229
- package/crates/team-agent/src/lifecycle/launch/cursor_mcp.rs +0 -522
- package/crates/team-agent/src/lifecycle/launch/cursor_mcp_iso.rs +0 -282
- package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1805
- package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
- package/crates/team-agent/src/lifecycle/tests/cursor_mcp_overlay.rs +0 -576
- package/crates/team-agent/src/lifecycle/tests/cursor_require_explicit_model_red.rs +0 -222
- package/crates/team-agent/src/lifecycle/tests/cursor_restart_resume_red.rs +0 -511
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1409
- 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/cursor_agent.rs +0 -44
- package/crates/team-agent/src/provider/adapters/pi.rs +0 -100
- package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
- package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
- package/crates/team-agent/src/provider/session_scan/cursor.rs +0 -538
- package/crates/team-agent/src/provider/testdata/cursor-list-models-native.stdout +0 -250
- package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
|
@@ -8,8 +8,6 @@
|
|
|
8
8
|
//! what: 按 bypass 结论写或清 MCP 自动放行相关变量
|
|
9
9
|
//! - name: apply_copilot_instructions_overlay
|
|
10
10
|
//! what: 把角色提示词写成 per-agent 的 AGENTS.md 并指向它
|
|
11
|
-
//! - name: apply_cursor_agent_rules_overlay
|
|
12
|
-
//! what: 把角色提示词写成 workspace 内 per-agent 的 cursor rules 文件
|
|
13
11
|
//! - name: fill_spawn_placeholders_full
|
|
14
12
|
//! what: 替换 argv 里的 workspace、agent_id 与 team_id 占位符
|
|
15
13
|
//! depends:
|
|
@@ -254,42 +252,6 @@ pub(crate) fn apply_copilot_instructions_overlay(
|
|
|
254
252
|
Ok(())
|
|
255
253
|
}
|
|
256
254
|
|
|
257
|
-
/// ---
|
|
258
|
-
/// purpose: 把角色提示词写成 workspace 内 per-agent 的 cursor rules 文件
|
|
259
|
-
/// params:
|
|
260
|
-
/// system_prompt: 写入 rules 正文,文件头声明 alwaysApply
|
|
261
|
-
/// returns: 成功返回空值
|
|
262
|
-
/// errors: 建目录或写文件失败时返回 StatePersist
|
|
263
|
-
/// ---
|
|
264
|
-
/// 0.5.67 Cursor append-system-prompt 方案 1 变体(冒烟 PASS, see
|
|
265
|
-
/// .team/artifacts/0.5.67-cursor-rules-smoke.md)— Cursor `agent` CLI 无
|
|
266
|
-
/// append/rule CLI flag, 只从 workspace 静态 rules 文件读:
|
|
267
|
-
/// `.cursor/rules/**/*.mdc` (alwaysApply: true) / `AGENTS.md` / `.cursorrules`。
|
|
268
|
-
///
|
|
269
|
-
/// 这里在 launch 路径写 `<workspace>/.cursor/rules/team-agent-role-<agent_id>.mdc`
|
|
270
|
-
/// 并把 role(= compile_worker_system_prompt 输出)放进去, argv 只带
|
|
271
|
-
/// `--workspace <workspace>`(cursor_agent.rs)。cursor CLI 读取该目录即加载 role。
|
|
272
|
-
///
|
|
273
|
-
/// 目录布局为 workspace 内 `.cursor/rules/`(Cursor 唯一 rules 通道; 无法像 copilot
|
|
274
|
-
/// 那样放 `.team/runtime/` —— 那是 Cursor 不读的路径)。文件名含 `<agent_id>`
|
|
275
|
-
/// 保证 per-agent 隔离, 不互相污染。
|
|
276
|
-
pub(crate) fn apply_cursor_agent_rules_overlay(
|
|
277
|
-
workspace: &Path,
|
|
278
|
-
agent_id: &str,
|
|
279
|
-
system_prompt: &str,
|
|
280
|
-
) -> Result<(), LifecycleError> {
|
|
281
|
-
let dir = workspace.join(".cursor").join("rules");
|
|
282
|
-
std::fs::create_dir_all(&dir)
|
|
283
|
-
.map_err(|e| LifecycleError::StatePersist(format!("{}: {e}", dir.display())))?;
|
|
284
|
-
let rules = dir.join(format!("team-agent-role-{agent_id}.mdc"));
|
|
285
|
-
let content = format!(
|
|
286
|
-
"---\ndescription: Team Agent role injection (auto-generated)\nalwaysApply: true\n---\n\n{system_prompt}\n"
|
|
287
|
-
);
|
|
288
|
-
std::fs::write(&rules, content.as_bytes())
|
|
289
|
-
.map_err(|e| LifecycleError::StatePersist(format!("{}: {e}", rules.display())))?;
|
|
290
|
-
Ok(())
|
|
291
|
-
}
|
|
292
|
-
|
|
293
255
|
/// ---
|
|
294
256
|
/// purpose: 扫出 copilot 侧残留的 MCP server,对非本框架的逐个追加禁用参数
|
|
295
257
|
/// params:
|
|
@@ -450,76 +412,6 @@ pub(super) fn parse_copilot_mcp_list_server_names(text: &str) -> Vec<String> {
|
|
|
450
412
|
out
|
|
451
413
|
}
|
|
452
414
|
|
|
453
|
-
/// Subscription seats inherit parent env, but that is implicit. Cursor cloud
|
|
454
|
-
/// on this host is blocked without a proxy; `profile_launch` copies these
|
|
455
|
-
/// keys only on the compatible-api path. Copy them explicitly here so a
|
|
456
|
-
/// subscription cursor seat sees the same keys. Values may contain
|
|
457
|
-
/// credentials — callers must only log presence/length, never the value.
|
|
458
|
-
const CURSOR_PROXY_KEYS: &[&str] = &[
|
|
459
|
-
"HTTPS_PROXY",
|
|
460
|
-
"HTTP_PROXY",
|
|
461
|
-
"ALL_PROXY",
|
|
462
|
-
"NO_PROXY",
|
|
463
|
-
"https_proxy",
|
|
464
|
-
"http_proxy",
|
|
465
|
-
"all_proxy",
|
|
466
|
-
"no_proxy",
|
|
467
|
-
];
|
|
468
|
-
|
|
469
|
-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
|
470
|
-
pub struct CursorProxyPresence {
|
|
471
|
-
pub https_proxy: bool,
|
|
472
|
-
pub no_proxy: bool,
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/// ---
|
|
476
|
-
/// purpose: 给订阅制 cursor 席位显式补上父进程里的代理变量
|
|
477
|
-
/// params:
|
|
478
|
-
/// env: 就地补键,已有同名键不覆盖
|
|
479
|
-
/// returns: 记录是否存在 https 代理与 no_proxy,只记存在与否不记值
|
|
480
|
-
/// ---
|
|
481
|
-
pub fn apply_cursor_subscription_proxy_env(
|
|
482
|
-
env: &mut BTreeMap<String, String>,
|
|
483
|
-
) -> CursorProxyPresence {
|
|
484
|
-
let mut https_proxy = false;
|
|
485
|
-
let mut no_proxy = false;
|
|
486
|
-
for key in CURSOR_PROXY_KEYS {
|
|
487
|
-
let Ok(value) = std::env::var(key) else {
|
|
488
|
-
continue;
|
|
489
|
-
};
|
|
490
|
-
if value.is_empty() {
|
|
491
|
-
continue;
|
|
492
|
-
}
|
|
493
|
-
if key.eq_ignore_ascii_case("HTTPS_PROXY") {
|
|
494
|
-
https_proxy = true;
|
|
495
|
-
}
|
|
496
|
-
if key.eq_ignore_ascii_case("NO_PROXY") {
|
|
497
|
-
no_proxy = true;
|
|
498
|
-
}
|
|
499
|
-
env.entry((*key).to_string()).or_insert(value);
|
|
500
|
-
}
|
|
501
|
-
CursorProxyPresence {
|
|
502
|
-
https_proxy,
|
|
503
|
-
no_proxy,
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
pub(crate) fn apply_cursor_subscription_proxy_env_with_profile(
|
|
508
|
-
env: &mut BTreeMap<String, String>,
|
|
509
|
-
profile_launch: &crate::provider::ProviderProfileLaunch,
|
|
510
|
-
) -> CursorProxyPresence {
|
|
511
|
-
if crate::lifecycle::profile_launch::cursor_subscription_direct_mode(profile_launch) {
|
|
512
|
-
for key in &profile_launch.env_unset {
|
|
513
|
-
env.remove(key);
|
|
514
|
-
}
|
|
515
|
-
return CursorProxyPresence {
|
|
516
|
-
https_proxy: false,
|
|
517
|
-
no_proxy: env.keys().any(|key| key.eq_ignore_ascii_case("NO_PROXY")),
|
|
518
|
-
};
|
|
519
|
-
}
|
|
520
|
-
apply_cursor_subscription_proxy_env(env)
|
|
521
|
-
}
|
|
522
|
-
|
|
523
415
|
/// ---
|
|
524
416
|
/// purpose: 把 profile 推出的环境清除与覆盖套用到 spawn 环境上
|
|
525
417
|
/// params:
|
|
@@ -23,15 +23,6 @@ use crate::transport::{PaneId, SessionName, Target, Transport, WindowName};
|
|
|
23
23
|
|
|
24
24
|
use crate::lifecycle::lock::{acquire_agent_lifecycle_lock, LifecycleLockRequest};
|
|
25
25
|
|
|
26
|
-
#[derive(Clone, Debug)]
|
|
27
|
-
pub(crate) struct ForkCaptureSeed {
|
|
28
|
-
pub source_agent_id: AgentId,
|
|
29
|
-
pub captured: crate::provider::CapturedSession,
|
|
30
|
-
pub captured_at: String,
|
|
31
|
-
pub pi_sessions_root: PathBuf,
|
|
32
|
-
pub profile_dir: PathBuf,
|
|
33
|
-
}
|
|
34
|
-
|
|
35
26
|
use super::*;
|
|
36
27
|
|
|
37
28
|
// ── lifecycle::launch —— 冷启 / quick-start / 危险审批探测 ──────────────────
|
|
@@ -360,47 +351,15 @@ pub(crate) use mcp_config::{
|
|
|
360
351
|
|
|
361
352
|
pub(crate) mod pi_mcp;
|
|
362
353
|
|
|
363
|
-
pub(crate) fn run_pi_catalog_preflight(
|
|
364
|
-
agents_dir: &std::path::Path,
|
|
365
|
-
discover: &mut dyn FnMut(&str) -> Result<Vec<String>, ()>,
|
|
366
|
-
) -> Result<(), crate::lifecycle::LifecycleError> {
|
|
367
|
-
crate::compiler::preflight_pi_models_in_team_with(agents_dir, discover).map_err(|error| {
|
|
368
|
-
crate::lifecycle::LifecycleError::PiModelPreflight {
|
|
369
|
-
requested: error.requested,
|
|
370
|
-
candidates: error.candidates,
|
|
371
|
-
action: error.action,
|
|
372
|
-
not_ready: error.not_ready,
|
|
373
|
-
}
|
|
374
|
-
})
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
mod cursor_mcp_iso;
|
|
378
|
-
pub(crate) use cursor_mcp_iso::cursor_mcp_primary_matches_scope;
|
|
379
|
-
pub use cursor_mcp_iso::{
|
|
380
|
-
cursor_mcp_isolation_enabled, cursor_mcp_json_path, cursor_mcp_project_dir,
|
|
381
|
-
materialize_cursor_mcp_project,
|
|
382
|
-
};
|
|
383
|
-
mod cursor_mcp;
|
|
384
|
-
pub(crate) use cursor_mcp::apply_cursor_mcp_enable_profile_env;
|
|
385
|
-
pub use cursor_mcp::{
|
|
386
|
-
apply_cursor_mcp_overlay, apply_cursor_spawn_workspace_pointers,
|
|
387
|
-
apply_cursor_workspace_physical_path, cursor_mcp_enable_argv, cursor_mcp_enable_working_dir,
|
|
388
|
-
enable_cursor_workspace_mcp, enable_cursor_workspace_mcp_with_profile, physical_workspace_path,
|
|
389
|
-
prepare_cursor_seat_mcp, refuse_second_cursor_occupant,
|
|
390
|
-
};
|
|
391
|
-
|
|
392
|
-
mod cursor_create_chat;
|
|
393
|
-
|
|
394
354
|
mod worker_env;
|
|
395
355
|
pub(super) use worker_env::*;
|
|
396
356
|
pub(crate) use worker_env::{
|
|
397
|
-
apply_copilot_instructions_overlay,
|
|
398
|
-
|
|
357
|
+
apply_copilot_instructions_overlay,
|
|
358
|
+
apply_mcp_auto_approval_env,
|
|
399
359
|
apply_profile_launch_env, auth_mode_env_value, fill_spawn_placeholders,
|
|
400
360
|
fill_spawn_placeholders_full, inherited_env_with_team_overrides, persist_command_plan_state,
|
|
401
361
|
spawn_timestamp,
|
|
402
362
|
};
|
|
403
|
-
pub use worker_env::{apply_cursor_subscription_proxy_env, CursorProxyPresence};
|
|
404
363
|
|
|
405
364
|
mod identity;
|
|
406
365
|
pub(super) use identity::*;
|
|
@@ -47,26 +47,6 @@ const COMPATIBLE_NETWORK_ENV_KEYS: &[&str] = &[
|
|
|
47
47
|
"REQUESTS_CA_BUNDLE",
|
|
48
48
|
];
|
|
49
49
|
|
|
50
|
-
// Cursor subscription direct mode removes only proxy URL inputs. NO_PROXY is
|
|
51
|
-
// deliberately retained: it is a bypass list, not a proxy endpoint, and the
|
|
52
|
-
// observed catalog failure came from the GLOBAL_AGENT proxy URL settings.
|
|
53
|
-
const CURSOR_DIRECT_PROXY_ENV_KEYS: &[&str] = &[
|
|
54
|
-
"HTTPS_PROXY",
|
|
55
|
-
"HTTP_PROXY",
|
|
56
|
-
"ALL_PROXY",
|
|
57
|
-
"https_proxy",
|
|
58
|
-
"http_proxy",
|
|
59
|
-
"all_proxy",
|
|
60
|
-
"GLOBAL_AGENT_HTTPS_PROXY",
|
|
61
|
-
"GLOBAL_AGENT_HTTP_PROXY",
|
|
62
|
-
];
|
|
63
|
-
|
|
64
|
-
pub(crate) fn cursor_subscription_direct_mode(profile_launch: &ProviderProfileLaunch) -> bool {
|
|
65
|
-
CURSOR_DIRECT_PROXY_ENV_KEYS
|
|
66
|
-
.iter()
|
|
67
|
-
.all(|key| profile_launch.env_unset.contains(*key))
|
|
68
|
-
}
|
|
69
|
-
|
|
70
50
|
#[derive(Debug, Clone)]
|
|
71
51
|
pub(crate) struct ProfileValues {
|
|
72
52
|
pub(crate) path: PathBuf,
|
|
@@ -117,6 +97,9 @@ pub(crate) fn prepare_provider_profile_launch_with_profile_dir(
|
|
|
117
97
|
profile_dir: Option<&Path>,
|
|
118
98
|
mcp_config: Option<&McpConfig>,
|
|
119
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
|
+
}
|
|
120
103
|
let input = AgentProfileInput {
|
|
121
104
|
id: agent
|
|
122
105
|
.get("id")
|
|
@@ -170,6 +153,9 @@ pub(crate) fn prepare_provider_profile_launch_from_json(
|
|
|
170
153
|
agent: &serde_json::Value,
|
|
171
154
|
mcp_config: Option<&McpConfig>,
|
|
172
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
|
+
}
|
|
173
159
|
let input = AgentProfileInput {
|
|
174
160
|
id: agent
|
|
175
161
|
.get("id")
|
|
@@ -219,9 +205,6 @@ fn prepare_profile_launch(
|
|
|
219
205
|
return Ok(ProviderProfileLaunch::default());
|
|
220
206
|
};
|
|
221
207
|
let Some(path) = find_profile_file(workspace, profile, agent.profile_dir.as_deref()) else {
|
|
222
|
-
if agent.provider == Provider::Pi && agent.auth_mode == AuthMode::Subscription {
|
|
223
|
-
return Ok(ProviderProfileLaunch::default());
|
|
224
|
-
}
|
|
225
208
|
return Err(profile_not_found(profile));
|
|
226
209
|
};
|
|
227
210
|
let loaded = read_profile_file(path)?;
|
|
@@ -229,26 +212,8 @@ fn prepare_profile_launch(
|
|
|
229
212
|
|
|
230
213
|
let mut env_overlay = provider_env_exports(agent.provider, agent.auth_mode, &loaded.values);
|
|
231
214
|
let mut env_unset = provider_env_unsets(agent.provider, agent.auth_mode);
|
|
232
|
-
|
|
233
|
-
let
|
|
234
|
-
let mut managed_mcp_config = false;
|
|
235
|
-
|
|
236
|
-
if matches!(agent.provider, Provider::Claude | Provider::ClaudeCode)
|
|
237
|
-
&& agent.auth_mode == AuthMode::CompatibleApi
|
|
238
|
-
{
|
|
239
|
-
let dir = compatible_claude_config_dir(workspace, &agent.id)?;
|
|
240
|
-
if let Some(config) = mcp_config {
|
|
241
|
-
ensure_compatible_claude_mcp_config(&dir, workspace, config)?;
|
|
242
|
-
managed_mcp_config = true;
|
|
243
|
-
}
|
|
244
|
-
let projects_root = dir.join("projects");
|
|
245
|
-
env_overlay.insert(
|
|
246
|
-
"CLAUDE_CONFIG_DIR".to_string(),
|
|
247
|
-
dir.to_string_lossy().to_string(),
|
|
248
|
-
);
|
|
249
|
-
claude_projects_root = Some(projects_root);
|
|
250
|
-
claude_config_dir = Some(dir);
|
|
251
|
-
}
|
|
215
|
+
// Claude Code's compatible-API config dir went with its legacy worker runtime.
|
|
216
|
+
let _ = mcp_config;
|
|
252
217
|
|
|
253
218
|
env_overlay.extend(compatible_api_network_exports(
|
|
254
219
|
agent.auth_mode,
|
|
@@ -261,16 +226,6 @@ fn prepare_profile_launch(
|
|
|
261
226
|
env_overlay.remove(*key);
|
|
262
227
|
}
|
|
263
228
|
}
|
|
264
|
-
if agent.provider == Provider::CursorAgent
|
|
265
|
-
&& agent.auth_mode == AuthMode::Subscription
|
|
266
|
-
&& profile_proxy_mode(&loaded.values) == "direct"
|
|
267
|
-
{
|
|
268
|
-
for key in CURSOR_DIRECT_PROXY_ENV_KEYS {
|
|
269
|
-
env_unset.insert((*key).to_string());
|
|
270
|
-
env_overlay.remove(*key);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
|
|
274
229
|
let command_overrides = provider_command_overrides(&agent, &loaded.values);
|
|
275
230
|
write_runtime_env_file(workspace, &agent.id, &env_overlay, &env_unset)?;
|
|
276
231
|
|
|
@@ -278,9 +233,9 @@ fn prepare_profile_launch(
|
|
|
278
233
|
env_overlay,
|
|
279
234
|
env_unset,
|
|
280
235
|
command_overrides,
|
|
281
|
-
claude_config_dir,
|
|
282
|
-
claude_projects_root,
|
|
283
|
-
managed_mcp_config,
|
|
236
|
+
claude_config_dir: None,
|
|
237
|
+
claude_projects_root: None,
|
|
238
|
+
managed_mcp_config: false,
|
|
284
239
|
})
|
|
285
240
|
}
|
|
286
241
|
|
|
@@ -463,19 +418,6 @@ fn provider_env_exports(
|
|
|
463
418
|
return exports;
|
|
464
419
|
}
|
|
465
420
|
match provider {
|
|
466
|
-
Provider::Claude | Provider::ClaudeCode => {
|
|
467
|
-
append_env_pair(&mut exports, "ANTHROPIC_BASE_URL", value_or_alternate(values, "ANTHROPIC_BASE_URL", "BASE_URL"));
|
|
468
|
-
if auth_mode == AuthMode::OfficialApi {
|
|
469
|
-
append_env_pair(&mut exports, "ANTHROPIC_API_KEY", value_or_alternate(values, "ANTHROPIC_API_KEY", "API_KEY"));
|
|
470
|
-
}
|
|
471
|
-
append_env_pair(&mut exports, "ANTHROPIC_AUTH_TOKEN", value_or_alternate(values, "ANTHROPIC_AUTH_TOKEN", "AUTH_TOKEN")
|
|
472
|
-
.or_else(|| {
|
|
473
|
-
(auth_mode == AuthMode::CompatibleApi)
|
|
474
|
-
.then(|| value_or_alternate(values, "ANTHROPIC_API_KEY", "API_KEY"))
|
|
475
|
-
.flatten()
|
|
476
|
-
}));
|
|
477
|
-
append_env_pair(&mut exports, "ANTHROPIC_MODEL", profile_model(values));
|
|
478
|
-
}
|
|
479
421
|
Provider::Codex => {
|
|
480
422
|
let key = value_or_alternate(values, "OPENAI_API_KEY", "API_KEY");
|
|
481
423
|
append_env_pair(&mut exports, "TEAM_AGENT_PROVIDER_API_KEY", key);
|
|
@@ -504,9 +446,9 @@ fn provider_env_exports(
|
|
|
504
446
|
}
|
|
505
447
|
}
|
|
506
448
|
}
|
|
507
|
-
//
|
|
508
|
-
//
|
|
509
|
-
Provider::
|
|
449
|
+
// Grok retains its native subscription credentials. Claude Code and Pi
|
|
450
|
+
// workers run only through their subscription-only contract leaves.
|
|
451
|
+
Provider::Claude | Provider::ClaudeCode | Provider::Grok | Provider::Pi => {}
|
|
510
452
|
Provider::Fake => {}
|
|
511
453
|
}
|
|
512
454
|
exports
|
|
@@ -527,11 +469,8 @@ mod append_env_contract {
|
|
|
527
469
|
let map = |pairs: &[(&str, &str)]| -> BTreeMap<String, String> {
|
|
528
470
|
pairs.iter().map(|(k, v)| (k.to_string(), v.to_string())).collect()
|
|
529
471
|
};
|
|
530
|
-
for provider in [Provider::Claude, Provider::ClaudeCode] {
|
|
531
|
-
|
|
532
|
-
("ANTHROPIC_BASE_URL", " raw\nbase "), ("ANTHROPIC_API_KEY", "dummy"),
|
|
533
|
-
("ANTHROPIC_AUTH_TOKEN", "dummy-token"), ("ANTHROPIC_MODEL", " raw model "),
|
|
534
|
-
]));
|
|
472
|
+
for provider in [Provider::Claude, Provider::ClaudeCode, Provider::Pi] {
|
|
473
|
+
assert!(provider_env_exports(provider, AuthMode::OfficialApi, &values).is_empty());
|
|
535
474
|
}
|
|
536
475
|
assert_eq!(provider_env_exports(Provider::Codex, AuthMode::CompatibleApi, &values), map(&[
|
|
537
476
|
("TEAM_AGENT_PROVIDER_API_KEY", "native-dummy"), ("OPENAI_API_KEY", "native-dummy"),
|
|
@@ -611,11 +550,8 @@ pub(crate) fn provider_env_unsets(provider: Provider, auth_mode: AuthMode) -> BT
|
|
|
611
550
|
// C-7-1 cr verdict: 一期 subscription-only(已登录态),exports/unsets 空;
|
|
612
551
|
// BYOK(COPILOT_PROVIDER_*)二期立项时单独 cr verdict 再开。
|
|
613
552
|
Provider::Copilot => {}
|
|
614
|
-
//
|
|
615
|
-
// `--print` 路径会因 https:// 方案撞 GLOBAL_AGENT,但主路径是 TUI。
|
|
616
|
-
// 禁止在这里 unset 代理。
|
|
553
|
+
// Grok has no provider-specific environment to unset.
|
|
617
554
|
Provider::Grok => {}
|
|
618
|
-
Provider::CursorAgent => {}
|
|
619
555
|
Provider::Pi => {}
|
|
620
556
|
Provider::Fake => {}
|
|
621
557
|
}
|
|
@@ -731,270 +667,6 @@ fn shell_quote(value: &str) -> String {
|
|
|
731
667
|
format!("'{}'", value.replace('\'', "'\"'\"'"))
|
|
732
668
|
}
|
|
733
669
|
|
|
734
|
-
fn compatible_claude_config_dir(
|
|
735
|
-
workspace: &Path,
|
|
736
|
-
agent_id: &str,
|
|
737
|
-
) -> Result<PathBuf, LifecycleError> {
|
|
738
|
-
let dir = workspace
|
|
739
|
-
.join(".team/runtime/provider-config")
|
|
740
|
-
.join(agent_id)
|
|
741
|
-
.join("claude");
|
|
742
|
-
std::fs::create_dir_all(&dir)
|
|
743
|
-
.map_err(|e| LifecycleError::StatePersist(format!("{}: {e}", dir.display())))?;
|
|
744
|
-
ensure_compatible_claude_config(&dir, workspace)?;
|
|
745
|
-
Ok(dir)
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
fn ensure_compatible_claude_config(dir: &Path, workspace: &Path) -> Result<(), LifecycleError> {
|
|
749
|
-
let settings_path = dir.join("settings.json");
|
|
750
|
-
let mut settings = read_json_object(&settings_path)?;
|
|
751
|
-
insert_if_missing(&mut settings, "theme", serde_json::json!("auto"));
|
|
752
|
-
insert_if_missing(
|
|
753
|
-
&mut settings,
|
|
754
|
-
"skipDangerousModePermissionPrompt",
|
|
755
|
-
serde_json::json!(true),
|
|
756
|
-
);
|
|
757
|
-
settings.insert(
|
|
758
|
-
"hasCompletedOnboarding".to_string(),
|
|
759
|
-
serde_json::json!(true),
|
|
760
|
-
);
|
|
761
|
-
settings.insert(
|
|
762
|
-
"hasTrustDialogAccepted".to_string(),
|
|
763
|
-
serde_json::json!(true),
|
|
764
|
-
);
|
|
765
|
-
insert_if_missing(
|
|
766
|
-
&mut settings,
|
|
767
|
-
"lastOnboardingVersion",
|
|
768
|
-
serde_json::json!("2.1.0"),
|
|
769
|
-
);
|
|
770
|
-
insert_if_missing(
|
|
771
|
-
&mut settings,
|
|
772
|
-
"firstStartTime",
|
|
773
|
-
serde_json::json!("1970-01-01T00:00:00.000Z"),
|
|
774
|
-
);
|
|
775
|
-
insert_if_missing(&mut settings, "numStartups", serde_json::json!(0));
|
|
776
|
-
insert_if_missing(
|
|
777
|
-
&mut settings,
|
|
778
|
-
"projectOnboardingSeenCount",
|
|
779
|
-
serde_json::json!(1),
|
|
780
|
-
);
|
|
781
|
-
write_json_object(&settings_path, &settings)?;
|
|
782
|
-
|
|
783
|
-
let state_path = dir.join(".claude.json");
|
|
784
|
-
let mut state = read_json_object(&state_path)?;
|
|
785
|
-
state.insert(
|
|
786
|
-
"hasCompletedOnboarding".to_string(),
|
|
787
|
-
serde_json::json!(true),
|
|
788
|
-
);
|
|
789
|
-
insert_if_missing(
|
|
790
|
-
&mut state,
|
|
791
|
-
"lastOnboardingVersion",
|
|
792
|
-
serde_json::json!("2.1.0"),
|
|
793
|
-
);
|
|
794
|
-
insert_if_missing(
|
|
795
|
-
&mut state,
|
|
796
|
-
"firstStartTime",
|
|
797
|
-
serde_json::json!("1970-01-01T00:00:00.000Z"),
|
|
798
|
-
);
|
|
799
|
-
insert_if_missing(&mut state, "numStartups", serde_json::json!(0));
|
|
800
|
-
ensure_claude_projects(&mut state, workspace, None);
|
|
801
|
-
write_json_object(&state_path, &state)
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
fn ensure_compatible_claude_mcp_config(
|
|
805
|
-
dir: &Path,
|
|
806
|
-
workspace: &Path,
|
|
807
|
-
mcp_config: &McpConfig,
|
|
808
|
-
) -> Result<(), LifecycleError> {
|
|
809
|
-
let state_path = dir.join(".claude.json");
|
|
810
|
-
let mut state = read_json_object(&state_path)?;
|
|
811
|
-
state.insert(
|
|
812
|
-
"hasCompletedOnboarding".to_string(),
|
|
813
|
-
serde_json::json!(true),
|
|
814
|
-
);
|
|
815
|
-
state.insert(
|
|
816
|
-
"hasTrustDialogAccepted".to_string(),
|
|
817
|
-
serde_json::json!(true),
|
|
818
|
-
);
|
|
819
|
-
insert_if_missing(
|
|
820
|
-
&mut state,
|
|
821
|
-
"projectOnboardingSeenCount",
|
|
822
|
-
serde_json::json!(1),
|
|
823
|
-
);
|
|
824
|
-
state.insert("mcpServers".to_string(), mcp_config.raw.clone());
|
|
825
|
-
state.insert(
|
|
826
|
-
"enabledMcpjsonServers".to_string(),
|
|
827
|
-
serde_json::json!(mcp_server_names(&mcp_config.raw)),
|
|
828
|
-
);
|
|
829
|
-
ensure_claude_projects(&mut state, workspace, Some(&mcp_config.raw));
|
|
830
|
-
write_json_object(&state_path, &state)
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
fn ensure_claude_projects(
|
|
834
|
-
state: &mut serde_json::Map<String, serde_json::Value>,
|
|
835
|
-
workspace: &Path,
|
|
836
|
-
mcp_servers: Option<&serde_json::Value>,
|
|
837
|
-
) {
|
|
838
|
-
if !state
|
|
839
|
-
.get("projects")
|
|
840
|
-
.is_some_and(serde_json::Value::is_object)
|
|
841
|
-
{
|
|
842
|
-
state.insert("projects".to_string(), serde_json::json!({}));
|
|
843
|
-
}
|
|
844
|
-
let Some(projects) = state
|
|
845
|
-
.get_mut("projects")
|
|
846
|
-
.and_then(serde_json::Value::as_object_mut)
|
|
847
|
-
else {
|
|
848
|
-
return;
|
|
849
|
-
};
|
|
850
|
-
for key in claude_project_keys(workspace) {
|
|
851
|
-
let entry = projects.entry(key).or_insert_with(|| serde_json::json!({}));
|
|
852
|
-
if !entry.is_object() {
|
|
853
|
-
*entry = serde_json::json!({});
|
|
854
|
-
}
|
|
855
|
-
let Some(project) = entry.as_object_mut() else {
|
|
856
|
-
continue;
|
|
857
|
-
};
|
|
858
|
-
project.insert(
|
|
859
|
-
"hasTrustDialogAccepted".to_string(),
|
|
860
|
-
serde_json::json!(true),
|
|
861
|
-
);
|
|
862
|
-
insert_if_missing(project, "projectOnboardingSeenCount", serde_json::json!(1));
|
|
863
|
-
if let Some(mcp_servers) = mcp_servers {
|
|
864
|
-
insert_if_missing(project, "allowedTools", serde_json::json!([]));
|
|
865
|
-
insert_if_missing(project, "mcpContextUris", serde_json::json!([]));
|
|
866
|
-
project.insert(
|
|
867
|
-
"enabledMcpjsonServers".to_string(),
|
|
868
|
-
serde_json::json!(mcp_server_names(mcp_servers)),
|
|
869
|
-
);
|
|
870
|
-
insert_if_missing(project, "disabledMcpjsonServers", serde_json::json!([]));
|
|
871
|
-
insert_if_missing(
|
|
872
|
-
project,
|
|
873
|
-
"hasClaudeMdExternalIncludesApproved",
|
|
874
|
-
serde_json::json!(false),
|
|
875
|
-
);
|
|
876
|
-
insert_if_missing(
|
|
877
|
-
project,
|
|
878
|
-
"hasClaudeMdExternalIncludesWarningShown",
|
|
879
|
-
serde_json::json!(false),
|
|
880
|
-
);
|
|
881
|
-
if !project
|
|
882
|
-
.get("mcpServers")
|
|
883
|
-
.is_some_and(serde_json::Value::is_object)
|
|
884
|
-
{
|
|
885
|
-
project.insert("mcpServers".to_string(), serde_json::json!({}));
|
|
886
|
-
}
|
|
887
|
-
if let Some(existing) = project
|
|
888
|
-
.get_mut("mcpServers")
|
|
889
|
-
.and_then(serde_json::Value::as_object_mut)
|
|
890
|
-
{
|
|
891
|
-
if let Some(servers) = mcp_servers.as_object() {
|
|
892
|
-
existing.extend(servers.clone());
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
}
|
|
898
|
-
|
|
899
|
-
fn mcp_server_names(mcp_servers: &serde_json::Value) -> Vec<String> {
|
|
900
|
-
mcp_servers
|
|
901
|
-
.as_object()
|
|
902
|
-
.map(|servers| servers.keys().cloned().collect())
|
|
903
|
-
.unwrap_or_default()
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
/// swallow batch 4 C1-C4 (MUST-NOT-9/13): a CORRUPT provider-config JSON fails
|
|
907
|
-
/// EXPLICITLY — the old `unwrap_or_default` turned a parse failure into an empty map
|
|
908
|
-
/// that the subsequent write flattened back over the user's file (silent destructive
|
|
909
|
-
/// rewrite). A missing file stays Ok(empty) — only an existing-but-unparseable file
|
|
910
|
-
/// errors, naming the path + parse detail + next action; the file is never touched.
|
|
911
|
-
fn read_json_object(
|
|
912
|
-
path: &Path,
|
|
913
|
-
) -> Result<serde_json::Map<String, serde_json::Value>, LifecycleError> {
|
|
914
|
-
let text = match std::fs::read_to_string(path) {
|
|
915
|
-
Ok(text) => text,
|
|
916
|
-
Err(error) if error.kind() == std::io::ErrorKind::NotFound => {
|
|
917
|
-
return Ok(serde_json::Map::new());
|
|
918
|
-
}
|
|
919
|
-
Err(error) => {
|
|
920
|
-
return Err(LifecycleError::RequirementUnmet(format!(
|
|
921
|
-
"profile_invalid_json: {} could not be read: {error}; fix or remove the file (or restore a backup) and relaunch",
|
|
922
|
-
path.display()
|
|
923
|
-
)));
|
|
924
|
-
}
|
|
925
|
-
};
|
|
926
|
-
match serde_json::from_str::<serde_json::Value>(&text) {
|
|
927
|
-
Ok(serde_json::Value::Object(map)) => Ok(map),
|
|
928
|
-
Ok(other) => Err(LifecycleError::RequirementUnmet(format!(
|
|
929
|
-
"profile_invalid_json: {} is not a JSON object (found {}); fix or remove the file (or restore a backup) and relaunch",
|
|
930
|
-
path.display(),
|
|
931
|
-
json_kind(&other)
|
|
932
|
-
))),
|
|
933
|
-
Err(error) => Err(LifecycleError::RequirementUnmet(format!(
|
|
934
|
-
"profile_invalid_json: {} could not be parsed: {error}; fix or remove the file (or restore a backup) and relaunch",
|
|
935
|
-
path.display()
|
|
936
|
-
))),
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
fn json_kind(value: &serde_json::Value) -> &'static str {
|
|
941
|
-
match value {
|
|
942
|
-
serde_json::Value::Null => "null",
|
|
943
|
-
serde_json::Value::Bool(_) => "a boolean",
|
|
944
|
-
serde_json::Value::Number(_) => "a number",
|
|
945
|
-
serde_json::Value::String(_) => "a string",
|
|
946
|
-
serde_json::Value::Array(_) => "an array",
|
|
947
|
-
serde_json::Value::Object(_) => "an object",
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
|
|
951
|
-
fn write_json_object(
|
|
952
|
-
path: &Path,
|
|
953
|
-
value: &serde_json::Map<String, serde_json::Value>,
|
|
954
|
-
) -> Result<(), LifecycleError> {
|
|
955
|
-
if let Some(parent) = path.parent() {
|
|
956
|
-
std::fs::create_dir_all(parent)
|
|
957
|
-
.map_err(|e| LifecycleError::StatePersist(format!("{}: {e}", parent.display())))?;
|
|
958
|
-
}
|
|
959
|
-
let body = serde_json::to_string_pretty(value)
|
|
960
|
-
.map_err(|e| LifecycleError::StatePersist(format!("serialize {}: {e}", path.display())))?;
|
|
961
|
-
std::fs::write(path, format!("{body}\n"))
|
|
962
|
-
.map_err(|e| LifecycleError::StatePersist(format!("{}: {e}", path.display())))?;
|
|
963
|
-
set_owner_only_permissions(path)
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
fn insert_if_missing(
|
|
967
|
-
map: &mut serde_json::Map<String, serde_json::Value>,
|
|
968
|
-
key: &str,
|
|
969
|
-
value: serde_json::Value,
|
|
970
|
-
) {
|
|
971
|
-
map.entry(key.to_string()).or_insert(value);
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
fn claude_project_keys(workspace: &Path) -> Vec<String> {
|
|
975
|
-
let mut keys = vec![workspace.to_string_lossy().to_string()];
|
|
976
|
-
if let Ok(resolved) = workspace.canonicalize() {
|
|
977
|
-
let resolved = resolved.to_string_lossy().to_string();
|
|
978
|
-
if !keys.iter().any(|key| key == &resolved) {
|
|
979
|
-
keys.push(resolved);
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
for key in keys.clone() {
|
|
983
|
-
if let Some(stripped) = key.strip_prefix("/private/var/") {
|
|
984
|
-
push_unique_string(&mut keys, format!("/var/{stripped}"));
|
|
985
|
-
} else if let Some(stripped) = key.strip_prefix("/var/") {
|
|
986
|
-
push_unique_string(&mut keys, format!("/private/var/{stripped}"));
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
keys
|
|
990
|
-
}
|
|
991
|
-
|
|
992
|
-
fn push_unique_string(values: &mut Vec<String>, value: String) {
|
|
993
|
-
if !values.iter().any(|existing| existing == &value) {
|
|
994
|
-
values.push(value);
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
|
|
998
670
|
fn compatible_api_network_exports(
|
|
999
671
|
auth_mode: AuthMode,
|
|
1000
672
|
values: &BTreeMap<String, String>,
|
|
@@ -1032,7 +704,7 @@ fn required_profile_keys(provider: Provider, auth_mode: AuthMode) -> &'static [&
|
|
|
1032
704
|
return &[];
|
|
1033
705
|
}
|
|
1034
706
|
match provider {
|
|
1035
|
-
Provider::
|
|
707
|
+
Provider::Codex => match auth_mode {
|
|
1036
708
|
AuthMode::OfficialApi => &["API_KEY"],
|
|
1037
709
|
AuthMode::CompatibleApi => &["BASE_URL", "API_KEY"],
|
|
1038
710
|
AuthMode::Subscription => &[],
|
|
@@ -1041,8 +713,9 @@ fn required_profile_keys(provider: Provider, auth_mode: AuthMode) -> &'static [&
|
|
|
1041
713
|
// C-7-1 cr verdict: copilot 一期 subscription-only,无 BYOK required key 集合;
|
|
1042
714
|
// 二期 BYOK 立项时填(向后兼容字段保留)。
|
|
1043
715
|
Provider::Copilot => &[],
|
|
1044
|
-
// 0.5.67:
|
|
1045
|
-
|
|
716
|
+
// 0.5.67: Grok 一期无 BYOK required key 集合 (同 copilot 精神)。Claude Code/Pi
|
|
717
|
+
// worker 只走 subscription-only contract leaf。
|
|
718
|
+
Provider::Claude | Provider::ClaudeCode | Provider::Grok | Provider::Pi => &[],
|
|
1046
719
|
Provider::Fake => &[],
|
|
1047
720
|
}
|
|
1048
721
|
}
|
|
@@ -232,10 +232,9 @@ impl SmokeTarget {
|
|
|
232
232
|
}
|
|
233
233
|
// C-7-1 cr verdict: copilot 一期 subscription-only,无 BYOK HTTP smoke
|
|
234
234
|
// 入口;同 GeminiCli/Fake 走 unsupported_provider_smoke_skipped。
|
|
235
|
-
// 0.5.67: grok
|
|
235
|
+
// 0.5.67: grok 同走 skipped (一期 subscription 已登录态)。
|
|
236
236
|
Provider::Copilot
|
|
237
237
|
| Provider::Grok
|
|
238
|
-
| Provider::CursorAgent
|
|
239
238
|
| Provider::Pi
|
|
240
239
|
| Provider::GeminiCli
|
|
241
240
|
| Provider::Fake => {
|