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

+13 -9
View File
@@ -734,9 +734,9 @@ CLI, unit tests (24) + integration tests (2).
`codegen.timeout: 3600`, the SimpleX gateway enabled `codegen.timeout: 3600`, the SimpleX gateway enabled
(`gateway.simplex.enabled = true`, `ws_url` from `simplex_chat.port`) and the (`gateway.simplex.enabled = true`, `ws_url` from `simplex_chat.port`) and the
standalone forwarding bridge enabled (`bridges.simplex.enabled = true`, standalone forwarding bridge enabled (`bridges.simplex.enabled = true`,
`ws_url` from `simplex_chat.forward_port`, top-level `simplex_bridge_url`) and `ws_url` from `simplex_chat.forward_port`) and
the LLM bridge enabled (`bridges.llm.enabled = true`, top-level the LLM bridge enabled (`bridges.llm.enabled = true`; it reuses the `llm`
`llm_bridge_url`; it reuses the `llm` model); model);
the operator sets `llm.model`/`llm.base_url` and `codegen.model`/ the operator sets `llm.model`/`llm.base_url` and `codegen.model`/
`codegen.base_url`. Bootstrap renders/enables four user services: `codegen.base_url`. Bootstrap renders/enables four user services:
`semif-simplex.service` (the command `simplex-chat` bot daemon, `semif-simplex.service` (the command `simplex-chat` bot daemon,
@@ -1273,9 +1273,13 @@ CLI, unit tests (24) + integration tests (2).
(surviving bridge restarts), unlike the live `/inbox` buffer; both are (surviving bridge restarts), unlike the live `/inbox` buffer; both are
read-only because v7 has no mark-read command (acking is a client-side read read-only because v7 has no mark-read command (acking is a client-side read
receipt). receipt).
- **Skill-facing config.** The top-level `simplex_bridge_url` is the address a - **Skill-facing config.** A body calls a bridge at the address derived from that
body calls (the data-contract config search auto-populates it); bootstrap keeps bridge's own `bridges.<name>` block (`host`/`port`/`token`) — the
it in sync with the bridge port. Skills reach a bridge with the ordinary `http` `simplex_bridge_url` / `llm_bridge_url` / `nextcloud_bridge_url` var (+ `_token`)
is injected into `ctx.config` by `build_scheduler` via
`bridges.registry.derived_config_vars`, so there is no duplicate top-level key to
keep in sync and the data-contract config search finds it and auto-populates the
skill config. Skills reach a bridge with the ordinary `http`
transport, so their hermetic tests are loopback HTTP like any other HTTP body. transport, so their hermetic tests are loopback HTTP like any other HTTP body.
`simplex.next_message` and `simplex.connect_link` are the seeds. `simplex.next_message` and `simplex.connect_link` are the seeds.
- **LLM bridge** (`bridges/llm.py`). A generic `POST /chat` - **LLM bridge** (`bridges/llm.py`). A generic `POST /chat`
@@ -1287,7 +1291,7 @@ CLI, unit tests (24) + integration tests (2).
scheduler's already-configured `llm` client through `run_bridges`/`build_bridge` scheduler's already-configured `llm` client through `run_bridges`/`build_bridge`
into `LLMBridge`, so the endpoint/model/sampler stay configured once in the into `LLMBridge`, so the endpoint/model/sampler stay configured once in the
top-level `llm` block; the `bridges.llm` block carries only the local listener top-level `llm` block; the `bridges.llm` block carries only the local listener
(`enabled`/`host`/`port`/`token`). Bodies reach it via the top-level (`enabled`/`host`/`port`/`token`). Bodies reach it via the derived
`llm_bridge_url` (+ optional `llm_bridge_token`). It runs inside the existing `llm_bridge_url` (+ optional `llm_bridge_token`). It runs inside the existing
`semif-bridge.service` process (all enabled bridges start together); with no `semif-bridge.service` process (all enabled bridges start together); with no
client it reports `502`, never a fabricated reply. `calendar.create_event` is client it reports `502`, never a fabricated reply. `calendar.create_event` is
@@ -1306,7 +1310,7 @@ CLI, unit tests (24) + integration tests (2).
`nextcloud_url`/`nextcloud_username`/`nextcloud_app_password`/ `nextcloud_url`/`nextcloud_username`/`nextcloud_app_password`/
`nextcloud_default_calendar`/`nextcloud_default_addressbook` as a fallback, so `nextcloud_default_calendar`/`nextcloud_default_addressbook` as a fallback, so
the same account the calendar seeds collect is configured once and a block value the same account the calendar seeds collect is configured once and a block value
wins. Bodies reach it via the top-level `nextcloud_bridge_url` (+ optional wins. Bodies reach it via the derived `nextcloud_bridge_url` (+ optional
`nextcloud_bridge_token`); the `BridgeInfo` declares only those two config vars. `nextcloud_bridge_token`); the `BridgeInfo` declares only those two config vars.
Routes (reads `GET`, mutations `POST`): files (`/files`, `/files/stat`, Routes (reads `GET`, mutations `POST`): files (`/files`, `/files/stat`,
`/files/read` text-or-base64, `/files/search`, `/files/write|mkdir|delete|move|copy`), `/files/read` text-or-base64, `/files/search`, `/files/write|mkdir|delete|move|copy`),
@@ -1357,7 +1361,7 @@ The bridge read path (`simplex.next_message`) and contact-link lookup
- [x] **4. LLM bridge** (`bridges/llm.py`). Shipped: `LLMBridge` exposes a - [x] **4. LLM bridge** (`bridges/llm.py`). Shipped: `LLMBridge` exposes a
generic `POST /chat` in front of the scheduler's configured `llm` client generic `POST /chat` in front of the scheduler's configured `llm` client
(threaded through `run_bridges`/`build_bridge`, never re-configured), registered (threaded through `run_bridges`/`build_bridge`, never re-configured), registered
in `CATALOG` and seeded under `bridges.llm` + top-level `llm_bridge_url`. in `CATALOG` and seeded under `bridges.llm` (its URL is derived from that block).
`calendar.create_event` extracts its title + description through it. `calendar.create_event` extracts its title + description through it.
- [x] **5. More bridges.** Each new third-party API gets its own `bridges/<name>.py` - [x] **5. More bridges.** Each new third-party API gets its own `bridges/<name>.py`
+ config block + `CATALOG` entry; the codegen prompts pick it up automatically + config block + `CATALOG` entry; the codegen prompts pick it up automatically
+14 -10
View File
@@ -513,14 +513,17 @@ Key blocks:
| `gateway.simplex` | command gateway: ws_url, allowlist, batching | | `gateway.simplex` | command gateway: ws_url, allowlist, batching |
| `gateway.voice` | voice gateway: wake/STT/TTS engines + models, audio devices, VAD, follow-up window | | `gateway.voice` | voice gateway: wake/STT/TTS engines + models, audio devices, VAD, follow-up window |
| `bridges.simplex` | forwarding bridge: host/port/token/ws_url | | `bridges.simplex` | forwarding bridge: host/port/token/ws_url |
| `simplex_bridge_url` / `simplex_bridge_token` | what skill bodies call |
| `bridges.llm` | LLM bridge: host/port/token (model comes from `llm`) | | `bridges.llm` | LLM bridge: host/port/token (model comes from `llm`) |
| `llm_bridge_url` / `llm_bridge_token` | what skill bodies call for generation |
| `bridges.nextcloud` | Nextcloud bridge: host/port/token + connection (url/username/app_password/defaults) | | `bridges.nextcloud` | Nextcloud bridge: host/port/token + connection (url/username/app_password/defaults) |
| `nextcloud_bridge_url` / `nextcloud_bridge_token` | what skill bodies call for Nextcloud |
| `simplex_chat` | gateway/forward ports and bot display names (binary refs come from `pins.json`) | | `simplex_chat` | gateway/forward ports and bot display names (binary refs come from `pins.json`) |
| `dashboard` | bind host/port | | `dashboard` | bind host/port |
Bridge skills read `simplex_bridge_url` / `llm_bridge_url` / `nextcloud_bridge_url`
(+ their `_token`) from `ctx.config`; each is **derived** at startup from its
`bridges.<name>` host/port/token, so there is no duplicate top-level key to keep
in sync. A bridge with no block (or no port) leaves the variable unresolved and
the operator is asked for it.
`llm.model` and `codegen.model` are **required** (no default): set each to a `llm.model` and `codegen.model` are **required** (no default): set each to a
model its endpoint serves. A missing model fails fast at startup with a clear model its endpoint serves. A missing model fails fast at startup with a clear
config error rather than sending a request to a model that isn't there. config error rather than sending a request to a model that isn't there.
@@ -710,7 +713,8 @@ so they see messages that arrived while the bridge was down — unlike the live
`/inbox` receive buffer. Both are read-only: v7 has no mark-read command, so `/inbox` receive buffer. Both are read-only: v7 has no mark-read command, so
acking is a client-side read receipt, not an API call. acking is a client-side read receipt, not an API call.
`simplex_bridge_url` (top-level config) is what skills call; the bridge catalog Skills call the forwarding bridge at the address derived from `bridges.simplex`
(`simplex_bridge_url`); the bridge catalog
is injected into every codegen prompt via `describe_bridges()`, so it is the is injected into every codegen prompt via `describe_bridges()`, so it is the
single source of bridge specifics. Adding a bridge = a class + a config block + single source of bridge specifics. Adding a bridge = a class + a config block +
a `CATALOG` entry. a `CATALOG` entry.
@@ -726,10 +730,10 @@ text (e.g. extract an event title + description) over HTTP instead of speaking
the OpenAI-compatible protocol itself. It does not own the model connection: the OpenAI-compatible protocol itself. It does not own the model connection:
`cli bridge` threads the scheduler's already-configured `llm` client into it, so `cli bridge` threads the scheduler's already-configured `llm` client into it, so
the endpoint/model/sampler live only in the top-level `llm` block; `bridges.llm` the endpoint/model/sampler live only in the top-level `llm` block; `bridges.llm`
carries just the local listener. Skills call it via `llm_bridge_url` carries just the local listener. Skills call it at the address derived from
(+ optional `llm_bridge_token`); with no client it returns `502`, never a `bridges.llm` (`llm_bridge_url`, + optional `llm_bridge_token`); with no client
fabricated reply. It starts in the same `semif-bridge.service` process as the it returns `502`, never a fabricated reply. It starts in the same
other enabled bridges. `semif-bridge.service` process as the other enabled bridges.
The **Nextcloud bridge** (`semif_agent/bridges/nextcloud.py`) is the third: it The **Nextcloud bridge** (`semif_agent/bridges/nextcloud.py`) is the third: it
wraps the account's native protocols — WebDAV files, CalDAV calendar events and wraps the account's native protocols — WebDAV files, CalDAV calendar events and
@@ -740,8 +744,8 @@ in the same `semif-bridge` process. The connection (base URL, username, app
password) is configured in `bridges.nextcloud` and falls back to the top-level password) is configured in `bridges.nextcloud` and falls back to the top-level
`nextcloud_url` / `nextcloud_username` / `nextcloud_app_password` / `nextcloud_url` / `nextcloud_username` / `nextcloud_app_password` /
`nextcloud_default_calendar` the calendar seeds use, so the account is `nextcloud_default_calendar` the calendar seeds use, so the account is
configured once. Skills call it via `nextcloud_bridge_url` (+ optional configured once. Skills call it at the address derived from `bridges.nextcloud`
`nextcloud_bridge_token`). Its HTTP surface: (`nextcloud_bridge_url`, + optional `nextcloud_bridge_token`). Its HTTP surface:
``` ```
GET /health GET /health
+3 -9
View File
@@ -117,12 +117,6 @@
}, },
"skill_bodies": "data/skills", "skill_bodies": "data/skills",
"skill_seeds": "seeds", "skill_seeds": "seeds",
"simplex_bridge_url": "http://127.0.0.1:5227",
"simplex_bridge_token": "",
"llm_bridge_url": "http://127.0.0.1:5229",
"llm_bridge_token": "",
"nextcloud_bridge_url": "http://127.0.0.1:5230",
"nextcloud_bridge_token": "",
"log": "data/decisions.jsonl", "log": "data/decisions.jsonl",
"trace": "data/runs.jsonl", "trace": "data/runs.jsonl",
"category_registry": "data/categories.json", "category_registry": "data/categories.json",
@@ -136,7 +130,7 @@
"bridges": { "bridges": {
"_comment": "Standalone third-party API bridges: a simple, secure local HTTP layer between codegen-authored skill bodies and real system services. Each bridge runs as its own process (`python -m semif_agent.cli bridge [--name NAME]`), one process per service daemon, and never runs inside the command gateway — gateway isolation is non-negotiable (see AGENTS.md). The bridge catalog (names, endpoints, config vars) is injected into the code-generation prompts via `semif_agent.bridges.describe_bridges()`.", "_comment": "Standalone third-party API bridges: a simple, secure local HTTP layer between codegen-authored skill bodies and real system services. Each bridge runs as its own process (`python -m semif_agent.cli bridge [--name NAME]`), one process per service daemon, and never runs inside the command gateway — gateway isolation is non-negotiable (see AGENTS.md). The bridge catalog (names, endpoints, config vars) is injected into the code-generation prompts via `semif_agent.bridges.describe_bridges()`.",
"simplex": { "simplex": {
"_comment": "SimpleX forwarding bridge: buffers every inbound DM (no allowlist — the point is to see who reached the bot through its invite link), and serves invite-link / read / send over HTTP. It owns its own simplex-chat daemon/profile (`ws_url`, `forward_port` above), separate from the command gateway's. Skills use the top-level `simplex_bridge_url`; keep it in sync with host/port. Binds localhost only; an optional `token` is required in the X-Semif-Token header when set.", "_comment": "SimpleX forwarding bridge: buffers every inbound DM (no allowlist — the point is to see who reached the bot through its invite link), and serves invite-link / read / send over HTTP. It owns its own simplex-chat daemon/profile (`ws_url`, `forward_port` above), separate from the command gateway's. Skills call it at http://host:port (derived from this block; no top-level duplicate). Binds localhost only; an optional `token` is required in the X-Semif-Token header when set.",
"enabled": true, "enabled": true,
"host": "127.0.0.1", "host": "127.0.0.1",
"port": 5227, "port": 5227,
@@ -148,14 +142,14 @@
"reconnect": {"initial": 1.0, "max": 60.0, "jitter": 0.2} "reconnect": {"initial": 1.0, "max": 60.0, "jitter": 0.2}
}, },
"llm": { "llm": {
"_comment": "LLM bridge: a generic `POST /chat` in front of the agent's configured `llm` model, so skill bodies can ask for short generated text (e.g. an event title + description) over HTTP instead of speaking the OpenAI-compatible protocol. It reuses the top-level `llm` client (endpoint/model/sampler configured once there); this block only carries the local listener. Skills use the top-level `llm_bridge_url`; keep it in sync with host/port. Binds localhost only; an optional `token` is required in the X-Semif-Token header when set. It runs inside the same `semif-bridge.service` process as the other enabled bridges.", "_comment": "LLM bridge: a generic `POST /chat` in front of the agent's configured `llm` model, so skill bodies can ask for short generated text (e.g. an event title + description) over HTTP instead of speaking the OpenAI-compatible protocol. It reuses the top-level `llm` client (endpoint/model/sampler configured once there); this block only carries the local listener. Skills call it at http://host:port (derived from this block; no top-level duplicate). Binds localhost only; an optional `token` is required in the X-Semif-Token header when set. It runs inside the same `semif-bridge.service` process as the other enabled bridges.",
"enabled": true, "enabled": true,
"host": "127.0.0.1", "host": "127.0.0.1",
"port": 5229, "port": 5229,
"token": "" "token": ""
}, },
"nextcloud": { "nextcloud": {
"_comment": "Nextcloud bridge: files (WebDAV), calendar events and tasks (CalDAV), contacts (CardDAV), and Notes (the Notes app) over one uniform local JSON API, so skill bodies never speak the native DAV/OCS protocols. It has no service daemon (Nextcloud is plain HTTPS) and runs inside the same `semif-bridge` process as the other enabled bridges. The connection is configured HERE (url/username/app_password); when a value is blank the bridge falls back to the top-level nextcloud_url/nextcloud_username/nextcloud_app_password/nextcloud_default_calendar the calendar seeds already use, so the account is configured once. `app_password` is a Nextcloud app password (Settings > Security > Devices & sessions), not the account password. `default_calendar`/`default_addressbook` are used when a request names none and the account has several. `verify_tls` false skips certificate verification (self-signed hosts). Skills use the top-level `nextcloud_bridge_url`; keep it in sync with host/port. Binds localhost only; an optional `token` is required in the X-Semif-Token header when set.", "_comment": "Nextcloud bridge: files (WebDAV), calendar events and tasks (CalDAV), contacts (CardDAV), and Notes (the Notes app) over one uniform local JSON API, so skill bodies never speak the native DAV/OCS protocols. It has no service daemon (Nextcloud is plain HTTPS) and runs inside the same `semif-bridge` process as the other enabled bridges. The connection is configured HERE (url/username/app_password); when a value is blank the bridge falls back to the top-level nextcloud_url/nextcloud_username/nextcloud_app_password/nextcloud_default_calendar the calendar seeds already use, so the account is configured once. `app_password` is a Nextcloud app password (Settings > Security > Devices & sessions), not the account password. `default_calendar`/`default_addressbook` are used when a request names none and the account has several. `verify_tls` false skips certificate verification (self-signed hosts). Skills call it at http://host:port (derived from this block; no top-level duplicate). Binds localhost only; an optional `token` is required in the X-Semif-Token header when set.",
"enabled": true, "enabled": true,
"host": "127.0.0.1", "host": "127.0.0.1",
"port": 5230, "port": 5230,
+7 -7
View File
@@ -616,21 +616,21 @@ SimpleX forwarding bridge (messaging UX for skills):
and 'semif-bridge' (the standalone bridge API). Its contact address is printed and 'semif-bridge' (the standalone bridge API). Its contact address is printed
above; re-print with: above; re-print with:
"$PYTHON" scripts/simplex-address.py --ws-url ws://127.0.0.1:$SIMPLEX_FORWARD_PORT "$PYTHON" scripts/simplex-address.py --ws-url ws://127.0.0.1:$SIMPLEX_FORWARD_PORT
- Skills reach it over HTTP via the top-level simplex_bridge_url - Skills reach it over HTTP at the address derived from bridges.simplex
(default http://127.0.0.1:5227); simplex.connect_link shows its address and (host/port, default http://127.0.0.1:5227); simplex.connect_link shows its
simplex.next_message reads messages sent to it. address and simplex.next_message reads messages sent to it.
LLM bridge (generation for skills): LLM bridge (generation for skills):
- Runs inside the same 'semif-bridge' process. It reuses the top-level `llm` - Runs inside the same 'semif-bridge' process. It reuses the top-level `llm`
model (configured once) and serves a generic POST /chat; skills call it via model (configured once) and serves a generic POST /chat; skills call it at
the top-level llm_bridge_url (default http://127.0.0.1:5229). the address derived from bridges.llm (default http://127.0.0.1:5229).
Nextcloud bridge (files/calendar/tasks/contacts/notes for skills): Nextcloud bridge (files/calendar/tasks/contacts/notes for skills):
- Runs inside the same 'semif-bridge' process (Nextcloud is plain HTTPS, so - Runs inside the same 'semif-bridge' process (Nextcloud is plain HTTPS, so
there is no separate daemon). Configure the account once in config.json under there is no separate daemon). Configure the account once in config.json under
bridges.nextcloud (url/username/app_password) — or reuse the top-level bridges.nextcloud (url/username/app_password) — or reuse the top-level
nextcloud_* values the calendar seeds collect. Skills call it via the nextcloud_* values the calendar seeds collect. Skills call it at the address
top-level nextcloud_bridge_url (default http://127.0.0.1:5230). derived from bridges.nextcloud (default http://127.0.0.1:5230).
EOF EOF
if [[ "$VOICE" = 1 ]]; then if [[ "$VOICE" = 1 ]]; then
+2
View File
@@ -26,6 +26,7 @@ from .base import BridgeInfo, BridgeService
from .inbox import MessagingInbox from .inbox import MessagingInbox
from .registry import ( from .registry import (
build_bridge, build_bridge,
derived_config_vars,
describe_bridges, describe_bridges,
known_infos, known_infos,
run_bridges, run_bridges,
@@ -36,6 +37,7 @@ __all__ = [
"BridgeService", "BridgeService",
"MessagingInbox", "MessagingInbox",
"build_bridge", "build_bridge",
"derived_config_vars",
"describe_bridges", "describe_bridges",
"known_infos", "known_infos",
"run_bridges", "run_bridges",
+29
View File
@@ -32,6 +32,35 @@ def known_infos() -> list[BridgeInfo]:
return [bridge_class.INFO for bridge_class in CATALOG] 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: def describe_bridges() -> str:
"""A prompt block describing every available bridge service. """A prompt block describing every available bridge service.
+7
View File
@@ -313,6 +313,13 @@ def build_llm_client(config: dict, engine):
def build_scheduler(config: dict) -> tuple[Scheduler, dict]: def build_scheduler(config: dict) -> tuple[Scheduler, dict]:
# Bridge listener addresses/tokens are derived from each bridge's own
# `bridges.<name>` block (host/port/token) — the single source of truth.
# There is no duplicate top-level *_bridge_url to drift; skills read these
# from ctx.config and the contract config search finds them here.
from .bridges.registry import derived_config_vars
config = {**config, **derived_config_vars(config)}
engine = build_engine(config) engine = build_engine(config)
llm = build_llm_client(config, engine) llm = build_llm_client(config, engine)
log = DecisionLog(config.get("log", "data/decisions.jsonl")) log = DecisionLog(config.get("log", "data/decisions.jsonl"))
+38 -1
View File
@@ -15,7 +15,11 @@ import urllib.request
import pytest import pytest
from semif_agent.bridges.llm import LLMBridge from semif_agent.bridges.llm import LLMBridge
from semif_agent.bridges.registry import describe_bridges, known_infos from semif_agent.bridges.registry import (
derived_config_vars,
describe_bridges,
known_infos,
)
from semif_agent.bridges.simplex import SimplexBridge from semif_agent.bridges.simplex import SimplexBridge
@@ -674,6 +678,39 @@ def test_every_bridge_documents_its_config_vars_and_auth():
assert info.auth_config_var in info.config_vars, info.name assert info.auth_config_var in info.config_vars, info.name
def test_derived_config_vars_come_from_each_bridge_block():
config = {
"bridges": {
"simplex": {"host": "127.0.0.1", "port": 5227, "token": "s"},
"llm": {"host": "127.0.0.1", "port": 5229, "token": ""},
"nextcloud": {"host": "127.0.0.1", "port": 5230, "token": "n"},
}
}
derived = derived_config_vars(config)
assert derived["simplex_bridge_url"] == "http://127.0.0.1:5227"
assert derived["simplex_bridge_token"] == "s"
assert derived["llm_bridge_url"] == "http://127.0.0.1:5229"
assert derived["llm_bridge_token"] == ""
assert derived["nextcloud_bridge_url"] == "http://127.0.0.1:5230"
assert derived["nextcloud_bridge_token"] == "n"
def test_derived_config_vars_normalize_bind_all_host():
config = {"bridges": {"llm": {"host": "0.0.0.0", "port": 5229}}}
assert derived_config_vars(config)["llm_bridge_url"] == "http://127.0.0.1:5229"
def test_derived_config_vars_skip_unconfigured_bridges():
# No block at all: nothing derived, so the contract variable stays
# unresolved and the operator is asked for it.
assert derived_config_vars({}) == {}
# A block without a port is not a callable address: no URL, but the token
# var is still satisfiable (empty = no auth).
derived = derived_config_vars({"bridges": {"nextcloud": {"token": ""}}})
assert "nextcloud_bridge_url" not in derived
assert derived["nextcloud_bridge_token"] == ""
def test_describe_bridges_renders_service_auth_and_endpoints(): def test_describe_bridges_renders_service_auth_and_endpoints():
text = describe_bridges() text = describe_bridges()
assert "simplex" in text assert "simplex" in text