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.

fix(model-hub): place a native Source moved to the Hub into OpenCode (#2391)

Call Whiteb6469d0323d3
diff --git a/core/handlers/model_hub/migration.py b/core/handlers/model_hub/migration.py
index aa2b9e51a..5c942fd0d 100644
--- a/core/handlers/model_hub/migration.py
+++ b/core/handlers/model_hub/migration.py
@@ -15,6 +15,7 @@ from modules.agents.catalog import NATIVE_CLI_BACKENDS, NativeCliBackend, displa
from typing import Any, Awaitable, Callable, Collection, Literal, Mapping, Optional, Protocol, cast
from config.v2_config import (
+ MODEL_HUB_BACKENDS,
ModelHubConfig,
ModelHubModelConfig,
ModelHubSourceConfig,
@@ -193,6 +194,7 @@ class MigrationHost(Protocol):
self,
config: ModelHubConfig,
source: ModelHubSourceConfig,
+ backends: Collection[str] = MODEL_HUB_BACKENDS,
) -> None: ...
def _added_to(self, source_id: str) -> list[dict]: ...
@@ -1866,10 +1868,14 @@ async def _prepare_takeover(
source = ModelHubSourceConfig.from_payload(replacement)
updated.sources = [source if value.id == source.id else value for value in updated.sources]
_ensure_takeover_placement(updated, source, item.backend)
- # Now on the Hub, it is new to Vibey, which reaches every
- # Hub Source: placed like a new Source (a pending entry is seeded
- # below instead).
- host._apply_source_placement(updated, source, ("vibey",))
+ # Now on the Hub, it is new to every backend its native CLI
+ # could not serve, OpenCode and Vibey among them: placed there
+ # like a new Source (a pending Vibey entry is seeded below
+ # instead). Where it already served, the order stays the user's.
+ host._apply_source_placement(updated, source, tuple(
+ backend for backend in MODEL_HUB_BACKENDS
+ if not updated.source_eligible_for_backend(existing, backend)
+ ))
else:
updated.sources.append(source)
host._apply_source_placement(updated, source)
diff --git a/docs/plans/model-hub-contracts/vibey-consumer.md b/docs/plans/model-hub-contracts/vibey-consumer.md
index f9feb0601..13f1a9367 100644
--- a/docs/plans/model-hub-contracts/vibey-consumer.md
+++ b/docs/plans/model-hub-contracts/vibey-consumer.md
@@ -35,7 +35,8 @@ seed with no models.dev copy cached first fetches one in the foreground, bounded
so its rows usually carry the limits the Agent budgets with, and rows written
without one take them once a copy arrives (MH-LIMITS-001); a starting model is
one a placed Source's own non-retired inventory lists, never a passthrough route. A native Source that later moves
-to the Hub joins Vibey like a new Source.
+to the Hub joins Vibey like a new Source, as it joins OpenCode and every other
+backend its native CLI could not serve.
Where a user Agent already holds the name and no built-in exists, only the
supply is seeded.
The persisted row then belongs to the user and is never seeded again. Existing
diff --git a/tests/test_model_hub_migration_source_identity.py b/tests/test_model_hub_migration_source_identity.py
index 7bfe6a201..eedd4cff6 100644
--- a/tests/test_model_hub_migration_source_identity.py
+++ b/tests/test_model_hub_migration_source_identity.py
@@ -204,8 +204,13 @@ def test_existing_native_source_conversion_also_restores_missing_placement(
assert [model.to_payload() for model in source.models] == before["sources"][0]["models"]
assert store.config.effective_source_order(backend) == [source.id]
assert len(adapter.oauth_provisioned) == 1
- for other in {"claude", "codex", "opencode"} - {backend}:
+ for other in {"claude", "codex"} - {backend}:
assert store.config.to_payload()["agents"][other] == before["agents"][other]
+ # OpenCode could not use the native CLI Source; on the Hub it joins like a new one.
+ opencode = before["agents"]["opencode"]
+ assert opencode["sources"]["order"] == []
+ opencode["sources"]["order"] = [source.id]
+ assert store.config.to_payload()["agents"]["opencode"] == opencode
def test_deduplicated_auth_reversal_restores_every_physical_config(monkeypatch, tmp_path):