@team-agent/installer 0.5.124 → 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 (97) 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 +5 -53
  9. package/crates/team-agent/src/cli/intent/runtime_tests.rs +0 -120
  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 +40 -119
  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 +22 -6
  25. package/crates/team-agent/src/contract_runtime/config.rs +34 -24
  26. package/crates/team-agent/src/contract_runtime/discovery.rs +33 -0
  27. package/crates/team-agent/src/contract_runtime/framework.rs +89 -34
  28. package/crates/team-agent/src/contract_runtime/registry.rs +258 -21
  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/spawn.rs +0 -28
  43. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -1
  44. package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -108
  45. package/crates/team-agent/src/lifecycle/launch.rs +2 -20
  46. package/crates/team-agent/src/lifecycle/profile_launch.rs +11 -39
  47. package/crates/team-agent/src/lifecycle/profile_smoke.rs +1 -2
  48. package/crates/team-agent/src/lifecycle/restart/common.rs +1 -63
  49. package/crates/team-agent/src/lifecycle/role_config.rs +42 -3
  50. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +38 -7
  51. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +6 -2
  52. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1
  53. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -137
  54. package/crates/team-agent/src/lifecycle/tests.rs +0 -3
  55. package/crates/team-agent/src/lifecycle/worker_command_context.rs +2 -4
  56. package/crates/team-agent/src/mcp_server/readiness.rs +148 -97
  57. package/crates/team-agent/src/mcp_server/readiness_tests.rs +115 -16
  58. package/crates/team-agent/src/messaging/delivery.rs +181 -35
  59. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +4 -4
  60. package/crates/team-agent/src/messaging/enter_rescue_tests.rs +1 -1
  61. package/crates/team-agent/src/messaging/helpers.rs +19 -0
  62. package/crates/team-agent/src/messaging/tests/dup_inject.rs +66 -4
  63. package/crates/team-agent/src/messaging/tests/runtime.rs +110 -4
  64. package/crates/team-agent/src/messaging/tests/spine.rs +22 -6
  65. package/crates/team-agent/src/model/enums.rs +1 -8
  66. package/crates/team-agent/src/provider/adapter.rs +1 -67
  67. package/crates/team-agent/src/provider/adapters/mod.rs +0 -1
  68. package/crates/team-agent/src/provider/argv_route.rs +1 -5
  69. package/crates/team-agent/src/provider/bypass_flags.rs +3 -11
  70. package/crates/team-agent/src/provider/classify.rs +68 -3
  71. package/crates/team-agent/src/provider/faults.rs +1 -1
  72. package/crates/team-agent/src/provider/model_catalog.rs +2 -73
  73. package/crates/team-agent/src/provider/session/capture.rs +1 -1
  74. package/crates/team-agent/src/provider/session/context_fork.rs +4 -4
  75. package/crates/team-agent/src/provider/session_scan/common.rs +1 -2
  76. package/crates/team-agent/src/provider/session_scan.rs +0 -4
  77. package/crates/team-agent/src/provider/submit_now.rs +5 -28
  78. package/crates/team-agent/src/provider/tests/adapter.rs +5 -184
  79. package/crates/team-agent/src/provider/tests/classify.rs +53 -0
  80. package/crates/team-agent/src/provider/tests/command_helpers.rs +1 -4
  81. package/crates/team-agent/src/provider/types.rs +1 -1
  82. package/crates/team-agent/src/provider/wire.rs +48 -8
  83. package/crates/team-agent/src/tmux_backend/native_input_tests.rs +2 -178
  84. package/crates/team-agent/src/tmux_backend/tests.rs +151 -0
  85. package/crates/team-agent/src/tmux_backend.rs +43 -8
  86. package/crates/team-agent/src/transport/native_input.rs +2 -231
  87. package/package.json +4 -4
  88. package/skills/team-agent/SKILL.md +1 -1
  89. package/crates/team-agent/src/lifecycle/launch/cursor_create_chat.rs +0 -229
  90. package/crates/team-agent/src/lifecycle/launch/cursor_mcp.rs +0 -522
  91. package/crates/team-agent/src/lifecycle/launch/cursor_mcp_iso.rs +0 -282
  92. package/crates/team-agent/src/lifecycle/tests/cursor_mcp_overlay.rs +0 -576
  93. package/crates/team-agent/src/lifecycle/tests/cursor_require_explicit_model_red.rs +0 -222
  94. package/crates/team-agent/src/lifecycle/tests/cursor_restart_resume_red.rs +0 -511
  95. package/crates/team-agent/src/provider/adapters/cursor_agent.rs +0 -44
  96. package/crates/team-agent/src/provider/session_scan/cursor.rs +0 -538
  97. package/crates/team-agent/src/provider/testdata/cursor-list-models-native.stdout +0 -250
package/Cargo.lock CHANGED
@@ -420,12 +420,6 @@ version = "0.4.34"
420
420
  source = "registry+https://github.com/rust-lang/crates.io-index"
421
421
  checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
422
422
 
