fix(agent-terminal): approve node-pty install scripts for npm 12 - #1411
Merged
Conversation
npm 12 blocks dependency lifecycle scripts unless the installing project names the package in allowScripts. node-pty ships prebuilds for macOS and Windows only, so on Linux its install script is what compiles build/Release/pty.node. The generated managed-runtime package.json declared no allowScripts, so npm installed the tree, exited 0, and the Agent tab later failed with "Agent terminal runtime could not load WebTUI". Generate the runtime manifest with a name-only node-pty approval, and verify after install that pty.node actually exists (build/Release, build/Debug, or prebuilds/<platform>-<arch>, which is node-pty's own resolution order). A missing binary now triggers one targeted npm rebuild and, if that does not repair it, fails provisioning with the blocked-scripts diagnostic and the manual remedy instead of leaving a runtime that looks installed. Closes #1409
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On npm 12 the managed agent-terminal runtime installs but cannot run.
npm 12 no longer runs dependency lifecycle scripts (
preinstall,install,postinstall, and implicit node-gyp builds) unless the installing project approves the package by name in anallowScriptsfield.node-pty1.1.0 ships prebuilds fordarwin-arm64,darwin-x64,win32-arm64andwin32-x64only, so on Linux itsinstallscript is the thing that compilesbuild/Release/pty.node.writeRuntimePackageJsongenerated a manifest with noallowScripts, sonpm install --omit=dev ... @plannotator/webtui@0.1.0skipped node-pty's scripts, exited 0, and left a runtime with no native binary. The failure only surfaced later, when opening the Agent tab, as "Agent terminal runtime could not load WebTUI". The provisioning failure that did exist was worded as "Skipping agent terminal runtime install", which reads like a benign skip rather than a broken runtime.Reported by @smartobc-stephen, with the npm warning text, the node-pty resolution paths, and the local repair steps all included. That report is what made this diagnosable without an npm 12 machine.
Changes
packages/server/agent-terminal-runtime.tsbuildAgentTerminalRuntimePackageJson()(extracted fromwriteRuntimePackageJson) now emits"allowScripts": { "node-pty": true }alongside the existing pinned@plannotator/webtuidependency.verifyAgentTerminalNativeBinary(runtimeDir)runs afternpm installand before the existing WebTUI import preflight. It mirrors node-pty's own resolution order fromlib/utils.js(build/Release,build/Debug, thenprebuilds/<platform>-<arch>) and looks forpty.node.npm rebuild node-ptyand re-verifies. If the binary is still absent, provisioning fails with a message that names npm's script blocking and gives the exact repair command, instead of returning a runtime that looks installed.packages/server/agent-terminal-runtime.test.tsbuild/Releaseand on a matching platform prebuild.pty.nodeproduces the actionable error.On the proposed fix
Taken, with one amendment. The proposal used a version-pinned key,
"node-pty@1.1.0": true. npm matchesallowScriptskeys as exact strings, with no semver range support, and@plannotator/webtuidepends onnode-pty: ^1.1.0. The managed runtime installs with no lockfile, so the first node-pty patch release would make a pinned entry stop matching and silently reintroduce this exact bug. The name-only form keeps matching and is still narrow: exactly one package, never a blanket allow. node-pty is also the only package in that tree with lifecycle scripts, so one entry is sufficient.The field is inert on older npm, which ignores unknown top-level manifest keys. Verified on npm 11.12.1:
npm installaccepts the manifest without a warning and preserves the field when it rewritespackage.json.Verification
bun test packages/server/agent-terminal-runtime.test.ts packages/server/agent-terminal.test.ts: 14 pass, 0 fail.bunx tsc --noEmit -p packages/server/tsconfig.json: clean.installAgentTerminalRuntime()against a tempPLANNOTATOR_DATA_DIRreturnsinstalled, the written manifest keepsallowScripts, and the native check passes via thedarwin-arm64prebuild. The existing working path is unchanged.bun test packages/server/has 18 pre-existing failures in this environment (missingapps/pi-extension/generated/*vendored files and nosemsidecar). Confirmed identical on the base commit with the change stashed.Runtime coverage
Bun only. The managed runtime provisioning in
packages/server/agent-terminal-runtime.tshas no Pi mirror:apps/pi-extensiondeclares@plannotator/webtuias a direct dependency of the extension itself and imports it in process, so it never generates a runtime manifest.apps/pi-extension/vendor.shvendorspackages/core/agent-terminal.ts(types and layout helpers), not this file. Nothing to change on the Pi path.Not done
smoke_test_agent_terminalalready runsinstall-runtime agent-terminalon Linux, so it will start failing loudly once runners ship npm 12, which is the behavior the issue asked for. A dedicated pinned-npm-12 matrix leg is a separate change.Closes #1409
AI-assisted (Claude) under maintainer direction.