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

+5 -2
View File
@@ -14,8 +14,11 @@ Two boundaries matter:
own processes (`python -m semif_agent.cli bridge`) against their own service
daemons/profiles. This isolation is non-negotiable (see AGENTS.md).
- **The catalog is visible to codegen.** `describe_bridges()` is injected into
the code-generation prompts so the model knows which real services it may
build against and how to reach them.
every code-generation prompt (body, retry, regen, elicitation, testgen) and is
the single source of bridge specifics: the model learns which real services it
may build against, each one's base-URL config var, auth header/token var,
config-var docs, and its endpoints with request/response/error shapes. SKILL.md
and TESTGEN.md carry only the generic pattern.
"""
from .base import BridgeInfo, BridgeService
+7
View File
@@ -34,6 +34,13 @@ class BridgeInfo:
endpoints: tuple[str, ...] = ()
#: Other `ctx.config` keys a body built on this bridge may read.
config_vars: tuple[str, ...] = field(default=())
#: One-line semantic description per config var: `(name, description)`.
#: Every entry in `config_vars` must be documented here.
config_var_docs: tuple[tuple[str, str], ...] = ()
#: Optional shared-secret header the bridge enforces when its token is set
#: (e.g. `X-Semif-Token`), and the top-level `ctx.config` var holding it.
auth_header: str = ""
auth_config_var: str = ""
class BridgeService(ABC):
+25 -12
View File
@@ -33,24 +33,37 @@ def known_infos() -> list[BridgeInfo]:
def describe_bridges() -> str:
"""A prompt block describing every available bridge service.
Injected into the skill-body and elicitation prompts so codegen knows which
real services it may build a skill against, how to reach each one, and which
`ctx.config` variable carries its URL. Static — no bridge needs to be
running or enabled.
Injected into the skill-body, retry, regen, elicitation, and testgen
prompts so codegen knows which real services it may build a skill against,
how to reach and authenticate to each one, and which `ctx.config` variables
carry its URL, token, and other values. This is the single source of bridge
specifics — SKILL.md/TESTGEN.md carry only the generic pattern. Static: no
bridge needs to be running or enabled.
"""
lines = [
"Available bridge services (call these over HTTP with urllib.request; "
"never speak a service's native protocol directly):",
"never speak a service's native protocol directly; read every value "
"from ctx.config):",
]
for info in known_infos():
lines.append(f"- {info.name}: {info.description}")
lines.append(f" config var: {info.url_config_var}")
lines.append(f"- {info.name} (service: {info.service}): {info.description}")
lines.append(f" base URL config var: {info.url_config_var}")
if info.auth_header and info.auth_config_var:
lines.append(
f" auth: send the value of {info.auth_config_var} in the "
f"{info.auth_header} header when it is set"
)
docs = dict(info.config_var_docs)
if info.config_vars:
other = [v for v in info.config_vars if v != info.url_config_var]
if other:
lines.append(f" other config vars: {', '.join(other)}")
for endpoint in info.endpoints:
lines.append(f" {endpoint}")
lines.append(" config vars:")
for name in info.config_vars:
description = docs.get(name)
suffix = f" — {description}" if description else ""
lines.append(f" - {name}{suffix}")
if info.endpoints:
lines.append(" endpoints:")
for endpoint in info.endpoints:
lines.append(f" - {endpoint}")
return "\n".join(lines) + "\n"
+43 -10
View File
@@ -32,18 +32,51 @@ class SimplexBridge(BridgeService):
),
url_config_var="simplex_bridge_url",
endpoints=(
"GET /health -> {\"ok\": true} — the bridge is up",
"GET /contacts -> {\"contacts\": [{\"id\", \"display_name\"}]}",
"GET /inbox -> peek buffered inbound messages (does not consume)",
"GET /inbox/next?contact=<id> -> pop the oldest unread message for a "
"contact (or any contact) -> {\"message\": {...}|null}",
"GET /address -> the agent's SimpleX contact link "
"(creates it on first call) -> {\"short_link\", \"full_link\", "
"\"created\"}",
"GET /health -> 200 {\"ok\": true, \"platform\": \"simplex\"} — the "
"bridge is up",
"GET /contacts -> 200 {\"contacts\": [{\"id\", \"display_name\"}]} — "
"contacts learned from inbound messages",
"GET /inbox -> 200 {\"messages\": [{\"id\", \"contact_id\", "
"\"display_name\", \"text\", \"received_at\"}]} — peek buffered "
"inbound messages; does not consume",
"GET /inbox/next?contact=<id> -> 200 {\"message\": {...}|null} — pop "
"the oldest unread message (optionally from one contact); null means "
"none buffered. The bridge owns the read cursor",
"GET /address -> 200 {\"short_link\", \"full_link\", \"created\"} — "
"the agent's contact link; creates it on first call. 503 when the "
"daemon is not connected, 502 when the lookup fails",
"POST /send {\"recipient\": \"<id|display_name>\", \"text\": \"...\"} "
"-> {\"ok\", \"contact_id\"}",
"-> 200 {\"ok\": true, \"contact_id\": \"<id>\"}; 400 {\"error\": "
"\"...\"} on a missing/invalid field or an unknown recipient",
"any request -> 401 {\"error\": \"unauthorized\"} when the token is "
"configured and the auth header is missing or wrong",
),
config_vars=("simplex_bridge_url", "simplex_default_contact"),
config_vars=(
"simplex_bridge_url",
"simplex_default_contact",
"simplex_bridge_token",
),
config_var_docs=(
(
"simplex_bridge_url",
"Base URL of the local SimpleX forwarding bridge "
"(e.g. http://127.0.0.1:5227); never hardcode it in the body.",
),
(
"simplex_default_contact",
"Optional default SimpleX contact (contact id or display name) "
"used when the request does not already make the conversation "
"clear; leave blank to always choose among senders.",
),
(
"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.",
),
),
auth_header="X-Semif-Token",
auth_config_var="simplex_bridge_token",
)
def __init__(self, config: dict | None = None, trace=None, daemon=None):