Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(auth): stop member Agents page load from calling owner-only routes (#1623)
Max762e932df611
diff --git a/docs/plans/instance-access-role-member.md b/docs/plans/instance-access-role-member.mdindex 4030eea95..f39738f1c 100644--- a/docs/plans/instance-access-role-member.md+++ b/docs/plans/instance-access-role-member.md@@ -226,3 +226,72 @@ The remote-Owner task/watch write fallback can still admit a missing legacy name### Current-master default semanticsThe original follow-up brief referenced the pre-PR-#1606 audience-wide assignment predicate. PR #1606 had already replaced that model on `master`: an instance default is advisory, and ACL enforcement occurs per principal when the default is resolved. This alignment deliberately preserves #1606. A member may assign a private or scope-policy Agent as the default; a principal who cannot use it degrades to another usable Agent without changing the configured default or widening the target ACL.++## Addendum: Agents page load 403s (2026-08-21, post-#1621)++### Divergence found++After #1621 aligned the Agent ACL layer, a remote member opening `/agents` still+got two `instance_access_forbidden` toasts. Mutation worked; the *page load*+fired two Owner-only GETs. Both are capability/HTTP mismatches, not ACL gaps:++1. `AgentsPage.refreshOnboarding` was gated on `can_manage_agents`. #1621 made+ that bit true for `member`, so the page began requesting+ `GET /api/agent-onboarding` — a route deliberately kept Owner-only because+ bulk onboarding is a one-way instance-wide migration. The handler's `catch`+ swallowed the throw, but `ApiContext.handleApiError` had already toasted.+2. The Agents detail panel auto-selects the default Agent on first load and+ loads that backend's model catalog: `GET /api/claude/models`,+ `GET /api/codex/models`, or `GET /api/backend/opencode/providers`. None was+ named by any policy table, so all three fell to the Owner default-deny.++### Decisions++1. Onboarding UI keys off `is_instance_owner`, not `can_manage_agents`. The+ route stays Owner (addendum above, `_require_agent_onboarding_access`); the+ UI now matches it, so the banner simply never loads for a member and cannot+ 403. The member keeps New Agent, Import, Global prompts, edit, and default —+ all already member-tier.+2. The Claude and Codex model catalogs are editor-tier, added to+ `_EDITOR_HTTP_RULES` as exact GET rules. Editor rather than member because+ Chat's `AgentRoutePicker` shares the same loader and is an editor surface;+ member inherits editor by rank. Deliberately **not** an `/api/backend`+ namespace: the rest of that namespace is credential and host work —+ `*/auth*`, custom-provider writes, CLI install, runtime restart — and keeps+ Owner by the unknown-route default. Both are `backend_model_snapshot` reads+ of a shared catalog: no provider configuration in the body, no backend+ contact on the request.+3. **OpenCode gets no editor-tier catalog, and the picker degrades instead.**+ `GET /api/backend/opencode/providers` stays Owner. It is not separable from+ the Settings surface in either direction: its rows carry provider base URLs,+ masked API-key previews, the active auth type, and the instance tool-call+ permission setting, and serving it runs `_opencode_get_server()` →+ `ensure_running()`, which installs the caller-context plugin, may restart or+ terminate the running daemon, and starts one if none is up.++ Two alternatives were tried and rejected. A `{id, name, models}` projection+ over the same call removes the disclosure but keeps the host-lifecycle+ effect. Probing health first does not help either: `get_providers()` and its+ siblings each call `ensure_running()` themselves.++ So the model picker reads the Owner-only endpoint best-effort, through+ `readOpencodeProvidersForModelPicker`, which declares+ `instance_access_forbidden` an expected code. A lower rank gets no OpenCode+ suggestions and types the model id — what it already did before the member+ rank existed, minus the toast. `getOpencodeProviders` keeps its loud 403 for+ Settings, where a refusal is a genuine incident.++ **Follow-up (not this change):** give OpenCode a daemon-free catalog snapshot+ the way Claude and Codex have one. `vibe/backend_model_catalog.py` supports+ only those two today, and `vibe/data/backend_models.json` carries no OpenCode+ entries, so there is nothing to serve without the daemon. Once a snapshot+ exists, the picker reads it at editor tier and the degradation above goes+ away.++### Rule this leaves behind++A capability bit is the UI's permission to *render* a surface; the HTTP policy+is what may be *called*. When a rank gains a capability, every request the+surface issues on load has to be re-checked against the policy tables, including+the shared read-only lookups a page pulls in indirectly. A UI gate that is+merely close to the route's tier produces a toast on every page load.diff --git a/tests/test_instance_authorization.py b/tests/test_instance_authorization.pyindex 5dcbb1179..11792f310 100644--- a/tests/test_instance_authorization.py+++ b/tests/test_instance_authorization.py@@ -308,6 +308,10 @@ def test_advertised_capability_namespaces_cover_current_and_future_routes() -> N# The Web UI's ShowPageShareControl reads the page it can mutate;# editors must keep GET access (regression: PR #1606 round 1).("GET", "/api/show-pages/session-1"),+ # Read-only model catalogs behind Chat's route picker and the Agents+ # detail panel. Editor-tier because the picker is an editor surface.+ ("GET", "/api/claude/models"),+ ("GET", "/api/codex/models"),)for method, path in editor_examples:assert http_authorization_policy(method, path).minimum_role == "editor", path@@ -358,7 +362,22 @@ def test_advertised_capability_namespaces_cover_current_and_future_routes() -> N("POST", "/api/control"),("POST", "/api/upgrade"),("POST", "/api/logs"),+ # Classifying the read-only catalogs above does not widen /api/backend:+ # credential, custom-provider, install, and runtime routes keep Owner by+ # the unknown-route default. That includes OpenCode's provider catalog --+ # it is the Settings surface (base URLs, masked keys, active auth type,+ # tool-call permission state) and reading it starts the daemon, so unlike+ # the Claude and Codex snapshots it is not a catalog a lower rank may+ # read. The model picker treats its 403 as "no catalog".+ ("GET", "/api/backend/opencode/providers"),("POST", "/api/backend/codex/auth"),+ ("POST", "/api/backend/claude/auth"),+ ("POST", "/api/backend/opencode/auth"),+ ("DELETE", "/api/backend/opencode/auth/anthropic"),+ ("POST", "/api/backend/opencode/providers"),+ ("POST", "/api/backend/opencode/future-mutation"),+ ("POST", "/api/claude/models/refresh"),+ ("POST", "/api/codex/future-mutation"),# Access administration and bearer credentials.("PUT", "/api/permissions/authorized-users"),("GET", "/api/users/bind-codes"),@@ -445,6 +464,65 @@ def test_member_reachable_routes_are_bounded_by_declaration() -> None:assert synthetic.minimum_role == "owner", method+def test_agents_page_load_reads_are_admitted_for_every_rank_that_sees_the_page() -> None:+ """The GETs one Agents-page load issues must be admitted by the ranks it renders for.++ A remote member landing on ``/agents`` got two ``instance_access_forbidden``+ toasts after the Agent ACL fix: the page's own reads were reachable, but the+ onboarding inventory was requested off ``can_manage_agents`` (a member bit)+ while the route is deliberately Owner, and the backend model catalogs the+ detail panel loads were classified by nobody and so fell to the Owner+ default. The property is stated over the ranks rather than over a list of+ fixed cases: whoever can reach the surface can complete its load. Chat's+ route picker shares the catalog loader and is an editor surface, so editor is+ the floor for the catalogs; the rest of the page is member management.++ OpenCode is the exception the test also pins. It has no catalog separable+ from its Settings surface, so its read stays Owner and the picker degrades to+ a typed model id -- silently, because the loader declares that refusal+ expected. "Completes its load" therefore means "issues no request whose 403+ the user is told about", not "every backend answers".+ """++ page_load_reads = (+ ("GET", "/api/agents"),+ ("GET", "/api/agents/demo"),+ ("GET", "/api/running-agents"),+ ("GET", "/api/models/agents"),+ )+ catalog_reads = (+ ("GET", "/api/claude/models"),+ ("GET", "/api/codex/models"),+ )++ for role in ("editor", "member", "owner"):+ context = _context(role, remote=True)+ for method, path in catalog_reads:+ minimum_role = http_authorization_policy(method, path).minimum_role+ assert minimum_role is not None and context.has_role(minimum_role), f"{role} {path}"++ for role in ("member", "owner"):+ context = _context(role, remote=True)+ for method, path in (*page_load_reads, *catalog_reads):+ minimum_role = http_authorization_policy(method, path).minimum_role+ assert minimum_role is not None and context.has_role(minimum_role), f"{role} {path}"++ # The counterparts a member page load must not announce. Bulk onboarding is a+ # one-way instance-wide migration and must not be requested at all; the+ # OpenCode provider catalog may be requested but its refusal is expected data+ # for the picker. Both stay Owner, so a toast from either is a UI defect+ # rather than a policy gap.+ owner_only_page_neighbours = (+ ("GET", "/api/agent-onboarding"),+ ("POST", "/api/agent-onboarding"),+ ("GET", "/api/backend/opencode/providers"),+ )+ for method, path in owner_only_page_neighbours:+ minimum_role = http_authorization_policy(method, path).minimum_role+ assert minimum_role == "owner", path+ assert not _context("member", remote=True).has_role(minimum_role), path++def test_workbench_events_follow_role_boundaries() -> None:viewer = _context("viewer", remote=True)editor = _context("editor", remote=True)diff --git a/ui/src/components/workbench/AgentsPage.test.tsx b/ui/src/components/workbench/AgentsPage.test.tsxnew file mode 100644index 000000000..93c6fc5c9--- /dev/null+++ b/ui/src/components/workbench/AgentsPage.test.tsx@@ -0,0 +1,132 @@+/* @vitest-environment jsdom */++import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';+import { cleanup, render, waitFor } from '@testing-library/react';+import { MemoryRouter } from 'react-router-dom';++import { InstanceAuthorizationContext } from '../../context/InstanceAuthorizationContext';+import type { InstanceCapabilities, InstanceRole } from '../../lib/sessionInfo';+import { OWNER_INSTANCE_CAPABILITIES } from '../../lib/sessionInfo';+import { AgentsPage } from './AgentsPage';++const api = vi.hoisted(() => ({+ listVibeAgents: vi.fn(),+ getVibeAgent: vi.fn(),+ getVibeAgentOnboarding: vi.fn(),+ getRunningAgents: vi.fn(),+ connectWorkbenchEvents: vi.fn(),+}));++vi.mock('react-i18next', () => ({+ useTranslation: () => ({ t: (key: string) => key }),+}));++vi.mock('../../context/ApiContext', async (importOriginal) => ({+ ...(await importOriginal<typeof import('../../context/ApiContext')>()),+ useApi: () => api,+}));++vi.mock('../../context/ToastContext', () => ({+ useToast: () => ({ showToast: vi.fn() }),+}));++// The detail panel's model catalog is an HTTP read of its own; serve it locally+// so this file is about which requests the page load issues, not about the+// catalog's contents.+vi.mock('../../lib/backendModels', async (importOriginal) => ({+ ...(await importOriginal<typeof import('../../lib/backendModels')>()),+ loadBackendModelsWithRefresh: (+ _api: unknown,+ _backend: string,+ onLoaded: (payload: { models: string[] }) => void,+ ) => {+ onLoaded({ models: [] });+ return () => {};+ },+}));++vi.mock('./AgentGraphTab', () => ({ AgentGraphTab: () => null }));+vi.mock('./NewAgentDialog', () => ({ NewAgentDialog: () => null }));+vi.mock('./RunAgentDialog', () => ({ RunAgentDialog: () => null }));+vi.mock('./GlobalPromptsDialog', () => ({ GlobalPromptsDialog: () => null }));++const AGENT = {+ id: 'agt-claude',+ name: 'claude',+ display_name: 'claude',+ description: null,+ backend: 'claude',+ model: 'sonnet',+ reasoning_effort: null,+ enabled: true,+ archived: false,+ archived_at: null,+ source: 'builtin',+ updated_at: '2026-08-19T00:00:00Z',+};++// A remote Instance Member: the rank keeps Agent CRUD (`can_manage_agents`) but+// is not the Instance Owner. Bulk onboarding is Owner-only on the HTTP policy,+// so this is exactly the projection that used to 403 on page load.+const MEMBER_CAPABILITIES: InstanceCapabilities = {+ ...OWNER_INSTANCE_CAPABILITIES,+ is_instance_owner: false,+ can_manage_instance: false,+ can_manage_access_members: false,+};++function renderPage(instanceRole: InstanceRole, capabilities: InstanceCapabilities) {+ return render(+ <InstanceAuthorizationContext.Provider+ value={{ remote: true, instanceKind: 'organization', instanceRole, capabilities }}+ >+ <MemoryRouter initialEntries={['/agents']}>+ <AgentsPage />+ </MemoryRouter>+ </InstanceAuthorizationContext.Provider>,+ );+}++// jsdom has no layout, so the capability tab strip's scroll-into-view is a+// no-op here; the page itself stays real.+const originalScrollIntoView = Element.prototype.scrollIntoView;++beforeEach(() => {+ Element.prototype.scrollIntoView = vi.fn();+ api.listVibeAgents.mockReset();+ api.listVibeAgents.mockResolvedValue({ ok: true, agents: [AGENT], default_agent_name: 'claude' });+ api.getVibeAgent.mockReset();+ api.getVibeAgent.mockResolvedValue({ ok: true, agent: AGENT });+ api.getVibeAgentOnboarding.mockReset();+ api.getVibeAgentOnboarding.mockResolvedValue({ available: false });+ api.getRunningAgents.mockReset();+ api.getRunningAgents.mockResolvedValue({ ok: true, counts: { total: 0 } });+ api.connectWorkbenchEvents.mockReset();+ api.connectWorkbenchEvents.mockReturnValue(() => {});+});++afterEach(() => {+ cleanup();+ vi.clearAllMocks();+ Element.prototype.scrollIntoView = originalScrollIntoView;+});++describe('AgentsPage load requests follow the rank that can serve them', () => {+ it('does not request the Owner-only onboarding inventory for a member', async () => {+ const view = renderPage('member', MEMBER_CAPABILITIES);++ // Wait on a request the member IS entitled to, so the assertion below runs+ // after the page load has actually settled rather than before it starts.+ await waitFor(() => expect(api.listVibeAgents).toHaveBeenCalled());+ await waitFor(() => expect(api.getVibeAgent).toHaveBeenCalled());+ expect(api.getVibeAgentOnboarding).not.toHaveBeenCalled();+ view.unmount();+ });++ it('still requests the onboarding inventory for the instance owner', async () => {+ const view = renderPage('owner', OWNER_INSTANCE_CAPABILITIES);++ await waitFor(() => expect(api.getVibeAgentOnboarding).toHaveBeenCalled());+ view.unmount();+ });+});diff --git a/ui/src/components/workbench/AgentsPage.tsx b/ui/src/components/workbench/AgentsPage.tsxindex 6a62f8c06..eaec30f93 100644--- a/ui/src/components/workbench/AgentsPage.tsx+++ b/ui/src/components/workbench/AgentsPage.tsx@@ -123,9 +123,14 @@ export const AgentsPage: React.FC = () => {const visibleTabs = capabilities.can_use_agents ? AGENTS_TAB_ORDER : (['definitions'] as const);const activeTab = capabilities.can_use_agents ? agentsTab : 'definitions';const canEditAgents = capabilities.can_manage_agents;+ // Bulk Agent onboarding is a one-way instance-wide migration and stays Owner+ // on the HTTP policy, so it follows owner identity rather than the Agent-CRUD+ // capability a member also has: keying the fetch off `can_manage_agents` sent+ // a member's page load into an owner-only GET and surfaced the 403 as a toast.+ const canOnboardAgents = capabilities.is_instance_owner;const refreshOnboarding = useCallback(async () => {- if (!capabilities.can_manage_agents) {+ if (!canOnboardAgents) {setOnboardingInventory(null);return;}@@ -135,7 +140,7 @@ export const AgentsPage: React.FC = () => {} catch {setOnboardingInventory(null);}- }, [api, capabilities.can_manage_agents]);+ }, [api, canOnboardAgents]);const refresh = useCallback(async () => {setLoading(true);@@ -492,7 +497,7 @@ export const AgentsPage: React.FC = () => {{/* The run graph follows the Agent capability. */}{capabilities.can_use_agents && activeTab === 'running' && <AgentGraphTab />}- {activeTab === 'definitions' && onboardingInventory && (+ {activeTab === 'definitions' && canOnboardAgents && onboardingInventory && (<OrganizationAgentOnboardinginventory={onboardingInventory}expanded={onboardingExpanded}diff --git a/ui/src/context/ApiContext.tsx b/ui/src/context/ApiContext.tsxindex 3e3b454ab..4940367a6 100644--- a/ui/src/context/ApiContext.tsx+++ b/ui/src/context/ApiContext.tsx@@ -632,6 +632,7 @@ export type ApiContextType = {options?: { model?: string },) => Promise<BackendAuthTestResult>;getOpencodeProviders: () => Promise<OpencodeProviderListResult>;+ readOpencodeProvidersForModelPicker: () => Promise<OpencodeProviderListResult>;saveOpencodeCustomProvider: (payload: OpencodeCustomProviderPayload,) => Promise<OpencodeMutationResult>;@@ -3796,6 +3797,20 @@ export const ApiProvider: React.FC<{ children: React.ReactNode }> = ({ children...(options?.model ? { model: options.model } : {}),}),getOpencodeProviders: () => getJson('/api/backend/opencode/providers'),+ // The same endpoint, read by the model pickers instead of by Settings, where+ // a refusal is an answer rather than an incident. OpenCode's only catalog is+ // this Settings one — it carries provider base URLs, masked keys, and auth+ // state, and reaching it starts the daemon — so it stays Owner-only while the+ // pickers render for every rank that may configure an Agent. Those ranks get+ // no OpenCode suggestions and type the model id, which is what they already+ // did before the member rank existed; announcing that as an error would put a+ // toast on a page load the user did nothing wrong on. Declared here rather+ // than at the three call sites so one of them cannot forget it, and kept off+ // ``getOpencodeProviders`` so Settings still reports its own 403 loudly.+ readOpencodeProvidersForModelPicker: () =>+ getJson('/api/backend/opencode/providers', {+ expectedCodes: ['instance_access_forbidden'],+ }),saveOpencodeCustomProvider: (payload) =>postJson('/api/backend/opencode/custom-provider', payload),deleteOpencodeCustomProvider: (providerId) =>diff --git a/ui/src/lib/backendModels.test.ts b/ui/src/lib/backendModels.test.tsindex 262440b53..d0e0c380c 100644--- a/ui/src/lib/backendModels.test.ts+++ b/ui/src/lib/backendModels.test.ts@@ -1,7 +1,51 @@import { afterEach, describe, expect, it, vi } from 'vitest';-import type { ApiContextType } from '../context/ApiContext';-import { loadBackendModelsWithRefresh } from './backendModels';+import { ApiError, type ApiContextType } from '../context/ApiContext';+import { fetchBackendModels, loadBackendModelsWithRefresh } from './backendModels';++describe('fetchBackendModels for OpenCode', () => {+ it('reads the provider catalog through the picker helper, never the Settings one', async () => {+ const readOpencodeProvidersForModelPicker = vi.fn().mockResolvedValue({+ ok: true,+ providers: [+ { id: 'openrouter', configured: true, models: ['anthropic/claude-x'] },+ { id: 'openai', configured: false, models: ['gpt-5'] },+ ],+ });+ const getOpencodeProviders = vi.fn();+ const api = {+ readOpencodeProvidersForModelPicker,+ getOpencodeProviders,+ } as unknown as ApiContextType;++ const result = await fetchBackendModels(api, 'opencode');++ // Settings owns the toast-on-403 read; the picker must not borrow it, or a+ // member's page load announces a refusal it is expected to absorb.+ expect(getOpencodeProviders).not.toHaveBeenCalled();+ expect(result.models).toEqual(['openrouter/anthropic/claude-x']);+ });++ it('degrades to an empty catalog when the rank may not read the Settings endpoint', async () => {+ const api = {+ readOpencodeProvidersForModelPicker: vi+ .fn()+ .mockRejectedValue(new ApiError('forbidden', 403, 'instance_access_forbidden')),+ } as unknown as ApiContextType;++ await expect(fetchBackendModels(api, 'opencode')).resolves.toEqual({ models: [] });+ });++ it('still propagates a failure that is not the expected refusal', async () => {+ const api = {+ readOpencodeProvidersForModelPicker: vi+ .fn()+ .mockRejectedValue(new ApiError('boom', 500, null)),+ } as unknown as ApiContextType;++ await expect(fetchBackendModels(api, 'opencode')).rejects.toBeInstanceOf(ApiError);+ });+});describe('loadBackendModelsWithRefresh', () => {afterEach(() => {diff --git a/ui/src/lib/backendModels.ts b/ui/src/lib/backendModels.tsindex 184d87e42..9982e381b 100644--- a/ui/src/lib/backendModels.ts+++ b/ui/src/lib/backendModels.ts@@ -1,4 +1,4 @@-import type { ApiContextType } from '../context/ApiContext';+import { ApiError, type ApiContextType } from '../context/ApiContext';export interface BackendModels {/** Selectable model identifiers for the backend. */@@ -54,7 +54,16 @@ export async function fetchBackendModels(};}if (backend === 'opencode') {- const res = await api.getOpencodeProviders();+ // Best-effort: OpenCode's catalog lives behind the Owner-only Settings+ // endpoint, so a rank that may configure an Agent but not the instance gets+ // no suggestions and types the model id. ``allowCustomValue`` on every+ // caller's Combobox is what makes that a degraded list rather than a dead+ // field. See ``readOpencodeProvidersForModelPicker``.+ const res = await api.readOpencodeProvidersForModelPicker().catch((err) => {+ if (err instanceof ApiError && err.code === 'instance_access_forbidden') return null;+ throw err;+ });+ if (!res) return { models: [] };const models = (res.providers ?? []).filter((p) => p.configured).flatMap((p) =>(p.models ?? []).map((m) => `${p.id}/${m}`),);diff --git a/vibe/authorization.py b/vibe/authorization.pyindex e8ea5678b..2c6507e60 100644--- a/vibe/authorization.py+++ b/vibe/authorization.py@@ -523,6 +523,22 @@ _EDITOR_HTTP_RULES = tuple(("GET", r"^/api/agents/[^/]+$"),("GET", r"^/api/agents-graph$"),("GET", r"^/api/agent-backends$"),+ # Read-only model catalogs. Chat's route picker is an editor surface and+ # the Agents detail panel is a member one, so the catalog they share is+ # editor-tier and member inherits it. Both routes are snapshot reads of a+ # shared model catalog: no provider configuration, no backend contact.+ # Listed one route at a time rather than as a namespace, so neither+ # `/api/claude/*` nor `/api/codex/*` grows an editor-visible mutation by+ # accident.+ #+ # OpenCode has no editor-visible catalog. Its only one is+ # `/api/backend/opencode/providers`, which is the Settings surface --+ # base URLs, masked API keys, active auth type, tool-call permission+ # state -- and reaching it runs `ensure_running()`, which can install a+ # plugin, restart, or launch the daemon. Both stay Owner; the model+ # picker treats the refusal as "no catalog" instead.+ ("GET", r"^/api/claude/models$"),+ ("GET", r"^/api/codex/models$"),("GET", r"^/api/running-agents$"),("POST", r"^/api/running-agents/end$"),# Files favorites live under /api/browse, not /api/files. Admit only this