Dashboard: Connect dialog with the API key and opencode setup

The API key button is Connect again. Besides the key, it walks through adding this server to
opencode: type the API's address (remembered in the browser; prefilled on a LAN visit) and it
fills in a command that saves the key to a 0600 file without it touching shell history, and
the provider block from the same builder as `llmhost opencode-config`. GET /api/connect
replaces /api/key, behind the same sign-in.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-05 23:03:56 -08:00
parent 6fd82448c5
commit 04ff14c58f
4 changed files with 93 additions and 18 deletions

View file

@ -517,11 +517,17 @@ def make_handler(sampler, key, oidc=None):
elif path == "/api/status":
if self.authed():
self.send_json(200, sampler.snapshot())
elif path == "/api/key":
# For handing to clients. Behind the same sign-in as everything else here;
# send_json marks it no-store.
elif path == "/api/connect":
# What the Connect dialog hands to clients: the key, and opencode's provider
# block from the same builder as `llmhost opencode-config`. The public API
# address can't be known here, so the page fills in baseURL, the provider id
# and its label from what the viewer types. Behind the same sign-in as
# everything else; send_json marks it no-store.
if self.authed():
self.send_json(200, {"key": key})
cfg = paths.load_config() or sampler.cfg
block = opencode.provider_block(cfg, "HOST", "KEYFILE", "LABEL")
self.send_json(200, {"key": key, "api_port": cfg["api_port"],
"model": plan.SERVED_ALIAS, "opencode": block})
elif path == "/api/logs":
if self.authed():
lines = [l for l in service.logs("model", 1500)