fix(sdk): find broker in package-root bin/ without relying on postinstall#768
Merged
willwashburn merged 1 commit intomainfrom Apr 22, 2026
Merged
Conversation
…tall
The agent-relay npm tarball ships platform-specific brokers at its
top-level `bin/` (`bin/agent-relay-broker-darwin-arm64`, etc.), while
`getBrokerBinaryPath()` only searched `packages/sdk/bin/`. Users without
a successful postinstall step (--ignore-scripts, pnpm/bun script
policies, corporate proxies blocking the fallback download) got
`spawn agent-relay-broker ENOENT` even though the binary was sitting in
the installed tarball.
Walk up to 6 ancestors of the SDK module and check for
`bin/agent-relay-broker(-{platform}-{arch})` so the tarball layout
resolves directly — no postinstall copy required. Dev checkout still
resolves to target/release via the existing earlier search step.
Verified against the real agent-relay@4.0.37 tarball with
--ignore-scripts: resolver now returns the bundled binary from both the
`packages/sdk/` and `node_modules/@agent-relay/sdk/` load paths.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced Apr 22, 2026
Closed
6 tasks
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
Closes the ENOENT path that bit Falko (and anyone whose postinstall step is skipped or fails).
The published `agent-relay` tarball contains platform-specific brokers at its top-level `bin/`:
```
package/bin/agent-relay-broker-darwin-arm64
package/bin/agent-relay-broker-darwin-x64
package/bin/agent-relay-broker-linux-arm64
package/bin/agent-relay-broker-linux-x64
```
But `getBrokerBinaryPath()` only searched `packages/sdk/bin/`. That directory is populated by `scripts/postinstall.js` copying from the top-level `bin/`. Any environment that skips postinstall (`--ignore-scripts`, Bun, pnpm policies, corporate proxies blocking the fallback download) ends up with `packages/sdk/bin/` empty, the resolver returns `null`, `AgentRelayClient.spawn()` falls back to the bare string `'agent-relay-broker'`, and Node emits:
```
spawn agent-relay-broker ENOENT (pid=unknown; cwd=...; command=agent-relay-broker init --name ... --channels general; stdout_tail=; stderr_tail=)
```
even though the binary is sitting right there in the install.
Fix: walk up to 6 ancestors of the SDK module and also check `bin/agent-relay-broker` and `bin/agent-relay-broker-{platform}-{arch}`. The resolver now finds the shipped binary directly — no postinstall copy required. Dev checkouts are unaffected because the source-checkout Cargo path is still tried first.
Test plan
Verified against the real published tarball (`agent-relay@4.0.37`) unpacked with `--ignore-scripts`: