From 58e0754449e927a5d1169b62305ad011e815f243 Mon Sep 17 00:00:00 2001 From: Drewry Pope Date: Mon, 23 Nov 2026 00:17:45 -0600 Subject: [PATCH] feat(ready-for-agent): package the pinned npm release as a Nix derivation + register the deploy target (#12909) ready-for-agent was the one #12768 service with no derivation to point a deploy definition at: an npm-pinned 1.1.0 install into ~/.local by pm-stack/ready-for-agent/install.sh. This slice packages it and registers it; the pm-apps unit's ExecStart cutover stays with the bundled #12768/#1752 slice. - pkgs/ready-for-agent/package.nix: the pinned 1.1.0 launcher + linux-x64 platform tarballs with fixed hashes. The launcher is a thin JS script that resolves the platform package through node's module resolution and spawns its Bun-compiled ELF, so the npm layout (platform package nested in the launcher's node_modules) is reproduced verbatim and the launcher runs unmodified; autoPatchelfHook patches the ELF (pkgs/claude-code shape). versionCheckHook asserts --version reports 1.1.0 in the build. - lib/default.nix: ready-for-agent package + app in make-pm-stack; the deploy-list check now greps for it. - pkgs/deploy/default.nix + services.nix: the ready-for-agent definition (bin/ready-for-agent, start --no-open, port 6056, health http://127.0.0.1:6056/, laptop/systemd) replacing the #12768 deferral comment. Verification (laptop worktree off origin/main): - nix build .#ready-for-agent succeeds; the result runs --version -> "ready-for-agent v1.1.0". - nix eval .#deployTargets.x86_64-linux: 19 targets including ready-for-agent with the definition fields above. --- lib/default.nix | 7 +- pkgs/deploy/default.nix | 3 + pkgs/deploy/services.nix | 33 +++++++--- pkgs/ready-for-agent/package.nix | 108 +++++++++++++++++++++++++++++++ 4 files changed, 141 insertions(+), 10 deletions(-) create mode 100644 pkgs/ready-for-agent/package.nix diff --git a/lib/default.nix b/lib/default.nix index a13d771d6..5b0760ae3 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1418,7 +1418,9 @@ let # dispatch, and git-sync as Nix derivations built from this repo's # pm-stack source. The nixos pm-stack module callPackages the same # files into its units; these outputs make `nix build .#pm-` - # the package-level check. + # the package-level check. ready-for-agent joins them from + # pkgs/ready-for-agent — the one pm-stack app packaged from its + # pinned upstream npm release rather than repo source (#12909). make-pm-stack = inputs.flake-utils.lib.eachDefaultSystem ( system: let @@ -1428,6 +1430,7 @@ let pm-aggregator = pkgs.callPackage ../pkgs/pm-aggregator/package.nix { }; pm-dispatch = pkgs.callPackage ../pkgs/pm-dispatch/package.nix { }; pm-git-sync = pkgs.callPackage ../pkgs/pm-git-sync/package.nix { }; + ready-for-agent = pkgs.callPackage ../pkgs/ready-for-agent/package.nix { }; }; mkApp = pkg: program: { type = "app"; @@ -1447,6 +1450,7 @@ let pm-aggregator-generate-digest = mkApp pmPackages.pm-aggregator "pm-aggregator-generate-digest"; pm-dispatch = mkApp pmPackages.pm-dispatch "pm-dispatch"; pm-git-sync = mkApp pmPackages.pm-git-sync "pm-git-sync"; + ready-for-agent = mkApp pmPackages.ready-for-agent "ready-for-agent"; }; } ); @@ -1609,6 +1613,7 @@ let grep -q "pm-aggregator" list.txt grep -q "pm-projector" list.txt grep -q "pm-tunnel" list.txt + grep -q "ready-for-agent" list.txt grep -q "quota-recorder" list.txt grep -q "session-proxy" list.txt grep -q "mcpx" list.txt diff --git a/pkgs/deploy/default.nix b/pkgs/deploy/default.nix index 0e094b84c..4830385a4 100644 --- a/pkgs/deploy/default.nix +++ b/pkgs/deploy/default.nix @@ -64,6 +64,9 @@ let pmAggregator = callPackage ../pm-aggregator/package.nix { }; pmProjector = callPackage ../pm-projector/package.nix { }; pmTunnel = cloudflared; + # Issue #12909: ready-for-agent, packaged from its pinned npm + # tarballs — the last of the four #12768 services to register. + readyForAgent = callPackage ../ready-for-agent/package.nix { }; }; jsonDefinitions = lib.mapAttrs (name: defn: defn // { package = "${defn.package}"; }) definitions; in diff --git a/pkgs/deploy/services.nix b/pkgs/deploy/services.nix index edad75c67..178c6631a 100644 --- a/pkgs/deploy/services.nix +++ b/pkgs/deploy/services.nix @@ -27,6 +27,7 @@ pmAggregator, pmProjector, pmTunnel, + readyForAgent, }: { queue-broker = { @@ -428,13 +429,27 @@ class = "systemd"; }; - # ready-for-agent - NOT registered here yet, deliberately, on - # issue #12768's own terms: it has no Nix derivation to point a - # definition at (it is an npm-pinned 1.1.0 install into ~/.local by - # pm-stack/ready-for-agent/install.sh), and its deployment of - # record is the NixOS pm-apps module under #1752. Registration - # waits on the packaging slice, #12909; when that lands, its - # definition (bin/ready-for-agent, args [ "start" "--no-open" ], - # ports [ 6056 ], healthCheck http://127.0.0.1:6056/) replaces - # this comment. + # ready-for-agent (#12909): the Harness UI + operator CLI. Its + # deployment of record is still the NixOS pm-apps module under + # #1752, whose unit runs the imperative ~/.local install + # (pm-stack/ready-for-agent/install.sh) — this definition is + # registration only, like the other pm-stack targets above, until + # the bundled cutover (#12768) switches the unit's ExecStart to + # this derivation. + ready-for-agent = { + package = readyForAgent; + entryPoint = "bin/ready-for-agent"; + args = [ + "start" + "--no-open" + ]; + environment = { }; + secrets = [ ]; # the harness reads its own on-disk config; no broker-resolved names + user = "user"; + ports = [ 6056 ]; # Harness UI + GraphQL, loopback + restart = "on-failure"; + healthCheck = "http://127.0.0.1:6056/"; + targets = [ "laptop" ]; + class = "systemd"; + }; } diff --git a/pkgs/ready-for-agent/package.nix b/pkgs/ready-for-agent/package.nix new file mode 100644 index 000000000..82f407af0 --- /dev/null +++ b/pkgs/ready-for-agent/package.nix @@ -0,0 +1,108 @@ +{ + lib, + stdenvNoCC, + fetchurl, + autoPatchelfHook, + makeWrapper, + nodejs, + versionCheckHook, +}: + +# ready-for-agent — the PM stack's dispatch-layer Harness UI + operator +# CLI (pm-stack Phase 2), packaged from the pinned upstream npm release +# (code#12909; the packaging half of the #12768 deploy registration). +# +# Until this derivation existed, the laptop installed the package +# imperatively: pm-stack/ready-for-agent/install.sh runs +# `npm install -g --prefix ~/.local ready-for-agent@1.1.0`, and the +# NixOS pm-apps module's user unit (#1752) runs +# ~/.local/bin/ready-for-agent. This package gives the deploy registry +# a derivation to point a definition at; switching the pm-apps unit's +# ExecStart to the store binary is the bundled-cutover question on +# #12768/#1752, not this slice. +# +# DISTRIBUTION SHAPE -- why two tarballs: `ready-for-agent` is a thin +# JS launcher (bin/ready-for-agent.js, node >= 20) that resolves the +# platform package `ready-for-agent-linux-x64` through node's module +# resolution and spawns its bin/ready-for-agent, a Bun-compiled +# standalone ELF. npm installs the platform package as an +# optionalDependency nested in the launcher's node_modules; that exact +# layout is reproduced here from the two pinned tarballs, so the +# launcher runs unmodified. The payload is a dynamically linked ELF, +# hence autoPatchelfHook. Same shape as pkgs/claude-code. +# +# To update: bump version, then +# nix store prefetch-file --json \ +# https://registry.npmjs.org/ready-for-agent/-/ready-for-agent-.tgz +# nix store prefetch-file --json \ +# https://registry.npmjs.org/ready-for-agent-linux-x64/-/ready-for-agent-linux-x64-.tgz +# (the platform packages track the launcher version exactly), and bump +# PINNED_VERSION in pm-stack/ready-for-agent/install.sh in the same +# pass, until the cutover retires the imperative install. + +let + version = "1.1.0"; + + launcher = fetchurl { + url = "https://registry.npmjs.org/ready-for-agent/-/ready-for-agent-${version}.tgz"; + hash = "sha256-OGo+u1+0dwggc7mt6xrynPJzpZs9J3zOT7lrbpOKvEA="; + }; + + platformPkg = fetchurl { + url = "https://registry.npmjs.org/ready-for-agent-linux-x64/-/ready-for-agent-linux-x64-${version}.tgz"; + hash = "sha256-YrhxxGHTWht7A9O3XJemwqfdGw0VyZQ2ISGsIJU6DtU="; + }; +in +stdenvNoCC.mkDerivation { + pname = "ready-for-agent"; + inherit version; + + dontUnpack = true; + + nativeBuildInputs = [ + autoPatchelfHook + makeWrapper + ]; + + # Upstream ships the Bun payload stripped; re-stripping gains nothing. + dontStrip = true; + + installPhase = '' + runHook preInstall + + # The launcher package, verbatim (npm tarballs root at package/). + mkdir -p "$out/lib/ready-for-agent" + tar -xzf ${launcher} -C "$out/lib/ready-for-agent" --strip-components=1 + + # The platform package where the launcher's module resolution + # looks for it: nested node_modules, exactly as npm's + # optionalDependency install lays it down. + mkdir -p "$out/lib/ready-for-agent/node_modules/ready-for-agent-linux-x64" + tar -xzf ${platformPkg} \ + -C "$out/lib/ready-for-agent/node_modules/ready-for-agent-linux-x64" \ + --strip-components=1 + chmod +x "$out/lib/ready-for-agent/node_modules/ready-for-agent-linux-x64/bin/ready-for-agent" + + install -Dm644 "$out/lib/ready-for-agent/README.md" \ + "$out/share/doc/ready-for-agent/README.md" + + makeWrapper ${lib.getExe nodejs} "$out/bin/ready-for-agent" \ + --add-flags "$out/lib/ready-for-agent/bin/ready-for-agent.js" + + runHook postInstall + ''; + + nativeInstallCheckInputs = [ versionCheckHook ]; + versionCheckProgramArg = "--version"; + doInstallCheck = true; + + meta = { + description = "Ready for Agent: local Harness UI + backend and operator CLI"; + homepage = "https://github.com/berenddeboer/ready-for-agent"; + downloadPage = "https://www.npmjs.com/package/ready-for-agent"; + license = lib.licenses.mit; + mainProgram = "ready-for-agent"; + platforms = [ "x86_64-linux" ]; + sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; + }; +}