HarnessRouter Community Edition: the self-hosted, Apache-2.0 edition of the unified interface for agent harnesses. Run Codex, Claude Code, Hermes, PI, DSH, and more through one API, with sessions, streaming, files, cancellation, and failure handling. Implements the Unified Harness Protocol (UHP), an open standard. Your keys, your infrastructure.
Python agent-apiagent-frameworkagent-harnessai-agentsai-infrastructurecoding-agentconformance-testingdeepseek-harnessharness-engineeringhermesllmopen-protocolopen-sourceopen-standardpi-coding-agentself-hosteduhpunified-apiunified-harness-protocolunified-interface
fix(selfhost): share links work — the resolver no longer needs a hosted graph, and the login gate lets them through
richard-epsilla8627b43d9415
diff --git a/gateway/app.py b/gateway/app.pyindex 509f127d..7a5018cd 100644--- a/gateway/app.py+++ b/gateway/app.py@@ -6223,8 +6223,11 @@ async def get_session_share(sid: str, request: Request) -> dict:async def _share_sid(token: str) -> str | None:"""Resolve a share token to its session id — only while sharing is enabled."""tok = re.sub(r"[^A-Za-z0-9]", "", token or "")- if not tok or not VG_GATEWAY_URL:+ if not tok:return None+ # No VG_GATEWAY_URL guard: the lookup below goes through BACKING.graph, which is the SQLite+ # store self-hosted. The guard predated that store and made every share link on a self-hosted+ # box resolve to "not found" while the console happily minted them.hit = _SHARE_TOKEN_CACHE.get(tok)if hit and time.time() - hit[0] < _SHARE_TTL:return hit[1] or Nonediff --git a/gateway/tests/test_share_selfhost.py b/gateway/tests/test_share_selfhost.pynew file mode 100644index 00000000..f324b361--- /dev/null+++ b/gateway/tests/test_share_selfhost.py@@ -0,0 +1,60 @@+"""Share links on a self-hosted box: no hosted graph URL, the SQLite backing, and a link that has+to resolve for someone who has no account. The resolver used to bail out the moment+VG_GATEWAY_URL was empty, so every self-hosted share answered "share not found" while the console+happily minted the links."""+import asyncio+import os+import sys+from pathlib import Path++import pytest+from fastapi.testclient import TestClient++sys.path.insert(0, str(Path(__file__).resolve().parents[1]))+os.environ.setdefault("HR_BACKING", "local")+import app as gw # noqa: E402++ORG = "local"+++def api(monkeypatch):+ monkeypatch.setattr(gw, "VG_GATEWAY_URL", "") # self-hosted: there is no hosted graph++ async def principal(request):+ return {"org": ORG, "member": "me@local"}+ monkeypatch.setattr(gw, "_principal", principal)+ gw._SHARE_TOKEN_CACHE.clear()+ gw._SHARE_STATE_CACHE.clear()+ return TestClient(gw.app)+++def _session(sid: str, **extra) -> None:+ asyncio.run(gw._vertex_upsert(sid, {"tenant": ORG, "status": "done", "member_id": "me@local", **extra}))+++def test_a_share_link_resolves_without_a_hosted_graph(api):+ sid = "hsessshare" + os.urandom(4).hex()+ _session(sid)+ r = api.post(f"/v1/sessions/{sid}/share", json={"enabled": True})+ assert r.status_code == 200 and r.json()["enabled"] is True+ token = r.json()["token"]+ assert token.startswith("shr")+ assert asyncio.run(gw._share_sid(token)) == sid+ # The public route, as the recipient hits it: no principal, no cookie, just the link.+ assert api.get(f"/share/{token}/meta").status_code == 200+++def test_switching_sharing_off_revokes_the_link(api):+ sid = "hsessshare" + os.urandom(4).hex()+ _session(sid)+ token = api.post(f"/v1/sessions/{sid}/share", json={"enabled": True}).json()["token"]+ assert api.get(f"/share/{token}/meta").status_code == 200+ assert api.post(f"/v1/sessions/{sid}/share", json={"enabled": False}).status_code == 200+ assert asyncio.run(gw._share_sid(token)) is None+ assert api.get(f"/share/{token}/meta").status_code == 404+++def test_an_unknown_token_is_not_found(api):+ assert asyncio.run(gw._share_sid("shr" + "0" * 32)) is None+ assert api.get("/share/shr" + "0" * 32 + "/meta").status_code == 404diff --git a/ui/src/middleware.ts b/ui/src/middleware.tsindex d7883d53..fe760da7 100644--- a/ui/src/middleware.ts+++ b/ui/src/middleware.ts@@ -49,6 +49,11 @@ function isPublic(path: string): boolean {// this is a UHP server before deciding what credential to present. The document is version// metadata — no user data.|| path === '/api/harness/v1/uhp'+ // A shared task is FOR people without an account: the link is the credential. The page and+ // the data it fetches are public; what they reveal is decided by the gateway, which answers+ // only for a token whose owner has sharing switched on, and with nothing but that session.+ || path.startsWith('/share/')+ || path.startsWith('/api/share/')|| path.startsWith('/_next/')// An /api path is never a static asset, whatever it ends with. Neither is /data — those are// files a TASK produced, and agents write .png, .svg, .css and .js routinely. Matching those