## Summary
Rebuilds the web onboarding after the first-run prototype: a four-step
wizard
(model, search, agents, data sync) that opens on a first run and can be
reopened with `?onboard=1`.
The wizard is a frame. The model and search steps render the settings
dialog's own model page and web-search controls, the agents step renders
the
sub-agents roster's connect list; each domain hands its step body over
in
`src/app/install.ts`, so every control keeps one owner and the wizard
reads no
sibling's private file ("step body" is defined in `ui-web/CONTEXT.md`).
Only
the data-sync step is drawn by the onboard domain, over four new wire
methods
(`import.scan/run/status/stop`) that put the CLI's cold-start import
(`raven import`) on the RPC surface: one in-process task, progress from
the
importer's own state file, stop through its cancel file. The sync step
is
offered only when the importer can run and knows an agent the machine
has.
Four first-run faults the real host showed, each fixed with a test:
`setup.status` answered "configured" when no config file existed (a
fresh
install never saw the wizard); the settings snapshot froze on an empty
provider list when the boot's refresh raced the session switch; the role
picker offered nothing for a provider connected a moment ago; toasts sat
below the wizard's layer. The fifth -- `config.set model` refusing a
first
run's first default -- landed on the base branch meanwhile (#524, with a
`needs_restart` reply); the wizard reads that reply and says in its
footer
that the gateway has to restart before it can chat, instead of the
reader
learning it from the first send.
Setting the memory-extraction model through `settings.everosSet` now
records
`memory.backend` the way the CLI wizard does, so memory and the import
can
work on a web-onboarded install.
A two-reviewer pass over the branch before this PR found six things,
each
fixed with a test: `import.run` awaited a scan and a backend start
before it
held its task, so two frames dispatched together both started (the slot
is
now claimed before the first await, and the background task logs its own
failure); `settings.everosSet` read the CLI wizard's explicit `null` --
the
reader declined memory -- as "nobody chose" (only an absent key records
the
default now); the wizard asked `import.scan` once on open, so a
first run could never reach the sync step the model step's memory model
makes possible (leaving the agents step, by Next or Skip, asks again);
the
agents step connected a stale row -- its preset moved to another
transport --
with the flag the settings page had ruled out for it (the write follows
the
row's stage now, and a shipped agent switched off is offered back); the
web
step's fetch chip said "ready" unconditionally. A second pass over those
fixes closed what they left: the footer's primary on the agents step
also
re-asks the importer before closing (a reader who connected an agent
presses
that, not Skip), only the latest scan answer lands, openai endpoints are
out
of every wizard bucket, a stale row's connect asks the settings page's
own
confirm and carries its migration tag, and the confirm veil stands above
the
wizard while it is open (it sat under it). `import.status` and
`import.stop` have no caller in the page yet: they are the wire twins of
`raven import status` and `raven import stop`, kept with the other two
so a
client can find out how the import the wizard started is going.
`import.run`
records which sources the run covers and `import.status` counts those
alone,
so a subset run is not measured against every source an earlier run left
in
the state file; a run the CLI started records none, and then every entry
counts, the way `raven import status` does.
Deliberate deviations from the prototype and the CLI wizard: no sandbox,
channel or memory steps (memory is the everos roles of the model step);
the
`evolve` role is not offered (no backend reads it; to be added together
with
the settings page); agents that need an API key (openai kind) are not
listed
as available; `hosted_vllm` / `custom` stay hidden as on the settings
page;
the search key is not probed and no shell rc line is written; no
progress
view after the wizard closes (`raven import status` shows it); agent
rows use
the sub-agents page's row style and its "connect / disconnect" wording;
the
shipped ravens are whatever the roster reports. Known limits, not
changed
here: a gateway that started with no provider keeps its latched build
error
after the wizard finishes, so chat turns need a gateway restart (the
wizard
now says so); and a reader who declined memory in the CLI wizard
(`memory.backend` is an explicit null) has no control on the web to
switch it
back on, so the sync step stays out for them until `raven onboard` is
run
again. The `.ob*`
rules leave `page.css` for the domain's own sheet; the picker's two row
classes shared with the old flow take the model prefix; the 25 old
catalogue
keys are replaced by the wizard's 16 and the TUI copy is regenerated.
## Type
- [ ] Fix
- [x] Feature
- [ ] Docs
- [ ] CI / tooling
- [ ] Refactor
- [ ] Other
## Verification
```
cd ui-web && npm test # 185 files, 2568 tests passed (40 gates included)
cd ui-web && npm run type-check # clean
cd ui-web && npm run lint # 0 errors
cd ui-web && node scripts/check-class-namespace.mjs # OK, pins lowered, no list grown
cd ui-web && npm run build && python3 build.py # boot goldens 250/251 match
make test-python # or the touched files:
uv run pytest tests/test_rpc_import_sync.py tests/test_rpc_setup.py tests/test_rpc_settings.py \
tests/test_rpc_config.py tests/test_rpc_schema_match.py tests/test_rpc_registration.py \
tests/test_rpc_console.py tests/test_cli_import_commands.py tests/test_agent_tools_web_providers.py \
tests/test_importer_state.py -q
# 817 passed
uv run python scripts/check_source_language.py ca89cb50..HEAD # exit 0
npm run lint:i18n --prefix ui-tui # generated catalogue up to date
```
Real host: two gateways under their own RAVEN_HOME (an empty one and a
copy
of a configured one), walked with playwright through all four steps --
first-run auto-open, connect a provider, pick a chat model, save a
search key,
agent probe and a refused connect (toast above the wizard), the sync
step
reached on a first run through the model step's memory model and a Skip
on
the agents step, its counts and switch (import not started). Screenshots
compared step by step against the prototype's.
- [x] Relevant tests pass locally
- [x] Relevant lint / type checks pass locally
- [ ] User-facing docs or screenshots are updated when needed
## Risk
- [x] Security impact considered
- [x] Backward compatibility considered
- [x] Rollback path is clear for risky changes
Behaviour changes: a page whose gateway reports no configured provider
opens
on the wizard instead of the chat page (the redirect to Settings >
Models
stays for the page behind it); `setup.status` reports `false` for a
missing
config file (the TUI's setup handoff sees the same answer);
`settings.everosSet`
on the `llm` section also writes `memory.backend` when no key is
recorded (an
explicit `null` stays); the role
picker lists the registry's models for a provider with nothing added;
toasts
now stand above every layer but the splash, and the confirm veil stands
above
the onboarding layer only while the wizard is open. Rollback is
reverting the
squash commit; no config migration.
## Related Issues
N/A
---------
Co-authored-by: Claude (claude-fable-5-1) <noreply@anthropic.com>
214 lines
8.1 KiB
Python
214 lines
8.1 KiB
Python
"""Tests for ``setup.status`` RPC handler (specs §3.9, design §3a.1).
|
|
|
|
provider_configured is true only when the onboarding gate's criterion is met:
|
|
``agents.defaults.model`` is set AND a provider signal exists (a non-``auto``
|
|
``agents.defaults.provider`` or a ``providers.<name>.apiKey``). Either alone
|
|
is not enough to drive a turn, so the UI parks on the setup panel. On any read
|
|
/ parse failure the handler returns the v0.1 fallback
|
|
``{"provider_configured": true}`` so the hermes UI never gets blocked just
|
|
because the config file is in an unexpected shape.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from raven.rpc.dispatcher import Dispatcher
|
|
from raven.rpc.methods.setup import register_setup_methods, setup_status
|
|
|
|
|
|
@pytest.fixture
|
|
def fake_home(monkeypatch, tmp_path) -> Path:
|
|
"""Redirect ``Path.home()`` to a tmp dir so tests don't touch the user's config."""
|
|
monkeypatch.setattr(Path, "home", lambda: tmp_path)
|
|
return tmp_path
|
|
|
|
|
|
async def test_setup_status_provider_configured_true(fake_home: Path) -> None:
|
|
cfg_dir = fake_home / ".raven"
|
|
cfg_dir.mkdir()
|
|
(cfg_dir / "config.json").write_text(
|
|
json.dumps(
|
|
{
|
|
"agents": {"defaults": {"provider": "anthropic", "model": "anthropic/claude-sonnet-4-5"}},
|
|
"providers": {"anthropic": {"apiKey": "sk-ant"}},
|
|
}
|
|
)
|
|
)
|
|
result = await setup_status({})
|
|
assert result == {"provider_configured": True}
|
|
|
|
|
|
async def test_a_pinned_provider_name_is_not_credentials(fake_home: Path) -> None:
|
|
"""The name says which section to ask about, not that it holds anything.
|
|
|
|
``agents.defaults.provider`` was waved through on its own, as a signal from
|
|
configs predating per-provider sections. It is now written on every model
|
|
change, so that branch would have let a pinned name stand for credentials
|
|
nobody has -- an empty config would pass the gate and the first turn would
|
|
fail with whatever the backend said about a missing key.
|
|
"""
|
|
cfg_dir = fake_home / ".raven"
|
|
cfg_dir.mkdir()
|
|
(cfg_dir / "config.json").write_text(
|
|
json.dumps({"agents": {"defaults": {"provider": "anthropic", "model": "anthropic/claude-sonnet-4-5"}}})
|
|
)
|
|
|
|
assert await setup_status({}) == {"provider_configured": False}
|
|
|
|
|
|
async def test_setup_status_provider_without_model_returns_false(fake_home: Path) -> None:
|
|
# A provider but no default model can't drive a turn → not configured.
|
|
cfg_dir = fake_home / ".raven"
|
|
cfg_dir.mkdir()
|
|
(cfg_dir / "config.json").write_text(json.dumps({"agents": {"defaults": {"provider": "anthropic"}}}))
|
|
result = await setup_status({})
|
|
assert result == {"provider_configured": False}
|
|
|
|
|
|
async def test_setup_status_missing_config_is_a_first_run(fake_home: Path) -> None:
|
|
# No file at all is a fresh install: the page opens its wizard on this.
|
|
result = await setup_status({})
|
|
assert result == {"provider_configured": False}
|
|
|
|
|
|
async def test_setup_status_malformed_config_falls_back_true(fake_home: Path) -> None:
|
|
cfg_dir = fake_home / ".raven"
|
|
cfg_dir.mkdir()
|
|
(cfg_dir / "config.json").write_text("not-valid-json{{{")
|
|
result = await setup_status({})
|
|
assert result == {"provider_configured": True}
|
|
|
|
|
|
async def test_setup_status_provider_auto_returns_false(fake_home: Path) -> None:
|
|
cfg_dir = fake_home / ".raven"
|
|
cfg_dir.mkdir()
|
|
(cfg_dir / "config.json").write_text(json.dumps({"agents": {"defaults": {"provider": "auto"}}}))
|
|
result = await setup_status({})
|
|
assert result == {"provider_configured": False}
|
|
|
|
|
|
async def test_setup_status_minimax_oauth_token_returns_true(
|
|
fake_home: Path,
|
|
tmp_path: Path,
|
|
monkeypatch: pytest.MonkeyPatch,
|
|
) -> None:
|
|
from raven.providers.minimax_oauth import MiniMaxOAuthToken, save_token
|
|
|
|
cfg_dir = fake_home / ".raven"
|
|
cfg_dir.mkdir()
|
|
(cfg_dir / "config.json").write_text(
|
|
json.dumps({"agents": {"defaults": {"provider": "auto", "model": "minimax-global/MiniMax-M3"}}})
|
|
)
|
|
monkeypatch.setenv("MINIMAX_OAUTH_TOKEN_DIR", str(tmp_path))
|
|
save_token(
|
|
"global",
|
|
MiniMaxOAuthToken(
|
|
"access",
|
|
"refresh",
|
|
4_000_000_000_000,
|
|
"https://api.minimax.io/anthropic/v1",
|
|
),
|
|
)
|
|
|
|
assert await setup_status({}) == {"provider_configured": True}
|
|
|
|
|
|
async def test_setup_status_ignores_minimax_token_for_other_model(
|
|
fake_home: Path,
|
|
tmp_path: Path,
|
|
monkeypatch: pytest.MonkeyPatch,
|
|
) -> None:
|
|
from raven.providers.minimax_oauth import MiniMaxOAuthToken, save_token
|
|
|
|
cfg_dir = fake_home / ".raven"
|
|
cfg_dir.mkdir()
|
|
(cfg_dir / "config.json").write_text(
|
|
json.dumps({"agents": {"defaults": {"provider": "auto", "model": "anthropic/claude-sonnet-4-5"}}})
|
|
)
|
|
monkeypatch.setenv("MINIMAX_OAUTH_TOKEN_DIR", str(tmp_path))
|
|
save_token(
|
|
"global",
|
|
MiniMaxOAuthToken(
|
|
"access",
|
|
"refresh",
|
|
4_000_000_000_000,
|
|
"https://api.minimax.io/anthropic/v1",
|
|
),
|
|
)
|
|
|
|
assert await setup_status({}) == {"provider_configured": False}
|
|
|
|
|
|
async def test_setup_status_registered_via_helper(fake_home: Path) -> None:
|
|
cfg_dir = fake_home / ".raven"
|
|
cfg_dir.mkdir()
|
|
(cfg_dir / "config.json").write_text(
|
|
json.dumps(
|
|
{
|
|
"agents": {"defaults": {"provider": "openai", "model": "openai/gpt-4o-mini"}},
|
|
"providers": {"openai": {"apiKey": "sk-openai"}},
|
|
}
|
|
)
|
|
)
|
|
d = Dispatcher()
|
|
register_setup_methods(d)
|
|
resp = await d.dispatch({"jsonrpc": "2.0", "id": 1, "method": "setup.status", "params": {}})
|
|
assert resp["result"]["provider_configured"] is True
|
|
|
|
|
|
def test_camel_case_provider_key_is_recognized_as_configured() -> None:
|
|
"""A multi-word provider key arrives as the camelCase ``ProvidersConfig``
|
|
serializes to, and the gate must still see it.
|
|
|
|
``canonical_provider_name`` does not split camelCase (it cannot tell
|
|
"azureOpenai" from "OpenRouter" by capitals alone), so iterating the raw
|
|
payload's keys and asking ``sections.get`` about each one misses a
|
|
declared field spelled this way: it validates into ``azure_openai`` fine,
|
|
but ``sections.get("azureOpenai")`` then re-derives a mismatched lookup key
|
|
and returns None. A configured Azure or Copilot install used to park on
|
|
the setup panel for exactly this reason.
|
|
"""
|
|
import raven.rpc.methods.setup as setup
|
|
|
|
payload = {
|
|
"agents": {"defaults": {"model": "azure_openai/my-deployment"}},
|
|
"providers": {"azureOpenai": {"apiKey": "az-TEST", "apiBase": "https://x.openai.azure.com"}},
|
|
}
|
|
assert setup._detect_provider_configured(payload) is True
|
|
|
|
|
|
def test_minimax_oauth_is_detected_from_either_spelling_of_the_prefix(monkeypatch) -> None:
|
|
"""The region is read off the model-id prefix, which arrives underscored.
|
|
|
|
The check used to compare against hyphenated literals, so a saved
|
|
"minimax_global/..." matched nothing and a logged-in user read as unconfigured.
|
|
"""
|
|
import raven.rpc.methods.setup as setup
|
|
|
|
seen: list[str] = []
|
|
monkeypatch.setattr(
|
|
"raven.providers.minimax_oauth.load_token",
|
|
lambda region: seen.append(region) or object(),
|
|
)
|
|
for model in ("minimax_global/abab6.5", "minimax-global/abab6.5"):
|
|
seen.clear()
|
|
payload = {"agents": {"defaults": {"model": model}}}
|
|
assert setup._detect_provider_configured(payload) is True
|
|
assert seen == ["global"], model
|
|
|
|
|
|
async def test_setup_status_reads_the_config_raven_home_points_at(monkeypatch, tmp_path: Path) -> None:
|
|
"""``RAVEN_HOME`` decides where config.json lives for every other reader;
|
|
the setup gate used to hand-derive ``~/.raven`` and answer for the wrong
|
|
file when the variable was set."""
|
|
monkeypatch.setenv("RAVEN_HOME", str(tmp_path / "elsewhere"))
|
|
(tmp_path / "elsewhere").mkdir()
|
|
(tmp_path / "elsewhere" / "config.json").write_text(json.dumps({"agents": {"defaults": {"provider": "auto"}}}))
|
|
monkeypatch.setattr(Path, "home", lambda: tmp_path / "home")
|
|
|
|
assert (await setup_status({}))["provider_configured"] is False
|