mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 13:29:19 +08:00
fix(install): distinguish protocol targets in status
This commit is contained in:
@@ -90,6 +90,8 @@ headroom install remove
|
||||
|
||||
`apply` creates or updates a named deployment profile, stores its manifest under `~/.headroom/deploy/<profile>/manifest.json`, applies reversible configuration changes, and starts the selected runtime.
|
||||
|
||||
`status` distinguishes the default backend from the Anthropic and OpenAI protocol targets. Each target is shown as `configured` or `default`; target URLs and credentials are not printed. An OpenAI-compatible deployment can therefore have `Default backend: anthropic` and `OpenAI target: configured` at the same time.
|
||||
|
||||
## Presets and runtime kinds
|
||||
|
||||
### Presets
|
||||
|
||||
@@ -1180,7 +1180,13 @@ def install_status(profile: str) -> None:
|
||||
config = payload.get("config")
|
||||
if not isinstance(config, dict):
|
||||
config = {}
|
||||
click.echo(f"Backend: {config.get('backend', manifest.backend)}")
|
||||
click.echo(f"Default backend: {config.get('backend', manifest.backend)}")
|
||||
click.echo(
|
||||
f"Anthropic target: {'configured' if config.get('anthropic_api_url') else 'default'}"
|
||||
)
|
||||
click.echo(
|
||||
f"OpenAI target: {'configured' if config.get('openai_api_url') else 'default'}"
|
||||
)
|
||||
|
||||
|
||||
@install.command("start")
|
||||
|
||||
@@ -449,69 +449,6 @@ def test_install_apply_explicit_env_overrides_captured(monkeypatch) -> None:
|
||||
assert captured["extra_env"]["ANTHROPIC_TARGET_API_URL"] == "https://explicit.internal/v1"
|
||||
|
||||
|
||||
def test_install_status_includes_backend_from_health_probe(monkeypatch) -> None:
|
||||
runner = CliRunner()
|
||||
|
||||
class Manifest:
|
||||
targets = ["claude"]
|
||||
tool_envs = {}
|
||||
profile = "default"
|
||||
preset = "persistent-service"
|
||||
runtime_kind = "python"
|
||||
supervisor_kind = "service"
|
||||
scope = "user"
|
||||
port = 8787
|
||||
backend = "anthropic"
|
||||
health_url = "http://127.0.0.1:8787/readyz"
|
||||
|
||||
monkeypatch.setattr("headroom.cli.install.load_manifest", lambda profile: Manifest())
|
||||
monkeypatch.setattr(
|
||||
"headroom.cli.install.runtime_status",
|
||||
lambda manifest: "running",
|
||||
)
|
||||
monkeypatch.setattr("headroom.cli.install.probe_ready", lambda url: True)
|
||||
monkeypatch.setattr(
|
||||
"headroom.cli.install.probe_json",
|
||||
lambda url: {"config": {"backend": "anthropic"}},
|
||||
)
|
||||
|
||||
result = runner.invoke(main, ["install", "status"])
|
||||
|
||||
assert result.exit_code == 0, result.output
|
||||
assert "Status: running" in result.output
|
||||
assert "Healthy: yes" in result.output
|
||||
assert "Backend: anthropic" in result.output
|
||||
|
||||
|
||||
def test_install_status_survives_non_dict_config(monkeypatch) -> None:
|
||||
"""A health payload whose `config` is a non-dict (e.g. a different service
|
||||
answering on the port returns config: null) must not crash the command."""
|
||||
runner = CliRunner()
|
||||
|
||||
class Manifest:
|
||||
targets = ["claude"]
|
||||
tool_envs = {}
|
||||
profile = "default"
|
||||
preset = "persistent-service"
|
||||
runtime_kind = "python"
|
||||
supervisor_kind = "service"
|
||||
scope = "user"
|
||||
port = 8787
|
||||
backend = "anthropic"
|
||||
health_url = "http://127.0.0.1:8787/readyz"
|
||||
|
||||
monkeypatch.setattr("headroom.cli.install.load_manifest", lambda profile: Manifest())
|
||||
monkeypatch.setattr("headroom.cli.install.runtime_status", lambda manifest: "running")
|
||||
monkeypatch.setattr("headroom.cli.install.probe_ready", lambda url: True)
|
||||
monkeypatch.setattr("headroom.cli.install.probe_json", lambda url: {"config": None})
|
||||
|
||||
result = runner.invoke(main, ["install", "status"])
|
||||
|
||||
# No AttributeError; Backend falls back to the manifest value.
|
||||
assert result.exit_code == 0, result.output
|
||||
assert "Backend: anthropic" in result.output
|
||||
|
||||
|
||||
def test_install_restart_uses_internal_helpers(monkeypatch) -> None:
|
||||
runner = CliRunner()
|
||||
calls: list[str] = []
|
||||
|
||||
Reference in New Issue
Block a user