Skip to content

Complete node-pty removal (fixes #204)#227

Closed
khaliqgant wants to merge 12 commits into
mainfrom
fix/complete-issue-204-node-pty-removal
Closed

Complete node-pty removal (fixes #204)#227
khaliqgant wants to merge 12 commits into
mainfrom
fix/complete-issue-204-node-pty-removal

Conversation

@khaliqgant

Copy link
Copy Markdown
Member

Summary

Completes the incomplete work from the claude/fix-issue-204-uNZ6y branch that removed the node-pty dependency.

Issues fixed:

  1. Double-formatting bug - The branch removed pre-formatted message detection from Rust format_for_injection(), but Node.js buildInjectionString() still formats messages before sending. This caused messages to be wrapped twice ("Relay message from... Relay message from...").

  2. Debug statements - shared.ts had debug console.log statements that should not be in production code.

Changes

  • Restored pre-formatted message detection in relay-pty/src/protocol.rs
  • Removed debug console.log statements from src/wrapper/shared.ts
  • Restored tests for pre-formatted message handling

Test plan

  • Build completes successfully (npm run build)
  • TypeScript compiles without errors (npx tsc --noEmit)
  • Rust tests pass (cd relay-pty && cargo test)
  • Message injection works end-to-end without double-formatting

Background

Issue #204 reports that npm install breaks on Node versions other than 22.0.0 due to node-pty's native compilation issues. The fix removes node-pty and uses the relay-pty Rust binary instead. This PR completes that work by fixing the two issues that made the original branch incomplete.

🤖 Generated with Claude Code

claude and others added 12 commits January 18, 2026 18:53
Change .nvmrc from exact version v22.0.0 to major version 22, allowing
any 22.x.x version to be used. This fixes compatibility issues for users
running different minor/patch versions of Node 22.

Fixes #204
- Remove node-pty from package.json dependencies
- Update spawner.ts to require relay-pty binary (no fallback)
- Simplify AgentWrapper type to only use RelayPtyOrchestrator

This improves Node.js version compatibility by removing the native
node-pty module that requires compilation for each Node version.
The relay-pty Rust binary provides PTY functionality instead.

Related to #204
BREAKING: Removes node-pty native module dependency and migrates all
PTY functionality to use the relay-pty Rust binary.

Changes:
- Remove node-pty from package.json dependencies
- Update spawner.ts to require relay-pty binary (no fallback)
- Migrate cli-pty-runner.ts to use relay-pty via child_process.spawn
- Migrate cli-auth.ts to use relay-pty for auth flows
- Update onboarding.ts to remove IPty type dependency
- Create wrapper-types.ts for shared event type definitions
- Update imports in agent-manager.ts, persistence.ts to use wrapper-types.ts

This improves Node.js version compatibility (including Node 25) by
eliminating native module compilation requirements. The relay-pty Rust
binary provides equivalent PTY functionality without version constraints.

The relay-pty binary must be available for:
- Agent spawning via Spawner
- CLI authentication flows
- CLI PTY runner operations

Fixes #204
Add GitHub Actions workflow that tests npm install across multiple
Node.js versions (18, 20, 22, 24, 25) using Docker containers.

Tests include:
- Full install and build in official Node images
- npm pack and global installation (npm install -g)
- ESM import verification
- Minimal install in slim images (no build tools)

This ensures the package installs correctly after removing the
node-pty native module dependency.

Related to #204
Replace references to node-pty with relay-pty in:
- spawner.ts file header and spawn method doc
- spawner.test.ts file header
The PtyWrapper class is no longer used after migrating to
RelayPtyOrchestrator. Remove the file to fix TypeScript
compilation errors from the missing node-pty dependency.

Event types have been moved to wrapper-types.ts.
- Use local import (./dist/index.js) instead of global package import
- Add npm test to verify functionality after build
- Remove problematic global install test
- Add fresh install test (deletes package-lock.json first)
- Verify native modules compile correctly
Update test scripts in scripts/test-cli-auth/ to use relay-pty
binary instead of node-pty:

- ci-test-runner.ts: Migrated to child_process.spawn with relay-pty
- test-oauth-flow.ts: Migrated to child_process.spawn with relay-pty
- package.json: Removed node-pty dependency

This completes the removal of node-pty from the entire codebase.
Remove scripts/test-pty-input.js and scripts/test-pty-input-auto.js
which were manual debugging scripts that used node-pty. These are not
part of the test suite and would fail without node-pty.
Add multi-stage Docker build that compiles relay-pty from source:
- Stage 1: Build relay-pty using rust:1.75-slim
- Stage 2: Copy binary to runtime image

This fixes the CLI OAuth tests which now depend on relay-pty
instead of node-pty for PTY emulation.
Add overrides for react and react-dom to resolve peer dependency conflict.
drizzle-orm@0.45.1 has optional peer dependencies on React Native packages
(expo-sqlite, @op-engineering/op-sqlite) that require React 19, but this
web project uses React 18.3.1. The overrides tell npm to use React 18
regardless of what the optional React Native packages want.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The claude/fix-issue-204-uNZ6y branch removed node-pty but had two issues:

1. Double-formatting bug: Rust protocol.rs removed pre-formatted message
   detection, but Node.js buildInjectionString() still formats messages.
   This caused messages to be wrapped twice with "Relay message from...".

   Fix: Restored the pre-formatted check in format_for_injection() that
   skips formatting when body already starts with "Relay message from ".

2. Debug statements: shared.ts had console.log debug statements that
   should not be in production code.

   Fix: Removed debug console.log statements from buildInjectionString().

Also restored the removed tests for pre-formatted message handling.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@my-senior-dev-pr-review

Copy link
Copy Markdown

🤖 My Senior Dev — Analysis Complete

👤 For @khaliqgant

📁 Expert in src/bridge/ (11 edits) • ⚡ 83rd PR this month

View your contributor analytics →


📊 22 files reviewed • 7 high risk • 1 need attention

🚨 High Risk:

  • package-lock.json — Contains dependency changes that could break the application if outdated packages are included.
  • package.json — Essential for verifying the compatibility of new dependencies introduced with 'relay-pty'.
  • scripts/test-cli-auth/ci-test-runner.ts — Core script modifications may directly affect testing effectiveness and integrity.
  • +4 more

⚠️ Needs Attention:

  • .github/workflows/node-compat.yml — Ensures CI workflows properly test across multiple Node.js environments, important for compatibility post-refactor.
  • relay-pty/src/protocol.rs — Critical changes to message formatting logic for PTY events need in-depth review for correctness and error prevention.
  • +4 more concerns...

🚀 Open Interactive Review →

The full interface unlocks features not available in GitHub:

  • 💬 AI Chat — Ask questions on any file, get context-aware answers
  • 🔍 Smart Hovers — See symbol definitions and usage without leaving the diff
  • 📚 Code Archeology — Understand how files evolved over time (/archeology)
  • 🎯 Learning Insights — See how this PR compares to similar changes

💬 Chat here: @my-senior-dev explain this change — or try @chaos-monkey @security-auditor @optimizer @skeptic @junior-dev

📖 View all 12 personas & slash commands

You can interact with me by mentioning @my-senior-dev in any comment:

In PR comments or on any line of code:

  • Ask questions about the code or PR
  • Request explanations of specific changes
  • Get suggestions for improvements

Slash commands:

  • /help — Show all available commands
  • /archeology — See the history and evolution of changed files
  • /profile — Performance analysis and suggestions
  • /expertise — Find who knows this code best
  • /personas — List all available AI personas

AI Personas (mention to get their perspective):

Persona Focus
@chaos-monkey 🐵 Edge cases & failure scenarios
@skeptic 🤨 Challenge assumptions
@optimizer Performance & efficiency
@security-auditor 🔒 Security vulnerabilities
@accessibility-advocate Inclusive design
@junior-dev 🌱 Simple explanations
@tech-debt-collector 💳 Code quality & shortcuts
@ux-champion 🎨 User experience
@devops-engineer 🚀 Deployment & scaling
@documentation-nazi 📚 Documentation gaps
@legacy-whisperer 🏛️ Working with existing code
@test-driven-purist Testing & TDD

For the best experience, view this PR on myseniordev.com — includes AI chat, file annotations, and interactive reviews.

@khaliqgant khaliqgant closed this Jan 19, 2026
@khaliqgant

Copy link
Copy Markdown
Member Author

Closed in favor of #207

@willwashburn willwashburn deleted the fix/complete-issue-204-node-pty-removal branch May 15, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants