From 816a101b6c9192d687086ba844e3b5743dcaeb22 Mon Sep 17 00:00:00 2001 From: Proactive Runtime Bot Date: Mon, 22 Jun 2026 10:24:04 +0200 Subject: [PATCH 1/2] fix(build): drop redundant @agent-relay/* tsconfig paths so the compiled CLI keeps workspace exports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../2026-06/traj_d88jruejk2zk/summary.md | 32 +++++++++ .../2026-06/traj_d88jruejk2zk/trajectory.json | 65 +++++++++++++++++++ CHANGELOG.md | 1 + packages/cli/src/cli/lib/fleet-sidecar.ts | 12 ++-- packages/cli/tsconfig.json | 26 ++------ packages/fleet/src/index.ts | 6 +- tsconfig.json | 28 ++------ 7 files changed, 118 insertions(+), 52 deletions(-) create mode 100644 .agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/summary.md create mode 100644 .agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/trajectory.json diff --git a/.agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/summary.md b/.agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/summary.md new file mode 100644 index 000000000..abf2f28fe --- /dev/null +++ b/.agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/summary.md @@ -0,0 +1,32 @@ +# Trajectory: Fix @agent-relay/fleet exports dropped to undefined in bun --compile standalone binary (local up Fleet local node skipped) + +> **Status:** ✅ Completed +> **Confidence:** 90% +> **Started:** June 22, 2026 at 09:44 AM +> **Completed:** June 22, 2026 at 10:06 AM + +--- + +## Summary + +Fixed bun-compiled CLI dropping @agent-relay/* workspace exports to undefined (Fleet local node skipped / 'is not a function' on local up). Root cause: bun & esbuild honor tsconfig paths that map workspace packages to their .d.ts (no runtime exports); paths resolve per nearest tsconfig to the importing file, so transitive imports broke too. Final fix (after a fresh-eyes review pivoted away from an earlier build-script workaround): removed the redundant @agent-relay/* paths from the root and packages/cli tsconfig.json — they duplicated the npm workspace node_modules symlinks, so tsc still resolves .d.ts (via package exports.types) and bundlers resolve .js (via exports.import). Also reverted the now-obsolete namespace-import workarounds in fleet-sidecar.ts and fleet/src/index.ts to plain named imports. tsc type-checking untouched. Verified: build:core green (0 type errors), built binary, local up starts implicit fleet node with fleet-node.json connected:true + spawn:claude/codex/gemini. + +**Approach:** Standard approach + +--- + +## Key Decisions + +### Fix at the bundler layer via empty-paths tsconfig next to the build entry +- **Chose:** Fix at the bundler layer via empty-paths tsconfig next to the build entry +- **Reasoning:** Root cause: packages/cli/tsconfig.json paths map @agent-relay/* to dist/index.d.ts; bun/esbuild honor tsconfig paths and bundle the declaration files (no runtime exports) -> undefined. fleet breaks because it is only ever namespace-imported. Build-script override is surgical and leaves tsc type-checking untouched, vs changing shared root paths. + +--- + +## Chapters + +### 1. Work +*Agent: default* + +- Fix at the bundler layer via empty-paths tsconfig next to the build entry: Fix at the bundler layer via empty-paths tsconfig next to the build entry +- Root cause is bun/esbuild honoring tsconfig paths (->.d.ts, no runtime exports) per-importing-file; fix needs empty-paths tsconfig in EVERY bundled package dist, not just the entry, to cover transitive workspace imports. Verified end-to-end: fleet-node.json connected:true with all spawn handlers. diff --git a/.agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/trajectory.json b/.agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/trajectory.json new file mode 100644 index 000000000..9e6101836 --- /dev/null +++ b/.agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/trajectory.json @@ -0,0 +1,65 @@ +{ + "id": "traj_d88jruejk2zk", + "version": 1, + "task": { + "title": "Fix @agent-relay/fleet exports dropped to undefined in bun --compile standalone binary (local up Fleet local node skipped)" + }, + "status": "completed", + "startedAt": "2026-06-22T07:44:17.272Z", + "completedAt": "2026-06-22T08:06:29.530Z", + "agents": [ + { + "name": "default", + "role": "lead", + "joinedAt": "2026-06-22T07:53:58.239Z" + } + ], + "chapters": [ + { + "id": "chap_fmr96gta9rp3", + "title": "Work", + "agentName": "default", + "startedAt": "2026-06-22T07:53:58.239Z", + "endedAt": "2026-06-22T08:06:29.530Z", + "events": [ + { + "ts": 1782114838239, + "type": "decision", + "content": "Fix at the bundler layer via empty-paths tsconfig next to the build entry: Fix at the bundler layer via empty-paths tsconfig next to the build entry", + "raw": { + "question": "Fix at the bundler layer via empty-paths tsconfig next to the build entry", + "chosen": "Fix at the bundler layer via empty-paths tsconfig next to the build entry", + "alternatives": [], + "reasoning": "Root cause: packages/cli/tsconfig.json paths map @agent-relay/* to dist/index.d.ts; bun/esbuild honor tsconfig paths and bundle the declaration files (no runtime exports) -> undefined. fleet breaks because it is only ever namespace-imported. Build-script override is surgical and leaves tsc type-checking untouched, vs changing shared root paths." + }, + "significance": "high" + }, + { + "ts": 1782115588773, + "type": "reflection", + "content": "Root cause is bun/esbuild honoring tsconfig paths (->.d.ts, no runtime exports) per-importing-file; fix needs empty-paths tsconfig in EVERY bundled package dist, not just the entry, to cover transitive workspace imports. Verified end-to-end: fleet-node.json connected:true with all spawn handlers.", + "raw": { + "confidence": 0.9 + }, + "significance": "high", + "tags": [ + "confidence:0.9" + ] + } + ] + } + ], + "retrospective": { + "summary": "Fixed bun-compiled CLI dropping @agent-relay/* workspace exports to undefined (Fleet local node skipped / 'is not a function' on local up). Root cause: bun & esbuild honor tsconfig paths that map workspace packages to their .d.ts (no runtime exports); paths resolve per nearest tsconfig to the importing file, so transitive imports broke too. Fix: build-bun.sh & build-standalone.sh write an empty-paths tsconfig into every packages/*/dist before bundling, forcing node_modules (.js) resolution. tsc type-checking untouched. Verified: rebuilt core from source, built binary, local up starts implicit fleet node with fleet-node.json connected:true + spawn:claude/codex/gemini.", + "approach": "Standard approach", + "confidence": 0.9 + }, + "commits": [], + "filesChanged": [], + "projectId": "AgentWorkforce/relay", + "tags": [], + "_trace": { + "startRef": "c7380efd69238db002f4cba087cebef593bf9fcd", + "endRef": "c7380efd69238db002f4cba087cebef593bf9fcd" + } +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index ae5b019bb..2d351bcf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### 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. - `agent-relay` and `@agent-relay/sdk` require `@relaycast/sdk` `^4.1.2`, whose matching `@relaycast/types` package is now published, so publish installs resolve cleanly without pinning. - `agent-relay fleet serve ` loads plain JavaScript node definitions without `jiti`, so the published Bun-compiled CLI can serve compiled JS node files. - Spawned opencode worker agents no longer pause for interactive tool-approval prompts; the broker injects a wildcard allow-all permission block into every generated `opencode.json`, augmenting existing partial permission objects rather than replacing them. diff --git a/packages/cli/src/cli/lib/fleet-sidecar.ts b/packages/cli/src/cli/lib/fleet-sidecar.ts index 58185b5fe..ec79e65f2 100644 --- a/packages/cli/src/cli/lib/fleet-sidecar.ts +++ b/packages/cli/src/cli/lib/fleet-sidecar.ts @@ -8,11 +8,13 @@ import type { FleetRelaySendMessageInput, FleetSpawnAgentInput, } from '@agent-relay/fleet'; -// bun's standalone `--compile` bundler mis-validates named value imports from -// this workspace package against its generated .d.ts ("No matching export"). -// A namespace import + destructure sidesteps it while keeping call sites unchanged. -import * as fleetSdk from '@agent-relay/fleet'; -const { defineDefaultLocalNode, invokeNodeHandler, nodeInfo, nodeManifest, triggerSyncInputs } = fleetSdk; +import { + defineDefaultLocalNode, + invokeNodeHandler, + nodeInfo, + nodeManifest, + triggerSyncInputs, +} from '@agent-relay/fleet'; import { PROTOCOL_VERSION, type BrokerToSdk, diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index 741afa868..28994ad7a 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -14,26 +14,12 @@ "resolveJsonModule": true, "declaration": true, "declarationMap": true, - "sourceMap": true, - "baseUrl": ".", - "paths": { - "@agent-relay/config": ["../config/dist/index.d.ts"], - "@agent-relay/config/*": ["../config/dist/*"], - "@agent-relay/policy": ["../policy/dist/index.d.ts"], - "@agent-relay/policy/*": ["../policy/dist/*"], - "@agent-relay/sdk": ["../sdk/dist/index.d.ts"], - "@agent-relay/sdk/*": ["../sdk/dist/*"], - "@agent-relay/harness-driver": ["../harness-driver/dist/index.d.ts"], - "@agent-relay/harness-driver/*": ["../harness-driver/dist/*"], - "@agent-relay/harnesses": ["../harnesses/dist/index.d.ts"], - "@agent-relay/harnesses/*": ["../harnesses/dist/*"], - "@agent-relay/fleet": ["../fleet/dist/index.d.ts"], - "@agent-relay/fleet/*": ["../fleet/dist/*"], - "@agent-relay/utils": ["../utils/dist/index.d.ts"], - "@agent-relay/utils/*": ["../utils/dist/*"], - "@agent-relay/cloud": ["../cloud/dist/index.d.ts"], - "@agent-relay/cloud/*": ["../cloud/dist/*"] - } + "sourceMap": true + // No `paths` for @agent-relay/* on purpose: the npm workspace symlinks them + // into node_modules, so tsc resolves their `.d.ts` and bundlers (bun, + // esbuild) resolve their `.js`. Mapping them to `dist/index.d.ts` here made + // the compiled CLI inline the declaration files and lose every workspace + // export at runtime (e.g. `local up` → "Fleet local node skipped"). }, "include": ["src/index.ts", "src/cli/index.ts", "src/cli/bootstrap.ts", "src/cli/agent-relay-mcp.ts"], "exclude": ["node_modules", "dist", "src/**/*.test.ts"] diff --git a/packages/fleet/src/index.ts b/packages/fleet/src/index.ts index c1380aa21..91d7ab4cc 100644 --- a/packages/fleet/src/index.ts +++ b/packages/fleet/src/index.ts @@ -1,9 +1,5 @@ import { z } from 'zod'; -import type { PtyHarness } from '@agent-relay/harnesses'; -// Namespace import sidesteps bun --compile's named-import validation against the -// package .d.ts (see packages/cli .../fleet-sidecar.ts). -import * as harnessDefs from '@agent-relay/harnesses'; -const { claude, codex, definePtyHarness, gemini } = harnessDefs; +import { claude, codex, definePtyHarness, gemini, type PtyHarness } from '@agent-relay/harnesses'; import { resolveStaticHarnessConfig, type StaticPtyHarnessDefinition } from '@agent-relay/harness-driver'; import type { AgentSpec, diff --git a/tsconfig.json b/tsconfig.json index 676bd1087..ea54b2f40 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,28 +12,12 @@ "resolveJsonModule": true, "declaration": true, "declarationMap": true, - "sourceMap": true, - "baseUrl": ".", - "paths": { - "@agent-relay/config": ["packages/config/dist/index.d.ts"], - "@agent-relay/config/*": ["packages/config/dist/*"], - "@agent-relay/policy": ["packages/policy/dist/index.d.ts"], - "@agent-relay/policy/*": ["packages/policy/dist/*"], - "@agent-relay/sdk": ["packages/sdk/dist/index.d.ts"], - "@agent-relay/sdk/*": ["packages/sdk/dist/*"], - "@agent-relay/harness-driver": ["packages/harness-driver/dist/index.d.ts"], - "@agent-relay/harness-driver/*": ["packages/harness-driver/dist/*"], - "@agent-relay/harnesses": ["packages/harnesses/dist/index.d.ts"], - "@agent-relay/harnesses/*": ["packages/harnesses/dist/*"], - "@agent-relay/integration-prompts": ["packages/integration-prompts/dist/index.d.ts"], - "@agent-relay/integration-prompts/*": ["packages/integration-prompts/dist/*"], - "@agent-relay/fleet": ["packages/fleet/dist/index.d.ts"], - "@agent-relay/fleet/*": ["packages/fleet/dist/*"], - "@agent-relay/utils": ["packages/utils/dist/index.d.ts"], - "@agent-relay/utils/*": ["packages/utils/dist/*"], - "@agent-relay/cloud": ["packages/cloud/dist/index.d.ts"], - "@agent-relay/cloud/*": ["packages/cloud/dist/*"] - } + "sourceMap": true + // No `paths` for @agent-relay/* on purpose: the npm workspace symlinks them + // into node_modules, so tsc resolves their `.d.ts` and bundlers (bun, + // esbuild) resolve their `.js`. Mapping them to `dist/index.d.ts` here made + // bundlers inline the declaration files (no runtime exports), so the + // compiled CLI lost every workspace export at runtime. }, "files": [], "include": [] From 4ecf58f63b1b9b297f93f23a893835f1649afddc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 22 Jun 2026 08:25:45 +0000 Subject: [PATCH 2/2] style: auto-format with Prettier --- .../completed/2026-06/traj_d88jruejk2zk/summary.md | 8 +++++--- .../completed/2026-06/traj_d88jruejk2zk/trajectory.json | 6 ++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/summary.md b/.agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/summary.md index abf2f28fe..bad39d561 100644 --- a/.agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/summary.md +++ b/.agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/summary.md @@ -9,7 +9,7 @@ ## Summary -Fixed bun-compiled CLI dropping @agent-relay/* workspace exports to undefined (Fleet local node skipped / 'is not a function' on local up). Root cause: bun & esbuild honor tsconfig paths that map workspace packages to their .d.ts (no runtime exports); paths resolve per nearest tsconfig to the importing file, so transitive imports broke too. Final fix (after a fresh-eyes review pivoted away from an earlier build-script workaround): removed the redundant @agent-relay/* paths from the root and packages/cli tsconfig.json — they duplicated the npm workspace node_modules symlinks, so tsc still resolves .d.ts (via package exports.types) and bundlers resolve .js (via exports.import). Also reverted the now-obsolete namespace-import workarounds in fleet-sidecar.ts and fleet/src/index.ts to plain named imports. tsc type-checking untouched. Verified: build:core green (0 type errors), built binary, local up starts implicit fleet node with fleet-node.json connected:true + spawn:claude/codex/gemini. +Fixed bun-compiled CLI dropping @agent-relay/_ workspace exports to undefined (Fleet local node skipped / 'is not a function' on local up). Root cause: bun & esbuild honor tsconfig paths that map workspace packages to their .d.ts (no runtime exports); paths resolve per nearest tsconfig to the importing file, so transitive imports broke too. Final fix (after a fresh-eyes review pivoted away from an earlier build-script workaround): removed the redundant @agent-relay/_ paths from the root and packages/cli tsconfig.json — they duplicated the npm workspace node_modules symlinks, so tsc still resolves .d.ts (via package exports.types) and bundlers resolve .js (via exports.import). Also reverted the now-obsolete namespace-import workarounds in fleet-sidecar.ts and fleet/src/index.ts to plain named imports. tsc type-checking untouched. Verified: build:core green (0 type errors), built binary, local up starts implicit fleet node with fleet-node.json connected:true + spawn:claude/codex/gemini. **Approach:** Standard approach @@ -18,15 +18,17 @@ Fixed bun-compiled CLI dropping @agent-relay/* workspace exports to undefined (F ## Key Decisions ### Fix at the bundler layer via empty-paths tsconfig next to the build entry + - **Chose:** Fix at the bundler layer via empty-paths tsconfig next to the build entry -- **Reasoning:** Root cause: packages/cli/tsconfig.json paths map @agent-relay/* to dist/index.d.ts; bun/esbuild honor tsconfig paths and bundle the declaration files (no runtime exports) -> undefined. fleet breaks because it is only ever namespace-imported. Build-script override is surgical and leaves tsc type-checking untouched, vs changing shared root paths. +- **Reasoning:** Root cause: packages/cli/tsconfig.json paths map @agent-relay/\* to dist/index.d.ts; bun/esbuild honor tsconfig paths and bundle the declaration files (no runtime exports) -> undefined. fleet breaks because it is only ever namespace-imported. Build-script override is surgical and leaves tsc type-checking untouched, vs changing shared root paths. --- ## Chapters ### 1. Work -*Agent: default* + +_Agent: default_ - Fix at the bundler layer via empty-paths tsconfig next to the build entry: Fix at the bundler layer via empty-paths tsconfig next to the build entry - Root cause is bun/esbuild honoring tsconfig paths (->.d.ts, no runtime exports) per-importing-file; fix needs empty-paths tsconfig in EVERY bundled package dist, not just the entry, to cover transitive workspace imports. Verified end-to-end: fleet-node.json connected:true with all spawn handlers. diff --git a/.agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/trajectory.json b/.agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/trajectory.json index 9e6101836..24e1fa148 100644 --- a/.agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/trajectory.json +++ b/.agentworkforce/trajectories/completed/2026-06/traj_d88jruejk2zk/trajectory.json @@ -42,9 +42,7 @@ "confidence": 0.9 }, "significance": "high", - "tags": [ - "confidence:0.9" - ] + "tags": ["confidence:0.9"] } ] } @@ -62,4 +60,4 @@ "startRef": "c7380efd69238db002f4cba087cebef593bf9fcd", "endRef": "c7380efd69238db002f4cba087cebef593bf9fcd" } -} \ No newline at end of file +}