11#!/usr/bin/env node
22// Emit the set of files the daemon and CLI need at runtime, computed by
3- // static module-graph tracing (@vercel/nft) from the three entry points.
3+ // static module-graph tracing (@vercel/nft) from the daemon entry points.
44// Used by nix/package.nix's installPhase to materialize $out/lib/paseo
55// with only the bytes the daemon actually loads — no Expo, RN, Metro,
66// Electron, ML stacks, or other non-daemon workspace bloat.
1515import { nodeFileTrace } from "@vercel/nft" ;
1616import { glob } from "node:fs/promises" ;
1717import path from "node:path" ;
18+ import { pathToFileURL } from "node:url" ;
1819
1920const REPO_ROOT = path . resolve ( import . meta. dirname , ".." ) ;
2021
21- // Three entry points. The terminal worker is forked into its own Node
22- // process and has its own require tree (node-pty, etc.) — nft does not
23- // follow fork boundaries, so it must be traced separately.
22+ const { sherpaPlatformPackageName } = await import (
23+ pathToFileURL (
24+ path . join (
25+ REPO_ROOT ,
26+ "packages/server/dist/server/server/speech/providers/local/sherpa/sherpa-runtime-env.js" ,
27+ ) ,
28+ ) . href
29+ ) ;
30+
31+ // Daemon entry points. Workers forked into their own Node processes have
32+ // independent require trees; nft does not follow fork boundaries, so trace
33+ // them separately.
2434const entries = [
2535 "packages/cli/dist/index.js" ,
2636 "packages/server/dist/scripts/supervisor-entrypoint.js" ,
2737 "packages/server/dist/server/terminal/terminal-worker-process.js" ,
38+ "packages/server/dist/server/server/speech/providers/local/worker-process.js" ,
2839] ;
2940
3041// Files read at runtime via fs APIs rather than `require`. nft only
@@ -44,19 +55,22 @@ const additionalInputs = [
4455 // the Nix derivation builds for one platform at a time and ships only
4556 // its own binaries.
4657 `node_modules/node-pty/prebuilds/${ process . platform } -${ process . arch } /**` ,
58+ // sherpa-onnx-node dynamically resolves a platform-specific native package.
59+ // Copy the wrapper plus the host platform package explicitly.
60+ "node_modules/sherpa-onnx-node/**" ,
61+ `node_modules/${ sherpaPlatformPackageName ( ) } /**` ,
4762] ;
4863
4964// Trace.
5065const { fileList, warnings } = await nodeFileTrace ( entries , {
5166 base : REPO_ROOT ,
5267 // Tolerate the conditional / dynamic patterns we already audited:
53- // sherpa-onnx-${platform}-${arch} package resolution (sherpa is
54- // intentionally not built in the Nix sandbox; voice features degrade
55- // gracefully when unavailable), and a handful of test-only requires
56- // that get tree-shaken out by tsc.
68+ // sherpa-onnx-${platform}-${arch} package resolution (the host package
69+ // is copied explicitly above), and a handful of test-only requires that
70+ // get tree-shaken out by tsc.
5771 ignore : [
5872 // Cross-platform native packages for the sherpa speech runtime;
59- // unsupported in the Nix build, lazily loaded when present .
73+ // only the host platform package is needed at runtime .
6074 "sherpa-onnx-*/**" ,
6175 // Platform-specific clipboard variants; only the host's variant
6276 // is needed at runtime, and the package's index.js resolver picks
0 commit comments