Split the internet upgrades: API-only tunnel, OIDC, authenticator codes, expose-dashboard

install-newt now sets up the tunnel for the API only; the dashboard stays on the LAN.
Dashboard sign-in is its own step: install-oidc (the OIDC flow, split out) or install-otp,
which pairs authenticator apps with a QR code in the terminal (stdlib QR encoder, TOTP per
RFC 6238) so a code also opens the dashboard, with replay and lockout rules.
expose-dashboard walks through publishing the dashboard, only after install-newt, and
warns while it's protected by the API key alone; with codes it offers to switch the key off
for the dashboard. Each install-* has a remove-*.

Also opencode-install.sh: a standalone script, fetched from the repo, that installs opencode
if needed, saves the API key to a 0600 file and adds the provider to opencode.json for new
and existing configs. /v1/models reports whether the model reasons, for that script.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
neil 2026-11-06 15:56:54 -08:00
parent e6ff4ce909
commit c8b70afdbf
20 changed files with 1715 additions and 239 deletions

View file

@ -104,7 +104,8 @@ def run_server(cfg, entry, choice, args):
controls = hfcache.template_controls(choice["repo"])
srv = proxy.listen(port, proxy.make_handler(
inner, entry["name"], choice.get("est_context", entry["context"]), paths.api_key(), stats,
aliases=(choice.get("repo"),), reasoning=proxy.reasoning_setting(entry, controls)))
aliases=(choice.get("repo"),), reasoning=proxy.reasoning_setting(entry, controls),
reasons=choice.get("reasoning", entry.get("reasoning"))))
proxy.kill_stale(inner, VENV, "mlx_lm")
exe = str(VENV / "bin/mlx_lm.server")

View file

@ -73,10 +73,12 @@ def _uncached(usage):
def make_handler(inner_port, served_name, context, key, stats, aliases=(), reasoning=None,
upstream_model="default_model", upstream_key=None):
upstream_model="default_model", upstream_key=None, reasons=False):
"""upstream_model: what the inner server calls the loaded model ("default_model" makes
mlx_lm use the preloaded one; vLLM wants its --served-model-name). upstream_key: sent
on to an inner server that checks keys itself (vLLM)."""
on to an inner server that checks keys itself (vLLM). reasons: whether the model
thinks, reported in /v1/models so a client setup (opencode-install.sh) can configure
the model the way `llmhost opencode-config` does."""
# Names a client may call the loaded model: its llm-host name, its repo id, and the
# stable alias that means "whatever is loaded" (plan.SERVED_ALIAS).
accepted = {served_name.lower(), plan.SERVED_ALIAS, *(a.lower() for a in aliases if a)}
@ -121,7 +123,8 @@ def make_handler(inner_port, served_name, context, key, stats, aliases=(), reaso
return
if self.path.startswith("/v1/models"):
return self._json(200, {"object": "list", "data": [
{"id": served_name, "object": "model", "owned_by": "llm-host", "max_model_len": context}]})
{"id": served_name, "object": "model", "owned_by": "llm-host", "max_model_len": context,
"reasoning": bool(reasons)}]})
self._forward("GET", None)
def _model_ok(self, body):

View file

@ -175,7 +175,8 @@ def run_server(cfg, entry, choice, args):
srv = proxy.listen(port, proxy.make_handler(
inner, entry["name"], choice.get("est_context", entry["context"]), key, stats,
aliases=(choice.get("repo"),), reasoning=proxy.reasoning_setting(entry, controls),
upstream_model=entry["name"], upstream_key=key))
upstream_model=entry["name"], upstream_key=key,
reasons=choice.get("reasoning", entry.get("reasoning"))))
proxy.kill_stale(inner, VENV, "vllm")
exe = str(VENV / "bin/vllm")
# vLLM's output goes straight to ours (the service log); nothing in it needs reading.