423
- [[package]]
424
- name = "md5"
425
- version = "0.7.0"
426
- source = "registry+https://github.com/rust-lang/crates.io-index"
427
- checksum = "490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771"
428
-
429
423
  [[package]]
430
424
  name = "memchr"
431
425
  version = "2.8.3"
@@ -727,13 +721,12 @@ dependencies = [
727
721
 
728
722
  [[package]]
729
723
  name = "team-agent"
730
- version = "0.5.124"
724
+ version = "0.5.125"
731
725
  dependencies = [
732
726
  "anyhow",
733
727
  "chrono",
734
728
  "conpty-transport",
735
729
  "libc",
736
- "md5",
737
730
  "regex",
738
731
  "rusqlite",
739
732
  "serde",
package/Cargo.toml CHANGED
@@ -11,7 +11,7 @@ exclude = ["crates/team-agent-contract"]
11
11
 
12
12
  [workspace.package]
13
13
  edition = "2021"
14
- version = "0.5.124"
14
+ version = "0.5.125"
15
15
  license = "AGPL-3.0"
16
16
  rust-version = "1.95"
17
17
 
package/README.md CHANGED
@@ -131,8 +131,8 @@ The default is OFF. `~/.team-agent/argv-routing.json` stores the switch and mapp
131
131
  `enable`/`disable` preserve mappings; `set` replaces, `add` appends, and `clear` removes one mapping.
132
132
  Commands report both persisted and effective states, including an active environment override.
133
133
 
134
- Provider keys: `claude`, `codex`, `copilot`, `gemini_cli`, `grok`, `cursor_agent`, `pi`.
135
- Claude/Claude Code share one mapping; `claude_code`/`claude-code` and `agent`/`cursor` are accepted aliases.
134
+ Provider keys: `claude`, `codex`, `copilot`, `gemini_cli`, `grok`, `pi`.
135
+ Claude/Claude Code share one mapping; `claude_code`/`claude-code` are accepted aliases.
136
136
  Everything after the first `--` is literal argv data, including `--help`, `--json`, empty strings
137
137
  and `{workspace}`; no shell expansion is performed. Arguments are inserted immediately after
138
138
  the native executable, before its original arguments. Do not store secrets or override framework-managed
package/README.zh.md CHANGED
@@ -130,8 +130,8 @@ team-agent route disable
130
130
  (忽略大小写和两侧空白),无效值安全关闭。`enable/disable` 不清映射,`set` 精确替换、
131
131
  `add` 按序追加、`clear` 删除一个映射。结果同时报告持久化态、实际有效态与环境覆盖。
132
132
 
133
- Provider 键为 `claude`、`codex`、`copilot`、`gemini_cli`、`grok`、`cursor_agent`、`pi`。
134
- Claude/Claude Code 共用映射;支持 `claude_code/claude-code` 和 `agent/cursor` 别名。
133
+ Provider 键为 `claude`、`codex`、`copilot`、`gemini_cli`、`grok`、`pi`。
134
+ Claude/Claude Code 共用映射;支持 `claude_code/claude-code` 别名。
135
135
  第一个 `--` 后全部是字面 argv,包括 `--help`、`--json`、空字符串、`{workspace}`,不会二次 shell 展开。
136
136
  注入位置为原生 executable 之后、原有参数之前。不要保存密码/token,或覆盖框架管理的
137
137
  session/MCP/权限参数;既有身份、认证与安全检查不变。
@@ -22,7 +22,6 @@ thiserror.workspace = true
22
22
  serde.workspace = true
23
23
  serde_json.workspace = true
24
24
  sha2.workspace = true
25
- md5 = "0.7"
26
25
  regex.workspace = true
27
26
  chrono.workspace = true
28
27
  libc.workspace = true
@@ -117,6 +117,23 @@ fn is_public_window_name(provider: &str, window: &str) -> bool {
117
117
  if provider == "grok_build" && window == "grok" {
118
118
  return true;
119
119
  }
120
+ // An npm-installed Codex runs its vendor launcher under PATH's `node`, so
121
+ // tmux names the pane after that process instead of `codex`.
122
+ if provider == "codex_tui" && matches!(window, "codex" | "node") {
123
+ return true;
124
+ }
125
+ // The same holds for npm-installed Pi; legacy `pi` keeps its own rule.
126
+ if provider == "pi_tui" && matches!(window, "pi" | "node") {
127
+ return true;
128
+ }
129
+ // tmux names a Claude pane after the image its `claude` route execs: an npm
130
+ // `claude.exe`, or the native installer's version-named `<semver>` file.
131
+ if provider == "claude_tui"
132
+ && (matches!(window, "claude" | "claude.exe")
133
+ || team_agent_contract::providers::claude::catalog::semver(window))
134
+ {
135
+ return true;
136
+ }
120
137
  parse_provider(provider).is_some_and(|parsed| {
121
138
  command_name(parsed) == window
122
139
  || crate::layout::worker_window_helpers::provider_window_name(parsed) == window
@@ -1445,6 +1462,28 @@ mod tests {
1445
1462
  );
1446
1463
  }
1447
1464
 
1465
+ #[test]
1466
+ fn codex_contract_window_may_carry_its_public_or_node_launcher_name() {
1467
+ assert!(is_public_window_name("codex_tui", "codex"));
1468
+ assert!(is_public_window_name("codex_tui", "node"));
1469
+ assert!(!is_public_window_name("codex_tui", "grok"));
1470
+ assert!(!is_public_window_name("grok_build", "node"));
1471
+ assert!(is_public_window_name("pi_tui", "pi"));
1472
+ assert!(is_public_window_name("pi_tui", "node"));
1473
+ assert!(!is_public_window_name("pi_tui", "codex"));
1474
+ }
1475
+
1476
+ #[test]
1477
+ fn claude_contract_window_may_carry_its_npm_or_version_named_image() {
1478
+ for window in ["claude", "claude.exe", "2.1.309", "2.1.282"] {
1479
+ assert!(is_public_window_name("claude_tui", window), "{window}");
1480
+ }
1481
+ for window in ["2.1", "claude-wrapper", "node", "grok"] {
1482
+ assert!(!is_public_window_name("claude_tui", window), "{window}");
1483
+ }
1484
+ assert!(!is_public_window_name("grok_build", "2.1.309"));
1485
+ }
1486
+
1448
1487
  #[test]
1449
1488
  fn doctor_accepts_public_window_name_when_no_pane_id_is_recorded() {
1450
1489
  let state = grok_state(json!({}));
@@ -1721,7 +1760,6 @@ pub(crate) fn provider_doctor_checks() -> Value {
1721
1760
  crate::provider::Provider::Codex,
1722
1761
  crate::provider::Provider::GeminiCli,
1723
1762
  crate::provider::Provider::Grok,
1724
- crate::provider::Provider::CursorAgent,
1725
1763
  crate::provider::Provider::Fake,
1726
1764
  ] {
1727
1765
  let adapter = crate::provider::get_adapter(provider);
@@ -48,7 +48,7 @@ fn emit_with_json_order(
48
48
  }
49
49
 
50
50
  ///
51
- /// `main(argv)`(`parser.py:84`):**CLI 唯一进程入口**。codex/claude/copilot/grok/cursor passthrough 早返回 →
51
+ /// `main(argv)`(`parser.py:84`):**CLI 唯一进程入口**。codex/claude/copilot/grok passthrough 早返回 →
52
52
  /// 解析 argv 到 subcommand → 调对应 handler → 异常落盘 + 信封 + `ExitCode::Error` →
53
53
  /// `consume_leader_inbox_summary` → `emit` → `result.ok is False ? Error : Ok`。
54
54
  /// **行为入口**:契约可端到端跑 argv→(stdout, exit code)。
@@ -330,7 +330,7 @@ fn dispatch_machine(command: &str, args: &[String], cwd: &Path) -> Result<ExitCo
330
330
  // Command grammar, not provider identity parsing: these are top-level CLI
331
331
  // passthrough verbs for starting a leader under a provider executable.
332
332
  const LEADER_PASSTHROUGH_COMMANDS: &[&str] =
333
- &["codex", "claude", "copilot", "grok", "cursor", "pi"];
333
+ &["codex", "claude", "copilot", "grok", "pi"];
334
334
 
335
335
  pub(crate) fn is_leader_passthrough_command(command: &str) -> bool {
336
336
  LEADER_PASSTHROUGH_COMMANDS.contains(&command)
@@ -388,7 +388,7 @@ pub(crate) fn default_help() -> String {
388
388
  append_help_section(
389
389
  &mut out,
390
390
  "Leader launch",
391
- &["pi", "codex", "claude", "copilot", "grok", "cursor", "kiro"],
391
+ &["pi", "codex", "claude", "copilot", "grok", "kiro"],
392
392
  );
393
393
  out.push_str("\nCommand arguments and examples: team-agent <command> --help");
394
394
  out
@@ -457,7 +457,7 @@ pub(super) fn command_help(command: Option<&str>) -> String {
457
457
  "team-agent inbox leader -n 3\nteam-agent inbox worker --limit 5\nteam-agent inbox leader --workspace . --team help-demo --json", "Wait for a natural reply, then check team-agent status if needed. Do not inspect worker terminal content."),
458
458
  "status" => ("Optional <agent> selects one agent. --summary/--detail retain compatibility and do not add fields.\nNine fields: name/provider/model/effort/runtime_status/activity/health/session_name/tmux_command.\nRuntime, activity and health are distinct. unknown means insufficient evidence; null means unset. No default model is guessed.",
459
459
  "team-agent status\nteam-agent status worker\nteam-agent status --workspace . --team help-demo --json", "Read replies with team-agent inbox leader -n 3; diagnose problems with team-agent doctor --workspace ."),
460
- "models" => ("--provider selects the provider, default pi. QUERY or --search performs keyword search; they are mutually exclusive.\nUse cursor for the contract-native Cursor catalog; cursor_agent retains the legacy entrypoint. Copilot has no model discovery entrypoint here. Results come from the native catalog, not guesses.",
460
+ "models" => ("--provider selects the provider, default pi. QUERY or --search performs keyword search; they are mutually exclusive.\nUse cursor (or cursor-agent, agent, cursor_agent) for the contract-native Cursor catalog. Copilot has no model discovery entrypoint here. Results come from the native catalog, not guesses.",
461
461
  "team-agent models --provider pi\nteam-agent models --provider pi --search luna\nteam-agent models --provider cursor --json", "Use the exact returned model in a role file or team-agent start AGENT --model MODEL; stop a running seat before changing its settings."),
462
462
  "restart" => ("restart AGENT and team restart default to --session auto; bare/explicit-path restart keeps preserve.\n--session preserve requires continuation evidence; auto permits only the original legal fresh fallback, not guaranteed saved memory.\n--dry-run plans without lifecycle effects. --allow-fresh is the legacy authorized opt-in; --session-converge-deadline is in seconds.",
463
463
  "team-agent restart worker --dry-run --json\nteam-agent restart worker --session preserve --workspace . --dry-run --json", "Use team-agent team restart for deliberate team recovery; choose --session preserve when context must be retained. Team restart leaves explicitly stopped/paused seats alone; team-agent start intentionally activates the non-paused roster. Inspect partial/unknown outcomes with status/doctor, never blind reset or retry."),
@@ -499,7 +499,7 @@ pub(super) fn command_help(command: Option<&str>) -> String {
499
499
  "", "Prepare complete TEAM.md/roles with explicit user choices, then run team-agent start in the opened Leader's tool context, never an ordinary worker conversation."),
500
500
  };
501
501
  let examples = if matches!(spec.kind, CommandKind::LeaderPassthrough { .. }) {
502
- let native = if name == "cursor" { "agent" } else { name };
502
+ let native = name;
503
503
  if name == "pi" {
504
504
  "team-agent pi\nteam-agent pi -- --model openai-codex/gpt-6-luna\npi --help".to_string()
505
505
  } else {
@@ -525,9 +525,6 @@ pub(super) fn command_help(command: Option<&str>) -> String {
525
525
  if name == "restart" {
526
526
  out.push_str("\nRestart forms: restart AGENT selects one registered agent (default session auto); use agent restart ID to disambiguate a same-named directory. Legacy bare or explicit-path restart retains preserve and original receipts. New team restart defaults to auto. auto never means reset; native capability refusals remain authoritative.");
527
527
  }
528
- if name == "cursor" {
529
- out.push_str("\nDiscover models with team-agent models --provider cursor_agent.");
530
- }
531
528
  if name == "copilot" {
532
529
  out.push_str(
533
530
  "\nCopilot has no team-agent models entrypoint; consult native provider help.",
@@ -1646,9 +1643,20 @@ fn role_agent_args(
1646
1643
  }
1647
1644
  match flag {
1648
1645
  "--provider" => {
1649
- let provider = crate::provider::wire::parse_provider(&value)
1650
- .ok_or_else(|| CliError::Usage(format!("unknown provider: {value}")))?;
1651
- role.provider = Some(crate::provider::wire::provider_wire(provider).to_string());
1646
+ // A contract name (e.g. `agent` for Cursor) is written as its leaf id.
1647
+ #[cfg(unix)]
1648
+ let contract = crate::contract_runtime::registry::declared(&value, false)
1649
+ .map(|descriptor| descriptor.identity.id);
1650
+ #[cfg(not(unix))]
1651
+ let contract: Option<&str> = None;
1652
+ let provider = match contract {
1653
+ Some(id) => id,
1654
+ None => crate::provider::wire::provider_wire(
1655
+ crate::provider::wire::parse_provider(&value)
1656
+ .ok_or_else(|| CliError::Usage(format!("unknown provider: {value}")))?,
1657
+ ),
1658
+ };
1659
+ role.provider = Some(provider.to_string());
1652
1660
  }
1653
1661
  "--bypass" => {
1654
1662
  role.bypass = Some(match value.as_str() {
@@ -1735,6 +1743,24 @@ mod role_cli_tests {
1735
1743
  assert_eq!(patch.bypass, Some(false));
1736
1744
  }
1737
1745
 
1746
+ #[cfg(unix)]
1747
+ #[test]
1748
+ fn provider_accepts_contract_names_as_their_leaf_id() {
1749
+ for (name, leaf) in [
1750
+ ("cursor", "cursor"), ("cursor-agent", "cursor"), ("agent", "cursor"),
1751
+ ("cursor_agent", "cursor"), ("kiro", "kiro"), ("codex_tui", "codex_tui"),
1752
+ ] {
1753
+ let (_, patch) = role_agent_args(
1754
+ &strings(&["w", "--provider", name, "--bypass", "true"]), true,
1755
+ ).unwrap_or_else(|error| panic!("{name}: {error}"));
1756
+ assert_eq!(patch.provider.as_deref(), Some(leaf), "{name}");
1757
+ }
1758
+ let (_, patch) =
1759
+ role_agent_args(&strings(&["w", "--provider", "codex", "--bypass", "true"]), true).unwrap();
1760
+ assert_eq!(patch.provider.as_deref(), Some("codex"), "a bare shared key stays legacy");
1761
+ assert!(role_agent_args(&strings(&["w", "--provider", "Cursor", "--bypass", "true"]), true).is_err());
1762
+ }
1763
+
1738
1764
  #[test]
1739
1765
  fn strict_role_options_reject_ambiguous_values() {
1740
1766
  for args in [
@@ -2189,8 +2215,8 @@ mod tests {
2189
2215
  .collect();
2190
2216
  assert_eq!(
2191
2217
  expected.len(),
2192
- 35,
2193
- "the public catalog adds the four canonical lifecycle surfaces"
2218
+ 34,
2219
+ "the public catalog adds the four canonical lifecycle surfaces and retires the Cursor launcher"
2194
2220
  );
2195
2221
  for spec_name in &expected {
2196
2222
  assert!(
@@ -2522,12 +2548,12 @@ mod tests {
2522
2548
 
2523
2549
  let cursor = models_args(&cli_argv(&[
2524
2550
  "--provider",
2525
- "cursor_agent",
2551
+ "cursor",
2526
2552
  "--search",
2527
2553
  "GPT Luna",
2528
2554
  ]))
2529
2555
  .unwrap();
2530
- assert_eq!(cursor.provider, "cursor_agent");
2556
+ assert_eq!(cursor.provider, "cursor");
2531
2557
  assert_eq!(cursor.search.as_deref(), Some("GPT Luna"));
2532
2558
 
2533
2559
  let both = models_args(&cli_argv(&["luna", "--search", "gpt"])).unwrap_err();
@@ -481,32 +481,14 @@ fn stop_args(plan: &Plan, id: &str) -> StopAgentArgs {
481
481
  json: true,
482
482
  }
483
483
  }
484
- fn check_incarnation_cwd(
485
- selected: &SelectedTeam,
486
- id: &str,
487
- row: &Value,
488
- provider: crate::provider::Provider,
489
- ) -> Result<(), CliError> {
484
+ fn check_incarnation_cwd(selected: &SelectedTeam, row: &Value) -> Result<(), CliError> {
490
485
  if let Some(cwd) = row
491
486
  .get("spawn_cwd")
492
487
  .and_then(Value::as_str)
493
488
  .filter(|cwd| !cwd.is_empty())
494
489
  {
495
- let declared_cwd = Path::new(cwd);
496
- let cwd = checked(declared_cwd.canonicalize())?;
497
- let inside = cwd.starts_with(&selected.run_workspace);
498
- #[cfg(unix)]
499
- let owned_cursor_primary = !inside
500
- && provider == crate::provider::Provider::CursorAgent
501
- && checked(crate::lifecycle::launch::cursor_mcp_primary_matches_scope(
502
- &selected.run_workspace,
503
- &selected.team_key,
504
- id,
505
- declared_cwd,
506
- ))?;
507
- #[cfg(not(unix))]
508
- let owned_cursor_primary = false;
509
- if !cwd.is_dir() || !(inside || owned_cursor_primary) {
490
+ let cwd = checked(Path::new(cwd).canonicalize())?;
491
+ if !cwd.is_dir() || !cwd.starts_with(&selected.run_workspace) {
510
492
  return Err(refusal("legacy incarnation cwd is outside the selected workspace; no context or scope fallback"));
511
493
  }
512
494
  }
@@ -589,7 +571,7 @@ fn preflight_start(
589
571
  {
590
572
  return Err(refusal("resume metadata lacks the scoped spawn cwd"));
591
573
  }
592
- check_incarnation_cwd(selected, id, row, provider)?;
574
+ check_incarnation_cwd(selected, row)?;
593
575
  if row
594
576
  .get("task_prompt_delivered")
595
577
  .is_some_and(|value| !value.is_null() && !value.is_boolean())
@@ -649,13 +631,7 @@ fn add(
649
631
  {
650
632
  return Err(usage("role creation requires explicit provider and dangerously_skip_permissions decisions"));
651
633
  }
652
- let (_, compiled) = role(plan, selected, id, Some(&path))?;
653
- #[cfg(unix)]
654
- if crate::contract_runtime::registry::descriptor(provider(&compiled)).is_some() {
655
- return Err(refusal(
656
- "native dynamic add is not admitted; no legacy fallback",
657
- ));
658
- }
634
+ role(plan, selected, id, Some(&path))?;
659
635
  path.to_string_lossy().into_owned()
660
636
  }
661
637
  None => {
@@ -664,16 +640,6 @@ fn add(
664
640
  "unknown agent: supply a complete --role-file or --provider and --bypass",
665
641
  ));
666
642
  }
667
- #[cfg(unix)]
668
- if patch
669
- .provider
670
- .as_deref()
671
- .is_some_and(|p| crate::contract_runtime::registry::descriptor(p).is_some())
672
- {
673
- return Err(refusal(
674
- "native dynamic add is not admitted; no legacy fallback",
675
- ));
676
- }
677
643
  String::new()
678
644
  }
679
645
  };
@@ -1216,20 +1182,6 @@ pub(super) fn recheck(plan: &Plan, step: &Step, after_stop: bool) -> Result<(),
1216
1182
  }
1217
1183
  }
1218
1184
  }
1219
- #[cfg(unix)]
1220
- if !crate::contract_runtime::framework::is_contract(row)
1221
- && crate::provider::wire::parse_provider(provider(row))
1222
- == Some(crate::provider::Provider::CursorAgent)
1223
- && (matches!(step, Step::StartAgent(_))
1224
- || (plan.intent.verb == Verb::Restart && matches!(step, Step::StopAgent(_)))
1225
- || (matches!(step, Step::RestartTeam(_))
1226
- && row.get("status").and_then(Value::as_str) == Some("running")
1227
- && !crate::state::projection::agent_explicit_stop(row)))
1228
- {
1229
- // Reopen the same ownership proof at the existing execution recheck,
1230
- // before effects; a planning-time receipt is not a filesystem lease.
1231
- check_incarnation_cwd(&selected, id, row, crate::provider::Provider::CursorAgent)?;
1232
- }
1233
1185
  }
1234
1186
  Ok(())
1235
1187
  }
@@ -2,10 +2,6 @@
2
2
  use super::super::tests::Sandbox;
3
3
  use super::*;
4
4
 
5
- #[cfg(unix)]
6
- #[path = "../../../tests/support/hermetic.rs"]
7
- mod hermetic_guard;
8
-
9
5
  fn fixture(ids: &[&str]) -> (Sandbox, Intent) {
10
6
  let root = Sandbox::new();
11
7
  std::fs::create_dir(root.path().join("agents")).unwrap();
@@ -452,116 +448,6 @@ fn preserve_rejects_known_missing_backing_before_stop_auto_uses_existing_decisio
452
448
  }
453
449
  }
454
450
 
455
- #[cfg(unix)]
456
- fn cursor_scope_fixture() -> (
457
- hermetic_guard::HermeticTestEnv,
458
- Sandbox,
459
- SelectedTeam,
460
- PathBuf,
461
- Value,
462
- ) {
463
- let env = hermetic_guard::HermeticTestEnv::enter("cursor-intent-scope");
464
- let (root, _) = fixture(&["one"]);
465
- install(root.path(), &[("one", "stopped", true)]);
466
- let selected =
467
- resolve_active_team_readonly(root.path(), Some("fixture"), SelectorMode::RuntimeOnly)
468
- .unwrap();
469
- let config = crate::provider::McpConfig {
470
- raw: json!({"team_orchestrator": {
471
- "command": std::env::current_exe().unwrap(),
472
- "args": ["mcp-server", "--workspace", root.path()],
473
- "env": {"TEAM_AGENT_WORKSPACE": root.path(), "TEAM_AGENT_ID": "one", "TEAM_AGENT_OWNER_TEAM_ID": "fixture", "TEAM_AGENT_AUTH_MODE": "subscription"}
474
- }}),
475
- };
476
- let primary = crate::lifecycle::launch::prepare_cursor_seat_mcp(root.path(), "one", &config)
477
- .unwrap()
478
- .unwrap();
479
- let sid = "af3ce55e-2ee9-4bc5-8dae-b628e7447286";
480
- let archive = env
481
- .home()
482
- .join(".cursor/chats")
483
- .join(format!(
484
- "{:x}",
485
- md5::compute(primary.to_string_lossy().as_bytes())
486
- ))
487
- .join(sid);
488
- std::fs::create_dir_all(&archive).unwrap();
489
- std::fs::write(archive.join("meta.json"), b"{}").unwrap();
490
- let row = json!({"provider":"cursor_agent","status":"stopped","explicit_stop":true,"session_id":sid,"rollout_path":archive,"spawn_cwd":primary});
491
- (env, root, selected, primary, row)
492
- }
493
-
494
- #[test]
495
- #[cfg(unix)]
496
- #[serial_test::serial(env)]
497
- fn issue342_cursor_owned_primary_scope_is_readonly_and_exact() {
498
- let (_env, root, selected, primary, row) = cursor_scope_fixture();
499
- let state = crate::state::persist::runtime_state_path(root.path());
500
- let record = root
501
- .path()
502
- .join(".team/runtime/provider-config/one/cursor-project.json");
503
- let paths = [state, record, primary.join(".cursor/mcp.json")];
504
- let before: Vec<_> = paths.iter().map(|p| std::fs::read(p).unwrap()).collect();
505
- assert!(!primary.starts_with(root.path()));
506
- for policy in [SessionPolicy::Preserve, SessionPolicy::Auto] {
507
- assert!(preflight_start(&selected, "one", &row, policy).is_ok());
508
- }
509
- let after: Vec<_> = paths.iter().map(|p| std::fs::read(p).unwrap()).collect();
510
- assert_eq!(
511
- before, after,
512
- "scope preflight must not write state, record or MCP config"
513
- );
514
-
515
- let mut foreign_provider = row.clone();
516
- foreign_provider["provider"] = json!("pi");
517
- assert!(preflight_start(&selected, "one", &foreign_provider, SessionPolicy::Auto).is_err());
518
- let mut other_team = selected.clone();
519
- other_team.team_key = "foreign-team".into();
520
- assert!(preflight_start(&other_team, "one", &row, SessionPolicy::Preserve).is_err());
521
- assert!(preflight_start(&selected, "two", &row, SessionPolicy::Preserve).is_err());
522
- let outside = Sandbox::new();
523
- let mut other_workspace = selected.clone();
524
- other_workspace.run_workspace = outside.path().to_owned();
525
- assert!(preflight_start(&other_workspace, "one", &row, SessionPolicy::Preserve).is_err());
526
- assert!(!outside.path().join(".team").exists());
527
- }
528
-
529
- #[test]
530
- #[cfg(unix)]
531
- #[serial_test::serial(env)]
532
- fn issue342_cursor_scope_refuses_unrecorded_alias_and_replaced_incarnation() {
533
- use std::os::unix::fs::{symlink, DirBuilderExt};
534
- let (_env, root, selected, primary, row) = cursor_scope_fixture();
535
- let record = root
536
- .path()
537
- .join(".team/runtime/provider-config/one/cursor-project.json");
538
- let bytes = std::fs::read(&record).unwrap();
539
- let retained = record.with_extension("retained");
540
- std::fs::rename(&record, &retained).unwrap();
541
- assert!(preflight_start(&selected, "one", &row, SessionPolicy::Preserve).is_err());
542
- assert!(
543
- !record.exists(),
544
- "a same-named external directory is not authority to create a record"
545
- );
546
- std::fs::rename(retained, &record).unwrap();
547
- let mut forged = row.clone();
548
- let arbitrary = Sandbox::new();
549
- forged["spawn_cwd"] = json!(arbitrary.path());
550
- assert!(preflight_start(&selected, "one", &forged, SessionPolicy::Auto).is_err());
551
- let alias = root.path().join("primary-alias");
552
- symlink(&primary, &alias).unwrap();
553
- forged["spawn_cwd"] = json!(alias);
554
- assert!(preflight_start(&selected, "one", &forged, SessionPolicy::Preserve).is_err());
555
- let old = primary.with_extension("retained");
556
- std::fs::rename(&primary, old).unwrap();
557
- std::fs::DirBuilder::new()
558
- .mode(0o700)
559
- .create(&primary)
560
- .unwrap();
561
- assert!(preflight_start(&selected, "one", &row, SessionPolicy::Auto).is_err());
562
- assert_eq!(std::fs::read(record).unwrap(), bytes);
563
- }
564
-
565
451
  #[test]
566
452
  #[serial_test::serial(env)]
567
453
  fn changed_role_and_socket_refuse_in_the_real_readonly_recheck() {
@@ -637,10 +523,6 @@ fn stopped_text_without_physical_identity_is_unknown_and_standalone_source_keeps
637
523
 
638
524
  #[test]
639
525
  fn declared_provider_aliases_do_not_create_false_drift_or_absorb_native_routes() {
640
- assert!(!drift(
641
- &json!({"provider":"agent"}),
642
- &json!({"provider":"cursor_agent"})
643
- ));
644
526
  assert!(same_provider("claude-code", "claude_code"));
645
527
  assert!(!same_provider("cursor", "cursor_agent"));
646
528
  assert!(!same_provider("grok_build", "grok"));
@@ -712,8 +594,6 @@ fn provider_argv0_is_exact_basename_not_substring() {
712
594
  for argv0 in ["2.1.309", "claude-wrapper", "team-agent", "node", ""] {
713
595
  assert!(!argv0_names(argv0, Provider::Claude), "{argv0}");
714
596
  }
715
- assert!(argv0_names("agent", Provider::CursorAgent));
716
- assert!(!argv0_names("team-agent", Provider::CursorAgent));
717
597
  }
718
598
 
719
599
  #[test]
@@ -1,5 +1,5 @@
1
1
  //!
2
- //! cli · leader — `codex`/`claude`/`copilot`/`grok`/`cursor` passthrough(`cmd_leader_passthrough` + `_provider_args` /
2
+ //! cli · leader — `codex`/`claude`/`copilot`/`grok` passthrough(`cmd_leader_passthrough` + `_provider_args` /
3
3
  //! `_leader_launcher_args`)+ leader fallback inbox 摘要(`consume_leader_inbox_summary` 及
4
4
  //! `_leader_inbox_entries` / `_leader_inbox_summary` / `_leader_inbox_entry_title`)。
5
5
 
@@ -96,7 +96,7 @@ fn without_leader_json(values: &[String]) -> Vec<String> {
96
96
  }
97
97
 
98
98
  ///
99
- /// `codex`/`claude`/`copilot`/`grok`/`cursor` passthrough(`parser.py:86`/`_run_leader_passthrough`):leader 早返回,
99
+ /// `codex`/`claude`/`copilot`/`grok` passthrough(`parser.py:86`/`_run_leader_passthrough`):leader 早返回,
100
100
  /// **不**进 subparser。`-h`/`--help` 打 usage 直接返回 [`CmdResult::none`]。否则解析 attach
101
101
  /// 旗标 + `lifecycle_port::start_leader`。`command` 必须是闭集动词,禁止 command-text 回落到 ClaudeCode。
102
102
  pub fn cmd_leader_passthrough(
@@ -140,7 +140,6 @@ pub(crate) fn leader_passthrough_provider(command: &str) -> Option<crate::model:
140
140
  "claude" => Some(Provider::ClaudeCode),
141
141
  "copilot" => Some(Provider::Copilot),
142
142
  "grok" => Some(Provider::Grok),
143
- "cursor" => Some(Provider::CursorAgent),
144
143
  "pi" => Some(Provider::Pi),
145
144
  _ => None,
146
145
  }
@@ -5,7 +5,7 @@ use serde_json::json;
5
5
  use std::io::{self, Write};
6
6
  use std::path::PathBuf;
7
7
 
8
- pub(crate) const HELP: &str = "Purpose:\nPersist supplemental system instructions for future Team Agent Leader launches only.\nUsage: team-agent leader-prompt [show|set|append|clear] [--json] [--file PATH | -- TEXT]\n\nOptions:\nshow (default) prints the exact text; set replaces it; append joins old and new text with two newlines; clear removes it.\nset/append require exactly one TEXT token after --, or --file PATH containing UTF-8 text. No implicit stdin.\nEverything after -- is literal text, including --json and --help. Empty text and NUL are rejected.\nConfiguration: ~/.team-agent/leader-prompt.txt, independent of the workspace. Mutations do not echo the text.\nOnly new Pi, Claude, Codex and Grok Leaders apply it; Worker launches never read it. Cursor/Copilot are refused when configured.\nCodex merges explicit argv developer_instructions, but overrides that user/profile configuration slot; migrate its existing text here.\nNative core prompts and unrelated launch arguments remain unchanged. Attach does not update an existing session.\nExamples:\nteam-agent leader-prompt show\nteam-agent leader-prompt set -- 'Keep replies concise.'\nteam-agent leader-prompt clear\n\nNext Action:\nUse show to inspect the text, then start a new Leader with team-agent pi (or claude/codex/grok).\nset/append/clear affect the next new process, not running Leaders or their conversation history.";
8
+ pub(crate) const HELP: &str = "Purpose:\nPersist supplemental system instructions for future Team Agent Leader launches only.\nUsage: team-agent leader-prompt [show|set|append|clear] [--json] [--file PATH | -- TEXT]\n\nOptions:\nshow (default) prints the exact text; set replaces it; append joins old and new text with two newlines; clear removes it.\nset/append require exactly one TEXT token after --, or --file PATH containing UTF-8 text. No implicit stdin.\nEverything after -- is literal text, including --json and --help. Empty text and NUL are rejected.\nConfiguration: ~/.team-agent/leader-prompt.txt, independent of the workspace. Mutations do not echo the text.\nOnly new Pi, Claude, Codex and Grok Leaders apply it; Worker launches never read it. Copilot is refused when configured.\nCodex merges explicit argv developer_instructions, but overrides that user/profile configuration slot; migrate its existing text here.\nNative core prompts and unrelated launch arguments remain unchanged. Attach does not update an existing session.\nExamples:\nteam-agent leader-prompt show\nteam-agent leader-prompt set -- 'Keep replies concise.'\nteam-agent leader-prompt clear\n\nNext Action:\nUse show to inspect the text, then start a new Leader with team-agent pi (or claude/codex/grok).\nset/append/clear affect the next new process, not running Leaders or their conversation history.";
9
9
 
10
10
  #[derive(Clone, Copy, Debug, Eq, PartialEq)]
11
11
  enum Operation {
@@ -3467,18 +3467,19 @@ pub mod lifecycle_port {
3467
3467
  ) -> Result<Value, CliError> {
3468
3468
  let agent_id = crate::model::ids::AgentId::new(agent);
3469
3469
  let source = (!role_file.is_empty()).then(|| Path::new(role_file));
3470
+ // A contract role is added by the same role transaction; its seat then
3471
+ // starts in the native framework (lifecycle::launch::add_agent).
3470
3472
  #[cfg(unix)]
3471
- {
3473
+ if !crate::contract_runtime::framework::declares_contract(
3474
+ source,
3475
+ role_config.provider.as_deref(),
3476
+ ) {
3472
3477
  crate::contract_runtime::framework::require_legacy_lifecycle(
3473
3478
  workspace,
3474
3479
  team,
3475
3480
  Some(agent),
3476
3481
  "add-agent",
3477
3482
  )?;
3478
- crate::contract_runtime::framework::require_legacy_role(
3479
- source,
3480
- role_config.provider.as_deref(),
3481
- )?;
3482
3483
  }
3483
3484
  match crate::lifecycle::role_config::add_agent_from_role(
3484
3485
  workspace,