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(model-hub): restore dormant OpenCode routes
cyhd8e54e9e878c
diff --git a/core/handlers/model_hub/resolver.py b/core/handlers/model_hub/resolver.pyindex 243c22b55..ead2fe546 100644--- a/core/handlers/model_hub/resolver.py+++ b/core/handlers/model_hub/resolver.py@@ -101,15 +101,22 @@ def source_eligible_for_backend(source: ModelHubSourceConfig, backend: str) -> bdef opencode_inventory_menu_ids(config: ModelHubConfig) -> frozenset[str]:- """Return the OpenCode identities current eligible inventory can add."""+ """Return OpenCode identities backed by current eligible inventory."""- return frozenset(+ identities = {opencode_model_id(source.vendor, model.id)for source in config.sourcesif source_eligible_for_backend(source, "opencode")for model in source.modelsif not model.retired- )+ }+ for menu_model, route in config.agents["opencode"].routes.items():+ if any(+ inspect_exact_hop(config, "opencode", menu_model, hop).supply_eligible+ for hop in route.hops+ ):+ identities.add(menu_model)+ return frozenset(identities)def source_retry_ready(source: ModelHubSourceConfig, now: datetime | None) -> bool:diff --git a/docs/plans/model-hub-contracts/api.md b/docs/plans/model-hub-contracts/api.mdindex 8f1254dea..a76729a1e 100644--- a/docs/plans/model-hub-contracts/api.md+++ b/docs/plans/model-hub-contracts/api.md@@ -40,7 +40,7 @@ compatibility path.| PUT `/api/models/agents/<backend>/sources` | `{order: string[]}` → `{agent: AgentSupply}` | Stores and re-echoes the complete canonical order; no policy state exists. This route never touches a Route chain and has no guarded `409` branch. || POST `/api/models/agents/<backend>/chains/reorder` | `{order?: string[]}` → `{agent: AgentSupply}` | With `order`, atomically stores the complete Source order and idempotently reorders every stored Route by it; with no body, applies the already stored order. In either form it adds, removes, remaps, matches, and guards nothing. The total order is defined below. || PATCH `/api/models/agents/<backend>/mode` | `{mode}` → `{agent: AgentSupply}` | Explicit `hub` / `direct` switch. A qualifying Direct → Gateway switch atomically adopts the recognized CLI login as the first native Source; other switches create nothing. |-| PUT `/api/models/agents/opencode/menu` | `{baseline: AgentMenu, menu: AgentMenu}` → `{agent: AgentSupply}` | Atomically applies the additions, removals, and optional view change between `baseline` and `menu` to the latest stored OpenCode menu. Concurrent unrelated selections survive. A newly added identifier must still be supplied by current OpenCode-eligible inventory at commit time; already checked route aliases may be preserved or removed without same-name inventory. |+| PUT `/api/models/agents/opencode/menu` | `{baseline: AgentMenu, menu: AgentMenu}` → `{agent: AgentSupply}` | Atomically applies the additions, removals, and optional view change between `baseline` and `menu` to the latest stored OpenCode menu. Concurrent unrelated selections survive. A newly added identifier must still be supplied by current OpenCode-eligible inventory at commit time; this includes a dormant Route alias whose saved Route retains an exact eligible inventory hop. Already checked route aliases may be preserved or removed without same-name inventory. || GET `/api/models/agents/<backend>/chains` | → `{chains: AgentChain[]}` | Hub only. Returns the complete Overview model set in menu order, followed by a selected model or configured Route not already present. All members share one config snapshot and observation time. Direct returns the documented `direct_mode` error. || GET `/api/models/agents/<backend>/chain?model=<id>` | → `{chain: AgentChain}` | Hub only. Direct returns the documented `direct_mode` error. || PUT `/api/models/agents/<backend>/chain?model=<id>` | `{hops: RouteHop[], force?: boolean, would_remove_hops?: RouteHopRef[], would_interrupt?: SupplyGap[]}` → guarded `409` or `{chain, removed_hops, interrupted}` | Replaces the exact Source/model pairs in submitted order after validating new or changed pairs; the handler never reads `sources.order`, and the submitted `hops` carry no Source-order semantics. It is the `mutation.route_replace` row of the authoritative mutation matrix. A visible noninterrupting hop removal is ordinary success; only a resulting protected-supply interruption enters the guard. |diff --git a/tests/test_model_hub_resolution.py b/tests/test_model_hub_resolution.pyindex f626d45a3..40db03645 100644--- a/tests/test_model_hub_resolution.py+++ b/tests/test_model_hub_resolution.py@@ -1133,6 +1133,50 @@ def test_opencode_menu_preserves_an_existing_route_alias_while_adding_inventory()+def test_opencode_menu_reselects_a_dormant_route_alias_with_an_eligible_exact_hop(tmp_path):+ source = _source("src_opencode05", ("upstream-model",), vendor="openai")+ config = _config([source])+ opencode = config.agents["opencode"]+ opencode.routes["openai/menu-model"] = ModelHubRouteConfig(+ hops=(ModelHubRouteHopConfig(source.id, "upstream-model"),)+ )+ service, store, _ = _service(tmp_path, config)++ asyncio.run(+ service.set_opencode_menu(+ {"view": "featured", "checked": []},+ {"view": "featured", "checked": ["openai/menu-model"]},+ )+ )++ saved = store.load().agents["opencode"]+ assert saved.menu.checked == ["openai/menu-model"]+ assert saved.routes["openai/menu-model"].hops == (+ ModelHubRouteHopConfig(source.id, "upstream-model"),+ )+++def test_opencode_menu_rejects_a_dormant_route_alias_with_a_stale_exact_hop(tmp_path):+ source = _source("src_opencode06", (), vendor="openai")+ config = _config([source])+ config.agents["opencode"].routes["openai/menu-model"] = ModelHubRouteConfig(+ hops=(ModelHubRouteHopConfig(source.id, "removed-model"),)+ )+ service, store, _ = _service(tmp_path, config)++ with pytest.raises(ModelHubError) as exc:+ asyncio.run(+ service.set_opencode_menu(+ {"view": "featured", "checked": []},+ {"view": "featured", "checked": ["openai/menu-model"]},+ )+ )++ assert exc.value.code == "mapping_target_unavailable"+ assert exc.value.status == 409+ assert store.load().agents["opencode"].menu.checked == []++def test_opencode_menu_applies_local_intent_to_the_latest_saved_menu(tmp_path):source = _source("src_opencode03",diff --git a/ui/src/components/settings/models/OpenCodeMenuDialog.test.tsx b/ui/src/components/settings/models/OpenCodeMenuDialog.test.tsxindex 443673821..8143cafac 100644--- a/ui/src/components/settings/models/OpenCodeMenuDialog.test.tsx+++ b/ui/src/components/settings/models/OpenCodeMenuDialog.test.tsx@@ -164,6 +164,41 @@ describe('OpenCodeMenuDialog', () => {));});+ it('reselects a dormant route alias backed by an eligible exact hop', async () => {+ const user = userEvent.setup();+ const configured = {+ ...agent,+ menu: { view: 'featured' as const, checked: [] },+ routes: { 'openai/menu-model': { hops: [{ source_id: 'src_openai', model_id: 'gpt-5.6-sol' }] } },+ };+ vi.spyOn(modelsApi, 'getAgentSources').mockResolvedValue(configured);+ const putMenu = vi.spyOn(modelsApi, 'putMenu').mockResolvedValue({+ ...configured,+ menu: { view: 'featured', checked: ['openai/menu-model'] },+ });+ render(+ <I18nextProvider i18n={i18n}>+ <OpenCodeMenuDialog+ open+ sourceReads={{ readValue: vi.fn().mockResolvedValue(sources) }}+ onClose={vi.fn()}+ onSaved={vi.fn()}+ onObserved={vi.fn()}+ menuWrite={{ pending: false, track: async (work) => work() }}+ />+ </I18nextProvider>,+ );++ const alias = await screen.findByRole('checkbox', { name: /openai\/menu-model/i });+ expect(alias.getAttribute('aria-checked')).toBe('false');+ await user.click(alias);+ await user.click(screen.getByRole('button', { name: 'Save selection' }));+ await waitFor(() => expect(putMenu).toHaveBeenCalledWith(+ { view: 'featured', checked: [] },+ { view: 'featured', checked: ['openai/menu-model'] },+ ));+ });+it('preserves a checked cross-model route while saving an unrelated addition', async () => {const user = userEvent.setup();const configured = {diff --git a/ui/src/components/settings/models/OpenCodeMenuDialog.tsx b/ui/src/components/settings/models/OpenCodeMenuDialog.tsxindex b24b7e50b..eab7fff8b 100644--- a/ui/src/components/settings/models/OpenCodeMenuDialog.tsx+++ b/ui/src/components/settings/models/OpenCodeMenuDialog.tsx@@ -30,7 +30,8 @@ const selectableModels = (agent: AgentSupply, sources: Source[]): MenuModel[] =>const standardVendors = new Set(agent.standard_vendors ?? []);const namesById = new Map<string, Set<string>>();const sourceNames = new Map(sources.map((source) => [source.id, source.display_name]));- for (const source of eligibleSources(sources, agent)) {+ const eligibleById = new Map(eligibleSources(sources, agent).map((source) => [source.id, source]));+ for (const source of eligibleById.values()) {for (const model of source.models) {if (model.retired) continue;const id = buildIdentifier(source.vendor, model.id, standardVendors);@@ -39,6 +40,16 @@ const selectableModels = (agent: AgentSupply, sources: Source[]): MenuModel[] =>namesById.set(id, names);}}+ for (const [id, route] of Object.entries(agent.routes ?? {})) {+ const names = new Set(namesById.get(id));+ for (const hop of route.hops) {+ const source = eligibleById.get(hop.source_id);+ if (source?.models.some((model) => model.id === hop.model_id && !model.retired)) {+ names.add(source.display_name);+ }+ }+ if (names.size > 0) namesById.set(id, names);+ }for (const id of agent.menu?.checked ?? []) {if (namesById.has(id)) continue;const names = new Set<string>();