Collect only the env vars that should be written into the profile file.
(env: NodeJS.ProcessEnv)
| 199 | |
| 200 | /** Collect only the env vars that should be written into the profile file. */ |
| 201 | private collectProfileEnv(env: NodeJS.ProcessEnv): Record<string, string> { |
| 202 | const out: Record<string, string> = {}; |
| 203 | |
| 204 | // 1. User-supplied env — always forwarded. |
| 205 | for (const [key, value] of Object.entries(this.userEnv)) { |
| 206 | if (value !== undefined) { |
| 207 | out[key] = value; |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | // 2. CPU workaround — only if auto-applied and not already overridden. |
| 212 | if (this.platformCpuWorkaround && process.platform === "darwin") { |
| 213 | const cpuKeys = [ |
| 214 | "HINDSIGHT_API_EMBEDDINGS_LOCAL_FORCE_CPU", |
| 215 | "HINDSIGHT_API_RERANKER_LOCAL_FORCE_CPU", |
| 216 | ]; |
| 217 | for (const key of cpuKeys) { |
| 218 | if (!(key in out) && env[key] !== undefined) { |
| 219 | out[key] = env[key] as string; |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | return out; |
| 225 | } |
| 226 | |
| 227 | private async startDaemon(env: NodeJS.ProcessEnv): Promise<void> { |
| 228 | const [cmd, ...baseArgs] = getEmbedCommand({ |