@team-agent/installer 0.5.123 → 0.5.125

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.
Files changed (107) hide show
  1. package/Cargo.lock +1 -8
  2. package/Cargo.toml +1 -1
  3. package/README.md +2 -2
  4. package/README.zh.md +2 -2
  5. package/crates/team-agent/Cargo.toml +0 -1
  6. package/crates/team-agent/src/cli/diagnose.rs +39 -1
  7. package/crates/team-agent/src/cli/emit.rs +41 -15
  8. package/crates/team-agent/src/cli/intent/runtime.rs +30 -54
  9. package/crates/team-agent/src/cli/intent/runtime_tests.rs +59 -118
  10. package/crates/team-agent/src/cli/leader.rs +2 -3
  11. package/crates/team-agent/src/cli/leader_prompt.rs +1 -1
  12. package/crates/team-agent/src/cli/mod.rs +6 -5
  13. package/crates/team-agent/src/cli/models.rs +93 -128
  14. package/crates/team-agent/src/cli/route.rs +1 -1
  15. package/crates/team-agent/src/cli/send/persist.rs +36 -0
  16. package/crates/team-agent/src/cli/send/presentation.rs +7 -1
  17. package/crates/team-agent/src/cli/send.rs +3 -1
  18. package/crates/team-agent/src/cli/spec.rs +1 -2
  19. package/crates/team-agent/src/cli/status_port/brief.rs +66 -0
  20. package/crates/team-agent/src/cli/tests/base.rs +4 -11
  21. package/crates/team-agent/src/cli/tests/status_send.rs +17 -0
  22. package/crates/team-agent/src/compiler/tests.rs +21 -5
  23. package/crates/team-agent/src/compiler.rs +24 -1
  24. package/crates/team-agent/src/contract_runtime/backend.rs +30 -6
  25. package/crates/team-agent/src/contract_runtime/config.rs +34 -24
  26. package/crates/team-agent/src/contract_runtime/discovery.rs +79 -56
  27. package/crates/team-agent/src/contract_runtime/framework.rs +89 -34
  28. package/crates/team-agent/src/contract_runtime/registry.rs +299 -24
  29. package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -1
  30. package/crates/team-agent/src/coordinator/tick.rs +89 -1
  31. package/crates/team-agent/src/db/message_store.rs +78 -3
  32. package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -1
  33. package/crates/team-agent/src/leader/prompt.rs +1 -2
  34. package/crates/team-agent/src/leader/provider_attribution.rs +0 -52
  35. package/crates/team-agent/src/leader/start.rs +0 -1
  36. package/crates/team-agent/src/leader/tests/prompt_contract.rs +2 -3
  37. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +91 -0
  38. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +14 -1
  39. package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -9
  40. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -1
  41. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +2 -2
  42. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +19 -101
  43. package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -28
  44. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -1
  45. package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -108
  46. package/crates/team-agent/src/lifecycle/launch.rs +2 -20
  47. package/crates/team-agent/src/lifecycle/profile_launch.rs +11 -39
  48. package/crates/team-agent/src/lifecycle/profile_smoke.rs +1 -2
  49. package/crates/team-agent/src/lifecycle/restart/common.rs +1 -63
  50. package/crates/team-agent/src/lifecycle/role_config.rs +42 -3
  51. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +43 -13
  52. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +6 -2
  53. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +1 -3
  54. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +4 -16
  55. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +1 -3
  56. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +84 -53
  57. package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +19 -1
  58. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +21 -0
  59. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1
  60. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -137
  61. package/crates/team-agent/src/lifecycle/tests.rs +0 -3
  62. package/crates/team-agent/src/lifecycle/worker_command_context.rs +2 -4
  63. package/crates/team-agent/src/mcp_server/readiness.rs +148 -97
  64. package/crates/team-agent/src/mcp_server/readiness_tests.rs +115 -16
  65. package/crates/team-agent/src/messaging/delivery.rs +186 -38
  66. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +4 -4
  67. package/crates/team-agent/src/messaging/enter_rescue_tests.rs +1 -1
  68. package/crates/team-agent/src/messaging/helpers.rs +19 -0
  69. package/crates/team-agent/src/messaging/tests/dup_inject.rs +66 -4
  70. package/crates/team-agent/src/messaging/tests/runtime.rs +110 -4
  71. package/crates/team-agent/src/messaging/tests/spine.rs +22 -6
  72. package/crates/team-agent/src/model/enums.rs +1 -8
  73. package/crates/team-agent/src/provider/adapter.rs +1 -67
  74. package/crates/team-agent/src/provider/adapters/mod.rs +0 -1
  75. package/crates/team-agent/src/provider/adapters/pi.rs +4 -4
  76. package/crates/team-agent/src/provider/argv_route.rs +1 -5
  77. package/crates/team-agent/src/provider/bypass_flags.rs +3 -11
  78. package/crates/team-agent/src/provider/classify.rs +68 -3
  79. package/crates/team-agent/src/provider/faults.rs +1 -1
  80. package/crates/team-agent/src/provider/model_catalog.rs +2 -73
  81. package/crates/team-agent/src/provider/session/capture.rs +1 -1
  82. package/crates/team-agent/src/provider/session/context_fork.rs +4 -4
  83. package/crates/team-agent/src/provider/session_scan/common.rs +1 -2
  84. package/crates/team-agent/src/provider/session_scan/pi.rs +32 -19
  85. package/crates/team-agent/src/provider/session_scan.rs +0 -4
  86. package/crates/team-agent/src/provider/submit_now.rs +5 -28
  87. package/crates/team-agent/src/provider/tests/adapter.rs +5 -184
  88. package/crates/team-agent/src/provider/tests/classify.rs +53 -0
  89. package/crates/team-agent/src/provider/tests/command_helpers.rs +3 -6
  90. package/crates/team-agent/src/provider/types.rs +1 -1
  91. package/crates/team-agent/src/provider/wire.rs +48 -8
  92. package/crates/team-agent/src/tmux_backend/native_input_tests.rs +2 -178
  93. package/crates/team-agent/src/tmux_backend/tests.rs +151 -0
  94. package/crates/team-agent/src/tmux_backend.rs +43 -8
  95. package/crates/team-agent/src/transport/native_input.rs +2 -231
  96. package/npm/install.mjs +40 -3
  97. package/package.json +4 -4
  98. package/skills/team-agent/SKILL.md +1 -1
  99. package/crates/team-agent/src/lifecycle/launch/cursor_create_chat.rs +0 -229
  100. package/crates/team-agent/src/lifecycle/launch/cursor_mcp.rs +0 -522
  101. package/crates/team-agent/src/lifecycle/launch/cursor_mcp_iso.rs +0 -282
  102. package/crates/team-agent/src/lifecycle/tests/cursor_mcp_overlay.rs +0 -576
  103. package/crates/team-agent/src/lifecycle/tests/cursor_require_explicit_model_red.rs +0 -222
  104. package/crates/team-agent/src/lifecycle/tests/cursor_restart_resume_red.rs +0 -511
  105. package/crates/team-agent/src/provider/adapters/cursor_agent.rs +0 -44
  106. package/crates/team-agent/src/provider/session_scan/cursor.rs +0 -538
  107. package/crates/team-agent/src/provider/testdata/cursor-list-models-native.stdout +0 -250
