fix(persona-kit): defer @relayfile/local-mount import to call site#121
Conversation
`@relayfile/local-mount` imports `@parcel/watcher` at module top, which
loads a per-platform native binary at evaluation time (e.g.
`@parcel/watcher-linux-x64-glibc` on Lambda). Eagerly importing it from
`mount.ts` meant every `import('@agentworkforce/persona-kit')` evaluated
the binary load — including server-side validation paths that never call
`applyPersonaMount`.
Concrete blast: cloud's deploy POST does
`await import("@agentworkforce/persona-kit")` to call `parsePersonaSpec`
on the uploaded bundle. The Lambda runtime is linux-x64-glibc, but
OpenNext's tracer doesn't bundle @parcel/watcher's optional native
prebuild, so the import resolution throws:
"Persona validation is unavailable:
@agentworkforce/persona-kit could not be loaded
... No prebuild or local build of @parcel/watcher found.
Tried @parcel/watcher-linux-x64-glibc."
Fix: lazy-import `@relayfile/local-mount` inside a small helper that
`applyPersonaMount` awaits at call time. Mount is a CLI/runtime concern,
not a server concern, so deferring is correct semantically and lets the
native binary stay un-loaded on hosts that never apply a mount.
The barrel `index.ts` re-exports stay intact — back-compat for any
direct consumer of `applyPersonaMount`. The change is purely the
import timing inside `mount.ts`.
Verified:
* 170/170 persona-kit tests pass.
* 544 tests across the whole workforce repo pass (`pnpm run test`).
* Probe script: `import('@agentworkforce/persona-kit')` followed by
`parsePersonaSpec(...)` succeeds with NO `@parcel/watcher` load on
the call path.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesDeferred import refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Comment |
Summary
mount.tsimported@relayfile/local-mountat module top, which transitively imports@parcel/watcherand triggers a per-platform native-binary load at module evaluation time. That broke every server-side consumer that just wanted to callparsePersonaSpec— most visibly the cloud deploy POST handler in AWS Lambda.Concrete blast
User ran
agentworkforce deploy --no-prompt --harness-source oauthagainstagentrelay.com/cloud. After all the workspace/integrations/harness checks passed, the bundle upload landed at cloud's deploy POST, which does:…to validate the uploaded persona. The Lambda runtime is
linux-x64-glibc, but OpenNext's dep-tracer didn't bundle@parcel/watcher's optional native prebuild (@parcel/watcher-linux-x64-glibc). Result:The fix
@parcel/watcheris a real dep for the CLI/runtime path (auto-sync, watch mode). It is not a dep for the server-side validation path. The right thing is to load it only when a mount is actually being applied.mount.tsnow defers the@relayfile/local-mountimport via a smallloadCreateMount()helper that's awaited insideapplyPersonaMount. At module-evaluation timemount.tsno longer touches the watcher; at call time, mount consumers see no behavior change. The barrel re-export fromindex.tsstays intact — no API breakage.Verified
pnpm run test— 544 tests across 8 packages, all pass.parsePersonaSpec(...)): succeeds with no @parcel/watcher load.Once this publishes and the user retries their proactive-agents deploy, cloud's
import('@agentworkforce/persona-kit')should succeed andparsePersonaSpecshould run to completion — clearing the last known blocker on the end-to-end customer flow.Test plan
pnpm -F @agentworkforce/persona-kit run test— 170/170 passpnpm run typecheck— all packages cleanpnpm run test— 544/544 pass repo-wideimport('@agentworkforce/persona-kit')+parsePersonaSpecdoes not trigger @parcel/watcher on darwin-arm64🤖 Generated with Claude Code