From 14200a2927be1444996f50b21d0385c128be1a27 Mon Sep 17 00:00:00 2001 From: repo-worker-tmp-code-b Date: Tue, 17 Nov 2026 02:53:21 -0600 Subject: [PATCH] feat(deploy): register laptop-agent in the services layer (#5769 M2) One services-layer definition for laptop-agent in pkgs/deploy/services.nix (package pkgs/laptop-agent, reconciled in #10131), wired through pkgs/deploy/default.nix. restart=always per the 2026-11-16 daemon-death lesson (#2879); healthCheck=null because /health is token-gated (401) and the deploy probe cannot present a token - health is verified via the authenticated client after activation. Also bring the queue-broker definition in line with the live unit: QUEUE_BROKER_BACKEND=turso (#6741) and the Turso token named in secrets. --- pkgs/deploy/default.nix | 1 + pkgs/deploy/services.nix | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/pkgs/deploy/default.nix b/pkgs/deploy/default.nix index 2820debac6..b68457122d 100644 --- a/pkgs/deploy/default.nix +++ b/pkgs/deploy/default.nix @@ -21,6 +21,7 @@ let fleetPkgs = callPackage ../fleet { inherit sourceRev; }; definitions = import ./services.nix { inherit (fleetPkgs) fleet; + laptopAgent = callPackage ../laptop-agent/package.nix { }; mcpx = callPackage ../mcpx/package.nix { }; routeProxy = callPackage ./route-proxy.nix { }; # The existing Cloudflare deploy apps (issue #5767, phase 1) — the diff --git a/pkgs/deploy/services.nix b/pkgs/deploy/services.nix index 21241a1320..00addbb95d 100644 --- a/pkgs/deploy/services.nix +++ b/pkgs/deploy/services.nix @@ -12,6 +12,7 @@ # service (systemd / launchd / cloudflare / sandbox / container). { fleet, + laptopAgent, mcpx, routeProxy, idMailDeploy, @@ -28,10 +29,16 @@ ]; environment = { PORT = "4801"; # PORT_QUEUE_BROKER, pkgs/fleet/crates/fleet-config + # Live since the Turso cutover (#6741): matches the + # 30-turso-queue.conf drop-in the running unit carries. + QUEUE_BROKER_BACKEND = "turso"; }; # Names only — values are resolved by the secrets broker at # activation time (later slice); a definition never carries a value. - secrets = [ "supabase.muse-dev2.service-role-key" ]; + secrets = [ + "turso.fleet-queue-rw-token" # the Turso backend token, by name + "supabase.muse-dev2.service-role-key" # legacy Postgres backend + ]; user = "user"; ports = [ 4801 ]; restart = "on-failure"; @@ -59,6 +66,33 @@ class = "systemd"; }; + laptop-agent = { + package = laptopAgent; + entryPoint = "bin/laptop-agent"; + args = [ ]; + environment = { + LAPTOP_AGENT_HOST = "100.99.113.103"; + LAPTOP_AGENT_PORT = "4799"; + }; + # The daemon token is a local file (~/.config/laptop-agent/token) + # the daemon reads itself at startup; no broker-resolved secrets. + secrets = [ ]; + user = "user"; + ports = [ 4799 ]; + # The hand-written unit this replaces ran Restart=always: the + # 2026-11-16 daemon-death episode (code#2879) showed on-failure + # does not restart a clean (SIGTERM/success) exit. + restart = "always"; + # No unauthenticated health endpoint exists: /health requires the + # daemon token (401 without it), which the deploy probe cannot + # present, so healthCheck stays null (the session-proxy/mcpx + # shape) and health is verified through the authenticated client + # (laptop-agent.py health) after activation - issue #5769. + healthCheck = null; + targets = [ "laptop" ]; + class = "systemd"; + }; + session-proxy = { package = fleet; entryPoint = "bin/fleet";