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(remote): protect local-state boundaries
Maxf8015ae55cfc
diff --git a/docs/plans/2026-08-04-org-master-conservative-harness-gate.md b/docs/plans/2026-08-04-org-master-conservative-harness-gate.mdindex 70a186b12..db17f774e 100644--- a/docs/plans/2026-08-04-org-master-conservative-harness-gate.md+++ b/docs/plans/2026-08-04-org-master-conservative-harness-gate.md@@ -29,6 +29,10 @@ entitlement mirror before remote recurring execution can be enabled.are a separate sharing surface, not remote Workbench authorization.- Make every remote Workbench capability read-only with respect to local Agent,terminal, file, and Harness execution.+- The sole remote Cloud service exception is subject-bound Cloud ASR for a+ current remote editor or owner. It mints only a short-lived `asr` token for+ direct browser-to-Cloud audio transfer; it never authorizes a local Agent turn+ or the local ASR relay. Viewers and stale authorization claims are denied.- Reject remote Task and Watch creation or update at the definition serviceboundary when an explicit remote `AuthorizationContext` is present.- Suspend previously persisted remote-origin Tasks and Watches before any Agent,@@ -67,7 +71,10 @@ entitlement mirror before remote recurring execution can be enabled.protected fields are stripped before persistence so a concurrent local updatecannot be overwritten by a stale remote round-trip. ExplicitSession/Project display fields and explicit UI/config preferences remain- available.+ available. The same remote projection is used after a config save, and all+ remote Project reads redact local paths and arbitrary metadata regardless of+ Instance role. Live Agent process snapshots and graph diagnostics remain+ trusted-local rather than receiving a partial remote projection.3. The durable Delivery owner retires remote-origin queue entries before theFIFO claim that starts an Agent turn.4. Task and Watch stores reject explicit remote definition writes.@@ -102,6 +109,10 @@ substitute for either dependency.local runtime or filesystem services.- Remote logs, Doctor reads/runs, UI reloads, and legacy OpenCode helpers failbefore any file read, diagnostic, process spawn, service exit, or config write.+- Remote Cloud ASR tokens mint only for current editors/owners and only with the+ `asr` scope; viewers, stale sessions, and other scopes never reach the broker.+- Remote config saves and every Project read surface omit local configuration,+ filesystem paths, arbitrary metadata, and local runtime diagnostics.- An unknown owner-only API route is trusted-local by default; remote exposurerequires an exact method/path policy entry and regression evidence. A new pathunder an already approved namespace does not inherit remote access.diff --git a/storage/projects_service.py b/storage/projects_service.pyindex 5b2f64b2c..3411b6942 100644--- a/storage/projects_service.py+++ b/storage/projects_service.py@@ -210,9 +210,9 @@ def _project_for_context(str(project.get("id") or ""),)}- if not context.is_instance_owner:- # Remote collaborators need Project identity and routing defaults, but- # never the host's absolute workdir or arbitrary local metadata.+ if context.is_remote:+ # A remote Instance owner is still not trusted to inspect the host's+ # absolute workdir or arbitrary local metadata.payload["folder_path"] = ""payload["metadata"] = {}return payloaddiff --git a/tests/test_instance_authorization.py b/tests/test_instance_authorization.pyindex e87282549..0efa7f1ee 100644--- a/tests/test_instance_authorization.py+++ b/tests/test_instance_authorization.py@@ -26,10 +26,13 @@ def test_remote_roles_keep_management_monotonic_but_execution_disabled() -> Noneassert viewer.can_read_instance is Trueassert viewer.can_chat is False+ assert viewer.can_use_cloud_asr is Falseassert editor.can_read_instance is Trueassert editor.can_chat is False+ assert editor.can_use_cloud_asr is Trueassert editor.can_manage_projects is Falseassert owner.can_chat is False+ assert owner.can_use_cloud_asr is Trueassert owner.can_manage_projects is Trueassert owner.can_manage_agents is Trueassert owner.can_use_terminal is False@@ -37,6 +40,7 @@ def test_remote_roles_keep_management_monotonic_but_execution_disabled() -> Noneassert owner.can_use_system is Falseassert trusted_local_context().can_manage_instance is Trueassert trusted_local_context().can_chat is True+ assert trusted_local_context().can_use_cloud_asr is False@pytest.mark.parametrize(diff --git a/tests/test_remote_access_vibe_cloud.py b/tests/test_remote_access_vibe_cloud.pyindex 66b214757..b3557c34a 100644--- a/tests/test_remote_access_vibe_cloud.py+++ b/tests/test_remote_access_vibe_cloud.py@@ -2414,12 +2414,40 @@ def test_mint_cloud_token_returns_none_on_backend_error(monkeypatch) -> None:assert remote_access.mint_cloud_token(config, sub="u", email="[email protected]") is None-def test_cloud_token_for_request_does_not_mint_when_remote_chat_is_disabled([email protected]("role", ("editor", "owner"))+def test_cloud_token_for_request_mints_for_authorized_remote_asr(monkeypatch,+ role,) -> None:config = _cloud_broker_config()monkeypatch.setattr(remote_access, "current_authorization_revision", lambda *a, **k: 1)- cookie = _session_cookie(config)+ cookie = _session_cookie(config, role=role)+ captured: dict = {}++ def fake_json_request(*args, **kwargs):+ captured["payload"] = args[1]+ return {"access_token": "ct_xyz", "expires_in": 43200}++ monkeypatch.setattr(remote_access, "_json_request", fake_json_request)++ token = remote_access.cloud_token_for_request(config, cookie)++ assert token is not None+ assert token["base_url"] == "https://avibe.bot"+ assert token["token"] == "ct_xyz"+ assert token["scope"] == "asr"+ assert token["expires_at"] > int(time.time())+ assert captured["payload"] == {+ "sub": "user-1",+ "email": "[email protected]",+ "scope": "asr",+ }+++def test_cloud_token_for_request_rejects_non_asr_scope(monkeypatch) -> None:+ config = _cloud_broker_config()+ monkeypatch.setattr(remote_access, "current_authorization_revision", lambda *a, **k: 1)+ cookie = _session_cookie(config, role="owner")called = Falsedef fake_json_request(*args, **kwargs):@@ -2429,7 +2457,7 @@ def test_cloud_token_for_request_does_not_mint_when_remote_chat_is_disabled(monkeypatch.setattr(remote_access, "_json_request", fake_json_request)- assert remote_access.cloud_token_for_request(config, cookie) is None+ assert remote_access.cloud_token_for_request(config, cookie, scope="future") is Noneassert called is False@@ -2480,6 +2508,8 @@ def test_cloud_token_for_request_requires_editor_role(monkeypatch) -> None:assert remote_access.cloud_token_for_request(config, cookie) is Noneassert called is False++def test_ra_tq_029_connector_environment_applies_ip_and_interface_controls() -> None:config = _config()cloud = config.remote_access.vibe_clouddiff --git a/tests/test_ui_project_access.py b/tests/test_ui_project_access.pyindex dc2c61640..686c8c96c 100644--- a/tests/test_ui_project_access.py+++ b/tests/test_ui_project_access.py@@ -371,12 +371,11 @@ def test_archived_project_invalidates_retained_remote_urls(monkeypatch, tmp_path"publish",lambda event_type, data: published.append((event_type, data)),)- owner = _remote_client(config, role="owner", email="[email protected]")- archive = owner.delete(+ local = app.test_client()+ archive = local.delete(f"/api/projects/{ids['project_a']}",- base_url=REMOTE_ORIGIN,- environ_base=REMOTE_PEER,- headers=csrf_headers(owner, REMOTE_ORIGIN),+ base_url="http://localhost",+ headers=csrf_headers(local, "http://localhost"),)assert archive.status_code == 200assert (@@ -518,6 +517,14 @@ def test_remote_message_is_blocked_before_persistence_or_dispatch(def test_viewer_no_match_owner_and_local_matrix(monkeypatch, tmp_path) -> None:monkeypatch.setenv("AVIBE_HOME", str(tmp_path))config, ids = _setup_state(tmp_path)+ engine = create_sqlite_engine()+ with engine.begin() as conn:+ conn.execute(+ scopes.update()+ .where(scopes.c.native_id == ids["project_a"])+ .values(metadata_json=json.dumps({"host_path_hint": "/private/host"}))+ )+ engine.dispose()viewer = _remote_client(config, role="viewer", email="[email protected]")assert _get(viewer, f"/api/sessions/{ids['session_a']}").status_code == 200@@ -579,15 +586,28 @@ def test_viewer_no_match_owner_and_local_matrix(monkeypatch, tmp_path) -> None:assert _get(organization_member, f"/api/media/{ids['media_a']}").status_code == 404owner = _remote_client(config, role="owner", email="[email protected]")- assert {row["id"] for row in _get(owner, "/api/projects").get_json()["projects"]} == {+ owner_projects = _get(owner, "/api/projects").get_json()["projects"]+ assert {row["id"] for row in owner_projects} == {ids["project_a"],ids["project_b"],}+ assert all(row["folder_path"] == "" and row["metadata"] == {} for row in owner_projects)+ owner_project = _get(owner, f"/api/projects/{ids['project_a']}").get_json()+ assert owner_project["folder_path"] == ""+ assert owner_project["metadata"] == {}+ owner_bootstrap = _get(owner, "/api/workbench/projects-bootstrap").get_json()+ assert all(+ row["folder_path"] == "" and row["metadata"] == {}+ for row in owner_bootstrap["projects"]+ )assert _get(owner, f"/api/sessions/{ids['unscoped']}").status_code == 200local = app.test_client()local_projects = local.get("/api/projects", base_url="http://localhost").get_json()["projects"]assert {row["id"] for row in local_projects} == {ids["project_a"], ids["project_b"]}+ local_project_a = next(row for row in local_projects if row["id"] == ids["project_a"])+ assert local_project_a["folder_path"] == str((tmp_path / "project-a").resolve())+ assert local_project_a["metadata"] == {"host_path_hint": "/private/host"}assert local.get(f"/api/sessions/{ids['unscoped']}", base_url="http://localhost").status_code == 200diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.pyindex bbcde1a49..c4cbef2d8 100644--- a/tests/test_ui_remote_access_auth.py+++ b/tests/test_ui_remote_access_auth.py@@ -805,6 +805,39 @@ def test_remote_config_uses_the_safe_projection_for_an_instance_owner(monkeypatcassert "memory" not in payload+def test_remote_config_post_uses_the_safe_projection_for_an_instance_owner(monkeypatch, tmp_path):+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ config = _save_config(tmp_path)+ config.runtime.default_cwd = "/private/local-agent-workdir"+ config.agents.codex.cli_path = "/opt/avibe/bin/codex"+ config.save()+ client = app.test_client()+ client.set_cookie(+ remote_access.SESSION_COOKIE_NAME,+ remote_session_cookie(config, "[email protected]", "user-owner", role="owner"),+ domain="alex.avibe.bot",+ )++ response = client.post(+ "/api/config",+ json={"ui": {"instance_name": "Remote Workbench"}},+ headers=csrf_headers(client, "https://alex.avibe.bot"),+ base_url="https://alex.avibe.bot",+ environ_base=_remote_peer(),+ )++ assert response.status_code == 200+ payload = response.get_json()+ assert payload["ui"]["instance_name"] == "Remote Workbench"+ assert set(payload) == {"language", "mode", "setup_state", "ui", "version"}+ assert "runtime" not in payload+ assert "agents" not in payload+ assert "memory" not in payload+ assert "remote_access_runtime" not in payload+ assert "platform_runtime" not in payload+ assert "agent_backend_runtime" not in payload++def test_remote_session_info_includes_authenticated_subject(monkeypatch, tmp_path):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))config = _save_config(tmp_path)@@ -958,6 +991,31 @@ def test_remote_agent_termination_is_blocked_before_controller_access(assert response.get_json()["code"] == "remote_execution_disabled"[email protected]("path", ("/api/running-agents", "/api/agents-graph"))+def test_remote_runtime_snapshots_are_blocked_before_controller_access(monkeypatch, tmp_path, 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", role="owner"),+ domain="alex.avibe.bot",+ )++ async def unexpected_snapshot(*args, **kwargs):+ raise AssertionError("remote runtime snapshot reached the local controller")++ monkeypatch.setattr("vibe.internal_client.list_running_agents", unexpected_snapshot)+ response = client.get(+ path,+ base_url="https://alex.avibe.bot",+ environ_base=_remote_peer(),+ )++ assert response.status_code == 403+ assert response.get_json()["code"] == "remote_execution_disabled"++@pytest.mark.parametrize("json_body",[diff --git a/ui/src/components/workbench/AgentsPage.tsx b/ui/src/components/workbench/AgentsPage.tsxindex 16c44f664..54f54991f 100644--- a/ui/src/components/workbench/AgentsPage.tsx+++ b/ui/src/components/workbench/AgentsPage.tsx@@ -71,7 +71,7 @@ export const AgentsPage: React.FC = () => {const { t } = useTranslation();const api = useApi();const { showToast } = useToast();- const { capabilities } = useInstanceAuthorization();+ const { capabilities, remote } = useInstanceAuthorization();const [agentsTab, setAgentsTab] = useState<AgentsTabKey>('definitions');const [runningActiveCount, setRunningActiveCount] = useState<number | null>(null);const [eventBridgeConnected, setEventBridgeConnected] = useState(false);@@ -91,6 +91,8 @@ export const AgentsPage: React.FC = () => {// Mobile drill-down: a row tap opens the detail full-screen. The agent// auto-selected on mount stays in the list view until the user drills in.const [detailOpen, setDetailOpen] = useState(false);+ const visibleTabs = remote ? (['definitions'] as const) : AGENTS_TAB_ORDER;+ const activeTab = remote ? 'definitions' : agentsTab;const refreshOnboarding = useCallback(async () => {if (!capabilities.can_manage_agents) {@@ -151,6 +153,10 @@ export const AgentsPage: React.FC = () => {}, [selected]);const fetchRunningActiveCount = useCallback(async () => {+ if (remote) {+ setRunningActiveCount(null);+ return;+ }try {const result = await api.getRunningAgents();if (result.ok && result.counts) {@@ -165,7 +171,7 @@ export const AgentsPage: React.FC = () => {} catch {setRunningActiveCount(null);}- }, [api]);+ }, [api, remote]);// Keep the badge fresh on every tab (including 运行) so it never depends on// the graph view's filters.@@ -174,6 +180,10 @@ export const AgentsPage: React.FC = () => {}, [fetchRunningActiveCount]);useEffect(() => {+ if (remote) {+ setEventBridgeConnected(false);+ return;+ }return api.connectWorkbenchEvents({onConnected: (data) => {if (data.source === 'controller') {@@ -192,9 +202,10 @@ export const AgentsPage: React.FC = () => {onSessionStatus: () => fetchRunningActiveCount(),onAuthorizationChanged: () => void refresh(),});- }, [api, fetchRunningActiveCount, refresh]);+ }, [api, fetchRunningActiveCount, refresh, remote]);useEffect(() => {+ if (remote) return;// Reconcile the badge even while SSE is connected: process death / orphan /// reap is a sampled snapshot with no run/session SSE event, so a slow// liveness poll keeps the count fresh (30s connected, 8s disconnected),@@ -244,7 +255,7 @@ export const AgentsPage: React.FC = () => {document.removeEventListener('visibilitychange', refreshNow);window.removeEventListener('focus', refreshNow);};- }, [eventBridgeConnected, fetchRunningActiveCount]);+ }, [eventBridgeConnected, fetchRunningActiveCount, remote]);const selectAgent = useCallback(async (name: string, openDetail = false) => {@@ -420,10 +431,10 @@ export const AgentsPage: React.FC = () => {}/>- {/* Sub-tab row: Definitions | Running */}+ {/* Local runtime diagnostics are intentionally unavailable remotely. */}<div className="flex items-center gap-0 overflow-x-auto border-b border-border">- {AGENTS_TAB_ORDER.map((key) => {- const active = agentsTab === key;+ {visibleTabs.map((key) => {+ const active = activeTab === key;return (<buttonkey={key}@@ -459,10 +470,10 @@ export const AgentsPage: React.FC = () => {})}</div>- {/* 运行 tab body — the run graph (replaces the old flat running list). */}- {agentsTab === 'running' && <AgentGraphTab />}+ {/* The run graph is a trusted-local process diagnostic. */}+ {!remote && activeTab === 'running' && <AgentGraphTab />}- {agentsTab === 'definitions' && onboardingInventory && (+ {activeTab === 'definitions' && onboardingInventory && (<OrganizationAgentOnboardinginventory={onboardingInventory}expanded={onboardingExpanded}@@ -474,7 +485,7 @@ export const AgentsPage: React.FC = () => {)}{/* Toolbar — design.pen Imduv: search + backend filter + spacer + Import + 新建 Agent */}- <div className={clsx('flex flex-wrap items-center gap-2.5', agentsTab === 'running' ? 'hidden' : detailOpen && 'max-lg:hidden')}>+ <div className={clsx('flex flex-wrap items-center gap-2.5', activeTab === 'running' ? 'hidden' : detailOpen && 'max-lg:hidden')}><div className="flex h-9 w-full items-center gap-2 rounded-md border border-input bg-background px-3 transition-colors focus-within:border-ring focus-within:ring-2 focus-within:ring-ring sm:w-[320px]"><Search className="size-3.5 shrink-0 text-muted" /><input@@ -497,7 +508,7 @@ export const AgentsPage: React.FC = () => {</Button></div>- {agentsTab === 'definitions' && error && (+ {activeTab === 'definitions' && error && (<div className="rounded-md border border-destructive/40 bg-destructive/[0.06] px-3 py-2 text-[12px] text-destructive">{error}</div>@@ -512,7 +523,7 @@ export const AgentsPage: React.FC = () => {<divclassName={clsx('grid gap-5',- agentsTab === 'running' && 'hidden',+ activeTab === 'running' && 'hidden',// `minmax(0,1fr)` + `min-w-0` keep the list column shrinkable; bare// `1fr` would let a long agent row push the fixed detail card off-screen.selected ? 'grid-cols-1 lg:grid-cols-[minmax(0,1fr)_420px]' : 'grid-cols-1',diff --git a/vibe/authorization.py b/vibe/authorization.pyindex 32923226b..2f7d5dd16 100644--- a/vibe/authorization.py+++ b/vibe/authorization.py@@ -89,6 +89,12 @@ class AuthorizationContext:def can_chat(self) -> bool:return not self.is_remote and self.has_role("editor")+ @property+ def can_use_cloud_asr(self) -> bool:+ """Allow the explicit remote Cloud ASR capability, not local execution."""++ return self.is_remote and self.has_role("editor")+@propertydef can_manage_projects(self) -> bool:return self.has_role("owner")@@ -373,7 +379,7 @@ _REMOTE_OWNER_ALLOWED_HTTP_RULES = tuple((frozenset({"GET", "HEAD", "POST"}), r"^/api/agent-onboarding$"),(frozenset({"GET", "HEAD"}),- r"^/api/(?:agents/[^/]+|agents-graph|running-agents|settings)$",+ r"^/api/(?:agents/[^/]+|settings)$",),(frozenset({"GET", "HEAD"}),diff --git a/vibe/remote_access.py b/vibe/remote_access.pyindex 8afc84373..530375819 100644--- a/vibe/remote_access.py+++ b/vibe/remote_access.py@@ -1391,19 +1391,24 @@ def cloud_token_for_request(cookie_value: str | None,scope: str = "asr",) -> dict[str, Any] | None:- """Resolve the logged-in user from the remote-access session cookie and mint a- short-lived cloud token for them.+ """Mint a short-lived, subject-bound Cloud ASR token for a remote editor.Returns ``{base_url, token, expires_at, scope}`` for the frontend, or ``None``- when there is no authenticated user or the mint fails.+ when the request is not an eligible remote ASR request or the mint fails.++ This deliberately does not reuse ``can_chat``: that capability authorizes a+ local Agent turn and must remain false for every remote caller. New Cloud+ scopes require their own explicit entitlement instead of inheriting ASR."""+ if scope != "asr":+ return Noneconfig = config or V2Config.load()payload = parse_session_cookie(config, cookie_value)if payload is None or session_needs_authorization_refresh(payload):return Nonefrom vibe.authorization import context_from_session_payload- if not context_from_session_payload(payload).can_chat:+ if not context_from_session_payload(payload).can_use_cloud_asr:return Noneemail = str(payload.get("email", "")).strip()sub = str(payload.get("sub", "")).strip()diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex 697c8ea2b..6f8d4f86f 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -5389,13 +5389,22 @@ async def config_post():agent_backend_runtime["restart_code"] = restart_result.get("code")else:agent_backend_runtime["apply_on_next_start"] = True- response_payload = api.client_config_payload(config)- if remote_access_runtime is not None:- response_payload["remote_access_runtime"] = remote_access_runtime- if platform_runtime is not None:- response_payload["platform_runtime"] = platform_runtime- if agent_backend_runtime is not None:- response_payload["agent_backend_runtime"] = agent_backend_runtime+ authorization_context = getattr(g, "authorization_context", None)+ is_remote = bool(authorization_context is not None and authorization_context.is_remote)+ response_payload = (+ api.remote_config_payload(config)+ if is_remote+ else api.client_config_payload(config)+ )+ # Remote config writes are restricted to preferences. Runtime reconciliation+ # results belong to trusted-local configuration and can expose local state.+ if not is_remote:+ if remote_access_runtime is not None:+ response_payload["remote_access_runtime"] = remote_access_runtime+ if platform_runtime is not None:+ response_payload["platform_runtime"] = platform_runtime+ if agent_backend_runtime is not None:+ response_payload["agent_backend_runtime"] = agent_backend_runtimereturn jsonify(response_payload)