Skip to content

fix: repair npm global install — walk-up dep resolution, spawn-helper chmod, platform-aware messages#638

Merged
suraj-markup merged 17 commits intoComposioHQ:mainfrom
suraj-markup:fix/two-step-setup-blockers
Mar 26, 2026
Merged

fix: repair npm global install — walk-up dep resolution, spawn-helper chmod, platform-aware messages#638
suraj-markup merged 17 commits intoComposioHQ:mainfrom
suraj-markup:fix/two-step-setup-blockers

Conversation

@suraj-markup
Copy link
Collaborator

@suraj-markup suraj-markup commented Mar 23, 2026

Summary

Fixes P0 blockers preventing npm install -g @composio/ao && ao start from working. Addresses 4 issues: npm dependency hoisting resolution, node-pty spawn-helper permissions, interactive tmux/git install with user consent, and terminal server crash recovery.

Changes

packages/cli/src/lib/preflight.ts

Replace the single-level existsSync check with findPackageUp() — a walk-up resolver that checks node_modules/@composio/ao-core at every ancestor directory, mirroring Node's own module resolution. Error messages now distinguish between npm (npm install -g @composio/ao@latest) and pnpm (pnpm install && pnpm build) users.

checkTmux() now attempts auto-install (brew/apt/dnf) with a log line before each attempt, then falls back to platform-specific error messages.

packages/cli/src/commands/start.ts

  • ensureTmux() in runStartup() — centralized tmux enforcement covering ALL ao start paths (normal, URL quick-start, retry with existing config). No silent sudo — uses askYesNo() to get user consent before attempting install, matching the existing ensureGit() pattern.
  • Uses tryInstallWithAttempts() + tmuxInstallAttempts() for consistent install flow with progress logging.
  • Blocks with clear platform-specific instructions on failure (no degraded runtime: "process" fallback).

packages/ao/bin/postinstall.js (new)

Runs after npm install -g @composio/ao. Locates node-pty via the same walk-up pattern, finds spawn-helper in prebuilds/<platform>-<arch>/, and chmod 0o755. Skips silently on Windows and when no prebuild exists. Non-fatal on failure.

packages/web/server/start-all.ts

Terminal WebSocket servers now auto-restart on crash (up to 3 attempts) with slot-based bookkeeping — restarts replace the existing child process slot in-place, preventing duplicate entries that would break the cleanup countdown.

eslint.config.js

Added packages/ao/bin override for Node.js globals (process, console) — matches existing scripts/** pattern.

packages/cli/__tests__/lib/preflight.test.ts

Expanded checkBuilt tests from 3 to 5, covering pnpm layout, npm hoisted layout (walk-up), npm/pnpm error hints, and missing dist. Updated tmux tests for auto-install and platform-aware messages.

Test plan

  • pnpm typecheck passes
  • All 15 preflight tests pass (5 new/updated for checkBuilt)
  • 222/223 CLI tests pass (1 failure = pre-existing flaky doctor-script.test.ts)
  • pnpm lint — no new errors on changed files
  • Web server typecheck passes (tsc -p tsconfig.server.json --noEmit)

Closes #619, closes #624

🤖 Generated with Claude Code

… chmod, platform-aware messages

- Replace hardcoded single-level checkBuilt() with findPackageUp() walk-up
  resolver that handles npm hoisting (fixes ComposioHQ#619)
- Add postinstall script to chmod node-pty spawn-helper for global installs
  (fixes ComposioHQ#624)
- Platform-aware tmux install messages (brew/apt/dnf/WSL instead of
  hardcoded brew)
- Auto-restart crashed terminal servers in start-all.ts (up to 3 retries)
- ESLint config for packages/ao/bin scripts
- Expanded preflight tests (3 → 5 checkBuilt cases)

Closes ComposioHQ#619, closes ComposioHQ#624

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
suraj-markup and others added 5 commits March 24, 2026 03:31
…rt bookkeeping

- checkTmux() now attempts auto-install (brew/apt/dnf) before erroring
- Config generation uses runtime: "process" when tmux unavailable
- start.ts tries auto-install during config creation, falls back gracefully
- Fix restart bookkeeping in start-all.ts: slot-based tracking prevents
  duplicate children entries that broke cleanup countdown
- Updated design doc reflecting all fixes and review feedback

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…llback

A degraded runtime gives a bad first impression. Instead of silently
falling back to runtime: "process", ao start now:
1. Tries auto-install (brew/apt/dnf)
2. On failure, exits with clear platform-specific install command
3. User runs one command, then re-runs ao start

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Refactor ensureTmux() to use askYesNo() + tryInstallWithAttempts()
  matching the existing ensureGit() pattern — no silent sudo
- Add log line before each auto-install attempt in preflight.checkTmux()
- Update config warning: "will prompt to install at startup"
- Update design doc to reflect interactive consent flow
- Include prior uncommitted changes: interactive install prompts for
  git/gh/agent-runtime, ensureGit(), canPromptForInstall(), askYesNo()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace ASCII art flow diagrams with styled HTML/CSS flowcharts using
color-coded nodes (blue=command, yellow=decision, green=success,
red=failure) and proper branching layout.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Expand the Interactive Prerequisite Prompts section with:
- Full prerequisite matrix table (tmux, git, agent runtime, gh, docker)
  showing required status, prompts, install methods per platform, and
  failure behavior
- Key behaviors list (consent-first, logging, blocking, non-TTY fallback)
- Example terminal output for fresh machine install flow

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The skip option number was hardcoded as 5 in the display, prompt,
bounds check, and skip check. If a fifth agent were added, selecting
it would trigger Skip instead of installing. Now derived dynamically.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fireddd
Copy link
Collaborator

fireddd commented Mar 26, 2026

I had also raised a pr regarding tmux fix, whether in the installation we can indicate the user about tmux not present in the error, https://github.com/ComposioHQ/agent-orchestrator/pull/250/changes, not sure we should be directly installing as a forceful install can cause problems in existing projects

@suraj-markup
Copy link
Collaborator Author

@fireddd thank you for mentioning the issue. I have fixed the auto install without interactive mode and now for any install we have interactive mode in our cli.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@suraj-markup suraj-markup merged commit b057456 into ComposioHQ:main Mar 26, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants