@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.
- package/Cargo.lock +1 -8
- package/Cargo.toml +1 -1
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/crates/team-agent/Cargo.toml +0 -1
- package/crates/team-agent/src/cli/diagnose.rs +39 -1
- package/crates/team-agent/src/cli/emit.rs +41 -15
- package/crates/team-agent/src/cli/intent/runtime.rs +30 -54
- package/crates/team-agent/src/cli/intent/runtime_tests.rs +59 -118
- package/crates/team-agent/src/cli/leader.rs +2 -3
- package/crates/team-agent/src/cli/leader_prompt.rs +1 -1
- package/crates/team-agent/src/cli/mod.rs +6 -5
- package/crates/team-agent/src/cli/models.rs +93 -128
- package/crates/team-agent/src/cli/route.rs +1 -1
- package/crates/team-agent/src/cli/send/persist.rs +36 -0
- package/crates/team-agent/src/cli/send/presentation.rs +7 -1
- package/crates/team-agent/src/cli/send.rs +3 -1
- package/crates/team-agent/src/cli/spec.rs +1 -2
- package/crates/team-agent/src/cli/status_port/brief.rs +66 -0
- package/crates/team-agent/src/cli/tests/base.rs +4 -11
- package/crates/team-agent/src/cli/tests/status_send.rs +17 -0
- package/crates/team-agent/src/compiler/tests.rs +21 -5
- package/crates/team-agent/src/compiler.rs +24 -1
- package/crates/team-agent/src/contract_runtime/backend.rs +30 -6
- package/crates/team-agent/src/contract_runtime/config.rs +34 -24
- package/crates/team-agent/src/contract_runtime/discovery.rs +79 -56
- package/crates/team-agent/src/contract_runtime/framework.rs +89 -34
- package/crates/team-agent/src/contract_runtime/registry.rs +299 -24
- package/crates/team-agent/src/coordinator/runtime_detectors.rs +0 -1
- package/crates/team-agent/src/coordinator/tick.rs +89 -1
- package/crates/team-agent/src/db/message_store.rs +78 -3
- package/crates/team-agent/src/layout/worker_window_helpers.rs +0 -1
- package/crates/team-agent/src/leader/prompt.rs +1 -2
- package/crates/team-agent/src/leader/provider_attribution.rs +0 -52
- package/crates/team-agent/src/leader/start.rs +0 -1
- package/crates/team-agent/src/leader/tests/prompt_contract.rs +2 -3
- package/crates/team-agent/src/lifecycle/launch/add_agent.rs +91 -0
- package/crates/team-agent/src/lifecycle/launch/add_agent_state.rs +14 -1
- package/crates/team-agent/src/lifecycle/launch/agent_state.rs +0 -9
- package/crates/team-agent/src/lifecycle/launch/fork_agent.rs +0 -1
- package/crates/team-agent/src/lifecycle/launch/mcp_config.rs +2 -2
- package/crates/team-agent/src/lifecycle/launch/pi_mcp.rs +19 -101
- package/crates/team-agent/src/lifecycle/launch/spawn.rs +0 -28
- package/crates/team-agent/src/lifecycle/launch/spec_state.rs +0 -1
- package/crates/team-agent/src/lifecycle/launch/worker_env.rs +0 -108
- package/crates/team-agent/src/lifecycle/launch.rs +2 -20
- package/crates/team-agent/src/lifecycle/profile_launch.rs +11 -39
- package/crates/team-agent/src/lifecycle/profile_smoke.rs +1 -2
- package/crates/team-agent/src/lifecycle/restart/common.rs +1 -63
- package/crates/team-agent/src/lifecycle/role_config.rs +42 -3
- package/crates/team-agent/src/lifecycle/tests/cli_argv_routing_red.rs +43 -13
- package/crates/team-agent/src/lifecycle/tests/clone_fork_copilot_perms_red.rs +6 -2
- package/crates/team-agent/src/lifecycle/tests/pi_catalog_red.rs +1 -3
- package/crates/team-agent/src/lifecycle/tests/pi_command_red.rs +4 -16
- package/crates/team-agent/src/lifecycle/tests/pi_compiler_red.rs +1 -3
- package/crates/team-agent/src/lifecycle/tests/pi_executable_mcp_red.rs +84 -53
- package/crates/team-agent/src/lifecycle/tests/pi_fork_session_inheritance_red.rs +19 -1
- package/crates/team-agent/src/lifecycle/tests/pi_session_delivery_red.rs +21 -0
- package/crates/team-agent/src/lifecycle/tests/restart_rebind_hotfix_252_red.rs +0 -1
- package/crates/team-agent/src/lifecycle/tests/worker_spawn_env_red.rs +0 -137
- package/crates/team-agent/src/lifecycle/tests.rs +0 -3
- package/crates/team-agent/src/lifecycle/worker_command_context.rs +2 -4
- package/crates/team-agent/src/mcp_server/readiness.rs +148 -97
- package/crates/team-agent/src/mcp_server/readiness_tests.rs +115 -16
- package/crates/team-agent/src/messaging/delivery.rs +186 -38
- package/crates/team-agent/src/messaging/delivery_consumption_tests.rs +4 -4
- package/crates/team-agent/src/messaging/enter_rescue_tests.rs +1 -1
- package/crates/team-agent/src/messaging/helpers.rs +19 -0
- package/crates/team-agent/src/messaging/tests/dup_inject.rs +66 -4
- package/crates/team-agent/src/messaging/tests/runtime.rs +110 -4
- package/crates/team-agent/src/messaging/tests/spine.rs +22 -6
- package/crates/team-agent/src/model/enums.rs +1 -8
- package/crates/team-agent/src/provider/adapter.rs +1 -67
- package/crates/team-agent/src/provider/adapters/mod.rs +0 -1
- package/crates/team-agent/src/provider/adapters/pi.rs +4 -4
- package/crates/team-agent/src/provider/argv_route.rs +1 -5
- package/crates/team-agent/src/provider/bypass_flags.rs +3 -11
- package/crates/team-agent/src/provider/classify.rs +68 -3
- package/crates/team-agent/src/provider/faults.rs +1 -1
- package/crates/team-agent/src/provider/model_catalog.rs +2 -73
- package/crates/team-agent/src/provider/session/capture.rs +1 -1
- package/crates/team-agent/src/provider/session/context_fork.rs +4 -4
- package/crates/team-agent/src/provider/session_scan/common.rs +1 -2
- package/crates/team-agent/src/provider/session_scan/pi.rs +32 -19
- package/crates/team-agent/src/provider/session_scan.rs +0 -4
- package/crates/team-agent/src/provider/submit_now.rs +5 -28
- package/crates/team-agent/src/provider/tests/adapter.rs +5 -184
- package/crates/team-agent/src/provider/tests/classify.rs +53 -0
- package/crates/team-agent/src/provider/tests/command_helpers.rs +3 -6
- package/crates/team-agent/src/provider/types.rs +1 -1
- package/crates/team-agent/src/provider/wire.rs +48 -8
- package/crates/team-agent/src/tmux_backend/native_input_tests.rs +2 -178
- package/crates/team-agent/src/tmux_backend/tests.rs +151 -0
- package/crates/team-agent/src/tmux_backend.rs +43 -8
- package/crates/team-agent/src/transport/native_input.rs +2 -231
- package/npm/install.mjs +40 -3
- package/package.json +4 -4
- package/skills/team-agent/SKILL.md +1 -1
- package/crates/team-agent/src/lifecycle/launch/cursor_create_chat.rs +0 -229
- package/crates/team-agent/src/lifecycle/launch/cursor_mcp.rs +0 -522
- package/crates/team-agent/src/lifecycle/launch/cursor_mcp_iso.rs +0 -282
- package/crates/team-agent/src/lifecycle/tests/cursor_mcp_overlay.rs +0 -576
- package/crates/team-agent/src/lifecycle/tests/cursor_require_explicit_model_red.rs +0 -222
- package/crates/team-agent/src/lifecycle/tests/cursor_restart_resume_red.rs +0 -511
- package/crates/team-agent/src/provider/adapters/cursor_agent.rs +0 -44
- package/crates/team-agent/src/provider/session_scan/cursor.rs +0 -538
- package/crates/team-agent/src/provider/testdata/cursor-list-models-native.stdout +0 -250
|
@@ -146,3 +146,56 @@ fn classify_open_turn_dead_is_abnormal_crashed_mid_turn() {
|
|
|
146
146
|
// Golden via /tmp/probe_idle.py (idle_predicate.evaluate_takeover_reminder).
|
|
147
147
|
// Nodes / monitor_state passed as serde_json::Value dicts (Python dict shape).
|
|
148
148
|
|
|
149
|
+
|
|
150
|
+
// #379: Claude Code's live session registry, located before and after capture.
|
|
151
|
+
#[cfg(unix)]
|
|
152
|
+
#[test]
|
|
153
|
+
fn claude_registry_turn_state_reads_the_live_record_for_this_transcript() {
|
|
154
|
+
let config = std::env::temp_dir().join(format!("ta-claude-registry-{}", std::process::id()));
|
|
155
|
+
let _ = std::fs::remove_dir_all(&config);
|
|
156
|
+
let sid = "11111111-2222-4333-8444-555555555555";
|
|
157
|
+
let projects = config.join("projects").join("-owned-cwd");
|
|
158
|
+
std::fs::create_dir_all(&projects).unwrap();
|
|
159
|
+
std::fs::create_dir_all(config.join("sessions")).unwrap();
|
|
160
|
+
let rollout = projects.join(format!("{sid}.jsonl"));
|
|
161
|
+
std::fs::write(&rollout, "").unwrap();
|
|
162
|
+
let sessions = config.join("sessions");
|
|
163
|
+
let expected_key = Some((sessions.clone(), sid.to_string()));
|
|
164
|
+
assert_eq!(claude_registry_key(&serde_json::json!({"rollout_path": rollout})), expected_key);
|
|
165
|
+
// Cold start: the launch's `--session-id` and projects root, before any capture.
|
|
166
|
+
assert_eq!(
|
|
167
|
+
claude_registry_key(&serde_json::json!({
|
|
168
|
+
"_pending_session_id": sid, "session_id": "stale", "claude_projects_root": config.join("projects"),
|
|
169
|
+
})),
|
|
170
|
+
expected_key
|
|
171
|
+
);
|
|
172
|
+
// Only `<config>/projects/<slug>/<id>.jsonl` names a registry.
|
|
173
|
+
assert_eq!(claude_registry_key(&serde_json::json!({"rollout_path": config.join(format!("{sid}.jsonl"))})), None);
|
|
174
|
+
let live = std::process::id();
|
|
175
|
+
let write = |pid: u32, session: &str, tmux: &str, status: &str| {
|
|
176
|
+
let record = serde_json::json!({"pid": pid, "sessionId": session, "tmux": tmux, "status": status});
|
|
177
|
+
std::fs::write(sessions.join(format!("{pid}.json")), record.to_string()).unwrap();
|
|
178
|
+
};
|
|
179
|
+
let read = |pane: Option<&str>| claude_registry_turn_state(&sessions, sid, pane);
|
|
180
|
+
for (status, expected) in [
|
|
181
|
+
("busy", Some(TurnState::Working)),
|
|
182
|
+
("waiting", Some(TurnState::BlockedOnHuman)),
|
|
183
|
+
("idle", Some(TurnState::Idle)),
|
|
184
|
+
("starting", None),
|
|
185
|
+
] {
|
|
186
|
+
write(live, sid, "team-x:@3.%7", status);
|
|
187
|
+
assert_eq!(read(Some("%7")), expected, "{status}");
|
|
188
|
+
}
|
|
189
|
+
write(live, sid, "team-x:@3.%7", "busy");
|
|
190
|
+
assert_eq!(read(None), Some(TurnState::Working));
|
|
191
|
+
assert_eq!(read(Some("%8")), None, "another pane's record");
|
|
192
|
+
write(live, "99999999-2222-4333-8444-555555555555", "team-x:@3.%7", "busy");
|
|
193
|
+
assert_eq!(read(Some("%7")), None, "another session's record");
|
|
194
|
+
std::fs::remove_file(sessions.join(format!("{live}.json"))).unwrap();
|
|
195
|
+
let mut child = std::process::Command::new("true").spawn().unwrap();
|
|
196
|
+
let dead = child.id();
|
|
197
|
+
child.wait().unwrap();
|
|
198
|
+
write(dead, sid, "team-x:@3.%7", "busy");
|
|
199
|
+
assert_eq!(read(Some("%7")), None, "a dead process is no evidence");
|
|
200
|
+
let _ = std::fs::remove_dir_all(&config);
|
|
201
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#![allow(clippy::unwrap_used, clippy::expect_used, clippy::panic)]
|
|
3
3
|
use super::*;
|
|
4
4
|
use crate::model::enums::ProviderEffort;
|
|
5
|
-
use crate::provider::adapters::{claude, codex, copilot,
|
|
5
|
+
use crate::provider::adapters::{claude, codex, copilot, grok, pi};
|
|
6
6
|
use crate::provider::ProviderCommandOverrides;
|
|
7
7
|
|
|
8
8
|
#[test]
|
|
@@ -27,8 +27,6 @@ fn command_helpers_keep_provider_argv_bytes_and_order() {
|
|
|
27
27
|
assert_eq!(copilot::copilot_base_command(
|
|
28
28
|
AuthMode::Subscription, Some(&mcp), Some(raw), Some(""), true,
|
|
29
29
|
), ["copilot", "--no-color", "--no-auto-update", "--no-remote", "--disable-builtin-mcps", "--allow-all", "--allow-tool", "team_orchestrator", "--model", "", "--additional-mcp-config", "{}"]);
|
|
30
|
-
assert_eq!(cursor_agent::cursor_agent_base_command(Some(raw), true).expect("cursor"),
|
|
31
|
-
["agent", "--trust", "--sandbox", "disabled", "--force", "--model", raw, "--workspace", "{workspace}"]);
|
|
32
30
|
assert_eq!(grok::grok_base_command(Some(raw), Some(" model-id "), true, Some(ProviderEffort::Medium)).expect("grok"),
|
|
33
31
|
["grok", "--always-approve", "--model", "model-id", "--effort", "medium", "--rules", raw]);
|
|
34
32
|
assert_eq!(grok::grok_base_command(Some(""), Some(" "), false, None).expect("grok empty"), ["grok", "--rules", ""]);
|
|
@@ -36,8 +34,8 @@ fn command_helpers_keep_provider_argv_bytes_and_order() {
|
|
|
36
34
|
extension: std::path::Path::new("extension.ts"), model: Some("vendor/model"),
|
|
37
35
|
effort: Some(ProviderEffort::XHigh), system_prompt: raw,
|
|
38
36
|
session_dir: Some(std::path::Path::new("sessions")),
|
|
39
|
-
session: pi::PiSessionSelector::Fresh
|
|
40
|
-
}).expect("pi"), ["pi", "-e", "extension.ts", "--model", "vendor/model", "--thinking", "xhigh", "--append-system-prompt", raw, "--session-dir", "sessions", "--
|
|
37
|
+
session: pi::PiSessionSelector::Fresh, agent_id: "worker",
|
|
38
|
+
}).expect("pi"), ["pi", "-e", "extension.ts", "--model", "vendor/model", "--thinking", "xhigh", "--append-system-prompt", raw, "--session-dir", "sessions", "--name", "worker"]);
|
|
41
39
|
}
|
|
42
40
|
|
|
43
41
|
#[test]
|
|
@@ -50,6 +48,5 @@ fn command_helpers_keep_absent_options_and_safe_defaults() {
|
|
|
50
48
|
["codex", "--no-alt-screen", "--disable", "shell_snapshot", "--disable", "apps"]);
|
|
51
49
|
assert_eq!(copilot::copilot_base_command(AuthMode::Subscription, None, None, None, false),
|
|
52
50
|
["copilot", "--no-color", "--no-auto-update", "--no-remote", "--disable-builtin-mcps", "--allow-tool", "team_orchestrator"]);
|
|
53
|
-
assert_eq!(cursor_agent::cursor_agent_base_command(None, false).expect("cursor"), ["agent", "--workspace", "{workspace}"]);
|
|
54
51
|
assert_eq!(grok::grok_base_command(None, None, false, None).expect("grok"), ["grok"]);
|
|
55
52
|
}
|
|
@@ -359,7 +359,7 @@ pub struct ProviderCommandContext<'a> {
|
|
|
359
359
|
/// - Pi: low|medium|high|xhigh|max → `--thinking <level>`; ultra rejected
|
|
360
360
|
/// - Grok: low|medium|high|xhigh → `--effort <level>`; max/ultra rejected
|
|
361
361
|
/// - Copilot / Gemini / Fake: low..xhigh ignored with a caller warning;
|
|
362
|
-
/// max/ultra rejected.
|
|
362
|
+
/// max/ultra rejected.
|
|
363
363
|
pub effort: Option<crate::model::enums::ProviderEffort>,
|
|
364
364
|
}
|
|
365
365
|
|
|
@@ -24,6 +24,38 @@
|
|
|
24
24
|
|
|
25
25
|
use crate::model::enums::Provider;
|
|
26
26
|
|
|
27
|
+
/// A state row written by a release that still ran the legacy Cursor engine.
|
|
28
|
+
/// No legacy runtime exists for it now; it must never fall back to another
|
|
29
|
+
/// provider. Role and CLI declarations of these names select the contract leaf.
|
|
30
|
+
pub(crate) const RETIRED_PROVIDER_ERROR: &str =
|
|
31
|
+
"legacy cursor_agent seat has no runtime in this release; stop or remove it, then add it again (provider: cursor)";
|
|
32
|
+
|
|
33
|
+
pub(crate) fn is_retired_provider(raw: &str) -> bool {
|
|
34
|
+
matches!(raw.trim().to_ascii_lowercase().as_str(), "cursor_agent" | "agent")
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
pub(crate) fn require_active_state_providers(
|
|
38
|
+
state: &serde_json::Value,
|
|
39
|
+
target: Option<&str>,
|
|
40
|
+
) -> Result<(), &'static str> {
|
|
41
|
+
if state
|
|
42
|
+
.get("agents")
|
|
43
|
+
.and_then(serde_json::Value::as_object)
|
|
44
|
+
.is_some_and(|agents| {
|
|
45
|
+
agents.iter().any(|(id, row)| {
|
|
46
|
+
target.is_none_or(|target| target == id)
|
|
47
|
+
&& row
|
|
48
|
+
.get("provider")
|
|
49
|
+
.and_then(serde_json::Value::as_str)
|
|
50
|
+
.is_some_and(is_retired_provider)
|
|
51
|
+
})
|
|
52
|
+
})
|
|
53
|
+
{
|
|
54
|
+
return Err(RETIRED_PROVIDER_ERROR);
|
|
55
|
+
}
|
|
56
|
+
Ok(())
|
|
57
|
+
}
|
|
58
|
+
|
|
27
59
|
/// Canonical snake_case wire string for `Provider`. Used for state JSON,
|
|
28
60
|
/// log fields, and any cross-process serialization. Stable: do not change
|
|
29
61
|
/// existing values.
|
|
@@ -35,7 +67,6 @@ pub(crate) fn provider_wire(provider: Provider) -> &'static str {
|
|
|
35
67
|
Provider::Copilot => "copilot",
|
|
36
68
|
Provider::GeminiCli => "gemini_cli",
|
|
37
69
|
Provider::Grok => "grok",
|
|
38
|
-
Provider::CursorAgent => "cursor_agent",
|
|
39
70
|
Provider::Pi => "pi",
|
|
40
71
|
Provider::Fake => "fake",
|
|
41
72
|
}
|
|
@@ -83,7 +114,6 @@ pub(crate) fn requires_resume_backing(provider: Provider) -> bool {
|
|
|
83
114
|
| Provider::ClaudeCode
|
|
84
115
|
| Provider::Copilot
|
|
85
116
|
| Provider::Grok
|
|
86
|
-
| Provider::CursorAgent
|
|
87
117
|
| Provider::Pi
|
|
88
118
|
)
|
|
89
119
|
}
|
|
@@ -104,10 +134,6 @@ pub(crate) fn aliases(provider: Provider) -> &'static [&'static str] {
|
|
|
104
134
|
Provider::Copilot => &["copilot"],
|
|
105
135
|
Provider::GeminiCli => &["gemini_cli"],
|
|
106
136
|
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
137
|
Provider::Pi => &["pi"],
|
|
112
138
|
Provider::Fake => &["fake"],
|
|
113
139
|
}
|
|
@@ -125,7 +151,6 @@ pub(crate) fn command_name(provider: Provider) -> &'static str {
|
|
|
125
151
|
Provider::Copilot => "copilot",
|
|
126
152
|
Provider::GeminiCli => "gemini",
|
|
127
153
|
Provider::Grok => "grok",
|
|
128
|
-
Provider::CursorAgent => "agent",
|
|
129
154
|
Provider::Pi => "pi",
|
|
130
155
|
Provider::Fake => "team-agent",
|
|
131
156
|
}
|
|
@@ -138,7 +163,6 @@ const ALL_PROVIDERS: &[Provider] = &[
|
|
|
138
163
|
Provider::Copilot,
|
|
139
164
|
Provider::GeminiCli,
|
|
140
165
|
Provider::Grok,
|
|
141
|
-
Provider::CursorAgent,
|
|
142
166
|
Provider::Pi,
|
|
143
167
|
Provider::Fake,
|
|
144
168
|
];
|
|
@@ -290,6 +314,22 @@ mod tests {
|
|
|
290
314
|
assert_eq!(parse_provider("CLAUDE"), None); // case-sensitive
|
|
291
315
|
}
|
|
292
316
|
|
|
317
|
+
#[test]
|
|
318
|
+
fn retired_state_guard_is_scoped_to_the_addressed_seat() {
|
|
319
|
+
let state = serde_json::json!({"agents": {
|
|
320
|
+
"pi": {"provider": "pi"},
|
|
321
|
+
"claude": {"provider": "claude"},
|
|
322
|
+
"retired": {"provider": "cursor_agent"}
|
|
323
|
+
}});
|
|
324
|
+
assert!(require_active_state_providers(&state, Some("pi")).is_ok());
|
|
325
|
+
assert!(require_active_state_providers(&state, Some("claude")).is_ok());
|
|
326
|
+
assert!(require_active_state_providers(&state, Some("retired")).is_err());
|
|
327
|
+
assert!(require_active_state_providers(&state, None).is_err());
|
|
328
|
+
for retired in ["cursor_agent", "agent"] {
|
|
329
|
+
assert_eq!(parse_provider(retired), None, "no legacy engine to parse into");
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
293
333
|
#[test]
|
|
294
334
|
fn aliases_first_entry_is_canonical_wire() {
|
|
295
335
|
for &p in ALL_PROVIDERS {
|
|
@@ -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::
|
|
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
|
+
}
|