Files
semif-agent/semif_agent/bridges/__init__.py
T
gabby d9cc7e4fed bridges: add a Nextcloud bridge (files, calendars, tasks, contacts, notes)
A standalone bridge wrapping the account's native protocols — WebDAV files,
CalDAV events and tasks, CardDAV contacts, and the OCS Notes API — behind one
token-guarded localhost JSON surface, so a codegen-authored body never speaks
DAV/OCS directly.

- nextcloud_client.py: stdlib-only client (urllib + xml.etree + ssl + base64)
  with Basic auth, DAV/OCS request bodies, and minimal iCalendar/vCard build +
  parse; every failure is a NextcloudError carrying the HTTP status.
- nextcloud.py: NextcloudBridge with no service daemon (check_requirements is
  always (True, None)), ~35 routes (GET reads, POST mutations). Event/task
  updates edit the stored iCalendar in place (preserving VALARM/ATTENDEE) behind
  If-Match; creates use If-None-Match. Missing connection is 503; a real
  Nextcloud failure is 502, never a fabricated success.
- registry: CATALOG entry + build_bridge passes the top-level nextcloud_* values
  as a fallback so the account the calendar seeds collect is configured once.
- config.example.json: bridges.nextcloud block + nextcloud_bridge_url/token.
- docs: README, AGENTS, bridges/__init__, bootstrap closing notes.

Tests drive the real client over a loopback http.server faking Nextcloud's
DAV/OCS shapes. One codegen test's context window was raised because the bridge
catalog injected into every prompt grew the baseline prompt.
2026-10-07 12:17:39 +00:00

43 lines
1.6 KiB
Python

"""Third-party API bridges: a secure local layer between skills and services.
A **bridge service** is a standalone process that exposes one third-party system
(SimpleX, the local language model, Nextcloud) to codegen-authored skill bodies
over a local, token-guarded HTTP API. It exists so a generated body never speaks
a system's native protocol (WebSocket, SMTP, CalDAV, an OpenAI-compatible chat
API, a CLI's private flags) directly: it calls a small, documented, uniform HTTP
surface instead, and the bridge owns the messy integration details and
credentials.
Two boundaries matter:
- **Bridges are not the gateway.** The command gateway only takes commands and
replies; it must never grow read/send/invite endpoints. Bridges run as their
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
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. CODEGEN.md
and TESTGEN.md carry only the generic pattern.
"""
from .base import BridgeInfo, BridgeService
from .inbox import MessagingInbox
from .registry import (
build_bridge,
describe_bridges,
known_infos,
run_bridges,
)
__all__ = [
"BridgeInfo",
"BridgeService",
"MessagingInbox",
"build_bridge",
"describe_bridges",
"known_infos",
"run_bridges",
]