Skip to content

armgit / avibe

Public Imported from GitHub
0

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.

chore(org): sync integration with latest master

Maxe59d15a1baea
diff --cc core/web_push_notifications.py
index 88de49145,c955879a8..d892f23f9
--- a/core/web_push_notifications.py
+++ b/core/web_push_notifications.py
@@@ -232,8 -155,10 +232,10 @@@ def _web_push_owner_metadata_for_messag
agent_row[3],
_parse_metadata(agent_row[4]),
):
- return []
+ return None, {}
- session_id, created_at, row_id = agent_row[0], agent_row[1], agent_row[2]
+ session_id, transcript_at, row_id = agent_row[0], agent_row[1], agent_row[2]
+
+ user_order = messages_service.transcript_order_value(messages)
user_rows = conn.execute(
select(messages.c.metadata_json)
diff --cc storage/alembic/versions/20260804_0047_merge_org_master.py
index 3fb9b82dc,000000000..2985d6370
mode 100644,000000..100644
--- a/storage/alembic/versions/20260804_0047_merge_org_master.py
+++ b/storage/alembic/versions/20260804_0047_merge_org_master.py
@@@ -1,22 -1,0 +1,22 @@@
+"""merge Organization schema into the master migration line
+
- Revision ID: 20260804_0046
- Revises: 20260725_0038, 20260802_0045
++Revision ID: 20260804_0047
++Revises: 20260725_0038, 20260804_0046
+Create Date: 2026-08-04
+"""
+
+from __future__ import annotations
+
+
- revision = "20260804_0046"
- down_revision = ("20260725_0038", "20260802_0045")
++revision = "20260804_0047"
++down_revision = ("20260725_0038", "20260804_0046")
+branch_labels = None
+depends_on = None
+
+
+def upgrade() -> None:
+ pass
+
+
+def downgrade() -> None:
+ pass
diff --cc storage/messages_service.py
index 5d3e33d8d,3f82d83d1..554941b50
--- a/storage/messages_service.py
+++ b/storage/messages_service.py
@@@ -379,11 -411,9 +432,11 @@@ def search_messages
# sessions stay active), so exclude a disabled scope's messages too. A
# missing scope_settings row (legacy / folder-less project) is enabled.
.where(or_(scope_settings.c.enabled.is_(None), scope_settings.c.enabled != 0))
- .order_by(messages.c.created_at.desc(), messages.c.id.desc())
+ .order_by(transcript_order_value().desc(), messages.c.id.desc())
.limit(effective_limit)
)
+ if allowed_scope_ids is not None:
+ stmt = stmt.where(agent_sessions.c.scope_id.in_(allowed_scope_ids))
rows = conn.execute(stmt).mappings().all()
@@@ -664,19 -695,14 +719,19 @@@ def list_session_messages
older_q = (
query.where(
or_(
- messages.c.created_at < anchor,
- and_(messages.c.created_at == anchor, messages.c.id < around_id),
+ order_value < anchor,
+ and_(order_value == anchor, messages.c.id < around_id),
)
)
- .order_by(messages.c.created_at.desc(), messages.c.id.desc())
+ .order_by(order_value.desc(), messages.c.id.desc())
.limit(effective_limit + 1)
)
- older = [_row_to_payload(dict(row)) for row in conn.execute(older_q).mappings().all()]
+ older = [
+ _row_to_payload(
+ dict(row), include_private_metadata=include_private_metadata
+ )
+ for row in conn.execute(older_q).mappings().all()
+ ]
has_older = len(older) > effective_limit
older = older[:effective_limit]
older.reverse()
@@@ -691,19 -715,14 +746,19 @@@
newer_q = (
query.where(
or_(
- messages.c.created_at > anchor,
- and_(messages.c.created_at == anchor, messages.c.id > around_id),
+ order_value > anchor,
+ and_(order_value == anchor, messages.c.id > around_id),
)
)
- .order_by(messages.c.created_at.asc(), messages.c.id.asc())
+ .order_by(order_value.asc(), messages.c.id.asc())
.limit(effective_limit + 1)
)
- newer = [_row_to_payload(dict(row)) for row in conn.execute(newer_q).mappings().all()]
+ newer = [
+ _row_to_payload(
+ dict(row), include_private_metadata=include_private_metadata
+ )
+ for row in conn.execute(newer_q).mappings().all()
+ ]
has_newer = len(newer) > effective_limit
newer = newer[:effective_limit]
@@@ -715,15 -734,10 +770,18 @@@
}
if tail:
# Newest ``limit`` rows, then flip back to chronological for the caller.
- query = query.order_by(messages.c.created_at.desc(), messages.c.id.desc()).limit(effective_limit + 1)
- rows = _attach_agent_run_provenance(
+ order_value = transcript_order_value()
- query = query.order_by(order_value.desc(), messages.c.id.desc()).limit(effective_limit + 1)
++ query = query.order_by(order_value.desc(), messages.c.id.desc()).limit(
++ effective_limit + 1
++ )
+ rows = _attach_harness_provenance(
- conn, [_row_to_payload(dict(row)) for row in conn.execute(query).mappings().all()]
+ conn,
+ [
+ _row_to_payload(
+ dict(row), include_private_metadata=include_private_metadata
+ )
+ for row in conn.execute(query).mappings().all()
+ ],
)
has_older = len(rows) > effective_limit
rows = rows[:effective_limit]
@@@ -740,19 -755,13 +799,21 @@@
if anchor is not None:
query = query.where(
or_(
- messages.c.created_at < anchor,
- and_(messages.c.created_at == anchor, messages.c.id < before_id),
+ order_value < anchor,
+ and_(order_value == anchor, messages.c.id < before_id),
)
)
- query = query.order_by(messages.c.created_at.desc(), messages.c.id.desc()).limit(effective_limit + 1)
- rows = _attach_agent_run_provenance(
- query = query.order_by(order_value.desc(), messages.c.id.desc()).limit(effective_limit + 1)
++ query = query.order_by(order_value.desc(), messages.c.id.desc()).limit(
++ effective_limit + 1
++ )
+ rows = _attach_harness_provenance(
- conn, [_row_to_payload(dict(row)) for row in conn.execute(query).mappings().all()]
+ conn,
+ [
+ _row_to_payload(
+ dict(row), include_private_metadata=include_private_metadata
+ )
+ for row in conn.execute(query).mappings().all()
+ ],
)
has_older = len(rows) > effective_limit
rows = rows[:effective_limit]
@@@ -769,19 -779,14 +831,22 @@@
if anchor is not None:
query = query.where(
or_(
- messages.c.created_at > anchor,
- and_(messages.c.created_at == anchor, messages.c.id > after_id),
+ order_value > anchor,
+ and_(order_value == anchor, messages.c.id > after_id),
)
)
- query = query.order_by(messages.c.created_at.asc(), messages.c.id.asc()).limit(effective_limit + 1)
- rows = _attach_agent_run_provenance(
+ order_value = transcript_order_value()
- query = query.order_by(order_value.asc(), messages.c.id.asc()).limit(effective_limit + 1)
++ query = query.order_by(order_value.asc(), messages.c.id.asc()).limit(
++ effective_limit + 1
++ )
+ rows = _attach_harness_provenance(
- conn, [_row_to_payload(dict(row)) for row in conn.execute(query).mappings().all()]
+ conn,
+ [
+ _row_to_payload(
+ dict(row), include_private_metadata=include_private_metadata
+ )
+ for row in conn.execute(query).mappings().all()
+ ],
)
# Probe one extra row against the clamped page size: a full page alone does
# not prove there is another page, but the extra row does.
@@@ -991,12 -964,8 +1056,12 @@@ def list_inbox_sessions
cursor returned as ``next_cursor``).
"""
+ allowed_scope_ids = list(dict.fromkeys(scope_ids)) if scope_ids is not None else None
+ if allowed_scope_ids == []:
+ return {"sessions": [], "next_cursor": None}
+
def _latest_message_value(
- column_name: str,
+ column_name: Optional[str],
*,
author: Optional[str] = None,
types: Optional[tuple[str, ...]] = None,
diff --cc tests/test_remote_access_vibe_cloud.py
index 84978cb30,b6523ec10..942355fb4
--- a/tests/test_remote_access_vibe_cloud.py
+++ b/tests/test_remote_access_vibe_cloud.py
@@@ -4,7 -4,7 +4,8 @@@ import ipaddres
import json
import threading
import time
+import urllib.parse
+ from types import SimpleNamespace
import pytest
from cryptography.hazmat.primitives.asymmetric import rsa
@@@ -2317,26 -1985,25 +2411,23 @@@ def test_mint_cloud_token_returns_none_
assert remote_access.mint_cloud_token(config, sub="u", email="[email protected]") is None
--def test_cloud_token_for_request_mints_for_authenticated_user(monkeypatch) -> None:
++def test_cloud_token_for_request_does_not_mint_when_remote_chat_is_disabled(
++ monkeypatch,
++) -> None:
config = _cloud_broker_config()
- cookie = remote_access.make_session_cookie(config, "[email protected]", "user-1")
+ monkeypatch.setattr(remote_access, "current_authorization_revision", lambda *a, **k: 1)
+ cookie = _session_cookie(config)
++ called = False
-- monkeypatch.setattr(
-- remote_access,
-- "_json_request",
-- lambda *a, **k: {"access_token": "ct_xyz", "expires_in": 43200},
-- )
++ def fake_json_request(*args, **kwargs):
++ nonlocal called
++ called = True
++ return {"access_token": "ct_xyz", "expires_in": 43200}
-- before = int(time.time())
-- result = remote_access.cloud_token_for_request(config, cookie)
-- after = int(time.time())
++ monkeypatch.setattr(remote_access, "_json_request", fake_json_request)
-- assert result is not None
-- assert result["base_url"] == "https://avibe.bot"
-- assert result["token"] == "ct_xyz"
-- assert result["scope"] == "asr"
-- assert before + 43200 <= result["expires_at"] <= after + 43200
++ assert remote_access.cloud_token_for_request(config, cookie) is None
++ assert called is False
def test_cloud_token_for_request_returns_none_without_valid_session(monkeypatch) -> None:
diff --cc tests/test_remote_authorization_revision.py
index 812df124a,000000000..a976538a0
mode 100644,000000..100644
--- a/tests/test_remote_authorization_revision.py
+++ b/tests/test_remote_authorization_revision.py
@@@ -1,407 -1,0 +1,406 @@@
+from __future__ import annotations
+
+import asyncio
+import time
+from typing import Any
+
+import pytest
+
+from config.v2_config import (
+ AgentsConfig,
+ PlatformsConfig,
+ RemoteAccessConfig,
+ RuntimeConfig,
+ SlackConfig,
+ UiConfig,
+ V2Config,
+)
+from tests.ui_server_test_helpers import csrf_headers
+from vibe import remote_access, ui_server
+from vibe.authorization import context_from_session_payload
+from vibe.ui_compat import g
+from vibe.ui_server import app
+
+
+def _paired_config(tmp_path, *, revision: int = 41) -> V2Config:
+ config = V2Config(
+ mode="self_host",
+ version="v2",
+ platform="slack",
+ platforms=PlatformsConfig(enabled=["slack"], primary="slack"),
+ slack=SlackConfig(bot_token=""),
+ runtime=RuntimeConfig(default_cwd="."),
+ agents=AgentsConfig(),
+ ui=UiConfig(),
+ remote_access=RemoteAccessConfig(),
+ )
+ cloud = config.remote_access.vibe_cloud
+ cloud.enabled = True
+ cloud.backend_url = "https://backend.test"
+ cloud.public_url = "https://alex.avibe.bot"
+ cloud.client_id = "vr_client_123"
+ cloud.instance_id = "inst_123"
+ cloud.instance_secret = "instance-secret"
+ cloud.session_secret = "session-secret"
+ cloud.authorization_endpoint = "https://backend.test/oauth/authorize"
+ cloud.redirect_uri = "https://alex.avibe.bot/auth/callback"
+ config.save()
+ remote_access._clear_authorization_revision_cache()
+ remote_access._replace_authorization_revision(config, revision)
+ return config
+
+
+def _organization_claims(
+ config: V2Config,
+ *,
+ revision: int = 41,
+ role: str = "editor",
+) -> dict[str, Any]:
+ return {
+ "vibe_instance_id": config.remote_access.vibe_cloud.instance_id,
+ "vibe_instance_role": role,
+ "vibe_instance_access_source": "organization_group",
+ "vibe_instance_authorization_revision": revision,
+ "vibe_organization_id": "org_123",
+ "vibe_organization_member_id": "member_123",
+ "vibe_organization_role": "member",
+ "vibe_group_ids": ["group_research"],
+ "vibe_membership_version": "membership-v1",
+ }
+
+
+def _organization_cookie(
+ config: V2Config,
+ *,
+ revision: int = 41,
+ subject: str = "user-1",
+) -> str:
+ return remote_access.make_session_cookie(
+ config,
+ f"{subject}@example.com",
+ subject,
+ session_claims=_organization_claims(config, revision=revision),
+ )
+
+
+def test_authorization_revision_device_contract_is_monotonic(monkeypatch, tmp_path):
+ """I1057-AC2/AC3: one paired-device watermark drives every hostname."""
+
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ config = _paired_config(tmp_path)
+ calls = []
+
+ def request(cfg, method, suffix, payload=None, *, timeout=8.0):
+ calls.append((cfg, method, suffix, payload, timeout))
+ return {"authorization_revision": 42}
+
+ monkeypatch.setattr(remote_access, "_device_json_request", request)
+
+ assert remote_access.sync_authorization_revision_once(config) == {
+ "ok": True,
+ "authorization_revision": 42,
+ }
+ assert calls == [(config, "GET", "authorization-revision", None, 8.0)]
+ assert remote_access.current_authorization_revision(config) == 42
+
+ monkeypatch.setattr(
+ remote_access,
+ "_device_json_request",
+ lambda *args, **kwargs: {"authorization_revision": 41},
+ )
+ assert remote_access.sync_authorization_revision_once(config) == {
+ "ok": False,
+ "error": "authorization_revision_regressed",
+ }
+ assert remote_access.current_authorization_revision(config) == 42
+
+
+def test_paired_session_requires_signed_current_revision(monkeypatch, tmp_path):
+ """I1057-AC4: unsigned, missing, and stale authorization versions fail closed."""
+
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ config = _paired_config(tmp_path)
+ missing = _organization_claims(config)
+ missing.pop("vibe_instance_authorization_revision")
+
+ with pytest.raises(
+ remote_access.OAuthCodeExchangeError,
+ match="invalid_authorization_revision",
+ ):
+ remote_access.make_session_cookie(
+ config,
+ "user-1",
+ session_claims=missing,
+ )
+
+ with pytest.raises(
+ remote_access.OAuthCodeExchangeError,
+ match="stale_authorization_revision",
+ ):
+ _organization_cookie(config, revision=40)
+
+
+ "hosted_change",
+ [
+ "role_downgrade",
+ "group_membership_removal",
+ "group_archival",
+ "member_removal",
+ "access_binding_removal",
+ ],
+)
+def test_revision_advance_revokes_active_editor_http_session(
+ monkeypatch,
+ tmp_path,
+ hosted_change,
+):
- """I1057-AC1/AC2: every narrowing cause revokes active editor mutations."""
++ """I1057-AC1/AC2: narrowing invalidates a remote session with chat disabled."""
+
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ config = _paired_config(tmp_path)
+ cookie = _organization_cookie(config)
+ payload = remote_access.parse_session_cookie(config, cookie)
+ assert payload is not None
- assert context_from_session_payload(payload).can_chat is True
++ assert context_from_session_payload(payload).can_chat is False
+
+ client = app.test_client()
+ client.set_cookie(remote_access.SESSION_COOKIE_NAME, cookie, domain="alex.avibe.bot")
+ headers = csrf_headers(client, "https://alex.avibe.bot")
+ before = client.post(
+ "/api/sessions",
+ base_url="https://alex.avibe.bot",
+ headers=headers,
+ json={},
+ )
+ assert before.status_code == 400
+
+ assert hosted_change
+ remote_access._replace_authorization_revision(config, 42)
+ after = client.post(
+ "/api/sessions",
+ base_url="https://alex.avibe.bot",
+ headers=headers,
+ json={},
+ )
+
+ assert after.status_code == 401
+ assert after.get_json()["error"] == "remote_access_login_required"
+
+
+def test_default_and_custom_hostname_sessions_share_revision(monkeypatch, tmp_path):
+ """I1057-AC3: host-scoped cookies cannot retain divergent authorization."""
+
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ config = _paired_config(tmp_path)
+ remote_access._replace_active_hostnames(config, ["max.fileguard.io"])
+ default_client = app.test_client()
+ custom_client = app.test_client()
+ default_client.set_cookie(
+ remote_access.SESSION_COOKIE_NAME,
+ _organization_cookie(config, subject="default-user"),
+ domain="alex.avibe.bot",
+ )
+ custom_client.set_cookie(
+ remote_access.SESSION_COOKIE_NAME,
+ _organization_cookie(config, subject="custom-user"),
+ domain="max.fileguard.io",
+ )
+
+ assert default_client.get(
+ "/api/session",
+ base_url="https://alex.avibe.bot",
+ ).get_json()["authenticated"] is True
+ assert custom_client.get(
+ "/api/session",
+ base_url="https://max.fileguard.io",
+ ).get_json()["authenticated"] is True
+
+ remote_access._replace_authorization_revision(config, 42)
+
+ assert default_client.get(
+ "/api/session",
+ base_url="https://alex.avibe.bot",
+ ).get_json()["authenticated"] is False
+ assert custom_client.get(
+ "/api/session",
+ base_url="https://max.fileguard.io",
+ ).get_json()["authenticated"] is False
+
+
+def test_revision_snapshot_expiry_and_renewal_fail_closed(monkeypatch, tmp_path):
+ """I1057-AC4: offline snapshots and renewal races cannot extend old claims."""
+
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ config = _paired_config(tmp_path)
+ cookie = _organization_cookie(config)
+ payload = remote_access.parse_session_cookie(config, cookie)
+ assert payload is not None
+
+ remote_access._replace_authorization_revision(config, 42)
+ with pytest.raises(
+ remote_access.OAuthCodeExchangeError,
+ match="stale_authorization_revision",
+ ):
+ remote_access.make_session_cookie(
+ config,
+ "user-1",
+ session_claims=payload,
+ )
+
+ remote_access._replace_authorization_revision(config, 42)
+ snapshot = remote_access._load_authorization_revision_snapshot(config)
+ assert snapshot is not None
+ _, updated_at = snapshot
+ assert remote_access.session_authorization_is_current(
+ config,
+ {"vibe_instance_authorization_revision": 42},
+ now=updated_at + remote_access.AUTHORIZATION_REVISION_MAX_AGE_SECONDS + 1,
+ ) is False
+
+
+def test_workbench_and_show_sse_end_after_revision_change(monkeypatch, tmp_path):
+ """I1057-AC4/AC6: active and resumed SSE streams converge on the watermark."""
+
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ config = _paired_config(tmp_path)
+ cookie = _organization_cookie(config)
+ payload = remote_access.parse_session_cookie(config, cookie)
+ assert payload is not None
+ context = context_from_session_payload(payload)
+
+ class EmptyShowEventStore:
+ def list(self, *args, **kwargs):
+ return {"events": [], "next_after_id": None}
+
+ def close(self):
+ return None
+
+ monkeypatch.setattr(ui_server, "_show_session_event_store", EmptyShowEventStore)
+
+ async def exercise() -> None:
+ with app.test_request_context("/api/events"):
+ g.authorization_context = context
+ g.remote_session_payload = payload
+ response = await ui_server.workbench_events()
+ iterator = response.body_iterator.__aiter__()
+ try:
+ for _ in range(3):
+ await iterator.__anext__()
+ remote_access._replace_authorization_revision(config, 42)
+ with pytest.raises(StopAsyncIteration):
+ await asyncio.wait_for(iterator.__anext__(), timeout=1)
+ finally:
+ await iterator.aclose()
+
+ remote_access._replace_authorization_revision(config, 42)
+ show_response = await ui_server._show_events_stream(
+ "ses123",
+ after_id="show_evt_resume",
+ authorization_context=context,
+ remote_session_payload=payload,
+ remote_config=config,
+ )
+ show_iterator = show_response.body_iterator.__aiter__()
+ try:
+ with pytest.raises(StopAsyncIteration):
+ await asyncio.wait_for(show_iterator.__anext__(), timeout=1)
+ finally:
+ await show_iterator.aclose()
+
+ asyncio.run(exercise())
+
+
+def test_websocket_reconnect_and_active_waiter_recheck_revision(monkeypatch, tmp_path):
+ """I1057-AC4/AC6: active sockets close and stale reconnects are rejected."""
+
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ config = _paired_config(tmp_path)
+ cookie = _organization_cookie(config)
+
+ class Socket:
+ cookies = {remote_access.SESSION_COOKIE_NAME: cookie}
+
+ websocket = Socket()
+ monkeypatch.setattr(ui_server, "_websocket_is_local_request", lambda *args: False)
+ monkeypatch.setattr(ui_server, "_remote_access_host_allowed", lambda *args: True)
+ monkeypatch.setattr(ui_server, "_websocket_normalized_host", lambda *args: "alex.avibe.bot")
+ monkeypatch.setattr(ui_server, "_AUTHORIZATION_REVISION_RECHECK_SECONDS", 0.001)
+
+ payload = ui_server._remote_access_websocket_session_payload(websocket, config)
+ assert payload is not None
+
+ async def exercise() -> None:
+ waiter = asyncio.create_task(
+ ui_server._wait_for_remote_session_authorization_loss(config, payload)
+ )
+ await asyncio.sleep(0)
+ remote_access._replace_authorization_revision(config, 42)
+ await asyncio.wait_for(waiter, timeout=1)
+
+ asyncio.run(exercise())
+ assert ui_server._remote_access_websocket_session_payload(websocket, config) is None
+
+
- def test_terminal_websocket_fails_closed_when_revision_changes_after_gate(
++def test_terminal_websocket_rejects_stale_remote_session_before_accept(
+ monkeypatch,
+ tmp_path,
+):
- """I1057-AC4: a gate-to-accept revision race cannot drop remote identity."""
++ """I1057-AC4: a stale remote terminal request is never accepted."""
+
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ config = _paired_config(tmp_path)
+
+ class RecordingWebSocket:
+ client = None
+ query_params = {}
+
+ def __init__(self):
+ self.calls = []
+
+ async def accept(self):
+ self.calls.append(("accept", None))
+
+ async def close(self, code=1000):
+ self.calls.append(("close", code))
+
+ websocket = RecordingWebSocket()
+ monkeypatch.setattr(ui_server, "_terminal_enabled", lambda: True)
+ monkeypatch.setattr(ui_server, "TERMINAL_SUPPORTED", True)
+ monkeypatch.setattr(ui_server, "_terminal_origin_allowed", lambda socket: True)
+ monkeypatch.setattr(ui_server, "_show_runtime_websocket_authorized", lambda *a, **k: True)
+ monkeypatch.setattr(ui_server, "_load_remote_access_config", lambda: config)
+ monkeypatch.setattr(ui_server, "_remote_access_websocket_session_claims", lambda *a: None)
+ monkeypatch.setattr(ui_server, "_websocket_is_local_request", lambda *a: False)
+ monkeypatch.setattr(
+ ui_server,
+ "get_terminal_service",
+ lambda: (_ for _ in ()).throw(AssertionError("stale socket reached terminal")),
+ )
+
+ asyncio.run(ui_server.terminal_websocket(websocket, "test"))
+
+ assert websocket.calls == [
- ("accept", None),
+ ("close", ui_server._AUTHORIZATION_REFRESH_WEBSOCKET_CLOSE_CODE),
+ ]
+
+
+def test_trusted_local_access_ignores_hosted_revision_state(monkeypatch, tmp_path):
+ """I1057-AC5: trusted local access stays owner-equivalent while sync is offline."""
+
+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))
+ config = _paired_config(tmp_path)
+ state_path = remote_access._authorization_revision_state_path()
+ state_path.unlink()
+ remote_access._clear_authorization_revision_cache()
+ assert remote_access.current_authorization_revision(config) is None
+
+ response = app.test_client().get(
+ "/api/config",
+ base_url="http://127.0.0.1:5123",
+ )
+
+ assert response.status_code == 200
+ assert response.get_json()["runtime"]["default_cwd"] == "."
diff --cc tests/test_sqlite_state_migration.py
index 637aed8a4,ed19a939b..050fcc143
--- a/tests/test_sqlite_state_migration.py
+++ b/tests/test_sqlite_state_migration.py
@@@ -28,7 -28,7 +28,7 @@@ from storage.settings_service import SQ
from vibe.message_types import build_partial_index_predicate
--HEAD_REVISION = "20260804_0046"
++HEAD_REVISION = "20260804_0047"
MESSAGE_PARTIAL_INDEX_PREDICATES = {
"ix_messages_inbox_activity": (
"session_id is not null and type in "
diff --cc tests/test_web_push_notifications.py
index 20c9b0551,6986b18fd..00c613cb8
--- a/tests/test_web_push_notifications.py
+++ b/tests/test_web_push_notifications.py
@@@ -1,45 -1,11 +1,45 @@@
from __future__ import annotations
from core import web_push_notifications
-from storage import message_deliveries, messages_service, web_push_service
+from storage import message_deliveries, messages_service, project_access_service, web_push_service
from storage.db import create_sqlite_engine
from storage.importer import ensure_sqlite_state
- from storage.models import agent_sessions
+ from storage.models import agent_sessions, messages
from storage.settings_service import upsert_scope
+from vibe import remote_access
+from vibe.authorization import AuthorizationContext
+
+
+def _remote_authorization_record(user_key: str) -> dict:
+ subject = user_key.removeprefix("remote:")
+ record = web_push_notifications.web_push_authorization_context_record(
+ user_key,
+ AuthorizationContext(
+ instance_role="editor",
+ subject=subject,
+ email=f"{subject}@example.com",
+ instance_access_source="email",
+ claims_issued_at=int(web_push_notifications.time.time()),
+ is_remote=True,
+ ),
+ )
+ assert record is not None
+ return record
+
+
+def _paired_revision_config(revision: int):
+ from core.services.settings import default_config
+
+ config = default_config()
+ cloud = config.remote_access.vibe_cloud
+ cloud.enabled = True
+ cloud.instance_id = "inst-push"
+ cloud.instance_secret = "device-secret"
+ cloud.backend_url = "https://backend.test"
+ config.save()
+ remote_access._clear_authorization_revision_cache()
+ remote_access._replace_authorization_revision(config, revision)
+ return config
def test_maybe_notify_inbox_message_schedules_agent_result(monkeypatch):
diff --cc ui/src/i18n/en.json
index f20151768,e3a0c54f3..a5593d151
--- a/ui/src/i18n/en.json
+++ b/ui/src/i18n/en.json
@@@ -1143,7 -1131,66 +1143,23 @@@
"rttUnavailable": "Unavailable",
"requestPath": "Requests · P95 {{p95}} · P99 {{p99}} · {{slow}}% > 1 s",
"requestPathUnavailable": "Requests unavailable · {{success}}/{{count}} succeeded",
- "requestPathMeasuring": "Measuring requests · {{count}} samples"
+ "requestPathMeasuring": "Measuring requests · {{count}} samples",
+ "networkPath": "Network path",
+ "networkBrowserIngress": "This browser",
+ "networkProvider": "Network",
+ "networkConnectorEdges": "Tunnel edges",
+ "networkLocalBrowser": "Local browser",
+ "networkIngressUnavailable": "Ingress location unavailable",
+ "networkLocationUnavailable": "Location unavailable",
+ "networkAdditionalLocations": "{{location}} +{{count}} more",
+ "networkRouteSameMetro": "No geographic detour detected",
+ "networkRouteSameCountry": "Within-country route",
+ "networkRouteCrossCountry": "Potential cross-country route",
+ "networkRouteUnknown": "Route assessment unavailable",
+ "networkTechnicalDetails": "Technical details",
+ "networkEdgeNodes": "Cloudflare edge nodes",
+ "networkAnycastIps": "Cloudflare Anycast IPs",
- "networkIpUnavailable": "Edge IP unavailable",
- "optimizeRoute": "Optimize route",
- "optimizingRoute": "Optimizing...",
- "optimizeStarted": "A second Connector is evaluating a better route"
- },
- "models": {
- "eligibility": {
- "subscription_wrong_client": "{{vendor}} subscriptions only work in {{backend}}",
- "opencode_api_key_only": "OpenCode can only be supplied by API-key sources",
- "consent_required": "Needs your consent for experimental hub supply first"
- },
- "oauth": {
- "upstream_failed": "The vendor didn't complete this sign-in, please retry",
- "engine_unavailable": "The Hub isn't responding, please retry",
- "submission_failed": "Couldn't submit what you pasted, please retry",
- "ambiguous_engine_binding": "Couldn't tell which account signed in — do one at a time, then retry",
- "binding_failed": "That account is already used by another source",
- "expired": "Authorization timed out, please reconnect"
- },
- "probe": {
- "native_cli_unavailable": "Can't use the CLI's sign-in",
- "no_candidate": {
- "waiting": "Every source is cooling down",
- "interrupted": "No source can serve this model right now"
- }
- },
- "source": {
- "cooldown": {
- "network": "Network unreachable",
- "timeout": "Repeated timeouts",
- "rate_limited": "Rate limited",
- "quota_exhausted": "Cycle quota used up",
- "server_error": "Upstream server error"
- },
- "needs_action": {
- "oauth_expired": "Needs a new sign-in",
- "balance_exhausted": "Out of balance — top it up",
- "credential_revoked": "Credential revoked — enter a new one",
- "account_banned": "Account is restricted"
- },
- "error": {
- "unclassified": "Unknown error — temporarily unavailable"
- }
- }
++ "networkIpUnavailable": "Edge IP unavailable"
},
"accessBlocked": {
"title": "Can't open the control panel here",
@@@ -3087,10 -3074,18 +3103,12 @@@
"scheduled": "Scheduled task",
"watch": "Watch",
"webhook": "Webhook",
+ "hook": "Hook",
+ "activityRecovery": "Recovered activity",
- "showIntent": "Page action",
"harness": "From agent",
"from": "From",
- "agentFallback": "agent"
- },
- "annotation": {
- "titleUser": "User annotation",
- "titleAgent": "Agent annotation",
- "resolved": "Resolved",
- "screenshot": "Screenshot"
+ "agentFallback": "agent",
+ "showIntent": "Page action"
},
"picker": {
"agent": "Agent",
diff --cc ui/src/i18n/zh.json
index 577301a09,2778fd770..63c2bba83
--- a/ui/src/i18n/zh.json
+++ b/ui/src/i18n/zh.json
@@@ -1143,7 -1131,66 +1143,23 @@@
"rttUnavailable": "不可用",
"requestPath": "远程请求 · P95 {{p95}} · P99 {{p99}} · {{slow}}% 超过 1 秒",
"requestPathUnavailable": "远程请求不可用 · {{success}}/{{count}} 成功",
- "requestPathMeasuring": "正在测量远程请求 · {{count}} 个样本"
+ "requestPathMeasuring": "正在测量远程请求 · {{count}} 个样本",
+ "networkPath": "网络路径",
+ "networkBrowserIngress": "当前浏览器",
+ "networkProvider": "网络",
+ "networkConnectorEdges": "Tunnel 边缘节点",
+ "networkLocalBrowser": "本地浏览器",
+ "networkIngressUnavailable": "入口位置暂不可用",
+ "networkLocationUnavailable": "位置暂不可用",
+ "networkAdditionalLocations": "{{location}},另有 {{count}} 个",
+ "networkRouteSameMetro": "未发现地理绕路",
+ "networkRouteSameCountry": "境内路径",
+ "networkRouteCrossCountry": "可能存在跨国路径",
+ "networkRouteUnknown": "暂无法判断是否绕路",
+ "networkTechnicalDetails": "技术详情",
+ "networkEdgeNodes": "Cloudflare 边缘节点",
+ "networkAnycastIps": "Cloudflare Anycast IP",
- "networkIpUnavailable": "暂未获取边缘 IP",
- "optimizeRoute": "优化线路",
- "optimizingRoute": "优化中...",
- "optimizeStarted": "第二条 Connector 正在评估更优线路"
- },
- "models": {
- "eligibility": {
- "subscription_wrong_client": "{{vendor}} 订阅仅可供 {{backend}} 使用",
- "opencode_api_key_only": "OpenCode 只能由 API Key 来源供给",
- "consent_required": "需要先同意实验性中枢供给"
- },
- "oauth": {
- "upstream_failed": "厂商没有完成这次登录,请重试",
- "engine_unavailable": "中枢没有响应,请重试",
- "submission_failed": "粘贴的内容没能提交,请重试",
- "ambiguous_engine_binding": "分不清登录的是哪个账号,请一次只登一个再重试",
- "binding_failed": "该账号已被另一来源使用",
- "expired": "授权超时,请重新连接"
- },
- "probe": {
- "native_cli_unavailable": "用不上 CLI 的登录",
- "no_candidate": {
- "waiting": "所有来源都在冷却",
- "interrupted": "现在没有来源能提供这个模型"
- }
- },
- "source": {
- "cooldown": {
- "network": "网络不通",
- "timeout": "连续超时",
- "rate_limited": "触发限流",
- "quota_exhausted": "本周期额度用完",
- "server_error": "上游服务异常"
- },
- "needs_action": {
- "oauth_expired": "需要重新登录",
- "balance_exhausted": "余额不足,需要充值",
- "credential_revoked": "凭据已失效,需要重新填写",
- "account_banned": "账号被限制使用"
- },
- "error": {
- "unclassified": "未知错误,暂时不可用"
- }
- }
++ "networkIpUnavailable": "暂未获取边缘 IP"
},
"accessBlocked": {
"title": "无法在此地址打开控制台",
@@@ -3087,10 -3074,18 +3103,12 @@@
"scheduled": "定时任务",
"watch": "Watch 监听",
"webhook": "Webhook",
+ "hook": "Hook",
+ "activityRecovery": "活动恢复",
- "showIntent": "页面操作",
"harness": "来自 Agent",
"from": "来自",
- "agentFallback": "智能体"
- },
- "annotation": {
- "titleUser": "用户批注",
- "titleAgent": "Agent 批注",
- "resolved": "已处理",
- "screenshot": "截图"
+ "agentFallback": "智能体",
+ "showIntent": "页面操作"
},
"picker": {
"agent": "Agent",