aboutsummaryrefslogtreecommitdiff
path: root/src/detect/agents/amp.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-30 23:54:41 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-30 23:54:41 +0300
commitd477341e6af816ff4396042b084a0378ef437b4a (patch)
treee332b6f7a0d23d9effd21c3ca8ab27698ed83444 /src/detect/agents/amp.rs
parent8df1639048529b383358000879b5ee078a90b9f9 (diff)
refactor: split agent detection by agent
Move screen detection into per-agent modules and keep visible-state arbitration centralized in terminal state. Tighten Codex prompt-scoped working detection and Claude hook/screen recovery for stale blocked and idle reports. Add a focused just recipe for single-test runs. refs #349 refs #352
Diffstat (limited to 'src/detect/agents/amp.rs')
-rw-r--r--src/detect/agents/amp.rs41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/detect/agents/amp.rs b/src/detect/agents/amp.rs
new file mode 100644
index 00000000..ad76ca27
--- /dev/null
+++ b/src/detect/agents/amp.rs
@@ -0,0 +1,41 @@
+use super::super::AgentState;
+
+/// Amp (Sourcegraph) detection.
+///
+/// Blocked approval prompts use a shared footer with options like
+/// "Approve", "Allow All for This Session", "Allow All for Every Session",
+/// "Allow File for Every Session", and "Deny with feedback". The header varies
+/// by approval type, for example "Invoke tool ...?", "Run this command?",
+/// "Allow editing file:", or "Allow creating file:".
+///
+/// Working layout:
+/// ```text
+/// ✓ Search Map the core runtime architecture...
+/// ⋯ Oracle ▼
+/// ≈ Running tools... Esc to cancel
+/// ```
+pub(super) fn detect(content: &str) -> AgentState {
+ let lower = content.to_lowercase();
+
+ let has_waiting_for_approval = lower.contains("waiting for approval");
+ let has_approval_header = lower.contains("invoke tool")
+ || lower.contains("run this command?")
+ || lower.contains("allow editing file:")
+ || lower.contains("allow creating file:")
+ || lower.contains("confirm tool call");
+ let has_approval_actions = lower.contains("approve")
+ && (lower.contains("allow all for this session")
+ || lower.contains("allow all for every session")
+ || lower.contains("allow file for every session")
+ || lower.contains("deny with feedback"));
+
+ if has_approval_actions && (has_waiting_for_approval || has_approval_header) {
+ return AgentState::Blocked;
+ }
+
+ if lower.contains("esc to cancel") {
+ return AgentState::Working;
+ }
+
+ AgentState::Idle
+}