Skip to content

fix(build): drop redundant @agent-relay/* tsconfig paths so the compiled CLI keeps workspace exports#1184

Merged
khaliqgant merged 2 commits into
mainfrom
fix/fleet-bun-compile-namespace-drop
Jun 22, 2026
Merged

fix(build): drop redundant @agent-relay/* tsconfig paths so the compiled CLI keeps workspace exports#1184
khaliqgant merged 2 commits into
mainfrom
fix/fleet-bun-compile-namespace-drop

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Jun 22, 2026

Copy link
Copy Markdown
Member

Problem

The Bun-compiled agent-relay standalone binary dropped every @agent-relay/* workspace export to undefined at runtime. agent-relay local up failed with:

Fleet local node skipped: C90 is not a function. (... 'C90' is undefined)

C90 was the minified defineDefaultLocalNode from @agent-relay/fleet. The whole @agent-relay/fleet namespace bundled empty. (The broker still started — the implicit Fleet local node is best-effort and the failure is caught — but the node never came up.)

Root cause

The root tsconfig.json and packages/cli/tsconfig.json mapped every @agent-relay/* import to a sibling package's dist/index.d.ts via compilerOptions.paths. Bun and esbuild honor tsconfig paths when bundling, so they inlined the declaration files — which have only export declare (no runtime values) — leaving the bundled namespace {}.

Two details that made it specific and multi-layered:

  • Bun resolves paths from the tsconfig nearest the importing file (and follows extends). Packages fleet/harnesses/integration-prompts extend root and inherited the paths → broke; sdk/harness-driver don't → resolved via node_modules → worked. That's why only some packages failed.
  • Fixing only the entry left the transitive import (fleetharnesses) broken, surfacing as a deeper spawn requires a PTY harness definition.

Fix

Remove the @agent-relay/* paths (and the now-orphaned baseUrl) from tsconfig.json and packages/cli/tsconfig.json. They were redundant with the npm workspace node_modules symlinks:

  • tsc resolves @agent-relay/*.d.ts via each package's exports/types.
  • bundlers (bun, esbuild) resolve → .js via import/default.

With the source defect gone, the namespace-import workarounds in fleet-sidecar.ts and fleet/src/index.ts (added to dodge the same .d.ts mis-resolution) revert to plain named imports.

Scope / safety

  • Type-check unaffected: npm run build:core0 type errors (incl. the 3 packages that inherit root paths).
  • Subpath imports (@agent-relay/harness-driver/protocol, @agent-relay/sdk/actions, …) still resolve via package exports.
  • web/, and the tests//evals tsconfigs that still carry these paths, are independent — only ever consumed by tsc, never by a bun/esbuild bundle — so they're intentionally untouched.
  • JSONC comments in the tsconfigs are safe (only tsc/bun/esbuild read these files).

Verification

A freshly compiled binary runs local up with the implicit fleet node fully up:

// .agentworkforce/relay/fleet-node.json
{ "connected": true, "handlers": ["spawn:claude", "spawn:codex", "spawn:gemini"] }

No "Fleet local node skipped", no "is not a function".

🤖 Generated with Claude Code

Review in cubic

…led CLI keeps workspace exports

The Bun-compiled `agent-relay` standalone binary dropped every @agent-relay/*
workspace export to `undefined` at runtime, so `local up` failed with
"Fleet local node skipped: … is not a function" (the implicit Fleet local node
calling `defineDefaultLocalNode`).

Root cause: the root and packages/cli `tsconfig.json` mapped every @agent-relay/*
import to a sibling package's `dist/index.d.ts` via `compilerOptions.paths`. Bun
and esbuild honor tsconfig `paths` when bundling, so they inlined the declaration
files — which have no runtime exports — and the bundled namespace came back empty.

Those paths were redundant: the npm workspace already symlinks @agent-relay/*
into node_modules, so `tsc` resolves their `.d.ts` (via package `exports`/`types`)
and bundlers resolve their `.js` (via `import`/`default`). Removing them fixes the
bundled binary without affecting type-checking. With the source defect gone, the
namespace-import workarounds in fleet-sidecar.ts and fleet/src/index.ts (added to
dodge the same .d.ts mis-resolution) revert to plain named imports.

Verified: `npm run build:core` is green (0 type errors), and a freshly compiled
binary runs `local up` with the implicit fleet node connected
(fleet-node.json connected:true, handlers spawn:claude/codex/gemini).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@khaliqgant khaliqgant requested a review from willwashburn as a code owner June 22, 2026 08:24
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Removes baseUrl/paths mappings for @agent-relay/* from the root and packages/cli tsconfig.json files, which previously caused Bun/esbuild to resolve workspace packages to .d.ts declarations instead of compiled JS. Reverts namespace-import workarounds in fleet-sidecar.ts and packages/fleet/src/index.ts back to direct named imports, and adds a changelog entry plus trajectory records.

Changes

Bun CLI Workspace Export Fix

Layer / File(s) Summary
Remove @agent-relay/* tsconfig path mappings
tsconfig.json, packages/cli/tsconfig.json
Removes baseUrl and paths blocks that previously mapped @agent-relay/* to dist/index.d.ts declarations; replaces them with comments explaining the intentional omission so bundlers resolve via workspace symlinks and compiled JS.
Revert namespace-import workarounds to named imports
packages/cli/src/cli/lib/fleet-sidecar.ts, packages/fleet/src/index.ts
fleet-sidecar.ts switches from import * as fleetSdk plus destructuring back to direct named imports from @agent-relay/fleet; fleet/src/index.ts collapses the type-only plus namespace import pattern into a single named import from @agent-relay/harnesses.
Changelog and trajectory records
CHANGELOG.md, .agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/*
Adds a Fixed entry in CHANGELOG.md and new trajectory summary.md/trajectory.json files recording root cause analysis, fix, and verification results.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • AgentWorkforce/relay#1108: Introduced the namespace-import workaround in fleet-sidecar.ts that this PR reverts, targeting the same @agent-relay/fleet Bun standalone bundling issue.

Suggested reviewers

  • willwashburn

🐰 No more undefined in the warren,
The .d.ts paths caused all the barren!
Named imports now hop straight and true,
symlinks carry the runtime through.
local up springs to life — hooray! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main fix: removing redundant tsconfig paths to resolve the issue where compiled CLI loses workspace exports.
Description check ✅ Passed The description provides comprehensive Problem, Root cause, Fix, Scope/safety, and Verification sections, exceeding the template requirements with thorough technical detail.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/fleet-bun-compile-namespace-drop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@agent-relay-code

Copy link
Copy Markdown
Contributor

pr-reviewer could not complete review for #1184 in AgentWorkforce/relay.
The review harness exited with code 1.
No review was posted; this needs operator attention.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request resolves an issue where the Bun-compiled agent-relay standalone binary dropped workspace exports to undefined at runtime, causing local up to fail. The fix removes the redundant @agent-relay/* path mappings from the root and package-level tsconfig.json files, allowing bundlers to resolve the compiled JavaScript files via npm workspace symlinks while TypeScript still resolves types. Additionally, previous namespace-import workarounds in fleet-sidecar.ts and fleet/src/index.ts have been reverted to standard named imports, and a trajectory log has been added. No review comments were provided, so there is no feedback to address.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@CHANGELOG.md`:
- Line 12: The CHANGELOG entry contains excessive implementation details
(tsconfig paths, .d.ts versus compiled JS, npm workspace symlinks) that distract
from the user-visible impact. Simplify the entry to focus only on what users
care about: that `agent-relay local up` now successfully starts the implicit
Fleet local node instead of failing with the "is not a function" error. Remove
all technical details about how the fix was implemented (tsconfig changes,
workspace symlinks, declaration files) and keep the entry concise and
impact-focused as per CHANGELOG guidelines.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 79c1670f-b9bb-49c3-a937-ab1414c1cb6d

📥 Commits

Reviewing files that changed from the base of the PR and between c7380ef and 4ecf58f.

📒 Files selected for processing (7)
  • .agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/summary.md
  • .agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/trajectory.json
  • CHANGELOG.md
  • packages/cli/src/cli/lib/fleet-sidecar.ts
  • packages/cli/tsconfig.json
  • packages/fleet/src/index.ts
  • tsconfig.json

Comment thread CHANGELOG.md

### Fixed

- The Bun-compiled `agent-relay` standalone binary now bundles workspace packages from their compiled JS instead of their `.d.ts`, so `local up` starts the implicit Fleet local node instead of failing with `Fleet local node skipped: … is not a function`. The `tsconfig` `paths` that mapped `@agent-relay/*` to declaration files (no runtime exports) were redundant with the npm workspace symlinks and have been removed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

CHANGELOG entry includes implementation details; focus on user-visible impact only.

Per coding guidelines for CHANGELOG.md, entries should be "concise and impact-first, with one short bullet per user-visible change. Omit... internal notes, and implementation details."

The current entry includes technical implementation details (tsconfig paths, .d.ts vs. compiled JS, npm workspace symlinks, "no runtime exports") that users don't need to understand. The user-visible change is singular: local up now works instead of failing.

Suggested revision (concise, impact-first, omits implementation):

agent-relay local up now starts the implicit Fleet local node instead of failing with "Fleet local node skipped: … is not a function" in the Bun-compiled standalone binary.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CHANGELOG.md` at line 12, The CHANGELOG entry contains excessive
implementation details (tsconfig paths, .d.ts versus compiled JS, npm workspace
symlinks) that distract from the user-visible impact. Simplify the entry to
focus only on what users care about: that `agent-relay local up` now
successfully starts the implicit Fleet local node instead of failing with the
"is not a function" error. Remove all technical details about how the fix was
implemented (tsconfig changes, workspace symlinks, declaration files) and keep
the entry concise and impact-focused as per CHANGELOG guidelines.

Source: Coding guidelines

@agent-relay-code

Copy link
Copy Markdown
Contributor

Review: PR #1184 — fix/fleet-bun-compile-namespace-drop

What the PR does

Removes the redundant paths mappings for @agent-relay/* from the root tsconfig.json and packages/cli/tsconfig.json (which mapped each workspace package to its dist/index.d.ts), and reverts two namespace-import workarounds back to plain named imports in packages/cli/src/cli/lib/fleet-sidecar.ts and packages/fleet/src/index.ts.

Root cause being fixed: bun/esbuild honor tsconfig paths, so mapping workspace packages to their .d.ts made the Bun-compiled standalone binary inline declaration files (which carry no runtime exports), dropping every workspace export to undefined (manifesting as local upFleet local node skipped: … is not a function).

Verification (ran the way CI does)

  • npm ci → workspace packages symlink into node_modules as expected.
  • npm run build:core (the full dependency-ordered build, triggered by pretest/npm test) → green, 0 type errors across all 11 packages including the two with reverted imports.
  • Confirmed each package's package.json exports.types/exports.import correctly steer tsc to .d.ts and bundlers to .js, so the removed paths are genuinely redundant with the workspace symlinks. The build order guarantees deps are built before dependents.
  • Runtime check on built packages/fleet/dist/index.js: all five exports (defineDefaultLocalNode, invokeNodeHandler, nodeInfo, nodeManifest, triggerSyncInputs) resolve as function — the fix's intended effect.
  • npx vitest run959 passed, 5 skipped, 0 failures.
  • npm --prefix packages/cli run lint0 errors (only pre-existing complexity/naming warnings, none on the PR's changed lines).
  • prettier --check on all PR-changed files → clean.

The change is non-semantic from a runtime-behavior standpoint (it restores correct exports rather than altering logic) and stays tightly within the PR's purpose. I made no edits — the PR is correct as written.

Addressed comments

  • No bot or human review comments were provided in the PR metadata (.workforce/context.json / no comments file), so there are no review threads to account for.

Advisory Notes

  • prettier --check . reports 16 warnings, but all are in untracked local sandbox directories (slack/…, github/…) that are not git-tracked and therefore not part of this PR or CI. No action needed; flagging only so the noise isn't mistaken for a real formatting gate failure.

I cannot confirm the live status of GitHub CI checks or PR mergeability from this sandbox (those are reported by cloud post-run), so I am not declaring the PR human-ready.

@agent-relay-code

Copy link
Copy Markdown
Contributor

Review: PR #1184fix(build): drop redundant @agent-relay/* tsconfig paths

Summary of the change

The PR fixes the Bun --compile standalone binary dropping @agent-relay/* workspace exports to undefined (causing local up → "Fleet local node skipped: … is not a function"). It:

  • Removes the @agent-relay/* paths mappings (which pointed at dist/index.d.ts) from the root tsconfig.json and packages/cli/tsconfig.json.
  • Reverts the now-obsolete namespace-import workarounds back to plain named imports in packages/cli/src/cli/lib/fleet-sidecar.ts and packages/fleet/src/index.ts.
  • Adds a CHANGELOG.md entry and trajectory records.

Assessment — the fix is correct

The root cause is accurate: mapping @agent-relay/* to .d.ts files made bun/esbuild inline declaration files (no runtime exports). Removing the redundant paths is the right, minimal fix because:

  • The npm workspace symlinks already exist in node_modules/@agent-relay/* (verified), and every package has correct exports (types.d.ts, import/default.js).
  • Under moduleResolution: NodeNext, tsc resolves the .d.ts via the symlink + exports.types, and bundlers resolve the .js.

Verification performed

I installed deps and ran the canonical build chain (build:core). Results:

  • build:fleet PASSES (PR-modified package, named imports + root-extends tsconfig with no paths).
  • build:harnesses PASSES (supplies the named exports fleet imports).
  • build:sdk PASSES; AgentRelay.triggers resolves; the transient fleet-sidecar.ts "Property 'triggers'" errors disappeared once sdk's dist was built.
  • All named imports in the diff map to real exports (defineDefaultLocalNode, invokeNodeHandler, nodeInfo, nodeManifest, triggerSyncInputs, claude, codex, definePtyHarness, gemini, PtyHarness).
  • Zero @agent-relay/* resolution errors and zero "no exported member" errors anywhere — confirming the paths removal does not break workspace resolution.
  • The other tsconfigs that still carry paths (sdk, evals, tests/integration/broker) are untouched and out of scope.
  • Build scripts (build-bun.sh, build-standalone.sh) contain no leftovers from the abandoned "empty-paths tsconfig" approach.

Remaining errors seen in build:cli (Cannot find module 'jiti' / 'posthog-node' / '@modelcontextprotocol/sdk' and their implicit-any cascades) are sandbox install artifacts — those directories are empty placeholders in this environment, not anything the PR removed. They would not occur in CI's clean install.

Edits made

None. The PR needs no mechanical (lint/format/typo) fixes — the head commit was already Prettier-formatted, and there are no semantic issues to flag.

Addressed comments

  • No bot or human review comments were present (.workforce/ contains only pr.diff, changed-files.txt, context.json; no comments/reviews file, and context.json lists no review threads). Nothing to address.

Advisory Notes

  • None. The change is self-contained and within the PR's stated purpose.

I cannot independently confirm CI is green (the sandbox install is incomplete, so I could not run the full build:core/test end to end without environment workarounds), and I cannot verify GitHub mergeability status. Because required CI completion/passing and mergeability cannot be confirmed from here, I am not printing READY.

@khaliqgant khaliqgant merged commit 2eb86d0 into main Jun 22, 2026
46 of 47 checks passed
@khaliqgant khaliqgant deleted the fix/fleet-bun-compile-namespace-drop branch June 22, 2026 09:18
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