@@ -328,34 +328,6 @@ pub(super) fn spawn_agents(
328
328
  );
329
329
  }
330
330
  }
331
- // Cursor: role 经 .cursor/rules。MCP 身份默认写 provider-config/<id>/cursor
332
- // (不继承父进程 TEAM_AGENT_*)。--workspace 指该工程根,--add-dir 真 workspace。
333
- // 隔离关闭时仍拒绝第二席(共用 mcp.json last-writer)。不改 HOME。
334
- if matches!(provider, Provider::CursorAgent) {
335
- refuse_second_cursor_occupant(workspace, agent_id_raw, Some(spec))?;
336
- apply_cursor_agent_rules_overlay(workspace, agent_id_raw, system_prompt.as_str())?;
337
- let project = crate::lifecycle::launch::prepare_cursor_seat_mcp(
338
- workspace,
339
- agent_id_raw,
340
- &mcp_config,
341
- )?;
342
- enable_cursor_workspace_mcp_with_profile(
343
- workspace,
344
- project.as_deref(),
345
- Some(&profile_launch),
346
- )?;
347
- apply_cursor_spawn_workspace_pointers(&mut plan.argv, workspace, agent_id_raw)?;
348
- let proxy = apply_cursor_subscription_proxy_env_with_profile(&mut env, &profile_launch);
349
- let event_log = crate::event_log::EventLog::new(workspace);
350
- let _ = event_log.write(
351
- "provider.cursor.proxy_presence",
352
- serde_json::json!({
353
- "agent_id": agent_id_raw,
354
- "https_proxy": proxy.https_proxy,
355
- "no_proxy": proxy.no_proxy,
356
- }),
357
- );
358
- }
359
331
  // Grok 无 --mcp-config;写 <cwd>/.grok/config.toml 让 CLI 读到 team-agent。
