blob: 73d1a8b0047161ad832154eec206e17c2ffb3680 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
use super::super::AgentState;
pub(super) fn detect(content: &str) -> AgentState {
if has_kimi_blocked_prompt(content) {
return AgentState::Blocked;
}
if has_kimi_working_status(content) {
return AgentState::Working;
}
AgentState::Idle
}
fn has_kimi_blocked_prompt(content: &str) -> bool {
let lower = content.to_lowercase();
lower.contains("requesting approval")
&& (lower.contains("approve once") || lower.contains("approve for this session"))
&& lower.contains("reject")
&& (lower.contains("1/2/3/4 choose") || lower.contains("↵ confirm"))
}
fn has_kimi_working_status(content: &str) -> bool {
content.lines().any(|line| {
let trimmed = line.trim();
if matches!(
trimmed,
"🌕" | "🌖" | "🌗" | "🌘" | "🌑" | "🌒" | "🌓" | "🌔"
) {
return true;
}
let mut chars = trimmed.chars();
let Some(first) = chars.next() else {
return false;
};
if !('\u{2800}'..='\u{28FF}').contains(&first) {
return false;
}
let rest = chars
.as_str()
.trim_start_matches(|c| ('\u{2800}'..='\u{28FF}').contains(&c))
.trim_start()
.to_lowercase();
rest.starts_with("thinking...") || rest.starts_with("using ")
})
}
|