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.
This commit is contained in:
1 parent
e64354e78d
commit
d9cc7e4fed
10 files changed
+2819
-14
No files matched your search
@@ -14,10 +14,11 @@ import threading
|
||||
|
||||
from .base import BridgeInfo, BridgeService
|
||||
from .llm import LLMBridge
|
||||
from .nextcloud import NextcloudBridge
|
||||
from .simplex import SimplexBridge
|
||||
|
||||
#: Known bridge services. Order is presentation order.
|
||||
CATALOG: tuple[type[BridgeService], ...] = (SimplexBridge, LLMBridge)
|
||||
CATALOG: tuple[type[BridgeService], ...] = (SimplexBridge, LLMBridge, NextcloudBridge)
|
||||
|
||||
|
||||
def _class_for(name: str) -> type[BridgeService] | None:
|
||||
@@ -75,7 +76,9 @@ def build_bridge(
|
||||
|
||||
`llm` is the scheduler's configured language-model client, handed to the LLM
|
||||
bridge so it reuses the top-level `llm` endpoint/model instead of duplicating
|
||||
that config. Other bridges ignore it.
|
||||
that config. The Nextcloud bridge gets the top-level `nextcloud_*` values as a
|
||||
fallback, so the same account the calendar seeds use is configured once. Other
|
||||
bridges ignore both.
|
||||
"""
|
||||
bridge_class = _class_for(name)
|
||||
if bridge_class is None:
|
||||
@@ -83,6 +86,18 @@ def build_bridge(
|
||||
block = (config.get("bridges", {}) or {}).get(name, {}) or {}
|
||||
if bridge_class is LLMBridge:
|
||||
return LLMBridge(block, trace=trace, client=llm)
|
||||
if bridge_class is NextcloudBridge:
|
||||
return NextcloudBridge(
|
||||
block,
|
||||
trace=trace,
|
||||
fallback={
|
||||
"url": config.get("nextcloud_url"),
|
||||
"username": config.get("nextcloud_username"),
|
||||
"app_password": config.get("nextcloud_app_password"),
|
||||
"default_calendar": config.get("nextcloud_default_calendar"),
|
||||
"default_addressbook": config.get("nextcloud_default_addressbook"),
|
||||
},
|
||||
)
|
||||
return bridge_class(block, trace=trace)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user