lean_ctx/proxy/web_app/
mod.rs1#[allow(dead_code)]
2pub(crate) mod conversation_tracker;
3pub(crate) mod dashboard;
4#[allow(dead_code)]
5pub(crate) mod normalize;
6#[cfg(test)]
7mod proof_tests;
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub enum WebAppProvider {
12 ClaudeWeb,
13 ChatGptWeb,
14 GeminiWeb,
15}
16
17#[derive(Debug, Clone)]
20pub struct NormalizedRequest {
21 pub provider: WebAppProvider,
22 pub messages: Vec<serde_json::Value>,
23 pub system_prompt: Option<String>,
24 pub model: Option<String>,
25 pub conversation_id: Option<String>,
26 pub parent_message_id: Option<String>,
27}
28
29#[cfg(test)]
30pub(crate) fn detect_web_provider(host: &str, path: &str) -> Option<WebAppProvider> {
31 let _ = path;
32 let host = host
33 .trim()
34 .trim_end_matches('.')
35 .split(':')
36 .next()
37 .unwrap_or_default();
38
39 if host.eq_ignore_ascii_case("claude.ai") {
40 Some(WebAppProvider::ClaudeWeb)
41 } else if host.eq_ignore_ascii_case("chat.openai.com")
42 || host.eq_ignore_ascii_case("chatgpt.com")
43 {
44 Some(WebAppProvider::ChatGptWeb)
45 } else if host.eq_ignore_ascii_case("gemini.google.com") {
46 Some(WebAppProvider::GeminiWeb)
47 } else {
48 None
49 }
50}