@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.
Files changed (151) 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 -69
  7. package/crates/team-agent/src/cli/emit.rs +45 -15
  8. package/crates/team-agent/src/cli/intent/runtime.rs +5 -53
  9. package/crates/team-agent/src/cli/intent/runtime_tests.rs +10 -130
  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 +28 -33
  13. package/crates/team-agent/src/cli/models.rs +44 -880
  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/mod.rs +1 -1
  22. package/crates/team-agent/src/cli/tests/run_delegation.rs +5 -4
  23. package/crates/team-agent/src/cli/tests/status_send.rs +17 -0
  24. package/crates/team-agent/src/compiler/tests.rs +39 -8
  25. package/crates/team-agent/src/compiler.rs +28 -204
  26. package/crates/team-agent/src/contract_runtime/backend.rs +79 -40
  27. package/crates/team-agent/src/contract_runtime/config.rs +37 -24
  28. package/crates/team-agent/src/contract_runtime/discovery.rs +33 -0
  29. package/crates/team-agent/src/contract_runtime/fork.rs +368 -0
  30. package/crates/team-agent/src/contract_runtime/framework.rs +87 -34
  31. package/crates/team-agent/src/contract_runtime/mod.rs +1 -0
  32. package/crates/team-agent/src/contract_runtime/registry.rs +299 -21
  33. package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -1
  34. package/crates/team-agent/src/coordinator/tests/api_error_recovery.rs +29 -8
  35. package/crates/team-agent/src/coordinator/tests/health_sync.rs +0 -42
  36. package/crates/team-agent/src/coordinator/tick.rs +89 -1
  37. package/crates/team-agent/src/db/message_store.rs +78 -3
  38. package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -1
  39. package/crates/team-agent/src/leader/prompt.rs +1 -2
  40. package/crates/team-agent/src/leader/provider_attribution.rs +0 -52
  41. package/crates/team-agent/src/leader/start.rs +1 -2
  42. package/crates/team-agent/src/leader/tests/prompt_contract.rs +2 -3
  43. package/crates/team-agent/src/lifecycle/launch/add_agent.rs +91 -0
  44. package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +15 -195
  45. package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -9
  46. package/crates/team-agent/src/lifecycle/launch/clone_agent.rs +11 -27
  47. package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +18 -29
  48. package/crates/team-agent/src/lifecycle/launch/fork_entry.rs +6 -87
  49. package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +3 -11
  50. package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +74 -244
  51. package/crates/team-agent/src/lifecycle/launch/quick_start.rs +0 -24
  52. package/crates/team-agent/src/lifecycle/launch/role_source.rs +5 -0
  53. package/crates/team-agent/src/lifecycle/launch/spawn.rs +21 -61
  54. package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -1
  55. package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -108
  56. package/crates/team-agent/src/lifecycle/launch.rs +2 -43
  57. package/crates/team-agent/src/lifecycle/profile_launch.rs +21 -348
  58. package/crates/team-agent/src/lifecycle/profile_smoke.rs +1 -2
  59. package/crates/team-agent/src/lifecycle/restart/common.rs +43 -378
  60. package/crates/team-agent/src/lifecycle/restart/selection.rs +5 -5
  61. package/crates/team-agent/src/lifecycle/restart.rs +0 -2
  62. package/crates/team-agent/src/lifecycle/role_config.rs +42 -3
  63. package/crates/team-agent/src/lifecycle/tests/behavioral_diff_264_red.rs +11 -6
  64. package/crates/team-agent/src/lifecycle/tests/claude_profile_launch_red.rs +8 -320
  65. package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +60 -145
  66. package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +8 -334
  67. package/crates/team-agent/src/lifecycle/tests/communication_mode_runtime_contract_red.rs +30 -11
  68. package/crates/team-agent/src/lifecycle/tests/copilot_provider_red.rs +2 -2
  69. package/crates/team-agent/src/lifecycle/tests/core.rs +17 -16
  70. package/crates/team-agent/src/lifecycle/tests/grok_require_explicit_model_red.rs +12 -12
  71. package/crates/team-agent/src/lifecycle/tests/harvest2_a_batch_red.rs +3 -51
  72. package/crates/team-agent/src/lifecycle/tests/launch_spawn.rs +26 -28
  73. package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +6 -18
  74. package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +52 -70
  75. package/crates/team-agent/src/lifecycle/tests/pi_dual_entry_red.rs +4 -157
  76. package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +10 -302
  77. package/crates/team-agent/src/lifecycle/tests/pi_lifecycle_doctor_red.rs +1 -68
  78. package/crates/team-agent/src/lifecycle/tests/pi_native_mcp_capability_red.rs +1 -19
  79. package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +2 -100
  80. package/crates/team-agent/src/lifecycle/tests/quick_start_worker_readiness_red.rs +11 -10
  81. package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1
  82. package/crates/team-agent/src/lifecycle/tests/restart_session_capture_red.rs +2 -106
  83. package/crates/team-agent/src/lifecycle/tests/status_credential_redaction_contract.rs +2 -2
  84. package/crates/team-agent/src/lifecycle/tests/swallow_batch4_semantics_red.rs +2 -254
  85. package/crates/team-agent/src/lifecycle/tests/upgrade_compat_0211_red.rs +4 -4
  86. package/crates/team-agent/src/lifecycle/tests/verify_rs031_window_consistency_red.rs +6 -5
  87. package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +7 -153
  88. package/crates/team-agent/src/lifecycle/tests.rs +0 -6
  89. package/crates/team-agent/src/lifecycle/types.rs +2 -18
  90. package/crates/team-agent/src/lifecycle/worker_command_context.rs +2 -4
  91. package/crates/team-agent/src/mcp_server/readiness.rs +148 -97
  92. package/crates/team-agent/src/mcp_server/readiness_tests.rs +115 -16
  93. package/crates/team-agent/src/messaging/delivery.rs +185 -168
  94. package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +5 -5
  95. package/crates/team-agent/src/messaging/enter_rescue_tests.rs +1 -1
  96. package/crates/team-agent/src/messaging/helpers.rs +19 -0
  97. package/crates/team-agent/src/messaging/tests/dup_inject.rs +67 -5
  98. package/crates/team-agent/src/messaging/tests/runtime.rs +110 -4
  99. package/crates/team-agent/src/messaging/tests/spine.rs +46 -36
  100. package/crates/team-agent/src/model/enums.rs +1 -8
  101. package/crates/team-agent/src/provider/adapter.rs +33 -302
  102. package/crates/team-agent/src/provider/adapters/mod.rs +4 -5
  103. package/crates/team-agent/src/provider/argv_route.rs +1 -5
  104. package/crates/team-agent/src/provider/bypass_flags.rs +3 -11
  105. package/crates/team-agent/src/provider/classify.rs +68 -3
  106. package/crates/team-agent/src/provider/faults.rs +1 -1
  107. package/crates/team-agent/src/provider/model_catalog.rs +14 -273
  108. package/crates/team-agent/src/provider/session/capture.rs +7 -107
  109. package/crates/team-agent/src/provider/session/context_fork/outcome.rs +0 -4
  110. package/crates/team-agent/src/provider/session/context_fork.rs +17 -109
  111. package/crates/team-agent/src/provider/session_scan/common.rs +11 -36
  112. package/crates/team-agent/src/provider/session_scan/pi.rs +1 -34
  113. package/crates/team-agent/src/provider/session_scan.rs +4 -14
  114. package/crates/team-agent/src/provider/submit_now.rs +5 -28
  115. package/crates/team-agent/src/provider/tests/adapter.rs +39 -275
  116. package/crates/team-agent/src/provider/tests/classify.rs +53 -0
  117. package/crates/team-agent/src/provider/tests/command_helpers.rs +3 -15
  118. package/crates/team-agent/src/provider/tests/idle.rs +0 -25
  119. package/crates/team-agent/src/provider/types.rs +1 -1
  120. package/crates/team-agent/src/provider/wire.rs +79 -11
  121. package/crates/team-agent/src/state/abnormal_watch/tests/mod.rs +1 -1
  122. package/crates/team-agent/src/state/persist.rs +6 -6
  123. package/crates/team-agent/src/state/repository/tests.rs +2 -2
  124. package/crates/team-agent/src/tmux_backend/native_input_tests.rs +2 -178
  125. package/crates/team-agent/src/tmux_backend/tests.rs +151 -0
  126. package/crates/team-agent/src/tmux_backend.rs +43 -8
  127. package/crates/team-agent/src/transport/native_input.rs +2 -231
  128. package/package.json +4 -4
  129. package/skills/team-agent/SKILL.md +7 -5
  130. package/skills/team-agent/command-coverage.json +15 -1
  131. package/skills/team-agent/docs/reference/team-agent-operator.md +5 -3
  132. package/skills/team-agent/references/team-agent-operator.md +5 -3
  133. package/crates/team-agent/src/lifecycle/launch/cursor_create_chat.rs +0 -229
  134. package/crates/team-agent/src/lifecycle/launch/cursor_mcp.rs +0 -522
  135. package/crates/team-agent/src/lifecycle/launch/cursor_mcp_iso.rs +0 -282
  136. package/crates/team-agent/src/lifecycle/restart/avatar.rs +0 -1805
  137. package/crates/team-agent/src/lifecycle/tests/claude_compatible_config_red.rs +0 -325
  138. package/crates/team-agent/src/lifecycle/tests/cursor_mcp_overlay.rs +0 -576
  139. package/crates/team-agent/src/lifecycle/tests/cursor_require_explicit_model_red.rs +0 -222
  140. package/crates/team-agent/src/lifecycle/tests/cursor_restart_resume_red.rs +0 -511
  141. package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +0 -210
  142. package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +0 -1409
  143. package/crates/team-agent/src/provider/adapters/claude.rs +0 -78
  144. package/crates/team-agent/src/provider/adapters/claude_fork.rs +0 -131
  145. package/crates/team-agent/src/provider/adapters/cursor_agent.rs +0 -44
  146. package/crates/team-agent/src/provider/adapters/pi.rs +0 -100
  147. package/crates/team-agent/src/provider/session/context_fork/claude.rs +0 -123
  148. package/crates/team-agent/src/provider/session_scan/claude.rs +0 -523
  149. package/crates/team-agent/src/provider/session_scan/cursor.rs +0 -538
  150. package/crates/team-agent/src/provider/testdata/cursor-list-models-native.stdout +0 -250
  151. package/crates/team-agent/src/test_support/models_timeout_fixture.rs +0 -144
