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:
1 parent
b348f19486
commit
08d6bb23e2
19 files changed
+1006
-29
No files matched your search
@@ -59,6 +59,13 @@ class GatewayService:
|
||||
self.home_channel = str(cfg.get("home_channel", "") or "")
|
||||
self.reply_prefix = str(cfg.get("reply_prefix", "") or "")
|
||||
self.poll_interval = float(poll_interval)
|
||||
inbox_cfg = cfg.get("inbox", {}) or {}
|
||||
#: When false the gateway only buffers inbound messages (for a read
|
||||
#: skill to pull) instead of dispatching them as scheduler requests.
|
||||
self.inbox_dispatch = bool(inbox_cfg.get("dispatch", True))
|
||||
#: Optional callback invoked for every authorized inbound message,
|
||||
#: before routing. The bridge uses it to fill its inbox.
|
||||
self.observer = None
|
||||
self.outbound: "queue.Queue[OutboundMessage | None]" = queue.Queue()
|
||||
self._owners: dict[str, str] = {}
|
||||
self._parents: dict[str, str] = {}
|
||||
@@ -106,6 +113,13 @@ class GatewayService:
|
||||
def handle_inbound(self, msg: InboundMessage) -> None:
|
||||
"""Handle one authorized inbound message. Called by the adapter."""
|
||||
with self._route_lock:
|
||||
if self.observer is not None:
|
||||
self.observer(msg)
|
||||
if not self.inbox_dispatch:
|
||||
# Pull mode: buffer only (the observer recorded it); a read
|
||||
# skill will consume it later. No scheduler request, no reply.
|
||||
self.drain()
|
||||
return
|
||||
reply_to = msg.chat_id
|
||||
pending = self.scheduler.pending
|
||||
if pending is not None and self._pending_owner is None:
|
||||
|
||||
Reference in new issue
Block a user