mirror of
https://github.com/R0m1k3/Loki.git
synced 2026-10-21 22:18:13 +02:00
Lot 17 : interrupteurs système tenus par la façade (LOKI_SYSTEM=rust)
La façade sert /api/internet (moteur web, serveur Crawl4AI et sa clé jamais rendue, joignabilité avec son cache de 30 s), /api/computer (interrupteur du navigateur, binaire trouvé, vision), /api/apikey (clé de complétion, repli sur config.env, adresse /v1 à coller dans un client tiers) et /api/network (écoute du moteur) quand LOKI_SYSTEM=rust (expérimental ; le Go reste le défaut). Restent au Go derrière son API interne (facade_system.go) : le cache de joignabilité de ses outils web (/internal/v1/web/reach/reset), le Chromium des outils browser_* (/internal/v1/cdp/shutdown) et le redémarrage qui applique une clé neuve quand la façade ne pilote pas le moteur (/internal/v1/service/action). Le relais du tunnel garde l'hôte et X-Forwarded-Proto du client. Correction en passant : maskAPIKey paniquait sur une clé d'un octet, et /api/apikey tombait à chaque lecture. Parité : parity_system_test.go tire du Go 61 appels de route avec la base et les sondes reçues par trois faux Crawl4AI après chacun, et huit dispositions du dossier de Playwright, rejoués par tests/system.rs ; ce qui reste au Go vérifié de bout en bout ; TestFacadeSysteme, TestFacadeRelaisGardeHote et TestMaskAPIKeyCourte côté Go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016tcGfJWefW5kUGoC2wL8cv
This commit is contained in:
19 files changed
+3110
-3
No files matched your search
@@ -84,6 +84,12 @@ pub struct FakeGo {
|
||||
pub prestarts: Mutex<u32>,
|
||||
/// /internal/v1/dictate/stop reçus.
|
||||
pub dictate_stops: Mutex<u32>,
|
||||
/// /internal/v1/web/reach/reset reçus.
|
||||
pub reach_resets: Mutex<u32>,
|
||||
/// /internal/v1/cdp/shutdown reçus.
|
||||
pub cdp_shutdowns: Mutex<u32>,
|
||||
/// /internal/v1/service/action reçus : (action, if_active).
|
||||
pub service_actions: Mutex<Vec<(String, bool)>>,
|
||||
/// Comportement de /internal/v1/crypt/* (préfixe « SCELLE: » par défaut).
|
||||
pub crypt_mode: Mutex<CryptMode>,
|
||||
/// Réponse de /internal/v1/conv/workspace (None : 404).
|
||||
@@ -99,6 +105,11 @@ impl FakeGo {
|
||||
.or_default()
|
||||
.insert(key.into(), val.as_bytes().to_vec());
|
||||
}
|
||||
pub fn del(&self, bucket: &str, key: &str) {
|
||||
if let Some(b) = self.store.lock().unwrap().get_mut(bucket) {
|
||||
b.remove(key);
|
||||
}
|
||||
}
|
||||
pub fn get(&self, bucket: &str, key: &str) -> Option<String> {
|
||||
let s = self.store.lock().unwrap();
|
||||
s.get(bucket)?
|
||||
@@ -351,6 +362,23 @@ async fn handle(st: Arc<FakeGo>, req: Request<Incoming>) -> Response<Full<Bytes>
|
||||
200,
|
||||
serde_json::json!({ "generating": *st.generating.lock().unwrap() }).to_string(),
|
||||
),
|
||||
"/internal/v1/web/reach/reset" => {
|
||||
*st.reach_resets.lock().unwrap() += 1;
|
||||
resp(204, "")
|
||||
}
|
||||
"/internal/v1/cdp/shutdown" => {
|
||||
*st.cdp_shutdowns.lock().unwrap() += 1;
|
||||
resp(204, "")
|
||||
}
|
||||
"/internal/v1/service/action" => {
|
||||
let body = req.into_body().collect().await.unwrap().to_bytes();
|
||||
let v: serde_json::Value = serde_json::from_slice(&body).unwrap_or_default();
|
||||
st.service_actions.lock().unwrap().push((
|
||||
v["action"].as_str().unwrap_or("").to_string(),
|
||||
v["if_active"].as_bool().unwrap_or(false),
|
||||
));
|
||||
resp(200, r#"{"ran":true,"error":""}"#)
|
||||
}
|
||||
"/internal/v1/dictate/stop" => {
|
||||
*st.dictate_stops.lock().unwrap() += 1;
|
||||
resp(204, "")
|
||||
@@ -550,6 +578,7 @@ pub struct Opts {
|
||||
pub mem: Option<Arc<loki_rs::memory::Memory>>,
|
||||
pub presets: bool,
|
||||
pub engine_ctl: Option<Arc<loki_rs::enginectl::EngineCtl>>,
|
||||
pub system: Option<Arc<loki_rs::system::System>>,
|
||||
}
|
||||
|
||||
/// Comme [`start`], avec la conversation tenue par la façade
|
||||
@@ -647,6 +676,7 @@ pub async fn start_with(
|
||||
mem: opts.mem,
|
||||
presets: opts.presets,
|
||||
engine_ctl: opts.engine_ctl,
|
||||
system: opts.system,
|
||||
};
|
||||
tokio::spawn(loki_rs::proxy::serve(fl, cfg, async move {
|
||||
let _ = rx.await;
|
||||
|
||||
Reference in new issue
Block a user