Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix: salvage self-contained fixes from #395 (#402)

Ruben Lütke523cd92285da
diff --git a/docs/jarvis-agents-bridge.md b/docs/jarvis-agents-bridge.md
index b9ccd111ad..337f77af9a 100644
--- a/docs/jarvis-agents-bridge.md
+++ b/docs/jarvis-agents-bridge.md
@@ -107,11 +107,13 @@ The following ADs are **refined** by empirical findings from `docs/spike-results
| `openrouter` | `openrouter` | `OPENROUTER_API_KEY` | `openrouter_api_key` |
| `grok` | `xai` | `XAI_API_KEY` (fallback `GROK_API_KEY`) | (Grok key) |
| `nvidia` | `nvidia` | `NVIDIA_API_KEY` | `nvidia_api_key` |
+ | `vertex` | `vertex` | `VERTEX_API_KEY` (fallback `GOOGLE_VERTEX_API_KEY`; ADC may be keyless) | Vertex key / Google Cloud ADC |
| `ollama` | `ollama` | — (keyless) | — |
| `local-openai` | `local-openai` | — (keyless) | — |
- The last three rows do not run on the external CLI worker: they are
- OpenAI-compatible API brains served by the in-process `ApiAgentWorker`. Their
+ The last four rows do not run on the external CLI worker: they are
+ API brains served by the in-process `ApiAgentWorker`. Vertex may authenticate
+ through a stored key or Google Cloud Application Default Credentials. Their
rows exist so each is selectable as a Jarvis-Agent in the API-Keys view —
without a row, a user running a local model could not pick it at all.
`ollama` and `local-openai` are keyless by design: no Agent key slot exists,
diff --git a/jarvis/brain/cost.py b/jarvis/brain/cost.py
index 776cbe683a..d17aeeb999 100644
--- a/jarvis/brain/cost.py
+++ b/jarvis/brain/cost.py
@@ -168,6 +168,20 @@ PRICING_USD_PER_MTOK: dict[str, tuple[float, float]] = {
"grok-4": (5.0, 15.0),
"grok-4.1-fast": (0.40, 1.60),
"grok-3": (5.0, 15.0),
+ # ── Z.ai GLM (Coding Plan / direct API) ───────────────────────────
+ # Z.ai list prices (docs.z.ai pricing page, checked 2026-10-05).
+ "glm-5.3": (1.40, 4.40),
+ "glm-5.3-flash": (0.15, 0.50),
+ "glm-5.3-flashx": (0.37, 1.25),
+ "glm-5.2": (1.40, 4.40),
+ "glm-5.1": (1.40, 4.40),
+ "glm-5": (1.00, 3.20),
+ "glm-4.7": (0.60, 2.20),
+ "glm-4.7-flashx": (0.07, 0.40),
+ "glm-4.7-flash": (0.0, 0.0),
+ "glm-4.6": (0.60, 2.20),
+ "glm-4.5": (0.60, 2.20),
+ "glm-4.5-air": (0.20, 1.10),
# ── DeepSeek ────────────────────────────────────────────────────
"deepseek-chat": (0.27, 1.10),
"deepseek-reasoner": (0.55, 2.19),
@@ -205,6 +219,7 @@ PRICING_USD_PER_MTOK: dict[str, tuple[float, float]] = {
# Anthropic's 1.25x write premium slightly rather than inventing a rate.
CACHE_READ_FRACTION_DEFAULT = 0.10
CACHE_READ_FRACTION_BY_PREFIX: tuple[tuple[str, float], ...] = (
+ ("glm-", 0.20),
("gemini", 0.25),
("google/", 0.25),
# Measured from xAI's own costUsdTicks (2026-08-25): a quarter, not a tenth.
diff --git a/jarvis/brain/model_catalog.py b/jarvis/brain/model_catalog.py
index 27793b046e..41e394ef9f 100644
--- a/jarvis/brain/model_catalog.py
+++ b/jarvis/brain/model_catalog.py
@@ -619,6 +619,9 @@ REALTIME_MODELS: dict[str, list[ModelInfo]] = {
# capabilities guide, which now permits the complete 30-voice Gemini
# prebuilt roster. Same names on both sockets (AI Studio vs Cloud project).
REALTIME_VOICES: dict[str, list[ModelInfo]] = {
+ # GPT-Live chooses its voice at session startup. Keep the provider's
+ # documented default available even when the richer voice roster changes.
+ "openai-live": _ids(["marin"]),
# A self-hosted server ships whatever voices its operator installed, and a
# list of OpenAI voice names would be a guess the server then rejects. One
# honest entry: the adapter sends no voice override and the server uses its
diff --git a/jarvis/brain/ollama_library.py b/jarvis/brain/ollama_library.py
index 0d33d1fbb7..8705e0c488 100644
--- a/jarvis/brain/ollama_library.py
+++ b/jarvis/brain/ollama_library.py
@@ -327,17 +327,44 @@ def parse_tags_html(page: str, name: str) -> list[dict[str, Any]]:
href_re = re.compile(rf'href="/(?:library/)?{re.escape(name)}:([^"?#]+)"')
matches = list(href_re.finditer(page))
first_seen: list[tuple[str, int]] = []
- seen: set[str] = set()
+ positions: dict[str, list[int]] = {}
for match in matches:
tag = match.group(1)
- if tag not in seen:
- seen.add(tag)
+ positions.setdefault(tag, []).append(match.start())
+ if len(positions[tag]) == 1:
first_seen.append((tag, match.start()))
+ def _facts_window(tag: str, fallback: str) -> str:
+ """Prefer the duplicate link that actually carries this tag's facts.
+
+ Ollama renders mobile and desktop links for one tag, and their order has
+ changed over time. A bare desktop link can be followed by unrelated age
+ text before the next distinct tag; treating that whole span as this tag
+ made a current model look a year old. Rich mobile anchors carry their
+ own facts, so score every duplicate before using the legacy fallback.
+ """
+ candidates: list[tuple[int, str]] = []
+ for start in positions[tag]:
+ close = page.find("</a>", start)
+ if close < 0:
+ continue
+ candidate = page[start : close + 4]
+ score = sum(
+ (
+ bool(_SIZE_RE.search(candidate)),
+ bool(re.search(r"[\d.]+[KM]\s+context window", candidate)),
+ bool(re.search(r"[A-Za-z][A-Za-z, ]*?\s+input\b", candidate)),
+ bool(re.search(r"(?:\d+ \w+ ago|yesterday)", candidate)),
+ )
+ )
+ if score:
+ candidates.append((score, candidate))
+ return max(candidates, key=lambda item: item[0])[1] if candidates else fallback
+
entries: list[dict[str, Any]] = []
for index, (tag, start) in enumerate(first_seen):
end = first_seen[index + 1][1] if index + 1 < len(first_seen) else len(page)
- window = page[start:end]
+ window = _facts_window(tag, page[start:end])
size_match = _SIZE_RE.search(window)
context_match = re.search(r"([\d.]+[KM])\s+context window", window)
diff --git a/jarvis/ui/web/server.py b/jarvis/ui/web/server.py
index d97fcc1077..5c2612b8df 100644
--- a/jarvis/ui/web/server.py
+++ b/jarvis/ui/web/server.py
@@ -141,6 +141,10 @@ class WebServer:
) -> None:
self._defer_feature_routes = defer_feature_routes
self.cfg = cfg
+ # Deferred boot work belongs to this server instance. Explicit handles
+ # let stop() drain it before pytest/asyncio tears the event loop down.
+ self._anyio_pool_warm_task: asyncio.Task[None] | None = None
+ self._deferred_reload_task: asyncio.Task[None] | None = None
self.bus = bus if bus is not None else get_default_bus()
self._clients: dict[str, WebSocket] = {}
self._client_send_locks: dict[str, asyncio.Lock] = {}
@@ -849,7 +853,9 @@ class WebServer:
return
logger.info("anyio worker pool warmed: {} thread(s) resident", resident)
- asyncio.create_task(_warm(), name="anyio-pool-warm")
+ self._anyio_pool_warm_task = asyncio.create_task(
+ _warm(), name="anyio-pool-warm"
+ )
async def _voice_ready_watchdog(self, deadline_s: float = 45.0) -> None:
"""Release boot waiters after a failed warm-up without promising speech.
@@ -3969,6 +3975,16 @@ class WebServer:
mars_shutdown_failure = type(exc).__name__
logger.warning("Mars station cleanup incomplete ({})", mars_shutdown_failure)
registry_bootstraps_stopped = await self._stop_registry_bootstraps()
+ # A short-lived server can stop before these delayed boot helpers run.
+ # Own and drain them here instead of leaving asyncio.run()/pytest to
+ # discover them during loop teardown. Stop the deferred registry reload
+ # before its registries are closed below so shutdown cannot race a scan.
+ for attr in ("_anyio_pool_warm_task", "_deferred_reload_task"):
+ task = getattr(self, attr, None)
+ setattr(self, attr, None)
+ if task is not None and not task.done():
+ task.cancel()
+ await asyncio.gather(task, return_exceptions=True)
society = getattr(self.app.state, "society", None)
society_shutdown_failure: str | None = None
if society is not None:
diff --git a/jarvis/workspace/agents.py b/jarvis/workspace/agents.py
index 6c11401389..92e3a0e789 100644
--- a/jarvis/workspace/agents.py
+++ b/jarvis/workspace/agents.py
@@ -1112,7 +1112,7 @@ def _custom_aliases(display_name: str, entry_id: str) -> tuple[str, ...]:
elif words and len(words[0]) >= 4 and words[0].isalpha():
out.append(words[0])
slug = str(entry_id or "").lower()
- if len(slug) >= 4 and slug.isalpha() and slug not in out:
+ if len(slug) >= 4 and slug.replace("-", "").isalnum() and slug not in out:
out.append(slug)
return tuple(out)
@@ -1401,8 +1401,12 @@ def reserved_call_signs() -> frozenset[str]:
names.add(first[0].lower())
names.update(spelling.lower() for spelling in agent.spoken_aliases)
# Single letters and anything with a space in it are not call-sign shaped,
- # so reserving them protects nothing and only shrinks the pool.
- return frozenset(n for n in names if n.isalpha() and len(n) > 1)
+ # so reserving them protects nothing and only shrinks the pool. Slugs may
+ # contain hyphens; dots, slashes and other punctuation stay excluded.
+ return frozenset(
+ n for n in names
+ if len(n) > 1 and n.replace("-", "").isalnum()
+ )
@dataclass(slots=True)
diff --git a/tests/integration/test_phase1a_smoke.py b/tests/integration/test_phase1a_smoke.py
index fdb83b1d3b..e1dcafcdef 100644
--- a/tests/integration/test_phase1a_smoke.py
+++ b/tests/integration/test_phase1a_smoke.py
@@ -5,6 +5,8 @@ If agents 1-6 haven't merged their files yet, the test skips gracefully.
"""
from __future__ import annotations
+import asyncio
+
import pytest
@@ -56,6 +58,18 @@ async def test_webserver_starts_and_stops(test_config):
finally:
await srv.stop()
+ # Delayed boot helpers are owned by WebServer and must be gone before the
+ # pytest-asyncio runner starts its own loop teardown.
+ assert srv._anyio_pool_warm_task is None
+ assert srv._deferred_reload_task is None
+ leaked = {
+ task.get_name()
+ for task in asyncio.all_tasks()
+ if task is not asyncio.current_task() and not task.done()
+ }
+ assert "anyio-pool-warm" not in leaked
+ assert "deferred-registry-reload" not in leaked
+
def test_rest_api_health(test_config):
WebServer = _try_import_webserver()
diff --git a/tests/missions/worker_runtime/test_provider_map.py b/tests/missions/worker_runtime/test_provider_map.py
index d9e0289ff6..86c98f1dbd 100644
--- a/tests/missions/worker_runtime/test_provider_map.py
+++ b/tests/missions/worker_runtime/test_provider_map.py
@@ -195,7 +195,9 @@ def test_ad6_table_is_complete() -> None:
in-process ApiAgentWorker (not the Jarvis-Agent CLI worker harness); its row
exists so it is a selectable Jarvis-Agent in the API-Keys view.
- ``ollama`` and ``local-openai`` are the self-hosted rows. They carry a key
+ ``vertex`` is the Google Cloud API row and runs through the in-process
+ ApiAgentWorker, like ``nvidia``. ``ollama`` and ``local-openai`` are the
+ self-hosted rows. They carry a key
slot name for shape only: no Agent key slot exists, so the worker proceeds
keyless and the brain plugin supplies its own dummy SDK key. Their rows
exist for the same reason as ``nvidia`` — without one, a user running a
diff --git a/tests/unit/brain/test_ollama_library.py b/tests/unit/brain/test_ollama_library.py
index 24b3a1dba8..cc98413606 100644
--- a/tests/unit/brain/test_ollama_library.py
+++ b/tests/unit/brain/test_ollama_library.py
@@ -108,6 +108,21 @@ def test_size_units_are_read_the_way_the_catalog_writes_them(
assert library.parse_tags_html(markup, "x")[0]["size_gb"] == expected
+def test_tags_parser_prefers_the_rich_duplicate_over_intervening_age_text() -> None:
+ page = (
+ '<a href="/library/qwen3.5:4b">qwen3.5:4b</a>'
+ '<span>unrelated release 1 year ago</span>'
+ '<a href="/library/qwen3.5:4b">'
+ 'qwen3.5:4b • 3.4GB • 256K context window • Text, Image input • 7 months ago'
+ '</a>'
+ '<a href="/library/qwen3.5:9b">qwen3.5:9b</a> 6.6GB'
+ )
+ tags = library.parse_tags_html(page, "qwen3.5")
+ small = next(item for item in tags if item["tag"] == "4b")
+ assert small["size_gb"] == 3.4
+ assert small["updated"] == "7 months ago"
+
+
def test_tags_parser_reads_size_context_and_inputs(tags_page: str) -> None:
latest = library.parse_tags_html(tags_page, "qwen3.5")[0]
assert latest["id"] == "qwen3.5:latest"
diff --git a/tests/unit/test_brain_cost.py b/tests/unit/test_brain_cost.py
index e0d550b717..bbe488c2c7 100644
--- a/tests/unit/test_brain_cost.py
+++ b/tests/unit/test_brain_cost.py
@@ -178,3 +178,18 @@ def test_grok_cache_reads_bill_at_a_quarter() -> None:
assert cache_read_fraction("grok-4.6-build") == 0.25
assert cache_read_fraction("gpt-5.5") == 0.10
+
+
+def test_zai_glm_rates_do_not_inherit_anthropic_pricing() -> None:
+ from jarvis.brain.cost import calculate_cost_usd
+
+ assert calculate_cost_usd("glm-4.6", 1_000_000, 1_000_000) == pytest.approx(2.80)
+ assert calculate_cost_usd("glm-5.1", 1_000_000, 1_000_000) == pytest.approx(5.80)
+ assert calculate_cost_usd("glm-4.7-flash", 1_000_000, 1_000_000) == 0.0
+
+
+def test_zai_glm_cache_reads_use_twenty_percent_of_input_rate() -> None:
+ from jarvis.brain.cost import cache_read_fraction, calculate_cost_usd
+
+ assert cache_read_fraction("glm-5.3") == pytest.approx(0.20)
+ assert calculate_cost_usd("glm-5.3", 0, 0, 1_000_000) == pytest.approx(0.28)
diff --git a/tests/unit/workspace/test_custom_clis.py b/tests/unit/workspace/test_custom_clis.py
index b3a4c31bb5..8c82014ca1 100644
--- a/tests/unit/workspace/test_custom_clis.py
+++ b/tests/unit/workspace/test_custom_clis.py
@@ -420,3 +420,12 @@ def test_a_custom_name_is_reserved_against_pane_call_signs() -> None:
custom_clis.create_custom_cli("FixtureCLI", "fixture-cli")
registry.refresh_custom_agents()
assert "fixturecli" in registry.reserved_call_signs()
+
+
+def test_a_hyphenated_id_stays_a_spoken_alias_and_call_sign() -> None:
+ """A two-word name yields a hyphenated id; it must still be addressable."""
+ entry = custom_clis.create_custom_cli("Acme Coding", "acme")
+ registry.refresh_custom_agents()
+ assert entry.id == "acme-coding"
+ assert registry.spoken_aliases().get("acme-coding") == "acme-coding"
+ assert "acme-coding" in registry.reserved_call_signs()