Commit ccbb365
fix(persona-kit): defer @relayfile/local-mount import to call site (#121)
`@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: Ricky Schema Cascade <ricky@agent-relay.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent 33436ba commit ccbb365
1 file changed
Lines changed: 19 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
3 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
4 | 21 | | |
5 | 22 | | |
6 | 23 | | |
| |||
68 | 85 | | |
69 | 86 | | |
70 | 87 | | |
| 88 | + | |
71 | 89 | | |
72 | 90 | | |
73 | 91 | | |
| |||
0 commit comments