From c310ce57f4488c319768ac87ad56bda81e7fa814 Mon Sep 17 00:00:00 2001 From: m3ta-chiron Date: Sat, 31 Oct 2026 11:18:49 +0100 Subject: [PATCH 1/2] =?UTF-8?q?feat(m3-hermes):=20T3=20Code=20cockpit=20?= =?UTF-8?q?=E2=80=94=20t3=20serve=20systemd=20service,=20mesh-only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three-lane agent setup (interactive cockpit / autonomous workers / Hermes control lane): T3 Code server runs on m3-hermes as a systemd service under the m3tam3re user, reachable only from the NetBird mesh (direct pairing, no T3 Connect cloud relay). - hosts/m3-hermes/services/t3code.nix: t3 serve on port 3773 (port registry), User=m3tam3re, keyless m3ta-gateway opencode config for harnesses, claude-code/opencode2 in service PATH - ports.nix: t3code = 3773 - fix netbirdRange in ai-memory.nix + hermes-dashboard.nix: the fleet mesh actually runs in 100.81.0.0/16 (wt0 kernel route), the previous 100.64.0.0/16 rules never matched any real peer One-time steps after deploy (documented in the module header): sudo -u m3tam3re claude auth login; t3 pair for client devices. --- hosts/common/ports.nix | 3 + hosts/m3-hermes/services/ai-memory.nix | 3 +- hosts/m3-hermes/services/default.nix | 1 + hosts/m3-hermes/services/hermes-dashboard.nix | 2 +- hosts/m3-hermes/services/t3code.nix | 108 ++++++++++++++++++ 5 files changed, 115 insertions(+), 2 deletions(-) create mode 100644 hosts/m3-hermes/services/t3code.nix diff --git a/hosts/common/ports.nix b/hosts/common/ports.nix index 822950b..e03da32 100644 --- a/hosts/common/ports.nix +++ b/hosts/common/ports.nix @@ -46,6 +46,9 @@ hermes-dashboard = 9119; ai-memory = 49374; + # Agent cockpit + t3code = 3773; + # Home automation homarr = 7575; diff --git a/hosts/m3-hermes/services/ai-memory.nix b/hosts/m3-hermes/services/ai-memory.nix index 8859826..e605205 100644 --- a/hosts/m3-hermes/services/ai-memory.nix +++ b/hosts/m3-hermes/services/ai-memory.nix @@ -5,7 +5,8 @@ }: let # Netbird mesh VPN range — the server is only reachable from mesh peers. # m3-atlas Traefik proxies memory.m3ta.dev to this port over Netbird. - netbirdRange = "100.64.0.0/16"; + # (Fleet mesh address block is 100.81.0.0/16 — kernel route on wt0.) + netbirdRange = "100.81.0.0/16"; port = config.m3ta.ports.get "ai-memory"; in { # ── ai-memory server ────────────────────────────────────────────────── diff --git a/hosts/m3-hermes/services/default.nix b/hosts/m3-hermes/services/default.nix index df3d708..f5054b0 100644 --- a/hosts/m3-hermes/services/default.nix +++ b/hosts/m3-hermes/services/default.nix @@ -5,5 +5,6 @@ ./hermes-dashboard.nix ./ai-memory.nix ./netbird.nix + ./t3code.nix ]; } diff --git a/hosts/m3-hermes/services/hermes-dashboard.nix b/hosts/m3-hermes/services/hermes-dashboard.nix index 4304e87..effcb13 100644 --- a/hosts/m3-hermes/services/hermes-dashboard.nix +++ b/hosts/m3-hermes/services/hermes-dashboard.nix @@ -6,7 +6,7 @@ }: let # Netbird mesh VPN range — dashboard only accessible from mesh peers. # m3-atlas Traefik proxies to this port over Netbird. - netbirdRange = "100.64.0.0/16"; + netbirdRange = "100.81.0.0/16"; apiPort = config.m3ta.ports.get "hermes-api"; dashboardPort = config.m3ta.ports.get "hermes-dashboard"; diff --git a/hosts/m3-hermes/services/t3code.nix b/hosts/m3-hermes/services/t3code.nix new file mode 100644 index 0000000..b296646 --- /dev/null +++ b/hosts/m3-hermes/services/t3code.nix @@ -0,0 +1,108 @@ +# T3 Code server (https://t3.codes) — interactive coding-agent cockpit. +# +# Part of the three-lane agent setup (agreed 2026-10-26): +# - Lane 1, interactive cockpit: T3 Code on m3-hermes, reached over the +# NetBird mesh via direct pairing (no T3 Connect cloud relay). +# - Lane 2, autonomous workers: herdr sandbox (see herdr-sandbox.nix). +# - Lane 3, control & inbox: Hermes via Matrix (unchanged). +# +# Flow: T3 desktop/mobile app ──NetBird mesh──▶ wt0 :3773 (this server). +# The server binds 0.0.0.0, but the firewall admits the port for mesh +# peers only — same posture as ai-memory and the hermes dashboard. +# +# One-time interactive steps after deploy (deliberately NOT declarative): +# - Pair clients: `sudo -u m3tam3re t3 pair` (or take the pairing URL +# from `journalctl -u t3code` after first start) and add the +# environment in the T3 app via the printed URL/QR code. +# - Claude Code login once: `sudo -u m3tam3re claude auth login` +# (state persists in /home/m3tam3re/.claude). +# - OpenCode needs no login: ~/.config/opencode/opencode.jsonc is +# symlinked below to the keyless m3ta-gateway endpoint. +{ + config, + pkgs, + ... +}: let + # NetBird mesh range of this fleet (kernel route: 100.81.0.0/16 dev wt0). + netbirdRange = "100.81.0.0/16"; + port = config.m3ta.ports.get "t3code"; + + # Keyless LLM endpoint for harnesses spawned by T3 Code — the same + # endpoint the herdr sandbox workers use (the proxy injects provider + # keys server-side; budget caps live in the NetBird policy). + cockpitOpencodeConfig = pkgs.writeText "opencode.jsonc" (builtins.toJSON { + "$schema" = "https://opencode.ai/config.json"; + provider = { + m3ta-gateway = { + npm = "@ai-sdk/openai-compatible"; + name = "m3ta-gateway"; + options = { + baseURL = "https://downy-cardamom.p.m3ta.dev/v1"; + apiKey = "none"; + }; + models = { + claude-sonnet-5 = { + name = "Claude Sonnet 5"; + }; + claude-opus-5 = { + name = "Claude Opus 5"; + }; + }; + }; + }; + model = "m3ta-gateway/claude-sonnet-5"; + }); +in { + # CLI on the system for interactive admin (t3 pair, t3 service status) + # plus the harnesses T3 Code orchestrates. Login shells need them for + # the one-time auth flows documented in the header. + environment.systemPackages = [ + pkgs.llm-agents.t3code + pkgs.llm-agents.opencode2 + pkgs.llm-agents.claude-code + ]; + + # OpenCode provider config for the cockpit user (mirrors herdr-sandbox). + systemd.tmpfiles.rules = [ + "d /home/m3tam3re/.config 0750 m3tam3re users -" + "d /home/m3tam3re/.config/opencode 0750 m3tam3re users -" + "L+ /home/m3tam3re/.config/opencode/opencode.jsonc - - - - ${cockpitOpencodeConfig}" + ]; + + # ── T3 Code server (system service, cockpit user) ──────────────────── + systemd.services.t3code = { + description = "T3 Code server (interactive coding-agent cockpit)"; + after = ["network-online.target"]; + wants = ["network-online.target"]; + wantedBy = ["multi-user.target"]; + + serviceConfig = { + User = "m3tam3re"; + Group = "users"; + WorkingDirectory = "/home/m3tam3re"; + ExecStart = "${pkgs.llm-agents.t3code}/bin/t3 serve --host 0.0.0.0"; + Restart = "on-failure"; + RestartSec = "5"; + }; + + environment.T3CODE_PORT = toString port; + + # Harness CLIs and git for the agents T3 Code spawns. + path = with pkgs; [ + git + llm-agents.opencode2 + llm-agents.claude-code + ]; + }; + + networking.firewall = { + extraCommands = '' + # Allow t3code only from Netbird mesh VPN + ip46tables -A nixos-fw -p tcp --dport ${toString port} -s ${netbirdRange} -j nixos-fw-accept + ''; + + extraStopCommands = '' + ip46tables -D nixos-fw -p tcp --dport ${toString port} -s ${netbirdRange} -j nixos-fw-accept 2>/dev/null || true + ''; + }; +} -- 2.56.0 From 275546f0ee53e503e75800251a230b479ea059a8 Mon Sep 17 00:00:00 2001 From: m3ta-chiron Date: Sat, 31 Oct 2026 12:12:06 +0100 Subject: [PATCH 2/2] =?UTF-8?q?fix(t3code):=20drop=20gateway=20symlink=20?= =?UTF-8?q?=E2=80=94=20subscription=20login=20per=20harness?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subscription auth (Claude Code, OpenCode) must live in each harness's own credential store; providers do not allow routing subscriptions through other tools. The keyless m3ta-gateway stays herdr-worker-only. Both harnesses now login interactively once after deploy (see module header). --- hosts/m3-hermes/services/t3code.nix | 45 +++++------------------------ 1 file changed, 7 insertions(+), 38 deletions(-) diff --git a/hosts/m3-hermes/services/t3code.nix b/hosts/m3-hermes/services/t3code.nix index b296646..6f98d1a 100644 --- a/hosts/m3-hermes/services/t3code.nix +++ b/hosts/m3-hermes/services/t3code.nix @@ -10,14 +10,16 @@ # The server binds 0.0.0.0, but the firewall admits the port for mesh # peers only — same posture as ai-memory and the hermes dashboard. # -# One-time interactive steps after deploy (deliberately NOT declarative): +# One-time interactive steps after deploy (deliberately NOT declarative — +# subscription auth must live in each harness's own credential store and +# may not be shared with other tools per provider ToS): # - Pair clients: `sudo -u m3tam3re t3 pair` (or take the pairing URL # from `journalctl -u t3code` after first start) and add the # environment in the T3 app via the printed URL/QR code. -# - Claude Code login once: `sudo -u m3tam3re claude auth login` -# (state persists in /home/m3tam3re/.claude). -# - OpenCode needs no login: ~/.config/opencode/opencode.jsonc is -# symlinked below to the keyless m3ta-gateway endpoint. +# - Claude Code: `sudo -u m3tam3re claude auth login` +# (persists in /home/m3tam3re/.claude). +# - OpenCode: `sudo -u m3tam3re opencode auth login` +# (subscription auth persists in OpenCode's own state dir). { config, pkgs, @@ -26,32 +28,6 @@ # NetBird mesh range of this fleet (kernel route: 100.81.0.0/16 dev wt0). netbirdRange = "100.81.0.0/16"; port = config.m3ta.ports.get "t3code"; - - # Keyless LLM endpoint for harnesses spawned by T3 Code — the same - # endpoint the herdr sandbox workers use (the proxy injects provider - # keys server-side; budget caps live in the NetBird policy). - cockpitOpencodeConfig = pkgs.writeText "opencode.jsonc" (builtins.toJSON { - "$schema" = "https://opencode.ai/config.json"; - provider = { - m3ta-gateway = { - npm = "@ai-sdk/openai-compatible"; - name = "m3ta-gateway"; - options = { - baseURL = "https://downy-cardamom.p.m3ta.dev/v1"; - apiKey = "none"; - }; - models = { - claude-sonnet-5 = { - name = "Claude Sonnet 5"; - }; - claude-opus-5 = { - name = "Claude Opus 5"; - }; - }; - }; - }; - model = "m3ta-gateway/claude-sonnet-5"; - }); in { # CLI on the system for interactive admin (t3 pair, t3 service status) # plus the harnesses T3 Code orchestrates. Login shells need them for @@ -62,13 +38,6 @@ in { pkgs.llm-agents.claude-code ]; - # OpenCode provider config for the cockpit user (mirrors herdr-sandbox). - systemd.tmpfiles.rules = [ - "d /home/m3tam3re/.config 0750 m3tam3re users -" - "d /home/m3tam3re/.config/opencode 0750 m3tam3re users -" - "L+ /home/m3tam3re/.config/opencode/opencode.jsonc - - - - ${cockpitOpencodeConfig}" - ]; - # ── T3 Code server (system service, cockpit user) ──────────────────── systemd.services.t3code = { description = "T3 Code server (interactive coding-agent cockpit)"; -- 2.56.0