Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(auth): project remote session runtime safely
Maxf1b760b0623a
diff --git a/tests/test_instance_authorization.py b/tests/test_instance_authorization.pyindex 1fe92e43b..2349f0c1b 100644--- a/tests/test_instance_authorization.py+++ b/tests/test_instance_authorization.py@@ -232,7 +232,8 @@ def test_remote_http_policy_defaults_local_machine_and_unknown_routes_to_local_o("GET", "/status", REMOTE_HTTP_LOCAL_ONLY),("HEAD", "/status", REMOTE_HTTP_LOCAL_ONLY),("POST", "/api/show-pages/ses-1/ensure", REMOTE_HTTP_ALLOWED),- ("GET", "/api/memory/settings", REMOTE_HTTP_ALLOWED),+ ("GET", "/api/memory/settings", REMOTE_HTTP_LOCAL_ONLY),+ ("GET", "/api/memory/failures", REMOTE_HTTP_LOCAL_ONLY),("HEAD", "/api/memory/log/entry", REMOTE_HTTP_LOCAL_ONLY),("PATCH", "/api/memory/settings", REMOTE_HTTP_LOCAL_ONLY),("POST", "/api/memory/search", REMOTE_HTTP_ALLOWED),diff --git a/tests/test_ui_memory_routes.py b/tests/test_ui_memory_routes.pyindex b01e5dbe9..69dbda2ce 100644--- a/tests/test_ui_memory_routes.py+++ b/tests/test_ui_memory_routes.py@@ -138,8 +138,12 @@ def test_memory_authenticated_avibe_cloud_uses_the_remote_workbench_principal(calls.append(("clear", user_key))return {"status_code": 200, "body": {"status": "completed", "epoch": 2}}+ async def failures(): # pragma: no cover - must stay unreached+ raise AssertionError("remote memory failures reached the local sidecar")+monkeypatch.setattr(internal_client, "memory_profile", profile)monkeypatch.setattr(internal_client, "memory_clear", clear)+ monkeypatch.setattr(internal_client, "memory_failures", failures)client = app.test_client()client.set_cookie(remote_access.SESSION_COOKIE_NAME,@@ -154,6 +158,12 @@ def test_memory_authenticated_avibe_cloud_uses_the_remote_workbench_principal(base_url="https://alex.avibe.bot",environ_base={"REMOTE_ADDR": "203.0.113.10"},)+ failures_response = client.get(+ "/api/memory/failures",+ headers=remote_headers,+ base_url="https://alex.avibe.bot",+ environ_base={"REMOTE_ADDR": "203.0.113.10"},+ )profile_response = client.get("/api/memory/profile",headers=remote_headers,@@ -168,8 +178,10 @@ def test_memory_authenticated_avibe_cloud_uses_the_remote_workbench_principal(environ_base={"REMOTE_ADDR": "203.0.113.10"},)- assert settings_response.status_code == 200- assert "diagnostics" not in settings_response.get_json()+ assert settings_response.status_code == 403+ assert settings_response.get_json()["code"] == "remote_execution_disabled"+ assert failures_response.status_code == 403+ assert failures_response.get_json()["code"] == "remote_execution_disabled"assert profile_response.status_code == 200# The profile read is genuinely scoped to the remote principal, so it keeps# crossing the tunnel under that principal's user key. `clear` only carries@@ -267,9 +279,9 @@ def test_memory_avibe_cloud_read_still_requires_same_origin(monkeypatch, tmp_pat)assert missing_origin.status_code == 403- assert missing_origin.get_json() == {"status": "failed", "error": "memory_disabled"}+ assert missing_origin.get_json()["code"] == "remote_execution_disabled"assert cross_origin.status_code == 403- assert cross_origin.get_json() == {"status": "failed", "error": "memory_disabled"}+ assert cross_origin.get_json()["code"] == "remote_execution_disabled"def test_memory_status_proxies_controller_over_uds(monkeypatch, tmp_path) -> None:diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.pyindex d431e5e5e..8d1c57e5f 100644--- a/tests/test_ui_remote_access_auth.py+++ b/tests/test_ui_remote_access_auth.py@@ -1419,6 +1419,54 @@ def test_remote_session_and_project_metadata_predicates_remain_allowed():)+def test_remote_turn_state_filters_harness_activity_labels(monkeypatch, tmp_path):+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ config = _save_config(tmp_path)+ client = app.test_client()+ client.set_cookie(+ remote_access.SESSION_COOKIE_NAME,+ remote_session_cookie(config, "[email protected]", "user-owner"),+ domain="alex.avibe.bot",+ )++ async def projected(_session_id):+ return {+ "status_code": 200,+ "body": {+ "in_flight": False,+ "foreground": "idle",+ "background_activities": [+ {+ "id": "backend-1",+ "item_kind": "backend_activity",+ "label": "Waiting for turn",+ "status": "running",+ },+ {+ "id": "task-1",+ "item_kind": "task",+ "label": "private prompt head",+ "status": "scheduled",+ },+ ],+ "pending_activity_output_count": 1,+ "connection": "connected",+ },+ }++ monkeypatch.setattr("vibe.internal_client.turn_state", projected)+ response = client.get(+ "/api/sessions/ses-local/turn-state",+ base_url="https://alex.avibe.bot",+ environ_base=_remote_peer(),+ )++ assert response.status_code == 200+ body = response.get_json()+ assert [item["id"] for item in body["background_activities"]] == ["backend-1"]+ assert body["background_activities"][0]["label"] == "Waiting for turn"++@pytest.mark.parametrize(("method", "path", "payload"),[diff --git a/tests/test_ui_session_stream.py b/tests/test_ui_session_stream.pyindex 27b891af7..f006ae748 100644--- a/tests/test_ui_session_stream.py+++ b/tests/test_ui_session_stream.py@@ -30,7 +30,8 @@ from storage import message_deliveries, messages_servicefrom storage.models import agent_sessions, messagesfrom storage.models import scope_settingsfrom storage.settings_service import upsert_scope-from tests.ui_server_test_helpers import csrf_headers+from tests.ui_server_test_helpers import csrf_headers, remote_session_cookie+from vibe import remote_access@pytest.fixture()@@ -1132,6 +1133,8 @@ def test_chat_bootstrap_returns_first_screen_payload(isolated_state, tmp_path):"runtime_key": "runtime-1","kind": "background_task","status": "running",+ "item_kind": "backend_activity",+ "label": "Waiting for turn",}],"pending_activity_output_count": 0,@@ -1166,9 +1169,132 @@ def test_chat_bootstrap_returns_first_screen_payload(isolated_state, tmp_path):assert body["turn_state"]["foreground"] == "running"assert body["turn_state"]["pending_input_count"] == 1assert body["turn_state"]["background_activities"][0]["id"] == "task-1"+ assert body["turn_state"]["background_activities"][0]["label"] == "Waiting for turn"assert body["turn_state"]["connection"] == "connected"+def test_chat_bootstrap_filters_non_backend_activities_for_remote_context(isolated_state, tmp_path):+ from vibe.ui_server import app++ monkeypatch = pytest.MonkeyPatch()+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ from tests.test_ui_memory_routes import _save_remote_config++ config = _save_remote_config(tmp_path)+ _, session_id = _make_session(tmp_path)+ client = app.test_client()+ client.set_cookie(+ remote_access.SESSION_COOKIE_NAME,+ remote_session_cookie(config, "[email protected]", "user-owner"),+ domain="alex.avibe.bot",+ )++ async def projected(_session_id):+ return {+ "status_code": 200,+ "body": {+ "in_flight": False,+ "foreground": "idle",+ "pending_input_count": 0,+ "background_activities": [+ {+ "id": "backend-1",+ "item_kind": "backend_activity",+ "label": "Waiting for approval",+ "status": "running",+ },+ {+ "id": "task-1",+ "item_kind": "task",+ "label": "private prompt head",+ "status": "scheduled",+ },+ ],+ "pending_activity_output_count": 1,+ "connection": "reconnecting",+ },+ }++ with (+ patch("vibe.internal_client.turn_state", projected),+ patch(+ "vibe.api.get_vibe_agents",+ return_value={+ "agents": [{"name": "worker", "backend": "claude", "enabled": True}],+ "default_agent_name": "worker",+ },+ ),+ ):+ response = client.get(+ f"/api/sessions/{session_id}/bootstrap",+ base_url="https://alex.avibe.bot",+ environ_base={"REMOTE_ADDR": "203.0.113.10"},+ )+ monkeypatch.undo()++ assert response.status_code == 200+ body = response.get_json()+ assert [item["id"] for item in body["turn_state"]["background_activities"]] == ["backend-1"]+ assert body["turn_state"]["background_activities"][0]["label"] == "Waiting for approval"+++def test_turn_state_route_filters_non_backend_activities_for_remote_context(isolated_state, tmp_path):+ from vibe.ui_server import app++ monkeypatch = pytest.MonkeyPatch()+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ from tests.test_ui_memory_routes import _save_remote_config++ config = _save_remote_config(tmp_path)+ _, session_id = _make_session(tmp_path)+ client = app.test_client()+ client.set_cookie(+ remote_access.SESSION_COOKIE_NAME,+ remote_session_cookie(config, "[email protected]", "user-owner"),+ domain="alex.avibe.bot",+ )++ async def projected(session_id_inner):+ assert session_id_inner == session_id+ return {+ "status_code": 200,+ "body": {+ "in_flight": False,+ "foreground": "idle",+ "pending_input_count": 0,+ "background_activities": [+ {+ "id": "backend-1",+ "item_kind": "backend_activity",+ "label": "Waiting for approval",+ "status": "running",+ },+ {+ "id": "watch-1",+ "item_kind": "watch",+ "label": "private waiter prompt",+ "status": "enabled",+ },+ ],+ "pending_activity_output_count": 1,+ "connection": "reconnecting",+ },+ }++ with patch("vibe.internal_client.turn_state", projected):+ response = client.get(+ f"/api/sessions/{session_id}/turn-state",+ base_url="https://alex.avibe.bot",+ environ_base={"REMOTE_ADDR": "203.0.113.10"},+ )+ monkeypatch.undo()++ assert response.status_code == 200+ body = response.get_json()+ assert [item["id"] for item in body["background_activities"]] == ["backend-1"]+ assert body["background_activities"][0]["label"] == "Waiting for approval"++def test_queue_row_send_now_passes_the_exact_delivery_id(isolated_state, tmp_path):from vibe.ui_server import app@@ -1427,6 +1553,7 @@ def test_turn_state_route_preserves_orthogonal_runtime_axes(isolated_state, tmp_"runtime_key": "runtime-1","kind": "background_task","status": "running",+ "item_kind": "backend_activity",}],"pending_activity_output_count": 1,diff --git a/ui/src/lib/adminNavigation.test.ts b/ui/src/lib/adminNavigation.test.tsindex 14c97d212..edbb59b61 100644--- a/ui/src/lib/adminNavigation.test.ts+++ b/ui/src/lib/adminNavigation.test.ts@@ -39,6 +39,7 @@ describe('isLocalSystemPath', () => {expect(isLocalSystemPath('/admin/settings/service')).toBe(true);expect(isLocalSystemPath('/admin/settings/platforms')).toBe(true);expect(isLocalSystemPath('/admin/settings/backends')).toBe(true);+ expect(isLocalSystemPath('/admin/settings/models')).toBe(true);expect(isLocalSystemPath('/harness')).toBe(true);expect(isLocalSystemPath('/apps/library')).toBe(true);});@@ -50,7 +51,6 @@ describe('isLocalSystemPath', () => {it('leaves remotely usable destinations open', () => {expect(isLocalSystemPath('/admin/settings/messaging')).toBe(false);- expect(isLocalSystemPath('/admin/settings/models')).toBe(false);expect(isLocalSystemPath('/admin/organization/overview')).toBe(false);expect(isLocalSystemPath('/')).toBe(false);});diff --git a/ui/src/lib/adminNavigation.ts b/ui/src/lib/adminNavigation.tsindex c9e0bd3be..b216ca0d7 100644--- a/ui/src/lib/adminNavigation.ts+++ b/ui/src/lib/adminNavigation.ts@@ -10,12 +10,12 @@ export const isMemorySettingsPath = (pathname: string): boolean =>* the owner check alone still renders them: the Dashboard immediately requests* `/api/doctor`, `/api/logs`, `/api/settings`, `/api/users` and drives* `/api/control`; Remote Access drives pair / start / stop / optimize / settings- * / diagnose (only its status read is remote-permitted); the service, platform- * and backend settings pages save protected config fields; Harness opens on- * `/api/harness/bootstrap`; and the Library's Show Page controls are local-only.- * They therefore need the trusted-local `can_use_system` capability on top,- * otherwise a remote owner gets partial or empty state and every mutation ends- * in `remote_execution_disabled`.+ * / diagnose (only its status read is remote-permitted); the service, platform,+ * backend, and Model Hub settings pages save or reorder protected local state;+ * Harness opens on `/api/harness/bootstrap`; and the Library's Show Page+ * controls are local-only. They therefore need the trusted-local+ * `can_use_system` capability on top, otherwise a remote owner gets partial or+ * empty state and every mutation ends in `remote_execution_disabled`.** This is the single source of truth for both halves of the gate — the route* redirect and the navigation entries that point at it — so a withheld page can@@ -29,6 +29,7 @@ const LOCAL_SYSTEM_ROUTES = ['/admin/settings/service','/admin/settings/platforms','/admin/settings/backends',+ '/admin/settings/models','/harness','/apps/library',];diff --git a/vibe/authorization.py b/vibe/authorization.pyindex c5df856df..28c5e8a4e 100644--- a/vibe/authorization.py+++ b/vibe/authorization.py@@ -467,15 +467,14 @@ _REMOTE_OWNER_ALLOWED_HTTP_RULES = tuple(r"^/api/harness/counts$",),# Memory reads that describe this principal's own view stay remote, and- # search is scoped to the caller. The admin log is not: its readers- # enumerate and hydrate memcells for every principal, so it stays local.- # Memory administration is absent for the same reason: a settings PATCH- # repoints the shared provider endpoints, and `runtime/restart` /- # `clear` act on the whole local sidecar rather than one principal.- (- frozenset({"GET", "HEAD"}),- r"^/api/memory/(?:settings|status|failures|profile)$",- ),+ # search is scoped to the caller. Shared provider settings and the+ # process-global failure log do not: both expose data across principals,+ # so they stay trusted-local with the admin log and other sidecar-wide+ # operations. Memory administration is absent for the same reason: a+ # settings PATCH repoints the shared provider endpoints, and+ # `runtime/restart` / `clear` act on the whole local sidecar rather than+ # one principal.+ (frozenset({"GET", "HEAD"}), r"^/api/memory/(?:status|profile)$"),(frozenset({"POST"}), r"^/api/memory/search$"),))diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex a8daefd76..ceea0fa04 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -8248,6 +8248,7 @@ def _session_runtime_projection(*,pending_input_count: int | None = None,controller_available: bool | None = True,+ authorization_context=None,) -> dict[str, Any]:"""Normalize the controller's orthogonal Session runtime axes for the UI."""@@ -8283,6 +8284,12 @@ def _session_runtime_projection(if isinstance(raw_activities, list)else [])+ if getattr(authorization_context, "is_remote", False):+ activities = [+ item+ for item in activities+ if str(item.get("item_kind") or "") == "backend_activity"+ ]projection: dict[str, Any] = {# Retained as a read-only compatibility alias for older clients."in_flight": None if foreground == "unknown" else foreground == "running",@@ -8383,18 +8390,21 @@ async def sessions_bootstrap(session_id: str):turn_state = _session_runtime_projection(turn_body,pending_input_count=len(visible_queued),+ authorization_context=authorization_context,)except internal_client.InternalServerUnavailable:turn_state = _session_runtime_projection(None,pending_input_count=len(visible_queued),controller_available=False,+ authorization_context=authorization_context,)except internal_client.InternalServerTimeout:turn_state = _session_runtime_projection(None,pending_input_count=len(visible_queued),controller_available=None,+ authorization_context=authorization_context,)return jsonify(@@ -10543,6 +10553,7 @@ async def sessions_turn_state(session_id: str):_session_runtime_projection(None,controller_available=False,+ authorization_context=getattr(g, "authorization_context", None),))except internal_client.InternalServerTimeout:@@ -10558,7 +10569,10 @@ async def sessions_turn_state(session_id: str):504,)body = result.get("body") or {}- projection = _session_runtime_projection(body)+ projection = _session_runtime_projection(+ body,+ authorization_context=getattr(g, "authorization_context", None),+ )projection["recovered_agent_status"] = bool(body.get("recovered_agent_status", False))