← Commit history

0.2.106: name the caller on every call to Adom Bridge (ab 2.1.205 caller_identity_required)

Colby Knox ·5eb54f85ca · ·parent 9bce8f6
7 files changed +35−6
CHANGELOG.md+6
@@ -1,5 +1,11 @@ # Changelog +## 0.2.106++- Includes 0.2.105 (Altium on any drive, #40).+- **Every call the bridge makes to Adom Bridge names a caller.** Adom Bridge 2.1.205 refuses a call that names no AI thread (`caller_identity_required`). The bridge already named itself in the call's arguments when it had no caller to act for. It now also sends the `X-Adom-Caller-Thread` header, and does so whenever a request brought caller headers without a thread. The bridge never calls its own verbs through Adom Bridge, which is what broke EAGLE imports in the Fusion bridge.+- Tested on Adom Bridge 2.1.205: `altium_instances`, `altium_check_dialogs`, `altium_license_status` and `altium_diagnostics`, whose own calls to Adom Bridge carry no forwarded caller.+ ## 0.2.105  - **Altium installed on another drive is found** (#40). The bridge looked for Altium only under `C:\Program Files\Altium`, so an install on D: answered "not installed". It now reads where each install is recorded in the Windows registry (`HKLM\SOFTWARE\Altium\Builds`), and still searches `\Program Files\Altium` on every fixed drive for an install the registry does not list. `altium_launch` starts the install wherever it is, and `install:"develop"` also recognises Develop by its registered name, whatever its folder is called.
bridge-rs/src/ab.rs+24−1
@@ -6,7 +6,11 @@ pub fn call(command: &str, args: Value, forwarded: &[(String, String)], timeout_     let base = std::env::var("ADOM_DIRECT_API_URL").unwrap_or_else(|_| "http://127.0.0.1:24680".into());     let url = format!("{}/command", base.trim_end_matches('/'));     let mut args = args;-    if forwarded.is_empty() {+    // ab 2.1.205 refuses a call that names no AI thread (caller_identity_required). With no caller's thread to forward+    // (the bridge's own background work, or a request that brought only some caller headers), the bridge names itself,+    // in the args and in the header ab reads first.+    let own_thread = !has_thread(forwarded);+    if own_thread {         if let Some(o) = args.as_object_mut() {             o.entry("caller").or_insert(json!({"aiThread": "altium-bridge", "source": "bridge"}));         }@@ -20,6 +24,7 @@ pub fn call(command: &str, args: Value, forwarded: &[(String, String)], timeout_     for (k, v) in forwarded {         req = req.set(k, v);     }+    if own_thread { req = req.set("X-Adom-Caller-Thread", "altium-bridge"); }     req = req.set("X-Adom-Caller-Delegate", "altium");     match req.send_json(json!({"command": command, "args": args})) {         Ok(r) => unwrap_output(r.into_json::<Value>().unwrap_or_else(|e| json!({"success": false, "error": format!("ab reply not JSON: {e}")}))),@@ -31,6 +36,24 @@ pub fn call(command: &str, args: Value, forwarded: &[(String, String)], timeout_     } } +/// Whether the forwarded caller headers name an AI thread. Pure.+pub fn has_thread(forwarded: &[(String, String)]) -> bool {+    forwarded.iter().any(|(k, v)| k.eq_ignore_ascii_case("x-adom-caller-thread") && !v.trim().is_empty())+}++#[cfg(test)]+mod caller_tests {+    use super::*;++    #[test]+    fn the_bridge_names_itself_unless_a_thread_is_forwarded() {+        assert!(!has_thread(&[]), "background work");+        assert!(!has_thread(&[("X-Adom-Caller-Container".into(), "c1".into())]), "a container but no thread");+        assert!(!has_thread(&[("X-Adom-Caller-Thread".into(), " ".into())]), "a blank thread does not count");+        assert!(has_thread(&[("x-adom-caller-thread".into(), "altium-lane".into())]));+    }+}+ /// Adom Bridge's shell approval as `status` reports it. It gates synthetic input (UIA set and click, keys) even for a /// bridge on the loopback, and a dialog flow without it fails silently: fusion-bridge#133 on a user's PC. Pure. pub fn shell_approved(status: &Value) -> bool {
bridge-rs/src/main.rs+1−1
@@ -82,7 +82,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.105";+pub const BRIDGE_VERSION: &str = "0.2.106";  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.105",+  "version": "0.2.106",   "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.105",+  "version": "0.2.106",   "hero": {     "type": "image",     "path": "screenshots/hero.png"
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-0.2.105+0.2.106
src/bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "altium",   "displayName": "Altium Designer",-  "version": "0.2.105",+  "version": "0.2.106",   "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",