fix(cli): prefer native Node TS stripping over tsx fallback#741
Merged
Conversation
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>
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
runScriptFilenow triesnode --experimental-strip-typesbeforetsx/ts-node, so a plain@agent-relay/sdk-only install works out of the box on Node 22.6+ with no extra runtime deps.--experimental-strip-typesexits 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.tswith only@agent-relay/sdkinstalled hit:Root cause: no
tsx/ts-nodewas locally installed → fell through tonpx tsx→ tsx's path resolver walkednode_modules/agent-trajectoriesas CJS and the package only declaresimport/typesconditions, 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 verifiednode --experimental-strip-types workflows/build-activity-monitor.tsruns the workflow's dry-run path cleanly (Validation: PASS).See the companion PR on
AgentWorkforce/trajectoriesthat also adds adefaultcondition to that package's exports as belt-and-suspenders.Test plan
vitest run src/cli/commands/setup.test.ts— 20/20 passtsc --noEmit— cleanagent-relaybinary and dry-run a.tsworkflow in a project with only@agent-relay/sdkinstalled🤖 Generated with Claude Code