by adom
Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.
← Commit history
0.2.95: /health answers without calling Adom Bridge (#30, adom/adom-bridge#260)
8 files changed
+46−16
CHANGELOG.md+6@@ -1,5 +1,11 @@ # Changelog +## 0.2.95++- **The health check no longer calls back into Adom Bridge** (#30, adom/adom-bridge#260). Adom Bridge probes every bridge's `/health` every few seconds. The altium bridge answered it by asking Adom Bridge for Altium's processes and windows, so the answer depended on Adom Bridge being free at that moment. `/health` now reads whether Altium runs straight from Windows, and reports the licence the last verb saw (up to two minutes old) instead of asking. It answers in about 45 ms with the same light: green when Altium runs and is licensed, yellow when it is not running.+- On one machine, Adom Bridge 2.1.168 ends a healthy altium bridge about 17 s after every start and logs nothing. 0.2.94's self-check showed the bridge answering right up to the end. That is filed on Adom Bridge as #260; this change removes the one way the bridge's own answer could depend on it.+- Tested on Altium Designer 26.11.1: `/health` with Altium closed and running, and 11 lifecycle and board verbs passed.+ ## 0.2.94 - **The bridge no longer exits when its HTTP listener stops accepting** (#30). On one machine every bridge process stopped 30 to 60 s after it started, with nothing printed. 0.2.93's crash log already captures Rust's own fatal messages, so this was not a stack overflow or a failed allocation. tiny_http 0.12 ends its accept thread on the first failed `accept()`, after which the bridge's request loop ended and the process exited cleanly and silently. The bridge now logs the error to `altium-bridge-crash.log` and listens again on the same port.
bridge-rs/src/health.rs+29−11@@ -37,30 +37,48 @@ pub fn parse_title(t: &str) -> Option<Value> { /// snapshot-cached). Kept here as the name every verb historically gates on. pub fn licence_state() -> Value { let v = crate::instance::licence_state();- if v.get("running").and_then(|b| b.as_bool()) == Some(false) && crate::instance::ab_unreachable() {- return json!({"running": false, "abUnreachable": true});- }+ let v = if v.get("running").and_then(|b| b.as_bool()) == Some(false) && crate::instance::ab_unreachable() {+ json!({"running": false, "abUnreachable": true})+ } else { v };+ remember_licence(&v); v } +/// Kept for /health: called by every licence read.+pub fn remember_licence(v: &Value) {+ if let Ok(mut g) = LAST_LICENCE.lock() {+ *g = Some((std::time::Instant::now(), v.clone()));+ }+}++/// The licence state the last verb saw, for /health (which must not ask ab).+static LAST_LICENCE: std::sync::Mutex<Option<(std::time::Instant, Value)>> = std::sync::Mutex::new(None);+ pub fn is_running() -> bool { licence_state().get("running").and_then(|b| b.as_bool()).unwrap_or(false) } +/// ab's health probe. It never calls back into ab: ab probes every bridge every few seconds, and a probe answer that+/// waited on ab itself could miss, which ab can read as a dead bridge (adom/adom-bridge#260, altium-bridge#30). Whether+/// Altium runs is read natively; the licence is the last one a verb saw, up to two minutes old, else unknown. pub fn report() -> Value {- let lic = licence_state();- let running = lic.get("running").and_then(|b| b.as_bool()).unwrap_or(false);- let (led, summary) = if lic.get("abUnreachable").and_then(|b| b.as_bool()).unwrap_or(false) {- ("yellow", "Adom Bridge unreachable".to_string())- } else if !running {+ let rows = crate::win32::visible_windows().unwrap_or_default();+ let running = crate::win32::pids_of("X2.EXE").unwrap_or_default().into_iter()+ .any(|p| crate::win32::pid_has_main_window(p, &rows));+ let lic = LAST_LICENCE.lock().ok().and_then(|g| g.as_ref()+ .filter(|(at, _)| at.elapsed() < std::time::Duration::from_secs(120)).map(|(_, v)| v.clone()));+ let licensed = lic.as_ref().and_then(|v| v.get("licensed")).and_then(|b| b.as_bool());+ let (led, summary) = if !running { ("yellow", "Altium not running".to_string())- } else if lic.get("licensed").and_then(|b| b.as_bool()) == Some(false) {- ("yellow", format!("Altium {}", lic.get("state").and_then(|s| s.as_str()).unwrap_or("No License")))+ } else if licensed == Some(false) {+ ("yellow", format!("Altium {}", lic.as_ref().and_then(|v| v.get("state")).and_then(|s| s.as_str()).unwrap_or("No License"))) } else if agent::is_alive() { ("green", "Altium + agent ready".to_string()) } else { ("green", "Altium running (agent idle)".to_string()) }; json!({"status": "ok", "led": led, "summary": summary, "tooltip": format!("altium-bridge {BRIDGE_VERSION} - {summary}"),- "bridgeVersion": BRIDGE_VERSION, "licence": lic, "engine": "rust"})+ "bridgeVersion": BRIDGE_VERSION, "running": running,+ "licence": lic.unwrap_or_else(|| json!({"running": running, "licensed": null, "note": "no verb has read the licence in the last two minutes"})),+ "engine": "rust"}) }
bridge-rs/src/instance.rs+6@@ -316,6 +316,12 @@ pub fn main_window() -> Option<Value> { /// Parsed from the selected instance's main window title (the cheapest truthful source). pub fn licence_state() -> Value {+ let v = licence_state_read();+ crate::health::remember_licence(&v);+ v+}++fn licence_state_read() -> Value { let mw = match main_window() { Some(w) => w, None => return json!({"running": false, "licensed": null, "state": null}),
bridge-rs/src/main.rs+1−1@@ -80,7 +80,7 @@ use tiny_http::{Header, Method, Response, Server}; /// Attached to every failed reply (see the /command handler). const REPORT_ISSUES: &str = "If this looks like an altium-bridge BUG (not a refusal you expected), report it: check for a duplicate with `adom-wiki issue list adom/altium-bridge`, then `adom-wiki issue create adom/altium-bridge --title \"<verb>: <one-line symptom>\" --category bug-report --body \"<what you ran, what you expected, what happened, the VERBATIM response JSON (and errorShot if present), bridgeVersion, the Altium version from altium_status, the OS>\"`. A relay, routing, toast or lifecycle problem belongs on adom/adom-bridge instead. Reports from real machines are how this bridge gets correct: three different Altium builds behaved three different ways in one weekend."; -pub const BRIDGE_VERSION: &str = "0.2.94";+pub const BRIDGE_VERSION: &str = "0.2.95"; fn json_response(status: u16, body: &serde_json::Value) -> Response<std::io::Cursor<Vec<u8>>> { let data = serde_json::to_vec(body).unwrap_or_else(|_| b"{}".to_vec());
package.json+1−1@@ -1,6 +1,6 @@ { "slug": "altium-bridge",- "version": "0.2.94",+ "version": "0.2.95", "type": "app", "description": "Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.", "tags": [
page.json+1−1@@ -4,7 +4,7 @@ "type": "app", "title": "Altium Bridge: AI for Altium Designer", "brief": "Let an AI (Claude, ChatGPT, Codex or any agent) run Altium Designer for you: create symbols and footprints, place parts (also from Altium 365), wire and annotate schematics, Update PCB, set the stack-up and rules, route, pour copper, add mounting holes and stitching vias, run ERC and DRC, and make Gerbers, BOMs and STEP. Free in Hydrogen; bring your own AI and Altium licence.",- "version": "0.2.94",+ "version": "0.2.95", "hero": { "type": "image", "path": "screenshots/hero.png"
src/BRIDGE_VERSION+1−1@@ -1 +1 @@-0.2.94+0.2.95
src/bridge.json+1−1@@ -2,7 +2,7 @@ "manifest_version": 1, "name": "altium", "displayName": "Altium Designer",- "version": "0.2.94",+ "version": "0.2.95", "description": "Drive Altium Designer from Adom: a resident DelphiScript agent (eval + the 1,100-command process launcher), the X2 -R command line, UIA over the VCL shell, dialogs by PID, screenshots of every Altium window, and Altium 365.", "homepage": "https://wiki.adom.inc/adom/altium-bridge", "docs": "https://wiki.adom.inc/adom/altium-bridge",