Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion packages/persona-kit/src/mount.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
import { createMount } from '@relayfile/local-mount';
import type { ResolvedMountPolicy } from './plan.js';

// `@relayfile/local-mount` pulls in `@parcel/watcher`, which loads a
// per-platform native binary at module evaluation time
// (`@parcel/watcher-linux-x64-glibc`, `-darwin-arm64`, …). When
// persona-kit is loaded server-side just to call `parsePersonaSpec`
// (e.g. cloud's `import('@agentworkforce/persona-kit')` to validate a
// deploy bundle), eagerly importing local-mount fails any host that
// doesn't ship a matching prebuild — most notably AWS Lambda's
// `@parcel/watcher-linux-x64-glibc`, which OpenNext doesn't bundle.
//
// Deferring the local-mount import to `applyPersonaMount`'s call site
// means the native binary only loads when a mount is actually being
// applied (which is a CLI/runtime concern, never a server-side
// validation concern).
async function loadCreateMount(): Promise<typeof import('@relayfile/local-mount').createMount> {
const mod = await import('@relayfile/local-mount');
return mod.createMount;
}

export interface PersonaMountHandle {
/**
* Working directory the harness should be spawned in. When the mount is
Expand Down Expand Up @@ -68,6 +85,7 @@ export async function applyPersonaMount(
'applyPersonaMount: options.personaId is required when a mount policy is supplied'
);
}
const createMount = await loadCreateMount();
const handle = await createMount(options.cwd, options.mountDir, {
ignoredPatterns: [...mount.ignoredPatterns],
readonlyPatterns: [...mount.readonlyPatterns],
Expand Down
Loading