codegen: move bridge specifics into the catalog

Bridge specifics (service, base-URL config var, auth header/token var,
config-var docs, endpoints with error shapes) now live in BridgeInfo and
render through describe_bridges(), which is injected into body, retry,
regen, elicitation, and testgen prompts. SKILL.md/TESTGEN.md carry only
the generic pattern.

- regen prompt regains the catalog (was a dangling reference)
- elicitation integration hint rides body/retry/regen as an advisory
- top-level simplex_bridge_token config var; bootstrap syncs it
- simplex seeds read the token and send X-Semif-Token when set
This commit is contained in:
Denton Social committed 2026-09-28 23:30:44 -05:00
1 parent d0df6f16c4
commit 98ec4ee5e2
19 files changed
+324 -89

No files matched your search

+2 -1
View File
@@ -1,4 +1,5 @@
{
"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."
"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.",
"simplex_bridge_token": "Shared secret for the bridge, if one is configured; sent as the X-Semif-Token header. Leave blank when the bridge requires no auth."
}
+14 -2
View File
@@ -25,9 +25,14 @@ from semif_agent.skills import ActionResult, Prediction
INTEGRATION = {
"service": "simplex",
"transport": "http",
"config_vars": ["simplex_bridge_url", "simplex_default_contact"],
"config_vars": [
"simplex_bridge_url",
"simplex_default_contact",
"simplex_bridge_token",
],
}
TIMEOUT_SECONDS = 20
@@ -42,8 +47,15 @@ def _base(ctx):
return url
def _headers(ctx):
token = str(ctx.config.get("simplex_bridge_token", "") or "").strip()
return {"X-Semif-Token": token} if token else {}
def _get(ctx, path):
request = urllib.request.Request(_base(ctx) + path)
request = urllib.request.Request(
_base(ctx) + path, headers=_headers(ctx)
)
try:
with urllib.request.urlopen(request, timeout=TIMEOUT_SECONDS) as response:
return json.loads(response.read().decode("utf-8"))
+30 -3
View File
@@ -42,6 +42,7 @@ class FakeEngine:
class BridgeHandler(BaseHTTPRequestHandler):
messages = []
requests = []
tokens = []
def _send(self, payload, status=200):
body = json.dumps(payload).encode("utf-8")
@@ -53,6 +54,7 @@ class BridgeHandler(BaseHTTPRequestHandler):
def do_GET(self):
self.requests.append(self.path)
self.tokens.append(self.headers.get("X-Semif-Token"))
url = urllib.parse.urlparse(self.path)
if url.path == "/inbox":
self._send({"messages": list(self.messages)})
@@ -72,7 +74,11 @@ class BridgeHandler(BaseHTTPRequestHandler):
def start_server(messages):
handler = type("Handler", (BridgeHandler,), {"messages": list(messages), "requests": []})
handler = type(
"Handler",
(BridgeHandler,),
{"messages": list(messages), "requests": [], "tokens": []},
)
server = ThreadingHTTPServer(("127.0.0.1", 0), handler)
threading.Thread(target=server.serve_forever, daemon=True).start()
return server, handler, f"http://127.0.0.1:{server.server_address[1]}"
@@ -88,8 +94,12 @@ def message(identifier, contact, name, text):
}
def config(url, default=""):
return {"simplex_bridge_url": url, "simplex_default_contact": default}
def config(url, default="", token=""):
return {
"simplex_bridge_url": url,
"simplex_default_contact": default,
"simplex_bridge_token": token,
}
def test_multiple_senders_uses_semif_decision():
@@ -192,12 +202,29 @@ def test_unreachable_bridge_fails_honestly():
print(action.action_log)
def test_auth_token_is_sent_when_configured():
server, handler, url = start_server([message("m1", "4", "Alice", "hi")])
try:
engine = FakeEngine()
ctx = ActionContext(engine=engine, config=config(url, token="sekret"))
request = Request("read my next simplex message")
prediction = skill.predict(ctx, request)
action = skill.act(ctx, request, prediction)
assert "hi" in action.action_log, action.action_log
assert set(handler.tokens) == {"sekret"}, handler.tokens
print(action.action_log)
finally:
server.shutdown()
server.server_close()
def main():
test_multiple_senders_uses_semif_decision()
test_default_contact_skips_decision()
test_single_sender_needs_no_decision()
test_empty_inbox_is_reported_honestly()
test_unreachable_bridge_fails_honestly()
test_auth_token_is_sent_when_configured()
print("ok")