360
332
  if matches!(provider, Provider::Grok) {
361
333
  ensure_grok_login_and_folder_trust(workspace)?;
@@ -643,7 +643,6 @@ pub(crate) fn provider_display_str(provider: Provider) -> &'static str {
643
643
  Provider::Copilot => "copilot",
644
644
  Provider::GeminiCli => "gemini_cli",
645
645
  Provider::Grok => "grok",
646
- Provider::CursorAgent => "cursor_agent",
647
646
  Provider::Pi => "pi",
648
647
  Provider::Fake => "fake",
649
648
  }
@@ -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:
@@ -374,33 +374,15 @@ pub(crate) fn run_pi_catalog_preflight(
374
374
  })
375
375
  }
376
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
377
  mod worker_env;
395
378
  pub(super) use worker_env::*;
396
379
  pub(crate) use worker_env::{
397
- apply_copilot_instructions_overlay, apply_cursor_agent_rules_overlay,
398
- apply_cursor_subscription_proxy_env_with_profile, apply_mcp_auto_approval_env,
380
+ apply_copilot_instructions_overlay,
381
+ apply_mcp_auto_approval_env,
399
382
  apply_profile_launch_env, auth_mode_env_value, fill_spawn_placeholders,
400
383
  fill_spawn_placeholders_full, inherited_env_with_team_overrides, persist_command_plan_state,
401
384
  spawn_timestamp,
402
385
  };
403
- pub use worker_env::{apply_cursor_subscription_proxy_env, CursorProxyPresence};
404
386
 
405
387
  mod identity;
406
388
  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 agent.get("provider").and_then(YamlValue::as_str).is_some_and(crate::provider::wire::is_retired_provider) {
101
+ return Err(LifecycleError::Provider(crate::provider::wire::RETIRED_PROVIDER_ERROR.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 agent.get("provider").and_then(serde_json::Value::as_str).is_some_and(crate::provider::wire::is_retired_provider) {
157
+ return Err(LifecycleError::Provider(crate::provider::wire::RETIRED_PROVIDER_ERROR.into()));
158
+ }
173
159
  let input = AgentProfileInput {
174
160
  id: agent
175
161
  .get("id")
@@ -261,16 +247,6 @@ fn prepare_profile_launch(
261
247
  env_overlay.remove(*key);
262
248
  }
263
249
  }
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
250
  let command_overrides = provider_command_overrides(&agent, &loaded.values);
275
251
  write_runtime_env_file(workspace, &agent.id, &env_overlay, &env_unset)?;
276
252
 
@@ -504,9 +480,8 @@ fn provider_env_exports(
504
480
  }
505
481
  }
506
482
  }
507
- // grok/cursor_agent 一期无 credential/profile exports(subscription 已登录态)。
508
- // Cursor 订阅席默认继承代理;PROXY_MODE=direct 的局部清除在上方处理。
509
- Provider::Grok | Provider::CursorAgent | Provider::Pi => {}
483
+ // Grok and Pi retain their native subscription credentials.
484
+ Provider::Grok | Provider::Pi => {}
510
485
  Provider::Fake => {}
511
486
  }
512
487
  exports
