gateway: show/create the SimpleX contact link (simplex.connect_link seed)

Add a reusable corrId->Future request path to SimplexAdapter so the daemon
can be queried off the event loop, expose it as GET /address on the local
messaging bridge (injected address_provider; 503 unwired, 502 on daemon
failure), and ship a simplex.connect_link seed that reports the bot's short
and full contact link honestly, creating it on first call.
This commit is contained in:
Denton Social committed 2026-09-28 05:14:01 -05:00
1 parent 9057213217
commit a9b096f2e8
12 files changed
+532 -28

No files matched your search

+36 -2
View File
@@ -17,9 +17,11 @@ from semif_agent.gateway.base import InboundMessage, OutboundMessage
from semif_agent.gateway.bridge import MessagingBridge
def start_bridge(**config):
def start_bridge(address_provider=None, **config):
outbound = queue.Queue()
bridge = MessagingBridge(outbound, config=config)
bridge = MessagingBridge(
outbound, config=config, address_provider=address_provider
)
port = bridge.start()
return bridge, outbound, f"http://127.0.0.1:{port}"
@@ -160,3 +162,35 @@ def test_token_is_required_when_configured():
assert get(f"{base}/inbox", token="sekret") == {"messages": []}
finally:
bridge.stop()
def test_address_uses_provider():
link = {"short_link": "simplex:/abc", "full_link": "https://x", "created": False}
bridge, _, base = start_bridge(address_provider=lambda: link)
try:
assert get(f"{base}/address") == link
finally:
bridge.stop()
def test_address_without_provider_is_unavailable():
bridge, _, base = start_bridge()
try:
with pytest.raises(urllib.error.HTTPError) as exc:
get(f"{base}/address")
assert exc.value.code == 503
finally:
bridge.stop()
def test_address_provider_failure_is_reported():
def boom():
raise RuntimeError("not connected")
bridge, _, base = start_bridge(address_provider=boom)
try:
with pytest.raises(urllib.error.HTTPError) as exc:
get(f"{base}/address")
assert exc.value.code == 502
finally:
bridge.stop()