bridges: derive skill config vars from the bridge block

Bridge listener addresses were hand-maintained duplicates of
bridges.<name>.host/port at the top level (simplex_bridge_url,
llm_bridge_url, nextcloud_bridge_url, plus their _token). A host
provisioned before a bridge was added never gained the key, so a skill
for that bridge could not resolve its URL: the contract config search
fell back to 'ask' and a front end captured an unrelated reply as the
value (a voice task request was recorded as nextcloud_bridge_url).

Add bridges.registry.derived_config_vars(config): for every catalog
bridge, derive <name>_bridge_url/<name>_bridge_token from its own
bridges.<name> host/port/token. build_scheduler injects these into the
config the scheduler and ctx.config expose, so the contract config
search finds them and skills read them with no top-level duplicate.
A block with no port contributes no URL, leaving an unconfigured bridge
as an unresolved variable the operator is asked for. Bind-all hosts
normalize to 127.0.0.1.

Remove the six redundant top-level keys from config.example.json and
update README/AGENTS/bootstrap notes. Tests cover derivation, bind-all
normalization, and the unconfigured-bridge skip.
This commit is contained in:
gabby committed 2026-10-08 00:17:53 +00:00
1 parent d9cc7e4fed
commit 228886f7cd
8 files changed
+113 -36

No files matched your search

+29
View File
@@ -32,6 +32,35 @@ def known_infos() -> list[BridgeInfo]:
return [bridge_class.INFO for bridge_class in CATALOG]
def derived_config_vars(config: dict) -> dict[str, str]:
"""Skill-facing config vars for every bridge, derived from its own block.
The `bridges.<name>` block is the single source of truth: its `host`/`port`
are the listener a skill body calls and its `token` is the shared secret.
There is deliberately no duplicate top-level `*_bridge_url`/`*_bridge_token`
to keep in sync — the values are derived here and injected into the config a
skill reads (`ctx.config`). A bridge with no block (or no port) contributes
nothing, so an unconfigured bridge still surfaces as an unresolved contract
variable the operator is asked for.
"""
blocks = config.get("bridges", {}) or {}
derived: dict[str, str] = {}
for info in known_infos():
block = blocks.get(info.name)
if not isinstance(block, dict):
continue
host = str(block.get("host") or "127.0.0.1").strip()
# A bind-all address is not a callable one; skills always call loopback.
if host in ("", "0.0.0.0", "::", "[::]"):
host = "127.0.0.1"
port = block.get("port")
if info.url_config_var and port:
derived[info.url_config_var] = f"http://{host}:{int(port)}"
if info.auth_config_var:
derived[info.auth_config_var] = str(block.get("token") or "")
return derived
def describe_bridges() -> str:
"""A prompt block describing every available bridge service.