@@ -611,11 +586,8 @@ pub(crate) fn provider_env_unsets(provider: Provider, auth_mode: AuthMode) -> BT
611
586
  // C-7-1 cr verdict: 一期 subscription-only(已登录态),exports/unsets 空;
612
587
  // BYOK(COPILOT_PROVIDER_*)二期立项时单独 cr verdict 再开。
613
588
  Provider::Copilot => {}
614
- // grok 无 env 需 unset。cursor 订阅席必须保留代理键(TUI 连云要用);
615
- // `--print` 路径会因 https:// 方案撞 GLOBAL_AGENT,但主路径是 TUI。
616
- // 禁止在这里 unset 代理。
589
+ // Grok has no provider-specific environment to unset.
617
590
  Provider::Grok => {}
618
- Provider::CursorAgent => {}
619
591
  Provider::Pi => {}
620
592
  Provider::Fake => {}
621
593
  }
@@ -1041,8 +1013,8 @@ fn required_profile_keys(provider: Provider, auth_mode: AuthMode) -> &'static [&
1041
1013
  // C-7-1 cr verdict: copilot 一期 subscription-only,无 BYOK required key 集合;
1042
1014
  // 二期 BYOK 立项时填(向后兼容字段保留)。
1043
1015
  Provider::Copilot => &[],
1044
- // 0.5.67: grok/cursor_agent 一期无 BYOK required key 集合 (同 copilot 精神)。
1045
- Provider::Grok | Provider::CursorAgent | Provider::Pi => &[],
1016
+ // 0.5.67: Grok/Pi 一期无 BYOK required key 集合 (同 copilot 精神)。
1017
+ Provider::Grok | Provider::Pi => &[],
1046
1018
  Provider::Fake => &[],
1047
1019
  }
1048
1020
  }
@@ -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/cursor_agent 同走 skipped (一期 subscription 已登录态)。
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 => {
@@ -464,44 +464,6 @@ pub(super) fn spawn_agent_window(
464
464
  &mut env,
465
465
  )?;
466
466
  }
467
- // Keep provider/native cwd distinct from the real Team workspace. Cursor
468
- // changes cwd to --workspace before writing its cwd-keyed session archive.
469
- let mut native_spawn_cwd = spawn_cwd.to_path_buf();
470
- // 0.5.67 Cursor 方案 1 变体: role 经 workspace rules 文件注入 (不 argv)。
471
- if provider == crate::provider::Provider::CursorAgent {
472
- crate::lifecycle::launch::refuse_second_cursor_occupant(
473
- workspace,
474
- agent_id.as_str(),
475
- None,
476
- )?;
477
- crate::lifecycle::launch::apply_cursor_agent_rules_overlay(
478
- workspace,
479
- agent_id.as_str(),
480
- &system_prompt,
481
- )?;
482
- let project = crate::lifecycle::launch::prepare_cursor_seat_mcp(
483
- workspace,
484
- agent_id.as_str(),
485
- &mcp_config,
486
- )?;
487
- if let Some(primary) = project.as_ref() {
488
- native_spawn_cwd = primary.clone();
489
- }
490
- crate::lifecycle::launch::enable_cursor_workspace_mcp_with_profile(
491
- workspace,
492
- project.as_deref(),
493
- Some(&profile_launch),
494
- )?;
495
- crate::lifecycle::launch::apply_cursor_spawn_workspace_pointers(
496
- &mut plan.argv,
497
- workspace,
498
- agent_id.as_str(),
499
- )?;
500
- crate::lifecycle::launch::apply_cursor_subscription_proxy_env_with_profile(
501
- &mut env,
502
- &profile_launch,
503
- );
504
- }
505
467
  if provider == crate::provider::Provider::Grok {
506
468
  crate::lifecycle::launch::ensure_grok_login_and_folder_trust(workspace)?;
507
469
  crate::lifecycle::launch::apply_grok_mcp_overlay(workspace, &mcp_config)?;
@@ -702,7 +664,7 @@ pub(super) fn spawn_agent_window(
702
664
  plan,
703
665
  profile_launch,
704
666
  layout_placement: layout_placement.cloned(),
705
- spawn_cwd: native_spawn_cwd,
667
+ spawn_cwd: spawn_cwd.to_path_buf(),
706
668
  mcp_config_path,
707
669
  owner_team_id: team_id,
708
670
  })