@@ -24,6 +24,57 @@
24
24
 
25
25
  use crate::model::enums::Provider;
26
26
 
27
+ /// A state row written by a release that still ran a legacy worker engine:
28
+ /// Cursor's `cursor_agent`/`agent`, Claude Code's `claude`/`claude_code` or
29
+ /// Pi's `pi`. No legacy worker runtime exists for it now; it must never fall
30
+ /// back to another provider. Role and CLI declarations of these names select
31
+ /// the contract leaf, whose state row carries the leaf id instead. A leader is
32
+ /// not an `agents` row, so its own provider key is unaffected.
33
+ pub(crate) const RETIRED_PROVIDER_ERROR: &str =
34
+ "legacy cursor_agent seat has no runtime in this release; stop or remove it, then add it again (provider: cursor)";
35
+ const RETIRED_CLAUDE_ERROR: &str =
36
+ "legacy claude seat has no runtime in this release; stop or remove it, then add it again (provider: claude)";
37
+ const RETIRED_PI_ERROR: &str =
38
+ "legacy pi seat has no runtime in this release; stop or remove it, then add it again (provider: pi)";
39
+
40
+ pub(crate) fn is_retired_provider(raw: &str) -> bool {
41
+ matches!(
42
+ raw.trim().to_ascii_lowercase().as_str(),
43
+ "cursor_agent" | "agent" | "claude" | "claude_code" | "claude-code" | "pi"
44
+ )
45
+ }
46
+
47
+ /// The refusal for a retired state row, naming the provider to re-add it with.
48
+ pub(crate) fn retired_provider_error(raw: &str) -> &'static str {
49
+ match raw.trim().to_ascii_lowercase().as_str() {
50
+ "claude" | "claude_code" | "claude-code" => RETIRED_CLAUDE_ERROR,
51
+ "pi" => RETIRED_PI_ERROR,
52
+ _ => RETIRED_PROVIDER_ERROR,
53
+ }
54
+ }
55
+
56
+ pub(crate) fn require_active_state_providers(
57
+ state: &serde_json::Value,
58
+ target: Option<&str>,
59
+ ) -> Result<(), &'static str> {
60
+ let retired = state
61
+ .get("agents")
62
+ .and_then(serde_json::Value::as_object)
63
+ .and_then(|agents| {
64
+ agents.iter().find_map(|(id, row)| {
65
+ row.get("provider")
66
+ .and_then(serde_json::Value::as_str)
67
+ .filter(|provider| {
68
+ target.is_none_or(|target| target == id) && is_retired_provider(provider)
69
+ })
70
+ })
71
+ });
72
+ match retired {
73
+ Some(provider) => Err(retired_provider_error(provider)),
74
+ None => Ok(()),
75
+ }
76
+ }
77
+
27
78
  /// Canonical snake_case wire string for `Provider`. Used for state JSON,
