bridges: standalone third-party API bridges; isolate the command gateway

Split messaging UX (invite links, read, send) out of the command gateway into a
new `semif_agent.bridges` layer. Each bridge is its own process (`cli bridge`)
against its own service daemon/profile; the SimpleX bridge owns a second
simplex-chat daemon and buffers every inbound DM, so a message sent to the
connect-link address shows up in `simplex.next_message`.

- new: bridges/{base,inbox,registry,simplex}.py + neutral semif_agent/simplex_ws.py
- gateway: delete bridge.py; drop address/observer/pull-mode from the command path
- codegen: inject the bridge catalog (describe_bridges) into body + elicitation prompts
- seeds: repoint simplex.next_message/connect_link to top-level `simplex_bridge_url`
- config/bootstrap: new top-level `bridges` block + `simplex_bridge_url`; render
  semif-simplex-forward + semif-bridge units; gateway config loses bridge/inbox
- docs: AGENTS.md gateway isolation is non-negotiable
This commit is contained in:
Denton Social committed 2026-09-28 15:24:44 -05:00
1 parent d46fbdca19
commit ddc5cb66c8
31 files changed
+1702 -1088

No files matched your search

+1 -1
View File
@@ -1,3 +1,3 @@
{
"messaging_bridge_url": "Base URL of the messenger gateway's local HTTP bridge, e.g. http://127.0.0.1:5227 (no trailing slash needed)."
"simplex_bridge_url": "Base URL of the standalone SimpleX forwarding bridge, e.g. http://127.0.0.1:5227 (no trailing slash needed)."
}
+13 -13
View File
@@ -1,11 +1,11 @@
"""Show the SimpleX contact link others use to connect to this agent.
Real integration: the running messenger gateway serves a local HTTP bridge
(`messaging_bridge_url`). The gateway's own connection to the `simplex-chat`
daemon is the only thing that can read (or create) the bot's *user contact
address*; this body asks the bridge for it and reports the link honestly. It
never opens a WebSocket to the daemon and never invents a link: if the gateway
is not running or has no address, it says so.
Real integration: the standalone SimpleX forwarding bridge
(`simplex_bridge_url`). The bridge's own connection to the `simplex-chat`
daemon is the only thing that can read (or create) the forwarding bot's *user
contact address*; this body asks the bridge for it and reports the link
honestly. It never opens a WebSocket to the daemon and never invents a link: if
the bridge is not running or has no address, it says so.
`GET /address` shows the existing link and creates one on first call, returning
`{short_link, full_link, created}`.
@@ -22,20 +22,20 @@ from semif_agent.skills import ActionResult, Prediction
INTEGRATION = {
"service": "simplex",
"transport": "http",
"config_vars": ["messaging_bridge_url"],
"config_vars": ["simplex_bridge_url"],
}
TIMEOUT_SECONDS = 30
class BridgeError(Exception):
"""The local messaging bridge is unreachable or returned an error."""
"""The SimpleX forwarding bridge is unreachable or returned an error."""
def _base(ctx):
url = str(ctx.config.get("messaging_bridge_url", "") or "").strip().rstrip("/")
url = str(ctx.config.get("simplex_bridge_url", "") or "").strip().rstrip("/")
if not url:
raise BridgeError("messaging_bridge_url is not configured")
raise BridgeError("simplex_bridge_url is not configured")
return url
@@ -57,8 +57,8 @@ def predict(ctx, request):
except BridgeError as exc:
return Prediction(text=f"bridge error: {exc}")
if not payload.get("ok"):
return Prediction(text="bridge error: gateway bridge is not healthy")
return Prediction(text="ready: messenger bridge reachable")
return Prediction(text="bridge error: simplex forwarding bridge is not healthy")
return Prediction(text="ready: simplex forwarding bridge reachable")
def act(ctx, request, prediction):
@@ -77,7 +77,7 @@ def act(ctx, request, prediction):
if not (short or full):
return ActionResult(
action_log=(
"simplex.connect_link: the gateway returned no SimpleX "
"simplex.connect_link: the bridge returned no SimpleX "
"contact link; the bot has no address yet."
),
new_state=request.text,
+3 -3
View File
@@ -1,10 +1,10 @@
"""Hermetic mechanics test for simplex.connect_link.
Run from this folder: `python skill.test.py`. No external network: a loopback
http.server plays the messenger gateway's bridge. This proves the body health-
http.server plays the standalone SimpleX forwarding bridge. This proves the body health-
checks the bridge, fetches the contact link, reports a freshly created link, and
fails honestly when the bridge has no provider or is unreachable. It does NOT
prove the live integration — only a real run against the gateway and a real
prove the live integration — only a real run against the bridge and a real
simplex-chat daemon does.
"""
@@ -59,7 +59,7 @@ def start_server(address=None, address_status=200):
def config(url):
return {"messaging_bridge_url": url}
return {"simplex_bridge_url": url}
def test_reports_existing_link():
+1 -1
View File
@@ -1,4 +1,4 @@
{
"messaging_bridge_url": "Base URL of the messenger gateway's local HTTP bridge, e.g. http://127.0.0.1:5227 (no trailing slash needed).",
"simplex_bridge_url": "Base URL of the standalone SimpleX forwarding bridge, e.g. http://127.0.0.1:5227 (no trailing slash needed).",
"simplex_default_contact": "Optional display name or contact id to read from by default when the conversation is not otherwise clear; leave blank to always choose among the conversations with unread messages."
}
+1 -1
View File
@@ -1,3 +1,3 @@
{
"description": "Read the next unread SimpleX message through the messenger gateway."
"description": "Read the next unread SimpleX message through the forwarding bridge."
}
+11 -11
View File
@@ -1,11 +1,11 @@
"""Read the next unread SimpleX message through the messenger gateway.
"""Read the next unread SimpleX message through the forwarding bridge.
Real integration: the running messenger gateway serves a local HTTP bridge
(`messaging_bridge_url`) that buffers every inbound DM and forwards outbound
sends. `predict` peeks that inbox, finds which conversations have unread
messages, and resolves which one to read with a SemIf sub-decision when more
than one does (honoring a configured default contact); `act` pops and reports
the oldest unread message for that conversation.
Real integration: the standalone SimpleX forwarding bridge
(`simplex_bridge_url`) buffers every inbound DM and forwards outbound sends.
`predict` peeks that inbox, finds which conversations have unread messages, and
resolves which one to read with a SemIf sub-decision when more than one does
(honoring a configured default contact); `act` pops and reports the oldest
unread message for that conversation.
The bridge owns the read cursor, so this skill keeps no state of its own. It
never opens a WebSocket to the `simplex-chat` daemon — the bridge is the only
@@ -25,20 +25,20 @@ from semif_agent.skills import ActionResult, Prediction
INTEGRATION = {
"service": "simplex",
"transport": "http",
"config_vars": ["messaging_bridge_url", "simplex_default_contact"],
"config_vars": ["simplex_bridge_url", "simplex_default_contact"],
}
TIMEOUT_SECONDS = 20
class BridgeError(Exception):
"""The local messaging bridge is unreachable or returned an error."""
"""The SimpleX forwarding bridge is unreachable or returned an error."""
def _base(ctx):
url = str(ctx.config.get("messaging_bridge_url", "") or "").strip().rstrip("/")
url = str(ctx.config.get("simplex_bridge_url", "") or "").strip().rstrip("/")
if not url:
raise BridgeError("messaging_bridge_url is not configured")
raise BridgeError("simplex_bridge_url is not configured")
return url
+3 -3
View File
@@ -1,11 +1,11 @@
"""Hermetic mechanics test for simplex.next_message.
Run from this folder: `python skill.test.py`. No external network: a loopback
http.server plays the messenger gateway's bridge. This proves the body peeks the
http.server plays the standalone SimpleX forwarding bridge. This proves the body peeks the
inbox, resolves the conversation through a SemIf sub-decision (or a configured
default), pops the real `next` message, and fails honestly when the bridge is
unreachable. It does NOT prove the live integration — only a real run against
the gateway and a real contact does.
the bridge and a real contact does.
"""
import json
@@ -89,7 +89,7 @@ def message(identifier, contact, name, text):
def config(url, default=""):
return {"messaging_bridge_url": url, "simplex_default_contact": default}
return {"simplex_bridge_url": url, "simplex_default_contact": default}
def test_multiple_senders_uses_semif_decision():