Skip to content

fix(cli): prefer native Node TS stripping over tsx fallback#741

Merged
khaliqgant merged 2 commits into
mainfrom
fix/ts-runner-native-strip
Apr 15, 2026
Merged

fix(cli): prefer native Node TS stripping over tsx fallback#741
khaliqgant merged 2 commits into
mainfrom
fix/ts-runner-native-strip

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

@khaliqgant khaliqgant commented Apr 15, 2026

Summary

  • runScriptFile now tries node --experimental-strip-types before tsx/ts-node, so a plain @agent-relay/sdk-only install works out of the box on Node 22.6+ with no extra runtime deps.
  • On older Node, --experimental-strip-types exits non-zero with no parse-error fingerprint; we treat that as "runner unsupported" and fall through to tsx, preserving existing behavior.

Why

A user running agent-relay run workflows/build-activity-monitor.ts with only @agent-relay/sdk installed hit:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in .../agent-trajectories/package.json
  at resolveTsPaths (.../tsx/dist/register-*.cjs)

Root cause: no tsx/ts-node was locally installed → fell through to npx tsx → tsx's path resolver walked node_modules/agent-trajectories as CJS and the package only declares import/types conditions, so Node's CJS resolver failed before any workflow code ran.

Node 22.6+ ships built-in TS type stripping (--experimental-strip-types), which does not go through tsx at all, completely sidesteps the transitive CJS/ESM resolver issue, and requires no local install. I verified node --experimental-strip-types workflows/build-activity-monitor.ts runs the workflow's dry-run path cleanly (Validation: PASS).

See the companion PR on AgentWorkforce/trajectories that also adds a default condition to that package's exports as belt-and-suspenders.

Test plan

  • vitest run src/cli/commands/setup.test.ts — 20/20 pass
  • tsc --noEmit — clean
  • Build a fresh agent-relay binary and dry-run a .ts workflow in a project with only @agent-relay/sdk installed
  • Verify on a Node <22.6 box that it falls through to tsx/ts-node as before

🤖 Generated with Claude Code


Open with Devin

Node 22.6+ can run .ts workflow files directly via
--experimental-strip-types. Use it before tsx/ts-node in
runScriptFile so a plain @agent-relay/sdk-only install works
with no additional runtime dependencies.

Previously, users with only @agent-relay/sdk installed fell
through to npx tsx, which downloads tsx on demand and then
trips over a transitive CJS resolver error walking node_modules
(ERR_PACKAGE_PATH_NOT_EXPORTED from agent-trajectories, whose
exports map declares import/types only).

When node --experimental-strip-types is not supported (<22.6)
Node exits non-zero with no parse-error fingerprint; we treat
that as "runner unsupported" and fall through to tsx, preserving
the existing behavior for older Nodes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

- setup.ts: only fall through to the next TS runner when Node exits 9
  (unrecognized --experimental-strip-types). Parsing stderr could mask
  real script errors as "runner unsupported".
- broker-lifecycle.ts: hoist client construction so disconnect() runs
  in a finally, ensuring cleanup on both success and failure paths.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@khaliqgant khaliqgant merged commit 9b0b319 into main Apr 15, 2026
43 checks passed
@khaliqgant khaliqgant deleted the fix/ts-runner-native-strip branch April 15, 2026 11:28
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.

1 participant