28
79
  /// log fields, and any cross-process serialization. Stable: do not change
29
80
  /// existing values.
@@ -35,7 +86,6 @@ pub(crate) fn provider_wire(provider: Provider) -> &'static str {
35
86
  Provider::Copilot => "copilot",
36
87
  Provider::GeminiCli => "gemini_cli",
37
88
  Provider::Grok => "grok",
38
- Provider::CursorAgent => "cursor_agent",
39
89
  Provider::Pi => "pi",
40
90
  Provider::Fake => "fake",
41
91
  }
@@ -83,7 +133,6 @@ pub(crate) fn requires_resume_backing(provider: Provider) -> bool {
83
133
  | Provider::ClaudeCode
84
134
  | Provider::Copilot
85
135
  | Provider::Grok
86
- | Provider::CursorAgent
87
136
  | Provider::Pi
88
137
  )
89
138
  }
@@ -104,10 +153,6 @@ pub(crate) fn aliases(provider: Provider) -> &'static [&'static str] {
104
153
  Provider::Copilot => &["copilot"],
105
154
  Provider::GeminiCli => &["gemini_cli"],
106
155
  Provider::Grok => &["grok"],
107
- // canonical wire form 恒为首项 (parse_provider round-trip 依赖); "agent"
108
- // 是 exec 二进制名, 仅作 alias (不参与 command-text 子串匹配, 见
109
- // leader/provider_attribution.rs TODO)。
110
- Provider::CursorAgent => &["cursor_agent", "agent"],
111
156
  Provider::Pi => &["pi"],
112
157
  Provider::Fake => &["fake"],
113
158
  }
@@ -125,7 +170,6 @@ pub(crate) fn command_name(provider: Provider) -> &'static str {
125
170
  Provider::Copilot => "copilot",
126
171
  Provider::GeminiCli => "gemini",
127
172
  Provider::Grok => "grok",
128
- Provider::CursorAgent => "agent",
129
173
  Provider::Pi => "pi",
130
174
  Provider::Fake => "team-agent",
131
175
  }
@@ -138,7 +182,6 @@ const ALL_PROVIDERS: &[Provider] = &[
138
182
  Provider::Copilot,
139
183
  Provider::GeminiCli,
140
184
  Provider::Grok,
141
- Provider::CursorAgent,
142
185
  Provider::Pi,
143
186
  Provider::Fake,
144
187
  ];
@@ -215,9 +258,7 @@ mod tests {
215
258
  "compiler must validate providers through typed helpers"
216
259
  );
217
260
  assert!(
218
- delivery_rs.contains("parse_canonical_provider")
219
- && delivery_rs.contains("parse_provider")
220
- && delivery_rs.contains("provider_wire"),
261
+ delivery_rs.contains("parse_canonical_provider"),
221
262
  "message delivery provider dispatch must use wire helpers"
222
263
  );
223
264
  for (path, source) in [
@@ -290,6 +331,33 @@ mod tests {
290
331
  assert_eq!(parse_provider("CLAUDE"), None); // case-sensitive
291
332
  }
292
333
 
334
+ #[test]
335
+ fn retired_state_guard_is_scoped_to_the_addressed_seat() {
336
+ let state = serde_json::json!({"agents": {
337
+ "pi": {"provider": "pi_tui"},
338
+ "claude": {"provider": "claude_tui"},
339
+ "copilot": {"provider": "copilot"},
340
+ "retired": {"provider": "cursor_agent"},
341
+ "legacy_claude": {"provider": "claude_code"},
342
+ "legacy_pi": {"provider": "pi"}
343
+ }});
344
+ assert!(require_active_state_providers(&state, Some("pi")).is_ok());
345
+ assert!(require_active_state_providers(&state, Some("claude")).is_ok());
346
+ assert!(require_active_state_providers(&state, Some("copilot")).is_ok());
347
+ assert_eq!(require_active_state_providers(&state, Some("retired")), Err(RETIRED_PROVIDER_ERROR));
348
+ assert_eq!(require_active_state_providers(&state, Some("legacy_claude")), Err(RETIRED_CLAUDE_ERROR));
349
+ assert_eq!(require_active_state_providers(&state, Some("legacy_pi")), Err(RETIRED_PI_ERROR));
350
+ assert!(require_active_state_providers(&state, None).is_err());
351
+ for retired in ["cursor_agent", "agent"] {
352
+ assert_eq!(parse_provider(retired), None, "no legacy engine to parse into");
353
+ }
354
+ // The leader keys still parse: a leader is never an `agents` row.
355
+ for leader in ["claude", "claude_code", "pi"] {
356
+ assert!(is_retired_provider(leader), "{leader}");
357
+ assert!(parse_provider(leader).is_some(), "{leader}");
358
+ }
359
+ }
360
+
293
361
  #[test]
294
362
  fn aliases_first_entry_is_canonical_wire() {
295
363
  for &p in ALL_PROVIDERS {
@@ -102,7 +102,7 @@ fn observation_identity_separates_same_name_team_path_and_spawn_generation() {
102
102
  ("/active_team_key", json!("b")),
103
103
  ("/agents/w/rollout_path", json!("/fixture/other.jsonl")),
104
104
  ("/agents/w/spawn_epoch", json!(2)),
105
- ("/agents/w/provider", json!("claude")),
105
+ ("/agents/w/provider", json!("copilot")),
106
106
  ("/agents/w/spawned_at", json!("new-incarnation")),
107
107
  ] {
108
108
  let mut changed = initial.clone();
@@ -2730,7 +2730,7 @@ mod tests {
2730
2730
  &json!({
2731
2731
  "session_name": "team-a",
2732
2732
  "active_team_key": "team-a",
2733
- "agents": {"f1": {"provider": "claude", "status": "starting"}}
2733
+ "agents": {"f1": {"provider": "copilot", "status": "starting"}}
2734
2734
  }),
2735
2735
  );
2736
2736
  // f2 loaded before f1's reservation. Persist carries the still-unspawned
@@ -2738,7 +2738,7 @@ mod tests {
2738
2738
  let incoming = json!({
2739
2739
  "session_name": "team-a",
2740
2740
  "active_team_key": "team-a",
2741
- "agents": {"f2": {"provider": "claude", "status": "starting"}}
2741
+ "agents": {"f2": {"provider": "copilot", "status": "starting"}}
2742
2742
  });
2743
2743
  save_runtime_state_with_lifecycle_topology_authority(&ws, &incoming, "team-a", &["f2"])
2744
2744
  .unwrap();
@@ -2749,7 +2749,7 @@ mod tests {
2749
2749
  // f1 starts after f2 takes its snapshot; capture is not complete yet.
2750
2750
  let mut started = stale.clone();
2751
2751
  started["agents"]["f1"] = json!({
2752
- "provider": "claude",
2752
+ "provider": "copilot",
2753
2753
  "status": "running",
2754
2754
  "pane_id": "%1",
2755
2755
  "pane_pid": 101,
@@ -2763,7 +2763,7 @@ mod tests {
2763
2763
  .unwrap();
2764
2764
  let latest = read_state(&ws);
2765
2765
  stale["agents"]["f2"] = json!({
2766
- "provider": "claude",
2766
+ "provider": "copilot",
2767
2767
  "status": "running",
2768
2768
  "pane_id": "%2",
2769
2769
  "pane_pid": 102,
@@ -3410,7 +3410,7 @@ mod tests {
3410
3410
  "agents": {
3411
3411
  "alpha": {
3412
3412
  "status": "stopped",
3413
- "provider": "claude",
3413
+ "provider": "copilot",
3414
3414
  "session_id": "stale-poisoned-uuid",
3415
3415
  "rollout_path": Value::Null,
3416
3416
  "captured_at": Value::Null,
@@ -3427,7 +3427,7 @@ mod tests {
3427
3427
  "agents": {
3428
3428
  "alpha": {
3429
3429
  "status": "running",
3430
- "provider": "claude",
3430
+ "provider": "copilot",
3431
3431
  "session_id": Value::Null,
3432
3432
  "rollout_path": Value::Null,
3433
3433
  "captured_at": Value::Null,
@@ -123,9 +123,9 @@ fn stopped_start_commit_updates_exact_target_and_both_mirrors()
123
123
  let held = json!({"agent_id":"worker","provider":"grok_build","runtime_family":"contract",
124
124
  "status":"stopped","explicit_stop":true,"generation":1,"contract_instance":"instance-one",
125
125
  "session_id":"same-session","native_endpoint":"old-endpoint"});
126
- let peer = json!({"agent_id":"peer","provider":"pi","status":"stopped","explicit_stop":true,
126
+ let peer = json!({"agent_id":"peer","provider":"copilot","status":"stopped","explicit_stop":true,
127
127
  "session_id":"peer-session","generation":1});
128
- let control = json!({"agent_id":"control","provider":"pi","status":"running","session_id":"control-session"});
128
+ let control = json!({"agent_id":"control","provider":"copilot","status":"running","session_id":"control-session"});
129
129
  let agents = json!({"worker":held,"peer":peer,"control":control});
130
130
  let initial = json!({"session_name":"team-a","active_team_key":"team-a","agents":agents,
131
131
  "teams":{"team-a":{"session_name":"team-a","status":"alive","agents":agents},
@@ -20,12 +20,6 @@ enum Mode {
20
20
  R6IdleNotice,
21
21
  PiFolded,
22
22
  PiFoldedUnstable,
23
- CursorFollowup,
24
- CursorHeaderEvicted,
25
- CursorHistoryOnly,
26
- CursorLongHistory,
27
- CursorExpanded,
28
- CursorExpandedDirty,
29
23
  }
30
24
  struct State {
31
25
  mode: Mode,
@@ -59,13 +53,7 @@ impl CommandRunner for Runner {
59
53
  };
60
54
  let height = if matches!(
61
55
  state.mode,
62
- Mode::R6IdleNotice
63
- | Mode::PiFolded
64
- | Mode::PiFoldedUnstable
65
- | Mode::CursorHistoryOnly
66
- | Mode::CursorLongHistory
67
- | Mode::CursorExpanded
68
- | Mode::CursorExpandedDirty
56
+ Mode::R6IdleNotice | Mode::PiFolded | Mode::PiFoldedUnstable
69
57
  ) {
70
58
  24
71
59
  } else {
@@ -177,64 +165,6 @@ impl CommandRunner for Runner {
177
165
  }
178
166
  String::new()
179
167
  };
180
- let stdout = if state.provider == Provider::CursorAgent
181
- && argv.iter().any(|arg| arg == "capture-pane")
182
- {
183
- let followup = matches!(
184
- state.mode,
185
- Mode::CursorFollowup
186
- | Mode::CursorHeaderEvicted
187
- | Mode::CursorHistoryOnly
188
- | Mode::CursorLongHistory
189
- | Mode::CursorExpanded
190
- | Mode::CursorExpandedDirty
191
- );
192
- let placeholder = if followup {
193
- "Add a follow-up"
194
- } else {
195
- "Plan, search, build anything"
196
- };
197
- let header = if matches!(state.mode, Mode::CursorFollowup)
198
- || (matches!(state.mode, Mode::CursorHeaderEvicted) && state.pasted > 0)
199
- {
200
- ""
201
- } else {
202
- "Cursor Agent\nv2026.10.01-e373342\n"
203
- };
204
- let (composer, history) = if state.entered > 0 {
205
- (placeholder, "[Pasted text #2 +25 lines]")
206
- } else if state.pasted > 0 {
207
- ("[Pasted text #2 +25 lines]", "[Pasted text #1 +25 lines]")
208
- } else {
209
- (placeholder, "[Pasted text #1 +25 lines]")
210
- };
211
- let padding = if matches!(state.mode, Mode::CursorLongHistory) {
212
- "historical transcript row\n".repeat(70)
213
- } else {
214
- String::new()
215
- };
216
- let frame = format!(
217
- "{header}{history}\n{padding}→ {composer}\nGrok 4.7 High Run Everything\n/owned/project\n"
218
- );
219
- if matches!(state.mode, Mode::CursorExpanded | Mode::CursorExpandedDirty) {
220
- let expanded = include_str!("../../tests/fixtures/cursor-followup-expanded.txt");
221
- if matches!(state.mode, Mode::CursorExpandedDirty)
222
- || state.pasted > 0 && state.entered == 0
223
- {
224
- format!("[Pasted text #1 +30 lines]\n{expanded}")
225
- } else if state.entered > 0 {
226
- format!("{marker}\n→ Add a follow-up\nGrok 4.7 256K High · 8.6% Run Everything\n/owned/project\n")
227
- } else {
228
- "[Pasted text #1 +30 lines]\n→ Add a follow-up\nGrok 4.7 256K High · 8.6% Run Everything\n/owned/project\n".into()
229
- }
230
- } else if matches!(state.mode, Mode::CursorHistoryOnly) {
231
- format!("{frame}{}", "unknown current row\n".repeat(24))
232
- } else {
233
- frame
234
- }
235
- } else {
236
- stdout
237
- };
238
168
  Ok(CommandOutput {
239
169
  success: true,
240
170
  code: Some(0),
@@ -485,7 +415,7 @@ fn native_input_capsule_baseline_exclusion_is_provider_aware() {
485
415
  vec!["[paste #1 +30 lines]", "[paste #2 1234 chars]"]
486
416
  );
487
417
  assert_eq!(
488
- capsule_labels(Provider::CursorAgent, history),
418
+ capsule_labels(Provider::Claude, history),
489
419
  vec!["[Pasted text #3 +25 lines]"]
490
420
  );
491
421
  }
@@ -734,112 +664,6 @@ fn native_input_rescue_binding_busy_and_canonical_changes_never_send_a_key() {
734
664
  assert_eq!(f.state.lock().unwrap().entered, 0);
735
665
  }
736
666
 
737
- #[test]
738
- fn native_input_cursor_owned_new_capsule_transfers_to_transcript_without_token_claim() {
739
- let f = Fixture::new(Mode::Normal);
740
- f.state.lock().unwrap().provider = Provider::CursorAgent;
741
- let (report, evidence) = f.inject();
742
- let report = report.unwrap();
743
- let evidence = evidence.unwrap();
744
- assert_eq!(
745
- report.inject_verification,
746
- InjectVerification::CaptureContainsNewPastedContentPrompt
747
- );
748
- assert_eq!(
749
- report.submit_verification,
750
- SubmitVerification::EnterSentWithoutPlaceholderCheck
751
- );
752
- assert_eq!(
753
- evidence.capsule.as_deref(),
754
- Some("[Pasted text #2 +25 lines]")
755
- );
756
- assert_eq!(evidence.baseline_capsules, ["[Pasted text #1 +25 lines]"]);
757
- let state = f.state.lock().unwrap();
758
- assert_eq!(state.pasted, 1);
759
- assert_eq!(state.entered, 1);
760
- }
761
-
762
- #[test]
763
- fn native_input_cursor_clean_followup_uses_one_paste_one_enter_across_banner_eviction() {
764
- for mode in [
765
- Mode::CursorFollowup,
766
- Mode::CursorHeaderEvicted,
767
- Mode::CursorLongHistory,
768
- ] {
769
- let f = Fixture::new(mode);
770
- f.state.lock().unwrap().provider = Provider::CursorAgent;
771
- let (report, evidence) = f.inject();
772
- let report = report.unwrap();
773
- assert_eq!(
774
- report.submit_verification,
775
- SubmitVerification::EnterSentWithoutPlaceholderCheck
776
- );
777
- let evidence = evidence.unwrap();
778
- assert_eq!(evidence.phase, NativeInputPhase::Accepted);
779
- assert_eq!(
780
- evidence.capsule.as_deref(),
781
- Some("[Pasted text #2 +25 lines]")
782
- );
783
- let state = f.state.lock().unwrap();
784
- assert_eq!((state.pasted, state.entered), (1, 1));
785
- }
786
- }
787
-
788
- #[test]
789
- fn native_input_cursor_expanded_followup_reaches_seen_then_one_enter() {
790
- let f = Fixture::new(Mode::CursorExpanded);
791
- f.state.lock().unwrap().provider = Provider::CursorAgent;
792
- let text = "For a harmless terminal-scroll fixture, reply with exactly 240 numbered lines, one per line, from 001 through 240, each formatted `NNN: amber`; do not use tools or change any files. Then wait.\n\n[team-agent-token:msg_one]";
793
- let (report, evidence) = with_native_input(Some(f.request()), || {
794
- f.backend.inject(
795
- &Target::Pane(PaneId::new("%1")),
796
- &InjectPayload::Text(text.into()),
797
- Key::Enter,
798
- true,
799
- )
800
- });
801
- let report = report.unwrap();
802
- assert_eq!(
803
- report.submit_verification,
804
- SubmitVerification::EnterSentWithoutPlaceholderCheck
805
- );
806
- assert_eq!(
807
- report.inject_verification,
808
- InjectVerification::CaptureContainsToken
809
- );
810
- let evidence = evidence.unwrap();
811
- assert_eq!(evidence.phase, NativeInputPhase::Accepted);
812
- assert!(evidence.capsule.is_none());
813
- assert_eq!(evidence.baseline_capsules, ["[Pasted text #1 +30 lines]"]);
814
- let state = f.state.lock().unwrap();
815
- assert_eq!((state.pasted, state.entered), (1, 1));
816
- assert!(state.stage_captures[1] >= 2);
817
- }
818
-
819
- #[test]
820
- fn native_input_cursor_foreign_expanded_followup_is_zero_effect() {
821
- let f = Fixture::new(Mode::CursorExpandedDirty);
822
- f.state.lock().unwrap().provider = Provider::CursorAgent;
823
- let (report, _) = f.inject();
824
- assert!(report.is_err());
825
- let state = f.state.lock().unwrap();
826
- assert_eq!((state.pasted, state.entered), (0, 0));
827
- }
828
-
829
- #[test]
830
- fn native_input_cursor_history_only_composer_cannot_authorize_paste_or_enter() {
831
- let f = Fixture::new(Mode::CursorHistoryOnly);
832
- f.state.lock().unwrap().provider = Provider::CursorAgent;
833
- let (result, _) = f.inject();
834
- let state = f.state.lock().unwrap();
835
- assert_eq!(
836
- (state.pasted, state.entered),
837
- (0, 0),
838
- "old history is not current composer authority"
839
- );
840
- assert!(result.is_err());
841
- }
842
-
843
667
  #[test]
844
668
  fn native_input_buffer_uses_authoritative_message_not_first_quoted_marker() {
845
669
  let f = Fixture::new(Mode::Normal);
@@ -4101,3 +4101,154 @@ fn wrap_gap_true_on_joined_token_a_cannot_see() {
4101
4101
  "B must still cover the wrap gap A cannot see"
4102
4102
  );
4103
4103
  }
4104
+
4105
+ // ═════════════════════════════════════════════════════════════════════════
4106
+ // #379: Claude Code echoes the submitted turn right above its composer box
4107
+ // ═════════════════════════════════════════════════════════════════════════
4108
+
4109
+ const CLAUDE_379_MARKER: &str = "[team-agent-token:msg_claude379]";
4110
+
4111
+ /// A 56-column Claude Code 2.1.309 pane as tmux captures it: history, the rows
4112
+ /// above the box, the composer between two rules (`❯` + U+00A0), then the footer.
4113
+ fn claude_379_frame(history: &str, above: &str, composer: &str) -> String {
4114
+ let rule = "─".repeat(56);
4115
+ format!(
4116
+ "{history}\n\n{above}\n ◐ medium · /effort\n{rule}\n❯\u{a0}{composer}\n{rule}\n ⏵⏵ bypass permissions on (shift+tab to cycle)\n"
4117
+ )
4118
+ }
4119
+
4120
+ fn claude_379_payload() -> String {
4121
+ format!("Team Agent message from leader:\n\nline1\nline2\n\n{CLAUDE_379_MARKER}")
4122
+ }
4123
+
4124
+ /// The submitted turn as Claude draws it in history: `❯` then indented rows.
4125
+ fn claude_379_echo() -> String {
4126
+ claude_379_payload()
4127
+ .lines()
4128
+ .enumerate()
4129
+ .map(|(i, line)| match (i, line.is_empty()) {
4130
+ (0, _) => format!("❯ {line}"),
4131
+ (_, true) => String::new(),
4132
+ _ => format!(" {line}"),
4133
+ })
4134
+ .collect::<Vec<_>>()
4135
+ .join("\n")
4136
+ }
4137
+
4138
+ #[test]
4139
+ fn issue379_history_echo_above_the_claude_box_is_not_composer() {
4140
+ let text = normalize_capture(&claude_379_frame(&claude_379_echo(), "· Waddling…", ""));
4141
+ assert!(
4142
+ super::token_in_bottom_n(&text, CLAUDE_379_MARKER, 15),
4143
+ "fixture: the echo sits inside the legacy bottom-15 window"
4144
+ );
4145
+ assert!(!super::should_resubmit_enter(&text, CLAUDE_379_MARKER, None));
4146
+ assert_eq!(
4147
+ super::consumption_from_capture(&text, CLAUDE_379_MARKER, true, None),
4148
+ Some(true)
4149
+ );
4150
+ assert_eq!(
4151
+ super::consumption_from_capture(
4152
+ &text,
4153
+ CLAUDE_379_MARKER,
4154
+ false,
4155
+ Some(super::PasteLatch::HashId(1))
4156
+ ),
4157
+ Some(true)
4158
+ );
4159
+ // The token still between the rules is still composer.
4160
+ let pending = normalize_capture(&claude_379_frame("", "", &format!("ping {CLAUDE_379_MARKER}")));
4161
+ assert!(super::should_resubmit_enter(&pending, CLAUDE_379_MARKER, None));
4162
+ assert_eq!(
4163
+ super::consumption_from_capture(&pending, CLAUDE_379_MARKER, true, None),
4164
+ Some(false)
4165
+ );
4166
+ }
4167
+
4168
+ #[test]
4169
+ fn issue379_claude_busy_is_the_live_spinner_row_not_a_glyph_scan() {
4170
+ for spinner in ["· Waddling…", "✻ Baking… (3s · thinking)", "✽ Beboppin'…"] {
4171
+ let text = normalize_capture(&claude_379_frame("❯ question", spinner, ""));
4172
+ let busy = super::provider_busy_signal_match(&text);
4173
+ assert_eq!(
4174
+ busy.map(|signal| signal.kind),
4175
+ Some(BusySignalKind::SpinnerGlyph),
4176
+ "{spinner}"
4177
+ );
4178
+ assert_eq!(
4179
+ observe_turn_from_capture(&text, Some(CLAUDE_379_MARKER)),
4180
+ TurnVerification::LeaderNewTurnBoundaryVerified
4181
+ );
4182
+ }
4183
+ // Todo rows under the spinner push it past the bottom window; still busy.
4184
+ let todos = "✶ Sprouting…\n ⎿ ☐ one\n ☐ two\n ☐ three\n ☐ four\n ☐ five\n ☐ six";
4185
+ let text = normalize_capture(&claude_379_frame("❯ question", todos, ""));
4186
+ assert!(super::provider_busy_signal_match(&text).is_some());
4187
+ // A finished turn's summary and transcript prose are not a live turn.
4188
+ let done = normalize_capture(&claude_379_frame(
4189
+ "❯ question\n\n⏺ Still working on thinking about it.",
4190
+ "✻ Worked for 3s",
4191
+ "",
4192
+ ));
4193
+ assert!(super::provider_busy_signal_match(&done).is_none());
4194
+ // Queued input is native custody: busy, and not composer text.
4195
+ let queued = normalize_capture(&claude_379_frame(
4196
+ &claude_379_echo(),
4197
+ "",
4198
+ "Press up to edit queued messages",
4199
+ ));
4200
+ assert!(super::provider_busy_signal_match(&queued).is_some());
4201
+ assert!(!super::should_resubmit_enter(&queued, CLAUDE_379_MARKER, None));
4202
+ }
4203
+
4204
+ #[test]
4205
+ fn issue379_claude_submit_verifies_on_the_first_enter() {
4206
+ let folded = claude_379_frame("⏺ earlier reply", "", "[Pasted text #1 +5 lines]");
4207
+ let submitted = claude_379_frame(&claude_379_echo(), "· Waddling… (1s · thinking)", "");
4208
+ let (be, rec) = backend_folded(&folded, &submitted);
4209
+ let report = be
4210
+ .inject(
4211
+ &Target::Pane(PaneId::new("%7")),
4212
+ &InjectPayload::Text(claude_379_payload()),
4213
+ Key::Enter,
4214
+ true,
4215
+ )
4216
+ .expect("inject");
4217
+ assert_eq!(
4218
+ report.submit_verification,
4219
+ SubmitVerification::EnterSentWithoutPlaceholderCheck
4220
+ );
4221
+ let calls = rec.lock().unwrap().clone();
4222
+ assert_eq!(count_submit_enters(&calls), 1, "no extra Enter into an empty composer; calls={calls:?}");
4223
+ // Enter not taken: the folded paste stays between the rules.
4224
+ let (be, _rec) = backend_folded(&folded, &folded);
4225
+ let report = be
4226
+ .inject(
4227
+ &Target::Pane(PaneId::new("%7")),
4228
+ &InjectPayload::Text(claude_379_payload()),
4229
+ Key::Enter,
4230
+ true,
4231
+ )
4232
+ .expect("inject");
4233
+ assert_eq!(
4234
+ report.submit_verification,
4235
+ SubmitVerification::SubmitConsumptionUnverified
4236
+ );
4237
+ }
4238
+
4239
+ #[test]
4240
+ fn issue379_busy_seen_in_any_post_enter_sample_survives_a_quiet_final_frame() {
4241
+ let mut diagnostics = super::ConsumptionDiagnostics::default();
4242
+ let busy = normalize_capture(&claude_379_frame("❯ question", "✳ Moseying…", ""));
4243
+ let quiet = normalize_capture(&claude_379_frame("❯ question", "⏺ Streaming reply", ""));
4244
+ for text in [&busy, &quiet] {
4245
+ diagnostics.record(super::consumption_capture_observation(
4246
+ text,
4247
+ Some(CLAUDE_379_MARKER),
4248
+ false,
4249
+ None,
4250
+ ));
4251
+ }
4252
+ assert!(diagnostics.busy_seen);
4253
+ assert!(diagnostics.busy_signal_kind.is_none(), "latest sample stays as observed");
4254
+ }