Skip to content

fix(sdk): find broker in package-root bin/ without relying on postinstall#768

Merged
willwashburn merged 1 commit intomainfrom
fix/sdk-find-broker-in-package-root-bin
Apr 22, 2026
Merged

fix(sdk): find broker in package-root bin/ without relying on postinstall#768
willwashburn merged 1 commit intomainfrom
fix/sdk-find-broker-in-package-root-bin

Conversation

@willwashburn
Copy link
Copy Markdown
Member

@willwashburn willwashburn commented Apr 22, 2026

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`:

  • `broker-path.js` loaded from `package/packages/sdk/dist/` → resolves to `package/bin/agent-relay-broker-darwin-arm64`.
  • `broker-path.js` loaded from `package/node_modules/@agent-relay/sdk/dist/` (bundled-dep layout) → same result.
  • Dev checkout (`/Users/will/Projects/relay/packages/sdk/dist/broker-path.js`) → still resolves to `target/release/agent-relay-broker` (source-checkout path still wins).
  • CI

Open in Devin Review

…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>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@willwashburn willwashburn merged commit 344f457 into main Apr 22, 2026
40 checks passed
@willwashburn willwashburn deleted the fix/sdk-find-broker-in-package-root-bin branch April 22, 2026 16:41
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