From c13a0093c314c02fcaeb49472f85c9371913085d Mon Sep 17 00:00:00 2001 From: Erik Simon Date: Fri, 2 Oct 2026 23:54:48 +0200 Subject: [PATCH] =?UTF-8?q?feat(mars):=20honcho-console=20phase=203=20?= =?UTF-8?q?=E2=80=94=20metrics,=20stage=20models,=20spend?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Honcho now exports Prometheus metrics (METRICS_ENABLED) for the console's token, cost and latency views. The console prices each stage with the models read from honcho-api's own environment, and reads Honcho's OpenRouter key as a systemd credential for actual spend. Co-Authored-By: Claude Opus 5.5 --- flake.lock | 8 ++++---- hosts/mars/honcho-console.nix | 19 ++++++++++++++++++- hosts/mars/honcho.nix | 3 +++ 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 3d3f014..535837f 100644 --- a/flake.lock +++ b/flake.lock @@ -163,11 +163,11 @@ ] }, "locked": { - "lastModified": 1790976022, - "narHash": "sha256-e0Sd421oXTLc/wexJV67+6ZohJFN094JIUwWRe8aHFc=", + "lastModified": 1790978027, + "narHash": "sha256-vh99ByvfTONYlISdvOht5nznEAu9rIKHIqVvmxGgZos=", "ref": "refs/heads/master", - "rev": "7080b5615b8845e1a87b8b08af9af77f45c21a23", - "revCount": 4, + "rev": "b275d3d0d9e9df998af9d153c7431b7be5047531", + "revCount": 9, "type": "git", "url": "ssh://gitea@git.mgaction.town:2222/darman/honcho-console.git" }, diff --git a/hosts/mars/honcho-console.nix b/hosts/mars/honcho-console.nix index 8b5e953..ecc36d9 100644 --- a/hosts/mars/honcho-console.nix +++ b/hosts/mars/honcho-console.nix @@ -1,9 +1,14 @@ -{ inputs, ... }: +{ config, inputs, ... }: # Web console for luna's Honcho (honcho.nix). Bound on all interfaces but # its port stays closed in the firewall, so like Hermes' dashboard it is # reachable over tailscale0 only: http://mars.orbit.sol:8095. It can rewrite # luna's memory, so it stays off the LAN and off neptun. +let + # Honcho's own model settings, so cost per stage tracks honcho.nix. + env = config.virtualisation.oci-containers.containers.honcho-api.environment; + level = l: env."DIALECTIC_LEVELS__${l}__MODEL_CONFIG__MODEL"; +in { imports = [ inputs.honcho-console.nixosModules.default ]; @@ -14,6 +19,18 @@ allowWrites = true; cardSnapshotInterval = "15m"; representationSnapshotInterval = "24h"; + + stageModels = { + "deriver.ingestion" = env.DERIVER_MODEL_CONFIG__MODEL; + "deriver.summary" = env.SUMMARY_MODEL_CONFIG__MODEL; + "dreamer.deduction" = env.DREAM_DEDUCTION_MODEL_CONFIG__MODEL; + # card_refresh reuses the deduction model. + "dreamer.card_refresh" = env.DREAM_DEDUCTION_MODEL_CONFIG__MODEL; + "dreamer.induction" = env.DREAM_INDUCTION_MODEL_CONFIG__MODEL; + } // builtins.listToAttrs (map (l: { name = "dialectic.${l}"; value = level l; }) + [ "minimal" "low" "medium" "high" "max" ]); + # Honcho's key, used by nothing else: its usage is Honcho's actual spend. + openrouterKeyFile = config.sops.secrets.openrouter_api_key.path; }; # Honcho's tables must exist before the grant covers them. diff --git a/hosts/mars/honcho.nix b/hosts/mars/honcho.nix index 4bf65e4..c2c3619 100644 --- a/hosts/mars/honcho.nix +++ b/hosts/mars/honcho.nix @@ -20,6 +20,9 @@ let DB_CONNECTION_URI = "postgresql+psycopg://honcho@/honcho?host=/run/postgresql"; AUTH_USE_AUTH = "false"; CACHE_ENABLED = "false"; + # Read by honcho-console (token usage, latency). The deriver serves its own + # on 0.0.0.0:9090, which the firewall keeps off the LAN. + METRICS_ENABLED = "true"; HOME = "/tmp"; LLM_OPENAI_BASE_URL = "https://openrouter.ai/api/v1";