diff --git a/default.nix b/default.nix index bc39debfa..88a2b8da8 100644 --- a/default.nix +++ b/default.nix @@ -31,13 +31,6 @@ let ./packages/client ./packages/transcript-core ./packages/transcript-html - # pnpm.patchedDependencies entries — read by pnpm during install and - # applied to the upstream tarball. Currently: - # - node-pty@1.1.0.patch: adds a foregroundPid accessor wrapping - # tcgetpgrp(masterFd). Upstream feature request: - # https://github.com/microsoft/node-pty/issues/913 — drop this - # patch once that lands. - ./patches ]; }; @@ -52,7 +45,7 @@ let # hash-fresh` enforces this stays in sync with pnpm-lock.yaml by forcing # fetchPnpmDeps to re-execute (--rebuild), so stale artifacts in the # binary cache can't silently satisfy a hash that no longer matches. - hash = "sha256-TW9ejq4ubRQzV2QeZs8gkXZcHYVmIv9u5E4r+pQpjm8="; + hash = "sha256-KIDaKB+Kf+dUUP/a4R7JPj2c5oQIh4z0fFs5OU9J+Lw="; fetcherVersion = 3; }; diff --git a/package.json b/package.json index 19654bd90..29e74bb91 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,6 @@ "@anthropic-ai/sdk": "^0.91.1", "@xterm/xterm": "github:juspay/xterm.js#fix/kolu-xterm-fixes-built", "@xterm/addon-webgl": "github:juspay/xterm.js#fix/kolu-xterm-fixes-built&path:/addons/addon-webgl" - }, - "patchedDependencies": { - "node-pty@1.1.0": "patches/node-pty@1.1.0.patch" } }, "devDependencies": { diff --git a/packages/server/package.json b/packages/server/package.json index 1751d2ab4..1d63e1429 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -34,7 +34,7 @@ "kolu-opencode": "workspace:*", "kolu-shared": "workspace:*", "kolu-transcript-html": "workspace:*", - "node-pty": "^1.0.0", + "node-pty": "github:juspay/node-pty#fix/darwin-pty-fd-leak", "pino": "^10.3.1", "pino-pretty": "^13.1.3", "selfsigned": "^5.5.0", diff --git a/patches/node-pty@1.1.0.patch b/patches/node-pty@1.1.0.patch deleted file mode 100644 index f88f997e3..000000000 --- a/patches/node-pty@1.1.0.patch +++ /dev/null @@ -1,80 +0,0 @@ -diff --git a/lib/unixTerminal.js b/lib/unixTerminal.js -index 1ec12f796a822c78fba9ad7f6448c3987e325c23..ebf97b4eca3a246f7a7d50ea0505267cb91cb291 100644 ---- a/lib/unixTerminal.js -+++ b/lib/unixTerminal.js -@@ -166,6 +166,11 @@ var UnixTerminal = /** @class */ (function (_super) { - enumerable: false, - configurable: true - }); -+ Object.defineProperty(UnixTerminal.prototype, "foregroundPid", { -+ get: function () { return pty.foregroundPid(this._fd); }, -+ enumerable: false, -+ configurable: true -+ }); - /** - * openpty - */ -diff --git a/package.json b/package.json -index 94a2c14381727674b8964c1b50e5e47a9205ffbc..255123d93509a4ad00e4ab5605b96d3b4927bc26 100644 ---- a/package.json -+++ b/package.json -@@ -38,7 +38,7 @@ - "build": "tsc -b ./src/tsconfig.json", - "watch": "tsc -b -w ./src/tsconfig.json", - "lint": "eslint -c .eslintrc.js --ext .ts src/", -- "install": "node scripts/prebuild.js || node-gyp rebuild", -+ "install": "node-gyp rebuild", - "postinstall": "node scripts/post-install.js", - "compileCommands": "node scripts/gen-compile-commands.js", - "test": "cross-env NODE_ENV=test mocha -R spec --exit lib/*.test.js", -diff --git a/src/unix/pty.cc b/src/unix/pty.cc -index 7b4b9e1f990fbf95b51528bb56dc9717f5b87532..319dd5782b347e459dd7f16a335f0dc91e299ac0 100644 ---- a/src/unix/pty.cc -+++ b/src/unix/pty.cc -@@ -220,6 +220,7 @@ Napi::Value PtyFork(const Napi::CallbackInfo& info); - Napi::Value PtyOpen(const Napi::CallbackInfo& info); - Napi::Value PtyResize(const Napi::CallbackInfo& info); - Napi::Value PtyGetProc(const Napi::CallbackInfo& info); -+Napi::Value PtyGetForegroundPid(const Napi::CallbackInfo& info); - - /** - * Functions -@@ -575,6 +576,30 @@ Napi::Value PtyGetProc(const Napi::CallbackInfo& info) { - return name_; - } - -+/** -+ * Foreground Process Group PID -+ * -+ * Returns the pid of the foreground process group attached to the pty -+ * referenced by `fd`, or undefined if the lookup fails. Cross-platform -+ * (Linux + macOS) — wraps tcgetpgrp(3), which `pty_getproc` already -+ * calls internally to resolve the foreground process name. -+ */ -+Napi::Value PtyGetForegroundPid(const Napi::CallbackInfo& info) { -+ Napi::Env env(info.Env()); -+ Napi::HandleScope scope(env); -+ -+ if (info.Length() != 1 || !info[0].IsNumber()) { -+ throw Napi::Error::New(env, "Usage: pty.foregroundPid(fd)"); -+ } -+ -+ int fd = info[0].As().Int32Value(); -+ pid_t pgrp = tcgetpgrp(fd); -+ if (pgrp == -1) { -+ return env.Undefined(); -+ } -+ return Napi::Number::New(env, static_cast(pgrp)); -+} -+ - /** - * Nonblocking FD - */ -@@ -793,6 +818,7 @@ Napi::Object init(Napi::Env env, Napi::Object exports) { - exports.Set("open", Napi::Function::New(env, PtyOpen)); - exports.Set("resize", Napi::Function::New(env, PtyResize)); - exports.Set("process", Napi::Function::New(env, PtyGetProc)); -+ exports.Set("foregroundPid", Napi::Function::New(env, PtyGetForegroundPid)); - return exports; - } - diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3d522aaea..6f9c4709c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,11 +16,6 @@ overrides: packageExtensionsChecksum: sha256-GuGZA8jCJUaUE/saX+uezWes2nMASx9CFDTN3Aun/K8= -patchedDependencies: - node-pty@1.1.0: - hash: 50f459cfc12675225bca395a9aab75c311e4cd6206f9c4990e818932465c8cd6 - path: patches/node-pty@1.1.0.patch - importers: .: @@ -464,8 +459,8 @@ importers: specifier: workspace:* version: link:../transcript-html node-pty: - specifier: ^1.0.0 - version: 1.1.0(patch_hash=50f459cfc12675225bca395a9aab75c311e4cd6206f9c4990e818932465c8cd6) + specifier: github:juspay/node-pty#fix/darwin-pty-fd-leak + version: https://codeload.github.com/juspay/node-pty/tar.gz/cc137d90e39bb9e5c72ca8b9d81210e5005c5fa3 pino: specifier: ^10.3.1 version: 10.3.1 @@ -3697,8 +3692,9 @@ packages: node-addon-api@7.1.1: resolution: {integrity: sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==} - node-pty@1.1.0: - resolution: {integrity: sha512-20JqtutY6JPXTUnL0ij1uad7Qe1baT46lyolh2sSENDd4sTzKZ4nmAFkeAARDKwmlLjPx6XKRlwRUxwjOy+lUg==} + node-pty@https://codeload.github.com/juspay/node-pty/tar.gz/cc137d90e39bb9e5c72ca8b9d81210e5005c5fa3: + resolution: {tarball: https://codeload.github.com/juspay/node-pty/tar.gz/cc137d90e39bb9e5c72ca8b9d81210e5005c5fa3} + version: 1.1.0 node-releases@2.0.37: resolution: {integrity: sha512-1h5gKZCF+pO/o3Iqt5Jp7wc9rH3eJJ0+nh/CIoiRwjRxde/hAHyLPXYN4V3CqKAbiZPSeJFSWHmJsbkicta0Eg==} @@ -7825,7 +7821,7 @@ snapshots: node-addon-api@7.1.1: {} - node-pty@1.1.0(patch_hash=50f459cfc12675225bca395a9aab75c311e4cd6206f9c4990e818932465c8cd6): + node-pty@https://codeload.github.com/juspay/node-pty/tar.gz/cc137d90e39bb9e5c72ca8b9d81210e5005c5fa3: dependencies: node-addon-api: 7.1.1