Merge remote-tracking branch 'gitea-ai/gsd/phase-13-aiui-functional-conversational-node-control-and-content-surf'
Demo images / Build & push demo images (push) Successful in 3m14s

This commit is contained in:
archipelago
2026-08-09 08:17:22 -04:00
481 changed files with 90667 additions and 210 deletions
+36
View File
@@ -1087,6 +1087,22 @@ async fn run_nginx() -> Result<bool> {
/// rejected. Stripped during nginx bootstrap so the backend solely owns CORS.
const NGINX_LND_DUP_CORS: &str = " add_header Access-Control-Allow-Origin $http_origin always;\n add_header Access-Control-Allow-Credentials \"true\" always;\n";
/// S4 follow-up (2026-08-07): pre-fix nodes proxy /aiui/api/web-search
/// STRAIGHT to SearXNG (127.0.0.1:8888) with no session check — anyone on the
/// LAN can run searches attributed to the node's IP. The canonical conf routes
/// it through the session-gated daemon (5678) and forwards the Cookie. The
/// stale target string is unique to that block, so a plain replace is safe.
/// Pure and testable; `None` when the stale shape is absent.
fn heal_stale_web_search_block(content: &str) -> Option<String> {
if !content.contains("proxy_pass http://127.0.0.1:8888/search;") {
return None;
}
Some(content.replace(
"proxy_pass http://127.0.0.1:8888/search;\n proxy_http_version 1.1;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;",
"proxy_pass http://127.0.0.1:5678;\n proxy_http_version 1.1;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_set_header Cookie $http_cookie;",
))
}
async fn patch_nginx_conf(path: &str) -> Result<bool> {
let content = fs::read_to_string(path)
.await
@@ -1116,6 +1132,7 @@ async fn patch_nginx_conf(path: &str) -> Result<bool> {
content.contains("listen 80 default_server;") && !content.contains("listen [::]:80");
let missing_v6_https =
content.contains("listen 443 ssl default_server;") && !content.contains("listen [::]:443");
let stale_web_search = heal_stale_web_search_block(&content).is_some();
if !missing_app_catalog
&& !missing_bitcoin_status
&& !missing_lnd_proxy
@@ -1125,12 +1142,18 @@ async fn patch_nginx_conf(path: &str) -> Result<bool> {
&& !needs_fedimint_css
&& !missing_v6_http
&& !missing_v6_https
&& !stale_web_search
{
return Ok(false);
}
let mut patched = content.clone();
if let Some(p) = heal_stale_web_search_block(&patched) {
patched = p;
}
if missing_v6_http {
patched = patched.replace(
"listen 80 default_server;",
@@ -1302,6 +1325,19 @@ mod tests {
let outcome = PodmanHealOutcome::Unhealthy;
assert_ne!(outcome, PodmanHealOutcome::Healthy);
}
#[test]
fn stale_web_search_block_is_gated_and_idempotent() {
let stale = " location /aiui/api/web-search {\n proxy_pass http://127.0.0.1:8888/search;\n proxy_http_version 1.1;\n proxy_set_header Host $host;\n proxy_set_header X-Real-IP $remote_addr;\n proxy_connect_timeout 30s;\n }";
let healed = heal_stale_web_search_block(stale).expect("stale block must heal");
assert!(healed.contains("proxy_pass http://127.0.0.1:5678;"));
assert!(healed.contains("proxy_set_header Cookie $http_cookie;"));
assert!(!healed.contains("8888"));
// Second pass is a no-op (idempotent self-heal).
assert!(heal_stale_web_search_block(&healed).is_none());
// A config without the block is untouched.
assert!(heal_stale_web_search_block("location / { try_files $uri /index.html; }").is_none());
}
}
/// Repair this node's own systemd restart policy.