From efbd43842eda161225fc869e381170fc4569da59 Mon Sep 17 00:00:00 2001 From: Olivier Berthet Date: Fri, 24 Apr 2026 08:27:41 +0200 Subject: [PATCH] fix(ts): declare node-pty as optionalDependency to unblock tsc check The package-lock declares node-pty: ^1.1.0 but package.json doesn't list it under any dependency block, leaving npm install in a state where the lock and the manifest disagree. After a fresh install, node-pty ends up missing from node_modules on platforms without build tools, and tsc -p tsconfig.json --noEmit fails with 6 TS2307 errors across: - src/core/services/adapters/claudeInteractiveAdapter.ts - src/core/services/adapters/cursorInteractiveAdapter.ts Reproduction (clean state): rm -rf agentchatbus-ts/node_modules/node-pty npm run check -> 6 errors: 'Cannot find module node-pty or its corresponding type declarations' on type-only imports of node-pty. Root cause: The runtime guards (dynamic import('node-pty').catch(...)) are correctly in place in the three interactive adapters, but the type imports (type NodePtyModule = typeof import('node-pty')) are evaluated at type-check time and require node-pty to be resolvable. Fix: Declare node-pty: ^1.1.0 under optionalDependencies in agentchatbus-ts/package.json. This: - Aligns the manifest with the lock (lock now correctly marks node-pty as optional: true). - Lets npm install fetch node-pty when build tools are available. - Lets npm install proceed with a warning when build tools are missing (Windows without node-gyp prerequisites, minimal Linux images), without breaking the install. - Makes tsc see the types so the check passes everywhere. No source code changes are needed: the dynamic import guards already fall back to a clean RUNTIME error message when node-pty is absent. Verification: npm install -> clean, lock updates to optional: true npm run check -> green npm run build -> green (1.9MB bundle, 31s) npm test -> 670 passed, 28 failed; failures are pre-existing on upstream/main (verified by stashing the fix and rerunning the same failing files - identical failures). None of the failures touch node-pty / PTY adapters. Refs: ACB v0.2.29 sync follow-up. --- agentchatbus-ts/package-lock.json | 9 +++++++-- agentchatbus-ts/package.json | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/agentchatbus-ts/package-lock.json b/agentchatbus-ts/package-lock.json index a51d3d96..82234b5f 100644 --- a/agentchatbus-ts/package-lock.json +++ b/agentchatbus-ts/package-lock.json @@ -14,8 +14,8 @@ "@xterm/addon-fit": "^0.11.0", "@xterm/headless": "^6.0.0", "@xterm/xterm": "^6.0.0", + "cross-spawn": "^7.0.6", "fastify": "^5.2.1", - "node-pty": "^1.1.0", "zod": "^4.3.6" }, "bin": { @@ -34,6 +34,9 @@ }, "engines": { "node": ">=20" + }, + "optionalDependencies": { + "node-pty": "^1.1.0" } }, "node_modules/@esbuild/aix-ppc64": { @@ -2681,7 +2684,8 @@ "version": "7.1.1", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", "integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==", - "license": "MIT" + "license": "MIT", + "optional": true }, "node_modules/node-pty": { "version": "1.1.0", @@ -2689,6 +2693,7 @@ "integrity": "sha512-20JqtutY6JPXTUnL0ij1uad7Qe1baT46lyolh2sSENDd4sTzKZ4nmAFkeAARDKwmlLjPx6XKRlwRUxwjOy+lUg==", "hasInstallScript": true, "license": "MIT", + "optional": true, "dependencies": { "node-addon-api": "^7.1.0" } diff --git a/agentchatbus-ts/package.json b/agentchatbus-ts/package.json index d89255bf..f26eba7b 100644 --- a/agentchatbus-ts/package.json +++ b/agentchatbus-ts/package.json @@ -39,5 +39,8 @@ "tsx": "^4.19.2", "typescript": "^5.8.2", "vitest": "^3.1.1" + }, + "optionalDependencies": { + "node-pty": "^1.1.0" } }