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(org): keep remote execution trusted-local
Max791eeff488b4
diff --git a/core/internal_server.py b/core/internal_server.pyindex 73bbc51f1..bac7eca64 100644--- a/core/internal_server.py+++ b/core/internal_server.py@@ -621,6 +621,26 @@ def create_app(if delivery is not None and delivery["session_id"] == session_idelse None)+ if (+ delivery is not None+ and delivery_payload is not None+ and message_deliveries.delivery_has_remote_resource_context(delivery)+ ):+ message_deliveries.retire_not_written(+ conn,+ session_id,+ delivery_id,+ reason="remote_execution_disabled",+ )+ return JSONResponse(+ status_code=403,+ content={+ "ok": False,+ "code": "remote_execution_disabled",+ "session_id": session_id,+ "delivery_id": delivery_id,+ },+ )attachment_specs: list[dict[str, Any]] = []if delivery_payload is not None:from core.workbench_media import resolve_attachment_specsdiff --git a/core/scheduled_tasks.py b/core/scheduled_tasks.pyindex b94b4498c..a5bf67ab8 100644--- a/core/scheduled_tasks.py+++ b/core/scheduled_tasks.py@@ -1505,8 +1505,12 @@ class ScheduledTaskStore:user_context: Any = None,) -> ScheduledTask:from core.vibe_agents import ensure_agent_name_access- from storage.resource_access_service import metadata_with_resource_user_context+ from storage.resource_access_service import (+ ensure_local_harness_definition_write,+ metadata_with_resource_user_context,+ )+ ensure_local_harness_definition_write(user_context)ensure_agent_name_access(agent_name, user_context=user_context)task = ScheduledTask(id=uuid4().hex[:12],@@ -1596,8 +1600,12 @@ class ScheduledTaskStore:user_context: Any = None,) -> ScheduledTask:from core.vibe_agents import ensure_agent_name_access- from storage.resource_access_service import metadata_with_resource_user_context+ from storage.resource_access_service import (+ ensure_local_harness_definition_write,+ metadata_with_resource_user_context,+ )+ ensure_local_harness_definition_write(user_context)ensure_agent_name_access(agent_name, user_context=user_context)task = self._tasks[task_id]# Captured before the first mutation: this is the state the CALLER read@@ -1813,6 +1821,20 @@ class ScheduledTaskStore:expected_uncanceled_run_id=expected_uncanceled_run_id,)+ def suspend_task(self, task_id: str, *, error: str) -> bool:+ """Atomically disable a definition before an unsafe execution boundary."""++ self.maybe_reload()+ task = self._tasks.get(task_id)+ if task is None:+ return False+ expect = self._read_state(task)+ task.enabled = False+ task.last_run_at = _utc_now_iso()+ task.last_error = error+ task.updated_at = _utc_now_iso()+ return self._write_task(task, expect)+class TaskExecutionStore:def __init__(self, root: Optional[Path] = None):@@ -6326,6 +6348,16 @@ class ScheduledTaskService:#: which is what stops the same failure being reported twice.escalation_run_id: Optional[str] = Nonetry:+ from storage.resource_access_service import (+ REMOTE_AUTONOMOUS_HARNESS_DISABLED_CODE,+ metadata_has_remote_resource_context,+ )++ if (+ request.request_type not in {"task_run", "scheduled"}+ and metadata_has_remote_resource_context(request.metadata)+ ):+ raise PermissionError(REMOTE_AUTONOMOUS_HARNESS_DISABLED_CODE)if request.request_type in {"task_run", "scheduled"}:self.store.maybe_reload()task = self.store.get_task(request.task_id or "")@@ -6988,12 +7020,31 @@ class ScheduledTaskService:disable_one_shot: bool,agent_id: Optional[str] = None,) -> TaskExecutionResult:+ from storage.resource_access_service import (+ REMOTE_AUTONOMOUS_HARNESS_DISABLED_CODE,+ metadata_has_remote_resource_context,+ )+error: Optional[str] = Nonecomplete_on_return = Truereconcile_delivery_on_return = Falsefailure_code: Optional[str] = Nonesession_id = task.session_idsession_key = task.session_key+ if metadata_has_remote_resource_context(task.metadata):+ error = REMOTE_AUTONOMOUS_HARNESS_DISABLED_CODE+ if not self.store.suspend_task(task.id, error=error):+ logger.warning(+ "Remote-origin scheduled task %s changed before it could be suspended",+ task.id,+ )+ self.reconcile_jobs()+ return TaskExecutionResult(+ error=error,+ session_key=session_key,+ session_id=session_id,+ failure_code=REMOTE_AUTONOMOUS_HARNESS_DISABLED_CODE,+ )user_context = self._resource_user_context(task.metadata)binding_change: Optional[SessionBindingChange] = None# HFR-276: an earlier fire of THIS definition may have reserved a replacementdiff --git a/core/session_turns.py b/core/session_turns.pyindex 8708deb66..8c7d53676 100644--- a/core/session_turns.py+++ b/core/session_turns.py@@ -1129,6 +1129,25 @@ class SessionTurnManager:if not segment or any(row is None for row in segment):return Nonedelivery_rows = [row for row in segment if row is not None]+ remote_rows = [+ row+ for row in delivery_rows+ if delivery_store.delivery_has_remote_resource_context(row)+ ]+ if remote_rows:+ for row in remote_rows:+ if not self._retire_delivery_not_written(+ conn,+ session_id,+ str(row["id"]),+ reason="remote_execution_disabled",+ ):+ raise RuntimeError("remote FIFO Delivery retirement lost")+ logger.warning(+ "retired remote-origin queued Delivery=%s before Agent dispatch",+ row["id"],+ )+ continueinvalid_rows = [rowfor row in delivery_rows@@ -2767,6 +2786,7 @@ class SessionTurnManager:archived_before_dispatch = Falserun_terminal_before_dispatch = Falseinvalid_delivery_ids: set[str] = set()+ remote_delivery_ids: set[str] = set()with self._sqlite_engine().begin() as conn:reserve_write_lock(conn)latest = delivery_store.get_turn(conn, turn_id)@@ -2795,6 +2815,11 @@ class SessionTurnManager:for row in deliveriesif not self._has_resolvable_delivery_input(conn, row)}+ remote_delivery_ids = {+ str(row["id"])+ for row in deliveries+ if delivery_store.delivery_has_remote_resource_context(row)+ }run_ids = list(dict.fromkeys(run_id@@ -2842,6 +2867,25 @@ class SessionTurnManager:if terminal.get("changed"):await self._resume_post_terminal(str(turn["session_id"]))return False+ if remote_delivery_ids:+ logger.warning(+ "durable Turn=%s was blocked because it contains remote-origin input",+ turn_id,+ )+ terminal = self._terminalize_durable_turn(+ turn_id,+ "not_written",+ settled_by="remote_execution_disabled",+ evidence_kind="remote_origin_before_native_dispatch",+ retire_unwritten_delivery_ids={+ str(row["id"])+ for row in deliveries+ },+ )+ if terminal.get("changed"):+ self._publish_queue_update(str(turn["session_id"]))+ await self._resume_post_terminal(str(turn["session_id"]))+ return Falseif invalid_delivery_ids:logger.error("durable Turn=%s lost its resolvable input before native dispatch",diff --git a/core/watches.py b/core/watches.pyindex 47647b44f..3535b2700 100644--- a/core/watches.py+++ b/core/watches.py@@ -481,8 +481,12 @@ class ManagedWatchStore:user_context: Any = None,) -> ManagedWatch:from core.vibe_agents import ensure_agent_name_access- from storage.resource_access_service import metadata_with_resource_user_context+ from storage.resource_access_service import (+ ensure_local_harness_definition_write,+ metadata_with_resource_user_context,+ )+ ensure_local_harness_definition_write(user_context)ensure_agent_name_access(agent_name, user_context=user_context)watch = ManagedWatch(id=uuid4().hex[:12],@@ -579,8 +583,12 @@ class ManagedWatchStore:user_context: Any = None,) -> ManagedWatch:from core.vibe_agents import ensure_agent_name_access- from storage.resource_access_service import metadata_with_resource_user_context+ from storage.resource_access_service import (+ ensure_local_harness_definition_write,+ metadata_with_resource_user_context,+ )+ ensure_local_harness_definition_write(user_context)ensure_agent_name_access(agent_name, user_context=user_context)watch = self._watches[watch_id]# Captured before the first mutation: the state ``vibe watch update`` read and@@ -1294,6 +1302,11 @@ class ManagedWatchService:return Falseasync def _run_watch(self, watch_id: str) -> None:+ from storage.resource_access_service import (+ REMOTE_AUTONOMOUS_HARNESS_DISABLED_CODE,+ metadata_has_remote_resource_context,+ )+lifetime_started = asyncio.get_running_loop().time()self._watch_started_at[watch_id] = _utc_now_iso()self._runtime_state_dirty = True@@ -1309,6 +1322,19 @@ class ManagedWatchService:watch = self.store.get_watch(watch_id)if watch is None or not watch.enabled:return+ if metadata_has_remote_resource_context(watch.metadata):+ self._watch_store_call(+ watch.id,+ "suspend_remote_origin",+ lambda: self.store.mark_cycle_result(+ watch.id,+ exit_code=None,+ error=REMOTE_AUTONOMOUS_HARNESS_DISABLED_CODE,+ disable=True,+ ),+ guarded=True,+ )+ returnif watch.mode == "forever" and watch.lifetime_timeout_seconds > 0:elapsed = asyncio.get_running_loop().time() - lifetime_starteddiff --git a/docs/CLI.md b/docs/CLI.mdindex 23e17c8b5..eef511f52 100644--- a/docs/CLI.md+++ b/docs/CLI.md@@ -173,6 +173,12 @@ Start the guided Avibe Cloud remote-access setup.vibe remote```+In the conservative Organization release, the remote Workbench remains+available for Organization management and authorized Project, Session, message,+and history reads. Agent turns, Harness definition changes and autonomous+execution, terminal access, and file operations remain trusted-local only; open+Avibe on the machine to perform those actions.+**Flow:**- The CLI explains what remote access does before asking for anything.- Open `https://avibe.bot`, sign up or log in, create a new remote-access bot, claim your personal domain, and copy the one-time pairing key.diff --git a/docs/CLI_ZH.md b/docs/CLI_ZH.mdindex c43d0599b..45a8df55a 100644--- a/docs/CLI_ZH.md+++ b/docs/CLI_ZH.md@@ -154,6 +154,10 @@ vibe doctor repair tmux --yesvibe remote```+在 Organization 的保守发布版本中,远程工作台仍可用于 Organization 管理,以及按权限+查看 Project、Session、消息和历史记录。Agent 对话、Harness 定义修改与自主执行、+终端和文件操作仅允许可信本机调用;如需执行这些操作,请在运行 Avibe 的机器上打开。+**流程:**- CLI 会先解释远程访问的作用,不会一上来就要求输入配对码。- 打开 `https://avibe.bot`,注册或登录,创建新的 remote-access bot,领取自己的个人域名,然后复制一次性 pairing key。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.mdnew file mode 100644index 000000000..953c5a252--- /dev/null+++ b/docs/plans/2026-08-04-org-master-conservative-harness-gate.md@@ -0,0 +1,73 @@+# Organization-to-Master Conservative Execution Gate++Status: Approved for the `org` to `master` integration release on 2026-08-04.++## Background++PR #1162 carries Organization principals into the local Workbench and Resource+ACL model. The Agent runtimes are intentionally shell-capable and can mutate+their own environment, so Agent environment variables cannot authenticate a+remote caller or turn persisted identity into durable execution authority.++The existing Organization-aware Harness plan already defines stored principal+data as provenance, not bearer authority, and requires an authoritative local+entitlement mirror before remote recurring execution can be enabled.++## Approved Release Boundary++- Keep Organization management, Project and Resource ACL management, and+ authorized Project, Session, message, and history reads.+- Keep trusted-local Workbench, CLI, Task, Watch, Agent, terminal, and file+ behavior unchanged.+- Keep IM-triggered Agent behavior unchanged.+- Make every remote Workbench capability read-only with respect to local Agent,+ terminal, file, and Harness execution.+- Reject remote Task and Watch creation or update at the definition service+ boundary when an explicit remote `AuthorizationContext` is present.+- Suspend previously persisted remote-origin Tasks and Watches before any Agent,+ command, or waiter process starts.+- Retire previously queued remote Workbench Deliveries before they can be+ claimed by a durable Agent turn.+- Treat persisted `resource_user_context` only as provenance indicating remote+ origin. It is never sufficient authority for autonomous execution.++## Enforcement Points++1. The signed HTTP session projects remote `can_chat`, terminal, file, and+ system execution capabilities as false.+2. The UI server rejects remote message dispatch, Show-event Agent dispatch,+ terminal sockets, file operations, and Harness definition mutations before+ invoking their underlying services.+3. The durable Delivery owner retires remote-origin queue entries before the+ FIFO claim that starts an Agent turn.+4. Task and Watch stores reject explicit remote definition writes.+5. Task and Watch executors detect persisted remote provenance and atomically+ disable the definition with `remote_autonomous_harness_disabled` before any+ process spawn or Agent dispatch.++## Deferred Phase 2++Remote Agent and autonomous Harness execution stay disabled until both are+available:++- server-mediated Agent tools whose caller identity cannot be removed or forged+ by the Agent process; and+- an authoritative local entitlement mirror that revalidates current Instance+ revision, membership, role, groups, Project access, and Resource ACLs at every+ launch and resume boundary.++No opaque token passed through the current Agent environment is considered a+substitute for either dependency.++## Validation++- Remote Workbench message and Show dispatch do not reserve or start a turn.+- Remote terminal and file requests fail closed; trusted-local requests retain+ existing behavior.+- Remote Task and Watch add/update calls produce no definition write.+- Existing remote-origin Tasks and Watches are disabled before command, waiter,+ or Agent dispatch.+- Existing queued remote Workbench Deliveries are retired before FIFO claim;+ later local queue entries remain runnable.+- Focused backend tests, frontend build, Ruff, lock validation, and diff checks+ pass before the PR is pushed for a new current-head review.diff --git a/storage/message_deliveries.py b/storage/message_deliveries.pyindex 729617cb7..e403207c0 100644--- a/storage/message_deliveries.py+++ b/storage/message_deliveries.py@@ -358,6 +358,16 @@ def delivery_payload(row: dict[str, Any]) -> dict[str, Any]:}+def delivery_has_remote_resource_context(row: dict[str, Any]) -> bool:+ """Return whether an immutable Delivery snapshot records remote origin."""++ metadata = delivery_payload(row).get("metadata")+ return isinstance(metadata, dict) and isinstance(+ metadata.get("resource_user_context"),+ dict,+ )++def public_delivery_payload(row: dict[str, Any]) -> dict[str, Any]:"""Return a Delivery payload without server-owned identity metadata."""diff --git a/storage/resource_access_service.py b/storage/resource_access_service.pyindex 609f287a8..bb2e922c0 100644--- a/storage/resource_access_service.py+++ b/storage/resource_access_service.py@@ -31,6 +31,7 @@ ACCESS_LEVELS = frozenset({"public", "scope", "private"})ORGANIZATION_ROLES = frozenset({"owner", "admin", "member"})RESOURCE_USER_CONTEXT_METADATA_KEY = "resource_user_context"RESOURCE_ORGANIZATIONS_META_KEY = "resource_access_organizations"+REMOTE_AUTONOMOUS_HARNESS_DISABLED_CODE = "remote_autonomous_harness_disabled"class ResourceAccessError(ValueError):@@ -201,6 +202,26 @@ def resolve_resource_access_context(return trusted_local_context()+def ensure_local_harness_definition_write(+ user_context: ResourceUserContext | Mapping[str, Any] | None = None,+) -> ResourceUserContext:+ """Keep executable Harness definitions on the trusted-local side."""++ context = resolve_resource_access_context(user_context)+ if context.is_remote:+ raise ResourceAccessError(REMOTE_AUTONOMOUS_HARNESS_DISABLED_CODE)+ return context+++def metadata_has_remote_resource_context(metadata: Mapping[str, Any] | None) -> bool:+ """Return whether persisted metadata records a remote-origin principal."""++ return isinstance(metadata, Mapping) and isinstance(+ metadata.get(RESOURCE_USER_CONTEXT_METADATA_KEY),+ Mapping,+ )++def metadata_with_resource_user_context(metadata: Mapping[str, Any] | None,user_context: ResourceUserContext | Mapping[str, Any] | None = None,@@ -241,7 +262,11 @@ def resource_user_context_from_metadata(*,now: int | None = None,) -> ResourceUserContext | None:- """Restore a remote definition creator context, or None for local legacy work."""+ """Restore remote provenance for non-executable compatibility callers.++ The returned object is not autonomous execution authority. Task and Watch+ executors reject metadata carrying this provenance before calling here.+ """if not isinstance(metadata, Mapping):return Nonediff --git a/tests/test_cli_task_command.py b/tests/test_cli_task_command.pyindex 5eb9ef9bc..677a0dc8d 100644--- a/tests/test_cli_task_command.py+++ b/tests/test_cli_task_command.py@@ -731,7 +731,10 @@ def test_task_show_missing_id_returns_guidance(tmp_path: Path) -> None:assert payload["help_command"] == "vibe task list"-def test_task_add_records_caller_context_metadata(tmp_path: Path, capsys, monkeypatch) -> None:+def test_remote_task_add_is_rejected_without_persisting_definition(+ tmp_path: Path,+ monkeypatch,+) -> None:# ``patch.dict(..., clear=False)`` below pins only the five ids this test names, so# the ORIGIN half of the contract (platform/channel/session_key/...) leaked in from# the Avibe Agent shell that runs the suite and appeared in the asserted metadata.@@ -772,26 +775,11 @@ def test_task_add_records_caller_context_metadata(tmp_path: Path, capsys, monkeypatch("vibe.cli._ensure_config", return_value=_configured_v2({"slack"})),patch("vibe.cli._task_store", return_value=store),):- result = cli.cmd_task_add(args)+ result, payload = _capture_stderr_json(cli.cmd_task_add, args)- assert result == 0- payload = json.loads(capsys.readouterr().out)- assert "task" not in payload- expected = {- "kind": "caller_context",- "caller": {- "session_id": "sesCaller",- "run_id": "runCaller",- "source": "agent_turn",- "backend": "codex",- "native_session_id": "native-codex-1",- },- }- assert payload["definition"]["metadata"]["created_by"] == expected- stored = cli.ScheduledTaskStore(store_path).get_task(payload["definition"]["id"])- assert stored is not None- assert stored.metadata["created_by"] == expected- assert stored.metadata["resource_user_context"]["sub"] == "remote-editor"+ assert result == 1+ assert payload["code"] == "remote_autonomous_harness_disabled"+ assert cli.ScheduledTaskStore(store_path).list_tasks() == []def test_task_add_create_per_run_scope_id_records_session_scope_metadata(tmp_path: Path, capsys) -> None:diff --git a/tests/test_cli_watch_command.py b/tests/test_cli_watch_command.pyindex 19bd9e6b2..e8a60c709 100644--- a/tests/test_cli_watch_command.py+++ b/tests/test_cli_watch_command.py@@ -423,7 +423,9 @@ def test_watch_add_creates_shell_watch(tmp_path: Path, capsys) -> None:assert payload["definition"]["retry_exit_codes"] == [75]-def test_watch_add_records_caller_context_metadata(tmp_path: Path, capsys) -> None:+def test_remote_watch_add_is_rejected_without_startup_or_persistence(+ tmp_path: Path,+) -> None:store_path = tmp_path / "watches.json"runtime_path = tmp_path / "watch_runtime.json"store = ManagedWatchStore(store_path)@@ -455,32 +457,25 @@ def test_watch_add_records_caller_context_metadata(tmp_path: Path, capsys) -> No),}+ startup_calls: list[str] = []++ def unexpected_startup(*args, **kwargs):+ startup_calls.append(args[2])+ raise AssertionError("remote Watch must not start")+with (patch.dict(os.environ, caller_env, clear=False),patch("vibe.cli._ensure_config", return_value=_configured_v2({"slack"})),patch("vibe.cli._watch_store", return_value=store),patch("vibe.cli._watch_runtime_store", return_value=runtime_store),- patch("vibe.cli._wait_for_watch_startup", side_effect=lambda *args, **kwargs: _startup_ok(store, runtime_store, args[2])),+ patch("vibe.cli._wait_for_watch_startup", side_effect=unexpected_startup),):- result = cli.cmd_watch_add(args)+ result, payload = _capture_stderr_json(cli.cmd_watch_add, args)- assert result == 0- payload = json.loads(capsys.readouterr().out)- expected = {- "kind": "caller_context",- "caller": {- "session_id": "sesCaller",- "run_id": "runCaller",- "source": "agent_turn",- "backend": "opencode",- "native_session_id": "native-opencode-1",- },- }- assert payload["definition"]["metadata"]["created_by"] == expected- stored = ManagedWatchStore(store_path).get_watch(payload["definition"]["id"])- assert stored is not None- assert stored.metadata["created_by"] == expected- assert stored.metadata["resource_user_context"]["sub"] == "remote-editor"+ assert result == 1+ assert payload["code"] == "remote_autonomous_harness_disabled"+ assert ManagedWatchStore(store_path).list_watches() == []+ assert startup_calls == []def test_watch_add_create_per_run_scope_id_records_session_scope_metadata(tmp_path: Path, capsys) -> None:diff --git a/tests/test_instance_authorization.py b/tests/test_instance_authorization.pyindex 3c3b7841e..46b9d3110 100644--- a/tests/test_instance_authorization.py+++ b/tests/test_instance_authorization.py@@ -15,7 +15,7 @@ def _remote_context(role: str) -> AuthorizationContext:return AuthorizationContext(instance_role=role, is_remote=True)-def test_role_capabilities_are_monotonic() -> None:+def test_remote_roles_keep_management_monotonic_but_execution_disabled() -> None:viewer = AuthorizationContext(instance_role="viewer", is_remote=True)editor = AuthorizationContext(instance_role="editor", is_remote=True)owner = AuthorizationContext(instance_role="owner", is_remote=True)@@ -23,11 +23,16 @@ def test_role_capabilities_are_monotonic() -> None:assert viewer.can_read_instance is Trueassert viewer.can_chat is Falseassert editor.can_read_instance is True- assert editor.can_chat is True+ assert editor.can_chat is Falseassert editor.can_manage_projects is False+ assert owner.can_chat is Falseassert owner.can_manage_projects is Trueassert owner.can_manage_agents is True+ assert owner.can_use_terminal is False+ assert owner.can_use_files is False+ assert owner.can_use_system is Falseassert trusted_local_context().can_manage_instance is True+ assert trusted_local_context().can_chat is True@pytest.mark.parametrize(@@ -68,7 +73,7 @@ def test_context_uses_role_not_diagnostic_source_for_owner() -> None:)assert context.is_instance_owner is False- assert context.can_chat is True+ assert context.can_chat is Falseassert context.can_manage_instance is Falseassert context.authorization_revision == 0diff --git a/tests/test_internal_server.py b/tests/test_internal_server.pyindex c5f9cc3b2..832a48404 100644--- a/tests/test_internal_server.py+++ b/tests/test_internal_server.py@@ -1664,6 +1664,53 @@ def test_dispatch_async_replay_of_queued_delivery_is_idempotent(monkeypatch, tmpassert transcript == []+def test_dispatch_async_retires_remote_reservation_before_turn_start(+ monkeypatch,+ tmp_path,+):+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ engine, session = _create_test_session(+ tmp_path,+ native_id="proj_remote_dispatch_reservation",+ )+ with engine.begin() as conn:+ remote = _reserve_submission(+ conn,+ scope_id=session["scope_id"],+ session_id=session["id"],+ text="remote reserved input",+ metadata={"resource_user_context": {"sub": "remote-user"}},+ )++ controller = _build_controller_double()+ app = internal_server.create_app(controller)+ transport = httpx.ASGITransport(app=app)++ async def _go():+ async with httpx.AsyncClient(+ transport=transport,+ base_url="http://testserver",+ ) as client:+ return await client.post(+ "/internal/dispatch_async",+ json={+ "session_id": session["id"],+ "text": "remote reserved input",+ "user_message_id": remote["id"],+ },+ )++ response = asyncio.run(_go())++ assert response.status_code == 403+ assert response.json()["code"] == "remote_execution_disabled"+ controller.message_handler.handle_user_message.assert_not_awaited()+ with engine.connect() as conn:+ stored = message_deliveries.get_delivery(conn, remote["id"])+ assert stored is not None+ assert stored["state"] == "retired"++def test_dispatch_async_persists_acceptance_before_a_lost_response_replay(monkeypatch,tmp_path,@@ -5168,6 +5215,105 @@ def _manager_accepting_runs():return manager, runs+def test_flush_retires_remote_head_and_runs_later_local_delivery(+ tmp_path,+ monkeypatch,+):+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ engine, session = _create_test_session(+ tmp_path,+ native_id="proj_remote_queue_retirement",+ )+ with engine.begin() as conn:+ remote = message_deliveries.enqueue_queued(+ conn,+ scope_id=session["scope_id"],+ session_id=session["id"],+ text="remote queued input",+ metadata={"resource_user_context": {"sub": "remote-user"}},+ )+ local = message_deliveries.enqueue_queued(+ conn,+ scope_id=session["scope_id"],+ session_id=session["id"],+ text="local queued input",+ metadata={+ session_turns.MEMORY_USER_ID_METADATA: "local",+ session_turns.MEMORY_ORDINARY_TEXT_METADATA: True,+ },+ )++ manager, runs = _manager_accepting_runs()+ assert asyncio.run(manager.flush_queue(session["id"])) is True++ assert [(text, source) for text, source, _context in runs] == [+ ("local queued input", SOURCE_HUMAN)+ ]+ with engine.connect() as conn:+ remote_saved = message_deliveries.get_delivery(conn, remote["id"])+ local_saved = message_deliveries.get_delivery(conn, local["id"])+ assert remote_saved is not None+ assert remote_saved["state"] == "retired"+ assert local_saved is not None+ assert local_saved["state"] == "accepted"+++def test_claimed_remote_turn_is_terminalized_before_native_dispatch(+ tmp_path,+ monkeypatch,+):+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ engine, session = _create_test_session(+ tmp_path,+ native_id="proj_remote_claimed_turn",+ )+ turn_id = message_deliveries.new_turn_id()+ with engine.begin() as conn:+ queued = message_deliveries.enqueue_queued(+ conn,+ scope_id=session["scope_id"],+ session_id=session["id"],+ text="claimed remote input",+ metadata={"resource_user_context": {"sub": "remote-user"}},+ )+ row = message_deliveries.get_delivery(conn, queued["id"])+ assert row is not None+ message_deliveries.claim_start_batch(+ conn,+ turn_id=turn_id,+ session_id=session["id"],+ backend="claude",+ deliveries=[row],+ dispatch_text="claimed remote input",+ )++ manager = session_turns.SessionTurnManager(+ controller=types.SimpleNamespace(),+ build_context=lambda sid: MessageContext(+ user_id="U",+ channel_id="C",+ platform="avibe",+ platform_specific={"agent_session_id": sid},+ ),+ )++ async def unexpected_run(*_args, **_kwargs):+ raise AssertionError("remote-origin turn must not reach native dispatch")++ manager._run = unexpected_run+ assert asyncio.run(manager._start_persisted_turn(turn_id)) is False++ with engine.connect() as conn:+ saved_turn = message_deliveries.get_turn(conn, turn_id)+ saved_delivery = message_deliveries.get_delivery(conn, queued["id"])+ assert saved_turn is not None+ assert saved_turn["state"] == "terminal"+ assert saved_turn["terminal_outcome"] == "not_written"+ assert saved_turn["settled_by"] == "remote_execution_disabled"+ assert saved_delivery is not None+ assert saved_delivery["state"] == "retired"++def test_flush_runs_scheduled_row_as_scheduled_with_provenance(tmp_path, monkeypatch):"""A queued scheduled run flushes as its OWN SOURCE_SCHEDULED turn with itsdelivery provenance restored — not merged into a plain user turn (#84)."""diff --git a/tests/test_resource_acl_agents.py b/tests/test_resource_acl_agents.pyindex 9e4b4986f..08c68bdfd 100644--- a/tests/test_resource_acl_agents.py+++ b/tests/test_resource_acl_agents.py@@ -416,7 +416,7 @@ def test_remote_agent_request_and_selection_reject_inaccessible_agent(monkeypatcenviron_base=_remote_peer(),)assert blocked_legacy_turn.status_code == 403- assert blocked_legacy_turn.get_json()["code"] == "agent_access_forbidden"+ assert blocked_legacy_turn.get_json()["code"] == "remote_execution_disabled"assert dispatch_calls == []with engine.begin() as connection:@@ -437,10 +437,13 @@ def test_remote_agent_request_and_selection_reject_inaccessible_agent(monkeypatcenviron_base=_remote_peer(),)assert revoked_turn.status_code == 403- assert revoked_turn.get_json()["code"] == "agent_access_forbidden"+ assert revoked_turn.get_json()["code"] == "remote_execution_disabled"assert dispatch_calls == []- with pytest.raises(VibeAgentAccessError):+ with pytest.raises(+ resource_access_service.ResourceAccessError,+ match="remote_autonomous_harness_disabled",+ ):ScheduledTaskStore(tmp_path / "tasks.json").add_task(session_key="avibe::project::proj_acl_agents",prompt="run",@@ -450,7 +453,10 @@ def test_remote_agent_request_and_selection_reject_inaccessible_agent(monkeypatctimezone_name="UTC",user_context=context,)- with pytest.raises(VibeAgentAccessError):+ with pytest.raises(+ resource_access_service.ResourceAccessError,+ match="remote_autonomous_harness_disabled",+ ):ManagedWatchStore(tmp_path / "watches.json").add_watch(name="acl watch",session_key="avibe::project::proj_acl_agents",@@ -505,7 +511,10 @@ def test_remote_external_guest_cannot_create_agent(monkeypatch, tmp_path) -> Nonstore.close()-def test_remote_background_definitions_recheck_agent_acl_before_dispatch(monkeypatch, tmp_path) -> None:+def test_remote_background_definitions_are_rejected_and_legacy_rows_fail_before_dispatch(+ monkeypatch,+ tmp_path,+) -> None:monkeypatch.setenv("AVIBE_HOME", str(tmp_path))agent_store, agents = _seed_agents_with_policies()context = _organization_context("member-1")@@ -513,6 +522,43 @@ def test_remote_background_definitions_recheck_agent_acl_before_dispatch(monkeypwatch_store = ManagedWatchStore(tmp_path / "watches.json")request_store = TaskExecutionStore(tmp_path / "task_requests")try:+ with pytest.raises(+ resource_access_service.ResourceAccessError,+ match="remote_autonomous_harness_disabled",+ ):+ task_store.add_task(+ session_key="slack::channel::C123",+ prompt="run task",+ schedule_type="cron",+ agent_name=agents["public"].name,+ cron="0 * * * *",+ timezone_name="UTC",+ user_context=context,+ )+ with pytest.raises(+ resource_access_service.ResourceAccessError,+ match="remote_autonomous_harness_disabled",+ ):+ watch_store.add_watch(+ name="acl watch",+ session_key="slack::channel::C123",+ command=["true"],+ shell_command=None,+ prefix=None,+ cwd=str(tmp_path),+ mode="once",+ timeout_seconds=1,+ lifetime_timeout_seconds=0,+ retry_exit_codes=[75],+ retry_delay_seconds=1,+ post_to=None,+ deliver_key=None,+ agent_name=agents["public"].name,+ user_context=context,+ )+ assert task_store.list_tasks() == []+ assert watch_store.list_watches() == []+task = task_store.add_task(session_key="slack::channel::C123",prompt="run task",@@ -520,13 +566,14 @@ def test_remote_background_definitions_recheck_agent_acl_before_dispatch(monkeypagent_name=agents["public"].name,cron="0 * * * *",timezone_name="UTC",- metadata={- resource_access_service.RESOURCE_USER_CONTEXT_METADATA_KEY: {- "sub": "owner-1",- }- },- user_context=context,+ shell_command="touch should-not-run",)+ task.metadata = {+ resource_access_service.RESOURCE_USER_CONTEXT_METADATA_KEY: {+ "sub": "legacy-remote-user"+ }+ }+ task_store.upsert_task(task)watch = watch_store.add_watch(name="acl watch",session_key="slack::channel::C123",@@ -542,21 +589,13 @@ def test_remote_background_definitions_recheck_agent_acl_before_dispatch(monkeyppost_to=None,deliver_key=None,agent_name=agents["public"].name,- user_context=context,)- assert task.metadata[resource_access_service.RESOURCE_USER_CONTEXT_METADATA_KEY]["sub"] == "member-1"- assert watch.metadata[resource_access_service.RESOURCE_USER_CONTEXT_METADATA_KEY]["sub"] == "member-1"-- with agent_store.engine.begin() as connection:- resource_access_service.apply_control_plane_intent(- connection,- organization_id="org-1",- resource_kind="agent",- resource_id=agents["public"].id,- revision=1,- access_level="private",- group_ids=[],- )+ watch.metadata = {+ resource_access_service.RESOURCE_USER_CONTEXT_METADATA_KEY: {+ "sub": "legacy-remote-user"+ }+ }+ watch_store.upsert_watch(watch)service = ScheduledTaskService(controller=SimpleNamespace(),@@ -566,7 +605,12 @@ def test_remote_background_definitions_recheck_agent_acl_before_dispatch(monkeyptask_result = asyncio.run(service._execute_task(task, execution_id="task-run", disable_one_shot=False))- assert task_result.error == "Agent access is not permitted."+ assert task_result.error == "remote_autonomous_harness_disabled"+ stored_task = task_store.get_task(task.id)+ assert stored_task is not None+ assert stored_task.enabled is False+ assert stored_task.last_error == "remote_autonomous_harness_disabled"+ assert not (tmp_path / "should-not-run").exists()request = request_store.enqueue_hook_send(session_key=watch.session_key,@@ -584,6 +628,6 @@ def test_remote_background_definitions_recheck_agent_acl_before_dispatch(monkeypcompleted = request_store.get_run(request.id)assert completed is not Noneassert completed["status"] == "failed"- assert completed["error"] == "Agent access is not permitted."+ assert completed["error"] == "remote_autonomous_harness_disabled"finally:agent_store.close()diff --git a/tests/test_ui_remote_access_auth.py b/tests/test_ui_remote_access_auth.pyindex 86b3b121f..358e6832b 100644--- a/tests/test_ui_remote_access_auth.py+++ b/tests/test_ui_remote_access_auth.py@@ -798,7 +798,7 @@ def test_remote_session_info_includes_authenticated_subject(monkeypatch, tmp_pat"capabilities": {"is_instance_owner": True,"can_read_instance": True,- "can_chat": True,+ "can_chat": False,"can_manage_projects": True,"can_manage_agents": True,"can_manage_instance": True,@@ -806,14 +806,172 @@ def test_remote_session_info_includes_authenticated_subject(monkeypatch, tmp_pat"can_use_skills": True,"can_use_vault_secrets": True,"can_use_show_pages": True,- "can_use_terminal_files": True,- "can_use_terminal": True,- "can_use_files": True,- "can_use_system": True,+ "can_use_terminal_files": False,+ "can_use_terminal": False,+ "can_use_files": False,+ "can_use_system": False,},}+def test_remote_file_api_is_blocked_while_local_file_browsing_still_works(+ 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",+ )++ remote_response = client.get(+ "/api/files/list",+ params={"path": str(tmp_path)},+ base_url="https://alex.avibe.bot",+ environ_base=_remote_peer(),+ )+ local_response = app.test_client().get(+ "/api/files/list",+ params={"path": str(tmp_path)},+ base_url="http://localhost",+ environ_base={"REMOTE_ADDR": "127.0.0.1"},+ )++ assert remote_response.status_code == 403+ assert remote_response.get_json()["code"] == "remote_execution_disabled"+ assert local_response.status_code == 200+ assert local_response.get_json()["path"] == str(tmp_path.resolve())+++ ("method", "path", "json_body"),+ [+ ("PATCH", "/api/harness/tasks/task-1", {"enabled": False}),+ ("DELETE", "/api/harness/tasks/task-1", None),+ ("PATCH", "/api/harness/watches/watch-1", {"enabled": False}),+ ("DELETE", "/api/harness/watches/watch-1", None),+ ],+)+def test_remote_harness_mutations_are_blocked_before_store_access(+ monkeypatch,+ tmp_path,+ method,+ path,+ json_body,+):+ 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",+ )++ response = client.request(+ method,+ path,+ json=json_body,+ base_url="https://alex.avibe.bot",+ environ_base=_remote_peer(),+ )++ assert response.status_code == 403+ assert response.get_json()["code"] == "remote_execution_disabled"+++def test_remote_show_dispatch_is_rejected_before_event_reservation(+ 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",+ )+ monkeypatch.setattr(ui_server, "_is_cli_show_event_request", lambda: True)++ def unexpected_store():+ raise AssertionError("remote Show dispatch must not reserve an event")++ monkeypatch.setattr(ui_server, "_show_session_event_store", unexpected_store)+ response = client.post(+ "/api/show/sessions/ses-remote/events",+ json={+ "type": "human.intent.submitted",+ "actor": "human",+ "payload": {"intent": "choose", "dispatch": True},+ },+ headers=csrf_headers(client, "https://alex.avibe.bot"),+ base_url="https://alex.avibe.bot",+ environ_base=_remote_peer(),+ )++ assert response.status_code == 403+ assert response.get_json()["code"] == "remote_execution_disabled"+++def test_remote_owner_can_still_read_authorized_session_history(+ monkeypatch,+ tmp_path,+):+ from storage import messages_service, workbench_sessions_service+ from storage.db import create_sqlite_engine+ from storage.importer import ensure_sqlite_state+ from storage.settings_service import upsert_scope++ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ config = _save_config(tmp_path)+ ensure_sqlite_state()+ engine = create_sqlite_engine()+ with engine.begin() as conn:+ scope_id = upsert_scope(+ conn,+ platform="avibe",+ scope_type="project",+ native_id="proj_remote_history",+ now="2026-08-04T00:00:00Z",+ )+ session = workbench_sessions_service.create_session(+ conn,+ scope_id=scope_id,+ agent_backend="codex",+ agent_name="worker",+ )+ messages_service.append(+ conn,+ scope_id=scope_id,+ session_id=session["id"],+ platform="avibe",+ author="user",+ message_type="user",+ text="readable history",+ )++ client = app.test_client()+ client.set_cookie(+ remote_access.SESSION_COOKIE_NAME,+ remote_session_cookie(config, "[email protected]", "user-owner"),+ domain="alex.avibe.bot",+ )+ response = client.get(+ f"/api/sessions/{session['id']}/messages",+ base_url="https://alex.avibe.bot",+ environ_base=_remote_peer(),+ )++ assert response.status_code == 200+ assert [row["text"] for row in response.get_json()["messages"]] == [+ "readable history"+ ]++def test_remote_viewer_can_read_but_cannot_use_management_api(monkeypatch, tmp_path):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))config = _save_config(tmp_path)@@ -2514,7 +2672,7 @@ def test_terminal_websocket_rejects_remote_same_host_different_origin(monkeypatc@pytest.mark.skipif(not ui_server.TERMINAL_SUPPORTED, reason="terminal requires a POSIX pty")@pytest.mark.parametrize("origin", ["https://alex.avibe.bot", "https://alex.avibe.bot:443"])-def test_terminal_websocket_accepts_remote_exact_trusted_origin(monkeypatch, tmp_path, origin):+def test_terminal_websocket_rejects_remote_exact_trusted_origin(monkeypatch, tmp_path, origin):monkeypatch.setenv("VIBE_UI_ENABLE_TERMINAL", "1")monkeypatch.setenv("AVIBE_HOME", str(tmp_path))config = _save_config(tmp_path)@@ -2532,17 +2690,19 @@ def test_terminal_websocket_accepts_remote_exact_trusted_origin(monkeypatch, tmpdomain="alex.avibe.bot",)- with client.websocket_connect(- "wss://alex.avibe.bot/api/terminal/test",- headers={- "host": "alex.avibe.bot",- "origin": origin,- "x-forwarded-for": "203.0.113.10",- },- ):- pass+ with pytest.raises(WebSocketDisconnect) as exc:+ with client.websocket_connect(+ "wss://alex.avibe.bot/api/terminal/test",+ headers={+ "host": "alex.avibe.bot",+ "origin": origin,+ "x-forwarded-for": "203.0.113.10",+ },+ ):+ pass- assert accepted is True+ assert exc.value.code == 1008+ assert accepted is False@pytest.mark.skipif(not ui_server.TERMINAL_SUPPORTED, reason="terminal requires a POSIX pty")@@ -2578,7 +2738,7 @@ def test_terminal_websocket_rejects_remote_viewer(monkeypatch, tmp_path):@pytest.mark.skipif(not ui_server.TERMINAL_SUPPORTED, reason="terminal requires a POSIX pty")-def test_terminal_websocket_accepts_active_custom_hostname(monkeypatch, tmp_path):+def test_terminal_websocket_rejects_remote_active_custom_hostname(monkeypatch, tmp_path):monkeypatch.setenv("VIBE_UI_ENABLE_TERMINAL", "1")monkeypatch.setenv("AVIBE_HOME", str(tmp_path))config = _save_config(tmp_path)@@ -2602,17 +2762,19 @@ def test_terminal_websocket_accepts_active_custom_hostname(monkeypatch, tmp_pathdomain="max.fileguard.io",)- with client.websocket_connect(- "wss://max.fileguard.io/api/terminal/test",- headers={- "host": "max.fileguard.io",- "origin": "https://max.fileguard.io",- "x-forwarded-for": "203.0.113.10",- },- ):- pass+ with pytest.raises(WebSocketDisconnect) as exc:+ with client.websocket_connect(+ "wss://max.fileguard.io/api/terminal/test",+ headers={+ "host": "max.fileguard.io",+ "origin": "https://max.fileguard.io",+ "x-forwarded-for": "203.0.113.10",+ },+ ):+ pass- assert accepted is True+ assert exc.value.code == 1008+ assert accepted is Falsedef test_terminal_effective_session_id_scopes_remote_subjects():@@ -2629,7 +2791,7 @@ def test_terminal_effective_session_id_scopes_remote_subjects():@pytest.mark.skipif(not ui_server.TERMINAL_SUPPORTED, reason="terminal requires a POSIX pty")-def test_terminal_websocket_scopes_remote_session_id_by_authenticated_subject(monkeypatch, tmp_path):+def test_terminal_websocket_never_starts_a_remote_subject_session(monkeypatch, tmp_path):monkeypatch.setenv("VIBE_UI_ENABLE_TERMINAL", "1")monkeypatch.setenv("AVIBE_HOME", str(tmp_path))config = _save_config(tmp_path)@@ -2647,23 +2809,23 @@ def test_terminal_websocket_scopes_remote_session_id_by_authenticated_subject(moremote_session_cookie(config, f"{subject}@example.com", subject),domain="alex.avibe.bot",)- with client.websocket_connect(- "wss://alex.avibe.bot/api/terminal/shared-session",- headers={- "host": "alex.avibe.bot",- "origin": "https://alex.avibe.bot",- "x-forwarded-for": "203.0.113.10",- },- ):- pass+ with pytest.raises(WebSocketDisconnect) as exc:+ with client.websocket_connect(+ "wss://alex.avibe.bot/api/terminal/shared-session",+ headers={+ "host": "alex.avibe.bot",+ "origin": "https://alex.avibe.bot",+ "x-forwarded-for": "203.0.113.10",+ },+ ):+ pass+ assert exc.value.code == 1008connect_as("user-1")connect_as("user-1")connect_as("user-2")- assert handled_session_ids[0] == handled_session_ids[1]- assert handled_session_ids[0] != handled_session_ids[2]- assert all(session_id.endswith("-shared-session") for session_id in handled_session_ids)+ assert handled_session_ids == []@pytest.mark.skipif(not ui_server.TERMINAL_SUPPORTED, reason="terminal requires a POSIX pty")diff --git a/tests/test_watches.py b/tests/test_watches.pyindex 87e3b5eb3..79a0966e9 100644--- a/tests/test_watches.py+++ b/tests/test_watches.py@@ -215,6 +215,47 @@ def test_managed_watch_store_recovery_accepts_empty_command_arguments(tmp_path:assert recovered[0].command == [sys.executable, "wait.py", ""]+def test_remote_origin_watch_is_disabled_before_waiter_spawn(tmp_path: Path) -> None:+ store = ManagedWatchStore(tmp_path / "watches.json")+ watch = store.add_watch(+ name="Legacy remote watch",+ session_key="slack::channel::C123",+ command=[sys.executable, "-c", "raise AssertionError('must not run')"],+ shell_command=None,+ prefix=None,+ cwd=str(tmp_path),+ mode="once",+ timeout_seconds=5,+ lifetime_timeout_seconds=0,+ retry_exit_codes=[75],+ retry_delay_seconds=30,+ post_to=None,+ deliver_key=None,+ )+ watch.metadata = {"resource_user_context": {"sub": "legacy-remote-user"}}+ store.upsert_watch(watch)+ service = ManagedWatchService(+ controller=SimpleNamespace(),+ store=store,+ request_store=TaskExecutionStore(tmp_path / "task_requests"),+ runtime_store=WatchRuntimeStateStore(tmp_path / "watch_runtime.json"),+ )+ service._running = True+ service._requires_service_lease = False++ async def unexpected_run_cycle(*_args, **_kwargs):+ raise AssertionError("remote-origin waiter must not spawn")++ service._run_cycle = unexpected_run_cycle # type: ignore[method-assign]+ asyncio.run(service._run_watch(watch.id))++ saved = store.get_watch(watch.id)+ assert saved is not None+ assert saved.enabled is False+ assert saved.last_started_at is None+ assert saved.last_error == "remote_autonomous_harness_disabled"++def test_managed_watch_exec_uses_stable_supervisor(tmp_path: Path, monkeypatch) -> None:captured: dict[str, object] = {}store = ManagedWatchStore(tmp_path / "watches.json")diff --git a/ui/src/i18n/en.json b/ui/src/i18n/en.jsonindex a4e1cf40b..f20151768 100644--- a/ui/src/i18n/en.json+++ b/ui/src/i18n/en.json@@ -1209,7 +1209,8 @@"memory_runtime_manifest_unavailable": "The memory runtime manifest couldn't be downloaded.","memory_runtime_archive_unavailable": "The memory runtime download isn't available right now.","session_agent_unavailable": "The source session's Agent is no longer available. Choose an enabled Agent to fork this session.",- "reserved_session": "Avibe owns this session — it only receives workspace notifications."+ "reserved_session": "Avibe owns this session — it only receives workspace notifications.",+ "remote_execution_disabled": "Remote access is read-only for Agent, Harness, terminal, and file execution in this release. Open Avibe on the machine to run this action."},"apps": {"title": "Apps",diff --git a/ui/src/i18n/zh.json b/ui/src/i18n/zh.jsonindex 9272feaa1..577301a09 100644--- a/ui/src/i18n/zh.json+++ b/ui/src/i18n/zh.json@@ -1209,7 +1209,8 @@"memory_runtime_manifest_unavailable": "无法下载记忆运行时的清单。","memory_runtime_archive_unavailable": "记忆运行时的下载包当前不可用。","session_agent_unavailable": "源会话的 Agent 已不可用。请选择一个已启用的 Agent 来复刻此会话。",- "reserved_session": "该会话由 Avibe 管理,只接收工作区通知。"+ "reserved_session": "该会话由 Avibe 管理,只接收工作区通知。",+ "remote_execution_disabled": "当前版本的远程访问仅支持查看,不能执行 Agent、Harness、终端或文件操作。请在运行 Avibe 的机器上执行此操作。"},"apps": {"title": "应用",diff --git a/vibe/authorization.py b/vibe/authorization.pyindex 927de9251..8acee191d 100644--- a/vibe/authorization.py+++ b/vibe/authorization.py@@ -77,7 +77,7 @@ class AuthorizationContext:@propertydef can_chat(self) -> bool:- return self.has_role("editor")+ return not self.is_remote and self.has_role("editor")@propertydef can_manage_projects(self) -> bool:@@ -104,19 +104,19 @@ class AuthorizationContext:@propertydef can_use_terminal_files(self) -> bool:- return self.has_role("owner")+ return not self.is_remote and self.has_role("owner")@propertydef can_use_terminal(self) -> bool:- return self.has_role("owner")+ return not self.is_remote and self.has_role("owner")@propertydef can_use_files(self) -> bool:- return self.has_role("owner")+ return not self.is_remote and self.has_role("owner")@propertydef can_use_system(self) -> bool:- return self.has_role("owner")+ return not self.is_remote and self.has_role("owner")def capability_projection(self) -> dict[str, bool]:return {diff --git a/vibe/cli.py b/vibe/cli.pyindex 77bf7cd7f..6849775b1 100644--- a/vibe/cli.py+++ b/vibe/cli.py@@ -273,6 +273,25 @@ def _print_task_error(exc: Exception, *, help_command: str | None = None) -> Non# payload builder below.if isinstance(exc, UnresolvableSessionTarget) and exc.reason == "reserved":exc = _reserved_session_cli_error(exc)+ from storage.resource_access_service import (+ REMOTE_AUTONOMOUS_HARNESS_DISABLED_CODE,+ ResourceAccessError,+ )++ if (+ isinstance(exc, ResourceAccessError)+ and exc.code == REMOTE_AUTONOMOUS_HARNESS_DISABLED_CODE+ ):+ try:+ lang = V2Config.load().language+ except Exception:+ lang = "en"+ exc = TaskCliError(+ str(exc),+ code=exc.code,+ hint=i18n_t("harness.notice.remoteExecutionDisabled", lang),+ help_command=help_command,+ )if isinstance(exc, TaskCliError):payload = {"schema_version": 1,diff --git a/vibe/i18n/en.json b/vibe/i18n/en.jsonindex ae56c777c..2e846d1dc 100644--- a/vibe/i18n/en.json+++ b/vibe/i18n/en.json@@ -97,6 +97,7 @@"workspaceSession": "Workspace notifications","workspaceSessionProtected": "This session receives Avibe's workspace failure notifications and cannot be archived or modified.","workspaceSessionReadOnly": "This session only receives Avibe's workspace failure notifications — it does not accept messages.",+ "remoteExecutionDisabled": "Remote access is read-only for Agent, Harness, terminal, and file execution in this release. Open Avibe on the machine to run this action.","failureClass": "Failure class: {failureClass}","lastSucceeded": "Last succeeded: {when}","origin": "Created in: {origin}",diff --git a/vibe/i18n/zh.json b/vibe/i18n/zh.jsonindex d48ec41ff..354b43cca 100644--- a/vibe/i18n/zh.json+++ b/vibe/i18n/zh.json@@ -97,6 +97,7 @@"workspaceSession": "工作区通知","workspaceSessionProtected": "该会话用于接收 Avibe 的工作区失败通知,无法归档或修改。","workspaceSessionReadOnly": "该会话只接收 Avibe 的工作区失败通知,不接受发送消息。",+ "remoteExecutionDisabled": "当前版本的远程访问仅支持查看,不能执行 Agent、Harness、终端或文件操作。请在运行 Avibe 的机器上执行此操作。","failureClass": "失败类型:{failureClass}","lastSucceeded": "上次成功时间:{when}","origin": "创建位置:{origin}",diff --git a/vibe/ui_server.py b/vibe/ui_server.pyindex ac4aba73c..51efeb0cd 100644--- a/vibe/ui_server.py+++ b/vibe/ui_server.py@@ -2233,6 +2233,40 @@ def enforce_instance_role_capabilities():return None+def _is_remote_local_execution_request(method: str, path: str) -> bool:+ normalized_method = method.upper()+ if path.startswith(("/api/files/", "/api/browse")):+ return True+ if path.startswith("/api/terminal/"):+ return True+ if path.startswith("/api/harness/") and normalized_method not in {+ "GET",+ "HEAD",+ "OPTIONS",+ }:+ return True+ return normalized_method == "POST" and bool(+ re.fullmatch(+ r"/api/sessions/[^/]+/(?:messages|attachments|queue/[^/]+/send-now)",+ path,+ )+ )++[email protected]_request+def enforce_remote_local_execution_boundary():+ """Keep shell-capable Workbench surfaces on the trusted-local origin."""++ context = getattr(g, "authorization_context", None)+ if (+ context is None+ or not context.is_remote+ or not _is_remote_local_execution_request(request.method, request.path)+ ):+ return None+ return _remote_execution_disabled_response()++_PROJECT_RESOURCE_PATHS = (("project", re.compile(r"^/api/projects/([^/]+)(?:/agents-md)?$")),("session", re.compile(r"^/api/sessions/([^/]+)(?:/.*)?$")),@@ -2746,12 +2780,15 @@ async def terminal_websocket(websocket: WebSocket, session_id: str):await websocket.close(code=1008)return- await websocket.accept()config = _load_remote_access_config()remote_payload = _remote_access_websocket_session_claims(websocket, config)if remote_payload is None and not _websocket_is_local_request(websocket, config):await websocket.close(code=_AUTHORIZATION_REFRESH_WEBSOCKET_CLOSE_CODE)return+ if remote_payload is not None:+ await websocket.close(code=1008)+ return+ await websocket.accept()remote_addr = _websocket_client_host(websocket) or "unknown"remote_subject = Noneauthorization_refresh_at = None@@ -8039,6 +8076,7 @@ RESERVED_SESSION_PROTECTED_I18N_KEY = "harness.notice.workspaceSessionProtected"#: is not an answer to "why did my message not send", and the composer's own inert-state#: notice has to say the same thing this body says.RESERVED_SESSION_READ_ONLY_I18N_KEY = "harness.notice.workspaceSessionReadOnly"+REMOTE_EXECUTION_DISABLED_I18N_KEY = "harness.notice.remoteExecutionDisabled"def _reserved_session_response(i18n_key: str, *, code: str = "reserved_session"):@@ -8061,6 +8099,17 @@ def _reserved_session_response(i18n_key: str, *, code: str = "reserved_session")return _coded_error_response(code, t(i18n_key, lang), 403)+def _remote_execution_disabled_response():+ from core.services import settings as settings_service++ lang = settings_service.load_config_or_default().language+ return _coded_error_response(+ "remote_execution_disabled",+ t(REMOTE_EXECUTION_DISABLED_I18N_KEY, lang),+ 403,+ )++def _backend_locked_response(err):"""Shared 409 payload for a rejected cross-backend session change.@@ -11313,6 +11362,13 @@ async def _show_event_response_from_payload(public_share_id: str | None = None,allow_dispatch: bool = True,):+ context = getattr(g, "authorization_context", None)+ if (+ context is not None+ and context.is_remote+ and show_event_requests_dispatch(payload)+ ):+ return _remote_execution_disabled_response()if show_event_payload_session_mismatch(session_id, payload):return (jsonify(