Skip to content

Commit 0c935a5

Browse files
author
A.R.
committed
fix(#5.1): strip HEADLESS_ONLY/NO_DAEMON from daemon spawn env
Issue #5 root cause: `PERPLEXITY_HEADLESS_ONLY=1` leaked from the IDE config env block into the daemon process. When the daemon spawned, it inherited `...process.env`, so `PerplexityClient.init()` saw the flag and skipped the headed bootstrap entirely — authenticated Pro features remained unavailable. Changes: - stdio-daemon-proxy.ts: remove `PERPLEXITY_HEADLESS_ONLY` from the auto-generated env block (new configs won't carry it). - launcher.ts spawnDetachedDaemon: delete both `PERPLEXITY_HEADLESS_ONLY` and `PERPLEXITY_NO_DAEMON` from the env before spawning. - runtime.ts spawnBundledDaemon: same stripping. This also fixes pre-existing IDE configs that still have the flag: the spawn-time strip removes it regardless of config age. Refs issue #5
1 parent d53b008 commit 0c935a5

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

packages/extension/src/auto-config/transports/stdio-daemon-proxy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ export const stdioDaemonProxyBuilder: TransportBuilder = {
1717
}
1818

1919
const env: Record<string, string> = {
20-
PERPLEXITY_HEADLESS_ONLY: "1",
2120
// NOTE: no PERPLEXITY_NO_DAEMON — launcher multiplexes onto the shared daemon.
21+
// NOTE: no PERPLEXITY_HEADLESS_ONLY — the daemon decides headless vs headed
22+
// based on its own availability probe, not the IDE's env block.
2223
};
2324

2425
if (typeof input.chromePath === "string" && input.chromePath.length > 0) {

packages/extension/src/daemon/runtime.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,11 +460,17 @@ async function spawnBundledDaemon(options: { configDir: string; host?: string; p
460460
`[daemon] PERPLEXITY_VAULT_PASSPHRASE: ${extraEnv.PERPLEXITY_VAULT_PASSPHRASE ? "set" : "unset"}`,
461461
);
462462

463+
// Strip launcher-scoped flags that must never reach the daemon's own
464+
// PerplexityClient.init() — they would force headless mode or stdio bypass.
465+
const baseEnv = { ...process.env };
466+
delete baseEnv.PERPLEXITY_HEADLESS_ONLY;
467+
delete baseEnv.PERPLEXITY_NO_DAEMON;
468+
463469
const child = spawn(process.execPath, args, {
464470
detached: true,
465471
stdio: ["ignore", logFd, logFd],
466472
env: {
467-
...process.env,
473+
...baseEnv,
468474
...extraEnv,
469475
// Hard-coded overrides — must come AFTER extraEnv so a buggy provider
470476
// cannot clobber them.

packages/mcp-server/src/daemon/launcher.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,11 +931,17 @@ async function spawnDetachedDaemon(options: {
931931
args.push("--tunnel");
932932
}
933933

934+
// Strip launcher-scoped flags that must never reach the daemon's own
935+
// PerplexityClient.init() — they would force headless mode or stdio bypass.
936+
const env = { ...process.env };
937+
delete env.PERPLEXITY_HEADLESS_ONLY;
938+
delete env.PERPLEXITY_NO_DAEMON;
939+
934940
const child = spawn(process.execPath, args, {
935941
detached: true,
936942
stdio: "ignore",
937943
env: {
938-
...process.env,
944+
...env,
939945
PERPLEXITY_CONFIG_DIR: options.configDir,
940946
},
941947
});

0 commit comments

Comments
 (0)