@@ -1540,30 +1502,6 @@ pub(super) fn resume_backing_probe_for_agent(
1540
1502
  None => false,
1541
1503
  }
1542
1504
  }
1543
- Provider::CursorAgent => {
1544
- let spawn_cwd = agent
1545
- .get("spawn_cwd")
1546
- .and_then(serde_json::Value::as_str)
1547
- .map(PathBuf::from)
1548
- .unwrap_or_else(|| workspace.to_path_buf());
1549
- let rollout_ok = rollout_path.is_some_and(|path| {
1550
- crate::provider::session_scan::cursor::cursor_session_archive_present(path.as_path())
1551
- });
1552
- let discovered = crate::provider::session_scan::cursor::cursor_session_dir_for_cwd(
1553
- session_id.as_str(),
1554
- &spawn_cwd,
1555
- );
1556
- if let Some(dir) = discovered.as_ref() {
1557
- checked_paths.push(dir.clone());
1558
- }
1559
- if let Some(home) = std::env::var_os("HOME").map(PathBuf::from) {
1560
- checked_paths.push(home.join(".cursor").join("chats"));
1561
- }
1562
- rollout_ok
1563
- || discovered.as_ref().is_some_and(|dir| {
1564
- crate::provider::session_scan::cursor::cursor_session_archive_present(dir)
1565
- })
1566
- }
1567
1505
  Provider::Pi => {
1568
1506
  let spawn_cwd = agent
1569
1507
  .get("spawn_cwd")
@@ -115,7 +115,19 @@ fn add_at_selected(
115
115
  Some(path) => read_text(path)?,
116
116
  None => String::new(),
117
117
  };
118
- let reconciled = reconcile_creation(&text, patch)?;
118
+ #[allow(unused_mut)]
119
+ let mut reconciled = reconcile_creation(&text, patch)?;
120
+ // A generated legacy role falls back to its id as instructions at compile
121
+ // time; a contract role requires a body, so give it a neutral default.
122
+ #[cfg(unix)]
123
+ if source.is_none()
124
+ && reconciled.prompt.is_none()
125
+ && crate::contract_runtime::framework::declares_contract(None, reconciled.provider.as_deref())
126
+ {
127
+ reconciled.prompt = Some(format!(
128
+ "You are {agent_id}. Complete the tasks assigned by the leader.\n"
129
+ ));
130
+ }
119
131
  let next = patched_role(&text, agent_id, &reconciled, source.is_none())?;
120
132
  let snapshot = RoleSnapshot::capture(selected, &role_path)?;
121
133
  let result = (|| {
@@ -330,11 +342,12 @@ fn reconcile_creation(
330
342
  .get("provider")
331
343
  .and_then(Value::as_str)
332
344
  .filter(|value| !value.trim().is_empty());
345
+ let opted_in = matches!(meta.get("contract_runtime"), Some(Value::Bool(true)));
333
346
  if let Some(file_provider) = file_provider {
334
- let file_provider = crate::provider::wire::parse_provider(file_provider)
347
+ let file_provider = declared_provider(file_provider, opted_in)
335
348
  .ok_or_else(|| LifecycleError::Compile("unknown role provider".into()))?;
336
349
  if let Some(provider) = &next.provider {
337
- if crate::provider::wire::parse_provider(provider) != Some(file_provider) {
350
+ if declared_provider(provider, opted_in) != Some(file_provider) {
338
351
  return Err(conflict("provider"));
339
352
  }
340
353
  next.provider = None;
@@ -400,6 +413,18 @@ fn reconcile_creation(
400
413
  Ok(next)
401
414
  }
402
415
 
416
+ /// One identity per declared provider: its contract leaf id, else its legacy
417
+ /// wire form, so `agent` in a role file and `--provider cursor` agree.
418
+ fn declared_provider(value: &str, contract_runtime: bool) -> Option<&'static str> {
419
+ #[cfg(unix)]
420
+ if let Some(descriptor) = crate::contract_runtime::registry::declared(value, contract_runtime) {
421
+ return Some(descriptor.identity.id);
422
+ }
423
+ #[cfg(not(unix))]
424
+ let _ = contract_runtime;
425
+ crate::provider::wire::parse_provider(value).map(crate::provider::wire::provider_wire)
426
+ }
427
+
403
428
  fn role_path(selected: &SelectedTeam, agent_id: &AgentId) -> PathBuf {
404
429
  selected
405
430
  .team_dir
@@ -976,6 +1001,20 @@ mod tests {
976
1001
  }
977
1002
  }
978
1003
 
1004
+ #[cfg(unix)]
1005
+ #[test]
1006
+ fn cursor_names_in_a_role_file_and_cli_are_one_provider() {
1007
+ for file in ["cursor", "cursor-agent", "agent", "cursor_agent"] {
1008
+ let text = format!("---\nprovider: {file}\ndangerously_skip_permissions: true\n---\nbody");
1009
+ for cli in ["cursor", "agent"] {
1010
+ let patch = RoleConfigPatch { provider: Some(cli.into()), ..Default::default() };
1011
+ assert_eq!(reconcile_creation(&text, &patch).unwrap(), RoleConfigPatch::default(), "{file}/{cli}");
1012
+ }
1013
+ let pi = RoleConfigPatch { provider: Some("pi".into()), ..Default::default() };
1014
+ assert!(reconcile_creation(&text, &pi).is_err(), "{file}");
1015
+ }
1016
+ }
1017
+
979
1018
  #[test]
980
1019
  fn legacy_cr_only_header_does_not_change_engine_when_patched() {
981
1020
  let text = "---\rprovider: codex\ndangerously_skip_permissions: false\r---\r\rbody\r";
@@ -33,7 +33,6 @@ const CANONICAL: &[(&str, Provider)] = &[
33
33
  ("copilot", Provider::Copilot),
34
34
  ("gemini_cli", Provider::GeminiCli),
35
35
  ("grok", Provider::Grok),
36
- ("cursor_agent", Provider::CursorAgent),
37
36
  ("pi", Provider::Pi),
38
37
  ];
39
38
  struct Fixture {
@@ -587,7 +586,6 @@ provider_tests! {
587
586
  a06_copilot => "copilot", Copilot;
588
587
  a06_gemini_cli => "gemini_cli", GeminiCli;
589
588
  a06_grok => "grok", Grok;
590
- a06_cursor_agent => "cursor_agent", CursorAgent;
591
589
  a06_pi => "pi", Pi;
592
590
  }
593
591
 
@@ -840,18 +838,17 @@ fn a09_resume_retains_session_metadata_while_routes_change() {
840
838
  let f = Fixture::new("argv-resume");
841
839
  f.start_team("pi", &["worker"]);
842
840
  let selected = crate::state::projection::select_runtime_state(&f.ws, Some("argvteam")).unwrap();
843
- let pending = selected["agents"]["worker"]["_pending_session_id"]
844
- .as_str()
845
- .unwrap()
846
- .to_string();
841
+ // Fresh Pi assigns its own session id; capture records it afterwards.
842
+ assert!(selected["agents"]["worker"]["_pending_session_id"].is_null());
843
+ let session_id = "8d6c1f2e-4a5b-4c7d-9e0f-a09000000001";
847
844
  let session = crate::lifecycle::launch::pi_mcp::pi_seat_paths(&f.ws, "argvteam", "worker")
848
845
  .sessions
849
846
  .join("valid.jsonl");
850
847
  fs::create_dir_all(session.parent().unwrap()).unwrap();
851
- fs::write(&session, format!("{}\n{}\n", json!({"type":"session","version":3,"id":pending,"cwd":f.ws,"timestamp":"2026-01-01T00:00:00Z"}), json!({"type":"message","id":"a","parentId":null,"timestamp":"2026-01-01T00:00:01Z","message":{"role":"user","content":[{"type":"text","text":"seed"}]}}))).unwrap();
848
+ fs::write(&session, format!("{}\n{}\n", json!({"type":"session","version":3,"id":session_id,"cwd":f.ws,"timestamp":"2026-01-01T00:00:00Z"}), json!({"type":"message","id":"a","parentId":null,"timestamp":"2026-01-01T00:00:01Z","message":{"role":"user","content":[{"type":"text","text":"seed"}]}}))).unwrap();
852
849
  f.mutate_agent("worker", |a| {
853
850
  a["status"] = json!("stopped");
854
- a["session_id"] = json!(pending);
851
+ a["session_id"] = json!(session_id);
855
852
  a["rollout_path"] = json!(session);
856
853
  a["captured_at"] = json!("2026-01-01T00:00:01Z");
857
854
  a["captured_via"] = json!("session_scan");
@@ -1237,7 +1234,7 @@ fn a07_attach_existing_never_opens_enabled_invalid_route_config() {
1237
1234
 
1238
1235
  #[test]
1239
1236
  #[serial(env)]
1240
- fn a13_all_provider_version_auth_and_cursor_mcp_auxiliary_argv_are_native() {
1237
+ fn a13_all_provider_version_and_auth_auxiliary_argv_are_native() {
1241
1238
  let f = Fixture::new("argv-aux");
1242
1239
  let mappings = CANONICAL
1243
1240
  .iter()
@@ -1250,10 +1247,6 @@ fn a13_all_provider_version_auth_and_cursor_mcp_auxiliary_argv_are_native() {
1250
1247
  }
1251
1248
  let _ = crate::provider::get_adapter(Provider::ClaudeCode)
1252
1249
  .auth_hint(crate::model::enums::AuthMode::Subscription);
1253
- assert_eq!(
1254
- crate::lifecycle::launch::cursor_mcp_enable_argv(),
1255
- ["agent", "mcp", "enable", "team_orchestrator"]
1256
- );
1257
1250
  let _ = f.cold("copilot");
1258
1251
  let probes = fs::read_to_string(&f.probes).unwrap();
1259
1252
  assert!(!probes.contains("route-must-not-enter-aux"));
@@ -1402,6 +1395,43 @@ fn a15_provider_drift_and_unknown_force_remain_refused() {
1402
1395
  );
1403
1396
  }
1404
1397
 
1398
+ #[test]
1399
+ #[serial(env)]
1400
+ fn issue381_every_cursor_name_adds_through_the_contract_leaf_never_legacy_agent() {
1401
+ let f = Fixture::new("cursor-contract-add");
1402
+ f.start_team("codex", &["worker"]);
1403
+ let before = crate::state::projection::select_runtime_state(&f.ws, Some("argvteam")).unwrap();
1404
+ let probes_before = fs::read_to_string(&f.probes).unwrap_or_default();
1405
+ for (index, name) in ["cursor", "cursor-agent", "agent", "cursor_agent"].into_iter().enumerate() {
1406
+ let id = format!("cursor-{index}");
1407
+ let added = crate::lifecycle::role_config::add_agent_from_role(
1408
+ &f.ws,
1409
+ &AgentId::new(&id),
1410
+ None,
1411
+ &crate::lifecycle::role_config::RoleConfigPatch {
1412
+ provider: Some(name.into()),
1413
+ model: Some("gpt-5.6-luna-xhigh".into()),
1414
+ bypass: Some(true),
1415
+ // An omitted --prompt still yields a valid contract role body.
1416
+ prompt: (index > 0).then(|| "Reply to every task.".into()),
1417
+ ..Default::default()
1418
+ },
1419
+ false,
1420
+ Some("argvteam"),
1421
+ );
1422
+ // The fixture PATH has a fake legacy `agent` but no `cursor-agent`:
1423
+ // the contract leaf's discovery refuses before any native effect.
1424
+ let error = added.expect_err("no cursor-agent on PATH").to_string();
1425
+ assert!(error.contains("cursor-agent"), "{name}: {error}");
1426
+ assert!(!f.team.join(format!("agents/{id}.md")).exists(), "{name}: role rolled back");
1427
+ let after = crate::state::projection::select_runtime_state(&f.ws, Some("argvteam")).unwrap();
1428
+ assert!(after["agents"].get(&id).is_none(), "{name}: seed row rolled back");
1429
+ assert_eq!(after["agents"]["worker"], before["agents"]["worker"], "{name}");
1430
+ }
1431
+ let probes = fs::read_to_string(&f.probes).unwrap_or_default();
1432
+ assert_eq!(probes, probes_before, "no legacy `agent` probe or catalog read");
1433
+ }
1434
+
1405
1435
  #[test]
1406
1436
  #[serial(env)]
1407
1437
  fn a15_route_does_not_relax_running_start_reset_discard_or_unsupported_fork() {
@@ -92,8 +92,9 @@ const ISOLATION_GUARD_TEST: &str = concat!(
92
92
  /// These fixtures need process-global HOME and TEAM_AGENT_* overrides, while the
93
93
  /// lib-test harness runs sibling tests in parallel. Execute each body as the sole
94
94
  /// selected test in a child process so HermeticTestEnv never mutates the parent
95
- /// test process. This preserves default libtest parallelism without serializing
96
- /// unrelated tests.
95
+ /// test process. Fixture-caller tests still hold `serial(env)` while their child
96
+ /// runs: the child inherits the parent's PATH, and a sibling env test may have a
97
+ /// fake `tmux` on it that never creates the fixture caller socket.
97
98
  fn run_process_isolated(marker: &str, test_name: &str, body: impl FnOnce()) {
98
99
  if std::env::var_os(marker).is_some() {
99
100
  body();
@@ -492,6 +493,7 @@ exec sleep 3600
492
493
  /// `verifier-r8-caps-recharter-signoff.md`. The SQLite FK-table integrity and
493
494
  /// exact-nonce recall remain the GREEN half / subscription-E2E (§1.4).
494
495
  #[test]
496
+ #[serial_test::serial(env)]
495
497
  fn r8_copilot_fork_is_no_longer_capability_refused() {
496
498
  run_process_isolated(R8_CHILD, R8_TEST, || {
497
499
  // R8 uses the LIBRARY entry `fork_agent_with_transport` (the same entry the old
@@ -549,6 +551,7 @@ fn r8_copilot_fork_is_no_longer_capability_refused() {
549
551
  /// (本 fixture = false → `source=disabled`),不再依赖 leader argv 继承。任何
550
552
  /// fork 都不得出现 `source=leader_process`(旧模型已删)或 capability 高于源。
551
553
  #[test]
554
+ #[serial_test::serial(env)]
552
555
  fn r7_fork_effective_permissions_are_clamped_to_leader_guardrail() {
553
556
  run_process_isolated(R7_CHILD, R7_TEST, || {
554
557
  // Claude source + success-path backing shim so the fork COMPLETES and a NEW
@@ -571,6 +574,7 @@ fn r7_fork_effective_permissions_are_clamped_to_leader_guardrail() {
571
574
  /// false) must also resolve to `source=disabled` under any ancestry seam. 0.5.66
572
575
  /// 起 policy 与 leader argv 无关:source 恒 `disabled`,fork 恒不升级(MUST-16)。
573
576
  #[test]
577
+ #[serial_test::serial(env)]
574
578
  fn r7b_fork_policy_under_restricted_leader_ancestry_is_disabled() {
575
579
  run_process_isolated(R7B_CHILD, R7B_TEST, || {
576
580
  let case = Case::start_with_ancestry("cf-r7b", RESTRICTED_LEADER_ARGV);
@@ -92,9 +92,7 @@ fn command_for_model(model: &str) -> Vec<String> {
92
92
  effort: Some(ProviderEffort::Medium),
93
93
  system_prompt: "worker contract",
94
94
  session_dir: Some(Path::new("/workspace/.team/runtime/pi/t1/w1/sessions")),
95
- session: PiSessionSelector::Fresh {
96
- session_id: "716ba0cb-c491-4471-b41a-43c8d5e1f05a",
97
- },
95
+ session: PiSessionSelector::Fresh,
98
96
  agent_id: "w1",
99
97
  })
100
98
  .expect("catalog member must build a semantic Pi argv")