gateway: serve a local messaging bridge so skills can send/read SimpleX

The gateway now exposes a localhost stdlib HTTP API (bridge.py) that
buffers authorized inbound DMs and forwards outbound sends, so a skill
body never opens a WebSocket to the simplex-chat daemon. Endpoints:
GET /health, /contacts, /inbox (peek), /inbox/next (pop oldest unread),
POST /send (resolve id/display name onto the adapter's outbound queue).
GatewayService gains an observer hook and inbox.dispatch (pull-only mode).

Expose the capability to codegen (SKILL.md, BODY_DIRECTIVES, elicitation,
TESTGEN.md) and add the simplex.next_message seed (SemIf recipient
resolution) with its hermetic loopback test. Config: messaging_bridge_url
plus gateway.simplex.{inbox,bridge}; bootstrap keeps them in sync.
This commit is contained in:
Denton Social committed 2026-09-26 21:39:39 -05:00
1 parent b348f19486
commit 08d6bb23e2
19 files changed
+1006 -29

No files matched your search

+21
View File
@@ -340,3 +340,24 @@ def test_service_answered_question_routes_back(tmp_path):
service.handle_inbound(InboundMessage(text="work", chat_id="4", contact_id="4"))
assert not scheduler.pending_questions()
def test_service_observer_sees_authorized_inbound(tmp_path):
scheduler = build_scheduler(tmp_path)
service = build_service(scheduler)
seen = []
service.observer = seen.append
service.handle_inbound(InboundMessage(text="hi", chat_id="4", contact_id="4"))
assert [m.text for m in seen] == ["hi"]
def test_service_pull_mode_buffers_without_dispatch(tmp_path):
scheduler = build_scheduler(tmp_path)
service = GatewayService(scheduler, FakeAdapter(), config={"inbox": {"dispatch": False}})
seen = []
service.observer = seen.append
service.handle_inbound(InboundMessage(text="hi", chat_id="4", contact_id="4"))
assert [m.text for m in seen] == ["hi"], "pull mode must still buffer for a read skill"
assert drain_outbound(service) == [], "pull mode must not reply or dispatch"
assert scheduler.current is None
assert scheduler.pending is None